xref: /titanic_41/usr/src/cmd/cmd-inet/lib/nwamd/events.h (revision ea394cb00fd96864e34d2841b4a22357b621c78f)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _EVENTS_H
28 #define	_EVENTS_H
29 
30 #include <door.h>
31 #include <libsysevent.h>
32 #include <libuutil.h>
33 #include <pthread.h>
34 #include <ucontext.h>
35 
36 #include <libnwam.h>
37 #include <libnwam_priv.h>
38 
39 struct nwamd_object;
40 typedef struct nwamd_object *nwamd_object_t;
41 
42 #include "ncp.h"
43 
44 /* Define internal-to-nwamd events here */
45 #define	NWAM_EVENT_TYPE_OBJECT_INIT		NWAM_EVENT_MAX + 1
46 #define	NWAM_EVENT_TYPE_OBJECT_FINI		NWAM_EVENT_MAX + 2
47 #define	NWAM_EVENT_TYPE_TIMED_CHECK_CONDITIONS	NWAM_EVENT_MAX + 3
48 #define	NWAM_EVENT_TYPE_TRIGGERED_CHECK_CONDITIONS NWAM_EVENT_MAX + 4
49 #define	NWAM_EVENT_TYPE_NCU_CHECK		NWAM_EVENT_MAX + 5
50 #define	NWAM_EVENT_TYPE_TIMER			NWAM_EVENT_MAX + 6
51 #define	NWAM_EVENT_TYPE_UPGRADE			NWAM_EVENT_MAX + 7
52 #define	NWAM_EVENT_TYPE_PERIODIC_SCAN		NWAM_EVENT_MAX + 8
53 #define	NWAM_EVENT_TYPE_QUEUE_QUIET		NWAM_EVENT_MAX + 9
54 
55 #define	NEXT_FEW_SECONDS			5
56 
57 /*
58  * Forward definition.
59  */
60 /*
61  * Wrapper structure for libnwam event (nwam_events_msg_t),  containing
62  * event id (used to uniquely identify events on the event queue),
63  * associated object (if any), and uu_list_node.
64  */
65 typedef struct nwamd_event {
66 	int32_t event_type;
67 	uint64_t event_id;
68 	struct timespec event_time;
69 	char event_object[NWAM_MAX_NAME_LEN];
70 	nwam_object_type_t event_object_type;
71 	uu_list_node_t event_node;
72 	boolean_t event_send;
73 	nwam_event_t event_msg;
74 } *nwamd_event_t;
75 
76 typedef struct nwamd_event_method {
77 	int32_t event_type;
78 	void (*event_method)(nwamd_event_t);
79 } nwamd_event_method_t;
80 
81 extern sysevent_handle_t *shp;
82 
83 /* Event generator init/fini code */
84 extern void nwamd_routing_events_init(void);
85 extern void nwamd_routing_events_fini(void);
86 extern void nwamd_sysevent_events_init(void);
87 extern void nwamd_sysevent_events_fini(void);
88 
89 /* Event init/enqueueing */
90 extern void nwamd_event_queue_init(void);
91 extern void nwamd_event_queue_fini(void);
92 extern void nwamd_event_sources_init(void);
93 extern void nwamd_event_sources_fini(void);
94 extern nwamd_event_t nwamd_event_init(int32_t, nwam_object_type_t, size_t,
95     const char *);
96 extern void nwamd_event_do_not_send(nwamd_event_t);
97 extern nwamd_event_t nwamd_event_init_object_action(nwam_object_type_t,
98     const char *, const char *, nwam_action_t);
99 extern nwamd_event_t nwamd_event_init_object_state(nwam_object_type_t,
100     const char *, nwam_state_t, nwam_aux_state_t);
101 extern nwamd_event_t nwamd_event_init_priority_group_change(int64_t);
102 extern nwamd_event_t nwamd_event_init_link_action(const char *, nwam_action_t);
103 extern nwamd_event_t nwamd_event_init_link_state(const char *, boolean_t);
104 extern nwamd_event_t nwamd_event_init_if_state(const char *, uint32_t,
105     uint32_t, uint32_t, struct sockaddr *);
106 extern nwamd_event_t nwamd_event_init_wlan(const char *, int32_t, boolean_t,
107     nwam_wlan_t *, uint_t);
108 extern nwamd_event_t nwamd_event_init_ncu_check(void);
109 extern nwamd_event_t nwamd_event_init_init(void);
110 extern nwamd_event_t nwamd_event_init_shutdown(void);
111 extern void nwamd_event_enqueue(nwamd_event_t);
112 extern void nwamd_event_enqueue_timed(nwamd_event_t, int);
113 extern void nwamd_event_enqueue_expired_events(void);
114 extern boolean_t nwamd_event_enqueued(int32_t, nwam_object_type_t,
115     const char *);
116 extern void nwamd_event_send(nwam_event_t);
117 extern void nwamd_event_fini(nwamd_event_t);
118 extern void nwamd_event_handler(void);
119 
120 #endif /* _EVENTS_H */
121