16ba597c5SAnurag S. Maskey /* 26ba597c5SAnurag S. Maskey * CDDL HEADER START 36ba597c5SAnurag S. Maskey * 46ba597c5SAnurag S. Maskey * The contents of this file are subject to the terms of the 56ba597c5SAnurag S. Maskey * Common Development and Distribution License (the "License"). 66ba597c5SAnurag S. Maskey * You may not use this file except in compliance with the License. 76ba597c5SAnurag S. Maskey * 86ba597c5SAnurag S. Maskey * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 96ba597c5SAnurag S. Maskey * or http://www.opensolaris.org/os/licensing. 106ba597c5SAnurag S. Maskey * See the License for the specific language governing permissions 116ba597c5SAnurag S. Maskey * and limitations under the License. 126ba597c5SAnurag S. Maskey * 136ba597c5SAnurag S. Maskey * When distributing Covered Code, include this CDDL HEADER in each 146ba597c5SAnurag S. Maskey * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 156ba597c5SAnurag S. Maskey * If applicable, add the following below this CDDL HEADER, with the 166ba597c5SAnurag S. Maskey * fields enclosed by brackets "[]" replaced with your own identifying 176ba597c5SAnurag S. Maskey * information: Portions Copyright [yyyy] [name of copyright owner] 186ba597c5SAnurag S. Maskey * 196ba597c5SAnurag S. Maskey * CDDL HEADER END 206ba597c5SAnurag S. Maskey */ 216ba597c5SAnurag S. Maskey 226ba597c5SAnurag S. Maskey /* 23*f6da83d4SAnurag S. Maskey * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 246ba597c5SAnurag S. Maskey */ 256ba597c5SAnurag S. Maskey 266ba597c5SAnurag S. Maskey #ifndef _EVENTS_H 276ba597c5SAnurag S. Maskey #define _EVENTS_H 286ba597c5SAnurag S. Maskey 296ba597c5SAnurag S. Maskey #include <door.h> 306ba597c5SAnurag S. Maskey #include <libsysevent.h> 316ba597c5SAnurag S. Maskey #include <libuutil.h> 326ba597c5SAnurag S. Maskey #include <pthread.h> 336ba597c5SAnurag S. Maskey #include <ucontext.h> 346ba597c5SAnurag S. Maskey 356ba597c5SAnurag S. Maskey #include <libnwam.h> 366ba597c5SAnurag S. Maskey #include <libnwam_priv.h> 376ba597c5SAnurag S. Maskey 386ba597c5SAnurag S. Maskey struct nwamd_object; 396ba597c5SAnurag S. Maskey typedef struct nwamd_object *nwamd_object_t; 406ba597c5SAnurag S. Maskey 416ba597c5SAnurag S. Maskey #include "ncp.h" 426ba597c5SAnurag S. Maskey 436ba597c5SAnurag S. Maskey /* Define internal-to-nwamd events here */ 446ba597c5SAnurag S. Maskey #define NWAM_EVENT_TYPE_OBJECT_INIT NWAM_EVENT_MAX + 1 456ba597c5SAnurag S. Maskey #define NWAM_EVENT_TYPE_OBJECT_FINI NWAM_EVENT_MAX + 2 466ba597c5SAnurag S. Maskey #define NWAM_EVENT_TYPE_TIMED_CHECK_CONDITIONS NWAM_EVENT_MAX + 3 476ba597c5SAnurag S. Maskey #define NWAM_EVENT_TYPE_TRIGGERED_CHECK_CONDITIONS NWAM_EVENT_MAX + 4 486ba597c5SAnurag S. Maskey #define NWAM_EVENT_TYPE_NCU_CHECK NWAM_EVENT_MAX + 5 496ba597c5SAnurag S. Maskey #define NWAM_EVENT_TYPE_TIMER NWAM_EVENT_MAX + 6 506ba597c5SAnurag S. Maskey #define NWAM_EVENT_TYPE_UPGRADE NWAM_EVENT_MAX + 7 516ba597c5SAnurag S. Maskey #define NWAM_EVENT_TYPE_PERIODIC_SCAN NWAM_EVENT_MAX + 8 526ba597c5SAnurag S. Maskey #define NWAM_EVENT_TYPE_QUEUE_QUIET NWAM_EVENT_MAX + 9 536ba597c5SAnurag S. Maskey 546ba597c5SAnurag S. Maskey #define NEXT_FEW_SECONDS 5 556ba597c5SAnurag S. Maskey 566ba597c5SAnurag S. Maskey /* 576ba597c5SAnurag S. Maskey * Forward definition. 586ba597c5SAnurag S. Maskey */ 596ba597c5SAnurag S. Maskey /* 606ba597c5SAnurag S. Maskey * Wrapper structure for libnwam event (nwam_events_msg_t), containing 616ba597c5SAnurag S. Maskey * event id (used to uniquely identify events on the event queue), 626ba597c5SAnurag S. Maskey * associated object (if any), and uu_list_node. 636ba597c5SAnurag S. Maskey */ 646ba597c5SAnurag S. Maskey typedef struct nwamd_event { 656ba597c5SAnurag S. Maskey int32_t event_type; 666ba597c5SAnurag S. Maskey uint64_t event_id; 676ba597c5SAnurag S. Maskey struct timespec event_time; 686ba597c5SAnurag S. Maskey char event_object[NWAM_MAX_NAME_LEN]; 696ba597c5SAnurag S. Maskey nwam_object_type_t event_object_type; 706ba597c5SAnurag S. Maskey uu_list_node_t event_node; 716ba597c5SAnurag S. Maskey boolean_t event_send; 726ba597c5SAnurag S. Maskey nwam_event_t event_msg; 736ba597c5SAnurag S. Maskey } *nwamd_event_t; 746ba597c5SAnurag S. Maskey 756ba597c5SAnurag S. Maskey typedef struct nwamd_event_method { 766ba597c5SAnurag S. Maskey int32_t event_type; 776ba597c5SAnurag S. Maskey void (*event_method)(nwamd_event_t); 786ba597c5SAnurag S. Maskey } nwamd_event_method_t; 796ba597c5SAnurag S. Maskey 806ba597c5SAnurag S. Maskey extern sysevent_handle_t *shp; 816ba597c5SAnurag S. Maskey 826ba597c5SAnurag S. Maskey /* Event generator init/fini code */ 836ba597c5SAnurag S. Maskey extern void nwamd_routing_events_init(void); 846ba597c5SAnurag S. Maskey extern void nwamd_routing_events_fini(void); 856ba597c5SAnurag S. Maskey extern void nwamd_sysevent_events_init(void); 866ba597c5SAnurag S. Maskey extern void nwamd_sysevent_events_fini(void); 876ba597c5SAnurag S. Maskey 886ba597c5SAnurag S. Maskey /* Event init/enqueueing */ 896ba597c5SAnurag S. Maskey extern void nwamd_event_queue_init(void); 906ba597c5SAnurag S. Maskey extern void nwamd_event_queue_fini(void); 916ba597c5SAnurag S. Maskey extern void nwamd_event_sources_init(void); 926ba597c5SAnurag S. Maskey extern void nwamd_event_sources_fini(void); 936ba597c5SAnurag S. Maskey extern nwamd_event_t nwamd_event_init(int32_t, nwam_object_type_t, size_t, 946ba597c5SAnurag S. Maskey const char *); 956ba597c5SAnurag S. Maskey extern void nwamd_event_do_not_send(nwamd_event_t); 966ba597c5SAnurag S. Maskey extern nwamd_event_t nwamd_event_init_object_action(nwam_object_type_t, 976ba597c5SAnurag S. Maskey const char *, const char *, nwam_action_t); 986ba597c5SAnurag S. Maskey extern nwamd_event_t nwamd_event_init_object_state(nwam_object_type_t, 996ba597c5SAnurag S. Maskey const char *, nwam_state_t, nwam_aux_state_t); 1006ba597c5SAnurag S. Maskey extern nwamd_event_t nwamd_event_init_priority_group_change(int64_t); 1016ba597c5SAnurag S. Maskey extern nwamd_event_t nwamd_event_init_link_action(const char *, nwam_action_t); 1026ba597c5SAnurag S. Maskey extern nwamd_event_t nwamd_event_init_link_state(const char *, boolean_t); 1036ba597c5SAnurag S. Maskey extern nwamd_event_t nwamd_event_init_if_state(const char *, uint32_t, 104*f6da83d4SAnurag S. Maskey uint32_t, struct sockaddr *, struct sockaddr *); 1056ba597c5SAnurag S. Maskey extern nwamd_event_t nwamd_event_init_wlan(const char *, int32_t, boolean_t, 1066ba597c5SAnurag S. Maskey nwam_wlan_t *, uint_t); 1076ba597c5SAnurag S. Maskey extern nwamd_event_t nwamd_event_init_ncu_check(void); 1086ba597c5SAnurag S. Maskey extern nwamd_event_t nwamd_event_init_init(void); 1096ba597c5SAnurag S. Maskey extern nwamd_event_t nwamd_event_init_shutdown(void); 1106ba597c5SAnurag S. Maskey extern void nwamd_event_enqueue(nwamd_event_t); 1116ba597c5SAnurag S. Maskey extern void nwamd_event_enqueue_timed(nwamd_event_t, int); 1126ba597c5SAnurag S. Maskey extern void nwamd_event_enqueue_expired_events(void); 1136ba597c5SAnurag S. Maskey extern boolean_t nwamd_event_enqueued(int32_t, nwam_object_type_t, 1146ba597c5SAnurag S. Maskey const char *); 1156ba597c5SAnurag S. Maskey extern void nwamd_event_send(nwam_event_t); 1166ba597c5SAnurag S. Maskey extern void nwamd_event_fini(nwamd_event_t); 1176ba597c5SAnurag S. Maskey extern void nwamd_event_handler(void); 1186ba597c5SAnurag S. Maskey 1196ba597c5SAnurag S. Maskey #endif /* _EVENTS_H */ 120