@@ -67,7 +67,7 @@ static struct updatehub_context {
6767 uint8_t uri_path [MAX_PATH_SIZE ];
6868 uint8_t payload [MAX_PAYLOAD_SIZE ];
6969 int downloaded_size ;
70- struct pollfd fds [1 ];
70+ struct zsock_pollfd fds [1 ];
7171 int sock ;
7272 int nfds ;
7373} ctx ;
@@ -99,15 +99,15 @@ static int bin2hex_str(uint8_t *bin, size_t bin_len, char *str, size_t str_buf_l
9999
100100static void wait_fds (void )
101101{
102- if (poll (ctx .fds , ctx .nfds , NETWORK_TIMEOUT ) < 0 ) {
102+ if (zsock_poll (ctx .fds , ctx .nfds , NETWORK_TIMEOUT ) < 0 ) {
103103 LOG_ERR ("Error in poll" );
104104 }
105105}
106106
107107static void prepare_fds (void )
108108{
109109 ctx .fds [ctx .nfds ].fd = ctx .sock ;
110- ctx .fds [ctx .nfds ].events = POLLIN ;
110+ ctx .fds [ctx .nfds ].events = ZSOCK_POLLIN ;
111111 ctx .nfds ++ ;
112112}
113113
@@ -153,7 +153,7 @@ static void cleanup_connection(void)
153153{
154154 int i ;
155155
156- if (close (ctx .sock ) < 0 ) {
156+ if (zsock_close (ctx .sock ) < 0 ) {
157157 LOG_ERR ("Could not close the socket" );
158158 }
159159
@@ -167,8 +167,8 @@ static void cleanup_connection(void)
167167
168168static bool start_coap_client (void )
169169{
170- struct addrinfo * addr ;
171- struct addrinfo hints ;
170+ struct zsock_addrinfo * addr ;
171+ struct zsock_addrinfo hints ;
172172 int resolve_attempts = 10 ;
173173 int ret = -1 ;
174174
@@ -193,7 +193,7 @@ static bool start_coap_client(void)
193193#endif
194194
195195 while (resolve_attempts -- ) {
196- ret = getaddrinfo (UPDATEHUB_SERVER , port , & hints , & addr );
196+ ret = zsock_getaddrinfo (UPDATEHUB_SERVER , port , & hints , & addr );
197197 if (ret == 0 ) {
198198 break ;
199199 }
@@ -206,7 +206,7 @@ static bool start_coap_client(void)
206206
207207 ret = 1 ;
208208
209- ctx .sock = socket (addr -> ai_family , SOCK_DGRAM , protocol );
209+ ctx .sock = zsock_socket (addr -> ai_family , SOCK_DGRAM , protocol );
210210 if (ctx .sock < 0 ) {
211211 LOG_ERR ("Failed to create UDP socket" );
212212 goto error ;
@@ -215,19 +215,19 @@ static bool start_coap_client(void)
215215 ret = -1 ;
216216
217217#if defined(CONFIG_UPDATEHUB_DTLS )
218- if (setsockopt (ctx .sock , SOL_TLS , TLS_SEC_TAG_LIST ,
219- sec_list , sizeof (sec_list )) < 0 ) {
218+ if (zsock_setsockopt (ctx .sock , SOL_TLS , TLS_SEC_TAG_LIST ,
219+ sec_list , sizeof (sec_list )) < 0 ) {
220220 LOG_ERR ("Failed to set TLS_TAG option" );
221221 goto error ;
222222 }
223223
224- if (setsockopt (ctx .sock , SOL_TLS , TLS_PEER_VERIFY , & verify , sizeof (int )) < 0 ) {
224+ if (zsock_setsockopt (ctx .sock , SOL_TLS , TLS_PEER_VERIFY , & verify , sizeof (int )) < 0 ) {
225225 LOG_ERR ("Failed to set TLS_PEER_VERIFY option" );
226226 goto error ;
227227 }
228228#endif
229229
230- if (connect (ctx .sock , addr -> ai_addr , addr -> ai_addrlen ) < 0 ) {
230+ if (zsock_connect (ctx .sock , addr -> ai_addr , addr -> ai_addrlen ) < 0 ) {
231231 LOG_ERR ("Cannot connect to UDP remote" );
232232 goto error ;
233233 }
@@ -236,7 +236,7 @@ static bool start_coap_client(void)
236236
237237 ret = 0 ;
238238error :
239- freeaddrinfo (addr );
239+ zsock_freeaddrinfo (addr );
240240
241241 if (ret > 0 ) {
242242 cleanup_connection ();
@@ -345,7 +345,7 @@ static int send_request(enum coap_msgtype msgtype, enum coap_method method,
345345 goto error ;
346346 }
347347
348- ret = send (ctx .sock , request_packet .data , request_packet .offset , 0 );
348+ ret = zsock_send (ctx .sock , request_packet .data , request_packet .offset , 0 );
349349 if (ret < 0 ) {
350350 LOG_ERR ("Could not send request" );
351351 goto error ;
@@ -425,7 +425,7 @@ static void install_update_cb(void)
425425
426426 wait_fds ();
427427
428- rcvd = recv (ctx .sock , data , MAX_DOWNLOAD_DATA , MSG_DONTWAIT );
428+ rcvd = zsock_recv (ctx .sock , data , MAX_DOWNLOAD_DATA , ZSOCK_MSG_DONTWAIT );
429429 if (rcvd <= 0 ) {
430430 ctx .code_status = UPDATEHUB_NETWORKING_ERROR ;
431431 LOG_ERR ("Could not receive data" );
@@ -693,7 +693,7 @@ static void probe_cb(char *metadata, size_t metadata_size)
693693
694694 wait_fds ();
695695
696- rcvd = recv (ctx .sock , tmp , MAX_DOWNLOAD_DATA , MSG_DONTWAIT );
696+ rcvd = zsock_recv (ctx .sock , tmp , MAX_DOWNLOAD_DATA , ZSOCK_MSG_DONTWAIT );
697697 if (rcvd <= 0 ) {
698698 LOG_ERR ("Could not receive data" );
699699 ctx .code_status = UPDATEHUB_NETWORKING_ERROR ;
0 commit comments