Ejemplo n.º 1
0
void
sr_session_handshake(sr_session_t *s)
{
	struct sr_session_priv *priv = s->priv;
	gchar *auth, *tmp;
	glong timestamp;
	gchar *handshake_url;
	SoupMessage *message;
	GTimeVal time_val;

	g_get_current_time(&time_val);
	timestamp = time_val.tv_sec;

	tmp = g_strdup_printf("%s%li", priv->hash_pwd, timestamp);
	auth = g_compute_checksum_for_string(G_CHECKSUM_MD5, tmp, -1);
	g_free(tmp);

	handshake_url = g_strdup_printf("%s&p=1.2.1&c=%s&v=%s&u=%s&t=%li&a=%s",
			priv->url,
			priv->client_id,
			priv->client_ver,
			priv->user,
			timestamp,
			auth);

	message = soup_message_new("GET", handshake_url);
	soup_session_queue_message(priv->soup,
			message,
			handshake_cb,
			s);

	g_free(handshake_url);
	g_free(auth);

	if (priv->api_key) {
		if (!priv->session_key)
			ws_auth(s);
		else
			ws_love(s);
	}
}
Ejemplo n.º 2
0
/*========================================================================
    Routine    Description:
        wifi state machine -- management the entry for each of wifi state
        because wifi_rx_proc() maybe no need to be called in some state or substate
        a bool param "b_doRx" is be used to declare it

    Arguments:
    Return Value:
    Note:
========================================================================*/
void wifi_state_machine(void)
{
#ifdef CONFIG_STATION
    bool b_doRx = FALSE;     /*not use and move wifi_rx_proc() before wifi_state_machine() to fix Dequeue fail*/

    switch (pIoTMlme->CurrentWifiState) {
        case WIFI_STATE_INIT:
            ws_init(&b_doRx);
            break;
            /*Smart Connection SM*/
        case WIFI_STATE_SMTCNT:
            ws_smt_conn(&b_doRx);
            break;
            /*Scan SM*/
        case WIFI_STATE_SCAN:
            /*send Probe req frame at first , then listen Probe response in each channel*/
            ws_scan(&b_doRx);
            break;
            /*Auth SM*/
        case WIFI_STATE_AUTH:
            ws_auth(&b_doRx);
            break;
            /*Assoc SM*/
        case WIFI_STATE_ASSOC:
            ws_assoc(&b_doRx);
            break;
            /*4 Way handshake SM*/
        case WIFI_STATE_4WAY:
            ws_4way(&b_doRx);
            break;
            /*Connected SM*/
        case WIFI_STATE_CONNED:
            ws_connected(&b_doRx);
#if CFG_SUPPORT_TCPIP
            if (pIoTMlme->TcpInit == FALSE) {
                /*pIoTMlme->TcpInit shall be set FALSE, once call 
                   wifi_state_chg(WIFI_STATE_INIT, 0) or iot_linkdown()*/
                tcpip_init();
                /*if user add their own tcp/udp connection in other place, but not in tcpip_init()
                   it need to initial such connection here*/
            }
            tcpip_periodic_timer();
#endif
            break;
        default:
            b_doRx = TRUE;
            break;
    }
#endif

#ifdef CONFIG_SOFTAP
#if CFG_SUPPORT_TCPIP
    if (pIoTMlme->TcpInit == FALSE) {
        tcpip_init();
        /*if user add their own tcp/udp connection in other place, but not in tcpip_init()
           it need to initial such connection here*/
    }
    tcpip_periodic_timer();
#endif
#endif

    return;
}