1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef _LIBINETUTIL_IMPL_H
28*0Sstevel@tonic-gate #define	_LIBINETUTIL_IMPL_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate /*
33*0Sstevel@tonic-gate  * Contains implementation-specific definitions for libinetutil.
34*0Sstevel@tonic-gate  */
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #ifdef	__cplusplus
37*0Sstevel@tonic-gate extern "C" {
38*0Sstevel@tonic-gate #endif
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate #include <netinet/inetutil.h>
41*0Sstevel@tonic-gate #include <sys/types.h>
42*0Sstevel@tonic-gate #include <sys/socket.h>
43*0Sstevel@tonic-gate #include <netinet/in.h>
44*0Sstevel@tonic-gate #include <net/if.h>
45*0Sstevel@tonic-gate #include <sys/poll.h>
46*0Sstevel@tonic-gate #include <signal.h>
47*0Sstevel@tonic-gate #include <limits.h>
48*0Sstevel@tonic-gate 
49*0Sstevel@tonic-gate /*
50*0Sstevel@tonic-gate  * timer queue implementation-specific artifacts which may change.  A
51*0Sstevel@tonic-gate  * `iu_tq_t' is an incomplete type as far as the consumer of timer queues
52*0Sstevel@tonic-gate  * is concerned.
53*0Sstevel@tonic-gate  */
54*0Sstevel@tonic-gate 
55*0Sstevel@tonic-gate typedef struct iu_timer_node {
56*0Sstevel@tonic-gate 
57*0Sstevel@tonic-gate 	struct iu_timer_node		*iutn_prev;
58*0Sstevel@tonic-gate 	struct iu_timer_node		*iutn_next;
59*0Sstevel@tonic-gate 	struct iu_timer_node		*iutn_expire_next;
60*0Sstevel@tonic-gate 	hrtime_t			iutn_abs_timeout;
61*0Sstevel@tonic-gate 	iu_timer_id_t			iutn_timer_id;
62*0Sstevel@tonic-gate 	iu_tq_callback_t		*iutn_callback;
63*0Sstevel@tonic-gate 	void				*iutn_arg;
64*0Sstevel@tonic-gate 	int				iutn_pending_delete;
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate } iu_timer_node_t;
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate struct iu_timer_queue {
69*0Sstevel@tonic-gate 	iu_timer_id_t	iutq_next_timer_id;
70*0Sstevel@tonic-gate 	iu_timer_node_t	*iutq_head;		/* in order of time-to-fire */
71*0Sstevel@tonic-gate 	int		iutq_in_expire;	/* nonzero if in the expire function */
72*0Sstevel@tonic-gate 	uchar_t		iutq_timer_id_map[(IU_TIMER_ID_MAX + CHAR_BIT) /
73*0Sstevel@tonic-gate 				CHAR_BIT];
74*0Sstevel@tonic-gate };
75*0Sstevel@tonic-gate 
76*0Sstevel@tonic-gate /*
77*0Sstevel@tonic-gate  * event handler implementation-specific artifacts which may change.  An
78*0Sstevel@tonic-gate  * `iu_eh_t' is an incomplete type as far as the consumer of event handlers is
79*0Sstevel@tonic-gate  * concerned.
80*0Sstevel@tonic-gate  */
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate typedef struct iu_event_node {
83*0Sstevel@tonic-gate 
84*0Sstevel@tonic-gate 	iu_eh_callback_t	*iuen_callback;	/* callback to call */
85*0Sstevel@tonic-gate 
86*0Sstevel@tonic-gate 	void			*iuen_arg;	/* argument to pass to the */
87*0Sstevel@tonic-gate 						/* callback */
88*0Sstevel@tonic-gate } iu_event_node_t;
89*0Sstevel@tonic-gate 
90*0Sstevel@tonic-gate typedef struct iu_eh_sig_info  {
91*0Sstevel@tonic-gate 
92*0Sstevel@tonic-gate 	boolean_t		iues_pending;	/* signal is currently */
93*0Sstevel@tonic-gate 						/* pending */
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate 	iu_eh_sighandler_t	*iues_handler;	/* handler for a given signal */
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate 	void			*iues_data; 	/* data to pass back to the */
98*0Sstevel@tonic-gate 						/* handler */
99*0Sstevel@tonic-gate } iu_eh_sig_info_t;
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate struct iu_event_handler {
102*0Sstevel@tonic-gate 
103*0Sstevel@tonic-gate 	struct pollfd		*iueh_pollfds;	/* array of pollfds */
104*0Sstevel@tonic-gate 
105*0Sstevel@tonic-gate 	iu_event_node_t		*iueh_events;	/* corresponding pollfd info */
106*0Sstevel@tonic-gate 
107*0Sstevel@tonic-gate 	unsigned int		iueh_num_fds;	/* number of pollfds/events */
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate 	boolean_t		iueh_stop;	/* true when done */
110*0Sstevel@tonic-gate 
111*0Sstevel@tonic-gate 	unsigned int		iueh_reason;	/* if stop is true, reason */
112*0Sstevel@tonic-gate 
113*0Sstevel@tonic-gate 	sigset_t		iueh_sig_regset;	/* registered signal */
114*0Sstevel@tonic-gate 							/* set */
115*0Sstevel@tonic-gate 
116*0Sstevel@tonic-gate 	iu_eh_sig_info_t	iueh_sig_info[NSIG];	/* signal handler */
117*0Sstevel@tonic-gate 							/* information */
118*0Sstevel@tonic-gate 
119*0Sstevel@tonic-gate 	iu_eh_shutdown_t	*iueh_shutdown;	/* shutdown callback */
120*0Sstevel@tonic-gate 
121*0Sstevel@tonic-gate 	void			*iueh_shutdown_arg;	/* data for shutdown */
122*0Sstevel@tonic-gate 							/* callback */
123*0Sstevel@tonic-gate };
124*0Sstevel@tonic-gate 
125*0Sstevel@tonic-gate #ifdef	__cplusplus
126*0Sstevel@tonic-gate }
127*0Sstevel@tonic-gate #endif
128*0Sstevel@tonic-gate 
129*0Sstevel@tonic-gate #endif	/* !_LIBINETUTIL_IMPL_H */
130