Files
2026-07-30 11:19:44 +05:30

375 lines
8.8 KiB
C

/* 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
****************************************************************************
*/