488 lines
17 KiB
C
488 lines
17 KiB
C
|
|
/*
|
|
******************************************************************************
|
|
* HEADER FILE
|
|
*
|
|
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipdhcpc6_ia.h,v $ $Revision: 1.19.16.1 $
|
|
* $Source: /home/interpeak/CVSRoot/ipdhcpc6/src/ipdhcpc6_ia.h,v $
|
|
* $Author: ulf $ $Date: 2011-11-16 10:33:26 $
|
|
* $State: Exp $ $Locker: $
|
|
*
|
|
* INTERPEAK_COPYRIGHT_STRING
|
|
* Design and implementation by Joel Hortelius <joel.hortelius@interpeak.se>
|
|
******************************************************************************
|
|
*/
|
|
#ifndef IPDHCPC6_IA_H
|
|
#define IPDHCPC6_IA_H
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 1 DESCRIPTION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 2 CONFIGURATION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 3 INCLUDE FILES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 4 DEFINES
|
|
****************************************************************************
|
|
*/
|
|
#define ipdhcpc6_iap_deallocate(iap) ((*((struct Ipdhcpc6_ia*)(iap))->table->deallocate) (iap))
|
|
#define ipdhcpc6_iap_configure(iap) ((*((struct Ipdhcpc6_ia*)(iap))->table->configure) ((iap)))
|
|
|
|
#define IPDHCPC6_IA_BINDING_CHECK(ia)\
|
|
{\
|
|
if (ia->ia.binding.binding.num == 0)\
|
|
{\
|
|
IPCOM_LOG1(INFO,\
|
|
"%s: No addresses in this IA",\
|
|
ia->ia.ifp->context->context->name);\
|
|
break;\
|
|
}\
|
|
}
|
|
|
|
|
|
|
|
#define IPDHCPC6_IA_NAMESIZE (32)
|
|
|
|
|
|
#define IPDHCPC6_IA_STATE_SOLICIT 0
|
|
#define IPDHCPC6_IA_STATE_BOUND 1
|
|
|
|
#define IPDHCPC6_IA_ACTION_IS_RUNNING(s) IP_BIT_ISTRUE((s), 0x80000000)
|
|
#define IPDHCPC6_IA_ACTION_RUNNING(s) ((s) | 0x80000000)
|
|
#define IPDHCPC6_IA_ACTION_BASE(s) ((s) & ~0x80000000)
|
|
|
|
#define IPDHCPC6_IA_ACTION_IDLE 0
|
|
#define IPDHCPC6_IA_ACTION_SOLICIT 1
|
|
#define IPDHCPC6_IA_ACTION_REQUEST 2
|
|
#define IPDHCPC6_IA_ACTION_RENEW 3
|
|
#define IPDHCPC6_IA_ACTION_REBIND 4
|
|
#define IPDHCPC6_IA_ACTION_CONFIRM 5
|
|
#define IPDHCPC6_IA_ACTION_RELEASE 6
|
|
#define IPDHCPC6_IA_ACTION_DECLINE 7
|
|
#define IPDHCPC6_IA_ACTION_REBINDCONF 8 /* IA_PD only, because 'rebind' must be sent with 'confirm' parameters */
|
|
|
|
#define IPDHCPC6_IA_ACTION_SOLICITING IPDHCPC6_IA_ACTION_RUNNING(IPDHCPC6_IA_ACTION_SOLICIT)
|
|
#define IPDHCPC6_IA_ACTION_REQUESTING IPDHCPC6_IA_ACTION_RUNNING(IPDHCPC6_IA_ACTION_REQUEST)
|
|
#define IPDHCPC6_IA_ACTION_RENEWING IPDHCPC6_IA_ACTION_RUNNING(IPDHCPC6_IA_ACTION_RENEW)
|
|
#define IPDHCPC6_IA_ACTION_REBINDING IPDHCPC6_IA_ACTION_RUNNING(IPDHCPC6_IA_ACTION_REBIND)
|
|
#define IPDHCPC6_IA_ACTION_CONFIRMING IPDHCPC6_IA_ACTION_RUNNING(IPDHCPC6_IA_ACTION_CONFIRM)
|
|
#define IPDHCPC6_IA_ACTION_RELEASING IPDHCPC6_IA_ACTION_RUNNING(IPDHCPC6_IA_ACTION_RELEASE)
|
|
#define IPDHCPC6_IA_ACTION_DECLINEING IPDHCPC6_IA_ACTION_RUNNING(IPDHCPC6_IA_ACTION_DECLINE)
|
|
#define IPDHCPC6_IA_ACTION_REBINDCONFING IPDHCPC6_IA_ACTION_RUNNING(IPDHCPC6_IA_ACTION_REBINDCONF)
|
|
|
|
#define IPDHCPC6_IA_FLAGS_VERIFY 1 /* verify that the binding is valid */
|
|
/*
|
|
****************************************************************************
|
|
* 5 TYPES
|
|
****************************************************************************
|
|
*/
|
|
struct Ipdhcpc6_if;
|
|
struct Ipdhcpc6_if_server;
|
|
struct Ipdhcpc6_ia_table;
|
|
struct Ipdhcpc6_ia;
|
|
struct Ipdhcpc6_ia_if;
|
|
struct Ipdhcpc6_tagcomm_buffer;
|
|
struct Ipdhcpc6_tagcomm_tag;
|
|
|
|
typedef Ip_bool (*Ipdhcpc6_ia_configure_t)
|
|
(
|
|
struct Ipdhcpc6_ia *iap
|
|
);
|
|
|
|
typedef void (*Ipdhcpc6_ia_deallocate_t)
|
|
(
|
|
struct Ipdhcpc6_ia *iap
|
|
);
|
|
|
|
typedef struct Ipdhcpc6_ia* (*Ipdhcpc6_ia_allocate_t)
|
|
(
|
|
);
|
|
|
|
|
|
typedef void (*Ipdhcpc6_ia_attributes_t)
|
|
(
|
|
Ip_u32 cmd,
|
|
struct Ipdhcpc6_ia *ia,
|
|
struct Ipdhcpc6_tagcomm_tag *tag,
|
|
struct Ipdhcpc6_tagcomm_buffer *response
|
|
);
|
|
|
|
typedef void (*Ipdhcpc6_ia_ifevent_t)
|
|
(
|
|
struct Ipdhcpc6_ia *ia,
|
|
Ipcom_hash *table,
|
|
Ip_u32 ostate,
|
|
Ip_u32 nstate
|
|
);
|
|
|
|
typedef void (*Ipdhcpc6_ia_reconfigure_t)
|
|
(
|
|
struct Ipdhcpc6_ia *iap
|
|
);
|
|
|
|
|
|
typedef struct Ipdhcpc6_ia_table
|
|
{
|
|
/**/
|
|
Ip_u32 type;
|
|
const char *name;
|
|
|
|
Ipdhcpc6_ia_configure_t configure;
|
|
Ipdhcpc6_ia_deallocate_t deallocate;
|
|
Ipdhcpc6_ia_allocate_t allocate;
|
|
Ipdhcpc6_ia_attributes_t attributes;
|
|
Ipdhcpc6_ia_ifevent_t ifevent;
|
|
Ipdhcpc6_ia_reconfigure_t reconfigure;
|
|
} Ipdhcpc6_ia_table_t;
|
|
|
|
|
|
typedef struct Ipdhcpc6_fqdn
|
|
{
|
|
char name[255]; /*Full Qualified Domain Name*/
|
|
Ipdhcpc6_attr_array_t addrs; /*Address for the client*/
|
|
Ip_u32 success; /*Status of update*/
|
|
} Ipdhcpc6_fqdn_t;
|
|
/* IA structure */
|
|
typedef struct Ipdhcpc6_ia
|
|
{
|
|
Ipcom_list next; /* Next IF */
|
|
struct Ipdhcpc6_if *ifp; /* Interface owner */
|
|
Ip_u32 flags; /* State flags */
|
|
Ip_u32 iaid; /* IAID */
|
|
char *desc; /* Description of this IA */
|
|
char *tag; /* Tag of this IA */
|
|
struct Ipdhcpc6_if_server *server; /* Server */
|
|
Ipcom_tmo2 valid; /* Valid timeout */
|
|
Ipdhcpc6_ia_table_t *table; /* Table */
|
|
Ipdhcpc6_attr_ia_state_t state;
|
|
Ipdhcpc6_attr_array_t history;
|
|
Ipdhcpc6_attr_ia_binding_t binding; /* Current bindings */
|
|
Ipdhcpc6_fqdn_t fqdn; /* Current used fqdn */
|
|
} Ipdhcpc6_ia_t;
|
|
|
|
typedef struct Ipdhcpc6_ia_server
|
|
{
|
|
Ipcom_list next;
|
|
Ipdhcpc6_if_server_t *server;
|
|
}
|
|
Ipdhcpc6_ia_server_t;
|
|
|
|
/* IA offer strcuture */
|
|
typedef struct Ipdhcpc6_ia_offer
|
|
{
|
|
Ipdhcpc6_ia_server_t server;
|
|
|
|
Ip_u8 preference;
|
|
Ipdhcpc6_attr_ia_binding_t binding;
|
|
}
|
|
Ipdhcpc6_ia_offer_t;
|
|
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 6 FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_set_context
|
|
*===========================================================================
|
|
* Description: Set the context owning a particular IA
|
|
* Parameters: iap - The IA
|
|
* ifp - The context
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_GLOBAL Ip_bool ipdhcpc6_ia_set_context(Ipdhcpc6_ia_t *iap,
|
|
struct Ipdhcpc6_if *ifp);
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_free
|
|
*===========================================================================
|
|
* Description: Free an interface structure.
|
|
* Parameters: iapp - [IN/OUT] Structure to free; pointer will be set
|
|
* to NULL.
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_GLOBAL void ipdhcpc6_ia_free(Ipdhcpc6_ia_t **iapp);
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_hash_alloc
|
|
*===========================================================================
|
|
* Description: Allocate the IA HASH for the interface.
|
|
* Parameters:
|
|
* Returns: The IA HASH tables
|
|
*
|
|
*/
|
|
IP_GLOBAL Ipcom_hash **ipdhcpc6_ia_hash_alloc(void);
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_hash_free
|
|
*===========================================================================
|
|
* Description: Free the IA hash table
|
|
* Parameters: iahp - [IN/OUT] The Hash table array. Will be set to IP_NULL.
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_GLOBAL void ipdhcpc6_ia_hash_free(Ipcom_hash ***iahp);
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_list_alloc
|
|
*===========================================================================
|
|
* Description: Allocate the IA LIST for the interface.
|
|
* Parameters:
|
|
* Returns: The IA LIST array
|
|
*
|
|
*/
|
|
IP_GLOBAL Ipcom_list *ipdhcpc6_ia_list_alloc(void);
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_list_free
|
|
*===========================================================================
|
|
* Description: Free the IA list array
|
|
* Parameters: ialp - [IN/OUT] The IA list array. Will be set to IP_NULL
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_GLOBAL void ipdhcpc6_ia_list_free(Ipcom_list **ialp);
|
|
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_sysvar_hints
|
|
*===========================================================================
|
|
* Description: Parse hints for addresses/prefixes in an IA
|
|
* Parameters: iap - The IA we're parsing for.
|
|
* tag - The tag we're looking in
|
|
* hintsp - Where to store the hints
|
|
* Returns: IP_TRUE if successful.
|
|
*
|
|
*/
|
|
IP_GLOBAL Ip_bool ipdhcpc6_ia_sysvar_hints(Ipdhcpc6_ia_t *iap,
|
|
Ipdhcpc6_attr_ia_binding_t *hintsp);
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_configure
|
|
*===========================================================================
|
|
* Description: Read the IA's configured for this particular IFP
|
|
* Parameters: IFP - The IFP.
|
|
* Returns: IP_TRUE if successful
|
|
*
|
|
*/
|
|
IP_GLOBAL Ip_bool ipdhcpc6_ia_configure(Ipdhcpc6_if_t *ifp);
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_lookup_by_iaid
|
|
*===========================================================================
|
|
* Description: Find an IA based on type and IAID
|
|
* Parameters: context - The DHCPC6 context
|
|
* iatype - Type of IA
|
|
* iaid - IAID
|
|
* Returns: The IA if found.
|
|
*
|
|
*/
|
|
IP_GLOBAL Ipdhcpc6_ia_t *ipdhcpc6_ia_lookup_by_iaid(Ipdhcpc6_context_t *context,
|
|
Ip_u32 iatype,
|
|
Ip_u32 iaid);
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_lookup_by_ianame
|
|
*===========================================================================
|
|
* Description: Find an IA based on type and IANAME in a provided IF
|
|
* Parameters: ifp - The interface
|
|
* iatype - Type of IA
|
|
* ianame - IA Name
|
|
* Returns: The IA if found.
|
|
*
|
|
*/
|
|
IP_GLOBAL Ipdhcpc6_ia_t *ipdhcpc6_ia_lookup_by_ianame(Ipdhcpc6_if_t *ifp,
|
|
Ip_u32 iatype,
|
|
const char *ianame);
|
|
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_lookup_by_iaobj
|
|
*===========================================================================
|
|
* Description: Find an IA based on type and an identity block
|
|
* Parameters: ifp - The interface
|
|
* iaobj - The iaobj.
|
|
* Returns: The IA if found.
|
|
*
|
|
*/
|
|
IP_GLOBAL Ipdhcpc6_ia_t *ipdhcpc6_ia_lookup_by_iaobj(Ipdhcpc6_if_t *ifp,
|
|
Ipdhcpc6_attr_ia_t *iaobj);
|
|
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_attr_header
|
|
*===========================================================================
|
|
* Description: Add the identity blocks associated with an IA
|
|
* Parameters: ia - The IA
|
|
* buf - The buffer to add them in.
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_GLOBAL void ipdhcpc6_ia_attr_header(Ipdhcpc6_ia_t *ia,
|
|
struct Ipdhcpc6_tagcomm_buffer *buf);
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_attr_bindings
|
|
*===========================================================================
|
|
* Description: Add any hints to the buffer
|
|
* Parameters: hints - The hints
|
|
* buf - The buffer to add them in.
|
|
* hints - Hints
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_GLOBAL void ipdhcpc6_ia_attr_bindings(Ipdhcpc6_attr_ia_binding_t *iab,
|
|
Ipdhcpc6_tagcomm_buffer_t *buf,
|
|
Ip_bool hints);
|
|
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_server_exists
|
|
*===========================================================================
|
|
* Description: Does the server already existin the list
|
|
* Parameters: head - The list
|
|
* server - The server we're looking for.
|
|
* Returns: IP_TRUE if yes.
|
|
*
|
|
*/
|
|
IP_GLOBAL Ip_bool ipdhcpc6_ia_server_exists(Ipcom_list *head,
|
|
Ipdhcpc6_if_server_t *server);
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_parse_iaaddr
|
|
*===========================================================================
|
|
* Description: Parse and find all bindings in the IA options block.
|
|
* Parameters: iab - The IA bindings attribute
|
|
* options - The options block
|
|
* size - size of the options block
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_GLOBAL void ipdhcpc6_ia_parse_iaaddr(Ipdhcpc6_attr_ia_binding_t *iab,
|
|
Ip_u8 *options,
|
|
Ip_size_t size);
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_set_binding_valid_timeout
|
|
*===========================================================================
|
|
* Description: Set a timeout based on the valid values of the bindings.
|
|
* Parameters: iap - The IAP
|
|
* func - Timeout function
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_GLOBAL void ipdhcpc6_ia_set_binding_valid_timeout(Ipdhcpc6_ia_t *iap,
|
|
Ipcom_tmo2_func func);
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_binding_lookup
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_GLOBAL Ipdhcpc6_attr_binding_t *ipdhcpc6_ia_binding_lookup(Ipdhcpc6_ia_t *ia,
|
|
Ipdhcpc6_attr_binding_t *binding);
|
|
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_history_update
|
|
*===========================================================================
|
|
* Description: Update the current history.
|
|
* Parameters: ia - The IA to update the history for.
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_GLOBAL void ipdhcpc6_ia_history_update(Ipdhcpc6_ia_t *ia);
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_offer_free
|
|
*===========================================================================
|
|
* Description: IA free
|
|
* Parameters:offerp - offer pointer
|
|
* Returns:None
|
|
*
|
|
*/
|
|
IP_GLOBAL void ipdhcpc6_ia_offer_free(Ipdhcpc6_ia_offer_t **offerp);
|
|
/*
|
|
*===========================================================================
|
|
* ipdhcpc6_ia_set_running
|
|
*===========================================================================
|
|
* Description: Set IA state as running
|
|
* Parameters:ia - IA pointer
|
|
* Returns: None
|
|
*
|
|
*/
|
|
IP_GLOBAL void ipdhcpc6_ia_set_running(Ipdhcpc6_ia_t *ia);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* END OF FILE
|
|
****************************************************************************
|
|
*/
|