xref: /illumos-gate/usr/src/lib/libinetutil/common/libinetutil_impl.h (revision 1da57d551424de5a9d469760be7c4b4d4f10a755)
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 _LIBINETUTIL_IMPL_H
28 #define	_LIBINETUTIL_IMPL_H
29 
30 /*
31  * Contains implementation-specific definitions for libinetutil.
32  */
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 #include <netinet/inetutil.h>
39 #include <sys/types.h>
40 #include <sys/socket.h>
41 #include <netinet/in.h>
42 #include <net/if.h>
43 #include <sys/poll.h>
44 #include <signal.h>
45 #include <limits.h>
46 
47 /*
48  * timer queue implementation-specific artifacts which may change.  A
49  * `iu_tq_t' is an incomplete type as far as the consumer of timer queues
50  * is concerned.
51  */
52 
53 typedef struct iu_timer_node {
54 
55 	struct iu_timer_node		*iutn_prev;
56 	struct iu_timer_node		*iutn_next;
57 	struct iu_timer_node		*iutn_expire_next;
58 	hrtime_t			iutn_abs_timeout;
59 	iu_timer_id_t			iutn_timer_id;
60 	iu_tq_callback_t		*iutn_callback;
61 	void				*iutn_arg;
62 	int				iutn_pending_delete;
63 
64 } iu_timer_node_t;
65 
66 struct iu_timer_queue {
67 	iu_timer_id_t	iutq_next_timer_id;
68 	iu_timer_node_t	*iutq_head;		/* in order of time-to-fire */
69 	int		iutq_in_expire;	/* nonzero if in the expire function */
70 	uchar_t		iutq_timer_id_map[(IU_TIMER_ID_MAX + CHAR_BIT) /
71 				CHAR_BIT];
72 };
73 
74 /*
75  * event handler implementation-specific artifacts which may change.  An
76  * `iu_eh_t' is an incomplete type as far as the consumer of event handlers is
77  * concerned.
78  */
79 
80 typedef struct iu_event_node {
81 
82 	iu_eh_callback_t	*iuen_callback;	/* callback to call */
83 
84 	void			*iuen_arg;	/* argument to pass to the */
85 						/* callback */
86 } iu_event_node_t;
87 
88 typedef struct iu_eh_sig_info  {
89 
90 	boolean_t		iues_pending;	/* signal is currently */
91 						/* pending */
92 
93 	iu_eh_sighandler_t	*iues_handler;	/* handler for a given signal */
94 
95 	void			*iues_data; 	/* data to pass back to the */
96 						/* handler */
97 } iu_eh_sig_info_t;
98 
99 struct iu_event_handler {
100 
101 	struct pollfd		*iueh_pollfds;	/* array of pollfds */
102 
103 	iu_event_node_t		*iueh_events;	/* corresponding pollfd info */
104 
105 	unsigned int		iueh_num_fds;	/* number of pollfds/events */
106 
107 	boolean_t		iueh_stop;	/* true when done */
108 
109 	unsigned int		iueh_reason;	/* if stop is true, reason */
110 
111 	sigset_t		iueh_sig_regset;	/* registered signal */
112 							/* set */
113 
114 	iu_eh_sig_info_t	iueh_sig_info[NSIG];	/* signal handler */
115 							/* information */
116 
117 	iu_eh_shutdown_t	*iueh_shutdown;	/* shutdown callback */
118 
119 	void			*iueh_shutdown_arg;	/* data for shutdown */
120 							/* callback */
121 };
122 
123 #ifdef	__cplusplus
124 }
125 #endif
126 
127 #endif	/* !_LIBINETUTIL_IMPL_H */
128