diff --git a/examples/client.c b/examples/client.c index caf2a9aa..30b83b8e 100644 --- a/examples/client.c +++ b/examples/client.c @@ -364,8 +364,8 @@ resolve_address(const coap_str_const_t *server, struct sockaddr *dst) { #define HANDLE_BLOCK1(Pdu) \ ((method == COAP_REQUEST_PUT || method == COAP_REQUEST_POST) && \ ((flags & FLAGS_BLOCK) == 0) && \ - ((Pdu)->hdr->code == COAP_RESPONSE_CODE(201) || \ - (Pdu)->hdr->code == COAP_RESPONSE_CODE(204))) + ((Pdu)->hdr->code == COAP_RESPONSE_CODE_CREATED || \ + (Pdu)->hdr->code == COAP_RESPONSE_CODE_CHANGED)) static inline int check_token(coap_pdu_t *received) { diff --git a/examples/coap-rd.c b/examples/coap-rd.c index 3e543330..fb42346f 100644 --- a/examples/coap-rd.c +++ b/examples/coap-rd.c @@ -129,7 +129,7 @@ hnd_get_resource(coap_context_t *ctx UNUSED_PARAM, HASH_FIND(hh, resources, resource->uri_path->s, resource->uri_path->length, rd); - response->code = COAP_RESPONSE_CODE(205); + response->code = COAP_RESPONSE_CODE_CONTENT; coap_add_option(response, COAP_OPTION_CONTENT_TYPE, @@ -153,7 +153,7 @@ hnd_put_resource(coap_context_t *ctx UNUSED_PARAM, coap_string_t *query UNUSED_PARAM, coap_pdu_t *response) { #if 1 - response->code = COAP_RESPONSE_CODE(501); + response->code = COAP_RESPONSE_CODE_NOT_IMPLEMENTED; #else /* FIXME */ coap_opt_iterator_t opt_iter; coap_opt_t *token, *etag; @@ -179,7 +179,7 @@ hnd_put_resource(coap_context_t *ctx UNUSED_PARAM, if (!tmp.s) { coap_log(LOG_DEBUG, "hnd_put_rd: cannot allocate storage for new rd\n"); - code = COAP_RESPONSE_CODE(503); + code = COAP_RESPONSE_CODE_SERVICE_UNAVAILABLE; goto finish; } @@ -195,12 +195,12 @@ hnd_put_resource(coap_context_t *ctx UNUSED_PARAM, memcpy(rd->etag, COAP_OPT_VALUE(etag), rd->etag_len); } - code = COAP_RESPONSE_CODE(204); + code = COAP_RESPONSE_CODE_CHANGED; /* FIXME: update lifetime */ } else { - code = COAP_RESPONSE_CODE(503); + code = COAP_RESPONSE_CODE_SERVICE_UNAVAILABLE; } finish: @@ -242,7 +242,7 @@ hnd_delete_resource(coap_context_t *ctx, * using coap_malloc() and must be released. */ coap_delete_resource(ctx, resource); - response->code = COAP_RESPONSE_CODE(202); + response->code = COAP_RESPONSE_CODE_DELETED; } static void @@ -255,7 +255,7 @@ hnd_get_rd(coap_context_t *ctx UNUSED_PARAM, coap_pdu_t *response) { unsigned char buf[3]; - response->code = COAP_RESPONSE_CODE(205); + response->code = COAP_RESPONSE_CODE_CONTENT; coap_add_option(response, COAP_OPTION_CONTENT_TYPE, @@ -429,7 +429,7 @@ hnd_post_rd(coap_context_t *ctx, loc = (unsigned char *)coap_malloc(LOCSIZE); if (!loc) { - response->code = COAP_RESPONSE_CODE(500); + response->code = COAP_RESPONSE_CODE_INTERNAL_ERROR; return; } memcpy(loc, RD_ROOT_STR, RD_ROOT_SIZE); @@ -542,7 +542,7 @@ hnd_post_rd(coap_context_t *ctx, /* create response */ - response->code = COAP_RESPONSE_CODE(201); + response->code = COAP_RESPONSE_CODE_CREATED; { /* split path into segments and add Location-Path options */ unsigned char _b[LOCSIZE]; diff --git a/examples/coap-server.c b/examples/coap-server.c index 5920d393..03a06f33 100644 --- a/examples/coap-server.c +++ b/examples/coap-server.c @@ -222,7 +222,7 @@ hnd_get_time(coap_context_t *ctx UNUSED_PARAM, tmp = gmtime(&now); if (!tmp) { /* If 'now' is not valid */ - response->code = COAP_RESPONSE_CODE(404); + response->code = COAP_RESPONSE_CODE_NOT_FOUND; return; } else { @@ -236,7 +236,7 @@ hnd_get_time(coap_context_t *ctx UNUSED_PARAM, } else { /* if my_clock_base was deleted, we pretend to have no such resource */ - response->code = COAP_RESPONSE_CODE(404); + response->code = COAP_RESPONSE_CODE_NOT_FOUND; } } @@ -259,7 +259,7 @@ hnd_put_time(coap_context_t *ctx UNUSED_PARAM, /* if my_clock_base was deleted, we pretend to have no such resource */ response->code = - my_clock_base ? COAP_RESPONSE_CODE(204) : COAP_RESPONSE_CODE(201); + my_clock_base ? COAP_RESPONSE_CODE_CHANGED : COAP_RESPONSE_CODE_CREATED; coap_resource_notify_observers(resource, NULL); @@ -278,7 +278,7 @@ hnd_put_time(coap_context_t *ctx UNUSED_PARAM, /* Sanity check input value */ if (!gmtime(&my_clock_base)) { unsigned char buf[3]; - response->code = COAP_RESPONSE_CODE(400); + response->code = COAP_RESPONSE_CODE_BAD_REQUEST; coap_add_option(response, COAP_OPTION_CONTENT_FORMAT, coap_encode_var_safe(buf, sizeof(buf), @@ -320,7 +320,7 @@ hnd_get_async(coap_context_t *ctx, if (async->id != request->tid) { coap_opt_filter_t f; coap_option_filter_clear(f); - response->code = COAP_RESPONSE_CODE(503); + response->code = COAP_RESPONSE_CODE_SERVICE_UNAVAILABLE; } return; } @@ -367,7 +367,7 @@ check_async(coap_context_t *ctx, response = coap_pdu_init(async->flags & COAP_ASYNC_CONFIRM ? COAP_MESSAGE_CON : COAP_MESSAGE_NON, - COAP_RESPONSE_CODE(205), 0, size); + COAP_RESPONSE_CODE_CONTENT, 0, size); if (!response) { coap_log(LOG_DEBUG, "check_async: insufficient memory, we'll try later\n"); data.val = data.val + 15 * COAP_TICKS_PER_SECOND; @@ -473,7 +473,7 @@ hnd_put_example_data(coap_context_t *ctx UNUSED_PARAM, coap_log(LOG_WARNING, "No cache entry available for the non-first BLOCK1\n"); } - response->code = COAP_RESPONSE_CODE(500); + response->code = COAP_RESPONSE_CODE_INTERNAL_ERROR; return; } @@ -487,7 +487,7 @@ hnd_put_example_data(coap_context_t *ctx UNUSED_PARAM, else if (offset > (data_so_far ? data_so_far->length : 0)) { /* Upload is not sequential - block missing */ - response->code = COAP_RESPONSE_CODE(408); + response->code = COAP_RESPONSE_CODE_INCOMPLETE; return; } else if (offset < @@ -540,10 +540,10 @@ hnd_put_example_data(coap_context_t *ctx UNUSED_PARAM, just_respond: if (block1.m) { - response->code = COAP_RESPONSE_CODE(231); + response->code = COAP_RESPONSE_CODE_CONTINUE; } else { - response->code = COAP_RESPONSE_CODE(204); + response->code = COAP_RESPONSE_CODE_CHANGED; } coap_add_option(response, COAP_OPTION_BLOCK1, @@ -569,7 +569,7 @@ just_respond: else { example_data_media_type = COAP_MEDIATYPE_TEXT_PLAIN; } - response->code = COAP_RESPONSE_CODE(204); + response->code = COAP_RESPONSE_CODE_CHANGED; coap_resource_notify_observers(resource, NULL); } else { @@ -578,7 +578,7 @@ just_respond: coap_delete_binary(example_data_ptr); } example_data_ptr = coap_new_binary(0); - response->code = COAP_RESPONSE_CODE(204); + response->code = COAP_RESPONSE_CODE_CHANGED; } } @@ -787,7 +787,7 @@ get_ongoing_proxy_session(coap_session_t *session, coap_pdu_t *response, new_proxy_list = realloc(proxy_list, (i+1)*sizeof(proxy_list[0])); if (new_proxy_list == NULL) { - response->code = COAP_RESPONSE_CODE(500); + response->code = COAP_RESPONSE_CODE_INTERNAL_ERROR; return NULL; } proxy_list = new_proxy_list; @@ -807,7 +807,7 @@ get_ongoing_proxy_session(coap_session_t *session, coap_pdu_t *response, scheme = uri->scheme; } if (resolve_address(&server, &dst.addr.sa) < 0) { - response->code = COAP_RESPONSE_CODE(502); + response->code = COAP_RESPONSE_CODE_BAD_GATEWAY; return NULL; } switch (dst.addr.sa.sa_family) { @@ -865,7 +865,7 @@ get_ongoing_proxy_session(coap_session_t *session, coap_pdu_t *response, break; } if (proxy_list[i].ongoing == NULL) { - response->code = COAP_RESPONSE_CODE(505); + response->code = COAP_RESPONSE_CODE_PROXYING_NOT_SUPPORTED; return NULL; } proxy_list_count++; @@ -908,7 +908,7 @@ hnd_proxy_uri(coap_context_t *ctx UNUSED_PARAM, if (opt) { if (!get_uri_proxy_scheme_info(request, opt, &uri, &uri_path, &uri_query)) { - response->code = COAP_RESPONSE_CODE(505); + response->code = COAP_RESPONSE_CODE_PROXYING_NOT_SUPPORTED; goto cleanup; } proxy_scheme_option = 1; @@ -926,24 +926,24 @@ hnd_proxy_uri(coap_context_t *ctx UNUSED_PARAM, &uri) < 0) { /* Need to return a 5.05 RFC7252 Section 5.7.2 */ coap_log(LOG_WARNING, "Proxy URI not decodable\n"); - response->code = COAP_RESPONSE_CODE(505); + response->code = COAP_RESPONSE_CODE_PROXYING_NOT_SUPPORTED; goto cleanup; } } if (!(proxy_scheme_option || proxy_uri)) { - response->code = COAP_RESPONSE_CODE(404); + response->code = COAP_RESPONSE_CODE_NOT_FOUND; goto cleanup; } if (uri.host.length == 0) { /* Ongoing connection not well formed */ - response->code = COAP_RESPONSE_CODE(505); + response->code = COAP_RESPONSE_CODE_PROXYING_NOT_SUPPORTED; goto cleanup; } if (!verify_proxy_scheme_supported(uri.scheme)) { - response->code = COAP_RESPONSE_CODE(505); + response->code = COAP_RESPONSE_CODE_PROXYING_NOT_SUPPORTED; goto cleanup; } @@ -964,13 +964,13 @@ hnd_proxy_uri(coap_context_t *ctx UNUSED_PARAM, coap_new_message_id(ongoing), coap_session_max_pdu_size(session)); if (!pdu) { - response->code = COAP_RESPONSE_CODE(500); + response->code = COAP_RESPONSE_CODE_INTERNAL_ERROR; goto cleanup; } if (token && !coap_add_token(pdu, token->length, token->s)) { coap_log(LOG_DEBUG, "cannot add token to proxy request\n"); - response->code = COAP_RESPONSE_CODE(500); + response->code = COAP_RESPONSE_CODE_INTERNAL_ERROR; goto cleanup; } @@ -1102,7 +1102,7 @@ hnd_delete(coap_context_t *ctx, /* get the uri_path */ uri_path = coap_get_uri_path(request); if (!uri_path) { - response->code = COAP_RESPONSE_CODE(404); + response->code = COAP_RESPONSE_CODE_NOT_FOUND; return; } @@ -1123,7 +1123,7 @@ hnd_delete(coap_context_t *ctx, /* Dynamic resource no longer required - delete it */ coap_delete_resource(ctx, resource); coap_delete_string(uri_path); - response->code = COAP_RESPONSE_CODE(202); + response->code = COAP_RESPONSE_CODE_DELETED; } /* @@ -1152,7 +1152,7 @@ hnd_get(coap_context_t *ctx UNUSED_PARAM, uri_path = coap_resource_get_uri_path(resource); if (!uri_path) { - response->code = COAP_RESPONSE_CODE(404); + response->code = COAP_RESPONSE_CODE_NOT_FOUND; return; } @@ -1162,7 +1162,7 @@ hnd_get(coap_context_t *ctx UNUSED_PARAM, } } if (i == dynamic_count) { - response->code = COAP_RESPONSE_CODE(404); + response->code = COAP_RESPONSE_CODE_NOT_FOUND; return; } @@ -1205,7 +1205,7 @@ hnd_put(coap_context_t *ctx UNUSED_PARAM, /* get the uri_path */ uri_path = coap_get_uri_path(request); if (!uri_path) { - response->code = COAP_RESPONSE_CODE(404); + response->code = COAP_RESPONSE_CODE_NOT_FOUND; return; } @@ -1220,7 +1220,7 @@ hnd_put(coap_context_t *ctx UNUSED_PARAM, if (i == dynamic_count) { if (dynamic_count >= support_dynamic) { /* Should have been caught in hnd_unknown_put() */ - response->code = COAP_RESPONSE_CODE(406); + response->code = COAP_RESPONSE_CODE_NOT_ACCEPTABLE; coap_delete_string(uri_path); return; } @@ -1232,7 +1232,7 @@ hnd_put(coap_context_t *ctx UNUSED_PARAM, dynamic_entry[i].value = NULL; dynamic_entry[i].resource = resource; dynamic_entry[i].created = 1; - response->code = COAP_RESPONSE_CODE(201); + response->code = COAP_RESPONSE_CODE_CREATED; if ((option = coap_check_option(request, COAP_OPTION_CONTENT_FORMAT, &opt_iter)) != NULL) { dynamic_entry[i].media_type = @@ -1255,14 +1255,14 @@ hnd_put(coap_context_t *ctx UNUSED_PARAM, 0); } else { dynamic_count--; - response->code = COAP_RESPONSE_CODE(500); + response->code = COAP_RESPONSE_CODE_INTERNAL_ERROR; coap_delete_string(uri_path); return; } } else { /* Need to do this as coap_get_uri_path() created it */ coap_delete_string(uri_path); - response->code = COAP_RESPONSE_CODE(204); + response->code = COAP_RESPONSE_CODE_CHANGED; } resource_entry = &dynamic_entry[i]; @@ -1288,7 +1288,7 @@ hnd_put(coap_context_t *ctx UNUSED_PARAM, coap_log(LOG_WARNING, "No cache entry available for the non-first BLOCK1\n"); } - response->code = COAP_RESPONSE_CODE(500); + response->code = COAP_RESPONSE_CODE_INTERNAL_ERROR; return; } @@ -1302,7 +1302,7 @@ hnd_put(coap_context_t *ctx UNUSED_PARAM, else if (offset > (data_so_far ? data_so_far->length : 0)) { /* Upload is not sequential - block missing */ - response->code = COAP_RESPONSE_CODE(408); + response->code = COAP_RESPONSE_CODE_INCOMPLETE; return; } else if (offset < @@ -1339,14 +1339,14 @@ hnd_put(coap_context_t *ctx UNUSED_PARAM, just_respond: if (block1.m) { - response->code = COAP_RESPONSE_CODE(231); + response->code = COAP_RESPONSE_CODE_CONTINUE; } else if (resource_entry->created) { - response->code = COAP_RESPONSE_CODE(201); + response->code = COAP_RESPONSE_CODE_CREATED; resource_entry->created = 0; } else { - response->code = COAP_RESPONSE_CODE(204); + response->code = COAP_RESPONSE_CODE_CHANGED; } coap_add_option(response, COAP_OPTION_BLOCK1, @@ -1403,14 +1403,14 @@ hnd_unknown_put(coap_context_t *ctx, /* check if creating a new resource is allowed */ if (dynamic_count >= support_dynamic) { - response->code = COAP_RESPONSE_CODE(406); + response->code = COAP_RESPONSE_CODE_NOT_ACCEPTABLE; return; } /* get the uri_path - will get used by coap_resource_init() */ uri_path = coap_get_uri_path(request); if (!uri_path) { - response->code = COAP_RESPONSE_CODE(404); + response->code = COAP_RESPONSE_CODE_NOT_FOUND; return; } @@ -1451,7 +1451,7 @@ remove_proxy_association(coap_session_t *session, int send_failure) { /* Need to send back a gateway failure */ response = coap_pdu_init(COAP_MESSAGE_NON, - COAP_RESPONSE_CODE(502), + COAP_RESPONSE_CODE_BAD_GATEWAY, coap_new_message_id(proxy_list[i].incoming), coap_session_max_pdu_size(proxy_list[i].incoming)); if (!response) { diff --git a/include/coap2/pdu.h b/include/coap2/pdu.h index d83ca74c..fc36eb76 100644 --- a/include/coap2/pdu.h +++ b/include/coap2/pdu.h @@ -346,6 +346,44 @@ typedef uint8_t coap_proto_t; #define COAP_PROTO_TCP 3 #define COAP_PROTO_TLS 4 +/** + * @brief Set of response codes available for a response packet. + * + * To be used when creating a response. + */ +enum coap_response_code { + COAP_RESPONSE_CODE_OK = COAP_RESPONSE_CODE(200), + COAP_RESPONSE_CODE_CREATED = COAP_RESPONSE_CODE(201), + COAP_RESPONSE_CODE_DELETED = COAP_RESPONSE_CODE(202), + COAP_RESPONSE_CODE_VALID = COAP_RESPONSE_CODE(203), + COAP_RESPONSE_CODE_CHANGED = COAP_RESPONSE_CODE(204), + COAP_RESPONSE_CODE_CONTENT = COAP_RESPONSE_CODE(205), + COAP_RESPONSE_CODE_CONTINUE = COAP_RESPONSE_CODE(231), + COAP_RESPONSE_CODE_BAD_REQUEST = COAP_RESPONSE_CODE(400), + COAP_RESPONSE_CODE_UNAUTHORIZED = COAP_RESPONSE_CODE(401), + COAP_RESPONSE_CODE_BAD_OPTION = COAP_RESPONSE_CODE(402), + COAP_RESPONSE_CODE_FORBIDDEN = COAP_RESPONSE_CODE(403), + COAP_RESPONSE_CODE_NOT_FOUND = COAP_RESPONSE_CODE(404), + COAP_RESPONSE_CODE_NOT_ALLOWED = COAP_RESPONSE_CODE(405), + COAP_RESPONSE_CODE_NOT_ACCEPTABLE = COAP_RESPONSE_CODE(406), + COAP_RESPONSE_CODE_INCOMPLETE = COAP_RESPONSE_CODE(408), + COAP_RESPONSE_CODE_CONFLICT = COAP_RESPONSE_CODE(409), + COAP_RESPONSE_CODE_PRECONDITION_FAILED = COAP_RESPONSE_CODE(412), + COAP_RESPONSE_CODE_REQUEST_TOO_LARGE = COAP_RESPONSE_CODE(413), + COAP_RESPONSE_CODE_UNSUPPORTED_CONTENT_FORMAT = + COAP_RESPONSE_CODE(415), + COAP_RESPONSE_CODE_UNPROCESSABLE = COAP_RESPONSE_CODE(422), + COAP_RESPONSE_CODE_TOO_MANY_REQUESTS = COAP_RESPONSE_CODE(429), + COAP_RESPONSE_CODE_INTERNAL_ERROR = COAP_RESPONSE_CODE(500), + COAP_RESPONSE_CODE_NOT_IMPLEMENTED = COAP_RESPONSE_CODE(501), + COAP_RESPONSE_CODE_BAD_GATEWAY = COAP_RESPONSE_CODE(502), + COAP_RESPONSE_CODE_SERVICE_UNAVAILABLE = COAP_RESPONSE_CODE(503), + COAP_RESPONSE_CODE_GATEWAY_TIMEOUT = COAP_RESPONSE_CODE(504), + COAP_RESPONSE_CODE_PROXYING_NOT_SUPPORTED = + COAP_RESPONSE_CODE(505), + COAP_RESPONSE_CODE_HOP_LIMIT_REACHED = COAP_RESPONSE_CODE(508) +}; + /** * Creates a new CoAP PDU with at least enough storage space for the given * @p size maximum message size. The function returns a pointer to the diff --git a/man/coap_cache.txt.in b/man/coap_cache.txt.in index f374d8ef..eb2dec7e 100644 --- a/man/coap_cache.txt.in +++ b/man/coap_cache.txt.in @@ -247,7 +247,7 @@ hnd_put_example_data(coap_context_t *ctx, coap_log(LOG_WARNING, "No cache entry available for the non-first BLOCK1\n"); } - response->code = COAP_RESPONSE_CODE(500); + response->code = COAP_RESPONSE_CODE_INTERNAL_ERROR; return; } @@ -261,7 +261,7 @@ hnd_put_example_data(coap_context_t *ctx, else if (offset > (data_so_far ? data_so_far->length : 0)) { /* Upload is not sequential - block missing */ - response->code = COAP_RESPONSE_CODE(408); + response->code = COAP_RESPONSE_CODE_INCOMPLETE; return; } else if (offset < @@ -305,10 +305,10 @@ hnd_put_example_data(coap_context_t *ctx, just_respond: if (block1.m) { - response->code = COAP_RESPONSE_CODE(231); + response->code = COAP_RESPONSE_CODE_CONTINUE; } else { - response->code = COAP_RESPONSE_CODE(204); + response->code = COAP_RESPONSE_CODE_CHANGED; } coap_add_option(response, COAP_OPTION_BLOCK1, diff --git a/man/coap_handler.txt.in b/man/coap_handler.txt.in index fa020ae0..318a4fa9 100644 --- a/man/coap_handler.txt.in +++ b/man/coap_handler.txt.in @@ -220,7 +220,7 @@ coap_string_t *query, coap_pdu_t *response) { tmp = gmtime(&now); if (!tmp) { /* If 'now' is not valid */ - response->code = COAP_RESPONSE_CODE(404); + response->code = COAP_RESPONSE_CODE_NOT_FOUND; return; } len = strftime((char *)buf, sizeof(buf), "%b %d %H:%M:%S", tmp); diff --git a/man/coap_observe.txt.in b/man/coap_observe.txt.in index 92629fb0..30d032cf 100644 --- a/man/coap_observe.txt.in +++ b/man/coap_observe.txt.in @@ -186,7 +186,7 @@ coap_string_t *query, coap_pdu_t *response) { tmp = gmtime(&now); if (!tmp) { /* If 'now' is not valid */ - response->code = COAP_RESPONSE_CODE(404); + response->code = COAP_RESPONSE_CODE_NOT_FOUND; return; } len = strftime((char *)buf, sizeof(buf), "%b %d %H:%M:%S", tmp); @@ -224,7 +224,7 @@ coap_string_t *query, coap_pdu_t *response) { if (!uri_path) { /* Unexpected Failure */ - response->code = COAP_RESPONSE_CODE(400); + response->code = COAP_RESPONSE_CODE_BAD_REQUEST; return; } @@ -238,7 +238,7 @@ coap_string_t *query, coap_pdu_t *response) { /* Other resources code */ /* Failure response */ - response->code = COAP_RESPONSE_CODE(400); + response->code = COAP_RESPONSE_CODE_BAD_REQUEST; } /* Initialize generic GET handler */ diff --git a/man/coap_pdu_setup.txt.in b/man/coap_pdu_setup.txt.in index 8054190d..eaa72767 100644 --- a/man/coap_pdu_setup.txt.in +++ b/man/coap_pdu_setup.txt.in @@ -416,7 +416,7 @@ coap_string_t *query, coap_pdu_t *response) { tmp = gmtime(&now); if (!tmp) { /* If 'now' is not valid */ - response->code = COAP_RESPONSE_CODE(404); + response->code = COAP_RESPONSE_CODE_NOT_FOUND; return; } len = strftime((char *)buf, sizeof(buf), "%b %d %H:%M:%S", tmp); diff --git a/man/coap_resource.txt.in b/man/coap_resource.txt.in index e05ae3a3..c5facbfd 100644 --- a/man/coap_resource.txt.in +++ b/man/coap_resource.txt.in @@ -193,7 +193,7 @@ coap_string_t *query, coap_pdu_t *response) { (void)token; (void)query; - response->code = COAP_RESPONSE_CODE(205); + response->code = COAP_RESPONSE_CODE_CONTENT; coap_add_option(response, COAP_OPTION_CONTENT_TYPE, @@ -223,7 +223,7 @@ coap_string_t *query, coap_pdu_t *response) { /* .. code .. */ - response->code = COAP_RESPONSE_CODE(202); + response->code = COAP_RESPONSE_CODE_DELETED; } static void @@ -376,7 +376,7 @@ coap_string_t *query, coap_pdu_t *response) { /* get the uri_path */ put_uri_path = coap_get_uri_path(request); if (!put_uri_path) { - response->code = COAP_RESPONSE_CODE(404); + response->code = COAP_RESPONSE_CODE_NOT_FOUND; return; } @@ -413,13 +413,13 @@ coap_string_t *query, coap_pdu_t *response) { /* get the uri_path - which will get used by coap_resource_init() */ uri_path = coap_get_uri_path(request); if (!uri_path) { - response->code = COAP_RESPONSE_CODE(404); + response->code = COAP_RESPONSE_CODE_NOT_FOUND; return; } /* Check if new URI Path is valid */ if (!check_url_fn (uri_path, request->code)) { - response->code = COAP_RESPONSE_CODE(404); + response->code = COAP_RESPONSE_CODE_NOT_FOUND; coap_delete_string(uri_path); return; }