You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/12/14 18:05:35 UTC
[2/2] incubator-mynewt-core git commit: oic;
server was making a copy of payload mbuf, instead of directly
chaining it to response header.
oic; server was making a copy of payload mbuf, instead of
directly chaining it to response header.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/ee6182e1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ee6182e1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ee6182e1
Branch: refs/heads/develop
Commit: ee6182e13f1870f5b43b7af4c817898543719418
Parents: 399a7ae
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Dec 14 10:03:53 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Dec 14 10:03:53 2016 -0800
----------------------------------------------------------------------
net/oic/include/oic/oc_ri.h | 4 +++-
net/oic/src/api/oc_ri.c | 17 ++++++++---------
2 files changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ee6182e1/net/oic/include/oic/oc_ri.h
----------------------------------------------------------------------
diff --git a/net/oic/include/oic/oc_ri.h b/net/oic/include/oic/oc_ri.h
index 9449685..e58af0b 100644
--- a/net/oic/include/oic/oc_ri.h
+++ b/net/oic/include/oic/oc_ri.h
@@ -149,7 +149,9 @@ int oc_ri_get_query_value(const char *query, int query_len, const char *key,
oc_interface_mask_t oc_ri_get_interface_mask(char *iface, int if_len);
-bool oc_ri_invoke_coap_entity_handler(void *request, void *response,
+typedef struct coap_packet coap_packet_t;
+bool oc_ri_invoke_coap_entity_handler(coap_packet_t *request,
+ coap_packet_t *response,
int32_t *offset, oc_endpoint_t *endpoint);
#ifdef __cplusplus
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ee6182e1/net/oic/src/api/oc_ri.c
----------------------------------------------------------------------
diff --git a/net/oic/src/api/oc_ri.c b/net/oic/src/api/oc_ri.c
index 3ff5040..2f0faea 100644
--- a/net/oic/src/api/oc_ri.c
+++ b/net/oic/src/api/oc_ri.c
@@ -357,8 +357,9 @@ does_interface_support_method(oc_resource_t *resource,
}
bool
-oc_ri_invoke_coap_entity_handler(void *request, void *response,
- int32_t *offset, oc_endpoint_t *endpoint)
+oc_ri_invoke_coap_entity_handler(coap_packet_t *request,
+ coap_packet_t *response, int32_t *offset,
+ oc_endpoint_t *endpoint)
{
/* Flags that capture status along various stages of processing
* the request.
@@ -369,13 +370,10 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response,
bool authorized = true;
#endif
- /* Parsed CoAP PDU structure. */
- coap_packet_t *const packet = (coap_packet_t *)request;
-
/* This function is a server-side entry point solely for requests.
* Hence, "code" contains the CoAP method code.
*/
- oc_method_t method = packet->code;
+ oc_method_t method = request->code;
/* Initialize request/response objects to be sent up to the app layer. */
oc_request_t request_obj;
@@ -395,7 +393,7 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response,
request_obj.query_len = 0;
request_obj.resource = 0;
request_obj.origin = endpoint;
- request_obj.packet = packet;
+ request_obj.packet = request;
/* Initialize OCF interface selector. */
oc_interface_mask_t interface = 0;
@@ -642,8 +640,9 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response,
}
#endif
if (response_buffer.response_length) {
- coap_set_payload(response, response_buffer.buffer,
- OS_MBUF_PKTLEN(response_buffer.buffer));
+ response->payload_m = response_buffer.buffer;
+ response->payload_len = OS_MBUF_PKTLEN(response_buffer.buffer);
+ response_buffer.buffer = NULL; /* freed in coap_serialize_message() */
coap_set_header_content_format(response, APPLICATION_CBOR);
}
/* response_buffer.code at this point contains a valid CoAP status