Logo Search packages:      
Sourcecode: l2tpd version File versions  Download package

avp.h

/*
 * $Id$
 *
 * Layer Two Tunnelling Protocol Daemon
 * Copyright (C) 1998 Adtran, Inc.
 * Copyright (C) 2002 Jeff McAdams
 *
 * Mark Spencer
 *
 * This software is distributed under the terms
 * of the GPL, which you should have received
 * along with this source.
 *
 * Attribute Value Pair structures and
 * definitions
 */

#include "common.h"

struct avp_hdr
{
    u_int16_t     length;
    u_int16_t     vendorid;
    u_int16_t     attr;
};

#define AVP_F_MANDATORY 0x1
#define AVP_F_FIXLEN    0x2
#define AVP_F_ASCII           0x4

struct avp
{
    u_int32_t     num;                    /* Number of AVP */
    u_int32_t     flags;
      u_int32_t   sz;                           /* expected avp payload size as
                                                       * (AVP_F_FIXLEN) ? (==) : (!>=)
                                                       * note: size checked is performed 
                                                       * after unhiding */
      u_int8_t    allowed_states[8];      /* List of allowed message types for
                                                       * a particular avp. Fixed len for
                                                       * alignement issues. */

    /* This should handle the AVP taking a tunnel, call, 
       * the data, and the length of the AVP as parameters.  
       * Should return 0 upon success */
    int (*handle) (struct tunnel *, struct call *, void *, int);

      /* This should handle avp specifics sanity checks */
      int (*validate) (int, struct tunnel *, struct call *, void *, int);
    char *description;              /* A name, for debugging */
};

extern int handle_avps (struct buffer *buf, struct tunnel *t, struct call *c);

extern char *msgtypes[];

#define VENDOR_ID 0             /* We don't have any extensions
                                   so we shoouldn't have to
                                   worry about this */

/*
 * Macros to extract information from length field of AVP
 */

#define AMBIT(len) (len & 0x8000)       /* Mandatory bit: If this is
                                           set on an unknown AVP, 
                                           we MUST terminate */

#define AHBIT(len) (len & 0x4000)       /* Hidden bit: Specifies
                                           information hiding */

#define AZBITS(len) (len & 0x3C00)      /* Reserved bits:  We must
                                           drop anything with any
                                           of these set.  */

#define ALENGTH(len) (len & 0x03FF)     /* Length:  Lenth of AVP */

#define MAXTIME 300             /* time to wait before checking
                                   Ns and Nr, in ms */

#define MBIT 0x8000             /* for setting */
#define HBIT 0x4000             /* Set on hidden avp's */

#define ASYNC_FRAMING 2
#define SYNC_FRAMING 1

#define ANALOG_BEARER 2
#define DIGITAL_BEARER 1

#define VENDOR_ERROR 6

#define ERROR_RESERVED 3
#define ERROR_LENGTH 2
#define ERROR_NOTEXIST 1
#define ERROR_NORES 4
#define ERROR_INVALID 6
#define RESULT_CLEAR 1
#define RESULT_ERROR 2
#define RESULT_EXISTS 3

/* avp id's */
#define     MESSAGE_TYPE_AVP        0
#define RESULT_CODE_AVP             1
#define PROTOCOL_VERSION_AVP  2
#define     FRAMING_CAP_AVP               3
#define     BEARER_CAP_AVP                4
#define TIE_BREAKER_AVP             5
#define     FIRMWARE_REV_AVP        6
#define     HOSTNAME_AVP                  7
#define VENDOR_NAME_AVP             8
#define ASSIGNED_TUN_ID_AVP         9
#define     RX_WIN_SIZE_AVP               10
#define     CHALLENGE_AVP                 11
#define     CHALLENGE_RESP_AVP            12
#define     CAUSE_ERROR_AVP               13
#define     ASSIGNED_SES_ID_AVP           14
#define     SERIAL_NUMBER_AVP       15
#define     MIN_BPS_AVP                   16
#define     MAX_BPS_AVP                   17
#define     BEARER_TYPE_AVP               18
#define     FRAMING_TYPE_AVP        19
#define     PACKET_DELAY_AVP        20
#define     CALLED_NUMBER_AVP       21
#define CALLING_NUMBER_AVP          22
#define     SUB_ADDRESS_AVP               23
#define     TX_CONNECT_SPEED_AVP    24
#define     PHYS_CHAN_ID_AVP        25
#define     INIT_RX_LCP_AVP               26
#define     LAST_TX_LCP_AVP               27
#define     LAST_RX_LCP_AVP               28
#define     PROXY_AUTH_TYPE_AVP           29
#define     PROXY_AUTH_NAME_AVP           30
#define     PROXY_AUTH_CHAL_AVP           31
#define     PROXY_AUTH_ID_AVP       32
#define     PROXY_AUTH_CHAL_RESP_AVP      33
#define CALL_ERROR_AVP              34
#define     ACCM_AVP                      35
#define RANDOM_VECTOR_AVP           36
#define     PRIV_GROUP_ID_AVP       37
#define     RX_CONNECT_SPEED_AVP    38
#define     SEQ_REQUIRED_AVP        39
#define AVP_MAX                     SEQ_REQUIRED_AVP

