269 lines
10 KiB
C
269 lines
10 KiB
C
|
|
/*
|
|
******************************************************************************
|
|
* INTERPEAK SOURCE FILE
|
|
*
|
|
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha_regext_dhaa.c,v $ $Revision: 1.3.16.1 $
|
|
* $Source: /home/interpeak/CVSRoot/ipmipha/config/ipmipha_regext_dhaa.c,v $
|
|
* $Author: svc-cmnet $
|
|
* $State: Exp $ $Locker: $
|
|
*
|
|
* INTERPEAK_COPYRIGHT_STRING
|
|
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
|
******************************************************************************
|
|
*/
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 1 DESCRIPTION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 2 CONFIGURATION
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include "ipmipha_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 <ipmip.h>
|
|
#include <private/ipmip_util.h>
|
|
#include <private/ipmip_sysvar.h>
|
|
|
|
#include <ipmip4.h>
|
|
#include <private/ipmip4_context.h>
|
|
#include <private/ipmip4_util.h>
|
|
#include <private/ipmip4_sysext.h>
|
|
|
|
#include "ipmipha.h"
|
|
#include "ipmipha_h.h"
|
|
#include "ipmipha_attr_h.h"
|
|
#include "ipmipha_if.h"
|
|
#include "ipmipha_node.h"
|
|
#include "ipmipha_pktbuf.h"
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 4 DEFINES
|
|
****************************************************************************
|
|
*/
|
|
#define IPMIPHA_REGEXT_DHAA "DHAA"
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 5 TYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
typedef struct Ipmipha_regext_dhaa_config_ifp
|
|
{
|
|
Ip_bool enabled;
|
|
} Ipmipha_regext_dhaa_config_ifp_t;
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 6 EXTERN PROTOTYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 7 LOCAL PROTOTYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 8 DATA
|
|
****************************************************************************
|
|
*/
|
|
static Ipmipha_extension_t ipmipha_regext_dhaa_srv;
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 9 STATIC FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
|
|
IP_STATIC void
|
|
ipmipha_regext_dhaa_ifp_config(struct Ipmipha_data *ctx,
|
|
struct Ipmip_proc *proc,
|
|
int action,
|
|
struct Ipmipha_iff *ifp,
|
|
void *gcfg,
|
|
Ipmipha_regext_dhaa_config_ifp_t *cfg,
|
|
Ipmip_cli_message_t *request)
|
|
{
|
|
IPMIP_UNUSED_PARAMETER(ctx);
|
|
IPMIP_UNUSED_PARAMETER(proc);
|
|
IPMIP_UNUSED_PARAMETER(gcfg);
|
|
IPMIP_UNUSED_PARAMETER(request);
|
|
|
|
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
|
{
|
|
cfg->enabled = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_TRUE, "ipmipha.dhaa"), "ipmipha.if.%s.dhaa", ifp->iff.ipmip.ifname);
|
|
}
|
|
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
|
{
|
|
}
|
|
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
|
{
|
|
/* Could dump, but dont bother */
|
|
ipmip_cli_config_printf(&request->message,
|
|
"ipmipha.if.%s.dhaa=%s",
|
|
ifp->iff.ipmip.ifname, cfg->enabled? "enabled" : "disabled");
|
|
}
|
|
}
|
|
|
|
IP_STATIC Ip_bool
|
|
ipmipha_regext_dhaa_pkt_req_verify(struct Ipmipha_data *ctx,
|
|
struct Ipmip_proc *proc,
|
|
void *global_config,
|
|
Ipmipha_regext_dhaa_config_ifp_t *ifp_config,
|
|
void *node_config,
|
|
struct Ipmipha_node *node,
|
|
struct Ipmipha_pktbuf *pbuf)
|
|
{
|
|
IPMIP_UNUSED_PARAMETER(ctx);
|
|
IPMIP_UNUSED_PARAMETER(proc);
|
|
IPMIP_UNUSED_PARAMETER(global_config);
|
|
IPMIP_UNUSED_PARAMETER(ifp_config);
|
|
IPMIP_UNUSED_PARAMETER(node_config);
|
|
|
|
if (node->registrations == 0 && pbuf->pktinfo.haBindingHomeAgentAddress != pbuf->iff.pub->ifaddr)
|
|
{
|
|
/* The destination IP address doesn't match the interface's; DHAA or
|
|
* basic home agent discovery in effect */
|
|
if ((pbuf->pktinfo.haBindingHomeAgentAddress == 0 || pbuf->pktinfo.haBindingHomeAgentAddress == 0xffffffff))
|
|
{
|
|
/* This home address is tentative; dont be too certain about it */
|
|
if (pbuf->ipmip4.ext.mobile.nai_mobile == IP_NULL)
|
|
{
|
|
ipmip_pktbuf_error(&pbuf->ipmip4.ipmip, IPMIP4_CODE_REP_HA_ADMIN_PROHIBIT, "request discarded due to required nai not specified in DHAA request");
|
|
return IP_FALSE;
|
|
}
|
|
|
|
if (pbuf->ipmip4.ext.mobile.dynamic_ha_request && IPMIP4_MSGEXT_AUTHENTICATED(pbuf->ipmip4.ext.mobile.dynamic_ha_request, pbuf->pktinfo.haBindingInnerAuth))
|
|
{
|
|
Ip_u32 haaddr = IP_GET_32ON8(IPMIP4_MSGEXT_LHDR_EXT_DATA(pbuf->ipmip4.ext.mobile.dynamic_ha_request));
|
|
if (haaddr != pbuf->iff.pub->ifaddr)
|
|
{
|
|
ipmip_pktbuf_error(&pbuf->ipmip4.ipmip, IPMIP4_CODE_REP_HA_ADMIN_PROHIBIT, "bad DHAA request extension, specified address is not this home agent");
|
|
return IP_FALSE;
|
|
}
|
|
}
|
|
|
|
/* Have it been resolved already? */
|
|
if (pbuf->pktinfo.haBindingResolvedHomeAgentAddress == 0)
|
|
{
|
|
/* Do resolve using sysvars */
|
|
if (!ipmip_sysvar_inet(0, &pbuf->pktinfo.haBindingResolvedHomeAgentAddress, IP_NULL, "ipmipha.if.%s.mn.nai.%s.dhaa.address", pbuf->iff.pub->ipmip.ifname, ipmip_ntop_strn(proc, (char *)IPMIP4_MSGEXT_SHDR_EXT_DATA(pbuf->ipmip4.ext.mobile.nai_mobile), IPMIP4_MSGEXT_SHDR_EXT_SIZE(pbuf->ipmip4.ext.mobile.nai_mobile))))
|
|
ipmip_sysvar_inet(0, &pbuf->pktinfo.haBindingResolvedHomeAgentAddress, IP_NULL, "ipmipha.if.%s.mn.nai.any.dhaa.address", pbuf->iff.pub->ipmip.ifname);
|
|
}
|
|
|
|
if (pbuf->pktinfo.haBindingResolvedHomeAgentAddress == 0)
|
|
pbuf->pktinfo.haBindingResolvedHomeAgentAddress = pbuf->iff.pub->ifaddr;
|
|
|
|
if (pbuf->pktinfo.haBindingResolvedHomeAgentAddress != pbuf->iff.pub->ifaddr)
|
|
{
|
|
ipmip_pktbuf_error(&pbuf->ipmip4.ipmip,
|
|
IPMIP4_CODE_REP_HA_REGISTER_REDIRECTED,
|
|
"request discarded due to DHAA redirected to new Home Agent");
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
return IP_FALSE;
|
|
}
|
|
|
|
IP_STATIC Ip_bool
|
|
ipmipha_regext_dhaa_setup(struct Ipmipha_data *ctx,
|
|
struct Ipmip_proc *proc,
|
|
int action,
|
|
void *global_config,
|
|
Ipmipha_regext_dhaa_config_ifp_t *ifp_config,
|
|
void *node_config,
|
|
struct Ipmipha_node *node,
|
|
Ipmip_cli_message_t *request)
|
|
{
|
|
IPMIP_UNUSED_PARAMETER(ctx);
|
|
IPMIP_UNUSED_PARAMETER(proc);
|
|
IPMIP_UNUSED_PARAMETER(global_config);
|
|
IPMIP_UNUSED_PARAMETER(node_config);
|
|
IPMIP_UNUSED_PARAMETER(node);
|
|
IPMIP_UNUSED_PARAMETER(request);
|
|
|
|
if (action == IPMIP_CALLBACK_CONFIG_READ)
|
|
{
|
|
return ifp_config->enabled;
|
|
}
|
|
else if (action == IPMIP_CALLBACK_CONFIG_FREE)
|
|
{
|
|
/* No dyncamically allocated values */
|
|
}
|
|
else if (action == IPMIP_CALLBACK_CONFIG_DUMP)
|
|
{
|
|
}
|
|
|
|
return IP_FALSE;
|
|
}
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 10 GLOBAL FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
IP_GLOBAL void ipmipha_regext_dhaa_install(void);
|
|
IP_GLOBAL void
|
|
ipmipha_regext_dhaa_install(void)
|
|
{
|
|
ipcom_memset(&ipmipha_regext_dhaa_srv, 0, sizeof(ipmipha_regext_dhaa_srv));
|
|
|
|
ipmipha_regext_dhaa_srv.name = IPMIPHA_REGEXT_DHAA;
|
|
ipmipha_regext_dhaa_srv.ifp_data_size = sizeof(Ipmipha_regext_dhaa_config_ifp_t);
|
|
ipmipha_regext_dhaa_srv.config_ifp = (Ipmipha_extension_config_ifp_t)ipmipha_regext_dhaa_ifp_config;
|
|
|
|
ipmipha_regext_dhaa_srv.pkt_req_validate = (Ipmipha_extension_pkt_req_validate_t)ipmipha_regext_dhaa_pkt_req_verify;
|
|
ipmipha_regext_dhaa_srv.setup = (Ipmipha_extension_setup_t)ipmipha_regext_dhaa_setup;
|
|
|
|
ipmipha_context_register_extension(&ipmipha_regext_dhaa_srv, IPMIPHA_FUNCTION_REGEXT);
|
|
}
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 11 PUBLIC FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* END OF FILE
|
|
****************************************************************************
|
|
*/
|