summaryrefslogtreecommitdiffstats
path: root/private/inc/sys/snet/ip_proto.h
blob: aa42742edf7bd3d8f978f2d8713539edaf4a2e77 (plain) (blame)
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
/*++

Copyright (c) 1991  Microsoft Corporation

Module Name:

    ip_proto.h

Abstract:

    This module contains definitions for STREAMS IP

Author:

    Eric Chin (ericc)           July 18, 1991

Revision History:

--*/

/******************************************************************
 *
 *  SpiderTCP Interface Primitives
 *
 *  Copyright (c) 1988  Spider Systems Limited
 *
 *  This Source Code is furnished under Licence, and may not be
 *  copied or distributed without express written agreement.
 *
 *  All rights reserved.
 *
 *  Written by          Nick Felisiak, Ian Heavens, Peter Reid,
 *                      Gavin Shearer, Mark Valentine
 *
 *  IP_PROTO.H
 *
 *   IP Streams proto primitives for TCP/IP on V.3/V.4 Streams
 *
 ******************************************************************/

#ifndef _SYS_SNET_IP_PROTO_
#define _SYS_SNET_IP_PROTO_


#ifndef IPOPTS
#define IPOPTS
#endif

#define IP_TX           6       /* tcp/udp send pkt to ip */
#define PROT_RX         8       /* tcp/udp get pkt from ip */
#define IP_PROTQ        9       /* tcp/udp send prot q to ip */
#define ICMP_RX         12      /* upper layer rcv icmp pkt from ip */
#define ICMP_TX         13      /* upper layer send icmp pkt to ip */
#define ENQ_LOCAL       14      /* validate local address enquiry */
#define ENQ_REMOTE      15      /* validate remote address enquiry */
#define IP_FLOW         16      /* flow control interface to upper layers */
#define IP_PROT_REMOVEQ 17      /* tcp/udp deregister prot q to ip */

#ifdef TESTOPT
/*
 * TESTOPT driver field
 */
#define TCPTEST         1
#define UDPTEST         TCPTEST
#define IPTEST          2

/*
 * TESTOPT type field
 */

#define NEXT            1       /* carry out for next num packets */
#define ALL             2       /* carry out for all packets */
#define OFF             3       /* turn off option */
#define RANDOM          4       /* carry out for random packets, prob 1/num */

/*
 * TESTOPT option field
 */

#define BAD_CKSUM       1
#define SHORT_HDR       2
#define DROP            3       /* drop packet or fragment */
#define CONTROL         4       /* OR ctl field with subopt, TCP only */
#define BAD_TYPE        5       /* bad multiplexing type: port for TCP,
                                   protocol for IP */

typedef struct testopt {
    char driver;    /* option for which driver: TCP/UDP, IP */
    char option;    /* option */
    char subopt;    /* suboption if applicable */
    char type;      /* next, on, off */
    int  num;       /* number of packets - depends on */
} TEST_OPT;

#endif

/*
 * 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;

/*
 * IP Option values
 */
#define OPT_EOL           0
#define OPT_NOP           1
#define OPT_SECURITY    130
#define OPT_LSRR        131
#define OPT_SSRR        137
#define OPT_RR            7
#define OPT_STRID       136
#define OPT_TIMESTAMP    68

/*
 * structure of pseudo-header used for communication
 * between IP and higher level processes
 */
typedef struct {
    short ps_pktid;            /* id to be used in inet header */
    short ps_status;           /* indicates status of requested action */
#define OK 0                       /* status for non-ICMP packet */
    IN_ADDRESS ps_src;         /* source address */
    IN_ADDRESS ps_dst;         /* destination address */
    unsigned short ps_txtlen;  /* length of text */
    short ps_offset;           /* Fragment Offset */
    short ps_if;               /* IP Interface number */
    unsigned char ps_prot;     /* Internet protocol number */
    char ps_df;                /* Don't Fragment flag */
    char ps_ttl;               /* Time to Live flag */
#ifdef TESTOPT
    int test;                  /* testing on for this packet */
    TEST_OPT testopt;          /* options for testing */
#endif
#ifdef IPOPTS
    char ps_pkt_type;          /* What's this packet doing? */
    char ps_optlen;            /* Length of options (in words) */
    char ps_tos;               /* Type of service */
    int ps_options[1];         /* Options */
#endif
} PSEUDO_HDR;

#define SIZ_PSEUDOHDR sizeof(PSEUDO_HDR)


/*
 * Types of pkt_type
 */

#define PS_FROM_ME      1       /* Started here */
#define PS_FOR_ME       2       /* Dest is this machine */
#define PS_THRU_ME      3       /* Just passing through */
#define PS_SS_ROUTING   4       /* Being strict source routed */
#define PS_LS_ROUTING   5       /* Being loose source routed */
#define PS_REPLY        6       /* response to another pkt (ie echo reply) */

