]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Fixed EAP-TNC not to include extra EAP header and TNC flags
authorJouni Malinen <j@w1.fi>
Wed, 16 Jul 2008 23:17:37 +0000 (02:17 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 16 Jul 2008 23:17:37 +0000 (02:17 +0300)
The change to support fragmentation added extra function to generate the
EAP header, but forgot to remove the original code and ended up getting two
EAP headers and TNC flags field in the generated message. These header
fields need to be added only in the function that builds the final message
(and if necessary, fragments the data).

src/eap_peer/eap_tnc.c
src/eap_server/eap_tnc.c

index c8d822fa84aa5fb4e8030c960e269beb87b338d0..b2705f733582d7c2cace25799b6ddaba8ca3b368 100644 (file)
@@ -206,7 +206,7 @@ static struct wpabuf * eap_tnc_process(struct eap_sm *sm, void *priv,
        struct eap_tnc_data *data = priv;
        struct wpabuf *resp;
        const u8 *pos, *end;
-       u8 *rpos, *rpos1, *start;
+       u8 *rpos, *rpos1;
        size_t len, rlen;
        size_t imc_len;
        char *start_buf, *end_buf;
@@ -380,17 +380,14 @@ static struct wpabuf * eap_tnc_process(struct eap_sm *sm, void *priv,
        }
        end_len = os_strlen(end_buf);
 
-       rlen = 1 + start_len + imc_len + end_len;
-       resp = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_TNC, rlen,
-                            EAP_CODE_RESPONSE, eap_get_id(reqData));
+       rlen = start_len + imc_len + end_len;
+       resp = wpabuf_alloc(rlen);
        if (resp == NULL) {
                os_free(start_buf);
                os_free(end_buf);
                return NULL;
        }
 
-       start = wpabuf_put(resp, 0);
-       wpabuf_put_u8(resp, EAP_TNC_VERSION);
        wpabuf_put_data(resp, start_buf, start_len);
        os_free(start_buf);
 
@@ -401,7 +398,8 @@ static struct wpabuf * eap_tnc_process(struct eap_sm *sm, void *priv,
        wpabuf_put_data(resp, end_buf, end_len);
        os_free(end_buf);
 
-       wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-TNC: Response", start, rlen);
+       wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-TNC: Response",
+                         wpabuf_head(resp), wpabuf_len(resp));
 
        data->out_buf = resp;
        data->state = MSG;
index d3a32706edc124396c80876c3197294796ca21c5..834685bb7dc279556bc3569f5574b9fdbfa1fa26 100644 (file)
@@ -94,10 +94,10 @@ static struct wpabuf * eap_tnc_build_start(struct eap_sm *sm,
 
 
 static struct wpabuf * eap_tnc_build(struct eap_sm *sm,
-                                    struct eap_tnc_data *data, u8 id)
+                                    struct eap_tnc_data *data)
 {
        struct wpabuf *req;
-       u8 *rpos, *rpos1, *start;
+       u8 *rpos, *rpos1;
        size_t rlen;
        char *start_buf, *end_buf;
        size_t start_len, end_len;
@@ -116,17 +116,14 @@ static struct wpabuf * eap_tnc_build(struct eap_sm *sm,
        }
        end_len = os_strlen(end_buf);
 
-       rlen = 1 + start_len + imv_len + end_len;
-       req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_TNC, rlen,
-                           EAP_CODE_REQUEST, id);
+       rlen = start_len + imv_len + end_len;
+       req = wpabuf_alloc(rlen);
        if (req == NULL) {
                os_free(start_buf);
                os_free(end_buf);
                return NULL;
        }
 
-       start = wpabuf_put(req, 0);
-       wpabuf_put_u8(req, EAP_TNC_VERSION);
        wpabuf_put_data(req, start_buf, start_len);
        os_free(start_buf);
 
@@ -137,15 +134,15 @@ static struct wpabuf * eap_tnc_build(struct eap_sm *sm,
        wpabuf_put_data(req, end_buf, end_len);
        os_free(end_buf);
 
-       wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-TNC: Request", start, rlen);
+       wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-TNC: Request",
+                         wpabuf_head(req), wpabuf_len(req));
 
        return req;
 }
 
 
 static struct wpabuf * eap_tnc_build_recommendation(struct eap_sm *sm,
-                                                   struct eap_tnc_data *data,
-                                                   u8 id)
+                                                   struct eap_tnc_data *data)
 {
        switch (data->recommendation) {
        case ALLOW:
@@ -166,7 +163,7 @@ static struct wpabuf * eap_tnc_build_recommendation(struct eap_sm *sm,
                return NULL;
        }
 
-       return eap_tnc_build(sm, data, id);
+       return eap_tnc_build(sm, data);
 }
 
 
@@ -251,7 +248,7 @@ static struct wpabuf * eap_tnc_buildReq(struct eap_sm *sm, void *priv, u8 id)
                return eap_tnc_build_start(sm, data, id);
        case CONTINUE:
                if (data->out_buf == NULL) {
-                       data->out_buf = eap_tnc_build(sm, data, id);
+                       data->out_buf = eap_tnc_build(sm, data);
                        if (data->out_buf == NULL) {
                                wpa_printf(MSG_DEBUG, "EAP-TNC: Failed to "
                                           "generate message");
@@ -262,8 +259,7 @@ static struct wpabuf * eap_tnc_buildReq(struct eap_sm *sm, void *priv, u8 id)
                return eap_tnc_build_msg(data, id);
        case RECOMMENDATION:
                if (data->out_buf == NULL) {
-                       data->out_buf = eap_tnc_build_recommendation(sm, data,
-                                                                    id);
+                       data->out_buf = eap_tnc_build_recommendation(sm, data);
                        if (data->out_buf == NULL) {
                                wpa_printf(MSG_DEBUG, "EAP-TNC: Failed to "
                                           "generate recommendation message");