Exemplo n.º 1
0
static void
wl_media_connected_cb(void* ctx)
{
        struct cm *cm = ctx;
        struct wl_network_t *net = wl_get_current_network();
        CM_DPRINTF("CM: connected to %s\n", ssid2str(&net->ssid));
        if (cm->conn_cb)
                cm->conn_cb(net, cm->ctx);
}
Exemplo n.º 2
0
cmd_state_t
cmd_status(int argc, char* argv[], void* ctx)
{
        struct net_cfg *ncfg = ctx;
        struct wl_network_t* net;
        uint8_t mac[WL_MAC_ADDR_LENGTH];

        printk("wl_api version " WL_API_RELEASE_NAME "\n");
        /* print mac address */
        if (wl_get_mac_addr(mac) != WL_SUCCESS) {
                printk("failed to get mac address\n");
                return CMD_DONE;
        }
        printk("hw addr: %s\n", mac2str(mac));

        /* print network info */
        net = wl_get_current_network();
        printk("link status: ");
        if (!net) {
                printk("down\n");
                return CMD_DONE;
        }
        print_network(net);

        /* print ip address */
        if (netif_is_up(netif_default))
                printk("ip addr: %s\n", ip2str(netif_default->ip_addr));
        else
                printk("ip addr: none\n");
        printk("dhcp : ");
        if (ncfg->dhcp_enabled) {
                printk("enabled\n");
        }
        else {
                printk("disabled\n");
        }


        return CMD_DONE;
}
Exemplo n.º 3
0
static void
select_net(struct cm* cm)
{
        struct wl_network_t *candidate_net;
        struct wl_network_t *current_net;
        struct wl_ssid_t *ssid_p;

        int ret;

        /* Nothing to do */
        if (0 == cm->candidate.ssid.len) {
                return;
        }
        
        current_net = wl_get_current_network();
        candidate_net = find_best_candidate(cm);

        /* Connected to the candidate? ... */
        if ( current_net == candidate_net ) {
                if ( current_net ) {
                        /* ...yes, dont change. */
                        
                        return;
                }
        }

        /* Roaming checks */
        if (current_net && candidate_net) {
                /* Are we changing BSSs? */
                if ( equal_ssid(&candidate_net->ssid, 
                                &current_net->ssid)) {

                        /* ...no. Does the currently connected
                         * net have a decent RSSI?...*/
                        if ( current_net->rssi > ROAMING_RSSI_THRESHOLD ) {
                                /* ...yes, stay with it. */
                                return;
                        }
                        /* ...no. Does the candidate have
                         * sufficiently better RSSI to
                         * motivate a switch to it? */
                        if ( candidate_net->rssi < current_net->rssi + 
                             ROAMING_RSSI_DIFF) {
                                return;
                        }
                        /* ...yes, try to roam to candidate_net */
                        CM_DPRINTF("CM: Roaming from rssi %d to %d\n",
                                   current_net->rssi,
                                   candidate_net->rssi);
                }
        }
        /* a candidate is found */
        if (candidate_net) {
                /* We connect to a specific bssid here because
                 * find_best_candidate() might have picked a
                 * particulare AP among many with the same SSID.
                 * wl_connect() would pick one of them at random.
                 */
                ret = wl_connect_bssid(candidate_net->bssid);
        }
        /* no candidate found */
        else {
                CM_DPRINTF("CM: No candidate found for ssid \"%s\"\n",
                           ssid2str(&cm->candidate.ssid));
                /* Might be a hidden SSID so we try to connect to it.
                 * wl_connect() will trigger a directed scan
                 * for the SSID in this case.
                 */
                ssid_p = &cm->candidate.ssid;
                ret = wl_connect(ssid_p->ssid, ssid_p->len);
        }
        switch (ret) {
        case WL_SUCCESS :
                return;
        case WL_BUSY:
                wl_disconnect();
                return;
        case WL_RETRY:
                break;
        default :
                CM_DPRINTF("CM: failed to connect\n");
                break;
        } 
                
        /* some operation failed or no candidate found */
        if (wl_scan() != WL_SUCCESS)
                CM_DPRINTF("CM: failed to scan\n");                
}