1/* $Id: lease.h,v 1.1.1.1 2006/12/04 00:45:29 Exp $ */ 2/* 3 * Copyright (C) International Business Machines Corp., 2003 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. Neither the name of the project nor the names of its contributors 15 * may be used to endorse or promote products derived from this software 16 * without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30 31/* Author: Shirley Ma, xma@us.ibm.com */ 32 33#ifndef __LEASE_H_DEFINED 34#define __LEASE_H_DEFINED 35 36#define LEASE_FILENAME_SIZE 37#define ADDR_UPDATE 0 38#define ADDR_REMOVE 1 39#define ADDR_VALIDATE 2 40#define ADDR_ABANDON 3 41 42#define PATH_SERVER6_LEASE "/tmp/server6.leases" //Modified. "/var/lib/dhcpv6/server6.leases" 43#define PATH_CLIENT6_LEASE "/tmp/client6.leases" //Modified. "/var/lib/dhcpv6/client6.leases" 44 45#define HASH_TABLE_COUNT 4 46 47extern struct hash_table **hash_anchors; 48#define server6_hash_table hash_anchors[HT_IAIDADDR] 49#define lease_hash_table hash_anchors[HT_IPV6LEASE] 50#define host_addr_hash_table hash_anchors[HT_IPV6ADDR] 51#define PREFIX_LEN_NOTINRA 64 52#define MAX_FILE_SIZE 512*1024 53 54 55typedef enum { IFADDRCONF_ADD, IFADDRCONF_REMOVE } ifaddrconf_cmd_t; 56 57enum hash_type{HT_IPV6ADDR = 0, HT_IPV6LEASE, HT_IAIDADDR}; 58 59struct dhcp6_iaidaddr client6_iaidaddr; 60FILE *server6_lease_file; 61FILE *client6_lease_file; 62FILE *lease_file; 63FILE *sync_file; 64struct hash_table **hash_anchors; 65 66struct client6_if { 67 iatype_t type; 68 struct dhcp6_iaid_info iaidinfo; 69 struct duid clientid; 70 struct duid serverid; 71}; 72 73struct dhcp6_iaidaddr { 74 TAILQ_ENTRY(dhcp6_iaidaddr) link; 75 struct client6_if client6_info; 76 time_t start_date; 77 state_t state; 78 struct dhcp6_if *ifp; 79 struct dhcp6_timer *timer; 80 /* list of client leases */ 81 TAILQ_HEAD(,dhcp6_lease) lease_list; 82}; 83 84extern u_int32_t do_hash __P((const void *, u_int8_t )); 85int get_linklocal __P((const char *, struct in6_addr *)); 86extern void dhcp6_init_iaidaddr __P((void)); 87extern int dhcp6_remove_iaidaddr __P((struct dhcp6_iaidaddr *)); 88extern int dhcp6_add_iaidaddr __P((struct dhcp6_optinfo *)); 89extern int dhcp6_update_iaidaddr __P((struct dhcp6_optinfo *, int)); 90extern struct dhcp6_timer *dhcp6_iaidaddr_timo __P((void *)); 91extern struct dhcp6_timer *dhcp6_lease_timo __P((void *)); 92extern u_int32_t get_min_preferlifetime __P((struct dhcp6_iaidaddr *)); 93extern u_int32_t get_max_validlifetime __P((struct dhcp6_iaidaddr *)); 94extern struct dhcp6_iaidaddr *dhcp6_find_iaidaddr __P((struct dhcp6_optinfo *)); 95extern struct dhcp6_lease *dhcp6_find_lease __P((struct dhcp6_iaidaddr *, 96 struct dhcp6_addr *)); 97extern int dhcp6_remove_lease __P((struct dhcp6_lease *)); 98extern int dhcp6_validate_bindings __P((struct dhcp6_optinfo *, struct dhcp6_iaidaddr *)); 99extern int get_iaid __P((const char *, const struct iaid_table *, int)); 100extern int create_iaid __P((struct iaid_table *, int)); 101extern FILE *init_leases __P((const char *)); 102extern void lease_parse __P((FILE *)); 103extern int do_iaidaddr_hash __P((struct dhcp6_lease *, struct client6_if *)); 104extern int write_lease __P((const struct dhcp6_lease *, FILE *)); 105extern FILE *sync_leases __P((FILE *, const char *, char *)); 106extern struct dhcp6_timer *syncfile_timo __P((void *)); 107extern unsigned int addr_hash __P((const void *)); 108extern unsigned int iaid_hash __P((const void *)); 109extern void * iaid_findkey __P((const void *)); 110extern int iaid_key_compare __P((const void *, const void *)); 111extern void * lease_findkey __P((const void *)); 112extern int lease_key_compare __P((const void *, const void *)); 113extern void * v6addr_findkey __P((const void *)); 114extern int v6addr_key_compare __P((const void *, const void *)); 115extern int client6_ifaddrconf __P((ifaddrconf_cmd_t , struct dhcp6_addr *)); 116extern int dhcp6_get_prefixlen __P((struct in6_addr *, struct dhcp6_if *)); 117extern int prefixcmp __P((struct in6_addr *, struct in6_addr *, int)); 118extern int addr_on_addrlist __P((struct dhcp6_list *, struct dhcp6_addr *)); 119struct link_decl; 120extern int dhcp6_create_prefixlist __P((struct dhcp6_optinfo *, 121 const struct dhcp6_optinfo *, 122 const struct dhcp6_iaidaddr *, 123 const struct link_decl *)); 124extern int dhcp6_create_addrlist __P(( struct dhcp6_optinfo *, 125 struct dhcp6_optinfo *, 126 const struct dhcp6_iaidaddr *, 127 const struct link_decl *)); 128extern int dad_parse(const char *file); 129#endif 130