Commit | Line | Data |
a0d0e21e |
1 | /* sockadapt.h |
2 | * |
3 | * Authors: Charles Bailey bailey@genetics.upenn.edu |
4 | * David Denholm denholm@conmat.phys.soton.ac.uk |
4633a7c4 |
5 | * Last Revised: 17-Mar-1995 |
a0d0e21e |
6 | * |
7 | * This file should include any other header files and procide any |
8 | * declarations, typedefs, and prototypes needed by perl for TCP/IP |
9 | * operations. |
10 | * |
748a9306 |
11 | * This version is set up for perl5 with socketshr 0.9D TCP/IP support. |
a0d0e21e |
12 | */ |
13 | |
4633a7c4 |
14 | /* SocketShr doesn't support these routines, but the DECC RTL contains |
15 | * stubs with these names, designed to be used with the UCX socket |
16 | * library. We avoid linker collisions by substituting new names. |
17 | */ |
18 | #define getnetbyaddr no_getnetbyaddr |
19 | #define getnetbyname no_getnetbyname |
20 | #define getnetent no_getnetent |
21 | #define setnetent no_setnetent |
22 | #define endnetent no_endnetent |
23 | |
24 | |
25 | #ifdef __GNU_CC__ |
a0d0e21e |
26 | |
748a9306 |
27 | /* we may not have netdb.h etc, so lets just do this here - div */ |
a0d0e21e |
28 | /* no harm doing this for all .c files - needed only by pp_sys.c */ |
29 | |
748a9306 |
30 | struct hostent { |
31 | char *h_name; /* official name of host */ |
32 | char **h_aliases; /* alias list */ |
33 | int h_addrtype; /* host address type */ |
34 | int h_length; /* length of address */ |
35 | char **h_addr_list; /* address */ |
a0d0e21e |
36 | }; |
748a9306 |
37 | #ifdef h_addr |
38 | # undef h_addr |
39 | #endif |
a0d0e21e |
40 | #define h_addr h_addr_list[0] |
41 | |
748a9306 |
42 | struct protoent { |
43 | char *p_name; /* official protocol name */ |
44 | char **p_aliases; /* alias list */ |
45 | int p_proto; /* protocol # */ |
46 | }; |
47 | |
48 | struct servent { |
49 | char *s_name; /* official service name */ |
50 | char **s_aliases; /* alias list */ |
51 | int s_port; /* port # */ |
52 | char *s_proto; /* protocol to use */ |
53 | }; |
54 | |
55 | struct in_addr { |
56 | unsigned long s_addr; |
57 | }; |
58 | |
59 | struct sockaddr { |
60 | unsigned short sa_family; /* address family */ |
61 | char sa_data[14]; /* up to 14 bytes of direct address */ |
62 | }; |
63 | |
4633a7c4 |
64 | /* |
65 | * Socket address, internet style. |
66 | */ |
67 | struct sockaddr_in { |
68 | short sin_family; |
69 | unsigned short sin_port; |
70 | struct in_addr sin_addr; |
71 | char sin_zero[8]; |
72 | }; |
73 | |
748a9306 |
74 | struct timeval { |
75 | long tv_sec; |
76 | long tv_usec; |
a0d0e21e |
77 | }; |
78 | |
79 | struct netent { |
80 | char *n_name; |
81 | char **n_aliases; |
82 | int n_addrtype; |
83 | long n_net; |
84 | }; |
4633a7c4 |
85 | |
86 | /* Since socketshr.h won't declare function prototypes unless it thinks |
87 | * the system headers have already been included, we convince it that |
88 | * this is the case. |
89 | */ |
90 | |
91 | #ifndef AF_INET |
92 | # define AF_INET 2 |
93 | #endif |
94 | #ifndef IPPROTO_TCP |
95 | # define IPPROTO_TCP 6 |
96 | #endif |
97 | #ifndef __INET_LOADED |
98 | # define __INET_LOADED |
99 | #endif |
100 | #ifndef __NETDB_LOADED |
101 | # define __NETDB_LOADED |
102 | #endif |
103 | |
104 | /* Finally, we provide prototypes for routines not supported by SocketShr, |
105 | * so that the stubs in sockadapt.c won't cause complaints about |
106 | * undeclared routines. |
107 | */ |
108 | |
109 | struct netent *getnetbyaddr( long net, int type); |
110 | struct netent *getnetbyname( char *name); |
111 | struct netent *getnetent(); |
112 | void setnetent(); |
113 | void endnetent(); |
114 | |
115 | #else /* !__GNU_CC__ */ |
116 | |
117 | /* DECC and VAXC have socket headers in the system set; they're for UCX, but |
118 | * we'll assume that the actual calling sequence is identical across the |
119 | * various TCP/IP stacks; these routines are pretty standard. |
120 | */ |
121 | #include <socket.h> |
122 | #include <in.h> |
123 | #include <inet.h> |
124 | #include <netdb.h> |
125 | /* However, we don't have these two in the system headers. */ |
126 | void setnetent(); |
127 | void endnetent(); |
128 | |
129 | #endif |
130 | |
131 | #include <socketshr.h> |
132 | /* socketshr.h from SocketShr 0.9D doesn't alias fileno; it's comments say |
133 | * that the CRTL version works OK. This isn't the case, at least with |
134 | * VAXC, so we use the SocketShr version. |
135 | * N.B. This means that sockadapt.h must be included *after* stdio.h. |
136 | * This is presently the case for Perl. |
137 | */ |
138 | #ifdef fileno |
139 | # undef fileno |
140 | #endif |
141 | #define fileno si_fileno |
142 | int si_fileno(FILE *); |
84753aa1 |
143 | |
144 | |
145 | /* Catch erroneous results for UDP sockets -- see sockadapt.c */ |
146 | #ifdef getpeername |
147 | # undef getpeername |
148 | #endif |
149 | #define getpeername my_getpeername |
150 | int my_getpeername _((int, struct sockaddr *, int *)); |