diff options
| author | tomas <tomas@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-07-14 14:00:43 +0000 |
|---|---|---|
| committer | tomas <tomas@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-07-14 14:00:43 +0000 |
| commit | 2b86160038e39d05fb7294187a9f6761351238ed (patch) | |
| tree | b7a8793b0b2a7fad6922dc17ba869cbb7faf52fc /src/net/udp.c | |
| parent | 39861d1c7b085b257d1ef23e0833b65a8a3741db (diff) | |
- fixed win32 socket bug compilation
git-svn-id: http://opensvn.csie.org/tuxanci_ng@132 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/net/udp.c')
| -rw-r--r-- | src/net/udp.c | 59 |
1 files changed, 5 insertions, 54 deletions
diff --git a/src/net/udp.c b/src/net/udp.c index 1ec1d2f..2507f2a 100644 --- a/src/net/udp.c +++ b/src/net/udp.c @@ -26,58 +26,6 @@ #include "udp.h" -#ifdef __WIN32__ -const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt) -{ - if ( af == AF_INET ) - { - struct sockaddr_in in; - memset(&in, 0, sizeof(in)); - in.sin_family = AF_INET; - memcpy(&in.sin_addr, src, sizeof(struct in_addr)); - getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in), dst, cnt, NULL, 0, NI_NUMERICHOST); - - return dst; - } - else if ( af == AF_INET6 ) - { - struct sockaddr_in6 in; - memset(&in, 0, sizeof(in)); - in.sin6_family = AF_INET6; - memcpy(&in.sin6_addr, src, sizeof(struct in_addr6)); - getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in6), dst, cnt, NULL, 0, NI_NUMERICHOST); - - return dst; - } - - return NULL; -} - -int inet_pton(int af, const char *src, void *dst) -{ - struct addrinfo hints, *res, *ressave; - - memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = af; - - if ( getaddrinfo(src, NULL, &hints, &res) != 0 ) - { - return -1; - } - - ressave = res; - - while ( res ) - { - memcpy(dst, res->ai_addr, res->ai_addrlen); - res = res->ai_next; - } - - freeaddrinfo(ressave); - return 0; -} -#endif - sock_udp_t* newSockUdp(int proto) { sock_udp_t *new; @@ -335,9 +283,12 @@ void getSockUdpIp(sock_udp_t *p, char *str_ip, int len) if( p->proto == PROTO_UDPv4 ) { - //strcpy(str_ip, inet_ntoa(p->sockAddr.sin_addr)); - //printf("strcpy(str_ip, inet_ntoa(p->sockAddr.sin_addr));\n"); +#ifndef __WIN32__ inet_ntop(AF_INET, &(p->sockAddr.sin_addr), str_ip, len); +#else + strcpy(str_ip, inet_ntoa(p->sockAddr.sin_addr)); + //printf("strcpy(str_ip, inet_ntoa(p->sockAddr.sin_addr));\n"); +#endif } #ifdef SUPPORT_IPv6 |