added some comment in here and there in pdu.h/c.
authorjihwan.seo <jihwan.seo@samsung.com>
Tue, 22 Mar 2016 08:02:51 +0000 (17:02 +0900)
committerJon A. Cruz <jon@joncruz.org>
Fri, 25 Mar 2016 01:46:21 +0000 (01:46 +0000)
Change-Id: Icc9fd12382d2d94f2909e383e780f8225115da3a
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/6169
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jon@joncruz.org>
resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.c
resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.h

index 1da4034..1b36674 100644 (file)
@@ -427,13 +427,13 @@ unsigned int coap_get_tcp_header_length_for_transport(coap_transport_type transp
         case coap_tcp:
             length = COAP_TCP_HEADER_NO_FIELD;
             break;
-        case coap_tcp_8bit:
+        case coap_tcp_8bit:   /* len(4bit) + TKL(4bit) + Len+bytes(1byte) + Code(1byte) */
             length = COAP_TCP_HEADER_8_BIT;
             break;
-        case coap_tcp_16bit:
+        case coap_tcp_16bit:  /* len(4bit) + TKL(4bit) + Len+bytes(2byte) + Code(1byte) */
             length = COAP_TCP_HEADER_16_BIT;
             break;
-        case coap_tcp_32bit:
+        case coap_tcp_32bit:  /* len(4bit) + TKL(4bit) + Len+bytes(4byte) + Code(1byte) */
             length = COAP_TCP_HEADER_32_BIT;
             break;
         default:
index d461913..c375416 100644 (file)
@@ -398,7 +398,7 @@ int coap_pdu_parse(unsigned char *data, size_t length, coap_pdu_t *pdu,
 
 #ifdef WITH_TCP
 /**
- * Get total message length from header.
+ * Get total pdu size including header + option + payload (with marker) from pdu data.
  *
  * @param data   The raw data to parse as CoAP PDU.
  * @param size   payload size of pdu.
@@ -407,7 +407,8 @@ int coap_pdu_parse(unsigned char *data, size_t length, coap_pdu_t *pdu,
 size_t coap_get_total_message_length(const unsigned char *data, size_t size);
 
 /**
- * Get transport type of coap header for coap over tcp through payload size.
+ * Get transport type of coap header for coap over tcp
+ * through payload size(including payload marker) + option size.
  *
  * @param size   payload size of pdu.
  * @return The transport type.
@@ -415,7 +416,8 @@ size_t coap_get_total_message_length(const unsigned char *data, size_t size);
 coap_transport_type coap_get_tcp_header_type_from_size(unsigned int size);
 
 /**
- * Get transport type of coap header for coap over tcp through init-byte.
+ * Get transport type of coap header for coap over tcp
+ * through first nibble(0~E) of init-byte .
  *
  * @param legnth   length value of init byte.
 * @return The transport type.
@@ -423,7 +425,8 @@ coap_transport_type coap_get_tcp_header_type_from_size(unsigned int size);
 coap_transport_type coap_get_tcp_header_type_from_initbyte(unsigned int length);
 
 /**
- * Add length value in field of coap header for coap over tcp.
+ * Add length of option/payload into 'Len+ byte...' field of coap header
+ * for coap over tcp.
  *
  * @param pdu  The pdu pointer.
  * @param transport The transport type.
@@ -433,7 +436,7 @@ void coap_add_length(const coap_pdu_t *pdu, coap_transport_type transport,
                      unsigned int length);
 
 /**
- * Get the value of length field of coap header for coap over tcp.
+ * Get the length of option/payload field of coap header for coap over tcp.
  *
  * @param pdu  The pdu pointer.
  * @param transport The transport type.
@@ -442,15 +445,16 @@ void coap_add_length(const coap_pdu_t *pdu, coap_transport_type transport,
 unsigned int coap_get_length(const coap_pdu_t *pdu, coap_transport_type transport);
 
 /**
- * Get pdu length from header of coap over tcp.
+ * Get the length of option/payload field of coap header for coap over tcp.
  *
  * @param header   The header to parse.
  * @return transport The transport type.
  */
-unsigned int coap_get_length_from_header(const unsigned char *header, coap_transport_type transport);
+unsigned int coap_get_length_from_header(const unsigned char *header,
+                                         coap_transport_type transport);
 
 /**
- * Get length of header for coap over tcp.
+ * Get length of header including len, TKL, Len+bytes, Code, token bytes for coap over tcp.
  *
  * @param data   The raw data to parse as CoAP PDU
  * @return header length + token length
@@ -458,7 +462,8 @@ unsigned int coap_get_length_from_header(const unsigned char *header, coap_trans
 unsigned int coap_get_tcp_header_length(unsigned char *data);
 
 /**
- * Get length of header without token length for coap over tcp.
+ * Get length of header including len, TKL, Len+bytes, Code
+ * without token bytes for coap over tcp.
  *
  * @param transport The transport type.
  * @return header length.