mirror of https://github.com/ARMmbed/mbed-os.git
Check for return status when opening socket
unittests fixed and added test to new lines.pull/3240/head
parent
4b17eb530c
commit
c8794b84f9
|
@ -193,6 +193,11 @@ static internal_socket_t *int_socket_create(uint16_t listen_port, bool use_ephem
|
||||||
}else{
|
}else{
|
||||||
this->listen_socket = socket_open(SOCKET_UDP, listen_port, secure_recv_sckt_msg);
|
this->listen_socket = socket_open(SOCKET_UDP, listen_port, secure_recv_sckt_msg);
|
||||||
}
|
}
|
||||||
|
// Socket create failed
|
||||||
|
if(this->listen_socket < 0){
|
||||||
|
ns_dyn_mem_free(this);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
// XXX API for this? May want to get clever to do recommended first query = 1 hop, retries = whole PAN
|
// XXX API for this? May want to get clever to do recommended first query = 1 hop, retries = whole PAN
|
||||||
socket_setsockopt(this->listen_socket, SOCKET_IPPROTO_IPV6, SOCKET_IPV6_MULTICAST_HOPS, &(const int16_t) {
|
socket_setsockopt(this->listen_socket, SOCKET_IPPROTO_IPV6, SOCKET_IPV6_MULTICAST_HOPS, &(const int16_t) {
|
||||||
16
|
16
|
||||||
|
|
|
@ -302,10 +302,14 @@ int8_t coap_service_initialize(int8_t interface_id, uint16_t listen_port, uint8_
|
||||||
ns_dyn_mem_free(this);
|
ns_dyn_mem_free(this);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
coap_connection_handler_open_connection(this->conn_handler, listen_port, ((this->service_options & COAP_SERVICE_OPTIONS_EPHEMERAL_PORT) == COAP_SERVICE_OPTIONS_EPHEMERAL_PORT),
|
if (0 > coap_connection_handler_open_connection(this->conn_handler, listen_port, ((this->service_options & COAP_SERVICE_OPTIONS_EPHEMERAL_PORT) == COAP_SERVICE_OPTIONS_EPHEMERAL_PORT),
|
||||||
((this->service_options & COAP_SERVICE_OPTIONS_SECURE) == COAP_SERVICE_OPTIONS_SECURE),
|
((this->service_options & COAP_SERVICE_OPTIONS_SECURE) == COAP_SERVICE_OPTIONS_SECURE),
|
||||||
((this->service_options & COAP_SERVICE_OPTIONS_VIRTUAL_SOCKET) != COAP_SERVICE_OPTIONS_VIRTUAL_SOCKET),
|
((this->service_options & COAP_SERVICE_OPTIONS_VIRTUAL_SOCKET) != COAP_SERVICE_OPTIONS_VIRTUAL_SOCKET),
|
||||||
((this->service_options & COAP_SERVICE_OPTIONS_SECURE_BYPASS) == COAP_SERVICE_OPTIONS_SECURE_BYPASS));
|
((this->service_options & COAP_SERVICE_OPTIONS_SECURE_BYPASS) == COAP_SERVICE_OPTIONS_SECURE_BYPASS))){
|
||||||
|
ns_dyn_mem_free(this->conn_handler);
|
||||||
|
ns_dyn_mem_free(this);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!coap_service_handle) {
|
if (!coap_service_handle) {
|
||||||
coap_service_handle = coap_message_handler_init(&own_alloc, &own_free, &coap_tx_function);
|
coap_service_handle = coap_message_handler_init(&own_alloc, &own_free, &coap_tx_function);
|
||||||
|
|
|
@ -35,6 +35,7 @@ bool test_coap_service_initialize()
|
||||||
if( -1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if( -1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
thread_conn_handler_stub.handler_obj = NULL;
|
thread_conn_handler_stub.handler_obj = NULL;
|
||||||
if( -1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if( -1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
||||||
|
@ -42,9 +43,18 @@ bool test_coap_service_initialize()
|
||||||
|
|
||||||
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t*)malloc(sizeof(coap_conn_handler_t));
|
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t*)malloc(sizeof(coap_conn_handler_t));
|
||||||
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
|
||||||
coap_message_handler_stub.coap_ptr = NULL;
|
coap_message_handler_stub.coap_ptr = NULL;
|
||||||
|
|
||||||
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
|
thread_conn_handler_stub.int_value = -1;
|
||||||
|
if( -1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
thread_conn_handler_stub.handler_obj = (coap_conn_handler_t*)malloc(sizeof(coap_conn_handler_t));
|
||||||
|
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
||||||
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
|
thread_conn_handler_stub.int_value = 0;
|
||||||
|
|
||||||
if( 1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if( 1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -173,6 +183,7 @@ bool test_coap_service_unregister_uri()
|
||||||
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
memset(thread_conn_handler_stub.handler_obj, 0, sizeof(coap_conn_handler_t));
|
||||||
nsdynmemlib_stub.returnCounter = 1;
|
nsdynmemlib_stub.returnCounter = 1;
|
||||||
coap_message_handler_stub.coap_ptr = NULL;
|
coap_message_handler_stub.coap_ptr = NULL;
|
||||||
|
thread_conn_handler_stub.int_value = 0;
|
||||||
|
|
||||||
if( 1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
if( 1 != coap_service_initialize(1, 2, 0, NULL, NULL ))
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue