/* ipmip6_if.h - ipmip6_if.h */ /* ****************************************************************************** * HEADER FILE * * Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmip6_if.h,v $ $Revision: 1.11 $ * $Source: /home/interpeak/CVSRoot/ipmip6/include/private/ipmip6_if.h,v $ * $Author: jhorteli $ $Date: 2010-12-07 09:55:18 $ * $State: Exp $ $Locker: $ * * INTERPEAK_COPYRIGHT_STRING * Design and implementation by Joel Hortelius ****************************************************************************** */ #ifndef IPMIP6_IF_H #define IPMIP6_IF_H /* **************************************************************************** * 1 DESCRIPTION **************************************************************************** */ /* DESCRIPTION This module defines the basic IPMIP6 interface management. The features include attachment and detachment of interfaces, notification callbacks on interface state changes */ /* **************************************************************************** * 2 CONFIGURATION **************************************************************************** */ /* **************************************************************************** * 3 INCLUDE FILES **************************************************************************** */ #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* **************************************************************************** * 4 DEFINES **************************************************************************** */ /* **************************************************************************** * 5 TYPES **************************************************************************** */ struct Ipmip6_if; struct Ipmip6_if_router; struct Ipmip6_if_coa; struct Ipmip6_if_prefix; struct Ipmip6_context; struct Ipmip_proc; typedef void (*Ipmip6_if_event_t) (struct Ipmip6_context *ctx, struct Ipmip_proc *proc, struct Ipmip6_if *ife, void *extdata); typedef struct Ipmip6_if_event_table { Ipmip6_if_event_t coa_del; Ipmip6_if_event_t coa_add; Ipmip6_if_event_t router_new; Ipmip6_if_event_t router_expire; Ipmip6_if_event_t prefix_new; Ipmip6_if_event_t prefix_expire; Ipmip6_if_event_t prefix_advertise; Ipmip6_if_event_t prefix_update; } Ipmip6_if_event_table_t; typedef struct Ipmip6_if_inet6 { Ipcom_list ifa_next; Ipmip6_address_t ifa_address; Ip_u8 ifa_scope; Ip_u8 ifa_flags; Ip_u8 ifa_installed; /* Installed by us? */ int ifa_references; /* Number of prefixes */ Ip_u32 ifa_addrcnt; } Ipmip6_if_inet6_t; #ifdef IPMIP_USE_INET typedef struct Ipmip6_if_inet { Ipcom_list ifa_next; Ip_u32 ifa_address; Ip_u32 ifa_addrcnt; } Ipmip6_if_inet_t; #endif /* Callback structure */ typedef struct Ipmip6_if_notify { Ipcom_list next; /* List linker */ /* The interface name we're looking for */ char ifname[IP_IFNAMSIZ + 1]; /* Event notification */ Ipmip_timer_lock_t *lock; Ipmip_timer_func_t func; Ipmip_timer_t timer; void *opaque; /* Attached IFP */ struct Ipmip6_if *ifp; } Ipmip6_if_notify_t; /* An interface entry */ typedef struct Ipmip6_if { Ipmip_if_t iff; Ipmip_timer_lock_t *iff_lock; Ipmip_if_cleanup_t iff_cleanup; Ip_u32 iff_references; Ip_u32 iff_changes; Ip_bool iff_down; /* Lists required to deal with coa callbacks */ Ipcom_list event; /* Registered L3 event callbacks*/ /* Lists holding the current routers for this interface */ Ipcom_list routers; /* Routers for this interface */ /* Created routes & addresses */ Ipcom_list routes; Ipcom_list inet6; #ifdef IPMIP_USE_INET Ipcom_list inet; #endif Ip_u32 iff_addrcnt; /* ND */ Ipcom_list iff_nd_nud; Ipcom_list iff_nd_proxy; struct Ip_in6_addr linklocal; /* Link local address */ Ipmip_timer_t to_solicit; /* Solication timeout */ Ipmip_timer_t to_cleanup; /* Solication timeout */ Ip_u8 solicitations; /* Number of solicitations */ Ip_u8 has_linklocal; /* Have link local address? */ Ip_u16 __unused; /* Currently unused */ } Ipmip6_if_t; /* **************************************************************************** * 6 FUNCTIONS **************************************************************************** */ /******************************************************************************* * * ipmip6_if_attach - ipmip6_if_attach * * Attach to a new interface and register a notification structure. Interface * information and handles will be stored within the notification structure. * An interface must not exist to be attached, it may appear at any time, * and disappear at any time. Appropriate callbacks will be invoked upon such * events. * * 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 sz * The size of the interface structure. * \i notify * Notification structure * \i cleanup * Interface cleanup handler * \ie * * RETURNS: * * ERRNO: * */ IP_GLOBAL void ipmip6_if_attach ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, Ip_size_t sz, Ipmip6_if_notify_t *notify, Ipmip_if_cleanup_t cleanup ); /******************************************************************************* * * ipmip6_if_detach_iflocked - ipmip6_if_detach_iflocked * * Detach from the interface specified by the notification structure. * This may cause the interface to be freed if there are no more references. * * THIS FUNCTION REQUIRES THAT THE INTERFACE LOCK IS HELD. * * 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 notify * Notification structure * \ie * * RETURNS: * * ERRNO: * */ IP_GLOBAL void ipmip6_if_detach_iflocked ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, Ipmip6_if_notify_t *notify ); /******************************************************************************* * * ipmip6_if_alloc_tunnel - ipmip6_if_alloc_tunnel * * Create a tunneling interface of the specified type and name. * * * 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 ifsize * Size of the interface structure. * \i ifname * Name of the interface * \i identity * Entity specific identity value * \i tunnel_type * Tunnel type; may be GRE, GIF or MINENCAP. * \i reorder * Only supported if GRE is selected. Guarantees in-sequence delivery. * \i cleanup * Interface cleanup routine. Will be invoked when the interface is freed. * \ie * * RETURNS: An interface structure. * * ERRNO: * */ IP_GLOBAL Ipmip6_if_t *ipmip6_if_alloc_tunnel ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, Ip_size_t ifsize, char *ifname, Ip_u8 identity, Ip_u8 tunnel_type, Ip_bool reorder, Ipmip_if_cleanup_t cleanup ); /******************************************************************************* * * ipmip6_if_send_router_solicitations_iflocked - ipmip6_if_send_router_solicitations_iflocked * * Initiate router solicitation sending on this particular interface. * * THIS FUNCTION REQUIRES THAT THE INTERFACE LOCK IS HELD. * * 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 ife * The interface structure. * \ie * * RETURNS: * * ERRNO: * */ IP_GLOBAL void ipmip6_if_send_router_solicitations_iflocked ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, Ipmip6_if_t *ife ); /******************************************************************************* * * ipmip6_if_lockbyname - ipmip6_if_lockbyname * * Lookup an interface by name. If found will be returned with the interface * lock held and referenced. * * 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 name * The interface name * \ie * * RETURNS: The interface if found. * * ERRNO: * */ IP_GLOBAL Ipmip6_if_t *ipmip6_if_lockbyname ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, const char *name ); /******************************************************************************* * * ipmip6_if_lockbyindex - ipmip6_if_lockbyindex * * Lookup an interface by ifindex. If found will be returned with the interface * lock held and referenced. * * 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 ifindex * The interface index * \ie * * RETURNS: The interface if found. * * ERRNO: * */ IP_GLOBAL Ipmip6_if_t *ipmip6_if_lockbyindex ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, Ip_u32 ifindex ); /******************************************************************************* * * ipmip6_if_release_iflocked - ipmip6_if_release_iflocked * * Dereference and unlock a particular interface. * This may cause the interface to be freed if there are no more references. * * THIS FUNCTION REQUIRES THAT THE INTERFACE LOCK IS HELD. * * 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 ife * Interface structure * \ie * * RETURNS: * * ERRNO: * */ IP_GLOBAL void ipmip6_if_release_iflocked ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, Ipmip6_if_t *ife ); /******************************************************************************* * * ipmip6_if_notify_event_iflocked - ipmip6_if_notify_event_iflocked * * Invoke a particular notification structure * * THIS FUNCTION REQUIRES THAT THE INTERFACE LOCK IS HELD. * * 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 notify * Interface notification structure * \ie * * RETURNS: * * ERRNO: * */ IP_GLOBAL void ipmip6_if_notify_event_iflocked ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, Ipmip6_if_notify_t *notify ); /******************************************************************************* * * ipmip6_if_notify_iflocked - ipmip6_if_notify_iflocked * * Invoke all notification handlers registered to an interface. * * THIS FUNCTION REQUIRES THAT THE INTERFACE LOCK IS HELD. * * 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 notify * Interface notification structure * \ie * * RETURNS: * * ERRNO: * */ IP_GLOBAL void ipmip6_if_notify_iflocked ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, Ipmip6_if_t *ife ); #ifdef IPMIP_USE_INET /******************************************************************************* * * ipmip6_if_inet_add_iflocked - ipmip6_if_inet_add_iflocked * * Add an INET address to the specified interface. * * THIS FUNCTION REQUIRES THAT THE INTERFACE LOCK IS HELD. * * 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 ife * Interface structure * \i ifa_addr * INET address * \ie * * RETURNS: * * ERRNO: * */ IP_GLOBAL void ipmip6_if_inet_add_iflocked ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, Ipmip6_if_t *ife, Ip_u32 ifa_addr ); /******************************************************************************* * * ipmip6_if_inet_del_iflocked - ipmip6_if_inet_del_iflocked * * Delete an INET address from the specified interface. * * THIS FUNCTION REQUIRES THAT THE INTERFACE LOCK IS HELD. * * 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 ife * Interface structure * \i ifa_addr * INET address * \ie * * RETURNS: * * ERRNO: * */ IP_GLOBAL void ipmip6_if_inet_del_iflocked ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, Ipmip6_if_t *ife, Ip_u32 ifa_addr ); #endif /******************************************************************************* * * ipmip6_if_inet6_get_iflocked - ipmip6_if_inet6_get_iflocked * * Tries to retrieve a specified address from an interface. Will return * the address object if it is assigned on the interface. * * THIS FUNCTION REQUIRES THAT THE INTERFACE LOCK IS HELD. * * 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 ife * Interface structure * \i paddr * INET6 address to look for * \ie * * RETURNS: An IPMIP6 address structure if it exists. * * ERRNO: * */ IP_GLOBAL Ipmip6_if_inet6_t *ipmip6_if_inet6_get_iflocked ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, Ipmip6_if_t *ife, struct Ip_in6_addr *paddr ); /******************************************************************************* * * ipmip6_if_inet6_add_iflocked - ipmip6_if_inet6_add_iflocked * * Add an INET6 address to the specified interface. * * THIS FUNCTION REQUIRES THAT THE INTERFACE LOCK IS HELD. * * 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 ife * Interface structure * \i ifa_addr * INET6 address * \i ifa_prefixlen * INET6 prefix length * \i ifa_scope * INET6 scope * \i ifa_flags * INET6 address flags * \ie * * RETURNS: * * ERRNO: * */ IP_GLOBAL void ipmip6_if_inet6_add_iflocked ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, Ipmip6_if_t *ife, struct Ip_in6_addr *ifa_addr, Ip_u8 ifa_prefixlen, Ip_u8 ifa_scope, Ip_u8 ifa_flags ); /******************************************************************************* * * ipmip6_if_inet6_del_iflocked - ipmip6_if_inet6_del_iflocked * * Deletes an INET6 address from the specified interface. * * THIS FUNCTION REQUIRES THAT THE INTERFACE LOCK IS HELD. * * 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 ife * Interface structure * \i ifa_addr * INET6 address * \ie * * RETURNS: * * ERRNO: * */ IP_GLOBAL void ipmip6_if_inet6_del_iflocked ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, Ipmip6_if_t *ife, struct Ip_in6_addr *ifa_addr ); /******************************************************************************* * * ipmip6_if_link_down_iflocked - ipmip6_if_link_down_iflocked * * Informs MIP that an interface is administratively down. * * THIS FUNCTION REQUIRES THAT THE INTERFACE LOCK IS HELD. * * 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 ife * Interface structure * \ie * * RETURNS: * * ERRNO: * */ IP_GLOBAL void ipmip6_if_link_down_iflocked ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, Ipmip6_if_t *ife ); /******************************************************************************* * * ipmip6_if_link_up_iflocked - ipmip6_if_link_up_iflocked * * Informs MIP that an interface is administratively up. * * THIS FUNCTION REQUIRES THAT THE INTERFACE LOCK IS HELD. * * 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 ife * Interface structure * \i ifindex * Interface index * \ie * * RETURNS: * * ERRNO: * */ IP_GLOBAL void ipmip6_if_link_up_iflocked ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, Ipmip6_if_t *ife, Ip_u32 ifindex ); /******************************************************************************* * * ipmip6_if_reference_locked - ipmip6_if_reference_locked * * Add another reference to the interface structure. * * THIS FUNCTION REQUIRES THAT THE INTERFACE LOCK IS HELD. * * 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 ife * Interface structure * \ie * * RETURNS: * * ERRNO: * */ IP_GLOBAL void ipmip6_if_reference_locked ( struct Ipmip6_context *ctx, struct Ipmip_proc *proc, Ipmip6_if_t *ifp ); #ifdef __cplusplus } #endif #endif /* **************************************************************************** * END OF FILE **************************************************************************** */