Added Doxygen documentation for WPS code
[libeap.git] / src / eap_peer / eap_wsc.c
index d4b0dc3..6c45993 100644 (file)
 
 
 struct eap_wsc_data {
-       enum { WAIT_START, MSG, FRAG_ACK, WAIT_FRAG_ACK, DONE, FAIL } state;
+       enum { WAIT_START, MESG, FRAG_ACK, WAIT_FRAG_ACK, DONE, FAIL } state;
        int registrar;
        struct wpabuf *in_buf;
        struct wpabuf *out_buf;
-       u8 in_op_code, out_op_code;
+       enum wsc_op_code in_op_code, out_op_code;
        size_t out_used;
        size_t fragment_size;
        struct wps_data *wps;
@@ -40,8 +40,8 @@ static const char * eap_wsc_state_txt(int state)
        switch (state) {
        case WAIT_START:
                return "WAIT_START";
-       case MSG:
-               return "MSG";
+       case MESG:
+               return "MESG";
        case FRAG_ACK:
                return "FRAG_ACK";
        case WAIT_FRAG_ACK:
@@ -131,7 +131,7 @@ static void * eap_wsc_init(struct eap_sm *sm)
        data = os_zalloc(sizeof(*data));
        if (data == NULL)
                return NULL;
-       data->state = registrar ? MSG : WAIT_START;
+       data->state = registrar ? MESG : WAIT_START;
        data->registrar = registrar;
        data->wps_ctx = wps;
 
@@ -162,7 +162,6 @@ static void * eap_wsc_init(struct eap_sm *sm)
        cfg.authenticator = 0;
        cfg.wps = wps;
        cfg.registrar = registrar ? data->wps_ctx->registrar : NULL;
-       cfg.enrollee_mac_addr = sm->mac_addr;
 
        phase1 = eap_get_config_phase1(sm);
        if (phase1 == NULL) {
@@ -192,10 +191,6 @@ static void * eap_wsc_init(struct eap_sm *sm)
                return NULL;
        }
 
-       if (registrar && wps)
-               os_memcpy(wps->uuid, sm->uuid, UUID_LEN);
-       else
-               cfg.uuid = sm->uuid;
        data->wps = wps_init(&cfg);
        if (data->wps == NULL) {
                os_free(data);
@@ -203,15 +198,9 @@ static void * eap_wsc_init(struct eap_sm *sm)
        }
        data->fragment_size = WSC_FRAGMENT_SIZE;
 
-
-       if (registrar) {
-               /* Testing */
-               wpa_printf(MSG_INFO, "EAP-WSC: Registrar functionality not "
-                          "yet fully supported - using test values");
-               u8 uuid_e[UUID_LEN];
-               os_memset(uuid_e, 0, UUID_LEN);
-               wps_registrar_add_pin(data->wps_ctx->registrar, uuid_e,
-                                     (const u8 *) "12345670", 8);
+       if (registrar && cfg.pin) {
+               wps_registrar_add_pin(data->wps_ctx->registrar, NULL,
+                                     cfg.pin, cfg.pin_len);
        }
 
        return data;
@@ -225,6 +214,7 @@ static void eap_wsc_deinit(struct eap_sm *sm, void *priv)
        wpabuf_free(data->out_buf);
        wps_deinit(data->wps);
        wps_registrar_deinit(data->wps_ctx->registrar);
+       data->wps_ctx->registrar = NULL;
        os_free(data->wps_ctx->network_key);
        data->wps_ctx->network_key = NULL;
        os_free(data);
@@ -285,7 +275,7 @@ static struct wpabuf * eap_wsc_build_msg(struct eap_wsc_data *data,
                        eap_wsc_state(data, FAIL);
                        ret->methodState = METHOD_DONE;
                } else
-                       eap_wsc_state(data, MSG);
+                       eap_wsc_state(data, MESG);
        } else {
                wpa_printf(MSG_DEBUG, "EAP-WSC: Sending out %lu bytes "
                           "(%lu more to send)", (unsigned long) send_len,
@@ -414,7 +404,7 @@ static struct wpabuf * eap_wsc_process(struct eap_sm *sm, void *priv,
                        return NULL;
                }
                wpa_printf(MSG_DEBUG, "EAP-WSC: Fragment acknowledged");
-               eap_wsc_state(data, MSG);
+               eap_wsc_state(data, MESG);
                return eap_wsc_build_msg(data, ret, id);
        }
 
@@ -434,7 +424,7 @@ static struct wpabuf * eap_wsc_process(struct eap_sm *sm, void *priv,
                        return NULL;
                }
                wpa_printf(MSG_DEBUG, "EAP-WSC: Received start");
-               eap_wsc_state(data, MSG);
+               eap_wsc_state(data, MESG);
                /* Start message has empty payload, skip processing */
                goto send_msg;
        } else if (op_code == WSC_Start) {
@@ -470,7 +460,7 @@ static struct wpabuf * eap_wsc_process(struct eap_sm *sm, void *priv,
                eap_wsc_state(data, FAIL);
                break;
        case WPS_CONTINUE:
-               eap_wsc_state(data, MSG);
+               eap_wsc_state(data, MESG);
                break;
        case WPS_FAILURE:
                wpa_printf(MSG_DEBUG, "EAP-WSC: WPS processing failed");
@@ -499,7 +489,7 @@ send_msg:
                data->out_used = 0;
        }
 
-       eap_wsc_state(data, MSG);
+       eap_wsc_state(data, MESG);
        return eap_wsc_build_msg(data, ret, id);
 }