static void device_state_changed (NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason, gpointer user_data) { NMDeviceWimax *self = NM_DEVICE_WIMAX (device); NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); if (new_state < NM_DEVICE_STATE_DISCONNECTED) remove_all_nsps (self); /* Request initial NSP list */ if ( new_state == NM_DEVICE_STATE_DISCONNECTED && old_state < NM_DEVICE_STATE_DISCONNECTED) { if (priv->sdk) iwmx_sdk_get_networks (priv->sdk); } if (new_state == NM_DEVICE_STATE_FAILED || new_state <= NM_DEVICE_STATE_DISCONNECTED) clear_activation_timeout (self); if (new_state == NM_DEVICE_STATE_ACTIVATED) { /* poll link quality and BSID */ clear_connected_poll (self); priv->poll_id = g_timeout_add_seconds (10, connected_poll_cb, self); connected_poll_cb (self); } else { clear_link_timeout (self); clear_connected_poll (self); set_link_status (self, NULL); } }
/* set state */ void set_state(int state) { wd_status.state = state; wd_status.info_updated |= WDS_STATE; if (state >= 1 && state <= 3 && wd_status.link_status != (state - 1)) { set_link_status(state - 1); } }
static gboolean connected_poll_cb (gpointer user_data) { NMDeviceWimax *self = NM_DEVICE_WIMAX (user_data); NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); WIMAX_API_CONNECTED_NSP_INFO_EX *sdk_nsp; WIMAX_API_LINK_STATUS_INFO_EX *link_status; g_return_val_if_fail (priv->sdk != NULL, FALSE); /* Get details of the connected NSP */ sdk_nsp = iwmx_sdk_get_connected_network (priv->sdk); if (sdk_nsp) { const char *nsp_name = (const char *) sdk_nsp->NSPName; NMWimaxNsp *nsp; nsp = get_nsp_by_name (self, nsp_name); if (nsp) { NMWimaxNspNetworkType net_type; guint signalq; net_type = nm_wimax_util_convert_network_type (sdk_nsp->networkType); if (net_type != nm_wimax_nsp_get_network_type (nsp)) g_object_set (nsp, NM_WIMAX_NSP_NETWORK_TYPE, net_type, NULL); signalq = sdk_nsp->linkQuality; if (signalq != nm_wimax_nsp_get_signal_quality (nsp)) g_object_set (nsp, NM_WIMAX_NSP_SIGNAL_QUALITY, signalq, NULL); nm_log_dbg (LOGD_WIMAX, "(%s): WiMAX NSP '%s' quality %d%% type %d", nm_device_get_iface (NM_DEVICE (self)), nsp_name, sdk_nsp->linkQuality, net_type); } free (sdk_nsp); } /* Get details of the current radio link */ link_status = iwmx_sdk_get_link_status_info (priv->sdk); if (link_status) { set_link_status (self, link_status); free (link_status); } return TRUE; /* reschedule */ }
static void device_state_changed (NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason) { NMDeviceWimax *self = NM_DEVICE_WIMAX (device); NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); /* Reset our stage1 (Prepare) done marker since it's only valid while in stage1 */ priv->prepare_done = FALSE; if (new_state < NM_DEVICE_STATE_DISCONNECTED) remove_all_nsps (self); /* Request initial NSP list when device is first started */ if ( new_state == NM_DEVICE_STATE_DISCONNECTED && old_state < NM_DEVICE_STATE_DISCONNECTED) { if (priv->sdk) iwmx_sdk_get_networks (priv->sdk); } if (new_state == NM_DEVICE_STATE_FAILED || new_state <= NM_DEVICE_STATE_DISCONNECTED) { set_current_nsp (self, NULL); clear_activation_timeout (self); } if (new_state == NM_DEVICE_STATE_ACTIVATED) { /* poll link quality and BSID */ clear_connected_poll (self); priv->poll_id = g_timeout_add_seconds (10, connected_poll_cb, self); connected_poll_cb (self); } else { clear_link_timeout (self); clear_connected_poll (self); set_link_status (self, NULL); } }
void probe_request( probe_timer_entry *entry, int event, uint64_t *dpid, uint16_t port_no ) { if ( event == PROBE_TIMER_EVENT_UP ) { get_current_time( &port_down_time ); } int old_state = entry->state; switch ( entry->state ) { case PROBE_TIMER_STATE_INACTIVE: switch( event ) { case PROBE_TIMER_EVENT_UP: set_send_delay_state( entry ); break; default: break; } break; case PROBE_TIMER_STATE_SEND_DELAY: switch( event ) { case PROBE_TIMER_EVENT_DOWN: set_inactive_state( entry ); break; case PROBE_TIMER_EVENT_TIMEOUT: set_wait_state( entry ); send_lldp( entry ); break; default: break; } break; case PROBE_TIMER_STATE_WAIT: switch( event ) { case PROBE_TIMER_EVENT_DOWN: set_inactive_state( entry ); break; case PROBE_TIMER_EVENT_RECV_LLDP: set_confirmed_state( entry ); entry->link_up = true; entry->to_datapath_id = *dpid; entry->to_port_no = port_no; topology_update_link_status link_status; link_status.from_dpid = entry->datapath_id; link_status.from_portno = entry->port_no; link_status.to_dpid = *dpid; link_status.to_portno = port_no; link_status.status = TD_PORT_UP; set_link_status( &link_status, NULL, NULL ); break; case PROBE_TIMER_EVENT_TIMEOUT: if ( --entry->retry_count > 0 ) { set_wait_state( entry ); send_lldp( entry ); } else { set_confirmed_state( entry ); entry->link_up = false; entry->to_datapath_id = 0; entry->to_port_no = 0; get_current_time( &( entry->link_down_time ) ); topology_update_link_status link_status; link_status.from_dpid = entry->datapath_id; link_status.from_portno = entry->port_no; link_status.to_dpid = 0; link_status.to_portno = 0; link_status.status = TD_PORT_DOWN; set_link_status( &link_status, NULL, NULL ); } break; default: break; } break; case PROBE_TIMER_STATE_CONFIRMED: switch( event ) { case PROBE_TIMER_EVENT_DOWN: set_inactive_state( entry ); break; case PROBE_TIMER_EVENT_TIMEOUT: if ( --entry->retry_count > 0 && !other_port_status_changed( entry ) ) { set_confirmed_state( entry ); } else { set_send_delay_state( entry ); } break; default: break; } break; default: UNREACHABLE(); break; } if ( entry->state != old_state ) { debug( "Update probe state: %d <= %d by event %d. dpid %" PRIx64 " %u.", entry->state, old_state, event, entry->datapath_id, entry->port_no ); } if ( entry->state != PROBE_TIMER_STATE_INACTIVE ) { insert_probe_timer_entry( entry ); } }