src/solaris/native/java/net/net_util_md.h

Print this page




  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #ifndef NET_UTILS_MD_H
  27 #define NET_UTILS_MD_H
  28 
  29 #include <sys/socket.h>
  30 #include <sys/types.h>
  31 #include <netdb.h>
  32 #include <netinet/in.h>
  33 #include <unistd.h>
  34 
  35 #ifndef USE_SELECT
  36 #include <sys/poll.h>
  37 #endif
  38 
  39 
  40 /*
  41    AIX needs a workaround for I/O cancellation, see:
  42    http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/close.htm
  43    ...
  44    The close subroutine is blocked until all subroutines which use the file
  45    descriptor return to usr space. For example, when a thread is calling close
  46    and another thread is calling select with the same file descriptor, the
  47    close subroutine does not return until the select call returns.
  48    ...
  49 */
  50 #if defined(__linux__) || defined(MACOSX) || defined (_AIX)
  51 extern int NET_Timeout(int s, long timeout);
  52 extern int NET_Read(int s, void* buf, size_t len);
  53 extern int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
  54        struct sockaddr *from, int *fromlen);
  55 extern int NET_ReadV(int s, const struct iovec * vector, int count);
  56 extern int NET_Send(int s, void *msg, int len, unsigned int flags);
  57 extern int NET_SendTo(int s, const void *msg, int len,  unsigned  int
  58        flags, const struct sockaddr *to, int tolen);
  59 extern int NET_Writev(int s, const struct iovec * vector, int count);
  60 extern int NET_Connect(int s, struct sockaddr *addr, int addrlen);
  61 extern int NET_Accept(int s, struct sockaddr *addr, int *addrlen);
  62 extern int NET_SocketClose(int s);
  63 extern int NET_Dup2(int oldfd, int newfd);
  64 
  65 #ifdef USE_SELECT
  66 extern int NET_Select(int s, fd_set *readfds, fd_set *writefds,
  67                fd_set *exceptfds, struct timeval *timeout);
  68 #else
  69 extern int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout);
  70 #endif
  71 
  72 #else
  73 
  74 #define NET_Timeout     JVM_Timeout
  75 #define NET_Read        JVM_Read
  76 #define NET_RecvFrom    JVM_RecvFrom
  77 #define NET_ReadV       readv
  78 #define NET_Send        JVM_Send
  79 #define NET_SendTo      JVM_SendTo
  80 #define NET_WriteV      writev
  81 #define NET_Connect     JVM_Connect
  82 #define NET_Accept      JVM_Accept
  83 #define NET_SocketClose JVM_SocketClose
  84 #define NET_Dup2        dup2
  85 #define NET_Select      select
  86 #define NET_Poll        poll
  87 
  88 #endif
  89 
  90 #if defined(__linux__) && defined(AF_INET6)
  91 int getDefaultIPv6Interface(struct in6_addr *target_addr);
  92 #endif
  93 
  94 #ifdef __solaris__
  95 extern int net_getParam(char *driver, char *param);
  96 #endif
  97 
  98 /* needed from libsocket on Solaris 8 */
  99 
 100 typedef int (*getaddrinfo_f)(const char *nodename, const char *servname,
 101     const struct addrinfo *hints, struct addrinfo **res);
 102 
 103 typedef void (*freeaddrinfo_f)(struct addrinfo *);
 104 
 105 typedef const char * (*gai_strerror_f)(int ecode);
 106 
 107 typedef int (*getnameinfo_f)(const struct sockaddr *, size_t,
 108     char *, size_t, char *, size_t, int);




  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #ifndef NET_UTILS_MD_H
  27 #define NET_UTILS_MD_H
  28 
  29 #include <sys/socket.h>
  30 #include <sys/types.h>
  31 #include <netdb.h>
  32 #include <netinet/in.h>
  33 #include <unistd.h>
  34 
  35 #ifndef USE_SELECT
  36 #include <sys/poll.h>
  37 #endif
  38 
  39 int NET_Timeout(int s, long timeout);
  40 int NET_Read(int s, void* buf, size_t len);
  41 int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
  42                  struct sockaddr *from, socklen_t *fromlen);
  43 int NET_ReadV(int s, const struct iovec * vector, int count);
  44 int NET_Send(int s, void *msg, int len, unsigned int flags);
  45 int NET_SendTo(int s, const void *msg, int len,  unsigned  int












  46        flags, const struct sockaddr *to, int tolen);
  47 int NET_Writev(int s, const struct iovec * vector, int count);
  48 int NET_Connect(int s, struct sockaddr *addr, int addrlen);
  49 int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen);
  50 int NET_SocketClose(int s);
  51 int NET_Dup2(int oldfd, int newfd);


  52 extern int NET_Select(int s, fd_set *readfds, fd_set *writefds,
  53                fd_set *exceptfds, struct timeval *timeout);

  54 extern int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout);

















  55 
  56 int NET_SocketAvailable(int s, jint *pbytes);
  57 
  58 #if defined(__linux__) && defined(AF_INET6)
  59 int getDefaultIPv6Interface(struct in6_addr *target_addr);
  60 #endif
  61 
  62 #ifdef __solaris__
  63 extern int net_getParam(char *driver, char *param);
  64 #endif
  65 
  66 /* needed from libsocket on Solaris 8 */
  67 
  68 typedef int (*getaddrinfo_f)(const char *nodename, const char *servname,
  69     const struct addrinfo *hints, struct addrinfo **res);
  70 
  71 typedef void (*freeaddrinfo_f)(struct addrinfo *);
  72 
  73 typedef const char * (*gai_strerror_f)(int ecode);
  74 
  75 typedef int (*getnameinfo_f)(const struct sockaddr *, size_t,
  76     char *, size_t, char *, size_t, int);