From: jihwan.seo Date: Tue, 25 Aug 2015 01:18:04 +0000 (+0900) Subject: Add Build Option in libcoap. X-Git-Tag: 1.2.0+RC1~70^2~48 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4d2c8162893d8e0fb831a075e07c6cdcbdb48c64;p=platform%2Fupstream%2Fiotivity.git Add Build Option in libcoap. Change-Id: I6f7c6a7885fb0b89fca95bff6cb8cf66c2d16537 Signed-off-by: jihwan.seo Reviewed-on: https://gerrit.iotivity.org/gerrit/2264 Reviewed-by: Jon A. Cruz Tested-by: Jon A. Cruz --- diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript b/resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript index 8c1059a..849c500 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript @@ -7,6 +7,7 @@ Import('env') libcoap_env = env.Clone() target_os = env.get('TARGET_OS') +ca_transport = env.get('TARGET_TRANSPORT') # As in the source code(C) includes arduino Time library head file(C++) # It requires compile the .c with g++ if target_os == 'arduino': @@ -35,6 +36,10 @@ if target_os not in ['windows', 'winrt']: libcoap_env.AppendUnique(CFLAGS = ['-Wall', '-ffunction-sections', '-fdata-sections', '-fno-exceptions']) +if target_os == 'linux': + if (('CI' in ca_transport) or ('ALL' in ca_transport)): + libcoap_env.AppendUnique(CPPDEFINES = ['WITH_TCP']) + if target_os == 'android': libcoap_env.AppendUnique(LIBS = ['log']) @@ -69,4 +74,4 @@ libcoap_src = [ libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_') libcoap_env.InstallTarget([libcoap], 'libcoap') -libcoap_env.UserInstallTargetLib([libcoap], 'libcoap') +libcoap_env.UserInstallTargetLib([libcoap], 'libcoap') \ No newline at end of file diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/option.c b/resource/csdk/connectivity/lib/libcoap-4.1.1/option.c index 04b8dee..77595d0 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/option.c +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/option.c @@ -32,6 +32,7 @@ options_start(coap_pdu_t *pdu, coap_transport_type transport) pdu->hdr->coap_hdr_udp_t.token_length; return (*opt == COAP_PAYLOAD_START) ? NULL : opt; } +#ifdef WITH_TCP else if(coap_tcp == transport && (pdu->hdr->coap_hdr_tcp_t.token + pdu->hdr->coap_hdr_tcp_t.token_length < (unsigned char *) pdu->hdr + pdu->length)) @@ -40,6 +41,7 @@ options_start(coap_pdu_t *pdu, coap_transport_type transport) pdu->hdr->coap_hdr_tcp_t.token_length; return (*opt == COAP_PAYLOAD_START) ? NULL : opt; } +#endif } else return NULL; @@ -145,6 +147,7 @@ coap_option_iterator_init(coap_pdu_t *pdu, coap_opt_iterator_t *oi, switch(transport) { +#ifdef WITH_TCP case coap_tcp: case coap_tcp_8bit: case coap_tcp_16bit: @@ -155,6 +158,7 @@ coap_option_iterator_init(coap_pdu_t *pdu, coap_opt_iterator_t *oi, token_length = pdu->hdr->coap_hdr_tcp_32bit_t.header_data[0] & 0x0f; headerSize = sizeof(pdu->hdr->coap_hdr_tcp_32bit_t); break; +#endif default: token_length = pdu->hdr->coap_hdr_udp_t.token_length; headerSize = sizeof(pdu->hdr->coap_hdr_udp_t); @@ -171,6 +175,7 @@ coap_option_iterator_init(coap_pdu_t *pdu, coap_opt_iterator_t *oi, return NULL; } } +#ifdef WITH_TCP else { if ((unsigned char *) &(pdu->hdr->coap_hdr_tcp_t) + pdu->length <= oi->next_option) @@ -179,6 +184,7 @@ coap_option_iterator_init(coap_pdu_t *pdu, coap_opt_iterator_t *oi, return NULL; } } +#endif assert((headerSize + token_length) <= pdu->length); @@ -481,4 +487,3 @@ size_t coap_opt_encode(coap_opt_t *opt, size_t maxlen, unsigned short delta, return l + length; } - diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.c b/resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.c index f1847d8..1975192 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.c +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.c @@ -58,11 +58,13 @@ void coap_pdu_clear(coap_pdu_t *pdu, size_t size, coap_transport_type transport, /* data is NULL unless explicitly set by coap_add_data() */ pdu->length = sizeof(pdu->hdr->coap_hdr_udp_t); } +#ifdef WITH_TCP else { /* data is NULL unless explicitly set by coap_add_data() */ pdu->length = length; } +#endif } #ifdef WITH_LWIP @@ -106,6 +108,7 @@ coap_pdu_init(unsigned char type, unsigned char code, unsigned short id, case coap_udp: length = sizeof(pdu->hdr->coap_hdr_udp_t); break; +#ifdef WITH_TCP case coap_tcp: length = COAP_TCP_HEADER_NO_FIELD; break; @@ -118,6 +121,7 @@ coap_pdu_init(unsigned char type, unsigned char code, unsigned short id, case coap_tcp_32bit: length = COAP_TCP_HEADER_32_BIT; break; +#endif default: debug("it has wrong type\n"); } @@ -160,6 +164,7 @@ coap_pdu_init(unsigned char type, unsigned char code, unsigned short id, pdu->hdr->coap_hdr_udp_t.type = type; pdu->hdr->coap_hdr_udp_t.code = code; break; +#ifdef WITH_TCP case coap_tcp: pdu->hdr->coap_hdr_tcp_t.message_length = 0; pdu->hdr->coap_hdr_tcp_t.code = code; @@ -178,6 +183,7 @@ coap_pdu_init(unsigned char type, unsigned char code, unsigned short id, pdu->hdr->coap_hdr_tcp_32bit_t.header_data[0] = COAP_TCP_LENGTH_FIELD_NUM_32_BIT << 4; pdu->hdr->coap_hdr_tcp_32bit_t.header_data[5] = code; break; +#endif default: debug("it has wrong type\n"); } @@ -223,6 +229,7 @@ void coap_delete_pdu(coap_pdu_t *pdu) #endif } +#ifdef WITH_TCP coap_transport_type coap_get_tcp_header_type_from_size(unsigned int size) { if (COAP_TCP_LENGTH_LIMIT_8_BIT < size && COAP_TCP_LENGTH_LIMIT_16_BIT >= size) @@ -329,6 +336,7 @@ unsigned int coap_get_length(const coap_pdu_t *pdu, coap_transport_type transpor return length; } +#endif void coap_add_code(const coap_pdu_t *pdu, coap_transport_type transport, unsigned int code) { @@ -339,6 +347,7 @@ void coap_add_code(const coap_pdu_t *pdu, coap_transport_type transport, unsigne case coap_udp: pdu->hdr->coap_hdr_udp_t.code = COAP_RESPONSE_CODE(code); break; +#ifdef WITH_TCP case coap_tcp: pdu->hdr->coap_hdr_tcp_t.code = COAP_RESPONSE_CODE(code); break; @@ -351,6 +360,7 @@ void coap_add_code(const coap_pdu_t *pdu, coap_transport_type transport, unsigne case coap_tcp_32bit: pdu->hdr->coap_hdr_tcp_32bit_t.header_data[5] = COAP_RESPONSE_CODE(code); break; +#endif default: debug("it has wrong type\n"); } @@ -366,6 +376,7 @@ unsigned int coap_get_code(const coap_pdu_t *pdu, coap_transport_type transport) case coap_udp: code = pdu->hdr->coap_hdr_udp_t.code; break; +#ifdef WITH_TCP case coap_tcp: code = pdu->hdr->coap_hdr_tcp_t.code; break; @@ -378,6 +389,7 @@ unsigned int coap_get_code(const coap_pdu_t *pdu, coap_transport_type transport) case coap_tcp_32bit: code = pdu->hdr->coap_hdr_tcp_32bit_t.header_data[5]; break; +#endif default: debug("it has wrong type\n"); } @@ -400,6 +412,7 @@ int coap_add_token(coap_pdu_t *pdu, size_t len, const unsigned char *data, token = pdu->hdr->coap_hdr_udp_t.token; pdu->length = HEADERLENGTH; break; +#ifdef WITH_TCP case coap_tcp: pdu->hdr->coap_hdr_tcp_t.token_length = len; token = pdu->hdr->coap_hdr_tcp_t.token; @@ -421,6 +434,7 @@ int coap_add_token(coap_pdu_t *pdu, size_t len, const unsigned char *data, token = pdu->hdr->coap_hdr_tcp_32bit_t.token; pdu->length = len + COAP_TCP_HEADER_32_BIT; break; +#endif default: debug("it has wrong type\n"); } @@ -449,6 +463,7 @@ void coap_get_token(const coap_hdr_t *pdu_hdr, coap_transport_type transport, *token_length = pdu_hdr->coap_hdr_udp_t.token_length; *token = (unsigned char *)pdu_hdr->coap_hdr_udp_t.token; break; +#ifdef WITH_TCP case coap_tcp: *token_length = pdu_hdr->coap_hdr_tcp_t.token_length; *token = (unsigned char *)pdu_hdr->coap_hdr_tcp_t.token; @@ -465,6 +480,7 @@ void coap_get_token(const coap_hdr_t *pdu_hdr, coap_transport_type transport, *token_length = (pdu_hdr->coap_hdr_tcp_32bit_t.header_data[0]) & 0x0f; *token = (unsigned char *)pdu_hdr->coap_hdr_tcp_32bit_t.token; break; +#endif default: debug("it has wrong type\n"); } @@ -488,6 +504,7 @@ size_t coap_add_option(coap_pdu_t *pdu, unsigned short type, unsigned int len, switch(transport) { +#ifdef WITH_TCP case coap_tcp: opt = (unsigned char *) &(pdu->hdr->coap_hdr_tcp_t) + pdu->length; break; @@ -500,6 +517,7 @@ size_t coap_add_option(coap_pdu_t *pdu, unsigned short type, unsigned int len, case coap_tcp_32bit: opt = (unsigned char *) &(pdu->hdr->coap_hdr_tcp_32bit_t) + pdu->length; break; +#endif default: opt = (unsigned char *) &(pdu->hdr->coap_hdr_udp_t) + pdu->length; break; @@ -691,6 +709,7 @@ int coap_pdu_parse(unsigned char *data, size_t length, coap_pdu_t *pdu, unsigned int headerSize = 0; switch(transport) { +#ifdef WITH_TCP case coap_tcp: headerSize = COAP_TCP_HEADER_NO_FIELD; break; @@ -703,6 +722,7 @@ int coap_pdu_parse(unsigned char *data, size_t length, coap_pdu_t *pdu, case coap_tcp_32bit: headerSize = COAP_TCP_HEADER_32_BIT; break; +#endif default: headerSize = sizeof(pdu->hdr->coap_hdr_udp_t); break; @@ -715,6 +735,7 @@ int coap_pdu_parse(unsigned char *data, size_t length, coap_pdu_t *pdu, coap_opt_t *opt = NULL; unsigned int tokenLength = 0; +#ifdef WITH_TCP switch(transport) { case coap_tcp: @@ -753,6 +774,7 @@ int coap_pdu_parse(unsigned char *data, size_t length, coap_pdu_t *pdu, default: debug("it has wrong type\n"); } +#endif pdu->length = length; if (coap_udp == transport) @@ -793,6 +815,7 @@ int coap_pdu_parse(unsigned char *data, size_t length, coap_pdu_t *pdu, length -= (tokenLength + headerSize); opt = (unsigned char *) (&(pdu->hdr->coap_hdr_udp_t) + 1) + tokenLength; } +#ifdef WITH_TCP else // common for tcp header setting { pdu->data = NULL; @@ -812,6 +835,7 @@ int coap_pdu_parse(unsigned char *data, size_t length, coap_pdu_t *pdu, /* skip header + token */ length -= (tokenLength + headerSize); } +#endif while (length && *opt != COAP_PAYLOAD_START) { diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.h b/resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.h index bb94e4d..d28a40d 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.h +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.h @@ -27,8 +27,12 @@ #ifdef WITH_ARDUINO #define COAP_MAX_PDU_SIZE 320 /* maximum size of a CoAP PDU for embedded platforms*/ #else +#ifdef WITH_TCP +#define COAP_MAX_PDU_SIZE 65536 /* maximum size of a CoAP PDU for big platforms*/ +#else #define COAP_MAX_PDU_SIZE 1400 /* maximum size of a CoAP PDU for big platforms*/ #endif +#endif #endif /* COAP_MAX_PDU_SIZE */ #define COAP_DEFAULT_VERSION 1 /* version of CoAP supported */ @@ -274,7 +278,7 @@ typedef union struct { - unsigned char header_data[6]; /* coap header which 32bit payload length*/ + unsigned char header_data[6]; unsigned char token[]; /* the actual token, if any */ } coap_hdr_tcp_32bit_t; @@ -405,6 +409,7 @@ void coap_delete_pdu(coap_pdu_t *); int coap_pdu_parse(unsigned char *data, size_t length, coap_pdu_t *pdu, coap_transport_type transport); +#ifdef WITH_TCP /** * Get transport type of coap header for coap over tcp through payload size. * @@ -439,6 +444,7 @@ void coap_add_length(const coap_pdu_t *pdu, coap_transport_type transport, * @return length value of init byte. */ unsigned int coap_get_length(const coap_pdu_t *pdu, coap_transport_type transport); +#endif /** * Add code in coap header. @@ -498,7 +504,7 @@ size_t coap_add_option(coap_pdu_t *pdu, unsigned short type, unsigned int len, /** * Adds option of given type to pdu that is passed as first - * parameter, but does not write a value. It works like coap_add_option with + * parameter, but does not write a val13ue. It works like coap_add_option with * respect to calling sequence (i.e. after token and before data). * This function returns a memory address to which the option data has to be * written before the PDU can be sent, or @c NULL on error.