10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 53431Scarlsonj * Common Development and Distribution License (the "License"). 63431Scarlsonj * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*12989SVasumathi.Sundaram@oracle.COM * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate #ifndef UTIL_H 260Sstevel@tonic-gate #define UTIL_H 270Sstevel@tonic-gate 280Sstevel@tonic-gate #include <sys/types.h> 290Sstevel@tonic-gate #include <netinet/in.h> 300Sstevel@tonic-gate #include <netinet/dhcp.h> 313431Scarlsonj #include <netinet/dhcp6.h> 320Sstevel@tonic-gate #include <libinetutil.h> 330Sstevel@tonic-gate #include <dhcpagent_ipc.h> 340Sstevel@tonic-gate 353431Scarlsonj #include "common.h" 363431Scarlsonj 370Sstevel@tonic-gate /* 380Sstevel@tonic-gate * general utility functions which have no better home. see util.c 390Sstevel@tonic-gate * for documentation on how to use the exported functions. 400Sstevel@tonic-gate */ 410Sstevel@tonic-gate 420Sstevel@tonic-gate #ifdef __cplusplus 430Sstevel@tonic-gate extern "C" { 440Sstevel@tonic-gate #endif 450Sstevel@tonic-gate 463431Scarlsonj struct dhcp_timer_s { 473431Scarlsonj iu_timer_id_t dt_id; 483431Scarlsonj lease_t dt_start; /* Initial timer value */ 493431Scarlsonj }; 500Sstevel@tonic-gate 510Sstevel@tonic-gate /* conversion functions */ 523431Scarlsonj const char *pkt_type_to_string(uchar_t, boolean_t); 530Sstevel@tonic-gate const char *monosec_to_string(monosec_t); 540Sstevel@tonic-gate time_t monosec_to_time(monosec_t); 553431Scarlsonj monosec_t hrtime_to_monosec(hrtime_t); 560Sstevel@tonic-gate 570Sstevel@tonic-gate /* shutdown handlers */ 580Sstevel@tonic-gate void graceful_shutdown(int); 590Sstevel@tonic-gate void inactivity_shutdown(iu_tq_t *, void *); 600Sstevel@tonic-gate 613431Scarlsonj /* timer functions */ 623431Scarlsonj void init_timer(dhcp_timer_t *, lease_t); 633431Scarlsonj boolean_t cancel_timer(dhcp_timer_t *); 643431Scarlsonj boolean_t schedule_timer(dhcp_timer_t *, iu_tq_callback_t *, void *); 650Sstevel@tonic-gate 660Sstevel@tonic-gate /* miscellaneous */ 674106Scarlsonj boolean_t add_default_route(uint32_t, struct in_addr *); 684106Scarlsonj boolean_t del_default_route(uint32_t, struct in_addr *); 690Sstevel@tonic-gate int daemonize(void); 700Sstevel@tonic-gate monosec_t monosec(void); 713431Scarlsonj void print_server_msg(dhcp_smach_t *, const char *, uint_t); 723431Scarlsonj boolean_t bind_sock(int, in_port_t, in_addr_t); 733431Scarlsonj boolean_t bind_sock_v6(int, in_port_t, const in6_addr_t *); 740Sstevel@tonic-gate const char *iffile_to_hostname(const char *); 753431Scarlsonj int dhcpv6_status_code(const dhcpv6_option_t *, uint_t, 763431Scarlsonj const char **, const char **, uint_t *); 77*12989SVasumathi.Sundaram@oracle.COM void write_lease_to_hostconf(dhcp_smach_t *); 780Sstevel@tonic-gate 790Sstevel@tonic-gate #ifdef __cplusplus 800Sstevel@tonic-gate } 810Sstevel@tonic-gate #endif 820Sstevel@tonic-gate 830Sstevel@tonic-gate #endif /* UTIL_H */ 84