1
2 #define MPPE_PAD 4
3 #define MPPE_MAX_KEY_LEN 16
4
5
6 #define MPPE_OPT_40 0x01
7 #define MPPE_OPT_128 0x02
8 #define MPPE_OPT_STATEFUL 0x04
9
10 #define MPPE_OPT_56 0x08
11 #define MPPE_OPT_MPPC 0x10
12 #define MPPE_OPT_D 0x20
13 #define MPPE_OPT_UNSUPPORTED (MPPE_OPT_56|MPPE_OPT_MPPC|MPPE_OPT_D)
14 #define MPPE_OPT_UNKNOWN 0x40
15
16
17
18
19
20
21
22
23 #define MPPE_C_BIT 0x01
24 #define MPPE_D_BIT 0x10
25 #define MPPE_L_BIT 0x20
26 #define MPPE_S_BIT 0x40
27 #define MPPE_M_BIT 0x80
28 #define MPPE_H_BIT 0x01
29
30
31 #define MPPE_ALL_BITS (MPPE_D_BIT|MPPE_L_BIT|MPPE_S_BIT|MPPE_M_BIT|MPPE_H_BIT)
32
33
34 #define MPPE_OPTS_TO_CI(opts, ci) \
35 do { \
36 u_char *ptr = ci; \
37 \
38 \
39 if (opts & MPPE_OPT_STATEFUL) \
40 *ptr++ = 0x0; \
41 else \
42 *ptr++ = MPPE_H_BIT; \
43 *ptr++ = 0; \
44 *ptr++ = 0; \
45 \
46 \
47 *ptr = 0; \
48 if (opts & MPPE_OPT_128) \
49 *ptr |= MPPE_S_BIT; \
50 if (opts & MPPE_OPT_40) \
51 *ptr |= MPPE_L_BIT; \
52 \
53 } while ( 0)
54
55
56 #define MPPE_CI_TO_OPTS(ci, opts) \
57 do { \
58 u_char *ptr = ci; \
59 \
60 opts = 0; \
61 \
62 \
63 if (!(ptr[0] & MPPE_H_BIT)) \
64 opts |= MPPE_OPT_STATEFUL; \
65 \
66 \
67 if (ptr[3] & MPPE_S_BIT) \
68 opts |= MPPE_OPT_128; \
69 if (ptr[3] & MPPE_L_BIT) \
70 opts |= MPPE_OPT_40; \
71 \
72 \
73 if (ptr[3] & MPPE_M_BIT) \
74 opts |= MPPE_OPT_56; \
75 if (ptr[3] & MPPE_D_BIT) \
76 opts |= MPPE_OPT_D; \
77 if (ptr[3] & MPPE_C_BIT) \
78 opts |= MPPE_OPT_MPPC; \
79 \
80 \
81 if (ptr[0] & ~MPPE_H_BIT) \
82 opts |= MPPE_OPT_UNKNOWN; \
83 if (ptr[1] || ptr[2]) \
84 opts |= MPPE_OPT_UNKNOWN; \
85 if (ptr[3] & ~MPPE_ALL_BITS) \
86 opts |= MPPE_OPT_UNKNOWN; \
87 } while ( 0)