root / lab4 / .minix-src / include / net / gen / vjhc.h @ 14
History | View | Annotate | Download (1.55 KB)
1 |
/*
|
---|---|
2 |
net/gen/vjhc.h
|
3 |
|
4 |
Defines for Van Jacobson TCP/IP Header Compression as defined in RFC-1144
|
5 |
|
6 |
Created: Nov 15, 1993 by Philip Homburg <philip@cs.vu.nl>
|
7 |
*/
|
8 |
|
9 |
#ifndef __NET__GEN__VJHC_H__
|
10 |
#define __NET__GEN__VJHC_H__
|
11 |
|
12 |
#define VJHC_FLAG_U 0x01 |
13 |
#define VJHC_FLAG_W 0x02 |
14 |
#define VJHC_FLAG_A 0x04 |
15 |
#define VJHC_FLAG_S 0x08 |
16 |
#define VJHC_FLAG_P 0x10 |
17 |
#define VJHC_FLAG_I 0x20 |
18 |
#define VJHC_FLAG_C 0x40 |
19 |
|
20 |
#define VJHC_SPEC_I (VJHC_FLAG_S | VJHC_FLAG_W | VJHC_FLAG_U)
|
21 |
#define VJHC_SPEC_D (VJHC_FLAG_S | VJHC_FLAG_A | VJHC_FLAG_W | VJHC_FLAG_U)
|
22 |
#define VJHC_SPEC_MASK (VJHC_FLAG_S | VJHC_FLAG_A | VJHC_FLAG_W | VJHC_FLAG_U)
|
23 |
|
24 |
#define VJHC_ENCODE(cp, n) \
|
25 |
{ \ |
26 |
if ((u16_t)(n) >= 256) \ |
27 |
{ \ |
28 |
*(cp)++= 0; \
|
29 |
*(cp)++= (n >> 8); \
|
30 |
*(cp)++= (n); \ |
31 |
} \ |
32 |
else \
|
33 |
*(cp)++= (n); \ |
34 |
} |
35 |
|
36 |
#define VJHC_ENCODEZ(cp, n) \
|
37 |
{ \ |
38 |
if ((u16_t)(n) == 0 || (u16_t)(n) >= 256) \ |
39 |
{ \ |
40 |
*(cp)++= 0; \
|
41 |
*(cp)++= (n >> 8); \
|
42 |
*(cp)++= (n); \ |
43 |
} \ |
44 |
else \
|
45 |
*(cp)++= (n); \ |
46 |
} |
47 |
|
48 |
#define VJHC_DECODEL(cp, l) \
|
49 |
{ \ |
50 |
if (*(cp) == 0) \ |
51 |
{ \ |
52 |
(l)= htonl(ntohl((l)) + (((cp)[1] << 8) | (cp)[2])); \ |
53 |
(cp) += 3; \
|
54 |
} \ |
55 |
else \
|
56 |
(l)= htonl(ntohl((l)) + (u32_t)*(cp)++); \ |
57 |
} |
58 |
|
59 |
#define VJHC_DECODES(cp, s) \
|
60 |
{ \ |
61 |
if (*(cp) == 0) \ |
62 |
{ \ |
63 |
(s)= htons(ntohs((s)) + (((cp)[1] << 8) | (cp)[2])); \ |
64 |
(cp) += 3; \
|
65 |
} \ |
66 |
else \
|
67 |
(s)= htons(ntohs((s)) + (u16_t)*(cp)++); \ |
68 |
} |
69 |
|
70 |
#define VJHC_DECODEU(cp, s) \
|
71 |
{ \ |
72 |
if (*(cp) == 0) \ |
73 |
{ \ |
74 |
(s)= htons(((cp)[1] << 8) | (cp)[2]); \ |
75 |
(cp) += 3; \
|
76 |
} \ |
77 |
else \
|
78 |
(s)= htons((u16_t)*(cp)++); \ |
79 |
} |
80 |
|
81 |
#endif /* __NET__GEN__VJHC_H__ */ |
82 |
|
83 |
/*
|
84 |
* $PchId: vjhc.h,v 1.2 1995/11/17 22:14:46 philip Exp $
|
85 |
*/
|