Files
m241Neelima/components/ip_net2-6.9/ipl2tp/src/ipl2tp_message.h
T
2026-07-30 11:19:44 +05:30

350 lines
13 KiB
C

/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipl2tp_message.h,v $ $Revision: 1.2 $
* $Source: /home/interpeak/CVSRoot/ipl2tp/src/ipl2tp_message.h,v $
* $Author: joel $ $Date: 2006-01-30 10:47:46 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
******************************************************************************
*/
#ifndef IPL2TP_MESSAGE_H
#define IPL2TP_MESSAGE_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include "ipl2tp_v2.h"
#include "ipl2tp_v3.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/* Container flag values */
#define IPL2TP_CONTAINER_SENT 0x01
#define IPL2TP_CONTAINER_RV 0x02
/*
*---------------------------------------------------------------------------
* Message type
*---------------------------------------------------------------------------
*/
#define IPL2TP_MSG_ZLB 0 /*$ ZLB - Zero-Length-Body (internal use) $*/
#define IPL2TP_MSG_SCCRQ 1 /*$ SCCRQ - Start-Control-Connection-Request $*/
#define IPL2TP_MSG_SCCRP 2 /*$ SCCRP - Start-Control-Connection-Reply $*/
#define IPL2TP_MSG_SCCCN 3 /*$ SCCCN - Start-Control-Connection-Connected $*/
#define IPL2TP_MSG_StopCCN 4 /*$ StopCCN - Stop-Control-Connection-Notify $*/
#define IPL2TP_MSG_HELLO 6 /*$ HELLO $*/
#define IPL2TP_MSG_OCRQ 7 /*$ OCRQ - Outgoing-Call-Request $*/
#define IPL2TP_MSG_OCRP 8 /*$ OCRP - Outgoing-Call-Reply $*/
#define IPL2TP_MSG_OCCN 9 /*$ OCCN - Outgoing-Call-Connected $*/
#define IPL2TP_MSG_ICRQ 10 /*$ ICRQ - Incoming-Call-Request $*/
#define IPL2TP_MSG_ICRP 11 /*$ ICRP - Incoming-Call-Reply $*/
#define IPL2TP_MSG_ICCN 12 /*$ ICCN - Incoming-Call-Connected $*/
#define IPL2TP_MSG_CDN 14 /*$ CDN - Call-Disconnect-Notify $*/
#define IPL2TP_MSG_WEN 15 /*$ WEN - WAN-Error-Notify $*/
#define IPL2TP_MSG_SLI 16 /*$ SLI - Set-Link-Info $*/
#define IPL2TP_MSG_ACK 20 /*$ ACK - Explicit acknowledgement $*/
#define IPL2TP_MSG_MAX (IPL2TP_MSG_ACK + 1)
#define ipl2tp_message_call(c,t,s,a)\
(*(((t)->table->messages)[c]))(t,s,a)
#define ipl2tp_message_sccrq(t)\
ipl2tp_message_call(IPL2TP_MSG_SCCRQ, t, IP_NULL, IP_NULL)
#define ipl2tp_message_sccrp(t,a)\
ipl2tp_message_call(IPL2TP_MSG_SCCRP, t, IP_NULL, a)
#define ipl2tp_message_scccn(t,a)\
ipl2tp_message_call(IPL2TP_MSG_SCCCN, t, IP_NULL, a)
#define ipl2tp_message_stopccn(t)\
ipl2tp_message_call(IPL2TP_MSG_StopCCN, t, IP_NULL, IP_NULL)
#define ipl2tp_message_icrq(s)\
ipl2tp_message_call(IPL2TP_MSG_ICRQ, (s)->tunnel, s, IP_NULL)
#define ipl2tp_message_icrp(s)\
ipl2tp_message_call(IPL2TP_MSG_ICRP, (s)->tunnel, s, IP_NULL)
#define ipl2tp_message_iccn(s)\
ipl2tp_message_call(IPL2TP_MSG_ICCN, (s)->tunnel, s, IP_NULL)
#define ipl2tp_message_ocrq(s)\
ipl2tp_message_call(IPL2TP_MSG_OCRQ, (s)->tunnel, s, IP_NULL)
#define ipl2tp_message_ocrp(s)\
ipl2tp_message_call(IPL2TP_MSG_OCRP, (s)->tunnel, s, IP_NULL)
#define ipl2tp_message_occn(s)\
ipl2tp_message_call(IPL2TP_MSG_OCCN, (s)->tunnel, s, IP_NULL)
#define ipl2tp_message_cdn(s)\
ipl2tp_message_call(IPL2TP_MSG_CDN, (s)->tunnel, s, IP_NULL)
#define ipl2tp_message_zlb(t)\
ipl2tp_message_call(IPL2TP_MSG_ZLB, t, IP_NULL, IP_NULL)
#define ipl2tp_message_hello(t)\
ipl2tp_message_call(IPL2TP_MSG_HELLO, t, IP_NULL, IP_NULL)
#define ipl2tp_message_sli(s)\
ipl2tp_message_call(IPL2TP_MSG_SLI, (s)->tunnel, s, IP_NULL)
/*
*---------------------------------------------------------------------------
* Result code
*---------------------------------------------------------------------------
*/
/* StopCCN result codes */
/*$$ BEGIN StopCCN_result_code $*/
#define IPL2TP_RES_StopCCN_GENERAL_REQUEST 1
/*$ General request to clear control connection $*/
#define IPL2TP_RES_StopCCN_GENERAL_ERROR 2
/*$ General error; Error code indicates the problem $*/
#define IPL2TP_RES_StopCCN_CHANNEL_EXISTS 3
/*$ Control channel already exists $*/
#define IPL2TP_RES_StopCCN_NOT_AUTHORIZED 4
/*$ Requester is not authorized to establish a control channel $*/
#define IPL2TP_RES_StopCCN_PROTOCOL_VERSION 5
/*$ The protocol version of the requester is not supported $*/
#define IPL2TP_RES_StopCCN_SHUTDOWN 6
/*$ Requester is being shut down $*/
#define IPL2TP_RES_StopCCN_STATE_MACHINE 7
/*$ Finite State Machine error $*/
/* CDN result codes */
#define IPL2TP_RES_CDN_LOSS_OF_CARRIER 1
/*$ Call disconnected due to loss of carrier $*/
#define IPL2TP_RES_CDN_GENERAL_ERROR 2
/*$ Call disconnected for the reason indicated in error code $*/
#define IPL2TP_RES_CDN_ADMINISTRATIVE 3
/*$ Call disconnected for administrative reasons $*/
#define IPL2TP_RES_CDN_RESOURCE_TEMP 4
/*$ Call failed due to temporary lack of appropriate facilities $*/
#define IPL2TP_RES_CDN_RESOURCE_PERM 5
/*$ Call failed due to permanent lack of appropriate facilities $*/
#define IPL2TP_RES_CDN_INVALID_DEST 6
/*$ Invalid destination $*/
#define IPL2TP_RES_CDN_NO_CARRIER 7
/*$ Call failed due to no carrier detected $*/
#define IPL2TP_RES_CDN_BUSY 8
/*$ Call failed due to detection of a busy signal $*/
#define IPL2TP_RES_CDN_NO_DIAL_TONE 9
/*$ Call failed due to lack of a dial tone $*/
#define IPL2TP_RES_CDN_TIMEOUT 10
/*$ Call was not established within time allotted by LAC $*/
#define IPL2TP_RES_CDN_FRAMING 11
/*$ Call was connected but no appropriate framing was detected $*/
#define IPL2TP_RES_CDN_SESSION_TIE_BREAKER 13
/*$ Call was connected but lost tie breaker $*/
#define IPL2TP_RES_CDN_PW_TYPE 14
/*$ Call was connected but no appropriate pw type was detected $*/
#define IPL2TP_RES_CDN_SEQUENCING_L2_SUBLAYER 15
/*$ Call was connected but sequencing required, no L2 sublayer present $*/
#define IPL2TP_RES_CDN_STATE_MACHINE 16
/*$ Call was connected but a state machine error occured $*/
/* Error codes */
#define IPL2TP_ERR_NO_CONTROL_CONN 1
/*$ No control connection exists yet for this LAC-LNS pair $*/
#define IPL2TP_ERR_WRONG_LENGTH 2
/*$ Length is wrong $*/
#define IPL2TP_ERR_OUT_OF_RANGE 3
/*$ One of the fields was out of range or reserved field was non-zero $*/
#define IPL2TP_ERR_RESOURCE_LIMIT 4
/*$ Insufficient resources to handle this operation now $*/
#define IPL2TP_ERR_SESSION_ID 5
/*$ The Session ID is invalid in this context $*/
#define IPL2TP_ERR_VENDOR_ERROR_LAC 6
/*$ A generic vendor-specific error occurred in the LAC $*/
#define IPL2TP_ERR_TRY_ANOTHER_LNS 7
/*$ Try another LNS destination, if possible $*/
#define IPL2TP_ERR_UNKNOWN_M_AVP 8
/*$ Shutdown due to receipt of an unknown AVP with the M-bit set $*/
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
/*
*===========================================================================
* Ipl2tp_admin
*===========================================================================
*
* Message administration stuff.
*/
typedef struct Ipl2tp_admin
{
Ipcom_list head; /* List header */
Ipcom_tmo timer; /* Timer control block */
Ipl2tp_tunnel *tunnel; /* Tunnel descriptor */
Ipl2tp_session *session; /* Session descriptor */
Ip_u16 timeout; /* Current timeout */
Ip_u8 retransmit; /* Retransmit counter */
Ip_u8 flags; /* Flags */
Ip_u16 size; /* Total size */
Ip_u16 pre_header; /* Pre header (IP/IP) */
void *digest; /* Pointer to digest */
void *rv_value; /* Random vector value */
Ip_u16 rv_length; /* Random vector length */
Ip_u16 *nr; /* Pointer to NR */
Ip_u16 *ns; /* Pointer to NS */
Ip_u16 *length; /* Length field */
Ip_u8 *start; /* Start of header */
Ip_bool is_zlb; /* Is it a ZLB? */
}
Ipl2tp_admin;
/* The various message forms */
typedef union Ipl2tp_header
{
Ipl2tp_v3_header v3; /* L2TPv3 control */
Ipl2tp_v2_header v2; /* L2TPv2 control */
}
Ipl2tp_header;
/*
*===========================================================================
* Ipl2tp_container
*===========================================================================
*
* Message descriptor with additional headers and stuff.
*/
typedef struct Ipl2tp_message
{
Ipl2tp_admin admin; /* Admin data */
Ip_u32 session; /* When doing tunneling over IP */
Ipl2tp_header header; /* Header */
}
Ipl2tp_message;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*
*===========================================================================
* ipl2tp_message_name
*===========================================================================
* Description: Get name of message.
* Parameters: type - Message type.
* Returns: Human readable message name.
*
*/
IP_GLOBAL CONST char * ipl2tp_message_name(Ip_u16 message_type);
/*
*===========================================================================
* ipl2tp_message_recognized
*===========================================================================
* Description: Check if message is recognized.
* Parameters: type - Message type.
* Returns: IP_TRUE if message type is recognized, IP_FALSE otherwise.
*
*/
IP_GLOBAL Ip_bool ipl2tp_message_recognized(Ip_u16 message_type);
/*
*===========================================================================
* ipl2tp_message_new
*===========================================================================
* Description: Allocate a new L2TP control container.
* Parameters: tunnel - The tunnel the container belongs to.
* session - The session the container belongs to.
* Returns: The container if successful; IP_NULL otherwise.
*
*/
IP_GLOBAL Ipl2tp_message *ipl2tp_message_new(Ipl2tp_tunnel *tunnel,
Ipl2tp_session *session);
/*
*===========================================================================
* ipl2tp_message_delete
*===========================================================================
* Description: Delete a L2TP control container
* Parameters: container - The container
* Returns:
*
*/
IP_GLOBAL void ipl2tp_message_delete(Ipl2tp_message *container);
/*
*===========================================================================
* ipl2tp_message_is_zlb
*===========================================================================
* Description: Mark container as ZLB
* Parameters: container - The container
* Returns:
*
*/
IP_GLOBAL void ipl2tp_message_is_zlb(Ipl2tp_message *container);
/*
*===========================================================================
* ipl2tp_message_rq
*===========================================================================
* Description: Send appropriate request based on type of session.
* Parameters: session - The session the container belongs to.
* Returns:
*
*/
IP_GLOBAL Ipl2tp_status ipl2tp_message_rq(Ipl2tp_session *session);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/