@@ -37,8 +37,8 @@ static int _sock_connect(struct esp_data *dev, struct esp_socket *sock)
3737 2 * NET_IPV4_ADDR_LEN )];
3838 char dst_addr_str [NET_IPV4_ADDR_LEN ];
3939 char src_addr_str [NET_IPV4_ADDR_LEN ];
40- struct sockaddr src ;
41- struct sockaddr dst ;
40+ struct net_sockaddr src ;
41+ struct net_sockaddr dst ;
4242 int ret ;
4343 int mode ;
4444
@@ -51,21 +51,21 @@ static int _sock_connect(struct esp_data *dev, struct esp_socket *sock)
5151 dst = sock -> dst ;
5252 k_mutex_unlock (& sock -> lock );
5353
54- if (dst .sa_family == AF_INET ) {
54+ if (dst .sa_family == NET_AF_INET ) {
5555 net_addr_ntop (dst .sa_family ,
5656 & net_sin (& dst )-> sin_addr ,
5757 dst_addr_str , sizeof (dst_addr_str ));
5858 } else {
5959 strcpy (dst_addr_str , "0.0.0.0" );
6060 }
6161
62- if (esp_socket_ip_proto (sock ) == IPPROTO_TCP ) {
62+ if (esp_socket_ip_proto (sock ) == NET_IPPROTO_TCP ) {
6363 snprintk (connect_msg , sizeof (connect_msg ),
6464 "AT+CIPSTART=%d,\"TCP\",\"%s\",%d,7200" ,
6565 sock -> link_id , dst_addr_str ,
66- ntohs (net_sin (& dst )-> sin_port ));
66+ net_ntohs (net_sin (& dst )-> sin_port ));
6767 } else {
68- if (src .sa_family == AF_INET && net_sin (& src )-> sin_port != 0 ) {
68+ if (src .sa_family == NET_AF_INET && net_sin (& src )-> sin_port != 0 ) {
6969 net_addr_ntop (src .sa_family ,
7070 & net_sin (& src )-> sin_addr ,
7171 src_addr_str , sizeof (src_addr_str ));
@@ -87,7 +87,7 @@ static int _sock_connect(struct esp_data *dev, struct esp_socket *sock)
8787 * to 2.
8888 */
8989 if ((net_sin (& dst )-> sin_addr .s_addr == 0 ) &&
90- (ntohs (net_sin (& dst )-> sin_port ) == 0 )) {
90+ (net_ntohs (net_sin (& dst )-> sin_port ) == 0 )) {
9191 mode = 2 ;
9292 /* Port 0 is reserved and a valid port needs to be provided when
9393 * connecting.
@@ -100,24 +100,25 @@ static int _sock_connect(struct esp_data *dev, struct esp_socket *sock)
100100 snprintk (connect_msg , sizeof (connect_msg ),
101101 "AT+CIPSTART=%d,\"UDP\",\"%s\",%d,%d,%d,\"%s\"" ,
102102 sock -> link_id , dst_addr_str ,
103- ntohs (net_sin (& dst )-> sin_port ), ntohs (net_sin (& src )-> sin_port ),
103+ net_ntohs (net_sin (& dst )-> sin_port ),
104+ net_ntohs (net_sin (& src )-> sin_port ),
104105 mode , src_addr_str );
105106 } else {
106107 snprintk (connect_msg , sizeof (connect_msg ),
107108 "AT+CIPSTART=%d,\"UDP\",\"%s\",%d" ,
108109 sock -> link_id , dst_addr_str ,
109- ntohs (net_sin (& dst )-> sin_port ));
110+ net_ntohs (net_sin (& dst )-> sin_port ));
110111 }
111112 }
112113
113114 LOG_DBG ("link %d, ip_proto %s, addr %s" , sock -> link_id ,
114- esp_socket_ip_proto (sock ) == IPPROTO_TCP ? "TCP" : "UDP" ,
115+ esp_socket_ip_proto (sock ) == NET_IPPROTO_TCP ? "TCP" : "UDP" ,
115116 dst_addr_str );
116117
117118 ret = esp_cmd_send (dev , NULL , 0 , connect_msg , ESP_CMD_TIMEOUT );
118119 if (ret == 0 ) {
119120 esp_socket_flags_set (sock , ESP_SOCK_CONNECTED );
120- if (esp_socket_type (sock ) == SOCK_STREAM ) {
121+ if (esp_socket_type (sock ) == NET_SOCK_STREAM ) {
121122 net_context_set_state (sock -> context ,
122123 NET_CONTEXT_CONNECTED );
123124 }
@@ -149,7 +150,7 @@ void esp_connect_work(struct k_work *work)
149150 k_mutex_unlock (& sock -> lock );
150151}
151152
152- static int esp_bind (struct net_context * context , const struct sockaddr * addr ,
153+ static int esp_bind (struct net_context * context , const struct net_sockaddr * addr ,
153154 socklen_t addrlen )
154155{
155156 struct esp_socket * sock ;
@@ -158,11 +159,11 @@ static int esp_bind(struct net_context *context, const struct sockaddr *addr,
158159 sock = (struct esp_socket * )context -> offload_context ;
159160 dev = esp_socket_to_dev (sock );
160161
161- if (esp_socket_ip_proto (sock ) == IPPROTO_TCP ) {
162+ if (esp_socket_ip_proto (sock ) == NET_IPPROTO_TCP ) {
162163 return 0 ;
163164 }
164165
165- if (IS_ENABLED (CONFIG_NET_IPV4 ) && addr -> sa_family == AF_INET ) {
166+ if (IS_ENABLED (CONFIG_NET_IPV4 ) && addr -> sa_family == NET_AF_INET ) {
166167 LOG_DBG ("link %d" , sock -> link_id );
167168
168169 if (esp_socket_connected (sock )) {
@@ -180,7 +181,7 @@ static int esp_bind(struct net_context *context, const struct sockaddr *addr,
180181}
181182
182183static int esp_connect (struct net_context * context ,
183- const struct sockaddr * addr ,
184+ const struct net_sockaddr * addr ,
184185 socklen_t addrlen ,
185186 net_context_connect_cb_t cb ,
186187 int32_t timeout ,
@@ -195,7 +196,7 @@ static int esp_connect(struct net_context *context,
195196
196197 LOG_DBG ("link %d, timeout %d" , sock -> link_id , timeout );
197198
198- if (!IS_ENABLED (CONFIG_NET_IPV4 ) || addr -> sa_family != AF_INET ) {
199+ if (!IS_ENABLED (CONFIG_NET_IPV4 ) || addr -> sa_family != NET_AF_INET ) {
199200 return - EAFNOSUPPORT ;
200201 }
201202
@@ -275,7 +276,7 @@ static int _sock_send(struct esp_socket *sock, struct net_pkt *pkt)
275276 MODEM_CMD ("SEND OK" , on_cmd_send_ok , 0U , "" ),
276277 MODEM_CMD ("SEND FAIL" , on_cmd_send_fail , 0U , "" ),
277278 };
278- struct sockaddr dst ;
279+ struct net_sockaddr dst ;
279280
280281 if (!esp_flags_are_set (dev , EDF_STA_CONNECTED | EDF_AP_ENABLED )) {
281282 return - ENETUNREACH ;
@@ -285,7 +286,7 @@ static int _sock_send(struct esp_socket *sock, struct net_pkt *pkt)
285286
286287 LOG_DBG ("link %d, len %d" , sock -> link_id , pkt_len );
287288
288- if (esp_socket_ip_proto (sock ) == IPPROTO_TCP ) {
289+ if (esp_socket_ip_proto (sock ) == NET_IPPROTO_TCP ) {
289290 snprintk (cmd_buf , sizeof (cmd_buf ),
290291 "AT+CIPSEND=%d,%d" , sock -> link_id , pkt_len );
291292 } else {
@@ -299,7 +300,7 @@ static int _sock_send(struct esp_socket *sock, struct net_pkt *pkt)
299300 snprintk (cmd_buf , sizeof (cmd_buf ),
300301 "AT+CIPSEND=%d,%d,\"%s\",%d" ,
301302 sock -> link_id , pkt_len , addr_str ,
302- ntohs (net_sin (& dst )-> sin_port ));
303+ net_ntohs (net_sin (& dst )-> sin_port ));
303304 }
304305
305306 k_sem_take (& dev -> cmd_handler_data .sem_tx_lock , K_FOREVER );
@@ -333,7 +334,7 @@ static int _sock_send(struct esp_socket *sock, struct net_pkt *pkt)
333334 }
334335
335336 /* Wait for 'SEND OK' or 'SEND FAIL' */
336- if (esp_socket_ip_proto (sock ) == IPPROTO_TCP ) {
337+ if (esp_socket_ip_proto (sock ) == NET_IPPROTO_TCP ) {
337338 ret = k_sem_take (& dev -> sem_response , TCP_SEND_TIMEOUT );
338339 } else {
339340 ret = k_sem_take (& dev -> sem_response , ESP_CMD_TIMEOUT );
@@ -392,7 +393,7 @@ static int esp_socket_send_one_pkt(struct esp_socket *sock)
392393 * more to this socket, as there will be a hole in the data
393394 * stream, which application layer is not expecting.
394395 */
395- if (esp_socket_type (sock ) == SOCK_STREAM ) {
396+ if (esp_socket_type (sock ) == NET_SOCK_STREAM ) {
396397 if (!esp_socket_flags_test_and_set (sock ,
397398 ESP_SOCK_CLOSE_PENDING )) {
398399 esp_socket_work_submit (sock , & sock -> close_work );
@@ -420,7 +421,7 @@ void esp_send_work(struct k_work *work)
420421}
421422
422423static int esp_sendto (struct net_pkt * pkt ,
423- const struct sockaddr * dst_addr ,
424+ const struct net_sockaddr * dst_addr ,
424425 socklen_t addrlen ,
425426 net_context_send_cb_t cb ,
426427 int32_t timeout ,
@@ -441,7 +442,7 @@ static int esp_sendto(struct net_pkt *pkt,
441442 return - ENETUNREACH ;
442443 }
443444
444- if (esp_socket_type (sock ) == SOCK_STREAM ) {
445+ if (esp_socket_type (sock ) == NET_SOCK_STREAM ) {
445446 atomic_val_t flags = esp_socket_flags (sock );
446447
447448 if (!(flags & ESP_SOCK_CONNECTED ) ||
@@ -463,7 +464,7 @@ static int esp_sendto(struct net_pkt *pkt,
463464 if (ret < 0 ) {
464465 return ret ;
465466 }
466- } else if (esp_socket_type (sock ) == SOCK_DGRAM ) {
467+ } else if (esp_socket_type (sock ) == NET_SOCK_DGRAM ) {
467468 memcpy (& sock -> dst , dst_addr , addrlen );
468469 }
469470 }
@@ -583,11 +584,11 @@ MODEM_CMD_DIRECT_DEFINE(on_cmd_ciprecvdata)
583584 }
584585
585586#if defined(CONFIG_WIFI_ESP_AT_CIPDINFO_USE ) && !defined(CONFIG_WIFI_ESP_AT_VERSION_1_7 )
586- struct sockaddr_in * recv_addr =
587- (struct sockaddr_in * ) & sock -> context -> remote ;
587+ struct net_sockaddr_in * recv_addr =
588+ (struct net_sockaddr_in * ) & sock -> context -> remote ;
588589
589- recv_addr -> sin_port = htons (port );
590- recv_addr -> sin_family = AF_INET ;
590+ recv_addr -> sin_port = net_htons (port );
591+ recv_addr -> sin_family = NET_AF_INET ;
591592
592593 /* IP addr comes within quotation marks, which is disliked by
593594 * conv function. So we remove them by subtraction 2 from
@@ -601,7 +602,7 @@ MODEM_CMD_DIRECT_DEFINE(on_cmd_ciprecvdata)
601602 strncpy (remote_ip_addr , & raw_remote_ip [1 ], remote_ip_str_len );
602603 remote_ip_addr [remote_ip_str_len ] = '\0' ;
603604
604- if (net_addr_pton (AF_INET , remote_ip_addr , & recv_addr -> sin_addr ) < 0 ) {
605+ if (net_addr_pton (NET_AF_INET , remote_ip_addr , & recv_addr -> sin_addr ) < 0 ) {
605606 LOG_ERR ("Invalid src addr %s" , remote_ip_addr );
606607 err = - EIO ;
607608 goto socket_unref ;
@@ -686,8 +687,8 @@ static int esp_recv(struct net_context *context,
686687 * traffic can be received.
687688 */
688689 if (!esp_socket_connected (sock ) &&
689- esp_socket_ip_proto (sock ) == IPPROTO_UDP &&
690- sock -> src .sa_family == AF_INET &&
690+ esp_socket_ip_proto (sock ) == NET_IPPROTO_UDP &&
691+ sock -> src .sa_family == NET_AF_INET &&
691692 net_sin (& sock -> src )-> sin_port != 0 ) {
692693 _sock_connect (dev , sock );
693694 }
@@ -757,7 +758,7 @@ static int esp_get(sa_family_t family,
757758
758759 LOG_DBG ("" );
759760
760- if (family != AF_INET ) {
761+ if (family != NET_AF_INET ) {
761762 return - EAFNOSUPPORT ;
762763 }
763764
0 commit comments