summaryrefslogblamecommitdiffstats
path: root/private/inc/sockets/netinet/in.h
blob: 53c2649370df073a0f61349f1bc0d2f4ff5289db (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
















































































































































































































































































































































































































































                                                                                 
/*++

Copyright (c) 1991 Microsoft Corporation

Module Name:

  in.h

Abstract:

  A version of the BSD 4.2 file <netinet/in.h> for NT tcp

Author:

  Sam Patton (sampa)   July 26, 1991

Revision History:

  when        who     what
  ----        ---     ----
  7-26-91    sampa    initial version

--*/

/******************************************************************
 *
 *  SpiderTCP Application Include Files
 *
 *  Spider Systems Limited
 *
 *  IN.H
 *
 *    A version of the BSD 4.2 file <netinet/in.h>
 *    for SpiderTCP
 *
 *
 ******************************************************************/

/*
 *       /usr/projects/spare/PBRAIN/SCCS/pbrainG/dev/src/include/netinet/0/s.in.h
 *      @(#)in.h        1.31
 *
 *      Last delta created      13:33:59 8/27/90
 *      This file extracted     08:53:51 7/10/91
 *
 *      Modifications:
 *
 */

#ifndef IN_INCLUDED
#define IN_INCLUDED


#ifdef PROJ8
/*
 *      BYTESWAP should be undef'ed if the machine's byte order
 *      is the same as network byte order - if it is the reverse
 *      it should be set to 1.
 */
#define BYTESWAP        1
#endif
#ifdef PROJ11
/*
 *      BYTESWAP should be undef'ed if the machine's byte order
 *      is the same as network byte order - if it is the reverse
 *      it should be set to 1.
 */
#define BYTESWAP        1
#endif

#ifdef PROJ9
/*
 *      BYTESWAP should be undef'ed if the machine's byte order
 *      is the same as network byte order - if it is the reverse
 *      it should be set to 1.
 */
#if m68k
#undef  BYTESWAP
#define EMBED           1
#else
#define BYTESWAP        1
#undef EMBED
#endif
#endif


#ifndef BYTESWAP
#    ifdef i386
#        define BYTESWAP 1
#    endif
#    ifdef MIPS
#        define BYTESWAP 1
#    endif
#    ifdef ALPHA
#        define BYTESWAP 1
#    endif
#    ifdef PPC
#        define BYTESWAP 1
#    endif
#endif


#define TLI_TCP         "/dev/tcp"      /* or else */
#define TLI_UDP         "/dev/udp"      /* or else */

/*
 * Protocols
 */
#define IPPROTO_IP            256               /* IP (for socket options etc) */
#define IPPROTO_ICMP            1               /* control message protocol */
#define IPPROTO_GGP             2               /* gateway^2 (deprecated) */
#define IPPROTO_TCP             6               /* tcp */
#define IPPROTO_EGP             8               /* exterior gateway protocol */
#define IPPROTO_PUP             12              /* pup */
#define IPPROTO_UDP             17              /* user datagram protocol */

#define IPPROTO_RAW             255             /* raw IP packet */
#define IPPROTO_MAX             256


#define ICMP_PROT       IPPROTO_ICMP
#define GWAY_PROT       3
#define TCP_PROT        IPPROTO_TCP
#define UDP_PROT        IPPROTO_UDP


#include <sys\snet\ip_proto.h>

#if 0
/*
 * define structure for DARPA internet address
 * usually use "longs" to access but sometimes need to split into
 * components
 */

typedef union {
                char  typea[4]; /* 4 x 8 bit version */
                short typeb[2];  /* 2 x 16 bit */
                long  typec;     /* 1 x 32 bit */
} IN_ADDRESS;
#endif


/*
 * Port/socket numbers: network standard functions
 */
#define IPPORT_ECHO             7
#define IPPORT_DISCARD          9
#define IPPORT_SYSTAT           11
#define IPPORT_DAYTIME          13
#define IPPORT_NETSTAT          15
#define IPPORT_FTP              21
#define IPPORT_TELNET           23
#define IPPORT_SMTP             25
#define IPPORT_TIMESERVER       37
#define IPPORT_NAMESERVER       42
#define IPPORT_WHOIS            43
#define IPPORT_MTP              57

/*
 * Port/socket numbers: host specific functions
 */
#define IPPORT_TFTP             69
#define IPPORT_RJE              77
#define IPPORT_FINGER           79
#define IPPORT_TTYLINK          87
#define IPPORT_SUPDUP           95

#define IPPORT_BIFFUDP          512
#define IPPORT_EXECSERVER       512
#define IPPORT_LOGINSERVER      513
#define IPPORT_WHOSERVER        513
#define IPPORT_CMDSERVER        514

/*
 * Ports < IPPORT_RESERVED are reserved for
 * privileged processes (e.g. root).
 */
#define IPPORT_RESERVED         1024

/*
 * Link numbers
 */
#define IMPLINK_IP              155
#define IMPLINK_LOWEXPER        156
#define IMPLINK_HIGHEXPER       158


/*
 * Internet address
 */
struct in_addr {
        union {
                struct { unsigned char s_b1,s_b2,s_b3,s_b4; } S_un_b;
                struct { unsigned short s_w1,s_w2; } S_un_w;
                unsigned long S_addr;
        } S_un;
#define s_addr  S_un.S_addr     /* can be used for most tcp & ip code */
#define s_host  S_un.S_un_b.s_b2        /* host on imp */
#define s_net   S_un.S_un_b.s_b1        /* network */
#define s_imp   S_un.S_un_w.s_w2        /* imp */
#define s_impno S_un.S_un_b.s_b4        /* imp # */
#define s_lh    S_un.S_un_b.s_b3        /* logical host */
};

/*
 * Definitions of bits in internet address integers.
 */
#define IN_CLASSA(i)            ((((long)(i))&0x80000000)==0)
#define IN_CLASSA_NET           0xff000000
#define IN_CLASSA_NSHIFT        24
#define IN_CLASSA_HOST          0x00ffffff
#define IN_CLASSA_MAX           128

#define IN_CLASSB(i)            ((((long)(i))&0xc0000000)==0x80000000)
#define IN_CLASSB_NET           0xffff0000
#define IN_CLASSB_NSHIFT        16
#define IN_CLASSB_HOST          0x0000ffff
#define IN_CLASSB_MAX           65536

#define IN_CLASSC(i)            ((((long)(i))&0xe0000000)==0xc0000000)
#define IN_CLASSC_NET           0xffffff00
#define IN_CLASSC_NSHIFT        8
#define IN_CLASSC_HOST          0x000000ff

#define INADDR_ANY              0x00000000
#define INADDR_BROADCAST        0xffffffff

/*
 * Socket address, internet style.
 */
struct sockaddr_in {
        short   		sin_family;
        unsigned short  sin_port;
        struct  in_addr sin_addr;
        char    		sin_zero[8];
};

/* Length of a SOCKADDR or SOCKADDR_IN structure */
#define SOCAD_LEN 16

#ifdef BYTESWAP

#define htons(x)        ((((x) >> 8) & 0x00FF) | (((x) << 8) & 0xFF00))

//
//BUGBUG - we need to investigate this
//

#define	FUTURE	1
#ifdef FUTURE
/*
 * this macro should be used if its faster than the function
 * - measure it on the target machine
 */
#ifndef i386
#define htonl(x)        ((((x) >> 24) & 0x000000FFL) | \
                        (((x) >>  8) & 0x0000FF00L) | \
                        (((x) <<  8) & 0x00FF0000L) | \
                        (((x) << 24) & 0xFF000000L))
