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

453 lines
14 KiB
C

/* ipmip6_context.h - ipmip6_context.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6_context.h,v $ $Revision: 1.10 $
* $Source: /home/interpeak/CVSRoot/ipmip6/include/private/ipmip6_context.h,v $
* $Author: jhorteli $ $Date: 2010-12-07 09:55:18 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
******************************************************************************
*/
#ifndef IPMIP6_CONTEXT_H
#define IPMIP6_CONTEXT_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
DESCRIPTION
MIP4 context definitions. Deals with process creation, and context
instantiations. This module provides a superset to the MIP context
definitions.Functions defined here will usually in turn invoke their
IPMIP counterpart.
EXAMPLE
To create, initialize, start stop and destroy a context in MIP6
.CS
/@ Just some sort of entity that one could have in a mobility systemm which
requires a unique identifier @/
struct Ipmip6_my_entities
{
struct Ipmip_my_entities ipmip;
int my_personal_data;
};
struct Ipmip6_my_context
{
Ipmip6_context_t ipmip; /@ Basic IPMIP context @/
int my_personal_data;
};
Ipmip6_if_event_table_t ipmip6_ifevent_table =
{
(Ipmip6_if_event_t)IP_NULL,
(Ipmip6_if_event_t)IP_NULL,
(Ipmip6_if_event_t)IP_NULL,
(Ipmip6_if_event_t)IP_NULL,
(Ipmip6_if_event_t)IP_NULL,
(Ipmip6_if_event_t)IP_NULL,
(Ipmip6_if_event_t)IP_NULL,
(Ipmip6_if_event_t)IP_NULL
};
struct Ipmip6_my_context *my_init_func6(Ipmip_proc_t *proc)
{
/@ Allocate my context; indicate the size of my overloaded structure @/
struct Ipmip6_my_context *ctx = (struct Ipmip6_my_context *)ipmip_context_alloc(proc, sizeof(*ctx), "mymip6", IPCOM_LOG_DEBUG2, 10);
/@ Initialize the MIP6 portion of the context @/
ipmip6_context_initialize(&ctx->ipmip6, proc, &ipmip6_ifevent_table);
/@ YOU NEED TO ADD MIP SPECIFC INITIALIZATION CODE HERE AS WELL
AS DEFINED IN ipmip_context.h/ipmip_cli.h/ipmip_pktbuf.h @/
/@ Start the context @/
ipmip6_context_start(&ctx->ipmip6, proc);
}
void my_stop_func6(Ipmip_proc_t *proc, struct Ipmip6_my_context *ctx)
{
/@ Stop the context @/
ipmip6_context_stop(&ctx->ipmip6, proc);
/@ Destroy the context @/
ipmip6_context_destroy(&ctx->ipmip6, proc);
}
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 Ipmip6_my_context *ctx = my_init_func6(proc);
/@ Stop the context @/
my_stop_func6(proc, ctx);
/@ Destroy the process context - If ipmip_proc_stop is used, @/
ipmip_proc_destroy(proc);
}
.CE
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <private/ipmip_context.h>
#include <private/ipmip_timer.h>
#include <ipmip6_mib.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
struct Ipmip6_nd_context;
struct Ipmip6_if_context;
struct Ipmip6_if;
struct Ipmip6_context;
struct Ipmip_proc;
struct Ipmip6_pkt_context;
struct Ipmip6_pktbuf;
struct Ipmip_cli_message;
typedef void (*Ipmip6_context_if_event_t) (struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
struct Ipmip6_if *ifp,
void *opaque);
typedef struct Ipmip6_context_if
{
Ipcom_list interfaces; /* Interface list */
Ip_bool no_solicitation;
Ipmip_timer_lock_t *iflock;
struct Ipmip6_if_event_table *iftable;
}
Ipmip6_context_if_t;
typedef struct Ipmip6_context
{
Ipmip_context_t ipmip;
/* Interface information */
Ipmip6_context_if_t iff;
/* Packet information */
struct Ipmip6_pkt_context *pkt;
Ipcom_mutex mip6TotalTraffic_lock;
struct Ipmip6_mib_mip6TotalTraffic mip6TotalTraffic;
Ip_u32 restart_counter;
}
Ipmip6_context_t;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipmip6_context_initialize - ipmip6_context_initialize
*
* One time initialization functions that will initialize the IPMIP6 portion
* of the context.
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP6. 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 ipmip6_context_create(). See ipmip6_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 ifevent
* The interface event table. Specifies the callbacks to be invoked
* when the MIP6 system encounters a route, address, prefix or interface
* status change.
* \ie
*
* RETURNS: IP_TRUE if successful, IP_FALSE otherwise.
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip6_context_initialize
(
Ipmip6_context_t *ctx,
Ipmip_proc_t *proc,
struct Ipmip6_if_event_table *ifevent
);
/*******************************************************************************
*
* ipmip6_context_restart_counter_update - ipmip6_context_restart_counter_update
*
* Updates the restart counter. Used by HEARTBEAT mechanisms to keep track
* of potential restarts or other events that would require the remote
* entities to either discard current connections or re-establish them.
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP6. 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 ipmip6_context_create(). See ipmip6_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:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip6_context_restart_counter_update
(
Ipmip6_context_t *ctx,
Ipmip_proc_t *proc
);
/*******************************************************************************
*
* ipmip6_context_destroy - ipmip6_context_destroy
*
* Destroy the IPMIP6 context. Will destroy all resources associated with the
* MIP6 entity, and also invoke the IPMIP ipmip_context_destroy routine
* to destroy resources allocated by the base IPMIP system.
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP6. 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 ipmip6_context_create(). See ipmip6_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 ipmip6_context_destroy
(
Ipmip6_context_t *ctx,
Ipmip_proc_t *proc
);
/*******************************************************************************
*
* ipmip6_context_stop - ipmip6_context_stop
*
* Stop the MIP6 context. Will also invoke ipmip_context_stop in order to
* stop all functions and resources currently active in the base IPMIP system.
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP6. 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 ipmip6_context_create(). See ipmip6_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 ipmip6_context_stop
(
Ipmip6_context_t *ctx,
Ipmip_proc_t *proc
);
/*******************************************************************************
*
* ipmip6_context_start - ipmip6_context_start
*
* Start the MIP6 context. Will also invoke ipmip_context_start in order to
* activate the functionalities in the base IPMIP system.
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP6. 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 ipmip6_context_create(). See ipmip6_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 ipmip6_context_start
(
Ipmip6_context_t *ctx,
Ipmip_proc_t *proc
);
/*******************************************************************************
*
* ipmip6_context_add_outbound - ipmip6_context_add_outbound
*
* Add global MIP6 outbound traffic statistics.
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP6. 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 ipmip6_context_create(). See ipmip6_context.h for
* more information regarding the mobility entity context singleton.
* \i octets
* Bytes to add
* \i pkts
* Pkts to add
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip6_context_add_outbound
(
Ipmip6_context_t *ctx,
Ip_u64 octets,
Ip_u64 pkts
);
/*******************************************************************************
*
* ipmip6_context_add_inbound - ipmip6_context_add_inbound
*
* Add global MIP6 inbound traffic statistics.
*
* Parameters:
* \is
* \i ctx
* The generic mobility singleton context for IPMIP6. 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 ipmip6_context_create(). See ipmip6_context.h for
* more information regarding the mobility entity context singleton.
* \i octets
* Bytes to add
* \i pkts
* Pkts to add
* \ie
*
* RETURNS: No return value
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip6_context_add_inbound
(
Ipmip6_context_t *ctx,
Ip_u64 octets,
Ip_u64 pkts
);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/