original files of m241
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
/* 00comp_ipnet_mobility.cdf - IPNet Mobility configuration file */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006-2007 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
|
||||
--------------------
|
||||
01j,11oct07,jho MIPFA_SPI_SECRET_LIST parameter change
|
||||
01i,03oct07,jho RADIUS and DIAMETER CDF mappings
|
||||
01f,27feb07,kch Added MIPMN_IPSEC_PROTECTED configuration parameter for
|
||||
mobile node. Also renamed MIPMN_IFNAME_LIST to MIPMN_IFNAME
|
||||
since only one interface can be configured at any time in
|
||||
the mobile node (WIND00089286).
|
||||
01e,23jan06,tlu Fix MIP CDF defects (85299, 85297, 85290)
|
||||
01d,25nov06,kch Added MIPHA_IF_NAT_T_KEEPALIVE_LIST configuration parameter.
|
||||
01c,23sep06,kch Fixed IPCOM shell commands description.
|
||||
01b,26aug06,kch Added support for configuration parameters.
|
||||
01a,22may06,kch created.
|
||||
*/
|
||||
|
||||
#ifdef _WRS_CONFIG_COMPONENT_IPMIPPM
|
||||
|
||||
Component INCLUDE_IPMIPPM {
|
||||
NAME IPv4 Proxy Mobility Client
|
||||
SYNOPSIS IPv4 Proxy Mobility Client
|
||||
MODULES ipmippm.o
|
||||
REQUIRES INCLUDE_IPCOM INCLUDE_IPNET INCLUDE_IPMIP4 INCLUDE_IPMIPMN
|
||||
CONFIGLETTES ipmippm_config.c
|
||||
_CHILDREN FOLDER_MOBILITY_PM
|
||||
CFG_PARAMS MIPPM_INTERFACES \
|
||||
MIPPM_TUNNEL_TYPE_ENUM \
|
||||
MIPPM_HOME_AGENT_ENUM
|
||||
}
|
||||
|
||||
Component INCLUDE_IPMIPPM_FEATURE_EXTENSION {
|
||||
NAME IPv4 Proxy Mobile Client Feature Extension Registration Hook
|
||||
SYNOPSIS IPv4 Proxy Mobile Client Feature Extension allows you provide \
|
||||
an additional registration hook for registration of \
|
||||
external functions.
|
||||
REQUIRES INCLUDE_IPMIPPM
|
||||
_CHILDREN FOLDER_MOBILITY_PM
|
||||
CFG_PARAMS MIPPM_FEATURE_INITIALIZATION_HOOK
|
||||
}
|
||||
|
||||
Component INCLUDE_IPMIPPM_PMIPV4_DHCP {
|
||||
NAME IPv4 Proxy Mobility Client PMIPv4 DHCP Interoperability
|
||||
SYNOPSIS IPv4 Proxy Mobility Client PMIPv4 DHCP Support includes \
|
||||
the communication with the integrated DHCP support in the \
|
||||
foreign agent
|
||||
REQUIRES INCLUDE_IPMIPPM
|
||||
_CHILDREN FOLDER_MOBILITY_PM
|
||||
CFG_PARAMS MIPPM_PMIPV4_DHCP_CLIENT_PORT_ENUM
|
||||
}
|
||||
|
||||
Component INCLUDE_IPMIPPM_CMD {
|
||||
NAME IPv4 Proxy Mobility Client IPCOM commands
|
||||
SYNOPSIS Mobile IPv4 Proxy Mobility IPCOM commands
|
||||
MODULES ipmippm_cmd_pm.o
|
||||
_CHILDREN FOLDER_MOBILITY_PM
|
||||
REQUIRES INCLUDE_IPCOM_SHELL_CMD INCLUDE_IPMIPPM
|
||||
}
|
||||
|
||||
Parameter MIPPM_FEATURE_INITIALIZATION_HOOK {
|
||||
NAME Proxy Mobile Client Feature Initialization Hook
|
||||
SYNOPSIS This is the function hook that you may define in order to \
|
||||
register extra functional extensions to the Proxy Mobile Client
|
||||
TYPE FUNCPTR
|
||||
DEFAULT your_function_here
|
||||
}
|
||||
|
||||
Parameter MIPPM_PMIPV4_DHCP_CLIENT_PORT_ENUM {
|
||||
NAME Proxy Mobility Client PMIPv4 DHCP communication port
|
||||
SYNOPSIS This parameter specifies what port the proxy mobility client \
|
||||
uses for communication. Syntax is <interface>=<client port>. For example \
|
||||
"eth0=434"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIPPM_INTERFACES {
|
||||
NAME Proxy Mobile Client Interface list
|
||||
SYNOPSIS Space-separated list of network interface which should be \
|
||||
managed by the Proxy Mobility Client \
|
||||
E.g., "eth0 eth1"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
Parameter MIPPM_TUNNEL_TYPE_ENUM {
|
||||
NAME Proxy Mobile Client Tunnel Type
|
||||
SYNOPSIS The type of tunnel negotiated between the client and \
|
||||
foreign agent is chosen by setting this configuration \
|
||||
option to "ipip", "gre" or "min" for IPIP, GRE or Minimal \
|
||||
Encapsulation respectively. If the home agent does not \
|
||||
support GRE or MIN, IPIP will be tried. If IPIP is not \
|
||||
supported as well, the registration operation will fail and \
|
||||
the mobile node must be reconfigured. Syntax for this \
|
||||
parameter is <interface>=<tunnel type>. For example \
|
||||
"eth0=gre"
|
||||
TYPE char *
|
||||
DEFAULT "ipip"
|
||||
}
|
||||
|
||||
Parameter MIPPM_HOME_AGENT_ENUM {
|
||||
NAME Proxy Mobile Client Home Agent IPv4 Address
|
||||
SYNOPSIS The default IPv4 address of the mobile node home agent, \
|
||||
which is used unless another is specified in the registration \
|
||||
trigger. The syntax for this parameter is \
|
||||
<interface>=<IPv4 address>. For example "eth0=10.1.2.3"
|
||||
TYPE char *
|
||||
DEFAULT ""
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: common.vxconfig,v $ $Revision: 1.5 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipmippm/config/common.vxconfig,v $
|
||||
# $Author: myakan $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
|
||||
#hidden option that enables IPMIPPM
|
||||
config SUPPORTS_MIPPM
|
||||
bool
|
||||
default y
|
||||
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_config.c,v $ $Revision: 1.9 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/config/ipmippm_config.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
IP_PUBLIC int ipmippm_cmd_pm(int argc, char **argv);
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err ipmippm_configure(void);
|
||||
IP_PUBLIC Ip_err ipmippm_init(void);
|
||||
IP_PUBLIC Ip_err ipmippm_exit(void);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Mobile Node sysvar Configuration
|
||||
*===========================================================================
|
||||
*/
|
||||
#if defined(INCLUDE_IPMIPPM)
|
||||
|
||||
IP_STATIC IP_CONST Ipcom_sysvar ipmippm_conf_sysvar[] =
|
||||
{
|
||||
{ "ipmippm.interfaces", MIPPM_INTERFACES},
|
||||
|
||||
#if 0
|
||||
/* Registration lifetime in seconds. 0 = infinite. */
|
||||
{ "ipmippm.reg_lifetime", MIPPM_REG_LIFETIME},
|
||||
|
||||
/* Receive broadcast packets from home network. */
|
||||
{ "ipmippm.receivebroadcasts",MIPPM_RECV_BROADCASTS},
|
||||
|
||||
/* Enable(1)/disable(0) reverse tunneling. */
|
||||
{ "ipmippm.reversetunneling", MIPPM_REVERSE_TUNNELING},
|
||||
|
||||
/* DHAA */
|
||||
{ "ipmippm.dhaa", MIPPM_DYNAMIC_HOME_AGENT_ASSIGNMENT },
|
||||
#endif
|
||||
/* Configuration delimiter - DO NOT EDIT! */
|
||||
{ IP_NULL, IP_NULL }
|
||||
};
|
||||
|
||||
IP_STATIC IP_CONST Ipcom_sysvar_ext ipmippm_conf_sysvar_ext[] =
|
||||
{
|
||||
#if 0
|
||||
/* Extended security association selection and creation */
|
||||
{ "ipmippm.fa.spi", "secret", MIPPM_FA_SPI_SECRET_LIST},
|
||||
{ "ipmippm.fa.spi", "method", MIPPM_FA_SPI_METHOD_LIST},
|
||||
{ "ipmippm.ha.spi", "secret", MIPPM_HA_SPI_SECRET_LIST },
|
||||
{ "ipmippm.ha.spi", "method", MIPPM_HA_SPI_METHOD_LIST},
|
||||
|
||||
{ "ipmippm.ha.sa.address", IP_NULL, MIPPM_HA_SA_ADDRESS_LIST},
|
||||
{ "ipmippm.fa.sa.address", IP_NULL, MIPPM_FA_SA_ADDRESS_LIST},
|
||||
#endif
|
||||
|
||||
/* "ipip" = IP over IP (gif), "gre" = GRE, "min" = minimal encapsulation. */
|
||||
{ "ipmippm.if", "tunneltype", MIPPM_TUNNEL_TYPE_ENUM},
|
||||
{ "ipmippm.if", "homeagent", MIPPM_HOME_AGENT_ENUM},
|
||||
|
||||
|
||||
#if defined(INCLUDE_IPMIPPM_PMIPV4_DHCP)
|
||||
{ "ipmippm.if", "pmipv4.dhcp.enable", "enabled"},
|
||||
{ "ipmippm.if", "pmipv4.dhcp.port", MIPPM_PMIPV4_DHCP_CLIENT_PORT_ENUM},
|
||||
#else
|
||||
{ "ipmippm.if.%s.enable", IP_NULL, "disabled"},
|
||||
#endif
|
||||
|
||||
/* Configuration delimiter - DO NOT EDIT! */
|
||||
{ IP_NULL, IP_NULL, IP_NULL }
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
IP_STATIC IP_CONST Ipcom_sysvar ipmippm_conf_sysvar[] =
|
||||
{
|
||||
/* Configuration delimiter - DO NOT EDIT! */
|
||||
{ IP_NULL, IP_NULL }
|
||||
};
|
||||
|
||||
#define INCLUDE_IPMIPPM_CMD 1
|
||||
#define INCLUDE_IPMIPPM_PMIPV4_DHCP 1
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIPPM_FEATURE_EXTENSION)
|
||||
extern void MIPPM_FEATURE_INITIALIZATION_HOOK(void);
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIPPM_PMIPV4_DHCP)
|
||||
IP_GLOBAL void ipmippm_pmipv4_install(void);
|
||||
#endif
|
||||
|
||||
typedef void (*Ipmippm_config_func_t) (void);
|
||||
Ipmippm_config_func_t ipmippm_function_registrations[] =
|
||||
{
|
||||
#if defined(INCLUDE_IPMIPPM_PMIPV4_DHCP)
|
||||
ipmippm_pmipv4_install,
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_IPMIPPM_FEATURE_EXTENSION)
|
||||
MIPPM_FEATURE_INITIALIZATION_HOOK,
|
||||
#endif
|
||||
IP_NULL
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipmn_configure
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipmippm_configure(void)
|
||||
{
|
||||
Ip_err err;
|
||||
/* Initialize IPMIPMN system variables. */
|
||||
if ((err = ipcom_sysvar_setv(ipmippm_conf_sysvar, 0)) != IPCOM_SUCCESS)
|
||||
return err;
|
||||
|
||||
#if defined(INCLUDE_IPMIPPM)
|
||||
if ((err = ipcom_sysvar_ext_setv(ipmippm_conf_sysvar_ext, 0)) != IPCOM_SUCCESS)
|
||||
return err;
|
||||
#endif
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_init
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipmippm_init(void)
|
||||
{
|
||||
#if defined(INCLUDE_IPMIPPM_CMD) && !defined(IP_PORT_LAS)
|
||||
(void)ipcom_shell_add_cmd("pm", "pm <command> [modifiers]", "Mobile IP Foreign Agent",
|
||||
ipmippm_cmd_pm,
|
||||
IPCOM_PRIORITY_DEFAULT, IPCOM_PROC_STACK_SMALL);
|
||||
#endif
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipfa_exit
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipmippm_exit(void)
|
||||
{
|
||||
#if defined(INCLUDE_IPMIPPM_CMD) && !defined(IP_PORT_LAS)
|
||||
(void)ipcom_shell_remove_cmd("pm", ipmippm_cmd_pm);
|
||||
#endif
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK CONFIGURATION HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_config.h,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/config/ipmippm_config.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-04-23 15:19:27 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIPMN_CONFIG_H
|
||||
#define IPMIPMN_CONFIG_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipmip4_config.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#ifdef IP_DEBUG
|
||||
#define IPMIPPM_EVENT_BACKLOG 300
|
||||
#else
|
||||
#define IPMIPPM_EVENT_BACKLOG 100
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
extern Ipmip_init_func_t ipmippm_function_registrations[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,170 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_pktbuf.c,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/config/ipmippm_pktbuf.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 "ipmippm_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_sysvar.h>
|
||||
|
||||
#include <ipmip4.h>
|
||||
#include <private/ipmip4_if.h>
|
||||
#include <private/ipmip4_sysext.h>
|
||||
#include <private/ipmip4_util.h>
|
||||
#include <private/ipmip4_pktbuf.h>
|
||||
#include <private/ipmip4_context.h>
|
||||
#include <private/ipmip4_auth.h>
|
||||
|
||||
#include "ipmippm_h.h"
|
||||
#include "ipmippm_pktbuf.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_pktbuf_alloc
|
||||
*===========================================================================
|
||||
* Description: Allocate a packet buffer
|
||||
* Parameters:
|
||||
* Returns: A newly allocated packet buffer
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip_pktbuf_t *
|
||||
ipmippm_pktbuf_alloc(Ipmippm_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ip_size_t extra)
|
||||
{
|
||||
Ipmippm_pktbuf_t *pbuf = ipcom_calloc(1, sizeof(Ipmippm_pktbuf_t) + extra);
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (pbuf)
|
||||
{
|
||||
pbuf->api.ipmip4.ipmip.pktend = (void *) (pbuf + 1);
|
||||
return &pbuf->api.ipmip4.ipmip;
|
||||
}
|
||||
|
||||
/* Return a Ipmipha_pktbuf_t */
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_pktbuf_free
|
||||
*===========================================================================
|
||||
* Description: Free a packet buffer
|
||||
* Parameters: pbuf - The packet buffer
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmippm_pktbuf_free(Ipmippm_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmippm_pktbuf_t *pbuf)
|
||||
{
|
||||
if (pbuf->trigger.pmTriggerCOA)
|
||||
ipcom_free(pbuf->trigger.pmTriggerCOA);
|
||||
|
||||
ipmipmn_api_pktbuf_free(&ctx->api, proc, &pbuf->api);
|
||||
|
||||
/* Free the data */
|
||||
ipcom_free(pbuf);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,140 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_pktbuf.h,v $ $Revision: 1.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/config/ipmippm_pktbuf.h,v $
|
||||
* $Author: ulf $ $Date: 2009-06-08 11:05:57 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIPMN_PKTBUF_H
|
||||
#define IPMIPMN_PKTBUF_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <private/ipmip4_cli.h>
|
||||
#include <private/ipmipmn_api_pktbuf.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmippm_context;
|
||||
struct Ipmippm_pktbuf;
|
||||
struct Ipmippm_client;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmipmn_api_coa;
|
||||
|
||||
typedef void (*Ipmippm_pktbuf_trigger_complete_t) (struct Ipmippm_context *ctx, struct Ipmip_proc *proc, struct Ipmippm_client *client, struct Ipmippm_pktbuf *pbuf, Ip_u8 status);
|
||||
typedef struct Ipmippm_pktbuf_trigger_info
|
||||
{
|
||||
struct Ipmip_attr *pmTriggerAttr[IPMIP4_CLI_PMIPV4_ATTR_MAX + 1];
|
||||
|
||||
Ip_u8 pmTriggerParsingState;
|
||||
|
||||
Ip_u8 pmTriggerSubscriberType;
|
||||
struct Ip_iovec pmTriggerSubscriber;
|
||||
Ip_u8 pmTriggerPerNodeAuthMethod;
|
||||
Ip_u32 pmTriggerType;
|
||||
|
||||
|
||||
Ipmipmn_api_coa_output_t pmTriggerCOAOutput;
|
||||
void *pmTriggerCOAOutputAuxData;
|
||||
Ip_size_t pmTriggerCOAOutputAuxSize;
|
||||
|
||||
Ipmippm_pktbuf_trigger_complete_t pmTriggerCompletion;
|
||||
void *pmTriggerCompletionData;
|
||||
|
||||
/* Internal */
|
||||
struct Ipmipmn_api_coa *pmTriggerCOA;
|
||||
} Ipmippm_pktbuf_trigger_info_t;
|
||||
|
||||
typedef struct Ipmippm_pktbuf
|
||||
{
|
||||
Ipmipmn_api_pktbuf_t api;
|
||||
|
||||
Ipmippm_pktbuf_trigger_info_t trigger;
|
||||
} Ipmippm_pktbuf_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_pktbuf_alloc
|
||||
*===========================================================================
|
||||
* Description: Allocate a packet buffer
|
||||
* Parameters: ctx - Context
|
||||
* proc - Process
|
||||
* Returns: A newly allocated packet buffer
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ipmip_pktbuf_t *ipmippm_pktbuf_alloc(struct Ipmippm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_size_t extra);
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_pktbuf_free
|
||||
*===========================================================================
|
||||
* Description: Free a packet buffer
|
||||
* Parameters: ctx - Context
|
||||
* proc - Process
|
||||
* pbuf - The packet buffer
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void ipmippm_pktbuf_free(struct Ipmippm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmippm_pktbuf_t *pbuf);
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,496 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_pmipv4.c,v $ $Revision: 1.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/config/ipmippm_pmipv4.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 "ipmippm_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock6.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_sysvar.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_route.h>
|
||||
|
||||
#include <ipnet.h>
|
||||
#include <ipnet_radvd.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_util.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
#include <private/ipmip_inet.h>
|
||||
|
||||
#include <ipmip4.h>
|
||||
#include <private/ipmip4_context.h>
|
||||
#include <private/ipmip4_util.h>
|
||||
#include <private/ipmip4_sysext.h>
|
||||
#include <private/ipmip4_pkt.h>
|
||||
|
||||
#include "ipmippm.h"
|
||||
#include "ipmippm_h.h"
|
||||
#include "ipmippm_attr_h.h"
|
||||
#include "ipmippm_pktbuf.h"
|
||||
#include "ipmippm_if.h"
|
||||
#include "ipmippm_client.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIPPM_PMIPV4_SERVICE "PMIPv4-UDP"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ipmippm_pmipv4_config_instance
|
||||
{
|
||||
Ipmip4_pkt_udp_register_t udpr;
|
||||
Ip_u16 port;
|
||||
struct Ip_sockaddr_in sin4;
|
||||
struct Ipmippm_client_conf *conf;
|
||||
} Ipmippm_pmipv4_config_instance_t;
|
||||
|
||||
typedef struct Ipmippm_pmipv4_output
|
||||
{
|
||||
struct Ip_sockaddr_in dst_output;
|
||||
Ipmippm_pmipv4_config_instance_t *inst_config;
|
||||
} Ipmippm_pmipv4_output_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
static Ipmipmn_api_extension_t ipmippm_pmipv4_srv;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC int
|
||||
ipmippm_pmipv4_reg_output_send(Ipmippm_context_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmippm_client_t *node,
|
||||
Ipmippm_pktbuf_t *pbuf,
|
||||
struct Ipmipmn_api_coa *coa,
|
||||
Ip_bool deregister,
|
||||
Ip_u32 src,
|
||||
Ip_u32 dst,
|
||||
Ipmippm_pmipv4_output_t *s_output)
|
||||
{
|
||||
Ipmip_buffer_t prrp;
|
||||
Ip_size_t rhdr;
|
||||
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(deregister);
|
||||
IPMIP_UNUSED_PARAMETER(src);
|
||||
IPMIP_UNUSED_PARAMETER(dst);
|
||||
IPMIP_UNUSED_PARAMETER(coa);
|
||||
|
||||
ipmip_buffer_init(&prrp);
|
||||
rhdr = ipmip_attr_hdr_req_create(&prrp, 0, 0, IPMIP4_CLI_PMIPV4_PRRQ);
|
||||
ipmip_attr_put(&prrp, IPMIP4_CLI_PMIPV4_ATTR_MESSAGE, IPMIP_BUFFER_SIZE(&pbuf->api.ipmip4.ipmip.packet), IPMIP_BUFFER_DATA(&pbuf->api.ipmip4.ipmip.packet));
|
||||
ipmip_attr_hdr_finalize(&prrp, rhdr);
|
||||
|
||||
if (ipcom_sendto(s_output->inst_config->udpr.fd, IPMIP_BUFFER_DATA(&prrp), IPMIP_BUFFER_SIZE(&prrp), 0, (struct Ip_sockaddr *)&s_output->dst_output, sizeof(s_output->dst_output)) < 0)
|
||||
{
|
||||
IPMIP4_EVENT_IF(WARNING, proc,
|
||||
ipmip_log_event_add(&data->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"%s unable to write request errno=%d",
|
||||
IPMIPMN_API_NODE_NAME(&data->api, proc, &node->api),
|
||||
ipcom_errno));
|
||||
ipmip_buffer_release(&prrp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ipmip_buffer_release(&prrp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmippm_pmipv4_trigger_complete(Ipmippm_context_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmippm_client_t *node,
|
||||
Ipmippm_pktbuf_t *pbuf,
|
||||
Ip_u8 status)
|
||||
{
|
||||
struct Ipmip_attr_header *hdr = (struct Ipmip_attr_header *)IPMIP_BUFFER_DATA(&pbuf->api.ipmip4.ipmip.packet);
|
||||
Ipmippm_pmipv4_config_instance_t *conf = pbuf->trigger.pmTriggerCompletionData;
|
||||
Ip_size_t rhdr;
|
||||
Ipmip_buffer_t trigger;
|
||||
|
||||
ipmip_buffer_init(&trigger);
|
||||
|
||||
rhdr = ipmip_attr_hdr_err(&trigger, hdr, status, IP_NULL);
|
||||
if (node != IP_NULL)
|
||||
{
|
||||
if (node->api.params.mnRegCoA)
|
||||
ipmip_attr_put_inet(&trigger, IPMIP4_CLI_PMIPV4_ATTR_NFA_COA, node->api.params.mnRegCoA->addr);
|
||||
ipmip_attr_put_inet(&trigger, IPMIP4_CLI_PMIPV4_ATTR_HOA, node->api.params.assigned_home_address);
|
||||
ipmip_attr_put_inet(&trigger, IPMIP4_CLI_PMIPV4_ATTR_HA, node->api.params.assigned_home_agent);
|
||||
ipmip_attr_put(&trigger, IPMIP4_CLI_PMIPV4_ATTR_MN_NAI, IPMIP4_MSGEXT_SHDR_EXT_SIZE(node->api.params.nai_mn), IPMIP4_MSGEXT_SHDR_EXT_DATA(node->api.params.nai_mn));
|
||||
ipmip_attr_put_u32(&trigger, IPMIP4_CLI_PMIPV4_ATTR_HA, node->api.params.assigned_home_agent);
|
||||
ipmip_attr_put_u32(&trigger, IPMIP4_CLI_PMIPV4_ATTR_LIFETIME, node->api.params.mnRegTimeGranted);
|
||||
}
|
||||
ipmip_attr_hdr_finalize(&trigger, rhdr);
|
||||
|
||||
if (ipcom_sendto(conf->udpr.fd, IPMIP_BUFFER_DATA(&trigger), IPMIP_BUFFER_SIZE(&trigger), 0, (struct Ip_sockaddr *)pbuf->api.ipmip4.ipmip.srcinfo.src, sizeof(struct Ip_sockaddr_in)) < 0)
|
||||
{
|
||||
IPMIP4_EVENT_IF(WARNING, proc,
|
||||
ipmip_log_event_add(&data->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"%s unable to write request errno=%d",
|
||||
IPMIPMN_API_NODE_NAME(&data->api, proc, &node->api),
|
||||
ipcom_errno));
|
||||
}
|
||||
|
||||
/* Remove the reference */
|
||||
ipmip_buffer_release(&trigger);
|
||||
ipmip_pktbuf_release(&data->api.ipmip4.ipmip, proc, &pbuf->api.ipmip4.ipmip);
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmippm_pmipv4_req_mobile_home(struct Ipmippm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmippm_client_conf *conf,
|
||||
Ipmippm_pmipv4_config_instance_t *inst_config,
|
||||
void *node_config,
|
||||
struct Ipmippm_client *node,
|
||||
Ip_bool deregister,
|
||||
struct Ipmippm_pktbuf *pbuf)
|
||||
{
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(conf);
|
||||
IPMIP_UNUSED_PARAMETER(deregister);
|
||||
IPMIP_UNUSED_PARAMETER(node_config);
|
||||
IPMIP_UNUSED_PARAMETER(inst_config);
|
||||
IPMIP_UNUSED_PARAMETER(node);
|
||||
IPMIP_UNUSED_PARAMETER(pbuf);
|
||||
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmippm_pmipv4_req_mobile_foreign(struct Ipmippm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmippm_client_conf *conf,
|
||||
Ipmippm_pmipv4_config_instance_t *inst_config,
|
||||
void *node_config,
|
||||
struct Ipmippm_client *node,
|
||||
Ip_bool deregister,
|
||||
struct Ipmippm_pktbuf *pbuf)
|
||||
{
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(conf);
|
||||
IPMIP_UNUSED_PARAMETER(deregister);
|
||||
IPMIP_UNUSED_PARAMETER(node_config);
|
||||
IPMIP_UNUSED_PARAMETER(inst_config);
|
||||
|
||||
if (node->pmAccessType)
|
||||
ipmip4_msgext_buffer_append_shdr(&pbuf->api.ipmip4.ipmip.packet, node->pmAccessType);
|
||||
if (node->pmDeviceID)
|
||||
ipmip4_msgext_buffer_append_shdr(&pbuf->api.ipmip4.ipmip.packet, node->pmDeviceID);
|
||||
if (node->pmInterfaceID)
|
||||
ipmip4_msgext_buffer_append_shdr(&pbuf->api.ipmip4.ipmip.packet, node->pmInterfaceID);
|
||||
if (node->pmSubscriberID)
|
||||
ipmip4_msgext_buffer_append_shdr(&pbuf->api.ipmip4.ipmip.packet, node->pmSubscriberID);
|
||||
if (node->pmPerNodeAuthMethod)
|
||||
ipmip4_msgext_buffer_append_lhdr(&pbuf->api.ipmip4.ipmip.packet, node->pmPerNodeAuthMethod);
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmippm_pmipv4_udp_prtrigger(Ipmippm_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmippm_pmipv4_config_instance_t *conf,
|
||||
Ipmippm_pktbuf_t *pbuf)
|
||||
{
|
||||
Ipmippm_pmipv4_output_t s_output;
|
||||
struct Ipmip_attr_header *hdr = (struct Ipmip_attr_header *)IPMIP_BUFFER_DATA(&pbuf->api.ipmip4.ipmip.packet);
|
||||
|
||||
ipmip_attr_hdr_parse(IPMIP4_CLI_PMIPV4_ATTR_MAX, hdr, pbuf->trigger.pmTriggerAttr);
|
||||
|
||||
pbuf->trigger.pmTriggerType = IPMIP_ATTR_HDR_TYPE(hdr);
|
||||
/**/
|
||||
pbuf->api.iff.priv = conf->conf->iff;
|
||||
|
||||
ipcom_memcpy(&s_output.dst_output, &pbuf->api.ipmip4.ipmip.srcinfo.src->sin, sizeof(s_output.dst_output));
|
||||
s_output.inst_config = conf;
|
||||
|
||||
pbuf->trigger.pmTriggerCOAOutput = (Ipmipmn_api_coa_output_t)ipmippm_pmipv4_reg_output_send;
|
||||
pbuf->trigger.pmTriggerCOAOutputAuxData = &s_output;
|
||||
pbuf->trigger.pmTriggerCOAOutputAuxSize = sizeof(s_output);
|
||||
pbuf->trigger.pmTriggerCompletion = (Ipmippm_pktbuf_trigger_complete_t)ipmippm_pmipv4_trigger_complete;
|
||||
pbuf->trigger.pmTriggerCompletionData = conf;
|
||||
|
||||
/* Need to do lookup */
|
||||
ipmippm_client_trigger_handoff(ctx, proc, pbuf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmippm_pmipv4_udp_prrq(Ipmippm_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmippm_pmipv4_config_instance_t *conf,
|
||||
Ipmippm_pktbuf_t *pbuf)
|
||||
{
|
||||
Ipmip_buffer_t prrq;
|
||||
struct Ipmip_attr_header *hdr = (struct Ipmip_attr_header *)IPMIP_BUFFER_DATA(&pbuf->api.ipmip4.ipmip.packet);
|
||||
|
||||
ipmip_attr_hdr_parse(IPMIP4_CLI_PMIPV4_ATTR_MAX, hdr, pbuf->trigger.pmTriggerAttr);
|
||||
|
||||
/**/
|
||||
pbuf->api.iff.priv = conf->conf->iff;
|
||||
|
||||
/**/
|
||||
if (pbuf->trigger.pmTriggerAttr[IPMIP4_CLI_PMIPV4_ATTR_MESSAGE] == IP_NULL)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"Received PMIPv4 PRRQ -- missing message"));
|
||||
goto done_out;
|
||||
}
|
||||
|
||||
ipmip_buffer_init(&prrq);
|
||||
ipmip_buffer_append(&prrq, IPMIP_ATTR_DATA(pbuf->trigger.pmTriggerAttr[IPMIP4_CLI_PMIPV4_ATTR_MESSAGE]), IPMIP_ATTR_PAYLOAD(pbuf->trigger.pmTriggerAttr[IPMIP4_CLI_PMIPV4_ATTR_MESSAGE]));
|
||||
ipmip_buffer_assign(&pbuf->api.ipmip4.ipmip.packet, &prrq);
|
||||
|
||||
ipmipmn_api_reg_recv(&ctx->api, proc, &pbuf->api);
|
||||
return;
|
||||
|
||||
done_out:
|
||||
ipmip_pktbuf_release(&ctx->api.ipmip4.ipmip, proc, &pbuf->api.ipmip4.ipmip);
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmippm_pmipv4_udp_recvmsg(Ipmippm_context_t *ctx,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmippm_pktbuf_t *pbuf,
|
||||
Ipmippm_pmipv4_config_instance_t *conf)
|
||||
{
|
||||
struct Ipmip_attr_header *hdr = (struct Ipmip_attr_header *)IPMIP_BUFFER_DATA(&pbuf->api.ipmip4.ipmip.packet);
|
||||
|
||||
if (IPMIP_BUFFER_SIZE(&pbuf->api.ipmip4.ipmip.packet) < sizeof(struct Ipmip_attr_header))
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"Received PMIPv4 Trigger Message -- Truncated"));
|
||||
goto done_out;
|
||||
}
|
||||
|
||||
switch (IPMIP_ATTR_HDR_TYPE(hdr))
|
||||
{
|
||||
case IPMIP4_CLI_PMIPV4_PREVRQ:
|
||||
IPMIP4_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&ctx->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"Received PMIPv4 PREVRQ"));
|
||||
ipmippm_pmipv4_udp_prtrigger(ctx, proc, conf, pbuf);
|
||||
return;
|
||||
case IPMIP4_CLI_PMIPV4_PTRQ:
|
||||
IPMIP4_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&ctx->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"Received PMIPv4 PTRQ"));
|
||||
ipmippm_pmipv4_udp_prtrigger(ctx, proc, conf, pbuf);
|
||||
return;
|
||||
case IPMIP4_CLI_PMIPV4_PRRQ:
|
||||
IPMIP4_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&ctx->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"Received PMIPv4 PRRQ"));
|
||||
ipmippm_pmipv4_udp_prrq(ctx, proc, conf, pbuf);
|
||||
return;
|
||||
}
|
||||
|
||||
done_out:
|
||||
ipmip_pktbuf_release(&ctx->api.ipmip4.ipmip, proc, &pbuf->api.ipmip4.ipmip);
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmippm_pmipv4_config(struct Ipmippm_context *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
const char *pre,
|
||||
const char *spec,
|
||||
struct Ipmippm_client_conf *conf,
|
||||
Ipmippm_pmipv4_config_instance_t *inst_config,
|
||||
Ipmip_cli_message_t *request)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(ctx);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(conf);
|
||||
IPMIP_UNUSED_PARAMETER(request);
|
||||
IPMIP_UNUSED_PARAMETER(pre);
|
||||
IPMIP_UNUSED_PARAMETER(spec);
|
||||
|
||||
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
||||
{
|
||||
inst_config->udpr.fd = IP_INVALID_SOCKET;
|
||||
if (ipmip_sysvar_bool(ipmip_sysvar_bool(IP_FALSE, "%s.pmipv4.dhcp.enable", pre), "%s.%spmipv4.dhcp.enable", pre, spec))
|
||||
{
|
||||
inst_config->port = (Ip_u16)ipmip_sysvar_ulong(ipmip_sysvar_ulong(IPMIP4_PORT, "%s.pmipv4.dhcp.port", pre), "%s.%spmipv4.dhcp.port", pre, spec);
|
||||
|
||||
ipcom_memset(&inst_config->sin4, 0, sizeof(inst_config->sin4));
|
||||
inst_config->sin4.sin_family = IP_AF_INET;
|
||||
IPCOM_SA_LEN_SET(&inst_config->sin4, sizeof(inst_config->sin4));
|
||||
inst_config->sin4.sin_port = ip_htons(inst_config->port);
|
||||
inst_config->sin4.sin_addr.s_addr = conf->iff->iff.ifaddr;
|
||||
|
||||
inst_config->udpr.fd = ipmip_inet_udp_socket(&inst_config->sin4);
|
||||
if (inst_config->udpr.fd != IP_INVALID_SOCKET)
|
||||
{
|
||||
inst_config->udpr.udp_callback = (Ipmip4_pkt_udp_cb_t)ipmippm_pmipv4_udp_recvmsg;
|
||||
inst_config->udpr.opaque = inst_config;
|
||||
|
||||
/* Start the process */
|
||||
inst_config->conf = conf;
|
||||
|
||||
/**/
|
||||
ipmip4_pkt_udp_register(&ctx->api.ipmip4, proc, &inst_config->udpr);
|
||||
|
||||
IPMIP4_EVENT_IF(WARNING, proc,
|
||||
ipmip_log_event_add(&ctx->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"Created PMIPv4 UDP socket for %s %s:%u",
|
||||
inst_config->conf->iff->iff.ipmip.ifname,
|
||||
ipmip_ntop_inet(proc, inst_config->conf->iff->iff.ifaddr),
|
||||
inst_config->port));
|
||||
}
|
||||
else
|
||||
{
|
||||
IPMIP4_EVENT_IF(WARNING, proc,
|
||||
ipmip_log_event_add(&ctx->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"Unable to create PMIPv4 UDP socket for %s %s:%u",
|
||||
inst_config->conf->iff->iff.ipmip.ifname,
|
||||
ipmip_ntop_inet(proc, inst_config->conf->iff->iff.ifaddr),
|
||||
inst_config->port));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
||||
{
|
||||
ipmip4_pkt_udp_unregister(&ctx->api.ipmip4, proc, &inst_config->udpr);
|
||||
if (inst_config->udpr.fd != IP_INVALID_SOCKET)
|
||||
ipcom_socketclose(inst_config->udpr.fd);
|
||||
|
||||
/* Clear */
|
||||
inst_config->udpr.fd = IP_INVALID_SOCKET;
|
||||
}
|
||||
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
||||
{
|
||||
/* Could dump, but dont bother */
|
||||
if (inst_config->udpr.fd != IP_INVALID_SOCKET)
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"%s.%spmipv4.dhcp.enable=enabled",
|
||||
pre, spec);
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"%s.%spmipv4.dhcp.port=%u",
|
||||
pre, spec, inst_config->port);
|
||||
}
|
||||
else
|
||||
{
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"%s.%spmipv4.dhcp.enable=disabled",
|
||||
pre, spec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL void ipmippm_pmipv4_install(void);
|
||||
IP_GLOBAL void
|
||||
ipmippm_pmipv4_install(void)
|
||||
{
|
||||
ipcom_memset(&ipmippm_pmipv4_srv, 0, sizeof(ipmippm_pmipv4_srv));
|
||||
|
||||
ipmippm_pmipv4_srv.name = IPMIPPM_PMIPV4_SERVICE;
|
||||
ipmippm_pmipv4_srv.instance_data_size = sizeof(Ipmippm_pmipv4_config_instance_t);
|
||||
ipmippm_pmipv4_srv.config_instance = (Ipmipmn_api_extension_config_instance_t)ipmippm_pmipv4_config;
|
||||
|
||||
ipmippm_pmipv4_srv.pkt_req_mobile_home = (Ipmipmn_api_extension_pkt_req_mobile_home_t)ipmippm_pmipv4_req_mobile_home;
|
||||
ipmippm_pmipv4_srv.pkt_req_mobile_foreign = (Ipmipmn_api_extension_pkt_req_mobile_foreign_t)ipmippm_pmipv4_req_mobile_foreign;
|
||||
|
||||
ipmippm_context_register_function(&ipmippm_pmipv4_srv);
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,11 @@
|
||||
IPTARGETS := lib
|
||||
ifneq ($(IPMAKEFILE),)
|
||||
include $(IPMAKEFILE)
|
||||
else
|
||||
include $(IPCOM_ROOT)/Makefile
|
||||
endif
|
||||
include ipmippm.mk
|
||||
include $(IPCOM_ROOT)/gmake/ipcom_make.mk
|
||||
|
||||
lib: dirs $(IPLIBFILE)
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
#############################################################################
|
||||
# IPMIPMN.MK
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm.mk,v $ $Revision: 1.7 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipmippm/gmake/ipmippm.mk,v $
|
||||
# $Author: jhorteli $ $Date: 2009-04-23 16:51:57 $
|
||||
# $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 ($(IPMIPPM),)
|
||||
ifneq ($(IPCOM_USE_INET),no)
|
||||
|
||||
IPMIPPM := yes
|
||||
|
||||
|
||||
#############################################################################
|
||||
# PRODUCT
|
||||
###########################################################################
|
||||
|
||||
IPPROD ?= ipmippm
|
||||
|
||||
|
||||
#############################################################################
|
||||
# DEFINE
|
||||
###########################################################################
|
||||
|
||||
IPDEFINE += -DIPMIPPM
|
||||
|
||||
|
||||
#############################################################################
|
||||
# INCLUDE
|
||||
###########################################################################
|
||||
|
||||
IPINCLUDE += -I$(IPMIPPM_ROOT)/config
|
||||
IPINCLUDE += -I$(IPMIPPM_ROOT)/include
|
||||
IPINCLUDE += -I$(IPMIPPM_ROOT)/src
|
||||
|
||||
|
||||
#############################################################################
|
||||
# OBJECTS
|
||||
###########################################################################
|
||||
|
||||
# Common files
|
||||
|
||||
# Library files.
|
||||
IPLIBOBJECTS += ipmippm_client.o
|
||||
IPLIBOBJECTS += ipmippm_reg.o
|
||||
IPLIBOBJECTS += ipmippm_attr.o
|
||||
IPLIBOBJECTS += ipmippm_if.o
|
||||
IPLIBOBJECTS += ipmippm_pktbuf.o
|
||||
IPLIBOBJECTS += ipmippm_cli.o
|
||||
IPLIBOBJECTS += ipmippm_main.o
|
||||
IPLIBOBJECTS += ipmippm_pmipv4.o
|
||||
|
||||
|
||||
ifneq ($(IPPORT),lkm)
|
||||
|
||||
# If las, don't include the entry point files.
|
||||
ifneq ($(IPPORT),las)
|
||||
|
||||
# Entry point files.
|
||||
IPLIBOBJECTS += ipmippm.o
|
||||
IPLIBOBJECTS += ipmippm_cmd_pm.o
|
||||
|
||||
endif # LAS
|
||||
|
||||
# Configuration
|
||||
IPLIBOBJECTS_C += ipmippm_config.o
|
||||
|
||||
# Compiles the xxx_config.o if the $SKIP_CONFIG macro is either not defined
|
||||
# or set to anything other than true.
|
||||
ifneq ($(SKIP_CONFIG),true)
|
||||
IPLIBOBJECTS += $(IPLIBOBJECTS_C)
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# VPATH
|
||||
###########################################################################
|
||||
|
||||
IPSRCDIRS += $(IPMIPPM_ROOT)/src $(IPMIPPM_ROOT)/config
|
||||
|
||||
|
||||
#############################################################################
|
||||
# LIB
|
||||
###########################################################################
|
||||
|
||||
IPLIBS += $(IPLIBROOT)/libipmippm.a
|
||||
|
||||
|
||||
#############################################################################
|
||||
# BINARIES
|
||||
###########################################################################
|
||||
|
||||
|
||||
ifeq ($(IPPORT),las)
|
||||
|
||||
# Path to binaries
|
||||
IPCMDDIR := $(IPOBJDIR)/bin
|
||||
IPDAEMONDIR := $(IPOBJDIR)/sbin
|
||||
|
||||
# List of shell commands to build
|
||||
IPMIPPMCMDS = pm
|
||||
_IPIPMIPPMCMDS = $(addprefix $(IPCMDDIR)/,$(IPMIPPMCMDS))
|
||||
|
||||
# List of daemons to build
|
||||
IPMIPPMD = pmd
|
||||
_IPMIPPMD = $(addprefix $(IPDAEMONDIR)/,$(IPMIPPMD))
|
||||
|
||||
bin: $(_IPIPMIPPMCMDS) $(_IPMIPPMD)
|
||||
|
||||
$(IPOBJDIR)/ipmippm_cmd_pm.o: $(IPMIPPM_ROOT)/src/ipmippm_cmd_pm.c
|
||||
@$(IPECHO) "+++ Compiling IPMIPPM shell command $<"
|
||||
$(IPVERB)$(IPCC) -Dipmippm_cmd_pm=ipcom_cmd_entry_point $(IPCFLAGS) -o $@ $<
|
||||
|
||||
$(IPOBJDIR)/ipmippm.o: $(IPMIPPM_ROOT)/src/ipmippm.c
|
||||
@$(IPECHO) "+++ Compiling IPMIPPM daemon $<"
|
||||
$(IPVERB)$(IPCC) -Dipmippm_proc=ipcom_daemon_entry_point -Dipmippm_create=ipcom_daemon_create $(IPCFLAGS) -o $@ $<
|
||||
|
||||
# Linking shell commands and daemons
|
||||
$(IPCMDDIR)/pm: $(IPOBJDIR)/ipmippm_cmd_pm.o $(IPOBJDIR)/ipcom_shell_cmd_stub.o
|
||||
@$(IPECHO) "+++ Linking IPMIPPM shell command $@"
|
||||
$(IPVERB)$(IPLD) -o $@ $(IPLDFLAGS) $^ $(IPLIBS) $(IPLIBS) $(IPLIBS) $(IPLASTLIBS)
|
||||
|
||||
$(IPDAEMONDIR)/pmd: $(IPOBJDIR)/ipmippm.o $(IPOBJDIR)/ipcom_daemon_stub.o
|
||||
@$(IPECHO) "+++ Linking IPMIPPMD daemon $@"
|
||||
$(IPVERB)$(IPLD) -o $@ $(IPLDFLAGS) $^ $(IPLIBS) $(IPLIBS) $(IPLIBS) $(IPLASTLIBS)
|
||||
|
||||
endif # LAS
|
||||
|
||||
|
||||
endif # LKM
|
||||
|
||||
endif # IPCOM_USE_INET
|
||||
endif # IPMIPPM
|
||||
|
||||
###########################################################################
|
||||
# END OF IPMIPPM.MK
|
||||
###########################################################################
|
||||
@@ -0,0 +1,79 @@
|
||||
/* ipmipmn.h - ipmipmn.h *//*
|
||||
******************************************************************************
|
||||
* INTERPEAK HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm.h,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/include/ipmippm.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-04-23 15:52:17 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Niklas Lundberg <n@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIPPM_H
|
||||
#define IPMIPPM_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
No description currently provided
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_sock.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPMIPPM_RELEASE 60701
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmipfa_l2trigger
|
||||
*===========================================================================
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,90 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_attr.h,v $ $Revision: 1.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/include/ipmippm_attr.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-04-23 15:19:27 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIPPM_ATTR_H
|
||||
#define IPMIPPM_ATTR_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <private/ipmipmn_api_attr.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/**/
|
||||
enum
|
||||
{
|
||||
IPMIPPM_CLI_CLIENT_LIST = IPMIP_CLI_TYPE_BASE,
|
||||
IPMIPPM_CLI_CLIENT_DELETE,
|
||||
IPMIPPM_CLI_CLIENT_GET,
|
||||
IPMIPPM_CLI_CLIENT_TRIGGER
|
||||
};
|
||||
|
||||
/**/
|
||||
enum
|
||||
{
|
||||
IPMIPPM_CLI_ATTR_NODE_HANDLE = IPMIPMN_CLI_API_ATTR_NODE_LAST,
|
||||
IPMIPPM_CLI_ATTR_NODE_INTERFACE_ID,
|
||||
IPMIPPM_CLI_ATTR_NODE_DEVICE_ID,
|
||||
IPMIPPM_CLI_ATTR_NODE_SUBSCRIBER_ID,
|
||||
IPMIPPM_CLI_ATTR_NODE_HARDWARE_ID,
|
||||
IPMIPPM_CLI_ATTR_NODE_FA_COA,
|
||||
IPMIPPM_CLI_ATTR_NODE_MAX
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,250 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_cli.h,v $ $Revision: 1.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/include/ipmippm_cli.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-04-23 15:19:27 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIPPM_CLI_H
|
||||
#define IPMIPPM_CLI_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <private/ipmip4_cli.h>
|
||||
#include <private/ipmipmn_api_cli.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip_attr;
|
||||
struct Ipmip_lladdr;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_cli_connect - ipmippm_cli_connect
|
||||
*
|
||||
* Connect to the foreign agent daemon.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i daemon_info
|
||||
* Will be filled in by the function
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on success
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_bool ipmippm_cli_connect
|
||||
(
|
||||
Ipmip_cli_daemon_t *daemon_info
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_cli_node_get - ipmippm_cli_node_get
|
||||
*
|
||||
* Retrieve information on a specific node
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i dameon
|
||||
* Connection to the daemon
|
||||
* \i req
|
||||
* Request to use.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The RTA containing the node's attributes if found, or IP_NULL.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC struct Ipmip_attr *ipmippm_cli_node_get
|
||||
(
|
||||
Ipmip_cli_daemon_t *daemon,
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 handle
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_cli_node_delete - ipmippm_cli_node_delete
|
||||
*
|
||||
* Delete a specific node
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i dameon
|
||||
* Connection to the daemon
|
||||
* \i req
|
||||
* Request to use.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void ipmippm_cli_node_delete
|
||||
(
|
||||
Ipmip_cli_daemon_t *daemon,
|
||||
Ip_u32 handle
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_cli_request_set_handle - ipmippm_cli_request_set_handle
|
||||
*
|
||||
* Set an handle identifier in the request
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i req
|
||||
* Daemon request structure
|
||||
* \i handle
|
||||
* The handle
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void ipmippm_cli_request_set_handle
|
||||
(
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 handle
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_cli_node_get_handle - ipmippm_cli_node_get_handle
|
||||
*
|
||||
* Returns the handle setting of the node
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i node
|
||||
* rta containing the node attributes
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The handle or zero if not found
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_u32 ipmippm_cli_node_get_handle
|
||||
(
|
||||
struct Ipmip_attr *node
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_cli_handle_next - ipmippm_cli_handle_next
|
||||
*
|
||||
* Return the next handle
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i iter
|
||||
* Iterator
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The next handle or 0
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_u32 ipmippm_cli_handle_next
|
||||
(
|
||||
Ipmip_attr_iter_t *iter
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_cli_node_list - ipmippm_cli_node_list
|
||||
*
|
||||
* List all nodes matching the specified search criteries
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i dameon
|
||||
* Connection to the IPMIPFA daemon
|
||||
* \i req
|
||||
* Request to use.
|
||||
* \i nai
|
||||
* NAI to look for, or IP_NULL
|
||||
* \i hoa
|
||||
* Home Address to look for
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IPCOM_SUCCESS if the request was successful
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int ipmippm_cli_node_list
|
||||
(
|
||||
Ipmip_cli_daemon_t *daemon,
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
const char *nai,
|
||||
Ip_u32 hoa
|
||||
);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm.c,v $ $Revision: 1.10 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/src/ipmippm.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Niklas Lundberg <n@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
*******************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include "ipmippm_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_sysvar.h>
|
||||
|
||||
#include <ipmip4.h>
|
||||
#include <private/ipmip4_pkt.h>
|
||||
#include <private/ipmip4_sysext.h>
|
||||
#include <private/ipmip4_util.h>
|
||||
#include <private/ipmip4_radius.h>
|
||||
|
||||
#include <private/ipmipmn_api.h>
|
||||
|
||||
#include "ipmippm.h"
|
||||
#include "ipmippm_h.h"
|
||||
#include "ipmippm_reg.h"
|
||||
#include "ipmippm_client.h"
|
||||
#include "ipmippm_attr_h.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Application datatypes
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err ipmippm_configure(void);
|
||||
IP_PUBLIC Ip_err ipmippm_init(void);
|
||||
IP_PUBLIC Ip_err ipmippm_exit(void);
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err ipmippm_start(void);
|
||||
IP_PUBLIC const char *ipmippm_version(void);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
IP_PUBLIC IPCOM_PROCESS(ipmippm_proc);
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippmd
|
||||
*===========================================================================
|
||||
* Description: The main process.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC
|
||||
IPCOM_PROCESS(ipmippm_proc)
|
||||
{
|
||||
ipmippm_main();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_start
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipmippm_start(void)
|
||||
{
|
||||
Ipcom_proc_attr attr;
|
||||
Ip_err ret;
|
||||
|
||||
ipcom_proc_attr_init(&attr);
|
||||
attr.stacksize = IPCOM_PROC_STACK_LARGE;
|
||||
|
||||
ret = ipcom_proc_acreate("ipmippmd", ipmippm_proc, &attr, IP_NULL);
|
||||
ip_assert(ret == IPCOM_SUCCESS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_version
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC const char *
|
||||
ipmippm_version(void)
|
||||
{
|
||||
return "@(#) IPMIPPM $Name: VXWORKS_ITER40_2019102207 $ - INTERPEAK_COPYRIGHT_STRING";
|
||||
}
|
||||
|
||||
|
||||
#if defined (IP_PORT_LAS)
|
||||
|
||||
/* Prototypes */
|
||||
IP_PUBLIC Ip_err ipcom_daemon_configure(void);
|
||||
IP_PUBLIC Ip_err ipcom_daemon_create(void);
|
||||
|
||||
IP_PUBLIC Ip_err
|
||||
ipcom_daemon_configure(void)
|
||||
{
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_err
|
||||
ipcom_daemon_create(void)
|
||||
{
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,336 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_attr.c,v $ $Revision: 1.9 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/src/ipmippm_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 "ipmippm_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.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_syslog.h>
|
||||
#include <ipcom_hash.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_cli.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
#include <private/ipmip_timer.h>
|
||||
#include <private/ipmip_buffer.h>
|
||||
|
||||
#include <ipmip4.h>
|
||||
#include <private/ipmip4_context.h>
|
||||
#include <private/ipmip4_msgext.h>
|
||||
#include <private/ipmip4_auth.h>
|
||||
#include <private/ipmip4_util.h>
|
||||
#include <private/ipmip4_attr.h>
|
||||
|
||||
#include "ipmippm.h"
|
||||
#include "ipmippm_h.h"
|
||||
#include "ipmippm_attr_h.h"
|
||||
#include "ipmippm_client.h"
|
||||
#include "ipmippm_if.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmippm_attr_op
|
||||
{
|
||||
Ipmip_cli_message_t *request;
|
||||
Ip_u32 hoa;
|
||||
const char *nai;
|
||||
Ip_u32 nai_len;
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_attr_list_client
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmippm_attr_list_client(Ipmippm_context_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmippm_client_t *node,
|
||||
struct Ipmippm_attr_op *aop,
|
||||
void *unused)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(unused);
|
||||
IPMIP_UNUSED_PARAMETER(data);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (aop->hoa != 0 && node->api.params.assigned_home_address != aop->hoa)
|
||||
return;
|
||||
|
||||
if (aop->nai && (node->api.params.nai_mn == IP_NULL || !ipmip_util_strnncmp(aop->nai, aop->nai_len, (char *)IPMIP4_MSGEXT_SHDR_EXT_DATA(node->api.params.nai_mn), IPMIP4_MSGEXT_SHDR_EXT_SIZE(node->api.params.nai_mn))))
|
||||
return;
|
||||
|
||||
/**/
|
||||
ipmip_attr_put_u32(&aop->request->message, IPMIPPM_CLI_ATTR_NODE_HANDLE, node->pmClientIdentity);
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC int
|
||||
ipmippm_attr_client_exec(int event,
|
||||
Ipmippm_context_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip_cli_message_t *request,
|
||||
Ipmippm_client_t *node)
|
||||
{
|
||||
int ret = IPMIP_TIMER_RET_DONE;
|
||||
if (event == IPMIP_TIMER_EVENT_RUN)
|
||||
{
|
||||
struct Ipmip_attr_header *hdr = (struct Ipmip_attr_header *)IPMIP_BUFFER_DATA(&request->request);
|
||||
Ip_size_t rhdr = 0;
|
||||
Ip_size_t rta;
|
||||
|
||||
if (node == IP_NULL)
|
||||
rhdr = ipmip_attr_hdr_err(&request->message, hdr, IP_ERRNO_ENOENT, IP_NULL);
|
||||
else
|
||||
{
|
||||
switch (IPMIP_ATTR_HDR_TYPE(hdr))
|
||||
{
|
||||
case IPMIPPM_CLI_CLIENT_DELETE:
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
ret = ipmippm_client_terminate(data, proc, node);
|
||||
break;
|
||||
case IPMIPPM_CLI_CLIENT_GET:
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
rta = ipmip_attr_begin(&request->message, IPMIPMN_API_CLI_ATTR_NODE);
|
||||
ipmipmn_api_attr_node_dump(&data->api, proc, request, &node->api);
|
||||
ipmip_attr_put_u32(&request->message, IPMIPPM_CLI_ATTR_NODE_HANDLE, node->pmClientIdentity);
|
||||
ipmipmn_api_attr_node_coa_dump(&data->api, proc, request, &node->api);
|
||||
ipmip_attr_end(&request->message, rta);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we have a reply header; terminate it */
|
||||
ipmip_attr_hdr_finalize(&request->message, rhdr);
|
||||
|
||||
/* Commit the reply */
|
||||
ipmip_cli_message_commit(&data->api.ipmip4.ipmip, proc, request);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Free the request */
|
||||
ipmip_cli_message_free(&data->api.ipmip4.ipmip, proc, request);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_attr_command
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
ipmippm_attr_command(struct Ipmippm_context *data,
|
||||
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 = 0;
|
||||
|
||||
switch (IPMIP_ATTR_HDR_TYPE(hdr))
|
||||
{
|
||||
case IPMIPPM_CLI_CLIENT_LIST:
|
||||
{
|
||||
struct Ipmip_attr *idattr[IPMIPPM_CLI_ATTR_NODE_MAX + 1];
|
||||
struct Ipmippm_attr_op aop;
|
||||
|
||||
ipcom_memset(&aop, 0, sizeof(aop));
|
||||
|
||||
aop.request = request;
|
||||
|
||||
ipmip_attr_hdr_parse(IPMIPPM_CLI_ATTR_NODE_MAX, hdr, idattr);
|
||||
|
||||
aop.hoa = ipmip_attr_get_inet(idattr[IPMIPMN_CLI_API_ATTR_NODE_HOA]);
|
||||
|
||||
/* NAI */
|
||||
aop.nai = ipmip_attr_get_data(idattr[IPMIPMN_CLI_API_ATTR_NODE_NAI]);
|
||||
if (aop.nai)
|
||||
aop.nai_len = IPMIP_ATTR_PAYLOAD(idattr[IPMIPMN_CLI_API_ATTR_NODE_NAI]);
|
||||
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
|
||||
/* Add all nodes */
|
||||
ipmip_context_id_lock(data->idents);
|
||||
ipmip_context_id_foreach(&data->api.ipmip4.ipmip,
|
||||
proc,
|
||||
data->idents,
|
||||
(Ipmip_util_hash_foreach_t)ipmippm_attr_list_client,
|
||||
&aop,
|
||||
IP_NULL);
|
||||
ipmip_context_id_unlock(data->idents);
|
||||
|
||||
}
|
||||
break;
|
||||
case IPMIPPM_CLI_CLIENT_GET:
|
||||
case IPMIPPM_CLI_CLIENT_DELETE:
|
||||
{
|
||||
Ip_u32 handle = ipmip_attr_hdr_find_u32(hdr, IPMIPPM_CLI_ATTR_NODE_HANDLE);
|
||||
|
||||
if (handle == 0)
|
||||
return -IP_ERRNO_EINVAL;
|
||||
|
||||
ipmippm_client_lookup_handle(data,
|
||||
proc,
|
||||
handle,
|
||||
&request->timer,
|
||||
(Ipmip_timer_func_t)ipmippm_attr_client_exec,
|
||||
request);
|
||||
return 0;
|
||||
}
|
||||
case IPMIPPM_CLI_CLIENT_TRIGGER:
|
||||
/* Locate NAI & AT and IFNAME */
|
||||
|
||||
|
||||
return 0;
|
||||
case IPMIP_CLI_NAME_LIST:
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
if (data->conf != IP_NULL)
|
||||
{
|
||||
/* Dump each configuration item we've currently got in human readable form */
|
||||
Ipmippm_if_t *ife;
|
||||
|
||||
/* Add interfaces */
|
||||
for (ife = IPCOM_LIST_FIRST(&data->conf->if_head); ife; ife = IPCOM_LIST_NEXT(&ife->iff.ipmip.next))
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP_CLI_ITEM_NAME,
|
||||
ife->iff.ipmip.ifname);
|
||||
}
|
||||
break;
|
||||
case IPMIP_CLI_CONFIG_GET:
|
||||
if (data->conf == IP_NULL)
|
||||
return -IP_ERRNO_EPERM;
|
||||
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
{
|
||||
/* Dump each configuration item we've currently got in human readable form */
|
||||
Ipmippm_if_t *ife;
|
||||
const char *name = ipmip_attr_hdr_find_str(hdr, IPMIP_CLI_ITEM_NAME);
|
||||
|
||||
/* Clear any old interfaces */
|
||||
for (ife = IPCOM_LIST_FIRST(&data->conf->if_head); ife; ife = IPCOM_LIST_NEXT(&ife->iff.ipmip.next))
|
||||
{
|
||||
char spec[IP_IFNAMSIZ + 6];
|
||||
|
||||
if (name != IP_NULL && ipcom_strcasecmp(ife->iff.ipmip.ifname, name) != 0)
|
||||
continue;
|
||||
|
||||
ipcom_snprintf(spec, sizeof(spec), "if.%s.", ife->iff.ipmip.ifname);
|
||||
|
||||
ipmipmn_api_attr_config_dump(&data->api, proc, request, &ife->conf->api, "ipmippm", spec);
|
||||
/**/
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmippm.if.%s.address=%s",
|
||||
ife->iff.ipmip.ifname, ife->iff.ipmip.ifname);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return ipmip4_attr_command(&data->api.ipmip4, proc, request);
|
||||
}
|
||||
|
||||
/* If we have a reply header; terminate it */
|
||||
ipmip_attr_hdr_finalize(&request->message, rhdr);
|
||||
|
||||
/* Commit the reply */
|
||||
ipmip_cli_message_commit(&data->api.ipmip4.ipmip, proc, request);
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,99 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_attr_h.h,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/src/ipmippm_attr_h.h,v $
|
||||
* $Author: jhorteli $ $Date: 2008-03-07 13:28:51 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIPPM_ATTR_H_H
|
||||
#define IPMIPPM_ATTR_H_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <ipmippm_h.h>
|
||||
#include <ipmippm_attr.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_attr_command - ipmippm_attr_command
|
||||
*
|
||||
* Process a proxy mobile node attribute command
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Context
|
||||
* \i proc
|
||||
* Process
|
||||
* \i request
|
||||
* Issued command
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IPCOM_SUCCESS on successful parsing
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL int ipmippm_attr_command
|
||||
(
|
||||
struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip_cli_message *request
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,180 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_cli.c,v $ $Revision: 1.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/src/ipmippm_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 "ipmippm_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.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_route.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_buffer.h>
|
||||
#include <private/ipmip_util.h>
|
||||
|
||||
#include <ipmip4.h>
|
||||
|
||||
#include "ipmippm.h"
|
||||
#include "ipmippm_attr.h"
|
||||
#include "ipmippm_cli.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_bool
|
||||
ipmippm_cli_connect(Ipmip_cli_daemon_t *daemon_info)
|
||||
{
|
||||
ipmip_cli_daemon_init(daemon_info, "ipmippm", IPCOM_IPD_ID_IPMIPPM);
|
||||
return ipmip_cli_daemon_connect(daemon_info);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmippm_cli_request_set_handle(Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 handle)
|
||||
{
|
||||
ipmip_attr_put_u32(&req->reqbuf, IPMIPPM_CLI_ATTR_NODE_HANDLE, handle);
|
||||
}
|
||||
|
||||
IP_PUBLIC struct Ipmip_attr *
|
||||
ipmippm_cli_node_get(Ipmip_cli_daemon_t *daemon,
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 handle)
|
||||
{
|
||||
ipmip_cli_daemon_request_start(req, IPMIPPM_CLI_CLIENT_GET);
|
||||
|
||||
ipmippm_cli_request_set_handle(req, handle);
|
||||
if (ipmip_cli_daemon_request(daemon, req) == IPCOM_SUCCESS)
|
||||
return ipmip_cli_daemon_find_request(req, IPMIPMN_API_CLI_ATTR_NODE);
|
||||
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmippm_cli_node_delete(Ipmip_cli_daemon_t *daemon,
|
||||
Ip_u32 handle)
|
||||
{
|
||||
Ipmip_cli_daemon_req_t req;
|
||||
|
||||
ipmip_cli_daemon_request_init(&req);
|
||||
ipmip_cli_daemon_request_start(&req, IPMIPPM_CLI_CLIENT_DELETE);
|
||||
ipmippm_cli_request_set_handle(&req, handle);
|
||||
ipmip_cli_daemon_request(daemon, &req);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmippm_cli_node_get_handle(struct Ipmip_attr *node)
|
||||
{
|
||||
return ipmip_attr_payload_find_u32(node, IPMIPPM_CLI_ATTR_NODE_HANDLE);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmippm_cli_handle_next(Ipmip_attr_iter_t *iter)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_get_u32(ipmip_attr_iter_next(iter, IPMIPPM_CLI_ATTR_NODE_HANDLE));
|
||||
}
|
||||
|
||||
IP_PUBLIC int
|
||||
ipmippm_cli_node_list(Ipmip_cli_daemon_t *daemon,
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
const char *nai,
|
||||
Ip_u32 hoa)
|
||||
{
|
||||
ipmip_cli_daemon_request_start(req, IPMIPPM_CLI_CLIENT_LIST);
|
||||
ipmipmn_api_cli_request_set_home_address(req,hoa);
|
||||
ipmipmn_api_cli_request_set_nai(req, nai);
|
||||
return ipmip_cli_daemon_request(daemon, req);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,381 @@
|
||||
/* ipmippm_client.h - ipmippm_client.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_client.h,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/src/ipmippm_client.h,v $
|
||||
* $Author: ulf $ $Date: 2009-06-08 11:05:57 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIPPM_CLIENT_H
|
||||
#define IPMIPPM_CLIENT_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
No description currently provided
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <private/ipmipmn_api.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIPPM_CLIENT_REGISTERED (1 << 0)
|
||||
|
||||
enum
|
||||
{
|
||||
IPMIPPM_CLIENT_PROXY_MODE_STANDARD,
|
||||
IPMIPPM_CLIENT_PROXY_MODE_WIMAX,
|
||||
IPMIPPM_CLIENT_PROXY_MODE_MAX
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
struct Ipmipmn_api_iff;
|
||||
struct Ipmipmn_api_pktbuf;
|
||||
struct Ipmippm_pktbuf;
|
||||
union Ipmip4_msgext_uhdr;
|
||||
|
||||
typedef struct Ipmippm_client_conf
|
||||
{
|
||||
Ipmipmn_api_node_conf_t api;
|
||||
|
||||
struct Ipmipmn_api_iff *iff;
|
||||
int proxy_mode;
|
||||
} Ipmippm_client_conf_t;
|
||||
|
||||
typedef struct Ipmippm_client
|
||||
{
|
||||
/* Generic Node */
|
||||
Ipmipmn_api_node_t api;
|
||||
Ip_u32 flags;
|
||||
|
||||
Ip_u32 pmClientIdentity;
|
||||
|
||||
Ip_u8 access_type;
|
||||
|
||||
/* New/Next FA */
|
||||
Ipmipmn_api_coa_t *pmTriggerCOA;
|
||||
|
||||
struct Ipmipmn_api_iff *ifp;
|
||||
Ipmip_lladdr_t *lladdr;
|
||||
|
||||
Ipcom_list triggers;
|
||||
|
||||
union Ipmip4_msgext_uhdr *pmAccessType;
|
||||
union Ipmip4_msgext_uhdr *pmDeviceID;
|
||||
union Ipmip4_msgext_uhdr *pmInterfaceID;
|
||||
union Ipmip4_msgext_uhdr *pmSubscriberID;
|
||||
union Ipmip4_msgext_uhdr *pmPerNodeAuthMethod;
|
||||
|
||||
|
||||
/* State */
|
||||
int state;
|
||||
|
||||
/* Fixed Parameters */
|
||||
Ip_u8 pmTunnelType;
|
||||
Ip_u8 pmReverseTunnel;
|
||||
} Ipmippm_client_t;
|
||||
|
||||
|
||||
typedef struct Ipmippm_client_key
|
||||
{
|
||||
struct Ip_iovec nai;
|
||||
Ip_u8 access_type;
|
||||
} Ipmippm_client_key_t;
|
||||
|
||||
extern Ipmipmn_api_node_functable_t ipmippm_client_func;
|
||||
extern Ipmipmn_api_node_state_functable_t ipmippm_client_state_func;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_client_alloc - ipmippm_client_alloc
|
||||
*
|
||||
* Create a node.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Context
|
||||
* \i proc
|
||||
* Process
|
||||
* \i pbuf
|
||||
* Packet buffer containing the trigger
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: The allocated node.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL Ipmippm_client_t * ipmippm_client_alloc
|
||||
(
|
||||
struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmippm_pktbuf *pbuf
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_client_context_init - ipmippm_client_context_init
|
||||
*
|
||||
* Initialize the client portion of the PM context
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Context
|
||||
* \i proc
|
||||
* Process
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmippm_client_context_init
|
||||
(
|
||||
struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_client_context_destroy - ipmippm_client_context_destroy
|
||||
*
|
||||
* Destroy the client portion of the PM context
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Context
|
||||
* \i proc
|
||||
* Process
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmippm_client_context_destroy
|
||||
(
|
||||
struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_client_terminate - ipmippm_client_terminate
|
||||
*
|
||||
* Gracefully terminate the specified client
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Context
|
||||
* \i proc
|
||||
* Process
|
||||
* \i client
|
||||
* The client to terminate
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: A timer process value.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL int ipmippm_client_terminate
|
||||
(
|
||||
struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmippm_client *client
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_client_clear - ipmippm_client_clear
|
||||
*
|
||||
* Gracefully terminate all existing clients
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Context
|
||||
* \i proc
|
||||
* Process
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmippm_client_clear
|
||||
(
|
||||
struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_client_lookup_handle - ipmippm_client_lookup_handle
|
||||
*
|
||||
* Lookup a client based on the handle
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Context
|
||||
* \i proc
|
||||
* Process
|
||||
* \i handle
|
||||
* The handle
|
||||
* \i timer
|
||||
* Timer object
|
||||
* \i func
|
||||
* Function to call
|
||||
* \i arg1
|
||||
* Opaque argument
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmippm_client_lookup_handle
|
||||
(
|
||||
struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_u32 handle,
|
||||
Ipmip_timer_t *timer,
|
||||
Ipmip_timer_func_t func,
|
||||
void *arg1
|
||||
);
|
||||
|
||||
IP_GLOBAL void ipmippm_client_findbynai
|
||||
(
|
||||
struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipmn_api_iff *ifp,
|
||||
struct Ip_iovec *nai,
|
||||
Ip_u8 access_type,
|
||||
Ipmip_timer_t *timer,
|
||||
Ipmip_timer_func_t func,
|
||||
void *arg1
|
||||
);
|
||||
|
||||
IP_GLOBAL void ipmippm_client_trigger_handoff
|
||||
(
|
||||
struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmippm_pktbuf *pbuf
|
||||
);
|
||||
|
||||
IP_GLOBAL const char *ipmippm_client_describe
|
||||
(
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmippm_client_t *client
|
||||
);
|
||||
|
||||
IP_GLOBAL Ipmipmn_api_coa_t *ipmippm_client_alloc_coa
|
||||
(
|
||||
Ip_u32 address,
|
||||
Ip_u16 lifetime,
|
||||
Ipmipmn_api_coa_output_t output,
|
||||
Ip_u32 extra
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_client_init_coa - ipmippm_client_init_coa
|
||||
*
|
||||
* Init parameters for a new CoA
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Context
|
||||
* \i proc
|
||||
* Process
|
||||
* \i node
|
||||
* The Node
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmippm_client_init_coa
|
||||
(
|
||||
struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmippm_client_t *client
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,504 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_cmd_pm.c,v $ $Revision: 1.9.16.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/src/ipmippm_cmd_pm.c,v $
|
||||
* $Author: jsheng $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Niklas Lundberg <n@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
*******************************************************************************
|
||||
*
|
||||
*/
|
||||
/*
|
||||
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_getopt.h>
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_tmo2.h>
|
||||
#include <ipcom_cmd.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_cli.h>
|
||||
#include <private/ipmip_context.h>
|
||||
|
||||
#include <ipmip4.h>
|
||||
#include <private/ipmip4_msgext.h>
|
||||
#include <private/ipmip4_netlink.h>
|
||||
#include <private/ipmip4_ntop.h>
|
||||
#include <private/ipmip4_lla.h>
|
||||
|
||||
#include "ipmippm.h"
|
||||
#include "ipmippm_attr.h"
|
||||
#include "ipmippm_cli.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC int ipmippm_cmd_pm(int argc, char **argv);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIPPM_CMD_OP_LIST (1)
|
||||
#define IPMIPPM_CMD_OP_SHOW (2)
|
||||
#define IPMIPPM_CMD_OP_DELETE (3)
|
||||
|
||||
IP_STATIC Ipcom_cmd_int_str_map ipmippm_cmd_ops[] =
|
||||
{
|
||||
{ IPMIPPM_CMD_OP_LIST, "list" },
|
||||
{ IPMIPPM_CMD_OP_SHOW, "show" },
|
||||
{ IPMIPPM_CMD_OP_DELETE, "delete" },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_cmd_print_binding_fmt
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmippm_cmd_print_binding_fmt(const char *hoa,
|
||||
const char *coa,
|
||||
const char *home_agent,
|
||||
const char *lifetime,
|
||||
const char *nai)
|
||||
{
|
||||
/* */
|
||||
ipcom_printf("%-20s %-20s %-16s %-15s %s"IP_LF,
|
||||
hoa, coa, home_agent, lifetime, nai);
|
||||
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmippm_cmd_print_node(Ipmip_proc_t *proc,
|
||||
struct Ipmip_attr *node,
|
||||
struct Ipmip_attr *coa,
|
||||
Ip_bool verbose)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(verbose);
|
||||
|
||||
ipcom_snprintf(proc->ntop.ntop_lla, sizeof(proc->ntop.ntop_lla),
|
||||
"%d/%d",
|
||||
ipmipmn_api_cli_node_get_time_remaining(node),
|
||||
ipmipmn_api_cli_node_get_time_requested(node));
|
||||
|
||||
ipmippm_cmd_print_binding_fmt(ipmip_ntop_inet(proc, ipmipmn_api_cli_node_get_home_address(node)),
|
||||
ipmip_ntop_inet(proc, ipmipmn_api_cli_node_coa_get_address(coa)),
|
||||
ipmip_ntop_inet(proc, ipmipmn_api_cli_node_get_home_agent(node)),
|
||||
proc->ntop.ntop_lla,
|
||||
ipmipmn_api_cli_node_get_nai(node));
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmippm_cmd_show_node(Ipmip_proc_t *proc,
|
||||
struct Ipmip_attr *node,
|
||||
struct Ipmip_attr *coa,
|
||||
Ip_bool verbose)
|
||||
{
|
||||
Ip_u32 tmp;
|
||||
Ip_u32 status;
|
||||
const char *str;
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(verbose);
|
||||
|
||||
ipcom_printf("Proxy Mobile Node : %08x"IP_LF, ipmippm_cli_node_get_handle(node));
|
||||
|
||||
status = ipmipmn_api_cli_node_get_status(node);
|
||||
ipcom_printf(" Status : %s"IP_LF, ipmipmn_api_attr_statename[status]);
|
||||
|
||||
tmp = ipmipmn_api_cli_node_get_home_address(node);
|
||||
if (tmp != 0)
|
||||
ipcom_printf(" Home Address : %s"IP_LF, ipmip_ntop_inet(proc, tmp));
|
||||
ipcom_printf(" Dynamic Home Address: %s"IP_LF, ipmipmn_api_cli_node_get_home_address_dynamic(node)? "yes" : "no");
|
||||
|
||||
tmp = ipmipmn_api_cli_node_get_home_agent(node);
|
||||
if (tmp != 0)
|
||||
ipcom_printf(" Assigned Home Agent : %s"IP_LF, ipmip_ntop_inet(proc, tmp));
|
||||
|
||||
tmp = ipmipmn_api_cli_node_get_home_agent_pending(node);
|
||||
if (tmp != 0)
|
||||
ipcom_printf(" Pending Home Agent : %s"IP_LF, ipmip_ntop_inet(proc, tmp));
|
||||
|
||||
ipcom_printf(" Reverse Tunnel : %s"IP_LF, ipmipmn_api_cli_node_get_tunnel_reverse(node)? "yes" : "no");
|
||||
ipcom_printf(" Broadcast : %s"IP_LF, ipmipmn_api_cli_node_get_receive_broadcast(node)? "yes" : "no");
|
||||
ipcom_printf(" Home Agent Discovery: %s"IP_LF, ipmipmn_api_attr_dhaa[ipmipmn_api_cli_node_get_home_agent_dhaa(node)]);
|
||||
|
||||
|
||||
ipcom_printf(" Tunnel type : %s"IP_LF, ipmip_util_tunnel_to_desc(ipmipmn_api_cli_node_get_tunnel_type(node)));
|
||||
|
||||
str = ipmipmn_api_cli_node_get_nai(node);
|
||||
if (str != IP_NULL)
|
||||
ipcom_printf(" Mobile Node NAI : %s"IP_LF, str);
|
||||
|
||||
if (status >= IPMIPMN_ATTR_STATE_REGISTERED)
|
||||
{
|
||||
ipcom_printf(" Established : %s"IP_LF, ipmip_ntop_tm(proc, ipmipmn_api_cli_node_get_created(node)));;
|
||||
ipcom_printf(" Updated : %s"IP_LF, ipmip_ntop_tm(proc, ipmipmn_api_cli_node_get_last_updated(node)));
|
||||
|
||||
ipcom_printf(" Lifetime : %u/%u"IP_LF, ipmipmn_api_cli_node_get_time_remaining(node), ipmipmn_api_cli_node_get_time_requested(node));
|
||||
|
||||
str = ipmipmn_api_cli_node_get_nai_ha(node);
|
||||
if (str != IP_NULL)
|
||||
ipcom_printf(" Home Agent NAI : %s"IP_LF, str);
|
||||
str = ipmipmn_api_cli_node_get_nai_aaah(node);
|
||||
if (str != IP_NULL)
|
||||
ipcom_printf(" AAAH Agent NAI : %s"IP_LF, str);
|
||||
}
|
||||
|
||||
/* Current care of? */
|
||||
if (coa != IP_NULL)
|
||||
{
|
||||
ipcom_printf(" Care Of Address :"IP_LF);
|
||||
ipcom_printf(" CoA Type : %s"IP_LF, ipmipmn_api_attr_coaname[ipmipmn_api_cli_node_coa_get_type(coa)]);
|
||||
ipcom_printf(" CoA Peer : %s"IP_LF, ipmipmn_api_attr_peername[ipmipmn_api_cli_node_coa_get_peer(coa)]);
|
||||
ipcom_printf(" CoA Address : %s"IP_LF, ipmip_ntop_inet(proc, ipmipmn_api_cli_node_coa_get_address(coa)));
|
||||
ipcom_printf(" Challenge : %s"IP_LF, ipmipmn_api_cli_node_coa_get_challenge(coa)? "yes" : "no");
|
||||
|
||||
tmp = ipmipmn_api_cli_node_coa_get_tunnel_flags(coa);
|
||||
ipcom_printf(" NAT Traversal : %s"IP_LF, IP_BIT_ARESET(tmp, IPMIP4_TUNNELMODE_NAT_T_CONFIRMED)? "yes" : "no");
|
||||
ipcom_printf(" Reg. Revocation : %s"IP_LF, IP_BIT_ARESET(tmp, IPMIP4_TUNNELMODE_REVOCATION_CONFIRMED)? "yes" : "no");
|
||||
ipcom_printf(" Retransmits : %u"IP_LF, ipmipmn_api_cli_node_coa_get_retransmits(coa));
|
||||
|
||||
tmp = ipmipmn_api_cli_node_coa_get_spi_mf(coa);
|
||||
if (tmp)
|
||||
ipcom_printf(" SPI MF : %u"IP_LF, tmp);
|
||||
tmp = ipmipmn_api_cli_node_coa_get_spi_mh(coa);
|
||||
if (tmp)
|
||||
ipcom_printf(" SPI MH : %u"IP_LF, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_cmd_print_event
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmippm_cmd_handle_exec(Ipmip_proc_t *proc,
|
||||
Ipmip_cli_daemon_t *daemon,
|
||||
Ip_u32 handle,
|
||||
Ip_u32 cmd,
|
||||
Ip_bool verbose)
|
||||
{
|
||||
struct Ipmip_attr *node;
|
||||
Ipmip_cli_daemon_req_t nreq;
|
||||
|
||||
ipmip_cli_daemon_request_init(&nreq);
|
||||
|
||||
if (cmd == IPMIPPM_CMD_OP_DELETE)
|
||||
ipmippm_cli_node_delete(daemon, handle);
|
||||
else if ((node = ipmippm_cli_node_get(daemon, &nreq, handle)) != IP_NULL)
|
||||
{
|
||||
struct Ipmip_attr *coa = ipmipmn_api_cli_node_coa_get(node);
|
||||
if(IP_NULL == coa)
|
||||
return;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case IPMIPPM_CMD_OP_LIST:
|
||||
ipmippm_cmd_print_node(proc, node, coa, verbose);
|
||||
break;
|
||||
case IPMIPPM_CMD_OP_SHOW:
|
||||
ipmippm_cmd_show_node(proc, node, coa, verbose);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ipmip_cli_daemon_request_release(&nreq);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_cmd_mn
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters: .
|
||||
* Returns: .
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipmippm_cmd_pm(int argc, char **argv)
|
||||
{
|
||||
Ipcom_getopt opt;
|
||||
int op_val;
|
||||
char *op;
|
||||
Ipmip_cli_daemon_t daemon;
|
||||
Ipmip_cli_daemon_req_t req;
|
||||
Ipmip_proc_t *proc = IP_NULL;
|
||||
int i;
|
||||
|
||||
daemon.fd = IP_INVALID_SOCKET;
|
||||
|
||||
ipmip_cli_daemon_request_init(&req);
|
||||
|
||||
proc = ipmip_proc_alloc();
|
||||
if (proc == IP_NULL)
|
||||
{
|
||||
ipcom_printf("mn: failed to create process context"IP_LF);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (argc < 2)
|
||||
goto usage;
|
||||
|
||||
|
||||
/* Get a connection to the home agent. */
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
if (ipmippm_cli_connect(&daemon))
|
||||
break;
|
||||
ipcom_sleep(1);
|
||||
}
|
||||
|
||||
if (daemon.fd == IP_INVALID_SOCKET)
|
||||
{
|
||||
ipcom_printf("pm: failed to connect to proxy client"IP_LF);
|
||||
ipmip_proc_destroy(proc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ipcom_getopt_clear_r(&opt);
|
||||
|
||||
op = argv[1];
|
||||
op_val = ipcom_cmd_str_to_key(ipmippm_cmd_ops, op);
|
||||
|
||||
if (op_val == -1)
|
||||
{
|
||||
if (ipmip4_cli_shell_cmd(argc, argv, proc, &daemon) == -1)
|
||||
{
|
||||
ipcom_printf("'%s' is an invalid operation"IP_LF, op);
|
||||
goto usage;
|
||||
}
|
||||
goto exit_out;
|
||||
}
|
||||
|
||||
|
||||
if (op_val == IPMIPPM_CMD_OP_LIST ||
|
||||
op_val == IPMIPPM_CMD_OP_SHOW ||
|
||||
op_val == IPMIPPM_CMD_OP_DELETE)
|
||||
{
|
||||
/* Show node information */
|
||||
Ip_bool all = IP_FALSE;
|
||||
Ip_bool verbose = IP_FALSE;
|
||||
const char *nai = IP_NULL;
|
||||
Ip_u32 hoa = 0;
|
||||
int args = 0;
|
||||
int ret = IPCOM_SUCCESS;
|
||||
static struct Ip_option long_options[] =
|
||||
{
|
||||
{"hoa", 1, 0, 0},
|
||||
{"nai", 1, 0, 0},
|
||||
{"all", 0, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
opt.long_only = 1;
|
||||
opt.long_options = long_options;
|
||||
|
||||
while ((i = ipcom_getopt_r(argc - 1, argv + 1, "av", &opt)) != -1)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
switch(opt.long_index)
|
||||
{
|
||||
case 0:
|
||||
/* hoa -- Home Address */
|
||||
args++;
|
||||
if (ipcom_inet_pton(IP_AF_INET, opt.optarg, &hoa) != 1)
|
||||
{
|
||||
ipcom_printf("bad '--hoa' IPv4 address."IP_LF);
|
||||
goto usage;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
/* nai */
|
||||
args++;
|
||||
nai = opt.optarg;
|
||||
break;
|
||||
case 2:
|
||||
args++;
|
||||
all = IP_TRUE;
|
||||
break;
|
||||
case 3:
|
||||
verbose = IP_TRUE;
|
||||
break;
|
||||
default:
|
||||
ipcom_printf("unknown option %s", long_options[opt.long_index].name);
|
||||
if (opt.optarg)
|
||||
ipcom_printf(" with arg %s", opt.optarg);
|
||||
ipcom_printf(IP_LF);
|
||||
goto usage;
|
||||
}
|
||||
break;
|
||||
case 'a':
|
||||
args++;
|
||||
all = IP_TRUE;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = IP_TRUE;
|
||||
break;
|
||||
default:
|
||||
ipcom_printf("fa: invalid option '%c'"IP_LF, i);
|
||||
goto usage;
|
||||
}
|
||||
}
|
||||
|
||||
if (op_val == IPMIPPM_CMD_OP_LIST)
|
||||
ipmippm_cmd_print_binding_fmt("Home Address",
|
||||
"Care of Address",
|
||||
"Home Agent",
|
||||
"Lifetime",
|
||||
"NAI");
|
||||
|
||||
if (args > 0)
|
||||
{
|
||||
if (all)
|
||||
ret = ipmippm_cli_node_list(&daemon, &req, IP_NULL, 0);
|
||||
else if (args)
|
||||
ret = ipmippm_cli_node_list(&daemon, &req, nai, hoa);
|
||||
|
||||
if (ret == IPCOM_SUCCESS)
|
||||
{
|
||||
Ipmip_attr_iter_t riter;
|
||||
Ip_u32 handle;
|
||||
|
||||
/**/
|
||||
ipmip_cli_daemon_iter_request_init(&req, &riter);
|
||||
while ((handle = ipmippm_cli_handle_next(&riter)) != 0)
|
||||
ipmippm_cmd_handle_exec(proc, &daemon, handle, op_val, verbose);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = opt.optind + 1; i < argc; i++)
|
||||
ipmippm_cmd_handle_exec(proc, &daemon, ipcom_strtoul(argv[i], IP_NULL, 0), op_val, verbose);
|
||||
}
|
||||
}
|
||||
|
||||
exit_out:
|
||||
ipmip_cli_daemon_disconnect(&daemon);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
ipmip_proc_destroy(proc);
|
||||
return 0;
|
||||
|
||||
/****** Usage ******/
|
||||
usage:
|
||||
ipmip_util_identprintf(proc, 0, "NAME"IP_LF);
|
||||
ipmip_util_identprintf(proc, 1, "pm - Displays Proxy Mobile Node bindings, statistics and status" IP_LF);
|
||||
ipmip_util_identprintf(proc, 0, "SYNOPSIS"IP_LF);
|
||||
ipmip_util_identprintf(proc, 1, "pm <command> [arguments]"IP_LF);
|
||||
ipmip_util_identprintf(proc, 0, "DESCRIPTION"IP_LF);
|
||||
ipmip_util_identprintf(proc, 1,
|
||||
"The pm command version %u.%u.%u is used to display current Proxy Mobile Node MIPv4"IP_LF
|
||||
"bindings, statistics and status."IP_LF,
|
||||
(IPMIPPM_RELEASE / 10000) % 100, (IPMIPPM_RELEASE / 100) % 100, IPMIPPM_RELEASE % 100);
|
||||
ipmip_util_identprintf(proc, 0, "COMMANDS"IP_LF);
|
||||
ipmip_util_cmdprintf(proc, 1, "show [--all] [--verbose] [--hoa=<hoa>] [--nai=<nai>] [<handle>]", "Show the proxy mobile node status");
|
||||
ipmip_util_identprintf(proc, 2, "--verbose Verbose mode"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "--all Affect all nodes"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "--hoa=<hoa> Specify the hoa we're looking for"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "--nai=<nai> Specify the nai we're looking for"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "<handle> The unique handle for the proxy mobile node"IP_LF);
|
||||
ipmip_util_cmdprintf(proc, 1, "delete [--all] [--hoa=<hoa>] [--nai=<nai>] [<handle>]", "Delete the proxy mobile node status");
|
||||
ipmip_util_identprintf(proc, 2, "--all Affect all nodes"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "--hoa=<hoa> Specify the hoa we're looking for"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "--nai=<nai> Specify the nai we're looking for"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "<handle> The unique handle for the proxy mobile node"IP_LF);
|
||||
ipmip_util_cmdprintf(proc, 1, "list [--all] [--hoa=<hoa>] [--nai=<nai>] [<handle>]", "List the proxy mobile nodes");
|
||||
ipmip_util_identprintf(proc, 2, "--all Affect all nodes"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "--hoa=<hoa> Specify the hoa we're looking for"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "--nai=<nai> Specify the nai we're looking for"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "<handle> The unique handle for the proxy mobile node"IP_LF);
|
||||
ipmip4_cli_shell_usage(proc);
|
||||
|
||||
ipmip_cli_daemon_disconnect(&daemon);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
ipmip_proc_destroy(proc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_h.h,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/src/ipmippm_h.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-04-23 15:19:27 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIPPM_H_H
|
||||
#define IPMIPPM_H_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <private/ipmipmn_api.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIPPM_SHUTDOWN_REG (1 << 0)
|
||||
|
||||
#define IPMIPPM_SHUTDOWN_ALL (IPMIPPM_SHUTDOWN_REG)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmipmn_client_conf;
|
||||
|
||||
/* All configuration collected */
|
||||
typedef struct Ipmippm_conf
|
||||
{
|
||||
Ipcom_list if_head;
|
||||
}
|
||||
Ipmippm_conf_t;
|
||||
|
||||
|
||||
typedef struct Ipmippm_context
|
||||
{
|
||||
Ipmipmn_api_context_t api;
|
||||
|
||||
/* Configuration */
|
||||
struct Ipmippm_conf *conf;
|
||||
struct Ipmip_context_id *idents;
|
||||
|
||||
/* */
|
||||
Ip_u32 clients;
|
||||
|
||||
Ip_u32 shutdown;
|
||||
|
||||
/* Lock to protect nodes */
|
||||
Ipcom_mutex attr_lock;
|
||||
}
|
||||
Ipmippm_context_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmipmn_api_extension;
|
||||
|
||||
IP_GLOBAL void ipmippm_main(void);
|
||||
IP_GLOBAL Ip_u32 ipmippm_context_register_function(struct Ipmipmn_api_extension *srv);
|
||||
IP_GLOBAL void ipmippm_msgext_vendor_parse_ext_register(struct Ipmip4_msgext_vendor_parse_ext *pext);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,398 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_if.c,v $ $Revision: 1.2.16.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/src/ipmippm_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 "ipmippm_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.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_syslog.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
#include <private/ipmip_timer.h>
|
||||
|
||||
#include <ipmip4.h>
|
||||
#include <private/ipmip4_context.h>
|
||||
#include <private/ipmip4_util.h>
|
||||
#include <private/ipmip4_sysext.h>
|
||||
#include <private/ipmip4_auth.h>
|
||||
#include <private/ipmip4_pkt.h>
|
||||
|
||||
#include "ipmippm.h"
|
||||
#include "ipmippm_h.h"
|
||||
#include "ipmippm_attr_h.h"
|
||||
#include "ipmippm_client.h"
|
||||
#include "ipmippm_if.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_client_key_hash_nai
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC unsigned
|
||||
ipmippm_if_client_key_hash_nai(Ipmippm_client_key_t *key)
|
||||
{
|
||||
/* Do the hash from the subtype and forward */
|
||||
return ipcom_hash_update(key->nai.iov_base, key->nai.iov_len, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_client_obj_hash_nai
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC unsigned
|
||||
ipmippm_if_client_obj_hash_nai(Ipmippm_client_t *client)
|
||||
{
|
||||
return ipcom_hash_update(IPMIP4_MSGEXT_SHDR_EXT_DATA(client->api.params.nai_mn), IPMIP4_MSGEXT_SHDR_EXT_SIZE(client->api.params.nai_mn), 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_client_cmp_nai
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipmippm_if_client_cmp_nai(Ipmippm_client_t *client, Ipmippm_client_key_t *key)
|
||||
{
|
||||
if (key->nai.iov_len == IPMIP4_MSGEXT_SHDR_EXT_SIZE(client->api.params.nai_mn))
|
||||
{
|
||||
if (ipcom_memcmp(key->nai.iov_base, IPMIP4_MSGEXT_SHDR_EXT_DATA(client->api.params.nai_mn), key->nai.iov_len) == 0)
|
||||
{
|
||||
/* */
|
||||
if (client->access_type == 0 || key->access_type == 0 || client->access_type == key->access_type)
|
||||
return IP_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_if_delete
|
||||
*===========================================================================
|
||||
* Description: Delete an interface
|
||||
* Parameters: iff - The interface to delete.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmippm_if_delete(Ipmippm_context_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmippm_if_t *iff)
|
||||
{
|
||||
/* Destroy the lock */
|
||||
/* Allocate the hash tables */
|
||||
ipcom_hash_delete(iff->hash_nai);
|
||||
|
||||
/* Create the locks & blocks */
|
||||
ipcom_mutex_delete(&iff->client_lock);
|
||||
|
||||
if (iff->if_lock)
|
||||
ipmip_timer_lock_destroy(&data->api.ipmip4.ipmip, proc, iff->if_lock);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_if_alloc
|
||||
*===========================================================================
|
||||
* Description: Allocate a specified interface, and verify arch specific
|
||||
* data.
|
||||
* Parameters: data - The FA data structure.
|
||||
* ifname - The interface name.
|
||||
* Returns: The interface structure if successfull; IP_NULL otherwise.
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ipmippm_if_t *
|
||||
ipmippm_if_alloc(Ipmippm_context_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
const char *ifname)
|
||||
{
|
||||
/* Allocate an interface structure */
|
||||
Ipmippm_if_t *iff = IP_NULL;
|
||||
Ip_u32 ifindex;
|
||||
|
||||
ifindex = ipcom_if_nametoindex(ifname);
|
||||
if (ifindex == 0)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&data->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"Configuration failed, due to unknown interface '%s'",
|
||||
ifname));
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
/* Allocate the structure */
|
||||
iff = (Ipmippm_if_t*)ipmip4_if_alloc(&data->api.ipmip4,
|
||||
proc,
|
||||
sizeof(*iff),
|
||||
ifname,
|
||||
ifindex,
|
||||
IPMIP_IF_TYPE_GENERIC,
|
||||
0,
|
||||
(Ipmip_if_cleanup_t )ipmippm_if_delete);
|
||||
|
||||
/* Sanity */
|
||||
if (iff == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
/* Allocate the hash tables */
|
||||
iff->hash_nai = ipcom_hash_new((Ipcom_hash_obj_func) ipmippm_if_client_obj_hash_nai,
|
||||
(Ipcom_hash_key_func) ipmippm_if_client_key_hash_nai,
|
||||
(Ipcom_hash_cmp_func) ipmippm_if_client_cmp_nai);
|
||||
|
||||
/* Create the locks & blocks */
|
||||
(void)ipcom_mutex_create(&iff->client_lock);
|
||||
|
||||
/* Return the interface structure */
|
||||
return iff;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_if_configure
|
||||
*===========================================================================
|
||||
* Description: Post creation configuration
|
||||
* Parameters: data - The data
|
||||
* proc - Current process
|
||||
* iff - The interface we're configuring.
|
||||
* conf - The configuration context.
|
||||
* Returns: IP_TRUE if successful
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipmippm_if_configure(Ipmippm_context_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmippm_if_t *iff)
|
||||
{
|
||||
/* If we don't have the FA address, try resolve it */
|
||||
if (iff->iff.ifaddr == 0)
|
||||
{
|
||||
/* Store extracted address */
|
||||
iff->iff.ifaddr = ipmip4_if_get_primary_address(&data->api.ipmip4, proc, &iff->iff);
|
||||
|
||||
/* Sanity */
|
||||
if (iff->iff.ifaddr == IP_INADDR_NONE ||
|
||||
iff->iff.ifaddr == IP_INADDR_ANY)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&data->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"auto-configuring: FAIL, %s returned for interface '%s'",
|
||||
ipmip_ntop_inet(proc, iff->iff.ifaddr),
|
||||
iff->iff.ipmip.ifname));
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/**/
|
||||
IPMIP4_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&data->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"auto-configuring: interface '%s' configured to use %s",
|
||||
iff->iff.ipmip.ifname,
|
||||
ipmip_ntop_inet(proc, iff->iff.ifaddr)));
|
||||
}
|
||||
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_if_create
|
||||
*===========================================================================
|
||||
* Description: Create an interface for a specified configuration.
|
||||
* Parameters: data - The FA entity.
|
||||
* proc - Current process.
|
||||
* conf - The current configuration.
|
||||
* ifname - The name of the interface.
|
||||
* Returns: IP_TRUE if successful.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool
|
||||
ipmippm_if_create(Ipmippm_context_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmippm_conf_t *conf,
|
||||
const char *ifname)
|
||||
{
|
||||
Ipmippm_if_t *iff;
|
||||
char spec[IP_IFNAMSIZ + 6];
|
||||
|
||||
|
||||
/* Try create the interface in question */
|
||||
if ((iff = ipmippm_if_alloc(data,proc,ifname)) == IP_NULL)
|
||||
return IP_FALSE;
|
||||
|
||||
/* Store it */
|
||||
ipcom_list_insert_first(&conf->if_head, &iff->iff.ipmip.next);
|
||||
|
||||
/* Initialize the lock */
|
||||
iff->if_lock = ipmip_timer_lock_alloc(&data->api.ipmip4.ipmip, proc, IP_NULL, IP_NULL);
|
||||
|
||||
iff->conf = ipcom_calloc(1, sizeof(*iff->conf));
|
||||
if(IP_NULL == iff->conf)
|
||||
return IP_FALSE;
|
||||
|
||||
iff->conf->iff = iff;
|
||||
|
||||
ipmip_sysvar_inet(0, &iff->iff.ifaddr, IP_NULL, "ipmippm.if.%s.address", iff->iff.ipmip.ifname);
|
||||
|
||||
if (!ipmippm_if_configure(data, proc, iff))
|
||||
goto fail;
|
||||
|
||||
ipcom_snprintf(spec, sizeof(spec), "if.%s.", ifname);
|
||||
|
||||
if (!ipmipmn_api_node_config_read(&data->api, proc, &iff->conf->api, "ipmippm", spec))
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&data->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"unable to read configuration for %s",
|
||||
ifname));
|
||||
goto fail;
|
||||
|
||||
}
|
||||
|
||||
return IP_TRUE;
|
||||
fail:
|
||||
ipmip_if_free(&data->api.ipmip4.ipmip, proc, &iff->iff.ipmip);
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipfa_if_start
|
||||
*===========================================================================
|
||||
* Description: Start an interface for a specified configuration.
|
||||
* Parameters: data - The FA entity.
|
||||
* proc - Current process.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmippm_if_stop(Ipmippm_context_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmippm_conf_t *conf)
|
||||
{
|
||||
Ipmippm_if_t *iff;
|
||||
|
||||
/* Send instant RtAdv on all active interfaces */
|
||||
while (IP_NULL != (iff = IPCOM_LIST_FIRST(&conf->if_head)))
|
||||
{
|
||||
ipmipmn_api_node_config_free(&data->api, proc, &iff->conf->api);
|
||||
ipmip_if_free(&data->api.ipmip4.ipmip, proc, &iff->iff.ipmip);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,154 @@
|
||||
/* ipmippm_if.h - ipmippm_if.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_if.h,v $ $Revision: 1.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/src/ipmippm_if.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-04-23 15:19:27 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIPPM_IFF_H
|
||||
#define IPMIPPM_IFF_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
No description currently provided
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <private/ipmip4_if.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmippm_context;
|
||||
struct Ipmippm_client_conf;
|
||||
struct Ipmip_proc;
|
||||
|
||||
/* one per interface */
|
||||
typedef struct Ipmipmn_api_iff
|
||||
{
|
||||
Ipmip4_if_t iff;
|
||||
|
||||
Ipmip_timer_lock_t *if_lock;
|
||||
|
||||
/* Client lookup structures */
|
||||
Ipcom_mutex client_lock;
|
||||
Ipcom_hash *hash_nai; /* All known MN using NAI address as key */
|
||||
|
||||
/**/
|
||||
struct Ipmippm_client_conf *conf;
|
||||
}
|
||||
Ipmippm_if_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_if_create - ipmippm_if_create
|
||||
*
|
||||
* Create an interface for a specified configuration.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* The FA entity.
|
||||
* \i proc
|
||||
* Current process.
|
||||
* \i conf
|
||||
* The current configuration.
|
||||
* \i ifname
|
||||
* The name of the interface.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE if successful.
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmippm_if_create
|
||||
(
|
||||
struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmippm_conf *conf,
|
||||
const char *ifname
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_if_stop - ipmippm_if_stop
|
||||
*
|
||||
* Stop the interfaces belonging to a particular configuration
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* The FA entity.
|
||||
* \i proc
|
||||
* Current process
|
||||
* \i conf
|
||||
* The current configuration.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmippm_if_stop
|
||||
(
|
||||
struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmippm_conf *conf
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,571 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_main.c,v $ $Revision: 1.8.16.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/src/ipmippm_main.c,v $
|
||||
* $Author: jsheng $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Niklas Lundberg <n@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
*******************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include "ipmippm_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_sysvar.h>
|
||||
|
||||
#include <ipmip4.h>
|
||||
#include <private/ipmip4_pkt.h>
|
||||
#include <private/ipmip4_sysext.h>
|
||||
#include <private/ipmip4_util.h>
|
||||
#include <private/ipmip4_radius.h>
|
||||
|
||||
#include <private/ipmipmn_api.h>
|
||||
|
||||
#include "ipmippm.h"
|
||||
#include "ipmippm_h.h"
|
||||
#include "ipmippm_reg.h"
|
||||
#include "ipmippm_client.h"
|
||||
#include "ipmippm_attr_h.h"
|
||||
#include "ipmippm_if.h"
|
||||
#include "ipmippm_pktbuf.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Application datatypes
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err ipmippm_configure(void);
|
||||
IP_PUBLIC Ip_err ipmippm_init(void);
|
||||
IP_PUBLIC Ip_err ipmippm_exit(void);
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
static int ipmippm_instances = 0;
|
||||
static Ipcom_once_t ipmippm_extensions_once = IPCOM_ONCE_INIT;
|
||||
static Ipmipmn_api_function_context_t ipmippm_extensions;
|
||||
static Ipcom_list ipmippm_msgext_vendor_extensions;
|
||||
static Ipmip_pktbuf_pktaux_t ipmippm_pktaux;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
ipmippm_main_once_init(void *unused)
|
||||
{
|
||||
int f;
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(unused);
|
||||
|
||||
/* Clear */
|
||||
ipcom_memset(&ipmippm_extensions, 0, sizeof(ipmippm_extensions));
|
||||
ipcom_memset(&ipmippm_pktaux, 0, sizeof(ipmippm_pktaux));
|
||||
ipcom_list_init(&ipmippm_msgext_vendor_extensions);
|
||||
|
||||
/* Must be first */
|
||||
ipmippm_reg_register_service();
|
||||
|
||||
/* Indicate the elements */
|
||||
/* Do service init */
|
||||
for (f = 0; ipmippm_function_registrations[f] != IP_NULL; f++)
|
||||
(*ipmippm_function_registrations[f]) ();
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmippm_config_free(Ipmippm_context_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmippm_conf_t *conf)
|
||||
{
|
||||
ipmippm_if_stop(data, proc, conf);
|
||||
|
||||
/**/
|
||||
ipcom_free(conf);
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_exit_agent
|
||||
*===========================================================================
|
||||
* Description: Cleanup the resources allocated by this FA entity.
|
||||
* Parameters: data - The FA entity structure.
|
||||
* proc - Current process
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmippm_exit_agent(Ipmippm_context_t *data,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
/* Sanity */
|
||||
if (data == IP_NULL)
|
||||
return;
|
||||
|
||||
/* Stop the context */
|
||||
ipmip4_context_stop(&data->api.ipmip4, proc);
|
||||
|
||||
/* Destroy any node context */
|
||||
ipmippm_client_context_destroy(data, proc);
|
||||
|
||||
/* Exit the IPD */
|
||||
if (data->api.fd_ipd == IP_INVALID_SOCKET)
|
||||
(void)ipcom_ipd_init("ipmippm", IPCOM_ERR_FAILED, &data->api.fd_ipd);
|
||||
|
||||
(void)ipcom_ipd_exit("ipmippm", data->api.fd_ipd);
|
||||
|
||||
/**/
|
||||
ipcom_mutex_delete(&data->attr_lock);
|
||||
|
||||
ipmip_context_id_destroy(data->idents);
|
||||
|
||||
/* Free the context */
|
||||
ipmip4_context_destroy(&data->api.ipmip4, proc);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_init_agent
|
||||
*===========================================================================
|
||||
* Description: Allocate and initialize a FA entity structure.
|
||||
* Parameters: proc - Current process
|
||||
* Returns: The new FA entity structure if successful.
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ipmippm_context_t *
|
||||
ipmippm_init_agent(Ipmip_proc_t *proc)
|
||||
{
|
||||
Ipmippm_context_t *data;
|
||||
|
||||
(void)IPMIP_ONCE(&ipmippm_extensions_once, ipmippm_main_once_init, IP_NULL);
|
||||
|
||||
data = (Ipmippm_context_t *) ipmip_context_alloc(proc, sizeof(*data), "ipmippm", IPMIP4_SYSTEM_PRIORITY, IPMIPPM_EVENT_BACKLOG);
|
||||
if (data == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
/* Add */
|
||||
data->api.functions = &ipmippm_extensions;
|
||||
data->api.ipmip4.vendor_extensions = &ipmippm_msgext_vendor_extensions;
|
||||
data->api.ipmip4.ipmip.pktaux = &ipmippm_pktaux;
|
||||
|
||||
ipmip4_context_init(&data->api.ipmip4, proc);
|
||||
|
||||
/* Initialize file descriptors */
|
||||
data->api.fd_ipd = IP_INVALID_SOCKET;
|
||||
|
||||
IPCOM_LOG1(INFO, "IPMIPPM starting [VR %d]", data->api.ipmip4.ipmip.vr);
|
||||
|
||||
(void)ipcom_mutex_create(&data->attr_lock);
|
||||
|
||||
data->idents = ipmip_context_id_create(ip_offsetof(Ipmippm_client_t, pmClientIdentity), 0xFFFFFFFF);
|
||||
|
||||
/* IPD init. */
|
||||
if (ipcom_ipd_init("ipmippm", IPCOM_SUCCESS, &data->api.fd_ipd) != IPCOM_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
ipmipmn_api_init(&data->api,
|
||||
proc,
|
||||
&ipmippm_client_func,
|
||||
&ipmippm_client_state_func);
|
||||
|
||||
/* Init data */
|
||||
ipmippm_client_context_init(data, proc);
|
||||
|
||||
ipmip_cli_context_create(&data->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"ipmippm",
|
||||
IPCOM_IPD_ID_IPMIPPM,
|
||||
(Ipmip_cli_callback_t)ipmippm_attr_command);
|
||||
|
||||
/* Create the packet buffer context */
|
||||
ipmip_pktbuf_context_create(&data->api.ipmip4.ipmip,
|
||||
proc,
|
||||
(Ipmip_pkt_buf_alloc_t)ipmippm_pktbuf_alloc,
|
||||
(Ipmip_pkt_buf_free_t)ipmippm_pktbuf_free);
|
||||
|
||||
/**/
|
||||
ipmip4_pkt_context_create(&data->api.ipmip4,
|
||||
proc,
|
||||
0,
|
||||
IP_NULL,
|
||||
IP_NULL,
|
||||
IP_NULL);
|
||||
|
||||
return data;
|
||||
|
||||
fail:
|
||||
ipmippm_exit_agent(data, proc);
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_config_exit
|
||||
*===========================================================================
|
||||
* Description: Clear out a configuration structure, free any resources
|
||||
* associated with it.
|
||||
* Parameters: data - The FA entity it belongs to
|
||||
* proc - The process
|
||||
* conf - The configuration structure.
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmippm_config_exit(Ipmippm_context_t *data,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
if (data->conf == IP_NULL)
|
||||
return;
|
||||
|
||||
/* Free all mobile nodes */
|
||||
ipmippm_client_clear(data, proc);
|
||||
|
||||
/**/
|
||||
ipmip4_context_stop(&data->api.ipmip4, proc);
|
||||
|
||||
/* Free the configuration */
|
||||
ipmippm_config_free(data, proc, data->conf);
|
||||
|
||||
data->conf = IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_config_init
|
||||
*===========================================================================
|
||||
* Description: Setup MIP ha after config has been read.
|
||||
* Parameters: data - The FA data entity.
|
||||
* proc - The process
|
||||
* Returns: -1 on error; 0 otherwise.
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipmippm_config_init(Ipmippm_context_t *data,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
Ipmippm_conf_t *conf = ipcom_calloc(1, sizeof(*conf));
|
||||
char **arr = IP_NULL;
|
||||
|
||||
if (conf == IP_NULL)
|
||||
return -IP_ERRNO_ENOMEM;
|
||||
|
||||
ipcom_list_init(&conf->if_head);
|
||||
|
||||
ipmippm_config_exit(data, proc);
|
||||
|
||||
arr = ipmip_sysvar_strarr("ipmippm.interfaces");
|
||||
if (arr == IP_NULL)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&data->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"Bad configuration. Invalid/missing \"ipmippm.interfaces\""));
|
||||
goto fail;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
for (i = 0; arr[i] != IP_NULL; i++)
|
||||
{
|
||||
/* If I can't create the interface, exit */
|
||||
if (ipmippm_if_create(data, proc, conf, arr[i]) == IP_FALSE)
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
/* Reconfigure (existing config was in place) */
|
||||
data->conf = conf;
|
||||
|
||||
ipmip4_context_start(&data->api.ipmip4, proc);
|
||||
ipcom_free(arr);
|
||||
return 0;
|
||||
fail:
|
||||
if (arr)
|
||||
ipcom_free(arr);
|
||||
ipmippm_config_free(data, proc, conf);
|
||||
ipmip_context_start(&data->api.ipmip4.ipmip, proc);
|
||||
return -IP_ERRNO_EINVAL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_data_process
|
||||
*===========================================================================
|
||||
* Description: Process any file descriptors set by the platform.
|
||||
* Parameters: data - The data structure
|
||||
* rset - The read set.
|
||||
* Returns: IP_FALSE if we should exit the process.
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipmippm_ipd_process(Ipmippm_context_t *data,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
/* IPD input. */
|
||||
int event;
|
||||
Ip_ssize_t len;
|
||||
Ipmippm_pktbuf_t *pbuf = (Ipmippm_pktbuf_t *)ipmip_pktbuf_alloc(&data->api.ipmip4.ipmip, proc, 512);
|
||||
|
||||
if (pbuf == IP_NULL)
|
||||
return IP_TRUE;
|
||||
|
||||
len = ipcom_ipd_read(data->api.fd_ipd, IPMIP_BUFFER_PTR(&pbuf->api.ipmip4.ipmip.packet), 512, &event);
|
||||
if (len < 0)
|
||||
{
|
||||
IPCOM_LOG2(ERR, "ipcom_socketread(IPD) failed : %s [%d]",
|
||||
ipcom_strerror(ipcom_errno), ipcom_errno);
|
||||
ipmip_util_sock_clear(data->api.fd_ipd);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Advance past */
|
||||
ipmip_buffer_append(&pbuf->api.ipmip4.ipmip.packet, IP_NULL, len);
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case IPCOM_IPD_EVENT_RECONFIGURE:
|
||||
IPCOM_LOG0(INFO, "Received IPD reconfigure message");
|
||||
if (ipmippm_config_init(data, proc) != 0)
|
||||
IPCOM_LOG0(ERR, "invalid new configuration - reconfigure failed");
|
||||
break;
|
||||
|
||||
case IPCOM_IPD_EVENT_KILL:
|
||||
IPCOM_LOG0(INFO, "Received IPD kill message");
|
||||
ipmip_pktbuf_release(&data->api.ipmip4.ipmip, proc, &pbuf->api.ipmip4.ipmip);
|
||||
return IP_FALSE;
|
||||
default:
|
||||
/* Ignore all other IPD messages */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ipmip_pktbuf_release(&data->api.ipmip4.ipmip, proc, &pbuf->api.ipmip4.ipmip);
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippmd
|
||||
*===========================================================================
|
||||
* Description: The main process.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmippm_main(void)
|
||||
{
|
||||
Ipmippm_context_t *data = IP_NULL;
|
||||
Ipmip_proc_t *proc;
|
||||
|
||||
ipcom_proc_init();
|
||||
|
||||
/* Get me a process context for this thread */
|
||||
proc = ipmip_proc_alloc();
|
||||
if(IP_NULL == proc)
|
||||
{
|
||||
ipcom_proc_exit();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Init IPMIPFA */
|
||||
if (ipmippm_instances++ == 0)
|
||||
(void)ipmippm_init();
|
||||
|
||||
/* Configure IPMIPFA. */
|
||||
if (ipmippm_configure() != IPCOM_SUCCESS)
|
||||
goto end;
|
||||
|
||||
/* Init IPMIPFA data. */
|
||||
if ((data = ipmippm_init_agent(proc)) == IP_NULL)
|
||||
goto end;
|
||||
|
||||
/* Init FA from configuration. */
|
||||
if (ipmippm_config_init(data, proc) != 0)
|
||||
{
|
||||
IPCOM_LOG0(WARNING,
|
||||
"PM not properly configured -- update the required sysvars and reconfigure");
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int num;
|
||||
int max_fd;
|
||||
Ip_fd_set read_set;
|
||||
|
||||
IP_FD_ZERO(&read_set);
|
||||
|
||||
/* Set the IPD */
|
||||
max_fd = data->api.fd_ipd;
|
||||
IP_FD_SET(data->api.fd_ipd, &read_set);
|
||||
|
||||
/* Select */
|
||||
num = ipcom_socketselect(max_fd + 1, &read_set, IP_NULL, IP_NULL, IP_NULL);
|
||||
|
||||
switch(num)
|
||||
{
|
||||
case -1: /* socket error. */
|
||||
IPCOM_LOG2(WARNING, "ipcom_socketselect() failed : %s [%d]", ipcom_strerror(ipcom_errno), ipcom_errno);
|
||||
(void)ipcom_sleep(1);
|
||||
break;
|
||||
|
||||
case 0: /* timeout, not used. triggered by bug in linux glibc if compiled with nptl */
|
||||
(void)ipcom_millisleep(1);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Process IPD */
|
||||
if (IP_FD_ISSET(data->api.fd_ipd, &read_set))
|
||||
{
|
||||
if (ipmippm_ipd_process(data, proc) == IP_FALSE)
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
/* If we've gotten the data, clear it */
|
||||
if (data != IP_NULL)
|
||||
{
|
||||
ipmippm_config_exit(data, proc);
|
||||
ipmippm_exit_agent(data, proc);
|
||||
}
|
||||
|
||||
/* Exit IPMIPFA */
|
||||
if (--ipmippm_instances == 0)
|
||||
(void)ipmippm_exit();
|
||||
|
||||
/* Free the context process */
|
||||
ipmip_proc_destroy(proc);
|
||||
|
||||
IPCOM_LOG0(INFO, "IPMIPPM ending");
|
||||
ipcom_proc_exit();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
/* INIT FUNCTIONS */
|
||||
IP_GLOBAL Ip_u32
|
||||
ipmippm_context_register_function(Ipmipmn_api_extension_t *srv)
|
||||
{
|
||||
Ip_u32 type = ipmippm_extensions.num++;
|
||||
|
||||
/* Store values */
|
||||
srv->type = type;
|
||||
|
||||
ipmippm_extensions.mask |= (1 << type);
|
||||
|
||||
ipmippm_extensions.functions[type] = srv;
|
||||
ipmippm_extensions.node_data += srv->node_data_size;
|
||||
|
||||
/* Register payload, if requested */
|
||||
if (srv->pktaux.pktbuf_data_size != 0)
|
||||
ipmip_pktbuf_pktaux_add(&ipmippm_pktaux, &srv->pktaux);
|
||||
|
||||
/* Return the type */
|
||||
return type;
|
||||
}
|
||||
|
||||
IP_GLOBAL void
|
||||
ipmippm_msgext_vendor_parse_ext_register(struct Ipmip4_msgext_vendor_parse_ext *pext)
|
||||
{
|
||||
/**/
|
||||
ipmip4_msgext_vendor_parse_ext_register(&ipmippm_msgext_vendor_extensions, &ipmippm_pktaux, pext);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,245 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_reg.c,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/src/ipmippm_reg.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 "ipmipmn_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_ipd.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_hash.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
#include <private/ipmip_timer.h>
|
||||
|
||||
#include <ipmip4.h>
|
||||
#include <private/ipmip4_lla.h>
|
||||
#include <private/ipmip4_util.h>
|
||||
#include <private/ipmip4_sysext.h>
|
||||
#include <private/ipmip4_context.h>
|
||||
#include <private/ipmip4_pkt.h>
|
||||
|
||||
#include "ipmippm_h.h"
|
||||
#include "ipmippm_client.h"
|
||||
#include "ipmippm_reg.h"
|
||||
#include "ipmippm_pktbuf.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC void
|
||||
ipmippm_reg_output_mobile_home(struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmippm_client_conf *conf,
|
||||
void *inst_config,
|
||||
void *node_config,
|
||||
struct Ipmippm_client *node,
|
||||
Ip_bool deregister,
|
||||
struct Ipmippm_pktbuf *pbuf)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(data);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(conf);
|
||||
IPMIP_UNUSED_PARAMETER(inst_config);
|
||||
IPMIP_UNUSED_PARAMETER(node_config);
|
||||
IPMIP_UNUSED_PARAMETER(deregister);
|
||||
IPMIP_UNUSED_PARAMETER(node);
|
||||
IPMIP_UNUSED_PARAMETER(pbuf);
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC Ip_bool
|
||||
ipmippm_reg_input_verify(struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmippm_client_conf *conf,
|
||||
void *inst_config,
|
||||
void *node_config,
|
||||
struct Ipmippm_client *node,
|
||||
struct Ipmippm_pktbuf *pbuf)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(data);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
IPMIP_UNUSED_PARAMETER(inst_config);
|
||||
IPMIP_UNUSED_PARAMETER(conf);
|
||||
IPMIP_UNUSED_PARAMETER(node_config);
|
||||
IPMIP_UNUSED_PARAMETER(node);
|
||||
IPMIP_UNUSED_PARAMETER(pbuf);
|
||||
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC void
|
||||
ipmippm_reg_input_success(struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmippm_client_conf *conf,
|
||||
void *inst_config,
|
||||
void *node_config,
|
||||
struct Ipmippm_client *node,
|
||||
struct Ipmippm_pktbuf *pbuf)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(inst_config);
|
||||
IPMIP_UNUSED_PARAMETER(conf);
|
||||
IPMIP_UNUSED_PARAMETER(node_config);
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(data);
|
||||
|
||||
node->api.params.mnRegTunnelType = pbuf->api.reginfo.mnRegTunnelType;
|
||||
|
||||
/* Assign our home agent */
|
||||
if (node->api.params.assigned_home_agent == 0)
|
||||
{
|
||||
/**/
|
||||
node->api.params.pending_home_agent = pbuf->api.pktinfo.mnRegHomeAgentAddress;
|
||||
node->api.params.assigned_home_agent = node->api.params.pending_home_agent;
|
||||
|
||||
IPMIP4_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&data->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"%s home agent '%s' assigned",
|
||||
ipmippm_client_describe(proc, node),
|
||||
ipmip_ntop_inet(proc, node->api.params.assigned_home_agent)));
|
||||
}
|
||||
|
||||
/* Accepted */
|
||||
if (node->api.params.assigned_home_address == 0)
|
||||
{
|
||||
/* OK; ADDRESS located, store it and configure our interface */
|
||||
node->api.params.assigned_home_address = pbuf->api.pktinfo.mnRegHomeAddress;
|
||||
node->api.params.pending_home_address = pbuf->api.pktinfo.mnRegHomeAddress;
|
||||
IPMIP4_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&data->api.ipmip4.ipmip,
|
||||
proc,
|
||||
"%s home address '%s' assigned",
|
||||
ipmippm_client_describe(proc, node),
|
||||
ipmip_ntop_inet(proc, pbuf->api.pktinfo.mnRegHomeAddress)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL void
|
||||
ipmippm_reg_register_service(void)
|
||||
{
|
||||
static Ipmipmn_api_extension_t ipmippm_node_ext;
|
||||
|
||||
ipcom_memset(&ipmippm_node_ext, 0, sizeof(ipmippm_node_ext));
|
||||
|
||||
ipmippm_node_ext.name = "REGISTER";
|
||||
ipmippm_node_ext.pkt_req_mobile_home = (Ipmipmn_api_extension_pkt_req_mobile_home_t)ipmippm_reg_output_mobile_home;
|
||||
ipmippm_node_ext.pkt_rep_validate = (Ipmipmn_api_extension_pkt_rep_validate_t)ipmippm_reg_input_verify;
|
||||
ipmippm_node_ext.pkt_rep_accepted = (Ipmipmn_api_extension_pkt_rep_accepted_t)ipmippm_reg_input_success;
|
||||
ipmippm_context_register_function(&ipmippm_node_ext);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmippm_reg_recv
|
||||
*===========================================================================
|
||||
* Description: Handles registration request and reply packages.
|
||||
* Parameters: data - Context
|
||||
* proc - Current process.
|
||||
* pbuf - Packet buffer
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmippm_reg_recv(struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmippm_pktbuf_t *pbuf)
|
||||
{
|
||||
/* Send immediately to the API input */
|
||||
ipmipmn_api_reg_recv(&data->api, proc, &pbuf->api);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,109 @@
|
||||
/* ipmippm_reg.h - ipmippm_reg.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_reg.h,v $ $Revision: 1.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmippm/src/ipmippm_reg.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-04-23 15:19:27 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIPPM_REG_H
|
||||
#define IPMIPPM_REG_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
No description currently provided
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <private/ipmipmn_api_reg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmippm_pktbuf;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmippm_reg_recv - ipmippm_reg_recv
|
||||
*
|
||||
* Handles registration request and reply packages.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Context
|
||||
* \i proc
|
||||
* Current process.
|
||||
* \i pbuf
|
||||
* Packet buffer
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmippm_reg_recv
|
||||
(
|
||||
struct Ipmippm_context *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmippm_pktbuf *pbuf
|
||||
);
|
||||
|
||||
|
||||
IP_GLOBAL void ipmippm_reg_register_service
|
||||
(
|
||||
void
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
Reference in New Issue
Block a user