xref: /titanic_44/usr/src/cmd/cmd-inet/sbin/dhcpagent/util.h (revision 4496171313bed39e96f21bc2f9faf2868e267ae3)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	UTIL_H
28 #define	UTIL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <netinet/in.h>
34 #include <netinet/dhcp.h>
35 #include <libinetutil.h>
36 #include <dhcpagent_ipc.h>
37 
38 /*
39  * general utility functions which have no better home.  see util.c
40  * for documentation on how to use the exported functions.
41  */
42 
43 #ifdef	__cplusplus
44 extern "C" {
45 #endif
46 
47 struct ifslist;				/* forward declaration */
48 
49 typedef int64_t monosec_t;		/* see README for details */
50 
51 /* conversion functions */
52 const char	*pkt_type_to_string(uchar_t);
53 const char	*monosec_to_string(monosec_t);
54 time_t		monosec_to_time(monosec_t);
55 uchar_t		dlpi_to_arp(uchar_t);
56 
57 /* shutdown handlers */
58 void		graceful_shutdown(int);
59 void		inactivity_shutdown(iu_tq_t *, void *);
60 
61 /* acknak handlers */
62 int		register_acknak(struct ifslist *);
63 int		unregister_acknak(struct ifslist *);
64 
65 /* ipc functions */
66 void		send_error_reply(dhcp_ipc_request_t *, int, int *);
67 void		send_ok_reply(dhcp_ipc_request_t *, int *);
68 void		send_data_reply(dhcp_ipc_request_t *, int *, int,
69 		    dhcp_data_type_t, void *, size_t);
70 
71 /* miscellaneous */
72 int		add_default_route(const char *, struct in_addr *);
73 int		del_default_route(const char *, struct in_addr *);
74 int		daemonize(void);
75 monosec_t	monosec(void);
76 void		print_server_msg(struct ifslist *, DHCP_OPT *);
77 int		bind_sock(int, in_port_t, in_addr_t);
78 const char	*iffile_to_hostname(const char *);
79 
80 #ifdef	__cplusplus
81 }
82 #endif
83 
84 #endif	/* UTIL_H */
85