diff options
author | Vinicius Costa Gomes <vinicius.gomes@intel.com> | 2017-01-17 16:00:33 -0800 |
---|---|---|
committer | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2017-01-20 16:23:19 +0200 |
commit | e44dfffba28f3e84ecad793ece2b36e60fcc96dc (patch) | |
tree | b55987392dd818794ee58d25107734aea9f83f43 /samples | |
parent | 0eaeaf248199dd9cc50d08e6512713dcee64f73b (diff) |
samples/zoap_server: Add Content-Format options to GET responses
The Californium tests expects that all GET responses include the
Content-Format information of the response. In our case, all responses
are of type plain-text.
Change-Id: I08844825f31ed8f4c54020a41b9172cef5da6d70
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Diffstat (limited to 'samples')
-rw-r--r-- | samples/net/zoap_server/src/zoap-server.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/samples/net/zoap_server/src/zoap-server.c b/samples/net/zoap_server/src/zoap-server.c index 7a07936d2..dc99aa925 100644 --- a/samples/net/zoap_server/src/zoap-server.c +++ b/samples/net/zoap_server/src/zoap-server.c @@ -39,6 +39,8 @@ static struct net_context *context; +static const uint8_t plain_text_format; + static int test_del(struct zoap_resource *resource, struct zoap_packet *request, const struct sockaddr *from) @@ -276,6 +278,12 @@ static int piggyback_get(struct zoap_resource *resource, zoap_header_set_id(&response, id); zoap_header_set_token(&response, token, tkl); + r = zoap_add_option(&response, ZOAP_OPTION_CONTENT_FORMAT, + &plain_text_format, sizeof(plain_text_format)); + if (r < 0) { + return -EINVAL; + } + payload = zoap_packet_get_payload(&response, &len); if (!payload) { return -EINVAL; @@ -371,6 +379,12 @@ static int query_get(struct zoap_resource *resource, zoap_header_set_id(&response, id); zoap_header_set_token(&response, token, tkl); + r = zoap_add_option(&response, ZOAP_OPTION_CONTENT_FORMAT, + &plain_text_format, sizeof(plain_text_format)); + if (r < 0) { + return -EINVAL; + } + payload = zoap_packet_get_payload(&response, &len); if (!payload) { return -EINVAL; @@ -483,6 +497,12 @@ done: zoap_header_set_id(&response, id); zoap_header_set_token(&response, token, tkl); + r = zoap_add_option(&response, ZOAP_OPTION_CONTENT_FORMAT, + &plain_text_format, sizeof(plain_text_format)); + if (r < 0) { + return -EINVAL; + } + payload = zoap_packet_get_payload(&response, &len); if (!payload) { return -EINVAL; @@ -566,6 +586,12 @@ static int large_get(struct zoap_resource *resource, zoap_header_set_id(&response, id); zoap_header_set_token(&response, token, tkl); + r = zoap_add_option(&response, ZOAP_OPTION_CONTENT_FORMAT, + &plain_text_format, sizeof(plain_text_format)); + if (r < 0) { + return -EINVAL; + } + r = zoap_add_block2_option(&response, &ctx); if (r < 0) { return -EINVAL; @@ -658,6 +684,12 @@ static int large_update_put(struct zoap_resource *resource, zoap_header_set_id(&response, id); zoap_header_set_token(&response, token, tkl); + r = zoap_add_option(&response, ZOAP_OPTION_CONTENT_FORMAT, + &plain_text_format, sizeof(plain_text_format)); + if (r < 0) { + return -EINVAL; + } + r = zoap_add_block2_option(&response, &ctx); if (r < 0) { return -EINVAL; |