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 _OBJECTS_H 28 #define _OBJECTS_H 29 30 #include <door.h> 31 #include <libsysevent.h> 32 #include <libuutil.h> 33 #include <pthread.h> 34 35 #include <libnwam.h> 36 #include "events.h" 37 #include "ncp.h" 38 #include "ncu.h" 39 40 /* 41 * Wrapper structure for libnwam object, containing name, type, 42 * associated object handle and optional object data field, and uu_list_node. 43 */ 44 struct nwamd_object { 45 char nwamd_object_name[NWAM_MAX_NAME_LEN]; 46 nwam_object_type_t nwamd_object_type; 47 48 /* 49 * These two elements provide a reference count for the structure and 50 * a lock for the data including reference count. 51 */ 52 int nwamd_object_refcount; 53 pthread_mutex_t nwamd_object_mutex; 54 55 void *nwamd_object_handle; /* can point at ENMs, locations, etc. */ 56 nwamd_ncu_t *nwamd_object_data; 57 nwam_state_t nwamd_object_state; 58 nwam_aux_state_t nwamd_object_aux_state; 59 uu_list_node_t nwamd_object_node; 60 }; 61 62 /* Object init/enqueueing */ 63 extern void nwamd_object_lists_init(void); 64 extern void nwamd_object_lists_fini(void); 65 extern nwamd_object_t nwamd_object_init(nwam_object_type_t, const char *, 66 void *, void *); 67 extern nwamd_object_t nwamd_object_find(nwam_object_type_t, const char *); 68 extern void nwamd_object_release_and_preserve(nwamd_object_t); 69 extern void nwamd_object_release(nwamd_object_t); 70 extern void nwamd_object_release_and_destroy(nwamd_object_t); 71 extern void nwamd_object_release_after_preserve(nwamd_object_t); 72 extern void nwamd_object_release_and_destroy_after_preserve(nwamd_object_t); 73 extern void nwamd_object_set_state(nwam_object_type_t, const char *, 74 nwam_state_t, nwam_aux_state_t); 75 extern void nwamd_object_set_state_timed(nwam_object_type_t, const char *, 76 nwam_state_t, nwam_aux_state_t, uint32_t); 77 extern nwamd_event_method_t *nwamd_object_event_methods(nwam_object_type_t); 78 extern int nwamd_walk_objects(nwam_object_type_t, 79 int (*)(nwamd_object_t, void *), void *); 80 extern int nwamd_object_update(const char *, nwam_object_type_t); 81 82 /* Known WLAN functions (no wlan objects, so no init/fini functions) */ 83 /* event methods */ 84 extern void nwamd_known_wlan_handle_init_event(nwamd_event_t); 85 86 /* refresh/destroy a known WLAN */ 87 extern int nwamd_known_wlan_action(const char *, nwam_action_t); 88 89 /* ENM functions */ 90 /* Init/fini functions for ENMs */ 91 extern void nwamd_init_enms(void); 92 extern void nwamd_fini_enms(void); 93 94 /* ENM condition check function */ 95 extern void nwamd_enm_check_conditions(void); 96 97 /* event methods */ 98 extern void nwamd_enm_handle_init_event(nwamd_event_t); 99 extern void nwamd_enm_handle_fini_event(nwamd_event_t); 100 101 /* enable/disable an enm */ 102 extern int nwamd_enm_action(const char *, nwam_action_t); 103 104 /* reread an enm from the repository */ 105 extern int nwamd_enm_refresh(const char *); 106 107 /* loc functions */ 108 /* Init/fini functions for locs */ 109 extern void nwamd_init_locs(void); 110 extern void nwamd_fini_locs(void); 111 112 /* loc condition check function */ 113 extern void nwamd_loc_check_conditions(void); 114 115 /* on shutdown, revert to legacy location */ 116 extern void nwamd_loc_revert_to_legacy(void); 117 118 /* event methods */ 119 extern void nwamd_loc_handle_init_event(nwamd_event_t); 120 extern void nwamd_loc_handle_fini_event(nwamd_event_t); 121 122 /* enable/disable a loc */ 123 extern int nwamd_loc_action(const char *, nwam_action_t); 124 125 /* reread a loc from the repository */ 126 extern int nwamd_loc_refresh(const char *); 127 128 /* NCU functions */ 129 extern void nwamd_init_ncus(void); 130 extern void nwamd_fini_ncus(void); 131 132 /* enable an ncp/ncu */ 133 extern int nwamd_ncp_action(const char *, nwam_action_t); 134 extern int nwamd_ncu_action(const char *, const char *, nwam_action_t); 135 136 /* 137 * Event callbacks. 138 */ 139 extern void nwamd_ncu_handle_init_event(nwamd_event_t); 140 extern void nwamd_ncu_handle_fini_event(nwamd_event_t); 141 extern void nwamd_ncu_handle_if_state_event(nwamd_event_t); 142 extern void nwamd_ncu_handle_if_action_event(nwamd_event_t); 143 extern void nwamd_ncu_handle_link_state_event(nwamd_event_t); 144 extern void nwamd_ncu_handle_link_action_event(nwamd_event_t); 145 extern void nwamd_ncu_handle_init_event(nwamd_event_t); 146 extern void nwamd_ncu_handle_fini_event(nwamd_event_t); 147 extern void nwamd_ncu_handle_action_event(nwamd_event_t); 148 extern void nwamd_ncu_handle_state_event(nwamd_event_t); 149 150 extern void nwamd_ncp_handle_action_event(nwamd_event_t); 151 extern void nwamd_ncp_handle_state_event(nwamd_event_t); 152 extern void nwamd_ncu_handle_periodic_scan_event(nwamd_event_t); 153 extern void nwamd_ncp_handle_enable_event(nwamd_event_t); 154 extern void nwamd_handle_upgrade(nwamd_event_t); 155 156 extern void nwamd_enm_handle_action_event(nwamd_event_t); 157 extern void nwamd_enm_handle_state_event(nwamd_event_t); 158 159 extern void nwamd_loc_handle_action_event(nwamd_event_t); 160 extern void nwamd_loc_handle_state_event(nwamd_event_t); 161 162 extern void nwamd_known_wlan_handle_action_event(nwamd_event_t); 163 164 extern void nwamd_add_phys_ncu_auto(nwam_ncp_handle_t, const char *); 165 extern void nwamd_rem_phys_ncu_auto(nwam_ncp_handle_t, const char *); 166 extern void add_auto_link(nwam_ncp_handle_t, const char *); 167 extern void add_auto_ip(nwam_ncp_handle_t, const char *); 168 extern void rem_auto_link(nwam_ncp_handle_t, const char *); 169 extern void rem_auto_ip(nwam_ncp_handle_t, const char *); 170 171 #endif /* _OBJECTS_H */ 172