diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2005-06-17 20:01:59 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2005-06-17 20:01:59 +0000 |
commit | b3ba5059dab9a7687d79ed591fc84591b315b1b3 (patch) | |
tree | d1db2042a65b352695d4d07b3d5fae552e754cdd /winsup | |
parent | 2778b3e2b6de5c6930f7e4edc0e73bc4d1f93bd5 (diff) | |
download | newlib-b3ba5059dab9a7687d79ed591fc84591b315b1b3.zip newlib-b3ba5059dab9a7687d79ed591fc84591b315b1b3.tar.gz newlib-b3ba5059dab9a7687d79ed591fc84591b315b1b3.tar.bz2 |
* cygwin.din (inet_pton): Export.
(inet_ntop): Export.
* net.cc (cygwin_inet_pton): Implement inet_pton for AF_INET for now.
(cygwin_inet_ntop): Implement inet_ntop for AF_INET for now.
* include/arpa/inet.h (inet_pton): Declare.
(inet_ntop): Declare.
* include/cygwin/version.h: Bump API minor number.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 10 | ||||
-rw-r--r-- | winsup/cygwin/cygwin.din | 2 | ||||
-rw-r--r-- | winsup/cygwin/include/arpa/inet.h | 2 | ||||
-rw-r--r-- | winsup/cygwin/include/cygwin/version.h | 3 | ||||
-rw-r--r-- | winsup/cygwin/net.cc | 46 |
5 files changed, 62 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index ac56bc5..beab9ec 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,15 @@ 2005-06-17 Corinna Vinschen <corinna@vinschen.de> + * cygwin.din (inet_pton): Export. + (inet_ntop): Export. + * net.cc (cygwin_inet_pton): Implement inet_pton for AF_INET for now. + (cygwin_inet_ntop): Implement inet_ntop for AF_INET for now. + * include/arpa/inet.h (inet_pton): Declare. + (inet_ntop): Declare. + * include/cygwin/version.h: Bump API minor number. + +2005-06-17 Corinna Vinschen <corinna@vinschen.de> + * fhandler.h (fhandler_union): Add missing members corresponding to fhandler_fifo and fhandler_netdrive. diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index 22caf37..22c991b 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -324,8 +324,10 @@ herror = cygwin_herror SIGFE hstrerror = cygwin_hstrerror NOSIGFE inet_addr = cygwin_inet_addr SIGFE inet_aton = cygwin_inet_aton SIGFE +inet_pton = cygwin_inet_pton SIGFE inet_network = cygwin_inet_network SIGFE inet_ntoa = cygwin_inet_ntoa SIGFE +inet_ntop = cygwin_inet_ntop SIGFE cygwin_internal NOSIGFE cygwin32_internal = cygwin_internal NOSIGFE listen = cygwin_listen SIGFE diff --git a/winsup/cygwin/include/arpa/inet.h b/winsup/cygwin/include/arpa/inet.h index 284e98e..f7db900 100644 --- a/winsup/cygwin/include/arpa/inet.h +++ b/winsup/cygwin/include/arpa/inet.h @@ -26,6 +26,8 @@ struct in_addr inet_makeaddr (unsigned long , unsigned long); in_addr_t inet_netof (struct in_addr); in_addr_t inet_network (const char *); char *inet_ntoa (struct in_addr); +int inet_pton (int, const char *, void *); +const char *inet_ntop (int, const void *, char *, size_t); #endif #ifdef __cplusplus diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 3046c21..88d95da 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -257,12 +257,13 @@ details. */ 128: Export pselect. 129: Export mkdtemp. 130: Export strtoimax, strtoumax, llabs, imaxabs, lldiv, imaxdiv. + 131: Export inet_ntop, inet_pton. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 130 +#define CYGWIN_VERSION_API_MINOR 131 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 00951a4..23989dd 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -2259,3 +2259,49 @@ cygwin_sendmsg (int fd, const struct msghdr *msg, int flags) syscall_printf ("%d = sendmsg (%d, %p, %x)", res, fd, msg, flags); return res; } + +/* See "UNIX Network Programming, Networing APIs: Sockets and XTI", + W. Richard Stevens, Prentice Hall PTR, 1998. */ +extern "C" int +cygwin_inet_pton (int family, const char *strptr, void *addrptr) +{ + if (family == AF_INET) + { + struct in_addr in_val; + + if (cygwin_inet_aton (strptr, &in_val)) + { + memcpy (addrptr, &in_val, sizeof (struct in_addr)); + return 1; + } + return 0; + } + set_errno (EAFNOSUPPORT); + return -1; +} + +/* See "UNIX Network Programming, Networing APIs: Sockets and XTI", + W. Richard Stevens, Prentice Hall PTR, 1998. */ +extern "C" const char * +cygwin_inet_ntop (int family, const void *addrptr, char *strptr, size_t len) +{ + const u_char *p = (const u_char *) addrptr; + + if (__check_null_invalid_struct_errno (strptr, len)) + return NULL; + if (family == AF_INET) + { + char temp[64]; /* Big enough for 4 ints ... */ + + __small_sprintf (temp, "%u.%u.%u.%u", p[0], p[1], p[2], p[3]); + if (strlen (temp) >= len) + { + set_errno (ENOSPC); + return NULL; + } + strcpy (strptr, temp); + return strptr; + } + set_errno (EAFNOSUPPORT); + return NULL; +} |