From d4059f74b7550647fa49213e6c35f4b865e0465f Mon Sep 17 00:00:00 2001 From: Lokesh B V Date: Thu, 17 Aug 2017 13:09:37 +0530 Subject: [PATCH] Fix Coding Rule Violation: Remove trailing white spaces. Signed-off-by: Lokesh B V --- .../examples/lwm2m_test/object_connectivity_moni.c | 2 +- apps/examples/lwm2m_test/object_location.c | 2 +- .../testcase/le_tc/kernel/tc_libc_pthread.c | 4 +- apps/examples/testcase/le_tc/kernel/tc_pthread.c | 2 +- .../ta_tc/device_management/utc/utc_dm_main.c | 2 +- apps/examples/wakaama_client/wakaama_client.c | 4 +- apps/netutils/libcoap/resource.c | 2 +- .../c_common/octhread/src/windows/octhread.c | 2 +- .../resource/csdk/stack/src/ocpayload.c | 2 +- .../tizen-sdb/EnrolleeSample/easysetup_wifi_conn.c | 8 +- .../src/provider/NSProviderScheduler.c | 10 +- external/wakaama/core/bootstrap.c | 2 +- external/wakaama/core/discover.c | 2 +- external/wakaama/core/liblwm2m.c | 2 +- external/wakaama/core/list.c | 2 +- external/wakaama/core/management.c | 2 +- external/wakaama/core/objects.c | 6 +- external/wakaama/core/observe.c | 2 +- external/wakaama/core/registration.c | 4 +- external/wakaama/core/tlv.c | 4 +- external/wakaama/core/transaction.c | 4 +- external/wakaama/core/uri.c | 2 +- external/wakaama/core/utils.c | 8 +- .../examples/client/common_monitor_interface.c | 52 ++--- .../examples/client/connectivity_interface.c | 68 +++--- .../examples/client/object_access_control.c | 4 +- .../examples/client/object_connectivity_moni.c | 14 +- .../examples/client/object_connectivity_stat.c | 4 +- external/wakaama/examples/client/object_device.c | 18 +- external/wakaama/examples/client/object_firmware.c | 2 +- external/wakaama/examples/client/object_location.c | 28 +-- external/wakaama/examples/client/object_security.c | 6 +- external/wakaama/examples/client/object_server.c | 2 +- external/wakaama/examples/client/test_object.c | 2 +- .../wakaama/examples/lightclient/object_device.c | 6 +- .../wakaama/examples/lightclient/object_security.c | 2 +- .../wakaama/examples/lightclient/object_server.c | 2 +- .../wakaama/examples/lightclient/test_object.c | 2 +- external/wakaama/examples/shared/commandline.c | 2 +- external/wakaama/examples/shared/connection.c | 2 +- external/wakaama/examples/shared/tinydtls/ccm.c | 58 ++--- external/wakaama/examples/shared/tinydtls/crypto.c | 44 ++-- external/wakaama/examples/shared/tinydtls/dtls.c | 238 ++++++++++----------- .../wakaama/examples/shared/tinydtls/dtls_debug.c | 48 ++--- .../wakaama/examples/shared/tinydtls/dtls_time.c | 6 +- .../wakaama/examples/shared/tinydtls/ecc/ecc.c | 130 +++++------ .../wakaama/examples/shared/tinydtls/ecc/testecc.c | 6 +- .../shared/tinydtls/examples/contiki/dtls-client.c | 8 +- .../shared/tinydtls/examples/contiki/dtls-server.c | 10 +- external/wakaama/examples/shared/tinydtls/hmac.c | 10 +- external/wakaama/examples/shared/tinydtls/netq.c | 10 +- .../wakaama/examples/shared/tinydtls/session.c | 14 +- .../wakaama/examples/shared/tinydtls/sha2/sha2.c | 10 +- .../examples/shared/tinydtls/sha2/sha2prog.c | 4 +- .../examples/shared/tinydtls/sha2/sha2speed.c | 6 +- .../examples/shared/tinydtls/tests/ccm-test.c | 22 +- .../examples/shared/tinydtls/tests/ccm-testdata.c | 22 +- .../examples/shared/tinydtls/tests/dtls-client.c | 40 ++-- .../examples/shared/tinydtls/tests/dtls-server.c | 26 +-- .../examples/shared/tinydtls/tests/prf-test.c | 8 +- os/kernel/pthread/pthread_mutexlock.c | 6 +- os/kernel/pthread/pthread_mutextrylock.c | 6 +- os/kernel/wdog/wd_delete.c | 2 +- os/net/tls/ssl_cli.c | 4 +- 64 files changed, 517 insertions(+), 517 deletions(-) diff --git a/apps/examples/lwm2m_test/object_connectivity_moni.c b/apps/examples/lwm2m_test/object_connectivity_moni.c index ff33829..93e0270 100644 --- a/apps/examples/lwm2m_test/object_connectivity_moni.c +++ b/apps/examples/lwm2m_test/object_connectivity_moni.c @@ -56,7 +56,7 @@ #define RES_O_SMNC 9 #define RES_O_SMCC 10 -#define VALUE_NETWORK_BEARER_GSM 0 //GSM see +#define VALUE_NETWORK_BEARER_GSM 0 //GSM see #define VALUE_AVL_NETWORK_BEARER_1 0 //GSM #define VALUE_AVL_NETWORK_BEARER_2 21 //WLAN #define VALUE_AVL_NETWORK_BEARER_3 41 //Ethernet diff --git a/apps/examples/lwm2m_test/object_location.c b/apps/examples/lwm2m_test/object_location.c index 53838da..b20527e 100644 --- a/apps/examples/lwm2m_test/object_location.c +++ b/apps/examples/lwm2m_test/object_location.c @@ -67,7 +67,7 @@ #define HORIZONTAL_VELOCITY_VERTICAL 1 // set vertical direction bit! #define HORIZONTAL_VELOCITY_WITH_UNCERTAINTY 2 -#define VELOCITY_OCTETS 5 // for HORIZONTAL_VELOCITY_WITH_UNCERTAINTY +#define VELOCITY_OCTETS 5 // for HORIZONTAL_VELOCITY_WITH_UNCERTAINTY typedef struct { float latitude; diff --git a/apps/examples/testcase/le_tc/kernel/tc_libc_pthread.c b/apps/examples/testcase/le_tc/kernel/tc_libc_pthread.c index ed61b23..7f4d688 100644 --- a/apps/examples/testcase/le_tc/kernel/tc_libc_pthread.c +++ b/apps/examples/testcase/le_tc/kernel/tc_libc_pthread.c @@ -1232,7 +1232,7 @@ static void tc_libc_pthread_pthread_rwlock_trywrlock(void) /** * @fn :tc_libc_pthread_pthread_setcancelstate * @brief :This tc tests pthread_setcancelstate() -* @Scenario :The function shall atomically both set the calling thread's cancelability state to the indicated state +* @Scenario :The function shall atomically both set the calling thread's cancelability state to the indicated state * and return the previous cancelability state at the location referenced by oldstate * If successful pthread_setcancelstate() function shall return zero; * otherwise, an error number shall be returned to indicate the error. @@ -1261,7 +1261,7 @@ static void tc_libc_pthread_pthread_setcancelstate(void) /** * @fn :tc_libc_pthread_pthread_setcanceltype * @brief :This tc tests pthread_setcanceltype() -* @Scenario :The function shall atomically both set the calling thread's cancelability type to the indicated type +* @Scenario :The function shall atomically both set the calling thread's cancelability type to the indicated type * and return the previous cancelability type at the location referenced by oldtype * If successful pthread_setcanceltype() function shall return zero; * otherwise, an error number shall be returned to indicate the error. diff --git a/apps/examples/testcase/le_tc/kernel/tc_pthread.c b/apps/examples/testcase/le_tc/kernel/tc_pthread.c index b1a3031..9966b75 100644 --- a/apps/examples/testcase/le_tc/kernel/tc_pthread.c +++ b/apps/examples/testcase/le_tc/kernel/tc_pthread.c @@ -1465,7 +1465,7 @@ static void tc_pthread_pthread_setgetname_np(void) /** * @fn :tc_pthread_pthread_setcanceltype * @brief :This tc tests pthread_setcanceltype() -* @Scenario :The function shall atomically both set the calling thread's cancelability type to the indicated type +* @Scenario :The function shall atomically both set the calling thread's cancelability type to the indicated type * and return the previous cancelability type at the location referenced by oldtype * If successful pthread_setcanceltype() function shall return zero; * otherwise, an error number shall be returned to indicate the error. diff --git a/apps/examples/testcase/ta_tc/device_management/utc/utc_dm_main.c b/apps/examples/testcase/ta_tc/device_management/utc/utc_dm_main.c index e15d7bf..6c68c94 100644 --- a/apps/examples/testcase/ta_tc/device_management/utc/utc_dm_main.c +++ b/apps/examples/testcase/ta_tc/device_management/utc/utc_dm_main.c @@ -145,7 +145,7 @@ static int wifiAutoConnect(void) if (waitTime <= 0) { printf("[AutoConnect]WiFi is not working. Test Canceled\n"); return 0; - } + } return 1; } return ret; diff --git a/apps/examples/wakaama_client/wakaama_client.c b/apps/examples/wakaama_client/wakaama_client.c index 6abf754..7ab6af8 100644 --- a/apps/examples/wakaama_client/wakaama_client.c +++ b/apps/examples/wakaama_client/wakaama_client.c @@ -109,7 +109,7 @@ void app_print_usage(void) } static void prv_wakaama_start(void) -{ +{ if (dm_lwm2m_start_client(&dm_context) != DM_ERROR_NONE) { fprintf(stderr, "Error creating wakaama thread\n"); } else { @@ -295,7 +295,7 @@ int wakaamaclient_main(int argc, char *argv[]) } sleep(10); if (dm_conn_get_scan_result(&appwifiscan_result) == DM_ERROR_NONE) { - wifi_iterator = appwifiscan_result; + wifi_iterator = appwifiscan_result; while (wifi_iterator != NULL) { for (i = 0; i < sizeof(wifi_aps) / sizeof(char *); i++) { if (!strncmp(wifi_iterator->ssid, wifi_aps[i], strlen(wifi_aps[i]))) { diff --git a/apps/netutils/libcoap/resource.c b/apps/netutils/libcoap/resource.c index 63e515e..eb06722 100644 --- a/apps/netutils/libcoap/resource.c +++ b/apps/netutils/libcoap/resource.c @@ -77,7 +77,7 @@ static inline void coap_free_subscription(coap_subscription_t *subscription) } else { \ (Offset)--; \ } \ - + /** * Adds Char to Buf if Offset is zero and Buf is less than Bufend. */ diff --git a/external/iotivity/iotivity_1.2-rel/resource/c_common/octhread/src/windows/octhread.c b/external/iotivity/iotivity_1.2-rel/resource/c_common/octhread/src/windows/octhread.c index 2613883..18c41a7 100644 --- a/external/iotivity/iotivity_1.2-rel/resource/c_common/octhread/src/windows/octhread.c +++ b/external/iotivity/iotivity_1.2-rel/resource/c_common/octhread/src/windows/octhread.c @@ -264,7 +264,7 @@ OCWaitResult_t oc_cond_wait_for(oc_cond cond, oc_mutex mutex, uint64_t microseco milli = INFINITE; } - // Wait for the given time + // Wait for the given time if (!SleepConditionVariableCS(&eventInfo->cond, &mutexInfo->mutex, milli)) { if (GetLastError() == ERROR_TIMEOUT) diff --git a/external/iotivity/iotivity_1.2-rel/resource/csdk/stack/src/ocpayload.c b/external/iotivity/iotivity_1.2-rel/resource/csdk/stack/src/ocpayload.c index 8a91935..c12513e 100644 --- a/external/iotivity/iotivity_1.2-rel/resource/csdk/stack/src/ocpayload.c +++ b/external/iotivity/iotivity_1.2-rel/resource/csdk/stack/src/ocpayload.c @@ -248,7 +248,7 @@ static void OCFreeRepPayloadValueContents(OCRepPayloadValue* val) OICFree(val->arr.iArray); break; case OCREP_PROP_STRING: - if (val->arr.strArray != NULL) + if (val->arr.strArray != NULL) { for(size_t i = 0; i < dimTotal; ++i) { diff --git a/external/iotivity/iotivity_1.2-rel/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/easysetup_wifi_conn.c b/external/iotivity/iotivity_1.2-rel/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/easysetup_wifi_conn.c index d8ff9fd..fcaedf8 100644 --- a/external/iotivity/iotivity_1.2-rel/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/easysetup_wifi_conn.c +++ b/external/iotivity/iotivity_1.2-rel/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/easysetup_wifi_conn.c @@ -108,10 +108,10 @@ static void WiFiActivateCallback(wifi_error_e result, void* user_data) static void ConnectedCallback(wifi_error_e err, void* data) { if(err == WIFI_ERROR_NONE) { - OIC_LOG(DEBUG, ES_WIFICONN_TAG, "Success to Connect AP"); + OIC_LOG(DEBUG, ES_WIFICONN_TAG, "Success to Connect AP"); } else { - OIC_LOG(ERROR, ES_WIFICONN_TAG, "Fail to Connect AP"); + OIC_LOG(ERROR, ES_WIFICONN_TAG, "Fail to Connect AP"); } } @@ -152,13 +152,13 @@ static bool WiFiFoundCallback(wifi_ap_h ap, void *data) OIC_LOG(ERROR, ES_WIFICONN_TAG, "Fail to connect wifi"); OIC_LOG_V(INFO, ES_WIFICONN_TAG, "Connect Fail Status : %s", PrintWifiErr((wifi_error_e) ret)); g_free(foundAP); - return false; + return false; } else { OIC_LOG_V(INFO, ES_WIFICONN_TAG, "Success to connect wifi : %s", PrintWifiErr((wifi_error_e) ret)); gWiFiConnFlag = true; g_free(foundAP); - return false; + return false; } diff --git a/external/iotivity/iotivity_1.2-rel/service/notification/src/provider/NSProviderScheduler.c b/external/iotivity/iotivity_1.2-rel/service/notification/src/provider/NSProviderScheduler.c index 3552999..cd48661 100755 --- a/external/iotivity/iotivity_1.2-rel/service/notification/src/provider/NSProviderScheduler.c +++ b/external/iotivity/iotivity_1.2-rel/service/notification/src/provider/NSProviderScheduler.c @@ -58,11 +58,11 @@ bool NSInitScheduler() #ifdef __TIZENRT__ -static int -embos_pthread_create(pthread_t *thread, - pthread_attr_t *attr, - pthread_startroutine_t start_routine, - pthread_addr_t arg, +static int +embos_pthread_create(pthread_t *thread, + pthread_attr_t *attr, + pthread_startroutine_t start_routine, + pthread_addr_t arg, const char *task_name, int stack_size) { /* All callers have null attr, so ignore it for simple implementation*/ diff --git a/external/wakaama/core/bootstrap.c b/external/wakaama/core/bootstrap.c index 7829628..823857e 100644 --- a/external/wakaama/core/bootstrap.c +++ b/external/wakaama/core/bootstrap.c @@ -430,7 +430,7 @@ coap_status_t bootstrap_handleCommand(lwm2m_context_t * contextP, prv_tagServer(contextP, dataP[i].id); } } - + if(result != COAP_204_CHANGED) // Stop object create or write when result is error { break; diff --git a/external/wakaama/core/discover.c b/external/wakaama/core/discover.c index e29e28e..a0f6384 100644 --- a/external/wakaama/core/discover.c +++ b/external/wakaama/core/discover.c @@ -323,7 +323,7 @@ int discover_serialize(lwm2m_context_t * contextP, // get object level attributes objParamP = prv_findAttributes(contextP, &tempUri, serverP); - + // get object instance level attributes tempUri.instanceId = uriP->instanceId; tempUri.flag = LWM2M_URI_FLAG_INSTANCE_ID; diff --git a/external/wakaama/core/liblwm2m.c b/external/wakaama/core/liblwm2m.c index e689e7d..41a6b34 100644 --- a/external/wakaama/core/liblwm2m.c +++ b/external/wakaama/core/liblwm2m.c @@ -16,7 +16,7 @@ * Simon Bernard - Please refer to git log * Toby Jaffey - Please refer to git log * Pascal Rieux - Please refer to git log - * + * *******************************************************************************/ /* diff --git a/external/wakaama/core/list.c b/external/wakaama/core/list.c index d7532b4..5264542 100644 --- a/external/wakaama/core/list.c +++ b/external/wakaama/core/list.c @@ -12,7 +12,7 @@ * * Contributors: * David Navarro, Intel Corporation - initial API and implementation - * + * *******************************************************************************/ #include "internals.h" diff --git a/external/wakaama/core/management.c b/external/wakaama/core/management.c index 008521d..23beb22 100644 --- a/external/wakaama/core/management.c +++ b/external/wakaama/core/management.c @@ -16,7 +16,7 @@ * Toby Jaffey - Please refer to git log * Bosch Software Innovations GmbH - Please refer to git log * Pascal Rieux - Please refer to git log - * + * *******************************************************************************/ /* Copyright (c) 2013, 2014 Intel Corporation diff --git a/external/wakaama/core/objects.c b/external/wakaama/core/objects.c index 4883b31..b04606e 100644 --- a/external/wakaama/core/objects.c +++ b/external/wakaama/core/objects.c @@ -17,7 +17,7 @@ * Benjamin Cabé - Please refer to git log * Bosch Software Innovations GmbH - Please refer to git log * Pascal Rieux - Please refer to git log - * + * *******************************************************************************/ /* @@ -798,7 +798,7 @@ coap_status_t object_createInstance(lwm2m_context_t * contextP, targetP = (lwm2m_object_t *)LWM2M_LIST_FIND(contextP->objectList, uriP->objectId); if (NULL == targetP) return COAP_404_NOT_FOUND; - if (NULL == targetP->createFunc) + if (NULL == targetP->createFunc) { return COAP_405_METHOD_NOT_ALLOWED; } @@ -816,7 +816,7 @@ coap_status_t object_writeInstance(lwm2m_context_t * contextP, targetP = (lwm2m_object_t *)LWM2M_LIST_FIND(contextP->objectList, uriP->objectId); if (NULL == targetP) return COAP_404_NOT_FOUND; - if (NULL == targetP->writeFunc) + if (NULL == targetP->writeFunc) { return COAP_405_METHOD_NOT_ALLOWED; } diff --git a/external/wakaama/core/observe.c b/external/wakaama/core/observe.c index 19f985a..cfdd1f1 100644 --- a/external/wakaama/core/observe.c +++ b/external/wakaama/core/observe.c @@ -14,7 +14,7 @@ * David Navarro, Intel Corporation - initial API and implementation * Toby Jaffey - Please refer to git log * Bosch Software Innovations GmbH - Please refer to git log - * + * *******************************************************************************/ /* diff --git a/external/wakaama/core/registration.c b/external/wakaama/core/registration.c index 23a9bfa..582a4a0 100644 --- a/external/wakaama/core/registration.c +++ b/external/wakaama/core/registration.c @@ -409,7 +409,7 @@ uint8_t registration_start(lwm2m_context_t * contextP) uint8_t result; LOG_ARG("State: %s", STR_STATE(contextP->state)); - + result = COAP_NO_ERROR; targetP = contextP->serverList; @@ -788,7 +788,7 @@ static int prv_getId(uint8_t * data, { data += 1; length -= 2; - } + } else { return 0; diff --git a/external/wakaama/core/tlv.c b/external/wakaama/core/tlv.c index 2bad1b0..e9b4a8d 100644 --- a/external/wakaama/core/tlv.c +++ b/external/wakaama/core/tlv.c @@ -14,7 +14,7 @@ * David Navarro, Intel Corporation - initial API and implementation * Fabien Fleutot - Please refer to git log * Bosch Software Innovations GmbH - Please refer to git log - * + * *******************************************************************************/ #include "internals.h" @@ -386,7 +386,7 @@ static int prv_getLength(int size, } -int tlv_serialize(bool isResourceInstance, +int tlv_serialize(bool isResourceInstance, int size, lwm2m_data_t * dataP, uint8_t ** bufferP) diff --git a/external/wakaama/core/transaction.c b/external/wakaama/core/transaction.c index 226cf3e..5aff2e4 100644 --- a/external/wakaama/core/transaction.c +++ b/external/wakaama/core/transaction.c @@ -322,14 +322,14 @@ bool transaction_handleResponse(lwm2m_context_t * contextP, coap_init_message(response, proto, COAP_TYPE_ACK, 0, message->mid); message_send(contextP, response, fromSessionH); } - + if ((COAP_401_UNAUTHORIZED == message->code) && (COAP_MAX_RETRANSMIT > transacP->retrans_counter)) { transacP->ack_received = false; transacP->retrans_time += COAP_RESPONSE_TIMEOUT; return true; } - } + } if (transacP->callback != NULL) { transacP->callback(transacP, message); diff --git a/external/wakaama/core/uri.c b/external/wakaama/core/uri.c index 3a5a9e6..05915e7 100644 --- a/external/wakaama/core/uri.c +++ b/external/wakaama/core/uri.c @@ -16,7 +16,7 @@ * Toby Jaffey - Please refer to git log * Bosch Software Innovations GmbH - Please refer to git log * Pascal Rieux - Please refer to git log - * + * *******************************************************************************/ /* diff --git a/external/wakaama/core/utils.c b/external/wakaama/core/utils.c index f984518..4f3dcf7 100644 --- a/external/wakaama/core/utils.c +++ b/external/wakaama/core/utils.c @@ -13,7 +13,7 @@ * Contributors: * David Navarro, Intel Corporation - initial API and implementation * Toby Jaffey - Please refer to git log - * + * *******************************************************************************/ /* @@ -526,7 +526,7 @@ int utils_intCopy(char * buffer, void utils_copyValue(void * dst, const void * src, size_t len) -{ +{ #ifdef LWM2M_BIG_ENDIAN memcpy(dst, src, len); #else @@ -756,7 +756,7 @@ static size_t prv_getBase64Size(size_t dataLen) } size_t utils_base64Encode(uint8_t * dataP, - size_t dataLen, + size_t dataLen, uint8_t * bufferP, size_t bufferLen) { @@ -820,7 +820,7 @@ size_t utils_opaqueToBase64(uint8_t * dataP, lwm2m_free(*bufferP); *bufferP = NULL; } - + return result_len; } diff --git a/external/wakaama/examples/client/common_monitor_interface.c b/external/wakaama/examples/client/common_monitor_interface.c index 2c4a643..bce9b5e 100644 --- a/external/wakaama/examples/client/common_monitor_interface.c +++ b/external/wakaama/examples/client/common_monitor_interface.c @@ -11,10 +11,10 @@ int readonce(FAR const char *filename, FAR char *buffer, uint8_t buflen) { int ret; - + printf("opening %s\n", filename); int fd = open(filename, O_RDONLY); - + memset(buffer, 0x00, buflen); if (fd < 0) { @@ -23,34 +23,34 @@ int readonce(FAR const char *filename, FAR char *buffer, uint8_t buflen) } else { - size_t nbytes; - - + size_t nbytes; + + /* Read until we hit the end of the file, until we have exhausted the * buffer space, or until some irrecoverable error occurs */ *buffer = '\0'; /* NUL terminate the empty buffer */ ret = ERROR; /* Assume failure */ - - nbytes = read(fd, buffer, buflen); + + nbytes = read(fd, buffer, buflen); printf("%d bytes read\n", nbytes); if (nbytes < 0) { /* Read error */ - + int errcode = errno; DEBUGASSERT(errcode > 0); - + /* EINTR is not a read error. It simply means that a signal was * received while waiting for the read to complete. */ - + if (errcode != EINTR) { /* Fatal error */ - - printf("EINTR error\n"); + + printf("EINTR error\n"); } } else if (nbytes >= 0) @@ -60,7 +60,7 @@ int readonce(FAR const char *filename, FAR char *buffer, uint8_t buflen) } } - + /* Close the file and return. */ close(fd); @@ -74,10 +74,10 @@ int readfile(FAR const char *filename, FAR char *buffer, uint8_t buflen) //ssize_t nread; ssize_t ntotal; int ret; - + printf("opening %s\n", filename); int fd = open(filename, O_RDONLY); - + if (fd < 0) { printf("error reading file %s\n", filename); @@ -85,9 +85,9 @@ int readfile(FAR const char *filename, FAR char *buffer, uint8_t buflen) } else { - size_t nbytes; - - + size_t nbytes; + + /* Read until we hit the end of the file, until we have exhausted the * buffer space, or until some irrecoverable error occurs */ @@ -97,25 +97,25 @@ int readfile(FAR const char *filename, FAR char *buffer, uint8_t buflen) bufptr = buffer; /* Working pointer */ remaining = buflen - 1; /* Reserve one byte for a NUL terminator */ ret = ERROR; /* Assume failure */ - + do { - nbytes = read(fd, buffer, buflen); + nbytes = read(fd, buffer, buflen); printf("%d bytes read\n", nbytes); if (nbytes < 0) { /* Read error */ - + int errcode = errno; DEBUGASSERT(errcode > 0); - + /* EINTR is not a read error. It simply means that a signal was * received while waiting for the read to complete. */ - + if (errcode != EINTR) { /* Fatal error */ - + printf("EINTR error\n"); break; } @@ -144,7 +144,7 @@ int readfile(FAR const char *filename, FAR char *buffer, uint8_t buflen) } } while (buflen > 0); } - + /* Close the file and return. */ close(fd); @@ -153,7 +153,7 @@ int readfile(FAR const char *filename, FAR char *buffer, uint8_t buflen) void mount_procfs(void) { - int ret; + int ret; ret = mount(NULL, PROC_MOUNTPOINT, "procfs", 0, NULL); } diff --git a/external/wakaama/examples/client/connectivity_interface.c b/external/wakaama/examples/client/connectivity_interface.c index 6e6b4a2..fe43ed7 100644 --- a/external/wakaama/examples/client/connectivity_interface.c +++ b/external/wakaama/examples/client/connectivity_interface.c @@ -31,12 +31,12 @@ char cm_iobuffer[PROC_BUFFER_LEN]; * * Description: * Get the underlined interface name - * + * * * Returned Value: * ****************************************************************************/ - + void get_interface_name(char *mac) { #if defined(CONFIG_WICED) @@ -58,23 +58,23 @@ void get_interface_name(char *mac) * Fetch IPv4/IPv6 address * * Returned Value: - * + * * ****************************************************************************/ - + void get_ip_address(char *ipAddr) { - int ret; + int ret; char *filepath; ret = mount(NULL, PROC_MOUNTPOINT, "procfs", 0, NULL); printf("mount returns value %d\n", ret); ret = asprintf(&filepath, "%s/connectivity/ipaddr", PROC_MOUNTPOINT); ret = readonce(filepath, cm_iobuffer, PROC_BUFFER_LEN); - strncpy(ipAddr, cm_iobuffer, strlen(cm_iobuffer)); + strncpy(ipAddr, cm_iobuffer, strlen(cm_iobuffer)); if (ret == OK) { printf("IP addr is %s\n", ipAddr); - } + } } /**************************************************************************** @@ -84,40 +84,40 @@ void get_ip_address(char *ipAddr) * Get the router IPv4/IPv6 address * * Returned Value: - * + * * ****************************************************************************/ - + void get_router_ip_address(char *routerIPAddr) { char mac[4]; get_interface_name(mac); -#ifdef CONFIG_NET_IPv4 +#ifdef CONFIG_NET_IPv4 struct in_addr addr; netlib_get_dripv4addr(mac,addr); inet_ntop(AF_INET, &addr, routerIPAddr, INET_ADDRSTRLEN); #endif #ifdef CONFIG_NET_IPv6 struct in6_addr addr; - netlib_get_dripv6addr(mac,addr); - inet_ntop(AF_INET6, &addr, routerIPAddr, INET6_ADDRSTRLEN); -#endif + netlib_get_dripv6addr(mac,addr); + inet_ntop(AF_INET6, &addr, routerIPAddr, INET6_ADDRSTRLEN); +#endif } /**************************************************************************** * Name: get_signal_strength * * Description: - * Get Signal Strength value (RSSI in case of IEEE 802.15.4) + * Get Signal Strength value (RSSI in case of IEEE 802.15.4) * * Returned Value: * Return the appropriate Callback flags * ****************************************************************************/ - + void get_signal_strength(int *rssi_value) { - int ret; + int ret; char *filepath; ret = mount(NULL, PROC_MOUNTPOINT, "procfs", 0, NULL); printf("mount returns value %d\n", ret); @@ -128,7 +128,7 @@ void get_signal_strength(int *rssi_value) // *rssi_value = atoi(cm_iobuffer); sscanf(cm_iobuffer, "%d", rssi_value); printf("rssi is %d\n", *rssi_value); - } + } } /**************************************************************************** @@ -138,7 +138,7 @@ void get_signal_strength(int *rssi_value) * Get link quality index value from MAC/PHY * * Returned Value: - * + * * ****************************************************************************/ @@ -157,10 +157,10 @@ int get_lqi() * Get link utilization statictics from MAC/PHY * * Returned Value: - * + * * ****************************************************************************/ - + int get_link_utilization() { return 0; @@ -174,10 +174,10 @@ int get_link_utilization() * Get tx data value from MAC/PHY * * Returned Value: - * + * * ****************************************************************************/ - + int get_tx_data() { //TODO: Feature implementation @@ -191,10 +191,10 @@ int get_tx_data() * Get rx data value from MAC/PHY * * Returned Value: - * + * * ****************************************************************************/ - + int get_rx_data() { ///TODO: Feature implementation @@ -208,7 +208,7 @@ int get_rx_data() * Get maximum message size * * Returned Value: - * + * * ****************************************************************************/ int get_max_message_size() @@ -225,12 +225,12 @@ int get_rx_data() * Get bitrate * * Returned Value: - * * - ****************************************************************************/ + * + ****************************************************************************/ void get_bitrate(int *bitrate) { - int ret; + int ret; char *filepath; ret = mount(NULL, PROC_MOUNTPOINT, "procfs", 0, NULL); printf("mount returns value %d\n", ret); @@ -239,7 +239,7 @@ int get_rx_data() if (ret == OK) { *bitrate = atoi(cm_iobuffer); - } + } } /**************************************************************************** @@ -249,12 +249,12 @@ int get_rx_data() * Get Network Bearer * * Returned Value: - * * - ****************************************************************************/ + * + ****************************************************************************/ void get_network_bearer(int *nwbearer) { - int ret; + int ret; char *filepath; ret = mount(NULL, PROC_MOUNTPOINT, "procfs", 0, NULL); printf("mount returns value %d\n", ret); @@ -271,12 +271,12 @@ void get_network_bearer(int *nwbearer) * Get Available Network Bearer * * Returned Value: - * + * * ****************************************************************************/ void get_avl_network_bearer(int *nwbearer) { - int ret; + int ret; char *filepath; ret = mount(NULL, PROC_MOUNTPOINT, "procfs", 0, NULL); printf("mount returns value %d\n", ret); diff --git a/external/wakaama/examples/client/object_access_control.c b/external/wakaama/examples/client/object_access_control.c index 2bb25e6..310b781 100644 --- a/external/wakaama/examples/client/object_access_control.c +++ b/external/wakaama/examples/client/object_access_control.c @@ -13,12 +13,12 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log * Pascal Rieux - please refer to git log - * + * ******************************************************************************/ /* * This "Access Control" object is optional and multiple instantiated - * + * * Resources: * * Name | ID | Oper. | Inst. | Mand.| Type | Range | Units | diff --git a/external/wakaama/examples/client/object_connectivity_moni.c b/external/wakaama/examples/client/object_connectivity_moni.c index b0c3168..4cbd3f5 100644 --- a/external/wakaama/examples/client/object_connectivity_moni.c +++ b/external/wakaama/examples/client/object_connectivity_moni.c @@ -1,6 +1,6 @@ /******************************************************************************* * - * Copyright (c) 2014 Bosch Software Innovations GmbH Germany. + * Copyright (c) 2014 Bosch Software Innovations GmbH Germany. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -13,12 +13,12 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log * Pascal Rieux - Please refer to git log - * + * *******************************************************************************/ /* * This Connectivity Monitoring object is optional and has a single instance - * + * * Resources: * * Name | ID | Oper. | Inst. | Mand.| Type | Range | Units | @@ -57,7 +57,7 @@ #define RES_O_SMNC 9 #define RES_O_SMCC 10 -#define VALUE_NETWORK_BEARER_GSM 0 //GSM see +#define VALUE_NETWORK_BEARER_GSM 0 //GSM see #define VALUE_AVL_NETWORK_BEARER_1 0 //GSM #define VALUE_AVL_NETWORK_BEARER_2 21 //WLAN #define VALUE_AVL_NETWORK_BEARER_3 41 //Ethernet @@ -71,7 +71,7 @@ #define VALUE_APN_2 "cda.vodafone.de" #define VALUE_CELL_ID 69696969 #define VALUE_RADIO_SIGNAL_STRENGTH 80 //dBm -#define VALUE_LINK_QUALITY 98 +#define VALUE_LINK_QUALITY 98 #define VALUE_LINK_UTILIZATION 666 #define VALUE_SMNC 33 #define VALUE_SMCC 44 @@ -250,7 +250,7 @@ lwm2m_object_t * get_object_conn_m(void) * It assigns his unique ID */ connObj->objID = LWM2M_CONN_MONITOR_OBJECT_ID; - + /* * and its unique instance * @@ -265,7 +265,7 @@ lwm2m_object_t * get_object_conn_m(void) lwm2m_free(connObj); return NULL; } - + /* * And the private function that will access the object. * Those function will be called when a read/write/execute query is made by the server. In fact the library don't need to diff --git a/external/wakaama/examples/client/object_connectivity_stat.c b/external/wakaama/examples/client/object_connectivity_stat.c index 939b32b..2461541 100644 --- a/external/wakaama/examples/client/object_connectivity_stat.c +++ b/external/wakaama/examples/client/object_connectivity_stat.c @@ -12,12 +12,12 @@ * * Contributors: * Bosch Software Innovations GmbH - Please refer to git log - * + * *******************************************************************************/ /* * This connectivity statistics object is optional and single instance only - * + * * Resources: * * Name | ID | Oper. | Inst. | Mand.| Type | Range | Units | Description | diff --git a/external/wakaama/examples/client/object_device.c b/external/wakaama/examples/client/object_device.c index 9e6e30c..d62243c 100644 --- a/external/wakaama/examples/client/object_device.c +++ b/external/wakaama/examples/client/object_device.c @@ -17,7 +17,7 @@ * Axel Lorente - Please refer to git log * Bosch Software Innovations GmbH - Please refer to git log * Pascal Rieux - Please refer to git log - * + * *******************************************************************************/ /* @@ -189,7 +189,7 @@ static uint8_t prv_set_value(lwm2m_data_t * dataP, case RES_O_FACTORY_RESET: return COAP_405_METHOD_NOT_ALLOWED; - case RES_O_AVL_POWER_SOURCES: + case RES_O_AVL_POWER_SOURCES: { lwm2m_data_t * subTlvP; @@ -231,7 +231,7 @@ static uint8_t prv_set_value(lwm2m_data_t * dataP, lwm2m_data_encode_int(PRV_POWER_CURRENT_1, &subTlvP[0]); subTlvP[1].id = 1; lwm2m_data_encode_int(PRV_POWER_CURRENT_2, &subTlvP[1]); - + lwm2m_data_encode_instances(subTlvP, 2, dataP); return COAP_205_CONTENT; @@ -257,7 +257,7 @@ static uint8_t prv_set_value(lwm2m_data_t * dataP, lwm2m_data_encode_instances(subTlvP, 1, dataP); return COAP_205_CONTENT; - } + } case RES_O_RESET_ERROR_CODE: return COAP_405_METHOD_NOT_ALLOWED; @@ -272,7 +272,7 @@ static uint8_t prv_set_value(lwm2m_data_t * dataP, case RES_O_TIMEZONE: lwm2m_data_encode_string(PRV_TIME_ZONE, dataP); return COAP_205_CONTENT; - + case RES_M_BINDING_MODES: lwm2m_data_encode_string(PRV_BINDING_MODE, dataP); return COAP_205_CONTENT; @@ -469,7 +469,7 @@ static uint8_t prv_device_write(uint16_t instanceId, //ToDo IANA TZ Format result = COAP_501_NOT_IMPLEMENTED; break; - + default: result = COAP_405_METHOD_NOT_ALLOWED; } @@ -558,7 +558,7 @@ lwm2m_object_t * get_object_device() lwm2m_free(deviceObj); return NULL; } - + /* * And the private function that will access the object. * Those function will be called when a read/write/execute query is made by the server. In fact the library don't need to @@ -571,7 +571,7 @@ lwm2m_object_t * get_object_device() deviceObj->userData = lwm2m_malloc(sizeof(device_data_t)); /* - * Also some user data can be stored in the object with a private structure containing the needed variables + * Also some user data can be stored in the object with a private structure containing the needed variables */ if (NULL != deviceObj->userData) { @@ -660,6 +660,6 @@ uint8_t device_change(lwm2m_data_t * dataArray, result = COAP_405_METHOD_NOT_ALLOWED; break; } - + return result; } diff --git a/external/wakaama/examples/client/object_firmware.c b/external/wakaama/examples/client/object_firmware.c index 507e4fa..7c93284 100644 --- a/external/wakaama/examples/client/object_firmware.c +++ b/external/wakaama/examples/client/object_firmware.c @@ -16,7 +16,7 @@ * David Navarro, Intel Corporation - Please refer to git log * Bosch Software Innovations GmbH - Please refer to git log * Pascal Rieux - Please refer to git log - * + * *******************************************************************************/ /* diff --git a/external/wakaama/examples/client/object_location.c b/external/wakaama/examples/client/object_location.c index c8736c4..16b48d9 100644 --- a/external/wakaama/examples/client/object_location.c +++ b/external/wakaama/examples/client/object_location.c @@ -1,5 +1,5 @@ /******************************************************************************* - * + * * Copyright (c) 2014 Bosch Software Innovations GmbH, Germany. * * All rights reserved. This program and the accompanying materials @@ -14,7 +14,7 @@ * Contributors: * Bosch Software Innovations GmbH - Please refer to git log * Pascal Rieux - Please refer to git log - * + * ******************************************************************************/ /*! \file LWM2M object "Location" implementation @@ -69,7 +69,7 @@ #define HORIZONTAL_VELOCITY_VERTICAL 1 // set vertical direction bit! #define HORIZONTAL_VELOCITY_WITH_UNCERTAINTY 2 -#define VELOCITY_OCTETS 5 // for HORIZONTAL_VELOCITY_WITH_UNCERTAINTY +#define VELOCITY_OCTETS 5 // for HORIZONTAL_VELOCITY_WITH_UNCERTAINTY typedef struct { @@ -89,7 +89,7 @@ static uint8_t prv_res2tlv(lwm2m_data_t* dataP, location_data_t* locDataP) { //-------------------------------------------------------------------- JH -- - uint8_t ret = COAP_205_CONTENT; + uint8_t ret = COAP_205_CONTENT; switch (dataP->id) // location resourceId { case RES_M_LATITUDE: @@ -117,7 +117,7 @@ static uint8_t prv_res2tlv(lwm2m_data_t* dataP, ret = COAP_404_NOT_FOUND; break; } - + return ret; } @@ -137,7 +137,7 @@ static uint8_t prv_location_read(uint16_t objInstId, int* numDataP, lwm2m_data_t** tlvArrayP, lwm2m_object_t* objectP) -{ +{ //-------------------------------------------------------------------- JH -- int i; uint8_t result = COAP_500_INTERNAL_SERVER_ERROR; @@ -157,24 +157,24 @@ static uint8_t prv_location_read(uint16_t objInstId, RES_M_TIMESTAMP, RES_O_SPEED }; // readable resources! - + *numDataP = sizeof(readResIds)/sizeof(uint16_t); *tlvArrayP = lwm2m_data_new(*numDataP); if (*tlvArrayP == NULL) return COAP_500_INTERNAL_SERVER_ERROR; - + // init readable resource id's for (i = 0 ; i < *numDataP ; i++) { (*tlvArrayP)[i].id = readResIds[i]; } } - + for (i = 0 ; i < *numDataP ; i++) { result = prv_res2tlv ((*tlvArrayP)+i, locDataP); if (result!=COAP_205_CONTENT) break; } - + return result; } @@ -240,8 +240,8 @@ void location_setLocationAtTime(lwm2m_object_t* locationObj, } /** - * This function creates the LWM2M Location. - * @return gives back allocated LWM2M data object structure pointer. On error, + * This function creates the LWM2M Location. + * @return gives back allocated LWM2M data object structure pointer. On error, * NULL value is returned. */ lwm2m_object_t * get_object_location(void) @@ -257,7 +257,7 @@ lwm2m_object_t * get_object_location(void) // It assigns its unique ID // The 6 is the standard ID for the optional object "Location". locationObj->objID = LWM2M_LOCATION_OBJECT_ID; - + // and its unique instance locationObj->instanceList = (lwm2m_list_t *)lwm2m_malloc(sizeof(lwm2m_list_t)); if (NULL != locationObj->instanceList) @@ -295,7 +295,7 @@ lwm2m_object_t * get_object_location(void) locationObj = NULL; } } - + return locationObj; } diff --git a/external/wakaama/examples/client/object_security.c b/external/wakaama/examples/client/object_security.c index 347fb07..85917c8 100644 --- a/external/wakaama/examples/client/object_security.c +++ b/external/wakaama/examples/client/object_security.c @@ -15,7 +15,7 @@ * Bosch Software Innovations GmbH - Please refer to git log * Pascal Rieux - Please refer to git log * Ville Skytta - Please refer to git log - * + * *******************************************************************************/ /* @@ -53,7 +53,7 @@ typedef struct _security_instance_ struct _security_instance_ * next; // matches lwm2m_list_t::next uint16_t instanceId; // matches lwm2m_list_t::id char * uri; - bool isBootstrap; + bool isBootstrap; uint8_t securityMode; char * publicIdentity; uint16_t publicIdLen; @@ -543,7 +543,7 @@ lwm2m_object_t * get_security_object(int serverId, memset(targetP, 0, sizeof(security_instance_t)); targetP->instanceId = 0; - targetP->uri = (char*)lwm2m_malloc(strlen(serverUri)+1); + targetP->uri = (char*)lwm2m_malloc(strlen(serverUri)+1); strcpy(targetP->uri, serverUri); targetP->securityMode = LWM2M_SECURITY_MODE_NONE; diff --git a/external/wakaama/examples/client/object_server.c b/external/wakaama/examples/client/object_server.c index 2f0531e..8fb5a72 100644 --- a/external/wakaama/examples/client/object_server.c +++ b/external/wakaama/examples/client/object_server.c @@ -15,7 +15,7 @@ * Julien Vermillard, Sierra Wireless * Bosch Software Innovations GmbH - Please refer to git log * Pascal Rieux - Please refer to git log - * + * *******************************************************************************/ /* diff --git a/external/wakaama/examples/client/test_object.c b/external/wakaama/examples/client/test_object.c index 4181eb9..607bbaf 100644 --- a/external/wakaama/examples/client/test_object.c +++ b/external/wakaama/examples/client/test_object.c @@ -18,7 +18,7 @@ * Achim Kraus, Bosch Software Innovations GmbH - Please refer to git log * Pascal Rieux - Please refer to git log * Ville Skytta - Please refer to git log - * + * *******************************************************************************/ /* diff --git a/external/wakaama/examples/lightclient/object_device.c b/external/wakaama/examples/lightclient/object_device.c index edc3917..51528bc 100644 --- a/external/wakaama/examples/lightclient/object_device.c +++ b/external/wakaama/examples/lightclient/object_device.c @@ -17,7 +17,7 @@ * Axel Lorente - Please refer to git log * Bosch Software Innovations GmbH - Please refer to git log * Pascal Rieux - Please refer to git log - * + * *******************************************************************************/ /* @@ -110,7 +110,7 @@ static uint8_t prv_set_value(lwm2m_data_t * dataP) case RES_M_REBOOT: return COAP_405_METHOD_NOT_ALLOWED; - + case RES_M_BINDING_MODES: lwm2m_data_encode_string(PRV_BINDING_MODE, dataP); return COAP_205_CONTENT; @@ -275,7 +275,7 @@ lwm2m_object_t * get_object_device() lwm2m_free(deviceObj); return NULL; } - + /* * And the private function that will access the object. * Those function will be called when a read/write/execute query is made by the server. In fact the library don't need to diff --git a/external/wakaama/examples/lightclient/object_security.c b/external/wakaama/examples/lightclient/object_security.c index ee12ea7..5b97ef9 100644 --- a/external/wakaama/examples/lightclient/object_security.c +++ b/external/wakaama/examples/lightclient/object_security.c @@ -14,7 +14,7 @@ * David Navarro, Intel Corporation - initial API and implementation * Bosch Software Innovations GmbH - Please refer to git log * Pascal Rieux - Please refer to git log - * + * *******************************************************************************/ /* diff --git a/external/wakaama/examples/lightclient/object_server.c b/external/wakaama/examples/lightclient/object_server.c index 3aa0a80..e932117 100644 --- a/external/wakaama/examples/lightclient/object_server.c +++ b/external/wakaama/examples/lightclient/object_server.c @@ -15,7 +15,7 @@ * Julien Vermillard, Sierra Wireless * Bosch Software Innovations GmbH - Please refer to git log * Pascal Rieux - Please refer to git log - * + * *******************************************************************************/ /* diff --git a/external/wakaama/examples/lightclient/test_object.c b/external/wakaama/examples/lightclient/test_object.c index 7c35b50..1f9e555 100644 --- a/external/wakaama/examples/lightclient/test_object.c +++ b/external/wakaama/examples/lightclient/test_object.c @@ -17,7 +17,7 @@ * Axel Lorente - Please refer to git log * Achim Kraus, Bosch Software Innovations GmbH - Please refer to git log * Pascal Rieux - Please refer to git log - * + * *******************************************************************************/ /* diff --git a/external/wakaama/examples/shared/commandline.c b/external/wakaama/examples/shared/commandline.c index 0fa7ff5..6c89679 100644 --- a/external/wakaama/examples/shared/commandline.c +++ b/external/wakaama/examples/shared/commandline.c @@ -13,7 +13,7 @@ * Contributors: * David Navarro, Intel Corporation - initial API and implementation * Fabien Fleutot - Please refer to git log - * + * *******************************************************************************/ #include diff --git a/external/wakaama/examples/shared/connection.c b/external/wakaama/examples/shared/connection.c index 48fc5d4..38518da 100644 --- a/external/wakaama/examples/shared/connection.c +++ b/external/wakaama/examples/shared/connection.c @@ -14,7 +14,7 @@ * Gregory Lemercier, Samsung Semiconductor - support for TCP/TLS * David Navarro, Intel Corporation - initial API and implementation * Pascal Rieux - Please refer to git log - * + * *******************************************************************************/ #include diff --git a/external/wakaama/examples/shared/tinydtls/ccm.c b/external/wakaama/examples/shared/tinydtls/ccm.c index 7563db8..7cf317d 100644 --- a/external/wakaama/examples/shared/tinydtls/ccm.c +++ b/external/wakaama/examples/shared/tinydtls/ccm.c @@ -46,7 +46,7 @@ (A)[i] |= (C) & 0xFF; \ } -static inline void +static inline void block0(size_t M, /* number of auth bytes */ size_t L, /* number of bytes to encode message length */ size_t la, /* l(a) octets additional authenticated data */ @@ -59,16 +59,16 @@ block0(size_t M, /* number of auth bytes */ /* copy the nonce */ memcpy(result + 1, nonce, DTLS_CCM_BLOCKSIZE - L); - + for (i=0; i < L; i++) { result[15-i] = lm & 0xff; lm >>= 8; } } -/** +/** * Creates the CBC-MAC for the additional authentication data that - * is sent in cleartext. + * is sent in cleartext. * * \param ctx The crypto context for the AES encryption. * \param msg The message starting with the additional authentication data. @@ -82,9 +82,9 @@ block0(size_t M, /* number of auth bytes */ */ static void add_auth_data(rijndael_ctx *ctx, const unsigned char *msg, size_t la, - unsigned char B[DTLS_CCM_BLOCKSIZE], + unsigned char B[DTLS_CCM_BLOCKSIZE], unsigned char X[DTLS_CCM_BLOCKSIZE]) { - size_t i,j; + size_t i,j; rijndael_encrypt(ctx, B, X); @@ -123,11 +123,11 @@ add_auth_data(rijndael_ctx *ctx, const unsigned char *msg, size_t la, memcpy(B + j, msg, i); la -= i; msg += i; - + memxor(B, X, DTLS_CCM_BLOCKSIZE); - + rijndael_encrypt(ctx, B, X); - + while (la > DTLS_CCM_BLOCKSIZE) { for (i = 0; i < DTLS_CCM_BLOCKSIZE; ++i) B[i] = X[i] ^ *msg++; @@ -135,14 +135,14 @@ add_auth_data(rijndael_ctx *ctx, const unsigned char *msg, size_t la, rijndael_encrypt(ctx, B, X); } - + if (la) { memset(B, 0, DTLS_CCM_BLOCKSIZE); memcpy(B, msg, la); memxor(B, X, DTLS_CCM_BLOCKSIZE); - rijndael_encrypt(ctx, B, X); - } + rijndael_encrypt(ctx, B, X); + } } static inline void @@ -153,13 +153,13 @@ encrypt(rijndael_ctx *ctx, size_t L, unsigned long counter, static unsigned long counter_tmp; - SET_COUNTER(A, L, counter, counter_tmp); + SET_COUNTER(A, L, counter, counter_tmp); rijndael_encrypt(ctx, A, S); memxor(msg, S, len); } static inline void -mac(rijndael_ctx *ctx, +mac(rijndael_ctx *ctx, unsigned char *msg, size_t len, unsigned char B[DTLS_CCM_BLOCKSIZE], unsigned char X[DTLS_CCM_BLOCKSIZE]) { @@ -173,9 +173,9 @@ mac(rijndael_ctx *ctx, } long int -dtls_ccm_encrypt_message(rijndael_ctx *ctx, size_t M, size_t L, - unsigned char nonce[DTLS_CCM_BLOCKSIZE], - unsigned char *msg, size_t lm, +dtls_ccm_encrypt_message(rijndael_ctx *ctx, size_t M, size_t L, + unsigned char nonce[DTLS_CCM_BLOCKSIZE], + unsigned char *msg, size_t lm, const unsigned char *aad, size_t la) { size_t i, len; unsigned long counter_tmp; @@ -196,7 +196,7 @@ dtls_ccm_encrypt_message(rijndael_ctx *ctx, size_t M, size_t L, /* copy the nonce */ memcpy(A + 1, nonce, DTLS_CCM_BLOCKSIZE - L); - + while (lm >= DTLS_CCM_BLOCKSIZE) { /* calculate MAC */ mac(ctx, msg, DTLS_CCM_BLOCKSIZE, B, X); @@ -225,8 +225,8 @@ dtls_ccm_encrypt_message(rijndael_ctx *ctx, size_t M, size_t L, /* update local pointers */ msg += lm; } - - /* calculate S_0 */ + + /* calculate S_0 */ SET_COUNTER(A, L, 0, counter_tmp); rijndael_encrypt(ctx, A, S); @@ -238,10 +238,10 @@ dtls_ccm_encrypt_message(rijndael_ctx *ctx, size_t M, size_t L, long int dtls_ccm_decrypt_message(rijndael_ctx *ctx, size_t M, size_t L, - unsigned char nonce[DTLS_CCM_BLOCKSIZE], - unsigned char *msg, size_t lm, + unsigned char nonce[DTLS_CCM_BLOCKSIZE], + unsigned char *msg, size_t lm, const unsigned char *aad, size_t la) { - + size_t len; unsigned long counter_tmp; unsigned long counter = 1; /* \bug does not work correctly on ia32 when @@ -266,11 +266,11 @@ dtls_ccm_decrypt_message(rijndael_ctx *ctx, size_t M, size_t L, /* copy the nonce */ memcpy(A + 1, nonce, DTLS_CCM_BLOCKSIZE - L); - + while (lm >= DTLS_CCM_BLOCKSIZE) { /* decrypt */ encrypt(ctx, L, counter, msg, DTLS_CCM_BLOCKSIZE, A, S); - + /* calculate MAC */ mac(ctx, msg, DTLS_CCM_BLOCKSIZE, B, X); @@ -290,13 +290,13 @@ dtls_ccm_decrypt_message(rijndael_ctx *ctx, size_t M, size_t L, * (i.e., we can use memcpy() here). */ memcpy(B + lm, X + lm, DTLS_CCM_BLOCKSIZE - lm); - mac(ctx, msg, lm, B, X); + mac(ctx, msg, lm, B, X); /* update local pointers */ msg += lm; } - - /* calculate S_0 */ + + /* calculate S_0 */ SET_COUNTER(A, L, 0, counter_tmp); rijndael_encrypt(ctx, A, S); @@ -305,7 +305,7 @@ dtls_ccm_decrypt_message(rijndael_ctx *ctx, size_t M, size_t L, /* return length if MAC is valid, otherwise continue with error handling */ if (equals(X, msg, M)) return len - M; - + error: return -1; } diff --git a/external/wakaama/examples/shared/tinydtls/crypto.c b/external/wakaama/examples/shared/tinydtls/crypto.c index b5345d3..7c3bf1b 100644 --- a/external/wakaama/examples/shared/tinydtls/crypto.c +++ b/external/wakaama/examples/shared/tinydtls/crypto.c @@ -136,7 +136,7 @@ dtls_handshake_parameters_t *dtls_handshake_new() /* initialize the handshake hash wrt. the hard-coded DTLS version */ dtls_debug("DTLSv12: initialize HASH_SHA256\n"); /* TLS 1.2: PRF(secret, label, seed) = P_(secret, label + seed) */ - /* FIXME: we use the default SHA256 here, might need to support other + /* FIXME: we use the default SHA256 here, might need to support other hash functions as well */ dtls_hash_init(&handshake->hs_state.hs_hash); } @@ -230,11 +230,11 @@ dtls_p_hash(dtls_hashfunc_t h, dtls_hmac_init(hmac_p, key, keylen); dtls_hmac_update(hmac_p, A, dlen); - + HMAC_UPDATE_SEED(hmac_p, label, labellen); HMAC_UPDATE_SEED(hmac_p, random1, random1len); HMAC_UPDATE_SEED(hmac_p, random2, random2len); - + dtls_hmac_finalize(hmac_p, tmp); memcpy(buf, tmp, buflen - len); @@ -245,7 +245,7 @@ dtls_p_hash(dtls_hashfunc_t h, return buflen; } -size_t +size_t dtls_prf(const unsigned char *key, size_t keylen, const unsigned char *label, size_t labellen, const unsigned char *random1, size_t random1len, @@ -254,16 +254,16 @@ dtls_prf(const unsigned char *key, size_t keylen, /* Clear the result buffer */ memset(buf, 0, buflen); - return dtls_p_hash(HASH_SHA256, - key, keylen, - label, labellen, + return dtls_p_hash(HASH_SHA256, + key, keylen, + label, labellen, random1, random1len, random2, random2len, buf, buflen); } void -dtls_mac(dtls_hmac_context_t *hmac_ctx, +dtls_mac(dtls_hmac_context_t *hmac_ctx, const unsigned char *record, const unsigned char *packet, size_t length, unsigned char *buf) { @@ -275,23 +275,23 @@ dtls_mac(dtls_hmac_context_t *hmac_ctx, dtls_hmac_update(hmac_ctx, record, sizeof(uint8) + sizeof(uint16)); dtls_hmac_update(hmac_ctx, L, sizeof(uint16)); dtls_hmac_update(hmac_ctx, packet, length); - + dtls_hmac_finalize(hmac_ctx, buf); } static size_t dtls_ccm_encrypt(aes128_ccm_t *ccm_ctx, const unsigned char *src, size_t srclen, - unsigned char *buf, + unsigned char *buf, unsigned char *nounce, const unsigned char *aad, size_t la) { long int len; assert(ccm_ctx); - len = dtls_ccm_encrypt_message(&ccm_ctx->ctx, 8 /* M */, + len = dtls_ccm_encrypt_message(&ccm_ctx->ctx, 8 /* M */, max(2, 15 - DTLS_CCM_NONCE_SIZE), nounce, - buf, srclen, + buf, srclen, aad, la); return len; } @@ -305,10 +305,10 @@ dtls_ccm_decrypt(aes128_ccm_t *ccm_ctx, const unsigned char *src, assert(ccm_ctx); - len = dtls_ccm_decrypt_message(&ccm_ctx->ctx, 8 /* M */, + len = dtls_ccm_decrypt_message(&ccm_ctx->ctx, 8 /* M */, max(2, 15 - DTLS_CCM_NONCE_SIZE), nounce, - buf, srclen, + buf, srclen, aad, la); return len; } @@ -331,7 +331,7 @@ dtls_psk_pre_master_secret(unsigned char *key, size_t keylen, memcpy(p, result, sizeof(uint16)); p += sizeof(uint16); - + memcpy(p, key, keylen); return 2 * (sizeof(uint16) + keylen); @@ -363,7 +363,7 @@ int dtls_ec_key_from_uint32_asn1(const uint32_t *key, size_t key_size, unsigned char *buf) { int i; unsigned char *buf_orig = buf; - int first = 1; + int first = 1; for (i = (key_size / sizeof(uint32_t)) - 1; i >= 0 ; i--) { if (key[i] == 0) @@ -373,7 +373,7 @@ int dtls_ec_key_from_uint32_asn1(const uint32_t *key, size_t key_size, *buf = 0; buf++; dtls_int_to_uint32(buf, key[i]); - buf += 4; + buf += 4; } else if (first && !(key[i] & 0xFF800000)) { buf[0] = (key[i] >> 16) & 0xff; buf[1] = (key[i] >> 8) & 0xff; @@ -450,7 +450,7 @@ dtls_ecdsa_create_sig_hash(const unsigned char *priv_key, size_t key_size, uint32_t priv[8]; uint32_t hash[8]; uint32_t rand[8]; - + dtls_ec_key_to_uint32(priv_key, key_size, priv); dtls_ec_key_to_uint32(sign_hash, sign_hash_size, hash); do { @@ -473,7 +473,7 @@ dtls_ecdsa_create_sig(const unsigned char *priv_key, size_t key_size, dtls_hash_update(&data, server_random, server_random_size); dtls_hash_update(&data, keyx_params, keyx_params_size); dtls_hash_finalize(sha256hash, &data); - + dtls_ecdsa_create_sig_hash(priv_key, key_size, sha256hash, sizeof(sha256hash), point_r, point_s); } @@ -508,7 +508,7 @@ dtls_ecdsa_verify_sig(const unsigned char *pub_key_x, unsigned char *result_r, unsigned char *result_s) { dtls_hash_ctx data; unsigned char sha256hash[DTLS_HMAC_DIGEST_SIZE]; - + dtls_hash_init(&data); dtls_hash_update(&data, client_random, client_random_size); dtls_hash_update(&data, server_random, server_random_size); @@ -520,7 +520,7 @@ dtls_ecdsa_verify_sig(const unsigned char *pub_key_x, } #endif /* DTLS_ECC */ -int +int dtls_encrypt(const unsigned char *src, size_t length, unsigned char *buf, unsigned char *nounce, @@ -546,7 +546,7 @@ error: return ret; } -int +int dtls_decrypt(const unsigned char *src, size_t length, unsigned char *buf, unsigned char *nounce, diff --git a/external/wakaama/examples/shared/tinydtls/dtls.c b/external/wakaama/examples/shared/tinydtls/dtls.c index 31d2ed8..1cf96fc 100644 --- a/external/wakaama/examples/shared/tinydtls/dtls.c +++ b/external/wakaama/examples/shared/tinydtls/dtls.c @@ -182,7 +182,7 @@ dtls_send_multi(dtls_context_t *ctx, dtls_peer_t *peer, unsigned char type, uint8 *buf_array[], size_t buf_len_array[], size_t buf_array_len); -/** +/** * Sends the fragment of length \p buflen given in \p buf to the * specified \p peer. The data will be MAC-protected and encrypted * according to the selected cipher and split into one or more DTLS @@ -191,7 +191,7 @@ dtls_send_multi(dtls_context_t *ctx, dtls_peer_t *peer, * * \param ctx The DTLS context to use. * \param peer The remote peer. - * \param type The content type of the record. + * \param type The content type of the record. * \param buf The data to send. * \param buflen The actual length of \p buf. * \return Less than zero on error, the number of bytes written otherwise. @@ -219,7 +219,7 @@ dtls_get_peer(const dtls_context_t *ctx, const session_t *session) { if (dtls_session_equals(&p->session, session)) return p; #endif /* WITH_CONTIKI */ - + return p; } @@ -233,9 +233,9 @@ dtls_add_peer(dtls_context_t *ctx, dtls_peer_t *peer) { } int -dtls_write(struct dtls_context_t *ctx, +dtls_write(struct dtls_context_t *ctx, session_t *dst, uint8 *buf, size_t len) { - + dtls_peer_t *peer = dtls_get_peer(ctx, dst); /* Check if peer connection already exists */ @@ -248,7 +248,7 @@ dtls_write(struct dtls_context_t *ctx, return (res >= 0) ? 0 : res; } else { /* a session exists, check if it is in state connected */ - + if (peer->state != DTLS_STATE_CONNECTED) { return 0; } else { @@ -274,7 +274,7 @@ dtls_get_cookie(uint8 *msg, size_t msglen, uint8 **cookie) { if (msglen < (*msg & 0xff) + sizeof(uint8)) return dtls_alert_fatal_create(DTLS_ALERT_HANDSHAKE_FAILURE); - + *cookie = msg + sizeof(uint8); return dtls_uint8_to_int(msg); @@ -283,7 +283,7 @@ dtls_get_cookie(uint8 *msg, size_t msglen, uint8 **cookie) { } static int -dtls_create_cookie(dtls_context_t *ctx, +dtls_create_cookie(dtls_context_t *ctx, session_t *session, uint8 *msg, size_t msglen, uint8 *cookie, int *clen) { @@ -293,10 +293,10 @@ dtls_create_cookie(dtls_context_t *ctx, /* create cookie with HMAC-SHA256 over: * - SECRET * - session parameters (only IP address?) - * - client version + * - client version * - random gmt and bytes * - session id - * - cipher_suites + * - cipher_suites * - compression method */ @@ -309,7 +309,7 @@ dtls_create_cookie(dtls_context_t *ctx, dtls_hmac_context_t hmac_context; dtls_hmac_init(&hmac_context, ctx->cookie_secret, DTLS_COOKIE_SECRET_LENGTH); - dtls_hmac_update(&hmac_context, + dtls_hmac_update(&hmac_context, (unsigned char *)&session->addr, session->size); /* feed in the beginning of the Client Hello up to and including the @@ -320,14 +320,14 @@ dtls_create_cookie(dtls_context_t *ctx, return dtls_alert_fatal_create(DTLS_ALERT_HANDSHAKE_FAILURE); dtls_hmac_update(&hmac_context, msg + DTLS_HS_LENGTH, e); - + /* skip cookie bytes and length byte */ e += *(uint8 *)(msg + DTLS_HS_LENGTH + e) & 0xff; e += sizeof(uint8); if (e + DTLS_HS_LENGTH > msglen) return dtls_alert_fatal_create(DTLS_ALERT_HANDSHAKE_FAILURE); - dtls_hmac_update(&hmac_context, + dtls_hmac_update(&hmac_context, msg + DTLS_HS_LENGTH + e, dtls_get_fragment_length(DTLS_HANDSHAKE_HEADER(msg)) - e); @@ -337,14 +337,14 @@ dtls_create_cookie(dtls_context_t *ctx, memset(cookie + len, 0, *clen - len); *clen = len; } - + memcpy(cookie, buf, *clen); return 0; } #ifdef DTLS_CHECK_CONTENTTYPE /* used to check if a received datagram contains a DTLS message */ -static char const content_types[] = { +static char const content_types[] = { DTLS_CT_CHANGE_CIPHER_SPEC, DTLS_CT_ALERT, DTLS_CT_HANDSHAKE, @@ -355,7 +355,7 @@ static char const content_types[] = { /** * Checks if \p msg points to a valid DTLS record. If - * + * */ static unsigned int is_record(uint8 *msg, size_t msglen) { @@ -366,16 +366,16 @@ is_record(uint8 *msg, size_t msglen) { && strchr(content_types, msg[0]) #endif && msg[1] == HIGH(DTLS_VERSION) - && msg[2] == LOW(DTLS_VERSION)) + && msg[2] == LOW(DTLS_VERSION)) { - rlen = DTLS_RH_LENGTH + + rlen = DTLS_RH_LENGTH + dtls_uint16_to_int(DTLS_RECORD_HEADER(msg)->length); - + /* we do not accept wrong length field in record header */ - if (rlen > msglen) + if (rlen > msglen) rlen = 0; - } - + } + return rlen; } @@ -385,11 +385,11 @@ is_record(uint8 *msg, size_t msglen) { * bytes. Increments sequence number counter of \p security. * \return pointer to the next byte after the written header. * The length will be set to 0 and has to be changed before sending. - */ + */ static inline uint8 * dtls_set_record_header(uint8 type, dtls_security_parameters_t *security, uint8 *buf) { - + dtls_int_to_uint8(buf, type); buf += sizeof(uint8); @@ -419,13 +419,13 @@ dtls_set_record_header(uint8 type, dtls_security_parameters_t *security, * buf is capable of holding at least \c sizeof(dtls_handshake_header_t) * bytes. Increments message sequence number counter of \p peer. * \return pointer to the next byte after \p buf - */ + */ static inline uint8 * -dtls_set_handshake_header(uint8 type, dtls_peer_t *peer, - int length, - int frag_offset, int frag_length, +dtls_set_handshake_header(uint8 type, dtls_peer_t *peer, + int length, + int frag_offset, int frag_length, uint8 *buf) { - + dtls_int_to_uint8(buf, type); buf += sizeof(uint8); @@ -439,16 +439,16 @@ dtls_set_handshake_header(uint8 type, dtls_peer_t *peer, /* increment handshake message sequence counter by 1 */ peer->handshake_params->hs_state.mseq_s++; } else { - memset(buf, 0, sizeof(uint16)); + memset(buf, 0, sizeof(uint16)); } buf += sizeof(uint16); - + dtls_int_to_uint24(buf, frag_offset); buf += sizeof(uint24); dtls_int_to_uint24(buf, frag_length); buf += sizeof(uint24); - + return buf; } @@ -491,7 +491,7 @@ static inline int is_psk_supported(dtls_context_t *ctx) static inline int is_ecdsa_supported(dtls_context_t *ctx, int is_client) { #ifdef DTLS_ECC - return ctx && ctx->h && ((!is_client && ctx->h->get_ecdsa_key) || + return ctx && ctx->h && ((!is_client && ctx->h->get_ecdsa_key) || (is_client && ctx->h->verify_ecdsa_key)); #else return 0; @@ -517,7 +517,7 @@ static inline int is_ecdsa_client_auth_supported(dtls_context_t *ctx) * @param code The cipher suite identifier to check * @param is_client 1 for a dtls client, 0 for server * @return @c 1 iff @p code is recognized, - */ + */ static int known_cipher(dtls_context_t *ctx, dtls_cipher_t code, int is_client) { int psk; @@ -596,7 +596,7 @@ static char *dtls_handshake_type_to_name(int type) * Calculate the pre master secret and after that calculate the master-secret. */ static int -calculate_key_block(dtls_context_t *ctx, +calculate_key_block(dtls_context_t *ctx, dtls_handshake_parameters_t *handshake, dtls_peer_t *peer, session_t *session, @@ -784,7 +784,7 @@ dtls_check_tls_extension(dtls_peer_t *peer, int ext_ec_point_formats = 0; dtls_handshake_parameters_t *handshake = peer->handshake_params; - if (data_length < sizeof(uint16)) { + if (data_length < sizeof(uint16)) { /* no tls extensions specified */ if (is_tls_ecdhe_ecdsa_with_aes_128_ccm_8(handshake->cipher)) { goto error; @@ -851,7 +851,7 @@ dtls_check_tls_extension(dtls_peer_t *peer, break; case TLS_EXT_ENCRYPT_THEN_MAC: /* As only AEAD cipher suites are currently available, this - * extension can be skipped. + * extension can be skipped. */ dtls_info("skipped encrypt-then-mac extension\n"); break; @@ -892,12 +892,12 @@ error: * * \param ctx The current DTLS context. * \param peer The remote peer whose security parameters are about to change. - * \param data The handshake message with a ClientHello. + * \param data The handshake message with a ClientHello. * \param data_length The actual size of \p data. * \return \c -Something if an error occurred, \c 0 on success. */ static int -dtls_update_parameters(dtls_context_t *ctx, +dtls_update_parameters(dtls_context_t *ctx, dtls_peer_t *peer, uint8 *data, size_t data_length) { int i, j; @@ -956,7 +956,7 @@ dtls_update_parameters(dtls_context_t *ctx, goto error; } - if (data_length < sizeof(uint8)) { + if (data_length < sizeof(uint8)) { /* no compression specified, take the current compression method */ if (security) config->compression = security->compression; @@ -980,14 +980,14 @@ dtls_update_parameters(dtls_context_t *ctx, ok = 1; } i -= sizeof(uint8); - data += sizeof(uint8); + data += sizeof(uint8); } if (!ok) { /* reset config cipher to a well-defined value */ goto error; } - + return dtls_check_tls_extension(peer, data, data_length, 1); error: if (peer->state == DTLS_STATE_CONNECTED) { @@ -1002,7 +1002,7 @@ error: * the new data. */ static inline int -check_client_keyexchange(dtls_context_t *ctx, +check_client_keyexchange(dtls_context_t *ctx, dtls_handshake_parameters_t *handshake, uint8 *data, size_t length) { @@ -1090,9 +1090,9 @@ clear_hs_hash(dtls_peer_t *peer) { dtls_hash_init(&peer->handshake_params->hs_state.hs_hash); } -/** +/** * Checks if \p record + \p data contain a Finished message with valid - * verify_data. + * verify_data. * * \param ctx The current DTLS context. * \param peer The remote peer of the security association. @@ -1169,11 +1169,11 @@ check_finished(dtls_context_t *ctx, dtls_peer_t *peer, * \param data_array_len The number of payloads given. * \param sendbuf The output buffer where the encrypted record * will be placed. - * \param rlen This parameter must be initialized with the + * \param rlen This parameter must be initialized with the * maximum size of \p sendbuf and will be updated * to hold the actual size of the stored packet * on success. On error, the value of \p rlen is - * undefined. + * undefined. * \return Less than zero on error, or greater than zero success. */ static int @@ -1185,7 +1185,7 @@ dtls_prepare_record(dtls_peer_t *peer, dtls_security_parameters_t *security, uint8 *p, *start; int res; unsigned int i; - + if (*rlen < DTLS_RH_LENGTH) { dtls_alert("The sendbuf (%zu bytes) is too small\n", *rlen); return dtls_alert_fatal_create(DTLS_ALERT_INTERNAL_ERROR); @@ -1209,8 +1209,8 @@ dtls_prepare_record(dtls_peer_t *peer, dtls_security_parameters_t *security, p += data_len_array[i]; res += data_len_array[i]; } - } else { /* TLS_PSK_WITH_AES_128_CCM_8 or TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 */ - /** + } else { /* TLS_PSK_WITH_AES_128_CCM_8 or TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 */ + /** * length of additional_data for the AEAD cipher which consists of * seq_num(2+6) + type(1) + version(2) + length(2) */ @@ -1226,7 +1226,7 @@ dtls_prepare_record(dtls_peer_t *peer, dtls_security_parameters_t *security, dtls_debug("dtls_prepare_record(): encrypt using unknown cipher\n"); } - /* set nonce + /* set nonce from RFC 6655: The "nonce" input to the AEAD algorithm is exactly that of [RFC5288]: the "nonce" SHALL be 12 bytes long and is constructed as follows: @@ -1290,16 +1290,16 @@ dtls_prepare_record(dtls_peer_t *peer, dtls_security_parameters_t *security, dtls_debug_dump("nonce:", nonce, DTLS_CCM_BLOCKSIZE); dtls_debug_dump("key:", dtls_kb_local_write_key(security, peer->role), dtls_kb_key_size(security, peer->role)); - + /* re-use N to create additional data according to RFC 5246, Section 6.2.3.3: - * + * * additional_data = seq_num + TLSCompressed.type + * TLSCompressed.version + TLSCompressed.length; */ memcpy(A_DATA, &DTLS_RECORD_HEADER(sendbuf)->epoch, 8); /* epoch and seq_num */ memcpy(A_DATA + 8, &DTLS_RECORD_HEADER(sendbuf)->content_type, 3); /* type and version */ dtls_int_to_uint16(A_DATA + 11, res - 8); /* length */ - + res = dtls_encrypt(start + 8, res - 8, start + 8, nonce, dtls_kb_local_write_key(security, peer->role), dtls_kb_key_size(security, peer->role), @@ -1314,7 +1314,7 @@ dtls_prepare_record(dtls_peer_t *peer, dtls_security_parameters_t *security, /* fix length of fragment in sendbuf */ dtls_int_to_uint16(sendbuf + 11, res); - + *rlen = DTLS_RH_LENGTH + res; return 0; } @@ -1367,16 +1367,16 @@ dtls_send_handshake_msg(dtls_context_t *ctx, header_type, data, data_length, 1); } -/** +/** * Returns true if the message @p Data is a handshake message that * must be included in the calculation of verify_data in the Finished * message. - * - * @param Type The message type. Only handshake messages but the initial + * + * @param Type The message type. Only handshake messages but the initial * Client Hello and Hello Verify Request are included in the hash, * @param Data The PDU to examine. * @param Length The length of @p Data. - * + * * @return @c 1 if @p Data must be included in hash, @c 0 otherwise. * * @hideinitializer @@ -1467,7 +1467,7 @@ dtls_send_multi(dtls_context_t *ctx, dtls_peer_t *peer, dtls_debug("copied to sendqueue\n"); #endif /* WITH_CONTIKI */ } - } else + } else dtls_warn("retransmit buffer full\n"); } @@ -1490,7 +1490,7 @@ dtls_send_alert(dtls_context_t *ctx, dtls_peer_t *peer, dtls_alert_level_t level return 0; } -int +int dtls_close(dtls_context_t *ctx, const session_t *remote) { int res = -1; dtls_peer_t *peer; @@ -1526,8 +1526,8 @@ static void dtls_destroy_peer(dtls_context_t *ctx, dtls_peer_t *peer, int unlink * Client Hello contains no cookie, the function fails and a Hello * Verify Request is sent to the peer (using the write callback function * registered with \p ctx). The return value is \c -1 on error, \c 0 when - * undecided, and \c 1 if the Client Hello was good. - * + * undecided, and \c 1 if the Client Hello was good. + * * \param ctx The DTLS context. * \param peer The remote party we are talking to, if any. * \param session Transport address of the remote peer. @@ -1537,8 +1537,8 @@ static void dtls_destroy_peer(dtls_context_t *ctx, dtls_peer_t *peer, int unlink * \c -1 otherwise. */ static int -dtls_verify_peer(dtls_context_t *ctx, - dtls_peer_t *peer, +dtls_verify_peer(dtls_context_t *ctx, + dtls_peer_t *peer, session_t *session, uint8 *data, size_t data_length) { @@ -1558,7 +1558,7 @@ dtls_verify_peer(dtls_context_t *ctx, dtls_debug_dump("create cookie", mycookie, len); assert(len == DTLS_COOKIE_LENGTH); - + /* Perform cookie check. */ len = dtls_get_cookie(data, data_length, &cookie); if (len < 0) { @@ -1688,7 +1688,7 @@ dtls_check_ecdsa_signature_elem(uint8 *data, size_t data_length, } static int -check_client_certificate_verify(dtls_context_t *ctx, +check_client_certificate_verify(dtls_context_t *ctx, dtls_peer_t *peer, uint8 *data, size_t data_length) { @@ -1837,7 +1837,7 @@ dtls_send_certificate_ecdsa(dtls_context_t *ctx, dtls_peer_t *peer, uint8 buf[DTLS_CE_LENGTH]; uint8 *p; - /* Certificate + /* Certificate * * Start message construction at beginning of buffer. */ p = buf; @@ -1847,7 +1847,7 @@ dtls_send_certificate_ecdsa(dtls_context_t *ctx, dtls_peer_t *peer, dtls_int_to_uint24(p, 91); /* length of this certificate */ p += sizeof(uint24); - + memcpy(p, &cert_asn1_header, sizeof(cert_asn1_header)); p += sizeof(cert_asn1_header); @@ -1935,7 +1935,7 @@ dtls_send_server_key_exchange_ecdh(dtls_context_t *ctx, dtls_peer_t *peer, uint32_t point_s[9]; dtls_handshake_parameters_t *config = peer->handshake_params; - /* ServerKeyExchange + /* ServerKeyExchange * * Start message construction at beginning of buffer. */ p = buf; @@ -2021,7 +2021,7 @@ dtls_send_server_certificate_request(dtls_context_t *ctx, dtls_peer_t *peer) uint8 buf[8]; uint8 *p; - /* ServerHelloDone + /* ServerHelloDone * * Start message construction at beginning of buffer. */ p = buf; @@ -2061,7 +2061,7 @@ static int dtls_send_server_hello_done(dtls_context_t *ctx, dtls_peer_t *peer) { - /* ServerHelloDone + /* ServerHelloDone * * Start message construction at beginning of buffer. */ @@ -2152,14 +2152,14 @@ dtls_send_server_hello_msgs(dtls_context_t *ctx, dtls_peer_t *peer) return 0; } -static inline int +static inline int dtls_send_ccs(dtls_context_t *ctx, dtls_peer_t *peer) { uint8 buf[1] = {1}; return dtls_send(ctx, peer, DTLS_CT_CHANGE_CIPHER_SPEC, buf, 1); } - + static int dtls_send_client_key_exchange(dtls_context_t *ctx, dtls_peer_t *peer) { @@ -2250,7 +2250,7 @@ dtls_send_certificate_verify_ecdh(dtls_context_t *ctx, dtls_peer_t *peer, dtls_hash_ctx hs_hash; unsigned char sha256hash[DTLS_HMAC_DIGEST_SIZE]; - /* ServerKeyExchange + /* ServerKeyExchange * * Start message construction at beginning of buffer. */ p = buf; @@ -2290,7 +2290,7 @@ dtls_send_finished(dtls_context_t *ctx, dtls_peer_t *peer, dtls_prf(peer->handshake_params->tmp.master_secret, DTLS_MASTER_SECRET_LENGTH, label, labellen, - PRF_LABEL(finished), PRF_LABEL_SIZE(finished), + PRF_LABEL(finished), PRF_LABEL_SIZE(finished), hash, length, p, DTLS_FIN_LENGTH); @@ -2457,7 +2457,7 @@ dtls_send_client_hello(dtls_context_t *ctx, dtls_peer_t *peer, } static int -check_server_hello(dtls_context_t *ctx, +check_server_hello(dtls_context_t *ctx, dtls_peer_t *peer, uint8 *data, size_t data_length) { @@ -2479,11 +2479,11 @@ check_server_hello(dtls_context_t *ctx, * and compression method (like dtls_update_parameters(). * Then calculate master secret and wait for ServerHelloDone. When received, * send ClientKeyExchange (?) and ChangeCipherSpec + ClientFinished. */ - + /* check server version */ data += DTLS_HS_LENGTH; data_length -= DTLS_HS_LENGTH; - + if (dtls_uint16_to_int(data) != DTLS_VERSION) { dtls_alert("unknown DTLS version\n"); return dtls_alert_fatal_create(DTLS_ALERT_PROTOCOL_VERSION); @@ -2499,7 +2499,7 @@ check_server_hello(dtls_context_t *ctx, data_length -= DTLS_RANDOM_LENGTH; SKIP_VAR_FIELD(data, data_length, uint8); /* skip session id */ - + /* Check cipher suite. As we offer all we have, it is sufficient * to check if the cipher suite selected by the server is in our * list of known cipher suites. Subsets are not supported. */ @@ -2549,7 +2549,7 @@ check_server_hello_verify_request(dtls_context_t *ctx, #ifdef DTLS_ECC static int -check_server_certificate(dtls_context_t *ctx, +check_server_certificate(dtls_context_t *ctx, dtls_peer_t *peer, uint8 *data, size_t data_length) { @@ -2723,7 +2723,7 @@ check_server_key_exchange_psk(dtls_context_t *ctx, #endif /* DTLS_PSK */ static int -check_certificate_request(dtls_context_t *ctx, +check_certificate_request(dtls_context_t *ctx, dtls_peer_t *peer, uint8 *data, size_t data_length) { @@ -2781,7 +2781,7 @@ check_certificate_request(dtls_context_t *ctx, current_sig_alg = dtls_uint8_to_int(data); data += sizeof(uint8); - if (current_hash_alg == TLS_EXT_SIG_HASH_ALGO_SHA256 && hash_alg == 0 && + if (current_hash_alg == TLS_EXT_SIG_HASH_ALGO_SHA256 && hash_alg == 0 && current_sig_alg == TLS_EXT_SIG_HASH_ALGO_ECDSA && sig_alg == 0) { hash_alg = current_hash_alg; sig_alg = current_sig_alg; @@ -2801,7 +2801,7 @@ check_certificate_request(dtls_context_t *ctx, } static int -check_server_hellodone(dtls_context_t *ctx, +check_server_hellodone(dtls_context_t *ctx, dtls_peer_t *peer, uint8 *data, size_t data_length) { @@ -2880,7 +2880,7 @@ decrypt_verify(dtls_peer_t *peer, uint8 *packet, size_t length, dtls_record_header_t *header = DTLS_RECORD_HEADER(packet); dtls_security_parameters_t *security = dtls_security_params_epoch(peer, dtls_get_epoch(header)); int clen; - + *cleartext = (uint8 *)packet + sizeof(dtls_record_header_t); clen = length - sizeof(dtls_record_header_t); @@ -2893,7 +2893,7 @@ decrypt_verify(dtls_peer_t *peer, uint8 *packet, size_t length, /* no cipher suite selected */ return clen; } else { /* TLS_PSK_WITH_AES_128_CCM_8 or TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 */ - /** + /** * length of additional_data for the AEAD cipher which consists of * seq_num(2+6) + type(1) + version(2) + length(2) */ @@ -2919,7 +2919,7 @@ decrypt_verify(dtls_peer_t *peer, uint8 *packet, size_t length, dtls_debug_dump("ciphertext", *cleartext, clen); /* re-use N to create additional data according to RFC 5246, Section 6.2.3.3: - * + * * additional_data = seq_num + TLSCompressed.type + * TLSCompressed.version + TLSCompressed.length; */ @@ -3342,7 +3342,7 @@ handle_handshake_msg(dtls_context_t *ctx, dtls_peer_t *peer, session_t *session, return err; } - + static int handle_handshake(dtls_context_t *ctx, dtls_peer_t *peer, session_t *session, const dtls_peer_type role, const dtls_state_t state, @@ -3454,7 +3454,7 @@ handle_handshake(dtls_context_t *ctx, dtls_peer_t *peer, session_t *session, } static int -handle_ccs(dtls_context_t *ctx, dtls_peer_t *peer, +handle_ccs(dtls_context_t *ctx, dtls_peer_t *peer, uint8 *record_header, uint8 *data, size_t data_length) { int err; @@ -3465,7 +3465,7 @@ handle_ccs(dtls_context_t *ctx, dtls_peer_t *peer, * updated successfully and a ChangeCipherSpec message was sent * by ourself, the security context is switched and the record * sequence number is reset. */ - + if (!peer || peer->state != DTLS_STATE_WAIT_CHANGECIPHERSPEC) { dtls_warn("expected ChangeCipherSpec during handshake\n"); return 0; @@ -3482,18 +3482,18 @@ handle_ccs(dtls_context_t *ctx, dtls_peer_t *peer, return err; } } - + peer->state = DTLS_STATE_WAIT_FINISHED; return 0; -} +} -/** +/** * Handles incoming Alert messages. This function returns \c 1 if the * connection should be closed and the peer is to be invalidated. */ static int -handle_alert(dtls_context_t *ctx, dtls_peer_t *peer, +handle_alert(dtls_context_t *ctx, dtls_peer_t *peer, uint8 *record_header, uint8 *data, size_t data_length) { int free_peer = 0; /* indicates whether to free peer */ @@ -3515,7 +3515,7 @@ handle_alert(dtls_context_t *ctx, dtls_peer_t *peer, */ if (data[0] == DTLS_ALERT_LEVEL_FATAL || data[1] == DTLS_ALERT_CLOSE_NOTIFY) { dtls_alert("%d invalidate peer\n", data[1]); - + #ifndef WITH_CONTIKI HASH_DEL_PEER(ctx->peers, peer); #else /* WITH_CONTIKI */ @@ -3532,7 +3532,7 @@ handle_alert(dtls_context_t *ctx, dtls_peer_t *peer, } - (void)CALL(ctx, event, &peer->session, + (void)CALL(ctx, event, &peer->session, (dtls_alert_level_t)data[0], (unsigned short)data[1]); switch (data[1]) { case DTLS_ALERT_CLOSE_NOTIFY: @@ -3547,7 +3547,7 @@ handle_alert(dtls_context_t *ctx, dtls_peer_t *peer, default: ; } - + if (free_peer) { dtls_stop_retransmission(ctx, peer); dtls_destroy_peer(ctx, peer, 0); @@ -3584,17 +3584,17 @@ static int dtls_alert_send_from_err(dtls_context_t *ctx, dtls_peer_t *peer, return -1; } -/** +/** * Handles incoming data as DTLS message from given peer. */ int -dtls_handle_message(dtls_context_t *ctx, +dtls_handle_message(dtls_context_t *ctx, session_t *session, uint8 *msg, int msglen) { dtls_peer_t *peer = NULL; unsigned int rlen; /* record length */ uint8 *data; /* (decrypted) payload */ - int data_length; /* length of decrypted payload + int data_length; /* length of decrypted payload (without MAC and padding) */ int err; @@ -3682,7 +3682,7 @@ dtls_handle_message(dtls_context_t *ctx, if (peer) { uint16_t expected_epoch = dtls_security_params(peer)->epoch; - uint16_t msg_epoch = + uint16_t msg_epoch = dtls_uint16_to_int(DTLS_RECORD_HEADER(msg)->epoch); /* The new security parameters must be used for all messages @@ -3770,13 +3770,13 @@ dtls_new_context(void *app_data) { memset(c, 0, sizeof(dtls_context_t)); c->app = app_data; - + LIST_STRUCT_INIT(c, sendqueue); #ifdef WITH_CONTIKI LIST_STRUCT_INIT(c, peers); /* LIST_STRUCT_INIT(c, key_store); */ - + process_start(&dtls_retransmit_process, (char *)c); PROCESS_CONTEXT_BEGIN(&dtls_retransmit_process); /* the retransmit timer must be initialized to some large value */ @@ -3786,9 +3786,9 @@ dtls_new_context(void *app_data) { if (dtls_prng(c->cookie_secret, DTLS_COOKIE_SECRET_LENGTH)) c->cookie_secret_age = now; - else + else goto error; - + return c; error: @@ -3835,7 +3835,7 @@ dtls_connect_peer(dtls_context_t *ctx, dtls_peer_t *peer) { dtls_debug("found peer, try to re-connect\n"); return dtls_renegotiate(ctx, &peer->session); } - + /* set local peer role to client, remote is server */ peer->role = DTLS_CLIENT; @@ -3852,7 +3852,7 @@ dtls_connect_peer(dtls_context_t *ctx, dtls_peer_t *peer) { res = dtls_send_client_hello(ctx, peer, NULL, 0); if (res < 0) dtls_warn("cannot send ClientHello\n"); - else + else peer->state = DTLS_STATE_CLIENTHELLO; return res; @@ -3864,7 +3864,7 @@ dtls_connect(dtls_context_t *ctx, const session_t *dst) { int res; peer = dtls_get_peer(ctx, dst); - + if (!peer) peer = dtls_new_peer(dst); @@ -3882,7 +3882,7 @@ dtls_connect(dtls_context_t *ctx, const session_t *dst) { } else if (res == 0) { CALL(ctx, event, &peer->session, 0, DTLS_EVENT_RENEGOTIATE); } - + return res; } @@ -3905,7 +3905,7 @@ dtls_retransmit(dtls_context_t *context, netq_t *node) { node->retransmit_cnt++; node->t = now + (node->timeout << node->retransmit_cnt); netq_insert_node(context->sendqueue, node); - + if (node->type == DTLS_CT_HANDSHAKE) { dtls_handshake_header_t *hs_header = DTLS_HANDSHAKE_HEADER(data); @@ -3914,7 +3914,7 @@ dtls_retransmit(dtls_context_t *context, netq_t *node) { } else { dtls_debug("** retransmit packet\n"); } - + err = dtls_prepare_record(node->peer, security, node->type, &data, &length, 1, sendbuf, &len); if (err < 0) { @@ -3930,7 +3930,7 @@ dtls_retransmit(dtls_context_t *context, netq_t *node) { } /* no more retransmissions, remove node from system */ - + dtls_debug("** removed transaction\n"); /* And finally delete the node */ @@ -3940,7 +3940,7 @@ dtls_retransmit(dtls_context_t *context, netq_t *node) { static void dtls_stop_retransmission(dtls_context_t *context, dtls_peer_t *peer) { netq_t *node; - node = list_head(context->sendqueue); + node = list_head(context->sendqueue); while (node) { if (dtls_session_equals(&node->peer->session, &peer->session)) { @@ -3949,7 +3949,7 @@ dtls_stop_retransmission(dtls_context_t *context, dtls_peer_t *peer) { list_remove(context->sendqueue, tmp); netq_node_free(tmp); } else - node = list_item_next(node); + node = list_item_next(node); } } @@ -3986,9 +3986,9 @@ PROCESS_THREAD(dtls_retransmit_process, ev, data) PROCESS_YIELD(); if (ev == PROCESS_EVENT_TIMER) { if (etimer_expired(&the_dtls_context.retransmit_timer)) { - + node = list_head(the_dtls_context.sendqueue); - + now = clock_time(); if (node && node->t <= now) { dtls_retransmit(&the_dtls_context, list_pop(the_dtls_context.sendqueue)); @@ -3997,15 +3997,15 @@ PROCESS_THREAD(dtls_retransmit_process, ev, data) /* need to set timer to some value even if no nextpdu is available */ if (node) { - etimer_set(&the_dtls_context.retransmit_timer, + etimer_set(&the_dtls_context.retransmit_timer, node->t <= now ? 1 : node->t - now); } else { etimer_set(&the_dtls_context.retransmit_timer, 0xFFFF); } - } + } } } - + PROCESS_END(); } #endif /* WITH_CONTIKI */ diff --git a/external/wakaama/examples/shared/tinydtls/dtls_debug.c b/external/wakaama/examples/shared/tinydtls/dtls_debug.c index c7ba2f4..cc74e33 100644 --- a/external/wakaama/examples/shared/tinydtls/dtls_debug.c +++ b/external/wakaama/examples/shared/tinydtls/dtls_debug.c @@ -55,7 +55,7 @@ const char *dtls_package_version() { return PACKAGE_VERSION; } -log_t +log_t dtls_get_log_level() { return maxlog; } @@ -67,7 +67,7 @@ dtls_set_log_level(log_t level) { /* this array has the same order as the type log_t */ static char *loglevels[] = { - "EMRG", "ALRT", "CRIT", "WARN", "NOTE", "INFO", "DEBG" + "EMRG", "ALRT", "CRIT", "WARN", "NOTE", "INFO", "DEBG" }; #ifdef HAVE_TIME_H @@ -84,8 +84,8 @@ print_timestamp(char *s, size_t len, time_t t) { static inline size_t print_timestamp(char *s, size_t len, clock_time_t t) { #ifdef HAVE_SNPRINTF - return snprintf(s, len, "%u.%03u", - (unsigned int)(t / CLOCK_SECOND), + return snprintf(s, len, "%u.%03u", + (unsigned int)(t / CLOCK_SECOND), (unsigned int)(t % CLOCK_SECOND)); #else /* HAVE_SNPRINTF */ /* @todo do manual conversion of timestamp */ @@ -95,12 +95,12 @@ print_timestamp(char *s, size_t len, clock_time_t t) { #endif /* HAVE_TIME_H */ -/** - * A length-safe strlen() fake. - * +/** + * A length-safe strlen() fake. + * * @param s The string to count characters != 0. * @param maxlen The maximum length of @p s. - * + * * @return The length of @p s. */ static inline size_t @@ -123,10 +123,10 @@ dsrv_print_addr(const session_t *addr, char *buf, size_t len) { char *p = buf; switch (addr->addr.sa.sa_family) { - case AF_INET: + case AF_INET: if (len < INET_ADDRSTRLEN) return 0; - + addrptr = &addr->addr.sin.sin_addr; port = ntohs(addr->addr.sin.sin_port); break; @@ -155,7 +155,7 @@ dsrv_print_addr(const session_t *addr, char *buf, size_t len) { if (addr->addr.sa.sa_family == AF_INET6) { if (p < buf + len) { *p++ = ']'; - } else + } else return 0; } @@ -205,7 +205,7 @@ dsrv_print_addr(const session_t *addr, char *buf, size_t len) { } #ifndef WITH_CONTIKI -void +void dsrv_log(log_t level, char *format, ...) { static char timebuf[32]; va_list ap; @@ -219,7 +219,7 @@ dsrv_log(log_t level, char *format, ...) { if (print_timestamp(timebuf,sizeof(timebuf), time(NULL))) fprintf(log_fd, "%s ", timebuf); - if (level <= DTLS_LOG_DEBUG) + if (level <= DTLS_LOG_DEBUG) fprintf(log_fd, "%s ", loglevels[level]); va_start(ap, format); @@ -228,7 +228,7 @@ dsrv_log(log_t level, char *format, ...) { fflush(log_fd); } #elif defined (HAVE_VPRINTF) /* WITH_CONTIKI */ -void +void dsrv_log(log_t level, char *format, ...) { static char timebuf[32]; va_list ap; @@ -239,7 +239,7 @@ dsrv_log(log_t level, char *format, ...) { if (print_timestamp(timebuf,sizeof(timebuf), clock_time())) PRINTF("%s ", timebuf); - if (level <= DTLS_LOG_DEBUG) + if (level <= DTLS_LOG_DEBUG) PRINTF("%s ", loglevels[level]); va_start(ap, format); @@ -253,12 +253,12 @@ dsrv_log(log_t level, char *format, ...) { void hexdump(const unsigned char *packet, int length) { int n = 0; - while (length--) { + while (length--) { if (n % 16 == 0) printf("%08X ",n); printf("%02X ", *packet++); - + n++; if (n % 8 == 0) { if (n % 16 == 0) @@ -271,7 +271,7 @@ void hexdump(const unsigned char *packet, int length) { /** dump as narrow string of hex digits */ void dump(unsigned char *buf, size_t len) { - while (len--) + while (len--) printf("%02x", *buf++); } @@ -287,7 +287,7 @@ void dtls_dsrv_log_addr(log_t level, const char *name, const int *addr) } #ifndef WITH_CONTIKI -void +void dtls_dsrv_hexdump_log(log_t level, const char *name, const unsigned char *buf, size_t length, int extend) { static char timebuf[32]; FILE *log_fd; @@ -301,7 +301,7 @@ dtls_dsrv_hexdump_log(log_t level, const char *name, const unsigned char *buf, s if (print_timestamp(timebuf, sizeof(timebuf), time(NULL))) fprintf(log_fd, "%s ", timebuf); - if (level <= DTLS_LOG_DEBUG) + if (level <= DTLS_LOG_DEBUG) fprintf(log_fd, "%s ", loglevels[level]); if (extend) { @@ -323,7 +323,7 @@ dtls_dsrv_hexdump_log(log_t level, const char *name, const unsigned char *buf, s } } else { fprintf(log_fd, "%s: (%zu bytes): ", name, length); - while (length--) + while (length--) fprintf(log_fd, "%02X", *buf++); } fprintf(log_fd, "\n"); @@ -331,7 +331,7 @@ dtls_dsrv_hexdump_log(log_t level, const char *name, const unsigned char *buf, s fflush(log_fd); } #else /* WITH_CONTIKI */ -void +void dtls_dsrv_hexdump_log(log_t level, const char *name, const unsigned char *buf, size_t length, int extend) { static char timebuf[32]; int n = 0; @@ -342,7 +342,7 @@ dtls_dsrv_hexdump_log(log_t level, const char *name, const unsigned char *buf, s if (print_timestamp(timebuf,sizeof(timebuf), clock_time())) PRINTF("%s ", timebuf); - if (level >= 0 && level <= DTLS_LOG_DEBUG) + if (level >= 0 && level <= DTLS_LOG_DEBUG) PRINTF("%s ", loglevels[level]); if (extend) { @@ -364,7 +364,7 @@ dtls_dsrv_hexdump_log(log_t level, const char *name, const unsigned char *buf, s } } else { PRINTF("%s: (%zu bytes): ", name, length); - while (length--) + while (length--) PRINTF("%02X", *buf++); } PRINTF("\n"); diff --git a/external/wakaama/examples/shared/tinydtls/dtls_time.c b/external/wakaama/examples/shared/tinydtls/dtls_time.c index 88c292a..cb38b20 100644 --- a/external/wakaama/examples/shared/tinydtls/dtls_time.c +++ b/external/wakaama/examples/shared/tinydtls/dtls_time.c @@ -56,8 +56,8 @@ dtls_clock_init(void) { dtls_clock_offset = time(NULL); #else # ifdef __GNUC__ - /* Issue a warning when using gcc. Other prepropressors do - * not seem to have a similar feature. */ + /* Issue a warning when using gcc. Other prepropressors do + * not seem to have a similar feature. */ # warning "cannot initialize clock" # endif dtls_clock_offset = 0; @@ -68,7 +68,7 @@ void dtls_ticks(dtls_tick_t *t) { #ifdef HAVE_SYS_TIME_H struct timeval tv; gettimeofday(&tv, NULL); - *t = (tv.tv_sec - dtls_clock_offset) * DTLS_TICKS_PER_SECOND + *t = (tv.tv_sec - dtls_clock_offset) * DTLS_TICKS_PER_SECOND + (tv.tv_usec * DTLS_TICKS_PER_SECOND / 1000000); #else #error "clock not implemented" diff --git a/external/wakaama/examples/shared/tinydtls/ecc/ecc.c b/external/wakaama/examples/shared/tinydtls/ecc/ecc.c index c6c8497..3c75a83 100644 --- a/external/wakaama/examples/shared/tinydtls/ecc/ecc.c +++ b/external/wakaama/examples/shared/tinydtls/ecc/ecc.c @@ -50,7 +50,7 @@ static uint32_t add( const uint32_t *x, const uint32_t *y, uint32_t *result, uin result[v] = d; d = d>>32; //save carry } - + return (uint32_t)d; } @@ -62,7 +62,7 @@ static uint32_t sub( const uint32_t *x, const uint32_t *y, uint32_t *result, uin result[v] = d & 0xFFFFFFFF; d = d>>32; d &= 0x1; - } + } return (uint32_t)d; } @@ -80,7 +80,7 @@ static void rshiftby(const uint32_t *in, uint8_t in_size, uint32_t *out, uint8_t static const uint32_t ecc_prime_m[8] = {0xffffffff, 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0xffffffff}; - + /* This is added after an static byte addition if the answer has a carry in MSB*/ static const uint32_t ecc_prime_r[8] = {0x00000001, 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff, 0xfffffffe, 0x00000000}; @@ -163,7 +163,7 @@ static int fieldMult(const uint32_t *x, const uint32_t *y, uint32_t *result, uin uint8_t k, n; uint64_t l; for (k = 0; k < length; k++){ - for (n = 0; n < length; n++){ + for (n = 0; n < length; n++){ l = (uint64_t)x[n]*(uint64_t)y[k]; temp[n+k] = l&0xFFFFFFFF; temp[n+k+1] = l>>32; @@ -184,66 +184,66 @@ static void fieldModP(uint32_t *A, const uint32_t *B) uint8_t n; setZero(tempm, 8); setZero(tempm2, 8); - /* A = T */ + /* A = T */ copy(B,A,arrayLength); - /* Form S1 */ - for(n=0;n<3;n++) tempm[n]=0; + /* Form S1 */ + for(n=0;n<3;n++) tempm[n]=0; for(n=3;n<8;n++) tempm[n]=B[n+8]; - /* tempm2=T+S1 */ + /* tempm2=T+S1 */ fieldAdd(A,tempm,ecc_prime_r,tempm2); - /* A=T+S1+S1 */ + /* A=T+S1+S1 */ fieldAdd(tempm2,tempm,ecc_prime_r,A); - /* Form S2 */ - for(n=0;n<3;n++) tempm[n]=0; - for(n=3;n<7;n++) tempm[n]=B[n+9]; + /* Form S2 */ + for(n=0;n<3;n++) tempm[n]=0; + for(n=3;n<7;n++) tempm[n]=B[n+9]; for(n=7;n<8;n++) tempm[n]=0; - /* tempm2=T+S1+S1+S2 */ + /* tempm2=T+S1+S1+S2 */ fieldAdd(A,tempm,ecc_prime_r,tempm2); - /* A=T+S1+S1+S2+S2 */ + /* A=T+S1+S1+S2+S2 */ fieldAdd(tempm2,tempm,ecc_prime_r,A); - /* Form S3 */ - for(n=0;n<3;n++) tempm[n]=B[n+8]; - for(n=3;n<6;n++) tempm[n]=0; + /* Form S3 */ + for(n=0;n<3;n++) tempm[n]=B[n+8]; + for(n=3;n<6;n++) tempm[n]=0; for(n=6;n<8;n++) tempm[n]=B[n+8]; - /* tempm2=T+S1+S1+S2+S2+S3 */ + /* tempm2=T+S1+S1+S2+S2+S3 */ fieldAdd(A,tempm,ecc_prime_r,tempm2); - /* Form S4 */ - for(n=0;n<3;n++) tempm[n]=B[n+9]; - for(n=3;n<6;n++) tempm[n]=B[n+10]; - for(n=6;n<7;n++) tempm[n]=B[n+7]; + /* Form S4 */ + for(n=0;n<3;n++) tempm[n]=B[n+9]; + for(n=3;n<6;n++) tempm[n]=B[n+10]; + for(n=6;n<7;n++) tempm[n]=B[n+7]; for(n=7;n<8;n++) tempm[n]=B[n+1]; - /* A=T+S1+S1+S2+S2+S3+S4 */ + /* A=T+S1+S1+S2+S2+S3+S4 */ fieldAdd(tempm2,tempm,ecc_prime_r,A); - /* Form D1 */ - for(n=0;n<3;n++) tempm[n]=B[n+11]; - for(n=3;n<6;n++) tempm[n]=0; - for(n=6;n<7;n++) tempm[n]=B[n+2]; + /* Form D1 */ + for(n=0;n<3;n++) tempm[n]=B[n+11]; + for(n=3;n<6;n++) tempm[n]=0; + for(n=6;n<7;n++) tempm[n]=B[n+2]; for(n=7;n<8;n++) tempm[n]=B[n+3]; - /* tempm2=T+S1+S1+S2+S2+S3+S4-D1 */ + /* tempm2=T+S1+S1+S2+S2+S3+S4-D1 */ fieldSub(A,tempm,ecc_prime_m,tempm2); - /* Form D2 */ - for(n=0;n<4;n++) tempm[n]=B[n+12]; - for(n=4;n<6;n++) tempm[n]=0; - for(n=6;n<7;n++) tempm[n]=B[n+3]; + /* Form D2 */ + for(n=0;n<4;n++) tempm[n]=B[n+12]; + for(n=4;n<6;n++) tempm[n]=0; + for(n=6;n<7;n++) tempm[n]=B[n+3]; for(n=7;n<8;n++) tempm[n]=B[n+4]; - /* A=T+S1+S1+S2+S2+S3+S4-D1-D2 */ + /* A=T+S1+S1+S2+S2+S3+S4-D1-D2 */ fieldSub(tempm2,tempm,ecc_prime_m,A); - /* Form D3 */ - for(n=0;n<3;n++) tempm[n]=B[n+13]; - for(n=3;n<6;n++) tempm[n]=B[n+5]; - for(n=6;n<7;n++) tempm[n]=0; + /* Form D3 */ + for(n=0;n<3;n++) tempm[n]=B[n+13]; + for(n=3;n<6;n++) tempm[n]=B[n+5]; + for(n=6;n<7;n++) tempm[n]=0; for(n=7;n<8;n++) tempm[n]=B[n+5]; - /* tempm2=T+S1+S1+S2+S2+S3+S4-D1-D2-D3 */ + /* tempm2=T+S1+S1+S2+S2+S3+S4-D1-D2-D3 */ fieldSub(A,tempm,ecc_prime_m,tempm2); - /* Form D4 */ - for(n=0;n<2;n++) tempm[n]=B[n+14]; - for(n=2;n<3;n++) tempm[n]=0; - for(n=3;n<6;n++) tempm[n]=B[n+6]; - for(n=6;n<7;n++) tempm[n]=0; + /* Form D4 */ + for(n=0;n<2;n++) tempm[n]=B[n+14]; + for(n=2;n<3;n++) tempm[n]=0; + for(n=3;n<6;n++) tempm[n]=B[n+6]; + for(n=6;n<7;n++) tempm[n]=0; for(n=7;n<8;n++) tempm[n]=B[n+6]; - /* A=T+S1+S1+S2+S2+S3+S4-D1-D2-D3-D4 */ + /* A=T+S1+S1+S2+S2+S3+S4-D1-D2-D3-D4 */ fieldSub(tempm2,tempm,ecc_prime_m,A); if(isGreater(A, ecc_prime_m, arrayLength) >= 0){ fieldSub(A, ecc_prime_m, ecc_prime_m, tempm); @@ -260,9 +260,9 @@ static void fieldModP(uint32_t *A, const uint32_t *B) * result: result of modulo calculation (max 36 bytes) * size: size of A * - * This uses the Barrett modular reduction as described in the Handbook - * of Applied Cryptography 14.42 Algorithm Barrett modular reduction, - * see http://cacr.uwaterloo.ca/hac/about/chap14.pdf and + * This uses the Barrett modular reduction as described in the Handbook + * of Applied Cryptography 14.42 Algorithm Barrett modular reduction, + * see http://cacr.uwaterloo.ca/hac/about/chap14.pdf and * http://everything2.com/title/Barrett+Reduction * * b = 32 (bite size of the processor architecture) @@ -300,14 +300,14 @@ static void fieldModO(const uint32_t *A, uint32_t *result, uint8_t length) { } static int isOne(const uint32_t* A){ - uint8_t n; - for(n=1;n<8;n++) - if (A[n]!=0) + uint8_t n; + for(n=1;n<8;n++) + if (A[n]!=0) break; - if ((n==8)&&(A[0]==1)) + if ((n==8)&&(A[0]==1)) return 1; - else + else return 0; } @@ -342,7 +342,7 @@ static int fieldAddAndDivide(const uint32_t *x, const uint32_t *modulus, const u add(result, reducer, tempas, 8); copy(tempas, result, arrayLength); } - + } return 0; } @@ -360,12 +360,12 @@ static void fieldInv(const uint32_t *A, const uint32_t *modulus, const uint32_t setZero(v, 8); uint8_t t; - copy(A,u,arrayLength); - copy(modulus,v,arrayLength); + copy(A,u,arrayLength); + copy(modulus,v,arrayLength); setZero(x1, 8); setZero(x2, 8); - x1[0]=1; - /* While u !=1 and v !=1 */ + x1[0]=1; + /* While u !=1 and v !=1 */ while ((isOne(u) || isOne(v))==0) { while(!(u[0]&1)) { /* While u is even */ rshift(u); /* divide by 2 */ @@ -376,19 +376,19 @@ static void fieldInv(const uint32_t *A, const uint32_t *modulus, const uint32_t copy(tempm,x1,arrayLength); /* x1=tempm */ //rshift(x1); /* Divide by 2 */ } - } + } while(!(v[0]&1)) { /* While v is even */ - rshift(v); /* divide by 2 */ + rshift(v); /* divide by 2 */ if (!(x2[0]&1)) /*ifx1iseven*/ rshift(x2); /* Divide by 2 */ else { fieldAddAndDivide(x2,modulus,reducer,tempm); /* tempm=x1+p */ - copy(tempm,x2,arrayLength); /* x1=tempm */ + copy(tempm,x2,arrayLength); /* x1=tempm */ //rshift(x2); /* Divide by 2 */ } - - } + + } t=sub(u,v,tempm,arrayLength); /* tempm=u-v */ if (t==0) { /* If u > 0 */ copy(tempm,u,arrayLength); /* u=u-v */ @@ -400,9 +400,9 @@ static void fieldInv(const uint32_t *A, const uint32_t *modulus, const uint32_t fieldSub(x2,x1,modulus,tempm); /* tempm=x2-x1 */ copy(tempm,x2,arrayLength); /* x2=x2-x1 */ } - } + } if (isOne(u)) { - copy(x1,B,arrayLength); + copy(x1,B,arrayLength); } else { copy(x2,B,arrayLength); } @@ -474,7 +474,7 @@ void static ec_add(const uint32_t *px, const uint32_t *py, const uint32_t *qx, c fieldSub(py, qy, ecc_prime_m, tempA); fieldSub(px, qx, ecc_prime_m, tempB); fieldInv(tempB, ecc_prime_m, ecc_prime_r, tempB); - fieldMult(tempA, tempB, tempD, arrayLength); + fieldMult(tempA, tempB, tempD, arrayLength); fieldModP(tempC, tempD); //tempC = lambda fieldMult(tempC, tempC, tempD, arrayLength); //tempA = lambda^2 diff --git a/external/wakaama/examples/shared/tinydtls/ecc/testecc.c b/external/wakaama/examples/shared/tinydtls/ecc/testecc.c index b36d46b..4f4cf0a 100644 --- a/external/wakaama/examples/shared/tinydtls/ecc/testecc.c +++ b/external/wakaama/examples/shared/tinydtls/ecc/testecc.c @@ -60,7 +60,7 @@ uint32_t BasePointy[8] = { 0x37bf51f5, 0xcbb64068, 0x6b315ece, 0x2bce3357, 0x7c0f9e16, 0x8ee7eb4a, 0xfe1a7f9b, 0x4fe342e2}; //de2444be bc8d36e6 82edd27e 0f271508 617519b3 221a8fa0 b77cab39 89da97c9 -uint32_t Sx[8] = { 0x89da97c9, 0xb77cab39, 0x221a8fa0, 0x617519b3, +uint32_t Sx[8] = { 0x89da97c9, 0xb77cab39, 0x221a8fa0, 0x617519b3, 0x0f271508, 0x82edd27e, 0xbc8d36e6, 0xde2444be}; //c093ae7f f36e5380 fc01a5aa d1e66659 702de80f 53cec576 b6350b24 3042a256 @@ -78,7 +78,7 @@ uint32_t Ty[8] = { 0xc8b24316, 0xb656e9d8, 0x598b9e7a, 0xf61a8a52, //c51e4753 afdec1e6 b6c6a5b9 92f43f8d d0c7a893 3072708b 6522468b 2ffb06fd uint32_t secret[8] = { 0x2ffb06fd, 0x6522468b, 0x3072708b, 0xd0c7a893, 0x92f43f8d, 0xb6c6a5b9, 0xafdec1e6, 0xc51e4753}; - + //72b13dd4 354b6b81 745195e9 8cc5ba69 70349191 ac476bd4 553cf35a 545a067e uint32_t resultAddx[8] = { 0x545a067e, 0x553cf35a, 0xac476bd4, 0x70349191, 0x8cc5ba69, 0x745195e9, 0x354b6b81, 0x72b13dd4}; @@ -150,7 +150,7 @@ void eccdhTest(){ uint32_t tempBx1[8]; uint32_t tempBy1[8]; uint32_t tempBx2[8]; - uint32_t tempBy2[8]; + uint32_t tempBy2[8]; uint32_t secretA[8]; uint32_t secretB[8]; ecc_setRandom(secretA); diff --git a/external/wakaama/examples/shared/tinydtls/examples/contiki/dtls-client.c b/external/wakaama/examples/shared/tinydtls/examples/contiki/dtls-client.c index b1af669..cc020e0 100644 --- a/external/wakaama/examples/shared/tinydtls/examples/contiki/dtls-client.c +++ b/external/wakaama/examples/shared/tinydtls/examples/contiki/dtls-client.c @@ -97,7 +97,7 @@ try_send(struct dtls_context_t *ctx, session_t *dst) { } static int -read_from_peer(struct dtls_context_t *ctx, +read_from_peer(struct dtls_context_t *ctx, session_t *session, uint8 *data, size_t len) { size_t i; for (i = 0; i < len; i++) @@ -106,7 +106,7 @@ read_from_peer(struct dtls_context_t *ctx, } static int -send_to_peer(struct dtls_context_t *ctx, +send_to_peer(struct dtls_context_t *ctx, session_t *session, uint8 *data, size_t len) { struct uip_udp_conn *conn = (struct uip_udp_conn *)dtls_get_app_data(ctx); @@ -327,11 +327,11 @@ PROCESS_THREAD(udp_server_process, ev, data) if (buflen) { if (!connected) connected = dtls_connect(dtls_context, &dst) >= 0; - + try_send(dtls_context, &dst); } } - + PROCESS_END(); } /*---------------------------------------------------------------------------*/ diff --git a/external/wakaama/examples/shared/tinydtls/examples/contiki/dtls-server.c b/external/wakaama/examples/shared/tinydtls/examples/contiki/dtls-server.c index d9269a8..7a25a56 100644 --- a/external/wakaama/examples/shared/tinydtls/examples/contiki/dtls-server.c +++ b/external/wakaama/examples/shared/tinydtls/examples/contiki/dtls-server.c @@ -79,7 +79,7 @@ static const unsigned char ecdsa_pub_key_y[] = { 0x17, 0xDE, 0x43, 0xF9, 0xF9, 0xAD, 0xEE, 0x70}; static int -read_from_peer(struct dtls_context_t *ctx, +read_from_peer(struct dtls_context_t *ctx, session_t *session, uint8 *data, size_t len) { size_t i; for (i = 0; i < len; i++) @@ -91,7 +91,7 @@ read_from_peer(struct dtls_context_t *ctx, } static int -send_to_peer(struct dtls_context_t *ctx, +send_to_peer(struct dtls_context_t *ctx, session_t *session, uint8 *data, size_t len) { struct uip_udp_conn *conn = (struct uip_udp_conn *)dtls_get_app_data(ctx); @@ -196,7 +196,7 @@ dtls_handle_read(dtls_context_t *ctx) { uip_ipaddr_copy(&session.addr, &UIP_IP_BUF->srcipaddr); session.port = UIP_UDP_BUF->srcport; session.size = sizeof(session.addr) + sizeof(session.port); - + dtls_handle_message(ctx, &session, uip_appdata, uip_datalen()); } } @@ -228,7 +228,7 @@ create_rpl_dag(uip_ipaddr_t *ipaddr) if(root_if != NULL) { rpl_dag_t *dag; uip_ipaddr_t prefix; - + rpl_set_root(RPL_DEFAULT_INSTANCE, ipaddr); dag = rpl_get_any_dag(); uip_ip6addr(&prefix, 0xaaaa, 0, 0, 0, 0, 0, 0, 0); @@ -310,7 +310,7 @@ PROCESS_THREAD(udp_server_process, ev, data) } #ifdef ENABLE_POWERTRACE - powertrace_start(CLOCK_SECOND * 2); + powertrace_start(CLOCK_SECOND * 2); #endif while(1) { diff --git a/external/wakaama/examples/shared/tinydtls/hmac.c b/external/wakaama/examples/shared/tinydtls/hmac.c index b8b1614..5285cdc 100644 --- a/external/wakaama/examples/shared/tinydtls/hmac.c +++ b/external/wakaama/examples/shared/tinydtls/hmac.c @@ -84,7 +84,7 @@ dtls_hmac_new(const unsigned char *key, size_t klen) { dtls_hmac_context_t *ctx; ctx = dtls_hmac_context_new(); - if (ctx) + if (ctx) dtls_hmac_init(ctx, key, klen); return ctx; @@ -126,11 +126,11 @@ dtls_hmac_free(dtls_hmac_context_t *ctx) { int dtls_hmac_finalize(dtls_hmac_context_t *ctx, unsigned char *result) { unsigned char buf[DTLS_HMAC_DIGEST_SIZE]; - size_t len; + size_t len; assert(ctx); assert(result); - + len = dtls_hash_finalize(buf, &ctx->data); dtls_hash_init(&ctx->data); @@ -159,10 +159,10 @@ int main(int argc, char **argv) { ctx = dtls_hmac_new(argv[1], strlen(argv[1])); assert(ctx); dtls_hmac_update(ctx, argv[2], strlen(argv[2])); - + len = dtls_hmac_finalize(ctx, buf); - for(i = 0; i < len; i++) + for(i = 0; i < len; i++) printf("%02x", buf[i]); printf("\n"); diff --git a/external/wakaama/examples/shared/tinydtls/netq.c b/external/wakaama/examples/shared/tinydtls/netq.c index 4148334..b3ed8f9 100644 --- a/external/wakaama/examples/shared/tinydtls/netq.c +++ b/external/wakaama/examples/shared/tinydtls/netq.c @@ -57,7 +57,7 @@ netq_init() { } #endif /* WITH_CONTIKI */ -int +int netq_insert_node(list_t queue, netq_t *node) { netq_t *p; @@ -120,21 +120,21 @@ netq_node_new(size_t size) { if (node) memset(node, 0, sizeof(netq_t)); - return node; + return node; } -void +void netq_node_free(netq_t *node) { if (node) netq_free_node(node); } -void +void netq_delete_all(list_t queue) { netq_t *p; if (queue) { while((p = list_pop(queue))) - netq_free_node(p); + netq_free_node(p); } } diff --git a/external/wakaama/examples/shared/tinydtls/session.c b/external/wakaama/examples/shared/tinydtls/session.c index 9acf565..6edfd8a 100644 --- a/external/wakaama/examples/shared/tinydtls/session.c +++ b/external/wakaama/examples/shared/tinydtls/session.c @@ -44,23 +44,23 @@ #else /* WITH_CONTIKI */ -static inline int +static inline int _dtls_address_equals_impl(const session_t *a, const session_t *b) { if (a->ifindex != b->ifindex || a->size != b->size || a->addr.sa.sa_family != b->addr.sa.sa_family) return 0; - + /* need to compare only relevant parts of sockaddr_in6 */ switch (a->addr.sa.sa_family) { case AF_INET: - return - a->addr.sin.sin_port == b->addr.sin.sin_port && - memcmp(&a->addr.sin.sin_addr, &b->addr.sin.sin_addr, + return + a->addr.sin.sin_port == b->addr.sin.sin_port && + memcmp(&a->addr.sin.sin_addr, &b->addr.sin.sin_addr, sizeof(struct in_addr)) == 0; case AF_INET6: - return a->addr.sin6.sin6_port == b->addr.sin6.sin6_port && - memcmp(&a->addr.sin6.sin6_addr, &b->addr.sin6.sin6_addr, + return a->addr.sin6.sin6_port == b->addr.sin6.sin6_port && + memcmp(&a->addr.sin6.sin6_addr, &b->addr.sin6.sin6_addr, sizeof(struct in6_addr)) == 0; default: /* fall through and signal error */ ; diff --git a/external/wakaama/examples/shared/tinydtls/sha2/sha2.c b/external/wakaama/examples/shared/tinydtls/sha2/sha2.c index 2578f17..f948049 100644 --- a/external/wakaama/examples/shared/tinydtls/sha2/sha2.c +++ b/external/wakaama/examples/shared/tinydtls/sha2/sha2.c @@ -1,7 +1,7 @@ /* * FILE: sha2.c * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/ - * + * * Copyright (c) 2000-2001, Aaron D. Gifford * All rights reserved. * @@ -16,7 +16,7 @@ * 3. Neither the name of the copyright holder nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -83,7 +83,7 @@ * * And for little-endian machines, add: * - * #define BYTE_ORDER LITTLE_ENDIAN + * #define BYTE_ORDER LITTLE_ENDIAN * * Or for big-endian machines: * @@ -516,11 +516,11 @@ void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) { /* Part of the message block expansion: */ s0 = W256[(j+1)&0x0f]; s0 = sigma0_256(s0); - s1 = W256[(j+14)&0x0f]; + s1 = W256[(j+14)&0x0f]; s1 = sigma1_256(s1); /* Apply the SHA-256 compression function to update a..h */ - T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + + T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); T2 = Sigma0_256(a) + Maj(a, b, c); h = g; diff --git a/external/wakaama/examples/shared/tinydtls/sha2/sha2prog.c b/external/wakaama/examples/shared/tinydtls/sha2/sha2prog.c index 8d9d6ae..7470b9e 100644 --- a/external/wakaama/examples/shared/tinydtls/sha2/sha2prog.c +++ b/external/wakaama/examples/shared/tinydtls/sha2/sha2prog.c @@ -1,7 +1,7 @@ /* * FILE: sha2prog.c * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/ - * + * * Copyright (c) 2000-2001, Aaron D. Gifford * All rights reserved. * @@ -16,7 +16,7 @@ * 3. Neither the name of the copyright holder nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/external/wakaama/examples/shared/tinydtls/sha2/sha2speed.c b/external/wakaama/examples/shared/tinydtls/sha2/sha2speed.c index 2e13575..5a567f6 100644 --- a/external/wakaama/examples/shared/tinydtls/sha2/sha2speed.c +++ b/external/wakaama/examples/shared/tinydtls/sha2/sha2speed.c @@ -1,7 +1,7 @@ /* * FILE: sha2speed.c * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/ - * + * * Copyright (c) 2000-2001, Aaron D. Gifford * All rights reserved. * @@ -16,7 +16,7 @@ * 3. Neither the name of the copyright holder nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -100,7 +100,7 @@ int main(int argc, char **argv) { SHA256_Init(&c256); SHA384_Init(&c384); SHA512_Init(&c512); - + gettimeofday(&start, (struct timezone*)0); for (j = 0; j < blocks; j++) { SHA256_Update(&c256, (unsigned char*)buf, BUFSIZE); diff --git a/external/wakaama/examples/shared/tinydtls/tests/ccm-test.c b/external/wakaama/examples/shared/tinydtls/tests/ccm-test.c index cbb7d2a..568f3e3 100644 --- a/external/wakaama/examples/shared/tinydtls/tests/ccm-test.c +++ b/external/wakaama/examples/shared/tinydtls/tests/ccm-test.c @@ -26,7 +26,7 @@ int fls(unsigned int i) { } #endif -void +void dump(unsigned char *buf, size_t len) { size_t i = 0; while (i < len) { @@ -63,28 +63,28 @@ int main(int argc, char **argv) { return -1; } - len = dtls_ccm_encrypt_message(&ctx, data[n].M, data[n].L, data[n].nonce, - data[n].msg + data[n].la, - data[n].lm - data[n].la, + len = dtls_ccm_encrypt_message(&ctx, data[n].M, data[n].L, data[n].nonce, + data[n].msg + data[n].la, + data[n].lm - data[n].la, data[n].msg, data[n].la); - + len += + data[n].la; printf("Packet Vector #%d ", n+1); if (len != data[n].r_lm || memcmp(data[n].msg, data[n].result, len)) printf("FAILED, "); - else + else printf("OK, "); - + printf("result is (total length = %lu):\n\t", len); dump(data[n].msg, len); - len = dtls_ccm_decrypt_message(&ctx, data[n].M, data[n].L, data[n].nonce, - data[n].msg + data[n].la, len - data[n].la, + len = dtls_ccm_decrypt_message(&ctx, data[n].M, data[n].L, data[n].nonce, + data[n].msg + data[n].la, len - data[n].la, data[n].msg, data[n].la); - + if (len < 0) printf("Packet Vector #%d: cannot decrypt message\n", n+1); - else + else printf("\t*** MAC verified (total length = %lu) ***\n", len + data[n].la); } diff --git a/external/wakaama/examples/shared/tinydtls/tests/ccm-testdata.c b/external/wakaama/examples/shared/tinydtls/tests/ccm-testdata.c index f0da4ae..efc9ea4 100644 --- a/external/wakaama/examples/shared/tinydtls/tests/ccm-testdata.c +++ b/external/wakaama/examples/shared/tinydtls/tests/ccm-testdata.c @@ -45,7 +45,7 @@ struct test_vector data[] = { 39, /* length of result */ { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x58, 0x8C, 0x97, 0x9A, 0x61, 0xC6, 0x63, 0xD2, 0xF0, 0x66, 0xD0, 0xC2, 0xC0, 0xF9, 0x89, 0x80, 0x6D, 0x5F, 0x6B, 0x61, 0xDA, 0xC3, 0x84, 0x17, 0xE8, 0xD1, 0x2C, 0xFD, 0xF9, 0x26, 0xE0} /* result */ }, - + /* #2 */ { 8, 2, 32, 8, { 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF}, /* AES key */ @@ -256,11 +256,11 @@ struct test_vector data[] = { /* #25 */ /* Cipher: AES-128 M=16 L=2 K_LEN=1 N_LEN=13 K=0x00 N=0x00000000000000000000000000 */ { 16, 2, 0, 0, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* AES key */ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* AES key */ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Nonce */ { }, /* msg */ 16, /* length of result */ - { 0x8b, 0x60, 0xab, 0xcd, 0x60, 0x43, 0x81, 0x0b, + { 0x8b, 0x60, 0xab, 0xcd, 0x60, 0x43, 0x81, 0x0b, 0xa3, 0x78, 0xa0, 0x1d, 0x4a, 0x29, 0x83, 0x0b } /* result */ }, @@ -268,11 +268,11 @@ struct test_vector data[] = { /* #26 */ /* Cipher: AES-128 M=16 L=2 K_LEN=1 N_LEN=13 K=0x00 N=0x00000000000000000000000000 */ { 16, 2, 37, 0, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* AES key */ - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* AES key */ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Nonce */ - { 0x45, 0x69, 0x6e, 0x20, 0x6b, 0x6c, 0x65, 0x69, + { 0x45, 0x69, 0x6e, 0x20, 0x6b, 0x6c, 0x65, 0x69, 0x6e, 0x65, 0x72, 0x20, 0x54, 0x65, 0x78, 0x74, 0x0a, 0x7a, 0x75, 0x6d, 0x20, 0x54, 0x65, 0x73, 0x74, 0x65, 0x6e, 0x20, 0x76, 0x6f, 0x6e, 0x20, @@ -281,7 +281,7 @@ struct test_vector data[] = { 53, /* length of result */ { 0x90, 0x11, 0x9c, 0x2d, 0x6b, 0xf9, 0xe9, 0x05, 0x3e, 0x0b, 0x44, 0x56, 0xca, 0xc8, 0xb6, 0x1a, - 0x00, 0x57, 0xa9, 0x8b, 0x6b, 0x69, 0x09, 0x7e, + 0x00, 0x57, 0xa9, 0x8b, 0x6b, 0x69, 0x09, 0x7e, 0x8e, 0x50, 0x50, 0x63, 0x50, 0x58, 0x0f, 0x78, 0x75, 0x69, 0x6e, 0x9f, 0x3d, 0x63, 0x93, 0xe7, 0x7a, 0x84, 0xe9, 0x9f, 0x11, 0x93, 0x95, 0xa0, @@ -308,7 +308,7 @@ struct test_vector data[] = { 0xef, 0xdc, 0xaf, 0xfe, 0xed, 0x39, 0x21, 0xee }, /* AES key */ { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 }, /* Nonce */ - { 0x45, 0x69, 0x6e, 0x20, 0x6b, 0x6c, 0x65, 0x69, + { 0x45, 0x69, 0x6e, 0x20, 0x6b, 0x6c, 0x65, 0x69, 0x6e, 0x65, 0x72, 0x20, 0x54, 0x65, 0x78, 0x74, 0x0a, 0x7a, 0x75, 0x6d, 0x20, 0x54, 0x65, 0x73, 0x74, 0x65, 0x6e, 0x20, 0x76, 0x6f, 0x6e, 0x20, @@ -344,7 +344,7 @@ struct test_vector data[] = { 0xef, 0xdc, 0xaf, 0xfe, 0xed, 0x39, 0x21, 0xee }, /* AES key */ { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x00 }, /* Nonce */ - { 0x45, 0x69, 0x6e, 0x20, 0x6b, 0x6c, 0x65, 0x69, + { 0x45, 0x69, 0x6e, 0x20, 0x6b, 0x6c, 0x65, 0x69, 0x6e, 0x65, 0x72, 0x20, 0x54, 0x65, 0x78, 0x74, 0x0a, 0x7a, 0x75, 0x6d, 0x20, 0x54, 0x65, 0x73, 0x74, 0x65, 0x6e, 0x20, 0x76, 0x6f, 0x6e, 0x20, @@ -378,7 +378,7 @@ struct test_vector data[] = { { 0x11, 0x22, 0x33, 0x44, 0xaa, 0xbb }, /* AES key */ { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99 }, /* Nonce */ - { 0x45, 0x69, 0x6e, 0x20, 0x6b, 0x6c, 0x65, 0x69, + { 0x45, 0x69, 0x6e, 0x20, 0x6b, 0x6c, 0x65, 0x69, 0x6e, 0x65, 0x72, 0x20, 0x54, 0x65, 0x78, 0x74, 0x0a, 0x7a, 0x75, 0x6d, 0x20, 0x54, 0x65, 0x73, 0x74, 0x65, 0x6e, 0x20, 0x76, 0x6f, 0x6e, 0x20, diff --git a/external/wakaama/examples/shared/tinydtls/tests/dtls-client.c b/external/wakaama/examples/shared/tinydtls/tests/dtls-client.c index 96ed0fa..8a2423d 100644 --- a/external/wakaama/examples/shared/tinydtls/tests/dtls-client.c +++ b/external/wakaama/examples/shared/tinydtls/tests/dtls-client.c @@ -1,4 +1,4 @@ -#include "tinydtls.h" +#include "tinydtls.h" /* This is needed for apple */ #define __APPLE_USE_RFC_3542 @@ -16,9 +16,9 @@ #include #include -#include "global.h" -#include "debug.h" -#include "dtls.h" +#include "global.h" +#include "debug.h" +#include "dtls.h" #define DEFAULT_PORT 20220 @@ -183,7 +183,7 @@ handle_stdin() { } static int -read_from_peer(struct dtls_context_t *ctx, +read_from_peer(struct dtls_context_t *ctx, session_t *session, uint8 *data, size_t len) { size_t i; for (i = 0; i < len; i++) @@ -192,7 +192,7 @@ read_from_peer(struct dtls_context_t *ctx, } static int -send_to_peer(struct dtls_context_t *ctx, +send_to_peer(struct dtls_context_t *ctx, session_t *session, uint8 *data, size_t len) { int fd = *(int *)dtls_get_app_data(ctx); @@ -209,15 +209,15 @@ dtls_handle_read(struct dtls_context_t *ctx) { int len; fd = *(int *)dtls_get_app_data(ctx); - + if (!fd) return -1; memset(&session, 0, sizeof(session_t)); session.size = sizeof(session.addr); - len = recvfrom(fd, buf, MAX_READ_BUF, 0, + len = recvfrom(fd, buf, MAX_READ_BUF, 0, &session.addr.sa, &session.size); - + if (len < 0) { perror("recvfrom"); return -1; @@ -227,7 +227,7 @@ dtls_handle_read(struct dtls_context_t *ctx) { } return dtls_handle_message(ctx, &session, buf, len); -} +} static void dtls_handle_signal(int sig) { @@ -239,7 +239,7 @@ static void dtls_handle_signal(int sig) /* stolen from libcoap: */ static int resolve_address(const char *server, struct sockaddr *dst) { - + struct addrinfo *res, *ainfo; struct addrinfo hints; static char addrstr[256]; @@ -321,7 +321,7 @@ static dtls_handler_t cb = { #define DTLS_CLIENT_CMD_CLOSE "client:close" #define DTLS_CLIENT_CMD_RENEGOTIATE "client:renegotiate" -int +int main(int argc, char **argv) { fd_set rfds, wfds; struct timeval timeout; @@ -372,7 +372,7 @@ main(int argc, char **argv) { case 'o' : output_file.length = strlen(optarg); output_file.s = (unsigned char *)malloc(output_file.length + 1); - + if (!output_file.s) { dtls_crit("cannot set output file: insufficient memory\n"); exit(-1); @@ -391,12 +391,12 @@ main(int argc, char **argv) { } dtls_set_log_level(log_level); - + if (argc <= optind) { usage(argv[0], dtls_package_version()); exit(1); } - + memset(&dst, 0, sizeof(session_t)); /* resolve destination address where server should be sent */ res = resolve_address(argv[optind++], &dst.addr.sa); @@ -410,7 +410,7 @@ main(int argc, char **argv) { port, otherwise */ dst.addr.sin.sin_port = htons(atoi(optind < argc ? argv[optind++] : port_str)); - + /* init socket and set it to non-blocking */ fd = socket(dst.addr.sa.sa_family, SOCK_DGRAM, 0); @@ -460,12 +460,12 @@ main(int argc, char **argv) { FD_SET(fileno(stdin), &rfds); FD_SET(fd, &rfds); /* FD_SET(fd, &wfds); */ - + timeout.tv_sec = 5; timeout.tv_usec = 0; - + result = select(fd+1, &rfds, &wfds, 0, &timeout); - + if (result < 0) { /* error */ if (errno != EINTR) perror("select"); @@ -495,7 +495,7 @@ main(int argc, char **argv) { } } } - + dtls_free_context(dtls_context); exit(0); } diff --git a/external/wakaama/examples/shared/tinydtls/tests/dtls-server.c b/external/wakaama/examples/shared/tinydtls/tests/dtls-server.c index 3f030b1..49e5d28 100644 --- a/external/wakaama/examples/shared/tinydtls/tests/dtls-server.c +++ b/external/wakaama/examples/shared/tinydtls/tests/dtls-server.c @@ -14,9 +14,9 @@ #include #include -#include "tinydtls.h" -#include "dtls.h" -#include "debug.h" +#include "tinydtls.h" +#include "dtls.h" +#include "debug.h" #define DEFAULT_PORT 20220 @@ -124,7 +124,7 @@ verify_ecdsa_key(struct dtls_context_t *ctx, #define DTLS_SERVER_CMD_RENEGOTIATE "server:renegotiate" static int -read_from_peer(struct dtls_context_t *ctx, +read_from_peer(struct dtls_context_t *ctx, session_t *session, uint8 *data, size_t len) { size_t i; for (i = 0; i < len; i++) @@ -145,7 +145,7 @@ read_from_peer(struct dtls_context_t *ctx, } static int -send_to_peer(struct dtls_context_t *ctx, +send_to_peer(struct dtls_context_t *ctx, session_t *session, uint8 *data, size_t len) { int fd = *(int *)dtls_get_app_data(ctx); @@ -173,7 +173,7 @@ dtls_handle_read(struct dtls_context_t *ctx) { perror("recvfrom"); return -1; } else { - dtls_debug("got %d bytes from port %d\n", len, + dtls_debug("got %d bytes from port %d\n", len, ntohs(session.addr.sin6.sin6_port)); if (sizeof(buf) < len) { dtls_warn("packet was truncated (%d bytes lost)\n", len - sizeof(buf)); @@ -181,11 +181,11 @@ dtls_handle_read(struct dtls_context_t *ctx) { } return dtls_handle_message(ctx, &session, buf, len); -} +} static int resolve_address(const char *server, struct sockaddr *dst) { - + struct addrinfo *res, *ainfo; struct addrinfo hints; static char addrstr[256]; @@ -254,7 +254,7 @@ static dtls_handler_t cb = { #endif /* DTLS_ECC */ }; -int +int main(int argc, char **argv) { dtls_context_t *the_context = NULL; log_t log_level = DTLS_LOG_WARN; @@ -341,12 +341,12 @@ main(int argc, char **argv) { FD_SET(fd, &rfds); /* FD_SET(fd, &wfds); */ - + timeout.tv_sec = 5; timeout.tv_usec = 0; - + result = select( fd+1, &rfds, &wfds, 0, &timeout); - + if (result < 0) { /* error */ if (errno != EINTR) perror("select"); @@ -359,7 +359,7 @@ main(int argc, char **argv) { } } } - + error: dtls_free_context(the_context); exit(0); diff --git a/external/wakaama/examples/shared/tinydtls/tests/prf-test.c b/external/wakaama/examples/shared/tinydtls/tests/prf-test.c index d8d83d9..841dcd0 100644 --- a/external/wakaama/examples/shared/tinydtls/tests/prf-test.c +++ b/external/wakaama/examples/shared/tinydtls/tests/prf-test.c @@ -5,19 +5,19 @@ #include "global.h" #include "crypto.h" -int +int main() { /* see http://www.ietf.org/mail-archive/web/tls/current/msg03416.html */ - unsigned char key[] = { 0x9b, 0xbe, 0x43, 0x6b, 0xa9, 0x40, 0xf0, 0x17, + unsigned char key[] = { 0x9b, 0xbe, 0x43, 0x6b, 0xa9, 0x40, 0xf0, 0x17, 0xb1, 0x76, 0x52, 0x84, 0x9a, 0x71, 0xdb, 0x35 }; - unsigned char label[] = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6c, 0x61, 0x62, + unsigned char label[] = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c}; unsigned char random1[] = { 0xa0, 0xba, 0x9f, 0x93, 0x6c, 0xda, 0x31, 0x18}; unsigned char random2[] = {0x27, 0xa6, 0xf7, 0x96, 0xff, 0xd5, 0x19, 0x8c }; unsigned char buf[200]; size_t result; - + result = dtls_prf(key, sizeof(key), label, sizeof(label), random1, sizeof(random1), diff --git a/os/kernel/pthread/pthread_mutexlock.c b/os/kernel/pthread/pthread_mutexlock.c index 1ee4b67..fd170e5 100644 --- a/os/kernel/pthread/pthread_mutexlock.c +++ b/os/kernel/pthread/pthread_mutexlock.c @@ -181,7 +181,7 @@ int pthread_mutex_lock(FAR pthread_mutex_t *mutex) sdbg("Returning EDEADLK\n"); ret = EDEADLK; } - } else + } else #endif /* CONFIG_PTHREAD_MUTEX_TYPES */ @@ -209,7 +209,7 @@ int pthread_mutex_lock(FAR pthread_mutex_t *mutex) #endif /* CONFIG_PTHREAD_MUTEX_TYPES */ #else /* CONFIG_PTHREAD_MUTEX_ROBUST */ /* This mutex is always robust, whatever type it is. */ - if (mutex->pid > 0 && sched_gettcb(mutex->pid) == NULL) + if (mutex->pid > 0 && sched_gettcb(mutex->pid) == NULL) #endif { DEBUGASSERT(mutex->pid != 0); /* < 0: available, >0 owned, ==0 error */ @@ -223,7 +223,7 @@ int pthread_mutex_lock(FAR pthread_mutex_t *mutex) mutex->flags |= _PTHREAD_MFLAGS_INCONSISTENT; ret = EOWNERDEAD; - } else + } else #endif /* !CONFIG_PTHREAD_MUTEX_UNSAFE */ { diff --git a/os/kernel/pthread/pthread_mutextrylock.c b/os/kernel/pthread/pthread_mutextrylock.c index b71e796..1b66f51 100644 --- a/os/kernel/pthread/pthread_mutextrylock.c +++ b/os/kernel/pthread/pthread_mutextrylock.c @@ -197,7 +197,7 @@ int pthread_mutex_trylock(FAR pthread_mutex_t *mutex) #endif /* CONFIG_PTHREAD_MUTEX_TYPES */ #else /* CONFIG_PTHREAD_MUTEX_ROBUST */ /* This mutex is always robust, whatever type it is. */ - if (mutex->pid > 0 && sched_gettcb(mutex->pid) == NULL) + if (mutex->pid > 0 && sched_gettcb(mutex->pid) == NULL) #endif { DEBUGASSERT(mutex->pid != 0); /* < 0: available, >0 owned, ==0 error */ @@ -215,14 +215,14 @@ int pthread_mutex_trylock(FAR pthread_mutex_t *mutex) /* The mutex is locked by another, active thread */ - else + else #endif /* CONFIG_PTHREAD_MUTEX_UNSAFE */ { ret = EBUSY; } } - + /* Some other, unhandled error occurred */ else { ret = status; diff --git a/os/kernel/wdog/wd_delete.c b/os/kernel/wdog/wd_delete.c index c31d94c..d8dc688 100644 --- a/os/kernel/wdog/wd_delete.c +++ b/os/kernel/wdog/wd_delete.c @@ -161,7 +161,7 @@ int wd_delete(WDOG_ID wdog) DEBUGASSERT(g_wdnfree <= CONFIG_PREALLOC_WDOGS); irqrestore(state); } else { - /* There is no guarantee that, this API is not called for statically + /* There is no guarantee that, this API is not called for statically * allocated timers as wd_delete is a global function. So restore the * irq properly so that it does not break the system */ diff --git a/os/net/tls/ssl_cli.c b/os/net/tls/ssl_cli.c index 98230da..368fa5a 100644 --- a/os/net/tls/ssl_cli.c +++ b/os/net/tls/ssl_cli.c @@ -347,7 +347,7 @@ static void ssl_write_supported_point_formats_ext(mbedtls_ssl_context *ssl, unsi *olen = 6; } -#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) @@ -1140,7 +1140,7 @@ static int ssl_parse_supported_point_formats_ext(mbedtls_ssl_context *ssl, const MBEDTLS_SSL_DEBUG_MSG(1, ("no point format in common")); return (MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO); } -#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) -- 2.7.4