375 lines
11 KiB
C
375 lines
11 KiB
C
|
|
/*
|
|
******************************************************************************
|
|
* INTERPEAK SOURCE FILE
|
|
*
|
|
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6mn_cli.c,v $ $Revision: 1.7 $
|
|
* $Source: /home/interpeak/CVSRoot/ipmip6mn/src/ipmip6mn_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 "ipmip6mn_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 <ipmip6.h>
|
|
#include <private/ipmip6_context.h>
|
|
#include <private/ipmip6_mh.h>
|
|
#include <private/ipmip6_mh_pkt.h>
|
|
#include <private/ipmip6_if.h>
|
|
#include <private/ipmip6_util.h>
|
|
#include <private/ipmip6_address.h>
|
|
|
|
#include "ipmip6mn.h"
|
|
#include "ipmip6mn_attr.h"
|
|
#include "ipmip6mn_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
|
|
ipmip6mn_cli_connect(Ipmip_cli_daemon_t *daemon_info)
|
|
{
|
|
ipmip_cli_daemon_init(daemon_info, "ipmip6mn", IPCOM_IPD_ID_IPMIP6MN);
|
|
return ipmip_cli_daemon_connect(daemon_info);
|
|
}
|
|
|
|
|
|
IP_PUBLIC void
|
|
ipmip6mn_cli_network_set_name(Ipmip_cli_daemon_req_t *req,
|
|
const char *name)
|
|
{
|
|
if (name)
|
|
ipmip_attr_put_str(&req->reqbuf, IPMIP6MN_CLI_NETWORK_ATTR_NAME, name);
|
|
}
|
|
|
|
IP_PUBLIC int
|
|
ipmip6mn_cli_network_list(Ipmip_cli_daemon_t *daemon,
|
|
Ipmip_cli_daemon_req_t *req,
|
|
const char *name)
|
|
{
|
|
ipmip_cli_daemon_request_start(req, IPMIP6MN_CLI_NETWORK_LIST);
|
|
|
|
ipmip6mn_cli_network_set_name(req, name);
|
|
|
|
return ipmip_cli_daemon_request(daemon, req);
|
|
}
|
|
|
|
IP_PUBLIC const char *
|
|
ipmip6mn_cli_network_next(Ipmip_attr_iter_t *iter)
|
|
{
|
|
/**/
|
|
return ipmip_attr_get_str(ipmip_attr_iter_next(iter, IPMIP6MN_CLI_NETWORK_ATTR_NAME));
|
|
}
|
|
|
|
IP_PUBLIC int
|
|
ipmip6mn_cli_network_get(Ipmip_cli_daemon_t *daemon,
|
|
Ipmip_cli_daemon_req_t *req,
|
|
const char *name)
|
|
{
|
|
if (name == IP_NULL)
|
|
return -IP_ERRNO_EINVAL;
|
|
|
|
ipmip_cli_daemon_request_start(req, IPMIP6MN_CLI_NETWORK_GET);
|
|
ipmip6mn_cli_network_set_name(req, name);
|
|
|
|
return ipmip_cli_daemon_request(daemon, req);
|
|
}
|
|
|
|
|
|
IP_PUBLIC const struct Ipmip6_mib_mip6MnHomeAddressEntry *
|
|
ipmip6mn_cli_network_get_mip6MnHomeAddressEntry(Ipmip_cli_daemon_req_t *req)
|
|
{
|
|
/**/
|
|
return (const struct Ipmip6_mib_mip6MnHomeAddressEntry*)ipmip_cli_daemon_find_request_data(req, IPMIP6MN_CLI_NETWORK_ATTR_MIB_mip6MnHomeAddressEntry);
|
|
}
|
|
|
|
IP_PUBLIC const struct Ipmip6_mib_mip6MnConf *
|
|
ipmip6mn_cli_network_get_mip6MnConf(Ipmip_cli_daemon_req_t *req)
|
|
{
|
|
return (const struct Ipmip6_mib_mip6MnConf*)ipmip_cli_daemon_find_request_data(req, IPMIP6MN_CLI_NETWORK_ATTR_MIB_mip6MnConf);
|
|
}
|
|
|
|
IP_PUBLIC const struct Ipmip6_mib_mip6MnRegnCounters *
|
|
ipmip6mn_cli_network_get_mip6MnRegnCounters(Ipmip_cli_daemon_req_t *req)
|
|
{
|
|
return (const struct Ipmip6_mib_mip6MnRegnCounters*)ipmip_cli_daemon_find_request_data(req, IPMIP6MN_CLI_NETWORK_ATTR_MIB_mip6MnRegnCounters);
|
|
}
|
|
|
|
IP_PUBLIC const struct Ipmip6_mib_mip6TotalTraffic *
|
|
ipmip6mn_cli_network_get_mip6TotalTraffic(Ipmip_cli_daemon_req_t *req)
|
|
{
|
|
return (const struct Ipmip6_mib_mip6TotalTraffic*)ipmip_cli_daemon_find_request_data(req, IPMIP6MN_CLI_NETWORK_ATTR_MIB_mip6TotalTraffic);
|
|
}
|
|
|
|
IP_PUBLIC const struct Ipmip6_mib_mip6NodeTrafficEntry *
|
|
ipmip6mn_cli_network_get_mip6NodeTrafficEntry(Ipmip_cli_daemon_req_t *req)
|
|
{
|
|
return (const struct Ipmip6_mib_mip6NodeTrafficEntry*)ipmip_cli_daemon_find_request_data(req, IPMIP6MN_CLI_NETWORK_ATTR_MIB_mip6NodeTrafficEntry);
|
|
}
|
|
|
|
|
|
IP_PUBLIC const char *
|
|
ipmip6mn_cli_network_get_name(Ipmip_cli_daemon_req_t *req)
|
|
{
|
|
/**/
|
|
return ipmip_cli_daemon_find_request_str(req, IPMIP6MN_CLI_NETWORK_ATTR_NAME);
|
|
}
|
|
|
|
|
|
IP_PUBLIC const char *
|
|
ipmip6mn_cli_network_get_tunnel_ifname(Ipmip_cli_daemon_req_t *req)
|
|
{
|
|
/**/
|
|
return ipmip_cli_daemon_find_request_str(req, IPMIP6MN_CLI_NETWORK_ATTR_TUNNEL_IFNAME);
|
|
}
|
|
|
|
IP_PUBLIC struct Ipmip_attr *
|
|
ipmip6mn_cli_network_get_ifnames(Ipmip_cli_daemon_req_t *req)
|
|
{
|
|
return ipmip_cli_daemon_find_request(req, IPMIP6MN_CLI_NETWORK_ATTR_INTERFACES);
|
|
}
|
|
|
|
IP_PUBLIC Ip_bool
|
|
ipmip6mn_cli_network_get_ifnames_iter(Ipmip_cli_daemon_req_t *req,
|
|
Ipmip_attr_iter_t *iter)
|
|
{
|
|
struct Ipmip_attr *rta = ipmip6mn_cli_network_get_ifnames(req);
|
|
if (rta)
|
|
{
|
|
ipmip_attr_payload_iter_init(rta,iter);
|
|
return IP_TRUE;
|
|
}
|
|
|
|
return IP_FALSE;
|
|
}
|
|
|
|
|
|
IP_PUBLIC const char *
|
|
ipmip6mn_cli_network_get_ifnames_next(Ipmip_attr_iter_t *iter)
|
|
{
|
|
return ipmip_attr_get_str(ipmip_attr_iter_next(iter, IPMIP6MN_CLI_NETWORK_ATTR_INTERFACES_NAME));
|
|
}
|
|
|
|
|
|
IP_PUBLIC struct Ipmip_attr *
|
|
ipmip6mn_cli_network_get_cn_bindings(Ipmip_cli_daemon_req_t *req)
|
|
{
|
|
return ipmip_cli_daemon_find_request(req, IPMIP6MN_CLI_NETWORK_ATTR_CN);
|
|
}
|
|
|
|
IP_PUBLIC struct Ipmip_attr *
|
|
ipmip6mn_cli_network_get_ha_bindings(Ipmip_cli_daemon_req_t *req)
|
|
{
|
|
return ipmip_cli_daemon_find_request(req, IPMIP6MN_CLI_NETWORK_ATTR_HA);
|
|
}
|
|
|
|
|
|
IP_PUBLIC Ip_bool
|
|
ipmip6mn_cli_network_get_ha_bindings_iter(Ipmip_cli_daemon_req_t *req,
|
|
Ipmip_attr_iter_t *iter)
|
|
{
|
|
struct Ipmip_attr *rta = ipmip6mn_cli_network_get_ha_bindings(req);
|
|
if (rta)
|
|
{
|
|
ipmip_attr_payload_iter_init(rta, iter);
|
|
return IP_TRUE;
|
|
}
|
|
|
|
return IP_FALSE;
|
|
}
|
|
|
|
IP_PUBLIC Ip_bool
|
|
ipmip6mn_cli_network_get_cn_bindings_iter(Ipmip_cli_daemon_req_t *req,
|
|
Ipmip_attr_iter_t *iter)
|
|
{
|
|
struct Ipmip_attr *rta = ipmip6mn_cli_network_get_cn_bindings(req);
|
|
if (rta)
|
|
{
|
|
ipmip_attr_payload_iter_init(rta, iter);
|
|
return IP_TRUE;
|
|
}
|
|
|
|
return IP_FALSE;
|
|
}
|
|
|
|
|
|
IP_PUBLIC const struct Ipmip6_mib_mip6MnBLTable *
|
|
ipmip6mn_cli_network_get_bindings_mip6MnBLTable(struct Ipmip_attr *rta)
|
|
{
|
|
return (const struct Ipmip6_mib_mip6MnBLTable *)ipmip_attr_payload_find_data(rta, IPMIP6MN_CLI_NETWORK_ATTR_BINDING_ITEM_MIB_mip6MnBLTable);
|
|
}
|
|
|
|
|
|
IP_PUBLIC Ip_u32
|
|
ipmip6mn_cli_network_get_bindings_encap(struct Ipmip_attr *rta)
|
|
{
|
|
/**/
|
|
return ipmip_attr_payload_find_u32(rta, IPMIP6MN_CLI_NETWORK_ATTR_BINDING_ITEM_ENCAP);
|
|
}
|
|
|
|
IP_PUBLIC const char *
|
|
ipmip6mn_cli_network_get_bindings_ifname(struct Ipmip_attr *rta)
|
|
{
|
|
/**/
|
|
return ipmip_attr_payload_find_str(rta, IPMIP6MN_CLI_NETWORK_ATTR_BINDING_ITEM_IFNAME);
|
|
}
|
|
|
|
|
|
IP_PUBLIC struct Ipmip_attr *
|
|
ipmip6mn_cli_network_get_bindings_next(Ipmip_attr_iter_t *iter)
|
|
{
|
|
return ipmip_attr_iter_next(iter, IPMIP6MN_CLI_NETWORK_ATTR_BINDING_ITEM);
|
|
}
|
|
|
|
#ifdef IPMIP_USE_INET
|
|
IP_PUBLIC struct Ipmip_attr *
|
|
ipmip6mn_cli_network_get_dsmipv6(Ipmip_cli_daemon_req_t *req)
|
|
{
|
|
return ipmip_cli_daemon_find_request(req, IPMIP6MN_CLI_NETWORK_ATTR_DSMIPV6);
|
|
}
|
|
|
|
IP_PUBLIC Ip_bool
|
|
ipmip6mn_cli_network_get_dsmipv6_iter(Ipmip_cli_daemon_req_t *req,
|
|
Ipmip_attr_iter_t *iter)
|
|
{
|
|
struct Ipmip_attr *rta = ipmip6mn_cli_network_get_dsmipv6(req);
|
|
if (rta)
|
|
{
|
|
ipmip_attr_payload_iter_init(rta,iter);
|
|
return IP_TRUE;
|
|
}
|
|
|
|
return IP_FALSE;
|
|
}
|
|
|
|
|
|
IP_PUBLIC const struct Ipmip6mn_attr_dsmipv6 *
|
|
ipmip6mn_cli_network_get_dsmipv6_next(Ipmip_attr_iter_t *iter)
|
|
{
|
|
return ipmip_attr_get_data(ipmip_attr_iter_next(iter, IPMIP6MN_CLI_NETWORK_ATTR_DSMIPV6_PREFIX));
|
|
}
|
|
|
|
#endif
|
|
|
|
IP_PUBLIC void
|
|
ipmip6mn_cli_network_addif_init(Ipmip_cli_daemon_req_t *req,
|
|
const char *network)
|
|
{
|
|
ipmip_cli_daemon_request_start(req, IPMIP6MN_CLI_NETWORK_IF_ADD);
|
|
ipmip6mn_cli_network_set_name(req, network);
|
|
}
|
|
|
|
IP_PUBLIC void
|
|
ipmip6mn_cli_network_delif_init(Ipmip_cli_daemon_req_t *req,
|
|
const char *network)
|
|
{
|
|
ipmip_cli_daemon_request_start(req, IPMIP6MN_CLI_NETWORK_IF_DEL);
|
|
ipmip6mn_cli_network_set_name(req, network);
|
|
}
|
|
|
|
IP_PUBLIC void
|
|
ipmip6mn_cli_network_add_ifname(Ipmip_cli_daemon_req_t *req,
|
|
const char *ifname)
|
|
{
|
|
if (ifname)
|
|
{
|
|
Ip_size_t rta;
|
|
|
|
rta = ipmip_attr_begin(&req->reqbuf, IPMIP6MN_CLI_NETWORK_ATTR_INTERFACES);
|
|
ipmip_attr_put_str(&req->reqbuf, IPMIP6MN_CLI_NETWORK_ATTR_INTERFACES_NAME, ifname);
|
|
ipmip_attr_end(&req->reqbuf, rta);
|
|
}
|
|
}
|
|
|
|
/*
|
|
****************************************************************************
|
|
* END OF FILE
|
|
****************************************************************************
|
|
*/
|