2008-10-26 Dan Williams <dcbw@redhat.com>

* 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



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4213 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2008-10-26 16:32:29 +00:00
parent 6d86495f71
commit 1cb9bacaad
7 changed files with 103 additions and 19 deletions

View File

@ -1,3 +1,15 @@
2008-10-26 Dan Williams <dcbw@redhat.com>
* 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 <dcbw@redhat.com>
* src/NetworkManagerPolicy.c

View File

@ -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,

View File

@ -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) {

View File

@ -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";
}

View File

@ -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 */

View File

@ -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";
}

View File

@ -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 */