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