platform: refactor signals by combining added/changed/removed
Before platform raised 3 signals for each object type. Combine them into one and add a new parameter @change_type to distinguish between the change type. Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
@@ -69,9 +69,6 @@ typedef struct {
|
|||||||
guint carrier_poll_id;
|
guint carrier_poll_id;
|
||||||
int atm_index;
|
int atm_index;
|
||||||
|
|
||||||
/* Watch for 'nas' interfaces going away */
|
|
||||||
guint lost_link_id;
|
|
||||||
|
|
||||||
/* PPP */
|
/* PPP */
|
||||||
NMPPPManager *ppp_manager;
|
NMPPPManager *ppp_manager;
|
||||||
|
|
||||||
@@ -320,20 +317,22 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
lost_link (NMPlatform *platform, int ifindex, NMPlatformLink *info, NMPlatformReason reason, NMDeviceAdsl *device_adsl)
|
link_changed_cb (NMPlatform *platform, int ifindex, NMPlatformLink *info, NMPlatformSignalChangeType change_type, NMPlatformReason reason, NMDeviceAdsl *device_adsl)
|
||||||
{
|
{
|
||||||
NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (device_adsl);
|
if (change_type == NM_PLATFORM_SIGNAL_REMOVED) {
|
||||||
NMDevice *device = NM_DEVICE (device_adsl);
|
NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (device_adsl);
|
||||||
|
NMDevice *device = NM_DEVICE (device_adsl);
|
||||||
|
|
||||||
/* This only gets called for PPPoE connections and "nas" interfaces */
|
/* This only gets called for PPPoE connections and "nas" interfaces */
|
||||||
|
|
||||||
if (priv->nas_ifindex >= 0 && ifindex == priv->nas_ifindex) {
|
if (priv->nas_ifindex >= 0 && ifindex == priv->nas_ifindex) {
|
||||||
/* NAS device went away for some reason; kill the connection */
|
/* NAS device went away for some reason; kill the connection */
|
||||||
nm_log_dbg (LOGD_ADSL, "(%s): NAS interface disappeared",
|
nm_log_dbg (LOGD_ADSL, "(%s): NAS interface disappeared",
|
||||||
nm_device_get_iface (device));
|
nm_device_get_iface (device));
|
||||||
nm_device_state_changed (device,
|
nm_device_state_changed (device,
|
||||||
NM_DEVICE_STATE_FAILED,
|
NM_DEVICE_STATE_FAILED,
|
||||||
NM_DEVICE_STATE_REASON_BR2684_FAILED);
|
NM_DEVICE_STATE_REASON_BR2684_FAILED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,9 +369,9 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_reason)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Watch for the 'nas' interface going away */
|
/* Watch for the 'nas' interface going away */
|
||||||
priv->lost_link_id = g_signal_connect (nm_platform_get (), NM_PLATFORM_LINK_REMOVED,
|
g_signal_connect (nm_platform_get (), NM_PLATFORM_SIGNAL_LINK_CHANGED,
|
||||||
G_CALLBACK (lost_link),
|
G_CALLBACK (link_changed_cb),
|
||||||
self);
|
self);
|
||||||
|
|
||||||
nm_log_dbg (LOGD_ADSL, "(%s): ATM setup successful", nm_device_get_iface (device));
|
nm_log_dbg (LOGD_ADSL, "(%s): ATM setup successful", nm_device_get_iface (device));
|
||||||
|
|
||||||
@@ -493,10 +492,7 @@ deactivate (NMDevice *device)
|
|||||||
priv->ppp_manager = NULL;
|
priv->ppp_manager = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->lost_link_id) {
|
g_signal_handlers_disconnect_by_func (nm_platform_get (), G_CALLBACK (link_changed_cb), device);
|
||||||
g_signal_handler_disconnect (nm_platform_get (), priv->lost_link_id);
|
|
||||||
priv->lost_link_id = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->brfd >= 0) {
|
if (priv->brfd >= 0) {
|
||||||
close (priv->brfd);
|
close (priv->brfd);
|
||||||
@@ -629,10 +625,7 @@ dispose (GObject *object)
|
|||||||
priv->carrier_poll_id = 0;
|
priv->carrier_poll_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->lost_link_id) {
|
g_signal_handlers_disconnect_by_func (nm_platform_get (), G_CALLBACK (link_changed_cb), self);
|
||||||
g_signal_handler_disconnect (nm_platform_get (), priv->lost_link_id);
|
|
||||||
priv->lost_link_id = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (priv->nas_ifname);
|
g_free (priv->nas_ifname);
|
||||||
priv->nas_ifname = NULL;
|
priv->nas_ifname = NULL;
|
||||||
|
@@ -355,34 +355,18 @@ static void cp_connection_updated (NMConnectionProvider *cp, NMConnection *conne
|
|||||||
|
|
||||||
static const char *state_to_string (NMDeviceState state);
|
static const char *state_to_string (NMDeviceState state);
|
||||||
|
|
||||||
static void link_changed_cb (NMPlatform *platform, int ifindex, NMPlatformLink *info, NMPlatformReason reason, NMDevice *device);
|
static void link_changed_cb (NMPlatform *platform, int ifindex, NMPlatformLink *info, NMPlatformSignalChangeType change_type, NMPlatformReason reason, NMDevice *device);
|
||||||
static void check_carrier (NMDevice *device);
|
static void check_carrier (NMDevice *device);
|
||||||
|
|
||||||
static void nm_device_queued_ip_config_change_clear (NMDevice *self);
|
static void nm_device_queued_ip_config_change_clear (NMDevice *self);
|
||||||
static void update_ip_config (NMDevice *self, gboolean initial);
|
static void update_ip_config (NMDevice *self, gboolean initial);
|
||||||
static void device_ip_changed (NMPlatform *platform, int ifindex, gpointer platform_object, NMPlatformReason reason, gpointer user_data);
|
static void device_ip_changed (NMPlatform *platform, int ifindex, gpointer platform_object, NMPlatformSignalChangeType change_type, NMPlatformReason reason, gpointer user_data);
|
||||||
|
|
||||||
static void nm_device_slave_notify_enslave (NMDevice *dev, gboolean success);
|
static void nm_device_slave_notify_enslave (NMDevice *dev, gboolean success);
|
||||||
static void nm_device_slave_notify_release (NMDevice *dev, NMDeviceStateReason reason);
|
static void nm_device_slave_notify_release (NMDevice *dev, NMDeviceStateReason reason);
|
||||||
|
|
||||||
static void addrconf6_start_with_link_ready (NMDevice *self);
|
static void addrconf6_start_with_link_ready (NMDevice *self);
|
||||||
|
|
||||||
static const char const *platform_ip_signals[] = {
|
|
||||||
NM_PLATFORM_IP4_ADDRESS_ADDED,
|
|
||||||
NM_PLATFORM_IP4_ADDRESS_CHANGED,
|
|
||||||
NM_PLATFORM_IP4_ADDRESS_REMOVED,
|
|
||||||
NM_PLATFORM_IP4_ROUTE_ADDED,
|
|
||||||
NM_PLATFORM_IP4_ROUTE_CHANGED,
|
|
||||||
NM_PLATFORM_IP4_ROUTE_REMOVED,
|
|
||||||
NM_PLATFORM_IP6_ADDRESS_ADDED,
|
|
||||||
NM_PLATFORM_IP6_ADDRESS_CHANGED,
|
|
||||||
NM_PLATFORM_IP6_ADDRESS_REMOVED,
|
|
||||||
NM_PLATFORM_IP6_ROUTE_ADDED,
|
|
||||||
NM_PLATFORM_IP6_ROUTE_CHANGED,
|
|
||||||
NM_PLATFORM_IP6_ROUTE_REMOVED,
|
|
||||||
};
|
|
||||||
static const int n_platform_ip_signals = G_N_ELEMENTS (platform_ip_signals);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_device_init (NMDevice *self)
|
nm_device_init (NMDevice *self)
|
||||||
{
|
{
|
||||||
@@ -502,7 +486,6 @@ constructor (GType type,
|
|||||||
NMDevice *dev;
|
NMDevice *dev;
|
||||||
NMDevicePrivate *priv;
|
NMDevicePrivate *priv;
|
||||||
NMPlatform *platform;
|
NMPlatform *platform;
|
||||||
int i;
|
|
||||||
static guint32 id = 0;
|
static guint32 id = 0;
|
||||||
|
|
||||||
object = G_OBJECT_CLASS (nm_device_parent_class)->constructor (type,
|
object = G_OBJECT_CLASS (nm_device_parent_class)->constructor (type,
|
||||||
@@ -535,13 +518,11 @@ constructor (GType type,
|
|||||||
|
|
||||||
/* Watch for external IP config changes */
|
/* Watch for external IP config changes */
|
||||||
platform = nm_platform_get ();
|
platform = nm_platform_get ();
|
||||||
for (i = 0; i < n_platform_ip_signals; i++) {
|
g_signal_connect (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, G_CALLBACK (device_ip_changed), dev);
|
||||||
g_signal_connect (platform, platform_ip_signals[i],
|
g_signal_connect (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, G_CALLBACK (device_ip_changed), dev);
|
||||||
G_CALLBACK (device_ip_changed), dev);
|
g_signal_connect (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, G_CALLBACK (device_ip_changed), dev);
|
||||||
}
|
g_signal_connect (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, G_CALLBACK (device_ip_changed), dev);
|
||||||
|
g_signal_connect (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, G_CALLBACK (link_changed_cb), dev);
|
||||||
g_signal_connect (platform, NM_PLATFORM_LINK_CHANGED,
|
|
||||||
G_CALLBACK (link_changed_cb), dev);
|
|
||||||
|
|
||||||
priv->initialized = TRUE;
|
priv->initialized = TRUE;
|
||||||
return object;
|
return object;
|
||||||
@@ -1142,13 +1123,16 @@ nm_device_set_carrier (NMDevice *device, gboolean carrier)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
link_changed_cb (NMPlatform *platform, int ifindex, NMPlatformLink *info, NMPlatformReason reason, NMDevice *device)
|
link_changed_cb (NMPlatform *platform, int ifindex, NMPlatformLink *info, NMPlatformSignalChangeType change_type, NMPlatformReason reason, NMDevice *device)
|
||||||
{
|
{
|
||||||
NMDeviceClass *klass = NM_DEVICE_GET_CLASS (device);
|
NMDeviceClass *klass = NM_DEVICE_GET_CLASS (device);
|
||||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
||||||
int my_ifindex = nm_device_get_ifindex (device);
|
int my_ifindex = nm_device_get_ifindex (device);
|
||||||
gboolean change_ip_ifname = FALSE;
|
gboolean change_ip_ifname = FALSE;
|
||||||
|
|
||||||
|
if (change_type != NM_PLATFORM_SIGNAL_CHANGED)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Ignore other devices. */
|
/* Ignore other devices. */
|
||||||
if (ifindex == my_ifindex) {
|
if (ifindex == my_ifindex) {
|
||||||
|
|
||||||
@@ -7107,7 +7091,7 @@ queued_ip_config_change (gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
device_ip_changed (NMPlatform *platform, int ifindex, gpointer platform_object, NMPlatformReason reason, gpointer user_data)
|
device_ip_changed (NMPlatform *platform, int ifindex, gpointer platform_object, NMPlatformSignalChangeType change_type, NMPlatformReason reason, gpointer user_data)
|
||||||
{
|
{
|
||||||
NMDevice *self = user_data;
|
NMDevice *self = user_data;
|
||||||
|
|
||||||
|
@@ -148,13 +148,6 @@ static NMDevice *find_device_by_ip_iface (NMManager *self, const gchar *iface);
|
|||||||
|
|
||||||
static void rfkill_change_wifi (const char *desc, gboolean enabled);
|
static void rfkill_change_wifi (const char *desc, gboolean enabled);
|
||||||
|
|
||||||
static void
|
|
||||||
platform_link_added_cb (NMPlatform *platform,
|
|
||||||
int ifindex,
|
|
||||||
NMPlatformLink *plink,
|
|
||||||
NMPlatformReason reason,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
static gboolean find_master (NMManager *self,
|
static gboolean find_master (NMManager *self,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
NMDevice *device,
|
NMDevice *device,
|
||||||
@@ -194,6 +187,8 @@ typedef struct {
|
|||||||
NMState state;
|
NMState state;
|
||||||
NMConnectivity *connectivity;
|
NMConnectivity *connectivity;
|
||||||
|
|
||||||
|
int ignore_link_added_cb;
|
||||||
|
|
||||||
NMPolicy *policy;
|
NMPolicy *policy;
|
||||||
|
|
||||||
NMDBusManager *dbus_mgr;
|
NMDBusManager *dbus_mgr;
|
||||||
@@ -1102,7 +1097,7 @@ system_create_virtual_device (NMManager *self, NMConnection *connection)
|
|||||||
* explicitly here, otherwise adding the platform/kernel device would
|
* explicitly here, otherwise adding the platform/kernel device would
|
||||||
* create it before this function can do the rest of the setup.
|
* create it before this function can do the rest of the setup.
|
||||||
*/
|
*/
|
||||||
g_signal_handlers_block_by_func (nm_platform_get (), G_CALLBACK (platform_link_added_cb), self);
|
priv->ignore_link_added_cb++;
|
||||||
|
|
||||||
if (nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME)) {
|
if (nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME)) {
|
||||||
device = nm_device_bond_new_for_connection (connection);
|
device = nm_device_bond_new_for_connection (connection);
|
||||||
@@ -1122,7 +1117,7 @@ system_create_virtual_device (NMManager *self, NMConnection *connection)
|
|||||||
g_object_unref (device);
|
g_object_unref (device);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (nm_platform_get (), G_CALLBACK (platform_link_added_cb), self);
|
priv->ignore_link_added_cb--;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
g_free (iface);
|
g_free (iface);
|
||||||
@@ -2078,13 +2073,11 @@ load_device_factories (NMManager *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
platform_link_added_cb (NMPlatform *platform,
|
platform_link_added (NMManager *self,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
NMPlatformLink *plink,
|
NMPlatformLink *plink,
|
||||||
NMPlatformReason reason,
|
NMPlatformReason reason)
|
||||||
gpointer user_data)
|
|
||||||
{
|
{
|
||||||
NMManager *self = NM_MANAGER (user_data);
|
|
||||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||||
NMDevice *device = NULL;
|
NMDevice *device = NULL;
|
||||||
GSList *iter;
|
GSList *iter;
|
||||||
@@ -2092,6 +2085,9 @@ platform_link_added_cb (NMPlatform *platform,
|
|||||||
|
|
||||||
g_return_if_fail (ifindex > 0);
|
g_return_if_fail (ifindex > 0);
|
||||||
|
|
||||||
|
if (priv->ignore_link_added_cb > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (find_device_by_ifindex (self, ifindex))
|
if (find_device_by_ifindex (self, ifindex))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -2202,18 +2198,29 @@ platform_link_added_cb (NMPlatform *platform,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
platform_link_removed_cb (NMPlatform *platform,
|
platform_link_cb (NMPlatform *platform,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
NMPlatformLink *plink,
|
NMPlatformLink *plink,
|
||||||
NMPlatformReason reason,
|
NMPlatformSignalChangeType change_type,
|
||||||
gpointer user_data)
|
NMPlatformReason reason,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
NMManager *self = NM_MANAGER (user_data);
|
switch (change_type) {
|
||||||
NMDevice *device;
|
case NM_PLATFORM_SIGNAL_ADDED:
|
||||||
|
platform_link_added (NM_MANAGER (user_data), ifindex, plink, reason);
|
||||||
|
break;
|
||||||
|
case NM_PLATFORM_SIGNAL_REMOVED: {
|
||||||
|
NMManager *self = NM_MANAGER (user_data);
|
||||||
|
NMDevice *device;
|
||||||
|
|
||||||
device = find_device_by_ifindex (self, ifindex);
|
device = find_device_by_ifindex (self, ifindex);
|
||||||
if (device)
|
if (device)
|
||||||
remove_device (self, device, FALSE);
|
remove_device (self, device, FALSE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -4738,12 +4745,8 @@ nm_manager_new (NMSettings *settings,
|
|||||||
nm_dbus_manager_register_object (priv->dbus_mgr, NM_DBUS_PATH, singleton);
|
nm_dbus_manager_register_object (priv->dbus_mgr, NM_DBUS_PATH, singleton);
|
||||||
|
|
||||||
g_signal_connect (nm_platform_get (),
|
g_signal_connect (nm_platform_get (),
|
||||||
NM_PLATFORM_LINK_ADDED,
|
NM_PLATFORM_SIGNAL_LINK_CHANGED,
|
||||||
G_CALLBACK (platform_link_added_cb),
|
G_CALLBACK (platform_link_cb),
|
||||||
singleton);
|
|
||||||
g_signal_connect (nm_platform_get (),
|
|
||||||
NM_PLATFORM_LINK_REMOVED,
|
|
||||||
G_CALLBACK (platform_link_removed_cb),
|
|
||||||
singleton);
|
singleton);
|
||||||
|
|
||||||
priv->rfkill_mgr = nm_rfkill_manager_new ();
|
priv->rfkill_mgr = nm_rfkill_manager_new ();
|
||||||
|
@@ -180,7 +180,7 @@ link_added_emit (gpointer user_data)
|
|||||||
|
|
||||||
device = link_get (info->platform, info->ifindex);
|
device = link_get (info->platform, info->ifindex);
|
||||||
g_assert (device);
|
g_assert (device);
|
||||||
g_signal_emit_by_name (info->platform, NM_PLATFORM_LINK_ADDED, info->ifindex, &device->link, NM_PLATFORM_REASON_INTERNAL);
|
g_signal_emit_by_name (info->platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, info->ifindex, &device->link, NM_PLATFORM_SIGNAL_ADDED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +250,7 @@ link_delete (NMPlatform *platform, int ifindex)
|
|||||||
memset (route, 0, sizeof (*route));
|
memset (route, 0, sizeof (*route));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_emit_by_name (platform, NM_PLATFORM_LINK_REMOVED, ifindex, &deleted_device, NM_PLATFORM_REASON_INTERNAL);
|
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, ifindex, &deleted_device, NM_PLATFORM_SIGNAL_REMOVED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -299,7 +299,7 @@ link_changed (NMPlatform *platform, NMFakePlatformLink *device)
|
|||||||
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
|
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
g_signal_emit_by_name (platform, NM_PLATFORM_LINK_CHANGED, device->link.ifindex, &device->link, NM_PLATFORM_REASON_INTERNAL);
|
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, device->link.ifindex, &device->link, NM_PLATFORM_SIGNAL_CHANGED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
|
|
||||||
if (device->link.master) {
|
if (device->link.master) {
|
||||||
NMFakePlatformLink *master = link_get (platform, device->link.master);
|
NMFakePlatformLink *master = link_get (platform, device->link.master);
|
||||||
@@ -871,12 +871,12 @@ ip4_address_add (NMPlatform *platform, int ifindex,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
memcpy (item, &address, sizeof (address));
|
memcpy (item, &address, sizeof (address));
|
||||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ADDRESS_CHANGED, ifindex, &address, NM_PLATFORM_REASON_INTERNAL);
|
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, ifindex, &address, NM_PLATFORM_SIGNAL_CHANGED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_array_append_val (priv->ip4_addresses, address);
|
g_array_append_val (priv->ip4_addresses, address);
|
||||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ADDRESS_ADDED, ifindex, &address, NM_PLATFORM_REASON_INTERNAL);
|
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, ifindex, &address, NM_PLATFORM_SIGNAL_ADDED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -911,12 +911,12 @@ ip6_address_add (NMPlatform *platform, int ifindex,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
memcpy (item, &address, sizeof (address));
|
memcpy (item, &address, sizeof (address));
|
||||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ADDRESS_CHANGED, ifindex, &address, NM_PLATFORM_REASON_INTERNAL);
|
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, ifindex, &address, NM_PLATFORM_SIGNAL_CHANGED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_array_append_val (priv->ip6_addresses, address);
|
g_array_append_val (priv->ip6_addresses, address);
|
||||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ADDRESS_ADDED, ifindex, &address, NM_PLATFORM_REASON_INTERNAL);
|
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, ifindex, &address, NM_PLATFORM_SIGNAL_ADDED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -935,7 +935,7 @@ ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, int plen)
|
|||||||
|
|
||||||
memcpy (&deleted_address, address, sizeof (deleted_address));
|
memcpy (&deleted_address, address, sizeof (deleted_address));
|
||||||
memset (address, 0, sizeof (*address));
|
memset (address, 0, sizeof (*address));
|
||||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ADDRESS_REMOVED, ifindex, &deleted_address, NM_PLATFORM_REASON_INTERNAL);
|
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, ifindex, &deleted_address, NM_PLATFORM_SIGNAL_REMOVED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -958,7 +958,7 @@ ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, int
|
|||||||
|
|
||||||
memcpy (&deleted_address, address, sizeof (deleted_address));
|
memcpy (&deleted_address, address, sizeof (deleted_address));
|
||||||
memset (address, 0, sizeof (*address));
|
memset (address, 0, sizeof (*address));
|
||||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ADDRESS_REMOVED, ifindex, &deleted_address, NM_PLATFORM_REASON_INTERNAL);
|
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, ifindex, &deleted_address, NM_PLATFORM_SIGNAL_REMOVED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1086,12 +1086,12 @@ ip4_route_add (NMPlatform *platform, int ifindex, in_addr_t network, int plen,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
memcpy (item, &route, sizeof (route));
|
memcpy (item, &route, sizeof (route));
|
||||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ROUTE_CHANGED, ifindex, &route, NM_PLATFORM_REASON_INTERNAL);
|
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, ifindex, &route, NM_PLATFORM_SIGNAL_CHANGED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_array_append_val (priv->ip4_routes, route);
|
g_array_append_val (priv->ip4_routes, route);
|
||||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ROUTE_ADDED, ifindex, &route, NM_PLATFORM_REASON_INTERNAL);
|
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, ifindex, &route, NM_PLATFORM_SIGNAL_ADDED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -1123,12 +1123,12 @@ ip6_route_add (NMPlatform *platform, int ifindex, struct in6_addr network, int p
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
memcpy (item, &route, sizeof (route));
|
memcpy (item, &route, sizeof (route));
|
||||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ROUTE_CHANGED, ifindex, &route, NM_PLATFORM_REASON_INTERNAL);
|
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, ifindex, &route, NM_PLATFORM_SIGNAL_CHANGED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_array_append_val (priv->ip6_routes, route);
|
g_array_append_val (priv->ip6_routes, route);
|
||||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ROUTE_ADDED, ifindex, &route, NM_PLATFORM_REASON_INTERNAL);
|
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, ifindex, &route, NM_PLATFORM_SIGNAL_ADDED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -1180,7 +1180,7 @@ ip4_route_delete (NMPlatform *platform, int ifindex, in_addr_t network, int plen
|
|||||||
if (route) {
|
if (route) {
|
||||||
memcpy (&deleted_route, route, sizeof (deleted_route));
|
memcpy (&deleted_route, route, sizeof (deleted_route));
|
||||||
memset (route, 0, sizeof (*route));
|
memset (route, 0, sizeof (*route));
|
||||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ROUTE_REMOVED, ifindex, &deleted_route, NM_PLATFORM_REASON_INTERNAL);
|
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, ifindex, &deleted_route, NM_PLATFORM_SIGNAL_REMOVED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -1195,7 +1195,7 @@ ip6_route_delete (NMPlatform *platform, int ifindex, struct in6_addr network, in
|
|||||||
if (route) {
|
if (route) {
|
||||||
memcpy (&deleted_route, route, sizeof (deleted_route));
|
memcpy (&deleted_route, route, sizeof (deleted_route));
|
||||||
memset (route, 0, sizeof (*route));
|
memset (route, 0, sizeof (*route));
|
||||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ROUTE_REMOVED, ifindex, &deleted_route, NM_PLATFORM_REASON_INTERNAL);
|
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, ifindex, &deleted_route, NM_PLATFORM_SIGNAL_REMOVED, NM_PLATFORM_REASON_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@@ -155,13 +155,6 @@ typedef enum {
|
|||||||
N_TYPES,
|
N_TYPES,
|
||||||
} ObjectType;
|
} ObjectType;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
ADDED,
|
|
||||||
CHANGED,
|
|
||||||
REMOVED,
|
|
||||||
N_STATUSES
|
|
||||||
} ObjectStatus;
|
|
||||||
|
|
||||||
static ObjectType
|
static ObjectType
|
||||||
object_type_from_nl_object (const struct nl_object *object)
|
object_type_from_nl_object (const struct nl_object *object)
|
||||||
{
|
{
|
||||||
@@ -1104,12 +1097,12 @@ to_string_object (NMPlatform *platform, struct nl_object *obj)
|
|||||||
|
|
||||||
/* Object and cache manipulation */
|
/* Object and cache manipulation */
|
||||||
|
|
||||||
static const char *signal_by_type_and_status[N_TYPES][N_STATUSES] = {
|
static const char *signal_by_type_and_status[N_TYPES] = {
|
||||||
[LINK] = { NM_PLATFORM_LINK_ADDED, NM_PLATFORM_LINK_CHANGED, NM_PLATFORM_LINK_REMOVED },
|
[LINK] = NM_PLATFORM_SIGNAL_LINK_CHANGED,
|
||||||
[IP4_ADDRESS] = { NM_PLATFORM_IP4_ADDRESS_ADDED, NM_PLATFORM_IP4_ADDRESS_CHANGED, NM_PLATFORM_IP4_ADDRESS_REMOVED },
|
[IP4_ADDRESS] = NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED,
|
||||||
[IP6_ADDRESS] = { NM_PLATFORM_IP6_ADDRESS_ADDED, NM_PLATFORM_IP6_ADDRESS_CHANGED, NM_PLATFORM_IP6_ADDRESS_REMOVED },
|
[IP6_ADDRESS] = NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED,
|
||||||
[IP4_ROUTE] = { NM_PLATFORM_IP4_ROUTE_ADDED, NM_PLATFORM_IP4_ROUTE_CHANGED, NM_PLATFORM_IP4_ROUTE_REMOVED },
|
[IP4_ROUTE] = NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED,
|
||||||
[IP6_ROUTE] = { NM_PLATFORM_IP6_ROUTE_ADDED, NM_PLATFORM_IP6_ROUTE_CHANGED, NM_PLATFORM_IP6_ROUTE_REMOVED }
|
[IP6_ROUTE] = NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct nl_cache *
|
static struct nl_cache *
|
||||||
@@ -1178,11 +1171,11 @@ check_cache_items (NMPlatform *platform, struct nl_cache *cache, int ifindex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
announce_object (NMPlatform *platform, const struct nl_object *object, ObjectStatus status, NMPlatformReason reason)
|
announce_object (NMPlatform *platform, const struct nl_object *object, NMPlatformSignalChangeType change_type, NMPlatformReason reason)
|
||||||
{
|
{
|
||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
ObjectType object_type = object_type_from_nl_object (object);
|
ObjectType object_type = object_type_from_nl_object (object);
|
||||||
const char *sig = signal_by_type_and_status[object_type][status];
|
const char *sig = signal_by_type_and_status[object_type];
|
||||||
|
|
||||||
switch (object_type) {
|
switch (object_type) {
|
||||||
case LINK:
|
case LINK:
|
||||||
@@ -1199,9 +1192,9 @@ announce_object (NMPlatform *platform, const struct nl_object *object, ObjectSta
|
|||||||
* event_notification() or link_delete() which block the announcment
|
* event_notification() or link_delete() which block the announcment
|
||||||
* themselves when appropriate.
|
* themselves when appropriate.
|
||||||
*/
|
*/
|
||||||
switch (status) {
|
switch (change_type) {
|
||||||
case ADDED:
|
case NM_PLATFORM_SIGNAL_ADDED:
|
||||||
case CHANGED:
|
case NM_PLATFORM_SIGNAL_CHANGED:
|
||||||
if (!link_is_software (rtnl_link) && !device.driver)
|
if (!link_is_software (rtnl_link) && !device.driver)
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
@@ -1215,12 +1208,12 @@ announce_object (NMPlatform *platform, const struct nl_object *object, ObjectSta
|
|||||||
* More precisely, kernel removes routes when interface goes !IFF_UP and
|
* More precisely, kernel removes routes when interface goes !IFF_UP and
|
||||||
* removes both addresses and routes when interface is removed.
|
* removes both addresses and routes when interface is removed.
|
||||||
*/
|
*/
|
||||||
switch (status) {
|
switch (change_type) {
|
||||||
case CHANGED:
|
case NM_PLATFORM_SIGNAL_CHANGED:
|
||||||
if (!device.connected)
|
if (!device.connected)
|
||||||
check_cache_items (platform, priv->route_cache, device.ifindex);
|
check_cache_items (platform, priv->route_cache, device.ifindex);
|
||||||
break;
|
break;
|
||||||
case REMOVED:
|
case NM_PLATFORM_SIGNAL_REMOVED:
|
||||||
check_cache_items (platform, priv->address_cache, device.ifindex);
|
check_cache_items (platform, priv->address_cache, device.ifindex);
|
||||||
check_cache_items (platform, priv->route_cache, device.ifindex);
|
check_cache_items (platform, priv->route_cache, device.ifindex);
|
||||||
g_hash_table_remove (priv->wifi_data, GINT_TO_POINTER (device.ifindex));
|
g_hash_table_remove (priv->wifi_data, GINT_TO_POINTER (device.ifindex));
|
||||||
@@ -1229,7 +1222,7 @@ announce_object (NMPlatform *platform, const struct nl_object *object, ObjectSta
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_emit_by_name (platform, sig, device.ifindex, &device, reason);
|
g_signal_emit_by_name (platform, sig, device.ifindex, &device, change_type, reason);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case IP4_ADDRESS:
|
case IP4_ADDRESS:
|
||||||
@@ -1242,15 +1235,15 @@ announce_object (NMPlatform *platform, const struct nl_object *object, ObjectSta
|
|||||||
/* Address deletion is sometimes accompanied by route deletion. We need to
|
/* Address deletion is sometimes accompanied by route deletion. We need to
|
||||||
* check all routes belonging to the same interface.
|
* check all routes belonging to the same interface.
|
||||||
*/
|
*/
|
||||||
switch (status) {
|
switch (change_type) {
|
||||||
case REMOVED:
|
case NM_PLATFORM_SIGNAL_REMOVED:
|
||||||
check_cache_items (platform, priv->route_cache, address.ifindex);
|
check_cache_items (platform, priv->route_cache, address.ifindex);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_emit_by_name (platform, sig, address.ifindex, &address, reason);
|
g_signal_emit_by_name (platform, sig, address.ifindex, &address, change_type, reason);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case IP6_ADDRESS:
|
case IP6_ADDRESS:
|
||||||
@@ -1259,7 +1252,7 @@ announce_object (NMPlatform *platform, const struct nl_object *object, ObjectSta
|
|||||||
|
|
||||||
if (!init_ip6_address (&address, (struct rtnl_addr *) object))
|
if (!init_ip6_address (&address, (struct rtnl_addr *) object))
|
||||||
return;
|
return;
|
||||||
g_signal_emit_by_name (platform, sig, address.ifindex, &address, reason);
|
g_signal_emit_by_name (platform, sig, address.ifindex, &address, change_type, reason);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case IP4_ROUTE:
|
case IP4_ROUTE:
|
||||||
@@ -1267,7 +1260,7 @@ announce_object (NMPlatform *platform, const struct nl_object *object, ObjectSta
|
|||||||
NMPlatformIP4Route route;
|
NMPlatformIP4Route route;
|
||||||
|
|
||||||
if (init_ip4_route (&route, (struct rtnl_route *) object))
|
if (init_ip4_route (&route, (struct rtnl_route *) object))
|
||||||
g_signal_emit_by_name (platform, sig, route.ifindex, &route, reason);
|
g_signal_emit_by_name (platform, sig, route.ifindex, &route, change_type, reason);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case IP6_ROUTE:
|
case IP6_ROUTE:
|
||||||
@@ -1275,7 +1268,7 @@ announce_object (NMPlatform *platform, const struct nl_object *object, ObjectSta
|
|||||||
NMPlatformIP6Route route;
|
NMPlatformIP6Route route;
|
||||||
|
|
||||||
if (init_ip6_route (&route, (struct rtnl_route *) object))
|
if (init_ip6_route (&route, (struct rtnl_route *) object))
|
||||||
g_signal_emit_by_name (platform, sig, route.ifindex, &route, reason);
|
g_signal_emit_by_name (platform, sig, route.ifindex, &route, change_type, reason);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
@@ -1306,7 +1299,7 @@ refresh_object (NMPlatform *platform, struct nl_object *object, gboolean removed
|
|||||||
if (cached_object) {
|
if (cached_object) {
|
||||||
nl_cache_remove (cached_object);
|
nl_cache_remove (cached_object);
|
||||||
|
|
||||||
announce_object (platform, cached_object, REMOVED, reason);
|
announce_object (platform, cached_object, NM_PLATFORM_SIGNAL_REMOVED, reason);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!kernel_object)
|
if (!kernel_object)
|
||||||
@@ -1322,7 +1315,7 @@ refresh_object (NMPlatform *platform, struct nl_object *object, gboolean removed
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
announce_object (platform, kernel_object, cached_object ? CHANGED : ADDED, reason);
|
announce_object (platform, kernel_object, cached_object ? NM_PLATFORM_SIGNAL_CHANGED : NM_PLATFORM_SIGNAL_ADDED, reason);
|
||||||
|
|
||||||
/* Refresh the master device (even on enslave/release) */
|
/* Refresh the master device (even on enslave/release) */
|
||||||
if (object_type_from_nl_object (kernel_object) == LINK) {
|
if (object_type_from_nl_object (kernel_object) == LINK) {
|
||||||
@@ -1518,7 +1511,7 @@ event_notification (struct nl_msg *msg, gpointer user_data)
|
|||||||
if (!link_is_announceable (platform, (struct rtnl_link *) cached_object))
|
if (!link_is_announceable (platform, (struct rtnl_link *) cached_object))
|
||||||
return NL_OK;
|
return NL_OK;
|
||||||
}
|
}
|
||||||
announce_object (platform, cached_object, REMOVED, NM_PLATFORM_REASON_EXTERNAL);
|
announce_object (platform, cached_object, NM_PLATFORM_SIGNAL_REMOVED, NM_PLATFORM_REASON_EXTERNAL);
|
||||||
|
|
||||||
return NL_OK;
|
return NL_OK;
|
||||||
case RTM_NEWLINK:
|
case RTM_NEWLINK:
|
||||||
@@ -1539,7 +1532,7 @@ event_notification (struct nl_msg *msg, gpointer user_data)
|
|||||||
error ("netlink cache error: %s", nl_geterror (nle));
|
error ("netlink cache error: %s", nl_geterror (nle));
|
||||||
return NL_OK;
|
return NL_OK;
|
||||||
}
|
}
|
||||||
announce_object (platform, kernel_object, ADDED, NM_PLATFORM_REASON_EXTERNAL);
|
announce_object (platform, kernel_object, NM_PLATFORM_SIGNAL_ADDED, NM_PLATFORM_REASON_EXTERNAL);
|
||||||
return NL_OK;
|
return NL_OK;
|
||||||
}
|
}
|
||||||
/* Ignore non-change
|
/* Ignore non-change
|
||||||
@@ -1556,7 +1549,7 @@ event_notification (struct nl_msg *msg, gpointer user_data)
|
|||||||
error ("netlink cache error: %s", nl_geterror (nle));
|
error ("netlink cache error: %s", nl_geterror (nle));
|
||||||
return NL_OK;
|
return NL_OK;
|
||||||
}
|
}
|
||||||
announce_object (platform, kernel_object, CHANGED, NM_PLATFORM_REASON_EXTERNAL);
|
announce_object (platform, kernel_object, NM_PLATFORM_SIGNAL_CHANGED, NM_PLATFORM_REASON_EXTERNAL);
|
||||||
|
|
||||||
return NL_OK;
|
return NL_OK;
|
||||||
default:
|
default:
|
||||||
@@ -3407,7 +3400,7 @@ udev_device_added (NMPlatform *platform,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
announce_object (platform, (struct nl_object *) rtnllink, is_changed ? CHANGED : ADDED, NM_PLATFORM_REASON_EXTERNAL);
|
announce_object (platform, (struct nl_object *) rtnllink, is_changed ? NM_PLATFORM_SIGNAL_CHANGED : NM_PLATFORM_SIGNAL_ADDED, NM_PLATFORM_REASON_EXTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -3443,7 +3436,7 @@ udev_device_removed (NMPlatform *platform,
|
|||||||
auto_nl_object struct rtnl_link *device = rtnl_link_get (priv->link_cache, ifindex);
|
auto_nl_object struct rtnl_link *device = rtnl_link_get (priv->link_cache, ifindex);
|
||||||
|
|
||||||
if (device)
|
if (device)
|
||||||
announce_object (platform, (struct nl_object *) device, REMOVED, NM_PLATFORM_REASON_EXTERNAL);
|
announce_object (platform, (struct nl_object *) device, NM_PLATFORM_SIGNAL_REMOVED, NM_PLATFORM_REASON_EXTERNAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,21 +41,11 @@ G_DEFINE_TYPE (NMPlatform, nm_platform, G_TYPE_OBJECT)
|
|||||||
|
|
||||||
/* NMPlatform signals */
|
/* NMPlatform signals */
|
||||||
enum {
|
enum {
|
||||||
LINK_ADDED,
|
SIGNAL_LINK_CHANGED,
|
||||||
LINK_CHANGED,
|
SIGNAL_IP4_ADDRESS_CHANGED,
|
||||||
LINK_REMOVED,
|
SIGNAL_IP6_ADDRESS_CHANGED,
|
||||||
IP4_ADDRESS_ADDED,
|
SIGNAL_IP4_ROUTE_CHANGED,
|
||||||
IP4_ADDRESS_CHANGED,
|
SIGNAL_IP6_ROUTE_CHANGED,
|
||||||
IP4_ADDRESS_REMOVED,
|
|
||||||
IP6_ADDRESS_ADDED,
|
|
||||||
IP6_ADDRESS_CHANGED,
|
|
||||||
IP6_ADDRESS_REMOVED,
|
|
||||||
IP4_ROUTE_ADDED,
|
|
||||||
IP4_ROUTE_CHANGED,
|
|
||||||
IP4_ROUTE_REMOVED,
|
|
||||||
IP6_ROUTE_ADDED,
|
|
||||||
IP6_ROUTE_CHANGED,
|
|
||||||
IP6_ROUTE_REMOVED,
|
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -337,8 +327,9 @@ nm_platform_query_devices (void)
|
|||||||
links_array = nm_platform_link_get_all ();
|
links_array = nm_platform_link_get_all ();
|
||||||
links = (NMPlatformLink *) links_array->data;
|
links = (NMPlatformLink *) links_array->data;
|
||||||
for (i = 0; i < links_array->len; i++) {
|
for (i = 0; i < links_array->len; i++) {
|
||||||
g_signal_emit (platform, signals[LINK_ADDED], 0,
|
g_signal_emit (platform, signals[SIGNAL_LINK_CHANGED], 0,
|
||||||
links[i].ifindex, &links[i], NM_PLATFORM_REASON_INTERNAL);
|
links[i].ifindex, &links[i], NM_PLATFORM_SIGNAL_ADDED,
|
||||||
|
NM_PLATFORM_REASON_INTERNAL);
|
||||||
}
|
}
|
||||||
g_array_unref (links_array);
|
g_array_unref (links_array);
|
||||||
}
|
}
|
||||||
@@ -2353,128 +2344,51 @@ nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6Route
|
|||||||
#undef _CMP_FIELD_MEMCMP
|
#undef _CMP_FIELD_MEMCMP
|
||||||
|
|
||||||
|
|
||||||
static void
|
static const char *
|
||||||
log_link (NMPlatformLink *device, const char *change_type)
|
_change_type_to_string (NMPlatformSignalChangeType change_type)
|
||||||
{
|
{
|
||||||
debug ("signal: link %s: %s", change_type, nm_platform_link_to_string (device));
|
switch (change_type) {
|
||||||
|
case NM_PLATFORM_SIGNAL_ADDED:
|
||||||
|
return "added";
|
||||||
|
case NM_PLATFORM_SIGNAL_CHANGED:
|
||||||
|
return "changed";
|
||||||
|
case NM_PLATFORM_SIGNAL_REMOVED:
|
||||||
|
return "removed";
|
||||||
|
default:
|
||||||
|
g_return_val_if_reached ("UNKNOWN");
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
log_link_added (NMPlatform *p, int ifindex, NMPlatformLink *device, gpointer user_data)
|
log_link (NMPlatform *p, int ifindex, NMPlatformLink *device, NMPlatformSignalChangeType change_type, gpointer user_data)
|
||||||
{
|
{
|
||||||
log_link (device, "added ");
|
|
||||||
|
debug ("signal: link %7s: %s", _change_type_to_string (change_type), nm_platform_link_to_string (device));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
log_link_changed (NMPlatform *p, int ifindex, NMPlatformLink *device, gpointer user_data)
|
log_ip4_address (NMPlatform *p, int ifindex, NMPlatformIP4Address *address, NMPlatformSignalChangeType change_type, gpointer user_data)
|
||||||
{
|
{
|
||||||
log_link (device, "changed");
|
debug ("signal: address 4 %7s: %s", _change_type_to_string (change_type), nm_platform_ip4_address_to_string (address));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
log_link_removed (NMPlatform *p, int ifindex, NMPlatformLink *device, gpointer user_data)
|
log_ip6_address (NMPlatform *p, int ifindex, NMPlatformIP6Address *address, NMPlatformSignalChangeType change_type, gpointer user_data)
|
||||||
{
|
{
|
||||||
log_link (device, "removed");
|
debug ("signal: address 6 %7s: %s", _change_type_to_string (change_type), nm_platform_ip6_address_to_string (address));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
log_ip4_address (NMPlatformIP4Address *address, const char *change_type)
|
log_ip4_route (NMPlatform *p, int ifindex, NMPlatformIP4Route *route, NMPlatformSignalChangeType change_type, gpointer user_data)
|
||||||
{
|
{
|
||||||
const char *name = nm_platform_link_get_name (address->ifindex);
|
debug ("signal: route 4 %7s: %s", _change_type_to_string (change_type), nm_platform_ip4_route_to_string (route));
|
||||||
|
|
||||||
debug ("(%s) signal: address 4 %s: %s", name, change_type, nm_platform_ip4_address_to_string (address));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
log_ip4_address_added (NMPlatform *p, int ifindex, NMPlatformIP4Address *address, gpointer user_data)
|
log_ip6_route (NMPlatform *p, int ifindex, NMPlatformIP6Route *route, NMPlatformSignalChangeType change_type, gpointer user_data)
|
||||||
{
|
{
|
||||||
log_ip4_address (address, "added ");
|
debug ("signal: route 6 %7s: %s", _change_type_to_string (change_type), nm_platform_ip6_route_to_string (route));
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
log_ip4_address_changed (NMPlatform *p, int ifindex, NMPlatformIP4Address *address, gpointer user_data)
|
|
||||||
{
|
|
||||||
log_ip4_address (address, "changed");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
log_ip4_address_removed (NMPlatform *p, int ifindex, NMPlatformIP4Address *address, gpointer user_data)
|
|
||||||
{
|
|
||||||
log_ip4_address (address, "removed");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
log_ip6_address (NMPlatformIP6Address *address, const char *change_type)
|
|
||||||
{
|
|
||||||
const char *name = nm_platform_link_get_name (address->ifindex);
|
|
||||||
|
|
||||||
debug ("(%s) signal: address 6 %s: %s", name, change_type, nm_platform_ip6_address_to_string (address));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
log_ip6_address_added (NMPlatform *p, int ifindex, NMPlatformIP6Address *address, gpointer user_data)
|
|
||||||
{
|
|
||||||
log_ip6_address (address, "added ");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
log_ip6_address_changed (NMPlatform *p, int ifindex, NMPlatformIP6Address *address, gpointer user_data)
|
|
||||||
{
|
|
||||||
log_ip6_address (address, "changed");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
log_ip6_address_removed (NMPlatform *p, int ifindex, NMPlatformIP6Address *address, gpointer user_data)
|
|
||||||
{
|
|
||||||
log_ip6_address (address, "removed");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
log_ip4_route (NMPlatformIP4Route *route, const char *change_type)
|
|
||||||
{
|
|
||||||
debug ("signal: route 4 %s: %s", change_type, nm_platform_ip4_route_to_string (route));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
log_ip4_route_added (NMPlatform *p, int ifindex, NMPlatformIP4Route *route, gpointer user_data)
|
|
||||||
{
|
|
||||||
log_ip4_route (route, "added ");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
log_ip4_route_changed (NMPlatform *p, int ifindex, NMPlatformIP4Route *route, gpointer user_data)
|
|
||||||
{
|
|
||||||
log_ip4_route (route, "changed");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
log_ip4_route_removed (NMPlatform *p, int ifindex, NMPlatformIP4Route *route, gpointer user_data)
|
|
||||||
{
|
|
||||||
log_ip4_route (route, "removed");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
log_ip6_route (NMPlatformIP6Route *route, const char *change_type)
|
|
||||||
{
|
|
||||||
debug ("signal: route 6 %s: %s", change_type, nm_platform_ip6_route_to_string (route));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
log_ip6_route_added (NMPlatform *p, int ifindex, NMPlatformIP6Route *route, gpointer user_data)
|
|
||||||
{
|
|
||||||
log_ip6_route (route, "added ");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
log_ip6_route_changed (NMPlatform *p, int ifindex, NMPlatformIP6Route *route, gpointer user_data)
|
|
||||||
{
|
|
||||||
log_ip6_route (route, "changed");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
log_ip6_route_removed (NMPlatform *p, int ifindex, NMPlatformIP6Route *route, gpointer user_data)
|
|
||||||
{
|
|
||||||
log_ip6_route (route, "removed");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
@@ -2490,7 +2404,7 @@ nm_platform_init (NMPlatform *object)
|
|||||||
G_SIGNAL_RUN_FIRST, \
|
G_SIGNAL_RUN_FIRST, \
|
||||||
G_CALLBACK (method), \
|
G_CALLBACK (method), \
|
||||||
NULL, NULL, NULL, \
|
NULL, NULL, NULL, \
|
||||||
G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_POINTER, NM_TYPE_PLATFORM_REASON);
|
G_TYPE_NONE, 4, G_TYPE_INT, G_TYPE_POINTER, NM_TYPE_PLATFORM_SIGNAL_CHANGE_TYPE, NM_TYPE_PLATFORM_REASON);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_platform_class_init (NMPlatformClass *platform_class)
|
nm_platform_class_init (NMPlatformClass *platform_class)
|
||||||
@@ -2498,19 +2412,9 @@ nm_platform_class_init (NMPlatformClass *platform_class)
|
|||||||
GObjectClass *object_class = G_OBJECT_CLASS (platform_class);
|
GObjectClass *object_class = G_OBJECT_CLASS (platform_class);
|
||||||
|
|
||||||
/* Signals */
|
/* Signals */
|
||||||
SIGNAL (LINK_ADDED, log_link_added)
|
SIGNAL (SIGNAL_LINK_CHANGED, log_link)
|
||||||
SIGNAL (LINK_CHANGED, log_link_changed)
|
SIGNAL (SIGNAL_IP4_ADDRESS_CHANGED, log_ip4_address)
|
||||||
SIGNAL (LINK_REMOVED, log_link_removed)
|
SIGNAL (SIGNAL_IP6_ADDRESS_CHANGED, log_ip6_address)
|
||||||
SIGNAL (IP4_ADDRESS_ADDED, log_ip4_address_added)
|
SIGNAL (SIGNAL_IP4_ROUTE_CHANGED, log_ip4_route)
|
||||||
SIGNAL (IP4_ADDRESS_CHANGED, log_ip4_address_changed)
|
SIGNAL (SIGNAL_IP6_ROUTE_CHANGED, log_ip6_route)
|
||||||
SIGNAL (IP4_ADDRESS_REMOVED, log_ip4_address_removed)
|
|
||||||
SIGNAL (IP6_ADDRESS_ADDED, log_ip6_address_added)
|
|
||||||
SIGNAL (IP6_ADDRESS_CHANGED, log_ip6_address_changed)
|
|
||||||
SIGNAL (IP6_ADDRESS_REMOVED, log_ip6_address_removed)
|
|
||||||
SIGNAL (IP4_ROUTE_ADDED, log_ip4_route_added)
|
|
||||||
SIGNAL (IP4_ROUTE_CHANGED, log_ip4_route_changed)
|
|
||||||
SIGNAL (IP4_ROUTE_REMOVED, log_ip4_route_removed)
|
|
||||||
SIGNAL (IP6_ROUTE_ADDED, log_ip6_route_added)
|
|
||||||
SIGNAL (IP6_ROUTE_CHANGED, log_ip6_route_changed)
|
|
||||||
SIGNAL (IP6_ROUTE_REMOVED, log_ip6_route_removed)
|
|
||||||
}
|
}
|
||||||
|
@@ -130,6 +130,12 @@ typedef struct {
|
|||||||
guint mtu;
|
guint mtu;
|
||||||
} NMPlatformLink;
|
} NMPlatformLink;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NM_PLATFORM_SIGNAL_ADDED,
|
||||||
|
NM_PLATFORM_SIGNAL_CHANGED,
|
||||||
|
NM_PLATFORM_SIGNAL_REMOVED,
|
||||||
|
} NMPlatformSignalChangeType;
|
||||||
|
|
||||||
#define NM_PLATFORM_LIFETIME_PERMANENT G_MAXUINT32
|
#define NM_PLATFORM_LIFETIME_PERMANENT G_MAXUINT32
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -401,21 +407,11 @@ typedef struct {
|
|||||||
* but you are free to copy the provided information and use it for later
|
* but you are free to copy the provided information and use it for later
|
||||||
* reference.
|
* reference.
|
||||||
*/
|
*/
|
||||||
#define NM_PLATFORM_LINK_ADDED "link-added"
|
#define NM_PLATFORM_SIGNAL_LINK_CHANGED "link-changed"
|
||||||
#define NM_PLATFORM_LINK_CHANGED "link-changed"
|
#define NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED "ip4-address-changed"
|
||||||
#define NM_PLATFORM_LINK_REMOVED "link-removed"
|
#define NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED "ip6-address-changed"
|
||||||
#define NM_PLATFORM_IP4_ADDRESS_ADDED "ip4-address-added"
|
#define NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED "ip4-route-changed"
|
||||||
#define NM_PLATFORM_IP4_ADDRESS_CHANGED "ip4-address-changed"
|
#define NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED "ip6-route-changed"
|
||||||
#define NM_PLATFORM_IP4_ADDRESS_REMOVED "ip4-address-removed"
|
|
||||||
#define NM_PLATFORM_IP6_ADDRESS_ADDED "ip6-address-added"
|
|
||||||
#define NM_PLATFORM_IP6_ADDRESS_CHANGED "ip6-address-changed"
|
|
||||||
#define NM_PLATFORM_IP6_ADDRESS_REMOVED "ip6-address-removed"
|
|
||||||
#define NM_PLATFORM_IP4_ROUTE_ADDED "ip4-route-added"
|
|
||||||
#define NM_PLATFORM_IP4_ROUTE_CHANGED "ip4-route-changed"
|
|
||||||
#define NM_PLATFORM_IP4_ROUTE_REMOVED "ip4-route-removed"
|
|
||||||
#define NM_PLATFORM_IP6_ROUTE_ADDED "ip6-route-added"
|
|
||||||
#define NM_PLATFORM_IP6_ROUTE_CHANGED "ip6-route-changed"
|
|
||||||
#define NM_PLATFORM_IP6_ROUTE_REMOVED "ip6-route-removed"
|
|
||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
|
@@ -7,13 +7,17 @@
|
|||||||
#define IP6_PLEN 64
|
#define IP6_PLEN 64
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ip4_address_callback (NMPlatform *platform, int ifindex, NMPlatformIP4Address *received, NMPlatformReason reason, SignalData *data)
|
ip4_address_callback (NMPlatform *platform, int ifindex, NMPlatformIP4Address *received, NMPlatformSignalChangeType change_type, NMPlatformReason reason, SignalData *data)
|
||||||
{
|
{
|
||||||
g_assert (received);
|
g_assert (received);
|
||||||
g_assert_cmpint (received->ifindex, ==, ifindex);
|
g_assert_cmpint (received->ifindex, ==, ifindex);
|
||||||
|
g_assert (data && data->name);
|
||||||
|
g_assert_cmpstr (data->name, ==, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED);
|
||||||
|
|
||||||
if (data->ifindex && data->ifindex != received->ifindex)
|
if (data->ifindex && data->ifindex != received->ifindex)
|
||||||
return;
|
return;
|
||||||
|
if (data->change_type != change_type)
|
||||||
|
return;
|
||||||
|
|
||||||
if (data->loop)
|
if (data->loop)
|
||||||
g_main_loop_quit (data->loop);
|
g_main_loop_quit (data->loop);
|
||||||
@@ -25,13 +29,17 @@ ip4_address_callback (NMPlatform *platform, int ifindex, NMPlatformIP4Address *r
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ip6_address_callback (NMPlatform *platform, int ifindex, NMPlatformIP6Address *received, NMPlatformReason reason, SignalData *data)
|
ip6_address_callback (NMPlatform *platform, int ifindex, NMPlatformIP6Address *received, NMPlatformSignalChangeType change_type, NMPlatformReason reason, SignalData *data)
|
||||||
{
|
{
|
||||||
g_assert (received);
|
g_assert (received);
|
||||||
g_assert_cmpint (received->ifindex, ==, ifindex);
|
g_assert_cmpint (received->ifindex, ==, ifindex);
|
||||||
|
g_assert (data && data->name);
|
||||||
|
g_assert_cmpstr (data->name, ==, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED);
|
||||||
|
|
||||||
if (data->ifindex && data->ifindex != received->ifindex)
|
if (data->ifindex && data->ifindex != received->ifindex)
|
||||||
return;
|
return;
|
||||||
|
if (data->change_type != change_type)
|
||||||
|
return;
|
||||||
|
|
||||||
if (data->loop)
|
if (data->loop)
|
||||||
g_main_loop_quit (data->loop);
|
g_main_loop_quit (data->loop);
|
||||||
@@ -46,9 +54,9 @@ static void
|
|||||||
test_ip4_address (void)
|
test_ip4_address (void)
|
||||||
{
|
{
|
||||||
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||||
SignalData *address_added = add_signal_ifindex (NM_PLATFORM_IP4_ADDRESS_ADDED, ip4_address_callback, ifindex);
|
SignalData *address_added = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_address_callback, ifindex);
|
||||||
SignalData *address_changed = add_signal_ifindex (NM_PLATFORM_IP4_ADDRESS_CHANGED, ip4_address_callback, ifindex);
|
SignalData *address_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip4_address_callback, ifindex);
|
||||||
SignalData *address_removed = add_signal_ifindex (NM_PLATFORM_IP4_ADDRESS_REMOVED, ip4_address_callback, ifindex);
|
SignalData *address_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_address_callback, ifindex);
|
||||||
GArray *addresses;
|
GArray *addresses;
|
||||||
NMPlatformIP4Address *address;
|
NMPlatformIP4Address *address;
|
||||||
in_addr_t addr;
|
in_addr_t addr;
|
||||||
@@ -101,9 +109,9 @@ static void
|
|||||||
test_ip6_address (void)
|
test_ip6_address (void)
|
||||||
{
|
{
|
||||||
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||||
SignalData *address_added = add_signal_ifindex (NM_PLATFORM_IP6_ADDRESS_ADDED, ip6_address_callback, ifindex);
|
SignalData *address_added = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip6_address_callback, ifindex);
|
||||||
SignalData *address_changed = add_signal_ifindex (NM_PLATFORM_IP6_ADDRESS_CHANGED, ip6_address_callback, ifindex);
|
SignalData *address_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip6_address_callback, ifindex);
|
||||||
SignalData *address_removed = add_signal_ifindex (NM_PLATFORM_IP6_ADDRESS_REMOVED, ip6_address_callback, ifindex);
|
SignalData *address_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip6_address_callback, ifindex);
|
||||||
GArray *addresses;
|
GArray *addresses;
|
||||||
NMPlatformIP6Address *address;
|
NMPlatformIP6Address *address;
|
||||||
struct in6_addr addr;
|
struct in6_addr addr;
|
||||||
@@ -156,8 +164,8 @@ test_ip6_address (void)
|
|||||||
static void
|
static void
|
||||||
test_ip4_address_external (void)
|
test_ip4_address_external (void)
|
||||||
{
|
{
|
||||||
SignalData *address_added = add_signal (NM_PLATFORM_IP4_ADDRESS_ADDED, ip4_address_callback);
|
SignalData *address_added = add_signal (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_address_callback);
|
||||||
SignalData *address_removed = add_signal (NM_PLATFORM_IP4_ADDRESS_REMOVED, ip4_address_callback);
|
SignalData *address_removed = add_signal (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_address_callback);
|
||||||
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||||
in_addr_t addr;
|
in_addr_t addr;
|
||||||
guint32 lifetime = 2000;
|
guint32 lifetime = 2000;
|
||||||
@@ -200,8 +208,8 @@ test_ip4_address_external (void)
|
|||||||
static void
|
static void
|
||||||
test_ip6_address_external (void)
|
test_ip6_address_external (void)
|
||||||
{
|
{
|
||||||
SignalData *address_added = add_signal (NM_PLATFORM_IP6_ADDRESS_ADDED, ip6_address_callback);
|
SignalData *address_added = add_signal (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip6_address_callback);
|
||||||
SignalData *address_removed = add_signal (NM_PLATFORM_IP6_ADDRESS_REMOVED, ip6_address_callback);
|
SignalData *address_removed = add_signal (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip6_address_callback);
|
||||||
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||||
struct in6_addr addr;
|
struct in6_addr addr;
|
||||||
guint32 lifetime = 2000;
|
guint32 lifetime = 2000;
|
||||||
@@ -239,7 +247,7 @@ test_ip6_address_external (void)
|
|||||||
void
|
void
|
||||||
setup_tests (void)
|
setup_tests (void)
|
||||||
{
|
{
|
||||||
SignalData *link_added = add_signal_ifname (NM_PLATFORM_LINK_ADDED, link_callback, DEVICE_NAME);
|
SignalData *link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, DEVICE_NAME);
|
||||||
|
|
||||||
nm_platform_link_delete (nm_platform_link_get_ifindex (DEVICE_NAME));
|
nm_platform_link_delete (nm_platform_link_get_ifindex (DEVICE_NAME));
|
||||||
g_assert (!nm_platform_link_exists (DEVICE_NAME));
|
g_assert (!nm_platform_link_exists (DEVICE_NAME));
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
static void
|
static void
|
||||||
test_cleanup_internal ()
|
test_cleanup_internal ()
|
||||||
{
|
{
|
||||||
SignalData *link_added = add_signal_ifname (NM_PLATFORM_LINK_ADDED, link_callback, DEVICE_NAME);
|
SignalData *link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, DEVICE_NAME);
|
||||||
int ifindex;
|
int ifindex;
|
||||||
GArray *addresses4;
|
GArray *addresses4;
|
||||||
GArray *addresses6;
|
GArray *addresses6;
|
||||||
|
@@ -2,11 +2,12 @@
|
|||||||
#include "nm-glib-compat.h"
|
#include "nm-glib-compat.h"
|
||||||
|
|
||||||
SignalData *
|
SignalData *
|
||||||
add_signal_full (const char *name, GCallback callback, int ifindex, const char *ifname)
|
add_signal_full (const char *name, NMPlatformSignalChangeType change_type, GCallback callback, int ifindex, const char *ifname)
|
||||||
{
|
{
|
||||||
SignalData *data = g_new0 (SignalData, 1);
|
SignalData *data = g_new0 (SignalData, 1);
|
||||||
|
|
||||||
data->name = name;
|
data->name = name;
|
||||||
|
data->change_type = change_type;
|
||||||
data->received = FALSE;
|
data->received = FALSE;
|
||||||
data->handler_id = g_signal_connect (nm_platform_get (), name, callback, data);
|
data->handler_id = g_signal_connect (nm_platform_get (), name, callback, data);
|
||||||
data->ifindex = ifindex;
|
data->ifindex = ifindex;
|
||||||
@@ -17,12 +18,28 @@ add_signal_full (const char *name, GCallback callback, int ifindex, const char *
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
_change_type_to_string (NMPlatformSignalChangeType change_type)
|
||||||
|
{
|
||||||
|
switch (change_type) {
|
||||||
|
case NM_PLATFORM_SIGNAL_ADDED:
|
||||||
|
return "added";
|
||||||
|
case NM_PLATFORM_SIGNAL_CHANGED:
|
||||||
|
return "changed";
|
||||||
|
case NM_PLATFORM_SIGNAL_REMOVED:
|
||||||
|
return "removed";
|
||||||
|
default:
|
||||||
|
g_return_val_if_reached ("UNKNOWN");
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
accept_signal (SignalData *data)
|
accept_signal (SignalData *data)
|
||||||
{
|
{
|
||||||
debug ("Accepting signal '%s' ifindex %d ifname %s.", data->name, data->ifindex, data->ifname);
|
debug ("Accepting signal '%s-%s' ifindex %d ifname %s.", data->name, _change_type_to_string (data->change_type), data->ifindex, data->ifname);
|
||||||
if (!data->received)
|
if (!data->received)
|
||||||
g_error ("Attemted to accept a non-received signal '%s'.", data->name);
|
g_error ("Attemted to accept a non-received signal '%s-%s'.", data->name, _change_type_to_string (data->change_type));
|
||||||
|
|
||||||
data->received = FALSE;
|
data->received = FALSE;
|
||||||
}
|
}
|
||||||
@@ -41,14 +58,14 @@ void
|
|||||||
free_signal (SignalData *data)
|
free_signal (SignalData *data)
|
||||||
{
|
{
|
||||||
if (data->received)
|
if (data->received)
|
||||||
g_error ("Attempted to free received but not accepted signal '%s'.", data->name);
|
g_error ("Attempted to free received but not accepted signal '%s-%s'.", data->name, _change_type_to_string (data->change_type));
|
||||||
|
|
||||||
g_signal_handler_disconnect (nm_platform_get (), data->handler_id);
|
g_signal_handler_disconnect (nm_platform_get (), data->handler_id);
|
||||||
g_free (data);
|
g_free (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
link_callback (NMPlatform *platform, int ifindex, NMPlatformLink *received, NMPlatformReason reason, SignalData *data)
|
link_callback (NMPlatform *platform, int ifindex, NMPlatformLink *received, NMPlatformSignalChangeType change_type, NMPlatformReason reason, SignalData *data)
|
||||||
{
|
{
|
||||||
|
|
||||||
GArray *links;
|
GArray *links;
|
||||||
@@ -57,11 +74,15 @@ link_callback (NMPlatform *platform, int ifindex, NMPlatformLink *received, NMPl
|
|||||||
|
|
||||||
g_assert (received);
|
g_assert (received);
|
||||||
g_assert_cmpint (received->ifindex, ==, ifindex);
|
g_assert_cmpint (received->ifindex, ==, ifindex);
|
||||||
|
g_assert (data && data->name);
|
||||||
|
g_assert_cmpstr (data->name, ==, NM_PLATFORM_SIGNAL_LINK_CHANGED);
|
||||||
|
|
||||||
if (data->ifindex && data->ifindex != received->ifindex)
|
if (data->ifindex && data->ifindex != received->ifindex)
|
||||||
return;
|
return;
|
||||||
if (data->ifname && g_strcmp0 (data->ifname, nm_platform_link_get_name (ifindex)) != 0)
|
if (data->ifname && g_strcmp0 (data->ifname, nm_platform_link_get_name (ifindex)) != 0)
|
||||||
return;
|
return;
|
||||||
|
if (change_type != data->change_type)
|
||||||
|
return;
|
||||||
|
|
||||||
if (data->loop) {
|
if (data->loop) {
|
||||||
debug ("Quitting main loop.");
|
debug ("Quitting main loop.");
|
||||||
@@ -69,9 +90,9 @@ link_callback (NMPlatform *platform, int ifindex, NMPlatformLink *received, NMPl
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data->received)
|
if (data->received)
|
||||||
g_error ("Received signal '%s' a second time.", data->name);
|
g_error ("Received signal '%s-%s' a second time.", data->name, _change_type_to_string (data->change_type));
|
||||||
|
|
||||||
debug ("Received signal '%s' ifindex %d ifname '%s'.", data->name, ifindex, received->name);
|
debug ("Received signal '%s-%s' ifindex %d ifname '%s'.", data->name, _change_type_to_string (data->change_type), ifindex, received->name);
|
||||||
data->received = TRUE;
|
data->received = TRUE;
|
||||||
|
|
||||||
/* Check the data */
|
/* Check the data */
|
||||||
@@ -81,16 +102,15 @@ link_callback (NMPlatform *platform, int ifindex, NMPlatformLink *received, NMPl
|
|||||||
cached = &g_array_index (links, NMPlatformLink, i);
|
cached = &g_array_index (links, NMPlatformLink, i);
|
||||||
if (cached->ifindex == received->ifindex) {
|
if (cached->ifindex == received->ifindex) {
|
||||||
g_assert (!memcmp (cached, received, sizeof (*cached)));
|
g_assert (!memcmp (cached, received, sizeof (*cached)));
|
||||||
if (!g_strcmp0 (data->name, NM_PLATFORM_LINK_REMOVED)) {
|
if (data->change_type == NM_PLATFORM_SIGNAL_REMOVED)
|
||||||
g_error ("Deleted link still found in the local cache.");
|
g_error ("Deleted link still found in the local cache.");
|
||||||
}
|
|
||||||
g_array_unref (links);
|
g_array_unref (links);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_array_unref (links);
|
g_array_unref (links);
|
||||||
|
|
||||||
if (g_strcmp0 (data->name, NM_PLATFORM_LINK_REMOVED))
|
if (data->change_type != NM_PLATFORM_SIGNAL_REMOVED)
|
||||||
g_error ("Added/changed link not found in the local cache.");
|
g_error ("Added/changed link not found in the local cache.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,21 +19,22 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
int handler_id;
|
int handler_id;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
NMPlatformSignalChangeType change_type;
|
||||||
gboolean received;
|
gboolean received;
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
int ifindex;
|
int ifindex;
|
||||||
const char *ifname;
|
const char *ifname;
|
||||||
} SignalData;
|
} SignalData;
|
||||||
|
|
||||||
SignalData *add_signal_full (const char *name, GCallback callback, int ifindex, const char *ifname);
|
SignalData *add_signal_full (const char *name, NMPlatformSignalChangeType change_type, GCallback callback, int ifindex, const char *ifname);
|
||||||
#define add_signal(name, callback) add_signal_full (name, (GCallback) callback, 0, NULL)
|
#define add_signal(name, change_type, callback) add_signal_full (name, change_type, (GCallback) callback, 0, NULL)
|
||||||
#define add_signal_ifindex(name, callback, ifindex) add_signal_full (name, (GCallback) callback, ifindex, NULL)
|
#define add_signal_ifindex(name, change_type, callback, ifindex) add_signal_full (name, change_type, (GCallback) callback, ifindex, NULL)
|
||||||
#define add_signal_ifname(name, callback, ifname) add_signal_full (name, (GCallback) callback, 0, ifname)
|
#define add_signal_ifname(name, change_type, callback, ifname) add_signal_full (name, change_type, (GCallback) callback, 0, ifname)
|
||||||
void accept_signal (SignalData *data);
|
void accept_signal (SignalData *data);
|
||||||
void wait_signal (SignalData *data);
|
void wait_signal (SignalData *data);
|
||||||
void free_signal (SignalData *data);
|
void free_signal (SignalData *data);
|
||||||
|
|
||||||
void link_callback (NMPlatform *platform, int ifindex, NMPlatformLink *received, NMPlatformReason reason, SignalData *data);
|
void link_callback (NMPlatform *platform, int ifindex, NMPlatformLink *received, NMPlatformSignalChangeType change_type, NMPlatformReason reason, SignalData *data);
|
||||||
|
|
||||||
void run_command (const char *format, ...);
|
void run_command (const char *format, ...);
|
||||||
|
|
||||||
|
@@ -110,7 +110,7 @@ software_add (NMLinkType link_type, const char *name)
|
|||||||
SignalData *parent_changed;
|
SignalData *parent_changed;
|
||||||
|
|
||||||
/* Don't call link_callback for the bridge interface */
|
/* Don't call link_callback for the bridge interface */
|
||||||
parent_added = add_signal_ifname (NM_PLATFORM_LINK_ADDED, link_callback, PARENT_NAME);
|
parent_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, PARENT_NAME);
|
||||||
if (nm_platform_bridge_add (PARENT_NAME))
|
if (nm_platform_bridge_add (PARENT_NAME))
|
||||||
wait_signal (parent_added);
|
wait_signal (parent_added);
|
||||||
free_signal (parent_added);
|
free_signal (parent_added);
|
||||||
@@ -118,7 +118,7 @@ software_add (NMLinkType link_type, const char *name)
|
|||||||
{
|
{
|
||||||
int parent_ifindex = nm_platform_link_get_ifindex (PARENT_NAME);
|
int parent_ifindex = nm_platform_link_get_ifindex (PARENT_NAME);
|
||||||
|
|
||||||
parent_changed = add_signal_ifindex (NM_PLATFORM_LINK_CHANGED, link_callback, parent_ifindex);
|
parent_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, parent_ifindex);
|
||||||
g_assert (nm_platform_link_set_up (parent_ifindex));
|
g_assert (nm_platform_link_set_up (parent_ifindex));
|
||||||
accept_signal (parent_changed);
|
accept_signal (parent_changed);
|
||||||
free_signal (parent_changed);
|
free_signal (parent_changed);
|
||||||
@@ -135,15 +135,15 @@ static void
|
|||||||
test_slave (int master, int type, SignalData *master_changed)
|
test_slave (int master, int type, SignalData *master_changed)
|
||||||
{
|
{
|
||||||
int ifindex;
|
int ifindex;
|
||||||
SignalData *link_added = add_signal_ifname (NM_PLATFORM_LINK_ADDED, link_callback, SLAVE_NAME);
|
SignalData *link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, SLAVE_NAME);
|
||||||
SignalData *link_changed, *link_removed;
|
SignalData *link_changed, *link_removed;
|
||||||
char *value;
|
char *value;
|
||||||
|
|
||||||
g_assert (software_add (type, SLAVE_NAME));
|
g_assert (software_add (type, SLAVE_NAME));
|
||||||
ifindex = nm_platform_link_get_ifindex (SLAVE_NAME);
|
ifindex = nm_platform_link_get_ifindex (SLAVE_NAME);
|
||||||
g_assert (ifindex > 0);
|
g_assert (ifindex > 0);
|
||||||
link_changed = add_signal_ifindex (NM_PLATFORM_LINK_CHANGED, link_callback, ifindex);
|
link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex);
|
||||||
link_removed = add_signal_ifindex (NM_PLATFORM_LINK_REMOVED, link_callback, ifindex);
|
link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex);
|
||||||
wait_signal (link_added);
|
wait_signal (link_added);
|
||||||
|
|
||||||
/* Set the slave up to see whether master's IFF_LOWER_UP is set correctly.
|
/* Set the slave up to see whether master's IFF_LOWER_UP is set correctly.
|
||||||
@@ -243,7 +243,7 @@ test_software (NMLinkType link_type, const char *link_typename)
|
|||||||
SignalData *link_added, *link_changed, *link_removed;
|
SignalData *link_added, *link_changed, *link_removed;
|
||||||
|
|
||||||
/* Add */
|
/* Add */
|
||||||
link_added = add_signal_ifname (NM_PLATFORM_LINK_ADDED, link_callback, DEVICE_NAME);
|
link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, DEVICE_NAME);
|
||||||
g_assert (software_add (link_type, DEVICE_NAME));
|
g_assert (software_add (link_type, DEVICE_NAME));
|
||||||
no_error ();
|
no_error ();
|
||||||
wait_signal (link_added);
|
wait_signal (link_added);
|
||||||
@@ -252,8 +252,8 @@ test_software (NMLinkType link_type, const char *link_typename)
|
|||||||
g_assert (ifindex >= 0);
|
g_assert (ifindex >= 0);
|
||||||
g_assert_cmpint (nm_platform_link_get_type (ifindex), ==, link_type);
|
g_assert_cmpint (nm_platform_link_get_type (ifindex), ==, link_type);
|
||||||
g_assert_cmpstr (nm_platform_link_get_type_name (ifindex), ==, link_typename);
|
g_assert_cmpstr (nm_platform_link_get_type_name (ifindex), ==, link_typename);
|
||||||
link_changed = add_signal_ifindex (NM_PLATFORM_LINK_CHANGED, link_callback, ifindex);
|
link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex);
|
||||||
link_removed = add_signal_ifindex (NM_PLATFORM_LINK_REMOVED, link_callback, ifindex);
|
link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex);
|
||||||
if (link_type == NM_LINK_TYPE_VLAN) {
|
if (link_type == NM_LINK_TYPE_VLAN) {
|
||||||
g_assert (nm_platform_vlan_get_info (ifindex, &vlan_parent, &vlan_id));
|
g_assert (nm_platform_vlan_get_info (ifindex, &vlan_parent, &vlan_id));
|
||||||
g_assert_cmpint (vlan_parent, ==, nm_platform_link_get_ifindex (PARENT_NAME));
|
g_assert_cmpint (vlan_parent, ==, nm_platform_link_get_ifindex (PARENT_NAME));
|
||||||
@@ -326,7 +326,7 @@ test_software (NMLinkType link_type, const char *link_typename)
|
|||||||
|
|
||||||
/* VLAN: Delete parent */
|
/* VLAN: Delete parent */
|
||||||
if (link_type == NM_LINK_TYPE_VLAN) {
|
if (link_type == NM_LINK_TYPE_VLAN) {
|
||||||
SignalData *link_removed_parent = add_signal_ifindex (NM_PLATFORM_LINK_REMOVED, link_callback, vlan_parent);
|
SignalData *link_removed_parent = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, vlan_parent);
|
||||||
|
|
||||||
g_assert (nm_platform_link_delete (vlan_parent));
|
g_assert (nm_platform_link_delete (vlan_parent));
|
||||||
accept_signal (link_removed_parent);
|
accept_signal (link_removed_parent);
|
||||||
@@ -366,7 +366,7 @@ test_vlan ()
|
|||||||
static void
|
static void
|
||||||
test_internal (void)
|
test_internal (void)
|
||||||
{
|
{
|
||||||
SignalData *link_added = add_signal_ifname (NM_PLATFORM_LINK_ADDED, link_callback, DEVICE_NAME);
|
SignalData *link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, DEVICE_NAME);
|
||||||
SignalData *link_changed, *link_removed;
|
SignalData *link_changed, *link_removed;
|
||||||
const char mac[6] = { 0x00, 0xff, 0x11, 0xee, 0x22, 0xdd };
|
const char mac[6] = { 0x00, 0xff, 0x11, 0xee, 0x22, 0xdd };
|
||||||
const char *address;
|
const char *address;
|
||||||
@@ -393,8 +393,8 @@ test_internal (void)
|
|||||||
g_assert_cmpstr (nm_platform_link_get_name (ifindex), ==, DEVICE_NAME);
|
g_assert_cmpstr (nm_platform_link_get_name (ifindex), ==, DEVICE_NAME);
|
||||||
g_assert_cmpint (nm_platform_link_get_type (ifindex), ==, NM_LINK_TYPE_DUMMY);
|
g_assert_cmpint (nm_platform_link_get_type (ifindex), ==, NM_LINK_TYPE_DUMMY);
|
||||||
g_assert_cmpstr (nm_platform_link_get_type_name (ifindex), ==, DUMMY_TYPEDESC);
|
g_assert_cmpstr (nm_platform_link_get_type_name (ifindex), ==, DUMMY_TYPEDESC);
|
||||||
link_changed = add_signal_ifindex (NM_PLATFORM_LINK_CHANGED, link_callback, ifindex);
|
link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex);
|
||||||
link_removed = add_signal_ifindex (NM_PLATFORM_LINK_REMOVED, link_callback, ifindex);
|
link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex);
|
||||||
|
|
||||||
/* Up/connected */
|
/* Up/connected */
|
||||||
g_assert (!nm_platform_link_is_up (ifindex)); no_error ();
|
g_assert (!nm_platform_link_is_up (ifindex)); no_error ();
|
||||||
@@ -453,7 +453,7 @@ test_internal (void)
|
|||||||
static void
|
static void
|
||||||
test_external (void)
|
test_external (void)
|
||||||
{
|
{
|
||||||
SignalData *link_added = add_signal_ifname (NM_PLATFORM_LINK_ADDED, link_callback, DEVICE_NAME);
|
SignalData *link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, DEVICE_NAME);
|
||||||
SignalData *link_changed, *link_removed;
|
SignalData *link_changed, *link_removed;
|
||||||
int ifindex;
|
int ifindex;
|
||||||
|
|
||||||
@@ -465,8 +465,8 @@ test_external (void)
|
|||||||
g_assert_cmpstr (nm_platform_link_get_name (ifindex), ==, DEVICE_NAME);
|
g_assert_cmpstr (nm_platform_link_get_name (ifindex), ==, DEVICE_NAME);
|
||||||
g_assert_cmpint (nm_platform_link_get_type (ifindex), ==, NM_LINK_TYPE_DUMMY);
|
g_assert_cmpint (nm_platform_link_get_type (ifindex), ==, NM_LINK_TYPE_DUMMY);
|
||||||
g_assert_cmpstr (nm_platform_link_get_type_name (ifindex), ==, DUMMY_TYPEDESC);
|
g_assert_cmpstr (nm_platform_link_get_type_name (ifindex), ==, DUMMY_TYPEDESC);
|
||||||
link_changed = add_signal_ifindex (NM_PLATFORM_LINK_CHANGED, link_callback, ifindex);
|
link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex);
|
||||||
link_removed = add_signal_ifindex (NM_PLATFORM_LINK_REMOVED, link_callback, ifindex);
|
link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex);
|
||||||
|
|
||||||
/* Up/connected/arp */
|
/* Up/connected/arp */
|
||||||
g_assert (!nm_platform_link_is_up (ifindex));
|
g_assert (!nm_platform_link_is_up (ifindex));
|
||||||
|
@@ -3,13 +3,17 @@
|
|||||||
#define DEVICE_NAME "nm-test-device"
|
#define DEVICE_NAME "nm-test-device"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ip4_route_callback (NMPlatform *platform, int ifindex, NMPlatformIP4Route *received, NMPlatformReason reason, SignalData *data)
|
ip4_route_callback (NMPlatform *platform, int ifindex, NMPlatformIP4Route *received, NMPlatformSignalChangeType change_type, NMPlatformReason reason, SignalData *data)
|
||||||
{
|
{
|
||||||
g_assert (received);
|
g_assert (received);
|
||||||
g_assert_cmpint (received->ifindex, ==, ifindex);
|
g_assert_cmpint (received->ifindex, ==, ifindex);
|
||||||
|
g_assert (data && data->name);
|
||||||
|
g_assert_cmpstr (data->name, ==, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED);
|
||||||
|
|
||||||
if (data->ifindex && data->ifindex != received->ifindex)
|
if (data->ifindex && data->ifindex != received->ifindex)
|
||||||
return;
|
return;
|
||||||
|
if (data->change_type != change_type)
|
||||||
|
return;
|
||||||
|
|
||||||
if (data->loop)
|
if (data->loop)
|
||||||
g_main_loop_quit (data->loop);
|
g_main_loop_quit (data->loop);
|
||||||
@@ -21,13 +25,17 @@ ip4_route_callback (NMPlatform *platform, int ifindex, NMPlatformIP4Route *recei
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ip6_route_callback (NMPlatform *platform, int ifindex, NMPlatformIP6Route *received, NMPlatformReason reason, SignalData *data)
|
ip6_route_callback (NMPlatform *platform, int ifindex, NMPlatformIP6Route *received, NMPlatformSignalChangeType change_type, NMPlatformReason reason, SignalData *data)
|
||||||
{
|
{
|
||||||
g_assert (received);
|
g_assert (received);
|
||||||
g_assert_cmpint (received->ifindex, ==, ifindex);
|
g_assert_cmpint (received->ifindex, ==, ifindex);
|
||||||
|
g_assert (data && data->name);
|
||||||
|
g_assert_cmpstr (data->name, ==, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED);
|
||||||
|
|
||||||
if (data->ifindex && data->ifindex != received->ifindex)
|
if (data->ifindex && data->ifindex != received->ifindex)
|
||||||
return;
|
return;
|
||||||
|
if (data->change_type != change_type)
|
||||||
|
return;
|
||||||
|
|
||||||
if (data->loop)
|
if (data->loop)
|
||||||
g_main_loop_quit (data->loop);
|
g_main_loop_quit (data->loop);
|
||||||
@@ -42,9 +50,9 @@ static void
|
|||||||
test_ip4_route ()
|
test_ip4_route ()
|
||||||
{
|
{
|
||||||
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||||
SignalData *route_added = add_signal (NM_PLATFORM_IP4_ROUTE_ADDED, ip4_route_callback);
|
SignalData *route_added = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_route_callback);
|
||||||
SignalData *route_changed = add_signal (NM_PLATFORM_IP4_ROUTE_CHANGED, ip4_route_callback);
|
SignalData *route_changed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip4_route_callback);
|
||||||
SignalData *route_removed = add_signal (NM_PLATFORM_IP4_ROUTE_REMOVED, ip4_route_callback);
|
SignalData *route_removed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_route_callback);
|
||||||
GArray *routes;
|
GArray *routes;
|
||||||
NMPlatformIP4Route rts[3];
|
NMPlatformIP4Route rts[3];
|
||||||
in_addr_t network;
|
in_addr_t network;
|
||||||
@@ -125,9 +133,9 @@ static void
|
|||||||
test_ip6_route ()
|
test_ip6_route ()
|
||||||
{
|
{
|
||||||
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
|
||||||
SignalData *route_added = add_signal (NM_PLATFORM_IP6_ROUTE_ADDED, ip6_route_callback);
|
SignalData *route_added = add_signal (NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip6_route_callback);
|
||||||
SignalData *route_changed = add_signal (NM_PLATFORM_IP6_ROUTE_CHANGED, ip6_route_callback);
|
SignalData *route_changed = add_signal (NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip6_route_callback);
|
||||||
SignalData *route_removed = add_signal (NM_PLATFORM_IP6_ROUTE_REMOVED, ip6_route_callback);
|
SignalData *route_removed = add_signal (NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip6_route_callback);
|
||||||
GArray *routes;
|
GArray *routes;
|
||||||
NMPlatformIP6Route rts[3];
|
NMPlatformIP6Route rts[3];
|
||||||
struct in6_addr network;
|
struct in6_addr network;
|
||||||
@@ -207,7 +215,7 @@ test_ip6_route ()
|
|||||||
void
|
void
|
||||||
setup_tests (void)
|
setup_tests (void)
|
||||||
{
|
{
|
||||||
SignalData *link_added = add_signal_ifname (NM_PLATFORM_LINK_ADDED, link_callback, DEVICE_NAME);
|
SignalData *link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, DEVICE_NAME);
|
||||||
|
|
||||||
nm_platform_link_delete (nm_platform_link_get_ifindex (DEVICE_NAME));
|
nm_platform_link_delete (nm_platform_link_get_ifindex (DEVICE_NAME));
|
||||||
g_assert (!nm_platform_link_exists (DEVICE_NAME));
|
g_assert (!nm_platform_link_exists (DEVICE_NAME));
|
||||||
|
Reference in New Issue
Block a user