Files
m241Neelima/components/ip_net2-6.9/ipmipha/config/ipmipha_regext_hoa.c
T
2026-07-30 11:19:44 +05:30

254 lines
10 KiB
C

/*
******************************************************************************
* INTERPEAK SOURCE FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha_regext_hoa.c,v $ $Revision: 1.3.16.1 $
* $Source: /home/interpeak/CVSRoot/ipmipha/config/ipmipha_regext_hoa.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_HOA "HOA"
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
typedef struct Ipmipha_regext_hoa_config_ifp
{
Ip_bool dynamic_hoa_required;
} Ipmipha_regext_hoa_config_ifp_t;
/*
****************************************************************************
* 6 EXTERN PROTOTYPES
****************************************************************************
*/
/*
****************************************************************************
* 7 LOCAL PROTOTYPES
****************************************************************************
*/
/*
****************************************************************************
* 8 DATA
****************************************************************************
*/
static Ipmipha_extension_t ipmipha_regext_hoa_srv;
/*
****************************************************************************
* 9 STATIC FUNCTIONS
****************************************************************************
*/
IP_STATIC void
ipmipha_regext_hoa_ifp_config(struct Ipmipha_data *ctx,
struct Ipmip_proc *proc,
int action,
struct Ipmipha_iff *ifp,
void *gcfg,
Ipmipha_regext_hoa_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->dynamic_hoa_required = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_FALSE, "ipmipha.mn.hoa.dynamic.required"), "ipmipha.if.%s.mn.hoa.dynamic.required", 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.mn.hoa.dynamic.required=%s",
ifp->iff.ipmip.ifname, cfg->dynamic_hoa_required? "enabled" : "disabled");
}
}
/*
*===========================================================================
* ipmipha_radius_auth
*===========================================================================
* Description: Resolve a mobile-AAA extension using RADIUS
* Parameters: ctx - Context
* proc - Current process
* setup - Setup structure
* ifcfg - Setup structure for current interface.
* pbuf - The container.
* lock - Timer lock
* func - Timer function callback
* Returns: IP_TRUE if pending, IP_FALSE otherwise
*/
IP_STATIC Ip_bool
ipmipha_regext_hoa_pkt_req_verify(struct Ipmipha_data *ctx,
struct Ipmip_proc *proc,
void *global_config,
Ipmipha_regext_hoa_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(node_config);
if (node->registrations == 0)
{
if (pbuf->pktinfo.haBindingHomeAddress == 0)
{
if (pbuf->pktinfo.haBindingResolvedHomeAddress == 0)
{
if (!ipmip_sysvar_inet(0, &pbuf->pktinfo.haBindingResolvedHomeAddress, IP_NULL, "ipmipha.if.%s.mn.nai.%s.hoa.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.haBindingResolvedHomeAddress, IP_NULL, "ipmipha.mn.nai.%s.hoa.address", 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)));
}
}
else
{
Ip_u32 addr;
if (ifp_config->dynamic_hoa_required)
{
ipmip_pktbuf_error(&pbuf->ipmip4.ipmip,
IPMIP4_CODE_REP_HA_ADMIN_PROHIBIT,
"home address must be dynamically allocated");
}
else if (pbuf->pktinfo.haBindingResolvedHomeAddress != 0 && pbuf->pktinfo.haBindingResolvedHomeAddress != pbuf->pktinfo.haBindingHomeAddress)
{
ipmip_pktbuf_error(&pbuf->ipmip4.ipmip,
IPMIP4_CODE_REP_HA_ADMIN_PROHIBIT,
"requested home address %s does not match resolved %s",
ipmip_ntop_inet(proc, pbuf->pktinfo.haBindingHomeAddress),
ipmip_ntop_inet(proc, pbuf->pktinfo.haBindingResolvedHomeAddress));
}
else
{
if (pbuf->ipmip4.ext.mobile.nai_mobile != IP_NULL)
{
if (ipmip_sysvar_inet(0, &addr, IP_NULL, "ipmipha.if.%s.mn.nai.%s.hoa.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, &addr, IP_NULL, "ipmipha.mn.nai.%s.hoa.address", 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))))
{
if (addr != pbuf->pktinfo.haBindingHomeAddress)
{
ipmip_pktbuf_error(&pbuf->ipmip4.ipmip,
IPMIP4_CODE_REP_HA_ADMIN_PROHIBIT,
"requested home address %s does not match statically configured %s",
ipmip_ntop_inet(proc, pbuf->pktinfo.haBindingHomeAddress),
ipmip_ntop_inet(proc, addr));
}
}
}
}
}
}
return IP_FALSE;
}
/*
****************************************************************************
* 10 GLOBAL FUNCTIONS
****************************************************************************
*/
IP_GLOBAL void ipmipha_regext_hoa_install(void);
IP_GLOBAL void
ipmipha_regext_hoa_install(void)
{
ipcom_memset(&ipmipha_regext_hoa_srv, 0, sizeof(ipmipha_regext_hoa_srv));
ipmipha_regext_hoa_srv.name = IPMIPHA_REGEXT_HOA;
ipmipha_regext_hoa_srv.ifp_data_size = sizeof(Ipmipha_regext_hoa_config_ifp_t);
ipmipha_regext_hoa_srv.config_ifp = (Ipmipha_extension_config_ifp_t)ipmipha_regext_hoa_ifp_config;
ipmipha_regext_hoa_srv.pkt_req_validate = (Ipmipha_extension_pkt_req_validate_t)ipmipha_regext_hoa_pkt_req_verify;
ipmipha_context_register_extension(&ipmipha_regext_hoa_srv, IPMIPHA_FUNCTION_REGEXT);
}
/*
****************************************************************************
* 11 PUBLIC FUNCTIONS
****************************************************************************
*/
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/