#else

__inline long
htonl(long x)
{
	return((((x) >> 24) & 0x000000FFL) |
                        (((x) >>  8) & 0x0000FF00L) |
                        (((x) <<  8) & 0x00FF0000L) |
                        (((x) << 24) & 0xFF000000L));
}

#endif /* i386 */
#else
extern long htonl();
#endif
#undef	FUTURE

#define ntohs(x)        htons(x)
#define ntohl(x)        htonl(x)

#define MASKA   0x000000FFL
#define MASKB   0x0000FFFFL
#define MASKC   0x00FFFFFFL
#define CLSHFT  5               /* Make C generate hyper-optimized case */

#else
/*
 * Macros for number representation conversion.
 */
#define ntohl(x)        (x)
#define ntohs(x)        (x)
#define htonl(x)        (x)
#define htons(x)        (x)

#define MASKA   0xFF000000L
#define MASKB   0xFFFF0000L
#define MASKC   0xFFFFFF00L
#define CLSHFT  29
#endif

#define CLA0    0               /* It takes the same arg; you mask it off, */
#define CLA1    1               /* shift, and then do a case statment with */
#define CLA2    2               /* some code having more than one label. */
#define CLA3    3               /* Values for class A */
#define CLB0    4
#define CLB1    5               /* B */
#define CLC     6               /* C */
#define CLI     7               /* Illegal */

