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