Fixed EAP-TNC not to include extra EAP header and TNC flags
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).
This commit is contained in:
parent
93ef879f0f
commit
6652b61cd4
2 changed files with 15 additions and 21 deletions
|
@ -206,7 +206,7 @@ static struct wpabuf * eap_tnc_process(struct eap_sm *sm, void *priv,
|
||||||
struct eap_tnc_data *data = priv;
|
struct eap_tnc_data *data = priv;
|
||||||
struct wpabuf *resp;
|
struct wpabuf *resp;
|
||||||
const u8 *pos, *end;
|
const u8 *pos, *end;
|
||||||
u8 *rpos, *rpos1, *start;
|
u8 *rpos, *rpos1;
|
||||||
size_t len, rlen;
|
size_t len, rlen;
|
||||||
size_t imc_len;
|
size_t imc_len;
|
||||||
char *start_buf, *end_buf;
|
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);
|
end_len = os_strlen(end_buf);
|
||||||
|
|
||||||
rlen = 1 + start_len + imc_len + end_len;
|
rlen = start_len + imc_len + end_len;
|
||||||
resp = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_TNC, rlen,
|
resp = wpabuf_alloc(rlen);
|
||||||
EAP_CODE_RESPONSE, eap_get_id(reqData));
|
|
||||||
if (resp == NULL) {
|
if (resp == NULL) {
|
||||||
os_free(start_buf);
|
os_free(start_buf);
|
||||||
os_free(end_buf);
|
os_free(end_buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
start = wpabuf_put(resp, 0);
|
|
||||||
wpabuf_put_u8(resp, EAP_TNC_VERSION);
|
|
||||||
wpabuf_put_data(resp, start_buf, start_len);
|
wpabuf_put_data(resp, start_buf, start_len);
|
||||||
os_free(start_buf);
|
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);
|
wpabuf_put_data(resp, end_buf, end_len);
|
||||||
os_free(end_buf);
|
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->out_buf = resp;
|
||||||
data->state = MSG;
|
data->state = MSG;
|
||||||
|
|
|
@ -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,
|
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;
|
struct wpabuf *req;
|
||||||
u8 *rpos, *rpos1, *start;
|
u8 *rpos, *rpos1;
|
||||||
size_t rlen;
|
size_t rlen;
|
||||||
char *start_buf, *end_buf;
|
char *start_buf, *end_buf;
|
||||||
size_t start_len, end_len;
|
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);
|
end_len = os_strlen(end_buf);
|
||||||
|
|
||||||
rlen = 1 + start_len + imv_len + end_len;
|
rlen = start_len + imv_len + end_len;
|
||||||
req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_TNC, rlen,
|
req = wpabuf_alloc(rlen);
|
||||||
EAP_CODE_REQUEST, id);
|
|
||||||
if (req == NULL) {
|
if (req == NULL) {
|
||||||
os_free(start_buf);
|
os_free(start_buf);
|
||||||
os_free(end_buf);
|
os_free(end_buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
start = wpabuf_put(req, 0);
|
|
||||||
wpabuf_put_u8(req, EAP_TNC_VERSION);
|
|
||||||
wpabuf_put_data(req, start_buf, start_len);
|
wpabuf_put_data(req, start_buf, start_len);
|
||||||
os_free(start_buf);
|
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);
|
wpabuf_put_data(req, end_buf, end_len);
|
||||||
os_free(end_buf);
|
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;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct wpabuf * eap_tnc_build_recommendation(struct eap_sm *sm,
|
static struct wpabuf * eap_tnc_build_recommendation(struct eap_sm *sm,
|
||||||
struct eap_tnc_data *data,
|
struct eap_tnc_data *data)
|
||||||
u8 id)
|
|
||||||
{
|
{
|
||||||
switch (data->recommendation) {
|
switch (data->recommendation) {
|
||||||
case ALLOW:
|
case ALLOW:
|
||||||
|
@ -166,7 +163,7 @@ static struct wpabuf * eap_tnc_build_recommendation(struct eap_sm *sm,
|
||||||
return NULL;
|
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);
|
return eap_tnc_build_start(sm, data, id);
|
||||||
case CONTINUE:
|
case CONTINUE:
|
||||||
if (data->out_buf == NULL) {
|
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) {
|
if (data->out_buf == NULL) {
|
||||||
wpa_printf(MSG_DEBUG, "EAP-TNC: Failed to "
|
wpa_printf(MSG_DEBUG, "EAP-TNC: Failed to "
|
||||||
"generate message");
|
"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);
|
return eap_tnc_build_msg(data, id);
|
||||||
case RECOMMENDATION:
|
case RECOMMENDATION:
|
||||||
if (data->out_buf == NULL) {
|
if (data->out_buf == NULL) {
|
||||||
data->out_buf = eap_tnc_build_recommendation(sm, data,
|
data->out_buf = eap_tnc_build_recommendation(sm, data);
|
||||||
id);
|
|
||||||
if (data->out_buf == NULL) {
|
if (data->out_buf == NULL) {
|
||||||
wpa_printf(MSG_DEBUG, "EAP-TNC: Failed to "
|
wpa_printf(MSG_DEBUG, "EAP-TNC: Failed to "
|
||||||
"generate recommendation message");
|
"generate recommendation message");
|
||||||
|
|
Loading…
Reference in a new issue