original files of m241
This commit is contained in:
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha.c,v $ $Revision: 1.102 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmipha/src/ipmipha.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Niklas Lundberg <n@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
*******************************************************************************
|
||||
*
|
||||
* Legend:
|
||||
* HA = Home agent
|
||||
* MN = Mobile node
|
||||
* FA = Foreign agent
|
||||
* CN = Correspondent node (someone on the internet the mobile node talks to
|
||||
* via the HA)
|
||||
* COA = Care-of address
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmipha_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_sysvar.h>
|
||||
#include <ipcom_syslog.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_timer.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
#include <private/ipmip_cli.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 <private/ipmip4_pktbuf.h>
|
||||
#include <private/ipmip4_diameter.h>
|
||||
|
||||
#include "ipmipha.h"
|
||||
#include "ipmipha_h.h"
|
||||
#include "ipmipha_attr_h.h"
|
||||
#include "ipmipha_if.h"
|
||||
#include "ipmipha_node.h"
|
||||
#include "ipmipha_reg.h"
|
||||
#include "ipmipha_agent.h"
|
||||
#include "ipmipha_route.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Private Application datatypes
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Registration request and reply
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmipha_rtmsg
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err ipmipha_create(void);
|
||||
IP_PUBLIC Ip_err ipmipha_start(void);
|
||||
IP_PUBLIC Ip_err ipmipha_init(void);
|
||||
IP_PUBLIC Ip_err ipmipha_exit(void);
|
||||
IP_PUBLIC Ip_err ipmipha_configure(void);
|
||||
|
||||
IP_PUBLIC const char *ipmipha_version(void);
|
||||
|
||||
#ifdef IPSNMP
|
||||
IP_EXTERN Ip_err ipmipha_mip_mib_init(void);
|
||||
IP_EXTERN Ip_err ipmip4_mip_mib_init(void);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC IPCOM_PROCESS(ipmipha_proc);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmiphad
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC
|
||||
IPCOM_PROCESS(ipmipha_proc)
|
||||
{
|
||||
/**/
|
||||
ipmipha_main();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_start
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipmipha_start(void)
|
||||
{
|
||||
Ipcom_proc_attr attr;
|
||||
Ip_err ret;
|
||||
#ifdef IPSNMP
|
||||
static int mib_once = 0;
|
||||
#endif
|
||||
|
||||
ipcom_proc_attr_init(&attr);
|
||||
attr.stacksize = IPCOM_PROC_STACK_LARGE;
|
||||
|
||||
ret = ipcom_proc_acreate("ipmiphad", ipmipha_proc, &attr, IP_NULL);
|
||||
ip_assert(ret == IPCOM_SUCCESS);
|
||||
|
||||
#ifdef IPSNMP
|
||||
if (mib_once == 0)
|
||||
{
|
||||
mib_once = 1;
|
||||
if (ipmipha_mip_mib_init() != IPCOM_SUCCESS)
|
||||
ret = IPCOM_ERR_FAILED;
|
||||
if (ipmip4_mip_mib_init() != IPCOM_SUCCESS)
|
||||
ret = IPCOM_ERR_FAILED;
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_version
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC const char *
|
||||
ipmipha_version(void)
|
||||
{
|
||||
return "@(#) IPMIPHA $Name: VXWORKS_ITER40_2019102207 $ - INTERPEAK_COPYRIGHT_STRING";
|
||||
}
|
||||
|
||||
|
||||
#if defined (IP_PORT_LAS)
|
||||
|
||||
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,371 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha_agent.c,v $ $Revision: 1.11 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmipha/src/ipmipha_agent.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 "ipmipha_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 "ipmipha.h"
|
||||
#include "ipmipha_h.h"
|
||||
#include "ipmipha_attr_h.h"
|
||||
#include "ipmipha_if.h"
|
||||
#include "ipmipha_agent.h"
|
||||
#include "ipmipha_pktbuf.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_agent_advert_build
|
||||
*===========================================================================
|
||||
* Description: Create an advertisement.
|
||||
* Parameters: data - Context
|
||||
* proc - Process
|
||||
* adv - The buffer to create the advertisement in.
|
||||
* iff - The interface for which we create the buffer.
|
||||
* lla_ext - Append the interfaces LLA extension
|
||||
* Returns: IP_TRUE on success.
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipmipha_agent_advert_build(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip_buffer_t *adv,
|
||||
Ipmipha_iff_t *iff)
|
||||
{
|
||||
Ipmip4_icmp_advert_t advpkt;
|
||||
Ipmip4_icmp_advert_t *advpktp;
|
||||
Ipmip4_icmp_ext_advert_t adv_ext;
|
||||
Ip_u16 adv_seq;
|
||||
|
||||
ipcom_memset(&advpkt, 0, sizeof(advpkt));
|
||||
ipcom_memset(&adv_ext, 0, sizeof(adv_ext));
|
||||
|
||||
/* ICMP advertisement header */
|
||||
advpkt.icmp_type = IPMIP4_ICMP_AGENT_ADVERTISEMENT;
|
||||
advpkt.icmp_code = data->ipnet_is_router ? IPMIP4_ICMP_CODE_GENERIC_ROUTER : IPMIP4_ICMP_CODE_AGENT_ONLY;
|
||||
advpkt.icmp_checksum = 0;
|
||||
advpkt.adv_num_addrs = 0;
|
||||
advpkt.adv_addr_entry_size = 2;
|
||||
advpkt.adv_lifetime = ip_htons(iff->adv_lifetime);
|
||||
|
||||
ipmip_buffer_append(adv, &advpkt, sizeof(advpkt));
|
||||
|
||||
/* Store */
|
||||
adv_seq = iff->adv_seq;
|
||||
|
||||
/* Add mobility agent advertisement extension */
|
||||
adv_ext.type = IPMIP4_ICMP_EXT_TYPE_MOBILITY_AGENT_ADV;
|
||||
adv_ext.length = 6;
|
||||
adv_ext.seq = ip_htons(adv_seq);
|
||||
adv_ext.reg_lifetime = ip_htons(iff->lifetime);
|
||||
adv_ext.flags = ip_ntohs(IPMIP4_ICMP_ADVEXT_FLAG_HOME_AGENT);
|
||||
|
||||
ipmip_buffer_append(adv, &adv_ext, sizeof(adv_ext) - sizeof(adv_ext.coa));
|
||||
|
||||
if (iff->nai_ha != IP_NULL)
|
||||
ipmip4_msgext_buffer_append_shdr(adv, iff->nai_ha);
|
||||
|
||||
if (++iff->adv_seq == 0)
|
||||
/* Roll-over prevention, so it does not look like we have rebooted */
|
||||
iff->adv_seq = 256;
|
||||
|
||||
advpktp = IPMIP_BUFFER_PTR(adv);
|
||||
advpktp->icmp_checksum = ipcom_in_checksum(IPMIP_BUFFER_DATA(adv), IPMIP_BUFFER_SIZE(adv));
|
||||
|
||||
IPMIP4_EVENT_IF(DEBUG2, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Sending Router Advertisement on %s with sequence #%u",
|
||||
iff->iff.ipmip.ifname, adv_seq));
|
||||
|
||||
/* Return advlen */
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_agent_solicitation_input
|
||||
*===========================================================================
|
||||
* Description: Process received ICMP Agent solicitations.
|
||||
* Parameters: pbuf - The packet buffer
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipmipha_agent_solicitation_input(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmipha_pktbuf_t *pbuf)
|
||||
{
|
||||
Ip_u8 *ext_start;
|
||||
int ext_len;
|
||||
int i;
|
||||
Ipmip4_icmp_solicit_t *solpkt;
|
||||
int sol_len;
|
||||
|
||||
/* Solicitation packet */
|
||||
solpkt = IPMIP_BUFFER_PTR(&pbuf->ipmip4.ipmip.packet);
|
||||
sol_len = sizeof(Ipmip4_icmp_solicit_t);
|
||||
|
||||
if (IPMIP_BUFFER_SIZE(&pbuf->ipmip4.ipmip.packet) < (unsigned)sol_len)
|
||||
return IP_FALSE;
|
||||
|
||||
if (pbuf->ipmip4.ipmip.srcinfo.ttl != 1)
|
||||
{
|
||||
IPMIP4_EVENT_IF(WARNING, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Router Solicitation input on %s from %s failed since TTL != 1",
|
||||
pbuf->iff.pub->ipmip.ifname,
|
||||
ipmip_ntop_inet(proc, pbuf->ipmip4.ipmip.srcinfo.src->sin.sin_addr.s_addr)));
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/* Extension part */
|
||||
ext_start = ipmip_buffer_offset(&pbuf->ipmip4.ipmip.packet, sol_len);
|
||||
ext_len = IPMIP_BUFFER_SIZE(&pbuf->ipmip4.ipmip.packet) - sol_len;
|
||||
|
||||
i = ipmip4_msgext_icmp_parse(proc,
|
||||
pbuf->iff.pub->ipmip.ifname,
|
||||
pbuf->ipmip4.ipmip.srcinfo.src->sin.sin_addr.s_addr,
|
||||
&pbuf->ipmip4.ext.icmp,
|
||||
ext_start,
|
||||
ext_len);
|
||||
|
||||
if (i != IPMIP4_REG_EXT_SUCCESS)
|
||||
return IP_FALSE;
|
||||
|
||||
|
||||
IPMIP4_EVENT_IF(DEBUG2, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Router Solicitation received on %s from %s/%s",
|
||||
pbuf->iff.pub->ipmip.ifname,
|
||||
ipmip_ntop_inet(proc, pbuf->ipmip4.ipmip.srcinfo.src->sin.sin_addr.s_addr),
|
||||
ipmip_ntop_lladdr(proc, pbuf->ipmip4.ipmip.srcinfo.lladdr)));
|
||||
|
||||
/* Write a directed output */
|
||||
ipmipha_agent_advert_output(data,
|
||||
proc,
|
||||
pbuf->iff.priv,
|
||||
(Ip_u32 *)&pbuf->ipmip4.ipmip.srcinfo.src->sin.sin_addr.s_addr,
|
||||
pbuf->ipmip4.ipmip.srcinfo.lladdr);
|
||||
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_agent_advert_output
|
||||
*===========================================================================
|
||||
* Description: Write an ordinary multicast/unicast advertisement
|
||||
* Parameters: data - Context
|
||||
* proc - Process
|
||||
* iff - The interface to send the advertisment from.
|
||||
* dst - If specified, unicast dst address
|
||||
* lla - If specified, unicast LLA address
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmipha_agent_advert_output(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmipha_iff_t *iff,
|
||||
Ip_u32 *dst,
|
||||
Ipmip_lladdr_t *lladdr)
|
||||
{
|
||||
Ipmip_buffer_t adv;
|
||||
|
||||
ipmip_buffer_init(&adv);
|
||||
/* Create the advertisement */
|
||||
if (ipmipha_agent_advert_build(data, proc, &adv, iff))
|
||||
{
|
||||
/* If dst is zero, specify it as the advertisement address */
|
||||
if (dst == IP_NULL)
|
||||
dst = &iff->adv_address;
|
||||
|
||||
/* Write the request */
|
||||
if (ipmip4_pkt_icmp_write(&data->ipmip4,
|
||||
proc,
|
||||
&adv,
|
||||
iff->iff.ifaddr,
|
||||
*dst,
|
||||
&iff->iff,
|
||||
lladdr) != IP_TRUE)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Failed to send %s Router Advertisement on %s",
|
||||
(dst == &iff->adv_address)? "unicast" : "multicast",
|
||||
iff->iff.ipmip.ifname));
|
||||
}
|
||||
|
||||
ipmip_buffer_release(&adv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_adv_recv
|
||||
*===========================================================================
|
||||
* Description: Handles incoming advertisements or solicitations
|
||||
* Parameters: data - Context
|
||||
* proc - Current process.
|
||||
* pbuf - Packet buffer
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmipha_adv_recv(struct Ipmipha_data *data,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmipha_pktbuf_t *pbuf)
|
||||
{
|
||||
if (data->conf == IP_NULL)
|
||||
return;
|
||||
|
||||
if (pbuf->ipmip4.ipmip.srcinfo.lladdr != IP_NULL)
|
||||
{
|
||||
Ipcom_icmp_header *icmph = IPMIP_BUFFER_PTR(&pbuf->ipmip4.ipmip.packet);
|
||||
|
||||
/* Truncated packet? */
|
||||
if (IPMIP_BUFFER_SIZE(&pbuf->ipmip4.ipmip.packet) < IPCOM_ICMP_HEADER_LENGTH)
|
||||
goto done_out;
|
||||
|
||||
if (pbuf->ipmip4.ipmip.srcinfo.dst->dst.sin.sin_addr.s_addr == ip_htonl(IP_INADDR_ALLHOSTS_GROUP)
|
||||
|| pbuf->ipmip4.ipmip.srcinfo.dst->dst.sin.sin_addr.s_addr == ip_htonl(IP_INADDR_ALLRTRS_GROUP)
|
||||
|| pbuf->ipmip4.ipmip.srcinfo.dst->dst.sin.sin_addr.s_addr == ip_htonl(IP_INADDR_ALLMA_GROUP)
|
||||
|| pbuf->ipmip4.ipmip.srcinfo.dst->dst.sin.sin_addr.s_addr == 0xffffffff)
|
||||
{
|
||||
/* Must find the interface */
|
||||
if ((pbuf->iff.pub = (Ipmip4_if_t *)ipmip_if_findbyindex(&data->conf->if_head, pbuf->ipmip4.ipmip.srcinfo.dst->ifindex)) == IP_NULL)
|
||||
goto done_out;
|
||||
}
|
||||
else if ((pbuf->iff.pub = ipmip4_if_findbyaddr(&data->conf->if_head, pbuf->ipmip4.ipmip.srcinfo.dst->dst.sin.sin_addr.s_addr)) == IP_NULL)
|
||||
goto done_out;
|
||||
|
||||
switch (icmph->type)
|
||||
{
|
||||
case IPMIP4_ICMP_ROUTER_SOLICITATION:
|
||||
if (IP_BIT_ISFALSE(data->shutdown, IPMIPHA_SHUTDOWN_ADV))
|
||||
{
|
||||
if (ipmipha_agent_solicitation_input(data, proc, pbuf))
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
done_out:
|
||||
/* Free the packet buffer */
|
||||
ipmip_pktbuf_release(&data->ipmip4.ipmip, proc, &pbuf->ipmip4.ipmip);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,143 @@
|
||||
/* ipmipha_agent.h - ipmipha_agent.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha_agent.h,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmipha/src/ipmipha_agent.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-04-01 18:33:43 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIPHA_AGENT_H
|
||||
#define IPMIPHA_AGENT_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
No description currently provided
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmipha_data;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmipha_iff;
|
||||
struct Ipmipha_pktbuf;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmipha_agent_advert_output - ipmipha_agent_advert_output
|
||||
*
|
||||
* Write an ordinary multicast/unicast advertisement
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Context
|
||||
* \i proc
|
||||
* Process
|
||||
* \i iff
|
||||
* The interface to send the advertisment from.
|
||||
* \i dst
|
||||
* If specified, unicast dst address
|
||||
* \i lladdr
|
||||
* If specified, unicast LLA address
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmipha_agent_advert_output
|
||||
(
|
||||
struct Ipmipha_data *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipha_iff *iff,
|
||||
Ip_addr4 *dst,
|
||||
Ipmip_lladdr_t *lladdr
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmipha_adv_recv - ipmipha_adv_recv
|
||||
*
|
||||
* Handles incoming advertisements or solicitations
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Context
|
||||
* \i proc
|
||||
* Current process.
|
||||
* \i pbuf
|
||||
* Packet buffer
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmipha_adv_recv
|
||||
(
|
||||
struct Ipmipha_data *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipha_pktbuf *pbuf
|
||||
);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,773 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha_attr.c,v $ $Revision: 1.22 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmipha/src/ipmipha_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 "ipmipha_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_route.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_buffer.h>
|
||||
#include <private/ipmip_util.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
|
||||
#include <ipmip4.h>
|
||||
#include <private/ipmip4_context.h>
|
||||
|
||||
#include "ipmipha.h"
|
||||
#include "ipmipha_h.h"
|
||||
#include "ipmipha_if.h"
|
||||
#include "ipmipha_node.h"
|
||||
#include "ipmipha_attr_h.h"
|
||||
#include "ipmipha_cli.h"
|
||||
#include "ipmipha_agent.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIPHA_ATTR_BUFSIZ 512
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmipha_attr_op
|
||||
{
|
||||
Ipmip_cli_message_t *request;
|
||||
Ip_u32 hoa;
|
||||
Ip_u32 ifindex;
|
||||
const char *nai;
|
||||
Ip_u32 nai_len;
|
||||
};
|
||||
|
||||
Ipmip_sysvar_key_map_t ipmipha_attr_lookup[] =
|
||||
{
|
||||
{ IPMIPHA_SPI_MN_HOA, "hoa" },
|
||||
{ IPMIPHA_SPI_MN_HOA, "address" },
|
||||
{ IPMIPHA_SPI_MN_NAI, "nai" },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC void
|
||||
ipmipha_attr_list_node(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmipha_node_t *node,
|
||||
struct Ipmipha_attr_op *aop,
|
||||
void *unused)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(unused);
|
||||
IPMIP_UNUSED_PARAMETER(data);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
|
||||
if (aop->hoa != 0 && node->haNodeHomeAddress.prefix != aop->hoa)
|
||||
return;
|
||||
|
||||
if (aop->ifindex != 0 && aop->ifindex != node->ifp->iff.ipmip.ifindex)
|
||||
return;
|
||||
|
||||
if (aop->nai && (node->nai_mobile == IP_NULL || !ipmip_util_strnncmp(aop->nai, aop->nai_len, (char *)IPMIP4_MSGEXT_SHDR_EXT_DATA(node->nai_mobile), IPMIP4_MSGEXT_SHDR_EXT_SIZE(node->nai_mobile))))
|
||||
return;
|
||||
|
||||
|
||||
/**/
|
||||
ipmip_attr_put_u32(&aop->request->message, IPMIPHA_CLI_ATTR_BC_X_HANDLE, node->haNodeIdentity);
|
||||
}
|
||||
|
||||
IP_STATIC int
|
||||
ipmipha_attr_node_exec(int event,
|
||||
Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmip_cli_message_t *request,
|
||||
Ipmipha_node_t *node)
|
||||
{
|
||||
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_node;
|
||||
Ip_size_t rta_binding;
|
||||
Ipmipha_node_binding_t *binding = IP_NULL;
|
||||
|
||||
|
||||
if (node == IP_NULL)
|
||||
rhdr = ipmip_attr_hdr_err(&request->message, hdr, IP_ERRNO_ENOENT, IP_NULL);
|
||||
else
|
||||
{
|
||||
Ip_u32 coa = ipmip_attr_hdr_find_inet(hdr, IPMIPHA_CLI_ATTR_BC_X_COA);
|
||||
if (coa == 0 || (binding = ipmipha_node_binding_coa(data, proc, node, coa)) != IP_NULL)
|
||||
{
|
||||
switch (IPMIP_ATTR_HDR_TYPE(hdr))
|
||||
{
|
||||
case IPMIPHA_CLI_BC_X_NODE_REVOKE:
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
ipmipha_node_binding_revoke(data, proc, node, binding, IPMIP_SYSVAR_MODE_REQUIRED, IP_FALSE);
|
||||
break;
|
||||
case IPMIPHA_CLI_BC_X_NODE_DELETE:
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
ipmipha_node_binding_delete(data, proc, node, binding);
|
||||
break;
|
||||
case IPMIPHA_CLI_BC_X_NODE_GET:
|
||||
{
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
|
||||
rta_node = ipmip_attr_begin(&request->message, IPMIPHA_CLI_ATTR_BC_X);
|
||||
|
||||
ipmip_attr_put_u32(&request->message, IPMIPHA_CLI_ATTR_BC_X_HANDLE, node->haNodeIdentity);
|
||||
|
||||
ipmip_attr_put(&request->message, IPMIPHA_CLI_ATTR_BC_X_mib_haCounterEntry, sizeof(node->mib), &node->mib);
|
||||
|
||||
if (node->nai_mobile != IP_NULL)
|
||||
ipmip_attr_put_strn(&request->message, IPMIPHA_CLI_ATTR_BC_X_NAI, (char *)IPMIP4_MSGEXT_SHDR_EXT_DATA(node->nai_mobile), IPMIP4_MSGEXT_SHDR_EXT_SIZE(node->nai_mobile));
|
||||
|
||||
if (node->nai_aaah != IP_NULL)
|
||||
ipmip_attr_put_strn(&request->message, IPMIPHA_CLI_ATTR_BC_X_NAI_AAAH, ((char *)IPMIP4_MSGEXT_SHDR_EXT_DATA(node->nai_aaah)) + 1, IPMIP4_MSGEXT_SHDR_EXT_SIZE(node->nai_aaah) - 1);
|
||||
|
||||
/* Extra info */
|
||||
ipmip_attr_put_inet(&request->message, IPMIPHA_CLI_ATTR_BC_X_HOA, node->haNodeHomeAddress.prefix);
|
||||
ipmip_attr_put_str(&request->message, IPMIPHA_CLI_ATTR_BC_X_IFNAME, node->ifp->iff.ipmip.ifname);
|
||||
|
||||
ipmip_attr_put_time_t(&request->message, IPMIPHA_CLI_ATTR_BC_X_CREATION_TIME, node->haNodeCreationTime);
|
||||
ipmip_attr_put_time_t(&request->message, IPMIPHA_CLI_ATTR_BC_X_LAST_UPDATED, node->haNodeLastUpdated);
|
||||
ipmip_attr_put_time_t(&request->message, IPMIPHA_CLI_ATTR_BC_X_AAA_VERIFICATION_TIME, node->haNodeAAAVerificationTime);
|
||||
ipmip_attr_put_u32(&request->message, IPMIPHA_CLI_ATTR_BC_X_AAA_ACCOUNTING_ENABLED, node->haNodeAccounting);
|
||||
|
||||
ipmip_attr_put_u64(&request->message, IPMIPHA_CLI_ATTR_BC_X_STATS_RCV_OCTETS64, node->haNodeRcvOctets);
|
||||
ipmip_attr_put_u64(&request->message, IPMIPHA_CLI_ATTR_BC_X_STATS_RCV_PKTS64, node->haNodeRcvPkts);
|
||||
ipmip_attr_put_u64(&request->message, IPMIPHA_CLI_ATTR_BC_X_STATS_SND_OCTETS64, node->haNodeSndOctets);
|
||||
ipmip_attr_put_u64(&request->message, IPMIPHA_CLI_ATTR_BC_X_STATS_SND_PKTS64, node->haNodeSndPkts);
|
||||
|
||||
if (coa == 0)
|
||||
binding = IPCOM_LIST_FIRST(&node->bindings);
|
||||
for (; binding != IP_NULL; binding = IPCOM_LIST_NEXT(&binding->next))
|
||||
{
|
||||
rta_binding = ipmip_attr_begin(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA);
|
||||
ipmip_attr_put_time_t(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA_CREATION_TIME, binding->haBindingCreationTime);
|
||||
ipmip_attr_put_time_t(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA_LAST_UPDATED, binding->haBindingLastUpdated);
|
||||
ipmip_attr_put_inet(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA_INET, binding->mib.haMobilityBindingCOA.s_addr);
|
||||
ipmip_attr_put_u32(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA_REG_FLAGS, binding->mib.haMobilityBindingRegFlags);
|
||||
|
||||
ipmip_attr_put_inet(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA_TUNNELING_ENDPOINT, binding->haBindingTunnelingEndpoint);
|
||||
ipmip_attr_put_u32(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA_TUNNELING_PORT, binding->haBindingTunnelingPort);
|
||||
ipmip_attr_put_u32(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA_TUNNELING_TYPE, binding->haBindingTunnelType);
|
||||
ipmip_attr_put_u32(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA_TUNNELING_FLAGS, binding->haBindingTunnelFlags);
|
||||
|
||||
ipmip_attr_put_u32(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA_SPI_MF, binding->haBindingSPIMobileHome);
|
||||
ipmip_attr_put_u32(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA_SPI_FH, binding->haBindingSPIForeignHome);
|
||||
ipmip_attr_put_u32(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA_SPI_AAA, binding->haBindingSPIMobileAAA);
|
||||
|
||||
ipmip_attr_put_u32(&request->message, IPMIPFA_CLI_ATTR_BC_X_COA_TIME_REMAINING, binding->mib.haMobilityBindingTimeRemaining);
|
||||
ipmip_attr_put_u32(&request->message, IPMIPFA_CLI_ATTR_BC_X_COA_TIME_GRANTED, binding->mib.haMobilityBindingTimeGranted);
|
||||
|
||||
/**/
|
||||
ipmip_attr_put_u64(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA_STATS_RCV_OCTETS64, node->haNodeRcvOctets - binding->haBindingRcvOctets);
|
||||
ipmip_attr_put_u64(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA_STATS_RCV_PKTS64, node->haNodeRcvPkts - binding->haBindingRcvPkts);
|
||||
ipmip_attr_put_u64(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA_STATS_SND_OCTETS64, node->haNodeSndOctets - binding->haBindingSndOctets);
|
||||
ipmip_attr_put_u64(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA_STATS_SND_PKTS64, node->haNodeSndPkts - binding->haBindingSndPkts);
|
||||
|
||||
/* MIB value */
|
||||
ipmip_attr_put(&request->message, IPMIPHA_CLI_ATTR_BC_X_COA_mib_haMobilityBindingEntry, sizeof(binding->mib), &binding->mib);
|
||||
ipmip_attr_end(&request->message, rta_binding);
|
||||
|
||||
if (coa)
|
||||
break;
|
||||
}
|
||||
ipmip_attr_end(&request->message, rta_node);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
rhdr = ipmip_attr_hdr_err(&request->message, hdr, IP_ERRNO_ENOENT, IP_NULL);
|
||||
|
||||
}
|
||||
|
||||
/* If we have a reply header; terminate it */
|
||||
ipmip_attr_hdr_finalize(&request->message, rhdr);
|
||||
|
||||
/* Commit the reply */
|
||||
ipmip_cli_message_commit(&data->ipmip4.ipmip, proc, request);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Free the request */
|
||||
ipmip_cli_message_free(&data->ipmip4.ipmip, proc, request);
|
||||
}
|
||||
|
||||
return IPMIP_TIMER_RET_DONE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
IP_GLOBAL int
|
||||
ipmipha_attr_command(struct Ipmipha_data *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;
|
||||
struct Ipmip_attr *idattr[IPMIPHA_CLI_ATTR_BC_X_MAX + 1];
|
||||
unsigned int si, f;
|
||||
|
||||
|
||||
switch (IPMIP_ATTR_HDR_TYPE(hdr))
|
||||
{
|
||||
case IPMIPHA_CLI_BC_X_NODE_LIST:
|
||||
{
|
||||
struct Ipmipha_attr_op aop;
|
||||
char *str;
|
||||
|
||||
ipcom_memset(&aop, 0, sizeof(aop));
|
||||
|
||||
aop.request = request;
|
||||
|
||||
ipmip_attr_hdr_parse(IPMIPHA_CLI_ATTR_BC_X_MAX, hdr, idattr);
|
||||
|
||||
aop.hoa = ipmip_attr_get_inet(idattr[IPMIPHA_CLI_ATTR_BC_X_HOA]);
|
||||
str = ipmip_attr_get_str(idattr[IPMIPHA_CLI_ATTR_BC_X_IFNAME]);
|
||||
if (str)
|
||||
aop.ifindex = ipcom_if_nametoindex(str);
|
||||
|
||||
/* NAI */
|
||||
aop.nai = ipmip_attr_get_data(idattr[IPMIPHA_CLI_ATTR_BC_X_NAI]);
|
||||
if (aop.nai)
|
||||
aop.nai_len = IPMIP_ATTR_PAYLOAD(idattr[IPMIPHA_CLI_ATTR_BC_X_NAI]);
|
||||
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
|
||||
/* Add all nodes */
|
||||
ipmip_context_id_lock(data->idents);
|
||||
ipmip_context_id_foreach(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
data->idents,
|
||||
(Ipmip_util_hash_foreach_t)ipmipha_attr_list_node,
|
||||
&aop,
|
||||
IP_NULL);
|
||||
ipmip_context_id_unlock(data->idents);
|
||||
}
|
||||
break;
|
||||
|
||||
case IPMIPHA_CLI_BC_X_NODE_REVOKE:
|
||||
case IPMIPHA_CLI_BC_X_NODE_GET:
|
||||
case IPMIPHA_CLI_BC_X_NODE_DELETE:
|
||||
{
|
||||
Ip_u32 handle = ipmip_attr_hdr_find_u32(hdr, IPMIPHA_CLI_ATTR_BC_X_HANDLE);
|
||||
|
||||
if (handle == 0)
|
||||
return -IP_ERRNO_EINVAL;
|
||||
|
||||
ipmipha_node_lookup_handle(data,
|
||||
proc,
|
||||
handle,
|
||||
&request->timer,
|
||||
(Ipmip_timer_func_t)ipmipha_attr_node_exec,
|
||||
request);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case IPMIPHA_CLI_DAEMON_REGISTRATION_COUNTERS:
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
ipmip_attr_put(&request->message, IPMIPHA_CLI_ATTR_DAEMON_REGCOUNTER, sizeof(data->mibRegCounters), &data->mibRegCounters);
|
||||
break;
|
||||
|
||||
case IPMIPHA_CLI_DAEMON_START:
|
||||
if (data->conf == IP_NULL)
|
||||
return -IP_ERRNO_EPERM;
|
||||
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
if (data->shutdown)
|
||||
{
|
||||
Ipmipha_iff_t *iff;
|
||||
data->shutdown = 0;
|
||||
/* Send instant RtAdv on all active interfaces */
|
||||
for (iff = IPCOM_LIST_FIRST(&data->conf->if_head); iff;
|
||||
iff = IPCOM_LIST_NEXT(&iff->iff.ipmip.next))
|
||||
{
|
||||
/* Should I send a multicast PrRtAdv? */
|
||||
if (iff->adv_interval > 0)
|
||||
ipmipha_agent_advert_output(data, proc, iff, IP_NULL, IP_NULL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IPMIPHA_CLI_DAEMON_STOP:
|
||||
if (data->conf == IP_NULL)
|
||||
return -IP_ERRNO_EPERM;
|
||||
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
data->shutdown = IPMIPHA_SHUTDOWN_ALL;
|
||||
break;
|
||||
|
||||
case IPMIPHA_CLI_DAEMON_MUTE:
|
||||
if (data->conf == IP_NULL)
|
||||
return -IP_ERRNO_EPERM;
|
||||
|
||||
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
|
||||
data->shutdown |= IPMIPHA_SHUTDOWN_ADV;
|
||||
break;
|
||||
|
||||
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 */
|
||||
Ipmipha_iff_t *ife;
|
||||
|
||||
ipmip_attr_put_str(&request->message,
|
||||
IPMIP_CLI_ITEM_NAME,
|
||||
"global");
|
||||
|
||||
/* 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);
|
||||
|
||||
/* Send instant RtAdv on all active interfaces */
|
||||
{
|
||||
/* Dump each configuration item we've currently got in human readable form */
|
||||
Ipmipha_iff_t *ife;
|
||||
const char *name = ipmip_attr_hdr_find_str(hdr, IPMIP_CLI_ITEM_NAME);
|
||||
|
||||
if (name == IP_NULL || ipcom_strcasecmp("global", name) == 0)
|
||||
{
|
||||
for (f = 0; f < IPMIPHA_FUNCTION_MAX; f++)
|
||||
{
|
||||
for (si = 0; si < data->extensions[f].num; si++)
|
||||
{
|
||||
if (data->extensions[f].functions[si]->config_global != IP_NULL && data->conf->extdata[f][si] != IP_NULL)
|
||||
(*data->extensions[f].functions[si]->config_global) (data, proc, IPMIP_CALLBACK_CONFIG_DUMP, data->conf->extdata[f][si], request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear any old interfaces */
|
||||
for (ife = IPCOM_LIST_FIRST(&data->conf->if_head); ife; ife = IPCOM_LIST_NEXT(&ife->iff.ipmip.next))
|
||||
{
|
||||
int i;
|
||||
|
||||
if (name != IP_NULL && ipcom_strcasecmp(ife->iff.ipmip.ifname, name) != 0)
|
||||
continue;
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.homeagent=%s",
|
||||
ife->iff.ipmip.ifname, ipmip_ntop_inet(proc, ife->iff.ifaddr));
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.homenetmask=%s",
|
||||
ife->iff.ipmip.ifname, ipmip_ntop_inet(proc, ife->home_netmask));
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.lifetime=%d",
|
||||
ife->iff.ipmip.ifname, ife->lifetime);
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.timestamp_replay_protection_max_diff=%d",
|
||||
ife->iff.ipmip.ifname, ife->replay_diff);
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.nai.ha=%s",
|
||||
ife->iff.ipmip.ifname, ipmip_ntop_strn(proc, (char *)IPMIP4_MSGEXT_SHDR_EXT_DATA(ife->nai_ha), IPMIP4_MSGEXT_SHDR_EXT_SIZE(ife->nai_ha)));
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.mn.nai.required=%s",
|
||||
ife->iff.ipmip.ifname, ife->mn_nai_require? "enabled" : "disabled");
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.adv_lifetime=%d",
|
||||
ife->iff.ipmip.ifname, ife->adv_lifetime);
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.adv_interval=%d",
|
||||
ife->iff.ipmip.ifname, ife->adv_interval);
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.adv_address=%s",
|
||||
ife->iff.ipmip.ifname, ipmip_ntop_inet(proc, ife->adv_address));
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.nat_t.enabled=%s",
|
||||
ife->iff.ipmip.ifname, ife->nat_t? "enabled" : "disabled");
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.nat_t.keepalive=%d",
|
||||
ife->iff.ipmip.ifname, ife->nat_t_keepalive);
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.fa_auth=%s",
|
||||
ife->iff.ipmip.ifname, ife->fa_auth? "enabled" : "disabled");
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.tunnel.reordering=%s",
|
||||
ife->iff.ipmip.ifname, ife->reordering? "enabled" : "disabled");
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.tunnel.reverse=%s",
|
||||
ife->iff.ipmip.ifname, ipmip_sysvar_mode_desc[ife->tunnel.reverse]);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.tunnel.ipip=%s",
|
||||
ife->iff.ipmip.ifname, ife->tunnel.enabled[IPMIP_TUNNELTYPE_IPIP]? "enabled" : "disabled");
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.tunnel.gre=%s",
|
||||
ife->iff.ipmip.ifname, ife->tunnel.enabled[IPMIP_TUNNELTYPE_GRE]? "enabled" : "disabled");
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.tunnel.minenc=%s",
|
||||
ife->iff.ipmip.ifname, ife->tunnel.enabled[IPMIP_TUNNELTYPE_MINENC]? "enabled" : "disabled");
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.simbind.enabled=%s",
|
||||
ife->iff.ipmip.ifname, ife->simbind_enabled? "enabled" : "disabled");
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.simbind.max=%d",
|
||||
ife->iff.ipmip.ifname, ife->simbind_max);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.revocation.enabled=%s",
|
||||
ife->iff.ipmip.ifname, ife->revocation? "enabled" : "disabled");
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.revocation.inform=%s",
|
||||
ife->iff.ipmip.ifname, ipmip_sysvar_mode_desc[ife->revocation_inform]);
|
||||
|
||||
ipcom_snprintf(proc->ntop.ntop_pbuf, sizeof(proc->ntop.ntop_pbuf), "ipmipha.if.%s.mn.sa.lookup.order=", ife->iff.ipmip.ifname);
|
||||
for (i = 0; ife->security.spi_mn_lookup_order[i] != IPMIPHA_SPI_MN_NONE; i++)
|
||||
{
|
||||
int j;
|
||||
for (j = 0; ipmipha_attr_lookup[j].str != IP_NULL; j++)
|
||||
{
|
||||
if (ipmipha_attr_lookup[j].key == ife->security.spi_mn_lookup_order[i])
|
||||
{
|
||||
if (i != 0)
|
||||
ipcom_strncat(proc->ntop.ntop_pbuf, ",", sizeof(proc->ntop.ntop_pbuf));
|
||||
ipcom_strncat(proc->ntop.ntop_pbuf, ipmipha_attr_lookup[j].str, sizeof(proc->ntop.ntop_pbuf));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
ipmip_cli_config_printf(&request->message, proc->ntop.ntop_pbuf);
|
||||
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.fa.sa.lookup.required=%s",
|
||||
ife->iff.ipmip.ifname, ife->security.spi_fa_lookup_required? "enabled" : "disabled");
|
||||
ipmip_cli_config_printf(&request->message,
|
||||
"ipmipha.if.%s.mn.sa.lookup.required=%s",
|
||||
ife->iff.ipmip.ifname, ife->security.spi_mn_lookup_required? "enabled" : "disabled");
|
||||
|
||||
|
||||
ipcom_snprintf(proc->ntop.ntop_name, sizeof(proc->ntop.ntop_name), "ipmipha.if.%s.spi", ife->iff.ipmip.ifname);
|
||||
ipmip4_auth_spi_dump(proc, ife->security.spi_ctx, proc->ntop.ntop_name, IP_TRUE, request);
|
||||
ipcom_snprintf(proc->ntop.ntop_name, sizeof(proc->ntop.ntop_name), "ipmipha.if.%s.fa.sa.address", ife->iff.ipmip.ifname);
|
||||
ipmip4_auth_spi_table_dump(proc, ife->security.spi_fa, proc->ntop.ntop_name, request);
|
||||
ipcom_snprintf(proc->ntop.ntop_name, sizeof(proc->ntop.ntop_name), "ipmipha.if.%s.mn.sa.address", ife->iff.ipmip.ifname);
|
||||
ipmip4_auth_spi_table_dump(proc, ife->security.spi_mn, proc->ntop.ntop_name, request);
|
||||
ipcom_snprintf(proc->ntop.ntop_name, sizeof(proc->ntop.ntop_name), "ipmipha.if.%s.mn.sa.nai", ife->iff.ipmip.ifname);
|
||||
ipmip4_auth_spi_hash_dump(proc, ife->security.spi_nai, proc->ntop.ntop_name, request);
|
||||
|
||||
|
||||
for (f = 0; f < IPMIPHA_FUNCTION_MAX; f++)
|
||||
{
|
||||
for (si = 0; si < data->extensions[f].num; si++)
|
||||
{
|
||||
if (data->extensions[f].functions[si]->config_ifp != IP_NULL && ife->extdata[f][si] != IP_NULL)
|
||||
(*data->extensions[f].functions[si]->config_ifp) (data, proc, IPMIP_CALLBACK_CONFIG_DUMP, ife, data->conf->extdata[f][si], ife->extdata[f][si], request);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
break;
|
||||
|
||||
default:
|
||||
return ipmip4_attr_command(&data->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->ipmip4.ipmip, proc, request);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_attr_mib_haMobilityBindingEntry
|
||||
*===========================================================================
|
||||
* Description: Returns a NULL terminated array of binding entries. The data
|
||||
* is dynamically allocated and must be freed by the caller.
|
||||
* Parameters:
|
||||
* Returns: Returns a NULL terminated array of binding entries.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL struct Ipmipha_mib_haMobilityBindingEntry **
|
||||
ipmipha_attr_mib_haMobilityBindingEntry(void)
|
||||
{
|
||||
struct Ipmipha_mib_haMobilityBindingEntry **header = IP_NULL;
|
||||
Ipmip_cli_daemon_t daemon;
|
||||
Ipmip_cli_daemon_req_t req;
|
||||
Ipmip_buffer_t cntbuf;
|
||||
|
||||
daemon.fd = IP_INVALID_SOCKET;
|
||||
|
||||
ipmip_cli_daemon_request_init(&req);
|
||||
ipmip_buffer_init(&cntbuf);
|
||||
|
||||
if (!ipmipha_cli_connect(&daemon))
|
||||
return IP_NULL;
|
||||
|
||||
if (ipmipha_cli_node_list(&daemon, &req, IP_NULL, IP_NULL, 0) == IPCOM_SUCCESS)
|
||||
{
|
||||
Ipmip_attr_iter_t iter;
|
||||
Ip_u32 handle;
|
||||
Ip_u32 num_entries = 0;
|
||||
Ip_u32 off = 0;
|
||||
struct Ipmipha_mib_haMobilityBindingEntry *array;
|
||||
char *data;
|
||||
|
||||
ipmip_cli_daemon_iter_request_init(&req, &iter);
|
||||
while ((handle = ipmipha_cli_handle_next(&iter)) != 0)
|
||||
{
|
||||
Ipmip_cli_daemon_req_t nreq;
|
||||
struct Ipmip_attr *node;
|
||||
|
||||
ipmip_cli_daemon_request_init(&nreq);
|
||||
|
||||
if ((node = ipmipha_cli_node_get(&daemon, &nreq, handle)) != IP_NULL)
|
||||
{
|
||||
Ipmip_attr_iter_t niter;
|
||||
struct Ipmip_attr *binding;
|
||||
|
||||
ipmip_attr_payload_iter_init(node, &niter);
|
||||
while ((binding = ipmipha_cli_binding_next(&niter)) != IP_NULL)
|
||||
{
|
||||
struct Ipmipha_mib_haMobilityBindingEntry *be = ipmipha_cli_binding_get_haMobilityBindingEntry(binding);
|
||||
if (be)
|
||||
ipmip_buffer_append(&cntbuf, be, sizeof(*be));
|
||||
}
|
||||
}
|
||||
|
||||
ipmip_cli_daemon_request_release(&nreq);
|
||||
}
|
||||
|
||||
/* Terminate array */
|
||||
num_entries = IPMIP_BUFFER_SIZE(&cntbuf) / sizeof(struct Ipmipha_mib_haMobilityBindingEntry);
|
||||
data = ipcom_malloc(IPMIP_BUFFER_SIZE(&cntbuf) + sizeof(struct Ipmipha_mib_haMobilityBindingEntry) * num_entries);
|
||||
if (data == IP_NULL)
|
||||
goto done_out;
|
||||
|
||||
header = (struct Ipmipha_mib_haMobilityBindingEntry**) data;
|
||||
array = (struct Ipmipha_mib_haMobilityBindingEntry*)(data + sizeof(struct Ipmipha_mib_haMobilityBindingEntry*) * (num_entries + 1));
|
||||
|
||||
ipcom_memcpy(array, IPMIP_BUFFER_PTR(&cntbuf), IPMIP_BUFFER_SIZE(&cntbuf));
|
||||
for (off = 0; off < num_entries; off++)
|
||||
header[off] = &array[off];
|
||||
|
||||
header[off] = IP_NULL;
|
||||
}
|
||||
|
||||
done_out:
|
||||
ipmip_buffer_release(&cntbuf);
|
||||
ipmip_cli_daemon_disconnect(&daemon);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
return header;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_attr_mib_haCounterEntry
|
||||
*===========================================================================
|
||||
* Description: Returns a NULL terminated array of counter entries. The data
|
||||
* is dynamically allocated and must be freed by the caller.
|
||||
* Parameters:
|
||||
* Returns: Returns a NULL terminated array of counter entries.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL struct Ipmipha_mib_haCounterEntry **
|
||||
ipmipha_attr_mib_haCounterEntry(void)
|
||||
{
|
||||
struct Ipmipha_mib_haCounterEntry **header = IP_NULL;
|
||||
Ipmip_cli_daemon_t daemon;
|
||||
Ipmip_cli_daemon_req_t req;
|
||||
Ipmip_buffer_t cntbuf;
|
||||
|
||||
daemon.fd = IP_INVALID_SOCKET;
|
||||
|
||||
ipmip_cli_daemon_request_init(&req);
|
||||
ipmip_buffer_init(&cntbuf);
|
||||
|
||||
if (!ipmipha_cli_connect(&daemon))
|
||||
return IP_NULL;
|
||||
|
||||
if (ipmipha_cli_node_list(&daemon, &req, IP_NULL, IP_NULL, 0) == IPCOM_SUCCESS)
|
||||
{
|
||||
Ipmip_attr_iter_t iter;
|
||||
Ip_u32 handle;
|
||||
Ip_u32 num_entries = 0;
|
||||
Ip_u32 off = 0;
|
||||
struct Ipmipha_mib_haCounterEntry *array;
|
||||
char *data;
|
||||
|
||||
ipmip_cli_daemon_iter_request_init(&req, &iter);
|
||||
while ((handle = ipmipha_cli_handle_next(&iter)) != 0)
|
||||
{
|
||||
Ipmip_cli_daemon_req_t nreq;
|
||||
struct Ipmip_attr *node;
|
||||
|
||||
ipmip_cli_daemon_request_init(&nreq);
|
||||
|
||||
if ((node = ipmipha_cli_node_get(&daemon, &nreq, handle)) != IP_NULL)
|
||||
{
|
||||
struct Ipmipha_mib_haCounterEntry *ne = ipmipha_cli_node_get_haCounterEntry(node);
|
||||
if (ne != IP_NULL)
|
||||
ipmip_buffer_append(&cntbuf, ne, sizeof(*ne));
|
||||
}
|
||||
|
||||
ipmip_cli_daemon_request_release(&nreq);
|
||||
}
|
||||
|
||||
num_entries = IPMIP_BUFFER_SIZE(&cntbuf) / sizeof(struct Ipmipha_mib_haCounterEntry);
|
||||
data = ipcom_malloc(IPMIP_BUFFER_SIZE(&cntbuf) + (num_entries + 1) * sizeof(struct Ipmipha_mib_haCounterEntry*));
|
||||
if (data == IP_NULL)
|
||||
goto done_out;
|
||||
|
||||
header = (struct Ipmipha_mib_haCounterEntry**) data;
|
||||
array = (struct Ipmipha_mib_haCounterEntry*)(data + sizeof(struct Ipmipha_mib_haCounterEntry*) * (num_entries + 1));
|
||||
|
||||
ipcom_memcpy(array, IPMIP_BUFFER_PTR(&cntbuf), IPMIP_BUFFER_SIZE(&cntbuf));
|
||||
for (off = 0; off < num_entries; off++)
|
||||
header[off] = &array[off];
|
||||
|
||||
/* Terminate array */
|
||||
header[off] = IP_NULL;
|
||||
}
|
||||
|
||||
done_out:
|
||||
ipmip_buffer_release(&cntbuf);
|
||||
ipmip_cli_daemon_disconnect(&daemon);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
return header;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_attr_mib_haRegNodeCounters
|
||||
*===========================================================================
|
||||
* Description: Returns a dynamically allocated structure containing the registration
|
||||
* counters for the home agent. The memory is dynamically allocated
|
||||
* and must be freed by the caller.
|
||||
* Parameters:
|
||||
* Returns: Returns the registration counter data.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL struct Ipmipha_mib_haRegNodeCounters *
|
||||
ipmipha_attr_mib_haRegNodeCounters(void)
|
||||
{
|
||||
struct Ipmipha_mib_haRegNodeCounters *header = IP_NULL;
|
||||
struct Ipmipha_mib_haRegNodeCounters *arg = IP_NULL;
|
||||
Ipmip_cli_daemon_t daemon;
|
||||
Ipmip_cli_daemon_req_t req;
|
||||
|
||||
daemon.fd = IP_INVALID_SOCKET;
|
||||
|
||||
ipmip_cli_daemon_request_init(&req);
|
||||
|
||||
if (!ipmipha_cli_connect(&daemon))
|
||||
return IP_NULL;
|
||||
|
||||
if ((arg = ipmipha_cli_daemon_registration_counters(&daemon, &req)) != IP_NULL)
|
||||
{
|
||||
header = ipcom_malloc(sizeof(*header));
|
||||
ipcom_memcpy(header, arg, sizeof(*header));
|
||||
}
|
||||
|
||||
ipmip_cli_daemon_disconnect(&daemon);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
return header;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,94 @@
|
||||
/* ipmipha_attr_h.h - ipmipha_attr_h.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha_attr_h.h,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmipha/src/ipmipha_attr_h.h,v $
|
||||
* $Author: jhorteli $ $Date: 2010-12-07 09:56:13 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIPHA_ATTR_H_H
|
||||
#define IPMIPHA_ATTR_H_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
No description currently provided
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include "ipmipha_attr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmipha_data;
|
||||
struct Ipmip_proc;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
extern Ipmip_sysvar_key_map_t ipmipha_attr_lookup[];
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_attr_command
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int ipmipha_attr_command(struct Ipmipha_data *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmip_cli_message *request);
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,469 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha_cli.c,v $ $Revision: 1.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmipha/src/ipmipha_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 "ipmipha_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 <private/ipmip4_context.h>
|
||||
|
||||
#include "ipmipha.h"
|
||||
#include "ipmipha_attr.h"
|
||||
#include "ipmipha_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
|
||||
ipmipha_cli_connect(Ipmip_cli_daemon_t *daemon_info)
|
||||
{
|
||||
ipmip_cli_daemon_init(daemon_info, "ipmipha", IPCOM_IPD_ID_IPMIPHA);
|
||||
return ipmip_cli_daemon_connect(daemon_info);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmipha_cli_daemon_mute(Ipmip_cli_daemon_t *daemon)
|
||||
{
|
||||
Ipmip_cli_daemon_req_t req;
|
||||
|
||||
ipmip_cli_daemon_request_init(&req);
|
||||
ipmip_cli_daemon_request_start(&req, IPMIPHA_CLI_DAEMON_MUTE);
|
||||
ipmip_cli_daemon_request(daemon, &req);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmipha_cli_daemon_start(Ipmip_cli_daemon_t *daemon)
|
||||
{
|
||||
Ipmip_cli_daemon_req_t req;
|
||||
|
||||
ipmip_cli_daemon_request_init(&req);
|
||||
ipmip_cli_daemon_request_start(&req, IPMIPHA_CLI_DAEMON_START);
|
||||
ipmip_cli_daemon_request(daemon, &req);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmipha_cli_daemon_stop(Ipmip_cli_daemon_t *daemon)
|
||||
{
|
||||
Ipmip_cli_daemon_req_t req;
|
||||
|
||||
ipmip_cli_daemon_request_init(&req);
|
||||
ipmip_cli_daemon_request_start(&req, IPMIPHA_CLI_DAEMON_STOP);
|
||||
ipmip_cli_daemon_request(daemon, &req);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
}
|
||||
|
||||
IP_PUBLIC struct Ipmipha_mib_haRegNodeCounters *
|
||||
ipmipha_cli_daemon_registration_counters(Ipmip_cli_daemon_t *daemon,
|
||||
Ipmip_cli_daemon_req_t *req)
|
||||
{
|
||||
ipmip_cli_daemon_request_start(req, IPMIPHA_CLI_DAEMON_REGISTRATION_COUNTERS);
|
||||
if (ipmip_cli_daemon_request(daemon, req) == IPCOM_SUCCESS)
|
||||
return (struct Ipmipha_mib_haRegNodeCounters *)ipmip_cli_daemon_find_request_data(req, IPMIPHA_CLI_ATTR_DAEMON_REGCOUNTER);
|
||||
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
IP_PUBLIC int
|
||||
ipmipha_cli_node_list(Ipmip_cli_daemon_t *daemon,
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
const char *nai,
|
||||
const char *ifname,
|
||||
Ip_u32 hoa)
|
||||
{
|
||||
ipmip_cli_daemon_request_start(req, IPMIPHA_CLI_BC_X_NODE_LIST);
|
||||
|
||||
ipmipha_cli_request_set_ifname(req, ifname);
|
||||
ipmipha_cli_request_set_nai(req, nai);
|
||||
ipmipha_cli_request_set_home_address(req, hoa);
|
||||
|
||||
return ipmip_cli_daemon_request(daemon, req);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmipha_cli_handle_next(Ipmip_attr_iter_t *iter)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_get_u32(ipmip_attr_iter_next(iter, IPMIPHA_CLI_ATTR_BC_X_HANDLE));
|
||||
}
|
||||
|
||||
IP_PUBLIC struct Ipmip_attr *
|
||||
ipmipha_cli_node_get(Ipmip_cli_daemon_t *daemon,
|
||||
Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 handle)
|
||||
{
|
||||
ipmip_cli_daemon_request_start(req, IPMIPHA_CLI_BC_X_NODE_GET);
|
||||
|
||||
ipmipha_cli_request_set_handle(req, handle);
|
||||
|
||||
if (ipmip_cli_daemon_request(daemon, req) == IPCOM_SUCCESS)
|
||||
return ipmip_cli_daemon_find_request(req, IPMIPHA_CLI_ATTR_BC_X);
|
||||
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmipha_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, IPMIPHA_CLI_BC_X_NODE_DELETE);
|
||||
ipmipha_cli_request_set_handle(&req, handle);
|
||||
ipmip_cli_daemon_request(daemon, &req);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmipha_cli_node_revoke(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, IPMIPHA_CLI_BC_X_NODE_REVOKE);
|
||||
ipmipha_cli_request_set_handle(&req, handle);
|
||||
ipmip_cli_daemon_request(daemon, &req);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmipha_cli_request_set_nai(Ipmip_cli_daemon_req_t *req,
|
||||
const char *nai)
|
||||
{
|
||||
if (nai)
|
||||
ipmip_attr_put_str(&req->reqbuf, IPMIPHA_CLI_ATTR_BC_X_NAI, nai);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmipha_cli_request_set_handle(Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 handle)
|
||||
{
|
||||
ipmip_attr_put_u32(&req->reqbuf, IPMIPHA_CLI_ATTR_BC_X_HANDLE, handle);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmipha_cli_request_set_home_address(Ipmip_cli_daemon_req_t *req,
|
||||
Ip_u32 hoa)
|
||||
{
|
||||
if (hoa)
|
||||
ipmip_attr_put_inet(&req->reqbuf, IPMIPHA_CLI_ATTR_BC_X_HOA, hoa);
|
||||
}
|
||||
|
||||
IP_PUBLIC void
|
||||
ipmipha_cli_request_set_ifname(Ipmip_cli_daemon_req_t *req,
|
||||
const char *ifname)
|
||||
{
|
||||
if (ifname)
|
||||
ipmip_attr_put_str(&req->reqbuf,IPMIPHA_CLI_ATTR_BC_X_IFNAME, ifname);
|
||||
}
|
||||
|
||||
|
||||
IP_PUBLIC const char *
|
||||
ipmipha_cli_node_get_ifname(struct Ipmip_attr *node)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_payload_find_str(node, IPMIPHA_CLI_ATTR_BC_X_IFNAME);
|
||||
}
|
||||
|
||||
IP_PUBLIC const char *
|
||||
ipmipha_cli_node_get_nai(struct Ipmip_attr *node)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_payload_find_str(node, IPMIPHA_CLI_ATTR_BC_X_NAI);
|
||||
}
|
||||
|
||||
IP_PUBLIC const char *
|
||||
ipmipha_cli_node_get_nai_aaah(struct Ipmip_attr *node)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_payload_find_str(node, IPMIPHA_CLI_ATTR_BC_X_NAI_AAAH);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmipha_cli_node_get_handle(struct Ipmip_attr *node)
|
||||
{
|
||||
return ipmip_attr_payload_find_u32(node, IPMIPHA_CLI_ATTR_BC_X_HANDLE);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmipha_cli_node_get_home_address(struct Ipmip_attr *node)
|
||||
{
|
||||
return ipmip_attr_payload_find_inet(node, IPMIPHA_CLI_ATTR_BC_X_HOA);
|
||||
}
|
||||
|
||||
IP_PUBLIC struct Ipmipha_mib_haCounterEntry *
|
||||
ipmipha_cli_node_get_haCounterEntry(struct Ipmip_attr *node)
|
||||
{
|
||||
return (struct Ipmipha_mib_haCounterEntry *)ipmip_attr_payload_find_data(node, IPMIPHA_CLI_ATTR_BC_X_mib_haCounterEntry);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_time_t
|
||||
ipmipha_cli_node_get_created(struct Ipmip_attr *node)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_payload_find_time_t(node, IPMIPHA_CLI_ATTR_BC_X_CREATION_TIME);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_time_t
|
||||
ipmipha_cli_node_get_last_updated(struct Ipmip_attr *node)
|
||||
{
|
||||
return ipmip_attr_payload_find_time_t(node, IPMIPHA_CLI_ATTR_BC_X_LAST_UPDATED);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_time_t
|
||||
ipmipha_cli_node_get_AAA_last_verified(struct Ipmip_attr *node)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_payload_find_time_t(node, IPMIPHA_CLI_ATTR_BC_X_AAA_VERIFICATION_TIME);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_bool
|
||||
ipmipha_cli_node_get_AAA_accounting_enabled(struct Ipmip_attr *node)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_payload_find_u32(node, IPMIPHA_CLI_ATTR_BC_X_AAA_ACCOUNTING_ENABLED) != 0;
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u64
|
||||
ipmipha_cli_node_get_stats_rcv_octets64(struct Ipmip_attr *node)
|
||||
{
|
||||
return ipmip_attr_payload_find_u64(node, IPMIPHA_CLI_ATTR_BC_X_STATS_RCV_OCTETS64);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u64
|
||||
ipmipha_cli_node_get_stats_rcv_pkts64(struct Ipmip_attr *node)
|
||||
{
|
||||
return ipmip_attr_payload_find_u64(node, IPMIPHA_CLI_ATTR_BC_X_STATS_RCV_PKTS64);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u64
|
||||
ipmipha_cli_node_get_stats_snd_octets64(struct Ipmip_attr *node)
|
||||
{
|
||||
return ipmip_attr_payload_find_u64(node, IPMIPHA_CLI_ATTR_BC_X_STATS_SND_OCTETS64);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u64
|
||||
ipmipha_cli_node_get_stats_snd_pkts64(struct Ipmip_attr *node)
|
||||
{
|
||||
return ipmip_attr_payload_find_u64(node, IPMIPHA_CLI_ATTR_BC_X_STATS_SND_PKTS64);
|
||||
}
|
||||
|
||||
IP_PUBLIC struct Ipmip_attr *
|
||||
ipmipha_cli_binding_next(Ipmip_attr_iter_t *iter)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_iter_next(iter, IPMIPHA_CLI_ATTR_BC_X_COA);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_time_t
|
||||
ipmipha_cli_binding_get_created(struct Ipmip_attr *binding)
|
||||
{
|
||||
/**/
|
||||
return ipmip_attr_payload_find_time_t(binding, IPMIPHA_CLI_ATTR_BC_X_COA_CREATION_TIME);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_time_t
|
||||
ipmipha_cli_binding_get_last_updated(struct Ipmip_attr *binding)
|
||||
{
|
||||
return ipmip_attr_payload_find_time_t(binding, IPMIPHA_CLI_ATTR_BC_X_COA_LAST_UPDATED);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u64
|
||||
ipmipha_cli_binding_get_stats_rcv_octets64(struct Ipmip_attr *binding)
|
||||
{
|
||||
return ipmip_attr_payload_find_u64(binding, IPMIPHA_CLI_ATTR_BC_X_COA_STATS_RCV_OCTETS64);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u64
|
||||
ipmipha_cli_binding_get_stats_rcv_pkts64(struct Ipmip_attr *binding)
|
||||
{
|
||||
return ipmip_attr_payload_find_u64(binding, IPMIPHA_CLI_ATTR_BC_X_COA_STATS_RCV_PKTS64);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u64
|
||||
ipmipha_cli_binding_get_stats_snd_octets64(struct Ipmip_attr *binding)
|
||||
{
|
||||
return ipmip_attr_payload_find_u64(binding, IPMIPHA_CLI_ATTR_BC_X_COA_STATS_SND_OCTETS64);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u64
|
||||
ipmipha_cli_binding_get_stats_snd_pkts64(struct Ipmip_attr *binding)
|
||||
{
|
||||
return ipmip_attr_payload_find_u64(binding, IPMIPHA_CLI_ATTR_BC_X_COA_STATS_SND_PKTS64);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmipha_cli_binding_get_address(struct Ipmip_attr *binding)
|
||||
{
|
||||
return ipmip_attr_payload_find_inet(binding, IPMIPHA_CLI_ATTR_BC_X_COA_INET);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmipha_cli_binding_get_tunnel_endpoint(struct Ipmip_attr *binding)
|
||||
{
|
||||
return ipmip_attr_payload_find_inet(binding, IPMIPHA_CLI_ATTR_BC_X_COA_TUNNELING_ENDPOINT);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmipha_cli_binding_get_tunnel_type(struct Ipmip_attr *binding)
|
||||
{
|
||||
return ipmip_attr_payload_find_u32(binding, IPMIPHA_CLI_ATTR_BC_X_COA_TUNNELING_TYPE);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmipha_cli_binding_get_tunnel_flags(struct Ipmip_attr *binding)
|
||||
{
|
||||
return ipmip_attr_payload_find_u32(binding, IPMIPHA_CLI_ATTR_BC_X_COA_TUNNELING_FLAGS);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u16
|
||||
ipmipha_cli_binding_get_tunnel_port(struct Ipmip_attr *binding)
|
||||
{
|
||||
return ipmip_attr_payload_find_u32(binding, IPMIPHA_CLI_ATTR_BC_X_COA_TUNNELING_PORT);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmipha_cli_binding_get_spi_mobile_foreign(struct Ipmip_attr *binding)
|
||||
{
|
||||
return ipmip_attr_payload_find_u32(binding, IPMIPHA_CLI_ATTR_BC_X_COA_SPI_MF);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmipha_cli_binding_get_spi_foreign_home(struct Ipmip_attr *binding)
|
||||
{
|
||||
return ipmip_attr_payload_find_u32(binding, IPMIPHA_CLI_ATTR_BC_X_COA_SPI_FH);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmipha_cli_binding_get_spi_mobile_AAA(struct Ipmip_attr *binding)
|
||||
{
|
||||
return ipmip_attr_payload_find_u32(binding, IPMIPHA_CLI_ATTR_BC_X_COA_SPI_AAA);
|
||||
}
|
||||
|
||||
IP_PUBLIC struct Ipmipha_mib_haMobilityBindingEntry *
|
||||
ipmipha_cli_binding_get_haMobilityBindingEntry(struct Ipmip_attr *binding)
|
||||
{
|
||||
return (struct Ipmipha_mib_haMobilityBindingEntry *)ipmip_attr_payload_find_data(binding, IPMIPHA_CLI_ATTR_BC_X_COA_mib_haMobilityBindingEntry);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmipha_cli_binding_get_time_granted(struct Ipmip_attr *binding)
|
||||
{
|
||||
return ipmip_attr_payload_find_u32(binding, IPMIPFA_CLI_ATTR_BC_X_COA_TIME_GRANTED);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmipha_cli_binding_get_time_remaining(struct Ipmip_attr *binding)
|
||||
{
|
||||
return ipmip_attr_payload_find_u32(binding, IPMIPFA_CLI_ATTR_BC_X_COA_TIME_REMAINING);
|
||||
}
|
||||
|
||||
IP_PUBLIC Ip_u32
|
||||
ipmipha_cli_binding_get_registration_flags(struct Ipmip_attr *binding)
|
||||
{
|
||||
return ipmip_attr_payload_find_u32(binding, IPMIPHA_CLI_ATTR_BC_X_COA_REG_FLAGS);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,614 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha_cmd_ha.c,v $ $Revision: 1.26 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmipha/src/ipmipha_cmd_ha.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $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_err.h>
|
||||
#include <ipcom_getopt.h>
|
||||
#include <ipcom_inet.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_cmd.h>
|
||||
#include <ipcom_getopt.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_ipd.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_context.h>
|
||||
#include <private/ipmip_cli.h>
|
||||
|
||||
#include <ipmip4.h>
|
||||
#include <private/ipmip4_msgext.h>
|
||||
#include <private/ipmip4_ntop.h>
|
||||
|
||||
#include "ipmipha.h"
|
||||
#include "ipmipha_mib.h"
|
||||
#include "ipmipha_attr.h"
|
||||
#include "ipmipha_cli.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIPHA_CMD_OP_LIST (1)
|
||||
#define IPMIPHA_CMD_OP_SHOW (2)
|
||||
#define IPMIPHA_CMD_OP_EVENTS (3)
|
||||
#define IPMIPHA_CMD_OP_FLUSH (4)
|
||||
#define IPMIPHA_CMD_OP_REVOKE (5)
|
||||
#define IPMIPHA_CMD_OP_STOP (6)
|
||||
#define IPMIPHA_CMD_OP_START (7)
|
||||
#define IPMIPHA_CMD_OP_DELETE (8)
|
||||
#define IPMIPHA_CMD_OP_MUTE (9)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC int ipmipha_cmd_ha(int argc, char **argv);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC Ipcom_cmd_int_str_map ipmipha_cmd_ops[] =
|
||||
{
|
||||
{ IPMIPHA_CMD_OP_LIST, "list" },
|
||||
{ IPMIPHA_CMD_OP_SHOW, "show" },
|
||||
{ IPMIPHA_CMD_OP_EVENTS, "events" },
|
||||
{ IPMIPHA_CMD_OP_FLUSH, "flush" },
|
||||
{ IPMIPHA_CMD_OP_REVOKE, "revoke" },
|
||||
{ IPMIPHA_CMD_OP_DELETE, "delete" },
|
||||
{ IPMIPHA_CMD_OP_STOP, "stop" },
|
||||
{ IPMIPHA_CMD_OP_START, "start" },
|
||||
{ IPMIPHA_CMD_OP_MUTE, "mute" },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_cmd_binding_flags
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC char *
|
||||
ipmipha_cmd_binding_flags(char *buffer,
|
||||
struct Ipmip_attr *binding)
|
||||
{
|
||||
char *tt = "";
|
||||
Ip_u32 type = ipmipha_cli_binding_get_tunnel_type(binding);
|
||||
Ip_u32 flags = ipmipha_cli_binding_get_registration_flags(binding);
|
||||
|
||||
if (type == IPMIP_TUNNELTYPE_GRE)
|
||||
tt = "G";
|
||||
else if (type == IPMIP_TUNNELTYPE_MINENC)
|
||||
tt = "M";
|
||||
|
||||
ipcom_sprintf(buffer,
|
||||
"%s%s%s%s",
|
||||
IP_BIT_ISTRUE(flags, IPMIP4_CODE_REQ_BROADCAST)? "B" : "",
|
||||
IP_BIT_ISTRUE(flags, IPMIP4_CODE_REQ_REVERSE_TUNNELING)? "T" : "",
|
||||
IP_BIT_ISTRUE(flags, IPMIP4_CODE_REQ_DECAPSULATION)? "D" : "",
|
||||
tt);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_cmd_coa_flags
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC const char *
|
||||
ipmipha_cmd_coa_nat(struct Ipmip_attr *binding)
|
||||
{
|
||||
Ip_u32 flags = ipmipha_cli_binding_get_tunnel_flags(binding);
|
||||
|
||||
if (IP_BIT_ARESET(flags, IPMIP4_TUNNELMODE_NAT_T_CONFIRMED))
|
||||
return "*";
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_cmd_print_binding_fmt
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmipha_cmd_print_binding_fmt(const char *hoa,
|
||||
const char *coa,
|
||||
const char *ifname,
|
||||
const char *lifetime,
|
||||
const char *flags)
|
||||
{
|
||||
/* */
|
||||
ipcom_printf("%-20s %-20s %-16s %-15s %s"IP_LF,
|
||||
hoa, coa, ifname, lifetime, flags);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_cmd_print_binding
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmipha_cmd_print_binding(Ipmip_proc_t *proc,
|
||||
Ip_u32 num,
|
||||
struct Ipmip_attr *node,
|
||||
struct Ipmip_attr *binding,
|
||||
Ip_bool verbose)
|
||||
{
|
||||
ipcom_snprintf(proc->ntop.ntop_lla, sizeof(proc->ntop.ntop_lla),
|
||||
"%d/%d",
|
||||
ipmipha_cli_binding_get_time_remaining(binding),
|
||||
ipmipha_cli_binding_get_time_granted(binding));
|
||||
|
||||
ipcom_snprintf(proc->ntop.ntop_pbuf, sizeof(proc->ntop.ntop_pbuf), "%s%s", ipmip_ntop_inet(proc, ipmipha_cli_binding_get_address(binding)), ipmipha_cmd_coa_nat(binding));
|
||||
if (num == 0)
|
||||
{
|
||||
ipmipha_cmd_print_binding_fmt(ipmip_ntop_inet(proc, ipmipha_cli_node_get_home_address(node)),
|
||||
proc->ntop.ntop_pbuf,
|
||||
ipmipha_cli_node_get_ifname(node),
|
||||
proc->ntop.ntop_lla,
|
||||
ipmipha_cmd_binding_flags(proc->ntop.ntop_name, binding));
|
||||
}
|
||||
else if (verbose)
|
||||
{
|
||||
ipmipha_cmd_print_binding_fmt("",
|
||||
proc->ntop.ntop_pbuf,
|
||||
ipmipha_cli_node_get_ifname(node),
|
||||
proc->ntop.ntop_lla,
|
||||
ipmipha_cmd_binding_flags(proc->ntop.ntop_name, binding));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_cmd_show_binding
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmipha_cmd_show_binding(Ipmip_proc_t *proc,
|
||||
Ip_u32 num,
|
||||
struct Ipmip_attr *node,
|
||||
struct Ipmip_attr *binding,
|
||||
Ip_bool verbose)
|
||||
{
|
||||
if (num == 0)
|
||||
{
|
||||
const char *str;
|
||||
/**/
|
||||
ipcom_printf("Node %08x:"IP_LF, ipmipha_cli_node_get_handle(node));
|
||||
ipcom_printf(" Home Address : %s"IP_LF, ipmip_ntop_inet(proc, ipmipha_cli_node_get_home_address(node)));
|
||||
ipcom_printf(" Creation : %s"IP_LF, ipmip_ntop_tm(proc, ipmipha_cli_node_get_created(node)));
|
||||
ipcom_printf(" Interface : %s"IP_LF, ipmipha_cli_node_get_ifname(node));
|
||||
|
||||
/**/
|
||||
ipcom_printf(" Sent Bytes : %lld"IP_LF, ipmipha_cli_node_get_stats_snd_octets64(node));
|
||||
ipcom_printf(" Sent Packets : %lld"IP_LF, ipmipha_cli_node_get_stats_snd_pkts64(node));
|
||||
ipcom_printf(" Receive Bytes : %lld"IP_LF, ipmipha_cli_node_get_stats_rcv_octets64(node));
|
||||
ipcom_printf(" Receive Packets : %lld"IP_LF, ipmipha_cli_node_get_stats_rcv_pkts64(node));
|
||||
|
||||
if ((str = ipmipha_cli_node_get_nai(node)) != IP_NULL)
|
||||
ipcom_printf(" Mobile NAI : %s"IP_LF, str);
|
||||
|
||||
if ((str = ipmipha_cli_node_get_nai_aaah(node)) != IP_NULL)
|
||||
ipcom_printf(" AAAH NAI : %s"IP_LF, str);
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Ip_u32 tmp;
|
||||
Ip_u32 flags = ipmipha_cli_binding_get_registration_flags(binding);
|
||||
|
||||
ipcom_printf(" Care-of Address %s:"IP_LF, ipmip_ntop_inet(proc, ipmipha_cli_binding_get_address(binding)));
|
||||
ipcom_printf(" Creation : %s"IP_LF, ipmip_ntop_tm(proc, ipmipha_cli_binding_get_created(binding)));
|
||||
ipcom_printf(" Last updated : %s"IP_LF, ipmip_ntop_tm(proc, ipmipha_cli_binding_get_last_updated(binding)));
|
||||
ipcom_printf(" Lifetime requested: %u"IP_LF, ipmipha_cli_binding_get_time_granted(binding));
|
||||
ipcom_printf(" Lifetime remaining: %u"IP_LF, ipmipha_cli_binding_get_time_remaining(binding));
|
||||
ipcom_printf(" Mode : %s"IP_LF, IP_BIT_ISTRUE(flags, IPMIP4_CODE_REQ_DECAPSULATION)? "co-located" : "foreign agent");
|
||||
|
||||
/**/
|
||||
ipcom_printf(" Sent Bytes# : %lld"IP_LF, ipmipha_cli_binding_get_stats_snd_octets64(binding));
|
||||
ipcom_printf(" Sent Packets# : %lld"IP_LF, ipmipha_cli_binding_get_stats_snd_pkts64(binding));
|
||||
ipcom_printf(" Receive Bytes# : %lld"IP_LF, ipmipha_cli_binding_get_stats_rcv_octets64(binding));
|
||||
ipcom_printf(" Receive Packets# : %lld"IP_LF, ipmipha_cli_binding_get_stats_rcv_pkts64(binding));
|
||||
ipcom_printf(" Broadcast : %s"IP_LF, IP_BIT_ISTRUE(flags, IPMIP4_CODE_REQ_BROADCAST)? "yes" : "no");
|
||||
ipcom_printf(" Reverse tunnel : %s"IP_LF, IP_BIT_ISTRUE(flags, IPMIP4_CODE_REQ_REVERSE_TUNNELING)? "yes" : "no");
|
||||
tmp = ipmipha_cli_binding_get_spi_mobile_foreign(binding);
|
||||
if (tmp)
|
||||
ipcom_printf(" SPI MH : %u"IP_LF, tmp);
|
||||
tmp = ipmipha_cli_binding_get_spi_foreign_home(binding);
|
||||
if (tmp)
|
||||
ipcom_printf(" SPI FH : %u"IP_LF, tmp);
|
||||
tmp = ipmipha_cli_binding_get_spi_mobile_AAA(binding);
|
||||
if (tmp)
|
||||
ipcom_printf(" SPI AAA : %u"IP_LF, tmp);
|
||||
tmp = ipmipha_cli_binding_get_tunnel_type(binding);
|
||||
ipcom_printf(" Tunnel type : %s"IP_LF, ipmip_util_tunnel_to_desc(tmp));
|
||||
|
||||
tmp = ipmipha_cli_binding_get_tunnel_flags(binding);
|
||||
ipcom_printf(" Reg. Revocation : %s"IP_LF, IP_BIT_ARESET(tmp, IPMIP4_TUNNELMODE_REVOCATION_CONFIRMED)? (IP_BIT_ISSET(flags, IPMIP4_TUNNELMODE_REVOCATION_INFORM)? "yes (inform)" : "yes") : "no");
|
||||
if (IP_BIT_ARESET(tmp, IPMIP4_TUNNELMODE_NAT_T_CONFIRMED))
|
||||
{
|
||||
ipcom_printf(" Nat traversal : yes"IP_LF);
|
||||
ipcom_printf(" Nat endpoint : %s"IP_LF, ipmip_ntop_inet(proc, ipmipha_cli_binding_get_tunnel_endpoint(binding)));
|
||||
ipcom_printf(" Nat port : %u"IP_LF, ipmipha_cli_binding_get_tunnel_port(binding));
|
||||
}
|
||||
else
|
||||
{
|
||||
ipcom_printf(" Nat traversal : no"IP_LF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IP_STATIC void
|
||||
ipmipha_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 == IPMIPHA_CMD_OP_REVOKE)
|
||||
ipmipha_cli_node_revoke(daemon, handle);
|
||||
else if (cmd == IPMIPHA_CMD_OP_DELETE)
|
||||
ipmipha_cli_node_delete(daemon, handle);
|
||||
else if ((node = ipmipha_cli_node_get(daemon, &nreq, handle)) != IP_NULL)
|
||||
{
|
||||
Ipmip_attr_iter_t riter;
|
||||
struct Ipmip_attr *binding;
|
||||
Ip_u32 num = 0;
|
||||
|
||||
/**/
|
||||
ipmip_attr_payload_iter_init(node, &riter);
|
||||
while ((binding = ipmipha_cli_binding_next(&riter)) != IP_NULL)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case IPMIPHA_CMD_OP_LIST:
|
||||
ipmipha_cmd_print_binding(proc, num, node, binding, verbose);
|
||||
break;
|
||||
case IPMIPHA_CMD_OP_SHOW:
|
||||
ipmipha_cmd_show_binding(proc, num, node, binding, verbose);
|
||||
break;
|
||||
}
|
||||
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
ipmip_cli_daemon_request_release(&nreq);
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_cmd_ha
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters: .
|
||||
* Returns: .
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipmipha_cmd_ha(int argc, char **argv)
|
||||
{
|
||||
Ipcom_getopt opt;
|
||||
int op_val;
|
||||
char *op;
|
||||
Ipmip_proc_t *proc = IP_NULL;
|
||||
Ipmip_cli_daemon_t daemon;
|
||||
Ipmip_cli_daemon_req_t req;
|
||||
int i;
|
||||
int used = 1;
|
||||
int vr = ipcom_proc_vr_get();
|
||||
int vr_new = vr;
|
||||
|
||||
daemon.fd = IP_INVALID_SOCKET;
|
||||
|
||||
ipmip_cli_daemon_request_init(&req);
|
||||
|
||||
proc = ipmip_proc_alloc();
|
||||
if (proc == IP_NULL)
|
||||
{
|
||||
ipcom_printf("ha: failed to create process context"IP_LF);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (argc < 2)
|
||||
goto usage;
|
||||
|
||||
if (argc >= 4 && ipcom_strcmp(argv[1], "-V") == 0)
|
||||
{
|
||||
used += 2;
|
||||
vr_new = ipcom_atoi(argv[2]);
|
||||
}
|
||||
|
||||
ipcom_proc_vr_set(vr_new);
|
||||
|
||||
/* Get a connection to the home agent. */
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
if (ipmipha_cli_connect(&daemon))
|
||||
break;
|
||||
ipcom_sleep(1);
|
||||
}
|
||||
|
||||
if (daemon.fd == IP_INVALID_SOCKET)
|
||||
{
|
||||
ipcom_printf("ha: failed to connect to home agent"IP_LF);
|
||||
ipmip_proc_destroy(proc);
|
||||
ipcom_proc_vr_set(vr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
op = argv[used];
|
||||
op_val = ipcom_cmd_str_to_key(ipmipha_cmd_ops, op);
|
||||
|
||||
if (op_val == -1)
|
||||
{
|
||||
if (ipmip4_cli_shell_cmd(argc - used + 1, argv + used - 1, proc, &daemon) == -1)
|
||||
{
|
||||
ipcom_printf("'%s' is an invalid operation"IP_LF, op);
|
||||
goto usage;
|
||||
}
|
||||
goto exit_out;
|
||||
}
|
||||
|
||||
ipcom_getopt_clear_r(&opt);
|
||||
|
||||
if (op_val == IPMIPHA_CMD_OP_LIST ||
|
||||
op_val == IPMIPHA_CMD_OP_SHOW ||
|
||||
op_val == IPMIPHA_CMD_OP_REVOKE ||
|
||||
op_val == IPMIPHA_CMD_OP_DELETE)
|
||||
{
|
||||
/* Show node information */
|
||||
Ip_bool all = IP_FALSE;
|
||||
Ip_bool verbose = IP_FALSE;
|
||||
const char *ifname = IP_NULL;
|
||||
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},
|
||||
{"ifname", 1, 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 - used, argv + used, "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:
|
||||
args++;
|
||||
ifname = opt.optarg;
|
||||
break;
|
||||
case 4:
|
||||
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 == IPMIPHA_CMD_OP_LIST)
|
||||
ipmipha_cmd_print_binding_fmt("Home Address",
|
||||
"Care of Address",
|
||||
"Interface",
|
||||
"Lifetime",
|
||||
"Flags");
|
||||
|
||||
if (args > 0)
|
||||
{
|
||||
if (all)
|
||||
ret = ipmipha_cli_node_list(&daemon, &req, IP_NULL, IP_NULL, 0);
|
||||
else if (args)
|
||||
ret = ipmipha_cli_node_list(&daemon, &req, nai, ifname, hoa);
|
||||
|
||||
if (ret == IPCOM_SUCCESS)
|
||||
{
|
||||
Ipmip_attr_iter_t riter;
|
||||
Ip_u32 handle;
|
||||
|
||||
/**/
|
||||
ipmip_cli_daemon_iter_request_init(&req, &riter);
|
||||
while ((handle = ipmipha_cli_handle_next(&riter)) != 0)
|
||||
ipmipha_cmd_handle_exec(proc, &daemon, handle, op_val, verbose);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = opt.optind + used; i < argc; i++)
|
||||
ipmipha_cmd_handle_exec(proc, &daemon, ipcom_strtoul(argv[i], IP_NULL, 0), op_val, verbose);
|
||||
}
|
||||
}
|
||||
else if (op_val == IPMIPHA_CMD_OP_START)
|
||||
ipmipha_cli_daemon_start(&daemon);
|
||||
else if (op_val == IPMIPHA_CMD_OP_STOP)
|
||||
ipmipha_cli_daemon_stop(&daemon);
|
||||
else if (op_val == IPMIPHA_CMD_OP_MUTE)
|
||||
ipmipha_cli_daemon_mute(&daemon);
|
||||
|
||||
ipmip_cli_daemon_disconnect(&daemon);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
ipmip_proc_destroy(proc);
|
||||
ipcom_proc_vr_set(vr);
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
ipmip_util_identprintf(proc, 0, "NAME"IP_LF);
|
||||
ipmip_util_identprintf(proc, 1, "ha - Displays Home Agent IPv4 bindings, statistics and status" IP_LF);
|
||||
ipmip_util_identprintf(proc, 0, "SYNOPSIS"IP_LF);
|
||||
ipmip_util_identprintf(proc, 1, "ha <command> [arguments]"IP_LF);
|
||||
ipmip_util_identprintf(proc, 0, "DESCRIPTION"IP_LF);
|
||||
ipmip_util_identprintf(proc, 1,
|
||||
"The ha command version %u.%u.%u is used to display current Home Agent MIPv4"IP_LF
|
||||
"bindings, statistics and status."IP_LF,
|
||||
(IPMIPHA_RELEASE / 10000) % 100, (IPMIPHA_RELEASE / 100) % 100, IPMIPHA_RELEASE % 100);
|
||||
ipmip_util_identprintf(proc, 0, "COMMANDS"IP_LF);
|
||||
ipmip_util_cmdprintf(proc, 1, "list [-a] [--nai=<nai>] [--ifname=<interface>] [--hoa=<home address>] [<handle>]", "Short list the specified binding(s)");
|
||||
ipmip_util_cmdprintf(proc, 1, "show [-a] [--verbose] [--nai=<nai>] [--ifname=<interface>] [--hoa=<home address>] [<handle>]", "Show the specified binding(s)");
|
||||
ipmip_util_cmdprintf(proc, 1, "revoke [-a] [--nai=<nai>] [--ifname=<interface>] [--hoa=<home address>] [<handle>]", "Revoke the specified binding(s)");
|
||||
ipmip_util_cmdprintf(proc, 1, "delete [-a] [--nai=<nai>] [--ifname=<interface>] [--hoa=<home address>] [<handle>]", "Delete the specified binding(s)");
|
||||
ipmip_util_identprintf(proc, 2, "-a All bindings"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "--nai=<nai> The network access name"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "--verbose Verbose output"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "--hoa=<home address> The home address"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "--ifname=<interface> The interface the binding is registered on"IP_LF);
|
||||
ipmip_util_identprintf(proc, 2, "handle=<handle number> The unique handle of this binding"IP_LF);
|
||||
ipmip4_cli_shell_usage(proc);
|
||||
|
||||
exit_out:
|
||||
ipmip_cli_daemon_disconnect(&daemon);
|
||||
ipmip_cli_daemon_request_release(&req);
|
||||
ipmip_proc_destroy(proc);
|
||||
ipcom_proc_vr_set(vr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,326 @@
|
||||
/* ipmipha_h.h - ipmipha_h.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha_h.h,v $ $Revision: 1.32 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmipha/src/ipmipha_h.h,v $
|
||||
* $Author: ulf $ $Date: 2009-06-08 11:05:50 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIPHA_H_H
|
||||
#define IPMIPHA_H_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
No description currently provided
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmipha_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <private/ipmip_cli.h>
|
||||
|
||||
#include <private/ipmip4_msgext.h>
|
||||
#include <private/ipmip4_auth.h>
|
||||
|
||||
#include "ipmipha_mib.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
enum
|
||||
{
|
||||
IPMIPHA_SPI_MN_HOA,
|
||||
IPMIPHA_SPI_MN_NAI,
|
||||
|
||||
IPMIPHA_SPI_MN_NONE = -1
|
||||
};
|
||||
|
||||
#define IPMIPHA_SHUTDOWN_ADV (1 << 0)
|
||||
#define IPMIPHA_SHUTDOWN_REG (1 << 1)
|
||||
#define IPMIPHA_SHUTDOWN_NODE (1 << 2)
|
||||
|
||||
#define IPMIPHA_SHUTDOWN_ALL (IPMIPHA_SHUTDOWN_ADV|IPMIPHA_SHUTDOWN_REG)
|
||||
|
||||
enum
|
||||
{
|
||||
IPMIPHA_FUNCTION_AAA = 0,
|
||||
IPMIPHA_FUNCTION_REGEXT,
|
||||
IPMIPHA_FUNCTION_MAX
|
||||
};
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
struct Ipmipha_data;
|
||||
struct Ipmipha_node_context;
|
||||
struct Ipmipha_route_context;
|
||||
struct Ipmipha_pktbuf;
|
||||
struct Ipmipha_iff;
|
||||
struct Ipmipha_node;
|
||||
struct Ipmipha_node_binding;
|
||||
struct Ipmip_cli_message;
|
||||
struct Ipmip_proc;
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Application datatypes
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
|
||||
|
||||
typedef void (*Ipmipha_extension_config_global_t)
|
||||
(
|
||||
struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
void *global_config,
|
||||
struct Ipmip_cli_message *request
|
||||
);
|
||||
|
||||
typedef void (*Ipmipha_extension_config_ifp_t)
|
||||
(
|
||||
struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
struct Ipmipha_iff *ifp,
|
||||
void *global_config,
|
||||
void *ifp_config,
|
||||
struct Ipmip_cli_message *request
|
||||
);
|
||||
|
||||
typedef int (*Ipmipha_extension_provide_t)
|
||||
(
|
||||
struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
void *global_config,
|
||||
void *ifp_config,
|
||||
void *node_config,
|
||||
struct Ipmipha_node *node
|
||||
);
|
||||
|
||||
typedef Ip_bool (*Ipmipha_extension_setup_t)
|
||||
(
|
||||
struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
int action,
|
||||
void *global_config,
|
||||
void *ifp_config,
|
||||
void *node_config,
|
||||
struct Ipmipha_node *node,
|
||||
struct Ipmip_cli_message *request
|
||||
);
|
||||
|
||||
typedef void (*Ipmipha_extension_pkt_req_mobile_home_t)
|
||||
(
|
||||
struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
void *global_config,
|
||||
void *ifp_config,
|
||||
void *node_config,
|
||||
struct Ipmipha_node *node,
|
||||
struct Ipmipha_pktbuf *req_pbuf,
|
||||
struct Ipmipha_pktbuf *rep_pbuf
|
||||
);
|
||||
|
||||
typedef void (*Ipmipha_extension_pkt_req_mobile_foreign_t)
|
||||
(
|
||||
struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
void *global_config,
|
||||
void *ifp_config,
|
||||
void *node_config,
|
||||
struct Ipmipha_node *node,
|
||||
struct Ipmipha_pktbuf *req_pbuf,
|
||||
struct Ipmipha_pktbuf *rep_pbuf
|
||||
);
|
||||
|
||||
typedef Ip_bool (*Ipmipha_extension_pkt_req_validate_t)
|
||||
(
|
||||
struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
void *global_config,
|
||||
void *ifp_config,
|
||||
void *node_config,
|
||||
struct Ipmipha_node *node,
|
||||
struct Ipmipha_pktbuf *pbuf
|
||||
);
|
||||
|
||||
typedef void (*Ipmipha_extension_pkt_req_accept_t)
|
||||
(
|
||||
struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
void *global_config,
|
||||
void *ifp_config,
|
||||
void *node_config,
|
||||
struct Ipmipha_node *node,
|
||||
struct Ipmipha_node_binding *binding,
|
||||
struct Ipmipha_pktbuf *pbuf
|
||||
);
|
||||
|
||||
typedef void (*Ipmipha_extension_pkt_rep_transport_t)
|
||||
(
|
||||
struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
void *global_config,
|
||||
void *ifp_config,
|
||||
void *node_config,
|
||||
struct Ipmipha_node *node,
|
||||
struct Ipmipha_pktbuf *req_pbuf,
|
||||
struct Ipmipha_pktbuf *rep_pbuf
|
||||
);
|
||||
|
||||
typedef struct Ipmipha_extension
|
||||
{
|
||||
const char *name;
|
||||
|
||||
Ip_u32 node_data_size;
|
||||
Ip_u32 ifp_data_size;
|
||||
Ip_u32 global_data_size;
|
||||
|
||||
/**/
|
||||
Ipmip_pktbuf_payload_t pktaux;
|
||||
|
||||
/* Callbacks */
|
||||
Ipmipha_extension_config_ifp_t config_ifp;
|
||||
Ipmipha_extension_config_global_t config_global;
|
||||
Ipmipha_extension_provide_t provide;
|
||||
Ipmipha_extension_setup_t setup;
|
||||
|
||||
Ipmipha_extension_pkt_req_mobile_home_t pkt_rep_mobile_home;
|
||||
Ipmipha_extension_pkt_req_validate_t pkt_req_validate;
|
||||
Ipmipha_extension_pkt_req_accept_t pkt_req_accept;
|
||||
Ipmipha_extension_pkt_req_mobile_foreign_t pkt_rep_mobile_foreign;
|
||||
|
||||
Ipmipha_extension_pkt_rep_transport_t pkt_rep_transport;
|
||||
|
||||
|
||||
/* Set by FA */
|
||||
Ip_u32 type;
|
||||
Ip_u32 func;
|
||||
Ip_u32 unique;
|
||||
} Ipmipha_extension_t;
|
||||
|
||||
|
||||
typedef struct Ipmipha_function_context
|
||||
{
|
||||
Ipmipha_extension_t *functions[32];
|
||||
Ip_u32 num;
|
||||
Ip_u32 node_data;
|
||||
Ip_u32 mask;
|
||||
} Ipmipha_function_context_t;
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Configuration IPMIPHA data
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
|
||||
/* All configuration collected */
|
||||
typedef struct Ipmipha_conf
|
||||
{
|
||||
Ipcom_list if_head;
|
||||
|
||||
void *extdata[IPMIPHA_FUNCTION_MAX][32];
|
||||
}
|
||||
Ipmipha_conf_t;
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Global IPMIPHA data
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipmipha_data
|
||||
{
|
||||
Ipmip4_context_t ipmip4;
|
||||
|
||||
struct Ipmipha_route_context *route;
|
||||
|
||||
struct Ipmip_context_id *idents;
|
||||
|
||||
/* Sockets */
|
||||
Ip_fd fd_ipd; /* ipd */
|
||||
|
||||
Ipmipha_conf_t *conf;
|
||||
|
||||
int ipnet_is_router;
|
||||
|
||||
/* MIB Registration Counters */
|
||||
Ipcom_mutex mibLock;
|
||||
struct Ipmipha_mib_haRegNodeCounters mibRegCounters;
|
||||
|
||||
int shutdown;
|
||||
|
||||
Ipmipha_function_context_t *extensions;
|
||||
Ip_u32 *extensions_node_data;
|
||||
}
|
||||
Ipmipha_data_t;
|
||||
|
||||
#define IPMIPHA_MIB_COUNTER_ADD(d,c,v) \
|
||||
do { \
|
||||
ipcom_mutex_lock((d)->mibLock); \
|
||||
(c) += (v); \
|
||||
ipcom_mutex_unlock((d)->mibLock); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmip4_msgext_vendor_parse_ext;
|
||||
|
||||
IP_GLOBAL void ipmipha_main(void);
|
||||
|
||||
IP_GLOBAL Ip_u32 ipmipha_context_register_extension(Ipmipha_extension_t *srv,
|
||||
int function);
|
||||
IP_GLOBAL void ipmipha_msgext_vendor_parse_ext_register(struct Ipmip4_msgext_vendor_parse_ext *pext);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,790 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha_if.c,v $ $Revision: 1.20.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmipha/src/ipmipha_if.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_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 <private/ipmip_dhcp.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 "ipmipha.h"
|
||||
#include "ipmipha_h.h"
|
||||
#include "ipmipha_attr_h.h"
|
||||
#include "ipmipha_if.h"
|
||||
#include "ipmipha_agent.h"
|
||||
#include "ipmipha_node.h"
|
||||
#include "ipmipha_route.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_destroy_tunnel
|
||||
*===========================================================================
|
||||
* Description: Destroy a particular tunnel.
|
||||
* Parameters: tunnel - The tunnel to destroy.
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmipha_if_destroy_tunnel(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmipha_iff_tunnel_t *iff)
|
||||
{
|
||||
/* No tunnel, don't bother */
|
||||
if (iff->iff.ipmip.ifindex == 0)
|
||||
return;
|
||||
|
||||
|
||||
/* Add the policy rule */
|
||||
ipmip_netlink_inX_rule(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
IP_AF_INET,
|
||||
IP_RTM_DELRULE,
|
||||
data->route->inbound_table,
|
||||
IPMIPHA_ROUTE_PRID(0),
|
||||
iff->iff.ipmip.ifindex,
|
||||
IP_NULL,
|
||||
0,
|
||||
IP_NULL,
|
||||
0,
|
||||
0,
|
||||
IP_FIB_RULE_FIND_SADDR);
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(data);
|
||||
IPMIP_UNUSED_PARAMETER(proc);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_if_create_tunnel
|
||||
*===========================================================================
|
||||
* Description: Create a specific tunnel for the provided interface
|
||||
* Parameters: data - The FA configuration data structure
|
||||
* iff - The interface in question.
|
||||
* iname - Instance name
|
||||
* num - Configuration instance num
|
||||
* remote - The remote end
|
||||
* identity - The identity
|
||||
* tunnel_type - Kind of tunnel.
|
||||
* Returns: A newly allocated tunnel instance
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ipmipha_iff_tunnel_t *
|
||||
ipmipha_if_create_tunnel(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmipha_iff_t *iff,
|
||||
Ip_u32 ifindex,
|
||||
Ip_u32 remote,
|
||||
Ip_u8 identity,
|
||||
Ip_u8 tunnel_type)
|
||||
{
|
||||
Ipmipha_iff_tunnel_t *tiff;
|
||||
char ifname[IP_IFNAMSIZ + 1];
|
||||
|
||||
/* Create the name */
|
||||
ipcom_snprintf(ifname,
|
||||
sizeof(ifname),
|
||||
"%s%dha%x",
|
||||
ipmip_util_tunnel_to_bsdname(tunnel_type),
|
||||
tunnel_type,
|
||||
ifindex);
|
||||
|
||||
tiff = (Ipmipha_iff_tunnel_t*)ipmip4_if_alloc_tunnel(&data->ipmip4,
|
||||
proc,
|
||||
sizeof(*tiff),
|
||||
ifname,
|
||||
iff->iff.ifaddr,
|
||||
data->ipmip4.pkt->s_udp_out.sin_port,
|
||||
remote,
|
||||
identity,
|
||||
tunnel_type,
|
||||
iff->reordering,
|
||||
(Ipmip_if_cleanup_t )ipmipha_if_destroy_tunnel);
|
||||
|
||||
return tiff;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_if_delete
|
||||
*===========================================================================
|
||||
* Description: Delete an interface
|
||||
* Parameters: iff - The interface to delete.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmipha_if_delete(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmipha_iff_t *iff)
|
||||
{
|
||||
/* Free the final resources */
|
||||
int i;
|
||||
|
||||
ipmip4_auth_context_destroy(iff->security.spi_ctx);
|
||||
|
||||
/* Free the SPI route tables */
|
||||
ipmip4_auth_spi_table_destroy(iff->security.spi_fa);
|
||||
ipmip4_auth_spi_table_destroy(iff->security.spi_mn);
|
||||
ipmip4_auth_spi_hash_destroy(iff->security.spi_nai);
|
||||
|
||||
|
||||
if (iff->nai_ha)
|
||||
ipcom_free(iff->nai_ha);
|
||||
|
||||
/**/
|
||||
if (iff->security.spi_mn_lookup_order)
|
||||
ipcom_free(iff->security.spi_mn_lookup_order);
|
||||
|
||||
/* Destroy the tunnels */
|
||||
for (i = 0; i < IPMIP_TUNNELTYPE_MAX; i++)
|
||||
{
|
||||
if (iff->tunnels[i] != IP_NULL)
|
||||
ipmip_if_free(&data->ipmip4.ipmip, proc, &iff->tunnels[i]->iff.ipmip);
|
||||
}
|
||||
|
||||
ipmip_dhcp_rtab_destroy(iff->dhcp_rtab);
|
||||
|
||||
/* Destroy the nodes */
|
||||
ipmipha_node_context_destroy(data, proc, iff->nodes);
|
||||
|
||||
/* Destroy the lock */
|
||||
if (iff->if_lock)
|
||||
ipmip_timer_lock_destroy(&data->ipmip4.ipmip, proc, iff->if_lock);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_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 Ipmipha_iff_t *
|
||||
ipmipha_if_alloc(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
const char *ifname)
|
||||
{
|
||||
/* Allocate an interface structure */
|
||||
Ipmipha_iff_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->ipmip4.ipmip,
|
||||
proc,
|
||||
"Configuration failed, due to unknown interface '%s'",
|
||||
ifname));
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
/* Allocate the structure */
|
||||
iff = (Ipmipha_iff_t*)ipmip4_if_alloc(&data->ipmip4,
|
||||
proc,
|
||||
sizeof(*iff),
|
||||
ifname,
|
||||
ifindex,
|
||||
IPMIP_IF_TYPE_GENERIC,
|
||||
IPMIPHA_IFF_IDENTITY_HA,
|
||||
(Ipmip_if_cleanup_t )ipmipha_if_delete);
|
||||
|
||||
/* Sanity */
|
||||
if (iff == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
/* Return the interface structure */
|
||||
return iff;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_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
|
||||
ipmipha_if_configure(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmipha_iff_t *iff,
|
||||
Ipmipha_conf_t *conf)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(conf);
|
||||
|
||||
/* 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->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->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->ipmip4.ipmip,
|
||||
proc,
|
||||
"auto-configuring: interface '%s' configured to use %s",
|
||||
iff->iff.ipmip.ifname,
|
||||
ipmip_ntop_inet(proc, iff->iff.ifaddr)));
|
||||
}
|
||||
|
||||
/* Get MAC address. */
|
||||
if (ipmip_if_resolve_lla(&data->ipmip4.ipmip, proc, &iff->iff.ipmip) == IP_FALSE)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Unable to retrieve link-layer address for interface '%s'",
|
||||
iff->iff.ipmip.ifname));
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/* Need to install the routing policy forcing traffic to the fwd table */
|
||||
{
|
||||
int i;
|
||||
|
||||
/*!!CALLED ONCE PER INTERFACE?? ADV_FD ONE PER INTERFACE?? Listen to solicitations sent to 224.0.0.1 */
|
||||
if (!ipmip4_pkt_icmp_join(&data->ipmip4, proc, ip_htonl(IP_INADDR_ALLHOSTS_GROUP), iff->iff.ipmip.ifindex))
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Unable to join all hosts group on interface '%s'",
|
||||
iff->iff.ipmip.ifname));
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/* Listen to solicitations sent to 224.0.0.2 */
|
||||
if (!ipmip4_pkt_icmp_join(&data->ipmip4, proc, ip_htonl(IP_INADDR_ALLRTRS_GROUP), iff->iff.ipmip.ifindex))
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Unable to join all routers group on interface '%s'",
|
||||
iff->iff.ipmip.ifname));
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/* Listen to solicitations sent to the Mobile-Agents multicast group 224.0.0.11 */
|
||||
if (!ipmip4_pkt_icmp_join(&data->ipmip4, proc, ip_htonl(IP_INADDR_ALLMA_GROUP), iff->iff.ipmip.ifindex))
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Unable to join all mobile agents group on interface '%s'",
|
||||
iff->iff.ipmip.ifname));
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
if (iff->adv_address != ip_htonl(IP_INADDR_ALLHOSTS_GROUP) &&
|
||||
iff->adv_address != ip_htonl(IP_INADDR_ALLRTRS_GROUP) &&
|
||||
iff->adv_address != ip_htonl(IP_INADDR_ALLMA_GROUP) &&
|
||||
IP_IN_CLASSD(iff->adv_address))
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Bad advertisement group %s on interface '%s'",
|
||||
ipmip_ntop_inet(proc, iff->adv_address),
|
||||
iff->iff.ipmip.ifname));
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/* IPIP tunnel */
|
||||
for (i = 0; i < IPMIP_TUNNELTYPE_MAX; i++)
|
||||
{
|
||||
if (iff->tunnel.enabled[i])
|
||||
{
|
||||
iff->tunnels[i] = ipmipha_if_create_tunnel(data,
|
||||
proc,
|
||||
iff,
|
||||
iff->iff.ipmip.ifindex,
|
||||
IP_INADDR_ANY,
|
||||
IPMIPHA_IFF_IDENTITY_HA_TUNNEL,
|
||||
i);
|
||||
/**/
|
||||
if (iff->tunnels[i] == IP_NULL)
|
||||
iff->tunnel.enabled[i] = IP_FALSE;
|
||||
else
|
||||
{
|
||||
/* Add the policy rule */
|
||||
ipmip_netlink_inX_rule(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
IP_AF_INET,
|
||||
IP_RTM_NEWRULE,
|
||||
data->route->inbound_table,
|
||||
IPMIPHA_ROUTE_PRID(0),
|
||||
iff->tunnels[i]->iff.ipmip.ifindex,
|
||||
IP_NULL,
|
||||
0,
|
||||
IP_NULL,
|
||||
0,
|
||||
0,
|
||||
IP_FIB_RULE_FIND_SADDR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_if_output_timeout
|
||||
*===========================================================================
|
||||
* Description: Periodically send RtAdv.
|
||||
* Parameters: iff - The interface we're sending on.
|
||||
* Returns: IP_TRUE
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipmipha_if_advert_output_timeout(int event,
|
||||
Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmipha_iff_t *iff,
|
||||
void *extra)
|
||||
{
|
||||
IPMIP_UNUSED_PARAMETER(extra);
|
||||
if (event == IPMIP_TIMER_EVENT_RUN)
|
||||
{
|
||||
/* Output it */
|
||||
if (IP_BIT_ISFALSE(data->shutdown, IPMIPHA_SHUTDOWN_ADV))
|
||||
ipmipha_agent_advert_output(data, proc, iff, IP_NULL, IP_NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Do nothing on cancellation */
|
||||
}
|
||||
|
||||
return IPMIP_TIMER_RET_REINSERT;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_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
|
||||
ipmipha_if_create(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmipha_conf_t *conf,
|
||||
const char *ifname)
|
||||
{
|
||||
Ipmipha_iff_t *iff;
|
||||
unsigned si;
|
||||
int i;
|
||||
|
||||
|
||||
/* Try create the interface in question */
|
||||
if ((iff = ipmipha_if_alloc(data,proc,ifname)) == IP_NULL)
|
||||
return IP_FALSE;
|
||||
|
||||
iff->nodes = ipmipha_node_context_alloc(data, proc);
|
||||
if (iff->nodes == IP_NULL)
|
||||
goto fail;
|
||||
|
||||
iff->dhcp_rtab = ipmip_dhcp_rtab_create(&data->ipmip4.ipmip, proc, IP_NULL);
|
||||
|
||||
/* Store it */
|
||||
ipcom_list_insert_first(&conf->if_head, &iff->iff.ipmip.next);
|
||||
|
||||
/* Initialize the lock */
|
||||
iff->if_lock = ipmip_timer_lock_alloc(&data->ipmip4.ipmip, proc, IP_NULL, IP_NULL);
|
||||
|
||||
/* Create the security context */
|
||||
iff->security.spi_ctx = ipmip4_auth_context_create();
|
||||
|
||||
iff->security.spi_fa = ipmip4_auth_spi_table_create(iff->security.spi_ctx);
|
||||
iff->security.spi_mn = ipmip4_auth_spi_table_create(iff->security.spi_ctx);
|
||||
iff->security.spi_nai = ipmip4_auth_spi_hash_create(iff->security.spi_ctx);
|
||||
|
||||
/* Do the SPI tables */
|
||||
iff->security.spi_fa_lookup_required = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_FALSE, "ipmipha.fa.sa.lookup.required"), "ipmipha.if.%s.fa.sa.lookup.required", iff->iff.ipmip.ifname);
|
||||
iff->security.spi_mn_lookup_required = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_FALSE, "ipmipha.mn.sa.lookup.required"), "ipmipha.if.%s.mn.sa.lookup.required", iff->iff.ipmip.ifname);
|
||||
|
||||
/* Read SPI's */
|
||||
ipmip_sysvar_foreach(proc,
|
||||
(Ipmip_sysvar_foreach_t) ipmip4_sysext_foreach_spi,
|
||||
iff->security.spi_ctx,
|
||||
"ipmipha.if.%s.spi.*", iff->iff.ipmip.ifname);
|
||||
ipmip_sysvar_foreach(proc,
|
||||
(Ipmip_sysvar_foreach_t) ipmip4_sysext_foreach_spi,
|
||||
iff->security.spi_ctx,
|
||||
"ipmipha.spi.*");
|
||||
|
||||
ipmip_sysvar_foreach(proc,
|
||||
(Ipmip_sysvar_foreach_t) ipmip4_sysext_foreach_spiroute,
|
||||
iff->security.spi_fa,
|
||||
"ipmipha.if.%s.fa.sa.address.*", iff->iff.ipmip.ifname);
|
||||
ipmip_sysvar_foreach(proc,
|
||||
(Ipmip_sysvar_foreach_t) ipmip4_sysext_foreach_spiroute,
|
||||
iff->security.spi_fa,
|
||||
"ipmipha.fa.sa.address.*");
|
||||
|
||||
|
||||
ipmip_sysvar_foreach(proc,
|
||||
(Ipmip_sysvar_foreach_t) ipmip4_sysext_foreach_spiroute,
|
||||
iff->security.spi_mn,
|
||||
"ipmipha.if.%s.mn.sa.address.*", iff->iff.ipmip.ifname);
|
||||
ipmip_sysvar_foreach(proc,
|
||||
(Ipmip_sysvar_foreach_t) ipmip4_sysext_foreach_spiroute,
|
||||
iff->security.spi_mn,
|
||||
"ipmipha.mn.sa.address.*");
|
||||
|
||||
|
||||
ipmip_sysvar_foreach(proc,
|
||||
(Ipmip_sysvar_foreach_t) ipmip4_sysext_foreach_spihash,
|
||||
iff->security.spi_nai,
|
||||
"ipmipha.if.%s.mn.sa.nai.*", iff->iff.ipmip.ifname);
|
||||
ipmip_sysvar_foreach(proc,
|
||||
(Ipmip_sysvar_foreach_t) ipmip4_sysext_foreach_spihash,
|
||||
iff->security.spi_nai,
|
||||
"ipmipha.mn.sa.nai.*");
|
||||
|
||||
/* Initialize ADV timeout */
|
||||
IPMIP_TIMER_INIT(&iff->adv_timer);
|
||||
|
||||
/* Get foreign agent addresses. Reachable by foreign subnets. */
|
||||
ipmip_sysvar_inet(0, &iff->iff.ifaddr, IP_NULL, "ipmipha.if.%s.homeagent", iff->iff.ipmip.ifname);
|
||||
|
||||
/* Backward compatibility */
|
||||
iff->lifetime = (Ip_u16)ipmip_sysvar_ulong(ipmip_sysvar_ulong(ipmip_sysvar_ulong(0, "ipmipha.lifetime"), "ipmipha.reg_lifetime"), "ipmipha.if.%s.lifetime", iff->iff.ipmip.ifname);
|
||||
if (iff->lifetime == 0)
|
||||
iff->lifetime = 0xffff;
|
||||
|
||||
iff->replay_diff = ipmip_sysvar_long(ipmip_sysvar_long(ipmip_sysvar_long(0, "ipmipha.timestamp_replay_protection_max_diff"), "ipmipha.timestampreplayprotectionmaxdiff"), "ipmipha.if.%s.timestamp_replay_protection_max_diff", iff->iff.ipmip.ifname);
|
||||
|
||||
if ((iff->nai_ha = (Ipmip4_msgext_uhdr_t *)ipmip4_sysext_nai_ha("ipmipha.if.%s.nai.ha", iff->iff.ipmip.ifname)) == IP_NULL)
|
||||
iff->nai_ha = (Ipmip4_msgext_uhdr_t *)ipmip4_sysext_nai_ha("ipmipha.nai.ha");
|
||||
iff->mn_nai_require = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_FALSE, "ipmipha.mn.nai.required"), "ipmipha.if.%s.mn.nai.required", iff->iff.ipmip.ifname);
|
||||
|
||||
/* Resolve the home netmask */
|
||||
if (!ipmip_sysvar_inet(ip_htonl(0xffffff00), &iff->home_netmask, IP_NULL, "ipmipha.if.%s.homenetmask", iff->iff.ipmip.ifname))
|
||||
ipmip_sysvar_inet(ip_htonl(0xffffff00), &iff->home_netmask, IP_NULL, "ipmipha.homenetmask");
|
||||
|
||||
if ((iff->security.spi_mn_lookup_order = ipmip_sysvar_array(ipmipha_attr_lookup, "ipmipha.if.%s.mn.sa.lookup.order", iff->iff.ipmip.ifname)) == IP_NULL)
|
||||
iff->security.spi_mn_lookup_order = ipmip_sysvar_array(ipmipha_attr_lookup, "ipmipha.mn.sa.lookup.order");
|
||||
|
||||
if (iff->security.spi_mn_lookup_order == IP_NULL)
|
||||
{
|
||||
iff->security.spi_mn_lookup_order = ipcom_calloc(3, sizeof(int));
|
||||
if (iff->security.spi_mn_lookup_order == IP_NULL)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Failed to allocate memory required for lookup order structure",
|
||||
iff->iff.ipmip.ifname));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/**/
|
||||
iff->security.spi_mn_lookup_order[0] = IPMIPHA_SPI_MN_HOA;
|
||||
iff->security.spi_mn_lookup_order[1] = IPMIPHA_SPI_MN_NAI;
|
||||
iff->security.spi_mn_lookup_order[2] = IPMIPHA_SPI_MN_NONE;
|
||||
}
|
||||
|
||||
/* Get ADV lifetime */
|
||||
iff->adv_lifetime = (Ip_u16)ipmip_sysvar_ulong(ipmip_sysvar_ulong(50, "ipmipha.adv_lifetime"), "ipmipha.if.%s.adv_lifetime", iff->iff.ipmip.ifname);
|
||||
|
||||
/* Get ADV interval */
|
||||
iff->adv_interval = ipmip_sysvar_long(ipmip_sysvar_long(10, "ipmipha.adv_interval"), "ipmipha.if.%s.adv_interval", iff->iff.ipmip.ifname);
|
||||
|
||||
/* Get ADV address */
|
||||
if (!ipmip_sysvar_inet(ip_htonl(IP_INADDR_ALLMA_GROUP), &iff->adv_address, IP_NULL, "ipmipha.if.%s.adv_address", iff->iff.ipmip.ifname))
|
||||
ipmip_sysvar_inet(ip_htonl(IP_INADDR_ALLMA_GROUP), &iff->adv_address, IP_NULL, "ipmipha.adv_address");
|
||||
|
||||
if (iff->adv_address == 0)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Bad advertisement group %s on interface '%s'",
|
||||
ipmip_ntop_inet(proc, iff->adv_address),
|
||||
iff->iff.ipmip.ifname));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* NAT-T configuration */
|
||||
iff->nat_t = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_TRUE, "ipmipha.nat_t.enabled"), "ipmipha.if.%s.nat_t.enabled", iff->iff.ipmip.ifname);
|
||||
iff->nat_t_keepalive = (Ip_u16)ipmip_sysvar_ulong(ipmip_sysvar_ulong(0, "ipmipha.nat_t.keepalive"), "ipmipha.if.%s.nat_t.keepalive", iff->iff.ipmip.ifname);
|
||||
|
||||
/* Do we require foreign agent authentication */
|
||||
iff->fa_auth = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_FALSE, "ipmipha.fa_auth"), "ipmipha.if.%s.fa_auth", iff->iff.ipmip.ifname);
|
||||
|
||||
/* Do we require foreign agent authentication */
|
||||
iff->reordering = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_FALSE, "ipmipha.tunnel.reordering"), "ipmipha.if.%s.tunnel.reordering", iff->iff.ipmip.ifname);
|
||||
|
||||
/* Reverse tunneling state? */
|
||||
iff->tunnel.reverse = ipmip_sysvar_mode(ipmip_sysvar_mode(IPMIP_SYSVAR_MODE_OPTIONAL, "ipmipha.tunnel.reverse"), "ipmipha.if.%s.tunnel.reverse", iff->iff.ipmip.ifname);
|
||||
|
||||
/**/
|
||||
iff->tunnel.enabled[IPMIP_TUNNELTYPE_NONE] = IP_TRUE;
|
||||
|
||||
/* IPIP allowed */
|
||||
iff->tunnel.enabled[IPMIP_TUNNELTYPE_IPIP] = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_TRUE, "ipmipha.tunnel.ipip"), "ipmipha.if.%s.tunnel.ipip", iff->iff.ipmip.ifname);
|
||||
|
||||
/* GRE allowed? */
|
||||
iff->tunnel.enabled[IPMIP_TUNNELTYPE_GRE] = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_TRUE, "ipmipha.tunnel.gre"), "ipmipha.if.%s.tunnel.gre", iff->iff.ipmip.ifname);
|
||||
|
||||
/* MINENC allowed? */
|
||||
iff->tunnel.enabled[IPMIP_TUNNELTYPE_MINENC] = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_TRUE, "ipmipha.tunnel.minenc"), "ipmipha.if.%s.tunnel.minenc", iff->iff.ipmip.ifname);
|
||||
|
||||
/* Simultaneous bindings */
|
||||
iff->simbind_enabled = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_TRUE, "ipmipha.simbind.enable"), "ipmipha.if.%s.simbind.enable", iff->iff.ipmip.ifname);
|
||||
iff->simbind_max = ipmip_sysvar_ulong(ipmip_sysvar_ulong(3, "ipmipha.simbind.max"), "ipmipha.if.%s.simbind.max", iff->iff.ipmip.ifname);
|
||||
|
||||
iff->revocation = ipmip_sysvar_bool(ipmip_sysvar_bool(IP_TRUE, "ipmipha.revocation.enabled"), "ipmipha.if.%s.revocation.enabled", iff->iff.ipmip.ifname);
|
||||
iff->revocation_inform = ipmip_sysvar_mode(ipmip_sysvar_mode(IPMIP_SYSVAR_MODE_OPTIONAL, "ipmipha.revocation.inform"), "ipmipha.if.%s.revocation.inform", iff->iff.ipmip.ifname);
|
||||
|
||||
if (!ipmipha_if_configure(data, proc, iff, conf))
|
||||
goto fail;
|
||||
|
||||
iff->ha_subbrd = iff->iff.ifaddr | ~iff->home_netmask;
|
||||
iff->ha_netbrd = iff->iff.ifaddr | ~IP_NETMASK(iff->iff.ifaddr);
|
||||
|
||||
/* Do the external parsing */
|
||||
|
||||
/* Do the external parsing */
|
||||
for (i = IPMIPHA_FUNCTION_MAX - 1; i >= 0; i--)
|
||||
{
|
||||
for (si = 0; si < data->extensions[i].num; si++)
|
||||
{
|
||||
if (data->extensions[i].functions[si]->config_ifp != IP_NULL)
|
||||
{
|
||||
if (data->extensions[i].functions[si]->ifp_data_size)
|
||||
{
|
||||
iff->extdata[i][si] = ipcom_calloc(1, data->extensions[i].functions[si]->ifp_data_size);
|
||||
(*data->extensions[i].functions[si]->config_ifp) (data, proc, IPMIP_CALLBACK_CONFIG_READ, iff, conf->extdata[i][si], iff->extdata[i][si], IP_NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return IP_TRUE;
|
||||
fail:
|
||||
ipmip_if_free(&data->ipmip4.ipmip, proc, &iff->iff.ipmip);
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_if_start
|
||||
*===========================================================================
|
||||
* Description: Start interfaces for a specified configuration.
|
||||
* Parameters: data - The FA entity.
|
||||
* proc - Current process.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmipha_if_start(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
Ipmipha_iff_t *iff;
|
||||
|
||||
if (data->conf == IP_NULL)
|
||||
return;
|
||||
|
||||
/* free interface list */
|
||||
for (iff = IPCOM_LIST_FIRST(&data->conf->if_head); iff != IP_NULL; iff = IPCOM_LIST_NEXT(&iff->iff.ipmip.next))
|
||||
{
|
||||
/* Is it activated? */
|
||||
if (iff->adv_interval > 0)
|
||||
{
|
||||
ipmip_timer_request(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
&iff->adv_timer,
|
||||
iff->if_lock,
|
||||
(Ipmip_timer_func_t)ipmipha_if_advert_output_timeout,
|
||||
iff,
|
||||
IP_NULL,
|
||||
iff->adv_interval * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipfa_if_start
|
||||
*===========================================================================
|
||||
* Description: Start an interface for a specified configuration.
|
||||
* Parameters: data - The FA entity.
|
||||
* proc - Current process.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmipha_if_stop(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmipha_conf_t *conf)
|
||||
{
|
||||
Ipmipha_iff_t *iff;
|
||||
|
||||
/* Send instant RtAdv on all active interfaces */
|
||||
while (IP_NULL != (iff = IPCOM_LIST_FIRST(&conf->if_head)))
|
||||
{
|
||||
int i;
|
||||
unsigned si;
|
||||
|
||||
for (i = IPMIPHA_FUNCTION_MAX - 1; i >= 0; i--)
|
||||
{
|
||||
for (si = 0; si < data->extensions[i].num; si++)
|
||||
{
|
||||
if (data->extensions[i].functions[si]->config_ifp != IP_NULL)
|
||||
{
|
||||
if (iff->extdata[i][si])
|
||||
{
|
||||
(*data->extensions[i].functions[si]->config_ifp) (data, proc, IPMIP_CALLBACK_CONFIG_FREE, iff, conf->extdata[i][si], iff->extdata[i][si], IP_NULL);
|
||||
ipcom_free(iff->extdata[i][si]);
|
||||
iff->extdata[i][si] = IP_NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ipmip_if_free(&data->ipmip4.ipmip, proc, &iff->iff.ipmip);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,244 @@
|
||||
/* ipmipha_if.h - ipmipha_if.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha_if.h,v $ $Revision: 1.13 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmipha/src/ipmipha_if.h,v $
|
||||
* $Author: ulf $ $Date: 2009-06-08 11:05:50 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIPHA_IFF_H
|
||||
#define IPMIPHA_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
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIPHA_IFF_IDENTITY_HA (0)
|
||||
#define IPMIPHA_IFF_IDENTITY_HA_TUNNEL (1)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmipha_data;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmipha_node_context;
|
||||
|
||||
typedef struct Ipmipha_iff_tunnel
|
||||
{
|
||||
Ipmip4_if_t iff;
|
||||
}
|
||||
Ipmipha_iff_tunnel_t;
|
||||
|
||||
|
||||
typedef struct Ipmipha_iff_tunnel_conf
|
||||
{
|
||||
Ip_u8 reverse; /* 0: Disabled; 1: Optional; 2: Required */
|
||||
Ip_bool enabled[IPMIP_TUNNELTYPE_MAX + 1];
|
||||
}
|
||||
Ipmipha_iff_tunnel_conf_t;
|
||||
|
||||
typedef struct Ipmipha_iff_security_conf
|
||||
{
|
||||
/* SPI lookup tables */
|
||||
Ipmip4_auth_context_t *spi_ctx;
|
||||
Ipmip4_auth_spi_table_t *spi_fa; /* FA SPI */
|
||||
Ipmip4_auth_spi_table_t *spi_mn; /* MN SPI */
|
||||
Ipmip4_auth_spi_hash_t *spi_nai; /* MN SPI NAI */
|
||||
|
||||
/* Required verifications */
|
||||
Ip_bool spi_mn_lookup_required;
|
||||
Ip_bool spi_fa_lookup_required;
|
||||
int *spi_mn_lookup_order;
|
||||
} Ipmipha_iff_security_conf_t;
|
||||
|
||||
struct Ipmip_dhcp_rtab;
|
||||
/* one per interface */
|
||||
typedef struct Ipmipha_iff
|
||||
{
|
||||
Ipmip4_if_t iff;
|
||||
|
||||
struct Ipmip_dhcp_rtab *dhcp_rtab;
|
||||
|
||||
Ip_u32 home_netmask;
|
||||
Ip_u32 ha_subbrd; /* subnet broadcast = ip | ~netmask (e.g. ip/16 -> 10.1.255.255) */
|
||||
Ip_u32 ha_netbrd; /* network broadcast = ip | ~IP_NETMASK(ip) (e.g. ip/16 -> 10.255.255.255) */
|
||||
Ip_u16 adv_lifetime;
|
||||
Ip_u16 adv_seq;
|
||||
int adv_interval;
|
||||
Ip_u32 adv_address; /* constant 255.255.255.255 or 224.0.0.X (from config) */
|
||||
Ip_bool fa_auth;
|
||||
Ip_bool revocation; /* 0: Disabled; 1: Enabled */
|
||||
Ip_bool reordering; /* 0: Disabled; 1: Enabled */
|
||||
Ip_bool simbind_enabled;
|
||||
Ip_u32 simbind_max;
|
||||
Ip_u32 replay_diff;
|
||||
|
||||
Ip_u16 lifetime;
|
||||
|
||||
Ipmip4_msgext_uhdr_t *nai_ha;
|
||||
Ip_bool mn_nai_require;
|
||||
|
||||
Ipmip_timer_t adv_timer;
|
||||
Ipmip_timer_lock_t *if_lock;
|
||||
|
||||
/* Ipcom_tmo2 adv_timeout; */
|
||||
Ip_u8 revocation_inform; /* 0: Disabled; 1: Enabled */
|
||||
Ip_u8 nat_t;
|
||||
Ip_u16 nat_t_keepalive;
|
||||
|
||||
|
||||
/* */
|
||||
Ipmipha_iff_tunnel_conf_t tunnel;
|
||||
Ipmipha_iff_security_conf_t security;
|
||||
|
||||
struct Ipmipha_node_context *nodes;
|
||||
|
||||
Ipmipha_iff_tunnel_t *tunnels[IPMIP_TUNNELTYPE_MAX + 1];
|
||||
void *extdata[IPMIPHA_FUNCTION_MAX][32];
|
||||
}
|
||||
Ipmipha_iff_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmipha_if_create - ipmipha_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 ipmipha_if_create
|
||||
(
|
||||
struct Ipmipha_data *data,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmipha_conf_t *conf,
|
||||
const char *ifname
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmipha_if_start - ipmipha_if_start
|
||||
*
|
||||
* Start interfaces for a specified configuration.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* The FA entity.
|
||||
* \i proc
|
||||
* Current process.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmipha_if_start
|
||||
(
|
||||
struct Ipmipha_data *data,
|
||||
struct Ipmip_proc *proc
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmipha_if_stop - ipmipha_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 ipmipha_if_stop
|
||||
(
|
||||
struct Ipmipha_data *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipha_conf *conf
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,723 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha_main.c,v $ $Revision: 1.9.16.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmipha/src/ipmipha_main.c,v $
|
||||
* $Author: jsheng $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Niklas Lundberg <n@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
*******************************************************************************
|
||||
*
|
||||
* Legend:
|
||||
* HA = Home agent
|
||||
* MN = Mobile node
|
||||
* FA = Foreign agent
|
||||
* CN = Correspondent node (someone on the internet the mobile node talks to
|
||||
* via the HA)
|
||||
* COA = Care-of address
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipmipha_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_sysvar.h>
|
||||
#include <ipcom_syslog.h>
|
||||
|
||||
#include <ipmip.h>
|
||||
#include <private/ipmip_timer.h>
|
||||
#include <private/ipmip_sysvar.h>
|
||||
#include <private/ipmip_cli.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 <private/ipmip4_pktbuf.h>
|
||||
#include <private/ipmip4_diameter.h>
|
||||
|
||||
#include "ipmipha.h"
|
||||
#include "ipmipha_h.h"
|
||||
#include "ipmipha_attr_h.h"
|
||||
#include "ipmipha_if.h"
|
||||
#include "ipmipha_node.h"
|
||||
#include "ipmipha_reg.h"
|
||||
#include "ipmipha_agent.h"
|
||||
#include "ipmipha_route.h"
|
||||
#include "ipmipha_pktbuf.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Private Application datatypes
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Registration request and reply
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmipha_rtmsg
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC Ip_err ipmipha_create(void);
|
||||
IP_PUBLIC Ip_err ipmipha_start(void);
|
||||
IP_PUBLIC Ip_err ipmipha_init(void);
|
||||
IP_PUBLIC Ip_err ipmipha_exit(void);
|
||||
IP_PUBLIC Ip_err ipmipha_configure(void);
|
||||
|
||||
IP_PUBLIC const char *ipmipha_version(void);
|
||||
|
||||
#ifdef IPSNMP
|
||||
IP_EXTERN Ip_err ipmipha_mip_mib_init(void);
|
||||
IP_EXTERN Ip_err ipmip4_mip_mib_init(void);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC IPCOM_PROCESS(ipmipha_proc);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Global IPMIPHA data
|
||||
*===========================================================================
|
||||
* All global IPMIPHA data is located in this structure.
|
||||
*/
|
||||
static int ipmipha_instances = 0;
|
||||
|
||||
static Ipcom_once_t ipmipha_extensions_once = IPCOM_ONCE_INIT;
|
||||
static Ipmipha_function_context_t ipmipha_extensions[IPMIPHA_FUNCTION_MAX];
|
||||
static Ip_u32 ipmipha_extensions_node_data = 0;
|
||||
static Ipcom_list ipmipha_msgext_vendor_extensions;
|
||||
static Ipmip_pktbuf_pktaux_t ipmipha_pktaux;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC Ip_err
|
||||
ipmipha_main_once_init(void *unused)
|
||||
{
|
||||
int f;
|
||||
|
||||
IPMIP_UNUSED_PARAMETER(unused);
|
||||
|
||||
/* Clear */
|
||||
ipcom_memset(&ipmipha_extensions[0], 0, sizeof(ipmipha_extensions));
|
||||
ipcom_memset(&ipmipha_pktaux, 0, sizeof(ipmipha_pktaux));
|
||||
ipcom_list_init(&ipmipha_msgext_vendor_extensions);
|
||||
|
||||
/* Do service init */
|
||||
for (f = 0; ipmipha_function_registrations[f] != IP_NULL; f++)
|
||||
(*ipmipha_function_registrations[f]) ();
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_config_free
|
||||
*===========================================================================
|
||||
* Description: Clear out a configuration structure, free any resources
|
||||
* associated with it.
|
||||
* Parameters: data - The HA entity it belongs to
|
||||
* proc - The process
|
||||
* conf - The configuration structure.
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmipha_config_free(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmipha_conf_t *conf)
|
||||
{
|
||||
ipmipha_if_stop(data, proc, conf);
|
||||
|
||||
/**/
|
||||
ipcom_free(conf);
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_config_exit
|
||||
*===========================================================================
|
||||
* Description: Clears the indicated configuration
|
||||
* Parameters: instance - The Home Agent instance we're currently working on.
|
||||
* conf - The configuration
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmipha_config_exit(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
Ipmipha_iff_t *iff;
|
||||
|
||||
if (data->conf == IP_NULL)
|
||||
return;
|
||||
|
||||
/* Disallow any new regs */
|
||||
ipmip4_pkt_context_stop(&data->ipmip4, proc);
|
||||
data->shutdown = IPMIPHA_SHUTDOWN_ALL;
|
||||
ipmip4_pkt_context_start(&data->ipmip4, proc);
|
||||
|
||||
/* Free all mobile nodes */
|
||||
ipmipha_node_clear(data, proc);
|
||||
|
||||
/* Stop the current context */
|
||||
ipmip4_context_stop(&data->ipmip4, proc);
|
||||
|
||||
/* free interface list */
|
||||
for (iff = IPCOM_LIST_FIRST(&data->conf->if_head); iff != IP_NULL; iff = IPCOM_LIST_NEXT(&iff->iff.ipmip.next))
|
||||
{
|
||||
if (iff->adv_interval > 0 &&
|
||||
iff->iff.ifaddr != 0)
|
||||
{
|
||||
/* Reduce lifetime to 0 */
|
||||
iff->adv_lifetime = 0;
|
||||
iff->lifetime = 0;
|
||||
ipmipha_agent_advert_output(data, proc, iff, IP_NULL, IP_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* Free the configuration */
|
||||
ipmipha_config_free(data, proc, data->conf);
|
||||
data->conf = IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_config_read
|
||||
*===========================================================================
|
||||
* Description: Read IPMIPHA config.
|
||||
* used in ipmipha_config_init
|
||||
* Parameters: .
|
||||
* Returns: .
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ipmipha_conf_t *
|
||||
ipmipha_config_read(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
Ipmipha_conf_t *conf;
|
||||
char **arr = IP_NULL;
|
||||
|
||||
conf = ipcom_calloc(1, sizeof(Ipmipha_conf_t));
|
||||
if (conf == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
ipcom_list_init(&conf->if_head);
|
||||
|
||||
/* Find all interfaces */
|
||||
arr = ipmip_sysvar_strarr("ipmipha.interfaces");
|
||||
if (arr == IP_NULL)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Bad configuration. Invalid/missing \"ipmipha.interfaces\""));
|
||||
goto fail;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
for (i = 0; arr[i] != IP_NULL; i++)
|
||||
{
|
||||
/* If I can't create the interface, exit */
|
||||
if (ipmipha_if_create(data, proc, conf, arr[i]) == IP_FALSE)
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
/* Free the interface name buffer */
|
||||
ipcom_free(arr);
|
||||
return conf; /* success */
|
||||
|
||||
fail:
|
||||
if (arr)
|
||||
ipcom_free(arr);
|
||||
ipmipha_config_free(data, proc, conf);
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_config_init
|
||||
*===========================================================================
|
||||
* Description: Initialize the configuration for the specified instance
|
||||
* Parameters: instance - The HA instance
|
||||
* Returns: 0 on success
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipmipha_config_init(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
Ipmipha_conf_t *conf;
|
||||
#ifndef IP_PORT_LAS
|
||||
int name[4];
|
||||
Ip_size_t oldlenp;
|
||||
#endif
|
||||
|
||||
/* No new nodes*/
|
||||
IP_BIT_SET(data->shutdown, IPMIPHA_SHUTDOWN_NODE);
|
||||
|
||||
if (data->conf)
|
||||
ipmipha_config_exit(data, proc);
|
||||
|
||||
/* Read configuration */
|
||||
conf = ipmipha_config_read(data, proc);
|
||||
if (conf == IP_NULL)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Configuration Failed - Invalid Configuration"));
|
||||
IP_BIT_CLR(data->shutdown, IPMIPHA_SHUTDOWN_NODE);
|
||||
ipmip_context_start(&data->ipmip4.ipmip, proc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifndef IP_PORT_LAS
|
||||
/* Check if we are a router */
|
||||
name[0] = IP_CTL_NET;
|
||||
name[1] = IP_AF_INET;
|
||||
name[2] = IP_IPPROTO_IP;
|
||||
name[3] = IP_IPCTL_FORWARDING;
|
||||
oldlenp = sizeof(data->ipnet_is_router);
|
||||
if (ipcom_sysctl(name, 4, &data->ipnet_is_router, &oldlenp, IP_NULL, IP_NULL) < 0)
|
||||
data->ipnet_is_router = 0;
|
||||
#endif
|
||||
|
||||
/* Reconfigure (existing config was in place) */
|
||||
data->conf = conf;
|
||||
|
||||
data->shutdown = 0;
|
||||
|
||||
ipmip4_context_start(&data->ipmip4, proc);
|
||||
ipmipha_if_start(data, proc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_exit_agent
|
||||
*===========================================================================
|
||||
* Description: Free the HA instance
|
||||
* Parameters: instance - The HA instance to free.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipmipha_exit_agent(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
/* Sanity */
|
||||
if (data == IP_NULL)
|
||||
return;
|
||||
|
||||
IPMIP4_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"IPMIPHA ending"));
|
||||
|
||||
/* Stop the context */
|
||||
ipmip4_context_stop(&data->ipmip4, proc);
|
||||
|
||||
/* Destroy route context */
|
||||
ipmipha_route_context_destroy(data, proc);
|
||||
|
||||
/* Exit the IPD */
|
||||
if (data->fd_ipd == IP_INVALID_SOCKET)
|
||||
(void)ipcom_ipd_init("ipmipha", IPCOM_ERR_FAILED, &data->fd_ipd);
|
||||
|
||||
(void)ipcom_ipd_exit("ipmipha", data->fd_ipd);
|
||||
|
||||
/* */
|
||||
ipcom_mutex_delete(&data->mibLock);
|
||||
|
||||
ipmip_context_id_destroy(data->idents);
|
||||
|
||||
/* Free the context */
|
||||
ipmip4_context_destroy(&data->ipmip4, proc);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_init_agent
|
||||
*===========================================================================
|
||||
* Description: Initialize an agent instance
|
||||
* Parameters:
|
||||
* Returns: The pointer to the agent instance if successful
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ipmipha_data_t *
|
||||
ipmipha_init_agent(Ipmip_proc_t *proc)
|
||||
{
|
||||
Ipmipha_data_t *data;
|
||||
|
||||
(void)IPMIP_ONCE(&ipmipha_extensions_once, ipmipha_main_once_init, IP_NULL);
|
||||
|
||||
|
||||
data = (Ipmipha_data_t *)ipmip_context_alloc(proc, sizeof(*data), "ipmipha", IPMIP4_SYSTEM_PRIORITY, IPMIPHA_EVENT_BACKLOG);
|
||||
if (data == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
/* Setup the extension structure */
|
||||
data->extensions = &ipmipha_extensions[0];
|
||||
data->extensions_node_data = &ipmipha_extensions_node_data;
|
||||
data->ipmip4.vendor_extensions = &ipmipha_msgext_vendor_extensions;
|
||||
data->ipmip4.ipmip.pktaux = &ipmipha_pktaux;
|
||||
|
||||
ipmip4_context_init(&data->ipmip4, proc);
|
||||
|
||||
data->fd_ipd = IP_INVALID_SOCKET;
|
||||
|
||||
IPMIP4_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"IPMIPHA starting [VR %d]", data->ipmip4.ipmip.vr));
|
||||
|
||||
(void)ipcom_mutex_create(&data->mibLock);
|
||||
|
||||
/* IPD init. */
|
||||
if (ipcom_ipd_init("ipmipha", IPCOM_SUCCESS, &data->fd_ipd) != IPCOM_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
data->idents = ipmip_context_id_create(ip_offsetof(Ipmipha_node_t, haNodeIdentity), 0xFFFFFFFF);
|
||||
|
||||
ipmip_cli_context_create(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"ipmipha",
|
||||
IPCOM_IPD_ID_IPMIPHA,
|
||||
(Ipmip_cli_callback_t)ipmipha_attr_command);
|
||||
|
||||
/* Create the packet buffer context */
|
||||
ipmip_pktbuf_context_create(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
(Ipmip_pkt_buf_alloc_t)ipmipha_pktbuf_alloc,
|
||||
(Ipmip_pkt_buf_free_t)ipmipha_pktbuf_free);
|
||||
|
||||
if (!ipmip4_pkt_context_create(&data->ipmip4,
|
||||
proc,
|
||||
IPMIP4_PKT_UDP_IN_434|IPMIP4_PKT_PKT_OUT|IPMIP4_PKT_ICMP_IN,
|
||||
(Ipmip4_pkt_udp_cb_t)ipmipha_reg_recv,
|
||||
(Ipmip4_pkt_icmp_cb_t)ipmipha_adv_recv,
|
||||
IP_NULL))
|
||||
goto fail;
|
||||
|
||||
ipmipha_route_context_alloc(data, proc);
|
||||
|
||||
return data;
|
||||
|
||||
fail:
|
||||
ipmipha_exit_agent(data, proc);
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_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
|
||||
ipmipha_ipd_process(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
/* IPD input. */
|
||||
int event;
|
||||
Ip_ssize_t len;
|
||||
Ipmipha_pktbuf_t *pbuf = (Ipmipha_pktbuf_t *)ipmip_pktbuf_alloc(&data->ipmip4.ipmip, proc, 512);
|
||||
|
||||
if (pbuf == IP_NULL)
|
||||
return IP_TRUE;
|
||||
|
||||
len = ipcom_ipd_read(data->fd_ipd, IPMIP_BUFFER_PTR(&pbuf->ipmip4.ipmip.packet), 512, &event);
|
||||
if (len < 0)
|
||||
ipmip_util_sock_clear(data->fd_ipd);
|
||||
else
|
||||
{
|
||||
/* Advance past */
|
||||
ipmip_buffer_append(&pbuf->ipmip4.ipmip.packet, IP_NULL, len);
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case IPCOM_IPD_EVENT_RECONFIGURE:
|
||||
IPMIP4_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Received IPD reconfigure message"));
|
||||
if (ipmipha_config_init(data, proc) != 0)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Invalid new configuration - reconfigure failed and process suspended. Please correct configuration"));
|
||||
}
|
||||
break;
|
||||
|
||||
case IPCOM_IPD_EVENT_KILL:
|
||||
IPMIP4_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Received IPD kill message"));
|
||||
ipmip_pktbuf_release(&data->ipmip4.ipmip, proc, &pbuf->ipmip4.ipmip);
|
||||
return IP_FALSE;
|
||||
|
||||
default:
|
||||
/* Ignore all other IPD messages */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ipmip_pktbuf_release(&data->ipmip4.ipmip, proc, &pbuf->ipmip4.ipmip);
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* To remove the warning */
|
||||
IP_PUBLIC IPCOM_PROCESS(ipmipha_proc);
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmiphad
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmipha_main(void)
|
||||
{
|
||||
char icmp_redirect[8];
|
||||
Ip_size_t size = sizeof(icmp_redirect);
|
||||
Ipmipha_data_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)
|
||||
goto end;
|
||||
|
||||
/**/
|
||||
ipmipha_configure();
|
||||
|
||||
/* First instance? */
|
||||
if (ipmipha_instances++ == 0)
|
||||
ipmipha_init();
|
||||
|
||||
ipcom_sysvar_get("ipnet.inet.IcmpRedirectSend",
|
||||
icmp_redirect,
|
||||
&size);
|
||||
if (ipcom_sysvar_set("ipnet.inet.IcmpRedirectSend", "0", IPCOM_SYSVAR_FLAG_OVERWRITE) != IPCOM_SUCCESS)
|
||||
goto end;
|
||||
|
||||
/* Init IPMIPHA */
|
||||
if ((data = ipmipha_init_agent(proc)) == IP_NULL)
|
||||
goto end;
|
||||
|
||||
/* Init HA from configuration */
|
||||
if (ipmipha_config_init(data, proc) != 0)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Invalid configuration - configure failed and process suspended. Please correct configuration"));
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int num;
|
||||
int max_fd;
|
||||
Ip_fd_set read_set;
|
||||
|
||||
IP_FD_ZERO(&read_set);
|
||||
|
||||
/* Set the IPD */
|
||||
max_fd = data->fd_ipd;
|
||||
IP_FD_SET(data->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. */
|
||||
(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->fd_ipd, &read_set))
|
||||
{
|
||||
if (ipmipha_ipd_process(data, proc) == IP_FALSE)
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
/* If we've gotten the data, clear it */
|
||||
if (data != IP_NULL)
|
||||
{
|
||||
ipmipha_config_exit(data, proc);
|
||||
ipmipha_exit_agent(data, proc);
|
||||
}
|
||||
|
||||
(void)ipcom_sysvar_set("ipnet.inet.IcmpRedirectSend",
|
||||
icmp_redirect,
|
||||
IPCOM_SYSVAR_FLAG_OVERWRITE);
|
||||
|
||||
|
||||
/* Last instance? */
|
||||
if (--ipmipha_instances == 0)
|
||||
ipmipha_exit();
|
||||
|
||||
/* Free the context process */
|
||||
ipmip_proc_destroy(proc);
|
||||
|
||||
ipcom_proc_exit();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* INIT FUNCTIONS */
|
||||
IP_GLOBAL Ip_u32
|
||||
ipmipha_context_register_extension(Ipmipha_extension_t *srv,
|
||||
int function)
|
||||
{
|
||||
Ipmipha_function_context_t *func = &ipmipha_extensions[function];
|
||||
Ip_u32 type = func->num++;
|
||||
|
||||
/* Store values */
|
||||
srv->type = type;
|
||||
srv->func = function;
|
||||
|
||||
/* Create the unique identifier */
|
||||
srv->unique = type;
|
||||
srv->unique |= function << 16;
|
||||
|
||||
func->mask |= (1 << type);
|
||||
ipmipha_extensions_node_data+= srv->node_data_size;
|
||||
ipmipha_extensions_node_data+= sizeof(void *);
|
||||
|
||||
func->functions[type] = srv;
|
||||
func->node_data += srv->node_data_size;
|
||||
|
||||
/* Register payload, if requested */
|
||||
if (srv->pktaux.pktbuf_data_size != 0)
|
||||
ipmip_pktbuf_pktaux_add(&ipmipha_pktaux, &srv->pktaux);
|
||||
|
||||
return srv->unique;
|
||||
}
|
||||
|
||||
IP_GLOBAL void
|
||||
ipmipha_msgext_vendor_parse_ext_register(struct Ipmip4_msgext_vendor_parse_ext *pext)
|
||||
{
|
||||
/**/
|
||||
ipmip4_msgext_vendor_parse_ext_register(&ipmipha_msgext_vendor_extensions, &ipmipha_pktaux, pext);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,208 @@
|
||||
/* ipmipha_reg.h - ipmipha_reg.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha_reg.h,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmipha/src/ipmipha_reg.h,v $
|
||||
* $Author: jhorteli $ $Date: 2009-04-23 14:24:35 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIPHA_REG_H
|
||||
#define IPMIPHA_REG_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
No description currently provided
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmipha_data;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmipha_node;
|
||||
struct Ipmipha_node_binding;
|
||||
struct Ipmipha_pktbuf;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmipha_reg_revoke_request - ipmipha_reg_revoke_request
|
||||
*
|
||||
* Send a revocation request for this particular binding
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Data
|
||||
* \i proc
|
||||
* Process
|
||||
* \i node
|
||||
* Node
|
||||
* \i binding
|
||||
* Binding
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE if successful
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmipha_reg_revoke_request
|
||||
(
|
||||
struct Ipmipha_data *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipha_node *node,
|
||||
struct Ipmipha_node_binding *binding
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmipha_reg_request_process - ipmipha_reg_request_process
|
||||
*
|
||||
* Process a container stage
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i event
|
||||
* Timer event
|
||||
* \i data
|
||||
* Context
|
||||
* \i proc
|
||||
* Current process
|
||||
* \i pbuf
|
||||
* The packet buffer
|
||||
* \i node
|
||||
* The node
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_FALSE
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL int ipmipha_reg_request_process
|
||||
(
|
||||
int event,
|
||||
struct Ipmipha_data *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipha_pktbuf *pbuf,
|
||||
struct Ipmipha_node *node
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmipha_reg_input_parse_request - ipmipha_reg_input_parse_request
|
||||
*
|
||||
* Parses basic values in a registration request.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Data context
|
||||
* \i proc
|
||||
* Process
|
||||
* \i pbuf
|
||||
* Packet buffer.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on success
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmipha_reg_input_parse_request
|
||||
(
|
||||
struct Ipmipha_data *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipha_pktbuf *pbuf
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmipha_reg_recv - ipmipha_reg_recv
|
||||
*
|
||||
* Handles registration request packages.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Context
|
||||
* \i proc
|
||||
* Current process.
|
||||
* \i pbuf
|
||||
* Packet buffer
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmipha_reg_recv
|
||||
(
|
||||
struct Ipmipha_data *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipha_pktbuf *pbuf,
|
||||
void *arg
|
||||
);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,656 @@
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha_route.c,v $ $Revision: 1.14.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmipha/src/ipmipha_route.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_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 <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_auth.h>
|
||||
#include <private/ipmip4_if.h>
|
||||
#include <private/ipmip4_pkt.h>
|
||||
#include <private/ipmip4_usr.h>
|
||||
#include <private/ipmip4_netlink.h>
|
||||
|
||||
#include "ipmipha.h"
|
||||
#include "ipmipha_h.h"
|
||||
#include "ipmipha_attr_h.h"
|
||||
#include "ipmipha_if.h"
|
||||
#include "ipmipha_route.h"
|
||||
#include "ipmipha_node.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
IP_STATIC int
|
||||
ipmipha_netlink_new_link_recv(struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmipha_node_t *node,
|
||||
Ipmipha_node_binding_t *binding,
|
||||
Ipmipha_node_capture_t *cap)
|
||||
{
|
||||
Ipmip_buffer_t rbuf;
|
||||
Ip_size_t hdr_off;
|
||||
struct Ip_mipmsg *msg;
|
||||
int ret;
|
||||
Ipmip_netlink_kern_handle_t handle;
|
||||
Ipmip_netlink_kern_compare_t scmp;
|
||||
|
||||
ipmip_buffer_init(&rbuf);
|
||||
|
||||
/* Create NLMSG HDR */
|
||||
ipmip_netlink_nlmsghdr_request(&rbuf, 0, 0, IP_RTM_NEWMIP, 0);
|
||||
msg = ipmip_buffer_offset(&rbuf, ipmip_netlink_nlmsghdr_put(&rbuf, IP_NULL, sizeof(*msg)));
|
||||
|
||||
msg->mip_family = IP_AF_INET;
|
||||
msg->mip_type = IP_WRMOB4_NEW_LINK_RX;
|
||||
msg->mip_flags = 0;
|
||||
|
||||
/* Create the nested HoA attribute */
|
||||
hdr_off = ipmip_netlink_nlmsghdr_rta_begin(&rbuf, IP_MIP_ENCAP);
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_DST, 4, &cap->prefix);
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_DST_LEN, cap->prefix_length);
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_TABLE, ctx->route->inbound_table);
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_LINK, IPMIP_LINK_SEND);
|
||||
|
||||
/* Route a binding */
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_IFINDEX, node->ifp->tunnels[binding->haBindingTunnelType]->iff.ipmip.ifindex);
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_GW, 4, &binding->haBindingTunnelingEndpoint);
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_FLAGS, IPMIP_RTF_SKIP);
|
||||
|
||||
ipcom_memset(&scmp, 0, sizeof(scmp));
|
||||
ipmip_netlink_route_src_tunnel_in(&scmp, binding->haBindingTunnelingEndpoint, IP_NULL);
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_SRCMAC, sizeof(scmp), &scmp);
|
||||
|
||||
/* Identity */
|
||||
handle.mip_facility = IPCOM_IPD_ID_IPMIPHA;
|
||||
handle.mip_ident = node->haNodeIdentity;
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_HANDLE, sizeof(handle), &handle);
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_end(&rbuf, hdr_off);
|
||||
|
||||
/* Complete the buffer */
|
||||
ipmip_netlink_nlmsghdr_done(&rbuf, 0);
|
||||
|
||||
/* NETLINK request */
|
||||
ret = ipmip_netlink_request(&ctx->ipmip4.ipmip,
|
||||
proc,
|
||||
ctx->ipmip4.ipmip.nl_req,
|
||||
0,
|
||||
0,
|
||||
(struct Ip_nlmsghdr *)IPMIP_BUFFER_PTR(&rbuf),
|
||||
IP_NULL);
|
||||
/**/
|
||||
ipmip_buffer_release(&rbuf);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip4.ipmip,
|
||||
proc,
|
||||
"Unable to perform Home Agent NEW LINK RECV = %d", -ret));
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
IP_STATIC int
|
||||
ipmipha_netlink_del_link_recv(struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmipha_node_t *node,
|
||||
Ipmipha_node_binding_t *binding,
|
||||
Ipmipha_node_capture_t *cap)
|
||||
{
|
||||
Ipmip_buffer_t rbuf;
|
||||
Ip_size_t hdr_off;
|
||||
struct Ip_mipmsg *msg;
|
||||
int ret;
|
||||
|
||||
ipmip_buffer_init(&rbuf);
|
||||
|
||||
/* Create NLMSG HDR */
|
||||
ipmip_netlink_nlmsghdr_request(&rbuf, 0, 0, IP_RTM_DELMIP, 0);
|
||||
msg = ipmip_buffer_offset(&rbuf, ipmip_netlink_nlmsghdr_put(&rbuf, IP_NULL, sizeof(*msg)));
|
||||
|
||||
msg->mip_family = IP_AF_INET;
|
||||
msg->mip_type = IP_WRMOB4_DEL_LINK_RX;
|
||||
msg->mip_flags = 0;
|
||||
|
||||
/* Create the nested HoA attribute */
|
||||
hdr_off = ipmip_netlink_nlmsghdr_rta_begin(&rbuf, IP_MIP_ENCAP);
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_DST, 4, &cap->prefix);
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_DST_LEN, cap->prefix_length);
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_TABLE, ctx->route->inbound_table);
|
||||
|
||||
/* Route a binding */
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_IFINDEX, node->ifp->tunnels[binding->haBindingTunnelType]->iff.ipmip.ifindex);
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_GW, 4, &binding->haBindingTunnelingEndpoint);
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_end(&rbuf, hdr_off);
|
||||
|
||||
/* Complete the buffer */
|
||||
ipmip_netlink_nlmsghdr_done(&rbuf, 0);
|
||||
|
||||
/* NETLINK request */
|
||||
ret = ipmip_netlink_request(&ctx->ipmip4.ipmip,
|
||||
proc,
|
||||
ctx->ipmip4.ipmip.nl_req,
|
||||
0,
|
||||
0,
|
||||
(struct Ip_nlmsghdr *)IPMIP_BUFFER_PTR(&rbuf),
|
||||
IP_NULL);
|
||||
/**/
|
||||
ipmip_buffer_release(&rbuf);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip4.ipmip,
|
||||
proc,
|
||||
"Unable to perform Home Agent DEL LINK RECV = %d", -ret));
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_route_reverse
|
||||
*===========================================================================
|
||||
* Description: Add/delete reverse bookkeeping route
|
||||
* Parameters: data - Current context
|
||||
* proc - Current process
|
||||
* add - IP_TRUE on ADD, IP_FALSE on delete.
|
||||
* node - Node we're doing this route command on
|
||||
* binding - Binding we're updating.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmipha_route_reverse(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ip_bool add,
|
||||
Ipmipha_node_t *node,
|
||||
Ipmipha_node_binding_t *binding)
|
||||
{
|
||||
/* */
|
||||
IPMIP4_EVENT_IF(DEBUG, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Node %s %s reverse statistics route from %s@%s",
|
||||
ipmipha_node_describe(proc, node, binding),
|
||||
add? "adding" : "deleting",
|
||||
ipmip_ntop_inet(proc, binding->haBindingTunnelingEndpoint),
|
||||
node->ifp->tunnels[binding->haBindingTunnelType]->iff.ipmip.ifname));
|
||||
|
||||
if (add)
|
||||
ipmipha_netlink_new_link_recv(data, proc, node, binding, &node->haNodeHomeAddress);
|
||||
else
|
||||
ipmipha_netlink_del_link_recv(data, proc, node, binding, &node->haNodeHomeAddress);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_route_binding
|
||||
*===========================================================================
|
||||
* Description: Add/delete host route "mn/32 -> co/32"
|
||||
* Parameters: data - Current context
|
||||
* proc - Current process
|
||||
* add - IP_TRUE on ADD, IP_FALSE on delete.
|
||||
* node - Node we're doing this route command on
|
||||
* binding - Binding we're updating.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmipha_route_binding(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ip_bool add,
|
||||
Ipmipha_node_t *node,
|
||||
Ipmipha_node_binding_t *binding)
|
||||
{
|
||||
/* */
|
||||
IPMIP4_EVENT_IF(DEBUG, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Node %s %s binding route to %s@%s",
|
||||
ipmipha_node_describe(proc, node, binding),
|
||||
add? "adding" : "deleting",
|
||||
ipmip_ntop_inet(proc, binding->haBindingTunnelingEndpoint),
|
||||
node->ifp->tunnels[binding->haBindingTunnelType]->iff.ipmip.ifname));
|
||||
|
||||
if (add)
|
||||
ipmipha_netlink_new_link_send(data, proc, node, binding, &node->haNodeHomeAddress);
|
||||
else
|
||||
ipmipha_netlink_del_link_send(data, proc, node, binding, &node->haNodeHomeAddress);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_route_arp
|
||||
*===========================================================================
|
||||
* Description: Used by ipmipha_reg_input() and ipmipha_node_timeout()
|
||||
* This is run when initiating proxying for a MN.
|
||||
* Sets(/deletes) a static, permanent, public and blackholed arp entry,
|
||||
* plus sends out a gratuitous arp.
|
||||
* Parameters: data - Context
|
||||
* proc - Current process
|
||||
* node - Node to add or remove ARP for.
|
||||
* set_or_del - Command.
|
||||
* Returns: IP_TRUE on success.
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmipha_route_arp(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc,
|
||||
Ipmipha_node_t *node,
|
||||
Ip_bool set)
|
||||
{
|
||||
if (ipmip_inet_arp_proxy(&data->ipmip4.ipmip, proc, node->ifp->iff.ipmip.ifindex, node->haNodeHomeAddress.prefix, set))
|
||||
{
|
||||
IPMIP4_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"Node %s %s Proxy ARP entry",
|
||||
ipmipha_node_describe(proc, node, IP_NULL),
|
||||
set? "adding" : "deleting"));
|
||||
}
|
||||
else
|
||||
{
|
||||
IPMIP4_EVENT_IF(INFO, proc,
|
||||
ipmip_log_event_add(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
"%s unable to %s Proxy ARP entry",
|
||||
ipmipha_node_describe(proc, node, IP_NULL),
|
||||
set? "add" : "delete"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipmipha_route_context_t
|
||||
*===========================================================================
|
||||
* Description: Allocate a route context
|
||||
* Parameters: data - Context
|
||||
* proc - Process
|
||||
* Returns: IP_TRUE on success
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_bool
|
||||
ipmipha_route_context_alloc(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
data->route = ipcom_calloc(1, sizeof(Ipmipha_route_context_t));
|
||||
if (data->route == IP_NULL)
|
||||
return IP_FALSE;
|
||||
|
||||
data->route->inbound_table = ipmip_util_route_table_alloc(&data->ipmip4.ipmip, proc);
|
||||
data->route->outbound_table = ipmip_util_route_table_alloc(&data->ipmip4.ipmip, proc);
|
||||
|
||||
/* Outbound rule */
|
||||
ipmip_netlink_inX_rule(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
IP_AF_INET,
|
||||
IP_RTM_NEWRULE,
|
||||
data->route->outbound_table,
|
||||
IPMIPHA_ROUTE_PRID(1),
|
||||
0,
|
||||
IP_NULL,
|
||||
0,
|
||||
IP_NULL,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipmipha_route_context_destroy
|
||||
*===========================================================================
|
||||
* Description: Destroy a route context
|
||||
* Parameters: data - Context
|
||||
* proc - Process
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipmipha_route_context_destroy(Ipmipha_data_t *data,
|
||||
Ipmip_proc_t *proc)
|
||||
{
|
||||
if (data->route)
|
||||
{
|
||||
/* Outbound rule */
|
||||
ipmip_netlink_inX_rule(&data->ipmip4.ipmip,
|
||||
proc,
|
||||
IP_AF_INET,
|
||||
IP_RTM_DELRULE,
|
||||
data->route->outbound_table,
|
||||
IPMIPHA_ROUTE_PRID(1),
|
||||
0,
|
||||
IP_NULL,
|
||||
0,
|
||||
IP_NULL,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
|
||||
ipmip_util_route_table_free(&data->ipmip4.ipmip, proc, data->route->inbound_table);
|
||||
ipmip_util_route_table_free(&data->ipmip4.ipmip, proc, data->route->outbound_table);
|
||||
|
||||
ipcom_free(data->route);
|
||||
data->route = IP_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IP_GLOBAL int
|
||||
ipmipha_netlink_new_link_send(struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmipha_node_t *node,
|
||||
Ipmipha_node_binding_t *binding,
|
||||
Ipmipha_node_capture_t *cap)
|
||||
{
|
||||
Ipmip_buffer_t rbuf;
|
||||
Ip_size_t hdr_off;
|
||||
struct Ip_mipmsg *msg;
|
||||
int ret;
|
||||
Ipmip_netlink_kern_handle_t handle;
|
||||
|
||||
ipmip_buffer_init(&rbuf);
|
||||
|
||||
/* Create NLMSG HDR */
|
||||
ipmip_netlink_nlmsghdr_request(&rbuf, 0, 0, IP_RTM_NEWMIP, 0);
|
||||
msg = ipmip_buffer_offset(&rbuf, ipmip_netlink_nlmsghdr_put(&rbuf, IP_NULL, sizeof(*msg)));
|
||||
|
||||
msg->mip_family = IP_AF_INET;
|
||||
msg->mip_type = IP_WRMOB4_NEW_LINK_TX;
|
||||
msg->mip_flags = 0;
|
||||
|
||||
/* Create the nested HoA attribute */
|
||||
hdr_off = ipmip_netlink_nlmsghdr_rta_begin(&rbuf, IP_MIP_ENCAP);
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_DST, 4, &cap->prefix);
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_DST_LEN, cap->prefix_length);
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_TABLE, ctx->route->outbound_table);
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_LINK, IPMIP_LINK_RECV);
|
||||
|
||||
if (binding != IP_NULL)
|
||||
{
|
||||
/* Route a binding */
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_IFINDEX, node->ifp->tunnels[binding->haBindingTunnelType]->iff.ipmip.ifindex);
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_GW, 4, &binding->haBindingTunnelingEndpoint);
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_FLAGS, IPMIP_RTF_MBINDING|IPMIP_RTF_TUNNELEND);
|
||||
|
||||
if (IP_BIT_ARESET(binding->haBindingTunnelFlags, IPMIP4_TUNNELMODE_NAT_T_CONFIRMED))
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_NAT_PORT, (IP_UDP_NAT_T_RFC3519 << 16 | binding->haBindingTunnelingPort));
|
||||
|
||||
/* Identity */
|
||||
handle.mip_facility = IPCOM_IPD_ID_IPMIPHA;
|
||||
handle.mip_ident = node->haNodeIdentity;
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_HANDLE, sizeof(handle), &handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Dual route */
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_IFINDEX, node->ifp->tunnels[IPMIP_TUNNELTYPE_IPIP]->iff.ipmip.ifindex);
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_GW, 4, &node->haNodeHomeAddress.prefix);
|
||||
}
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_end(&rbuf, hdr_off);
|
||||
|
||||
/* Complete the buffer */
|
||||
ipmip_netlink_nlmsghdr_done(&rbuf, 0);
|
||||
|
||||
/* NETLINK request */
|
||||
ret = ipmip_netlink_request(&ctx->ipmip4.ipmip,
|
||||
proc,
|
||||
ctx->ipmip4.ipmip.nl_req,
|
||||
0,
|
||||
0,
|
||||
(struct Ip_nlmsghdr *)IPMIP_BUFFER_PTR(&rbuf),
|
||||
IP_NULL);
|
||||
/**/
|
||||
ipmip_buffer_release(&rbuf);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip4.ipmip,
|
||||
proc,
|
||||
"Unable to perform Home Agent NEW LINK SEND = %d", -ret));
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
IP_GLOBAL int
|
||||
ipmipha_netlink_del_link_send(struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
Ipmipha_node_t *node,
|
||||
Ipmipha_node_binding_t *binding,
|
||||
Ipmipha_node_capture_t *cap)
|
||||
{
|
||||
Ipmip_buffer_t rbuf;
|
||||
Ip_size_t hdr_off;
|
||||
struct Ip_mipmsg *msg;
|
||||
int ret;
|
||||
|
||||
ipmip_buffer_init(&rbuf);
|
||||
|
||||
/* Create NLMSG HDR */
|
||||
ipmip_netlink_nlmsghdr_request(&rbuf, 0, 0, IP_RTM_DELMIP, 0);
|
||||
msg = ipmip_buffer_offset(&rbuf, ipmip_netlink_nlmsghdr_put(&rbuf, IP_NULL, sizeof(*msg)));
|
||||
|
||||
msg->mip_family = IP_AF_INET;
|
||||
msg->mip_type = IP_WRMOB4_DEL_LINK_TX;
|
||||
msg->mip_flags = 0;
|
||||
|
||||
/* Create the nested HoA attribute */
|
||||
hdr_off = ipmip_netlink_nlmsghdr_rta_begin(&rbuf, IP_MIP_ENCAP);
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_DST, 4, &cap->prefix);
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_DST_LEN, cap->prefix_length);
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_TABLE, ctx->route->outbound_table);
|
||||
|
||||
if (binding != IP_NULL)
|
||||
{
|
||||
/* Route a binding */
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_IFINDEX, node->ifp->tunnels[binding->haBindingTunnelType]->iff.ipmip.ifindex);
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_GW, 4, &binding->haBindingTunnelingEndpoint);
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_FLAGS, IPMIP_RTF_MBINDING);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Dual route */
|
||||
ipmip_netlink_nlmsghdr_rta_put_u32(&rbuf, IP_WRMOB4_ROUTE_IFINDEX, node->ifp->tunnels[IPMIP_TUNNELTYPE_IPIP]->iff.ipmip.ifindex);
|
||||
ipmip_netlink_nlmsghdr_rta_put(&rbuf, IP_WRMOB4_ROUTE_GW, 4, &node->haNodeHomeAddress.prefix);
|
||||
}
|
||||
|
||||
ipmip_netlink_nlmsghdr_rta_end(&rbuf, hdr_off);
|
||||
|
||||
/* Complete the buffer */
|
||||
ipmip_netlink_nlmsghdr_done(&rbuf, 0);
|
||||
|
||||
/* NETLINK request */
|
||||
ret = ipmip_netlink_request(&ctx->ipmip4.ipmip,
|
||||
proc,
|
||||
ctx->ipmip4.ipmip.nl_req,
|
||||
0,
|
||||
0,
|
||||
(struct Ip_nlmsghdr *)IPMIP_BUFFER_PTR(&rbuf),
|
||||
IP_NULL);
|
||||
/**/
|
||||
ipmip_buffer_release(&rbuf);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
IPMIP4_EVENT_IF(ERR, proc,
|
||||
ipmip_log_event_add(&ctx->ipmip4.ipmip,
|
||||
proc,
|
||||
"Unable to perform Home Agent DEL LINK SEND = %d", -ret));
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
IP_GLOBAL int
|
||||
ipmipha_netlink_new_handle(struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipha_node *node)
|
||||
{
|
||||
/**/
|
||||
return ipmip4_netlink_new_handle(&ctx->ipmip4, proc, IPCOM_IPD_ID_IPMIPHA, node->haNodeIdentity);
|
||||
}
|
||||
|
||||
IP_GLOBAL int
|
||||
ipmipha_netlink_del_handle(struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipha_node *node)
|
||||
{
|
||||
/**/
|
||||
return ipmip4_netlink_del_handle(&ctx->ipmip4, proc, IPCOM_IPD_ID_IPMIPHA, node->haNodeIdentity);
|
||||
}
|
||||
|
||||
IP_GLOBAL Ip_bool
|
||||
ipmipha_netlink_get_handle_stat(struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipha_node *node)
|
||||
{
|
||||
Ipmip4_netlink_kern_statistics_t link_recv, link_send;
|
||||
Ipmip_netlink_kern_handle_t handle;
|
||||
|
||||
/* Identity */
|
||||
handle.mip_facility = IPCOM_IPD_ID_IPMIPHA;
|
||||
handle.mip_ident = node->haNodeIdentity;
|
||||
|
||||
if (ipmip4_netlink_get_handle_stat(&ctx->ipmip4, proc, &handle, &link_recv, &link_send))
|
||||
{
|
||||
/* Update stats */
|
||||
IP_U64_ADD32(node->haNodeRcvOctets, link_recv.mip_s_octets);
|
||||
IP_U64_ADD32(node->haNodeRcvPkts, link_recv.mip_s_pkts);
|
||||
|
||||
IP_U64_ADD32(node->haNodeSndOctets, link_send.mip_s_octets);
|
||||
IP_U64_ADD32(node->haNodeSndPkts, link_send.mip_s_pkts);
|
||||
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,292 @@
|
||||
/* ipmipha_route.h - ipmipha_route.h */
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipha_route.h,v $ $Revision: 1.9.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipmipha/src/ipmipha_route.h,v $
|
||||
* $Author: svc-cmnet $ $Date: 2013-03-13 07:45:33 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPMIPHA_ROUTE_H
|
||||
#define IPMIPHA_ROUTE_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
No description currently provided
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPMIPHA_ROUTE_BASE_PRID (0)
|
||||
#define IPMIPHA_ROUTE_PRID(x) (IPMIPHA_ROUTE_BASE_PRID + (x))
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
struct Ipmipha_data;
|
||||
struct Ipmip_proc;
|
||||
struct Ipmipha_node;
|
||||
struct Ipmipha_node_binding;
|
||||
struct Ipmipha_node_capture;
|
||||
|
||||
typedef struct Ipmipha_route_context
|
||||
{
|
||||
Ip_u32 inbound_table; /* From Mobile Node */
|
||||
Ip_u32 outbound_table; /* To Mobile Node */
|
||||
} Ipmipha_route_context_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmipha_route_reverse - ipmipha_route_reverse
|
||||
*
|
||||
* Add/delete reverse bookkeeping route
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Current context
|
||||
* \i proc
|
||||
* Current process
|
||||
* \i add
|
||||
* IP_TRUE if add, IP_FALSE if del.
|
||||
* \i node
|
||||
* Node we're doing this route command on
|
||||
* \i binding
|
||||
* Binding we're updating.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmipha_route_reverse
|
||||
(
|
||||
struct Ipmipha_data *data,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_bool add,
|
||||
struct Ipmipha_node *node,
|
||||
struct Ipmipha_node_binding *binding
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmipha_route_binding - ipmipha_route_binding
|
||||
*
|
||||
* Add/delete host route "mn/32 -> co/32"
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Current context
|
||||
* \i proc
|
||||
* Current process
|
||||
* \i add
|
||||
* IP_TRUE if add, IP_FALSE if del.
|
||||
* \i node
|
||||
* Node we're doing this route command on
|
||||
* \i binding
|
||||
* Binding we're updating.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmipha_route_binding
|
||||
(
|
||||
struct Ipmipha_data *data,
|
||||
struct Ipmip_proc *proc,
|
||||
Ip_bool add,
|
||||
struct Ipmipha_node *node,
|
||||
struct Ipmipha_node_binding *binding
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmipha_route_arp - ipmipha_route_arp
|
||||
*
|
||||
* Used by ipmipha_reg_input() and ipmipha_node_timeout()
|
||||
* This is run when initiating proxying for a MN.
|
||||
*
|
||||
* Sets(/deletes) a static, permanent, public and blackholed arp entry,
|
||||
*
|
||||
* plus sends out a gratuitous arp.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Context
|
||||
* \i proc
|
||||
* Current process
|
||||
* \i node
|
||||
* Node to add or remove ARP for.
|
||||
* \i set_or_del
|
||||
* Command.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmipha_route_arp
|
||||
(
|
||||
struct Ipmipha_data *data,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipha_node *node,
|
||||
Ip_bool set
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmipha_route_context_alloc - ipmipha_route_context_alloc
|
||||
*
|
||||
* Allocate a route context
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* The FA context
|
||||
* \i proc
|
||||
* Current process
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: IP_TRUE on success
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL Ip_bool ipmipha_route_context_alloc
|
||||
(
|
||||
struct Ipmipha_data *data,
|
||||
struct Ipmip_proc *proc
|
||||
);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipmipha_route_context_destroy - ipmipha_route_context_destroy
|
||||
*
|
||||
* Destroy a route context
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i data
|
||||
* Context
|
||||
* \i proc
|
||||
* Process
|
||||
* \ie
|
||||
*
|
||||
* RETURNS: No return value
|
||||
*
|
||||
* ERRNO:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipmipha_route_context_destroy
|
||||
(
|
||||
struct Ipmipha_data *data,
|
||||
struct Ipmip_proc *proc
|
||||
);
|
||||
|
||||
|
||||
IP_GLOBAL int ipmipha_netlink_new_link_send
|
||||
(
|
||||
struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipha_node *node,
|
||||
struct Ipmipha_node_binding *binding,
|
||||
struct Ipmipha_node_capture *cap
|
||||
);
|
||||
|
||||
IP_GLOBAL int ipmipha_netlink_del_link_send
|
||||
(
|
||||
struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipha_node *node,
|
||||
struct Ipmipha_node_binding *binding,
|
||||
struct Ipmipha_node_capture *cap
|
||||
);
|
||||
|
||||
IP_GLOBAL int ipmipha_netlink_new_handle
|
||||
(
|
||||
struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipha_node *node
|
||||
);
|
||||
|
||||
IP_GLOBAL int ipmipha_netlink_del_handle
|
||||
(
|
||||
struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipha_node *node
|
||||
);
|
||||
|
||||
IP_GLOBAL Ip_bool ipmipha_netlink_get_handle_stat
|
||||
(
|
||||
struct Ipmipha_data *ctx,
|
||||
struct Ipmip_proc *proc,
|
||||
struct Ipmipha_node *node
|
||||
);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
Reference in New Issue
Block a user