diff --git a/ChangeLog b/ChangeLog index 0bd9920cfd..88ae26d1a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-10-26 Dan Williams + + * src/supplicant-manager/nm-supplicant-interface.c + src/supplicant-manager/nm-supplicant-interface.h + src/supplicant-manager/nm-supplicant-manager.c + src/supplicant-manager/nm-supplicant-manager.h + - Add state-to-string conversion functions + + * src/nm-device-wifi.c + src/nm-device-ethernet.c + - Normalize state info logging and use strings instead of numbers + 2008-10-26 Dan Williams * src/NetworkManagerPolicy.c diff --git a/src/nm-device-ethernet.c b/src/nm-device-ethernet.c index db25dc1a22..a3350e23bd 100644 --- a/src/nm-device-ethernet.c +++ b/src/nm-device-ethernet.c @@ -858,10 +858,10 @@ supplicant_mgr_state_cb (NMSupplicantInterface * iface, guint32 old_state, gpointer user_data) { - nm_info ("(%s) supplicant manager is now in state %d (from %d).", - nm_device_get_iface (NM_DEVICE (user_data)), - new_state, - old_state); + nm_info ("(%s): supplicant manager state: %s -> %s", + nm_device_get_iface (NM_DEVICE (user_data)), + nm_supplicant_manager_state_to_string (old_state), + nm_supplicant_manager_state_to_string (new_state)); schedule_state_handler (NM_DEVICE_ETHERNET (user_data), supplicant_mgr_state_cb_handler, @@ -943,10 +943,10 @@ supplicant_iface_state_cb (NMSupplicantInterface * iface, gpointer user_data) { - nm_info ("(%s) supplicant interface is now in state %d (from %d).", - nm_device_get_iface (NM_DEVICE (user_data)), - new_state, - old_state); + nm_info ("(%s): supplicant interface state: %s -> %s", + nm_device_get_iface (NM_DEVICE (user_data)), + nm_supplicant_interface_state_to_string (old_state), + nm_supplicant_interface_state_to_string (new_state)); schedule_state_handler (NM_DEVICE_ETHERNET (user_data), supplicant_iface_state_cb_handler, @@ -993,8 +993,10 @@ supplicant_iface_connection_state_cb (NMSupplicantInterface * iface, guint32 old_state, gpointer user_data) { - nm_info ("(%s) Supplicant interface state change: %d -> %d", - nm_device_get_iface (NM_DEVICE (user_data)), old_state, new_state); + nm_info ("(%s) supplicant connection state: %s -> %s", + nm_device_get_iface (NM_DEVICE (user_data)), + nm_supplicant_interface_connection_state_to_string (old_state), + nm_supplicant_interface_connection_state_to_string (new_state)); schedule_state_handler (NM_DEVICE_ETHERNET (user_data), supplicant_iface_connection_state_cb_handler, diff --git a/src/nm-device-wifi.c b/src/nm-device-wifi.c index b66dcd1b39..7cabe0fe73 100644 --- a/src/nm-device-wifi.c +++ b/src/nm-device-wifi.c @@ -2191,10 +2191,10 @@ supplicant_iface_state_cb_handler (gpointer user_data) self = task->self; priv = NM_DEVICE_WIFI_GET_PRIVATE (self); - nm_info ("(%s): supplicant interface state change: %d -> %d.", - nm_device_get_iface (NM_DEVICE (self)), - task->old_state, - task->new_state); + nm_info ("(%s): supplicant interface state: %s -> %s", + nm_device_get_iface (NM_DEVICE (self)), + nm_supplicant_interface_state_to_string (task->old_state), + nm_supplicant_interface_state_to_string (task->new_state)); if (task->new_state == NM_SUPPLICANT_INTERFACE_STATE_READY) { priv->scan_interval = SCAN_INTERVAL_MIN; @@ -2243,8 +2243,10 @@ supplicant_iface_connection_state_cb_handler (gpointer user_data) goto out; } - nm_info ("(%s): supplicant connection state change: %d -> %d", - nm_device_get_iface (dev), task->old_state, task->new_state); + nm_info ("(%s): supplicant connection state: %s -> %s", + nm_device_get_iface (dev), + nm_supplicant_interface_connection_state_to_string (task->old_state), + nm_supplicant_interface_connection_state_to_string (task->new_state)); priv->scanning = (task->new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_SCANNING); @@ -2315,9 +2317,10 @@ supplicant_mgr_state_cb_handler (gpointer user_data) priv = NM_DEVICE_WIFI_GET_PRIVATE (self); dev = NM_DEVICE (self); - nm_info ("(%s): supplicant manager is now in state %d (from %d).", - nm_device_get_iface (NM_DEVICE (self)), - task->new_state, task->old_state); + nm_info ("(%s): supplicant manager state: %s -> %s", + nm_device_get_iface (NM_DEVICE (self)), + nm_supplicant_manager_state_to_string (task->old_state), + nm_supplicant_manager_state_to_string (task->new_state)); /* If the supplicant went away, release the supplicant interface */ if (task->new_state == NM_SUPPLICANT_MANAGER_STATE_DOWN) { diff --git a/src/supplicant-manager/nm-supplicant-interface.c b/src/supplicant-manager/nm-supplicant-interface.c index 4a621200d6..37bfe60593 100644 --- a/src/supplicant-manager/nm-supplicant-interface.c +++ b/src/supplicant-manager/nm-supplicant-interface.c @@ -1250,3 +1250,48 @@ nm_supplicant_interface_get_connection_state (NMSupplicantInterface * self) return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->con_state; } + +const char * +nm_supplicant_interface_state_to_string (guint32 state) +{ + switch (state) { + case NM_SUPPLICANT_INTERFACE_STATE_INIT: + return "init"; + case NM_SUPPLICANT_INTERFACE_STATE_STARTING: + return "starting"; + case NM_SUPPLICANT_INTERFACE_STATE_READY: + return "ready"; + case NM_SUPPLICANT_INTERFACE_STATE_DOWN: + return "down"; + default: + break; + } + return "unknown"; +} + +const char * +nm_supplicant_interface_connection_state_to_string (guint32 state) +{ + switch (state) { + case NM_SUPPLICANT_INTERFACE_CON_STATE_DISCONNECTED: + return "disconnected"; + case NM_SUPPLICANT_INTERFACE_CON_STATE_INACTIVE: + return "inactive"; + case NM_SUPPLICANT_INTERFACE_CON_STATE_SCANNING: + return "scanning"; + case NM_SUPPLICANT_INTERFACE_CON_STATE_ASSOCIATING: + return "associating"; + case NM_SUPPLICANT_INTERFACE_CON_STATE_ASSOCIATED: + return "associated"; + case NM_SUPPLICANT_INTERFACE_CON_STATE_4WAY_HANDSHAKE: + return "4-way handshake"; + case NM_SUPPLICANT_INTERFACE_CON_STATE_GROUP_HANDSHAKE: + return "group handshake"; + case NM_SUPPLICANT_INTERFACE_CON_STATE_COMPLETED: + return "completed"; + default: + break; + } + return "unknown"; +} + diff --git a/src/supplicant-manager/nm-supplicant-interface.h b/src/supplicant-manager/nm-supplicant-interface.h index f68c2388aa..7a8a5f2e06 100644 --- a/src/supplicant-manager/nm-supplicant-interface.h +++ b/src/supplicant-manager/nm-supplicant-interface.h @@ -124,6 +124,10 @@ guint32 nm_supplicant_interface_get_state (NMSupplicantInterface * self); guint32 nm_supplicant_interface_get_connection_state (NMSupplicantInterface * self); +const char *nm_supplicant_interface_state_to_string (guint32 state); + +const char *nm_supplicant_interface_connection_state_to_string (guint32 state); + G_END_DECLS #endif /* NM_SUPPLICANT_INTERFACE_H */ diff --git a/src/supplicant-manager/nm-supplicant-manager.c b/src/supplicant-manager/nm-supplicant-manager.c index da4e108898..8687be49a8 100644 --- a/src/supplicant-manager/nm-supplicant-manager.c +++ b/src/supplicant-manager/nm-supplicant-manager.c @@ -321,3 +321,19 @@ nm_supplicant_manager_release_iface (NMSupplicantManager * self, } } } + +const char * +nm_supplicant_manager_state_to_string (guint32 state) +{ + switch (state) { + case NM_SUPPLICANT_MANAGER_STATE_DOWN: + return "down"; + case NM_SUPPLICANT_MANAGER_STATE_IDLE: + return "idle"; + default: + break; + } + return "unknown"; +} + + diff --git a/src/supplicant-manager/nm-supplicant-manager.h b/src/supplicant-manager/nm-supplicant-manager.h index fdff740aac..3ed7c6e92f 100644 --- a/src/supplicant-manager/nm-supplicant-manager.h +++ b/src/supplicant-manager/nm-supplicant-manager.h @@ -83,4 +83,6 @@ NMSupplicantInterface * nm_supplicant_manager_get_iface (NMSupplicantManager * m void nm_supplicant_manager_release_iface (NMSupplicantManager * mgr, NMSupplicantInterface * iface); +const char *nm_supplicant_manager_state_to_string (guint32 state); + #endif /* NM_SUPPLICANT_MANAGER_H */