/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <string.h> /* memcpy */
#include <fcntl.h>
#include <limits.h>
#include "dhcp_hostconf.h"
/*
* ifname_to_hostconf(): converts an interface name into a hostconf file for
* that interface
*
* input: const char *: the interface name
* boolean_t: B_TRUE if using DHCPv6
* output: char *: the hostconf filename
* note: uses an internal static buffer (not threadsafe)
*/
char *
{
return (filename);
}
/* Same but using the old prefix. */
static char *
{
return (filename);
}
/*
* remove_hostconf(): removes an interface.dhc file
*
* input: const char *: the interface name
* boolean_t: B_TRUE if using DHCPv6
* output: int: 0 if the file is removed, -1 if it can't be removed
* (errno is set)
*/
int
{
}
/*
* read_hostconf(): reads the contents of an <if>.dhc file into a PKT_LIST
*
* input: const char *: the interface name
* PKT_LIST **: a pointer to a PKT_LIST * to store the info in
* uint_t: the length of the list of PKT_LISTs
* boolean_t: B_TRUE if using DHCPv6
* output: int: >0 if the file is read and loaded into the PKT_LIST *
* successfully, -1 otherwise (errno is set)
* note: the PKT and PKT_LISTs are dynamically allocated here
*/
int
{
int fd;
int pcnt = 0;
int retval;
if (fd == -1) {
if (fd == -1)
return (-1);
}
goto failure;
goto failure;
goto failure;
/*
* read the packet back in from disk, and for v4, run it through
* dhcp_options_scan(). note that we use calloc() because
* dhcp_options_scan() relies on the structure being zeroed.
*/
goto failure;
/*
* Reached end of file on a boundary, but after
* we've read at least one packet, so we consider
* this successful, allowing us to use files from
* older versions of the agent happily.
*/
break;
goto failure;
goto failure;
goto failure;
goto failure;
/*
* First packet used to validate that we're interested,
* the rest are presumed to be historical reference and
* are not relativized
*/
if (pcnt == 0)
continue;
if (isv6) {
/*
* Loop over contents of the packet to find the address
* options.
*/
/*
* Extract option header and make sure option
* is intact.
*/
break;
/*
* If this isn't an option that contains
* address or prefix leases, then skip over it.
*/
continue;
}
/*
* Handle the option first.
*/
/* no timers in this structure */
opts += sizeof (dhcpv6_ia_ta_t);
} else {
/* both na and pd */
continue;
}
sizeof (d6in));
sizeof (d6in));
}
/*
* Now handle each suboption (address) inside.
*/
/*
* Verify the suboption header first.
*/
sizeof (d6o));
break;
continue;
}
/*
* Now process the contents.
*/
break;
sizeof (d6ia));
sizeof (d6ia));
}
}
} else {
/*
* make sure the IPv4 DHCP lease is still valid.
*/
sizeof (lease_t)) {
sizeof (lease_t));
goto failure;
}
}
}
return (pcnt);
while (pcnt-- > 0) {
}
return (-1);
}
/*
* write_hostconf(): writes the contents of a PKT_LIST into an <if>.dhc file
*
* input: const char *: the interface name
* PKT_LIST **: a list of pointers to PKT_LIST to write
* uint_t: length of the list of PKT_LIST pointers
* time_t: a starting time to treat the relative lease times
* in the first packet as relative to
* boolean_t: B_TRUE if using DHCPv6
* output: int: 0 if the file is written successfully, -1 otherwise
* (errno is set)
*/
int
const char *ifname,
{
int fd;
int retval;
int i, iovlen = 0;
0600);
if (fd == -1)
return (-1);
/*
* first write our magic number, then the relative time of the
* leases, then for each packet we write the length of the packet
* followed by the packet. we will then use the relative time in
* read_hostconf() to recalculate the lease times for the first packet.
*/
}
return (-1);
return (0);
}
/*
* relativize_time(): re-relativizes a time in a DHCP option
*
* input: DHCP_OPT *: the DHCP option parameter to convert
* time_t: the time the leases in the packet are currently relative to
* time_t: the current time which leases will become relative to
* output: void
*/
static void
{
return;
}
/*
* relativize_v6(): re-relativizes a time in a DHCPv6 option
*
* input: uint32_t *: the time value to convert
* time_t: the time the leases in the packet are currently relative to
* time_t: the current time which leases will become relative to
* output: void
*/
static void
{
if (hval != DHCPV6_INFTIME) {
*val = 0;
else
}
}