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