Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / xl2tpd / avp.h
blobc024ca68f998d2f5c868e7d9aec7889e7a8924df
1 /*
2 * Layer Two Tunnelling Protocol Daemon
3 * Copyright (C) 1998 Adtran, Inc.
4 * Copyright (C) 2002 Jeff McAdams
6 * Mark Spencer
8 * This software is distributed under the terms
9 * of the GPL, which you should have received
10 * along with this source.
12 * Attribute Value Pair structures and
13 * definitions
16 #include "common.h"
18 struct avp_hdr
20 _u16 length;
21 _u16 vendorid;
22 _u16 attr;
23 } __attribute__((packed));
25 struct avp
27 int num; /* Number of AVP */
28 int m; /* Set M? */
29 int (*handler) (struct tunnel *, struct call *, void *, int);
30 /* This should handle the AVP
31 taking a tunnel, call, the data,
32 and the length of the AVP as
33 parameters. Should return 0
34 upon success */
35 char *description; /* A name, for debugging */
38 extern int handle_avps (struct buffer *buf, struct tunnel *t, struct call *c);
40 extern char *msgtypes[];
42 #define VENDOR_ID 0 /* We don't have any extensions
43 so we shoouldn't have to
44 worry about this */
47 * Macros to extract information from length field of AVP
50 #define AMBIT(len) (len & 0x8000) /* Mandatory bit: If this is
51 set on an unknown AVP,
52 we MUST terminate */
54 #define AHBIT(len) (len & 0x4000) /* Hidden bit: Specifies
55 information hiding */
57 #define AZBITS(len) (len & 0x3C00) /* Reserved bits: We must
58 drop anything with any
59 of these set. */
61 #define ALENGTH(len) (len & 0x03FF) /* Length: Lenth of AVP */
63 #define MAXAVPSIZE 1023
65 #define MAXTIME 300 /* time to wait before checking
66 Ns and Nr, in ms */
68 #define MBIT 0x8000 /* for setting */
69 #define HBIT 0x4000 /* Set on hidden avp's */
71 #define ASYNC_FRAMING 2
72 #define SYNC_FRAMING 1
74 #define ANALOG_BEARER 2
75 #define DIGITAL_BEARER 1
77 #define VENDOR_ERROR 6
79 #define ERROR_RESERVED 3
80 #define ERROR_LENGTH 2
81 #define ERROR_NOTEXIST 1
82 #define ERROR_NORES 4
83 #define ERROR_INVALID 6
84 #define RESULT_CLEAR 1
85 #define RESULT_ERROR 2
86 #define RESULT_EXISTS 3
87 extern void encrypt_avp (struct buffer *, _u16, struct tunnel *);
88 extern int decrypt_avp (char *, struct tunnel *);
89 extern int message_type_avp (struct tunnel *, struct call *, void *, int);
90 extern int protocol_version_avp (struct tunnel *, struct call *, void *, int);
91 extern int framing_caps_avp (struct tunnel *, struct call *, void *, int);
92 extern int bearer_caps_avp (struct tunnel *, struct call *, void *, int);
93 extern int firmware_rev_avp (struct tunnel *, struct call *, void *, int);
94 extern int hostname_avp (struct tunnel *, struct call *, void *, int);
95 extern int vendor_avp (struct tunnel *, struct call *, void *, int);
96 extern int assigned_tunnel_avp (struct tunnel *, struct call *, void *, int);
97 extern int receive_window_size_avp (struct tunnel *, struct call *, void *,
98 int);
99 extern int result_code_avp (struct tunnel *, struct call *, void *, int);
100 extern int assigned_call_avp (struct tunnel *, struct call *, void *, int);
101 extern int call_serno_avp (struct tunnel *, struct call *, void *, int);
102 extern int bearer_type_avp (struct tunnel *, struct call *, void *, int);
103 extern int call_physchan_avp (struct tunnel *, struct call *, void *, int);
104 extern int dialed_number_avp (struct tunnel *, struct call *, void *, int);
105 extern int dialing_number_avp (struct tunnel *, struct call *, void *, int);
106 extern int sub_address_avp (struct tunnel *, struct call *, void *, int);
107 extern int frame_type_avp (struct tunnel *, struct call *, void *, int);
108 extern int rx_speed_avp (struct tunnel *, struct call *, void *, int);
109 extern int tx_speed_avp (struct tunnel *, struct call *, void *, int);
110 extern int packet_delay_avp (struct tunnel *, struct call *, void *, int);
111 extern int ignore_avp (struct tunnel *, struct call *, void *, int);
112 extern int seq_reqd_avp (struct tunnel *, struct call *, void *, int);
113 extern int challenge_avp (struct tunnel *, struct call *, void *, int);
114 extern int chalresp_avp (struct tunnel *, struct call *, void *, int);
115 extern int rand_vector_avp (struct tunnel *, struct call *, void *, int);
117 extern int add_challenge_avp (struct buffer *, unsigned char *, int);
118 extern int add_avp_rws (struct buffer *, _u16);
119 extern int add_tunnelid_avp (struct buffer *, _u16);
120 extern int add_vendor_avp (struct buffer *);
121 extern int add_hostname_avp (struct buffer *, const char *);
122 extern int add_firmware_avp (struct buffer *);
123 extern int add_bearer_caps_avp (struct buffer *buf, _u16 caps);
124 extern int add_frame_caps_avp (struct buffer *buf, _u16 caps);
125 extern int add_protocol_avp (struct buffer *buf);
126 extern int add_message_type_avp (struct buffer *buf, _u16 type);
127 extern int add_result_code_avp (struct buffer *buf, _u16, _u16, char *, int);
128 extern int add_bearer_avp (struct buffer *, int);
129 extern int add_frame_avp (struct buffer *, int);
130 extern int add_rxspeed_avp (struct buffer *, int);
131 extern int add_txspeed_avp (struct buffer *, int);
132 extern int add_serno_avp (struct buffer *, unsigned int);
133 #ifdef TEST_HIDDEN
134 extern int add_callid_avp (struct buffer *, _u16, struct tunnel *);
135 #else
136 extern int add_callid_avp (struct buffer *, _u16);
137 #endif
138 extern int add_ppd_avp (struct buffer *, _u16);
139 extern int add_seqreqd_avp (struct buffer *);
140 extern int add_chalresp_avp (struct buffer *, unsigned char *, int);
141 extern int add_randvect_avp (struct buffer *, unsigned char *, int);
142 extern int add_minbps_avp (struct buffer *buf, int speed); /* jz: needed for outgoing call */
143 extern int add_maxbps_avp (struct buffer *buf, int speed); /* jz: needed for outgoing call */
144 extern int add_number_avp (struct buffer *buf, char *no); /* jz: needed for outgoing call */