original files of m241
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/* 00folder_ipnet_mobility.cdf - IPNet Top-Level Folder configuration file */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 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,21sep06,kch Created.
|
||||
*/
|
||||
|
||||
|
||||
Folder FOLDER_MOBILITY_V4 {
|
||||
NAME Mobility Components IPv4
|
||||
SYNOPSIS Mobility Components IPv4
|
||||
_CHILDREN FOLDER_MOBILITY
|
||||
}
|
||||
|
||||
Folder FOLDER_MOBILITY_HA {
|
||||
NAME Home Agent for IPv4
|
||||
SYNOPSIS Home Agent for IPv4
|
||||
_CHILDREN FOLDER_MOBILITY_V4
|
||||
}
|
||||
|
||||
Folder FOLDER_MOBILITY_MN {
|
||||
NAME Mobile Node for IPv4
|
||||
SYNOPSIS Mobile Node for IPv4
|
||||
_CHILDREN FOLDER_MOBILITY_V4
|
||||
}
|
||||
|
||||
Folder FOLDER_MOBILITY_FA {
|
||||
NAME Foreign Agent for IPv4
|
||||
SYNOPSIS Foreign Agent for IPv4
|
||||
_CHILDREN FOLDER_MOBILITY_V4
|
||||
}
|
||||
|
||||
Folder FOLDER_MOBILITY_PM {
|
||||
NAME Proxy Mobility Client for IPv4
|
||||
SYNOPSIS Proxy Mobility Client for IPv4
|
||||
_CHILDREN FOLDER_MOBILITY_V4
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: common.vxconfig,v $ $Revision: 1.10 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipmip4/config/common.vxconfig,v $
|
||||
# $Author: myakan $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
|
||||
#hidden option that enables IPMIP4
|
||||
config SUPPORTS_MIP4
|
||||
bool
|
||||
default y
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_config.h,v $ $Revision: 1.9 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/config/ipmip4_config.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-03-31 14:59:24 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_CONFIG_H
|
||||
#define IPMIP4_CONFIG_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <ipcom_err.h>
|
||||
|
||||
#include <ipmip_config.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#ifdef IP_DEBUG
|
||||
#define IPMIP4_SYSTEM_PRIORITY IPCOM_LOG_DEBUG2
|
||||
#define IPMIP4_EVENT_PRIORITY IPCOM_LOG_DEBUG2
|
||||
#else
|
||||
#define IPMIP4_SYSTEM_PRIORITY IPCOM_LOG_WARNING
|
||||
#define IPMIP4_EVENT_PRIORITY IPCOM_LOG_INFO
|
||||
#endif
|
||||
|
||||
#define IPMIP4_SECRET_LENGTH_MAX 32
|
||||
|
||||
/* If defined, the MIP4 system will attempt to collect MIB statistics */
|
||||
#define IPMIP4_USE_MIB 1
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,191 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_vendor_ext.c,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/config/ipmip4_vendor_ext.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip4_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_drv_eth_filter.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_sysctl.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_netif.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
#include "ipmip4.h"
|
||||
#include <private/ipmip4_msgext.h>
|
||||
#include <private/ipmip4_util.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_vendor_ext_parse_cisco
|
||||
*===========================================================================
|
||||
* Description: Parse a cisco extension.
|
||||
* Parameters: mobile - The mobile structure to store the result in.
|
||||
* uhdr - The UHDR
|
||||
* Returns: IPMIP4_REG_EXT_SUCCESS on succes, IPMIP4_REG_EXT_UNKNOWN if
|
||||
* not known; other error code if failed.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
ipmip4_vendor_ext_parse_cisco(struct Ipmip4_msgext_mobile *mobile,
|
||||
union Ipmip4_msgext_uhdr *uhdr)
|
||||
{
|
||||
Ipmip4_nvse_t *nvse;
|
||||
|
||||
/* There are no CISCO CVSE's */
|
||||
if (IPMIP4_MSGEXT_UHDR_TYPE(uhdr) == IPMIP4_EXT_TYPE_CVSE)
|
||||
return IPMIP4_REG_EXT_UNKNOWN_VSE;
|
||||
|
||||
/* Get the NVSE data */
|
||||
nvse = (Ipmip4_nvse_t *)IPMIP4_MSGEXT_SHDR_EXT_DATA(uhdr);
|
||||
switch (IP_GET_NTOHS(nvse->vendor_type))
|
||||
{
|
||||
case IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF:
|
||||
/* Must be the NVSE header + 2 byte subtype minimum */
|
||||
if (IPMIP4_MSGEXT_NVSE_EXT_SIZE(uhdr) < 2)
|
||||
return IPMIP4_REG_EXT_POORLY_FORMED;
|
||||
switch (IP_GET_HTONS(IPMIP4_MSGEXT_NVSE_EXT_DATA(uhdr)))
|
||||
{
|
||||
case IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF_REQ:
|
||||
if (IPMIP4_MSGEXT_NVSE_EXT_SIZE(uhdr) < 4)
|
||||
return IPMIP4_REG_EXT_POORLY_FORMED;
|
||||
mobile->vendor.cisco.cfg_req = uhdr;
|
||||
break;
|
||||
case IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF_PREFIXLEN:
|
||||
if (IPMIP4_MSGEXT_NVSE_EXT_SIZE(uhdr) < 4)
|
||||
return IPMIP4_REG_EXT_POORLY_FORMED;
|
||||
mobile->vendor.cisco.prefixlen = uhdr;
|
||||
break;
|
||||
case IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF_DNS_SERVER:
|
||||
if (IPMIP4_MSGEXT_NVSE_EXT_SIZE(uhdr) < 10)
|
||||
return IPMIP4_REG_EXT_POORLY_FORMED;
|
||||
mobile->vendor.cisco.dns_server = uhdr;
|
||||
break;
|
||||
case IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF_DHCP_SERVER:
|
||||
if (IPMIP4_MSGEXT_NVSE_EXT_SIZE(uhdr) < 6)
|
||||
return IPMIP4_REG_EXT_POORLY_FORMED;
|
||||
mobile->vendor.cisco.dhcp_server = uhdr;
|
||||
break;
|
||||
case IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF_DHCP_CID:
|
||||
if (IPMIP4_MSGEXT_NVSE_EXT_SIZE(uhdr) < 4)
|
||||
return IPMIP4_REG_EXT_POORLY_FORMED;
|
||||
mobile->vendor.cisco.dhcp_cid = uhdr;
|
||||
break;
|
||||
case IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF_DEFAULT_GW:
|
||||
if (IPMIP4_MSGEXT_NVSE_EXT_SIZE(uhdr) < 6)
|
||||
return IPMIP4_REG_EXT_POORLY_FORMED;
|
||||
mobile->vendor.cisco.default_gw = uhdr;
|
||||
break;
|
||||
case IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF_DNS_SUFFIX:
|
||||
if (IPMIP4_MSGEXT_NVSE_EXT_SIZE(uhdr) < 3)
|
||||
return IPMIP4_REG_EXT_POORLY_FORMED;
|
||||
mobile->vendor.cisco.dns_suffix = uhdr;
|
||||
break;
|
||||
case IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF_CONFIG_URL:
|
||||
if (IPMIP4_MSGEXT_NVSE_EXT_SIZE(uhdr) < 2)
|
||||
return IPMIP4_REG_EXT_POORLY_FORMED;
|
||||
mobile->vendor.cisco.config_url = uhdr;
|
||||
break;
|
||||
default:
|
||||
return IPMIP4_REG_EXT_UNKNOWN_VSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return IPMIP4_REG_EXT_UNKNOWN_VSE;
|
||||
}
|
||||
|
||||
return IPMIP4_REG_EXT_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,146 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_vendor_ext.h,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/config/ipmip4_vendor_ext.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-03-02 17:34:49 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_VENDOR_EXT_H
|
||||
#define IPMIP4_VENDOR_EXT_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF 14
|
||||
|
||||
#define IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF_REQ 0
|
||||
#define IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF_PREFIXLEN 1
|
||||
#define IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF_DNS_SERVER 2
|
||||
#define IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF_DHCP_SERVER 3
|
||||
#define IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF_DHCP_CID 4
|
||||
#define IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF_DEFAULT_GW 5
|
||||
#define IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF_DNS_SUFFIX 6
|
||||
#define IPMIP4_VENDOR_EXT_MSGEXT_CISCO_HOSTCONF_CONFIG_URL 7
|
||||
|
||||
/* Testing purposes */
|
||||
#ifdef IPTESTENGINE
|
||||
#define IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_MN 0 /* Understood by Mobile Node */
|
||||
#define IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_FA 1 /* Understood by Foreign Agent */
|
||||
#define IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_HA 2 /* Understood by Home Agent */
|
||||
#define IPMIP4_VENDOR_EXT_MSGEXT_WINDRIVER_NOOP_ALL 3 /* Understood by ALL */
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
union Ipmip4_msgext_uhdr;
|
||||
|
||||
#ifdef IPTESTENGINE
|
||||
typedef struct Ipmip4_vendor_ext_msgext_wr
|
||||
{
|
||||
union Ipmip4_msgext_uhdr *nvse_noop_mn;
|
||||
union Ipmip4_msgext_uhdr *nvse_noop_fa;
|
||||
union Ipmip4_msgext_uhdr *nvse_noop_ha;
|
||||
union Ipmip4_msgext_uhdr *nvse_noop_all;
|
||||
union Ipmip4_msgext_uhdr *cvse_noop_mn;
|
||||
union Ipmip4_msgext_uhdr *cvse_noop_fa;
|
||||
union Ipmip4_msgext_uhdr *cvse_noop_ha;
|
||||
union Ipmip4_msgext_uhdr *cvse_noop_all;
|
||||
} Ipmip4_vendor_ext_msgext_wr_t;
|
||||
#endif
|
||||
|
||||
/* Cisco vendor extensions; RFC 4332 */
|
||||
typedef struct Ipmip4_vendor_ext_msgext_cisco
|
||||
{
|
||||
union Ipmip4_msgext_uhdr *cfg_req;
|
||||
union Ipmip4_msgext_uhdr *prefixlen;
|
||||
union Ipmip4_msgext_uhdr *dns_server;
|
||||
union Ipmip4_msgext_uhdr *dhcp_server;
|
||||
union Ipmip4_msgext_uhdr *dhcp_cid;
|
||||
union Ipmip4_msgext_uhdr *default_gw;
|
||||
union Ipmip4_msgext_uhdr *dns_suffix;
|
||||
union Ipmip4_msgext_uhdr *config_url;
|
||||
} Ipmip4_vendor_ext_msgext_cisco_t;
|
||||
|
||||
|
||||
typedef struct Ipmip4_vendor_ext_msgext
|
||||
{
|
||||
#ifdef IPTESTENGINE
|
||||
Ipmip4_vendor_ext_msgext_wr_t wr;
|
||||
#endif
|
||||
/**/
|
||||
Ipmip4_vendor_ext_msgext_cisco_t cisco;
|
||||
} Ipmip4_vendor_ext_msgext_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip4_msgext_mobile;
|
||||
union Ipmip4_msgext_uhdr;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_vendor_ext_parse_cisco
|
||||
*===========================================================================
|
||||
* Description: Parse a cisco extension.
|
||||
* Parameters: mobile - The mobile structure to store the result in.
|
||||
* uhdr - The UHDR
|
||||
* Returns: IPMIP4_REG_EXT_SUCCESS on succes, IPMIP4_REG_EXT_UNKNOWN if
|
||||
* not known; other error code if failed.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipmip4_vendor_ext_parse_cisco(struct Ipmip4_msgext_mobile *mobile,
|
||||
union Ipmip4_msgext_uhdr *uhdr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,11 @@
|
||||
IPTARGETS := lib
|
||||
ifneq ($(IPMAKEFILE),)
|
||||
include $(IPMAKEFILE)
|
||||
else
|
||||
include $(IPCOM_ROOT)/Makefile
|
||||
endif
|
||||
include ipmip4.mk
|
||||
include $(IPCOM_ROOT)/gmake/ipcom_make.mk
|
||||
|
||||
lib: dirs $(IPLIBFILE)
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
#############################################################################
|
||||
# IPMIP4.MK
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4.mk,v $ $Revision: 1.23 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipmip4/gmake/ipmip4.mk,v $
|
||||
# $Author: jhorteli $ $Date: 2009-03-31 14:59:24 $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# Copyright 2000-2006 Interpeak AB (http://www.interpeak.se). All rights reserved.
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
#
|
||||
# Copyright (c) 2006 Wind River Systems, Inc.
|
||||
#
|
||||
# The right to copy, distribute, modify or otherwise make use
|
||||
# of this software may be licensed only pursuant to the terms
|
||||
# of an applicable Wind River license agreement.
|
||||
#
|
||||
# modification history
|
||||
# --------------------
|
||||
# 01a,31aug06,kch Build ipmipmn_config.o only if $(SKIP_CONFIG) is either
|
||||
# not defined or set to anything other than true.
|
||||
#
|
||||
|
||||
ifeq ($(IPMIP4),)
|
||||
ifneq ($(IPCOM_USE_INET),no)
|
||||
|
||||
IPMIP4 := yes
|
||||
|
||||
|
||||
#############################################################################
|
||||
# PRODUCT
|
||||
###########################################################################
|
||||
|
||||
IPPROD ?= ipmip4
|
||||
|
||||
|
||||
#############################################################################
|
||||
# DEFINE
|
||||
###########################################################################
|
||||
|
||||
IPDEFINE += -DIPMIP4
|
||||
|
||||
|
||||
#############################################################################
|
||||
# INCLUDE
|
||||
###########################################################################
|
||||
|
||||
IPINCLUDE += -I$(IPMIP4_ROOT)/config
|
||||
IPINCLUDE += -I$(IPMIP4_ROOT)/include
|
||||
|
||||
|
||||
#############################################################################
|
||||
# OBJECTS
|
||||
###########################################################################
|
||||
|
||||
ifneq ($(IPPORT),las)
|
||||
# KERNEL objects
|
||||
IPLIBOBJECTS += ipmip4_ipnet.o
|
||||
IPLIBOBJECTS += ipmip4_netlink_kern.o
|
||||
endif
|
||||
|
||||
ifneq ($(IPPORT),lkm)
|
||||
|
||||
# Library files.
|
||||
IPLIBOBJECTS += ipmip4_attr.o
|
||||
IPLIBOBJECTS += ipmip4_auth.o
|
||||
IPLIBOBJECTS += ipmip4_cli.o
|
||||
IPLIBOBJECTS += ipmip4_context.o
|
||||
IPLIBOBJECTS += ipmip4_diameter.o
|
||||
IPLIBOBJECTS += ipmip4_if.o
|
||||
IPLIBOBJECTS += ipmip4_ipnet_usr.o
|
||||
IPLIBOBJECTS += ipmip4_ipradius.o
|
||||
IPLIBOBJECTS += ipmip4_lla.o
|
||||
IPLIBOBJECTS += ipmip4_msgext.o
|
||||
IPLIBOBJECTS += ipmip4_netlink.o
|
||||
IPLIBOBJECTS += ipmip4_ntop.o
|
||||
IPLIBOBJECTS += ipmip4_pkt.o
|
||||
IPLIBOBJECTS += ipmip4_sysext.o
|
||||
IPLIBOBJECTS += ipmip4_util.o
|
||||
IPLIBOBJECTS += ipmip4_vendor_ext.o
|
||||
|
||||
# SNMP
|
||||
ifneq ($(WIND_IPNET),true)
|
||||
IPLIBOBJECTS += ipmip4_mip_mib.o
|
||||
endif
|
||||
|
||||
#############################################################################
|
||||
# VPATH
|
||||
###########################################################################
|
||||
|
||||
IPSRCDIRS += $(IPMIP4_ROOT)/config
|
||||
endif # LKM
|
||||
IPSRCDIRS += $(IPMIP4_ROOT)/src
|
||||
|
||||
|
||||
#############################################################################
|
||||
# LIB
|
||||
###########################################################################
|
||||
|
||||
IPLIBS += $(IPLIBROOT)/libipmip4.a
|
||||
|
||||
|
||||
#############################################################################
|
||||
# BINARIES
|
||||
###########################################################################
|
||||
|
||||
|
||||
endif # IPCOM_USE_INET
|
||||
endif # IPMIP4
|
||||
|
||||
###########################################################################
|
||||
# END OF IPMIP4.MK
|
||||
###########################################################################
|
||||
@@ -0,0 +1,110 @@
|
||||
/* ipmip4.h - ipmip4.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4.h,v $ $Revision: 1.19 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/ipmip4.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-10-15 11:27:57 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_H
|
||||
#define IPMIP4_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
Base IPMIP4 defines. Flags, syslog and types used globally in the MIPv4
|
||||
submodule.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip4_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPMIP4_RELEASE 60701
|
||||
|
||||
#define IPMIP4_PORT 434
|
||||
|
||||
|
||||
#define IPMIP4_TUNNELMODE_REVERSE (1 << 0)
|
||||
#define IPMIP4_TUNNELMODE_NAT_T_REQUESTED (1 << 1)
|
||||
#define IPMIP4_TUNNELMODE_NAT_T_RECEIVED (1 << 2)
|
||||
#define IPMIP4_TUNNELMODE_NAT_T_UNRESOLVED (1 << 3)
|
||||
#define IPMIP4_TUNNELMODE_REVOCATION_REQUESTED (1 << 4)
|
||||
#define IPMIP4_TUNNELMODE_REVOCATION_RECEIVED (1 << 5)
|
||||
#define IPMIP4_TUNNELMODE_REVOCATION_INFORM (1 << 6)
|
||||
#define IPMIP4_TUNNELMODE_PROXY_BINDING (1 << 7)
|
||||
|
||||
#define IPMIP4_TUNNELMODE_NAT_T_CONFIRMED (IPMIP4_TUNNELMODE_NAT_T_REQUESTED|IPMIP4_TUNNELMODE_NAT_T_RECEIVED)
|
||||
#define IPMIP4_TUNNELMODE_REVOCATION_CONFIRMED (IPMIP4_TUNNELMODE_REVOCATION_REQUESTED|IPMIP4_TUNNELMODE_REVOCATION_RECEIVED)
|
||||
|
||||
#define IPMIP4_JAN_1970 2208988800UL
|
||||
|
||||
#define IPMIP4_RETCODE_CONTINUE (0)
|
||||
#define IPMIP4_RETCODE_SKIPPED (1)
|
||||
#define IPMIP4_RETCODE_PENDING (2)
|
||||
|
||||
/* Syslog priority and facility */
|
||||
#ifdef IPCOM_SYSLOG_PRIORITY
|
||||
#undef IPCOM_SYSLOG_PRIORITY
|
||||
#endif
|
||||
#define IPCOM_SYSLOG_PRIORITY IPMIP4_SYSTEM_PRIORITY
|
||||
#ifdef IPCOM_SYSLOG_FACILITY
|
||||
#undef IPCOM_SYSLOG_FACILITY
|
||||
#endif
|
||||
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPMIP
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,147 @@
|
||||
/* ipmip4_mib.h - ipmip4_mib.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_mib.h,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/ipmip4_mib.h,v $
|
||||
* $Author: joel $ $Date: 2007-08-28 14:54:29 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_MIB_H
|
||||
#define IPMIP4_MIB_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Base MIB implementation
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
Base MIB implementation
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIP4_MIB_mipEntities_mobileNode (1)
|
||||
#define IPMIP4_MIB_mipEntities_foreignAgent (1<<1)
|
||||
#define IPMIP4_MIB_mipEntities_homeAgent (1<<2)
|
||||
#define IPMIP4_MIB_mipEnable_enabled (1)
|
||||
#define IPMIP4_MIB_mipEnable_disabled (2)
|
||||
#define IPMIP4_MIB_mipEncapsulationSupported_ipInIp (1)
|
||||
#define IPMIP4_MIB_mipEncapsulationSupported_gre (1<<1)
|
||||
#define IPMIP4_MIB_mipEncapsulationSupported_minEnc (1<<2)
|
||||
#define IPMIP4_MIB_mipEncapsulationSupported_other (1<<3)
|
||||
#define IPMIP4_MIB_mipSecAlgorithmType_other (1)
|
||||
#define IPMIP4_MIB_mipSecAlgorithmType_md5 (2)
|
||||
#define IPMIP4_MIB_mipSecAlgorithmMode_other (1)
|
||||
#define IPMIP4_MIB_mipSecAlgorithmMode_prefixSuffix (2)
|
||||
#define IPMIP4_MIB_mipSecReplayMethod_other (1)
|
||||
#define IPMIP4_MIB_mipSecReplayMethod_timestamps (2)
|
||||
#define IPMIP4_MIB_mipSecReplayMethod_nonces (3)
|
||||
#define IPMIP4_MIB_mipSecRecentViolationReason_noMobilitySecurityAssociation (1)
|
||||
#define IPMIP4_MIB_mipSecRecentViolationReason_badAuthenticator (2)
|
||||
#define IPMIP4_MIB_mipSecRecentViolationReason_badIdentifier (3)
|
||||
#define IPMIP4_MIB_mipSecRecentViolationReason_badSPI (4)
|
||||
#define IPMIP4_MIB_mipSecRecentViolationReason_missingSecurityExtension (5)
|
||||
#define IPMIP4_MIB_mipSecRecentViolationReason_other (6)
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
struct Ipmip4_mib_mipSystem
|
||||
{
|
||||
Ip_u32 mipEntities; /* BITS */
|
||||
Ip_s32 mipEnable;
|
||||
Ip_u32 mipEncapsulationSupported; /* BITS */
|
||||
};
|
||||
|
||||
struct Ipmip4_mib_mipSecAssocEntry
|
||||
{
|
||||
struct Ip_in_addr mipSecPeerAddress;
|
||||
Ip_u32 mipSecSPI;
|
||||
Ip_s32 mipSecAlgorithmType;
|
||||
Ip_s32 mipSecAlgorithmMode;
|
||||
Ip_u8 *mipSecKey;
|
||||
Ip_s32 mipSecReplayMethod;
|
||||
};
|
||||
|
||||
extern Ip_u32 mipSecTotalViolations;
|
||||
|
||||
struct Ipmip4_mib_mipSecViolationEntry
|
||||
{
|
||||
struct Ip_in_addr mipSecViolatorAddress;
|
||||
Ip_u32 mipSecViolationCounter;
|
||||
Ip_s32 mipSecRecentViolationSPI;
|
||||
Ip_u32 mipSecRecentViolationTime;
|
||||
Ip_s32 mipSecRecentViolationIDLow;
|
||||
Ip_s32 mipSecRecentViolationIDHigh;
|
||||
Ip_s32 mipSecRecentViolationReason;
|
||||
};
|
||||
|
||||
struct Ipmip4_mib_maAdvConfigEntry
|
||||
{
|
||||
struct Ip_in_addr maInterfaceAddress;
|
||||
Ip_s32 maAdvMaxRegLifetime;
|
||||
Ip_bool maAdvPrefixLengthInclusion;
|
||||
struct Ip_in_addr maAdvAddress;
|
||||
Ip_s32 maAdvMaxInterval;
|
||||
Ip_s32 maAdvMinInterval;
|
||||
Ip_s32 maAdvMaxAdvLifetime;
|
||||
Ip_bool maAdvResponseSolicitationOnly;
|
||||
Ip_s32 maAdvStatus;
|
||||
};
|
||||
|
||||
struct Ipmip4_mib_maAdvertisement
|
||||
{
|
||||
Ip_u32 maAdvertisementsSent;
|
||||
Ip_u32 maAdvsSentForSolicitation;
|
||||
Ip_u32 maSolicitationsReceived;
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,170 @@
|
||||
/* ipmip4_attr.h - ipmip4_attr.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_attr.h,v $ $Revision: 1.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/private/ipmip4_attr.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-12-07 09:55:10 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_ATTR_H
|
||||
#define IPMIP4_ATTR_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
MIP4 attribute functions required for mobile IPv4. Deals with retrieval
|
||||
and assignment of MIPv4 specific attributes.
|
||||
|
||||
EXAMPLE
|
||||
|
||||
A basic example of how the IPMIP4 attribute function can be used. See
|
||||
my_init_func in ipmip_cli.h for an example as to how to properly register
|
||||
ipmip4myattr_attr_command.
|
||||
|
||||
.CS
|
||||
|
||||
/@ Define some attributes that the node have @/
|
||||
|
||||
enum
|
||||
{
|
||||
IPMIP4MYATTR_CLI_LIST = IPMIP4_CLI_BASE,
|
||||
IPMIP4MYATTR_CLI_MAX
|
||||
};
|
||||
|
||||
|
||||
IP_GLOBAL int
|
||||
ipmip4myattr_attr_command(struct Ipmip4my_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip_cli_message *request)
|
||||
{
|
||||
struct Ipmip_attr_header *hdr = (struct Ipmip_attr_header *)IPMIP_BUFFER_DATA(&request->request);
|
||||
Ip_size_t rhdr;
|
||||
unsigned int si, f;
|
||||
|
||||
switch (IPMIP_ATTR_HDR_TYPE(hdr))
|
||||
{
|
||||
case IPMIP4MYATTR_CLI_LIST:
|
||||
/@ LIST ALL NODES @/
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
break;
|
||||
default:
|
||||
/@ We did not define this command, see if its a generic MIP4 command @/
|
||||
return ipmip4_attr_command(&data->ipmip4, proc, request);
|
||||
}
|
||||
|
||||
/@ Terminate the reply header @/
|
||||
ipmip_attr_hdr_finalize(&request->message, rhdr);
|
||||
|
||||
/@ Terminate the reply header @/
|
||||
ipmip_cli_message_commit(&data->ipmip4.ipmip, proc, request);
|
||||
return 0;
|
||||
}
|
||||
|
||||
.CE
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <private/ipmip_attr.h>
|
||||
#include <private/ipmip4_cli.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
struct Ipmip4_context;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip_cli_message;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_attr_command - ipmip4_attr_command
|
||||
*
|
||||
* Internal function to MIP4 entities
|
||||
* Process MIP4 specific attributes
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i request
|
||||
* Request header
|
||||
* \i request
|
||||
* Request header
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: Return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipmip4_attr_command
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip_cli_message *request
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,285 @@
|
||||
/* ipmip4_cli.h - ipmip4_cli.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_cli.h,v $ $Revision: 1.10 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/private/ipmip4_cli.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-12-07 09:55:10 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_CLI_H
|
||||
#define IPMIP4_CLI_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
MIP4 CLI functions required for mobile IPv4. Deals with Command Line Interface
|
||||
communication with MIPv4. Also implements inter-MIP4 communcation commands
|
||||
for Proxy Mobility. The Proxy Mobility entiteis (PMIPv4 and FAv4) bounces
|
||||
registration messages and information between each other.
|
||||
|
||||
The PMIP functions are considered INTERNAL for this release. Until the
|
||||
IPMIPFA and IPMIPPM modules receives more extensive communcation.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <private/ipmip_cli.h>
|
||||
#include <private/ipmip4_attr.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
enum
|
||||
{
|
||||
IPMIP4_CLI_START = 2048,
|
||||
/* Proxy Registration Request Transport Message */
|
||||
IPMIP4_CLI_PMIPV4_PRRQ,
|
||||
/* Proxy Mobile Client Trigger Registration Request Message */
|
||||
IPMIP4_CLI_PMIPV4_PTRQ,
|
||||
/* Proxy Local Trigger Message */
|
||||
IPMIP4_CLI_PMIPV4_PLT,
|
||||
/* Registration revocation message */
|
||||
IPMIP4_CLI_PMIPV4_PREVRQ,
|
||||
|
||||
IPMIP4_CLI_BASE = 4096
|
||||
};
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
IPMIP4_CLI_PMIPV4_ATTR_NONE = 0,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_MESSAGE,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_HANDLER,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_IFNAME,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_IFADDR,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_NFA_COA,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_OFA_COA,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_MN_NAI,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_LIFETIME,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_ACCESS_TYPE,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_PER_NODE_AUTH_METHOD,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_INTERFACE_ID,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_DEVICE_ID,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_DEVICE_ID_TYPE,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_SUBSCRIBER_ID,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_SUBSCRIBER_ID_TYPE,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_HOA,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_HA,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_MN_HA_SPI,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_MN_HA_SPI_SECRET,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_DHCP_RELAY_SERVER,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_TUNNEL_TYPE,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_TUNNEL_REVERSE,
|
||||
IPMIP4_CLI_PMIPV4_ATTR_MAX
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip_cli_daemon;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_cli_shell_cmd - ipmip4_cli_shell_cmd
|
||||
*
|
||||
* Process global CLI commands
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i argc
|
||||
* Number of arguments
|
||||
* \i argv
|
||||
* Arguments
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i daemon
|
||||
* Daemon connection
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: > 0 syntax error, 0 = success
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipmip4_cli_shell_cmd
|
||||
(
|
||||
int argc,
|
||||
char **argv,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip_cli_daemon *daemon
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_cli_shell_usage - ipmip4_cli_shell_usage
|
||||
*
|
||||
* Print usage informatin for MIP4 related commands
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_cli_shell_usage
|
||||
(
|
||||
struct Ipmip_proc *proc
|
||||
);
|
||||
|
||||
|
||||
/*** PMIP functions ***/
|
||||
|
||||
IP_GLOBAL int ipmip4_cli_shell_pmipv4_cmd
|
||||
(
|
||||
int argc,
|
||||
char **argv,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip_cli_daemon *daemon
|
||||
);
|
||||
|
||||
IP_GLOBAL void ipmip4_cli_shell_pmipv4_usage
|
||||
(
|
||||
struct Ipmip_proc *proc
|
||||
);
|
||||
|
||||
|
||||
IP_PUBLIC void ipmip4_cli_pmipv4_local_trigger_request_init
|
||||
(
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
const char *nai
|
||||
);
|
||||
|
||||
IP_PUBLIC void ipmip4_cli_pmipv4_request_set_nai
|
||||
(
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
const char *nai
|
||||
);
|
||||
|
||||
IP_PUBLIC void ipmip4_cli_request_set_ifname
|
||||
(
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
const char *ifname
|
||||
);
|
||||
|
||||
IP_PUBLIC void ipmip4_cli_pmipv4_request_set_home_address
|
||||
(
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 hoa
|
||||
);
|
||||
|
||||
IP_PUBLIC void ipmip4_cli_pmipv4_request_set_home_agent
|
||||
(
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 ha
|
||||
);
|
||||
|
||||
IP_PUBLIC void ipmip4_cli_pmipv4_request_set_ofa
|
||||
(
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 fa
|
||||
);
|
||||
|
||||
IP_PUBLIC void ipmip4_cli_pmipv4_request_set_nfa
|
||||
(
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 fa
|
||||
);
|
||||
|
||||
IP_PUBLIC void ipmip4_cli_pmipv4_request_set_mn_ha_spi
|
||||
(
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 spi
|
||||
);
|
||||
|
||||
IP_PUBLIC void ipmip4_cli_pmipv4_request_set_mn_ha_spi_secret
|
||||
(
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
const char *secret
|
||||
);
|
||||
|
||||
IP_PUBLIC void ipmip4_cli_pmipv4_request_set_dhcp_relay_server
|
||||
(
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 srv
|
||||
);
|
||||
|
||||
IP_PUBLIC void ipmip4_cli_pmipv4_request_set_tunnel_type
|
||||
(
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 tunnel_type
|
||||
);
|
||||
|
||||
IP_PUBLIC void ipmip4_cli_pmipv4_request_set_handler
|
||||
(
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
const char *handler
|
||||
);
|
||||
|
||||
IP_PUBLIC void ipmip4_cli_pmipv4_request_set_ifaddr
|
||||
(
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
const char *ifaddr
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,299 @@
|
||||
/* ipmip4_context.h - ipmip4_context.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_context.h,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/private/ipmip4_context.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-12-07 09:55:10 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_CONTEXT_H
|
||||
#define IPMIP4_CONTEXT_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* MIP4 context definitions. Deals with process creation, and context
|
||||
* instantiations.
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
MIP4 context definitions. Deals with process creation, and context
|
||||
instantiations. This module provides a superset to the MIP context
|
||||
definitions.Functions defined here will usually in turn invoke their
|
||||
IPMIP counterpart.
|
||||
|
||||
EXAMPLE
|
||||
|
||||
To create, initialize, start stop and destroy a context in MIP4.
|
||||
|
||||
.CS
|
||||
|
||||
/@ Just some sort of entity that one could have in a mobility systemm which
|
||||
requires a unique identifier @/
|
||||
struct Ipmip4_my_entities
|
||||
{
|
||||
struct Ipmip_my_entities ipmip;
|
||||
|
||||
int my_personal_data;
|
||||
};
|
||||
|
||||
struct Ipmip4_my_context
|
||||
{
|
||||
Ipmip4_context_t ipmip; /@ Basic IPMIP context @/
|
||||
|
||||
int my_personal_data;
|
||||
Ipmip4_pkt_udp_register_t udpr;
|
||||
};
|
||||
|
||||
|
||||
struct Ipmip4_my_context *my_init_func4(Ipmip_proc_t *proc)
|
||||
{
|
||||
/@ Allocate my context; indicate the size of my overloaded structure @/
|
||||
struct Ipmip4_my_context *ctx = (struct Ipmip4_my_context *)ipmip_context_alloc(proc, sizeof(*ctx), "mymip4", IPCOM_LOG_DEBUG2, 10);
|
||||
|
||||
/@ Initialize the MIP4 portion of the context @/
|
||||
ipmip4_context_init(&ctx->ipmip4, proc);
|
||||
|
||||
/@ YOU NEED TO ADD MIP SPECIFC INITIALIZATION CODE HERE AS WELL
|
||||
AS DEFINED IN ipmip_context.h/ipmip_cli.h/ipmip_pktbuf.h @/
|
||||
|
||||
/@ Start the context @/
|
||||
ipmip4_context_start(&ctx->ipmip4, proc);
|
||||
}
|
||||
|
||||
void my_stop_func4(Ipmip_proc_t *proc, struct Ipmip4_my_context *ctx)
|
||||
{
|
||||
|
||||
/@ Stop the context @/
|
||||
ipmip4_context_stop(&ctx->ipmip4, proc);
|
||||
|
||||
/@ Destroy the context @/
|
||||
ipmip4_context_destroy(&ctx->ipmip4, proc);
|
||||
}
|
||||
|
||||
void main(int argc, char *argv[])
|
||||
{
|
||||
/@ For threads started with ipmip_proc_start, the proc structure is allocated
|
||||
automatically, for other types of threads such as main, we need to
|
||||
allocate it manually @/
|
||||
Ipmip_proc_t *proc = ipmip_proc_alloc();
|
||||
struct Ipmip4_my_context *ctx = my_init_func4(proc);
|
||||
|
||||
/@ Stop the context @/
|
||||
my_stop_func4(proc, ctx);
|
||||
|
||||
/@ Destroy the process context - If ipmip_proc_stop is used, @/
|
||||
ipmip_proc_destroy(proc);
|
||||
}
|
||||
|
||||
.CE
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <private/ipmip_context.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip4_pktbuf_context;
|
||||
|
||||
typedef struct Ipmip4_context
|
||||
{
|
||||
Ipmip_context_t ipmip;
|
||||
|
||||
Ipcom_list *vendor_extensions;
|
||||
|
||||
struct Ipmip4_pkt_context *pkt;
|
||||
} Ipmip4_context_t;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_context_destroy - ipmip4_context_destroy
|
||||
*
|
||||
* Destroy the IPMIP4 context. Will destroy all resources associated with the
|
||||
* MIP4 entity, and also invoke the IPMIP ipmip_context_destroy routine
|
||||
* to destroy resources allocated by the base IPMIP system.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_context_destroy
|
||||
(
|
||||
Ipmip4_context_t *ctx,
|
||||
Ipmip_proc_t *proc
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_context_stop - ipmip4_context_stop
|
||||
*
|
||||
* Stop the MIP4 context. Will also invoke ipmip_context_stop in order to
|
||||
* stop all functions and resources currently active in the base IPMIP system.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_context_stop
|
||||
(
|
||||
Ipmip4_context_t *ctx,
|
||||
Ipmip_proc_t *proc
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_context_start - ipmip4_context_start
|
||||
*
|
||||
* Start the MIP4 context. Will also invoke ipmip_context_start in order to
|
||||
* activate the functionalities in the base IPMIP system.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_context_start
|
||||
(
|
||||
Ipmip4_context_t *ctx,
|
||||
Ipmip_proc_t *proc
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_context_init - ipmip4_context_init
|
||||
*
|
||||
* One time initialization functions that will initialize the IPMIP4 portion
|
||||
* of the context.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_context_init
|
||||
(
|
||||
Ipmip4_context_t *ctx,
|
||||
Ipmip_proc_t *proc
|
||||
);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,442 @@
|
||||
/* ipmip4_diameter.h - ipmip4_diameter.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_diameter.h,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/private/ipmip4_diameter.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-12-07 09:55:10 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_DIAMETER_H
|
||||
#define IPMIP4_DIAMETER_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Implements the MIP4 wrapper for RFC4004 and IPDIAMETER
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
Implements the MIP4 wrapper for RFC4004 and IPDIAMETER. This file
|
||||
is used internally by the foreign agent and home agent.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIP4_DIAMETER_FEATURE_MN_HOA_REQ (1 << 0)
|
||||
#define IPMIP4_DIAMETER_FEATURE_HOA_IN_HOME_REALM (1 << 1)
|
||||
#define IPMIP4_DIAMETER_FEATURE_HA_REQ (1 << 2)
|
||||
#define IPMIP4_DIAMETER_FEATURE_FOREIGN_HA_AVAIL (1 << 3)
|
||||
#define IPMIP4_DIAMETER_FEATURE_MN_HA_KEYREQ (1 << 4)
|
||||
#define IPMIP4_DIAMETER_FEATURE_MN_FA_KEYREQ (1 << 5)
|
||||
#define IPMIP4_DIAMETER_FEATURE_FA_HA_KEYREQ (1 << 6)
|
||||
#define IPMIP4_DIAMETER_FEATURE_HA_IN_FOREIGN_NET (1 << 7)
|
||||
#define IPMIP4_DIAMETER_FEATURE_CO_LOCATED_MN (1 << 8)
|
||||
|
||||
#define IPMIP4_DIAMETER_ACCESS_REQUEST_SUCCESS (0)
|
||||
#define IPMIP4_DIAMETER_ACCESS_REQUEST_FAILURE (1)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip4_context;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip4_diameter_context;
|
||||
struct Ipdiameter_header_struct;
|
||||
struct Ipdiameter_request_struct;
|
||||
struct Ipmip_cli_message;
|
||||
|
||||
typedef void (*Ipmip4_diameter_func_t) (int result,
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_diameter_context *diameter,
|
||||
struct Ipmip4_pktbuf *pbuf,
|
||||
void *arg,
|
||||
struct Ipdiameter_request_struct *req,
|
||||
struct Ipdiameter_header_struct *request,
|
||||
struct Ipdiameter_header_struct *reply);
|
||||
|
||||
/* Callback function for a received HAR request */
|
||||
typedef void (*Ipmip4_diameter_HAR_recv_t) (struct Ipmip4_context *ctx,
|
||||
void *req,
|
||||
void *peer);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_diameter_context_create - ipmip4_diameter_context_create
|
||||
*
|
||||
* Create a diameter context if so specified by the configuration
|
||||
* parameters
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i defbase
|
||||
* Default value sysvar path
|
||||
* \i format
|
||||
* Base configuration path
|
||||
* \i ...
|
||||
* Additional format variables
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: A radius context if properly configured and enabled
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL struct Ipmip4_diameter_context * ipmip4_diameter_context_create
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
const char *defbase,
|
||||
const char *format,
|
||||
...
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_diameter_context_dump - ipmip4_diameter_context_dump
|
||||
*
|
||||
* Dump the configuration parameters of the context
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i diameter
|
||||
* Diameter context
|
||||
* \i request
|
||||
* CLI request to dump information to.
|
||||
* \i format
|
||||
* Base configuration path
|
||||
* \i ...
|
||||
* Additional format variables
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: A radius context if properly configured and enabled
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_diameter_context_dump
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_diameter_context *diameter,
|
||||
struct Ipmip_cli_message *request,
|
||||
const char *format,
|
||||
...
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_diameter_context_destroy - ipmip4_diameter_context_destroy
|
||||
*
|
||||
* Stop and destroy a radius context
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i diameter
|
||||
* Diameter context.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_diameter_context_destroy
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_diameter_context *diameter
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_diameter_access_request - ipmip4_diameter_access_request
|
||||
*
|
||||
* Do an ordinary access request; no challenge provided
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i diameter
|
||||
* Radius context
|
||||
* \i func
|
||||
* Diameter callback function
|
||||
* \i pbuf
|
||||
* Current transaction
|
||||
* \i arg
|
||||
* Opaque argument
|
||||
* \i request
|
||||
* Diameter request structure
|
||||
* \i packet
|
||||
* Diameter packet header
|
||||
* \i auth_type
|
||||
* Type of authentication
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on successful request transmission.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip4_diameter_access_request
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_diameter_context *diameter,
|
||||
Ipmip4_diameter_func_t func,
|
||||
Ipmip4_pktbuf_t *pbuf,
|
||||
void *arg,
|
||||
struct Ipdiameter_request_struct *request,
|
||||
struct Ipdiameter_header_struct *packet,
|
||||
int auth_type
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_diameter_request_alloc - ipmip4_diameter_request_alloc
|
||||
*
|
||||
* Initialize and allocate data required for an access request.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i diameter
|
||||
* Diameter context
|
||||
* \i request
|
||||
* Diameter request
|
||||
* \i packet
|
||||
* [OUT] Allocated Diameter packet header.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on successful init.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip4_diameter_request_alloc
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_diameter_context *diameter,
|
||||
struct Ipdiameter_request_struct *request,
|
||||
struct Ipdiameter_header_struct **packet
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_diameter_answer_alloc - ipmip4_diameter_answer_alloc
|
||||
*
|
||||
* Initialize and allocate data required for an access answer
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i diameter
|
||||
* Diameter context
|
||||
* \i sid
|
||||
* Session ID
|
||||
* \i sid_size
|
||||
* Size of session ID.
|
||||
* \i hbh
|
||||
* HBH
|
||||
* \i e2e
|
||||
* E2E
|
||||
* \i packet
|
||||
* [OUT] Allocated Diameter packet header.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on successful init.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip4_diameter_answer_alloc
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_diameter_context *diameter,
|
||||
void *sid,
|
||||
Ip_size_t sid_size,
|
||||
Ip_u32 hbh,
|
||||
Ip_u32 e2e,
|
||||
struct Ipdiameter_header_struct **packet
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_diameter_HAR_callback - ipmip4_diameter_HAR_callback
|
||||
*
|
||||
* Register the HAR callback function.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i func
|
||||
* The HAR callback function that will be invoked when
|
||||
*
|
||||
* a HAR is received by IPDIAMETER.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_diameter_HAR_callback
|
||||
(
|
||||
void *ctx,
|
||||
Ipmip4_diameter_HAR_recv_t func
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_diameter_proc - ipmip4_diameter_proc
|
||||
*
|
||||
* Retrieve the DIAMETER process block
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i diameter
|
||||
* context
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The process block
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip_proc_t * ipmip4_diameter_proc
|
||||
(
|
||||
struct Ipmip4_diameter_context *diameter
|
||||
);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,349 @@
|
||||
/* ipmip4_if.h - ipmip4_if.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_if.h,v $ $Revision: 1.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/private/ipmip4_if.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-12-07 09:55:10 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_IF_H
|
||||
#define IPMIP4_IF_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Basic interface management required for MIP4. Provides functions to
|
||||
* instantiate interfaces information containers, resolve LLA identifiers
|
||||
* and create and destroy tunnel interfaces
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
Basic interface management required for MIP4. Provides functions to
|
||||
instantiate interfaces information containers, resolve LLA identifiers
|
||||
and create and destroy tunnel interfaces
|
||||
|
||||
EXAMPLE
|
||||
|
||||
Examples how to create MIP4 enabled interfaces.
|
||||
|
||||
.CS
|
||||
|
||||
typedef struct Ipmip4_if_mine
|
||||
{
|
||||
Ipmip4_if_t iff;
|
||||
|
||||
/@ Any data I need to store in this interface structure @/
|
||||
ine my_private_data;
|
||||
} Ipmip4_if_mine_t;
|
||||
|
||||
IP_STATIC void
|
||||
ipmip4_my_if_delete(struct Ipmip4_my_context *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip4_if_mine_t *myif)
|
||||
{
|
||||
/@ Free any data that I have allocated @/
|
||||
}
|
||||
|
||||
Ipmip4_if_mine_t *my_if_alloc4(struct Ipmip4_my_context *ctx, Ipmip_proc_t *proc, const char *ifname)
|
||||
{
|
||||
Ipmip4_if_mine_t *myif;
|
||||
Ip_u32 ifindex;
|
||||
|
||||
ifindex = ipcom_if_nametoindex(ifname);
|
||||
|
||||
/@ Does it exist? @/
|
||||
if (ifindex == 0)
|
||||
return IP_NULL;
|
||||
|
||||
|
||||
myif = (Ipmip4_if_mine_t *)ipmip4_if_alloc(&ctx->ipmip4,
|
||||
proc,
|
||||
sizeof(*myif),
|
||||
ifname,
|
||||
ifindex,
|
||||
IPMIP_IF_TYPE_GENERIC,
|
||||
0,
|
||||
(Ipmip_if_cleanup_t )ipmip4_my_if_delete);
|
||||
|
||||
return myif;
|
||||
}
|
||||
|
||||
|
||||
.CE
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <private/ipmip_pktbuf.h>
|
||||
#include <private/ipmip_if.h>
|
||||
#include <private/ipmip4_lla.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip4_context;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip4_if;
|
||||
typedef struct Ipmip4_if
|
||||
{
|
||||
Ipmip_if_t ipmip;
|
||||
|
||||
Ipcom_list pktbufs;
|
||||
Ip_u32 ifaddr;
|
||||
|
||||
/* Cleanup function */
|
||||
Ipmip_if_cleanup_t cleanup;
|
||||
} Ipmip4_if_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_if_alloc - ipmip4_if_alloc
|
||||
*
|
||||
* Allocate and initialize the interface structure
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i ifsize
|
||||
* the size of the interface structure
|
||||
* \i ifname
|
||||
* The interface name
|
||||
* \i ifindex
|
||||
* The interface index.
|
||||
* \i type
|
||||
* Type of interface
|
||||
* \i identity
|
||||
* The interface identity.
|
||||
* \i cleanup
|
||||
* Function to be invoked prior to free.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The interface structure on success.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_if_t * ipmip4_if_alloc
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_size_t ifsize,
|
||||
const char *ifname,
|
||||
Ip_u32 ifindex,
|
||||
Ip_u8 type,
|
||||
Ip_u8 identity,
|
||||
Ipmip_if_cleanup_t cleanup
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_if_alloc_tunnel - ipmip4_if_alloc_tunnel
|
||||
*
|
||||
* Create a specific tunnel for the provided interface
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i ifsize
|
||||
* Total size of the interface structure
|
||||
* \i ifname
|
||||
* Wanted ifname
|
||||
* \i local
|
||||
* The local endpoint
|
||||
* \i local_port
|
||||
* Base port for NAT_T setup
|
||||
* \i remote
|
||||
* Remote endpoint
|
||||
* \i identity
|
||||
* The identity of the tunnel
|
||||
* \i tunnel_type
|
||||
* Tunnel type
|
||||
* \i reorder
|
||||
* Enable reordering if supported by interface
|
||||
* \i cleanup
|
||||
* Function to be invoked prior to free.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The interface structure on success.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_if_t * ipmip4_if_alloc_tunnel
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_size_t ifsize,
|
||||
char *ifname,
|
||||
Ip_u32 local,
|
||||
Ip_u16 local_port,
|
||||
Ip_u32 remote,
|
||||
Ip_u8 identity,
|
||||
Ip_u8 tunnel_type,
|
||||
Ip_bool reorder,
|
||||
Ipmip_if_cleanup_t cleanup
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_if_get_primary_address - ipmip4_if_get_primary_address
|
||||
*
|
||||
* Get the current primary address of the interface.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i iff
|
||||
* The interface
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: address on success; IP_INADDR_NONE on failure.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_u32 ipmip4_if_get_primary_address
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip4_if_t *iff
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_if_findbyaddr - ipmip4_if_findbyaddr
|
||||
*
|
||||
* Locate an interface in our configuration based on address.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i iflist
|
||||
* The list of interfaces.
|
||||
* \i addr
|
||||
* The interface address
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The interface pointer if it exists, IP_NULL otherwise.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_if_t * ipmip4_if_findbyaddr
|
||||
(
|
||||
Ipcom_list *iflist,
|
||||
Ip_u32 addr
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_if_findbypktinfo - ipmip4_if_findbypktinfo
|
||||
*
|
||||
* Locate an interface in our configuration based on address.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i iflist
|
||||
* The list of interfaces
|
||||
* \i pktinfo
|
||||
* The interface info
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The interface pointer if it exists, IP_NULL otherwise.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_if_t * ipmip4_if_findbypktinfo
|
||||
(
|
||||
Ipcom_list *iflist,
|
||||
Ipmip_pktbuf_pktinfo_t *pktinfo
|
||||
);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,80 @@
|
||||
/* ipmip4_ipnet.h - ipmip4_ipnet.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_ipnet.h,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/private/ipmip4_ipnet.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-10-21 12:21:20 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_IPNET_H
|
||||
#define IPMIP4_IPNET_H
|
||||
|
||||
#if defined(IPNET)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* IPNET ioctl wrapper
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
IPNET ioctl wrapper. NO LONGER USED.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_sock.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,441 @@
|
||||
/* ipmip4_lla.h - ipmip4_lla.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_lla.h,v $ $Revision: 1.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/private/ipmip4_lla.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-12-07 09:55:10 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_LLA_H
|
||||
#define IPMIP4_LLA_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Utility class that provides functions to create, interpret and modify
|
||||
* LLA identifiers.
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
Utility class that provides functions to create, interpret and modify
|
||||
LLA identifiers. LLA identifiers are a MIP4 specific hardware definition
|
||||
used by low-latency handovers. They are not commonly used by the MIP4
|
||||
entities, unless they are to be added or parsed from a MIP4 registration
|
||||
request/reply. In all internal state and processing the LLADDR definitions
|
||||
provided by ipmip_lladdr.h are used, which are a superset of the LLA. That is,
|
||||
a LLA can be converted to a LLADDR without loss of information, but the
|
||||
reverse is not necessarily true.
|
||||
|
||||
These functions are mostly internal and used for specific events defined
|
||||
by low latency handoffs and proxy mobility registrations.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <private/ipmip_lladdr.h>
|
||||
|
||||
#include <private/ipmip4_msgext.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIP4_ICMP_LLA_EXT_SUBTYPE_3GPP2_MOBILE_STATION 1 /* 3GPP2 Mobile Station ID: n byte identifier */
|
||||
#define IPMIP4_ICMP_LLA_EXT_SUBTYPE_3GPP_MOBILE_SUBSCRIBER 2 /* 3GPP Mobile Subscriber Id: n byte identifier */
|
||||
#define IPMIP4_ICMP_LLA_EXT_SUBTYPE_MAC 3 /* Ethernet 48 bit MAC address: 6 byte identifier */
|
||||
#define IPMIP4_ICMP_LLA_EXT_SUBTYPE_EUID64 4 /* EUID64 address: 8 byte identifier */
|
||||
#define IPMIP4_ICMP_LLA_EXT_SUBTYPE_SOLICITED_ADDRESS 5 /* Solicited IPv4 Address: 4 byte identifier */
|
||||
#define IPMIP4_ICMP_LLA_EXT_SUBTYPE_ACCESS_POINT 6 /* Access Point Identifier: 4 byte identifier */
|
||||
#define IPMIP4_ICMP_LLA_EXT_SUBTYPE_FA_ADDRESS 7 /* FA IPv4 Address: 4 byte identifier */
|
||||
|
||||
/* Calculate the required memory allocation depending
|
||||
* on the size of the link layer address/identifier */
|
||||
#define IPMIP4_ICMP_LLA_EXT_SIZE(llsize) ((sizeof(Ipmip4_icmp_lla_ext_t) + (llsize) - 1))
|
||||
/* The value of the 'length' field */
|
||||
#define IPMIP4_ICMP_LLA_EXT_LENGTH(llsize) ((llsize) + 1)
|
||||
/* The total size required to make a copy of an LLA */
|
||||
#define IPMIP4_ICMP_LLA_EXT_TOTAL_SIZE(lla) ((lla)->length + 2)
|
||||
/* The LLA size of an LLA */
|
||||
#define IPMIP4_ICMP_LLA_EXT_LLA_SIZE(lla) ((lla)->length - 1)
|
||||
|
||||
/* PMIPv4 definition and types */
|
||||
#define IPMIP4_LLA_PMIPV4_ACCESS_TECHNOLOGY_802_3 1
|
||||
#define IPMIP4_LLA_PMIPV4_ACCESS_TECHNOLOGY_802_11ABG 2
|
||||
#define IPMIP4_LLA_PMIPV4_ACCESS_TECHNOLOGY_802_16E 3
|
||||
#define IPMIP4_LLA_PMIPV4_ACCESS_TECHNOLOGY_802_16M 4
|
||||
#define IPMIP4_LLA_PMIPV4_ACCESS_TECHNOLOGY_3GPP_EUTRAN_LTE 5
|
||||
#define IPMIP4_LLA_PMIPV4_ACCESS_TECHNOLOGY_3GPP_UTRAN_GERAN 6
|
||||
#define IPMIP4_LLA_PMIPV4_ACCESS_TECHNOLOGY_3GPP2_1XRTT_HRPD 7
|
||||
#define IPMIP4_LLA_PMIPV4_ACCESS_TECHNOLOGY_3GPP2_UMB 8
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip4_msgext_array;
|
||||
union Ipmip4_msgext_uhdr;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_lla_llh_find_array_subtype - ipmip4_lla_llh_find_array_subtype
|
||||
*
|
||||
* Return a usable source LLA address based on found
|
||||
* extensions and a subtype
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i subtype
|
||||
* The specific subtype
|
||||
* \i ext
|
||||
* The found LLA extensions.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The LLA address if it found; IP_NULL Otherwise.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_icmp_lla_ext_t * ipmip4_lla_llh_find_array_subtype
|
||||
(
|
||||
Ip_u8 subtype,
|
||||
struct Ipmip4_msgext_array *ext
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_lla_llh_convert_array_to_lladdr - ipmip4_lla_llh_convert_array_to_lladdr
|
||||
*
|
||||
* Return a dynamically allocated source LLADDR address based on found
|
||||
* extensions and a subtype
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i lladdr
|
||||
* The LLADDR of the receiving interface
|
||||
* \i ext
|
||||
* The found LLA extensions.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The LLADDR address if it found; IP_NULL Otherwise.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip_lladdr_t * ipmip4_lla_llh_convert_array_to_lladdr
|
||||
(
|
||||
Ipmip_lladdr_t *lladdr,
|
||||
struct Ipmip4_msgext_array *ext
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_lla_llh_convert_lla_to_lladdr - ipmip4_lla_llh_convert_lla_to_lladdr
|
||||
*
|
||||
* Return a dynamically allocated source LLADDR address based on found
|
||||
* extensions and a subtype
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i lladdr
|
||||
* The LLADDR of the receiving interface
|
||||
* \i lla
|
||||
* The found LLA extension
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The LLADDR address if it found; IP_NULL Otherwise.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip_lladdr_t *ipmip4_lla_llh_convert_lla_to_lladdr
|
||||
(
|
||||
Ipmip_lladdr_t *lladdr,
|
||||
Ipmip4_icmp_lla_ext_t *lla
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_lla_llh_lladdr_buffer_icmp_append - ipmip4_lla_llh_lladdr_buffer_icmp_append
|
||||
*
|
||||
* Append an LLA to a buffer in ICMP mode
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i buf
|
||||
* A pointer to an initialized dynamic mobility buffer. See ipmip_buffer.h
|
||||
* for more information regarding dynamic buffers and their capabilities.
|
||||
* \i lla
|
||||
* The LLA
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The offset
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipmip4_lla_llh_lladdr_buffer_icmp_append
|
||||
(
|
||||
Ipmip_buffer_t *buf,
|
||||
Ipmip_lladdr_t *lladdr
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_lla_llh_lladdr_buffer_udp_append - ipmip4_lla_llh_lladdr_buffer_udp_append
|
||||
*
|
||||
* Append an LLA to a buffer in UDP mode
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i buf
|
||||
* A pointer to an initialized dynamic mobility buffer. See ipmip_buffer.h
|
||||
* for more information regarding dynamic buffers and their capabilities.
|
||||
* \i lla
|
||||
* The LLA
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The offset
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipmip4_lla_llh_lladdr_buffer_udp_append
|
||||
(
|
||||
Ipmip_buffer_t *buf,
|
||||
Ipmip_lladdr_t *lladdr
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_lla_pmipv4_lladdr_buffer_access_type_append - ipmip4_lla_pmipv4_lladdr_buffer_access_type_append
|
||||
*
|
||||
* Append an PMIPv4 Access Type option to a buffer based on the LLADDR
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i buf
|
||||
* A pointer to an initialized dynamic mobility buffer. See ipmip_buffer.h
|
||||
* for more information regarding dynamic buffers and their capabilities.
|
||||
* \i lladdr
|
||||
* The LLADDR
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_lla_pmipv4_lladdr_buffer_access_type_append
|
||||
(
|
||||
Ipmip_buffer_t *buf,
|
||||
Ipmip_lladdr_t *lladdr
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_lla_pmipv4_lladdr_buffer_interface_id_append - ipmip4_lla_pmipv4_lladdr_buffer_interface_id_append
|
||||
*
|
||||
* Append an PMIPv4 Interface ID option to a buffer based on the LLADDR
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i buf
|
||||
* A pointer to an initialized dynamic mobility buffer. See ipmip_buffer.h
|
||||
* for more information regarding dynamic buffers and their capabilities.
|
||||
* \i lladdr
|
||||
* The LLADDR
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_lla_pmipv4_lladdr_buffer_interface_id_append
|
||||
(
|
||||
Ipmip_buffer_t *buf,
|
||||
Ipmip_lladdr_t *lladdr
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_lla_pmipv4_lladdr_buffer_device_id_append - ipmip4_lla_pmipv4_lladdr_buffer_device_id_append
|
||||
*
|
||||
* Append an PMIPv4 Device ID option to a buffer based on the LLADDR
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i buf
|
||||
* A pointer to an initialized dynamic mobility buffer. See ipmip_buffer.h
|
||||
* for more information regarding dynamic buffers and their capabilities.
|
||||
* \i lladdr
|
||||
* The LLADDR
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_lla_pmipv4_lladdr_buffer_device_id_append
|
||||
(
|
||||
Ipmip_buffer_t *buf,
|
||||
Ipmip_lladdr_t *lladdr
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_lla_pmipv4_interface_id_convert_to_lladdr - ipmip4_lla_pmipv4_interface_id_convert_to_lladdr
|
||||
*
|
||||
* Convert a PMIPv4 interface identifier to a LLADDR type. The lladdr provided to
|
||||
* the function MUST be the corresponding interface's own LLADDR, which will be used
|
||||
* as hint when converting. The interface id does not contain any information regarding
|
||||
* interface type, since it is implicitly known by the MIP agent due to its knowledge
|
||||
* regarding serving interface.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i lladdr
|
||||
* The serving interface's link local address
|
||||
* \i ifid
|
||||
* The interface identifier
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: A newly allocated LLADDR containing the appropriate values.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip_lladdr_t *ipmip4_lla_pmipv4_interface_id_convert_to_lladdr
|
||||
(
|
||||
Ipmip_lladdr_t *lladdr,
|
||||
union Ipmip4_msgext_uhdr *ifid
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_lla_pmipv4_device_id_convert_to_lladdr - ipmip4_lla_pmipv4_device_id_convert_to_lladdr
|
||||
*
|
||||
* Convert a PMIPv4 device identifier to a LLADDR type. The lladdr provided to
|
||||
* the function MUST be the corresponding interface's own LLADDR, which will be used
|
||||
* as hint when converting. The device id does not contain any information regarding
|
||||
* interface type, since it is implicitly known by the MIP agent due to its knowledge
|
||||
* regarding serving interface.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i lladdr
|
||||
* The serving interface's link local address
|
||||
* \i ifid
|
||||
* The interface identifier
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: A newly allocated LLADDR containing the appropriate values.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip_lladdr_t *ipmip4_lla_pmipv4_device_id_convert_to_lladdr
|
||||
(
|
||||
Ipmip_lladdr_t *lladdr,
|
||||
union Ipmip4_msgext_uhdr *ifid
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_lla_pmipv4_access_type_from_lladdr_types - ipmip4_lla_pmipv4_access_type_from_lladdr_types
|
||||
*
|
||||
* Convert a LLADDR type and subtype to the corresponding access type
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i type
|
||||
* The interface major type
|
||||
* \i subtype
|
||||
* The interface minor type
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The access type corresponding to the interface values.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_u8 ipmip4_lla_pmipv4_access_type_from_lladdr_types
|
||||
(
|
||||
Ip_u8 type,
|
||||
Ip_u8 subtype
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_lla_pmipv4_device_id_type_from_lladdr_types - ipmip4_lla_pmipv4_device_id_type_from_lladdr_types
|
||||
*
|
||||
* Convert a LLADDR type and subtype to the corresponding device id type
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i type
|
||||
* The interface major type
|
||||
* \i subtype
|
||||
* The interface minor type
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The device id type corresponding to the interface values.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_u8 ipmip4_lla_pmipv4_device_id_type_from_lladdr_types
|
||||
(
|
||||
Ip_u8 type,
|
||||
Ip_u8 subtype
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,350 @@
|
||||
/* ipmip4_netlink.h - ipmip4_netlink.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_netlink.h,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/private/ipmip4_netlink.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-12-16 12:19:21 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_NETLINK_H
|
||||
#define IPMIP4_NETLINK_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
MIP4 NETLINK functions for mobile IPv4. Deals with MIP4 netlink specific
|
||||
commands and routes. The MIP4 methods mostly deals with registering
|
||||
entities in the kernel for more advanced GRE and statistics management
|
||||
than is usually provided by the base IPNET functionality.
|
||||
|
||||
EXAMPLE
|
||||
|
||||
This example illustrates how one can register a MIP handle in the kernel,
|
||||
and retrieve statistics.
|
||||
|
||||
.CS
|
||||
|
||||
IP_GLOBAL void
|
||||
my_handle_function(struct Ipmip4my_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip_my_entities *node)
|
||||
{
|
||||
Ipmip4_netlink_kern_statistics_t link_recv, link_send;
|
||||
Ipmip_netlink_kern_handle_t handle;
|
||||
|
||||
/@ Register this nodes handle in the kernel @/
|
||||
ipmip4_netlink_new_handle(&ctx->ipmip4, proc, IPCOM_IPD_ID_IPMYMIP, node->identity);
|
||||
|
||||
/@ Setup a userspace integrated handle @/
|
||||
handle.mip_facility = IPCOM_IPD_ID_IPMIPMYMIP;
|
||||
handle.mip_ident = node->identity;
|
||||
|
||||
/@ Retrieve current non-polled statistics from the kernel @/
|
||||
if (ipmip4_netlink_get_handle_stat(&ctx->ipmip4, proc, &handle, &link_recv, &link_send))
|
||||
{
|
||||
/@ Store the retrieved statistics @/
|
||||
}
|
||||
|
||||
/@ Register this nodes handle in the kernel @/
|
||||
ipmip4_netlink_del_handle(&ctx->ipmip4, proc, IPCOM_IPD_ID_IPMYMIP, node->identity);
|
||||
}
|
||||
|
||||
.CE
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_netlink.h>
|
||||
|
||||
#include <private/ipmip_netlink.h>
|
||||
#include <private/ipmip4_netlink_kern.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
union Ipmip4_msgext_uhdr;
|
||||
|
||||
struct Ipmip4_context;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip_netlink_kern_handle;
|
||||
struct Ipmip4_netlink_kern_statistics;
|
||||
struct Ipmip_netlink_kern_compare;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_netlink_get_handle_stat - ipmip4_netlink_get_handle_stat
|
||||
*
|
||||
* Retrieve the statistics associated with a handle. The statistics retrieved
|
||||
* is the currently non-polled statistics present in the kernel. This function
|
||||
* will reset the kernel structures. That is, for each invocation of this
|
||||
* method you will retrieve the statistics collected with start from the
|
||||
* previous invocation.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i handle
|
||||
* The MIP handle
|
||||
* \i link_recv
|
||||
* Container to populate with RECEIVE statistics
|
||||
* \i link_send
|
||||
* Container to populate with SEND statistics
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on success
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip4_netlink_get_handle_stat
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip_netlink_kern_handle *handle,
|
||||
struct Ipmip4_netlink_kern_statistics *link_recv,
|
||||
struct Ipmip4_netlink_kern_statistics *link_send
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_netlink_del_handle - ipmip4_netlink_del_handle
|
||||
*
|
||||
* Delete a MIP handle previously registered using ipmip4_netlink_new_handle.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i facility
|
||||
* The MIP facility. One of the IPCOM_IPD_ID_IPMIPXX product definitions.
|
||||
* \i identity
|
||||
* The unique identity parameter.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: 0 on success
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipmip4_netlink_del_handle
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_u32 facility,
|
||||
Ip_u32 identity
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_netlink_new_handle - ipmip4_netlink_new_handle
|
||||
*
|
||||
* Create a MIP handle.The facility/identity combination must be unique,
|
||||
* or this method will fail with an EEXIST errno.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i facility
|
||||
* The MIP facility. One of the IPCOM_IPD_ID_IPMIPXX product definitions.
|
||||
* \i identity
|
||||
* The unique identity parameter.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: 0 on success
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipmip4_netlink_new_handle
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_u32 facility,
|
||||
Ip_u32 identity
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_netlink_address_do - ipmip4_netlink_address_do
|
||||
*
|
||||
* Perform MIP4 specific address management. For example MIP exclusions,
|
||||
* home address activation/deactivation etc.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i cmd
|
||||
* The NETLINK command
|
||||
* \i type
|
||||
* The MIP sub command
|
||||
* \i flags
|
||||
* Command flags
|
||||
* \i ifindex
|
||||
* Interface index specifying the interface.
|
||||
* \i family
|
||||
* AF_INET or AF_INET6
|
||||
* \i addr
|
||||
* Address buffer
|
||||
* \i reply
|
||||
* Optional reply buffer.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: 0 on success
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipmip4_netlink_address_do
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int cmd,
|
||||
Ip_u16 type,
|
||||
Ip_u8 flags,
|
||||
Ip_u32 ifindex,
|
||||
Ip_u8 family,
|
||||
const void *addr,
|
||||
Ipmip_buffer_t *reply
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_netlink_route_validate - ipmip4_netlink_route_validate
|
||||
*
|
||||
* Validate a particular route.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i cmd
|
||||
* \i ifindex
|
||||
* Interface index specifying the interface.
|
||||
* \i addr
|
||||
* The address to verify routing for.
|
||||
* \i reply
|
||||
* Optional reply buffer.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: 0 on success
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipmip4_netlink_route_validate
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_u32 ifindex,
|
||||
Ip_u32 addr,
|
||||
Ipmip_buffer_t *reply
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,177 @@
|
||||
/* ipmip4_netlink_kern.h - ipmip4_netlink_kern.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_netlink_kern.h,v $ $Revision: 1.4.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/private/ipmip4_netlink_kern.h,v $
|
||||
* $Author: svc-cmnet $ $Date: 2013-03-13 07:45:31 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_NETLINK_KERN_H
|
||||
#define IPMIP4_NETLINK_KERN_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
MIP4 NETLINK KERNEL defines and attributes. Defines structures and attributes
|
||||
that are used when communicating with the MIPv4 netlink kernel implementation.
|
||||
The MIPv4 Kernel implementation integrates with IPNET flow and routing
|
||||
management in order to provide MIPv4 functionality and forwarding.
|
||||
|
||||
The definitions in this file are used by the support functions defined in
|
||||
ipmip4_netlink.h.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <private/ipmip_netlink_kern.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ipmip4_netlink_kern_statistics
|
||||
{
|
||||
Ip_u32 mip_s_octets;
|
||||
Ip_u32 mip_s_pkts;
|
||||
Ip_u32 mip_s_stamp_sec;
|
||||
Ip_u32 mip_s_stamp_msec;
|
||||
} Ipmip4_netlink_kern_statistics_t;
|
||||
|
||||
|
||||
#define IP_WRMOB4_NEW_TYPE_SILENT (1 << 0)
|
||||
#define IP_WRMOB4_NEW_TYPE_TEMPORARY (1 << 1)
|
||||
|
||||
enum Ip_wrmob4_deltype_t
|
||||
{
|
||||
IP_WRMOB4_DEL_UNSPEC,
|
||||
IP_WRMOB4_DEL_LINK_TX,
|
||||
IP_WRMOB4_DEL_LINK_RX,
|
||||
IP_WRMOB4_DEL_HANDLE,
|
||||
__IP_WRMOB4_DEL_MAX
|
||||
};
|
||||
|
||||
enum Ip_wrmob4_gettype_t
|
||||
{
|
||||
IP_WRMOB4_GET_UNSPEC,
|
||||
IP_WRMOB4_GET_HANDLE_STAT,
|
||||
IP_WRMOB4_GET_VALIDATE_ROUTE,
|
||||
__IP_WRMOB4_GET_MAX
|
||||
};
|
||||
|
||||
enum Ip_wrmob4_newtype_t
|
||||
{
|
||||
IP_WRMOB4_NEW_UNSPEC,
|
||||
IP_WRMOB4_NEW_LINK_TX,
|
||||
IP_WRMOB4_NEW_LINK_RX,
|
||||
IP_WRMOB4_NEW_HANDLE,
|
||||
__IP_WRMOB4_NEW_MAX
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
IP_WRMOB4_ROUTE_UNSPEC,
|
||||
IP_WRMOB4_ROUTE_HOA,
|
||||
IP_WRMOB4_ROUTE_FLAGS,
|
||||
IP_WRMOB4_ROUTE_IFINDEX,
|
||||
IP_WRMOB4_ROUTE_DST,
|
||||
IP_WRMOB4_ROUTE_DST_LEN,
|
||||
IP_WRMOB4_ROUTE_TABLE,
|
||||
IP_WRMOB4_ROUTE_GW,
|
||||
IP_WRMOB4_ROUTE_COA,
|
||||
IP_WRMOB4_ROUTE_MTU,
|
||||
IP_WRMOB4_ROUTE_SRCMAC,
|
||||
IP_WRMOB4_ROUTE_NAT_PORT,
|
||||
IP_WRMOB4_ROUTE_GRE_KEY,
|
||||
IP_WRMOB4_ROUTE_HANDLE,
|
||||
IP_WRMOB4_ROUTE_LINK,
|
||||
__IP_WRMOB4_ROUTE_MAX
|
||||
};
|
||||
#define IP_WRMOB4_ROUTE_MAX (__IP_WRMOB4_ROUTE_MAX - 1)
|
||||
|
||||
enum
|
||||
{
|
||||
IP_WRMOB4_STATS_UNSPEC,
|
||||
IP_WRMOB4_STATS_LINK_RECV,
|
||||
IP_WRMOB4_STATS_LINK_SEND,
|
||||
__IP_WRMOB4_STATS_MAX
|
||||
};
|
||||
#define IP_WRMOB4_STATS_MAX (__IP_WRMOB4_STATS_MAX - 1)
|
||||
|
||||
|
||||
#define IP_WRMOB4_SET_FLAG_CLEAR (1 << 0)
|
||||
|
||||
enum Ip_wrmob4_settype_t
|
||||
{
|
||||
IP_WRMOB4_SET_UNSPEC,
|
||||
IP_WRMOB4_SET_ADDRESS_ACTIVE,
|
||||
IP_WRMOB4_SET_NO_GLOBAL_SRC,
|
||||
__IP_WRMOB4_SET_MAX
|
||||
};
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
IP_WRMOB4_HOA_UNSPEC,
|
||||
IP_WRMOB4_HOA_ADDRESS,
|
||||
IP_WRMOB4_HOA_IFINDEX,
|
||||
__IP_WRMOB4_HOA_MAX
|
||||
};
|
||||
#define IP_WRMOB4_HOA_MAX (__IP_WRMOB4_HOA_MAX - 1)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef IPMIP_NATIVE_KERNEL
|
||||
|
||||
IP_GLOBAL void ipmip4_rtnetlink_init(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,80 @@
|
||||
/* ipmip4_ntop.h - ipmip4_ntop.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_ntop.h,v $ $Revision: 1.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/private/ipmip4_ntop.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-04-23 14:13:30 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_NTOP_H
|
||||
#define IPMIP4_NTOP_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Debug utility class providing functions to ease print's of various
|
||||
* values such as hexarrays, lla's, addresses and non-zero-terminated
|
||||
* strings.
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
Debug utility class providing functions to ease print's of various
|
||||
values such as hexarrays, lla's, addresses and non-zero-terminated
|
||||
strings.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <private/ipmip_ntop.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,833 @@
|
||||
/* ipmip4_pkt.h - ipmip4_pkt.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_pkt.h,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/private/ipmip4_pkt.h,v $
|
||||
* $Author: jhorteli $ $Date: 2011-01-21 15:31:36 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_PACKET_H
|
||||
#define IPMIP4_PACKET_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Base packet management class, containing vital information for creating
|
||||
* packets, receiving packets and sending packets.
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
Base packet management class, containing vital information for creating
|
||||
packets, receiving packets and sending packets.
|
||||
|
||||
EXAMPLE
|
||||
|
||||
These examples extends the example functions originally defined
|
||||
ipmip4_context.h, and shows how should create and manage the packet
|
||||
context.
|
||||
|
||||
.CS
|
||||
|
||||
IP_GLOBAL void
|
||||
ipmip4_reg_recv(struct Ipmip4_my_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip4_pktbuf_t *pbuf,
|
||||
void *arg)
|
||||
{
|
||||
/@ Process the registration request @/
|
||||
|
||||
|
||||
|
||||
/@ Release the packet buffer @/
|
||||
ipmip_pktbuf_release(&ctx->ipmip4.ipmip, proc, &pbuf->ipmip);
|
||||
}
|
||||
|
||||
IP_GLOBAL void
|
||||
ipmip4_udp_recv(struct Ipmip4_my_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip4_pktbuf_t *pbuf,
|
||||
void *arg)
|
||||
{
|
||||
/@ Process the UDP packet @/
|
||||
|
||||
|
||||
|
||||
/@ Release the packet buffer @/
|
||||
ipmip_pktbuf_release(&ctx->ipmip4.ipmip, proc, &pbuf->ipmip);
|
||||
}
|
||||
|
||||
IP_GLOBAL void
|
||||
ipmip4_adv_recv(struct Ipmip4_my_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip4_pktbuf_t *pbuf)
|
||||
{
|
||||
Ipcom_icmp_header *icmph = IPMIP_BUFFER_PTR(&pbuf->ipmip.packet);
|
||||
|
||||
/@ Process the ICMP packet @/
|
||||
|
||||
/@ Release the packet buffer @/
|
||||
ipmip_pktbuf_release(&data->ipmip4.ipmip, proc, &pbuf->ipmip4.ipmip);
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct Ipmip4_my_context *my_init_func4(Ipmip_proc_t *proc)
|
||||
{
|
||||
/@ Allocate my context; indicate the size of my overloaded structure @/
|
||||
struct Ipmip4_my_context *ctx = (struct Ipmip_my_context *)ipmip_context_alloc(proc, sizeof(*ctx), "mymip4", IPCOM_LOG_DEBUG2, 10);
|
||||
struct Ip_sockaddr_in udp;
|
||||
|
||||
/@ Initialize the MIP4 portion of the context @/
|
||||
ipmip4_context_init(&ctx->ipmip4, proc);
|
||||
|
||||
/@ Create a packet context @/
|
||||
ipmip4_pkt_context_create(&ctx->ipmip4,
|
||||
proc,
|
||||
IPMIP4_PKT_UDP_IN_434|IPMIP4_PKT_UDP_IN_OUT|IPMIP4_PKT_PKT_OUT|IPMIP4_PKT_ICMP_IN,
|
||||
(Ipmip4_pkt_udp_cb_t)ipmip4_reg_recv,
|
||||
(Ipmip4_pkt_icmp_cb_t)ipmip4_adv_recv,
|
||||
IP_NULL);
|
||||
|
||||
|
||||
/@ Register an extra UDP socket to the packet context @/
|
||||
ipcom_memset(&udp, 0, sizeof(udp));
|
||||
udp.sin_family = IP_AF_INET;
|
||||
udp.sin_len = sizeof(udp);
|
||||
udp.sin_addr.s_addr = 0;
|
||||
udp.sin_port = ip_htons(1000);
|
||||
|
||||
ctx->udpr.udp_callback = (Ipmip4_pkt_udp_cb_t)ipmip4_udp_recv;
|
||||
ctx->udpr.opaque = IP_NULL;
|
||||
|
||||
ctx->udpr.fd = ipmip_inet_udp_socket(&udp);
|
||||
ipmip4_pkt_udp_register(&ctx->ipmip4, proc, &cfg->udpr);
|
||||
|
||||
/@ Start the context @/
|
||||
ipmip4_context_start(&ctx->ipmip4, proc);
|
||||
}
|
||||
|
||||
.CE
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <private/ipmip_buffer.h>
|
||||
|
||||
#include <private/ipmip4_context.h>
|
||||
#include <private/ipmip4_if.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPMIP4_PKT_UDP_IN_434 (1 << 0)
|
||||
#define IPMIP4_PKT_UDP_IN_OUT (1 << 1) /* Use two different sockets for in/out */
|
||||
#define IPMIP4_PKT_PKT_IN (1 << 2) /* ARP/PACKET IN required */
|
||||
#define IPMIP4_PKT_PKT_OUT (1 << 3) /* ARP/PACKET OUT required */
|
||||
#define IPMIP4_PKT_ICMP_IN (1 << 4) /* Inbound ICMP packets */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include "ipcom_align16.h"
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipnet_pkt_arp
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef IP_PACKED1 struct Ipmip4_pkt_arp
|
||||
{
|
||||
/* ARP header. */
|
||||
Ip_u16 hrd; /* Format of hardware address. */
|
||||
Ip_u16 pro; /* Format of protocol address. */
|
||||
Ip_u16 hln_pln; /* Length of hardware and protocol address. */
|
||||
Ip_u16 op; /* Code */
|
||||
|
||||
Ip_u8 eth_src[IPMIP_ETH_ADDR_SIZE];
|
||||
Ip_u16 ip_src[2];
|
||||
|
||||
Ip_u8 eth_dst[IPMIP_ETH_ADDR_SIZE];
|
||||
Ip_u16 ip_dst[2];
|
||||
}
|
||||
IP_PACKED2 Ipmip4_pkt_arp_t;
|
||||
#include "ipcom_align16.h"
|
||||
|
||||
|
||||
struct Ipmip4_pktbuf;
|
||||
struct Ipmip4_context;
|
||||
struct Ipmip_proc;
|
||||
|
||||
typedef Ip_bool (*Ipmip4_pkt_udp_cb_t)
|
||||
(
|
||||
Ipmip4_context_t *context,
|
||||
Ipmip_proc_t *proc,
|
||||
struct Ipmip4_pktbuf *pbuf,
|
||||
void *arg
|
||||
);
|
||||
|
||||
typedef Ip_bool (*Ipmip4_pkt_icmp_cb_t)
|
||||
(
|
||||
Ipmip4_context_t *context,
|
||||
Ipmip_proc_t *proc,
|
||||
struct Ipmip4_pktbuf *pbuf
|
||||
);
|
||||
|
||||
typedef Ip_bool (*Ipmip4_pkt_packet_cb_t)
|
||||
(
|
||||
Ipmip4_context_t *context,
|
||||
Ipmip_proc_t *proc,
|
||||
struct Ipmip4_pktbuf *pbuf
|
||||
);
|
||||
|
||||
|
||||
typedef struct Ipmip4_pkt_udp_register
|
||||
{
|
||||
Ipcom_list next;
|
||||
|
||||
Ipmip4_pkt_udp_cb_t udp_callback;
|
||||
Ip_fd fd;
|
||||
void *opaque;
|
||||
} Ipmip4_pkt_udp_register_t;
|
||||
|
||||
typedef struct Ipmip4_pkt_context
|
||||
{
|
||||
Ipcom_list udp_sockets;
|
||||
|
||||
struct Ipmip_proc *proc;
|
||||
Ip_fd fd_raw;
|
||||
Ip_fd fd_pkt;
|
||||
|
||||
Ip_fd fd_icmp_in;
|
||||
|
||||
struct Ip_sockaddr_in s_udp_in;
|
||||
struct Ip_sockaddr_in s_udp_out;
|
||||
|
||||
Ip_u32 flags;
|
||||
|
||||
Ipmip4_pkt_udp_register_t udp_in;
|
||||
Ipmip4_pkt_udp_register_t udp_out;
|
||||
|
||||
/* Callbacks */
|
||||
Ipmip4_pkt_udp_cb_t udp;
|
||||
Ipmip4_pkt_icmp_cb_t icmp;
|
||||
Ipmip4_pkt_packet_cb_t packet;
|
||||
} Ipmip4_pkt_context_t;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_pkt_context_destroy - ipmip4_pkt_context_destroy
|
||||
*
|
||||
* Destroy the packet context
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_pkt_context_destroy
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_pkt_context_create - ipmip4_pkt_context_create
|
||||
*
|
||||
* Create the packet context
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i flags
|
||||
* Flags what packet context features we need.
|
||||
* \i udp
|
||||
* UDP callback
|
||||
* \i icmp
|
||||
* ICMP callback
|
||||
* \i packet
|
||||
* Packet callback
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on success.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip4_pkt_context_create
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_u32 flags,
|
||||
Ipmip4_pkt_udp_cb_t udp,
|
||||
Ipmip4_pkt_icmp_cb_t icmp,
|
||||
Ipmip4_pkt_packet_cb_t packet
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_pkt_context_start - ipmip4_pkt_context_start
|
||||
*
|
||||
* Start the packet context
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on success.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip4_pkt_context_start
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_pkt_context_stop - ipmip4_pkt_context_stop
|
||||
*
|
||||
* Stops the packet thread.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_pkt_context_stop
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_pkt_icmp_write - ipmip4_pkt_icmp_write
|
||||
*
|
||||
* Write an ICMP message to a link local host.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i payload
|
||||
* The payload packet
|
||||
* \i from
|
||||
* The source
|
||||
* \i to
|
||||
* The destination
|
||||
* \i iff
|
||||
* Outgoing interface
|
||||
* \i lladdr
|
||||
* Link level address
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE if successful.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip4_pkt_icmp_write
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip_buffer_t *payload,
|
||||
Ip_u32 from,
|
||||
Ip_u32 to,
|
||||
Ipmip4_if_t *iff,
|
||||
Ipmip_lladdr_t *lladdr
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_pkt_icmp_sendmsg - ipmip4_pkt_icmp_sendmsg
|
||||
*
|
||||
* Send an ICMP message
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i payload
|
||||
* The payload packet
|
||||
* \i from
|
||||
* The source
|
||||
* \i to
|
||||
* The destination
|
||||
* \i iff
|
||||
* Outgoing interface
|
||||
* \i ttl
|
||||
* TTL
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE if successful.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip4_pkt_icmp_sendmsg
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip_buffer_t *payload,
|
||||
Ip_u32 from,
|
||||
Ip_u32 to,
|
||||
Ipmip4_if_t *iff,
|
||||
Ip_u8 ttl
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_pkt_udp_sendmsg - ipmip4_pkt_udp_sendmsg
|
||||
*
|
||||
* Send a UDP message to a remote host
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i payload
|
||||
* The payload buffer
|
||||
* \i from
|
||||
* The source address
|
||||
* \i from_port
|
||||
* The source port in network byte order
|
||||
* \i to
|
||||
* The destination address
|
||||
* \i to_port
|
||||
* The destination port in network byte order
|
||||
* \i iff
|
||||
* If set; the interface to force the output on.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The resulting return code.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL int ipmip4_pkt_udp_sendmsg
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip_buffer_t *payload,
|
||||
Ip_u32 from,
|
||||
Ip_u16 from_port,
|
||||
Ip_u32 to,
|
||||
Ip_u16 to_port,
|
||||
Ipmip4_if_t *iff
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_pkt_udp_write - ipmip4_pkt_udp_write
|
||||
*
|
||||
* Send a UDP message to a link local host with the
|
||||
* indicated MAC address.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i payload
|
||||
* The payload buffer
|
||||
* \i from
|
||||
* The source address
|
||||
* \i from_port
|
||||
* The source port in netwrok byte order
|
||||
* \i to
|
||||
* The destination address
|
||||
* \i to_port
|
||||
* The destination port in network byte order
|
||||
* \i iff
|
||||
* Outgoing interface
|
||||
* \i lladdr
|
||||
* MAC address
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The resulting return code.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL int ipmip4_pkt_udp_write
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip_buffer_t *payload,
|
||||
Ip_u32 from,
|
||||
Ip_u16 from_port,
|
||||
Ip_u32 to,
|
||||
Ip_u16 to_port,
|
||||
Ipmip4_if_t *iff,
|
||||
Ipmip_lladdr_t *lladdr
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_pkt_arp_write - ipmip4_pkt_arp_write
|
||||
*
|
||||
* Send an ARP message to specific destination
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i from
|
||||
* From IP address
|
||||
* \i to
|
||||
* To IP address
|
||||
* \i iff
|
||||
* Outgoing interface
|
||||
* \i lladdr
|
||||
* LLA destination
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_pkt_arp_write
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_u32 from,
|
||||
Ip_u32 to,
|
||||
Ipmip4_if_t *iff,
|
||||
Ipmip_lladdr_t *lladdr
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_pkt_icmp_echo_request - ipmip4_pkt_icmp_echo_request
|
||||
*
|
||||
* Send an echo request message
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i from
|
||||
* Source IP
|
||||
* \i to
|
||||
* Destination IP
|
||||
* \i iff
|
||||
* Outgoing interface
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE if successful.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip4_pkt_icmp_echo_request
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_u32 from,
|
||||
Ip_u32 to,
|
||||
Ipmip4_if_t *iff
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_pkt_icmp_join - ipmip4_pkt_icmp_join
|
||||
*
|
||||
* Join a specific multicast group
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i group
|
||||
* The group
|
||||
* \i ifindex
|
||||
* The ifindex
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on success
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip4_pkt_icmp_join
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_u32 group,
|
||||
Ip_u32 ifindex
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_pkt_udp_register - ipmip4_pkt_udp_register
|
||||
*
|
||||
* Register a UDP socket to the packet loop. Packets received on these
|
||||
* sockets will be fed through the provided callback.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i udpr
|
||||
* UDP registration structure.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_pkt_udp_register
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip4_pkt_udp_register_t *udpr
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_pkt_udp_unregister - ipmip4_pkt_udp_unregister
|
||||
*
|
||||
* Unregister a UDP socket from the packet loop.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i udpr
|
||||
* UDP registration structure.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_pkt_udp_unregister
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip4_pkt_udp_register_t *udpr
|
||||
);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,99 @@
|
||||
/* ipmip4_pktbuf.h - ipmip4_pktbuf.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_pktbuf.h,v $ $Revision: 1.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/private/ipmip4_pktbuf.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-12-07 09:55:10 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_PKTBUF_H
|
||||
#define IPMIP4_PKTBUF_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Packet buffer base class, which is usually overloaded by the various
|
||||
* mobile agents and nodes in order to contain instantiation specific
|
||||
* information.
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
Packet buffer base class, which is usually overloaded by the various
|
||||
mobile agents and nodes in order to contain instantiation specific
|
||||
information.
|
||||
|
||||
This header file defines the IPMIP4 overloaded packet buffer. For examples
|
||||
and more extensive explanation, see ipmip_pktbuf.h
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <private/ipmip_pktbuf.h>
|
||||
|
||||
#include <private/ipmip4_msgext.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
union Ipmip4_pktbuf_ext
|
||||
{
|
||||
Ipmip4_msgext_icmp_t icmp;
|
||||
Ipmip4_msgext_mobile_t mobile;
|
||||
};
|
||||
|
||||
typedef struct Ipmip4_pktbuf
|
||||
{
|
||||
Ipmip_pktbuf_t ipmip;
|
||||
union Ipmip4_pktbuf_ext ext;
|
||||
} Ipmip4_pktbuf_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,723 @@
|
||||
/* ipmip4_radius.h - ipmip4_radius.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_radius.h,v $ $Revision: 1.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/private/ipmip4_radius.h,v $
|
||||
* $Author: jhorteli $ $Date: 2011-01-21 15:31:36 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_RADIUS_H
|
||||
#define IPMIP4_RADIUS_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Generic radius wrapper for use with AAA radius support. The functions
|
||||
* declared here MUST be instantiated in another file provided by the
|
||||
* customer, unless IPRADIUS is being used.
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
Generic radius wrapper for use with AAA radius support. The functions
|
||||
declared here MUST be instantiated in another file provided by the
|
||||
customer, unless IPRADIUS is being used.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIP4_RADIUS_ATTR_User_Name 1
|
||||
#define IPMIP4_RADIUS_ATTR_User_Password 2
|
||||
#define IPMIP4_RADIUS_ATTR_NAS_IP_Address 4
|
||||
#define IPMIP4_RADIUS_ATTR_Framed_IP_Address 8
|
||||
#define IPMIP4_RADIUS_ATTR_Vendor_Specific 26
|
||||
#define IPMIP4_RADIUS_ATTR_Tunnel_Password 69
|
||||
|
||||
#define IPMIP4_RADIUS_VENDOR_3GGP2 5535
|
||||
# define IPMIP4_RADIUS_VENDOR_3GPP2_Home_Agent_IP_Address 7
|
||||
# define IPMIP4_RADIUS_VENDOR_3GPP2_MN_HA_SPI 57
|
||||
# define IPMIP4_RADIUS_VENDOR_3GPP2_MN_HA_SHARED_KEY 58
|
||||
# define IPMIP4_RADIUS_VENDOR_3GPP2_Foreign_Agent_Address 79
|
||||
# define IPMIP4_RADIUS_VENDOR_3GPP2_MN_AAA_Removal_Indication 81
|
||||
# define IPMIP4_RADIUS_VENDOR_3GPP2_MN_MIP4_Mesg_Id 173
|
||||
#define IPMIP4_RADIUS_VENDOR_CISCO 9
|
||||
|
||||
#define IPMIP4_RADIUS_ACCT_Input_Octets 42
|
||||
#define IPMIP4_RADIUS_ACCT_Output_Octets 43
|
||||
#define IPMIP4_RADIUS_ACCT_Session_Time 46
|
||||
#define IPMIP4_RADIUS_ACCT_Input_Packets 47
|
||||
#define IPMIP4_RADIUS_ACCT_Output_Packets 48
|
||||
#define IPMIP4_RADIUS_ACCT_Input_Gigawords 52
|
||||
#define IPMIP4_RADIUS_ACCT_Output_Gigawords 53
|
||||
|
||||
/* Generic attribute macros */
|
||||
#define IPMIP4_RADIUS_ATTR_TYPE(x) (((Ip_u8 *)(x))[0])
|
||||
#define IPMIP4_RADIUS_ATTR_LEN(x) (((Ip_u8 *)(x))[1])
|
||||
#define IPMIP4_RADIUS_ATTR_DATA(x,o) (((Ip_u8 *)(x)) + 2 + (o))
|
||||
|
||||
/* VSA specific macros */
|
||||
#define IPMIP4_RADIUS_ATTR_VSA_VENDOR(x) IP_GET_NTOHL(IPMIP4_RADIUS_ATTR_DATA((x),0))
|
||||
#define IPMIP4_RADIUS_ATTR_VSA_TYPE(x) (*IPMIP4_RADIUS_ATTR_DATA((x), 4))
|
||||
#define IPMIP4_RADIUS_ATTR_VSA_LEN(x) (*IPMIP4_RADIUS_ATTR_DATA((x), 5))
|
||||
#define IPMIP4_RADIUS_ATTR_VSA_DATA(x) IPMIP4_RADIUS_ATTR_DATA((x), 6)
|
||||
|
||||
|
||||
#define IPMIP4_RADIUS_AUTH_CHAP 0
|
||||
#define IPMIP4_RADIUS_AUTH_USER_PASSWORD 1
|
||||
|
||||
|
||||
#define IPMIP4_RADIUS_ACCESS_REQUEST_SUCCESS (0)
|
||||
#define IPMIP4_RADIUS_ACCESS_REQUEST_FAILURE (1)
|
||||
#define IPMIP4_RADIUS_ACCOUNTING_START (2)
|
||||
#define IPMIP4_RADIUS_ACCOUNTING_FAILED (3)
|
||||
#define IPMIP4_RADIUS_ACCOUNTING_STOP (5)
|
||||
#define IPMIP4_RADIUS_ACCOUNTING_START_RESPONSE (6)
|
||||
#define IPMIP4_RADIUS_ACCOUNTING_STOP_RESPONSE (7)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip4_context;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip4_pktbuf;
|
||||
struct Ipmip4_radius_context;
|
||||
union Ipmip4_msgext_uhdr;
|
||||
struct Ipmip_cli_message;
|
||||
|
||||
typedef void Ipmip4_radius_packet_t;
|
||||
typedef void (*Ipmip4_radius_func_t) (int result,
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_radius_context *radius,
|
||||
struct Ipmip4_pktbuf *pbuf,
|
||||
void *arg,
|
||||
Ipmip4_radius_packet_t *request,
|
||||
Ipmip4_radius_packet_t *reply);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_radius_context_create - ipmip4_radius_context_create
|
||||
*
|
||||
* Create a radius context if so specified by the configuration
|
||||
* parameters
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i format
|
||||
* Base configuration path
|
||||
* \i ...
|
||||
* The format parameters
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: A radius context if properly configured and enabled
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL struct Ipmip4_radius_context * ipmip4_radius_context_create
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
const char *defbase,
|
||||
const char *format,
|
||||
...
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_radius_context_dump - ipmip4_radius_context_dump
|
||||
*
|
||||
* Dump a radius context
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i radius
|
||||
* Radius context
|
||||
* \i request
|
||||
* CLI request
|
||||
* \i format
|
||||
* Base configuration path
|
||||
* \i ...
|
||||
* The format parameters
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_radius_context_dump
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_radius_context *radius,
|
||||
struct Ipmip_cli_message *request,
|
||||
const char *format,
|
||||
...
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_radius_context_destroy - ipmip4_radius_context_destroy
|
||||
*
|
||||
* Stop and destroy a radius context
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i radius
|
||||
* Radius context.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_radius_context_destroy
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_radius_context *radius
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_radius_access_request - ipmip4_radius_access_request
|
||||
*
|
||||
* Do an ordinary access request; no challenge provided
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i radius
|
||||
* Radius context
|
||||
* \i func
|
||||
* Radius callback function
|
||||
* \i msg
|
||||
* The radius packet
|
||||
* \i pbuf
|
||||
* Current transaction
|
||||
* \i arg
|
||||
* Extra arg
|
||||
* \i auth_type
|
||||
* Auth Type
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on successful request transmission.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip4_radius_access_request
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_radius_context *radius,
|
||||
Ipmip4_radius_func_t func,
|
||||
Ipmip4_radius_packet_t *msg,
|
||||
struct Ipmip4_pktbuf *pbuf,
|
||||
void *arg,
|
||||
int auth_type
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_radius_access_request_init - ipmip4_radius_access_request_init
|
||||
*
|
||||
* Create a radius access base message
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i radius
|
||||
* Radius context
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: A message structure if successful
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_radius_packet_t* ipmip4_radius_access_request_init
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_radius_context *radius
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_radius_access_request_free - ipmip4_radius_access_request_free
|
||||
*
|
||||
* Free a radius access base message
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i radius
|
||||
* Radius context
|
||||
* \i msg
|
||||
* Message
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_radius_access_request_free
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_radius_context *radius,
|
||||
Ipmip4_radius_packet_t *msg
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_radius_attr_add - ipmip4_radius_attr_add
|
||||
*
|
||||
* Add a radius extension
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i radius
|
||||
* Radius context
|
||||
* \i msg
|
||||
* Message
|
||||
* \i type
|
||||
* Type of extension
|
||||
* \i data
|
||||
* Payload
|
||||
* \i size
|
||||
* Size of payload
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_radius_attr_add
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_radius_context *radius,
|
||||
Ipmip4_radius_packet_t *msg,
|
||||
Ip_u8 type,
|
||||
void *data,
|
||||
Ip_size_t size
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_radius_attr_next - ipmip4_radius_attr_next
|
||||
*
|
||||
* Get next radius extension
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i radius
|
||||
* Radius context
|
||||
* \i msg
|
||||
* Message
|
||||
* \i last
|
||||
* Last retrieved attribute or IP_NULL if first.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The next available attribute, or IP_NULL if no more attributes
|
||||
* are available.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_u8 * ipmip4_radius_attr_next
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_radius_context *radius,
|
||||
Ipmip4_radius_packet_t *msg,
|
||||
Ip_u8 *last
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_radius_accounting_start - ipmip4_radius_accounting_start
|
||||
*
|
||||
* Start radius accounting for the session
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i radius
|
||||
* Radius context
|
||||
* \i func
|
||||
* Callback function
|
||||
* \i unique_id
|
||||
* Unique session ID
|
||||
* \i pbuf
|
||||
* Packet buffer
|
||||
* \i arg
|
||||
* Extra arg
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on success.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip4_radius_accounting_start
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_radius_context *radius,
|
||||
Ipmip4_radius_func_t func,
|
||||
Ip_u32 unique_id,
|
||||
struct Ipmip4_pktbuf *pbuf,
|
||||
void *arg
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_radius_accounting_stop - ipmip4_radius_accounting_stop
|
||||
*
|
||||
* Stop radius accounting for the session
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i radius
|
||||
* Radius context
|
||||
* \i unique_id
|
||||
* Unique session ID
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on success.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmip4_radius_accounting_stop
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_radius_context *radius,
|
||||
Ip_u32 unique_id
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_radius_aaah - ipmip4_radius_aaah
|
||||
*
|
||||
* Return the AAAH NAI for a radius context. The memory is dynamically
|
||||
* allocated and must be freed by the caller.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i radius
|
||||
* Radius AAAH NAI
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The AAAH NAI.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL union Ipmip4_msgext_uhdr * ipmip4_radius_aaah
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_radius_context *radius
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_radius_decrypt_tunnel_password - ipmip4_radius_decrypt_tunnel_password
|
||||
*
|
||||
* Decrypt a RADIUS AVP encrypted using tunnel password
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i radius
|
||||
* Radius context
|
||||
* \i request
|
||||
* Radus request packet
|
||||
* \i attr
|
||||
* Attribute
|
||||
* \i attr_len
|
||||
* Length of attribute
|
||||
* \i buf
|
||||
* A pointer to an initialized dynamic mobility buffer. See ipmip_buffer.h
|
||||
* for more information regarding dynamic buffers and their capabilities. This
|
||||
* buffer is used to store the decrypted AVP in.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: A pointer to the decrypted value in the buffer.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL const char *ipmip4_radius_decrypt_tunnel_password
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_radius_context *radius,
|
||||
Ipmip4_radius_packet_t *request,
|
||||
Ip_u8 *attr,
|
||||
Ip_size_t attr_len,
|
||||
Ipmip_buffer_t *buf
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_radius_attr_vendor_add - ipmip4_radius_attr_vendor_add
|
||||
*
|
||||
* Add a radius VSA
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i ctx
|
||||
* The generic mobility singleton context for IPMIP4. For each started mobility
|
||||
* entity, there exists a mobility context which tracks configuration, system
|
||||
* events, available features and started processes. The mobility context is
|
||||
* created using ipmip4_context_create(). See ipmip4_context.h for
|
||||
* more information regarding the mobility entity context singleton.
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i radius
|
||||
* Radius context
|
||||
* \i msg
|
||||
* Message
|
||||
* \i vendor
|
||||
* Vendor
|
||||
* \i type
|
||||
* Vendor Type
|
||||
* \i data
|
||||
* Payload
|
||||
* \i size
|
||||
* Size of payload
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_radius_attr_vendor_add
|
||||
(
|
||||
struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_radius_context *radius,
|
||||
Ipmip4_radius_packet_t *msg,
|
||||
Ip_u32 vendor,
|
||||
Ip_u8 type,
|
||||
void *data,
|
||||
Ip_size_t size
|
||||
);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,449 @@
|
||||
/* ipmip4_sysext.h - ipmip4_sysext.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_sysext.h,v $ $Revision: 1.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/private/ipmip4_sysext.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-12-07 09:55:10 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_SYSEXT_H
|
||||
#define IPMIP4_SYSEXT_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Extended system configuration utility functions. These functions provide
|
||||
* ease-of-use configuration retrieval mechanisms.
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
Extended system configuration utility functions. These functions provide
|
||||
ease-of-use configuration retrieval mechanisms.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <ipcom_clib2.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_route.h>
|
||||
|
||||
#include <private/ipmip_sysvar.h>
|
||||
|
||||
#include <private/ipmip4_auth.h>
|
||||
#include <private/ipmip4_msgext.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip4_auth_spi;
|
||||
|
||||
extern Ipmip_sysvar_key_map_t ipmip4_sysext_spi_method[];
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_sysext_nvse_alloc - ipmip4_sysext_nvse_alloc
|
||||
*
|
||||
* Create an NVSE extension based on vendor, subtype and data
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i vendor
|
||||
* Vendor ID
|
||||
* \i subtype
|
||||
* Vendor NVSE subtype
|
||||
* \i data
|
||||
* The vendor value
|
||||
* \i size
|
||||
* The size of value
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The newly allocated NVSE structure
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_msgext_uhdr_t * ipmip4_sysext_nvse_alloc
|
||||
(
|
||||
Ip_u32 vendor,
|
||||
Ip_u16 subtype,
|
||||
void *data,
|
||||
Ip_size_t size
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_sysext_cvse_alloc - ipmip4_sysext_cvse_alloc
|
||||
*
|
||||
* Create an CVSE extension based on vendor, subtype and data
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i vendor
|
||||
* Vendor ID
|
||||
* \i subtype
|
||||
* Vendor CVSE subtype
|
||||
* \i data
|
||||
* The vendor value
|
||||
* \i size
|
||||
* The size of value
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The newly allocated CVSE structure
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_msgext_uhdr_t * ipmip4_sysext_cvse_alloc
|
||||
(
|
||||
Ip_u32 vendor,
|
||||
Ip_u16 subtype,
|
||||
void *data,
|
||||
Ip_size_t size
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_sysext_foreach_spi - ipmip4_sysext_foreach_spi
|
||||
*
|
||||
* Parse the configured SPI's
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i name
|
||||
* Name of the sysvar key
|
||||
* \i subkey
|
||||
* The matched subkey
|
||||
* \i value
|
||||
* The SPI value
|
||||
* \i spictx
|
||||
* The spi context
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_sysext_foreach_spi
|
||||
(
|
||||
struct Ipmip_proc *proc,
|
||||
char *name,
|
||||
char *subkey,
|
||||
const char *value,
|
||||
Ipmip4_auth_context_t *spictx
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_sysext_foreach_spiroute - ipmip4_sysext_foreach_spiroute
|
||||
*
|
||||
* Parse the configured SPI lookup definitions
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i name
|
||||
* Name of the sysvar key
|
||||
* \i subkey
|
||||
* The matched subkey
|
||||
* \i value
|
||||
* The SPI value
|
||||
* \i rtab
|
||||
* The route table
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_sysext_foreach_spiroute(struct Ipmip_proc *proc,
|
||||
char *name,
|
||||
char *subkey,
|
||||
const char *value,
|
||||
Ipmip4_auth_spi_table_t *rtab);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_sysext_foreach_spihash - ipmip4_sysext_foreach_spihash
|
||||
*
|
||||
* Parse the configured SPI lookup definitions regarding NAI's
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i name
|
||||
* Name of the sysvar key
|
||||
* \i subkey
|
||||
* The matched subkey
|
||||
* \i value
|
||||
* The SPI value
|
||||
* \i htable
|
||||
* The spu hash table
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmip4_sysext_foreach_spihash
|
||||
(
|
||||
struct Ipmip_proc *proc,
|
||||
char *name,
|
||||
char *subkey,
|
||||
const char *value,
|
||||
Ipmip4_auth_spi_hash_t *htable
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_sysext_nai_aaah - ipmip4_sysext_nai_aaah
|
||||
*
|
||||
* Parse and create a NAI AAAH from a sysvar
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i format
|
||||
* The sysvar format key.
|
||||
* \i ...
|
||||
* Optional arguments
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The newly allocated AAAH NAI structure
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_msgext_shdr_t * ipmip4_sysext_nai_aaah
|
||||
(
|
||||
const char *format,
|
||||
/* args */ ...
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_sysext_nai_ha - ipmip4_sysext_nai_ha
|
||||
*
|
||||
* Parse and create a NAI HA from a sysvar
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i format
|
||||
* The sysvar format key.
|
||||
* \i ...
|
||||
* Optional arguments
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The allocated HA NAI structure
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_msgext_shdr_t * ipmip4_sysext_nai_ha
|
||||
(
|
||||
const char *format,
|
||||
/* args */ ...
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_sysext_nai_mn - ipmip4_sysext_nai_mn
|
||||
*
|
||||
* Parse and create a NAI MN from a sysvar
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i format
|
||||
* The sysvar format key.
|
||||
* \i ...
|
||||
* Optional arguments
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The allocated MN NAI structure
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_msgext_shdr_t * ipmip4_sysext_nai_mn
|
||||
(
|
||||
const char *format,
|
||||
/* args */ ...
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_sysext_tunnel_type - ipmip4_sysext_tunnel_type
|
||||
*
|
||||
* Interpret a tunnel protocol to its tunnel type index
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i deftype
|
||||
* Default type index
|
||||
* \i format
|
||||
* The sysvar format string
|
||||
* \i ...
|
||||
* The optional arguments
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: -1 on error, deftype on none, tunnel type index otherwise
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipmip4_sysext_tunnel_type
|
||||
(
|
||||
int deftype,
|
||||
const char *format,
|
||||
/* args */ ...
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_sysext_spi_parse - ipmip4_sysext_spi_parse
|
||||
*
|
||||
* Parse a SPI definition defined in the format specification
|
||||
* provided in this function call.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i proc
|
||||
* The process context associated with the currently executing thread. Each
|
||||
* thread and/or process in MIP must have its own unique process context.
|
||||
* If a process is started using ipmip_proc_start, the process context will
|
||||
* be allocated automatically by the IPMIP framework. Otherwise it must
|
||||
* be allocated using ipmip_proc_alloc().
|
||||
* \i defspi
|
||||
* The default SPI used if spi is zero and no
|
||||
*
|
||||
* SPI is defined in the format context.
|
||||
* \i spi
|
||||
* The spi to use
|
||||
* \i secret
|
||||
* The secret to use. If not specified, will be
|
||||
*
|
||||
* parsed in the format context.
|
||||
* \i delim
|
||||
* Pre-delimitor to be prepended to all format
|
||||
*
|
||||
* context parsings.
|
||||
* \i format
|
||||
* Format string
|
||||
* \i ...
|
||||
* Format arguments
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The parsed security association.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL struct Ipmip4_auth_spi * ipmip4_sysext_spi_parse
|
||||
(
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_u32 defspi,
|
||||
Ip_u32 spi,
|
||||
const char *secret,
|
||||
const char *delim,
|
||||
const char *format,
|
||||
...
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_sysext_nai_aaah_create - ipmip4_sysext_nai_aaah_create
|
||||
*
|
||||
* Create a AAAH nai based on provided data
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* The data
|
||||
* \i data_length
|
||||
* The length of data
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The AAAH Nai.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_msgext_shdr_t * ipmip4_sysext_nai_aaah_create
|
||||
(
|
||||
Ip_u8 *data,
|
||||
Ip_size_t data_length
|
||||
);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,79 @@
|
||||
/* ipmip4_usr.h - ipmip4_usr.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_usr.h,v $ $Revision: 1.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/private/ipmip4_usr.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-10-21 12:21:20 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_USR_H
|
||||
#define IPMIP4_USR_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Wrapper functions to register information with the kernel.
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
Wrapper functions to register information with the kernel. NO LONGER USED.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip4_context;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmip4_if;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,97 @@
|
||||
/* ipmip4_util.h - ipmip4_util.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_util.h,v $ $Revision: 1.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/include/private/ipmip4_util.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-03-31 14:59:24 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_UTIL_H
|
||||
#define IPMIP4_UTIL_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Miscellaneous utility functions used by the MIP4 system
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
Miscellaneous utility functions used by the MIP4 system
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <private/ipmip_util.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIP4_EVENT_IF(x, proc, call) IPMIP_DO_IF(x, IPMIP4_EVENT_PRIORITY, proc, call)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmip4_util_now - ipmip4_util_now
|
||||
*
|
||||
* Return current NTP time
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* None.
|
||||
*
|
||||
* RETURNS: The current NTP time
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_u32 ipmip4_util_now
|
||||
(
|
||||
void
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,124 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_attr.c,v $ $Revision: 1.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/src/ipmip4_attr.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip4_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_drv_eth_filter.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_sysctl.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_netif.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_context.h>
|
||||
#include <private/ipmip_ntop.h>
|
||||
|
||||
#include "ipmip4_h.h"
|
||||
#include <private/ipmip4_context.h>
|
||||
#include <private/ipmip4_attr.h>
|
||||
#include <private/ipmip4_ntop.h>
|
||||
#include <private/ipmip4_util.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL int
|
||||
ipmip4_attr_command(struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip_cli_message *request)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_command(&ctx->ipmip, proc, request);
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,431 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_cli.c,v $ $Revision: 1.10 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/src/ipmip4_cli.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
#include "ipmip4_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_getopt.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_cli.h>
|
||||
#include <private/ipmip_util.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
|
||||
#include "ipmip4_h.h"
|
||||
#include <private/ipmip4_context.h>
|
||||
#include <private/ipmip4_cli.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip4_cli_pmipv4_request_set_home_address(Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 hoa)
|
||||
{
|
||||
if (hoa)
|
||||
ipmip_attr_put_inet(&req->reqbuf, IPMIP4_CLI_PMIPV4_ATTR_HOA, hoa);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip4_cli_pmipv4_request_set_dhcp_relay_server(Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 srv)
|
||||
{
|
||||
if (srv)
|
||||
ipmip_attr_put_inet(&req->reqbuf, IPMIP4_CLI_PMIPV4_ATTR_DHCP_RELAY_SERVER, srv);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip4_cli_pmipv4_request_set_home_agent(Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 ha)
|
||||
{
|
||||
if (ha)
|
||||
ipmip_attr_put_inet(&req->reqbuf, IPMIP4_CLI_PMIPV4_ATTR_HA, ha);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip4_cli_pmipv4_request_set_nfa(Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 fa)
|
||||
{
|
||||
if (fa)
|
||||
ipmip_attr_put_inet(&req->reqbuf, IPMIP4_CLI_PMIPV4_ATTR_NFA_COA, fa);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip4_cli_pmipv4_request_set_ofa(Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 fa)
|
||||
{
|
||||
if (fa)
|
||||
ipmip_attr_put_inet(&req->reqbuf, IPMIP4_CLI_PMIPV4_ATTR_OFA_COA, fa);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip4_cli_pmipv4_request_set_mn_ha_spi(Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 spi)
|
||||
{
|
||||
if (spi)
|
||||
ipmip_attr_put_inet(&req->reqbuf, IPMIP4_CLI_PMIPV4_ATTR_MN_HA_SPI, spi);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip4_cli_pmipv4_request_set_nai(Ipmip_cli_daemon_req_t *req,
|
||||
const char *nai)
|
||||
{
|
||||
if (nai)
|
||||
ipmip_attr_put_str(&req->reqbuf, IPMIP4_CLI_PMIPV4_ATTR_MN_NAI, nai);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip4_cli_request_set_ifname(Ipmip_cli_daemon_req_t *req,
|
||||
const char *ifname)
|
||||
{
|
||||
if (ifname)
|
||||
ipmip_attr_put_str(&req->reqbuf,IPMIP4_CLI_PMIPV4_ATTR_IFNAME, ifname);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip4_cli_pmipv4_request_set_mn_ha_spi_secret(Ipmip_cli_daemon_req_t *req,
|
||||
const char *secret)
|
||||
{
|
||||
if (secret)
|
||||
ipmip_attr_put_str(&req->reqbuf,IPMIP4_CLI_PMIPV4_ATTR_MN_HA_SPI_SECRET, secret);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip4_cli_pmipv4_request_set_handler(Ipmip_cli_daemon_req_t *req,
|
||||
const char *handler)
|
||||
{
|
||||
if (handler)
|
||||
ipmip_attr_put_str(&req->reqbuf, IPMIP4_CLI_PMIPV4_ATTR_HANDLER, handler);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip4_cli_pmipv4_request_set_ifaddr(Ipmip_cli_daemon_req_t *req,
|
||||
const char *ifaddr)
|
||||
{
|
||||
if (ifaddr)
|
||||
ipmip_attr_put_str(&req->reqbuf, IPMIP4_CLI_PMIPV4_ATTR_IFADDR, ifaddr);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip4_cli_pmipv4_request_set_tunnel_type(Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 tunnel_type)
|
||||
{
|
||||
ipmip_attr_put_u32(&req->reqbuf, IPMIP4_CLI_PMIPV4_ATTR_TUNNEL_TYPE, tunnel_type);
|
||||
}
|
||||
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmip4_cli_pmipv4_local_trigger_request_init(Ipmip_cli_daemon_req_t *req,
|
||||
const char *nai)
|
||||
{
|
||||
ipmip_cli_daemon_request_start(req, IPMIP4_CLI_PMIPV4_PLT);
|
||||
ipmip4_cli_pmipv4_request_set_nai(req, nai);
|
||||
}
|
||||
|
||||
IP_GLOBAL void
|
||||
ipmip4_cli_shell_pmipv4_usage(Ipmip_proc_t *proc)
|
||||
{
|
||||
ipmip_util_cmdprintf(proc, 1, "pmipv4 trigger <nai> <--ifaddr=<interface address> [options]", "Perform a PMIPv4 Trigger Option");
|
||||
ipmip_util_identprintf(proc, 2, "Where <nai> is the Network Access Identifier of this node."IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "Required options are:"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "--ifaddr=<interface address> Interface address in the notation relevant"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, " to the type of interface specified. I.e. ethernet for example"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, " would be xx:xx:xx:xx:xx:xx in hexadecimal form."IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "Optional options are:"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "--hoa=<home address> Home Address to be used in this trigger"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "--ha=<home agent> Home Agent to be used in this trigger"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "--ifname=<interface> Interface this PMIPv4 request is related to"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "--dhcpr-server=<address> DHCP server to use for this node"IP_LF);
|
||||
|
||||
}
|
||||
|
||||
IP_GLOBAL int
|
||||
ipmip4_cli_shell_pmipv4_cmd(int argc,
|
||||
char **argv,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip_cli_daemon_t *daemon)
|
||||
{
|
||||
static Ipcom_cmd_int_str_map ops[] = {
|
||||
{ 0, "pmipv4" },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
Ipcom_getopt opt;
|
||||
Ipmip_cli_daemon_req_t req;
|
||||
int op_val;
|
||||
int i;
|
||||
int ret = 0;
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
/**/
|
||||
ipmip_cli_daemon_request_init(&req);
|
||||
ipcom_getopt_clear_r(&opt);
|
||||
|
||||
if (argc < 2)
|
||||
return -1;
|
||||
|
||||
op_val = ipcom_cmd_str_to_key(ops, argv[1]);
|
||||
|
||||
if (op_val == -1)
|
||||
return -1;
|
||||
|
||||
ipmip_cli_daemon_request_init(&req);
|
||||
if (op_val == 0)
|
||||
{
|
||||
/* PMIPv4 */
|
||||
static Ipcom_cmd_int_str_map pmipv4_ops[] = {
|
||||
{ 0, "trigger" },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
ipcom_printf("Too few arguments to pmipv4 command"IP_LF);
|
||||
goto exit_out;
|
||||
}
|
||||
|
||||
op_val = ipcom_cmd_str_to_key(pmipv4_ops, argv[2]);
|
||||
if (op_val == -1)
|
||||
{
|
||||
ipcom_printf("Unknown subcommand pmipv4 '%s'"IP_LF, argv[1]);
|
||||
goto exit_out;
|
||||
}
|
||||
|
||||
if (op_val == 0)
|
||||
{
|
||||
static struct Ip_option long_options[] =
|
||||
{
|
||||
{"hoa", 1, 0, 0}, /* 0 */
|
||||
{"ha", 1, 0, 0}, /* 1 */
|
||||
{"ifname", 1, 0, 0}, /* 2 */
|
||||
{"nfa", 1, 0, 0}, /* 3 */
|
||||
{"ofa", 1, 0, 0}, /* 4 */
|
||||
{"mn-ha-spi", 1, 0, 0}, /* 5 */
|
||||
{"mn-ha-secret",1, 0, 0}, /* 6 */
|
||||
{"dhcpr-server",1, 0, 0}, /* 7 */
|
||||
{"handler", 1, 0, 0}, /* 8 */
|
||||
{"ifaddr", 1, 0, 0}, /* 9 */
|
||||
{"tunneltype", 1, 0, 0}, /* 10 */
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
Ip_u32 tmp32;
|
||||
|
||||
/* TRIGGER */
|
||||
if (argc < 4)
|
||||
{
|
||||
ipcom_printf("Too few arguments to pmipv4 trigger command"IP_LF);
|
||||
goto exit_out;
|
||||
}
|
||||
|
||||
/* Create the basic request */
|
||||
ipmip4_cli_pmipv4_local_trigger_request_init(&req, argv[3]);
|
||||
opt.long_only = 1;
|
||||
opt.long_options = long_options;
|
||||
while ((i = ipcom_getopt_r(argc - 3, argv + 3, "", &opt)) != -1)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
ipcom_printf("option %s"IP_LF, long_options[opt.long_index].name);
|
||||
|
||||
switch(opt.long_index)
|
||||
{
|
||||
case 0:
|
||||
/* hoa -- Home Address */
|
||||
if (ipcom_inet_pton(IP_AF_INET, opt.optarg, &tmp32) != 1)
|
||||
{
|
||||
ipcom_printf("bad '--hoa' IPv4 address."IP_LF);
|
||||
goto exit_out;
|
||||
}
|
||||
ipmip4_cli_pmipv4_request_set_home_address(&req, tmp32);
|
||||
break;
|
||||
case 1:
|
||||
/* ha */
|
||||
if (ipcom_inet_pton(IP_AF_INET, opt.optarg, &tmp32) != 1)
|
||||
{
|
||||
ipcom_printf("bad '--ha' IPv4 address."IP_LF);
|
||||
goto exit_out;
|
||||
}
|
||||
ipmip4_cli_pmipv4_request_set_home_agent(&req, tmp32);
|
||||
break;
|
||||
case 2:
|
||||
ipmip4_cli_request_set_ifname(&req, opt.optarg);
|
||||
break;
|
||||
case 3:
|
||||
if (ipcom_inet_pton(IP_AF_INET, opt.optarg, &tmp32) != 1)
|
||||
{
|
||||
ipcom_printf("bad '--nfa' IPv4 address."IP_LF);
|
||||
goto exit_out;
|
||||
}
|
||||
ipmip4_cli_pmipv4_request_set_nfa(&req, tmp32);
|
||||
break;
|
||||
case 4:
|
||||
if (ipcom_inet_pton(IP_AF_INET, opt.optarg, &tmp32) != 1)
|
||||
{
|
||||
ipcom_printf("bad '--ofa' IPv4 address."IP_LF);
|
||||
goto exit_out;
|
||||
}
|
||||
ipmip4_cli_pmipv4_request_set_ofa(&req, tmp32);
|
||||
break;
|
||||
case 5:
|
||||
tmp32 = ipcom_strtoul(opt.optarg, IP_NULL, 0);
|
||||
if (tmp32 == 0)
|
||||
{
|
||||
ipcom_printf("bad '--mn-ha-spi' SPI Value."IP_LF);
|
||||
goto exit_out;
|
||||
}
|
||||
ipmip4_cli_pmipv4_request_set_mn_ha_spi(&req, tmp32);
|
||||
break;
|
||||
case 6:
|
||||
ipmip4_cli_pmipv4_request_set_mn_ha_spi_secret(&req, opt.optarg);
|
||||
break;
|
||||
case 7:
|
||||
if (ipcom_inet_pton(IP_AF_INET, opt.optarg, &tmp32) != 1)
|
||||
{
|
||||
ipcom_printf("bad '--dhcpr-server' IPv4 address."IP_LF);
|
||||
goto exit_out;
|
||||
}
|
||||
ipmip4_cli_pmipv4_request_set_dhcp_relay_server(&req, tmp32);
|
||||
break;
|
||||
case 8:
|
||||
ipmip4_cli_pmipv4_request_set_handler(&req, opt.optarg);
|
||||
break;
|
||||
case 9:
|
||||
ipmip4_cli_pmipv4_request_set_ifaddr(&req, opt.optarg);
|
||||
break;
|
||||
case 10:
|
||||
{
|
||||
int type = ipmip_sysvar_cmd_str_to_key(ipmip_sysvar_tunnel_mask, opt.optarg);
|
||||
if (type == -1)
|
||||
{
|
||||
ipcom_printf("unknown tunneltype %s", opt.optarg);
|
||||
goto exit_out;
|
||||
}
|
||||
|
||||
/* */
|
||||
ipmip4_cli_pmipv4_request_set_tunnel_type(&req, ipmip_util_tunnelmask_to_type(type));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ipcom_printf("unhandled option %s", long_options[opt.long_index].name);
|
||||
if (opt.optarg)
|
||||
ipcom_printf(" with arg %s", opt.optarg);
|
||||
ipcom_printf(IP_LF);
|
||||
goto exit_out;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ipcom_printf("Unknown option '%c' in pmipv4 trigger command"IP_LF, i);
|
||||
goto exit_out;
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
if ((ret = ipmip_cli_daemon_request(daemon, &req)) < 0)
|
||||
ipcom_printf("PMIPv4 Trigger Failed with error: %s"IP_LF, ipcom_strerror(-ret));
|
||||
}
|
||||
}
|
||||
|
||||
exit_out:
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
return 0;
|
||||
}
|
||||
|
||||
IP_GLOBAL int
|
||||
ipmip4_cli_shell_cmd(int argc,
|
||||
char **argv,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip_cli_daemon_t *daemon)
|
||||
{
|
||||
return ipmip_cli_shell_cmd(argc, argv, proc, daemon);
|
||||
}
|
||||
|
||||
IP_GLOBAL void
|
||||
ipmip4_cli_shell_usage(Ipmip_proc_t *proc)
|
||||
{
|
||||
ipmip_cli_shell_usage(proc);
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_context.c,v $ $Revision: 1.19 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/src/ipmip4_context.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip4_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_timer.h>
|
||||
|
||||
#include "ipmip4_h.h"
|
||||
#include <private/ipmip4_util.h>
|
||||
#include <private/ipmip4_pkt.h>
|
||||
#include <private/ipmip4_auth.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL void
|
||||
ipmip4_context_init(Ipmip4_context_t *ctx,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
|
||||
ipmip4_auth_init(ctx, proc);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_context_start
|
||||
*===========================================================================
|
||||
* Description: Start the context
|
||||
* Parameters: ctx - The context
|
||||
* proc - Current thead context
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmip4_context_start(Ipmip4_context_t *ctx,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
ipmip_context_start(&ctx->ipmip, proc);
|
||||
|
||||
/* Start the context */
|
||||
ipmip4_pkt_context_start(ctx, proc);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_context_stop
|
||||
*===========================================================================
|
||||
* Description: Stop the context
|
||||
* Parameters: ctx - The context
|
||||
* proc - Process context
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmip4_context_stop(Ipmip4_context_t *ctx,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
ipmip4_pkt_context_stop(ctx, proc);
|
||||
|
||||
ipmip_context_stop(&ctx->ipmip, proc);
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_context_destroy
|
||||
*===========================================================================
|
||||
* Description: Destroy the context
|
||||
* Parameters: ctx - The context
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmip4_context_destroy(Ipmip4_context_t *ctx,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
ipmip4_pkt_context_destroy(ctx, proc);
|
||||
|
||||
ipmip_context_destroy(&ctx->ipmip, proc);
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,725 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_diameter.c,v $ $Revision: 1.13.10.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/src/ipmip4_diameter.c,v $
|
||||
* $Author: jsheng $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef IPDIAMETER
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip4_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_sysctl.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_clib2.h>
|
||||
|
||||
#include <ipdiameter.h>
|
||||
#include <ipdiameter_client.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
#include <private/ipmip_cli.h>
|
||||
|
||||
#include "ipmip4_h.h"
|
||||
#include <private/ipmip4_if.h>
|
||||
#include <private/ipmip4_pkt.h>
|
||||
#include <private/ipmip4_pktbuf.h>
|
||||
#include <private/ipmip4_context.h>
|
||||
#include <private/ipmip4_util.h>
|
||||
#include <private/ipmip4_diameter.h>
|
||||
#include <private/ipmip4_sysext.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
typedef Ip_err (*Ipmip4_event_callback_t) (int,
|
||||
struct Ipdiameter_request_struct *,
|
||||
struct Ipdiameter_header *,
|
||||
struct Ipdiameter_header *,
|
||||
struct Ipdiameter_server *);
|
||||
struct Ipmip4_diameter_server
|
||||
{
|
||||
/* Diameter specific info */
|
||||
Ipdiameter_server server;
|
||||
};
|
||||
|
||||
struct Ipmip4_diameter_HAR_data
|
||||
{
|
||||
/* Diameter specific info */
|
||||
void *opaque;
|
||||
Ipmip4_diameter_HAR_recv_t func;
|
||||
};
|
||||
|
||||
struct Ipmip4_diameter_context
|
||||
{
|
||||
/* Basic information */
|
||||
Ipmip4_context_t *context;
|
||||
Ipmip_proc_t *proc;
|
||||
Ipcom_mutex lock;
|
||||
|
||||
Ipmip4_msgext_uhdr_t *nai;
|
||||
|
||||
struct Ipmip4_diameter_server auth;
|
||||
};
|
||||
|
||||
struct Ipmip4_diameter_auth_request_cookie
|
||||
{
|
||||
struct Ipmip4_diameter_context *diameter;
|
||||
Ipmip4_pktbuf_t *pbuf;
|
||||
void *arg;
|
||||
Ipmip4_diameter_func_t func;
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_diameter_HAR
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmip4_diameter_HAR(Ip_u32 code,
|
||||
Ipdiameter_header *hdr,
|
||||
Ipdiameter_peer_entry *peer,
|
||||
void *opaque_data)
|
||||
{
|
||||
struct Ipmip4_diameter_HAR_data *data = opaque_data;
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(code);
|
||||
|
||||
/* */
|
||||
if (data && data->func)
|
||||
/* Invoke the callback */
|
||||
(data->func) (data->opaque, hdr, peer);
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_diameter_event_callback
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
ipmip4_diameter_event_callback(int event,
|
||||
struct Ipdiameter_request_struct *request_v,
|
||||
struct Ipdiameter_header_struct *request_packet_v,
|
||||
struct Ipdiameter_header_struct *response_packet_v,
|
||||
struct Ipdiameter_server *server_v)
|
||||
{
|
||||
struct Ipmip4_diameter_auth_request_cookie *cookie = request_v? request_v->cookie : IP_NULL;
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(server_v);
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case IPDIAMETER_EVENT_ACCESS_ACCEPT:
|
||||
if (cookie != IP_NULL && cookie->diameter != IP_NULL)
|
||||
(*cookie->func) (IPMIP4_DIAMETER_ACCESS_REQUEST_SUCCESS, cookie->diameter->context, cookie->diameter->proc, cookie->diameter, cookie->pbuf, cookie->arg, request_v, request_packet_v, response_packet_v);
|
||||
break;
|
||||
|
||||
case IPDIAMETER_EVENT_ACCESS_REJECT:
|
||||
case IPDIAMETER_EVENT_ACCESS_TIMEOUT:
|
||||
case IPDIAMETER_EVENT_ACCESS_CANCELLED:
|
||||
if (cookie != IP_NULL && cookie->diameter != IP_NULL)
|
||||
(*cookie->func) (IPMIP4_DIAMETER_ACCESS_REQUEST_FAILURE, cookie->diameter->context, cookie->diameter->proc, cookie->diameter, cookie->pbuf, cookie->arg, request_v, request_packet_v, response_packet_v);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/**/
|
||||
if (cookie != IP_NULL)
|
||||
{
|
||||
request_v->cookie = IP_NULL;
|
||||
ipcom_free(cookie);
|
||||
}
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_radius_read_server
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipmip4_diameter_read_server(struct Ipmip4_diameter_server *server,
|
||||
const char *defbase,
|
||||
const char *vformat,
|
||||
const char *pre,
|
||||
Ip_u16 defport,
|
||||
int server_type)
|
||||
{
|
||||
Ip_u32 srv = 0;
|
||||
Ip_bool success = IP_FALSE;
|
||||
char *realm = IP_NULL;
|
||||
char *hostname = IP_NULL;
|
||||
char *secret = IP_NULL;
|
||||
|
||||
if (vformat)
|
||||
ipmip_sysvar_inet(0, &srv, IP_NULL, "%s.%s.address", vformat, pre);
|
||||
if (srv == 0 && defbase)
|
||||
ipmip_sysvar_inet(0, &srv, IP_NULL, "%s.%s.address", defbase, pre);
|
||||
if (srv == 0)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "IPMIP4: Diameter configuration; %s address not specified", pre);
|
||||
goto done_out;
|
||||
}
|
||||
|
||||
if (vformat)
|
||||
realm = ipmip_sysvar("%s.%s.realm", vformat, pre);
|
||||
if (realm == IP_NULL && defbase)
|
||||
realm = ipmip_sysvar("%s.%s.realm", defbase, pre);
|
||||
|
||||
if (!realm)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "IPMIP4: Diameter configuration; %s realm not specified", pre);
|
||||
goto done_out;
|
||||
}
|
||||
|
||||
if (vformat)
|
||||
hostname = ipmip_sysvar("%s.%s.hostname", vformat, pre);
|
||||
if (hostname == IP_NULL && defbase)
|
||||
hostname = ipmip_sysvar("%s.%s.hostname", defbase, pre);
|
||||
|
||||
if (vformat)
|
||||
secret = ipmip_sysvar("%s.%s.secret", vformat, pre);
|
||||
if (secret == IP_NULL && defbase)
|
||||
secret = ipmip_sysvar("%s.%s.secret", defbase, pre);
|
||||
|
||||
|
||||
if (defbase)
|
||||
defport = (Ip_u16)ipmip_sysvar_ulong(defport, "%s.%s.port", defbase, pre);
|
||||
if (vformat)
|
||||
defport = (Ip_u16)ipmip_sysvar_ulong(defport, "%s.%s.port", vformat, pre);
|
||||
|
||||
/* Setup the server */
|
||||
server->server.server_addr.sin.sin_family = IP_AF_INET;
|
||||
server->server.server_addr.sin.sin_addr.s_addr = srv;
|
||||
server->server.server_addr.sin.sin_port = ipcom_htons(defport);
|
||||
IPCOM_SA_LEN_SET(&server->server.server_addr.sin, sizeof(struct Ip_sockaddr_in));
|
||||
server->server.server_type = server_type;
|
||||
|
||||
ipcom_strncpy(server->server.realm, realm, sizeof(server->server.realm));
|
||||
if (hostname)
|
||||
ipcom_strncpy(server->server.hostname, hostname, sizeof(server->server.hostname));
|
||||
|
||||
if (secret)
|
||||
{
|
||||
server->server.shared_secret_len = ipcom_strlen(secret);
|
||||
server->server.shared_secret_len = IP_MIN(server->server.shared_secret_len, sizeof(server->server.shared_secret));
|
||||
ipcom_strncpy((char *)server->server.shared_secret, (char *)secret, server->server.shared_secret_len);
|
||||
}
|
||||
|
||||
success = IP_TRUE;
|
||||
|
||||
done_out:
|
||||
if (secret)
|
||||
ipcom_free(secret);
|
||||
if (realm)
|
||||
ipcom_free(realm);
|
||||
if (hostname)
|
||||
ipcom_free(hostname);
|
||||
return success;
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmip4_diameter_dump_server(struct Ipmip_proc *proc,
|
||||
Ipmip_cli_message_t *request,
|
||||
struct Ipmip4_diameter_server *server,
|
||||
const char *vformat,
|
||||
const char *pre)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"%s.%s.address=%s",
|
||||
vformat, pre, ipmip_ntop_inet(proc, server->server.server_addr.sin.sin_addr.s_addr));
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"%s.%s.secret=<hidden>",
|
||||
vformat, pre);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"%s.%s.port=%d",
|
||||
vformat, pre, ip_ntohs(server->server.server_addr.sin.sin_port));
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"%s.%s.realm=%s",
|
||||
vformat, pre, server->server.realm);
|
||||
|
||||
if (ipcom_strlen(server->server.hostname))
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"%s.%s.hostname=%s",
|
||||
vformat, pre, server->server.hostname);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_diameter_context_create
|
||||
*===========================================================================
|
||||
* Description: Create a diameter context if so specified by the configuration
|
||||
* parameters
|
||||
* Parameters: ctx - MIPv4 context
|
||||
* proc - Current process context
|
||||
* format - Base configuration path
|
||||
* Returns: A radius context if properly configured and enabled
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL struct Ipmip4_diameter_context *
|
||||
ipmip4_diameter_context_create(struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
const char *defbase,
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
char *vformat = IP_NULL;
|
||||
struct Ipmip4_diameter_context *diameter = IP_NULL;
|
||||
va_list ap;
|
||||
|
||||
if (format)
|
||||
{
|
||||
va_start(ap, format);
|
||||
vformat = ipmip_util_vstrdup(format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
if (!vformat && !defbase)
|
||||
return IP_NULL;
|
||||
|
||||
diameter = ipcom_calloc(1, sizeof(*diameter));
|
||||
if (!diameter)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "IPMIP4: Diameter configuration; failed to allocate memory");
|
||||
goto done_out;
|
||||
}
|
||||
|
||||
(void)ipcom_mutex_create(&diameter->lock);
|
||||
|
||||
/* Base parameters */
|
||||
diameter->context = ctx;
|
||||
diameter->proc = ipmip_proc_alloc();
|
||||
|
||||
if (vformat)
|
||||
diameter->nai = (Ipmip4_msgext_uhdr_t *)ipmip4_sysext_nai_aaah("%s.nai", vformat);
|
||||
if (defbase && diameter->nai == IP_NULL)
|
||||
diameter->nai = (Ipmip4_msgext_uhdr_t *)ipmip4_sysext_nai_aaah("%s.nai", defbase);
|
||||
|
||||
/* Read data */
|
||||
if (!ipmip4_diameter_read_server(&diameter->auth, defbase, vformat, "access", 1812, DIAMETER_ACCESS_SERVER))
|
||||
{
|
||||
ipmip4_diameter_context_destroy(ctx, proc, diameter);
|
||||
diameter = IP_NULL;
|
||||
}
|
||||
|
||||
/* ipmip4_radius_read_server(&radius->radius.acct, vformat, "accounting", 1813, IPRADIUS_ACCOUNTING_SERVER); */
|
||||
|
||||
done_out:
|
||||
ipcom_free(vformat);
|
||||
return diameter;
|
||||
}
|
||||
|
||||
|
||||
IP_GLOBAL void
|
||||
ipmip4_diameter_context_dump(struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_diameter_context *diameter,
|
||||
Ipmip_cli_message_t *request,
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
char *vformat = IP_NULL;
|
||||
va_list ap;
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
|
||||
va_start(ap, format);
|
||||
vformat = ipmip_util_vstrdup(format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (diameter->nai)
|
||||
{
|
||||
Ip_u8 *data = &((Ip_u8 *)diameter->nai)[3];
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"%s.nai=%s",
|
||||
vformat, data);
|
||||
}
|
||||
|
||||
ipmip4_diameter_dump_server(proc, request, &diameter->auth, vformat, "access");
|
||||
|
||||
ipcom_free(vformat);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_diameter_request_alloc
|
||||
*===========================================================================
|
||||
* Description: Initialize and allocate data required for an access request.
|
||||
* Parameters: ctx - Context
|
||||
* proc - Current process
|
||||
* diameter - Diameter context
|
||||
* request - Diameter request
|
||||
* packet - [OUT] Allocated Diameter packet header.
|
||||
* Returns: IP_TRUE on successful init.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool
|
||||
ipmip4_diameter_request_alloc(struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_diameter_context *diameter,
|
||||
Ipdiameter_request *request,
|
||||
Ipdiameter_header **packet)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
/* Initialize the request */
|
||||
ipcom_memset(request, 0, sizeof(Ipdiameter_request));
|
||||
request->unique = ipdiameter_get_unique_id();
|
||||
ipdiameter_get_session_id(request->session_id, 0);
|
||||
request->pwd_type = IPDIAMETER_No_Password;
|
||||
/* IP address or port specified, set a desired server. */
|
||||
request->appl_id = DIAMETER_MIP;
|
||||
|
||||
request->num_servers = 1;
|
||||
ipcom_memcpy(&request->serv_list[0], &diameter->auth.server, sizeof(diameter->auth.server));
|
||||
|
||||
/* */
|
||||
*packet = ipdiameter_request_pkt_malloc(0);
|
||||
if (*packet == IP_NULL)
|
||||
return IP_FALSE;
|
||||
|
||||
/**/
|
||||
(*packet)->appl_id = ip_htonl(DIAMETER_MIP);
|
||||
|
||||
(void)ipdiameter_avp_add_array(*packet,
|
||||
DIAMETER_AVP_CODE_Session_Id,
|
||||
0,
|
||||
IP_NULL,
|
||||
(Ip_u8 *)request->session_id,
|
||||
ipcom_strlen(request->session_id));
|
||||
|
||||
ipdiameter_avp_add_u32(*packet,
|
||||
DIAMETER_AVP_CODE_Auth_Application_Id,
|
||||
DIAMETER_AVP_M_FLAG,
|
||||
IP_NULL,
|
||||
DIAMETER_MIP);
|
||||
|
||||
|
||||
(void)ipdiameter_avp_add_origin_host(*packet);
|
||||
(void)ipdiameter_avp_add_origin_realm(*packet);
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_diameter_answer_alloc
|
||||
*===========================================================================
|
||||
* Description: Initialize and allocate data required for an access request.
|
||||
* Parameters: ctx - Context
|
||||
* proc - Current process
|
||||
* diameter - Diameter context
|
||||
* sid - Session ID
|
||||
* sid_size - Size of session ID.
|
||||
* hbh - HBH
|
||||
* e2e - E2E
|
||||
* packet - [OUT] Allocated Diameter packet header.
|
||||
* Returns: IP_TRUE on successful init.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool
|
||||
ipmip4_diameter_answer_alloc(struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_diameter_context *diameter,
|
||||
void *sid,
|
||||
Ip_size_t sid_size,
|
||||
Ip_u32 hbh,
|
||||
Ip_u32 e2e,
|
||||
Ipdiameter_header **packet)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(diameter);
|
||||
|
||||
/* */
|
||||
*packet = ipdiameter_answer_pkt_malloc(0);
|
||||
if (*packet == IP_NULL)
|
||||
return IP_FALSE;
|
||||
|
||||
/**/
|
||||
(*packet)->appl_id = ip_htonl(DIAMETER_MIP);
|
||||
(*packet)->hbh_id = hbh;
|
||||
(*packet)->e2e_id = e2e;
|
||||
|
||||
(void)ipdiameter_avp_add_array(*packet,
|
||||
DIAMETER_AVP_CODE_Session_Id,
|
||||
0,
|
||||
IP_NULL,
|
||||
(Ip_u8 *)sid,
|
||||
sid_size);
|
||||
|
||||
ipdiameter_avp_add_u32(*packet,
|
||||
DIAMETER_AVP_CODE_Auth_Application_Id,
|
||||
DIAMETER_AVP_M_FLAG,
|
||||
IP_NULL,
|
||||
DIAMETER_MIP);
|
||||
|
||||
|
||||
(void)ipdiameter_avp_add_origin_host(*packet);
|
||||
(void)ipdiameter_avp_add_origin_realm(*packet);
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_diameter_access_request
|
||||
*===========================================================================
|
||||
* Description: Do an ordinary access request; no challenge provided
|
||||
* Parameters: ctx - Context
|
||||
* proc - Current process
|
||||
* diameter - Radius context
|
||||
* func - Diameter callback function
|
||||
* pbuf - Current transaction
|
||||
* arg - Opaque argument
|
||||
* request - Diameter request structure
|
||||
* packet - Diameter packet header
|
||||
* auth_type - Type of authentication
|
||||
* Returns: IP_TRUE on successful request transmission.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool
|
||||
ipmip4_diameter_access_request(struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_diameter_context *diameter,
|
||||
Ipmip4_diameter_func_t func,
|
||||
Ipmip4_pktbuf_t *pbuf,
|
||||
void *arg,
|
||||
Ipdiameter_request *request,
|
||||
Ipdiameter_header *packet,
|
||||
int auth_type)
|
||||
{
|
||||
int retval;
|
||||
Ip_u8 errattr;
|
||||
struct Ipmip4_diameter_auth_request_cookie *cookie;
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(auth_type);
|
||||
|
||||
cookie = ipcom_calloc(1, sizeof(*cookie));
|
||||
if(IP_NULL == cookie)
|
||||
return IP_FALSE;
|
||||
|
||||
cookie->arg = arg;
|
||||
cookie->diameter = diameter;
|
||||
cookie->func = func;
|
||||
cookie->pbuf = pbuf;
|
||||
|
||||
/***** Fill in request structure and send access request. *****/
|
||||
request->cookie = cookie;
|
||||
/* Set DIAMETER event callback. */
|
||||
request->event_callback = (Ipmip4_event_callback_t)ipmip4_diameter_event_callback;
|
||||
|
||||
ipdiameter_print_request(request);
|
||||
ipdiameter_print_pkt(packet);
|
||||
|
||||
retval = ipdiameter_access_request(packet, request, &errattr);
|
||||
if (retval != IPCOM_SUCCESS)
|
||||
{
|
||||
void *ptr = cookie->diameter;
|
||||
cookie->diameter = IP_NULL;
|
||||
if (ptr)
|
||||
ipcom_free(ptr);
|
||||
|
||||
/* Cookie will be freed in the event callback */
|
||||
ipmip_pktbuf_error(&pbuf->ipmip,
|
||||
0,
|
||||
"ipdiameter_access_request failed : '%s' (attr=%d)\n",
|
||||
ipdiameter_errname(retval),
|
||||
errattr);
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_diameter_context_destroy
|
||||
*===========================================================================
|
||||
* Description: Stop and destroy a radius context
|
||||
* Parameters: ctx - The context
|
||||
* proc - Current process
|
||||
* diameter - Diameter context.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmip4_diameter_context_destroy(struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip4_diameter_context *diameter)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (diameter != IP_NULL)
|
||||
{
|
||||
/* Do stop the context */
|
||||
ipmip_proc_destroy(diameter->proc);
|
||||
ipcom_mutex_delete(&diameter->lock);
|
||||
|
||||
if (diameter->nai)
|
||||
ipcom_free(diameter->nai);
|
||||
ipcom_free(diameter);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_diameter_HAR_callback
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmip4_diameter_HAR_callback(void *ctx,
|
||||
Ipmip4_diameter_HAR_recv_t func)
|
||||
{
|
||||
if (func != IP_NULL)
|
||||
{
|
||||
struct Ipmip4_diameter_HAR_data *hdata = ipcom_calloc(1, sizeof(*hdata));
|
||||
if(IP_NULL == hdata)
|
||||
return;
|
||||
|
||||
hdata->opaque = ctx;
|
||||
hdata->func = func;
|
||||
|
||||
ipdiameter_register_access_function(DIAMETER_CODE_Home_Agent_MIP_Request, ipmip4_diameter_HAR, hdata);
|
||||
}
|
||||
else
|
||||
{
|
||||
ipdiameter_deregister_access_function(DIAMETER_CODE_Home_Agent_MIP_Request);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_diameter_proc
|
||||
*===========================================================================
|
||||
* Description: Retrieve the DIAMETER process block
|
||||
* Parameters: diameter - context
|
||||
* Returns: The process block
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip_proc_t *
|
||||
ipmip4_diameter_proc(struct Ipmip4_diameter_context *diameter)
|
||||
{
|
||||
return diameter->proc;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#else
|
||||
int ipmip4_diameter_empty_file = 0;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,75 @@
|
||||
/* ipmip4_h.h - ipmip4_h.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_h.h,v $ $Revision: 1.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/src/ipmip4_h.h,v $
|
||||
* $Author: jhorteli $ $Date: 2008-02-20 12:21:56 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_H_H
|
||||
#define IPMIP4_H_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
No description currently provided
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include "ipmip4.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,490 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_if.c,v $ $Revision: 1.24.16.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/src/ipmip4_if.c,v $
|
||||
* $Author: jsheng $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip4_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_drv_eth_filter.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_sysctl.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_netif.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_netlink.h>
|
||||
#include <private/ipmip_log.h>
|
||||
|
||||
#include "ipmip4_h.h"
|
||||
#include <private/ipmip4_util.h>
|
||||
#include <private/ipmip4_if.h>
|
||||
#include <private/ipmip4_pkt.h>
|
||||
#include <private/ipmip4_pktbuf.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_if_destroy_tunnel
|
||||
*===========================================================================
|
||||
* Description: Destroy a particular tunnel.
|
||||
* Parameters: iff - The tunnel to destroy.
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmip4_if_destroy_tunnel(Ipmip4_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip4_if_t *iff)
|
||||
{
|
||||
struct Ip_ifreq ifreq;
|
||||
int i;
|
||||
|
||||
/* No tunnel, don't bother */
|
||||
if (iff->ipmip.ifindex == 0)
|
||||
return;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
/* Do down & destroy */
|
||||
ipmip_if_clear_flags(&ctx->ipmip, proc, &iff->ipmip, IP_IFF_UP);
|
||||
if (ipmip_if_ioctl(&ctx->ipmip, proc, &iff->ipmip, IP_SIOCIFDESTROY, &ifreq) < 0)
|
||||
{
|
||||
IPCOM_LOG3(ERR, "ipcom_socketioctl(%s, IP_SIOCIFDESTROY) failed: %s [%d]",
|
||||
iff->ipmip.ifname,
|
||||
ipcom_strerror(ipcom_errno),
|
||||
ipcom_errno);
|
||||
ipcom_sleep(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPCOM_LOG1(DEBUG, "tunnel interface '%s' destroyed",
|
||||
iff->ipmip.ifname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset index */
|
||||
iff->ipmip.ifindex = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_if_free
|
||||
*===========================================================================
|
||||
* Description: Destroy and free the interface specific data.
|
||||
* Parameters: ctx - Context
|
||||
* proc - Process
|
||||
* iff - the interface to destroy
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmip4_if_free(Ipmip4_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip4_if_t *iff)
|
||||
{
|
||||
/* Invoke cleanup functionality */
|
||||
if (iff->cleanup)
|
||||
(*iff->cleanup) (&ctx->ipmip, proc, &iff->ipmip);
|
||||
|
||||
/* Destroy this particular tunnel */
|
||||
if (iff->ipmip.type == IPMIP_IF_TYPE_TUNNEL)
|
||||
ipmip4_if_destroy_tunnel(ctx, proc, iff);
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_if_alloc
|
||||
*===========================================================================
|
||||
* Description: Allocate and initialize the interface structure
|
||||
* Parameters: ctx - Context
|
||||
* proc - Process
|
||||
* ifsize - the size of the interface structure
|
||||
* ifname - The interface name
|
||||
* ifindex - The interface index.
|
||||
* type - Type of interface
|
||||
* identity- The interface identity.
|
||||
* cleanup - Function to be invoked prior to free.
|
||||
* Returns: The interface structure on success.
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_if_t *
|
||||
ipmip4_if_alloc(Ipmip4_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ip_size_t ifsize,
|
||||
const char *ifname,
|
||||
Ip_u32 ifindex,
|
||||
Ip_u8 type,
|
||||
Ip_u8 identity,
|
||||
Ipmip_if_cleanup_t cleanup)
|
||||
{
|
||||
Ipmip4_if_t *iff = (Ipmip4_if_t *)ipmip_if_alloc(&ctx->ipmip,
|
||||
proc,
|
||||
ifsize,
|
||||
ifname,
|
||||
ifindex,
|
||||
type,
|
||||
identity,
|
||||
(Ipmip_if_cleanup_t)ipmip4_if_free);
|
||||
|
||||
if (iff == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
ipcom_list_init(&iff->pktbufs);
|
||||
iff->cleanup = cleanup;
|
||||
return iff;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipfa_if_alloc_tunnel
|
||||
*===========================================================================
|
||||
* Description: Create a specific tunnel for the provided interface
|
||||
* Parameters: ctx - Context
|
||||
* proc - Process
|
||||
* ifsize - Total size of the interface structure
|
||||
* ifname - Wanted ifname
|
||||
* local - The local endpoint
|
||||
* local_port - Base port for NAT_T setup
|
||||
* remote - Remote endpoint
|
||||
* identity - The identity of the tunnel
|
||||
* tunnel_type - Tunnel type
|
||||
* reorder - Enable reordering if supported by interface
|
||||
* cleanup - Function to be invoked prior to free.
|
||||
* Returns: The interface structure on success.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_if_t *
|
||||
ipmip4_if_alloc_tunnel(Ipmip4_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ip_size_t ifsize,
|
||||
char *ifname,
|
||||
Ip_u32 local,
|
||||
Ip_u16 local_port,
|
||||
Ip_u32 remote,
|
||||
Ip_u8 identity,
|
||||
Ip_u8 tunnel_type,
|
||||
Ip_bool reorder,
|
||||
Ipmip_if_cleanup_t cleanup)
|
||||
{
|
||||
struct Ip_ifreq ifreq;
|
||||
struct Ip_ifaliasreq alias;
|
||||
struct Ip_ip_tunnel_param tun;
|
||||
struct Ip_sockaddr_in *inaddr;
|
||||
Ip_u16 flags;
|
||||
Ipmip4_if_t *iff;
|
||||
|
||||
/* Allocate the structure */
|
||||
iff = ipmip4_if_alloc(ctx, proc, ifsize, ifname, 0, IPMIP_IF_TYPE_TUNNEL, identity, cleanup);
|
||||
if (iff == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
/* Try create the interface */
|
||||
if (ipmip_if_ioctl(&ctx->ipmip, proc, &iff->ipmip, IP_SIOCIFCREATE, &ifreq) < 0)
|
||||
{
|
||||
IPCOM_LOG3(ERR, "ipcom_socketioctl(%s, IP_SIOCIFCREATE) failed : %s [%d]",
|
||||
iff->ipmip.ifname,
|
||||
ipcom_strerror(ipcom_errno),
|
||||
ipcom_errno);
|
||||
goto destroy;
|
||||
}
|
||||
|
||||
/* May have been modified */
|
||||
ipcom_strncpy(iff->ipmip.ifname, ifreq.ifr_name, IP_IFNAMSIZ);
|
||||
|
||||
/* Store the index */
|
||||
iff->ipmip.ifindex = ipcom_if_nametoindex(iff->ipmip.ifname);
|
||||
iff->ipmip.tunnel_type = tunnel_type;
|
||||
|
||||
/* Change tunnel */
|
||||
ipcom_memset(&tun, 0, sizeof(tun));
|
||||
if((IP_IFNAMSIZ - 1) < strlen(iff->ipmip.ifname))
|
||||
{
|
||||
goto destroy;
|
||||
}
|
||||
ipcom_strcpy(tun.ifr_name, iff->ipmip.ifname);
|
||||
|
||||
tun.local_addr.sin.sin_family = IP_AF_INET;
|
||||
tun.local_addr.sin.sin_addr.s_addr = local;
|
||||
IPCOM_SA_LEN_SET(&tun.local_addr.sin, sizeof(struct Ip_sockaddr_in));
|
||||
|
||||
/* Prepare the tunnel for NAT-T */
|
||||
tun.local_addr.sin.sin_port = local_port;
|
||||
|
||||
tun.remote_addr.sin.sin_family = IP_AF_INET;
|
||||
tun.remote_addr.sin.sin_addr.s_addr = remote;
|
||||
IPCOM_SA_LEN_SET(&tun.remote_addr.sin, sizeof(struct Ip_sockaddr_in));
|
||||
tun.ttl = 64;
|
||||
|
||||
/* Set tunnel interface address */
|
||||
if (local)
|
||||
{
|
||||
ipcom_memset(&alias, 0, sizeof(alias));
|
||||
ipcom_strcpy(alias.ifra_name, ifreq.ifr_name);
|
||||
|
||||
inaddr = (struct Ip_sockaddr_in *)&alias.ifra_addr;
|
||||
inaddr->sin_family = IP_AF_INET;
|
||||
IPCOM_SA_LEN_SET(inaddr, sizeof(struct Ip_sockaddr_in));
|
||||
inaddr->sin_addr.s_addr = local;
|
||||
|
||||
inaddr = (struct Ip_sockaddr_in *)&alias.ifra_mask;
|
||||
inaddr->sin_family = IP_AF_INET;
|
||||
IPCOM_SA_LEN_SET(inaddr, sizeof(struct Ip_sockaddr_in));
|
||||
inaddr->sin_addr.s_addr = 0xffffffff;
|
||||
|
||||
/* Assign the CoA address */
|
||||
if (ipmip_netlink_inX_addr(&ctx->ipmip, proc, IP_AF_INET, IP_RTM_NEWADDR, iff->ipmip.ifindex, &local, 32, 0, 0) < 0)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip,
|
||||
proc,
|
||||
"Unable to assign address to tunnel interface %s",
|
||||
iff->ipmip.ifname));
|
||||
goto destroy;
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
flags = IP_IFF_UP;
|
||||
if (tunnel_type == IPMIP_TUNNELTYPE_MINENC)
|
||||
IP_BIT_SET(flags, IP_IFF_LINK0);
|
||||
if (tunnel_type == IPMIP_TUNNELTYPE_GRE && reorder)
|
||||
IP_BIT_SET(flags, IP_IFF_LINK1);
|
||||
if (ipmip_if_set_flags(&ctx->ipmip, proc, &iff->ipmip, flags) < 0)
|
||||
{
|
||||
IPCOM_LOG3(ERR, "ipcom_socketioctl(%s, IP_SIOCSIFFLAGS) failed: %s [%d]",
|
||||
iff->ipmip.ifname,
|
||||
ipcom_strerror(ipcom_errno),
|
||||
ipcom_errno);
|
||||
goto destroy;
|
||||
}
|
||||
|
||||
/* Set endpoints; will update minenc if set as well. */
|
||||
if (ipmip_util_ioctl(&ctx->ipmip, proc, IP_SIOCCHGTUNNEL, &tun) < 0)
|
||||
{
|
||||
IPCOM_LOG3(ERR, "ipcom_socketioctl(%s, IP_SIOCCHGTUNNEL) failed: %s [%d]",
|
||||
iff->ipmip.ifname,
|
||||
ipcom_strerror(ipcom_errno),
|
||||
ipcom_errno);
|
||||
goto destroy;
|
||||
}
|
||||
|
||||
return iff;
|
||||
|
||||
destroy:
|
||||
ipmip_if_free(&ctx->ipmip, proc, &iff->ipmip);
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_if_get_primary_address
|
||||
*===========================================================================
|
||||
* Description: Get the current primary address of the interface.
|
||||
* Parameters: iff - Interface
|
||||
* Returns: address on success; IP_INADDR_NONE on failure.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_u32
|
||||
ipmip4_if_get_primary_address(Ipmip4_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip4_if_t *iff)
|
||||
{
|
||||
Ipmip_buffer_t reply;
|
||||
int ret;
|
||||
Ip_u32 addr = IP_INADDR_NONE;
|
||||
|
||||
ipmip_buffer_init(&reply);
|
||||
|
||||
if ((ret = ipmip_netlink_inX_addr_dump(&ctx->ipmip, proc, IP_AF_INET, &reply)) < 0)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip,
|
||||
proc,
|
||||
"Unable to dump INET addresses error value %d", -ret));
|
||||
}
|
||||
else
|
||||
{
|
||||
struct Ip_nlmsghdr *nlh = IPMIP_BUFFER_PTR(&reply);
|
||||
Ip_size_t nlh_size = IPMIP_BUFFER_SIZE(&reply);
|
||||
|
||||
/* */
|
||||
while (IP_NLMSG_OK(nlh, nlh_size))
|
||||
{
|
||||
/**/
|
||||
if (nlh->nlmsg_type == IP_RTM_NEWADDR)
|
||||
{
|
||||
struct Ip_ifaddrmsg *ifa = IP_NLMSG_DATA(nlh);
|
||||
struct Ip_rtattr *ifap[IP_IFA_MAX + 1];
|
||||
|
||||
/* Resolve this entry; I want the prefix length and the address */
|
||||
if (ifa->ifa_index == (Ip_s32)iff->ipmip.ifindex)
|
||||
{
|
||||
/* Parse */
|
||||
ipmip_netlink_nlmsghdr_rta_parse(IP_IFA_MAX + 1,
|
||||
IP_IFA_RTA(ifa),
|
||||
IP_IFA_PAYLOAD(nlh),
|
||||
ifap);
|
||||
|
||||
/* Found one */
|
||||
if (ifap[IP_IFA_LOCAL])
|
||||
{
|
||||
if (ifa->ifa_family == IP_AF_INET)
|
||||
{
|
||||
addr = IP_GET_32ON8(IP_RTA_DATA(ifap[IP_IFA_LOCAL]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
nlh = IP_NLMSG_NEXT(nlh, nlh_size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**/
|
||||
ipmip_buffer_release(&reply);
|
||||
return addr;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_if_findbyaddr
|
||||
*===========================================================================
|
||||
* Description: Locate an interface in our configuration based on address.
|
||||
* Parameters: iflist - The list of interfaces.
|
||||
* addr - The interface address
|
||||
* Returns: The interface pointer if it exists, IP_NULL otherwise.
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_if_t *
|
||||
ipmip4_if_findbyaddr(Ipcom_list *iflist,
|
||||
Ip_u32 addr)
|
||||
{
|
||||
Ipmip4_if_t *iff;
|
||||
|
||||
for (iff = IPCOM_LIST_FIRST(iflist); iff; iff = IPCOM_LIST_NEXT(&iff->ipmip.next))
|
||||
{
|
||||
if (iff->ifaddr == addr)
|
||||
return iff;
|
||||
}
|
||||
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_if_findbypktinfo
|
||||
*===========================================================================
|
||||
* Description: Locate an interface in our configuration based on address.
|
||||
* Parameters: iflist - The list of interfaces
|
||||
* pktinfo - The interface info
|
||||
* Returns: The interface pointer if it exists, IP_NULL otherwise.
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_if_t *
|
||||
ipmip4_if_findbypktinfo(Ipcom_list *iflist,
|
||||
Ipmip_pktbuf_pktinfo_t *pktinfo)
|
||||
{
|
||||
Ipmip4_if_t *iff;
|
||||
|
||||
if ((iff = ipmip4_if_findbyaddr(iflist, pktinfo->dst.sin.sin_addr.s_addr)) == IP_NULL)
|
||||
iff = (Ipmip4_if_t *)ipmip_if_findbyindex(iflist, pktinfo->ifindex);
|
||||
|
||||
return iff;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,120 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_ipnet.c,v $ $Revision: 1.22 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/src/ipmip4_ipnet.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef IPCOM_KERNEL
|
||||
#define IPCOM_KERNEL
|
||||
#endif
|
||||
|
||||
#include "ipnet_config.h"
|
||||
|
||||
#if defined(IPNET) && defined(IPCOM_USE_INET)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_syslog.h>
|
||||
|
||||
#include "ipnet_h.h"
|
||||
#include "ipnet.h"
|
||||
|
||||
#ifdef IPTCP
|
||||
#include "iptcp.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <private/ipmip4_ipnet.h>
|
||||
#include <private/ipmip4_netlink_kern.h>
|
||||
|
||||
#include "ipmip4_ipnet_h.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
#else
|
||||
int ipmip4_ipnet_empty_file = 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,75 @@
|
||||
/* ipmip4_ipnet_h.h - ipmip4_ipnet_h.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_ipnet_h.h,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/src/ipmip4_ipnet_h.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-10-15 11:27:58 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIP4_IPNET_H_H
|
||||
#define IPMIP4_IPNET_H_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
No description currently provided
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <ipnet.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,120 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_ipnet_usr.c,v $ $Revision: 1.16 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/src/ipmip4_ipnet_usr.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip4_config.h"
|
||||
|
||||
#if defined(IPNET) && defined(IPCOM_USE_INET)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_sysctl.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_netif.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_buffer.h>
|
||||
#include <private/ipmip_lladdr.h>
|
||||
|
||||
#include "ipmip4_h.h"
|
||||
#include "ipmip4_ipnet_h.h"
|
||||
|
||||
#include <private/ipmip4_context.h>
|
||||
#include <private/ipmip4_if.h>
|
||||
#include <private/ipmip4_util.h>
|
||||
#include <private/ipmip4_usr.h>
|
||||
#include <private/ipmip4_pkt.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#else /* IPNET */
|
||||
int ipmip4_ipnet_usr_empty_file = 0;
|
||||
#endif
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,608 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_lla.c,v $ $Revision: 1.10 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/src/ipmip4_lla.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip4_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_drv_eth_filter.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_sysctl.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_netif.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
|
||||
#include "ipmip4_h.h"
|
||||
#include <private/ipmip4_lla.h>
|
||||
#include <private/ipmip4_util.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_lla_from_lladdr_types
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_u8
|
||||
ipmip4_lla_llh_from_lladdr_types(Ip_u8 type,
|
||||
Ip_u8 subtype)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case IPMIP_LLADDR_TYPE_3GPP2:
|
||||
return IPMIP4_ICMP_LLA_EXT_SUBTYPE_3GPP2_MOBILE_STATION;
|
||||
case IPMIP_LLADDR_TYPE_3GPP:
|
||||
return IPMIP4_ICMP_LLA_EXT_SUBTYPE_3GPP_MOBILE_SUBSCRIBER;
|
||||
case IPMIP_LLADDR_TYPE_MAC:
|
||||
return IPMIP4_ICMP_LLA_EXT_SUBTYPE_MAC;
|
||||
case IPMIP_LLADDR_TYPE_EUID64:
|
||||
return IPMIP4_ICMP_LLA_EXT_SUBTYPE_EUID64;
|
||||
case IPMIP_LLADDR_TYPE_INET:
|
||||
switch (subtype)
|
||||
{
|
||||
case IPMIP_LLADDR_SUBTYPE_INET_FA:
|
||||
return IPMIP4_ICMP_LLA_EXT_SUBTYPE_FA_ADDRESS;
|
||||
case IPMIP_LLADDR_SUBTYPE_INET_SOLICITED:
|
||||
return IPMIP4_ICMP_LLA_EXT_SUBTYPE_SOLICITED_ADDRESS;
|
||||
}
|
||||
break;
|
||||
case IPMIP_LLADDR_TYPE_BSSID:
|
||||
return IPMIP4_ICMP_LLA_EXT_SUBTYPE_ACCESS_POINT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_lla_to_lladdr_type
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_u8
|
||||
ipmip4_lla_llh_to_lladdr_type(Ip_u8 lla_type)
|
||||
{
|
||||
switch (lla_type)
|
||||
{
|
||||
case IPMIP4_ICMP_LLA_EXT_SUBTYPE_3GPP2_MOBILE_STATION:
|
||||
case IPMIP4_ICMP_LLA_EXT_SUBTYPE_3GPP_MOBILE_SUBSCRIBER:
|
||||
return IPMIP_LLADDR_TYPE_3GPP2;
|
||||
case IPMIP4_ICMP_LLA_EXT_SUBTYPE_MAC:
|
||||
return IPMIP_LLADDR_TYPE_MAC;
|
||||
case IPMIP4_ICMP_LLA_EXT_SUBTYPE_EUID64:
|
||||
return IPMIP_LLADDR_TYPE_EUID64;
|
||||
case IPMIP4_ICMP_LLA_EXT_SUBTYPE_SOLICITED_ADDRESS:
|
||||
case IPMIP4_ICMP_LLA_EXT_SUBTYPE_FA_ADDRESS:
|
||||
return IPMIP_LLADDR_TYPE_INET;
|
||||
case IPMIP4_ICMP_LLA_EXT_SUBTYPE_ACCESS_POINT:
|
||||
return IPMIP_LLADDR_TYPE_BSSID;
|
||||
default:
|
||||
return IPMIP_LLADDR_TYPE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_lla_to_lladdr_subtype
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_u8
|
||||
ipmip4_lla_llh_to_lladdr_subtype(Ip_u8 lla_type)
|
||||
{
|
||||
switch (lla_type)
|
||||
{
|
||||
case IPMIP4_ICMP_LLA_EXT_SUBTYPE_SOLICITED_ADDRESS:
|
||||
return IPMIP_LLADDR_SUBTYPE_INET_SOLICITED;
|
||||
case IPMIP4_ICMP_LLA_EXT_SUBTYPE_FA_ADDRESS:
|
||||
return IPMIP_LLADDR_SUBTYPE_INET_FA;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_lla_llh_find_array_lladdr
|
||||
*===========================================================================
|
||||
* Description: Return a usable source LLA address based on found
|
||||
* extensions and a subtype
|
||||
* Parameters: subtype - The specific subtype
|
||||
* ext - The found LLA extensions.
|
||||
* Returns: The LLA address if it found; IP_NULL Otherwise.
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ipmip4_icmp_lla_ext_t *
|
||||
ipmip4_lla_llh_find_array_lladdr(Ipmip_lladdr_t *lladdr,
|
||||
Ipmip4_msgext_array_t *ext)
|
||||
{
|
||||
if (lladdr)
|
||||
return ipmip4_lla_llh_find_array_subtype(ipmip4_lla_llh_from_lladdr_types(lladdr->type, lladdr->subtype), ext);
|
||||
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_lla_llh_find_array_subtype
|
||||
*===========================================================================
|
||||
* Description: Return a usable source LLA address based on found
|
||||
* extensions and a subtype
|
||||
* Parameters: subtype - The specific subtype
|
||||
* ext - The found LLA extensions.
|
||||
* Returns: The LLA address if it found; IP_NULL Otherwise.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_icmp_lla_ext_t *
|
||||
ipmip4_lla_llh_find_array_subtype(Ip_u8 subtype,
|
||||
Ipmip4_msgext_array_t *ext)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Locate a LLA with the same type as the interface */
|
||||
for (i = 0; i < ext->found; i++)
|
||||
{
|
||||
Ipmip4_icmp_lla_ext_t *lla = (Ipmip4_icmp_lla_ext_t *)ext->ext[i];
|
||||
if (lla->subtype == subtype)
|
||||
return lla;
|
||||
}
|
||||
|
||||
/* No match */
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_lla_llh_convert_lla_to_lladdr
|
||||
*===========================================================================
|
||||
* Description: Return a usable source LLA address based on found
|
||||
* extensions and a subtype
|
||||
* Parameters: subtype - The specific subtype
|
||||
* ext - The found LLA extensions.
|
||||
* Returns: The LLA address if it found; IP_NULL Otherwise.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip_lladdr_t *
|
||||
ipmip4_lla_llh_convert_lla_to_lladdr(Ipmip_lladdr_t *lladdr,
|
||||
Ipmip4_icmp_lla_ext_t *lla)
|
||||
{
|
||||
Ipmip_lladdr_t *nlladdr;
|
||||
|
||||
if (!lla)
|
||||
return IP_NULL;
|
||||
|
||||
nlladdr = ipmip_lladdr_build(IP_NULL,
|
||||
ipmip4_lla_llh_to_lladdr_type(lla->subtype),
|
||||
ipmip4_lla_llh_to_lladdr_subtype(lla->subtype),
|
||||
&lla->lla[0],
|
||||
IPMIP4_ICMP_LLA_EXT_LLA_SIZE(lla));
|
||||
if (lladdr && nlladdr)
|
||||
ipmip_lladdr_sanitize(lladdr, nlladdr);
|
||||
|
||||
return nlladdr;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_lla_llh_convert_array_to_lladdr
|
||||
*===========================================================================
|
||||
* Description: Return a usable source LLA address based on found
|
||||
* extensions and a subtype
|
||||
* Parameters: subtype - The specific subtype
|
||||
* ext - The found LLA extensions.
|
||||
* Returns: The LLA address if it found; IP_NULL Otherwise.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip_lladdr_t *
|
||||
ipmip4_lla_llh_convert_array_to_lladdr(Ipmip_lladdr_t *lladdr,
|
||||
Ipmip4_msgext_array_t *ext)
|
||||
{
|
||||
Ipmip4_icmp_lla_ext_t *lla = ipmip4_lla_llh_find_array_lladdr(lladdr, ext);
|
||||
|
||||
if (!lla)
|
||||
return IP_NULL;
|
||||
|
||||
return ipmip_lladdr_build(IP_NULL,
|
||||
lladdr->type,
|
||||
lladdr->subtype,
|
||||
&lla->lla[0],
|
||||
IPMIP4_ICMP_LLA_EXT_LLA_SIZE(lla));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_lla_buffer_icmp_append
|
||||
*===========================================================================
|
||||
* Description: Append an LLA to a buffer in ICMP mode
|
||||
* Parameters: buffer - The buffer
|
||||
* lla - The LLA
|
||||
* Returns: The offset
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
ipmip4_lla_llh_lladdr_buffer_icmp_append(Ipmip_buffer_t *buffer,
|
||||
Ipmip_lladdr_t *lladdr)
|
||||
{
|
||||
/**/
|
||||
int off = ipmip_buffer_append(buffer, lladdr, lladdr->len);
|
||||
if (off != -1)
|
||||
{
|
||||
Ipmip4_icmp_lla_ext_t *lla;
|
||||
lla = ipmip_buffer_offset(buffer, off);
|
||||
|
||||
/* Convert */
|
||||
lla->length = lladdr->len - 2;
|
||||
lla->type = IPMIP4_ICMP_EXT_TYPE_LLA;
|
||||
lla->subtype = ipmip4_lla_llh_from_lladdr_types(lladdr->type, lladdr->subtype);
|
||||
}
|
||||
|
||||
return off;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_lla_lladdr_buffer_udp_append
|
||||
*===========================================================================
|
||||
* Description: Append an LLA to a buffer in ICMP mode
|
||||
* Parameters: buffer - The buffer
|
||||
* lla - The LLA
|
||||
* Returns: The offset
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
ipmip4_lla_llh_lladdr_buffer_udp_append(Ipmip_buffer_t *buffer,
|
||||
Ipmip_lladdr_t *lladdr)
|
||||
{
|
||||
/**/
|
||||
int off = ipmip_buffer_append(buffer, lladdr, lladdr->len);
|
||||
if (off != -1)
|
||||
{
|
||||
Ipmip4_icmp_lla_ext_t *lla;
|
||||
lla = ipmip_buffer_offset(buffer, off);
|
||||
|
||||
/* Convert */
|
||||
lla->length = lladdr->len - 2;
|
||||
lla->type = IPMIP4_EXT_TYPE_LLA;
|
||||
lla->subtype = ipmip4_lla_llh_from_lladdr_types(lladdr->type, lladdr->subtype);
|
||||
}
|
||||
|
||||
return off;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_lla_from_lladdr_types
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_u8
|
||||
ipmip4_lla_pmipv4_access_type_from_lladdr_types(Ip_u8 type,
|
||||
Ip_u8 subtype)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case IPMIP_LLADDR_TYPE_3GPP2:
|
||||
switch (subtype)
|
||||
{
|
||||
case IPMIP_LLADDR_SUBTYPE_3GPP2_1xRTT_HRPD:
|
||||
return IPMIP4_PMIPV4_ACCESS_TYPE_3GPP2_1XRTT_HRPD;
|
||||
case IPMIP_LLADDR_SUBTYPE_3GPP2_UMB:
|
||||
default:
|
||||
return IPMIP4_PMIPV4_ACCESS_TYPE_3GPP2_UMB;
|
||||
}
|
||||
case IPMIP_LLADDR_TYPE_3GPP:
|
||||
switch (subtype)
|
||||
{
|
||||
case IPMIP_LLADDR_SUBTYPE_3GPP_EUTRAN_LTE:
|
||||
return IPMIP4_PMIPV4_ACCESS_TYPE_3GPP_EUTRAN_LTE;
|
||||
case IPMIP_LLADDR_SUBTYPE_3GPP_UTRAN_GERAN:
|
||||
default:
|
||||
return IPMIP4_PMIPV4_ACCESS_TYPE_3GPP_UTRAN_GERAN;
|
||||
}
|
||||
case IPMIP_LLADDR_TYPE_MAC:
|
||||
switch (subtype)
|
||||
{
|
||||
case IPMIP_LLADDR_SUBTYPE_MAC_802_3:
|
||||
case IPMIP_LLADDR_SUBTYPE_MAC_802_1Q:
|
||||
default:
|
||||
return IPMIP4_PMIPV4_ACCESS_TYPE_802_3;
|
||||
case IPMIP_LLADDR_SUBTYPE_MAC_802_11:
|
||||
return IPMIP4_PMIPV4_ACCESS_TYPE_802_11ABG;
|
||||
case IPMIP_LLADDR_SUBTYPE_MAC_802_16E:
|
||||
return IPMIP4_PMIPV4_ACCESS_TYPE_802_16E;
|
||||
case IPMIP_LLADDR_SUBTYPE_MAC_802_16M:
|
||||
return IPMIP4_PMIPV4_ACCESS_TYPE_802_16M;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
IP_GLOBAL Ip_u8
|
||||
ipmip4_lla_pmipv4_device_id_type_from_lladdr_types(Ip_u8 type,
|
||||
Ip_u8 subtype)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(subtype);
|
||||
switch (type)
|
||||
{
|
||||
case IPMIP_LLADDR_TYPE_MAC:
|
||||
return IPMIP4_PMIPV4_DEVICE_ID_ETH;
|
||||
case IPMIP_LLADDR_TYPE_ESN:
|
||||
return IPMIP4_PMIPV4_DEVICE_ID_ESN;
|
||||
case IPMIP_LLADDR_TYPE_MEID:
|
||||
return IPMIP4_PMIPV4_DEVICE_ID_MEID;
|
||||
case IPMIP_LLADDR_TYPE_IMEI:
|
||||
return IPMIP4_PMIPV4_DEVICE_ID_IMEI;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_GLOBAL void
|
||||
ipmip4_lla_pmipv4_lladdr_buffer_access_type_append(Ipmip_buffer_t *buffer,
|
||||
Ipmip_lladdr_t *lladdr)
|
||||
{
|
||||
/* Convert LLADDR to Interface ID */
|
||||
Ip_u8 attype = ipmip4_lla_pmipv4_access_type_from_lladdr_types(lladdr->type, lladdr->subtype);
|
||||
|
||||
if (attype != 0)
|
||||
{
|
||||
unsigned char *at = ipmip_buffer_get(buffer, 4);
|
||||
|
||||
if (at != IP_NULL)
|
||||
{
|
||||
at[0] = IPMIP4_EXT_TYPE_PMIPV4;
|
||||
at[1] = 2;
|
||||
at[2] = IPMIP4_PMIPV4_SUBTYPE_ACCESS_TYPE;
|
||||
at[3] = attype;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IP_GLOBAL void
|
||||
ipmip4_lla_pmipv4_lladdr_buffer_interface_id_append(Ipmip_buffer_t *buffer,
|
||||
Ipmip_lladdr_t *lladdr)
|
||||
{
|
||||
Ip_size_t llen = IPMIP_LLADDR_LEN_LLA(lladdr);
|
||||
if (llen > 0)
|
||||
{
|
||||
unsigned char *iid = ipmip_buffer_get(buffer, llen + 3);
|
||||
if (iid != 0)
|
||||
{
|
||||
iid[0] = IPMIP4_EXT_TYPE_PMIPV4;
|
||||
iid[1] = llen + 1;
|
||||
iid[2] = IPMIP4_PMIPV4_SUBTYPE_INTERFACE_ID;
|
||||
ipcom_memcpy(&iid[3], IPMIP_LLADDR_DATA(lladdr), llen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IP_GLOBAL void
|
||||
ipmip4_lla_pmipv4_lladdr_buffer_device_id_append(Ipmip_buffer_t *buffer,
|
||||
Ipmip_lladdr_t *lladdr)
|
||||
{
|
||||
Ip_size_t llen = IPMIP_LLADDR_LEN_LLA(lladdr);
|
||||
if (llen > 0)
|
||||
{
|
||||
Ip_u8 type;
|
||||
unsigned char *iid;
|
||||
|
||||
if ((type = ipmip4_lla_pmipv4_device_id_type_from_lladdr_types(lladdr->type, lladdr->subtype)) == 0)
|
||||
return;
|
||||
|
||||
iid = ipmip_buffer_get(buffer, llen + 4);
|
||||
if (iid != 0)
|
||||
{
|
||||
iid[0] = IPMIP4_EXT_TYPE_PMIPV4;
|
||||
iid[1] = llen + 2;
|
||||
iid[2] = IPMIP4_PMIPV4_SUBTYPE_DEVICE_ID;
|
||||
iid[3] = type;
|
||||
|
||||
ipcom_memcpy(&iid[4], IPMIP_LLADDR_DATA(lladdr), llen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_lla_to_lladdr_type
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_u8
|
||||
ipmip4_lla_pmipv4_access_type_to_lladdr_type(Ip_u8 pmipv4_type)
|
||||
{
|
||||
switch (pmipv4_type)
|
||||
{
|
||||
case IPMIP4_PMIPV4_ACCESS_TYPE_802_3:
|
||||
case IPMIP4_PMIPV4_ACCESS_TYPE_802_11ABG:
|
||||
case IPMIP4_PMIPV4_ACCESS_TYPE_802_16E:
|
||||
case IPMIP4_PMIPV4_ACCESS_TYPE_802_16M:
|
||||
return IPMIP_LLADDR_TYPE_MAC;
|
||||
case IPMIP4_PMIPV4_ACCESS_TYPE_3GPP_EUTRAN_LTE:
|
||||
case IPMIP4_PMIPV4_ACCESS_TYPE_3GPP_UTRAN_GERAN:
|
||||
return IPMIP_LLADDR_TYPE_3GPP;
|
||||
case IPMIP4_PMIPV4_ACCESS_TYPE_3GPP2_1XRTT_HRPD:
|
||||
case IPMIP4_PMIPV4_ACCESS_TYPE_3GPP2_UMB:
|
||||
return IPMIP_LLADDR_TYPE_3GPP2;
|
||||
default:
|
||||
return IPMIP_LLADDR_TYPE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
IP_STATIC Ip_u8
|
||||
ipmip4_lla_pmipv4_access_type_to_lladdr_subtype(Ip_u8 pmipv4_type)
|
||||
{
|
||||
switch (pmipv4_type)
|
||||
{
|
||||
case IPMIP4_PMIPV4_ACCESS_TYPE_802_3:
|
||||
return IPMIP_LLADDR_SUBTYPE_MAC_802_3;
|
||||
case IPMIP4_PMIPV4_ACCESS_TYPE_802_11ABG:
|
||||
return IPMIP_LLADDR_SUBTYPE_MAC_802_11;
|
||||
case IPMIP4_PMIPV4_ACCESS_TYPE_802_16E:
|
||||
return IPMIP_LLADDR_SUBTYPE_MAC_802_16E;
|
||||
case IPMIP4_PMIPV4_ACCESS_TYPE_802_16M:
|
||||
return IPMIP_LLADDR_SUBTYPE_MAC_802_16M;
|
||||
case IPMIP4_PMIPV4_ACCESS_TYPE_3GPP_EUTRAN_LTE:
|
||||
return IPMIP_LLADDR_SUBTYPE_3GPP_EUTRAN_LTE;
|
||||
case IPMIP4_PMIPV4_ACCESS_TYPE_3GPP_UTRAN_GERAN:
|
||||
return IPMIP_LLADDR_SUBTYPE_3GPP_UTRAN_GERAN;
|
||||
case IPMIP4_PMIPV4_ACCESS_TYPE_3GPP2_1XRTT_HRPD:
|
||||
return IPMIP_LLADDR_SUBTYPE_3GPP2_1xRTT_HRPD;
|
||||
case IPMIP4_PMIPV4_ACCESS_TYPE_3GPP2_UMB:
|
||||
return IPMIP_LLADDR_SUBTYPE_3GPP2_UMB;
|
||||
default:
|
||||
return IPMIP_LLADDR_TYPE_NONE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
IP_GLOBAL Ipmip_lladdr_t *
|
||||
ipmip4_lla_pmipv4_interface_id_convert_to_lladdr(Ipmip_lladdr_t *lladdr,
|
||||
Ipmip4_msgext_uhdr_t *ifid)
|
||||
{
|
||||
Ipmip_lladdr_t *nlladdr;
|
||||
Ipmip4_pmipv4_interface_id_t *id = (Ipmip4_pmipv4_interface_id_t *)ifid;
|
||||
|
||||
nlladdr = ipmip_lladdr_build(IP_NULL,
|
||||
lladdr->type,
|
||||
lladdr->subtype,
|
||||
&id->identifier[0],
|
||||
IPMIP4_MSGEXT_SHDR_EXT_SIZE(ifid) - 1);
|
||||
return nlladdr;
|
||||
}
|
||||
|
||||
IP_GLOBAL Ipmip_lladdr_t *
|
||||
ipmip4_lla_pmipv4_device_id_convert_to_lladdr(Ipmip_lladdr_t *lladdr,
|
||||
Ipmip4_msgext_uhdr_t *ifid)
|
||||
{
|
||||
Ipmip_lladdr_t *nlladdr;
|
||||
Ipmip4_pmipv4_device_id_t *id = (Ipmip4_pmipv4_device_id_t *)ifid;
|
||||
|
||||
/**/
|
||||
nlladdr = ipmip_lladdr_build(IP_NULL,
|
||||
lladdr->type,
|
||||
lladdr->subtype,
|
||||
&id->identifier[0],
|
||||
IPMIP4_MSGEXT_SHDR_EXT_SIZE(ifid) - 2);
|
||||
|
||||
return nlladdr;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,429 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_netlink.c,v $ $Revision: 1.7.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/src/ipmip4_netlink.c,v $
|
||||
* $Author: svc-cmnet $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip4_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_clib2.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_sysctl.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_log.h>
|
||||
|
||||
#include "ipmip4_h.h"
|
||||
#include <private/ipmip4_context.h>
|
||||
#include <private/ipmip4_msgext.h>
|
||||
#include <private/ipmip4_netlink.h>
|
||||
#include <private/ipmip4_util.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
IP_GLOBAL Ip_bool
|
||||
ipmip4_netlink_get_handle_stat(struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmip_netlink_kern_handle_t *handle,
|
||||
Ipmip4_netlink_kern_statistics_t *link_recv,
|
||||
Ipmip4_netlink_kern_statistics_t *link_send)
|
||||
{
|
||||
Ipmip_buffer_t rbuf;
|
||||
Ip_size_t hdr_off;
|
||||
struct Ip_mipmsg *msg;
|
||||
int ret;
|
||||
Ipmip_buffer_t reply;
|
||||
|
||||
ipmip_buffer_init(&rbuf);
|
||||
ipmip_buffer_init(&reply);
|
||||
|
||||
/* Create NLMSG HDR */
|
||||
ipmip_netlink_nlmsghdr_request(&rbuf, 0, 0, IP_RTM_GETMIP, 0);
|
||||
msg = ipmip_buffer_offset(&rbuf, ipmip_netlink_nlmsghdr_put(&rbuf, IP_NULL, sizeof(*msg)));
|
||||
|
||||
msg->mip_family = IP_AF_INET;
|
||||
msg->mip_type = IP_WRMOB4_GET_HANDLE_STAT;
|
||||
msg->mip_flags = 0;
|
||||
|
||||
/* Create the nested HoA attribute */
|
||||
hdr_off = ipmip_netlink_nlmsghdr_rta_begin(&rbuf, IP_MIP_ENCAP);
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_HANDLE, sizeof(*handle), handle);
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_end(&rbuf, hdr_off);
|
||||
|
||||
/* Complete the buffer */
|
||||
ipmip_netlink_nlmsghdr_done(&rbuf, 0);
|
||||
|
||||
/* NETLINK request */
|
||||
ret = ipmip_netlink_request(&ctx->ipmip,
|
||||
proc,
|
||||
ctx->ipmip.nl_req,
|
||||
0,
|
||||
0,
|
||||
(struct Ip_nlmsghdr *)IPMIP_BUFFER_PTR(&rbuf),
|
||||
&reply);
|
||||
/**/
|
||||
ipmip_buffer_release(&rbuf);
|
||||
|
||||
if (ret >= 0)
|
||||
{
|
||||
struct Ip_nlmsghdr *nlhdr = IPMIP_BUFFER_PTR(&reply);
|
||||
Ip_size_t sz = IPMIP_BUFFER_SIZE(&reply);
|
||||
|
||||
while (IP_NLMSG_OK(nlhdr, sz))
|
||||
{
|
||||
if (nlhdr->nlmsg_type == IP_RTM_GETMIP)
|
||||
{
|
||||
struct Ip_rtattr *rta = IP_MIP_RTA(IP_NLMSG_DATA(nlhdr));
|
||||
Ip_size_t rta_sz = IP_MIP_PAYLOAD(nlhdr);
|
||||
|
||||
while (IP_RTA_OK(rta, rta_sz))
|
||||
{
|
||||
if (rta->rta_type == IP_MIP_ENCAP)
|
||||
{
|
||||
/**/
|
||||
struct Ip_rtattr *srta[IP_WRMOB4_STATS_MAX + 1];
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_parse(IP_WRMOB4_STATS_MAX + 1,
|
||||
IP_RTA_DATA(rta),
|
||||
IP_RTA_PAYLOAD(rta),
|
||||
srta);
|
||||
|
||||
/* Add statistics */
|
||||
ipcom_memcpy(link_recv, IP_RTA_DATA(srta[IP_WRMOB4_STATS_LINK_RECV]), sizeof(*link_recv));
|
||||
ipcom_memcpy(link_send, IP_RTA_DATA(srta[IP_WRMOB4_STATS_LINK_SEND]), sizeof(*link_send));
|
||||
ipmip_buffer_release(&reply);
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
rta = IP_RTA_NEXT(rta, rta_sz);
|
||||
}
|
||||
}
|
||||
|
||||
nlhdr = IP_NLMSG_NEXT(nlhdr, sz);
|
||||
}
|
||||
}
|
||||
|
||||
ipmip_buffer_release(&reply);
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
|
||||
IP_GLOBAL int
|
||||
ipmip4_netlink_del_handle(struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_u32 facility,
|
||||
Ip_u32 identity)
|
||||
{
|
||||
Ipmip_buffer_t rbuf;
|
||||
Ip_size_t hdr_off;
|
||||
struct Ip_mipmsg *msg;
|
||||
int ret;
|
||||
Ipmip_netlink_kern_handle_t handle;
|
||||
|
||||
ipmip_buffer_init(&rbuf);
|
||||
|
||||
/* Create NLMSG HDR */
|
||||
ipmip_netlink_nlmsghdr_request(&rbuf, 0, 0, IP_RTM_DELMIP, 0);
|
||||
msg = ipmip_buffer_offset(&rbuf, ipmip_netlink_nlmsghdr_put(&rbuf, IP_NULL, sizeof(*msg)));
|
||||
|
||||
msg->mip_family = IP_AF_INET;
|
||||
msg->mip_type = IP_WRMOB4_DEL_HANDLE;
|
||||
msg->mip_flags = 0;
|
||||
|
||||
/* Create the nested HoA attribute */
|
||||
hdr_off = ipmip_netlink_nlmsghdr_rta_begin(&rbuf, IP_MIP_ENCAP);
|
||||
|
||||
/* Identity */
|
||||
handle.mip_facility = facility;
|
||||
handle.mip_ident = identity;
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_HANDLE, sizeof(handle), &handle);
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_end(&rbuf, hdr_off);
|
||||
|
||||
/* Complete the buffer */
|
||||
ipmip_netlink_nlmsghdr_done(&rbuf, 0);
|
||||
|
||||
/* NETLINK request */
|
||||
ret = ipmip_netlink_request(&ctx->ipmip,
|
||||
proc,
|
||||
ctx->ipmip.nl_req,
|
||||
0,
|
||||
0,
|
||||
(struct Ip_nlmsghdr *)IPMIP_BUFFER_PTR(&rbuf),
|
||||
IP_NULL);
|
||||
/**/
|
||||
ipmip_buffer_release(&rbuf);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip,
|
||||
proc,
|
||||
"Unable to perform MIP4 DEL HANDLE = %d", -ret));
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
IP_GLOBAL int
|
||||
ipmip4_netlink_new_handle(struct Ipmip4_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_u32 facility,
|
||||
Ip_u32 identity)
|
||||
{
|
||||
Ipmip_buffer_t rbuf;
|
||||
Ip_size_t hdr_off;
|
||||
struct Ip_mipmsg *msg;
|
||||
int ret;
|
||||
Ipmip_netlink_kern_handle_t handle;
|
||||
|
||||
ipmip_buffer_init(&rbuf);
|
||||
|
||||
/* Create NLMSG HDR */
|
||||
ipmip_netlink_nlmsghdr_request(&rbuf, 0, 0, IP_RTM_NEWMIP, 0);
|
||||
msg = ipmip_buffer_offset(&rbuf, ipmip_netlink_nlmsghdr_put(&rbuf, IP_NULL, sizeof(*msg)));
|
||||
|
||||
msg->mip_family = IP_AF_INET;
|
||||
msg->mip_type = IP_WRMOB4_NEW_HANDLE;
|
||||
msg->mip_flags = 0;
|
||||
|
||||
/* Create the nested HoA attribute */
|
||||
hdr_off = ipmip_netlink_nlmsghdr_rta_begin(&rbuf, IP_MIP_ENCAP);
|
||||
|
||||
/* Identity */
|
||||
handle.mip_facility = facility;
|
||||
handle.mip_ident = identity;
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_HANDLE, sizeof(handle), &handle);
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_end(&rbuf, hdr_off);
|
||||
|
||||
/* Complete the buffer */
|
||||
ipmip_netlink_nlmsghdr_done(&rbuf, 0);
|
||||
|
||||
/* NETLINK request */
|
||||
ret = ipmip_netlink_request(&ctx->ipmip,
|
||||
proc,
|
||||
ctx->ipmip.nl_req,
|
||||
0,
|
||||
0,
|
||||
(struct Ip_nlmsghdr *)IPMIP_BUFFER_PTR(&rbuf),
|
||||
IP_NULL);
|
||||
/**/
|
||||
ipmip_buffer_release(&rbuf);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip,
|
||||
proc,
|
||||
"Unable to perform MIP4 NEW HANDLE = %d", -ret));
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
IP_GLOBAL int
|
||||
ipmip4_netlink_address_do(Ipmip4_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
int cmd,
|
||||
Ip_u16 type,
|
||||
Ip_u8 flags,
|
||||
Ip_u32 ifindex,
|
||||
Ip_u8 family,
|
||||
const void *addr,
|
||||
Ipmip_buffer_t *reply)
|
||||
{
|
||||
Ipmip_buffer_t rbuf;
|
||||
Ip_size_t hdr_off;
|
||||
struct Ip_mipmsg *msg;
|
||||
int ret;
|
||||
|
||||
ipmip_buffer_init(&rbuf);
|
||||
|
||||
/* Create NLMSG HDR */
|
||||
ipmip_netlink_nlmsghdr_request(&rbuf, 0, 0, cmd, 0);
|
||||
msg = ipmip_buffer_offset(&rbuf, ipmip_netlink_nlmsghdr_put(&rbuf, IP_NULL, sizeof(*msg)));
|
||||
|
||||
msg->mip_family = IP_AF_INET;
|
||||
msg->mip_type = type;
|
||||
msg->mip_flags = flags;
|
||||
|
||||
/* Create the nested HoA attribute */
|
||||
hdr_off = ipmip_netlink_nlmsghdr_rta_begin(&rbuf, IP_MIP_ENCAP);
|
||||
if (addr)
|
||||
ipmip_netlink_nlmsghdr_rta_put_inX(&rbuf, IP_WRMOB4_HOA_ADDRESS, family, addr);
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_HOA_IFINDEX, ifindex);
|
||||
ipmip_netlink_nlmsghdr_rta_end(&rbuf, hdr_off);
|
||||
|
||||
/* Complete the buffer */
|
||||
ipmip_netlink_nlmsghdr_done(&rbuf, 0);
|
||||
|
||||
/* NETLINK request */
|
||||
ret = ipmip_netlink_request(&ctx->ipmip,
|
||||
proc,
|
||||
ctx->ipmip.nl_req,
|
||||
0,
|
||||
0,
|
||||
(struct Ip_nlmsghdr *)IPMIP_BUFFER_PTR(&rbuf),
|
||||
reply);
|
||||
/**/
|
||||
ipmip_buffer_release(&rbuf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
IP_GLOBAL int
|
||||
ipmip4_netlink_route_validate(Ipmip4_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ip_u32 ifindex,
|
||||
Ip_u32 addr,
|
||||
Ipmip_buffer_t *reply)
|
||||
{
|
||||
Ipmip_buffer_t rbuf;
|
||||
Ip_size_t hdr_off;
|
||||
struct Ip_mipmsg *msg;
|
||||
int ret;
|
||||
|
||||
ipmip_buffer_init(&rbuf);
|
||||
|
||||
/* Create NLMSG HDR */
|
||||
ipmip_netlink_nlmsghdr_request(&rbuf, 0, 0, IP_RTM_GETMIP, 0);
|
||||
msg = ipmip_buffer_offset(&rbuf, ipmip_netlink_nlmsghdr_put(&rbuf, IP_NULL, sizeof(*msg)));
|
||||
|
||||
msg->mip_family = IP_AF_INET;
|
||||
msg->mip_type = IP_WRMOB4_GET_VALIDATE_ROUTE;
|
||||
msg->mip_flags = 0;
|
||||
|
||||
/* Create the nested HoA attribute */
|
||||
hdr_off = ipmip_netlink_nlmsghdr_rta_begin(&rbuf, IP_MIP_ENCAP);
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_IFINDEX, ifindex);
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_DST, 4, &addr);
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_end(&rbuf, hdr_off);
|
||||
|
||||
/* Complete the buffer */
|
||||
ipmip_netlink_nlmsghdr_done(&rbuf, 0);
|
||||
|
||||
/* NETLINK request */
|
||||
ret = ipmip_netlink_request(&ctx->ipmip,
|
||||
proc,
|
||||
ctx->ipmip.nl_req,
|
||||
0,
|
||||
0,
|
||||
(struct Ip_nlmsghdr *)IPMIP_BUFFER_PTR(&rbuf),
|
||||
reply);
|
||||
/**/
|
||||
ipmip_buffer_release(&rbuf);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip,
|
||||
proc,
|
||||
"Unable to perform MIP4 command VALIDATE = %d", -ret));
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,112 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_ntop.c,v $ $Revision: 1.11 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/src/ipmip4_ntop.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip4_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_drv_eth_filter.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_sysctl.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_netif.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
|
||||
#include "ipmip4_h.h"
|
||||
#include <private/ipmip4_lla.h>
|
||||
#include <private/ipmip4_ntop.h>
|
||||
#include <private/ipmip4_context.h>
|
||||
#include <private/ipmip4_util.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,590 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_sysext.c,v $ $Revision: 1.19 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/src/ipmip4_sysext.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip4_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
|
||||
#include "ipmip4_h.h"
|
||||
#include <private/ipmip4_sysext.h>
|
||||
#include <private/ipmip4_util.h>
|
||||
#include <private/ipmip4_auth.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
Ipmip_sysvar_key_map_t ipmip4_sysext_spi_method[] =
|
||||
{
|
||||
{ IPMIP4_AUTH_METHOD_MD5_HMAC, "md5-hmac" },
|
||||
{ IPMIP4_AUTH_METHOD_MD5_HMAC, "hmac-md5" },
|
||||
{ IPMIP4_AUTH_METHOD_MD5_HMAC, "md5" },
|
||||
{ IPMIP4_AUTH_METHOD_CHAP, "chap" },
|
||||
{ IPMIP4_AUTH_METHOD_KEYGEN, "keygen" },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_sysext_nvse_alloc
|
||||
*===========================================================================
|
||||
* Description: Create an NVSE extension based on vendor, subtype and data
|
||||
* Parameters: vendor - Vendor ID
|
||||
* subtype - Vendor NVSE subtype
|
||||
* value - The vendor value
|
||||
* size - The size of value
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_msgext_uhdr_t *
|
||||
ipmip4_sysext_nvse_alloc(Ip_u32 vendor,
|
||||
Ip_u16 subtype,
|
||||
void *data,
|
||||
Ip_size_t size)
|
||||
{
|
||||
Ip_u8 *vse = ipcom_calloc(1, 10 + size);
|
||||
if (vse)
|
||||
{
|
||||
vse[0] = IPMIP4_EXT_TYPE_NVSE;
|
||||
vse[1] = (Ip_u8) (10 + size - 2);
|
||||
IP_SET_HTONL(&vse[4], vendor);
|
||||
IP_SET_HTONS(&vse[8], subtype);
|
||||
ipcom_memcpy(&vse[10], data, size);
|
||||
}
|
||||
|
||||
return (Ipmip4_msgext_uhdr_t *) vse;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_sysext_cvse_alloc
|
||||
*===========================================================================
|
||||
* Description: Create an CVSE extension based on vendor, subtype and data
|
||||
* Parameters: vendor - Vendor ID
|
||||
* subtype - Vendor CVSE subtype
|
||||
* value - The vendor value
|
||||
* size - The size of value
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_msgext_uhdr_t *
|
||||
ipmip4_sysext_cvse_alloc(Ip_u32 vendor,
|
||||
Ip_u16 subtype,
|
||||
void *data,
|
||||
Ip_size_t size)
|
||||
{
|
||||
Ip_u8 *vse = ipcom_calloc(1, 10 + size);
|
||||
if (vse)
|
||||
{
|
||||
vse[0] = IPMIP4_EXT_TYPE_CVSE;
|
||||
IP_SET_HTONS(&vse[2], (10 + size - 4));
|
||||
IP_SET_HTONL(&vse[4], vendor);
|
||||
IP_SET_HTONS(&vse[8], subtype);
|
||||
ipcom_memcpy(&vse[10], data, size);
|
||||
}
|
||||
|
||||
return (Ipmip4_msgext_uhdr_t *) vse;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_sysext_spi_parse
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_auth_spi_t *
|
||||
ipmip4_sysext_spi_parse(struct Ipmip_proc *proc,
|
||||
Ip_u32 defspi,
|
||||
Ip_u32 spival,
|
||||
const char *secret,
|
||||
const char *delim,
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
va_list ap;
|
||||
char *spec;
|
||||
|
||||
|
||||
va_start(ap, format);
|
||||
spec = ipmip_util_vstrdup(format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (spec)
|
||||
{
|
||||
Ipmip4_auth_spi_t *spi;
|
||||
char *vsecret = (char *)secret;
|
||||
int method;
|
||||
|
||||
if (spival == 0)
|
||||
spival = ipmip_sysvar_ulong(defspi, "%s%sspi", spec, delim);
|
||||
|
||||
if (spival == 0)
|
||||
{
|
||||
ipcom_free(spec);
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
/**/
|
||||
method = ipmip_sysvar_key(spival == IPMIP4_AUTH_SPI_CHAP_SPI? IPMIP4_AUTH_METHOD_CHAP : IPMIP4_AUTH_METHOD_MD5_HMAC, ipmip4_sysext_spi_method, "%s%smethod", spec, delim);
|
||||
|
||||
/* Try read the secret */
|
||||
if (vsecret == IP_NULL)
|
||||
{
|
||||
vsecret = ipmip_sysvar("%s%ssecret", spec, delim);
|
||||
if (vsecret == IP_NULL)
|
||||
vsecret = ipmip_sysvar(spec);
|
||||
}
|
||||
|
||||
if (vsecret == IP_NULL)
|
||||
{
|
||||
ipcom_free(spec);
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
/* Create the SPI */
|
||||
spi = ipmip4_auth_spi_create(proc, spival, vsecret, ipcom_strlen(vsecret), method);
|
||||
|
||||
/* Free memory */
|
||||
ipcom_free(spec);
|
||||
if (vsecret != IP_NULL && vsecret != secret)
|
||||
ipcom_free(vsecret);
|
||||
|
||||
return spi;
|
||||
}
|
||||
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
* ipmip4_sysext_foreach_spi
|
||||
*===========================================================================
|
||||
* Description: Parse the configured SPI's
|
||||
* Parameters: proc - Current process
|
||||
* name - Name of the sysvar key
|
||||
* subkey - The matched subkey
|
||||
* value - The SPI value
|
||||
* spictx - The spi context
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmip4_sysext_foreach_spi(struct Ipmip_proc *proc,
|
||||
char *name,
|
||||
char *subkey,
|
||||
const char *value,
|
||||
Ipmip4_auth_context_t *spictx)
|
||||
{
|
||||
/* Dont care about subkeys */
|
||||
char *dot;
|
||||
IPMIP_UNUSED_PARAMETER(name);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if ((dot = ipcom_strchr(subkey, '.')) == IP_NULL || ipcom_strcasecmp(dot, ".secret") == 0)
|
||||
{
|
||||
Ip_u32 spival = ipcom_strtoul(subkey, IP_NULL, 10);
|
||||
Ipmip4_auth_spi_t *spi;
|
||||
|
||||
if (spival < 256)
|
||||
return;
|
||||
|
||||
/**/
|
||||
spi = ipmip4_sysext_spi_parse(proc, 0, spival, value, ".", dot? ipmip_ntop_strn(proc, name, dot - name) : name);
|
||||
if (spi)
|
||||
ipmip4_auth_spi_add(spictx, spi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
* ipmip4_sysext_foreach_spiroute
|
||||
*===========================================================================
|
||||
* Description: Parse the configured SPI lookup definitions
|
||||
* Parameters: proc - Current process
|
||||
* name - Name of the sysvar key
|
||||
* subkey - The matched subkey
|
||||
* value - The SPI value
|
||||
* rtab - The route table
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmip4_sysext_foreach_spiroute(struct Ipmip_proc *proc,
|
||||
char *name,
|
||||
char *subkey,
|
||||
const char *value,
|
||||
Ipmip4_auth_spi_table_t *rtab)
|
||||
{
|
||||
Ip_u32 addr;
|
||||
Ip_u32 plen;
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(name);
|
||||
|
||||
/* Dont care about subkeys */
|
||||
if (ipcom_strcasecmp(subkey, "any") == 0)
|
||||
{
|
||||
/* Wildcard match */
|
||||
addr = 0;
|
||||
plen = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (ipmip_util_inet(subkey, &addr, &plen) == IP_FALSE)
|
||||
{
|
||||
IPCOM_LOG1(ERR,
|
||||
"SPI key '%s' is not a valid address",
|
||||
subkey);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
IPCOM_LOG3(DEBUG2,
|
||||
"Route SPI lookup %s/%d for SPI %s",
|
||||
ipmip_ntop_inet(proc, addr),
|
||||
plen,
|
||||
subkey);
|
||||
|
||||
/* Add the SPI route */
|
||||
ipmip4_auth_spi_table_add(rtab, addr, plen, ipcom_strtoul(value, IP_NULL, 10));
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
* ipmip4_sysext_foreach_spiroute
|
||||
*===========================================================================
|
||||
* Description: Parse the configured SPI lookup definitions
|
||||
* Parameters: proc - Current process
|
||||
* name - Name of the sysvar key
|
||||
* subkey - The matched subkey
|
||||
* value - The SPI value
|
||||
* htable - The spi hash table
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmip4_sysext_foreach_spihash(struct Ipmip_proc *proc,
|
||||
char *name,
|
||||
char *subkey,
|
||||
const char *value,
|
||||
Ipmip4_auth_spi_hash_t *htable)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(name);
|
||||
|
||||
/* Add the SPI route */
|
||||
IPCOM_LOG3(DEBUG2,
|
||||
"NAI SPI lookup %s (%d) for SPI %d", subkey, ipcom_strlen(subkey), ipcom_strtoul(value, IP_NULL, 10));
|
||||
if (!ipmip4_auth_spi_hash_add(htable, subkey, ipcom_strlen(subkey), ipcom_strtoul(value, IP_NULL, 10)))
|
||||
{
|
||||
IPCOM_LOG2(WARNING,
|
||||
"FAILED: NAI SPI lookup %s for SPI %d", subkey, ipcom_strtoul(value, IP_NULL, 10));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_sysext_nai_aaah
|
||||
*===========================================================================
|
||||
* Description: Parse and create a NAI AAAH from a sysvar
|
||||
* Parameters: format - The sysvar format key.
|
||||
* ... - Optional arguments
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_msgext_shdr_t *
|
||||
ipmip4_sysext_nai_aaah(const char *format,
|
||||
/* args */ ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *nai;
|
||||
Ipmip4_msgext_shdr_t *aaah_nai = IP_NULL;
|
||||
|
||||
va_start(ap, format);
|
||||
nai = ipmip_vsysvar(format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (nai != IP_NULL)
|
||||
{
|
||||
aaah_nai = ipmip4_sysext_nai_aaah_create((Ip_u8 *)nai, ipcom_strlen(nai));
|
||||
ipcom_free(nai);
|
||||
}
|
||||
|
||||
return aaah_nai;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_sysext_nai_ha
|
||||
*===========================================================================
|
||||
* Description: Parse and create a NAI HA from a sysvar
|
||||
* Parameters: format - The sysvar format key.
|
||||
* ... - Optional arguments
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_msgext_shdr_t *
|
||||
ipmip4_sysext_nai_ha(const char *format,
|
||||
/* args */ ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *nai;
|
||||
Ipmip4_msgext_shdr_t *ha_nai = IP_NULL;
|
||||
|
||||
va_start(ap, format);
|
||||
nai = ipmip_vsysvar(format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (nai != IP_NULL)
|
||||
{
|
||||
Ip_size_t nai_len = ipcom_strlen(nai);
|
||||
|
||||
if (nai_len >= 3)
|
||||
{
|
||||
Ip_u8 *nai_ext = ipcom_calloc(1, nai_len + 3);
|
||||
|
||||
/* */
|
||||
if (nai_ext != IP_NULL)
|
||||
{
|
||||
nai_ext[0] = IPMIP4_EXT_TYPE_NAI_AGENT;
|
||||
nai_ext[1] = (Ip_u8) (nai_len + 1);
|
||||
nai_ext[2] = IPMIP4_NAI_SUBTYPE_HA;
|
||||
ipcom_strncpy((char *)&nai_ext[3], nai, nai_len);
|
||||
|
||||
/* Store the NAI */
|
||||
ha_nai = (void*) nai_ext;
|
||||
}
|
||||
}
|
||||
else if (nai_len)
|
||||
{
|
||||
IPCOM_LOG0(WARNING, "Too short HA NAI. Syntax is hostname@domain");
|
||||
}
|
||||
|
||||
ipcom_free(nai);
|
||||
}
|
||||
|
||||
return ha_nai;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_sysext_nai_mn
|
||||
*===========================================================================
|
||||
* Description: Parse and create a NAI MN from a sysvar
|
||||
* Parameters: format - The sysvar format key.
|
||||
* ... - Optional arguments
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_msgext_shdr_t *
|
||||
ipmip4_sysext_nai_mn(const char *format,
|
||||
/* args */ ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *nai;
|
||||
Ipmip4_msgext_shdr_t *mn_nai = IP_NULL;
|
||||
|
||||
va_start(ap, format);
|
||||
nai = ipmip_vsysvar(format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (nai)
|
||||
mn_nai = ipmip4_msgext_nai_mn(IP_NULL, nai, ipcom_strlen(nai));
|
||||
|
||||
if (nai != IP_NULL)
|
||||
ipcom_free(nai);
|
||||
|
||||
return mn_nai;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_sysext_tunnel_type
|
||||
*===========================================================================
|
||||
* Description: Interpret a tunnel protocol to its tunnel type index
|
||||
* Parameters: deftype - Default type index
|
||||
* format - The sysvar format string
|
||||
* ... - The optional arguments
|
||||
* Returns: -1 on error, deftype on none, tunnel type index otherwise
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
ipmip4_sysext_tunnel_type(int deftype,
|
||||
const char *format,
|
||||
/* args */ ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *proto;
|
||||
static Ipmip_sysvar_key_map_t ttypes[] =
|
||||
{
|
||||
{ IPMIP_TUNNELTYPE_IPIP, "ipip" },
|
||||
{ IPMIP_TUNNELTYPE_GRE, "gre" },
|
||||
{ IPMIP_TUNNELTYPE_MINENC, "min" },
|
||||
{ IPMIP_TUNNELTYPE_IP6IP6, "ip6ip6" },
|
||||
{ IPMIP_TUNNELTYPE_GRE6, "gre6" },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
va_start(ap, format);
|
||||
proto = ipmip_vsysvar(format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (proto != IP_NULL)
|
||||
{
|
||||
deftype = ipmip_sysvar_cmd_str_to_key(ttypes, proto);
|
||||
if (deftype == -1)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "invalid tunnel type configuration (%s)", proto);
|
||||
}
|
||||
|
||||
ipcom_free(proto);
|
||||
}
|
||||
|
||||
return deftype;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_sysext_nai_aaah_create
|
||||
*===========================================================================
|
||||
* Description: Create a AAAH nai based on provided data
|
||||
* Parameters: data - The data
|
||||
* data_length - The length of data
|
||||
* Returns: The AAAH Nai.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip4_msgext_shdr_t *
|
||||
ipmip4_sysext_nai_aaah_create(Ip_u8 *data,
|
||||
Ip_size_t data_length)
|
||||
{
|
||||
Ipmip4_msgext_shdr_t *aaah_nai = IP_NULL;
|
||||
if (data != IP_NULL)
|
||||
{
|
||||
if (data_length >= 3)
|
||||
{
|
||||
Ip_u8 *nai_ext = ipcom_calloc(1, data_length + 4);
|
||||
|
||||
/* */
|
||||
if (nai_ext != IP_NULL)
|
||||
{
|
||||
nai_ext[0] = IPMIP4_EXT_TYPE_NAI_AGENT;
|
||||
nai_ext[1] = (Ip_u8) (data_length + 1);
|
||||
nai_ext[2] = IPMIP4_NAI_SUBTYPE_AAAH;
|
||||
ipcom_memcpy((char *)&nai_ext[3], data, data_length);
|
||||
|
||||
/* Store the NAI */
|
||||
aaah_nai = (void*) nai_ext;
|
||||
}
|
||||
}
|
||||
else if (data_length)
|
||||
{
|
||||
IPCOM_LOG0(WARNING, "Too short AAAH NAI. Syntax is hostname@domain");
|
||||
}
|
||||
}
|
||||
|
||||
return aaah_nai;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,127 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip4_util.c,v $ $Revision: 1.15 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmip4/src/ipmip4_util.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmip4_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_drv_eth_filter.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_sysctl.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_tmo2.h>
|
||||
#include <ipcom_netif.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
|
||||
#include "ipmip4_h.h"
|
||||
#include <private/ipmip4_util.h>
|
||||
#include <private/ipmip4_context.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmip4_util_now
|
||||
*===========================================================================
|
||||
* Description: Return current NTP time
|
||||
* Parameters:
|
||||
* Returns: The current NTP time
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_u32
|
||||
ipmip4_util_now(void)
|
||||
{
|
||||
return ((Ip_u32)ipmip_util_time()) + IPMIP4_JAN_1970;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
Reference in New Issue
Block a user