Skip to content

Commit

Permalink
net: lwm2m: only method GET is allowed for .well-known/core
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
  • Loading branch information
rbtchc committed Aug 28, 2017
1 parent 0fc1fba commit bbbc803
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions subsys/net/lib/lwm2m/lwm2m_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -1983,12 +1983,17 @@ static int handle_request(struct zoap_packet *request,
in.reader = &plain_text_reader;
out.writer = &plain_text_writer;

code = zoap_header_get_code(in.in_zpkt);

/* parse the URL path into components */
r = zoap_find_options(in.in_zpkt, ZOAP_OPTION_URI_PATH, options, 4);
if (r <= 0) {
/* '/' is used by bootstrap-delete only */

/* TODO: handle bootstrap-delete */
/*
* TODO: Handle bootstrap deleted --
* re-add when DTLS support ready
*/
r = -EPERM;
goto error;
}
Expand All @@ -1999,6 +2004,11 @@ static int handle_request(struct zoap_packet *request,
strncmp(options[0].value, ".well-known", 11) == 0) &&
(options[1].len == 4 &&
strncmp(options[1].value, "core", 4) == 0)) {
if ((code & ZOAP_REQUEST_MASK) != ZOAP_METHOD_GET) {
r = -EPERM;
goto error;
}

discover = true;
} else {
r = zoap_options_to_path(options, r, &path);
Expand Down Expand Up @@ -2027,10 +2037,6 @@ static int handle_request(struct zoap_packet *request,
accept = LWM2M_FORMAT_OMA_TLV;
}

/* TODO: Handle bootstrap deleted -- re-add when DTLS support ready */

code = zoap_header_get_code(in.in_zpkt);

/* find registered obj */
obj = get_engine_obj(path.obj_id);
if (!obj) {
Expand Down

0 comments on commit bbbc803

Please sign in to comment.