Files
m241Neelima/components/ip_net2-6.9/ipmip/include/private/ipmip_cli.h
T
2026-07-30 11:19:44 +05:30

1586 lines
41 KiB
C

/* ipmip_cli.h - ipmip_cli.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip_cli.h,v $ $Revision: 1.18 $
* $Source: /home/interpeak/CVSRoot/ipmip/include/private/ipmip_cli.h,v $
* $Author: jhorteli $ $Date: 2011-01-21 15:31:28 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
******************************************************************************
*/
#ifndef IPMIP_CLI_H
#define IPMIP_CLI_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
* Command shell functions. These methods are used in order to properly
* connect and communicate with a started instance of a mobile node or agent.
*/
/*
DESCRIPTION
Command shell functions. These methods are used in order to properly
connect and communicate with a started instance of a mobile node or agent.
The command shell communicates using attributes <ipmip_attr.h> and
buffers <ipmip_buffer.h>
EXAMPLE
A basic example of how the attribute functions can be used in a command
line interface command hook. See the examples in ipmip_context.h for
'example' type definitions.
.CS
/@ Define some commands that may be used in this fictional setup. Commands
should be used to modify, get or create nodes @/
enum
{
IPMIP_MY_CLI_LIST = 2048,
IPMIP_MY_CLI_GET,
IPMIP_MY_CLI_MAX
};
/@ Define some attributes that the node have @/
enum
{
IPMIP_MY_NODE_NONE,
IPMIP_MY_NODE_INFO
};
enum
{
IPMIP_MY_NODE_ATTR_NONE,
IPMIP_MY_NODE_ATTR_NAME,
IPMIP_MY_NODE_ATTR_IDENTITY,
IPMIP_MY_NODE_ATTR_MAX
};
/@ This function is invoked with a locked and retrieved node. We will
dump all information regarding it into the request buffer provided @/
IP_STATIC int
ipmip_my_attr_func_dump(int event,
struct Ipmip_my_context *ctx,
Ipmip_proc_t *proc,
Ipmip_cli_message_t *request,
struct Ipmip_my_entities *node)
{
/@ Was this function invoked properly? @/
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;
Ip_size_t rta_sub;
/@ No node provided, return an error message @/
if (node == IP_NULL)
rhdr = ipmip_attr_hdr_err(&request->message, hdr, IP_ERRNO_ENOENT, IP_NULL);
else
{
switch (IPMIP_ATTR_HDR_TYPE(hdr))
{
case IPMIP_MY_CLI_GET:
{
Ip_u32 rta;
/@ Initialize an acknowledgement, save the start offset @/
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
/@ We will store all information related to this node within another
attribute. Nesting attributes like this allows you to store information
regarding multiple nodes in one buffer. Each IPMIP_MY_NODE_INFO contains
the information of one node @/
rta = ipmip_attr_begin(buffer, IPMIP_MY_NODE_INFO);
/@ Store the nodes name @/
ipmip_attr_put_str(&request->message,
IPMIP_MY_NODE_ATTR_NAME,
node->name);
/@ Store the nodes identity @/
ipmip_attr_put_u32(&request->message,
IPMIP_MY_NODE_ATTR_IDENTITY,
node->identity);
/@ End this attribute. @/
ipmip_attr_end(buffer, rta);
break;
}
}
/@ Finalize this message @/
ipmip_attr_hdr_finalize(&request->message, rhdr);
/@ Return the message to the command line interface processing
routines @/
ipmip_cli_message_commit(&ctx->ipmip6.ipmip, proc, request);
}
else
{
/@ This callback was invoked with a CANCEL or ABORTED event
value. Free the request and return @/
ipmip_cli_message_free(&ctx->ipmip6.ipmip, proc, request);
}
/@ This timer is done - finalize processing @/
return IPMIP_TIMER_RET_DONE;
}
/@ This callback routine is called from the identity context foreach
routine invoked further down in the code. It will store the identity
of each invoked node into the request buffer @/
IP_STATIC void
ipmip_my_attr_list_nodes(struct Ipmip_my_context *ctx,
Ipmip_proc_t *proc,
struct Ipmip_my_entities *node,
struct Ipmip_cli_message *request,
void *unused2)
{
/@ Store the identity @/
ipmip_attr_put_u32(&request->message,
IPMIP_MY_NODE_ATTR_IDENTITY,
node->identity);
}
/@ This is the main attribute function for this 'product'. It will receive
CLI messages from shell components and try reply to them @/
IP_GLOBAL int
ipmip_my_attr_func(struct Ipmip_my_context *ctx,
struct Ipmip_proc *proc,
struct Ipmip_cli_message *request)
{
/@ Fetch the attribute header at the beginning of the buffer @/
struct Ipmip_attr_header *hdr = (struct Ipmip_attr_header *)IPMIP_BUFFER_DATA(&request->request);
Ip_size_t rhdr = 0;
switch (IPMIP_ATTR_HDR_TYPE(hdr))
{
case IPMIP_MY_CLI_LIST:
{
/@ Setup the acknowledgement header @/
rhdr = ipmip_attr_hdr_ack(&request->message, hdr);
/@ Lock the identity context @/
ipmip_context_id_lock(ctx->my_identities);
/@ Loop through the identity context and dump all identities @/
ipmip_context_id_foreach(&ctx->ipmip,
proc,
ctx->my_identities,
(Ipmip_util_hash_foreach_t)ipmip_my_attr_list_nodes,
request,
IP_NULL);
/@ Unlock the identity context @/
ipmip_context_id_unlock(ctx->my_identities);
}
break;
case IPMIP_MY_CLI_GET:
{
/@ We assume that the identity of the node is provided when we are to dump
data @/
Ip_u32 identity = ipmip_attr_hdr_find_u32(hdr, IPMIP_MY_NODE_ATTR_IDENTITY);
struct Ipmip_my_entities *node;
if (identity == 0)
return -IP_ERRNO_EINVAL;
/@ Lock the identity context @/
ipmip_context_id_lock(ctx->my_identities);
/@ Try locate the node from the identity context @/
node = ipmip_context_id_get(ctx->my_identities, identity;
if (node == IP_NULL)
{
/@ Unlock the identity context @/
ipmip_context_id_unlock(ctx->my_identities);
/@ Indicate that we did not find the node @/
return -IP_ERRNO_ENOENT;
}
/@ Send to the timer callback and let it deal with the result @/
ipmip_timer_request(&ctx->ipmip,
proc,
&request->timer,
node->lock,
(Ipmip_timer_func_t)ipmip_my_attr_func_dump,
request,
node,
0);
/@ Unlock the identity context @/
ipmip_context_id_unlock(ctx->my_identities);
/@ Exit the function here, the timer callback will deal with the
reply @/
return 0;
}
}
/@ Finalize the header @/
ipmip_attr_hdr_finalize(&request->message, rhdr);
/@ Return it to the CLI context @/
ipmip_cli_message_commit(&ctx->ipmip6.ipmip, proc, request);
return 0;
}
.CE
This example provides information as to how a CLI shell would communicate with
the mobility agents CLI context.
.CS
{
/@ Define the variables required for communication @/
Ipmip_cli_daemon_t daemon;
Ipmip_cli_daemon_req_t req;
/@ Initialize the daemon request structure @/
ipmip_cli_daemon_request_init(&req);
/@ Initialize the daemon communication structure @/
ipmip_cli_daemon_init(&daemon, "mymip", IPCOM_IPD_ID_IPMIPMYMIP);
/@ Attempt to connect to the mobility agent @/
if (ipmip_cli_daemon_connect(&daemon))
{
/@ Create a LIST request @/
ipmip_cli_daemon_request_start(&req, IPMIP_MY_CLI_LIST);
/@ Issue the request to the daemon @/
if (ipmip_cli_daemon_request(&daemon, &req) == IPCOM_SUCCESS)
{
/@ Parse the reply @/
Ip_u32 identity;
Ipmip_attr_iter_t riter;
/@ Initialize an iterator. The reply should be a list of identities @/
ipmip_cli_daemon_iter_request_init(&req, &riter);
/@ Loop over the iterator until there are no more iterators present @/
while ((identity = ipmip_attr_get_u32(ipmip_attr_iter_next(&riter, IPMIP_MY_NODE_ATTR_IDENTITY))) != 0)
{
Ipmip_cli_daemon_req_t greq;
/@ Let us fetch the information regarding this particular node @/
ipmip_cli_daemon_request_init(&greq);
/@ Issue a NODE GET request @/
ipmip_cli_daemon_request_start(&greq, IPMIP_MY_CLI_GET);
/@ Indicate what node we are interested in by providing its identity @/
ipmip_attr_put_u32(&greq->reqbuf, IPMIP_MY_NODE_ATTR_IDENTITY, identity);
/@ Issue the request @/
if (ipmip_cli_daemon_request(&daemon, &greq) == IPCOM_SUCCESS)
{
Ipmip_attr_t *node;
if ((node = ipmip_cli_daemon_find_request(req, IPMIP_MY_NODE_INFO)) != IP_NULL)
{
/@ Time to dump the retrieved information @/
ipcom_printf("NAME: %s IDENTITY: %d",
ipmip_attr_payload_find_str(node, IPMIP_MY_NODE_ATTR_NAME)):
ipmip_attr_payload_find_u32(node, IPMIP_MY_NODE_ATTR_IDENTITY)):
}
}
ipmip_cli_daemon_request_release(&breq);
}
}
}
ipmip_cli_daemon_request_release(&req);
ipmip_cli_daemon_disconnect(&daemon);
}
.CE
Here's provided an extended version of the context create function originally
defined the example of ipmip_context.h which provides information on how
to create the CLI context.
.CS
struct Ipmip_my_context *my_init_func(Ipmip_proc_t *proc)
{
/@ Allocate my context; indicate the size of my overloaded structure @/
struct Ipmip_my_context *ctx = (struct Ipmip_my_context *)ipmip_context_alloc(proc, sizeof(*ctx), "mymip", IPCOM_LOG_DEBUG2, 10);
/@ Create the CLI context. There is no need to START/STOP or destroy the CLI context,
since once created, the IPMIP context will assume ownership and deal with it @/
ipmip_cli_context_create(&ctx->ipmip,
proc,
"mymip",
IPCOM_IPD_ID_IPMYMIP,
(Ipmip_cli_callback_t)ipmip_my_attr_func);
/@ Create the identity structure - we've only setup a 16 bit identity field, so set the mask to 16 bits @/
ctx->my_identities = ipmip_context_id_create(ip_offsetof(struct Ipmip_my_entities, identity), 0xFFFF);
/@ Start the context @/
ipmip_context_start(&ctx->ipmip, proc);
}
.CE
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <private/ipmip_attr.h>
#include <private/ipmip_netlink.h>
#include <private/ipmip_timer.h>
#include <private/ipmip_log.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
enum
{
IPMIP_CLI_IDENT_NONE,
IPMIP_CLI_IDENT_WIMAX
};
enum
{
IPMIP_CLI_TYPE_SYSTEM = 512,
IPMIP_CLI_TYPE_MULTICAST_ADD,
IPMIP_CLI_TYPE_MULTICAST_DEL,
IPMIP_CLI_EVENT_GET = 768,
IPMIP_CLI_EVENT_FLUSH,
IPMIP_CLI_EVENT_HISTORY_GET,
IPMIP_CLI_EVENT_HISTORY_SET,
IPMIP_CLI_LOG_LEVEL_GET,
IPMIP_CLI_LOG_LEVEL_SET,
IPMIP_CLI_CONFIG_GET,
IPMIP_CLI_NAME_LIST,
IPMIP_CLI_TYPE_BASE = 1024
};
enum
{
IPMIP_CLI_MULTICAST_ATTR_NONE,
IPMIP_CLI_MULTICAST_ATTR_CHANNEL,
IPMIP_CLI_MULTICAST_ATTR_MAX
};
enum
{
IPMIP_CLI_ITEM_NONE,
IPMIP_CLI_ITEM_EVENT,
IPMIP_CLI_ITEM_CONFIG_LINE,
IPMIP_CLI_ITEM_NAME,
IPMIP_CLI_ITEM_SIZE,
IPMIP_CLI_ITEM_MAX
};
enum
{
IPMIP_CLI_ITEM_EVENT_NONE,
IPMIP_CLI_ITEM_EVENT_TIME,
IPMIP_CLI_ITEM_EVENT_MESSAGE,
IPMIP_CLI_ITEM_EVENT_LEVEL,
IPMIP_CLI_ITEM_EVENT_MAX
};
enum
{
IPMIP_CLI_REQ_REPLY_NOCOPY = (1 << 0)
};
#define ipmip_cli_daemon_request_header(req) ((struct Ipmip_attr_header *)IPMIP_BUFFER_DATA(&(req)->reqbuf))
#define ipmip_cli_daemon_find_request(req, attr) ipmip_attr_hdr_find(ipmip_cli_daemon_request_header(req), attr)
#define ipmip_cli_daemon_find_request_data(req, attr) ipmip_attr_hdr_find_data(ipmip_cli_daemon_request_header(req), attr)
#define ipmip_cli_daemon_find_request_str(req, attr) ipmip_attr_hdr_find_str(ipmip_cli_daemon_request_header(req), attr)
#define ipmip_cli_daemon_find_request_u32(req, attr) ipmip_attr_hdr_find_u32(ipmip_cli_daemon_request_header(req), attr)
#define ipmip_cli_daemon_find_request_inet(req, attr) ipmip_attr_hdr_find_inet(ipmip_cli_daemon_request_header(req), attr)
#define ipmip_cli_daemon_find_request_inet6(req, attr) ipmip_attr_hdr_find_inet6(ipmip_cli_daemon_request_header(req), attr)
#define ipmip_cli_daemon_iter_request_init(req, iter) ipmip_attr_hdr_iter_init(ipmip_cli_daemon_request_header(req), iter)
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
struct Ipmip_context;
struct Ipmip_proc;
struct Ipmip_cli_message;
struct Ipmip_attr_iter;
typedef int (*Ipmip_cli_callback_t) (struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
struct Ipmip_cli_message *request);
typedef struct Ipmip_cli_context
{
Ip_fd sfd;
Ip_u32 subsystem;
Ipcom_list clients;
Ipmip_cli_callback_t callback;
struct Ipmip_proc *proc;
char *header;
Ip_u32 pids;
Ipcom_mutex lock;
Ip_bool busy;
void *opaque;
/**/
#ifdef IPCOM_USE_INET
struct Ip_sockaddr_in sin4;
#endif
#ifdef IPCOM_USE_INET6
struct Ip_sockaddr_in6 sin6;
#endif
} Ipmip_cli_context_t;
typedef struct Ipmip_cli_ident
{
Ip_u32 pid;
Ip_time_t timestamp;
} Ipmip_cli_ident_t;
typedef struct Ipmip_cli_message
{
Ipcom_list next;
Ipmip_cli_ident_t ident;
int remain;
Ipmip_buffer_t request;
Ipmip_buffer_t message;
Ipmip_timer_t timer;
void *opaque;
} Ipmip_cli_message_t;
typedef struct Ipmip_cli_daemon
{
Ip_fd fd;
const char *header;
Ip_u32 pid;
Ip_u32 seq;
Ip_bool broadcast;
Ipmip_buffer_t message;
} Ipmip_cli_daemon_t;
typedef struct Ipmip_cli_daemon_req
{
Ip_u32 reqtype;
Ip_u32 reqflags;
Ipmip_buffer_t reqbuf;
} Ipmip_cli_daemon_req_t;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipmip_cli_message_multicast - ipmip_cli_message_multicast
*
* This is a kernel function used internally by the MIP entity.
* Broadcast a message to all Clients. The message will be freed in this
* call.
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP. For each started mobility
* entity, there exists a mobility context which tracks configuration, system
* events, available features and started processes. The mobility context is
* created using ipmip_context_create(). See ipmip_context.h for more information
* regarding the mobility entity context singleton.
* \i proc
* The process context associated with the currently executing thread. Each
* thread and/or process in MIP must have its own unique process context.
* If a process is started using ipmip_proc_start, the process context will
* be allocated automatically by the IPMIP framework. Otherwise it must
* be allocated using ipmip_proc_alloc().
* \i cli
* CLI context
* \i channel
* The channel to broadcast on.
* \i message
* The message
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_cli_message_multicast
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_cli_context_t *cli,
Ip_u32 channel,
Ipmip_cli_message_t *message
);
/*******************************************************************************
*
* ipmip_cli_context_create - ipmip_cli_context_create
*
* If a CLI context is required within your MIP agent, this function should
* be used to create it. Once created, the IPMIP context will deal with starting
* and stopping it. It will be freed when the IPMIP context is destroyed.
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP. For each started mobility
* entity, there exists a mobility context which tracks configuration, system
* events, available features and started processes. The mobility context is
* created using ipmip_context_create(). See ipmip_context.h for more information
* regarding the mobility entity context singleton.
* \i proc
* The process context associated with the currently executing thread. Each
* thread and/or process in MIP must have its own unique process context.
* If a process is started using ipmip_proc_start, the process context will
* be allocated automatically by the IPMIP framework. Otherwise it must
* be allocated using ipmip_proc_alloc().
* \i header
* The ipmip name
* \i subsystem
* The submodule
* \i callback
* Function callback to be invoked on messages
* \ie
*
* RETURNS: IP_TRUE on success
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL Ip_bool ipmip_cli_context_create
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
const char *header,
Ip_u32 subsystem,
Ipmip_cli_callback_t callback
);
/*******************************************************************************
*
* ipmip_cli_context_destroy - ipmip_cli_context_destroy
*
* This is a kernel function used internally by the MIP entity.
* Free the global CLI context. Unless you are very certain of what you are doing
* this function should not be invoked. The IPMIP context will call it when
* the IPMIP context is being destroyed.
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP. For each started mobility
* entity, there exists a mobility context which tracks configuration, system
* events, available features and started processes. The mobility context is
* created using ipmip_context_create(). See ipmip_context.h for more information
* regarding the mobility entity context singleton.
* \i proc
* The process context associated with the currently executing thread. Each
* thread and/or process in MIP must have its own unique process context.
* If a process is started using ipmip_proc_start, the process context will
* be allocated automatically by the IPMIP framework. Otherwise it must
* be allocated using ipmip_proc_alloc().
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL void ipmip_cli_context_destroy
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc
);
/*******************************************************************************
*
* ipmip_cli_context_start - ipmip_cli_context_start
*
* This is a kernel function used internally by the MIP entity.
* Start the global CLI context. Unless you know what you are doing, this
* particularl function should most probably not be invoked. It is invoked
* by the ipmip_context_start function when the IPMIP context is started, provided
* the CLI context has been created.
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP. For each started mobility
* entity, there exists a mobility context which tracks configuration, system
* events, available features and started processes. The mobility context is
* created using ipmip_context_create(). See ipmip_context.h for more information
* regarding the mobility entity context singleton.
* \i proc
* The process context associated with the currently executing thread. Each
* thread and/or process in MIP must have its own unique process context.
* If a process is started using ipmip_proc_start, the process context will
* be allocated automatically by the IPMIP framework. Otherwise it must
* be allocated using ipmip_proc_alloc().
* \ie
*
* RETURNS: IP_TRUE on success.
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL Ip_bool ipmip_cli_context_start
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc
);
/*******************************************************************************
*
* ipmip_cli_context_stop - ipmip_cli_context_stop
*
* This is a kernel function used internally by the MIP entity.
* Stop the global CLI context. Unless you know what you are doing, this
* particular function should most probably not be invoked. It is invoked
* by the ipmip_context_stop function when the IPMIP context is stopped.
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP. For each started mobility
* entity, there exists a mobility context which tracks configuration, system
* events, available features and started processes. The mobility context is
* created using ipmip_context_create(). See ipmip_context.h for more information
* regarding the mobility entity context singleton.
* \i proc
* The process context associated with the currently executing thread. Each
* thread and/or process in MIP must have its own unique process context.
* If a process is started using ipmip_proc_start, the process context will
* be allocated automatically by the IPMIP framework. Otherwise it must
* be allocated using ipmip_proc_alloc().
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL void ipmip_cli_context_stop
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc
);
/*******************************************************************************
*
* ipmip_cli_daemon_connect - ipmip_cli_daemon_connect
*
* Connect to a CLI context using daemon info structure. This routine
* is usually used by an application that wants to connect to a mobility entity,
* The daemon info parameter must be initialized by ipmip_cli_daemon_init
*
* Parameters:
* \is
* \i daemon_info
* Info required to connect to the daemon
* \ie
*
* RETURNS: IP_TRUE on success
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_cli_daemon_connect
(
Ipmip_cli_daemon_t *daemon_info
);
/*******************************************************************************
*
* ipmip_cli_daemon_disconnect - ipmip_cli_daemon_disconnect
*
* Disconnect to a CLI context using daemon info structure
*
* Parameters:
* \is
* \i daemon_info
* Info required to connect to the daemon
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_cli_daemon_disconnect
(
Ipmip_cli_daemon_t *daemon_info
);
/*******************************************************************************
*
* ipmip_cli_daemon_init - ipmip_cli_daemon_init
*
* Initialize a daemon info structure. This function is invoked during
* setup of a mobility agent communication channel. It is usually used
* by CLI shell functions, but may also be used by inter-mobility agent
* communication modules, such as proxy mobility. The funciton initialized
* all parameters to their appropriate values. One should invoke
* ipmip_cli_daemon_connect in order to actually connect.
*
* Parameters:
* \is
* \i daemon_info
* Daemon info structure
* \i header
* The ipmip name. For example "ipmipha".
* \i pid
* The CLI pid. One of the IPD macros, such as IPCOM_IPD_ID_IPMIPHA.
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_cli_daemon_init
(
Ipmip_cli_daemon_t *daemon_info,
const char *header,
Ip_u32 pid
);
/*******************************************************************************
*
* ipmip_cli_daemon_request - ipmip_cli_daemon_request
*
* This function sends a request message to the mobility agent identified
* by the daemon_info structure. ipmip_cli_daemon_connect must have been
* invoked prior to this call. If the request is successful, the reply
* will be provided in the reqbuf parameter of the daemon_req.
*
* Parameters:
* \is
* \i daemon_info
* Daemon info
* \i daemon_req
* Daemon request information
* \ie
*
* RETURNS: IPCOM_SUCCESS on success
*
* ERRNO:
*
*/
IP_GLOBAL int ipmip_cli_daemon_request
(
Ipmip_cli_daemon_t *daemon_info,
Ipmip_cli_daemon_req_t *daemon_req
);
/*******************************************************************************
*
* ipmip_cli_daemon_recvmsg - ipmip_cli_daemon_recvmsg
*
* Receives the next message on the socket
*
* Parameters:
* \is
* \i daemon_info
* Daemon info
* \i tv
* Timeout value
* \ie
*
* RETURNS: IPCOM_SUCCESS on success
*
* ERRNO:
*
*/
IP_GLOBAL int ipmip_cli_daemon_recvmsg
(
Ipmip_cli_daemon_t *daemon_info,
struct Ip_timeval *tv
);
/*******************************************************************************
*
* ipmip_cli_daemon_request_init - ipmip_cli_daemon_request_init
*
* Initializes a daemon request structure. Sets the request parameters
* to initialized values.
*
* Parameters:
* \is
* \i daemon_req
* Daemon request information
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_cli_daemon_request_init
(
Ipmip_cli_daemon_req_t *daemon_req
);
/*******************************************************************************
*
* ipmip_cli_daemon_request_start - ipmip_cli_daemon_request_start
*
* Starts a new request using the request structure. Init must be invoked
* prior to start. Start may be invoked many times on the same structure,
* in order to reuse memory and resources without allocating new. Once
* the request structure is to be discarded, release should be called to
* free resources.
*
* Parameters:
* \is
* \i daemon_req
* Daemon request information
* \i req_type
* Request type
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_cli_daemon_request_start
(
Ipmip_cli_daemon_req_t *daemon_req,
Ip_u32 req_type
);
/*******************************************************************************
*
* ipmip_cli_daemon_request_release - ipmip_cli_daemon_request_release
*
* Release any data held in a daemon request structure.
*
* Parameters:
* \is
* \i daemon_req
* Daemon request information
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_cli_daemon_request_release
(
Ipmip_cli_daemon_req_t *daemon_req
);
/*******************************************************************************
*
* ipmip_cli_message_commit - ipmip_cli_message_commit
*
* Commit a CLI message. The request will be freed.
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP. For each started mobility
* entity, there exists a mobility context which tracks configuration, system
* events, available features and started processes. The mobility context is
* created using ipmip_context_create(). See ipmip_context.h for more information
* regarding the mobility entity context singleton.
* \i proc
* The process context associated with the currently executing thread. Each
* thread and/or process in MIP must have its own unique process context.
* If a process is started using ipmip_proc_start, the process context will
* be allocated automatically by the IPMIP framework. Otherwise it must
* be allocated using ipmip_proc_alloc().
* \i request
* The request
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL void ipmip_cli_message_commit
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_cli_message_t *request
);
/*******************************************************************************
*
* ipmip_cli_message_free - ipmip_cli_message_free
*
* Free a non-commited request.
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP. For each started mobility
* entity, there exists a mobility context which tracks configuration, system
* events, available features and started processes. The mobility context is
* created using ipmip_context_create(). See ipmip_context.h for more information
* regarding the mobility entity context singleton.
* \i proc
* The process context associated with the currently executing thread. Each
* thread and/or process in MIP must have its own unique process context.
* If a process is started using ipmip_proc_start, the process context will
* be allocated automatically by the IPMIP framework. Otherwise it must
* be allocated using ipmip_proc_alloc().
* \i req
* The request
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL void ipmip_cli_message_free
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_cli_message_t *req
);
/*******************************************************************************
*
* ipmip_cli_message_alloc - ipmip_cli_message_alloc
*
* Allocate a request.
*
* Parameters:
* \is
* \i ident
* Client Context identity
* \ie
*
* RETURNS: A CLI message structure
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL Ipmip_cli_message_t *ipmip_cli_message_alloc
(
Ipmip_cli_ident_t *ident
);
/** GLOBAL CLI RELATED METHODS AND FUNCTIONS **/
/*******************************************************************************
*
* ipmip_cli_event_next - ipmip_cli_event_next
*
* Returns the next event
*
* Parameters:
* \is
* \i iter
* The iterator
* \i message
* Pointer to the event message
* \i time
* Pointer to the event time
* \i loglevel
* Pointer to the event log level
* \ie
*
* RETURNS: IP_TRUE on success
*
* ERRNO:
*
*/
IP_PUBLIC Ip_bool ipmip_cli_event_next
(
struct Ipmip_attr_iter *iter,
const char **message,
Ip_time_t *time,
int *loglevel
);
/*******************************************************************************
*
* ipmip_cli_event_list - ipmip_cli_event_list
*
* Returns the events stored in the daemon
*
* Parameters:
* \is
* \i daemon
* The handle to the daemon
* \i req
* The request pointer
* \ie
*
* RETURNS: IPCOM_SUCCESS on success
*
* ERRNO:
*
*/
IP_PUBLIC int ipmip_cli_event_list
(
Ipmip_cli_daemon_t *daemon,
Ipmip_cli_daemon_req_t *req
);
/*******************************************************************************
*
* ipmip_cli_event_flush - ipmip_cli_event_flush
*
* Flush all events stored in the daemon
*
* Parameters:
* \is
* \i daemon
* The handle to the daemon
* \ie
*
* RETURNS: IPCOM_SUCCESS on success
*
* ERRNO:
*
*/
IP_PUBLIC int ipmip_cli_event_flush
(
Ipmip_cli_daemon_t *daemon
);
/*******************************************************************************
*
* ipmip_cli_event_print - ipmip_cli_event_print
*
* Print all events with loglevels more or equal than the provided
*
* Parameters:
* \is
* \i proc
* The process context associated with the currently executing thread. Each
* thread and/or process in MIP must have its own unique process context.
* If a process is started using ipmip_proc_start, the process context will
* be allocated automatically by the IPMIP framework. Otherwise it must
* be allocated using ipmip_proc_alloc().
* \i daemon
* The handle to the daemon
* \i loglevel
* The indicated loglevel
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_PUBLIC void ipmip_cli_event_print
(
struct Ipmip_proc *proc,
Ipmip_cli_daemon_t *daemon,
int loglevel
);
/*******************************************************************************
*
* ipmip_cli_name_list - ipmip_cli_name_list
*
* Returns the named entities availble in the daemon
*
* Parameters:
* \is
* \i daemon
* The handle to the daemon
* \i req
* The request pointer
* \ie
*
* RETURNS: IPCOM_SUCCESS on success
*
* ERRNO:
*
*/
IP_PUBLIC int ipmip_cli_name_list
(
Ipmip_cli_daemon_t *daemon,
Ipmip_cli_daemon_req_t *req
);
/*******************************************************************************
*
* ipmip_cli_name_next - ipmip_cli_name_next
*
* Returns the next named entity
*
* Parameters:
* \is
* \i iter
* The iterator
* \i config
* Pointer to the config line
* \ie
*
* RETURNS: Next name
*
* ERRNO:
*
*/
IP_PUBLIC const char * ipmip_cli_name_next
(
struct Ipmip_attr_iter *iter
);
/*******************************************************************************
*
* ipmip_cli_config_next - ipmip_cli_config_next
*
* Returns the next configuration line
*
* Parameters:
* \is
* \i iter
* The iterator
* \i config
* Pointer to the config line
* \ie
*
* RETURNS: Next configuration line
*
* ERRNO:
*
*/
IP_PUBLIC const char * ipmip_cli_config_next
(
struct Ipmip_attr_iter *iter
);
/*******************************************************************************
*
* ipmip_cli_config_list - ipmip_cli_config_list
*
* Returns the configuration stored in the daemon
*
* Parameters:
* \is
* \i daemon
* The handle to the daemon
* \i req
* The request pointer
* \i name
* Configuration name
* \ie
*
* RETURNS: IPCOM_SUCCESS on success
*
* ERRNO:
*
*/
IP_PUBLIC int ipmip_cli_config_list
(
Ipmip_cli_daemon_t *daemon,
Ipmip_cli_daemon_req_t *req,
const char *name
);
/*******************************************************************************
*
* ipmip_cli_config_print - ipmip_cli_config_print
*
* Print all configuration lines belonging to the named configuration. Or all
* if no NAME has been specified
*
* Parameters:
* \is
* \i proc
* The process context associated with the currently executing thread. Each
* thread and/or process in MIP must have its own unique process context.
* If a process is started using ipmip_proc_start, the process context will
* be allocated automatically by the IPMIP framework. Otherwise it must
* be allocated using ipmip_proc_alloc().
* \i daemon
* The handle to the daemon
* \i name
* The configuration name
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_PUBLIC void ipmip_cli_config_print
(
struct Ipmip_proc *proc,
Ipmip_cli_daemon_t *daemon,
const char *name
);
/*******************************************************************************
*
* ipmip_cli_config_printf - ipmip_cli_config_printf
*
* Put a configuration line in a request
*
* Parameters:
* \is
* \i reqbuf
* Request buffer
* \i format
* The format
* \i ...
* The 'printf' arguments.
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_cli_config_printf
(
struct Ipmip_buffer *reqbuf,
const char *format,
...
);
/*******************************************************************************
*
* ipmip_cli_set_name - ipmip_cli_set_name
*
* Specify what NAMED item we're looking for
*
* Parameters:
* \is
* \i req
* Request
* \i name
* Configuration name
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_PUBLIC void ipmip_cli_set_name
(
Ipmip_cli_daemon_req_t *req,
const char *name
);
/*******************************************************************************
*
* ipmip_cli_set_size - ipmip_cli_set_size
*
* Specify a size attribute
*
* Parameters:
* \is
* \i req
* Request
* \i size
* Size
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_PUBLIC void ipmip_cli_set_size
(
Ipmip_cli_daemon_req_t *req,
Ip_u32 size
);
/*******************************************************************************
*
* ipmip_cli_shell_cmd - ipmip_cli_shell_cmd
*
* Process global CLI commands
*
* Parameters:
* \is
* \i argc
* Number of arguments
* \i argv
* Arguments
* \i proc
* The process context associated with the currently executing thread. Each
* thread and/or process in MIP must have its own unique process context.
* If a process is started using ipmip_proc_start, the process context will
* be allocated automatically by the IPMIP framework. Otherwise it must
* be allocated using ipmip_proc_alloc().
* \i daemon
* Daemon connection
* \ie
*
* RETURNS: > 0 syntax error, 0 = success
*
* ERRNO:
*
*/
IP_GLOBAL int ipmip_cli_shell_cmd
(
int argc,
char **argv,
struct Ipmip_proc *proc,
struct Ipmip_cli_daemon *daemon
);
/*******************************************************************************
*
* ipmip_cli_shell_usage - ipmip_cli_shell_usage
*
* Print usage information for MIP related commands
*
* Parameters:
* \is
* \i proc
* The process context associated with the currently executing thread. Each
* thread and/or process in MIP must have its own unique process context.
* If a process is started using ipmip_proc_start, the process context will
* be allocated automatically by the IPMIP framework. Otherwise it must
* be allocated using ipmip_proc_alloc().
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_cli_shell_usage
(
struct Ipmip_proc *proc
);
/*******************************************************************************
*
* ipmip_cli_loglevel_set - ipmip_cli_loglevel_set
*
* Set the loglevel in the daemon
*
* Parameters:
* \is
* \i daemon
* The handle to the daemon
* \i loglevel
* The loglevel
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_PUBLIC void ipmip_cli_loglevel_set
(
Ipmip_cli_daemon_t *daemon,
int loglevel
);
/*******************************************************************************
*
* ipmip_cli_multicast_add - ipmip_cli_multicast_add
*
* Start listening to a multicast channel
*
* Parameters:
* \is
* \i daemon
* The handle to the daemon
* \i channel
* The channel
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_PUBLIC void ipmip_cli_multicast_add
(
Ipmip_cli_daemon_t *daemon,
Ip_u32 channel
);
/*******************************************************************************
*
* ipmip_cli_multicast_del - ipmip_cli_multicast_del
*
* Stop listening to a multicast channel
*
* Parameters:
* \is
* \i daemon
* The handle to the daemon
* \i channel
* The channel
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_PUBLIC void ipmip_cli_multicast_del
(
Ipmip_cli_daemon_t *daemon,
Ip_u32 channel
);
/*******************************************************************************
*
* ipmip_cli_loglevel_get - ipmip_cli_loglevel_get
*
* Get the loglevel priority from the daemon
*
* Parameters:
* \is
* \i daemon
* The handle to the daemon
* \ie
*
* RETURNS: The loglevel priority
*
* ERRNO:
*
*/
IP_PUBLIC Ip_u32 ipmip_cli_loglevel_get
(
Ipmip_cli_daemon_t *daemon
);
/*******************************************************************************
*
* ipmip_cli_history_set - ipmip_cli_history_set
*
* Set the history size in the daemon
*
* Parameters:
* \is
* \i daemon
* The handle to the daemon
* \i history
* The history size
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_PUBLIC void ipmip_cli_history_set
(
Ipmip_cli_daemon_t *daemon,
Ip_u32 history
);
/*******************************************************************************
*
* ipmip_cli_history_get - ipmip_cli_history_get
*
* Get the history size from the daemon
*
* Parameters:
* \is
* \i daemon
* The handle to the daemon
* \ie
*
* RETURNS: The history size
*
* ERRNO:
*
*/
IP_PUBLIC Ip_u32 ipmip_cli_history_get
(
Ipmip_cli_daemon_t *daemon
);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/