3 * Copyright © 2001 Novell, Inc. All Rights Reserved.
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
12 * DESCRIPTION : Socket related functions.
14 * Date : January 2001.
15 * Date Modified: June 26th 2001.
21 #ifndef _INC_NW_SOCKET
22 #define _INC_NW_SOCKET
25 #include <sys/socket.h>
32 struct nwsockent local_context;
46 # undef getprotobyname
55 # define gethostbyname(name) NetDBgethostbyname(&local_context,name)
56 # define gethostbyaddr(a,l,t) NetDBgethostbyaddr(&local_context,a,l,t)
58 # define endhostent() NetDBendhostent(&local_context)
59 # define endnetent() NWendnetent(&local_context)
60 # define endprotoent() NWendprotoent(&local_context)
61 # define endservent() NWendservent(&local_context)
62 # define gethostent() NetDBgethostent(&local_context,NULL)
63 # define getprotoent() NWgetprotoent(&local_context)
64 # define gethostbyaddr(a,l,t) NetDBgethostbyaddr(&local_context,a,l,t)
65 # define getnetbyaddr(net,typ) NWgetnetbyaddr(&local_context,net,typ)
66 # define getnetbyname(name) NWgetnetbyname(&local_context,name)
67 # define getprotobyname(name) NWgetprotobyname(&local_context,name)
68 # define getservbyname(n,p) NWgetservbyname(&local_context,n,p)
69 # define getservbyport(n,p) NWgetservbyport(&local_context,n,p)
70 # define getservent() NWgetservent(&local_context)
71 # define sethostent() NWsethostent(&local_context, stayopen)
72 # define setnetent() NWsetnetent(&local_context, stayopen)
73 # define setprotoent() NWsetprotoent(&local_context, stayopen)
74 # define setservent() NWsetservent(&local_context, stayopen)
76 u_long nw_htonl(u_long hostlong);
77 u_short nw_htons(u_short hostshort);
78 u_long nw_ntohl(u_long netlong);
79 u_short nw_ntohs(u_short netshort);
81 SOCKET nw_accept(SOCKET s, struct sockaddr *addr, int *addrlen);
82 int nw_bind(SOCKET s, const struct sockaddr *addr, int addrlen);
83 int nw_connect(SOCKET s, const struct sockaddr *addr, int addrlen);
85 struct hostent * nw_gethostbyname(const char * name);
86 struct hostent * nw_gethostbyaddr(const char *addr, int len, int type);
87 int nw_gethostname(char *name, int len);
88 struct netent * nw_getnetbyaddr(long net, int type);
89 struct netent *nw_getnetbyname(char *name);
90 int nw_getpeername(SOCKET s, struct sockaddr *addr, int *addrlen);
91 struct protoent * nw_getprotobyname(const char *name);
92 struct protoent * nw_getprotobynumber(int num);
93 struct servent * nw_getservbyname(const char *name, const char *proto);
94 struct servent * nw_getservbyport(int port, const char *proto);
95 struct servent * nw_getservent(void);
96 void nw_sethostent(int stayopen);
97 void nw_setnetent(int stayopen);
98 void nw_setprotoent(int stayopen);
99 void nw_setservent(int stayopen);
100 int nw_setsockopt(SOCKET s, int level, int optname, const char* optval, int optlen);
102 int nw_getsockname(SOCKET s, struct sockaddr *addr, int *addrlen);
103 int nw_getsockopt(SOCKET s, int level, int optname, char *optval, int *optlen);
105 unsigned long nw_inet_addr(const char *cp);
106 char * nw_inet_ntoa(struct in_addr in);
108 void nw_endhostent();
110 void nw_endprotoent();
111 void nw_endservent();
112 struct hostent *nw_gethostent();
113 struct netent *nw_getnetent();
114 struct protoent * nw_getprotoent();
116 SOCKET nw_socket(int af, int type, int protocol);
117 int nw_listen(SOCKET s, int backlog);
118 int nw_send(SOCKET s, const char *buf, int len, int flags);
119 int nw_recv(SOCKET s, char *buf, int len, int flags);
120 int nw_sendto(SOCKET s, const char *buf, int len, int flags,const struct sockaddr *to, int tolen);
121 int nw_recvfrom(SOCKET s, char *buf, int len, int flags, struct sockaddr *from, int *fromlen);
122 int nw_select(int nfds, fd_set* rd, fd_set* wr, fd_set* ex, const struct timeval* timeout);
123 int nw_shutdown(SOCKET s, int how);
129 #endif // _INC_NW_SOCKET