original files of m241
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
/* 00comp_ipnet_l2tp.cdf - IPNet L2TP configuration file */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Wind River Systems, Inc.
|
||||
*
|
||||
* The right to copy, distribute or otherwise make use of this software
|
||||
* may be licensed only pursuant to the terms of an applicable Wind River
|
||||
* license agreement. No license to Wind River intellectual property rights
|
||||
* is granted herein. All rights not licensed by Wind River are reserved
|
||||
* by Wind River.
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01a,18jun09,ten created.
|
||||
*/
|
||||
|
||||
Component INCLUDE_IPL2TP {
|
||||
NAME L2TP
|
||||
SYNOPSIS L2TP
|
||||
MODULES ipl2tp_api.o
|
||||
CONFIGLETTES ipl2tp_config.c ipl2tp_example.c
|
||||
CFG_PARAMS L2TP_VERSION_2_ENABLE \
|
||||
L2TP_VERSION_3_ENABLE \
|
||||
L2TP_HOST_NAME
|
||||
}
|
||||
|
||||
Parameter L2TP_VERSION_2_ENABLE {
|
||||
NAME Enable L2TP Version 2
|
||||
SYNOPSIS Enables L2TP protocol version 2
|
||||
TYPE BOOL
|
||||
DEFAULT FALSE
|
||||
}
|
||||
|
||||
Parameter L2TP_VERSION_3_ENABLE {
|
||||
NAME Enable L2TP Version 3
|
||||
SYNOPSIS Enables L2TP protocol version 3
|
||||
TYPE BOOL
|
||||
DEFAULT TRUE
|
||||
}
|
||||
|
||||
Parameter L2TP_HOST_NAME {
|
||||
NAME L2TP Host Name
|
||||
SYSNOPSIS Name of local L2TP host
|
||||
TYPE char *
|
||||
DEFAULT "LAC"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: common.vxconfig,v $ $Revision: 1.3 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipl2tp/config/common.vxconfig,v $
|
||||
# $Author: myakan $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
|
||||
#hidden option that enables IPL2TP
|
||||
config SUPPORTS_L2TP
|
||||
bool
|
||||
default y
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipl2tp_config.c,v $ $Revision: 1.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipl2tp/config/ipl2tp_config.c,v $
|
||||
* $Author: joel $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
#include <ipl2tp.h>
|
||||
#include <ipl2tp_cmd.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err ipl2tp_configure(void);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
IP_STATIC IP_CONST Ipcom_sysvar ipl2tp_conf_sysvar[] =
|
||||
{
|
||||
{ "ipl2tp.v3.control.any.attributes", "secret=interop local_router_id=0" },
|
||||
{ "ipl2tp.v3.circuit.0.name", "mycircuit" },
|
||||
{ "ipl2tp.v3.circuit.0.interface", "eth0" },
|
||||
{ "ipl2tp.v3.circuit.0.vlan", "21" },
|
||||
{ "ipl2tp.v3.circuit.0.attributes", "pseudowire_type=ethernet_vlan data_sequencing=0" },
|
||||
|
||||
/* End of configuration - DO NOT REMOVE! */
|
||||
{ IP_NULL, IP_NULL }
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_configure
|
||||
*===========================================================================
|
||||
* Description: Configure FTP server.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipl2tp_configure(void)
|
||||
{
|
||||
/* Add the sysvars */
|
||||
ipcom_sysvar_setv(ipl2tp_conf_sysvar, 0);
|
||||
|
||||
/* Init shell commands */
|
||||
(void)ipcom_shell_add_cmd("l2tp", "l2tp <command> <parameters>",
|
||||
"L2TP client control",
|
||||
ipl2tp_cmd_main,
|
||||
IPCOM_SHELL_PRIO_SAME,
|
||||
IPCOM_PROC_STACK_DEFAULT);
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipl2tp_config.h,v $ $Revision: 1.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipl2tp/config/ipl2tp_config.h,v $
|
||||
* $Author: tneale $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _IPL2TP_CONFIG_H_
|
||||
#define _IPL2TP_CONFIG_H_
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*
|
||||
* L2TP configuration file.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 GENERAL
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPL2TP_SYSLOG_PRIORITY
|
||||
*===========================================================================
|
||||
* Initial L2TP syslog system priority.
|
||||
*/
|
||||
#ifdef IP_DEBUG
|
||||
#define IPL2TP_SYSLOG_PRIORITY IPCOM_LOG_DEBUG
|
||||
#else
|
||||
#define IPL2TP_SYSLOG_PRIORITY IPCOM_LOG_WARNING
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Version */
|
||||
#define IPL2TP_VERSION_NUM 160
|
||||
#define IPL2TP_VERSION_STR "6.0.0"
|
||||
#define IPL2TP_VERSION_API 4
|
||||
|
||||
/* Protocol version */
|
||||
#define IPL2TP_PROTOCOL_VER 1
|
||||
#define IPL2TP_PROTOCOL_REV 0
|
||||
|
||||
/* Host name */
|
||||
#define IPL2TP_VENDOR_NAME "WindRiver"
|
||||
#define IPL2TP_HOST_NAME "IPL2TP"
|
||||
|
||||
/* Default receive window size */
|
||||
#define IPL2TP_RECEIVE_WINDOW_SIZE 4
|
||||
|
||||
/* Max no of retransmissions */
|
||||
#define IPL2TP_MAX_RETRANSMIT 5
|
||||
|
||||
/* Seconds until first retransmission */
|
||||
#define IPL2TP_FIRST_RETRANSMIT_SEC 1
|
||||
|
||||
/* Max seconds between retransmissions */
|
||||
#define IPL2TP_MAX_BACKOFF_SEC 8
|
||||
|
||||
/* Seconds to keep a tunnel after StopCCN is received */
|
||||
#define IPL2TP_TUNNEL_ZOMBIE_SEC 32
|
||||
|
||||
/* Seconds between HELLO messages */
|
||||
#define IPL2TP_HELLO_INTERVAL_SEC 60
|
||||
|
||||
/* Seconds between HELLO ticks (resolution of HELLO transmission) */
|
||||
#define IPL2TP_HELLO_TICK_SEC 10
|
||||
|
||||
/* Tunnel establishment timeout */
|
||||
#define IPL2TP_ESTABLISH_TIMEOUT_SEC 60
|
||||
|
||||
/* Force a single session per tunnel */
|
||||
#define IPL2TP_OPEN_EXCLUSIVE IPL2TP_MIB_NO
|
||||
|
||||
/* Run-time log level */
|
||||
#define IPL2TP_RUNTIME_LOGLEVEL IPL2TP_LOGLEVEL_ALL
|
||||
|
||||
/* Max size of control message sent by us */
|
||||
#define IPL2TP_MAX_MESSAGE_SIZE 2048
|
||||
|
||||
/* Max size of error message */
|
||||
#define IPL2TP_MAX_ERROR_MESSAGE_SIZE 256
|
||||
|
||||
/* Min and max length of CHAP challenges */
|
||||
#define IPL2TP_MIN_CHALLENGE_LENGTH 16
|
||||
#define IPL2TP_MAX_CHALLENGE_LENGTH 16
|
||||
|
||||
/* Max size of host name */
|
||||
#define IPL2TP_MAX_HOST_NAME_SIZE 64
|
||||
|
||||
/* Max size of fixed AVP value */
|
||||
#define IPL2TP_MAX_AVP_VALUE_SIZE (32 - 6) /* 'call errors' is 32 octets */
|
||||
|
||||
/* Size of sent data headers */
|
||||
#define IPL2TP_DATA_HEADER_SIZE 12
|
||||
#define IPL2TP_MISALIGNED_DATA_HEADER_SIZE 14
|
||||
|
||||
/* No of preallocated descriptors */
|
||||
#define IPL2TP_PREALLOCATED_TUNNEL_NO 100
|
||||
#define IPL2TP_PREALLOCATED_SESSION_NO 100
|
||||
|
||||
/* Max numbers */
|
||||
#define IPL2TP_TUNNEL_MAX 8192
|
||||
#define IPL2TP_SESSION_MAX 8192
|
||||
|
||||
/* Initial size of attribute pool */
|
||||
#define IPL2TP_ATTRPOOL_SIZE 8
|
||||
|
||||
/* Max attribute type in an AVP */
|
||||
#define IPL2TP_AVP_MAX 75
|
||||
|
||||
/* Number of in-sequence out of window data messages before we reset
|
||||
* the sequence counter */
|
||||
#define IPL2TP_L2_OUT_OF_ORDER_RESET 10
|
||||
|
||||
/* Use mutex */
|
||||
#define IPL2TP_USE_MUTEX 1
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,97 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipl2tp_example.h,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipl2tp/config/ipl2tp_example.h,v $
|
||||
* $Author: tneale $ $Date: 2010-05-13 21:15:09 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPL2TP_EXAMPLE_H
|
||||
#define IPL2TP_EXAMPLE_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
struct Ipl2tp_example_fd_entry;
|
||||
typedef void (*Ipl2tp_example_data_cb)
|
||||
(
|
||||
struct Ipl2tp_example_fd_entry *entry,
|
||||
void *buffer,
|
||||
void *data,
|
||||
Ip_size_t size
|
||||
);
|
||||
|
||||
typedef struct Ipl2tp_example_fd_entry
|
||||
{
|
||||
Ipcom_list next;
|
||||
Ip_fd fd;
|
||||
void *ptr;
|
||||
Ipl2tp_example_data_cb data;
|
||||
}
|
||||
Ipl2tp_example_fd_entry_t;
|
||||
|
||||
typedef struct Ipl2tp_example_session
|
||||
{
|
||||
Ipl2tp_key key;
|
||||
void *circuit;
|
||||
}
|
||||
Ipl2tp_example_session_t;
|
||||
|
||||
extern Ipcom_hash *ipl2tp_example_sessions;
|
||||
extern Ipcom_list ipl2tp_example_fds;
|
||||
extern char ipl2tp_poke_abort[4];
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,372 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipl2tp_example_v2.c,v $ $Revision: 1.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipl2tp/config/ipl2tp_example_v2.c,v $
|
||||
* $Author: tneale $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_clib2.h"
|
||||
#include "ipcom_err.h"
|
||||
#include "ipcom_ipd.h"
|
||||
#include "ipcom_os.h"
|
||||
#include "ipcom_shell.h"
|
||||
#include "ipcom_sock2.h"
|
||||
#include "ipcom_syslog.h"
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_hash.h"
|
||||
#include "ipcom_sysvar.h"
|
||||
#include "ipcom_netif.h"
|
||||
|
||||
#include "ipl2tp_h.h"
|
||||
#include "ipl2tp_api.h"
|
||||
#include "ipl2tp_api_tunnel.h"
|
||||
#include "ipl2tp_api_session.h"
|
||||
#include "ipl2tp_attr.h"
|
||||
#include "ipl2tp_cmd.h"
|
||||
#include "ipl2tp_example.h"
|
||||
#include "ipl2tp_example_v2.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_example_tstatus_v2
|
||||
*===========================================================================
|
||||
* Description: Tunnel status callback.
|
||||
* Parameters: user_data - User callback data.
|
||||
* key - Tunnel ID.
|
||||
* status - Pointer to status info.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
ipl2tp_example_tstatus_v2(void *user_data,
|
||||
Ipl2tp_key *key,
|
||||
Ipl2tp_result *result)
|
||||
{
|
||||
#define A_AUTH IPL2TP_MIB_AUTH_NONE
|
||||
#define A_SECRET "interop"
|
||||
#define A_NAME "hel"
|
||||
|
||||
(void)user_data;
|
||||
|
||||
switch (result->status)
|
||||
{
|
||||
case IPL2TP_STATUS_OK:
|
||||
switch (result->result_code)
|
||||
{
|
||||
case IPL2TP_OUTGOING_AUTHENTICATION:
|
||||
{
|
||||
/* Allocate an attribute object */
|
||||
Ipl2tp_attrobj attr = IP_NULL;
|
||||
Ipl2tp_attrobj replies = IP_NULL;
|
||||
|
||||
ipl2tp_attr_add_query(&attr,
|
||||
IPL2TP_TATTR_GET_l2tpTunnelStatsRemoteHostName);
|
||||
|
||||
/* Retrieve the attributes, the answers will end up in 'replies' */
|
||||
ipl2tp_api_tunnel_attribute_get(key, attr, &replies);
|
||||
|
||||
IPCOM_LOG3(DEBUG,
|
||||
"IPL2TPv2: TUNNEL (IPL2TP_OUTGOING_AUTHENTICATION) v%d %d requested by '%s'",
|
||||
key->version, key->ident,
|
||||
ipl2tp_attr_strdata(ipl2tp_attr_first(replies)));
|
||||
|
||||
ipl2tp_attr_delete(&replies);
|
||||
|
||||
/* Add integer attribute */
|
||||
ipl2tp_attr_clear(attr);
|
||||
|
||||
/* Set authentication */
|
||||
if (ipl2tp_attr_iappend(&attr,
|
||||
IPL2TP_TATTR_SET_l2tpTunnelConfigAuthentication, A_AUTH) != IPL2TP_STATUS_OK ||
|
||||
/* Add string peer host name */
|
||||
ipl2tp_attr_strappend(&attr, IPL2TP_TATTR_SET_PEER_HOST_NAME, A_NAME) != IPL2TP_STATUS_OK ||
|
||||
/* Add authentication vector */
|
||||
ipl2tp_attr_vappend(&attr,
|
||||
IPL2TP_TATTR_SET_l2tpTunnelConfigSecret,
|
||||
A_SECRET, (int)ipcom_strlen(A_SECRET)) != IPL2TP_STATUS_OK)
|
||||
{
|
||||
IPCOM_LOG3(WARNING,
|
||||
"IPL2TPv2: v%d %d requested by '%s': unable to set attributes",
|
||||
key->version, key->ident,
|
||||
ipl2tp_attr_strdata(ipl2tp_attr_first(replies)));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Do set the attributes */
|
||||
ipl2tp_api_tunnel_attribute_set(key, attr);
|
||||
}
|
||||
|
||||
/* Delete the attribute object */
|
||||
ipl2tp_attr_delete(&attr);
|
||||
|
||||
if (ipcom_strcmp(ipl2tp_poke_abort, "toa") == 0)
|
||||
return 1;
|
||||
|
||||
/* We've installed the authentication data required,
|
||||
* do continue the tunnel processing and attempt to establish */
|
||||
ipl2tp_api_tunnel_authentication_established(key);
|
||||
break;
|
||||
}
|
||||
|
||||
case IPL2TP_OUTGOING_REQUEST:
|
||||
{
|
||||
Ipl2tp_attrobj replies = IP_NULL;
|
||||
Ipl2tp_attrobj attr = IP_NULL;
|
||||
|
||||
ipl2tp_attr_add_query(&attr,
|
||||
IPL2TP_TATTR_GET_l2tpTunnelStatsRemoteHostName);
|
||||
|
||||
/* Retrieve the attributes, the answers will end up in 'replies' */
|
||||
ipl2tp_api_tunnel_attribute_get(key, attr, &replies);
|
||||
IPCOM_LOG3(DEBUG,
|
||||
"IPL2TPv2: TUNNEL (IPL2TP_OUTGOING_REQUEST) v%d %d requested by '%s'",
|
||||
key->version, key->ident,
|
||||
ipl2tp_attr_strdata(ipl2tp_attr_first(replies)));
|
||||
ipl2tp_attr_delete(&replies);
|
||||
ipl2tp_attr_delete(&attr);
|
||||
|
||||
if (ipcom_strcmp(ipl2tp_poke_abort, "tor") == 0)
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case IPL2TP_OUTGOING_ESTABLISHED:
|
||||
IPCOM_LOG2(DEBUG,
|
||||
"IPL2TPv2: TUNNEL (IPL2TP_OUTGOING_ESTABLISHED) v%d %d opened",
|
||||
key->version, key->ident);
|
||||
if (ipcom_strcmp(ipl2tp_poke_abort, "toe") == 0)
|
||||
return 1;
|
||||
break;
|
||||
|
||||
case IPL2TP_INCOMING_ESTABLISHED:
|
||||
IPCOM_LOG2(DEBUG,
|
||||
"IPL2TPv2: TUNNEL (IPL2TP_INCOMING_ESTABLISHED) v%d %d opened",
|
||||
key->version, key->ident);
|
||||
if (ipcom_strcmp(ipl2tp_poke_abort, "tie") == 0)
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case IPL2TP_STATUS_NEGOTIATION:
|
||||
IPCOM_LOG2(DEBUG,
|
||||
"IPL2TPv2: TUNNEL (IPL2TP_STATUS_NEGOTIATION) v%d %d closed obsoleted by version negotiation",
|
||||
key->version, key->ident);
|
||||
break;
|
||||
|
||||
default:
|
||||
IPCOM_LOG5(DEBUG,
|
||||
"IPL2TPv2: TUNNEL (%u) v%d %d closed with status %d, %s",
|
||||
result->status,
|
||||
key->version, key->ident,
|
||||
(int)result->status,
|
||||
ipl2tp_api_errname(result->status));
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_example_sstatus_v2
|
||||
*===========================================================================
|
||||
* Description: Session status callback.
|
||||
* Parameters: user_data - User callback data.
|
||||
* key - Session ID.
|
||||
* status - Pointer to status info.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
ipl2tp_example_sstatus_v2(void *user_data,
|
||||
Ipl2tp_key *key,
|
||||
Ipl2tp_result *result)
|
||||
{
|
||||
unsigned long ifindexul = (unsigned long)user_data;
|
||||
int ifindex = (int)ifindexul;
|
||||
int ret = 1;
|
||||
|
||||
(void)ifindex;
|
||||
|
||||
switch (result->status)
|
||||
{
|
||||
case IPL2TP_STATUS_OK:
|
||||
switch (result->result_code)
|
||||
{
|
||||
case IPL2TP_OUTGOING_REQUEST:
|
||||
{
|
||||
Ipl2tp_attrobj replies = IP_NULL;
|
||||
|
||||
ipl2tp_api_session_attribute_query(key,
|
||||
IPL2TP_SATTR_GET_CALLED_NUMBER,
|
||||
&replies);
|
||||
IPCOM_LOG4(DEBUG,
|
||||
"IPL2TPv2: SESSION (IPL2TP_OUTGOING_REQUEST) v%d %d %s to '%s'",
|
||||
key->version, key->ident,
|
||||
ipl2tp_api_session_type(key),
|
||||
ipl2tp_attr_strdata(ipl2tp_attr_first(replies)));
|
||||
ipl2tp_attr_delete(&replies);
|
||||
if (ipcom_strcmp(ipl2tp_poke_abort, "sor") == 0)
|
||||
goto leave;
|
||||
break;
|
||||
}
|
||||
case IPL2TP_OUTGOING_REPLY:
|
||||
{
|
||||
Ipl2tp_attrobj attr = IP_NULL;
|
||||
|
||||
IPCOM_LOG3(DEBUG,
|
||||
"IPL2TPv2: SESSION (IPL2TP_OUTGOING_REPLY) v%d %d %s",
|
||||
key->version, key->ident,
|
||||
ipl2tp_api_session_type(key));
|
||||
|
||||
if (ipl2tp_attr_iappend(&attr,
|
||||
IPL2TP_SATTR_SET_TX_CONNECT_SPEED,
|
||||
38400) != IPL2TP_STATUS_OK ||
|
||||
ipl2tp_attr_iappend(&attr,
|
||||
IPL2TP_SATTR_SET_FRAMING_TYPE,
|
||||
IPL2TP_MIB_FRAMING_ASYNC) != IPL2TP_STATUS_OK)
|
||||
{
|
||||
IPCOM_LOG3(WARNING,
|
||||
"IPL2TPv2: SESSION (IPL2TP_OUTGOING_REPLY) v%d %d %s unable to set attributes",
|
||||
key->version, key->ident,
|
||||
ipl2tp_api_session_type(key));
|
||||
}
|
||||
else
|
||||
{
|
||||
ipl2tp_api_session_attribute_set(key, attr);
|
||||
}
|
||||
ipl2tp_attr_delete(&attr);
|
||||
|
||||
if (ipcom_strcmp(ipl2tp_poke_abort, "sop") == 0)
|
||||
goto leave;
|
||||
|
||||
ipl2tp_api_session_outgoing_established(key, 0, 0, "");
|
||||
break;
|
||||
}
|
||||
case IPL2TP_OUTGOING_ESTABLISHED:
|
||||
IPCOM_LOG3(DEBUG,
|
||||
"IPL2TPv2: SESSION (IPL2TP_OUTGOING_ESTABLISHED) v%d %d %s",
|
||||
key->version, key->ident,
|
||||
ipl2tp_api_session_type(key));
|
||||
if (ipcom_strcmp(ipl2tp_poke_abort, "soe") == 0)
|
||||
goto leave;
|
||||
break;
|
||||
|
||||
case IPL2TP_INCOMING_REQUEST:
|
||||
/* Setup */
|
||||
IPCOM_LOG3(DEBUG,
|
||||
"IPL2TPv2: SESSION (IPL2TP_INCOMING_REQUEST) v%d %d %s",
|
||||
key->version, key->ident,
|
||||
ipl2tp_api_session_type(key));
|
||||
ipl2tp_api_session_incoming_established(key, 0, 0, "");
|
||||
break;
|
||||
|
||||
case IPL2TP_INCOMING_ESTABLISHED:
|
||||
IPCOM_LOG3(DEBUG,
|
||||
"IPL2TPv2: SESSION (IPL2TP_INCOMING_ESTABLISHED) v%d %d %s",
|
||||
key->version, key->ident,
|
||||
ipl2tp_api_session_type(key));
|
||||
if (ipcom_strcmp(ipl2tp_poke_abort, "sie") == 0)
|
||||
goto leave;
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
IPCOM_LOG4(DEBUG,
|
||||
"IPL2TPv2: SESSION (%u) v%d %d closed with status %s",
|
||||
(int)result->status,
|
||||
key->version, key->ident,
|
||||
ipl2tp_api_errname(result->status));
|
||||
break;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
leave:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,100 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipl2tp_example_v2.h,v $ $Revision: 1.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipl2tp/config/ipl2tp_example_v2.h,v $
|
||||
* $Author: joel $ $Date: 2006-01-30 10:46:59 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPL2TP_EXAMPLE_V2_H
|
||||
#define IPL2TP_EXAMPLE_V2_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_example_sstatus_v3
|
||||
*===========================================================================
|
||||
* Description: Session status callback.
|
||||
* Parameters: user_data - User callback data.
|
||||
* key - Session ID.
|
||||
* status - Pointer to status info.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipl2tp_example_sstatus_v2(void *user_data,
|
||||
Ipl2tp_key *key,
|
||||
Ipl2tp_result *result);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_example_tstatus_v3
|
||||
*===========================================================================
|
||||
* Description: Tunnel status callback.
|
||||
* Parameters: user_data - User callback data.
|
||||
* key - Tunnel ID.
|
||||
* status - Pointer to status info.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipl2tp_example_tstatus_v2(void *user_data,
|
||||
Ipl2tp_key *key,
|
||||
Ipl2tp_result *result);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,974 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipl2tp_example_v3.c,v $ $Revision: 1.13.10.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipl2tp/config/ipl2tp_example_v3.c,v $
|
||||
* $Author: jren $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_clib2.h"
|
||||
#include "ipcom_err.h"
|
||||
#include "ipcom_ipd.h"
|
||||
#include "ipcom_os.h"
|
||||
#include "ipcom_shell.h"
|
||||
#include "ipcom_sock2.h"
|
||||
#include "ipcom_syslog.h"
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_hash.h"
|
||||
#include "ipcom_sysvar.h"
|
||||
#include "ipcom_netif.h"
|
||||
#include "ipcom_strlib.h"
|
||||
|
||||
#include "ipl2tp_h.h"
|
||||
#include "ipl2tp_api.h"
|
||||
#include "ipl2tp_api_tunnel.h"
|
||||
#include "ipl2tp_api_session.h"
|
||||
#include "ipl2tp_attr.h"
|
||||
#include "ipl2tp_cmd.h"
|
||||
#include "ipl2tp_example.h"
|
||||
#include "ipl2tp_example_v3.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ipl2tp_v3_circuit
|
||||
{
|
||||
char *name;
|
||||
char *intf;
|
||||
Ip_u32 ifnum;
|
||||
int pw_type;
|
||||
int vlan_tag;
|
||||
}
|
||||
Ipl2tp_v3_circuit_t;
|
||||
|
||||
typedef struct Ipl2tp_v3_ethernet_circuit
|
||||
{
|
||||
Ipl2tp_example_session_t session;
|
||||
Ipl2tp_example_fd_entry_t *fd_eth;
|
||||
}
|
||||
Ipl2tp_v3_ethernet_circuit_t;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_eth_data_cb
|
||||
*===========================================================================
|
||||
* Description: Data callback.
|
||||
* Parameters: user_data - User callback data.
|
||||
* buffer - Original data buffer.
|
||||
* payload - Payload pointer in data buffer.
|
||||
* length - Length of payload.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipl2tp_example_session_eth_data_output(void *user_data,
|
||||
Ipl2tp_key *key,
|
||||
void *buffer,
|
||||
void *payload,
|
||||
Ip_u16 length)
|
||||
{
|
||||
Ipl2tp_v3_ethernet_circuit_t *session = user_data;
|
||||
|
||||
IPL2TP_UNUSED(key);
|
||||
IPL2TP_UNUSED(buffer);
|
||||
|
||||
/* Do the write */
|
||||
if (session != IP_NULL)
|
||||
{
|
||||
struct Ip_sockaddr_ll to_ll;
|
||||
Ipl2tp_v3_circuit_t *circuit = session->session.circuit;
|
||||
|
||||
/* Modify the frame */
|
||||
if (circuit->pw_type == IPL2TP_ATTR_PW_TYPE_ETHERNET_VLAN &&
|
||||
circuit->vlan_tag != 0)
|
||||
{
|
||||
Ip_u8 *frame = payload;
|
||||
Ip_u16 vid = IP_GET_HTONS(frame + 14);
|
||||
|
||||
vid = (Ip_u16)(vid & 0xf000);
|
||||
vid = (Ip_u16)(vid | (Ip_u16)(circuit->vlan_tag & 0x0fff));
|
||||
IP_SET_HTONS(frame + 14, vid);
|
||||
}
|
||||
|
||||
ipcom_memset(&to_ll, 0, sizeof(to_ll));
|
||||
to_ll.sll_len = (Ip_u8)sizeof(to_ll);
|
||||
to_ll.sll_family = IP_AF_PACKET;
|
||||
to_ll.sll_ifindex = circuit->ifnum;
|
||||
|
||||
if (ipcom_sendto(session->fd_eth->fd, payload, length, 0,
|
||||
(struct Ip_sockaddr *)&to_ll, sizeof(to_ll)) < 0)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "IPL2TPv3: Error in ipcom send");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipl2tp_example_session_eth_data_input(Ipl2tp_example_fd_entry_t *entry,
|
||||
void *buffer,
|
||||
void *data,
|
||||
Ip_size_t size)
|
||||
{
|
||||
Ip_ptrdiff_t offset = (Ip_u8 *)data - (Ip_u8 *)buffer;
|
||||
|
||||
/* Get the eth session ID */
|
||||
Ipl2tp_v3_ethernet_circuit_t *session = entry->ptr;
|
||||
|
||||
/* Done */
|
||||
ipl2tp_api_session_ethernet_input(&session->session.key,
|
||||
data,
|
||||
(int)size,
|
||||
(int)offset,
|
||||
0,
|
||||
IP_TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_example_session_check_eth_interface
|
||||
*===========================================================================
|
||||
* Description: Determine if interface is currently in use by another circuit
|
||||
* Parameters: key: session key of sessio to be compared against
|
||||
* intf: name of interface
|
||||
* Returns: 1 if the interface is currently in use by another session
|
||||
* 0 otherwise
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipl2tp_example_session_check_eth_interface(Ipl2tp_key * key, char * intf)
|
||||
{
|
||||
Ipl2tp_status status;
|
||||
Ipl2tp_key this_tkey, next_tkey;
|
||||
Ipl2tp_key this_skey, next_skey;
|
||||
Ipl2tp_v3_circuit_t *circuit;
|
||||
Ipl2tp_v3_ethernet_circuit_t *session;
|
||||
|
||||
if ((intf == IP_NULL) || (ipcom_strlen(intf) == 0))
|
||||
return (0);
|
||||
|
||||
/* Get the first tunnel, if there is one */
|
||||
this_tkey.ident = 0;
|
||||
this_tkey.version = IPL2TP_VERSION_L2TPV3;
|
||||
if ((status = ipl2tp_api_tunnel_next(&this_tkey, &next_tkey)) != IPL2TP_STATUS_OK)
|
||||
return (0);
|
||||
|
||||
/* Go through all tunnels */
|
||||
while (status == IPL2TP_STATUS_OK)
|
||||
{
|
||||
/* If status is OK, next_tkey.ident must be non-zero */
|
||||
this_tkey.ident = next_tkey.ident;
|
||||
|
||||
/* Get the first session if there is one */
|
||||
if ((status = ipl2tp_api_session_next(&this_tkey, IP_NULL, &next_skey)) != IPL2TP_STATUS_OK)
|
||||
continue;
|
||||
|
||||
/* Go through all sessions in this tunnel */
|
||||
while (status == IPL2TP_STATUS_OK)
|
||||
{
|
||||
/* If status is OK, next_skey.ident must be non-zero, so use it */
|
||||
this_skey.ident = next_skey.ident;
|
||||
this_skey.version = next_skey.version;
|
||||
|
||||
/* Check the version - this only applies to version 3 */
|
||||
if (this_skey.version != IPL2TP_VERSION_L2TPV3)
|
||||
continue;
|
||||
|
||||
/* Check for a match, if the session is different */
|
||||
if (this_skey.ident != key->ident)
|
||||
{
|
||||
session = ipcom_hash_get(ipl2tp_example_sessions, &this_skey);
|
||||
if (session == IP_NULL)
|
||||
continue;
|
||||
|
||||
/* Check the interface name */
|
||||
circuit = (Ipl2tp_v3_circuit_t *)session->session.circuit;
|
||||
if (ipcom_strcmp(circuit->intf, intf) == 0)
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Get the next session, if there is one */
|
||||
status = ipl2tp_api_session_next(&this_tkey, &this_skey, &next_skey);
|
||||
}
|
||||
|
||||
/* Get the next tunnel if there is one */
|
||||
status = ipl2tp_api_tunnel_next(&this_tkey, &next_tkey);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_example_session_eth_destroy
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipl2tp_example_session_eth_destroy(Ipl2tp_key *key)
|
||||
{
|
||||
Ipl2tp_v3_ethernet_circuit_t *session = ipcom_hash_get(ipl2tp_example_sessions, key);
|
||||
|
||||
if (session != IP_NULL)
|
||||
{
|
||||
struct Ip_ifreq ifreq;
|
||||
Ipl2tp_attrobj attr = IP_NULL;
|
||||
Ipl2tp_v3_circuit_t *circuit = session->session.circuit;
|
||||
|
||||
if (ipl2tp_example_session_check_eth_interface(key, circuit->intf) == 0)
|
||||
{
|
||||
IPCOM_LOG1(DEBUG, "Interface %s has no other users", circuit->intf);
|
||||
|
||||
/* OK to turn off promisc mode */
|
||||
ipcom_memset(&ifreq, 0, sizeof(struct Ip_ifreq));
|
||||
ipcom_strncpy(ifreq.ifr_name, circuit->intf, IP_IFNAMSIZ - 1);
|
||||
|
||||
if (ipcom_socketioctl(session->fd_eth->fd, IP_SIOCGIFFLAGS, &ifreq) < 0)
|
||||
IPCOM_LOG1(ERR,
|
||||
"IPL2TPv3: failed to get interface flags: %s",
|
||||
ipcom_strerror(ipcom_errno));
|
||||
else
|
||||
{
|
||||
IP_BIT_CLR(ifreq.ip_ifr_flags, IP_IFF_PROMISC);
|
||||
if (ipcom_socketioctl(session->fd_eth->fd, IP_SIOCSIFFLAGS, &ifreq) < 0)
|
||||
IPCOM_LOG1(ERR,
|
||||
"IPL2TPv3: failed to set interface flags: %s",
|
||||
ipcom_strerror(ipcom_errno));
|
||||
}
|
||||
}
|
||||
else
|
||||
IPCOM_LOG1(DEBUG, "Interface %s does have other users", circuit->intf);
|
||||
|
||||
/* Remove the object */
|
||||
ipcom_hash_remove(ipl2tp_example_sessions, session);
|
||||
|
||||
/* Remove the socket */
|
||||
session->fd_eth->data = IP_NULL;
|
||||
session->fd_eth = IP_NULL;
|
||||
|
||||
/* Free the session */
|
||||
ipcom_free(session->session.circuit);
|
||||
ipcom_free(session);
|
||||
|
||||
/* Set the user data */
|
||||
if (ipl2tp_attr_pappend(&attr,
|
||||
IPL2TP_SATTR_SET_USER_DATA,
|
||||
IP_NULL) == IPL2TP_STATUS_OK)
|
||||
{
|
||||
ipl2tp_api_session_attribute_set(key, attr);
|
||||
ipl2tp_attr_delete(&attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_example_session_eth_create
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ipl2tp_v3_ethernet_circuit_t *
|
||||
ipl2tp_example_session_eth_create(Ipl2tp_v3_circuit_t *circuit,
|
||||
Ipl2tp_key *key)
|
||||
{
|
||||
Ipl2tp_v3_ethernet_circuit_t *session;
|
||||
Ipl2tp_attrobj attr = IP_NULL;
|
||||
struct Ip_ifreq ifreq;
|
||||
Ipl2tp_callback cb;
|
||||
|
||||
session = ipcom_calloc(1, sizeof(*session));
|
||||
if (session == IP_NULL)
|
||||
goto fail;
|
||||
|
||||
ipcom_memcpy(&session->session.key, key, sizeof(*key));
|
||||
session->session.circuit = circuit;
|
||||
session->fd_eth = ipcom_malloc(sizeof(*session->fd_eth));
|
||||
if (session->fd_eth == IP_NULL)
|
||||
goto fail;
|
||||
|
||||
/* Create socket for catching packets destined to proxied MNs */
|
||||
session->fd_eth->fd = ipcom_socket(IP_AF_PACKET, IP_SOCK_RAW, 0);
|
||||
if (session->fd_eth->fd == IP_INVALID_SOCKET)
|
||||
goto fail;
|
||||
|
||||
/* Bind raw socket to device */
|
||||
if (ipcom_setsockopt(session->fd_eth->fd, IP_SOL_SOCKET, IP_SO_BINDTODEVICE,
|
||||
circuit->intf, IP_IFNAMSIZ) == IP_SOCKERR)
|
||||
{
|
||||
ipcom_socketclose(session->fd_eth->fd);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ipcom_memset(&ifreq, 0, sizeof(struct Ip_ifreq));
|
||||
ipcom_if_indextoname(circuit->ifnum, ifreq.ifr_name);
|
||||
|
||||
if (ipcom_socketioctl(session->fd_eth->fd, IP_SIOCGIFFLAGS, &ifreq) < 0)
|
||||
{
|
||||
IPCOM_LOG1(ERR,
|
||||
"IPL2TPv3: failed to get interface flags: %s",
|
||||
ipcom_strerror(ipcom_errno));
|
||||
goto fail;
|
||||
}
|
||||
IP_BIT_SET(ifreq.ip_ifr_flags, IP_IFF_PROMISC);
|
||||
if (ipcom_socketioctl(session->fd_eth->fd, IP_SIOCSIFFLAGS, &ifreq) < 0)
|
||||
{
|
||||
IPCOM_LOG1(ERR,
|
||||
"IPL2TPv3: failed to set interface flags: %s",
|
||||
ipcom_strerror(ipcom_errno));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
session->fd_eth->ptr = session;
|
||||
session->fd_eth->data = ipl2tp_example_session_eth_data_input;
|
||||
|
||||
if (ipcom_hash_add(ipl2tp_example_sessions, session) != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "IPL2TPv3: failed to add session");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ipcom_list_insert_last(&ipl2tp_example_fds, &session->fd_eth->next);
|
||||
|
||||
/* Set the user data */
|
||||
if (ipl2tp_attr_pappend(&attr,
|
||||
IPL2TP_SATTR_SET_USER_DATA,
|
||||
session) != IPL2TP_STATUS_OK)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "IPL2TPv3: failed to set sesion user data");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Set the data callback */
|
||||
cb.eth_callback = (Ipl2tp_eth_callback)ipl2tp_example_session_eth_data_output;
|
||||
|
||||
if (ipl2tp_attr_pappend(&attr,
|
||||
IPL2TP_SATTR_SET_DATA_CALLBACK,
|
||||
(void *)cb.voidptr) != IPL2TP_STATUS_OK ||
|
||||
ipl2tp_attr_iappend(&attr,
|
||||
IPL2TP_SATTR_SET_LOCAL_CIRCUIT_STATUS,
|
||||
IPL2TP_MIB_UP) != IPL2TP_STATUS_OK)
|
||||
{
|
||||
IPCOM_LOG0(WARNING, "IPL2TPv3: failed to set attributes");
|
||||
}
|
||||
|
||||
ipl2tp_api_session_attribute_set(key, attr);
|
||||
ipl2tp_attr_delete(&attr);
|
||||
|
||||
return session;
|
||||
|
||||
fail:
|
||||
if (session)
|
||||
{
|
||||
if (session->fd_eth)
|
||||
ipcom_free(session->fd_eth);
|
||||
ipcom_free(session);
|
||||
}
|
||||
ipcom_free(circuit);
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_example_session_to_link
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ipl2tp_v3_circuit_t *
|
||||
ipl2tp_example_session_to_circuit(Ipl2tp_key *key,
|
||||
int type)
|
||||
{
|
||||
Ipl2tp_v3_circuit_t *circuit;
|
||||
Ipl2tp_attrobj replies = IP_NULL;
|
||||
Ipl2tp_attrobj attr = IP_NULL;
|
||||
Ipl2tp_attr a;
|
||||
Ip_u32 id;
|
||||
char buf[128];
|
||||
char *ctype;
|
||||
int i;
|
||||
int argc;
|
||||
char **argv = IP_NULL;
|
||||
|
||||
|
||||
|
||||
ipl2tp_api_session_attribute_query(key,
|
||||
IPL2TP_SATTR_GET_REMOTE_END_ID,
|
||||
&replies);
|
||||
if ((a = ipl2tp_attr_first(replies)) == IP_NULL)
|
||||
return IP_NULL;
|
||||
if (ipl2tp_attr_length(a) != 4)
|
||||
return IP_NULL;
|
||||
|
||||
/* Get the router ID */
|
||||
id = IP_GET_NTOHL(ipl2tp_attr_vdata(a));
|
||||
ipl2tp_attr_delete(&replies);
|
||||
|
||||
/* Parse the circuit */
|
||||
circuit = ipcom_calloc(1, sizeof(*circuit));
|
||||
|
||||
if(circuit == IP_NULL)
|
||||
{
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
/* */
|
||||
ipcom_snprintf(buf, sizeof(buf), "ipl2tp.v3.circuit.%ld.name", id);
|
||||
if ((circuit->name = ipcom_sysvar_get(buf, IP_NULL, IP_NULL)) == IP_NULL)
|
||||
goto fail;
|
||||
|
||||
ipcom_snprintf(buf, sizeof(buf), "ipl2tp.v3.circuit.%ld.interface", id);
|
||||
if ((circuit->intf = ipcom_sysvar_get(buf, IP_NULL, IP_NULL)) == IP_NULL)
|
||||
goto fail;
|
||||
|
||||
ipcom_snprintf(buf, sizeof(buf), "ipl2tp.v3.circuit.%ld.attributes", id);
|
||||
if ((ctype = ipcom_sysvar_get(buf, IP_NULL, IP_NULL)) == IP_NULL)
|
||||
{
|
||||
ipcom_snprintf(buf, sizeof(buf), "ipl2tp.v3.circuit.any.attributes");
|
||||
if ((ctype = ipcom_sysvar_get(buf, IP_NULL, IP_NULL)) == IP_NULL)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Got the argument vector; time to explode it */
|
||||
if (ipcom_parse_argstr(ctype, (int *)&argc, &argv) != 0)
|
||||
{
|
||||
ipcom_free(ctype);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
char *value;
|
||||
Ipl2tp_attr_info *info;
|
||||
|
||||
/**/
|
||||
if ((info = ipl2tp_api_attribute_find(ipl2tp_session_tags, argv[i], &value)) == IP_NULL)
|
||||
{
|
||||
IPCOM_LOG2(ERR,
|
||||
"L2TP: circuit %s: Invalid attribute %s",
|
||||
circuit->name, argv[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ipl2tp_api_attribute_parse(&attr,info,&value) == IP_FALSE)
|
||||
{
|
||||
IPCOM_LOG3(ERR,
|
||||
"L2TP: circuit %s: Invalid attribute %s and value %s",
|
||||
circuit->name, argv[i], value);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ipl2tp_api_session_attribute_set(key,attr);
|
||||
ipl2tp_attr_delete(&attr);
|
||||
ipcom_free(argv);
|
||||
ipcom_free(ctype);
|
||||
|
||||
|
||||
/* Retrieve the pseudowire type of the session */
|
||||
ipl2tp_api_session_attribute_query(key,
|
||||
IPL2TP_SATTR_GET_PSEUDOWIRE_TYPE,
|
||||
&replies);
|
||||
|
||||
if((a = ipl2tp_attr_first(replies)) == IP_NULL)
|
||||
{
|
||||
ipl2tp_attr_delete(&replies);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Does it match? */
|
||||
circuit->pw_type = ipl2tp_attr_idata(a);
|
||||
ipl2tp_attr_delete(&replies);
|
||||
|
||||
if (circuit->pw_type != type)
|
||||
{
|
||||
IPCOM_LOG3(ERR,
|
||||
"L2TP: circuit %s: Invalid pseudowire %u vs %u",
|
||||
circuit->name,
|
||||
circuit->pw_type,
|
||||
type);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* No interface */
|
||||
if ((circuit->ifnum = ipcom_if_nametoindex(circuit->intf)) == 0)
|
||||
goto fail;
|
||||
|
||||
/* VLAN tag */
|
||||
ipcom_snprintf(buf, sizeof(buf), "ipl2tp.v3.circuit.%ld.vlan", id);
|
||||
circuit->vlan_tag = ipcom_sysvar_get_as_int0(buf, 0);
|
||||
|
||||
return circuit;
|
||||
|
||||
fail:
|
||||
if (circuit->name != IP_NULL)
|
||||
ipcom_free(circuit->name);
|
||||
if (circuit->intf != IP_NULL)
|
||||
ipcom_free(circuit->intf);
|
||||
ipcom_free(circuit);
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_example_session_eth_setup
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ipl2tp_v3_ethernet_circuit_t *
|
||||
ipl2tp_example_session_eth_setup(Ipl2tp_key *key,
|
||||
int type)
|
||||
{
|
||||
Ipl2tp_v3_circuit_t *circuit;
|
||||
|
||||
/* Destroy any previous sessions */
|
||||
ipl2tp_example_session_eth_destroy(key);
|
||||
|
||||
/* Setup this end of the tunnel */
|
||||
if ((circuit = ipl2tp_example_session_to_circuit(key, type)) == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
/* Create the session */
|
||||
return ipl2tp_example_session_eth_create(circuit, key);
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_example_session_eth_status
|
||||
*===========================================================================
|
||||
* Description: Session status callback.
|
||||
* Parameters: user_data - User callback data.
|
||||
* key - Session ID.
|
||||
* status - Pointer to status info.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipl2tp_example_session_eth_status(void *user_data,
|
||||
Ipl2tp_key *key,
|
||||
Ipl2tp_result *result,
|
||||
int type)
|
||||
{
|
||||
Ipl2tp_v3_ethernet_circuit_t *session = user_data;
|
||||
|
||||
|
||||
switch (result->status)
|
||||
{
|
||||
case IPL2TP_STATUS_OK:
|
||||
switch (result->result_code)
|
||||
{
|
||||
case IPL2TP_OUTGOING_REQUEST:
|
||||
{
|
||||
/* Setup */
|
||||
if ((session = ipl2tp_example_session_eth_setup(key, type)) == IP_NULL)
|
||||
return IPL2TP_STATUS_BADID;
|
||||
|
||||
IPCOM_LOG4(DEBUG,
|
||||
"IPL2TPv3: SESSION (IPL2TP_OUTGOING_REQUEST) session[%s] v%d %d %s",
|
||||
((Ipl2tp_v3_circuit_t *)session->session.circuit)->name,
|
||||
key->version, key->ident,
|
||||
ipl2tp_api_session_type(key));
|
||||
break;
|
||||
}
|
||||
case IPL2TP_OUTGOING_REPLY:
|
||||
{
|
||||
IPCOM_LOG3(DEBUG,
|
||||
"IPL2TPv3: SESSION (IPL2TP_OUTGOING_REPLY) v%d %d %s",
|
||||
key->version, key->ident,
|
||||
ipl2tp_api_session_type(key));
|
||||
ipl2tp_api_session_outgoing_established(key, 0, 0, "");
|
||||
break;
|
||||
}
|
||||
case IPL2TP_OUTGOING_ESTABLISHED:
|
||||
/* */
|
||||
if (session == IP_NULL)
|
||||
{
|
||||
/* Setup */
|
||||
if ((session = ipl2tp_example_session_eth_setup(key, type)) == IP_NULL)
|
||||
return IPL2TP_STATUS_BADID;
|
||||
}
|
||||
|
||||
IPCOM_LOG4(DEBUG,
|
||||
"IPL2TPv3: SESSION (IPL2TP_OUTGOING_ESTABLISHED) session[%s] v%d %d %s",
|
||||
((Ipl2tp_v3_circuit_t *)session->session.circuit)->name,
|
||||
key->version, key->ident,
|
||||
ipl2tp_api_session_type(key));
|
||||
break;
|
||||
|
||||
case IPL2TP_INCOMING_REQUEST:
|
||||
/* Destroy any previous sessions */
|
||||
/* Setup */
|
||||
if ((session = ipl2tp_example_session_eth_setup(key, type)) == IP_NULL)
|
||||
return IPL2TP_STATUS_BADID;
|
||||
|
||||
IPCOM_LOG4(DEBUG,
|
||||
"IPL2TPv3: SESSION (IPL2TP_INCOMING_REQUEST) session[%s] v%d %d %s",
|
||||
((Ipl2tp_v3_circuit_t *)session->session.circuit)->name,
|
||||
key->version, key->ident,
|
||||
ipl2tp_api_session_type(key));
|
||||
|
||||
ipl2tp_api_session_incoming_established(key, 0, 0, "");
|
||||
break;
|
||||
|
||||
case IPL2TP_INCOMING_ESTABLISHED:
|
||||
/* */
|
||||
if (session == IP_NULL)
|
||||
{
|
||||
/* Setup */
|
||||
if ((session = ipl2tp_example_session_eth_setup(key, type)) == IP_NULL)
|
||||
return IPL2TP_STATUS_BADID;
|
||||
}
|
||||
|
||||
IPCOM_LOG4(DEBUG,
|
||||
"IPL2TPv3: SESSION (IPL2TP_INCOMING_ESTABLISHED) session[%s] v%d %d %s",
|
||||
((Ipl2tp_v3_circuit_t *)session->session.circuit)->name,
|
||||
key->version, key->ident,
|
||||
ipl2tp_api_session_type(key));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
IPCOM_LOG6(DEBUG,
|
||||
"IPL2TPv3: SESSION (%u) Session[%s] v%d %d %s closed with status %s",
|
||||
(int)result->status,
|
||||
session? ((Ipl2tp_v3_circuit_t *)session->session.circuit)->name : "<invalid>",
|
||||
key->version, key->ident,
|
||||
ipl2tp_api_session_type(key),
|
||||
ipl2tp_api_errname(result->status));
|
||||
ipl2tp_example_session_eth_destroy(key);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_example_tunnel_auth
|
||||
*===========================================================================
|
||||
* Description: Set the tunnel auth if available.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipl2tp_example_tunnel_auth(Ipl2tp_key *key,
|
||||
Ip_u32 rID,
|
||||
const char *peer)
|
||||
{
|
||||
char buf[128];
|
||||
char *ctype;
|
||||
Ipl2tp_attrobj attr = IP_NULL;
|
||||
int argc;
|
||||
char **argv = IP_NULL;
|
||||
int i;
|
||||
|
||||
do
|
||||
{
|
||||
IPCOM_LOG2(INFO,
|
||||
"L2TP: Verifying attributes for %ld@%s",
|
||||
rID, peer);
|
||||
|
||||
ipcom_snprintf(buf, sizeof(buf), "ipl2tp.v3.control.%ld.attributes", rID);
|
||||
if ((ctype = ipcom_sysvar_get(buf, IP_NULL, IP_NULL)) != IP_NULL)
|
||||
break;
|
||||
|
||||
ipcom_snprintf(buf, sizeof(buf), "ipl2tp.v3.control.%s.attributes", peer);
|
||||
if ((ctype = ipcom_sysvar_get(buf, IP_NULL, IP_NULL)) != IP_NULL)
|
||||
break;
|
||||
|
||||
ipcom_snprintf(buf, sizeof(buf), "ipl2tp.v3.control.any.attributes");
|
||||
if ((ctype = ipcom_sysvar_get(buf, IP_NULL, IP_NULL)) != IP_NULL)
|
||||
break;
|
||||
|
||||
return;
|
||||
} while (0);
|
||||
|
||||
|
||||
/* Got the argument vector; time to explode it */
|
||||
if (ipcom_parse_argstr(ctype, (int *)&argc, &argv) != 0)
|
||||
{
|
||||
ipcom_free(ctype);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
char *value;
|
||||
Ipl2tp_attr_info *info;
|
||||
|
||||
/**/
|
||||
if ((info = ipl2tp_api_attribute_find(ipl2tp_tunnel_tags, argv[i], &value)) == IP_NULL)
|
||||
{
|
||||
IPCOM_LOG1(ERR,
|
||||
"L2TP: tunnel: Invalid attribute %s",
|
||||
argv[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ipl2tp_api_attribute_parse(&attr,info,&value) == IP_FALSE)
|
||||
{
|
||||
IPCOM_LOG2(ERR,
|
||||
"L2TP: Invalid attribute %s and value %s",
|
||||
argv[i], value);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ipl2tp_api_tunnel_attribute_set(key,attr);
|
||||
ipl2tp_attr_delete(&attr);
|
||||
ipcom_free(argv);
|
||||
ipcom_free(ctype);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_example_sstatus_v3
|
||||
*===========================================================================
|
||||
* Description: Session status callback.
|
||||
* Parameters: user_data - User callback data.
|
||||
* key - Session ID.
|
||||
* status - Pointer to status info.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
ipl2tp_example_sstatus_v3(void *user_data,
|
||||
Ipl2tp_key *key,
|
||||
Ipl2tp_result *result)
|
||||
{
|
||||
int type;
|
||||
Ipl2tp_attrobj replies = IP_NULL;
|
||||
Ipl2tp_attr a;
|
||||
|
||||
ipl2tp_api_session_attribute_query(key,
|
||||
IPL2TP_SATTR_GET_PSEUDOWIRE_TYPE,
|
||||
&replies);
|
||||
|
||||
if((a = ipl2tp_attr_first(replies)) == IP_NULL)
|
||||
{
|
||||
ipl2tp_attr_delete(&replies);
|
||||
return IPL2TP_STATUS_BADAVP;
|
||||
}
|
||||
|
||||
type = ipl2tp_attr_idata(a);
|
||||
ipl2tp_attr_delete(&replies);
|
||||
|
||||
/* ETHERNET pseudowire type */
|
||||
if (type == IPL2TP_ATTR_PW_TYPE_ETHERNET ||
|
||||
type == IPL2TP_ATTR_PW_TYPE_ETHERNET_VLAN)
|
||||
{
|
||||
/* */
|
||||
return ipl2tp_example_session_eth_status(user_data, key, result, type);
|
||||
}
|
||||
|
||||
|
||||
return IPL2TP_STATUS_BADPW;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_example_tstatus_v3
|
||||
*===========================================================================
|
||||
* Description: Tunnel status callback.
|
||||
* Parameters: user_data - User callback data.
|
||||
* key - Tunnel ID.
|
||||
* status - Pointer to status info.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
ipl2tp_example_tstatus_v3(void *user_data,
|
||||
Ipl2tp_key *key,
|
||||
Ipl2tp_result *result)
|
||||
{
|
||||
Ipl2tp_attrobj replies = IP_NULL;
|
||||
Ipl2tp_attrobj attr = IP_NULL;
|
||||
Ipl2tp_attr a;
|
||||
Ip_u32 rID;
|
||||
const char *peer;
|
||||
|
||||
IPL2TP_UNUSED(user_data);
|
||||
|
||||
/* Get the remote info */
|
||||
ipl2tp_attr_add_query(&attr, IPL2TP_TATTR_GET_REMOTE_ROUTER_ID);
|
||||
ipl2tp_attr_add_query(&attr, IPL2TP_TATTR_GET_l2tpTunnelStatsRemoteHostName);
|
||||
|
||||
ipl2tp_api_tunnel_attribute_get(key, attr, &replies);
|
||||
ipl2tp_attr_delete(&attr);
|
||||
|
||||
/* Get the router ID */
|
||||
a = ipl2tp_attr_first(replies);
|
||||
if(a == IP_NULL)
|
||||
{
|
||||
ipl2tp_attr_delete(&replies);
|
||||
return 0;
|
||||
}
|
||||
|
||||
rID = ipl2tp_attr_idata(a);
|
||||
|
||||
/* Get the remote host name */
|
||||
a = ipl2tp_attr_next(a);
|
||||
peer = ipl2tp_attr_strdata(a);
|
||||
|
||||
switch (result->status)
|
||||
{
|
||||
case IPL2TP_STATUS_OK:
|
||||
switch (result->result_code)
|
||||
{
|
||||
case IPL2TP_OUTGOING_AUTHENTICATION:
|
||||
{
|
||||
/* Allocate an attribute object */
|
||||
IPCOM_LOG3(DEBUG,
|
||||
"IPL2TPv3: TUNNEL (IPL2TP_OUTGOING_AUTHENTICATION) v%d %d requested by '%s'",
|
||||
key->version, key->ident,
|
||||
peer);
|
||||
|
||||
ipl2tp_example_tunnel_auth(key, rID, peer);
|
||||
|
||||
|
||||
/* We've installed the authentication data required,
|
||||
* do continue the tunnel processing and attempt to establish */
|
||||
ipl2tp_api_tunnel_authentication_established(key);
|
||||
break;
|
||||
}
|
||||
|
||||
case IPL2TP_OUTGOING_REQUEST:
|
||||
{
|
||||
IPCOM_LOG3(DEBUG,
|
||||
"IPL2TPv3: TUNNEL (IPL2TP_OUTGOING_REQUEST) v%d %d from '%s'",
|
||||
key->version, key->ident,
|
||||
peer);
|
||||
break;
|
||||
}
|
||||
|
||||
case IPL2TP_OUTGOING_ESTABLISHED:
|
||||
IPCOM_LOG2(DEBUG,
|
||||
"IPL2TPv3: TUNNEL (IPL2TP_OUTGOING_ESTABLISHED) v%d %d opened",
|
||||
key->version, key->ident);
|
||||
break;
|
||||
|
||||
case IPL2TP_INCOMING_ESTABLISHED:
|
||||
IPCOM_LOG2(DEBUG,
|
||||
"IPL2TPv3: TUNNEL (IPL2TP_INCOMING_ESTABLISHED) v%d %d opened",
|
||||
key->version, key->ident);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case IPL2TP_STATUS_NEGOTIATION:
|
||||
IPCOM_LOG2(DEBUG,
|
||||
"IPL2TPv3: TUNNEL (IPL2TP_STATUS_NEGOTIATION) v%d %d closed obsoleted by version negotiation",
|
||||
key->version, key->ident);
|
||||
break;
|
||||
|
||||
default:
|
||||
IPCOM_LOG4(DEBUG,
|
||||
"IPL2TPv3: TUNNEL (%u) v%d %d closed with status %s",
|
||||
(int)result->status,
|
||||
key->version, key->ident,
|
||||
ipl2tp_api_errname(result->status));
|
||||
break;
|
||||
}
|
||||
|
||||
ipl2tp_attr_delete(&replies);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,99 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipl2tp_example_v3.h,v $ $Revision: 1.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipl2tp/config/ipl2tp_example_v3.h,v $
|
||||
* $Author: joel $ $Date: 2006-01-30 10:46:59 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPL2TP_EXAMPLE_V3_H
|
||||
#define IPL2TP_EXAMPLE_V3_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_example_sstatus_v3
|
||||
*===========================================================================
|
||||
* Description: Session status callback.
|
||||
* Parameters: user_data - User callback data.
|
||||
* key - Session ID.
|
||||
* status - Pointer to status info.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipl2tp_example_sstatus_v3(void *user_data,
|
||||
Ipl2tp_key *key,
|
||||
Ipl2tp_result *result);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipl2tp_example_tstatus_v3
|
||||
*===========================================================================
|
||||
* Description: Tunnel status callback.
|
||||
* Parameters: user_data - User callback data.
|
||||
* key - Tunnel ID.
|
||||
* status - Pointer to status info.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipl2tp_example_tstatus_v3(void *user_data,
|
||||
Ipl2tp_key *key,
|
||||
Ipl2tp_result *result);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
Reference in New Issue
Block a user