diff options
Diffstat (limited to 'src/wimax/iwmxsdk.c')
| -rw-r--r-- | src/wimax/iwmxsdk.c | 77 |
1 files changed, 58 insertions, 19 deletions
diff --git a/src/wimax/iwmxsdk.c b/src/wimax/iwmxsdk.c index dd78d5a4..9c3a78bb 100644 --- a/src/wimax/iwmxsdk.c +++ b/src/wimax/iwmxsdk.c @@ -27,7 +27,8 @@ #include <stdlib.h> #include <errno.h> #include <string.h> -#include <net/if.h> +#include <sys/socket.h> +#include <linux/if.h> #include <glib.h> @@ -190,6 +191,7 @@ typedef struct { WIMAX_API_DEVICE_STATUS new_status; WIMAX_API_DEVICE_STATUS old_status; WIMAX_API_STATUS_REASON reason; + WIMAX_API_CONNECTION_PROGRESS_INFO progress; } StateChangeInfo; static gboolean @@ -202,6 +204,7 @@ state_change_handler(gpointer user_data) info->new_status, info->old_status, info->reason, + info->progress, info->wmxsdk->callback_data); } wmxsdk_unref(info->wmxsdk); @@ -214,7 +217,8 @@ static void _schedule_state_change(struct wmxsdk *wmxsdk, WIMAX_API_DEVICE_STATUS new_status, WIMAX_API_DEVICE_STATUS old_status, - WIMAX_API_STATUS_REASON reason) + WIMAX_API_STATUS_REASON reason, + WIMAX_API_CONNECTION_PROGRESS_INFO progress) { StateChangeInfo *info; @@ -227,6 +231,7 @@ _schedule_state_change(struct wmxsdk *wmxsdk, info->new_status = new_status; info->old_status = old_status; info->reason = reason; + info->progress = progress; wmxsdk_ref(wmxsdk); g_idle_add(state_change_handler, info); @@ -476,6 +481,48 @@ const char *iwmx_sdk_media_status_to_str(WIMAX_API_MEDIA_STATUS status) } } +const char * +iwmx_sdk_con_progress_to_str(WIMAX_API_CONNECTION_PROGRESS_INFO progress) +{ + switch (progress) { + + /**< Device is in Ranging */ + case WIMAX_API_DEVICE_CONNECTION_PROGRESS_Ranging: + return "ranging"; + + /**< Device is in SBC */ + case WIMAX_API_DEVICE_CONNECTION_PROGRESS_SBC: + return "sbc"; + + /**< Device is in EAP authentication Device */ + case WIMAX_API_DEVICE_CONNECTION_PROGRESS_EAP_authentication_Device: + return "eap-auth-device"; + + /**< Device is in EAP authentication User */ + case WIMAX_API_DEVICE_CONNECTION_PROGRESS_EAP_authentication_User: + return "eap-auth-user"; + + /**< Device is in 3-way-handshake */ + case WIMAX_API_DEVICE_CONNECTION_PROGRESS_3_way_handshake: + return "3way-handshake"; + + /**< Device is in Registration */ + case WIMAX_API_DEVICE_CONNECTION_PROGRESS_Registration: + return "registration"; + + /**< Device is in De-registration */ + case WIMAX_API_DEVICE_CONNECTION_PROGRESS_De_registration: + return "deregistration"; + + /**< Device is registered (operational) */ + case WIMAX_API_DEVICE_CONNECTION_PROGRESS_Registered: + return "registered"; + + default: + return "unknown"; + } +} + /* * Get the device's status from the device * @@ -982,7 +1029,7 @@ static void __iwmx_sdk_state_change_cb(WIMAX_API_DEVICE_ID *device_id, wmxsdk->status = status; g_mutex_unlock(wmxsdk->status_mutex); - _schedule_state_change(wmxsdk, status, old_status, reason); + _schedule_state_change(wmxsdk, status, old_status, reason, pi); } /* @@ -1170,7 +1217,8 @@ static int iwmx_sdk_setup(struct wmxsdk *wmxsdk) _schedule_state_change(wmxsdk, status, WIMAX_API_DEVICE_STATUS_UnInitialized, - WIMAX_API_STATUS_REASON_Normal); + WIMAX_API_STATUS_REASON_Normal, + WIMAX_API_DEVICE_CONNECTION_PROGRESS_Ranging); return 0; @@ -1268,23 +1316,22 @@ void wmxsdk_unref(struct wmxsdk *wmxsdk) static void iwmx_sdk_dev_add(unsigned idx, unsigned api_idx, const char *name) { - int ifindex; struct wmxsdk *wmxsdk; const char *s; if (idx >= IWMX_SDK_DEV_MAX) { nm_log_err(LOGD_WIMAX, "BUG! idx (%u) >= IWMX_SDK_DEV_MAX (%u)", idx, IWMX_SDK_DEV_MAX); - goto error_bug; + return; } if (g_iwmx_sdk_devs[idx] != NULL) { nm_log_err(LOGD_WIMAX, "BUG! device index %u already enumerated?", idx); - goto error_bug; + return; } wmxsdk = wmxsdk_new(); if (wmxsdk == NULL) { nm_log_err(LOGD_WIMAX, "Can't allocate %zu bytes", sizeof(*wmxsdk)); - goto error_bug; + return; } /* @@ -1297,23 +1344,17 @@ static void iwmx_sdk_dev_add(unsigned idx, unsigned api_idx, const char *name) || sscanf(s, "if:%15[^ \f\n\r\t\v]", wmxsdk->ifname) != 1) { nm_log_err(LOGD_WIMAX, "Cannot extract network interface name off '%s'", name); - goto error_noifname; + goto error; } nm_log_dbg(LOGD_WIMAX, "network interface name: '%s'", wmxsdk->ifname); - ifindex = if_nametoindex(wmxsdk->ifname); - if (ifindex <= 0) { - nm_log_err(LOGD_WIMAX, "wxmsdk: %s: cannot find interface index", wmxsdk->ifname); - goto error_noifname; - } - strncpy(wmxsdk->name, name, sizeof(wmxsdk->name)); wmxsdk->device_id.privilege = WIMAX_API_PRIVILEGE_READ_WRITE; wmxsdk->device_id.deviceIndex = api_idx; if (iwmx_sdk_setup(wmxsdk) != 0) { nm_log_err(LOGD_WIMAX, "wxmsdk: %s: cannot set up interface", wmxsdk->ifname); - goto error_setup; + goto error; } g_iwmx_sdk_devs[idx] = wmxsdk; @@ -1322,10 +1363,8 @@ static void iwmx_sdk_dev_add(unsigned idx, unsigned api_idx, const char *name) iwmx_sdk_call_new_callbacks (wmxsdk); return; -error_setup: -error_noifname: +error: wmxsdk_unref(wmxsdk); -error_bug: return; } |