246 lines
8.9 KiB
C
246 lines
8.9 KiB
C
|
|
/*
|
|
******************************************************************************
|
|
* INTERPEAK SOURCE FILE
|
|
*
|
|
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmippm_reg.c,v $ $Revision: 1.8 $
|
|
* $Source: /home/interpeak/CVSRoot/ipmippm/src/ipmippm_reg.c,v $
|
|
* $Author: jhorteli $
|
|
* $State: Exp $ $Locker: $
|
|
*
|
|
* INTERPEAK_COPYRIGHT_STRING
|
|
* Design and implementation by Joel Hortelius <joel.hortelis@interpeak.se>
|
|
******************************************************************************
|
|
*/
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 1 DESCRIPTION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 2 CONFIGURATION
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include "ipmipmn_config.h"
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 3 INCLUDE FILES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#define IPCOM_USE_CLIB_PROTO
|
|
#include <ipcom_clib.h>
|
|
#include <ipcom_err.h>
|
|
#include <ipcom_os.h>
|
|
#include <ipcom_sock.h>
|
|
#include <ipcom_inet.h>
|
|
#include <ipcom_syslog.h>
|
|
#include <ipcom_ipd.h>
|
|
#include <ipcom_sock.h>
|
|
#include <ipcom_sock2.h>
|
|
#include <ipcom_list.h>
|
|
#include <ipcom_hash.h>
|
|
|
|
#include <ipmip.h>
|
|
#include <private/ipmip_sysvar.h>
|
|
#include <private/ipmip_timer.h>
|
|
|
|
#include <ipmip4.h>
|
|
#include <private/ipmip4_lla.h>
|
|
#include <private/ipmip4_util.h>
|
|
#include <private/ipmip4_sysext.h>
|
|
#include <private/ipmip4_context.h>
|
|
#include <private/ipmip4_pkt.h>
|
|
|
|
#include "ipmippm_h.h"
|
|
#include "ipmippm_client.h"
|
|
#include "ipmippm_reg.h"
|
|
#include "ipmippm_pktbuf.h"
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 4 DEFINES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 5 TYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 6 EXTERN PROTOTYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 7 LOCAL PROTOTYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 8 DATA
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 9 STATIC FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
IP_STATIC void
|
|
ipmippm_reg_output_mobile_home(struct Ipmippm_context *data,
|
|
struct Ipmip_proc *proc,
|
|
struct Ipmippm_client_conf *conf,
|
|
void *inst_config,
|
|
void *node_config,
|
|
struct Ipmippm_client *node,
|
|
Ip_bool deregister,
|
|
struct Ipmippm_pktbuf *pbuf)
|
|
{
|
|
IPMIP_UNUSED_PARAMETER(data);
|
|
IPMIP_UNUSED_PARAMETER(proc);
|
|
IPMIP_UNUSED_PARAMETER(conf);
|
|
IPMIP_UNUSED_PARAMETER(inst_config);
|
|
IPMIP_UNUSED_PARAMETER(node_config);
|
|
IPMIP_UNUSED_PARAMETER(deregister);
|
|
IPMIP_UNUSED_PARAMETER(node);
|
|
IPMIP_UNUSED_PARAMETER(pbuf);
|
|
}
|
|
|
|
|
|
IP_STATIC Ip_bool
|
|
ipmippm_reg_input_verify(struct Ipmippm_context *data,
|
|
struct Ipmip_proc *proc,
|
|
struct Ipmippm_client_conf *conf,
|
|
void *inst_config,
|
|
void *node_config,
|
|
struct Ipmippm_client *node,
|
|
struct Ipmippm_pktbuf *pbuf)
|
|
{
|
|
IPMIP_UNUSED_PARAMETER(data);
|
|
IPMIP_UNUSED_PARAMETER(proc);
|
|
IPMIP_UNUSED_PARAMETER(inst_config);
|
|
IPMIP_UNUSED_PARAMETER(conf);
|
|
IPMIP_UNUSED_PARAMETER(node_config);
|
|
IPMIP_UNUSED_PARAMETER(node);
|
|
IPMIP_UNUSED_PARAMETER(pbuf);
|
|
|
|
return IP_FALSE;
|
|
}
|
|
|
|
|
|
IP_STATIC void
|
|
ipmippm_reg_input_success(struct Ipmippm_context *data,
|
|
struct Ipmip_proc *proc,
|
|
struct Ipmippm_client_conf *conf,
|
|
void *inst_config,
|
|
void *node_config,
|
|
struct Ipmippm_client *node,
|
|
struct Ipmippm_pktbuf *pbuf)
|
|
{
|
|
IPMIP_UNUSED_PARAMETER(inst_config);
|
|
IPMIP_UNUSED_PARAMETER(conf);
|
|
IPMIP_UNUSED_PARAMETER(node_config);
|
|
|
|
IPMIP_UNUSED_PARAMETER(data);
|
|
|
|
node->api.params.mnRegTunnelType = pbuf->api.reginfo.mnRegTunnelType;
|
|
|
|
/* Assign our home agent */
|
|
if (node->api.params.assigned_home_agent == 0)
|
|
{
|
|
/**/
|
|
node->api.params.pending_home_agent = pbuf->api.pktinfo.mnRegHomeAgentAddress;
|
|
node->api.params.assigned_home_agent = node->api.params.pending_home_agent;
|
|
|
|
IPMIP4_EVENT_IF(INFO, proc,
|
|
ipmip_log_event_add(&data->api.ipmip4.ipmip,
|
|
proc,
|
|
"%s home agent '%s' assigned",
|
|
ipmippm_client_describe(proc, node),
|
|
ipmip_ntop_inet(proc, node->api.params.assigned_home_agent)));
|
|
}
|
|
|
|
/* Accepted */
|
|
if (node->api.params.assigned_home_address == 0)
|
|
{
|
|
/* OK; ADDRESS located, store it and configure our interface */
|
|
node->api.params.assigned_home_address = pbuf->api.pktinfo.mnRegHomeAddress;
|
|
node->api.params.pending_home_address = pbuf->api.pktinfo.mnRegHomeAddress;
|
|
IPMIP4_EVENT_IF(INFO, proc,
|
|
ipmip_log_event_add(&data->api.ipmip4.ipmip,
|
|
proc,
|
|
"%s home address '%s' assigned",
|
|
ipmippm_client_describe(proc, node),
|
|
ipmip_ntop_inet(proc, pbuf->api.pktinfo.mnRegHomeAddress)));
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 10 GLOBAL FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
IP_GLOBAL void
|
|
ipmippm_reg_register_service(void)
|
|
{
|
|
static Ipmipmn_api_extension_t ipmippm_node_ext;
|
|
|
|
ipcom_memset(&ipmippm_node_ext, 0, sizeof(ipmippm_node_ext));
|
|
|
|
ipmippm_node_ext.name = "REGISTER";
|
|
ipmippm_node_ext.pkt_req_mobile_home = (Ipmipmn_api_extension_pkt_req_mobile_home_t)ipmippm_reg_output_mobile_home;
|
|
ipmippm_node_ext.pkt_rep_validate = (Ipmipmn_api_extension_pkt_rep_validate_t)ipmippm_reg_input_verify;
|
|
ipmippm_node_ext.pkt_rep_accepted = (Ipmipmn_api_extension_pkt_rep_accepted_t)ipmippm_reg_input_success;
|
|
ipmippm_context_register_function(&ipmippm_node_ext);
|
|
}
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipmippm_reg_recv
|
|
*===========================================================================
|
|
* Description: Handles registration request and reply packages.
|
|
* Parameters: data - Context
|
|
* proc - Current process.
|
|
* pbuf - Packet buffer
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_GLOBAL void
|
|
ipmippm_reg_recv(struct Ipmippm_context *data,
|
|
struct Ipmip_proc *proc,
|
|
Ipmippm_pktbuf_t *pbuf)
|
|
{
|
|
/* Send immediately to the API input */
|
|
ipmipmn_api_reg_recv(&data->api, proc, &pbuf->api);
|
|
return;
|
|
}
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 11 PUBLIC FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* END OF FILE
|
|
****************************************************************************
|
|
*/
|