@@ -79,7 +79,7 @@ struct sm_send_ntf {
7979};
8080
8181static struct sm_socket {
82- int type ; /* SOCK_STREAM or SOCK_DGRAM */
82+ int type ; /* NRF_SOCK_STREAM or NRF_SOCK_DGRAM */
8383 uint16_t role ; /* Client or Server */
8484 sec_tag_t sec_tag ; /* Security tag of the credential */
8585 int family ; /* Socket address family */
@@ -119,7 +119,7 @@ static void init_socket(struct sm_socket *socket)
119119 socket -> type = 0 ;
120120 socket -> role = AT_SOCKET_ROLE_CLIENT ;
121121 socket -> sec_tag = SEC_TAG_TLS_INVALID ;
122- socket -> family = AF_UNSPEC ;
122+ socket -> family = NRF_AF_UNSPEC ;
123123 socket -> fd = INVALID_SOCKET ;
124124 socket -> cid = 0 ;
125125 socket -> send_flags = 0 ;
@@ -489,7 +489,7 @@ static int clear_so_send_cb(struct sm_socket *socket)
489489static int do_socket_open (struct sm_socket * sock )
490490{
491491 int ret = 0 ;
492- int proto = IPPROTO_TCP ;
492+ int proto = NRF_IPPROTO_TCP ;
493493
494494 if (sock -> family != NRF_AF_INET && sock -> family != NRF_AF_INET6 &&
495495 sock -> family != NRF_AF_PACKET ) {
@@ -715,7 +715,7 @@ static int sockopt_set(struct sm_socket *sock, enum at_sockopt at_option, int at
715715{
716716 int ret , level , option ;
717717 void * value = & at_value ;
718- socklen_t len = sizeof (at_value );
718+ net_socklen_t len = sizeof (at_value );
719719 struct timeval tmo ;
720720
721721 ret = at_sockopt_to_sockopt (at_option , & level , & option );
@@ -741,7 +741,7 @@ static int sockopt_set(struct sm_socket *sock, enum at_sockopt at_option, int at
741741static int sockopt_get (struct sm_socket * sock , enum at_sockopt at_option )
742742{
743743 int ret , value , level , option ;
744- socklen_t len = sizeof (int );
744+ net_socklen_t len = sizeof (int );
745745
746746 ret = at_sockopt_to_sockopt (at_option , & level , & option );
747747 if (ret ) {
@@ -813,7 +813,7 @@ static int at_sec_sockopt_to_sockopt(enum at_sec_sockopt at_option, int *level,
813813}
814814
815815static int sec_sockopt_set (struct sm_socket * sock , enum at_sec_sockopt at_option , void * value ,
816- socklen_t len )
816+ net_socklen_t len )
817817{
818818 int ret , level , option ;
819819
@@ -823,7 +823,7 @@ static int sec_sockopt_set(struct sm_socket *sock, enum at_sec_sockopt at_option
823823 }
824824
825825 /* Options with special handling. */
826- if (level == SOL_TLS && option == TLS_HOSTNAME ) {
826+ if (level == ZSOCK_SOL_TLS && option == ZSOCK_TLS_HOSTNAME ) {
827827 if (sm_util_casecmp (value , "NULL" )) {
828828 value = NULL ;
829829 len = 0 ;
@@ -843,7 +843,7 @@ static int sec_sockopt_set(struct sm_socket *sock, enum at_sec_sockopt at_option
843843static int sec_sockopt_get (struct sm_socket * sock , enum at_sec_sockopt at_option )
844844{
845845 int ret , value , level , option ;
846- socklen_t len = sizeof (int );
846+ net_socklen_t len = sizeof (int );
847847
848848 ret = at_sec_sockopt_to_sockopt (at_option , & level , & option );
849849 if (ret ) {
@@ -894,7 +894,7 @@ int bind_to_local_addr(struct sm_socket *sock, uint16_t port)
894894
895895 struct nrf_sockaddr_in local = {
896896 .sin_family = NRF_AF_INET ,
897- .sin_port = htons (port )
897+ .sin_port = net_htons (port )
898898 };
899899
900900 if (nrf_inet_pton (NRF_AF_INET , ipv4_addr , & local .sin_addr ) != 1 ) {
@@ -920,7 +920,7 @@ int bind_to_local_addr(struct sm_socket *sock, uint16_t port)
920920
921921 struct nrf_sockaddr_in6 local = {
922922 .sin6_family = NRF_AF_INET6 ,
923- .sin6_port = htons (port )
923+ .sin6_port = net_htons (port )
924924 };
925925
926926 if (nrf_inet_pton (NRF_AF_INET6 , ipv6_addr , & local .sin6_addr ) != 1 ) {
@@ -944,14 +944,14 @@ int bind_to_local_addr(struct sm_socket *sock, uint16_t port)
944944static int do_connect (struct sm_socket * sock , const char * url , uint16_t port )
945945{
946946 int ret = 0 ;
947- struct sockaddr sa = {.sa_family = AF_UNSPEC };
947+ struct net_sockaddr sa = {.sa_family = NET_AF_UNSPEC };
948948
949949 LOG_DBG ("connect %s:%d" , url , port );
950950 ret = util_resolve_host (sock -> cid , url , port , sock -> family , & sa );
951951 if (ret ) {
952952 return - EAGAIN ;
953953 }
954- if (sa .sa_family == AF_INET ) {
954+ if (sa .sa_family == NRF_AF_INET ) {
955955 ret = nrf_connect (sock -> fd , (struct nrf_sockaddr * )& sa ,
956956 sizeof (struct nrf_sockaddr_in ));
957957 } else {
@@ -1048,9 +1048,9 @@ static int do_recv(struct sm_socket *sock, int timeout, int flags,
10481048 int sockfd = sock -> fd ;
10491049 struct timeval tmo = {.tv_sec = timeout };
10501050
1051- ret = nrf_setsockopt (sock -> fd , SOL_SOCKET , SO_RCVTIMEO , & tmo , sizeof (tmo ));
1051+ ret = nrf_setsockopt (sock -> fd , NRF_SOL_SOCKET , NRF_SO_RCVTIMEO , & tmo , sizeof (tmo ));
10521052 if (ret ) {
1053- LOG_ERR ("nrf_setsockopt(%d) error: %d" , SO_RCVTIMEO , - errno );
1053+ LOG_ERR ("nrf_setsockopt(%d) error: %d" , NRF_SO_RCVTIMEO , - errno );
10541054 return - errno ;
10551055 }
10561056 ret = nrf_recv (sockfd , (void * )sm_data_buf , data_len , flags );
@@ -1093,7 +1093,7 @@ static int do_sendto(struct sm_socket *sock, const char *url, uint16_t port, con
10931093{
10941094 int ret = 0 ;
10951095 uint32_t sent = 0 ;
1096- struct sockaddr sa = {.sa_family = AF_UNSPEC };
1096+ struct net_sockaddr sa = {.sa_family = NET_AF_UNSPEC };
10971097 bool send_ntf = (flags & SM_MSG_SEND_ACK ) != 0 ;
10981098
10991099 LOG_DBG ("sendto %s:%d, flags=%d" , url , port , flags );
@@ -1120,8 +1120,8 @@ static int do_sendto(struct sm_socket *sock, const char *url, uint16_t port, con
11201120 do {
11211121 ret = nrf_sendto (sock -> fd , data + sent , len - sent , flags ,
11221122 (struct nrf_sockaddr * )& sa ,
1123- sa .sa_family == AF_INET ? sizeof (struct nrf_sockaddr_in )
1124- : sizeof (struct nrf_sockaddr_in6 ));
1123+ sa .sa_family == NRF_AF_INET ? sizeof (struct nrf_sockaddr_in )
1124+ : sizeof (struct nrf_sockaddr_in6 ));
11251125 if (ret <= 0 ) {
11261126 ret = - errno ;
11271127 break ;
@@ -1157,13 +1157,13 @@ static int do_recvfrom(struct sm_socket *sock, int timeout, int flags,
11571157 enum sm_socket_mode mode , size_t data_len )
11581158{
11591159 int ret ;
1160- struct sockaddr remote ;
1161- socklen_t addrlen = sizeof (struct sockaddr );
1160+ struct net_sockaddr remote ;
1161+ net_socklen_t addrlen = sizeof (struct nrf_sockaddr );
11621162 struct timeval tmo = {.tv_sec = timeout };
11631163
1164- ret = nrf_setsockopt (sock -> fd , SOL_SOCKET , SO_RCVTIMEO , & tmo , sizeof (tmo ));
1164+ ret = nrf_setsockopt (sock -> fd , NRF_SOL_SOCKET , NRF_SO_RCVTIMEO , & tmo , sizeof (tmo ));
11651165 if (ret ) {
1166- LOG_ERR ("nrf_setsockopt(%d) error: %d" , SO_RCVTIMEO , - errno );
1166+ LOG_ERR ("nrf_setsockopt(%d) error: %d" , NRF_SO_RCVTIMEO , - errno );
11671167 return - errno ;
11681168 }
11691169 ret = nrf_recvfrom (sock -> fd , (void * )sm_data_buf , data_len , flags ,
@@ -1184,7 +1184,7 @@ static int do_recvfrom(struct sm_socket *sock, int timeout, int flags,
11841184 char peer_addr [NRF_INET6_ADDRSTRLEN ] = {0 };
11851185 uint16_t peer_port = 0 ;
11861186
1187- util_get_peer_addr (& remote , peer_addr , & peer_port );
1187+ util_get_peer_addr (( struct net_sockaddr * ) & remote , peer_addr , & peer_port );
11881188 rsp_send ("\r\n#XRECVFROM: %d,%d,%d,\"%s\",%d\r\n" , sock -> fd , mode ,
11891189 ret , peer_addr , peer_port );
11901190 }
@@ -1209,7 +1209,7 @@ static int socket_datamode_callback(uint8_t op, const uint8_t *data, int len, ui
12091209 int ret = 0 ;
12101210
12111211 if (op == DATAMODE_SEND ) {
1212- if (datamode_sock -> type == SOCK_DGRAM &&
1212+ if (datamode_sock -> type == NRF_SOCK_DGRAM &&
12131213 (flags & SM_DATAMODE_FLAGS_MORE_DATA ) != 0 ) {
12141214 LOG_ERR ("Data mode buffer overflow" );
12151215 exit_datamode_handler (- EOVERFLOW );
@@ -1300,8 +1300,8 @@ STATIC int handle_at_socket(enum at_parser_cmd_type cmd_type, struct at_parser *
13001300
13011301 case AT_PARSER_CMD_TYPE_TEST :
13021302 rsp_send ("\r\n#XSOCKET: <handle>,(%d,%d,%d),(%d,%d,%d),(%d,%d),<cid>\r\n" ,
1303- AF_INET , AF_INET6 , AF_PACKET ,
1304- SOCK_STREAM , SOCK_DGRAM , SOCK_RAW ,
1303+ NRF_AF_INET , NRF_AF_INET6 , NRF_AF_PACKET ,
1304+ NRF_SOCK_STREAM , NRF_SOCK_DGRAM , NRF_SOCK_RAW ,
13051305 AT_SOCKET_ROLE_CLIENT , AT_SOCKET_ROLE_SERVER );
13061306 err = 0 ;
13071307 break ;
@@ -1357,9 +1357,9 @@ STATIC int handle_at_secure_socket(enum at_parser_cmd_type cmd_type,
13571357 goto error ;
13581358 }
13591359 if (sock -> role == AT_SOCKET_ROLE_SERVER ) {
1360- peer_verify = TLS_PEER_VERIFY_NONE ;
1360+ peer_verify = ZSOCK_TLS_PEER_VERIFY_NONE ;
13611361 } else if (sock -> role == AT_SOCKET_ROLE_CLIENT ) {
1362- peer_verify = TLS_PEER_VERIFY_REQUIRED ;
1362+ peer_verify = ZSOCK_TLS_PEER_VERIFY_REQUIRED ;
13631363 } else {
13641364 err = - EINVAL ;
13651365 goto error ;
@@ -1407,8 +1407,8 @@ STATIC int handle_at_secure_socket(enum at_parser_cmd_type cmd_type,
14071407 case AT_PARSER_CMD_TYPE_TEST :
14081408 rsp_send ("\r\n#XSSOCKET: <handle>,(%d,%d),(%d,%d),(%d,%d),"
14091409 "<sec_tag>,<peer_verify>,<cid>\r\n" ,
1410- AF_INET , AF_INET6 ,
1411- SOCK_STREAM , SOCK_DGRAM ,
1410+ NRF_AF_INET , NRF_AF_INET6 ,
1411+ NRF_SOCK_STREAM , NRF_SOCK_DGRAM ,
14121412 AT_SOCKET_ROLE_CLIENT , AT_SOCKET_ROLE_SERVER );
14131413 err = 0 ;
14141414 break ;
@@ -1962,7 +1962,7 @@ STATIC int handle_at_getaddrinfo(enum at_parser_cmd_type cmd_type, struct at_par
19621962 uint32_t param_count )
19631963{
19641964 int err = - EINVAL ;
1965- char hostname [NI_MAXHOST ];
1965+ char hostname [ZSOCK_NI_MAXHOST ];
19661966 char host [SM_MAX_URL ];
19671967 int size = SM_MAX_URL ;
19681968 struct nrf_addrinfo * result ;
@@ -1978,13 +1978,13 @@ STATIC int handle_at_getaddrinfo(enum at_parser_cmd_type cmd_type, struct at_par
19781978 if (param_count == 3 ) {
19791979 /* DNS query with designated address family */
19801980 struct nrf_addrinfo hints = {
1981- .ai_family = AF_UNSPEC
1981+ .ai_family = NRF_AF_UNSPEC
19821982 };
19831983 err = at_parser_num_get (parser , 2 , & hints .ai_family );
19841984 if (err ) {
19851985 return err ;
19861986 }
1987- if (hints .ai_family < 0 || hints .ai_family > AF_INET6 ) {
1987+ if (hints .ai_family < 0 || hints .ai_family > NRF_AF_INET6 ) {
19881988 return - EINVAL ;
19891989 }
19901990 err = nrf_getaddrinfo (host , NULL , & hints , & result );
@@ -2010,7 +2010,7 @@ STATIC int handle_at_getaddrinfo(enum at_parser_cmd_type cmd_type, struct at_par
20102010
20112011 nrf_inet_ntop (NRF_AF_INET , & host -> sin_addr , hostname ,
20122012 sizeof (hostname ));
2013- } else if (res -> ai_family == AF_INET6 ) {
2013+ } else if (res -> ai_family == NRF_AF_INET6 ) {
20142014 struct nrf_sockaddr_in6 * host =
20152015 (struct nrf_sockaddr_in6 * )result -> ai_addr ;
20162016
0 commit comments