Commit | Line | Data |
2986a63f |
1 | |
2 | /* |
3 | * Copyright © 2001 Novell, Inc. All Rights Reserved. |
4 | * |
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. |
7 | * |
8 | */ |
9 | |
10 | /* |
11 | * FILENAME : nw5sck.h |
12 | * DESCRIPTION : Socket related functions. |
13 | * Author : SGP |
14 | * Date : January 2001. |
15 | * |
16 | */ |
17 | |
18 | |
19 | |
20 | #ifndef _INC_NW_SOCKET |
21 | #define _INC_NW_SOCKET |
22 | |
23 | |
24 | #include <sys/socket.h> |
25 | #ifdef __cplusplus |
26 | extern "C" { |
27 | #endif |
28 | |
29 | typedef u_int SOCKET; |
30 | |
31 | struct nwsockent local_context; |
32 | |
33 | # undef gethostbyname |
34 | # undef gethostbyaddr |
35 | |
36 | # undef endhostent |
37 | # undef endnetent |
38 | # undef endprotoent |
39 | # undef endservent |
40 | # undef gethostent |
41 | # undef getprotoent |
42 | # undef getnetbyaddr |
43 | # undef getnetbyname |
44 | # undef gethostbyaddr |
45 | # undef getprotobyname |
46 | # undef getprotobyname |
47 | # undef getservbyname |
48 | # undef getservbyport |
49 | # undef getservent |
50 | # undef sethostent |
51 | # undef setnetent |
52 | # undef setprotoent |
53 | # undef setservent |
54 | |
55 | # define gethostbyname(name) NetDBgethostbyname(&local_context,name) |
56 | # define gethostbyaddr(a,l,t) NetDBgethostbyaddr(&local_context,a,l,t) |
57 | |
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 getprotobyname(name) NWgetprotobyname(&local_context,name) |
69 | # define getservbyname(n,p) NWgetservbyname(&local_context,n,p) |
70 | # define getservbyport(n,p) NWgetservbyport(&local_context,n,p) |
71 | # define getservent() NWgetservent(&local_context) |
72 | # define sethostent() NWsethostent(&local_context, stayopen) |
73 | # define setnetent() NWsetnetent(&local_context, stayopen) |
74 | # define setprotoent() NWsetprotoent(&local_context, stayopen) |
75 | # define setservent() NWsetservent(&local_context, stayopen) |
76 | |
77 | u_long nw_htonl(u_long hostlong); |
78 | u_short nw_htons(u_short hostshort); |
79 | u_long nw_ntohl(u_long netlong); |
80 | u_short nw_ntohs(u_short netshort); |
81 | |
82 | SOCKET nw_accept(SOCKET s, struct sockaddr *addr, int *addrlen); |
83 | int nw_bind(SOCKET s, const struct sockaddr *addr, int addrlen); |
84 | int nw_connect(SOCKET s, const struct sockaddr *addr, int addrlen); |
85 | |
86 | struct hostent * nw_gethostbyname(const char * name); |
87 | struct hostent * nw_gethostbyaddr(const char *addr, int len, int type); |
88 | int nw_gethostname(char *name, int len); |
89 | struct netent * nw_getnetbyaddr(long net, int type); |
90 | struct netent *nw_getnetbyname(char *name); |
91 | int nw_getpeername(SOCKET s, struct sockaddr *addr, int *addrlen); |
92 | struct protoent * nw_getprotobyname(const char *name); |
93 | struct protoent * nw_getprotobynumber(int num); |
94 | struct servent * nw_getservbyname(const char *name, const char *proto); |
95 | struct servent * nw_getservbyport(int port, const char *proto); |
96 | struct servent * nw_getservent(void); |
97 | void nw_sethostent(int stayopen); |
98 | void nw_setnetent(int stayopen); |
99 | void nw_setprotoent(int stayopen); |
100 | void nw_setservent(int stayopen); |
225a5dca |
101 | int nw_setsockopt(SOCKET s, int level, int optname, const char* optval, int optlen); |
2986a63f |
102 | |
103 | int nw_getsockname(SOCKET s, struct sockaddr *addr, int *addrlen); |
104 | int nw_getsockopt(SOCKET s, int level, int optname, char *optval, int *optlen); |
105 | |
106 | unsigned long nw_inet_addr(const char *cp); |
107 | |
108 | void nw_endhostent(); |
109 | void nw_endnetent(); |
110 | void nw_endprotoent(); |
111 | void nw_endservent(); |
112 | struct hostent *nw_gethostent(); |
113 | struct netent *nw_getnetent(); |
114 | struct protoent * nw_getprotoent(); |
115 | |
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); |
124 | #ifdef __cplusplus |
125 | } |
126 | #endif |
127 | |
128 | |
129 | #endif // _INC_NW_SOCKET |
130 | |