@@ -112,7 +112,7 @@ static int dtls_setup(int fd)
112112 err = zsock_setsockopt (fd , SOL_TLS , TLS_PEER_VERIFY , & verify , sizeof (verify ));
113113 if (err ) {
114114 LOG_ERR ("Failed to setup peer verification, err %d" , errno );
115- return err ;
115+ return - errno ;
116116 }
117117
118118 /* Associate the socket with the security tag
@@ -121,7 +121,7 @@ static int dtls_setup(int fd)
121121 err = zsock_setsockopt (fd , SOL_TLS , TLS_SEC_TAG_LIST , tls_sec_tag , sizeof (tls_sec_tag ));
122122 if (err ) {
123123 LOG_ERR ("Failed to setup TLS sec tag, err %d" , errno );
124- return err ;
124+ return - errno ;
125125 }
126126
127127 if (IS_ENABLED (CONFIG_NRF_PROVISIONING_COAP_DTLS_SESSION_CACHE )) {
@@ -134,13 +134,13 @@ static int dtls_setup(int fd)
134134 & session_cache , sizeof (session_cache ));
135135 if (err ) {
136136 LOG_ERR ("Failed to set TLS_SESSION_CACHE option: %d" , errno );
137- return err ;
137+ return - errno ;
138138 }
139139
140140 err = zsock_setsockopt (fd , SOL_TLS , TLS_HOSTNAME , COAP_HOST , strlen (COAP_HOST ));
141141 if (err ) {
142142 LOG_ERR ("Failed to setup TLS hostname, err %d" , errno );
143- return err ;
143+ return - errno ;
144144 }
145145
146146 /* Enable connection ID */
@@ -149,7 +149,7 @@ static int dtls_setup(int fd)
149149 err = zsock_setsockopt (fd , SOL_TLS , TLS_DTLS_CID , & dtls_cid , sizeof (dtls_cid ));
150150 if (err ) {
151151 LOG_ERR ("Failed to enable connection ID, err %d" , errno );
152- return err ;
152+ return - errno ;
153153 }
154154
155155 if (IS_ENABLED (CONFIG_SOC_NRF9120 )) {
@@ -159,7 +159,7 @@ static int dtls_setup(int fd)
159159 if (err ) {
160160 LOG_ERR ("Failed to set socket option SO_KEEPOPEN, err %d" , errno );
161161 socket_keep_open = false;
162- return err ;
162+ return - errno ;
163163 }
164164 socket_keep_open = true;
165165 }
@@ -207,25 +207,19 @@ static int socket_connect(int *const fd)
207207 * fd = zsock_socket (address -> ai_family , address -> ai_socktype , IPPROTO_DTLS_1_2 );
208208 if (* fd < 0 ) {
209209 LOG_ERR ("Failed to create UDP socket %d" , errno );
210- ret = - ENOTCONN ;
210+ ret = - errno ;
211211 goto clean_up ;
212212 }
213213
214214 /* Setup DTLS socket options */
215215 ret = dtls_setup (* fd );
216216 if (ret ) {
217- LOG_ERR ("Failed to setup TLS socket option" );
218- ret = - EACCES ;
219217 goto clean_up ;
220218 }
221219
222220 if (zsock_connect (* fd , address -> ai_addr , address -> ai_addrlen ) < 0 ) {
223221 LOG_ERR ("Failed to connect UDP socket %d" , errno );
224- if (errno == ETIMEDOUT ) {
225- ret = - ETIMEDOUT ;
226- } else {
227- ret = - ECONNREFUSED ;
228- }
222+ ret = - errno ;
229223 goto clean_up ;
230224 }
231225 LOG_INF ("Connected" );
@@ -573,8 +567,7 @@ int nrf_provisioning_coap_req(struct nrf_provisioning_coap_context *const coap_c
573567 coap_ctx -> rx_buf_len = sizeof (rx_buf );
574568
575569 ret = socket_connect (& coap_ctx -> connect_socket );
576- if (ret ) {
577- LOG_ERR ("Failed to connect socket" );
570+ if (ret < 0 ) {
578571 return ret ;
579572 }
580573
@@ -634,7 +627,6 @@ int nrf_provisioning_coap_req(struct nrf_provisioning_coap_context *const coap_c
634627 if (!socket_keep_open ) {
635628 ret = socket_connect (& coap_ctx -> connect_socket );
636629 if (ret < 0 ) {
637- LOG_ERR ("Failed to connect socket, error: %d" , ret );
638630 break ;
639631 }
640632
0 commit comments