typedef struct ip_protq {
    int prim_type;
    unsigned char prot;
} S_IP_PROTQ;

/*
 * status returned to upper layer in prot
 */
#define VALID   0
#define IN_USE  1
#define INVALID 2

/*
 * received from transport protocol when it sends a packet
 */
typedef struct ip_tx {
    int prim_type;
    short hdr_cnt;
    short unused1;       /* ensure structure is same size as S_PROT_RX */
    BOOLEAN unused2;     /* ensure structure is same size as S_PROT_RX */
    PSEUDO_HDR uph;
} S_IP_TX;

/*
 * sent to transport protocol when we receive a packet
 */
typedef struct prot_rx {
    int prim_type;
    IN_ADDRESS if_addr;
    BOOLEAN is_broadcast;
    PSEUDO_HDR uph;
} S_PROT_RX;


/*
 * The ICMP_RX struct
 */
struct icmp_rx {
    int prim_type;
    IN_ADDRESS if_addr;
    BOOLEAN is_broadcast;
    unsigned char type;
    unsigned char code;
    long src;
    long dst;
    unsigned long misc;
    PSEUDO_HDR uph;
};


/*
 * The ICMP_TX struct
 */
struct icmp_tx {
    int prim_type;
    unsigned char type;
    unsigned char code;
    long src;
    long dst;
    unsigned long misc;
    PSEUDO_HDR ph;
};



/*
 * The IP_ADDRENQ struct
 */

struct ip_addrenq {
    int           prim_type;           /* ENQ_LOCAL or ENQ_REMOTE */
    char         *handle;              /* Place holder for TCP */
    long          addr;                /* Remote address */
    long          local;               /* Returned local address */
    int           error;               /* Zero if OK, else errno */
    int           mss;                 /* Max seg size for this transfer */
    int           flags;               /* See below */
    int           ifno;                /* IP's interface number for this addr */
    int           broadcast;           /* Set if remote address is broadcast */
    unsigned long link_speed;          /* adapter link speed in kbits/second */
    unsigned long receive_buffer_size; /* bytes of adapter receive space */
};


#define ENQ_NO_KEEPALIVE        1       /* No keep-alives for this net */


/*
 * IP Flow control structure
 */

struct ip_flow_info {
    int prim_type;          /* IP_FLOW */
    int index;              /* IP Interface number */
    int info;               /* Blocked or unblocked */
};

/**************************************************************
 * ICMP constants:      types & codes
 **************************************************************/

#define ECHO_REPLY              0               /* echo reply */

#define DEST_UNR                3               /* destination unreachable: */

/* codes for DEST_UNR */
#define         NET_UNR                 0       /* net unreachable */
#define         HOST_UNR                1       /* host unreachable */
#define         PROT_UNR                2       /* protocol unreachable */
#define         PORT_UNR                3       /* port unreachable */
#define         FRAG_DF                 4       /* fragmentation needed + DF */
#define         SR_FAIL                 5       /* source route failed */
#define         DST_NET_UNKNOWN         6       /* dest network unknown */
#define         DST_HOST_UNKNOWN        7       /* dest host unknown */
#define         SRC_HOST_ISOLATED       8       /* source host isolated */
#define         NET_PROHIBITED          9       /* communication with dest
                                                   network administratively
                                                   prohibited */
#define         HOST_PROHIBITED         10      /* communication with dest
                                                   host administratively
                                                   prohibited */
#define         NET_UNR_FOR_TOS         11      /* network unreachable
                                                   for type of service */
#define         HOST_UNR_FOR_TOS        12      /* host unreachable
                                                   for type of service */

#define SRC_QUENCH              4               /* source quench */

#define REDIRECT                5               /* redirect message: */
#define         NET_RE                  0       /* redirect for network */
#define         HOST_RE                 1       /* redirect for host */
#define         TOSN_RE                 2       /* redirect for TOS/network */
#define         TOSH_RE                 3       /* redirect for TOS/host */

#define ICMP_ECHO               8               /* echo request */

#define TIME_EXCEEDED          11               /* time exceeded: */
#define         TTL_X                   0       /* time-to-live exceeded */
#define         FRAG_X                  1       /* frag reassem time excluded */

#define PARAMETER               12              /* parameter problem */
#define         PARAM_POINTER           0       /* pointer indicates error */
#define         PARAM_OPTION            1       /* required option missing */

#define TIME_STAMP              13              /* timestamp request */
#define STAMP_REPLY             14              /* timestamp reply */

#define INFO_REQ                15              /* information request */
#define INFO_REPLY              16              /* information reply */

#define MASK_REQ                17              /* address mask request */
#define MASK_REPLY              18              /* address mask reply */

#endif /* _SYS_SNET_IP_PROTO_ */