@@ -27,7 +27,7 @@ static ssize_t supl_read(void *p_buff, size_t nbytes, void *user_data)
27
27
{
28
28
ARG_UNUSED (user_data );
29
29
30
- ssize_t rc = recv (supl_fd , p_buff , nbytes , 0 );
30
+ ssize_t rc = zsock_recv (supl_fd , p_buff , nbytes , 0 );
31
31
32
32
if (rc < 0 && (errno == EAGAIN )) {
33
33
/* Return 0 to indicate a timeout. */
@@ -44,7 +44,7 @@ static ssize_t supl_write(const void *p_buff, size_t nbytes, void *user_data)
44
44
{
45
45
ARG_UNUSED (user_data );
46
46
47
- return send (supl_fd , p_buff , nbytes , 0 );
47
+ return zsock_send (supl_fd , p_buff , nbytes , 0 );
48
48
}
49
49
50
50
static int inject_agnss_type (void * agnss , size_t agnss_size , uint16_t type , void * user_data )
@@ -90,17 +90,17 @@ static int open_supl_socket(void)
90
90
{
91
91
int err ;
92
92
char port [6 ];
93
- struct addrinfo * info ;
93
+ struct zsock_addrinfo * info ;
94
94
95
- struct addrinfo hints = {
95
+ struct zsock_addrinfo hints = {
96
96
.ai_flags = AI_NUMERICSERV ,
97
97
.ai_family = AF_UNSPEC , /* Both IPv4 and IPv6 addresses accepted. */
98
98
.ai_socktype = SOCK_STREAM
99
99
};
100
100
101
101
snprintf (port , sizeof (port ), "%d" , SUPL_SERVER_PORT );
102
102
103
- err = getaddrinfo (SUPL_SERVER , port , & hints , & info );
103
+ err = zsock_getaddrinfo (SUPL_SERVER , port , & hints , & info );
104
104
if (err ) {
105
105
LOG_ERR ("Failed to resolve hostname %s, error: %d" , SUPL_SERVER , err );
106
106
@@ -110,11 +110,11 @@ static int open_supl_socket(void)
110
110
/* Not connected. */
111
111
err = -1 ;
112
112
113
- for (struct addrinfo * addr = info ; addr != NULL ; addr = addr -> ai_next ) {
113
+ for (struct zsock_addrinfo * addr = info ; addr != NULL ; addr = addr -> ai_next ) {
114
114
char ip [INET6_ADDRSTRLEN ] = { 0 };
115
115
struct sockaddr * const sa = addr -> ai_addr ;
116
116
117
- supl_fd = socket (sa -> sa_family , SOCK_STREAM , IPPROTO_TCP );
117
+ supl_fd = zsock_socket (sa -> sa_family , SOCK_STREAM , IPPROTO_TCP );
118
118
if (supl_fd < 0 ) {
119
119
LOG_ERR ("Failed to create socket, errno %d" , errno );
120
120
goto cleanup ;
@@ -126,21 +126,21 @@ static int open_supl_socket(void)
126
126
.tv_usec = 0 ,
127
127
};
128
128
129
- err = setsockopt (supl_fd , SOL_SOCKET , SO_RCVTIMEO , & timeout , sizeof (timeout ));
129
+ err = zsock_setsockopt (supl_fd , SOL_SOCKET , SO_RCVTIMEO , & timeout , sizeof (timeout ));
130
130
if (err ) {
131
131
LOG_ERR ("Failed to set socket timeout, errno %d" , errno );
132
132
goto cleanup ;
133
133
}
134
134
135
- inet_ntop (sa -> sa_family ,
136
- (void * )& ((struct sockaddr_in * )sa )-> sin_addr ,
137
- ip ,
138
- INET6_ADDRSTRLEN );
135
+ zsock_inet_ntop (sa -> sa_family ,
136
+ (void * )& ((struct sockaddr_in * )sa )-> sin_addr ,
137
+ ip ,
138
+ INET6_ADDRSTRLEN );
139
139
LOG_INF ("Connecting to %s port %d" , ip , SUPL_SERVER_PORT );
140
140
141
- err = connect (supl_fd , sa , addr -> ai_addrlen );
141
+ err = zsock_connect (supl_fd , sa , addr -> ai_addrlen );
142
142
if (err ) {
143
- close (supl_fd );
143
+ zsock_close (supl_fd );
144
144
supl_fd = -1 ;
145
145
146
146
/* Try the next address. */
@@ -152,13 +152,13 @@ static int open_supl_socket(void)
152
152
}
153
153
154
154
cleanup :
155
- freeaddrinfo (info );
155
+ zsock_freeaddrinfo (info );
156
156
157
157
if (err ) {
158
158
/* Unable to connect, close socket. */
159
159
LOG_ERR ("Could not connect to SUPL server" );
160
160
if (supl_fd > -1 ) {
161
- close (supl_fd );
161
+ zsock_close (supl_fd );
162
162
supl_fd = -1 ;
163
163
}
164
164
return -1 ;
@@ -169,7 +169,7 @@ static int open_supl_socket(void)
169
169
170
170
static void close_supl_socket (void )
171
171
{
172
- if (close (supl_fd ) < 0 ) {
172
+ if (zsock_close (supl_fd ) < 0 ) {
173
173
LOG_ERR ("Failed to close SUPL socket" );
174
174
}
175
175
}
0 commit comments