#define BROADCAST 0x00000000L

#define CASTA   0x00FFFFFFL
#define CASTB   0x0000FFFFL
#define CASTC   0x000000FFL


/******************************************************************
 *
 * Type Codes for Ethernet packets
 *
 ******************************************************************/

#define TY_ETHER 1
#ifndef TYPE_HACK
#define TY_PUP          0x0200
#define TY_IDP          0x0600
#define TY_IP           0x0800
#define TY_X25          0x0805
#define TY_ARP          0x0806
#define TY_RARP         0x8035
#ifndef NOTRAILER
#define TY_TRAIL        0x1000
#define TY_TRAIL_LO     0x1001
#define TY_TRAIL_HI     0x1002
#endif
#define TY_ECHO         0x9000
#else /*TYPE_HACK*/
#define TY_PUP          0x0200
#define TY_IDP          0x0600
#define TY_IP           0x0807          /* modified */
#define TY_X25          0x0805
#define TY_ARP          0x0808          /* modified */
#ifndef NOTRAILER
#define TY_TRAIL        0x2000          /* modified */
#define TY_TRAIL_LO     0x2001          /* modified */
#define TY_TRAIL_HI     0x2002          /* modified */
#endif
#define TY_ECHO         0x9000
#endif /*TYPE_HACK*/

/******************************************************************
 *
 * Type Codes for Arcnet packets
 *
 ******************************************************************/

#define ARCNET_TY_IP   0xd4
#define ARCNET_TY_ARP  0xd5
#define ARCNET_TY_RARP 0xd6

/*
 * LOOPBACK Address - in host and network byte order
 */
#define LOOPBACK 0x7F000001L
#ifdef BYTESWAP
#define NLOOPBACK 0x0100007FL
#else
#define NLOOPBACK 0x7F000001L
#endif

/*
 * interface flags
 */
#define IFF_UP                  0x01
#define IFF_BROADCAST           0x02
#define IFF_LOOPBACK            0x04
#define IFF_POINTOPOINT         0x08
#define IFF_FORWARDBROADCAST    0x10
#define IFF_NOKEEPALIVE         0x20
#define IFF_SLOWLINK            0x40


/*
 * IP Options
 */

#define IPO_TTL         103
#define IPO_TOS         104
#define IPO_OPTS        105
#define IPO_RDOPTION    106
#define IPO_RDROUTE     IPO_RDOPTION
#define IPO_OPTCOUNT    107
#define IPO_RRCOUNT     IPO_OPTCOUNT


/*
 * IP Option values
 */

#define OPT_SECURITY    130
#define OPT_LSRR        131
#define OPT_SSRR        137
#define OPT_RR            7
#define OPT_STRID       136
#define OPT_TIMESTAMP    68

/*
 * Default Time to Live
 */

#define IHTTL   60

/*
 * Maximum number of hops stored in a recorded route packet
 */

#define TCP_RR_MAX      16

#define MAXOPTLEN 256

#ifndef GENERICE
/*
 * errors generated
 */
#define EFRGSZ  1
#define EDLTYPE 2
#define EPRIM   3
#define EBUF    4
#define EMSG    5
#endif /*~GENERICE*/

#endif  //IN_INCLUDED