462 lines
14 KiB
C
462 lines
14 KiB
C
|
|
/*
|
|
******************************************************************************
|
|
* INTERPEAK SOURCE FILE
|
|
*
|
|
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmipfa_cli.c,v $ $Revision: 1.3 $
|
|
* $Source: /home/interpeak/CVSRoot/ipmipfa/src/ipmipfa_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 "ipmipfa_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 "ipmipfa.h"
|
|
#include "ipmipfa_attr.h"
|
|
#include "ipmipfa_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
|
|
ipmipfa_cli_connect(Ipmip_cli_daemon_t *daemon_info)
|
|
{
|
|
ipmip_cli_daemon_init(daemon_info, "ipmipfa", IPCOM_IPD_ID_IPMIPFA);
|
|
return ipmip_cli_daemon_connect(daemon_info);
|
|
}
|
|
|
|
|
|
IP_PUBLIC void
|
|
ipmipfa_cli_request_set_nai(Ipmip_cli_daemon_req_t *req,
|
|
const char *nai)
|
|
{
|
|
if (nai)
|
|
ipmip_attr_put_str(&req->reqbuf, IPMIPFA_CLI_ATTR_BC_X_NAI, nai);
|
|
}
|
|
|
|
IP_PUBLIC void
|
|
ipmipfa_cli_request_set_handle(Ipmip_cli_daemon_req_t *req,
|
|
Ip_u32 handle)
|
|
{
|
|
ipmip_attr_put_u32(&req->reqbuf, IPMIPFA_CLI_ATTR_BC_X_HANDLE, handle);
|
|
}
|
|
|
|
IP_PUBLIC void
|
|
ipmipfa_cli_request_set_home_address(Ipmip_cli_daemon_req_t *req,
|
|
Ip_u32 hoa)
|
|
{
|
|
if (hoa)
|
|
ipmip_attr_put_inet(&req->reqbuf, IPMIPFA_CLI_ATTR_BC_X_HOA, hoa);
|
|
}
|
|
|
|
IP_PUBLIC void
|
|
ipmipfa_cli_request_set_home_agent(Ipmip_cli_daemon_req_t *req,
|
|
Ip_u32 ha)
|
|
{
|
|
if (ha)
|
|
ipmip_attr_put_inet(&req->reqbuf, IPMIPFA_CLI_ATTR_BC_X_HA, ha);
|
|
}
|
|
|
|
IP_PUBLIC void
|
|
ipmipfa_cli_request_set_ifname(Ipmip_cli_daemon_req_t *req,
|
|
const char *ifname)
|
|
{
|
|
if (ifname)
|
|
ipmip_attr_put_str(&req->reqbuf,IPMIPFA_CLI_ATTR_BC_X_IFNAME, ifname);
|
|
}
|
|
|
|
|
|
IP_PUBLIC Ip_time_t
|
|
ipmipfa_cli_node_get_created(struct Ipmip_attr *node)
|
|
{
|
|
/**/
|
|
return ipmip_attr_payload_find_time_t(node, IPMIPFA_CLI_ATTR_BC_X_CREATION_TIME);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_node_get_handle(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_u32(node, IPMIPFA_CLI_ATTR_BC_X_HANDLE);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_node_get_home_address(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_inet(node, IPMIPFA_CLI_ATTR_BC_X_HOA);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_node_get_tunnel_endpoint(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_inet(node, IPMIPFA_CLI_ATTR_BC_X_TUNNEL_ENDPOINT);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_node_get_tunnel_type(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_u32(node, IPMIPFA_CLI_ATTR_BC_X_TUNNEL_TYPE);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_node_get_tunnel_flags(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_u32(node, IPMIPFA_CLI_ATTR_BC_X_TUNNEL_FLAGS);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_node_get_home_agent(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_inet(node, IPMIPFA_CLI_ATTR_BC_X_HA);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_node_get_time_granted(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_u32(node, IPMIPFA_CLI_ATTR_BC_X_TIME_GRANTED);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_node_get_time_remaining(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_u32(node, IPMIPFA_CLI_ATTR_BC_X_TIME_REMAINING);
|
|
}
|
|
|
|
IP_PUBLIC Ip_time_t
|
|
ipmipfa_cli_node_get_last_updated(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_time_t(node, IPMIPFA_CLI_ATTR_BC_X_LAST_UPDATED);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_node_get_registration_type(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_u32(node, IPMIPFA_CLI_ATTR_BC_X_REG_TYPE);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_node_get_spi_mobile_foreign(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_u32(node, IPMIPFA_CLI_ATTR_BC_X_SPI_MF);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_node_get_spi_foreign_home(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_u32(node, IPMIPFA_CLI_ATTR_BC_X_SPI_FH);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_node_get_spi_mobile_AAA(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_u32(node, IPMIPFA_CLI_ATTR_BC_X_SPI_AAA);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_node_get_registration_flags(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_u32(node, IPMIPFA_CLI_ATTR_BC_X_REG_FLAGS);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_node_get_visitor_ip(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_inet(node, IPMIPFA_CLI_ATTR_BC_X_VISITOR_IP);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_node_get_RegIdHigh(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_u32(node, IPMIPFA_CLI_ATTR_BC_X_REGIDHIGH);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_node_get_RegIdLow(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_u32(node, IPMIPFA_CLI_ATTR_BC_X_REGIDLOW);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u64
|
|
ipmipfa_cli_node_get_stats_rcv_octets64(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_u64(node, IPMIPFA_CLI_ATTR_BC_X_STATS_RCV_OCTETS64);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u64
|
|
ipmipfa_cli_node_get_stats_rcv_pkts64(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_u64(node, IPMIPFA_CLI_ATTR_BC_X_STATS_RCV_PKTS64);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u64
|
|
ipmipfa_cli_node_get_stats_snd_octets64(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_u64(node, IPMIPFA_CLI_ATTR_BC_X_STATS_SND_OCTETS64);
|
|
}
|
|
|
|
IP_PUBLIC Ip_u64
|
|
ipmipfa_cli_node_get_stats_snd_pkts64(struct Ipmip_attr *node)
|
|
{
|
|
return ipmip_attr_payload_find_u64(node, IPMIPFA_CLI_ATTR_BC_X_STATS_SND_PKTS64);
|
|
}
|
|
|
|
|
|
IP_PUBLIC const char *
|
|
ipmipfa_cli_node_get_ifname(struct Ipmip_attr *node)
|
|
{
|
|
/**/
|
|
return ipmip_attr_payload_find_str(node, IPMIPFA_CLI_ATTR_BC_X_IFNAME);
|
|
}
|
|
|
|
IP_PUBLIC const char *
|
|
ipmipfa_cli_node_get_nai(struct Ipmip_attr *node)
|
|
{
|
|
/**/
|
|
return ipmip_attr_payload_find_str(node, IPMIPFA_CLI_ATTR_BC_X_NAI);
|
|
}
|
|
|
|
IP_PUBLIC struct Ipmip_lladdr *
|
|
ipmipfa_cli_node_get_lladdr(struct Ipmip_attr *node)
|
|
{
|
|
/**/
|
|
return (struct Ipmip_lladdr *)ipmip_attr_payload_find_data(node, IPMIPFA_CLI_ATTR_BC_X_LLADDR);
|
|
}
|
|
|
|
|
|
IP_PUBLIC int
|
|
ipmipfa_cli_node_list(Ipmip_cli_daemon_t *daemon,
|
|
Ipmip_cli_daemon_req_t *req,
|
|
const char *nai,
|
|
const char *ifname,
|
|
Ip_u32 hoa,
|
|
Ip_u32 ha)
|
|
{
|
|
ipmip_cli_daemon_request_start(req, IPMIPFA_CLI_BC_X_LIST);
|
|
|
|
ipmipfa_cli_request_set_ifname(req, ifname);
|
|
ipmipfa_cli_request_set_nai(req, nai);
|
|
ipmipfa_cli_request_set_home_address(req, hoa);
|
|
ipmipfa_cli_request_set_home_agent(req, ha);
|
|
|
|
return ipmip_cli_daemon_request(daemon, req);
|
|
}
|
|
|
|
|
|
IP_PUBLIC struct Ipmip_attr *
|
|
ipmipfa_cli_node_get(Ipmip_cli_daemon_t *daemon,
|
|
Ipmip_cli_daemon_req_t *req,
|
|
Ip_u32 handle)
|
|
{
|
|
ipmip_cli_daemon_request_start(req, IPMIPFA_CLI_BC_X_GET);
|
|
|
|
ipmipfa_cli_request_set_handle(req, handle);
|
|
|
|
if (ipmip_cli_daemon_request(daemon, req) == IPCOM_SUCCESS)
|
|
return ipmip_cli_daemon_find_request(req, IPMIPFA_CLI_ATTR_BC_X);
|
|
|
|
return IP_NULL;
|
|
}
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmipfa_cli_handle_next(Ipmip_attr_iter_t *iter)
|
|
{
|
|
/**/
|
|
return ipmip_attr_get_u32(ipmip_attr_iter_next(iter, IPMIPFA_CLI_ATTR_BC_X_HANDLE));
|
|
}
|
|
|
|
|
|
IP_PUBLIC void
|
|
ipmipfa_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, IPMIPFA_CLI_DAEMON_MUTE);
|
|
ipmip_cli_daemon_request(daemon, &req);
|
|
ipmip_cli_daemon_request_release(&req);
|
|
}
|
|
|
|
IP_PUBLIC void
|
|
ipmipfa_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, IPMIPFA_CLI_DAEMON_START);
|
|
ipmip_cli_daemon_request(daemon, &req);
|
|
ipmip_cli_daemon_request_release(&req);
|
|
}
|
|
|
|
IP_PUBLIC void
|
|
ipmipfa_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, IPMIPFA_CLI_DAEMON_STOP);
|
|
ipmip_cli_daemon_request(daemon, &req);
|
|
ipmip_cli_daemon_request_release(&req);
|
|
}
|
|
|
|
IP_PUBLIC struct Ipmipfa_mib_RegistrationCounters *
|
|
ipmipfa_cli_daemon_registration_counters(Ipmip_cli_daemon_t *daemon,
|
|
Ipmip_cli_daemon_req_t *req)
|
|
{
|
|
ipmip_cli_daemon_request_start(req, IPMIPFA_CLI_DAEMON_REGISTRATION_COUNTERS);
|
|
if (ipmip_cli_daemon_request(daemon, req) == IPCOM_SUCCESS)
|
|
return (struct Ipmipfa_mib_RegistrationCounters *)ipmip_cli_daemon_find_request_data(req, IPMIPFA_CLI_ATTR_DAEMON_REGCOUNTER);
|
|
|
|
return IP_NULL;
|
|
}
|
|
|
|
|
|
IP_PUBLIC void
|
|
ipmipfa_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, IPMIPFA_CLI_BC_X_DELETE);
|
|
ipmipfa_cli_request_set_handle(&req, handle);
|
|
ipmip_cli_daemon_request(daemon, &req);
|
|
ipmip_cli_daemon_request_release(&req);
|
|
}
|
|
|
|
IP_PUBLIC void
|
|
ipmipfa_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, IPMIPFA_CLI_BC_X_REVOKE);
|
|
ipmipfa_cli_request_set_handle(&req, handle);
|
|
ipmip_cli_daemon_request(daemon, &req);
|
|
ipmip_cli_daemon_request_release(&req);
|
|
}
|
|
|
|
IP_PUBLIC Ip_bool
|
|
ipmipfa_cli_daemon_l2_trigger(Ipmip_cli_daemon_t *daemon,
|
|
int trigger,
|
|
Ip_u32 mnip,
|
|
const char *ifname,
|
|
Ip_u32 faip,
|
|
const char *ll)
|
|
{
|
|
int ret;
|
|
Ipmip_cli_daemon_req_t req;
|
|
|
|
ipmip_cli_daemon_request_init(&req);
|
|
ipmip_cli_daemon_request_start(&req, trigger);
|
|
|
|
if (mnip)
|
|
ipmip_attr_put_inet(&req.reqbuf, IPMIPFA_CLI_ATTR_BC_X_HOA, mnip);
|
|
if (faip)
|
|
ipmip_attr_put_inet(&req.reqbuf, IPMIPFA_CLI_ATTR_BC_X_VISITOR_IP, faip);
|
|
if (ifname)
|
|
ipmip_attr_put_str(&req.reqbuf, IPMIPFA_CLI_ATTR_BC_X_IFNAME, ifname);
|
|
if (ll)
|
|
ipmip_attr_put_str(&req.reqbuf, IPMIPFA_CLI_ATTR_BC_X_LLA_NAME, ll);
|
|
|
|
ret = ipmip_cli_daemon_request(daemon, &req);
|
|
ipmip_cli_daemon_request_release(&req);
|
|
|
|
return ret == IPCOM_SUCCESS;
|
|
}
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* END OF FILE
|
|
****************************************************************************
|
|
*/
|