xref: /titanic_50/usr/src/cmd/cmd-inet/sbin/dhcpagent/util.h (revision 6a634c9dca3093f3922e4b7ab826d7bdf17bf78e)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5d04ccbb3Scarlsonj  * Common Development and Distribution License (the "License").
6d04ccbb3Scarlsonj  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*0a3e1f6cSVasumathi Sundaram  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
237c478bd9Sstevel@tonic-gate  */
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate #ifndef	UTIL_H
267c478bd9Sstevel@tonic-gate #define	UTIL_H
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #include <sys/types.h>
297c478bd9Sstevel@tonic-gate #include <netinet/in.h>
307c478bd9Sstevel@tonic-gate #include <netinet/dhcp.h>
31d04ccbb3Scarlsonj #include <netinet/dhcp6.h>
327c478bd9Sstevel@tonic-gate #include <libinetutil.h>
337c478bd9Sstevel@tonic-gate #include <dhcpagent_ipc.h>
347c478bd9Sstevel@tonic-gate 
35d04ccbb3Scarlsonj #include "common.h"
36d04ccbb3Scarlsonj 
377c478bd9Sstevel@tonic-gate /*
387c478bd9Sstevel@tonic-gate  * general utility functions which have no better home.  see util.c
397c478bd9Sstevel@tonic-gate  * for documentation on how to use the exported functions.
407c478bd9Sstevel@tonic-gate  */
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
437c478bd9Sstevel@tonic-gate extern "C" {
447c478bd9Sstevel@tonic-gate #endif
457c478bd9Sstevel@tonic-gate 
46d04ccbb3Scarlsonj struct dhcp_timer_s {
47d04ccbb3Scarlsonj 	iu_timer_id_t	dt_id;
48d04ccbb3Scarlsonj 	lease_t		dt_start;		/* Initial timer value */
49d04ccbb3Scarlsonj };
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate /* conversion functions */
52d04ccbb3Scarlsonj const char	*pkt_type_to_string(uchar_t, boolean_t);
537c478bd9Sstevel@tonic-gate const char	*monosec_to_string(monosec_t);
547c478bd9Sstevel@tonic-gate time_t		monosec_to_time(monosec_t);
55d04ccbb3Scarlsonj monosec_t	hrtime_to_monosec(hrtime_t);
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /* shutdown handlers */
587c478bd9Sstevel@tonic-gate void		graceful_shutdown(int);
597c478bd9Sstevel@tonic-gate void		inactivity_shutdown(iu_tq_t *, void *);
607c478bd9Sstevel@tonic-gate 
61d04ccbb3Scarlsonj /* timer functions */
62d04ccbb3Scarlsonj void		init_timer(dhcp_timer_t *, lease_t);
63d04ccbb3Scarlsonj boolean_t	cancel_timer(dhcp_timer_t *);
64d04ccbb3Scarlsonj boolean_t	schedule_timer(dhcp_timer_t *, iu_tq_callback_t *, void *);
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate /* miscellaneous */
67cfb9c9abScarlsonj boolean_t	add_default_route(uint32_t, struct in_addr *);
68cfb9c9abScarlsonj boolean_t	del_default_route(uint32_t, struct in_addr *);
697c478bd9Sstevel@tonic-gate int		daemonize(void);
707c478bd9Sstevel@tonic-gate monosec_t	monosec(void);
71d04ccbb3Scarlsonj void		print_server_msg(dhcp_smach_t *, const char *, uint_t);
72d04ccbb3Scarlsonj boolean_t	bind_sock(int, in_port_t, in_addr_t);
73d04ccbb3Scarlsonj boolean_t	bind_sock_v6(int, in_port_t, const in6_addr_t *);
747c478bd9Sstevel@tonic-gate const char	*iffile_to_hostname(const char *);
75d04ccbb3Scarlsonj int		dhcpv6_status_code(const dhcpv6_option_t *, uint_t,
76d04ccbb3Scarlsonj     const char **, const char **, uint_t *);
77*0a3e1f6cSVasumathi Sundaram void		write_lease_to_hostconf(dhcp_smach_t *);
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
807c478bd9Sstevel@tonic-gate }
817c478bd9Sstevel@tonic-gate #endif
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate #endif	/* UTIL_H */
84