original files of m241

This commit is contained in:
neelimap
2026-07-30 11:19:44 +05:30
parent 170c2b3f3a
commit afc7070c1f
12254 changed files with 7655111 additions and 0 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,489 @@
/* ipmip_buffer.h - ipmip_buffer.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip_buffer.h,v $ $Revision: 1.9 $
* $Source: /home/interpeak/CVSRoot/ipmip/include/private/ipmip_buffer.h,v $
* $Author: jhorteli $ $Date: 2010-12-07 09:55:01 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
******************************************************************************
*/
#ifndef IPMIP_BUFFER_H
#define IPMIP_BUFFER_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
* Base implementation of the generic buffer management used in the MIP
* products
*/
/*
DESCRIPTION
Base implementation of the generic buffer management used in the MIP
products. The buffers are used for most everything related to message
handling within the MIP system. Both for internal messages and for
receiving and sending packets. The data associated with the buffer may
be re-allocated or modified internally when using append or get operations,
so a pointer in to a buffer MAY NOT be valid after invoking such routines.
EXAMPLE
These examples show how the various buffer manipulation functions should
be used.
.CS
{
Ipmip_buffer_t mybuf;
int off;
char *data;
/@ Initialize the buffer @/
ipmip_buffer_init(&mybuf);
/@ Get the next unused 40 bytes from the buffer. Make certain it
is zero before providing it to the user @/
data = ipmip_buffer_get_zero(40);
/@ Set the 40 bytes to 0x1 @/
ipcom_memset(data, 0x1, 40);
/@ Shrink the buffer with 20 bytes @/
ipmip_buffer_shrink(data, 20);
/@ Append another 30 bytes, with NULL data. This is the same as
ipmip_buffer_get, really. @/
off = ipmip_buffer_append(&mybuf, IP_NULL, 30);
/@ Transform the offset value returned to us by ipmip_buffer_append
to an appropriate pointer into the buffer @/
data = ipmip_buffer_offset(&mybuf, data);
/@ Set those 30 bytes to 0x2 @/
ipcom_memset(data, 0x2, 30);
/@ Should print 20 0x1 and 30 0x2. @/
for (off = 0; off < IPMIP_BUFFER_SIZE(&mybuf); off++)
{
data = ipmip_buffer_offset(&mybuf, off);
ipcom_printf("0x%x\n", *data);
}
/@ Free the resources associated with the buffer @/
ipmip_buffer_release(&mybuf);
}
.CE
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
#define IPMIP_BUFFER_SIZE(buf) ((buf)->offset)
#define IPMIP_BUFFER_DATA(buf) ((buf)->head)
#define IPMIP_BUFFER_PTR(buf) ((void *)IPMIP_BUFFER_DATA((buf)))
#define IPMIP_BUFFER_CURRENT(buf) ((void *)(&(buf)->head[IPMIP_BUFFER_SIZE(buf)]))
#define IPMIP_BUFFER_REMAIN(buf) ((buf)->size - (buf)->offset)
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
typedef struct Ipmip_buffer
{
Ip_u8 *head; /* Pointer to buffer */
Ip_size_t offset; /* Currently used size */
Ip_size_t size; /* Total size of buffer */
} Ipmip_buffer_t;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipmip_buffer_init - ipmip_buffer_init
*
* Initialize a buffer structure. Setup the base parameters. This function does
* not allocate any resources, it merely prepares the buffer for use.
*
* Parameters:
* \is
* \i buf
* A pointer to a dynamic mobility buffer. See ipmip_buffer.h
* for more information regarding dynamic buffers and their capabilities.
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*
*/
IP_GLOBAL void ipmip_buffer_init
(
Ipmip_buffer_t *buf
);
/*******************************************************************************
*
* ipmip_buffer_release - ipmip_buffer_release
*
* Release any resources associated with a buffer.
*
* Parameters:
* \is
* \i buf
* A pointer to an initialized dynamic mobility buffer. See ipmip_buffer.h
* for more information regarding dynamic buffers and their capabilities.
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*
*/
IP_GLOBAL void ipmip_buffer_release
(
Ipmip_buffer_t *buf
);
/*******************************************************************************
*
* ipmip_buffer_shrink - ipmip_buffer_shrink
*
* Shrink the used buffer space to the provided value. Will move the offset
* and size pointers to resize the buffer. No memory will be freed by this
* function. Any subsequent append or get operation will reuse memory
* marked as unused by this routine.
*
* Parameters:
* \is
* \i buf
* A pointer to an initialized dynamic mobility buffer. See ipmip_buffer.h
* for more information regarding dynamic buffers and their capabilities.
* \i size
* The size of the buffer
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*
*/
IP_GLOBAL void ipmip_buffer_shrink
(
Ipmip_buffer_t *buf,
Ip_size_t size
);
/*******************************************************************************
*
* ipmip_buffer_delete_header - ipmip_buffer_delete_header
*
* Remove the size first bytes of the buffer.
*
* Parameters:
* \is
* \i buf
* A pointer to an initialized dynamic mobility buffer. See ipmip_buffer.h
* for more information regarding dynamic buffers and their capabilities.
* \i size
* The size to remove
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*
*/
IP_GLOBAL void ipmip_buffer_delete_header
(
Ipmip_buffer_t *buf,
Ip_size_t size
);
/*******************************************************************************
*
* ipmip_buffer_delete_tail - ipmip_buffer_delete_tail
*
* Remove the size last bytes of the buffer. Will invoke ipmip_buffer_shrink
* with the appropriate parameters.
*
* Parameters:
* \is
* \i buf
* A pointer to an initialized dynamic mobility buffer. See ipmip_buffer.h
* for more information regarding dynamic buffers and their capabilities.
* \i size
* The size to remove
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*
*/
IP_GLOBAL void ipmip_buffer_delete_tail
(
Ipmip_buffer_t *buf,
Ip_size_t size
);
/*******************************************************************************
*
* ipmip_buffer_reserve - ipmip_buffer_reserve
*
* Increase the available buffer [allocated memory] with the
* provided value if ncessary. If there is not enough memory available to
* serve the request, the memory block associated with the buffer will
* be re-allocated.
*
* Parameters:
* \is
* \i buf
* A pointer to an initialized dynamic mobility buffer. See ipmip_buffer.h
* for more information regarding dynamic buffers and their capabilities.
* \i size
* The size to expand with.
* \ie
*
* RETURNS: IP_TRUE if successful
*
* ERRNO:
*
*
*/
IP_GLOBAL Ip_bool ipmip_buffer_reserve
(
Ipmip_buffer_t *buf,
Ip_size_t size
);
/*******************************************************************************
*
* ipmip_buffer_append - ipmip_buffer_append
*
* Append data to a buffer pointer. Will invoke ipmip_buffer_reserve if not
* enough space is available to serve the request.
*
* Parameters:
* \is
* \i buf
* A pointer to an initialized dynamic mobility buffer. See ipmip_buffer.h
* for more information regarding dynamic buffers and their capabilities.
* \i data
* Data block
* \i size
* Size of data block.
* \ie
*
* RETURNS: The offset to the stored data if successful, -1 otherwise.
*
* ERRNO:
*
*
*/
IP_GLOBAL int ipmip_buffer_append
(
Ipmip_buffer_t *buf,
const void *data,
Ip_size_t size
);
/*******************************************************************************
*
* ipmip_buffer_zero - ipmip_buffer_zero
*
* Append zero data to a buffer pointer. Will reserve a block of size bytes
* and guarantee that it is properly memset to 0.
*
* Parameters:
* \is
* \i buf
* A pointer to an initialized dynamic mobility buffer. See ipmip_buffer.h
* for more information regarding dynamic buffers and their capabilities.
* \i size
* Size of data block.
* \ie
*
* RETURNS: The offset to the stored data if successful, -1 otherwise.
*
* ERRNO:
*
*
*/
IP_GLOBAL int ipmip_buffer_zero
(
Ipmip_buffer_t *buf,
Ip_size_t size
);
/*******************************************************************************
*
* ipmip_buffer_assign - ipmip_buffer_assign
*
* Assign the buffer values held by sbuf to dbuf, and
* release anything previously held by dbuf.
*
* Parameters:
* \is
* \i dbuf
* Buffer pointer.
* \i sbuf
* Buffer pointer
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_buffer_assign
(
Ipmip_buffer_t *dbuf,
Ipmip_buffer_t *sbuf
);
/*******************************************************************************
*
* ipmip_buffer_get - ipmip_buffer_get
*
* Append size bytes and return the pointer to the
* verified block; this pointer is only valid until the next
* append call.
* Parameters:
* \is
* \i buf
* A pointer to an initialized dynamic mobility buffer. See ipmip_buffer.h
* for more information regarding dynamic buffers and their capabilities.
* \i size
* Size of data block.
* \ie
*
* RETURNS: The pointer
*
* ERRNO:
*
*
*/
IP_GLOBAL void* ipmip_buffer_get
(
Ipmip_buffer_t *buf,
Ip_size_t size
);
/*******************************************************************************
*
* ipmip_buffer_get_zero - ipmip_buffer_get_zero
*
* Append size bytes and return the pointer to the
* verified block; this pointer is only valid until the next
* append call. The memory area will be zeroed
* Parameters:
* \is
* \i buf
* A pointer to an initialized dynamic mobility buffer. See ipmip_buffer.h
* for more information regarding dynamic buffers and their capabilities.
* \i size
* Size of data block.
* \ie
*
* RETURNS: The pointer
*
* ERRNO:
*
*
*/
IP_GLOBAL void* ipmip_buffer_get_zero
(
Ipmip_buffer_t *buf,
Ip_size_t size
);
/*******************************************************************************
*
* ipmip_buffer_offset - ipmip_buffer_offset
*
* Return the pointer to the offset. This pointer is only valid until
* the buffer is modified by an append, reserve or get call.
*
* Parameters:
* \is
* \i buf
* A pointer to an initialized dynamic mobility buffer. See ipmip_buffer.h
* for more information regarding dynamic buffers and their capabilities.
* \i offset
* The offset
* \ie
*
* RETURNS: The pointer
*
* ERRNO:
*
*
*/
IP_GLOBAL void* ipmip_buffer_offset
(
Ipmip_buffer_t *buf,
int offset
);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,978 @@
/* ipmip_context.h - ipmip_context.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip_context.h,v $ $Revision: 1.23 $
* $Source: /home/interpeak/CVSRoot/ipmip/include/private/ipmip_context.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_CONTEXT_H
#define IPMIP_CONTEXT_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
* MIP context definitions. Deals with process creation, and context
* instantiations.
*/
/*
DESCRIPTION
MIP context definitions. Deals with process creation, and context
instantiations.
There are two types of contexts in the MIP setup, one is the Mobility
Context, which exists only one per mobility agent, and the second is
the process context which exists one for each thread/process.
Most functions in the MIP code base requires both the mobility context and
process context to be passed to it as arguments.
The mobility context is inherited by higher layers (so far IPMIP6 and IPMIP4)
which defines additional functionality beyond what is provided by the base
IPMIP implementation. The base IPMIP implementation initializes and handles
features such as timers, DHCP for v4 and v6, packet buffer management, ARP,
command line interface communication and netlink setup as well as logging
and event management.
EXAMPLE
To create, initialize, start stop and destroy a context.
.CS
/@ Just some sort of entity that one could have in a mobility systemm which
requires a unique identifier @/
struct Ipmip_my_entities
{
char name[16]; /@ Name for this entity @/
unsigned short identity; /@ Identity for this entity @/
Ipmip_timer_lock_t *lock; /@ Private lock for this entity @/
Ipmip_timer_t timer; /@ Timer handle for doing timers @/
Ip_u32 my_ip_address; /@ IP Address of this entity @/
struct Ipmip_if *my_interface; /@ Interface this entity is on @/
};
struct Ipmip_my_context
{
Ipmip_context_t ipmip; /@ Basic IPMIP context @/
Ipmip_proc_t *my_proc_func; /@ Container for a process of some sort @/
Ipmip_context_id_t *my_identities; /@ My identity context @/
Ipmip_dhcp_node_t my_dhcp; /@ DHCP context registration handle @/
Ip_u32 my_dhcp_server_address; /@ DHCP server address @/
Ipmip_dhcp6_node_t my_dhcp6; /@ DHCPv6 context registration handle @/
struct Ip_in6_addr my_dhcp6_server_address; /@ DHCP6 server address @/
Ipmip_timer_lock_t *my_lock; /@ A global lock @/
}
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 any subcontext such as DHCP, CLI - see the appropriate module for information @/
/@ 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);
/@ Create a lock we can use for serialization. This lock will be used by various examples,
and one may want to create more locks in order to not cause bottlenecks. @/
ctx->my_lock = ipmip_timer_lock_alloc(&ctx->ipmip, proc, IP_NULL, IP_NULL);
/@ Start the context @/
ipmip_context_start(&ctx->ipmip, proc);
}
void my_stop_func(Ipmip_proc_t *proc, struct Ipmip_my_context *ctx)
{
/@ Stop the context @/
ipmip_context_stop(&ctx->ipmip, proc);
/@ Destroy the identity context @/
ipmip_context_id_destroy(ctx->my_identities);
/@ Destroy the big lock @/
ipmip_timer_lock_destroy(&ctx->ipmip, proc, ctx->my_lock);
/@ Destroy the context @/
ipmip_context_destroy(&ctx->ipmip, proc);
}
static void my_proc_func(struct Ipmip_my_context *ctx,
Ipmip_proc_t *proc,
void *extra_arg)
{
/@ We may continue to do what we do until we're told to stop @/
for (; proc->quit != IP_TRUE;)
{
ipcom_sleep(1);
}
}
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)
{
/@ Begin by locking down the identity containter @/
ipmip_context_id_lock(ctx->my_identities);
/@ Free the unique identifier and unreference the entity @/
ipmip_context_id_release(ctx->my_identities, node);
/@ Finish up by unlocking the identity containter @/
ipmip_context_id_unlock(ctx->my_identities);
/@ Free the lock @/
ipmip_timer_lock_destroy(&ctx->ipmip, proc, node->lock);
/@ Free the entity @/
ipcom_free(node);
}
/@ This timer is done - finalize processing @/
return IPMIP_TIMER_RET_DONE;
}
static void ipmip_my_entity_delete_foreach(struct Ipmip_my_context *ctx,
Ipmip_proc_t *proc,
struct Ipmip_my_entities *node,
void *unused1,
void *unused2)
{
/@ Schedule a destruction timer - we're holding the identity lock,
but we need to acquire the node's own lock as well. @/
ipmip_timer_request(&ctx->ipmip,
proc,
&node->timer,
node->lock,
(Ipmip_timer_func_t)ipmip_my_entity_delete,
node,
IP_NULL,
0);
}
void main(int argc, char *argv[])
{
/@ For threads started with ipmip_proc_start, the proc structure is allocated
automatically, for other types of threads such as main, we need to
allocate it manually @/
Ipmip_proc_t *proc = ipmip_proc_alloc();
struct Ipmip_my_context *ctx = my_init_func(proc);
struct Ipmip_my_entities *node;
/@ Start a new process, using the ipmip_proc_start method - Store its
process context handle so that we may kill it later @/
ctx->my_proc_func = ipmip_proc_start(&ctx->ipmip, proc, "my_proc_func", (Ipmip_proc_func_t)my_proc_func, IP_NULL);
/@ Create an entity of some sort @/
node = ipcom_calloc(1, sizeof(*node));
ipcom_strcpy(node->name, "my.name@my.domain");
/@ More or less all nodes in the MIP system requires a locking mechanism.
See ipmip_timer.h for more extensive explanations @/
node->lock = ipmip_timer_lock(&ctx->ipmip, proc, IP_NULL, IP_NULL);
/@ Initialize the timer @/
IPMIP_TIMER_INIT(&node->timer);
/@ Allocate an unique ID @/
/@ Begin by locking down the identity containter @/
ipmip_context_id_lock(ctx->my_identities);
/@ This function will initialize the identity variable, and reference the node @/
ipmip_context_id_allocate(ctx->idents, node);
/@ Finish up by unlocking the identity containter @/
ipmip_context_id_unlock(ctx->my_identities);
/@ Free all nodes allocated @/
/@ Begin by locking down the identity containter @/
ipmip_context_id_lock(ctx->my_identities);
/@ Invoke the callback for each entity in the identity table @/
ipmip_context_id_foreach(&ctx->ipmip,
proc,
ctx->my_identities,
(Ipmip_util_hash_foreach_t)ipmip_my_entity_delete_foreach,
IP_NULL,
IP_NULL);
/@ Finish up by unlocking the identity containter @/
ipmip_context_id_unlock(ctx->my_identities);
/@ Wait for the nodes to have terminated properly. They're terminated
by a timer, so we need to wait until its completed @/
ipmip_context_id_empty(ctx->my_identities. -1);
/@ Stop the thread and collect it @/
ipmip_proc_stop(&ctx->ipmip, proc, ctx->my_proc_func, IP_NULL, IP_NULL);
/@ Stop the context @/
my_stop_func(proc, ctx);
/@ Destroy the process context - If ipmip_proc_stop is used, @/
ipmip_proc_destroy(proc);
}
.CE
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include "ipmip_ntop.h"
#include <ipcom_os.h>
#include <ipcom_hash.h>
#include <ipcom_list.h>
#include <private/ipmip_util.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
struct Ipmip_timer_context;
struct Ipmip_cli_context;
struct Ipmip_pktbuf_context;
struct Ipmip_pktbuf;
struct Ipmip_ntop;
struct Ipmip_netlink_handle;
struct Ipmip_netlink_context;
struct Ipmip_dhcp_context;
struct Ipmip_arp_context;
struct Ipmip_dhcp6_context;
struct Ipmip_pktbuf_pktaux;
struct Ipmip_dhcp6_embedded_server;
typedef struct Ipmip_context_log
{
Ipcom_mutex events_lock;
Ipcom_list events;
Ip_size_t events_max;
Ip_u32 loglevel;
} Ipmip_context_log_t;
typedef struct Ipmip_context_id
{
/**/
Ipcom_mutex identity_lock;
Ip_u32 identity;
Ipcom_hash *identity_table;
Ipcom_block identity_empty;
Ip_ptrdiff_t identity_offset;
Ip_u32 identity_mask;
} Ipmip_context_id_t;
/**/
typedef struct Ipmip_context
{
struct Ipmip_pktbuf_context *pktbuf;
struct Ipmip_timer_context *timer;
struct Ipmip_cli_context *cli;
struct Ipmip_netlink_context *nl;
#ifdef IPMIP_USE_INET
struct Ipmip_dhcp_context *dhcp;
struct Ipmip_arp_context *arp;
#endif
#ifdef IPMIP_USE_INET6
struct Ipmip_dhcp6_context *dhcp6;
#ifdef IP_PORT_LAS
struct Ipmip_dhcp6_embedded_server *dhcps6;
#endif
#endif
Ip_fd fd_ioctl;
struct Ipmip_netlink_handle *nl_req;
char *name;
int vr;
struct Ipmip_pktbuf_pktaux *pktaux;
/**/
/**/
Ipmip_context_log_t log;
} Ipmip_context_t;
/* Per thread specific information */
typedef struct Ipmip_proc
{
Ipmip_ntop_t ntop;
Ipcom_block proc_block;
Ip_bool quit;
Ip_pid_t pid;
union
{
Ip_u32 arg32;
} args;
} Ipmip_proc_t;
/**/
typedef void (*Ipmip_proc_func_t)
(
Ipmip_context_t *context,
Ipmip_proc_t *proc,
void *arg
);
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipmip_context_alloc - ipmip_context_alloc
*
* Allocate the mobility context. There exists only ONE context per mobility
* entity. The context contains information regarding timers, loglevels, history,
* packet buffers, open sockets and various sub-context functionalities such as
* DHCP, DHCPv6. This context is usually part of a larger entity specific
* context which will define additional funcitonaly beyond what the IPMIP module
* specifies.
*
* Parameters:
* \is
* \i proc
* \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 size
* Total size of context.
* \ie
*
* RETURNS: The newly allocated packet context on success.
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL Ipmip_context_t *ipmip_context_alloc
(
Ipmip_proc_t *proc,
Ip_size_t size,
const char *name,
int loglevel,
int evsize
);
/*******************************************************************************
*
* ipmip_context_destroy - ipmip_context_destroy
*
* Destroys the MIP context, and all sub-contexts allocated by it.
*
* 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_context_destroy
(
Ipmip_context_t *ctx,
Ipmip_proc_t *proc
);
/*******************************************************************************
*
* ipmip_context_stop - ipmip_context_stop
*
* Stop the context. Terminates all current processes, threads and activities
* controlled by the IPMIP context.
*
* 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_context_stop
(
Ipmip_context_t *ctx,
Ipmip_proc_t *proc
);
/*******************************************************************************
*
* ipmip_context_start - ipmip_context_start
*
* Start the context. Start the required processes, threads and event loops
* controlled by the IPMIP context.
*
* 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_context_start
(
Ipmip_context_t *ctx,
Ipmip_proc_t *proc
);
/*******************************************************************************
*
* ipmip_proc_start - ipmip_proc_start
*
* This method starts a new process and returns the process context for that
* newly started process. The process context contains a 'quit' indicator,
* which when set indicates that the mobility agent wants this process to
* exit in a controlled fashion.
*
* 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 proc_name
* Name of the process
* \i func
* Thread start function
* \i arg
* Opaque argument
* \ie
*
* RETURNS: Thread context, if successful.
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_proc_t * ipmip_proc_start
(
Ipmip_context_t *ctx,
Ipmip_proc_t *proc,
const char *proc_name,
Ipmip_proc_func_t func,
void *arg
);
/*******************************************************************************
*
* ipmip_proc_stop - ipmip_proc_stop
*
* Stop a specific process context and free the process context associated
* with it. Usually this function sets the 'quit' indicator in the
* process context and expects the process to see it.
* If that is not the case, such as that the process is waiting on a blocking
* call or any other such mechanism, it is possible to provide a wakeup function
* and opaque argument to the stop function. This wakeup function will be
* invoked at the proper location during the stop procedure. It is expected that
* the wakeup function interrupts whatever event the process is waiting for,
* and that it inspects the quit indicator and then exits accordingly.
*
* 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 stop_proc
* Thread context to stop
* \i func
* Wakeup function
* \i arg
* Opaque argument
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_proc_stop
(
Ipmip_context_t *ctx,
Ipmip_proc_t *proc,
Ipmip_proc_t *stop_proc,
Ipmip_proc_func_t func,
void *arg
);
/*******************************************************************************
*
* ipmip_proc_collect - ipmip_proc_collect
*
* See if a particular process has been stopped. If the process has indeed
* been stopped, the process context belonging to it will be freed by this
* function 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 stop_proc
* Thread context
* \ie
*
* RETURNS: IP_TRUE if the process was collected.
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_proc_collect
(
Ipmip_context_t *ctx,
Ipmip_proc_t *proc,
Ipmip_proc_t *stop_proc
);
/*******************************************************************************
*
* ipmip_proc_destroy - ipmip_proc_destroy
*
* Destroy the process context and free all resources associated with it. Should
* only be used on process contexts which has been allocated manually by
* ipmip_proc_alloc. All other process contexts should be dealt with by
* ipmip_proc_stop or ipmip_proc_collect.
*
* 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_proc_destroy
(
Ipmip_proc_t *proc
);
/*******************************************************************************
*
* ipmip_proc_alloc - ipmip_proc_alloc
*
* Creates a process context.
*
* Parameters:
*
* None.
*
* RETURNS: A process context on success
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_proc_t * ipmip_proc_alloc
(
void
);
/*******************************************************************************
*
* ipmip_context_id_create - ipmip_context_id_create
*
* Create an identity context. An identity context creates a hash table
* in which each object is guaranteed an unique identity value stored in the
* object offset provided in the create call.
*
* Parameters:
*
* \is
* \i offset
* The offset in the object where the identity is stored
* \i mask
* The mask to determine the size of identity
* \ie
*
* RETURNS: A new context
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_context_id_t * ipmip_context_id_create
(
Ip_ptrdiff_t offset,
Ip_u32 mask
);
/*******************************************************************************
*
* ipmip_context_id_destroy - ipmip_context_id_destroy
*
* Destroy an identity context
*
* Parameters:
*
* \is
* \i idctx
* The context to destroy
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_context_id_destroy
(
Ipmip_context_id_t *idctx
);
/*******************************************************************************
*
* ipmip_context_id_allocate - ipmip_context_id_allocate
*
* Allocate an identity value.If this object can be accessed simultaneously,
* you must lock it using ipmip_context_id_lock prior to the call
*
* Parameters:
*
* \is
* \i idctx
* Identity Context
* \i obj
* Object to allocate identity for
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_context_id_allocate
(
Ipmip_context_id_t *idctx,
void *obj
);
/*******************************************************************************
*
* ipmip_context_id_release - ipmip_context_id_release
*
* Release an identity value.If this object can be accessed simultaneously,
* you must lock it using ipmip_context_id_lock prior to the call
*
* Parameters:
*
* \is
* \i ctx
* Identity Context
* \i obj
* Object
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_context_id_release
(
Ipmip_context_id_t *idctx,
void *obj
);
/*******************************************************************************
*
* ipmip_context_id_get - ipmip_context_id_get
*
* Get an identity object. If this object can be accessed simultaneously,
* you must lock it using ipmip_context_id_lock prior to the call
*
* Parameters:
*
* \is
* \i ctx
* Identity Context
* \i ident
* Identity
* \ie
*
* RETURNS: The object allocating this identity or IP_NULL
*
* ERRNO:
*
*/
IP_GLOBAL void* ipmip_context_id_get
(
Ipmip_context_id_t *idctx,
Ip_u32 ident
);
/*******************************************************************************
*
* ipmip_context_id_empty - ipmip_context_id_empty
*
* Wait for the identity table to go empty. If a wait timeout is specified,
* the function while wait for at most wait_timeout milliseconds. If the
* context identity table is not empty by then, IP_FALSE will be returned.
*
* If -1 is specified, the function will wait indefinately.
*
* Parameters:
*
* \is
* \i ctx
* Identity Context
* \i wait_timeout
* Wait timeout in milliseconds, -1 specifies forever.
* \ie
*
* RETURNS: IP_TRUE if the identity context is empty
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_context_id_empty
(
Ipmip_context_id_t *idctx,
int wait_timeout
);
/*******************************************************************************
*
* ipmip_context_id_foreach - ipmip_context_id_foreach
*
* Go through an identity table and invoke each object through the
* callback
*
* Parameters:
* \is
* \i ctx
* Context
* \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 idctx
* Identity table
* \i func
* Object callback functions
* \i arg1
* Opaque argument 1
* \i arg2
* Opaque argument 2
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_context_id_foreach
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_context_id_t *idctx,
Ipmip_util_hash_foreach_t func,
void *arg1,
void *arg2
);
/*******************************************************************************
*
* ipmip_context_id_lock - ipmip_context_id_lock
*
* Lock an identity context. Identity context should always be locked during
* operations such as allocate, release, get or foreach. One should never
* attempt to unconditionally acquire other locks while holding the identity
* locks, since they are supposed to be atomic in a sense, only to be held
* to a bare minimum.
*
* Parameters:
*
* \is
* \i ctx
* Identity Context
* \ie
*
* SYNOPSIS
* \ss
* void ipmip_context_id_lock
* (
* Ipmip_context_id_t *ctx
* )
* \se
*
* RETURNS: No return value
*
* ERRNO:
*
*/
#define ipmip_context_id_lock(ctx) ipcom_mutex_lock((ctx)->identity_lock)
/*******************************************************************************
*
* ipmip_context_id_unlock - ipmip_context_id_unlock
*
* Unlock an identity context
*
* Parameters:
*
* \is
* \i ctx
* Identity Context
* \ie
*
* SYNOPSIS
* \ss
* void ipmip_context_id_unlock
* (
* Ipmip_context_id_t *ctx
* )
* \se
*
* RETURNS: No return value
*
* ERRNO:
*
*/
#define ipmip_context_id_unlock(ctx) ipcom_mutex_unlock((ctx)->identity_lock)
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,814 @@
/* ipmip_dhcp6.h - ipmip_dhcp6.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip_dhcp6.h,v $ $Revision: 1.7 $
* $Source: /home/interpeak/CVSRoot/ipmip/include/private/ipmip_dhcp6.h,v $
* $Author: jhorteli $ $Date: 2010-12-07 09:55:01 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
******************************************************************************
*/
#ifndef IPMIP_DHCP6_H
#define IPMIP_DHCP6_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
DESCRIPTION
DHCP6 proxy and server implementation used to integrate DHCP6 with various
MIP DHCP6 requirements. DHCP6 in primarily used with Proxy Mobility. This
module allows for a MIP entity to send, receive and process DHCP6 messages
from proxies, clients and servers.
EXAMPLE
This example provides a basic DHCP relay functionality example.
.CS
static int my_mip_dhcpv6_relay(int event,
struct Ipmip_my_context *ctx,
Ipmip_proc_t *proc,
Ipmip_dhcp6_node_t *relay,
Ipmip_pktbuf_t *pbuf)
{
/@ Properly invoked? @/
if (event == IPMIP_TIMER_EVENT_RUN)
{
Ipmip_dhcp6_hdr_t *pkt = (Ipmip_dhcp6_hdr_t *)IPMIP_BUFFER_PTR(&pbuf->packet);
Ipmip_dhcp6_relay_hdr_t *rpkt = (Ipmip_dhcp6_relay_hdr_t *)IPMIP_BUFFER_PTR(&pbuf->packet);
Ip_u8 hc = 0;
switch (pkt->msg_type)
{
case IPMIP_DHCP6_MSG_RELAY_REPLY:
{
Ipmip_dhcp6_option_hdr_t *rmsg = ipmip_dhcp6_option_buffer_find(&pbuf->.packet, IPMIP_DHCP6_OPTION_RELAY_MSG);
if (rmsg == IP_NULL)
goto done_out;
/@ Do forward @/
ipmip_dhcp6_send_msg(&ctx->ipmip, proc, rmsg + 1, IP_GET_NTOHS(&rmsg->length), &rpkt->peer_addr, relay->ifindex);
}
break;
case IPMIP_DHCP6_MSG_RELAY_FORWARD:
hc = rpkt->hop_count;
/@ Fall Through @/
default:
{
Ipmip_pktbuf_t *rpbuf = (Ipmip_pktbuf_t *)ipmip_dhcp6_relay_msg(&ctx->ipmip, proc, IP_NULL, hc, pbuf);
if (rpbuf)
{
ipmip_dhcp6_send_msg(&ctx->ipmip6.ipmip, proc, IPMIP_BUFFER_DATA(&rpbuf->packet), IPMIP_BUFFER_SIZE(&rpbuf->packet), &ctx->my_dhcp6_server_address, relay->ifindex);
ipmip_pktbuf_release(&ctx->ipmip6.ipmip, proc, rpbuf);
}
}
break;
}
}
done_out:
ipmip_pktbuf_release(&ctx->ipmip6.ipmip, proc, &pbuf->ipmip6.ipmip);
return IPMIP_TIMER_RET_DONE;
}
void my_init_func(struct Ipmip_my_context *ctx, Ipmip_proc_t *proc, int ifindex, struct Ip_in6_addr *server_addr)
{
/@ Create the DHCP context - Can be done during context initialization,
or later for example depending on configuration @/
/@ This context will create the required UDP sockets for retrieving and
sending DHCP6 datagrams @/
ipmip_dhcp6_context_create(&ctx->ipmip, proc);
/@ Setup the DHCP callback structure, specify the interface we
are interested in receiving replies from and what callback to be invoked @/
cfg->my_dhcp6.ifindex = ifindex;
cfg->my_dhcp6.lock = ctx->my_lock;
cfg->my_dhcp6.process_func = (Ipmip_timer_func_t)my_mip_dhcpv6_relay;
cfg->my_dhcp6_server_address = *server_addr;
/@ Register the DHCP callback function @/
ipmip_dhcp6_register(&ctx->ipmip, proc, &ctx->my_dhcp6);
}
.CE
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <private/ipmip_context.h>
#include <private/ipmip_timer.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef IPMIP_USE_INET6
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
#define IPMIP_DHCP6_MSG_SOLICIT 1
#define IPMIP_DHCP6_MSG_ADVERTISE 2
#define IPMIP_DHCP6_MSG_REQUEST 3
#define IPMIP_DHCP6_MSG_CONFIRM 4
#define IPMIP_DHCP6_MSG_RENEW 5
#define IPMIP_DHCP6_MSG_REBIND 6
#define IPMIP_DHCP6_MSG_REPLY 7
#define IPMIP_DHCP6_MSG_RELEASE 8
#define IPMIP_DHCP6_MSG_DECLINE 9
#define IPMIP_DHCP6_MSG_RECONFIGURE 10
#define IPMIP_DHCP6_MSG_INFORMATION_REQUEST 11
#define IPMIP_DHCP6_MSG_RELAY_FORWARD 12
#define IPMIP_DHCP6_MSG_RELAY_REPLY 13
#define IPMIP_DHCP6_OPTION_CLIENTID 1
#define IPMIP_DHCP6_OPTION_SERVERID 2
#define IPMIP_DHCP6_OPTION_IA_NA 3
#define IPMIP_DHCP6_OPTION_IA_TA 4
#define IPMIP_DHCP6_OPTION_IAADDR 5
#define IPMIP_DHCP6_OPTION_ORO 6
#define IPMIP_DHCP6_OPTION_PREFERENCE 7
#define IPMIP_DHCP6_OPTION_ELAPSED_TIME 8
#define IPMIP_DHCP6_OPTION_RELAY_MSG 9
#define IPMIP_DHCP6_OPTION_AUTH 11
#define IPMIP_DHCP6_OPTION_UNICAST 12
#define IPMIP_DHCP6_OPTION_STATUS_CODE 13
#define IPMIP_DHCP6_OPTION_RAPID_COMMIT 14
#define IPMIP_DHCP6_OPTION_USER_CLASS 15
#define IPMIP_DHCP6_OPTION_VENDOR_CLASS 16
#define IPMIP_DHCP6_OPTION_VENDOR_OPTS 17
#define IPMIP_DHCP6_OPTION_INTERFACE_ID 18
#define IPMIP_DHCP6_OPTION_RECONF_MSG 19
#define IPMIP_DHCP6_OPTION_RECONF_ACCEPT 20
#define IPMIP_DHCP6_OPTION_DNS_SERVERS 23
#define IPMIP_DHCP6_OPTION_DOMAIN_LIST 24
#define IPMIP_DHCP6_OPTION_IA_PD 25
#define IPMIP_DHCP6_OPTION_IAPREFIX 26
#define IPMIP_DHCP6_OPTION_SNTP_SERVERS 31
#define IPMIP_DHCP6_OPTION_INFORMATION_REFRESH_TIME 32
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
struct Ipmip_pktbuf;
struct Ipmip_context;
struct Ipmip_proc;
struct Ipmip_buffer;
#include <ipcom_align16.h>
typedef struct IP_PACKED1 Ipmip_dhcp6_hdr
{
Ip_u8 msg_type;
Ip_u8 tid[3];
} IP_PACKED2
Ipmip_dhcp6_hdr_t;
typedef struct IP_PACKED1 Ipmip_dhcp6_option_hdr
{
Ip_u16 code;
Ip_u16 length;
} IP_PACKED2
Ipmip_dhcp6_option_hdr_t;
typedef IP_PACKED1 struct Ipmip_dhcp6_relay_hdr
{
Ip_u8 msg_type;
Ip_u8 hop_count;
struct Ip_in6_addr link_addr;
struct Ip_in6_addr peer_addr;
}
IP_PACKED2 Ipmip_dhcp6_relay_hdr_t;
#include <ipcom_align16.h>
typedef struct Ipmip_dhcp6_node
{
/* HASH parameters */
Ip_u32 ifindex;
Ipmip_timer_lock_t *lock;
Ipmip_timer_func_t process_func;
void *opaque;
} Ipmip_dhcp6_node_t;
typedef struct Ipmip_dhcp6_context
{
/**/
Ipcom_mutex mutex;
Ip_fd fd_udp;
Ipcom_hash *ifindex_table;
} Ipmip_dhcp6_context_t;
typedef struct Ipmip_dhcp6_embedded_server
{
/**/
Ip_u32 refcount;
struct Ipmip_proc *proc;
} Ipmip_dhcp6_embedded_server_t;
extern struct Ip_in6_addr ipmip_dhcp6_all_dhcp_relay_agents_and_servers;
extern struct Ip_in6_addr ipmip_dhcp6_all_dhcp_servers;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipmip_dhcp6_context_create - ipmip_dhcp6_context_create
*
* Allocate the DHCP6 context
*
* 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:
*
*/
IP_GLOBAL void ipmip_dhcp6_context_create
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc
);
/*******************************************************************************
*
* ipmip_dhcp6_context_destroy - ipmip_dhcp6_context_destroy
*
* Free an DHCP6 context
*
* 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:
*
*/
IP_GLOBAL void ipmip_dhcp6_context_destroy
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc
);
/*******************************************************************************
*
* ipmip_dhcp6_process - ipmip_dhcp6_process
*
* Process DHCP6 messages. This method is invoked internally from the
* the packet loops. Unless you are certain of what you are doing, you should
* not invoke this method yourself.
*
* 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:
*
*/
IP_GLOBAL void ipmip_dhcp6_process
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc
);
/*******************************************************************************
*
* ipmip_dhcp6_relay_msg - ipmip_dhcp6_relay_msg
*
* Create a DHCP6 relay message based on a 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 link_addr
* Link address
* \i hop count
* Current hop count
* \i req
* Request to relay
* \ie
*
* RETURNS: The relay message
*
* ERRNO:
*
*/
IP_GLOBAL struct Ipmip_pktbuf *ipmip_dhcp6_relay_msg
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
struct Ip_in6_addr *link_addr,
Ip_u8 hop_count,
struct Ipmip_pktbuf *req
);
/*******************************************************************************
*
* ipmip_dhcp6_send_msg - ipmip_dhcp6_send_msg
*
* Forward a DHCP6 message
*
* 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 msg
* Message
* \i size
* Size of message
* \i dst
* Destination
* \i ifscope
* Interface
* \ie
*
* RETURNS: IPCOM_SUCCESS on success, < 0 on error.
*
* ERRNO:
*
*/
IP_GLOBAL int ipmip_dhcp6_send_msg
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
void *msg,
Ip_size_t size,
struct Ip_in6_addr *dst,
Ip_u32 ifscope
);
/*******************************************************************************
*
* ipmip_dhcp6_add_option - ipmip_dhcp6_add_option
*
* Add a DHCP6 option to a buffer
*
* Parameters:
* \is
* \i dhcp
* DHCP buffer
* \i code
* DHCP code
* \i length
* Length of option (data)
* \i data
* Data
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_dhcp6_add_option
(
struct Ipmip_buffer *dhcp,
Ip_u16 code,
Ip_u16 length,
void *data
);
/*******************************************************************************
*
* ipmip_dhcp6_option_next - ipmip_dhcp6_option_next
*
* Get next DHCP6 option
*
* Parameters:
* \is
* \i hdr
* Last header
* \i optstart
* DHCP options start
* \i optsize
* The size of DHCP options
* \ie
*
* RETURNS: DHCP6 option if found, IP_NULL otherwise
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_dhcp6_option_hdr_t *ipmip_dhcp6_option_next
(
Ipmip_dhcp6_option_hdr_t *hdr,
Ip_u8 *optstart,
int optsize
);
/*******************************************************************************
*
* ipmip_dhcp6_option_first - ipmip_dhcp6_option_first
*
* Get first DHCP6 option
*
* Parameters:
* \is
* \i options
* DHCP options
* \i optsize
* The size of DHCP options
* \ie
*
* RETURNS: DHCP6 option if found, IP_NULL otherwise
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_dhcp6_option_hdr_t *ipmip_dhcp6_option_first
(
Ip_u8 *options,
int optsize
);
/*******************************************************************************
*
* ipmip_dhcp6_option_find - ipmip_dhcp6_option_find
*
* Find a specific DHCP6 option
*
* Parameters:
* \is
* \i options
* DHCP options
* \i optsize
* The size of DHCP options
* \i code
* The code of the DHCP option
* \ie
*
* RETURNS: DHCP6 option if found, IP_NULL otherwise
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_dhcp6_option_hdr_t *ipmip_dhcp6_option_find
(
Ip_u8 *options,
int optsize,
Ip_u16 code
);
/*******************************************************************************
*
* ipmip_dhcp6_option_buffer_find - ipmip_dhcp6_option_buffer_find
*
* Find a specific DHCP6 option
*
* Parameters:
* \is
* \i dhcp
* DHCP packet
* \i code
* The code of the DHCP option
* \ie
*
* RETURNS: DHCP6 option if found, IP_NULL otherwise
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_dhcp6_option_hdr_t *ipmip_dhcp6_option_buffer_find
(
struct Ipmip_buffer *dhcp,
Ip_u16 code
);
/*******************************************************************************
*
* ipmip_dhcp6_option_buffer_first - ipmip_dhcp6_option_buffer_first
*
* Return the first DHCP6 option
*
* Parameters:
* \is
* \i dhcp
* DHCP packet
* \ie
*
* RETURNS: DHCP6 option if found, IP_NULL otherwise
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_dhcp6_option_hdr_t *ipmip_dhcp6_option_buffer_first
(
struct Ipmip_buffer *dhcp
);
/*******************************************************************************
*
* ipmip_dhcp6_option_buffer_next - ipmip_dhcp6_option_buffer_next
*
* Return the next DHCP6 option
*
* Parameters:
* \is
* \i hdr
* Last DHCP option
* \i dhcp
* DHCP packet
* \ie
*
* RETURNS: DHCP6 option if found, IP_NULL otherwise
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_dhcp6_option_hdr_t *ipmip_dhcp6_option_buffer_next
(
Ipmip_dhcp6_option_hdr_t *hdr,
struct Ipmip_buffer *dhcp
);
/*******************************************************************************
*
* ipmip_dhcp6_register - ipmip_dhcp6_register
*
* Register a forwarding structure
*
* 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 node
* Node to register
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_dhcp6_register
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_dhcp6_node_t *node
);
/*******************************************************************************
*
* ipmip_dhcp6_unregister - ipmip_dhcp6_unregister
*
* Unregister a forwarding structure
*
* 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 node
* Node to register
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_dhcp6_unregister
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_dhcp6_node_t *node
);
/*******************************************************************************
*
* ipmip_dhcp6_embedded_server_init - ipmip_dhcp6_embedded_server_init
*
* Initialize the embedded server
*
* 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:
*
*/
IP_GLOBAL void ipmip_dhcp6_embedded_server_init
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc
);
/*******************************************************************************
*
* ipmip_dhcp6_embedded_server_start - ipmip_dhcp6_embedded_server_start
*
* Start the embedded server
*
* 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 ifname
* Interface to use for duid init
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_dhcp6_embedded_server_start
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
const char *ifname
);
/*******************************************************************************
*
* ipmip_dhcp6_embedded_server_stop - ipmip_dhcp6_embedded_server_stop
*
* Stop the embedded server
*
* 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:
*
*/
IP_GLOBAL void ipmip_dhcp6_embedded_server_stop
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc
);
#endif
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,510 @@
/* ipmip_if.h - ipmip_if.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip_if.h,v $ $Revision: 1.8 $
* $Source: /home/interpeak/CVSRoot/ipmip/include/private/ipmip_if.h,v $
* $Author: jhorteli $ $Date: 2010-12-07 09:55:01 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
******************************************************************************
*/
#ifndef IPMIP_IF_H
#define IPMIP_IF_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
DESCRIPTION
Basic interface management required for MIP. Provides functions to
instantiate interfaces information containers, resolve LLADDR identifiers
and create and destroy tunnel interfaces. This is a base class that mostly
acts as container. The real interface implementations are usually located
higher up in the hierarchy such as IPMIP6 and IPMIP4.
EXAMPLE
.CS
struct Ipmip_my_iff
{
Ipmip_if_t ipmip;
char *extra_data;
};
static void ipmip_my_free_interface(struct Ipmip_my_context *ctx,
Ipmip_proc_t *proc,
struct Ipmip_my_iff *iff)
{
/@ Free any extra data associated with the interface @/
ipcom_free(iff->extra_data);
}
struct Ipmip_my_iff *ipmip_my_allocate_interface(struct Ipmip_my_context *ctx, Ipmip_proc_t *proc, int ifindex, const char *ifname)
{
/@ Allocate an interface container for the indicated interface @/
struct Ipmip_my_iff *iff = (struct Ipmip_my_iff *)ipmip_if_alloc(&ctx->ipmip,
proc,
sizeof(*iff),
ifname,
ifindex,
IPMIP_IF_TYPE_GENERIC,
0,
(Ipmip_if_cleanup_t)ipmip_my_free_interface);
/@ Just allocate some extra data to highlight the use of the interface free routine @/
iff->extra_data = ipcom_malloc(40);
return iff;
}
void ipmip_do_if(struct Ipmip_my_context *ctx, Ipmip_proc_t *proc, int ifindex, const char *ifname)
{
struct Ipmip_my_iff *iff = ipmip_my_allocate_interface(ctx, proc, ifindex, ifname);
/@ Set the interface UP @/
ipmip_if_set_flags(&ctx->ipmip, proc, &iff->ipmip, IP_IFF_UP);
/@ Set the interface DOWN @/
ipmip_if_clear_flags(&ctx->ipmip, proc, &iff->ipmip, IP_IFF_UP);
/@ Destroy the interface @/
ipmip_if_free(&ctx->ipmip, proc, &iff->ipmip);
}
.CE
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <private/ipmip_lladdr.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
enum
{
IPMIP_IF_TYPE_GENERIC,
IPMIP_IF_TYPE_TUNNEL
};
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
struct Ipmip_context;
struct Ipmip_proc;
struct Ipmip_if;
typedef void (*Ipmip_if_cleanup_t) (struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
struct Ipmip_if *ifp);
typedef struct Ipmip_if
{
Ipcom_list next;
/**/
char ifname[IP_IFNAMSIZ + 1];
Ip_u32 ifindex;
Ipmip_lladdr_t *lladdr;
Ipmip_if_cleanup_t cleanup;
/* Type of interface */
Ip_u8 type;
Ip_u8 identity;
Ip_u8 tunnel_type;
Ip_u8 __reserved;
} Ipmip_if_t;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipmip_if_alloc - ipmip_if_alloc
*
* Allocate and initialize the interface structure. Will return a pointer
* to the newly allocated interface structure. Since the IPMIP interface
* usually is overloaded by other implementations in order to define parameters
* required by those products, a size argument is provided that indicates the
* entire size of the interface structure to be allocated. For the same reason
* a cleanup hook can be registered, if there is data associated with an
* interface that must be released when the interface 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 ifsize
* the size of the interface structure
* \i ifname
* The interface name
* \i ifindex
* The interface index if available.
* \i type
* One of the IPMIP_IF_TYPE_GENERIC or IPMIP_IF_TYPE_TUNNEL.
* \i identity
* Implementation specific sub-identity, if one needs to discern between
* various types of interfaces.
* \i cleanup
* Cleanup hook that may be specified. Will be invoked during free.
* \ie
*
* RETURNS: The interface structure on success.
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_if_t * ipmip_if_alloc
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ip_size_t ifsize,
const char *ifname,
Ip_u32 ifindex,
Ip_u8 type,
Ip_u8 identity,
Ipmip_if_cleanup_t cleanup
);
/*******************************************************************************
*
* ipmip_if_free - ipmip_if_free
*
* Destroy and free the interface specific data. If a interface cleanup hook
* has been registered in the ipmip_if_alloc call, it will be invoked in this
* function.
*
* 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 iff
* the interface to destroy
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_if_free
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_if_t *iff
);
/*******************************************************************************
*
* ipmip_if_ioctl - ipmip_if_ioctl
*
* Invoke a interface ioctl.
*
* 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 iff
* the interface to destroy
* \i ioctl
* The ioctl
* \i ifreq
* The ioctl ifreq structure to complete
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL int ipmip_if_ioctl
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_if_t *iff,
unsigned long ioctl,
struct Ip_ifreq *ifreq
);
/*******************************************************************************
*
* ipmip_if_get_flags - ipmip_if_get_flags
*
* Get the current interface flags.
*
* 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 iff
* The interface
* \i flags
* Where to store the flags.
* \ie
*
* RETURNS: IP_TRUE on success
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_if_get_flags
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_if_t *iff,
Ip_u16 *flags
);
/*******************************************************************************
*
* ipmip_if_set_flags - ipmip_if_set_flags
*
* Set the current interface flags.
*
* 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 iff
* The interface
* \i flags
* The flags to set
* \ie
*
* RETURNS: IP_TRUE on success
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_if_set_flags
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_if_t *iff,
Ip_u16 flags
);
/*******************************************************************************
*
* ipmip_if_clear_flags - ipmip_if_clear_flags
*
* Clear the current interface flags.
*
* 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 iff
* The interface
* \i flags
* The flags to clear
* \ie
*
* RETURNS: IP_TRUE on success
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_if_clear_flags
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_if_t *iff,
Ip_u16 flags
);
/*******************************************************************************
*
* ipmip_if_resolve_lla - ipmip_if_resolve_lla
*
* Resolve the LLA of the interface
*
* 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 iff
* The interface
* \ie
*
* RETURNS: IP_TRUE on success; IP_FALSE otherwise.
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_if_resolve_lla
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_if_t *iff
);
/*******************************************************************************
*
* ipmip_if_findbyindex - ipmip_if_findbyindex
*
* Locate an interface in our configuration based on index
*
* Parameters:
* \is
* \i iflist
* The list of interfaces
* \i idx
* The interface index
* \ie
*
* RETURNS: The interface pointer if it exists, IP_NULL otherwise.
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_if_t * ipmip_if_findbyindex
(
Ipcom_list *iflist,
Ip_u32 idx
);
/*******************************************************************************
*
* ipmip_if_findbyname - ipmip_if_findbyname
*
* Locate an interface in our configuration based on name.
*
* Parameters:
* \is
* \i iflist
* The list of interfaces.
* \i ifname
* The interface name
* \ie
*
* RETURNS: The interface pointer if it exists, IP_NULL otherwise.
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_if_t * ipmip_if_findbyname
(
Ipcom_list *iflist,
const char *ifname
);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,717 @@
/* ipmip_inet.h - ipmip_inet.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip_inet.h,v $ $Revision: 1.9.10.1 $
* $Source: /home/interpeak/CVSRoot/ipmip/include/private/ipmip_inet.h,v $
* $Author: svc-cmnet $ $Date: 2013-03-13 07:45:30 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
******************************************************************************
*/
#ifndef IPMIP_INET_H
#define IPMIP_INET_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
DESCRIPTION
INET address domain specific utility functions and routines. This module
provides routines for sending/writing link layer packet frames, IP frames,
UDP frames and ARP messages.It also provides an ARP proxy for MIP entities
that are required to proxy ARP for various INET addresses such as Proxy MIP
entities, Home Agents in the INET domain, and NEMO solutions.
EXAMPLE
This is a disruptive example that simply proxy ARP answers any incoming
ARP requests.
.CS
static int my_arp_reply(int event,
struct Ipmip_my_context *ctx,
Ipmip_proc_t *proc,
Ipmip_arp_node_t *arp,
Ipmip_pktbuf_t *pbuf)
{
/@ Were we correctly invoked @/
if (event == IPMIP_TIMER_EVENT_RUN)
{
Ipmip_arp_hdr_t *pkt = (Ipmip_arp_hdr_t *)IPMIP_BUFFER_PTR(&pbuf->packet);
struct Ipmip_my_iff *iff = arp->opaque;
if (pkt->op == IPMIP_ARP_OP_REQUEST)
ipmip_inet_arp_reply(&ctx->ipmip, proc, pkt, &iff->ipmip);
}
ipmip_pktbuf_release(&ctx->ipmip6.ipmip, proc, &pbuf->ipmip6.ipmip);
return IPMIP_TIMER_RET_DONE;
}
void my_init_function(struct Ipmip_my_context *ctx, Ipmip_proc_t *proc, struct Ipmip_my_iff *iff)
{
static Ipmip_arp_node_t node;
ipmip_inet_arp_context_in_create(&ctx->ipmip, proc);
ipmip_inet_arp_context_out_create(&ctx->ipmip, proc);
ipcom_memset(&node, 0, sizeof(node));
arp.ifindex = iff->ipmip.ifindex;
arp.lock = ctx->my_lock;
arp.opaque = iff;
arp.process_func = (Ipmip_timer_func_t)my_arp_reply;
ipmip_inet_arp_register(&ctx->ipmip, proc, &arp);
}
.CE
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <ipcom_hash.h>
#include <private/ipmip_timer.h>
#include <private/ipmip_lladdr.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef IPMIP_USE_INET
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/* ARP pkt header values: */
#define IPMIP_ARP_HRD_ETHER ip_htons(0x0001)
#define IPMIP_ARP_PRO_IP ip_htons(IPMIP_ETH_P_IP)
#define IPMIP_ARP_HLN_PLN ip_htons(0x0604)
#define IPMIP_ARP_OP_REQUEST ip_htons(0x0001)
#define IPMIP_ARP_OP_REPLY ip_htons(0x0002)
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
struct Ipmip_context;
struct Ipmip_proc;
struct Ipmip_pktbuf;
struct Ipmip_lladdr;
struct Ipmip_if;
struct Ipmip_buffer;
typedef struct Ipmip_arp_node
{
/* HASH parameters */
Ip_u32 ifindex;
Ip_u32 src;
Ipmip_timer_lock_t *lock;
Ipmip_timer_func_t process_func;
void *opaque;
} Ipmip_arp_node_t;
typedef struct Ipmip_arp_context
{
/**/
Ipcom_mutex mutex;
Ip_fd fd_arp_in;
Ip_fd fd_arp_out;
Ipcom_hash *ifindex_table;
} Ipmip_arp_context_t;
#include "ipcom_align16.h"
typedef IP_PACKED1 struct Ipmip_arp_hdr
{
/* ARP header. */
Ip_u16 hrd; /* Format of hardware address. */
Ip_u16 pro; /* Format of protocol address. */
Ip_u16 hln_pln; /* Length of hardware and protocol address. */
Ip_u16 op; /* Code */
Ip_u8 eth_src[IPMIP_ETH_ADDR_SIZE];
Ip_u16 ip_src[2];
Ip_u8 eth_dst[IPMIP_ETH_ADDR_SIZE];
Ip_u16 ip_dst[2];
}
IP_PACKED2 Ipmip_arp_hdr_t;
#include "ipcom_align16.h"
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipmip_inet_arp_context_in_create - ipmip_inet_arp_context_in_create
*
* Allocate the ARP receive context; this context is required in order to
* receive ARP requests.
*
* 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:
*
*/
IP_GLOBAL void ipmip_inet_arp_context_in_create
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc
);
/*******************************************************************************
*
* ipmip_inet_arp_context_out_create - ipmip_inet_arp_context_out_create
*
* Allocate the ARP send context. This context is required in order to
* send ARP requests.
*
* 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:
*
*/
IP_GLOBAL void ipmip_inet_arp_context_out_create
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc
);
/*******************************************************************************
*
* ipmip_inet_arp_context_destroy - ipmip_inet_arp_context_destroy
*
* Free an ARP context. Free the in/out ARP contexts.
*
* 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:
*
*/
IP_GLOBAL void ipmip_inet_arp_context_destroy
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc
);
/*******************************************************************************
*
* ipmip_inet_udp_recvmsg - ipmip_inet_udp_recvmsg
*
* Receive an INET UDP message from an IP_IPPROTO_UDP socket. This method
* will also resolve link layer address, packet information (receiving address,
* interface) and TTL.
*
* 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 vlen
* Buffer size
* \i fd
* File descriptor
* \ie
*
* RETURNS: The packet buffer on success
*
* ERRNO:
*
*/
IP_GLOBAL struct Ipmip_pktbuf *ipmip_inet_udp_recvmsg
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ip_size_t vlen,
Ip_fd fd
);
/*******************************************************************************
*
* ipmip_inet_udp_write - ipmip_inet_udp_write
*
* Write an INET UDP message. This method will write the UDP frame directly
* with IP and link layer header out onto the interface specificied
* in the 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 fd_pkt
* AF_PACKET socket to use if required
* \i fd_raw
* SOCK_RAW socket to use if required
* \i payload
* UDP Payload
* \i from
* IP source address
* \i from_port
* UDP source port
* \i to
* IP destination address
* \i to_port
* UDP destination port
* \i iff
* Interface
* \i lladdr
* Destination LLADDR
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL int ipmip_inet_udp_write
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ip_fd fd_pkt,
Ip_fd fd_raw,
struct Ipmip_buffer *payload,
Ip_u32 from,
Ip_u16 from_port,
Ip_u32 to,
Ip_u16 to_port,
struct Ipmip_if *iff,
struct Ipmip_lladdr *lladdr
);
/*******************************************************************************
*
* ipmip_inet_udp_socket - ipmip_inet_udp_socket
*
* Allocate an INET UDP socket with the required ancillary data
* parameters set.
*
* Parameters:
* \is
* \i s_in
* Optional bind information
* \ie
*
* RETURNS: The new socket or IP_INVALID_SOCKET on failure.
*
* ERRNO:
*
*/
IP_GLOBAL Ip_fd ipmip_inet_udp_socket
(
struct Ip_sockaddr_in *s_in
);
/*******************************************************************************
*
* ipmip_inet_udp_sendmsg - ipmip_inet_udp_sendmsg
*
* Send an INET UDP message. The message will be provided with an IP header
* and sent using the provided raw socket. If an interface is provided,
* the frame will be forcibly sent through it.
*
* 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 fd_raw
* SOCK_RAW socket to use
* \i payload
* UDP Payload
* \i from
* IP source address
* \i from_port
* UDP source port
* \i to
* IP destination address
* \i to_port
* UDP destination port
* \i iff
* Interface to send frame on.
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL int ipmip_inet_udp_sendmsg
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ip_fd fd_raw,
struct Ipmip_buffer *payload,
Ip_u32 from,
Ip_u16 from_port,
Ip_u32 to,
Ip_u16 to_port,
struct Ipmip_if *iff
);
/*******************************************************************************
*
* ipmip_inet_arp_process - ipmip_inet_arp_process
*
* Used internally by IPMIP4 and IPMIP6 packet contexts.
* Process ARP messages
*
* 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:
*
*/
IP_GLOBAL void ipmip_inet_arp_process
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc
);
/*******************************************************************************
*
* ipmip_inet_arp_write - ipmip_inet_arp_write
*
* Write an ARP REPLY message to a specified link address on the specified
* interface.
*
* 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 from
* Source IP
* \i to
* Dest IP
* \i iff
* Interface
* \i lladdr
* Link local address
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_inet_arp_write
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ip_u32 from,
Ip_u32 to,
struct Ipmip_if *iff,
Ipmip_lladdr_t *lladdr
);
/*******************************************************************************
*
* ipmip_inet_arp_reply - ipmip_inet_arp_reply
*
* Reply to an ARP REQUEST. Will extract the required information from the
* request frame and invoke ipmip_inet_arp_write.
*
* 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 arp_req
* Arp request
* \i iff
* Interface
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_inet_arp_reply
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_arp_hdr_t *arp_req,
struct Ipmip_if *iff
);
/*******************************************************************************
*
* ipmip_inet_arp_register - ipmip_inet_arp_register
*
* Register an ARP structure. ARP frames destined for the address specified
* in the ARP node will be fed to the callback specified in the node.
*
* 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 node
* Node to register
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_inet_arp_register
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_arp_node_t *node
);
/*******************************************************************************
*
* ipmip_inet_arp_unregister - ipmip_inet_arp_unregister
*
* Unregister an ARP structure
*
* 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 node
* Node to register
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_inet_arp_unregister
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_arp_node_t *node
);
/*******************************************************************************
*
* ipmip_inet_arp_proxy - ipmip_inet_arp_proxy
*
* Install or Delete a static proxy arp entry
*
* 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 ifindex
* Interface index
* \i address
* The address to proxy for
* \i set
* IP_TRUE if set, IP_FALSE if delete
* \ie
*
* RETURNS: IP_TRUE on success
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_inet_arp_proxy
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ip_u32 ifindex,
Ip_u32 address,
Ip_bool set
);
#endif
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,325 @@
/* ipmip_inet6.h - ipmip_inet6.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip_inet6.h,v $ $Revision: 1.5 $
* $Source: /home/interpeak/CVSRoot/ipmip/include/private/ipmip_inet6.h,v $
* $Author: jhorteli $ $Date: 2010-12-07 09:55:01 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
******************************************************************************
*/
#ifndef IPMIP_INET6_H
#define IPMIP_INET6_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
DESCRIPTION
INET6 address domain specific utility functions and routines. This module
provides routines for joining/leaving multicast/anycast groups and receiving
UDP frames.
EXAMPLE
This example shows how to join/leave multicast or anycast addresses.
.CS
#define IPMIP_IP6_SET_ALL_NODES_ADDR(addr) do { \
IP_SET_HTONL(&(addr)->in6.addr32[0], 0xff020000); \
IP_SET_32ON16(&(addr)->in6.addr32[1], 0); \
IP_SET_32ON16(&(addr)->in6.addr32[2], 0); \
IP_SET_HTONL(&(addr)->in6.addr32[3], 0x00000001); \
} while(0)
void my_init_function(struct Ipmip_my_context *ctx, Ipmip_proc_t *proc, int ifindex, int fd)
{
struct Ip_in6_addr mcast;
/@ Create the all nodes multicast address @/
IPMIP_IP6_SET_ALL_NODES_ADDR(&mcast);
/@ Join the all nodes multicast address @/
ipmip_inet6_multicast_join(&ctx->ipmip, proc, fd, ifindex, &mcast);
/@ Leave the all nodes multicast address @/
ipmip_inet6_multicast_leave(&ctx->ipmip, proc, fd, ifindex, &mcast);
}
.CE
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef IPMIP_USE_INET6
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
struct Ipmip_pktbuf;
struct Ipmip_context;
struct Ipmip_proc;
struct Ip_in6_addr;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipmip_inet6_udp_recvmsg - ipmip_inet6_udp_recvmsg
*
* Receive an INET6 UDP message from an IP_IPPROTO_UDP socket. This method
* will also resolve the packet information (receiving interface, destination
* address)
*
* 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 vlen
* Buffer size
* \i fd
* File descriptor
* \ie
*
* RETURNS: The packet buffer on success
*
* ERRNO:
*
*/
IP_GLOBAL struct Ipmip_pktbuf *ipmip_inet6_udp_recvmsg
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ip_size_t vlen,
Ip_fd fd
);
/*******************************************************************************
*
* ipmip_inet6_multicast_join - ipmip_inet6_multicast_join
*
* Join a multicast group
*
* 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 fd
* File Descriptor
* \i ifindex
* Interface index
* \i mcast
* Multicast Group
* \ie
*
* RETURNS: IP_TRUE on success
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_inet6_multicast_join
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ip_fd fd,
Ip_u32 ifindex,
struct Ip_in6_addr *mcast
);
/*******************************************************************************
*
* ipmip_inet6_multicast_leave - ipmip_inet6_multicast_leave
*
* Join a multicast group
*
* 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 fd
* File Descriptor
* \i ifindex
* Interface index
* \i mcast
* Multicast Group
* \ie
*
* RETURNS: IP_TRUE on success
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_inet6_multicast_leave
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ip_fd fd,
Ip_u32 ifindex,
struct Ip_in6_addr *mcast
);
/*******************************************************************************
*
* ipmip_inet6_anycast_join - ipmip_inet6_anycast_join
*
* Join a anycast address
*
* 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 fd
* File Descriptor
* \i ifindex
* Interface index
* \i anycast
* Anycast address
* \ie
*
* RETURNS: IP_TRUE on success
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_inet6_anycast_join
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ip_fd fd,
Ip_u32 ifindex,
struct Ip_in6_addr *anycast
);
/*******************************************************************************
*
* ipmip_inet6_anycast_leave - ipmip_inet6_anycast_leave
*
* Join a multicast group
*
* 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 fd
* File Descriptor
* \i ifindex
* Interface index
* \i anycast
* Anycast address
* \ie
*
* RETURNS: IP_TRUE on success
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_inet6_anycast_leave
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ip_fd fd,
Ip_u32 ifindex,
struct Ip_in6_addr *anycast
);
#endif /* IPMIP_USE_INET6 */
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,480 @@
/* ipmip_lladdr.h - ipmip_lladdr.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip_lladdr.h,v $ $Revision: 1.15 $
* $Source: /home/interpeak/CVSRoot/ipmip/include/private/ipmip_lladdr.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_LLADDR_H
#define IPMIP_LLADDR_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
DESCRIPTION
Utility library for managing link-layer addresses. These methods compare,
create and convert link layer addresses for use by the MIP system. This library
MUST be a superset of the other link-layer address definitions provided by
MIP6, MIP4 and IPNET.
EXAMPLE
This example describes how to create a LLADDR.
.CS
Ipmip_lladdr_t *create_lladdr(void)
{
char *mac = { 0x1, 0x1, 0x1, 0x1, 0x1, 0x1 };
/@ Dynamically allocate an ethernet type LLADDR with the MAC set to all 1's @/
Ipmip_lladdr_t *lla = ipmip_lladdr_build(IP_NULL,
IPMIP_LLADDR_TYPE_MAC,
IPMIP_LLADDR_SUBTYPE_MAC_802_3,
mac,
6);
return lla;
}
.CE
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
enum
{
IPMIP_LLADDR_TYPE_NONE,
IPMIP_LLADDR_TYPE_MAC,
IPMIP_LLADDR_TYPE_EUID64,
IPMIP_LLADDR_TYPE_MEID,
IPMIP_LLADDR_TYPE_ESN,
IPMIP_LLADDR_TYPE_IMEI,
IPMIP_LLADDR_TYPE_INET,
IPMIP_LLADDR_TYPE_INET6,
IPMIP_LLADDR_TYPE_3GPP,
IPMIP_LLADDR_TYPE_3GPP2,
IPMIP_LLADDR_TYPE_BSSID,
IPMIP_LLADDR_TYPE_TUNNEL,
IPMIP_LLADDR_TYPE_PPP,
IPMIP_LLADDR_TYPE_LOOPBACK,
IPMIP_LLADDR_TYPE_MAX
};
#define IPMIP_ETH_ADDR_SIZE 6
#define IPMIP_ETH_P_IP 0x0800
#define IPMIP_ETH_P_ARP 0x0806
enum
{
IPMIP_LLADDR_SUBTYPE_3GPP2_NONE,
IPMIP_LLADDR_SUBTYPE_3GPP2_1xRTT_HRPD,
IPMIP_LLADDR_SUBTYPE_3GPP2_UMB,
IPMIP_LLADDR_SUBTYPE_3GPP2_MAX
};
enum
{
IPMIP_LLADDR_SUBTYPE_3GPP_NONE,
IPMIP_LLADDR_SUBTYPE_3GPP_EUTRAN_LTE,
IPMIP_LLADDR_SUBTYPE_3GPP_UTRAN_GERAN,
IPMIP_LLADDR_SUBTYPE_3GPP_MAX
};
enum
{
IPMIP_LLADDR_SUBTYPE_INET_NONE,
IPMIP_LLADDR_SUBTYPE_INET_FA,
IPMIP_LLADDR_SUBTYPE_INET_SOLICITED,
IPMIP_LLADDR_SUBTYPE_INET_MAX
};
enum
{
IPMIP_LLADDR_SUBTYPE_MAC_NONE,
IPMIP_LLADDR_SUBTYPE_MAC_802_3,
IPMIP_LLADDR_SUBTYPE_MAC_802_1Q,
IPMIP_LLADDR_SUBTYPE_MAC_802_11,
IPMIP_LLADDR_SUBTYPE_MAC_802_16E,
IPMIP_LLADDR_SUBTYPE_MAC_802_16M,
IPMIP_LLADDR_SUBTYPE_MAC_MAX
};
enum
{
IPMIP_LLADDR_SUBTYPE_TUNNEL_NONE,
IPMIP_LLADDR_SUBTYPE_TUNNEL_IPIP,
IPMIP_LLADDR_SUBTYPE_TUNNEL_IP6IP6,
IPMIP_LLADDR_SUBTYPE_TUNNEL_SIT,
IPMIP_LLADDR_SUBTYPE_TUNNEL_GRE,
IPMIP_LLADDR_SUBTYPE_TUNNEL_GRE6,
IPMIP_LLADDR_SUBTYPE_TUNNEL_6TO4,
IPMIP_LLADDR_SUBTYPE_TUNNEL_6OVER4,
IPMIP_LLADDR_SUBTYPE_TUNNEL_MAX
};
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
typedef struct Ipmip_lladdr
{
Ip_u8 type;
Ip_u8 subtype;
Ip_u8 len;
Ip_u8 lla[1];
}
Ipmip_lladdr_t;
#define IPMIP_LLADDR_LEN(lladdr) (((Ipmip_lladdr_t *)(lladdr))->len)
#define IPMIP_LLADDR_LEN_LLA(lladdr) (IPMIP_LLADDR_LEN(lladdr) - 3)
#define IPMIP_LLADDR_LEN_TOTAL(llalen) ((llalen) + 3)
#define IPMIP_LLADDR_DATA(lladdr) ((void*)(&((Ipmip_lladdr_t *)(lladdr))->lla[0]))
enum
{
IPMIP_LLADDR_FORMAT_NONE,
IPMIP_LLADDR_FORMAT_HEX,
IPMIP_LLADDR_FORMAT_INET,
IPMIP_LLADDR_FORMAT_U32,
IPMIP_LLADDR_FORMAT_DEC_DIGIT,
IPMIP_LLADDR_FORMAT_HEX_DIGIT,
IPMIP_LLADDR_FORMAT_INET6
};
struct Ipmip_proc;
typedef struct Ipmip_lladdr_parse
{
const char *pre;
Ip_u8 pre_len;
Ip_u8 type;
Ip_u8 subtype;
Ip_u8 format;
} Ipmip_lladdr_parse_t;
typedef struct Ipmip_lladdr_typedef
{
const char *name;
Ip_u8 size;
Ip_u8 format;
Ip_size_t max_subtypes;
const char **subtypes;
} Ipmip_lladdr_typedef_t;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
extern Ipmip_lladdr_parse_t ipmip_lladdr_parse_defs[];
extern Ipmip_lladdr_typedef_t ipmip_lladdr_type_defs[];
extern const char *ipmip_lladdr_mac_subtypes[];
extern const char *ipmip_lladdr_tunnel_subtypes[];
extern const char *ipmip_lladdr_inet_subtypes[];
extern const char *ipmip_lladdr_3gpp2_subtypes[];
extern const char *ipmip_lladdr_3gpp_subtypes[];
/*******************************************************************************
*
* ipmip_lladdr_build - ipmip_lladdr_build
*
* Initialize a LLA extension based on the provided parameters
*
* Parameters:
* \is
* \i lla_ext
* The extension; must be large enough
* \i type
* The type.
* \i type
* The subtype.
* \i lla
* The link layer address
* \i lla_len
* The link layer address length
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_lladdr_t *ipmip_lladdr_build
(
Ipmip_lladdr_t *lla_ext,
Ip_u8 type,
Ip_u8 subtype,
void *lla,
int lla_len
);
/*******************************************************************************
*
* ipmip_lladdr_cmp - ipmip_lladdr_cmp
*
* Compares two LLA's
*
* Parameters:
* \is
* \i lla1
* The first lla
* \i lla2
* The second lla
* \ie
*
* RETURNS: IP_TRUE if they're identical.
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_lladdr_cmp
(
Ipmip_lladdr_t *lla1,
Ipmip_lladdr_t *lla2
);
/*******************************************************************************
*
* ipmip_lladdr_dup - ipmip_lladdr_dup
*
* Duplicate a LLA
*
* Parameters:
* \is
* \i lla
* The lla to duplicate
* \ie
*
* RETURNS: A pointer to the new LLA
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_lladdr_t * ipmip_lladdr_dup
(
Ipmip_lladdr_t *lla
);
/*******************************************************************************
*
* ipmip_lladdr_arphdr_to_lltype - ipmip_lladdr_arphdr_to_lltype
*
* Convert an ARPHRD_* type to LLADDR
*
* Parameters:
* \is
* \i type
* The type to convert
* \i ll_type
* The resolved LLADDR type
* \i ll_subtype
* The resolved LLADDR subtype
* \ie
*
* RETURNS: IP_TRUE on success
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_lladdr_arphdr_to_lltype
(
Ip_u16 type,
Ip_u8 *ll_type,
Ip_u8 *ll_subtype
);
/*******************************************************************************
*
* ipmip_lladdr_ift_to_lltype - ipmip_lladdr_ift_to_lltype
*
* Convert an IFT_* type to LLADDR
*
* Parameters:
* \is
* \i type
* The type to convert
* \i ll_type
* The resolved LLADDR type
* \i ll_subtype
* The resolved LLADDR subtype
* \ie
*
* RETURNS: IP_TRUE on success
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_lladdr_ift_to_lltype
(
Ip_u16 type,
Ip_u8 *ll_type,
Ip_u8 *ll_subtype
);
/*******************************************************************************
*
* ipmip_lladdr_dl_to_lladdr - ipmip_lladdr_dl_to_lladdr
*
* Create a LLADDR based on DL and if
*
* Parameters:
* \is
* \i dl
* The link-layer address
* \i ifindex
* The ifindex
* \ie
*
* RETURNS: A pointer to the new LLA
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_lladdr_t * ipmip_lladdr_dl_to_lladdr
(
struct Ip_sockaddr_dl *dl,
Ip_u32 ifindex
);
/*******************************************************************************
*
* ipmip_lladdr_ll_to_lladdr - ipmip_lladdr_ll_to_lladdr
*
* Create a LLADDR based on LL and if
*
* Parameters:
* \is
* \i ll
* The link-layer address
* \ie
*
* RETURNS: A pointer to the new LLA
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_lladdr_t * ipmip_lladdr_ll_to_lladdr
(
struct Ip_sockaddr_ll *ll
);
/*******************************************************************************
*
* ipmip_lladdr_sanitize - ipmip_lladdr_sanitize
*
* Sanitize a LLADDR based on the interface's LLADDR
*
* Parameters:
* \is
* \i iflla
* The interface LLADDR
* \i lla
* The LLADDR to sanitize
* \ie
*
* RETURNS: A pointer to the LLA
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL Ipmip_lladdr_t *ipmip_lladdr_sanitize
(
Ipmip_lladdr_t *iflla,
Ipmip_lladdr_t *lla
);
/*******************************************************************************
*
* ipmip_lladdr_parse - ipmip_lladdr_parse
*
* Create a LLADDR based on a textual string
*
* 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 type_hint
* A hint regarding the LL type
* \i subtype_hint
* A hint regarding the LL subtype
* \i llstr
* The textual string
* \ie
*
* RETURNS: A pointer to the new LLA
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL Ipmip_lladdr_t * ipmip_lladdr_parse
(
struct Ipmip_proc *proc,
Ip_u8 type_hint,
Ip_u8 subtype_hint,
const char *llstr
);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,430 @@
/* ipmip_log.h - ipmip_log.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip_log.h,v $ $Revision: 1.7 $
* $Source: /home/interpeak/CVSRoot/ipmip/include/private/ipmip_log.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_LOG_H
#define IPMIP_LOG_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
DESCRIPTION
Utility library for handling the log/event system. Provides mechanisms for
deleting, retrieving, adding and configuring the logging system.
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
struct Ipmip_context;
struct Ipmip_proc;
struct Ipmip_cli_message;
typedef struct Ipmip_log_event
{
Ipcom_list next;
/* Stored information; to identify and explain */
Ip_time_t when;
Ip_u32 level;
char *event;
} Ipmip_log_event_t;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipmip_log_event_delete - ipmip_log_event_delete
*
* Delete the oldest event stored in the global log
*
* 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_log_event_delete
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc
);
/*******************************************************************************
*
* ipmip_log_event_flush - ipmip_log_event_flush
*
* Delete all events stored in the global log
*
* 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_log_event_flush
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc
);
/*******************************************************************************
*
* ipmip_log_attr_request_events - ipmip_log_attr_request_events
*
* Dump all stored events to the 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 request
* The request
* \ie
*
* RETURNS: The offset to the reply header
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL Ip_size_t ipmip_log_attr_request_events
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
struct Ipmip_cli_message *request
);
/*******************************************************************************
*
* ipmip_log_attr_request_history - ipmip_log_attr_request_history
*
* Dump the current configured event history size
*
* 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: The offset to the reply header
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL Ip_size_t ipmip_log_attr_request_history
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
struct Ipmip_cli_message *request
);
/*******************************************************************************
*
* ipmip_log_attr_request_loglevel - ipmip_log_attr_request_loglevel
*
* Dump the current configured log level value
*
* 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: The offset to the reply header
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL Ip_size_t ipmip_log_attr_request_loglevel
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
struct Ipmip_cli_message *request
);
/*******************************************************************************
*
* ipmip_log_event_add - ipmip_log_event_add
*
* Add an event
*
* 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 format
* The format string
* \i ...
* Variable number of arguments for format string
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_log_event_add
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
const char *format,
...
);
/*******************************************************************************
*
* ipmip_log_event_vadd - ipmip_log_event_vadd
*
* Add an event
*
* 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 format
* The format string
* \i ap
* The VA arguments for format
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_log_event_vadd
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
const char *format,
va_list ap
);
/*******************************************************************************
*
* ipmip_log_event_backlog - ipmip_log_event_backlog
*
* Set the current event backlog history
*
* 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 backlog
* The size of the backlog
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL void ipmip_log_event_backlog
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ip_u32 backlog
);
/*******************************************************************************
*
* ipmip_log_loglevel - ipmip_log_loglevel
*
* Set the current loglevel
*
* 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 loglevel
* The loglevel to set
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL void ipmip_log_loglevel
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ip_u32 loglevel
);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,156 @@
/* ipmip_netlink_kern.h - ipmip_netlink_kern.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip_netlink_kern.h,v $ $Revision: 1.6.10.1 $
* $Source: /home/interpeak/CVSRoot/ipmip/include/private/ipmip_netlink_kern.h,v $
* $Author: svc-cmnet $ $Date: 2013-03-13 07:45:30 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
******************************************************************************
*/
#ifndef IPMIP_NETLINK_KERN_H
#define IPMIP_NETLINK_KERN_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#ifndef IPMIP_NATIVE_KERNEL
#include "ipnet_dst_cache.h"
#include "ipnet_routesock.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
#ifndef IPMIP_NATIVE_KERNEL
#define IPMIP_RTF_TUNNELEND IPNET_RTF_TUNNELEND
#define IPMIP_RTF_SKIP IPNET_RTF_SKIP
#define IPMIP_RTF_MBINDING IPNET_RTF_MBINDING
#else
#define IPMIP_RTF_TUNNELEND (1 << 0)
#define IPMIP_RTF_SKIP (1 << 1)
#define IPMIP_RTF_MBINDING (1 << 2)
#endif
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
#ifndef IPMIP_NATIVE_KERNEL
struct Ipnet_route_entry_struct;
struct Ipcom_pkt_struct;
struct Ipnet_route_func_info;
struct Ipnet_netif_struct;
struct Ip_rtattr;
enum
{
IPMIP_NETLINK_KERN_SRCMAC = (1 << 0),
IPMIP_NETLINK_KERN_TUNNEL = (1 << 1),
IPMIP_NETLINK_KERN_GREKEY = (1 << 2),
IPMIP_NETLINK_KERN_INGRESS_IFINDEX = (1 << 3),
IPMIP_NETLINK_KERN_EGRESS_IFINDEX = (1 << 4),
IPMIP_NETLINK_KERN_PROTO = (1 << 5)
};
typedef struct Ipmip_netlink_route_flow_info
{
Ipnet_mip_flow_spec flow;
Ip_u32 type;
Ip_u32 ifindex;
Ipnet_dst_cache_mip_handle flow_handle;
} Ipmip_netlink_route_flow_info_t;
#endif
typedef struct Ipmip_netlink_kern_compare
{
Ip_u16 srcmac_type;
struct
{
union
{
#ifdef IPCOM_USE_INET
struct Ip_in_addr ip;
#endif
#ifdef IPCOM_USE_INET6
struct Ip_in6_addr ip6;
#endif
Ip_u8 opaque[16];
} hdr;
Ip_u32 gre_key;
Ip_u32 ifindex;
Ip_u8 srcmac_len;
Ip_u8 proto;
} srcmac;
} Ipmip_netlink_kern_compare_t;
typedef struct Ipmip_netlink_kern_handle
{
Ip_u32 mip_ident;
Ip_u32 mip_facility;
} Ipmip_netlink_kern_handle_t;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
#ifndef IPMIP_NATIVE_KERNEL
IP_GLOBAL Ip_bool ipmip_netlink_kern_rt_flow_set(struct Ipnet_route_func_info *rtinfo,
Ipmip_netlink_kern_compare_t *srccmp,
Ipnet_dst_cache_mip_handle flow_handle);
IP_GLOBAL Ipmip_netlink_kern_handle_t *ipmip_netlink_kern_handle_get(Ip_u32 vr, Ipmip_netlink_kern_handle_t *handle);
IP_GLOBAL Ipmip_netlink_kern_handle_t *ipmip_netlink_kern_handle_del(Ip_u32 vr, Ipmip_netlink_kern_handle_t *handle);
IP_GLOBAL void ipmip_netlink_kern_handle_add(Ip_u32 vr, Ipmip_netlink_kern_handle_t *handle);
IP_GLOBAL void ipmip_netlink_kern_handle_free(Ip_u32 vr, Ipmip_netlink_kern_handle_t *handle);
IP_GLOBAL void ipmip_netlink_kern_if_include(struct Ipnet_netif_struct *netif);
IP_GLOBAL void ipmip_netlink_kern_if_exclude(struct Ipnet_netif_struct *netif);
IP_GLOBAL void ipmip_netlink_kern_hoa_activate(struct Ipnet_netif_struct *netif, struct Ip_rtattr *rta);
IP_GLOBAL void ipmip_netlink_kern_hoa_deactivate(struct Ipnet_netif_struct *netif, struct Ip_rtattr *rta);
IP_GLOBAL void ipmip_rtnetlink_init(void);
#endif
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,463 @@
/* ipmip_ntop.h - ipmip_ntop.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip_ntop.h,v $ $Revision: 1.8 $
* $Source: /home/interpeak/CVSRoot/ipmip/include/private/ipmip_ntop.h,v $
* $Author: jhorteli $ $Date: 2010-12-07 09:55:01 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
******************************************************************************
*/
#ifndef IPMIP_NTOP_H
#define IPMIP_NTOP_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
* Debug utility class providing functions to ease print's of various
* values such as hexarrays, lla's, addresses and non-zero-terminated
* strings.
*/
/*
DESCRIPTION
Debug utility class providing functions to ease print's of various
values such as hexarrays, lla's, addresses and non-zero-terminated
strings.
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
#ifdef IPMIP_USE_INET6
#define IPMIP_ADDRESS_ADDRSIZE (IP_INET6_ADDRSTRLEN * 2)
#else
#define IPMIP_ADDRESS_ADDRSIZE (IP_INET_ADDRSTRLEN * 2)
#endif
#define IPMIP_ADDRESS_ADDRMASK 3
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
struct Ipmip_lladdr;
struct Ipmip_proc;
struct Ipmip_if;
struct Ip_timeval;
typedef struct Ipmip_ntop
{
Ip_u32 ntop_index;
char ntop_pbuf[256];
char ntop_lla[64];
char ntop_name[64];
char ntop_buffer[IPMIP_ADDRESS_ADDRMASK + 1][IPMIP_ADDRESS_ADDRSIZE];
} Ipmip_ntop_t;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipmip_ntop - ipmip_ntop
*
* Converts a ip address to a human readable text
* representation. The text representation resides
* in a static buffer capable of holding up to four
* different results.
*
* 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 family
* The IP family
* \i un
* Address union
* \ie
*
* RETURNS: A pointer to the static buffer holding the result.
*
* ERRNO:
*
*/
IP_GLOBAL const char * ipmip_ntop
(
struct Ipmip_proc *proc,
Ip_u8 family,
const void *un,
struct Ipmip_if *ifp
);
#ifdef IPMIP_USE_INET
/*******************************************************************************
*
* ipmip_ntop_inet - ipmip_ntop_inet
*
* Converts a ip address to a human readable text
* representation. The text representation resides
* in a static buffer capable of holding up to four
* different results.
*
* 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 addr
* Address
* \ie
*
* RETURNS: A pointer to the static buffer holding the result.
*
* ERRNO:
*
*/
IP_GLOBAL const char * ipmip_ntop_inet
(
struct Ipmip_proc *proc,
Ip_u32 addr
);
#endif
#ifdef IPMIP_USE_INET6
/*******************************************************************************
*
* ipmip_ntop_inet6 - ipmip_ntop_inet6
*
* Converts a ip address to a human readable text
* representation. The text representation resides
* in a static buffer capable of holding up to four
* different results.
*
* 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 addr
* Address
* \i ifp
* scope
* \ie
*
* RETURNS: A pointer to the static buffer holding the result.
*
* ERRNO:
*
*/
IP_GLOBAL const char * ipmip_ntop_inet6
(
struct Ipmip_proc *proc,
const struct Ip_in6_addr *addr,
struct Ipmip_if *ifp
);
#endif
/*******************************************************************************
*
* ipmip_ntop_sa - ipmip_ntop_sa
*
* Converts a ip address to a human readable text
* representation. The text representation resides
* in a static buffer capable of holding up to four
* different results.
*
* 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 un
* The sockaddr struct
* \ie
*
* RETURNS: A pointer to the static buffer holding the result.
*
* ERRNO:
*
*/
IP_GLOBAL const char * ipmip_ntop_sa
(
struct Ipmip_proc *proc,
union Ip_sockaddr_union *un
);
/*******************************************************************************
*
* ipmip4_ntop_lla - ipmip4_ntop_lla
*
* Try to convert a LLA represented L2/SOL address to
* some form of human readable output
*
* 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 lla
* The LLA extension
* \ie
*
* RETURNS: A pointer to a static buffer containing the LLA output.
*
* ERRNO:
*
*/
IP_GLOBAL const char * ipmip_ntop_lladdr
(
struct Ipmip_proc *proc,
struct Ipmip_lladdr *lla
);
/*******************************************************************************
*
* ipmip_ntop_lladdr_type - ipmip_ntop_lladdr_type
*
* Try to convert a LLA represented L2/SOL address to
* some form of human readable output
*
* 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 type
* The MAC type
* \i subtype
* The MAC subtype
* \i mac
* The MAC
* \ie
*
* RETURNS: A pointer to a static buffer containing the LLA output.
*
* ERRNO:
*
*/
IP_GLOBAL const char * ipmip_ntop_lladdr_type
(
struct Ipmip_proc *proc,
Ip_u8 type,
Ip_u8 subtype,
void *mac,
Ip_size_t mac_len
);
/*******************************************************************************
*
* ipmip_ntop_hex - ipmip_ntop_hex
*
* Try to convert a binary value to readable hexadecimal output
*
* 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 hxarr
* The array
* \i sz
* Size of the array
* \ie
*
* RETURNS: A pointer to a static buffer containing the hex output.
*
* ERRNO:
*
*/
IP_GLOBAL const char * ipmip_ntop_hex
(
struct Ipmip_proc *proc,
Ip_u8 *hxarr,
Ip_size_t sz
);
/*******************************************************************************
*
* ipmip_ntop_time - ipmip_ntop_time
*
* Try to convert a time value to human readable using ctime
*
* 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 tval
* The time
* \ie
*
* RETURNS: A pointer to a static buffer containing the time output
*
* ERRNO:
*
*/
IP_GLOBAL const char * ipmip_ntop_time
(
struct Ipmip_proc *proc,
Ip_time_t tval
);
/*******************************************************************************
*
* ipmip_ntop_tm - ipmip_ntop_tm
*
* Try to convert a time value to human readable using strftime
*
* 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 tval
* The time
* \ie
*
* RETURNS: A pointer to a static buffer containing the time output
*
* ERRNO:
*
*/
IP_GLOBAL const char *ipmip_ntop_tm
(
struct Ipmip_proc *proc,
Ip_time_t tval
);
/*******************************************************************************
*
* ipmip_ntop_tv - ipmip_ntop_tv
*
* Try to convert a time value to human readable using strftime
*
* 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 tv
* The time
* \ie
*
* RETURNS: A pointer to a static buffer containing the time output
*
* ERRNO:
*
*/
IP_GLOBAL const char *ipmip_ntop_tv
(
struct Ipmip_proc *proc,
struct Ip_timeval *tv
);
/*******************************************************************************
*
* ipmip_ntop_strn - ipmip_ntop_strn
*
* Create a zero terminated string representation.
*
* 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 str
* The string
* \i str_len
* The length of the string
* \ie
*
* RETURNS: A pointer to a static buffer containing the time output
*
* ERRNO:
*
*/
IP_GLOBAL const char * ipmip_ntop_strn
(
struct Ipmip_proc *proc,
const char *str,
Ip_size_t str_len
);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,653 @@
/* ipmip_pktbuf.h - ipmip_pktbuf.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip_pktbuf.h,v $ $Revision: 1.11 $
* $Source: /home/interpeak/CVSRoot/ipmip/include/private/ipmip_pktbuf.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_PKTBUF_H
#define IPMIP_PKTBUF_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
* Packet buffer base class, which is usually overloaded by the various
* mobile agents and nodes in order to contain instantiation specific
* information.
*/
/*
DESCRIPTION
Packet buffer base class, which is usually overloaded by the various
mobile agents and nodes in order to contain instantiation specific
information.
EXAMPLE
This example provides information regarding how the packet context create is done.
The base example is lifted from the ipmip_context.h, and the appropriate code
for packet context initialization added.
.CS
struct Ipmip_my_pktbuf
{
Ipmip_pktbuf_t ipmip;
int extra_data;
};
IP_GLOBAL Ipmip_pktbuf_t *ipmip_my_pktbuf_alloc(struct Ipmip_my_context *ctx,
Ipmip_proc_t *proc,
Ip_size_t extra)
{
struct Ipmip_my_pktbuf *pbuf = ipcom_calloc(1, sizeof(struct Ipmip_my_pktbuf) + extra);
if (pbuf)
{
/@ Initialize the packet buffer. Tell the IPMIP packet context where
our header ends. @/
pbuf->ipmip.pktend = (void *) (pbuf + 1);
return &pbuf->ipmip;
}
return IP_NULL;
}
IP_GLOBAL void ipmipha_pktbuf_free(struct Ipmip_my_context *ctx,
Ipmip_proc_t *proc,
struct Ipmip_my_pktbuf *pbuf)
{
/@ Free the packet buffer. If you had extra data allocated in the alloc,
this would be the place to free it @/
ipcom_free(pbuf);
}
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 packet context @/
ipmip_pktbuf_context_create(&ctx->ipmip,
proc,
(Ipmip_pkt_buf_alloc_t)ipmip_my_pktbuf_alloc,
(Ipmip_pkt_buf_free_t)ipmip_my_pktbuf_free);
/@ Start the context @/
ipmip_context_start(&ctx->ipmip, proc);
}
.CE
This particular example allocates and frees a buffer
.CS
void my_packet_routine(struct Ipmip_my_context *ctx, Ipmip_proc_t *proc)
{
/@ Allocate a packet buffer with a minimum of 1024 bytes already allocated @/
struct Ipmip_my_pktbuf *pbuf = (struct Ipmip_my_pktbuf * *)ipmip_pktbuf_alloc(&ctx->ipmip, proc, 1024);
/@ Release the packet buffer @/
ipmip_pktbuf_release(&ctx->ipmip, proc, &pbuf->ipmip);
}
.CE
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <ipcom_atomic.h>
#include <private/ipmip_timer.h>
#include <private/ipmip_buffer.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
#define ipmip_pktbuf_indexdata(pbuf, index) ((pbuf)->pktarr[i]))
#define ipmip_pktbuf_pktdata(pbuf, reg) ipmip_pktbuf_indexdata(pbuf, (reg)->pktbuf_data_index)
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
struct Ipmip_pktbuf;
struct Ipmip_if;
struct Ipmip_pkt_context;
struct Ipmip_context;
struct Ipmip_proc;
struct Ipmip_lladdr;
typedef struct Ipmip_pktbuf * (*Ipmip_pkt_buf_alloc_t)
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ip_size_t extra
);
typedef void (*Ipmip_pkt_buf_free_t)
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
struct Ipmip_pktbuf *pbuf
);
typedef void (*Ipmip_pkt_buf_released_t)
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
struct Ipmip_pktbuf *pbuf
);
typedef struct Ipmip_pktbuf_pktinfo
{
union Ip_sockaddr_union dst;
Ip_u32 ifindex;
} Ipmip_pktbuf_pktinfo_t;
struct Ipmip_pktbuf_srcinfo
{
union Ip_sockaddr_union *src;
Ipmip_pktbuf_pktinfo_t *dst;
struct Ip_sockaddr_dl *dl;
struct Ip_sockaddr_ll *ll;
struct Ipmip_lladdr *lladdr;
int ttl;
};
typedef struct Ipmip_pktbuf
{
Ipcom_list next;
Ipmip_buffer_t packet;
Ipmip_timer_t timeout;
Ipmip_timer_t pending;
Ipmip_pkt_buf_released_t released;
struct Ipmip_pktbuf_srcinfo srcinfo;
Ipcom_atomic_t refcnt;
/* Transaction identifier */
char *message;
Ip_u8 error_code;
/* App data */
Ip_u8 *pktend;
void **pktarr;
Ip_size_t pktoff;
} Ipmip_pktbuf_t;
typedef void (*Ipmip_pktbuf_free_data_t) (struct Ipmip_context *, struct Ipmip_proc *, struct Ipmip_pktbuf *, void *data);
typedef struct Ipmip_pktbuf_payload
{
Ipmip_pktbuf_free_data_t pktbuf_data_free;
Ip_size_t pktbuf_data_size;
Ip_u32 pktbuf_data_index;
} Ipmip_pktbuf_payload_t;
typedef struct Ipmip_pktbuf_context
{
Ipmip_pkt_buf_alloc_t bufalloc;
Ipmip_pkt_buf_free_t buffree;
} Ipmip_pktbuf_context_t;
typedef struct Ipmip_pktbuf_pktaux
{
Ipmip_pktbuf_payload_t *pktdata[IPMIP_PKTBUF_PKTAUX_SIZE];
Ip_size_t pktdata_num;
Ip_size_t pktdata_header;
Ip_size_t pktdata_payload;
} Ipmip_pktbuf_pktaux_t;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipmip_pktbuf_alloc - ipmip_pktbuf_alloc
*
* Allocate a pktbuf. The packet will have a minimum of pkt_size
* bytes already available in the packet buffer. The real allocation
* of this frame is done by the bufalloc hook registered in the packet
* context create.
*
* Parameters:
* \is
* \i context
* The context
* \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 pkt_size
* The initial size of the packet buffer
* \ie
*
* RETURNS: A newly allocated and initialized pktbuf on success
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_pktbuf_t * ipmip_pktbuf_alloc
(
struct Ipmip_context *context,
struct Ipmip_proc *proc,
Ip_size_t pkt_size
);
/*******************************************************************************
*
* ipmip_pktbuf_free - ipmip_pktbuf_free
*
* Free a previously allocated pktbuf. You should not invoke this function
* unless you are certain the packet is unreferenced. Otherwise you should
* invoke ipmip_pktbuf_release. The real releasing of resources is done by
* the buffree function registered in the packet context create.
*
* 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 pbuf
* The pktbuf
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_pktbuf_free
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_pktbuf_t *pbuf
);
/*******************************************************************************
*
* ipmip_pktbuf_release - ipmip_pktbuf_release
*
* Release the pktbuf, and if possible, free it.
*
* 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 pbuf
* The pktbuf
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_pktbuf_release
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_pktbuf_t *pbuf
);
/*******************************************************************************
*
* ipmip_pktbuf_reference - ipmip_pktbuf_reference
*
* Reference the pktbuf
*
* 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 pbuf
* The pktbuf
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_pktbuf_reference
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_pktbuf_t *pbuf
);
/*******************************************************************************
*
* ipmip_pktbuf_context_create - ipmip_pktbuf_context_create
*
* This function creates the packet buffer context. It requires two arguments,
* which are the bufalloc and buffree function callbacks.
* The bufalloc callback will be invoked when a packet frame is to be allocated,
* and parameters to this function call will be the extra size that IPMIP
* requires beyond the basic sizeof(Ipmip_pktbuf_t). The bufalloc function
* must initialize the pktend pointer in the Ipmip_pktbuf_t to the end
* of the packet header, where the end is either sizeof(Ipmip_pktbuf_t) bytes
* in to the frame, or more if Ipmip_pktbuf_t has been overloaded in order
* to define more required packet buffer parameters for that system.
* The buffree function hook will be invoked when a frame is to be freed. It
* is supposed to free the packet buffer and any extra data allocated by the
* bufalloc routine,
*
* 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 bufalloc
* Pkt buffer allocation function; If NULL a
*
* straight Ipmip_pktbuf_t will be allocated.
* \i buffree
* Overriding free function for packet buffers;
*
* if none, ordinary free will be used.
* \ie
*
* RETURNS: IP_TRUE if successful
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL Ip_bool ipmip_pktbuf_context_create
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_pkt_buf_alloc_t bufalloc,
Ipmip_pkt_buf_free_t buffree
);
/*******************************************************************************
*
* ipmip_pktbuf_context_destroy - ipmip_pktbuf_context_destroy
*
* Destroy the buffer context. This method is used internally by the IPMIP
* context, and you should not ever need to invoke it. It's called from
* the ipmip_context_destroy function.
*
* 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_pktbuf_context_destroy
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc
);
/*******************************************************************************
*
* ipmip_pktbuf_error - ipmip_pktbuf_error
*
* Set an error message and a code in a packet buffer.
*
* Parameters:
* \is
* \i pbuf
* The pktbuf
* \i error_code
* Error code
* \i format
* The format string
* \i ...
* The format parameters
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_pktbuf_error
(
Ipmip_pktbuf_t *pbuf,
Ip_u8 error_code,
const char *format,
...
);
#ifdef IPMIP_USE_INET
/*******************************************************************************
*
* ipmip_pktbuf_srcinfo_dst_inet - ipmip_pktbuf_srcinfo_dst_inet
*
* Set the destination sourceinfo based on an inet pktinfo.
*
* Parameters:
* \is
* \i pbuf
* The pktbuf
* \i pktinfo
* Packet info container
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL void ipmip_pktbuf_srcinfo_dst_inet
(
Ipmip_pktbuf_t *pbuf,
struct Ip_in_pktinfo *pktinfo
);
#endif
#ifdef IPMIP_USE_INET6
/*******************************************************************************
*
* ipmip_pktbuf_srcinfo_dst_inet6 - ipmip_pktbuf_srcinfo_dst_inet6
*
* Set the destination sourceinfo based on an inet6 pktinfo.
*
* Parameters:
* \is
* \i pbuf
* The pktbuf
* \i pktinfo
* Packet info container
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL void ipmip_pktbuf_srcinfo_dst_inet6
(
Ipmip_pktbuf_t *pbuf,
struct Ip_in6_pktinfo *pktinfo
);
#endif
/*******************************************************************************
*
* ipmip_pktbuf_pktaux_add - ipmip_pktbuf_pktaux_add
*
* Register a packet buffer data extension. This function is invoked during
* setup of a MIP entity. It will reserve the space indicated by pktaux in
* all allocated packet buffers.
*
* Parameters:
*
* \is
* \i aux
* Packet context auxillary information
* \i pktaux
* Packet buffer auxillary definition
* \ie
*
* RETURNS: The packet payload index on success, 0 on failure.
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL Ip_u32 ipmip_pktbuf_pktaux_add
(
Ipmip_pktbuf_pktaux_t *aux,
Ipmip_pktbuf_payload_t *pktaux
);
/*******************************************************************************
*
* ipmip_pktbuf_pktaux_data_get - ipmip_pktbuf_pktaux_data_get
*
* Retrieve the data allocated for a specific payload index. The payload
* index is the number returned by the ipmip_pktbuf_pktaux_add function.
*
* 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 pbuf
* Packet buffer
* \i payload_index
* The packet buffer payload index
* \i payload_create
* Create the payload buffer if TRUE, otherwise just return what is.
* \ie
*
* RETURNS: The data if available, or IP_NULL.
*
* ERRNO:
*
* NOMANUAL
*/
IP_GLOBAL void *ipmip_pktbuf_pktaux_data_get
(
struct Ipmip_context *ctx,
Ipmip_pktbuf_t *pbuf,
Ip_u32 payload_index,
Ip_bool payload_create
);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,374 @@
/* ipmip_rtab.h - ipmip_rtab.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip_rtab.h,v $ $Revision: 1.6 $
* $Source: /home/interpeak/CVSRoot/ipmip/include/private/ipmip_rtab.h,v $
* $Author: jhorteli $ $Date: 2010-12-07 09:55:01 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
******************************************************************************
*/
#ifndef IPMIP_RTAB_H
#define IPMIP_RTAB_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
DESCRIPTION
This is a route table instantiation class. It is mostly used to provide
overloaded configuration parameters and access information. It allows for
creating explicit information and add information that covers it, in the
same way a route table would.
So, one can create an information database containing NODE specific information,
and also add multiple layers of NETWORK dependent information.
A module can locate the most specific information, then traverse to less
and less specific information to retrieve or combine the requested data.
For example various Access Control lists uses this to specify access rights
for explicit nodes, as well as networks,
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <ipcom_route.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
enum
{
IPMIP_ROUTE_LOOKUP_MISS,
IPMIP_ROUTE_LOOKUP_MASK,
IPMIP_ROUTE_LOOKUP_MATCH
};
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
struct Ipmip_context;
struct Ipmip_proc;
typedef Ipcom_route Ipmip_rtab_t;
typedef struct Ipmip_route
{
Ipcom_route_entry hdr;
Ip_u8 bits;
struct Ipmip_route *narrow;
struct Ipmip_route *widen;
} Ipmip_route_t;
typedef Ip_bool (*Ipmip_route_walk_t) (struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_rtab_t *rtab,
Ipmip_route_t *rt,
void *opaque);
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipmip_route_lookup - ipmip_route_lookup
*
* Perform a lookup in a MIP route table.
*
* Parameters:
* \is
* \i rtab
* Routing Table. Must be allocated by ipcom_route_new_table.
* \i key
* Lookup key
* \i rtp
* Pointer to store the looked up route in.
* \ie
*
* RETURNS: IPMIP_ROUTE_LOOKUP_MISS on failure, IPMIP_ROUTE_LOOKUP_MASK on a
* non-perfect match and IPMIP_ROUTE_LOOKUP_MATCH on a perfect match.
*
* ERRNO:
*
*/
IP_GLOBAL int ipmip_route_lookup
(
Ipmip_rtab_t *rtab,
void *key,
Ipmip_route_t **rtp
);
/*******************************************************************************
*
* ipmip_route_lookup_any - ipmip_route_lookup_any
*
* Returns the first matching route.
*
* Parameters:
* \is
* \i rtab
* Routing Table. Must be allocated by ipcom_route_new_table.
* \i key
* Lookup key
* \ie
*
* RETURNS: The route on success, IP_NULL otherwise.
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_route_t *ipmip_route_lookup_any
(
Ipmip_rtab_t *rtab,
void *key
);
/*******************************************************************************
*
* ipmip_route_lookup_exact - ipmip_route_lookup_exact
*
* Returns an exact match..
*
* Parameters:
* \is
* \i rtab
* Routing Table. Must be allocated by ipcom_route_new_table.
* \i key
* Lookup key
* \ie
*
* RETURNS: The route on success, IP_NULL otherwise.
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_route_t *ipmip_route_lookup_exact
(
Ipmip_rtab_t *rtab,
void *key,
Ip_u8 bits
);
/*******************************************************************************
*
* ipmip_route_lookup_parent - ipmip_route_lookup_parent
*
* Returns the first route match with a wider mask than the provided route.
*
* Parameters:
* \is
* \i rtab
* Routing Table. Must be allocated by ipcom_route_new_table.
* \i rt
* Route to find parent for
* \ie
*
* RETURNS: The route on success, IP_NULL otherwise.
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_route_t *ipmip_route_lookup_parent
(
Ipmip_rtab_t *rtab,
Ipmip_route_t *rt
);
/*******************************************************************************
*
* ipmip_route_lookup_child - ipmip_route_lookup_child
*
* Returns the first route match with a narrower mask than the provided route.
*
* Parameters:
* \is
* \i rtab
* Routing Table. Must be allocated by ipcom_route_new_table.
* \i rt
* Route to find parent for
* \ie
*
* RETURNS: The route on success, IP_NULL otherwise.
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip_route_t *ipmip_route_lookup_child
(
Ipmip_rtab_t *rtab,
Ipmip_route_t *rt
);
/*******************************************************************************
*
* ipmip_route_notify - ipmip_route_notify
*
* Notification routine that should be either registered using
* ipcom_route_new_table during creation of the route table, or invoked
* from the customized notification routine that is.
*
* Parameters:
* \is
* \i rtab
* Routing Table
* \i rt
* Route we're notified about.
* \i code
* The error code
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_route_notify
(
Ipmip_rtab_t *rtab,
Ipmip_route_t *rt,
int code
);
/*******************************************************************************
*
* ipmip_route_add - ipmip_route_add
*
* Add a MIP route to the MIP routing table
*
* Parameters:
* \is
* \i rtab
* Routing Table
* \i rt
* Route we're adding
* \ie
*
* RETURNS: 0 on success, < 0 otherwise.
*
* ERRNO:
*
*/
IP_GLOBAL int ipmip_route_add
(
Ipmip_rtab_t *rtab,
Ipmip_route_t *rt
);
/*******************************************************************************
*
* ipmip_route_delete - ipmip_route_delete
*
* Delete a MIP route from the MIP routing table
*
* Parameters:
* \is
* \i rtab
* Routing Table
* \i rt
* Route we're removing
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_route_delete
(
Ipmip_rtab_t *rtab,
Ipmip_route_t *rt
);
/*******************************************************************************
*
* ipmip_route_walk - ipmip_route_walk
*
* Traverse a routing table and feed all routes to the callback function. If
* the callback function returns IP_TRUE, the route will be deleted.
*
* 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 rtab
* Routing Table
* \i opaque
* Opaque data to be provided with the walk_func
* \i walk_func
* Callback function
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_route_walk
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_rtab_t *rtab,
void *opaque,
Ipmip_route_walk_t walk_func
);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,803 @@
/* ipmip_sysvar.h - ipmip_sysvar.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip_sysvar.h,v $ $Revision: 1.17 $
* $Source: /home/interpeak/CVSRoot/ipmip/include/private/ipmip_sysvar.h,v $
* $Author: jhorteli $ $Date: 2010-12-07 09:55:01 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
******************************************************************************
*/
#ifndef IPMIP_SYSVAR_H
#define IPMIP_SYSVAR_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
* System configuration base functions. Base functions that provide wildcard
* and 'printf' similar syntax in order to retrieve system configuration
* variables.
*/
/*
DESCRIPTION
System configuration base functions. Base functions that provide wildcard
and 'printf' similar syntax in order to retrieve system configuration
variables.
EXAMPLE
Basic example as to how the sysvar utility functions are used.
.CS
void read_configuration_parameters(Ipmip_if_t *iff)
{
Ip_u16 lifetime = ipmip_sysvar_ushort(0, "ipmip6ha.interface.%s.lifetime", iff->ifname);
Ip_bool AlwaysVerifyTunnelSrc = ipmip_sysvar_bool(IP_FALSE, "ipmip6ha.interface.%s.AlwaysVerifyTunnelSrc", iff->ifname);
Ip_u32 BRIMaxRetriesNumber = ipmip_sysvar_u32(1, "ipmip6ha.interface.%s.BRIMaxRetriesNumber", iff->ifname);
}
.CE
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <ipcom_clib2.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/* */
#define IPMIP_SYSVAR_MODE_DISABLED 0
#define IPMIP_SYSVAR_MODE_OPTIONAL 1
#define IPMIP_SYSVAR_MODE_REQUIRED 2
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
struct Ipmip_proc;
struct Ipmip_context;
/*
* Description: Callback invoked for each matching entry in the sysvar
* table.
* Parameters: key - The entire name of the sysvar key
* subkey - The wildcard part of the matched sysvar key
* value - The value of the sysvar key
* data - Opaque data supplied with the call.
*/
typedef void (*Ipmip_sysvar_foreach_t) (struct Ipmip_proc *proc,
const char *key,
const char *subkey,
const char *value,
void *data);
typedef void (*Ipmip_sysvar_foreach_ext_t) (struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
const char *key,
const char *subkey,
const char *value,
void *data);
typedef struct Ipmip_sysvar_key_map
{
int key;
const char *str;
}
Ipmip_sysvar_key_map_t;
extern const char *ipmip_sysvar_mode_desc[];
extern const Ipmip_sysvar_key_map_t ipmip_sysvar_bool_ops[];
extern const Ipmip_sysvar_key_map_t ipmip_sysvar_tunnel_mask[];
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipmip_vsysvar - ipmip_vsysvar
*
* Return the configuration system variable value pointer to
* by the format string and the provided optional arguments.
* The return value is dynamically allocated, and must be
* freed by the caller.
*
* Parameters:
* \is
* \i format
* Format string
* \i ap
* Optional arguments
* \ie
*
* RETURNS: The configuration string value
*
* ERRNO:
*
*/
IP_GLOBAL char * ipmip_vsysvar
(
const char *format,
va_list ap
);
/*******************************************************************************
*
* ipmip_sysvar - ipmip_sysvar
*
* Return the configuration system variable value pointer to
* by the format string and the provided optional arguments.
* The return value is dynamically allocated, and must be
* freed by the caller.
*
* Parameters:
* \is
* \i format
* Format string
* \i ...
* Optional arguments
* \ie
*
* RETURNS: The configuration string value
*
* ERRNO:
*
*/
IP_GLOBAL char * ipmip_sysvar
(
const char *format,
/* args*/ ...
);
/*******************************************************************************
*
* ipmip_sysvar_set - ipmip_sysvar_set
*
* Set a particular system variable
*
* Parameters:
* \is
* \i value
* value
* \i format
* Format string
* \i ...
* Optional arguments
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_sysvar_set
(
const char *value,
const char *format,
/* args*/ ...
);
/*******************************************************************************
*
* ipmip_sysvar_set_ulong - ipmip_sysvar_set_ulong
*
* Set a particular system variable
*
* Parameters:
* \is
* \i value
* Value
* \i format
* Format string
* \i ...
* Optional arguments
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_sysvar_set_ulong
(
unsigned long value,
const char *format,
/* args*/ ...
);
/*******************************************************************************
*
* ipmip_sysvar_unset - ipmip_sysvar_unset
*
* Unset a particular system variable
*
* Parameters:
* \is
* \i format
* Format string
* \i ...
* Optional arguments
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_sysvar_unset
(
const char *format,
/* args*/ ...
);
/*******************************************************************************
*
* ipmip_sysvar_mode - ipmip_sysvar_mode
*
* Parse and return a mode value, where mode is either DISABLED,
* OPTIONAL or REQUIRED. DISABLED equals integer 0, or 'disable',
* 'disabled', 'false' or 'no'. OPTIONAL equals integer 1, or
* 'optional' or 'may'. REQUIRED equals 'yes', 'true', integer 2,
* 'enable', 'enabled' or 'required'
*
* Parameters:
* \is
* \i defval
* The default value.
* \i format
* Format string
* \i ...
* Optional arguments
* \ie
*
* RETURNS: IPMIP4_SYSVAR_MODE_DISABLED, IPMIP4_SYSVAR_MODE_OPTIONAL or
* IPMIP4_SYSVAR_MODE_REQUIRED
*
* ERRNO:
*
*/
IP_GLOBAL int ipmip_sysvar_mode
(
int defval,
const char *format,
/* args*/ ...
);
/*******************************************************************************
*
* ipmip_sysvar_bool - ipmip_sysvar_bool
*
* Parse and return a boolean value; A boolean value is either
* a numerical value, where != 0,enabled, enable, yes or true
* equals IP_TRUE, or 0, disabled, disable, no or false which equals
* IP_FALSE. If the system variable doesn't exist, the provided
* default value will be returned.
*
* Parameters:
* \is
* \i defval
* The default value.
* \i format
* Format string
* \i ...
* Optional arguments
* \ie
*
* RETURNS: The configuration value; IP_TRUE or IP_FALSE.
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_sysvar_bool
(
Ip_bool defval,
const char *format,
/* args*/ ...
);
/*******************************************************************************
*
* ipmip_sysvar_key - ipmip_sysvar_key
*
* Parse a sysvar key and map it to an option
*
* Parameters:
* \is
* \i defval
* Default value
* \i map
* Key options
* \i format
* Format string
* \i ...
* Optional arguments
* \ie
*
* RETURNS: -1 on failure; key value otherwise.
*
* ERRNO:
*
*/
IP_GLOBAL int ipmip_sysvar_key
(
int defval,
Ipmip_sysvar_key_map_t *map,
const char *format,
/* args*/ ...
);
/*******************************************************************************
*
* ipmip_sysvar_ulong - ipmip_sysvar_ulong
*
* Parse and return an unsigned long value; If the system variable
* doesn't exist, the provided default value will be returned.
*
* Parameters:
* \is
* \i defval
* The default value.
* \i format
* Format string
* \i ...
* Optional arguments
* \ie
*
* RETURNS: The configuration integer value
*
* ERRNO:
*
*/
IP_GLOBAL unsigned long ipmip_sysvar_ulong
(
unsigned long defval,
const char *format,
/* args*/ ...
);
/*******************************************************************************
*
* ipmip_sysvar_u32 - ipmip_sysvar_u32
*
* Parse and return an u32; If the system variable
* doesn't exist, the provided default value will be returned.
*
* Parameters:
* \is
* \i defval
* The default value.
* \i format
* Format string
* \i ...
* Optional arguments
* \ie
*
* RETURNS: The configuration integer value
*
* ERRNO:
*
*/
IP_GLOBAL Ip_u32 ipmip_sysvar_u32
(
Ip_u32 defval,
const char *format,
/* args*/ ...
);
/*******************************************************************************
*
* ipmip_sysvar_ushort - ipmip_sysvar_ushort
*
* Parse and return an unsigned short value; If the system variable
* doesn't exist, the provided default value will be returned.
*
* Parameters:
* \is
* \i defval
* The default value.
* \i format
* Format string
* \i ...
* Optional arguments
* \ie
*
* RETURNS: The configuration integer value
*
* ERRNO:
*
*/
IP_GLOBAL unsigned short ipmip_sysvar_ushort
(
unsigned short defval,
const char *format,
/* args*/ ...
);
/*******************************************************************************
*
* ipmip_sysvar_long - ipmip_sysvar_long
*
* Parse and return a long value; If the system variable
* doesn't exist, the provided default value will be returned.
*
* Parameters:
* \is
* \i defval
* The default value.
* \i format
* Format string
* \i ...
* Optional arguments
* \ie
*
* RETURNS: The configuration integer value
*
* ERRNO:
*
*/
IP_GLOBAL long ipmip_sysvar_long
(
long defval,
const char *format,
/* args*/ ...
);
/*******************************************************************************
*
* ipmip_sysvar_short - ipmip_sysvar_short
*
* Parse and return a long value; If the system variable
* doesn't exist, the provided default value will be returned.
*
* Parameters:
* \is
* \i defval
* The default value.
* \i format
* Format string
* \i ...
* Optional arguments
* \ie
*
* RETURNS: The configuration integer value
*
* ERRNO:
*
*/
IP_GLOBAL short ipmip_sysvar_short
(
short defval,
const char *format,
/* args*/ ...
);
#ifdef IPMIP_USE_INET
/*******************************************************************************
*
* ipmip_sysvar_inet - ipmip_sysvar_inet
*
* Read a sysvar variable and convert it to an IPv4 address and
* prefix. If plen is specified; it will look for /<num> prefix
* indicator, if not available, prefix will be 32.
*
* Parameters:
* \is
* \i defip
* Default value
* \i addr
* The addr to store the result in.
* \i plen
* Prefix length.[may be NULL]
* \i format
* Format string
* \i ...
* Arguments.
* \ie
*
* RETURNS: IP_TRUE on success; IP_FALSE otherwise
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_sysvar_inet
(
Ip_u32 defip,
Ip_u32 *addr,
Ip_u32 *plen,
const char *format,
/* args*/ ...
);
#endif
#ifdef IPMIP_USE_INET6
/*******************************************************************************
*
* ipmip_sysvar_inet6 - ipmip_sysvar_inet6
*
* Read a sysvar variable and convert it to an IPv6 address and
* prefix. If plen is specified; it will look for /<num> prefix
* indicator, if not available, prefix will be 32.
*
* Parameters:
* \is
* \i defip
* Default value
* \i addr
* The addr to store the result in.
* \i plen
* Prefix length.[may be NULL]
* \i format
* Format string
* \i ...
* Arguments.
* \ie
*
* RETURNS: IP_TRUE on success; IP_FALSE otherwise
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip_sysvar_inet6
(
const struct Ip_in6_addr *defaddr6,
struct Ip_in6_addr *addr,
Ip_u8 *plen,
const char *format,
/* args*/ ...
);
#endif
/*******************************************************************************
*
* ipmip_sysvar_foreach - ipmip_sysvar_foreach
*
* Iterate and expand tables in sysvar.
*
* 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 cb_func
* The sysvar foreach callback
* \i cookie
* Opaque data.
* \i format
* The format key
* \i ...
* Arguments
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_sysvar_foreach
(
struct Ipmip_proc *proc,
Ipmip_sysvar_foreach_t cb_func,
void *cookie,
const char *format,
/* args*/ ...
);
/*******************************************************************************
*
* ipmip_sysvar_foreach_ext - ipmip_sysvar_foreach_ext
*
* Iterate and expand tables in sysvar.
*
* 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 cb_func
* The sysvar foreach callback
* \i cookie
* Opaque data.
* \i format
* The format key
* \i ...
* Arguments
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip_sysvar_foreach_ext
(
struct Ipmip_context *ctx,
struct Ipmip_proc *proc,
Ipmip_sysvar_foreach_ext_t cb_func,
void *cookie,
const char *format,
/* args*/ ...
);
/*******************************************************************************
*
* ipmip_sysvar_array - ipmip_sysvar_array
*
* Parse and return an array of configuration options where each
* string will be matched to a configuration value and returned
* in a dynamically allocated integer array terminated with the
* value 0xffffffff. The integer array must be freed by the caller.
*
* Parameters:
* \is
* \i ops
* Options for parsing the strings
* \i format
* Format string
* \i ...
* Optional arguments
* \ie
*
* RETURNS: The integer array.
*
* ERRNO:
*
*/
IP_GLOBAL int * ipmip_sysvar_array
(
Ipmip_sysvar_key_map_t *ops,
const char *format,
/* args*/ ...
);
/*******************************************************************************
*
* ipmip_sysvar_strlist - ipmip_sysvar_strlist
*
* Parse and return a string array of the format
* <num entries><length><string><length><string> .. where length
* is 1 byte, and string is a zero terminated; the length includes
* the zero termination and the length byte; the array is
* terminated by a length byte with value 0. The returned data is
* dynamically allocated and must be freed by the caller. num
* entries is a one byte entry indicating the number of strings
* stored in the array.
*
* Parameters:
* \is
* \i format
* Format string
* \i ...
* format arguments
* \ie
*
* RETURNS: The strlist array
*
* ERRNO:
*
*/
IP_GLOBAL Ip_u8 * ipmip_sysvar_strlist
(
const char *format,
/* args*/ ...
);
/*******************************************************************************
*
* ipmip_sysvar_strarr - ipmip_sysvar_strarr
*
* Parse and return an IP_NULL string pointer array
*
* Parameters:
* \is
* \i format
* Format string
* \i ...
* format arguments
* \ie
*
* RETURNS: The string pointer array
*
* ERRNO:
*
*/
IP_GLOBAL char **ipmip_sysvar_strarr
(
const char *format,
/* args*/ ...
);
/*******************************************************************************
*
* ipmip_sysvar_cmd_str_to_key - ipmip_sysvar_cmd_str_to_key
*
* Converts the string representation in map to the numeric value.
*
* Parameters:
* \is
* \i map
* The int to string map to use.
* \i str
* The string to lookup
* \ie
*
* RETURNS: The numeric representation
*
* ERRNO:
*
*/
IP_GLOBAL int ipmip_sysvar_cmd_str_to_key
(
const Ipmip_sysvar_key_map_t *map,
const char *str
);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff