Add proper per-file copyright notices/licenses and top-level license.
[bluesky.git] / TBBT / trace_play / rpc / osdep.h
1 /*
2  * @(#)osdep.h     2.1     97/10/23
3  */
4 /*      @(#)types.h 1.18 87/07/24 SMI      */
5 /*
6  *   Copyright (c) 1992-1997,2001 by Standard Performance Evaluation Corporation
7  *      All rights reserved.
8  *              Standard Performance Evaluation Corporation (SPEC)
9  *              6585 Merchant Place, Suite 100
10  *              Warrenton, VA 20187
11  *
12  *      This product contains benchmarks acquired from several sources who
13  *      understand and agree with SPEC's goal of creating fair and objective
14  *      benchmarks to measure computer performance.
15  *
16  *      This copyright notice is placed here only to protect SPEC in the
17  *      event the source is misused in any manner that is contrary to the
18  *      spirit, the goals and the intent of SPEC.
19  *
20  *      The source code is provided to the user or company under the license
21  *      agreement for the SPEC Benchmark Suite for this product.
22  */
23
24 #ifndef __RPC_OSDEP_H__
25 #define __RPC_OSDEP_H__
26
27 /*
28  * OS dependancies
29  *
30  * These are non-XPG4.2 standard include files, if not compiling in a
31  * strict environment simply #include them, otherwise we must define
32  * our own missing pieces.  The definitions below are specific to
33  * Solaris 2.X and may be different on other systems.
34  */
35
36 #if !defined(_XOPEN_SOURCE) || defined (OSF1) || defined(AIX)
37 #if defined(SVR4)
38 #define BSD_COMP
39 #endif
40 #if defined(AIX)
41 #include <sys/param.h>
42 #endif
43 #include <sys/socket.h>
44 #include <netinet/in.h>
45 #include <net/if.h>
46 #include <netinet/tcp.h>
47 #include <arpa/inet.h>
48 #include <sys/ioctl.h>
49 #else
50 #if defined(_BIG_ENDIAN) && !defined(ntohl) && !defined(lint)
51 /* big-endian */
52 #define ntohl(x)        (x)
53 #define ntohs(x)        (x)
54 #define htonl(x)        (x)
55 #define htons(x)        (x)
56  
57 #elif !defined(ntohl) /* little-endian */
58  
59 extern unsigned short ntohs(unsigned short ns);
60 extern unsigned short htons(unsigned short hs);
61 extern unsigned long  ntohl(unsigned long nl);
62 extern unsigned long  htonl(unsigned long hl);
63  
64 #endif
65 /*
66  * Internet address
67  *      This definition contains obsolete fields for compatibility
68  *      with SunOS 3.x and 4.2bsd.  The presence of subnets renders
69  *      divisions into fixed fields misleading at best.  New code
70  *      should use only the s_addr field.
71  */
72 struct in_addr {
73         union {
74                 struct { unsigned char s_b1, s_b2, s_b3, s_b4; } S_un_b;
75                 struct { unsigned short s_w1, s_w2; } S_un_w;
76                 unsigned long S_addr;
77         } S_un;
78 #define s_addr  S_un.S_addr             /* should be used for all code */
79 #define s_host  S_un.S_un_b.s_b2        /* OBSOLETE: host on imp */
80 #define s_net   S_un.S_un_b.s_b1        /* OBSOLETE: network */
81 #define s_imp   S_un.S_un_w.s_w2        /* OBSOLETE: imp */
82 #define s_impno S_un.S_un_b.s_b4        /* OBSOLETE: imp # */
83 #define s_lh    S_un.S_un_b.s_b3        /* OBSOLETE: logical host */
84 };
85
86 struct sockaddr_in {
87         short   sin_family;
88         unsigned short sin_port;
89         struct  in_addr sin_addr;
90         char    sin_zero[8];
91 };
92
93 /*
94  * Structure used by kernel to store most
95  * addresses.
96  */
97 struct sockaddr {
98         uint16_t sa_family;             /* address family */
99         char    sa_data[14];            /* up to 14 bytes of direct address */
100 };
101
102 /*
103  * Interface request structure used for socket
104  * ioctl's.  All interface ioctl's must have parameter
105  * definitions which begin with ifr_name.  The
106  * remainder may be interface specific.
107  */
108 struct  ifreq {
109 #define IFNAMSIZ        16
110         char    ifr_name[IFNAMSIZ];             /* if name, e.g. "en0" */
111         union {
112                 struct  sockaddr ifru_addr;
113                 struct  sockaddr ifru_dstaddr;
114                 char    ifru_oname[IFNAMSIZ];   /* other if name */
115                 struct  sockaddr ifru_broadaddr;
116                 short   ifru_flags;
117                 int     ifru_metric;
118                 char    ifru_data[1];           /* interface dependent data */
119                 char    ifru_enaddr[6];
120                 int     if_muxid[2];            /* mux id's for arp and ip */
121
122                 /* Struct for FDDI ioctl's */
123                 struct ifr_dnld_reqs {
124                         void    *v_addr;
125                         void    *m_addr;
126                         void    *ex_addr;
127                         uint_t  size;
128                 } ifru_dnld_req;
129
130                 /* Struct for FDDI stats */
131                 struct ifr_fddi_stats {
132                         uint_t  stat_size;
133                         void    *fddi_stats;
134                 } ifru_fddi_stat;
135
136                 struct ifr_netmapents {
137                         uint_t  map_ent_size,   /* size of netmap structure */
138                                 entry_number;   /* index into netmap list */
139                         void    *fddi_map_ent;  /* pointer to user structure */
140                 } ifru_netmapent;
141
142                 /* Field for generic ioctl for fddi */
143
144                 struct ifr_fddi_gen_struct {
145                         int     ifru_fddi_gioctl; /* field for gen ioctl */
146                         void    *ifru_fddi_gaddr; /* Generic ptr to a field */
147                 } ifru_fddi_gstruct;
148
149         } ifr_ifru;
150
151 #define ifr_addr        ifr_ifru.ifru_addr      /* address */
152 #define ifr_dstaddr     ifr_ifru.ifru_dstaddr   /* other end of p-to-p link */
153 #define ifr_oname       ifr_ifru.ifru_oname     /* other if name */
154 #define ifr_broadaddr   ifr_ifru.ifru_broadaddr /* broadcast address */
155 #define ifr_flags       ifr_ifru.ifru_flags     /* flags */
156 #define ifr_metric      ifr_ifru.ifru_metric    /* metric */
157 #define ifr_data        ifr_ifru.ifru_data      /* for use by interface */
158 #define ifr_enaddr      ifr_ifru.ifru_enaddr    /* ethernet address */
159
160 /* FDDI specific */
161 #define ifr_dnld_req    ifr_ifru.ifru_dnld_req
162 #define ifr_fddi_stat   ifr_ifru.ifru_fddi_stat
163 #define ifr_fddi_netmap ifr_ifru.ifru_netmapent /* FDDI network map entries */
164 #define ifr_fddi_gstruct ifr_ifru.ifru_fddi_gstruct
165
166 #define ifr_ip_muxid    ifr_ifru.if_muxid[0]
167 #define ifr_arp_muxid   ifr_ifru.if_muxid[1]
168 };
169
170 struct  ifconf {
171         int     ifc_len;                /* size of associated buffer */
172         union {
173                 void    *ifcu_buf;
174                 struct  ifreq *ifcu_req;
175         } ifc_ifcu;
176 #define ifc_buf ifc_ifcu.ifcu_buf       /* buffer address */
177 #define ifc_req ifc_ifcu.ifcu_req       /* array of structures returned */
178 };
179
180 #define AF_INET                 2
181 #define IPPROTO_TCP             6
182 #define IPPROTO_UDP             17
183 #define IPPORT_RESERVED         1024
184 #define SOCK_DGRAM              1
185 #define SOCK_STREAM             2
186 #define SO_SNDBUF               0x1001
187 #define SO_RCVBUF               0x1002
188 #define SOL_SOCKET              0xffff
189 #define INADDR_ANY              (uint32_t)0x00000000
190 #define IFF_BROADCAST           0x2
191 #define IFF_UP                  0x1
192
193 #define IOCPARM_MASK    0xff
194 #define IOC_OUT         0x40000000
195 #define IOC_IN          0x80000000
196 #define IOC_INOUT       (IOC_IN|IOC_OUT)
197 #define _IOWR(x, y, t) \
198         (IOC_INOUT|((((int)sizeof (t))&IOCPARM_MASK)<<16)|(x<<8)|y)
199 #define SIOCGIFCONF             _IOWR('i', 20, struct ifconf)
200 #define SIOCGIFFLAGS    _IOWR('i', 17, struct ifreq)
201 #define SIOCGIFBRDADDR  _IOWR('i', 23, struct ifreq)
202
203 extern int accept(int, struct sockaddr *, int *);
204 extern int bind(int, struct sockaddr *, int);
205 extern int connect(int, struct sockaddr *, int);
206 extern int getsockname(int, struct sockaddr *, int *);
207 extern int getsockopt(int, int, int, char *, int *);
208 extern int listen(int, int);
209 extern int recvfrom(int, char *, int, int, struct sockaddr *, int *);
210 extern int sendto(int, const char *, int, int, const struct sockaddr *, int);
211 extern int setsockopt(int, int, int, const char *, int);
212 extern int socket(int, int, int);
213 extern unsigned long inet_netof(struct in_addr);
214 extern struct in_addr inet_makeaddr(int, int);
215
216 #endif /* _XOPEN_SOURCE */
217
218 #endif /* __RPC_OSDEP_H__ */