9
9
*/
10
10
11
11
/* Do NOT include sys/time.h in this file */
12
- # include < WinSock2.h>
12
+ /* Do NOT include WinSock2.h or winsock.h in this file */
13
13
#include <rtthread.h>
14
14
#include <sal_low_lvl.h>
15
15
#include <sal_socket.h>
16
16
#include <sal_netdb.h>
17
17
18
+ #define DBG_TAG "sal.winsock"
19
+ #define DBG_LVL DBG_INFO
20
+ #include <rtdbg.h>
21
+
18
22
/* Important, must reserve */
19
23
#pragma comment( lib, "ws2_32.lib" )
20
24
43
47
iResult = WSAStartup(MAKEWORD(2, 2), &wsa_data); \
44
48
if (iResult != 0) \
45
49
{ \
46
- rt_kprintf ("WSAStartup failed: %d\n", iResult); \
50
+ LOG_E ("WSAStartup failed: %d\n", iResult); \
47
51
return -RT_ERROR; \
48
52
} \
49
53
}while(0)
@@ -79,7 +83,7 @@ int win_connect(int s, const struct sockaddr *name, socklen_t namelen)
79
83
* result = connect(s, name, namelen);
80
84
* if (result == -1)
81
85
* {
82
- * rt_kprintf ("error :%d\n", WSAGetLastError());
86
+ * LOG_E ("error :%d\n", WSAGetLastError());
83
87
* return WSAGetLastError();
84
88
* }
85
89
* else
@@ -239,7 +243,7 @@ static int win_getaddrinfo(const char* nodename, const char* servname, const str
239
243
{
240
244
return EAI_MEMORY ;
241
245
}
242
- memset (ai , 0 , total_size );
246
+ rt_memset (ai , 0 , total_size );
243
247
/* cast through void* to get rid of alignment warnings */
244
248
sa = (struct sockaddr_storage * )(void * )((uint8_t * )ai + sizeof (struct addrinfo ));
245
249
struct sockaddr_in * sa4 = (struct sockaddr_in * )sa ;
@@ -261,7 +265,7 @@ static int win_getaddrinfo(const char* nodename, const char* servname, const str
261
265
{
262
266
/* copy nodename to canonname if specified */
263
267
ai -> ai_canonname = ((char * )ai + sizeof (struct addrinfo ) + sizeof (struct sockaddr_storage ));
264
- memcpy (ai -> ai_canonname , nodename , namelen );
268
+ rt_memcpy (ai -> ai_canonname , nodename , namelen );
265
269
ai -> ai_canonname [namelen ] = 0 ;
266
270
}
267
271
ai -> ai_addrlen = sizeof (struct sockaddr_storage );
@@ -358,9 +362,8 @@ static const struct sal_proto_family windows_inet_family =
358
362
& windows_netdb_ops ,
359
363
};
360
364
361
- #include <stdint.h>
362
- #include <netdev_ipaddr.h>
363
365
#include <netdev.h>
366
+ #include <netdev_ipaddr.h>
364
367
/* Set lwIP network interface device protocol family information */
365
368
int sal_win_netdev_set_pf_info (struct netdev * netdev )
366
369
{
@@ -369,4 +372,3 @@ int sal_win_netdev_set_pf_info(struct netdev* netdev)
369
372
netdev -> sal_user_data = (void * )& windows_inet_family ;
370
373
return 0 ;
371
374
}
372
-
0 commit comments