/* ipdhcps6.h - Public API of Wind River DHCPv6 Server */ /* ****************************************************************************** * INTERPEAK API HEADER FILE * * Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipdhcps6.h,v $ $Revision: 1.25.12.4 $ * $Source: /home/interpeak/CVSRoot/ipdhcps6/include/ipdhcps6.h,v $ * $Author: zluo0 $ $Date: 2013-01-07 02:14:02 $ * $State: Exp $ $Locker: $ * * INTERPEAK_COPYRIGHT_STRING * Design and implementation by Kenneth Jonsson ****************************************************************************** */ #ifndef IPDHCPS6_H #define IPDHCPS6_H /* **************************************************************************** * 1 DESCRIPTION **************************************************************************** */ /* DESCRIPTION This library contains the APIs used for configuration of Wind River DHCPv6 Server. */ /* **************************************************************************** * 2 CONFIGURATION **************************************************************************** */ #include "ipdhcps6_config.h" /* **************************************************************************** * 3 INCLUDE FILES **************************************************************************** */ #include #include #include #include #include "ipdhcps6_option.h" #ifdef __cplusplus extern "C" { #endif /* **************************************************************************** * 4 DEFINES **************************************************************************** */ /* IPNET release XYyZz, X = major version Yy = minor version (two different versions might be incompatible) Zz = patch version (two different versions are always compatible) */ #define IPDHCPS6_RELEASE 60701 #define IPDHCPS6_KEY_LEN 16 #define IPDHCPS6_PREFIX_PER_USER 1 #define IPDHCPS6_IPD_NAME "ipdhcps6" /* **************************************************************************** * 5 TYPES **************************************************************************** */ typedef struct Ipdhcps6_poolinfo_struct { /* The first address in the pool (inclusive) */ struct Ip_in6_addr first; /* The last address in the pool (inclusive) */ struct Ip_in6_addr last; /* The preferred lifetime in seconds of addresses drawn from this pool */ Ip_u32 preferred_lifetime; /* The valid lifetime in seconds of addresses drawn from this pool */ Ip_u32 valid_lifetime; /* Prefix information */ Ip_u8 prefix_len; } Ipdhcps6_poolinfo; /* Specification of a prefix option that can be added in a DHCPv6 message */ typedef struct Ipdhcps6_prefix_struct { /* The ID given to this prefix */ char key[IPDHCPS6_KEY_LEN]; /* The time this prefix should be preferred after assigned to a requesting router, 0xffffffff = infinite */ Ip_u32 preferred; /* The time this prefix should be valid after assigned to a requesting router, 0xffffffff = infinite */ Ip_u32 valid; /* The IPv6 prefix */ struct Ip_in6_addr prefix; /* The number of bits that is significant in the prefix */ int prefix_len; } Ipdhcps6_prefix; typedef struct Ipdhcps6_subnet_struct { /* NOTE! The prefix and ifindex members must have the specified order or lookups will fail */ struct Ip_in6_addr prefix; /* Interface index for link local prefix */ Ip_u32 ifindex; /* Prefix length in bits */ int prefix_len; } Ipdhcps6_subnet; typedef struct Ipdhcps6_user_struct { /* The name of this user */ char name[IPCOM_AUTH_USERNAME_MAX]; /* Array of prefix ID that should be added to this user */ char prefix_ids[IPDHCPS6_PREFIX_PER_USER][IPDHCPS6_KEY_LEN]; } Ipdhcps6_user; /* *=========================================================================== * ipdhcps6_all_dhcp_relay_agents_and_servers *=========================================================================== * Multicast address used by a client to communicate with * neighboring (i.e., on-link) relay agents and servers. * All servers and relay agents are members of this multicast group. * Should always be FF02::1:2. */ IP_EXTERN struct Ip_in6_addr ipdhcps6_all_dhcp_relay_agents_and_servers; /* *=========================================================================== * ipdhcps6_all_dhcp_servers *=========================================================================== * A site-scoped multicast address used * by a relay agent to communicate with servers, either * because the relay agent wants to send messages to * all servers or because it does not know the unicast * addresses of the servers. Note that in order for * a relay agent to use this address, it must have an * address of sufficient scope to be reachable by the * servers. All servers within the site are members of * this multicast group. * Should always be FF05::1:3 */ IP_EXTERN struct Ip_in6_addr ipdhcps6_all_dhcp_servers; /* *=========================================================================== * ipdhcps6_client_port *=========================================================================== * UDP port that the clients listen to. * Should always be 546. */ IP_EXTERN Ip_u16 ipdhcps6_client_port; /* *=========================================================================== * ipdhcps6_server_port *=========================================================================== * UDP port that the servers and relay agents listen to. * Should always be 547. */ IP_EXTERN Ip_u16 ipdhcps6_server_port; /* *=========================================================================== * ipdhcps6_log_id *=========================================================================== * The string used as identification when open the syslog. */ IP_EXTERN char *ipdhcps6_log_id; /* **************************************************************************** * 6 FUNCTIONS **************************************************************************** */ /******************************************************************************* * * ipdhcps6_subnet_from_ifname - Creates the subnet information that represents * the specified link. * * This routine adds a new subnet to the DHCP server configuration based on the * values provided by the interface. * * Parameter: * \is * \i * A pointer to an 'Ipdhcps6_subnet' structure that will hold the subnet * \i * The interface index used to create the subnet. * \ie * * RETURNS: * * ERRNO: */ IP_PUBLIC void ipdhcps6_subnet_from_ifindex ( Ipdhcps6_subnet *subnet, Ip_u32 ifindex ); /******************************************************************************* * * ipdhcps6_subnet_add - Adds a new subnet to the DHCP server configuration. * * This routine adds a new subnet to the DHCP server configuration. * * Parameter: * \is * \i * A pointer to an 'Ipdhcps6_subnet' structure. * \ie * * RETURNS: Either 'IPCOM_SUCCESS', if the call was successful, or the following * error: * \is * \i 'IPCOM_ERR_NO_MEMORY' * If the specified could not be created due to out of memory. * \i 'IPCOM_ERR_DUPLICATE' * If the specified already exist * \ie * * ERRNO: */ IP_PUBLIC Ip_err ipdhcps6_subnet_add ( Ipdhcps6_subnet *subnet ); /******************************************************************************* * * ipdhcps6_subnet_delete - delete subnet from the DHCP server configuration * * Deletes from the DHCP server configuration all options and address * pools associated with this is also deleted. * * Parameter: * \is * \i * A pointer to an 'Ipdhcps6_subnet' structure. * \ie * * RETURNS: Either 'IPCOM_SUCCESS', if the call was successful, or the following * error: * \is * \i 'IPCOM_ERR_NOT_FOUND' * If the specified has not been added. * \ie * * ERRNO: */ IP_PUBLIC Ip_err ipdhcps6_subnet_delete ( Ipdhcps6_subnet *subnet ); /******************************************************************************* * * ipdhcps6_subnet_list - list all added subnets * * This routine lists all added . * * Parameters: * \is * \i * An array of 'ipdhcps6_subnet' structures for holding the subnets, or * 'IP_NULL','' if the required size of the buffer should be written to * . * \i * A pointer to an integer value for the number of elements that can be stored in * the subnets array; when the function returns, points to the * number of elements copied to the array. * \ie * * RETURNS: Either 'IPCOM_SUCCESS', if the call was successful, or the following * error: * \is * \i 'IPCOM_ERR_NO_MEMORY' * If the array is too small. * \ie * * ERRNO: */ IP_PUBLIC Ip_err ipdhcps6_subnet_list ( Ipdhcps6_subnet subnets[], int *num_subnets ); /******************************************************************************* * * ipdhcps6_subnet_to_string - return a string representation of the specified * subnet * * This routine returns a string representation of the specified . * * Parameters: * \is * \i * A pointer to an 'Ipdhcps6_subnet' structure. * \i * The buffer for storing the string representation of the subnet. * \i * The length of the buffer. * \ie * * RETURNS: Either 'IPCOM_SUCCESS', if the call was successful, or the following * error: * \is * \i 'IPCOM_ERR_NO_MEMORY' * If the buffer is too small. * \ie * * ERRNO: */ IP_PUBLIC Ip_err ipdhcps6_subnet_to_string ( const Ipdhcps6_subnet *subnet, char *str, int str_len ); /******************************************************************************* * * ipdhcps6_pool_add - add Adds a pool of addresses to the specified subnet. * * This routine adds a pool of addresses to the specified subnet. * * Parameters: * \is * \i * A pointer to an 'ipdhcps6_subnet' structure to which we will add the pool. * \i * A pointer to the 'Ipdhcps6_poolinfo' structure containing the pool to be * added. * \ie * * RETURNS: Either 'IPCOM_SUCCESS', if the call was successful, or one of the * following errors: * \is * \i 'IPCOM_ERR_NO_MEMORY' * If no enough memory could be allocated to add the pool. * \i 'IPCOM_ERR_NOT_FOUND' * If the specified is not added to the server. * \i 'IPCOM_ERR_DUPLICATE' * If one or more of the addresses in the pool is already included in a pool * in the specified * \i 'IPCOM_ERR_INVALID_ARG' * the addresses of the pool is not on the specified . * \ie * * ERRNO: */ IP_PUBLIC Ip_err ipdhcps6_pool_add ( Ipdhcps6_subnet *subnet, Ipdhcps6_poolinfo *pool ); /******************************************************************************* * * ipdhcps6_pool_delete - delete a DHCPv6 pool from a specified subnet * * This routine deletes a DHCPv6 pool from the specified subnet. * * Parameters: * \is * \i * A pointer to the 'ipdhcps6_subnet' structure from which the pool is * to be deleted * \i * A pointer to the 'Ipdhcps6_poolinfo' structure containing the pool to delete. * \ie * * RETURNS: Either 'IPCOM_SUCCESS', or the following error: * \is * \i 'IPCOM_ERR_NOT_FOUND' * Either the subnet or the pool specified has not been added to the server. * \ie * * ERRNO: */ IP_PUBLIC Ip_err ipdhcps6_pool_delete ( Ipdhcps6_subnet *subnet, Ipdhcps6_poolinfo *pool ); /******************************************************************************* * * ipdhcps6_pool_get - Gets the address pool specification on a specific subnet. * subnet * * This routine gets the address pool specification on a specific subnet. The * data returned is dynamically allocated and must be freed by the invoker. * * Parameters: * \is * \i * A pointer to an 'ipdhcps6_subnet' structure from which we will get the pool. * \i * A pointer to the 'Ipdhcps6_poolinfo' pointer which will hold the pool * information on success. The array will be dynamically allocated * \i * A pointer to the size variable which will indicate the size of the * array on success * \ie * * RETURNS: Either 'IPCOM_SUCCESS', or the following error: * \is * \i 'IPCOM_ERR_NOT_FOUND' * The specified does not exist. * \ie * * ERRNO: */ IP_PUBLIC Ip_err ipdhcps6_pool_get ( Ipdhcps6_subnet *subnet, Ipdhcps6_poolinfo **pools, Ip_u32 *pools_size ); /******************************************************************************* * * ipdhcps6_option_add - add a DHCPv6 option * * This routine adds a DHCPv6 option, either globally or to a specified . * * Parameters: * \is * \i * Either a pointer to an 'ipdhcps6_subnet' structure for holding the option or * 'IP_NULL', if the option is to apply to all subnets. * \i