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 /* 223431Scarlsonj * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef UTIL_H 270Sstevel@tonic-gate #define UTIL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <sys/types.h> 320Sstevel@tonic-gate #include <netinet/in.h> 330Sstevel@tonic-gate #include <netinet/dhcp.h> 343431Scarlsonj #include <netinet/dhcp6.h> 350Sstevel@tonic-gate #include <libinetutil.h> 360Sstevel@tonic-gate #include <dhcpagent_ipc.h> 370Sstevel@tonic-gate 383431Scarlsonj #include "common.h" 393431Scarlsonj 400Sstevel@tonic-gate /* 410Sstevel@tonic-gate * general utility functions which have no better home. see util.c 420Sstevel@tonic-gate * for documentation on how to use the exported functions. 430Sstevel@tonic-gate */ 440Sstevel@tonic-gate 450Sstevel@tonic-gate #ifdef __cplusplus 460Sstevel@tonic-gate extern "C" { 470Sstevel@tonic-gate #endif 480Sstevel@tonic-gate 493431Scarlsonj struct dhcp_timer_s { 503431Scarlsonj iu_timer_id_t dt_id; 513431Scarlsonj lease_t dt_start; /* Initial timer value */ 523431Scarlsonj }; 530Sstevel@tonic-gate 540Sstevel@tonic-gate /* conversion functions */ 553431Scarlsonj const char *pkt_type_to_string(uchar_t, boolean_t); 560Sstevel@tonic-gate const char *monosec_to_string(monosec_t); 570Sstevel@tonic-gate time_t monosec_to_time(monosec_t); 583431Scarlsonj monosec_t hrtime_to_monosec(hrtime_t); 590Sstevel@tonic-gate 600Sstevel@tonic-gate /* shutdown handlers */ 610Sstevel@tonic-gate void graceful_shutdown(int); 620Sstevel@tonic-gate void inactivity_shutdown(iu_tq_t *, void *); 630Sstevel@tonic-gate 643431Scarlsonj /* timer functions */ 653431Scarlsonj void init_timer(dhcp_timer_t *, lease_t); 663431Scarlsonj boolean_t cancel_timer(dhcp_timer_t *); 673431Scarlsonj boolean_t schedule_timer(dhcp_timer_t *, iu_tq_callback_t *, void *); 680Sstevel@tonic-gate 690Sstevel@tonic-gate /* miscellaneous */ 70*4106Scarlsonj boolean_t add_default_route(uint32_t, struct in_addr *); 71*4106Scarlsonj boolean_t del_default_route(uint32_t, struct in_addr *); 720Sstevel@tonic-gate int daemonize(void); 730Sstevel@tonic-gate monosec_t monosec(void); 743431Scarlsonj void print_server_msg(dhcp_smach_t *, const char *, uint_t); 753431Scarlsonj boolean_t bind_sock(int, in_port_t, in_addr_t); 763431Scarlsonj boolean_t bind_sock_v6(int, in_port_t, const in6_addr_t *); 770Sstevel@tonic-gate const char *iffile_to_hostname(const char *); 783431Scarlsonj int dhcpv6_status_code(const dhcpv6_option_t *, uint_t, 793431Scarlsonj const char **, const char **, uint_t *); 800Sstevel@tonic-gate 810Sstevel@tonic-gate #ifdef __cplusplus 820Sstevel@tonic-gate } 830Sstevel@tonic-gate #endif 840Sstevel@tonic-gate 850Sstevel@tonic-gate #endif /* UTIL_H */ 86