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

748 lines
22 KiB
C

/* ipmip6_bc.h - ipmip6_bc.h */
/*
******************************************************************************
* HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6_bc.h,v $ $Revision: 1.6 $
* $Source: /home/interpeak/CVSRoot/ipmip6/include/private/ipmip6_bc.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_BC_H
#define IPMIP6_BC_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
DESCRIPTION
MIP6 binding cache implementation. Is only used by the Mobile Node v6 and
will eventually be obsoleted or transferred to the Mobile Node v6 domain.
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <ipcom_hash.h>
#include "ipmip6_mib.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/* State flags */
#define IPMIP6_BC_INCOMPLETE (1 << 0)
#define IPMIP6_BC_BINDING_UPDATE (1 << 1)
#define IPMIP6_BC_BINDING_ACK (1 << 2)
#define IPMIP6_BC_RR_HOME_INIT (1 << 3)
#define IPMIP6_BC_RR_HOME_TEST (1 << 4)
#define IPMIP6_BC_RR_CARE_OF_INIT (1 << 5)
#define IPMIP6_BC_RR_CARE_OF_TEST (1 << 6)
#define IPMIP6_BC_INVALID (1 << 7)
#define IPMIP6_BC_DELETED (1 << 8)
#define IPMIP6_BC_STOPPED (1 << 9)
#define IPMIP6_BC_ERROR (1 << 10)
#define IPMIP6_BC_RR_COMPLETE (IPMIP6_BC_RR_HOME_INIT |\
IPMIP6_BC_RR_HOME_TEST |\
IPMIP6_BC_RR_CARE_OF_INIT |\
IPMIP6_BC_RR_CARE_OF_TEST)
#define IPMIP6_BC_DEAD (IPMIP6_BC_INVALID | \
IPMIP6_BC_DELETED)
#define IPMIP6_BC_UNUSABLE (IPMIP6_BC_INCOMPLETE | \
IPMIP6_BC_STOPPED | \
IPMIP6_BC_DEAD)
#define IPMIP6_BC_ACTIVE(x) (((x) & (IPMIP6_BC_UNUSABLE)) == 0)
/* Notification callbacks */
#define IPMIP6_BC_HASH_REASON_ADD (0)
#define IPMIP6_BC_HASH_REASON_PURGE (1)
#define IPMIP6_BC_HASH_REASON_ERROR (2)
#define IPMIP6_BC_HASH_REASON_ACTIVATE (3)
#define IPMIP6_BC_HASH_REASON_DEACTIVATE (4)
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
/* Forward declaration to deal with the function callback prototypes */
struct Ipmip6_bc;
struct Ipmip6_bc_hash;
struct Ipmip6_context;
struct Ipmip_proc;
struct Ipmip6_pktbuf;
typedef struct Ipmip6_bc_key
{
struct Ip_in6_addr *key;
}
Ipmip6_bc_key_t;
typedef void (*Ipmip6_bc_hash_notify_t) (struct Ipmip6_context *ctx, struct Ipmip_proc *proc, void *opaque, struct Ipmip6_bc_hash *hash, struct Ipmip6_bc *bc, int reason);
typedef struct Ipmip6_bc_hash
{
Ipcom_hash *bch_hash;
Ipmip6_bc_hash_notify_t bch_notify;
void *bch_opaque;
}
Ipmip6_bc_hash_t;
/* Binding cache entry state callbacks */
typedef void (*Ipmip6_bc_activate_cb_t) (struct Ipmip6_context *ctx, struct Ipmip_proc *proc, struct Ipmip6_bc *bc, struct Ipmip6_pktbuf *pbuf);
typedef void (*Ipmip6_bc_deactivate_cb_t) (struct Ipmip6_context *ctx, struct Ipmip_proc *proc, struct Ipmip6_bc *bc);
typedef void (*Ipmip6_bc_remove_cb_t) (struct Ipmip6_context *ctx, struct Ipmip_proc *proc, struct Ipmip6_bc *bc);
typedef void (*Ipmip6_bc_purge_cb_t) (struct Ipmip6_context *ctx, struct Ipmip_proc *proc, struct Ipmip6_bc *bc);
typedef void (*Ipmip6_bc_start_cb_t) (struct Ipmip6_context *ctx, struct Ipmip_proc *proc, struct Ipmip6_bc *bc);
typedef void (*Ipmip6_bc_stop_cb_t) (struct Ipmip6_context *ctx, struct Ipmip_proc *proc, struct Ipmip6_bc *bc);
typedef struct Ipmip6_bc_cb
{
Ipmip6_bc_activate_cb_t activate;
Ipmip6_bc_deactivate_cb_t deactivate;
Ipmip6_bc_remove_cb_t remove;
Ipmip6_bc_purge_cb_t purge;
Ipmip6_bc_start_cb_t start;
Ipmip6_bc_stop_cb_t stop;
}
Ipmip6_bc_cb_t;
/* Binding cache */
typedef struct Ipmip6_bc
{
/* Hash we're inserted in */
Ipmip6_bc_hash_t *hash_table;
Ipmip_timer_lock_t *bc_lock;
/* Binding List key */
struct Ipmip6_mib_mip6MnBLTable mip6MnBLTable; /* Mobile Node */
/* State, depending on peer for meaning */
Ip_u16 state;
/* Sequence number */
Ip_u16 sequence;
Ip_u16 start_sequence;
/* Number of received acknowledgements */
Ip_u16 acknowledgements;
/* Binding Flags */
Ip_u16 flags;
/* Callbacks */
Ipmip6_bc_cb_t cb;
/* Lifetime values */
struct
{
/* Lifetime values for this binding cache */
struct
{
/* Original value */
Ip_u16 original;
/* When we're going to expire */
Ip_time_t expire;
/* Expire Timeout object */
Ipmip_timer_t to_expire;
/* Refresh Timeout object */
Ipmip_timer_t to_refresh;
/* Delete timeout object */
Ipmip_timer_t to_delete;
} lifetime;
} timeout;
}
Ipmip6_bc_t;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*******************************************************************************
*
* ipmip6_bc_delete - ipmip6_bc_delete
*
* Schedules a binding cache entry for deletion.
*
* 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 bc
* Binding Cache entry
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip6_bc_delete
(
struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
Ipmip6_bc_t *bc
);
/*******************************************************************************
*
* ipmip6_bc_error - ipmip6_bc_error
*
* Will indicate an error to the mobility entity. Will also schedule the
* binding cache entry for deletion.
*
* 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 bc
* Binding Cache entry
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip6_bc_error
(
struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
Ipmip6_bc_t *bc
);
/*******************************************************************************
*
* ipmip6_bc_purge - ipmip6_bc_purge
*
* Unconditionally purges a binding cache entry from the MIP entity.
*
* 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 bc
* Binding Cache entry
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip6_bc_purge
(
struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
Ipmip6_bc_t *bc
);
/*******************************************************************************
*
* ipmip6_bc_purge_hash - ipmip6_bc_purge_hash
*
* Unconditionally purges all binding cache entries stored in the
* provided hash table.
*
* 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 hash
* Binding Cache Hash table.
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip6_bc_purge_hash
(
struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
Ipmip6_bc_hash_t *hash
);
/*******************************************************************************
*
* ipmip6_bc_delete_hash - ipmip6_bc_delete_hash
*
* Schedules all binding cache entries stored in the hash table for deletion.
*
* 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 hash
* Binding Cache Hash table.
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip6_bc_delete_hash
(
struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
Ipmip6_bc_hash_t *hash
);
/*******************************************************************************
*
* ipmip6_bc_insert - ipmip6_bc_insert
*
* Insert a new binding cache entry into the provided hash table
*
* 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 hash
* Binding Cache Hash table.
* \i bc
* Binding Cache entry
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip6_bc_insert
(
struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
Ipmip6_bc_hash_t *hash,
Ipmip6_bc_t *bc
);
/*******************************************************************************
*
* ipmip6_bc_set_state - ipmip6_bc_set_state
*
* Sets a state in a binding cache entry. This will also invoke
* the appropriate binding cache update callback if necessary.
*
* 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 bc
* Binding Cache entry
* \i state
* The new state
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip6_bc_set_state
(
struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
Ipmip6_bc_t *bc,
Ip_u16 state
);
/*******************************************************************************
*
* ipmip6_bc_clear_state - ipmip6_bc_clear_state
*
* Clears a state in a binding cache entry. This will also
* invoke the appropriate binding cache update callback if
* necessary.
*
* 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 bc
* Binding Cache entry
* \i state
* The new state
* \i pbuf
* The packet buffer that initiated the state change.
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip6_bc_clear_state
(
struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
Ipmip6_bc_t *bc,
Ip_u16 state,
struct Ipmip6_pktbuf *pbuf
);
/*******************************************************************************
*
* ipmip6_bc_test_state - ipmip6_bc_test_state
*
* Verifies that specified states are set in the binding cache.
*
* Parameters:
* \is
* \i bc
* Binding Cache entry
* \i state
* The state(s) to test
* \i all
* If set, all states specified in state must be set. Otherwise any match will do.
* \ie
*
* RETURNS: IP_TRUE if the state(s) are/is set.
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip6_bc_test_state
(
Ipmip6_bc_t *bc,
Ip_u16 state,
Ip_bool all
);
/*******************************************************************************
*
* ipmip6_bc_stop_hash - ipmip6_bc_stop_hash
*
* Attempt to stop all binding cache entries in the hash
*
* 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 hash
* Binding Cache Hash table.
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip6_bc_stop_hash
(
struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
Ipmip6_bc_hash_t *hash
);
/*******************************************************************************
*
* ipmip6_bc_start_hash - ipmip6_bc_start_hash
*
* Attempt to start all binding cache entries in the hash
*
* 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 hash
* Binding Cache Hash table.
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip6_bc_start_hash
(
struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
Ipmip6_bc_hash_t *hash
);
/*******************************************************************************
*
* ipmip6_bc_create - ipmip6_bc_create
*
* Creates a basic binding cache entry and initiates default values
*
* 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 lock
* Lock to protect this particular binding cache
* \i size
* Size of the binding cache entry, including any extra space
* required by this mobility entity or registration type.
* \ie
*
* RETURNS: The binding cache entry.
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip6_bc_t *ipmip6_bc_create
(
struct Ipmip6_context *ctx,
struct Ipmip_proc *proc,
Ipmip_timer_lock_t *lock,
Ip_u32 size
);
/*******************************************************************************
*
* ipmip6_bc_key_hash_compare - ipmip6_bc_key_hash_compare
*
* Compares a hash key towards a binding cache object
*
* Parameters:
* \is
* \i bc
* Binding Cache entry
* \i key
* Binding Cache key.
* \ie
*
* RETURNS: IP_TRUE if they match, IP_FALSE otherwise.
*
* ERRNO:
*
*/
IP_GLOBAL Ip_bool ipmip6_bc_key_hash_compare
(
Ipmip6_bc_t *bc,
Ipmip6_bc_key_t *key
);
/*******************************************************************************
*
* ipmip6_bc_hash_create - ipmip6_bc_hash_create
*
* Creates a new Binding Cache Hash Table.
*
* Parameters:
* \is
* \i notify
* Binding Cache notification callback to be invoked on deletion, error management
* and state changes.
* \i opaque
* Opaque data to be associated with the table
* \i compare
* Hash compare function.
* \ie
*
* RETURNS: A newly allocated hash table.
*
* ERRNO:
*
*/
IP_GLOBAL Ipmip6_bc_hash_t *ipmip6_bc_hash_create
(
Ipmip6_bc_hash_notify_t notify,
void *opaque,
Ipcom_hash_cmp_func compare
);
/*******************************************************************************
*
* ipmip6_bc_hash_destroy - ipmip6_bc_hash_destroy
*
* Destroys a Binding Cache Hash Table.
*
* Parameters:
* \is
* \i hash
* Hash Table
* \ie
*
* RETURNS:
*
* ERRNO:
*
*/
IP_GLOBAL void ipmip6_bc_hash_destroy
(
Ipmip6_bc_hash_t *hash
);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/