xref: /titanic_51/usr/src/cmd/cmd-inet/lib/nwamd/events.h (revision 6a72db4a7fa12c3e0d1c1cf91a07390739fa0fbf)
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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #ifndef _EVENTS_H
27 #define	_EVENTS_H
28 
29 #include <door.h>
30 #include <libsysevent.h>
31 #include <libuutil.h>
32 #include <pthread.h>
33 #include <ucontext.h>
34 
35 #include <libnwam.h>
36 #include <libnwam_priv.h>
37 
38 struct nwamd_object;
39 typedef struct nwamd_object *nwamd_object_t;
40 
41 #include "ncp.h"
42 
43 /* Define internal-to-nwamd events here */
44 #define	NWAM_EVENT_TYPE_OBJECT_INIT		NWAM_EVENT_MAX + 1
45 #define	NWAM_EVENT_TYPE_OBJECT_FINI		NWAM_EVENT_MAX + 2
46 #define	NWAM_EVENT_TYPE_TIMED_CHECK_CONDITIONS	NWAM_EVENT_MAX + 3
47 #define	NWAM_EVENT_TYPE_TRIGGERED_CHECK_CONDITIONS NWAM_EVENT_MAX + 4
48 #define	NWAM_EVENT_TYPE_NCU_CHECK		NWAM_EVENT_MAX + 5
49 #define	NWAM_EVENT_TYPE_TIMER			NWAM_EVENT_MAX + 6
50 #define	NWAM_EVENT_TYPE_UPGRADE			NWAM_EVENT_MAX + 7
51 #define	NWAM_EVENT_TYPE_PERIODIC_SCAN		NWAM_EVENT_MAX + 8
52 #define	NWAM_EVENT_TYPE_QUEUE_QUIET		NWAM_EVENT_MAX + 9
53 
54 #define	NEXT_FEW_SECONDS			5
55 
56 /*
57  * Forward definition.
58  */
59 /*
60  * Wrapper structure for libnwam event (nwam_events_msg_t),  containing
61  * event id (used to uniquely identify events on the event queue),
62  * associated object (if any), and uu_list_node.
63  */
64 typedef struct nwamd_event {
65 	int32_t event_type;
66 	uint64_t event_id;
67 	struct timespec event_time;
68 	char event_object[NWAM_MAX_NAME_LEN];
69 	nwam_object_type_t event_object_type;
70 	uu_list_node_t event_node;
71 	boolean_t event_send;
72 	nwam_event_t event_msg;
73 } *nwamd_event_t;
74 
75 typedef struct nwamd_event_method {
76 	int32_t event_type;
77 	void (*event_method)(nwamd_event_t);
78 } nwamd_event_method_t;
79 
80 extern sysevent_handle_t *shp;
81 
82 /* Event generator init/fini code */
83 extern void nwamd_routing_events_init(void);
84 extern void nwamd_routing_events_fini(void);
85 extern void nwamd_sysevent_events_init(void);
86 extern void nwamd_sysevent_events_fini(void);
87 
88 /* Event init/enqueueing */
89 extern void nwamd_event_queue_init(void);
90 extern void nwamd_event_queue_fini(void);
91 extern void nwamd_event_sources_init(void);
92 extern void nwamd_event_sources_fini(void);
93 extern nwamd_event_t nwamd_event_init(int32_t, nwam_object_type_t, size_t,
94     const char *);
95 extern void nwamd_event_do_not_send(nwamd_event_t);
96 extern nwamd_event_t nwamd_event_init_object_action(nwam_object_type_t,
97     const char *, const char *, nwam_action_t);
98 extern nwamd_event_t nwamd_event_init_object_state(nwam_object_type_t,
99     const char *, nwam_state_t, nwam_aux_state_t);
100 extern nwamd_event_t nwamd_event_init_priority_group_change(int64_t);
101 extern nwamd_event_t nwamd_event_init_link_action(const char *, nwam_action_t);
102 extern nwamd_event_t nwamd_event_init_link_state(const char *, boolean_t);
103 extern nwamd_event_t nwamd_event_init_if_state(const char *, uint32_t,
104     uint32_t, struct sockaddr *, struct sockaddr *);
105 extern nwamd_event_t nwamd_event_init_wlan(const char *, int32_t, boolean_t,
106     nwam_wlan_t *, uint_t);
107 extern nwamd_event_t nwamd_event_init_ncu_check(void);
108 extern nwamd_event_t nwamd_event_init_init(void);
109 extern nwamd_event_t nwamd_event_init_shutdown(void);
110 extern void nwamd_event_enqueue(nwamd_event_t);
111 extern void nwamd_event_enqueue_timed(nwamd_event_t, int);
112 extern void nwamd_event_enqueue_expired_events(void);
113 extern boolean_t nwamd_event_enqueued(int32_t, nwam_object_type_t,
114     const char *);
115 extern void nwamd_event_send(nwam_event_t);
116 extern void nwamd_event_fini(nwamd_event_t);
117 extern void nwamd_event_handler(void);
118 
119 #endif /* _EVENTS_H */
120