Skip to content

Commit

Permalink
net: lwm2m: fix sending packet w/o token setup when error
Browse files Browse the repository at this point in the history
Token is missing when we jump to the error and token is not yet setup.
To correct it, we grab the token from the input packet at the beginning
of the handle_request()

Signed-off-by: Robert Chou <[email protected]>
  • Loading branch information
rbtchc authored and jukkar committed Nov 16, 2017
1 parent bde9dcd commit 9dcbbdb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions subsys/net/lib/lwm2m/lwm2m_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -2421,6 +2421,13 @@ static int handle_request(struct coap_packet *request,

code = coap_header_get_code(in.in_cpkt);

/* setup response token */
tkl = coap_header_get_token(in.in_cpkt, token);
if (tkl) {
msg->tkl = tkl;
msg->token = token;
}

/* parse the URL path into components */
r = coap_find_options(in.in_cpkt, COAP_OPTION_URI_PATH, options, 4);
if (r <= 0) {
Expand Down Expand Up @@ -2529,13 +2536,6 @@ static int handle_request(struct coap_packet *request,
break;
}

/* setup response token */
tkl = coap_header_get_token(in.in_cpkt, token);
if (tkl) {
msg->tkl = tkl;
msg->token = token;
}

/* setup incoming data */
in.frag = coap_packet_get_payload(in.in_cpkt, &in.offset,
&in.payload_len);
Expand Down

0 comments on commit 9dcbbdb

Please sign in to comment.