00001 /* @file dhcp6_lease.h 00002 * 00003 * Representation of DHCPv6 lease options for libdhcp 00004 * 00005 */ 00006 /* 00007 * Copyright (C) 2006 Red Hat, Inc. All rights reserved. 00008 * 00009 * This copyrighted material is made available to anyone wishing to use, 00010 * modify, copy, or redistribute it subject to the terms and conditions of 00011 * the GNU General Public License v.2. This program is distributed in the 00012 * hope that it will be useful, but WITHOUT ANY WARRANTY expressed or 00013 * implied, including the implied warranties of MERCHANTABILITY or FITNESS 00014 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 00015 * details. You should have received a copy of the GNU General Public 00016 * License along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00018 * USA. Any Red Hat trademarks that are incorporated in the source code or 00019 * documentation are not subject to the GNU General Public License and may 00020 * only be used or replicated with the express permission of Red Hat, Inc. 00021 * 00022 * Red Hat Author(s): Jason Vas Dias 00023 * David Cantrell 00024 */ 00025 00026 #ifndef _DHCP6_LEASE_H 00027 #define _DHCP6_LEASE_H 00028 00029 #include <sys/types.h> 00030 #include <netinet/in.h> 00031 #include <stdint.h> 00032 00033 #include <sys/queue.h> /* glibc list macros */ 00034 00035 /** @addtogroup DHCPv6_lease 00036 * @{ 00037 */ 00038 00039 /** 00040 * DHCPv6 address types. 00041 */ 00042 enum dhcpv6_address_type_e 00043 { 00044 DHCPv6_ADDRESS, /**< permanent lease address */ 00045 DHCPv6_TEMPORARY_ADDRESS, /**< temporary address given with delegated prefix */ 00046 DHCPv6_DELEGATED_PREFIX /**< delegated prefix to configure radvd(8) with */ 00047 } DHCPv6_address_type; 00048 00049 /** 00050 * DHCPv6 address type. 00051 * There may be multiple DHCPv6 addresses per lease, 00052 * each of which may have different prefix length, 00053 * and lifetimes. 00054 */ 00055 typedef 00056 struct dhcp6_lease_address_s 00057 { 00058 struct in6_addr address; /**< the IPv6 lease address bytes */ 00059 uint8_t prefix_length; /**< lease address prefix length */ 00060 uint8_t type; /**< lease address type */ 00061 uint16_t status; /**< lease address status */ 00062 time_t time_acquired; /**< time lease address acquired */ 00063 time_t valid_lifetime; /**< valid lifetime of lease address */ 00064 time_t prefer_lifetime;/**< prefer lifetime of lease address */ 00065 STAILQ_ENTRY ( dhcp6_lease_address_s ) link; /**< next lease address */ 00066 } DHCPv6_lease_address; 00067 00068 00069 /** 00070 * DHCPv6 lease address list type. 00071 */ 00072 typedef 00073 STAILQ_HEAD( dhcp6_lease_address_list_s, dhcp6_lease_address_s ) 00074 DHCPv6_lease_address_list; 00075 00076 /** 00077 * DHCPv6 DNS server IPv6 address list element type. 00078 */ 00079 typedef 00080 struct ipv6_address_s 00081 { 00082 struct in6_addr address; 00083 STAILQ_ENTRY( ipv6_address_s ) link; 00084 } IPv6_address; 00085 00086 /** 00087 * DHCPv6 DNS server IPv6 address list type. 00088 */ 00089 typedef 00090 STAILQ_HEAD( ipv6_address_list_s, ipv6_address_s ) 00091 IPv6_address_list; 00092 00093 00094 /** 00095 * DHCPv6 lease type 00096 */ 00097 typedef 00098 struct dhcp6_lease_s 00099 { 00100 DHCPv6_lease_address_list addresses; /**< list of lease addresses */ 00101 time_t renew_time; /**< time lease should be renewed */ 00102 time_t rebind_time; /**< time lease must be rebound */ 00103 char *search_list; /**< dns domain name search list, if sent */ 00104 IPv6_address_list dns; /**< domain name servers */ 00105 char *if_name; /**< interface name */ 00106 uint32_t if_index; /**< interface index */ 00107 uint32_t iaid; /**< DHCPv6 lease identifier */ 00108 uint8_t *client_duid; /**< DHCPv6 client identifier */ 00109 uint8_t *server_duid; /**< DHCPv6 server identifier */ 00110 uint16_t client_duid_len; /**< DHCPv6 client identifier length*/ 00111 uint16_t server_duid_len; /**< DHCPv6 server identifier length*/ 00112 struct in6_addr server_address; /**< DHCPv6 server address */ 00113 } DHCPv6_lease; 00114 00115 struct dhcp6_optinfo; /**< defined in dhcpv6's dhcp6.h */ 00116 00117 extern DHCPv6_lease *dhcpv6_lease ( struct dhcp6_optinfo * );/**< 00118 * call this with the dhcp6_optinfo * returned to the 00119 * libdhcp callback on the DHC6_BOUND state to construct 00120 * a DHCPv6_lease . 00121 */ 00122 00123 extern void dhcpv6_lease_free( DHCPv6_lease * ); /**< 00124 * frees all resources associated with the DHCPv6_lease 00125 */ 00126 00127 extern int dhcpv6_pack_lease( DHCPv6_lease* lease, uint8_t* buf, uint32_t len); /**< 00128 * packs the DHCPv6_lease in a buffer of length len, suitable for IPC 00129 * / mmap'ed file storage. 00130 */ 00131 00132 extern DHCPv6_lease *dhcpv6_unpack_lease( uint8_t* buf ); /**< 00133 * unpacks the DHCPv6_lease from a buffer created by dhcpv6_pack_lease() 00134 */ 00135 00136 /**@}*/ 00137 00138 #endif