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