extern int validate_msgtype_avp(int, struct tunnel *, struct call *, void *, int);
extern int validate_gen_avp(int, struct tunnel *, struct call *, void *, int);

extern void encrypt_avp (struct buffer *, _u16, struct tunnel *);
extern int decrypt_avp (char *, struct tunnel *);

extern int message_type_avp (struct tunnel *, struct call *, void *, int);
extern int protocol_version_avp (struct tunnel *, struct call *, void *, int);
extern int framing_caps_avp (struct tunnel *, struct call *, void *, int);
extern int bearer_caps_avp (struct tunnel *, struct call *, void *, int);
extern int firmware_rev_avp (struct tunnel *, struct call *, void *, int);
extern int hostname_avp (struct tunnel *, struct call *, void *, int);
extern int vendor_avp (struct tunnel *, struct call *, void *, int);
extern int assigned_tunnel_avp (struct tunnel *, struct call *, void *, int);
extern int receive_window_size_avp (struct tunnel *, struct call *, void *,
                                    int);
extern int result_code_avp (struct tunnel *, struct call *, void *, int);
extern int assigned_session_avp (struct tunnel *, struct call *, void *, int);
extern int call_serno_avp (struct tunnel *, struct call *, void *, int);
extern int bearer_type_avp (struct tunnel *, struct call *, void *, int);
extern int call_physchan_avp (struct tunnel *, struct call *, void *, int);
extern int called_number_avp (struct tunnel *, struct call *, void *, int);
extern int calling_number_avp (struct tunnel *, struct call *, void *, int);
extern int sub_address_avp (struct tunnel *, struct call *, void *, int);
extern int frame_type_avp (struct tunnel *, struct call *, void *, int);
extern int rx_speed_avp (struct tunnel *, struct call *, void *, int);
extern int tx_speed_avp (struct tunnel *, struct call *, void *, int);
extern int packet_delay_avp (struct tunnel *, struct call *, void *, int);
extern int ignore_avp (struct tunnel *, struct call *, void *, int);
extern int seq_reqd_avp (struct tunnel *, struct call *, void *, int);
extern int challenge_avp (struct tunnel *, struct call *, void *, int);
extern int chalresp_avp (struct tunnel *, struct call *, void *, int);
extern int rand_vector_avp (struct tunnel *, struct call *, void *, int);

extern int add_challenge_avp (struct buffer *, char *, int);
extern int add_avp_rws (struct buffer *, _u16);
extern int add_tunnelid_avp (struct buffer *, _u16);
extern int add_vendor_avp (struct buffer *);
extern int add_hostname_avp (struct buffer *, struct tunnel*);
extern int add_firmware_avp (struct buffer *);
extern int add_bearer_caps_avp (struct buffer *buf, _u16 caps);
extern int add_frame_caps_avp (struct buffer *buf, _u16 caps);
extern int add_protocol_avp (struct buffer *buf);
extern int add_message_type_avp (struct buffer *buf, _u16 type);
extern int add_result_code_avp (struct buffer *buf, _u16, _u16, char *, int);
extern int add_bearer_avp (struct buffer *, int);
extern int add_frame_avp (struct buffer *, int);
extern int add_rxspeed_avp (struct buffer *, int);
extern int add_txspeed_avp (struct buffer *, int);
extern int add_serno_avp (struct buffer *, unsigned int);
#ifdef TEST_HIDDEN
extern int add_callid_avp (struct buffer *, _u16, struct tunnel *);
#else
extern int add_callid_avp (struct buffer *, _u16);
#endif
extern int add_ppd_avp (struct buffer *, _u16);
extern int add_seqreqd_avp (struct buffer *);
extern int add_chalresp_avp (struct buffer *, char *, int);
extern int add_randvect_avp (struct buffer *, char *, int);
extern int add_minbps_avp (struct buffer *buf, int speed);      /* jz: needed for outgoing call */
extern int add_maxbps_avp (struct buffer *buf, int speed);      /* jz: needed for outgoing call */
extern int add_number_avp (struct buffer *buf, char *no);       /* jz: needed for outgoing call */

Generated by  Doxygen 1.6.0   Back to index