1d62bc4baSyz147064 /* 2d62bc4baSyz147064 * CDDL HEADER START 3d62bc4baSyz147064 * 4d62bc4baSyz147064 * The contents of this file are subject to the terms of the 5d62bc4baSyz147064 * Common Development and Distribution License (the "License"). 6d62bc4baSyz147064 * You may not use this file except in compliance with the License. 7d62bc4baSyz147064 * 8d62bc4baSyz147064 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9d62bc4baSyz147064 * or http://www.opensolaris.org/os/licensing. 10d62bc4baSyz147064 * See the License for the specific language governing permissions 11d62bc4baSyz147064 * and limitations under the License. 12d62bc4baSyz147064 * 13d62bc4baSyz147064 * When distributing Covered Code, include this CDDL HEADER in each 14d62bc4baSyz147064 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15d62bc4baSyz147064 * If applicable, add the following below this CDDL HEADER, with the 16d62bc4baSyz147064 * fields enclosed by brackets "[]" replaced with your own identifying 17d62bc4baSyz147064 * information: Portions Copyright [yyyy] [name of copyright owner] 18d62bc4baSyz147064 * 19d62bc4baSyz147064 * CDDL HEADER END 20d62bc4baSyz147064 */ 21d62bc4baSyz147064 22d62bc4baSyz147064 /* 23*32715170SCathy Zhou * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 24d62bc4baSyz147064 */ 25d62bc4baSyz147064 26d62bc4baSyz147064 /* 27d62bc4baSyz147064 * Functions to maintain a table of datalink configuration information. 28d62bc4baSyz147064 */ 29d62bc4baSyz147064 30d62bc4baSyz147064 #ifndef _DLMGMT_IMPL_H 31d62bc4baSyz147064 #define _DLMGMT_IMPL_H 32d62bc4baSyz147064 33d62bc4baSyz147064 #ifdef __cplusplus 34d62bc4baSyz147064 extern "C" { 35d62bc4baSyz147064 #endif 36d62bc4baSyz147064 37d62bc4baSyz147064 #include <door.h> 38d62bc4baSyz147064 #include <libdllink.h> 3982a2fc47SJames Carlson #include <sys/avl.h> 40d62bc4baSyz147064 41d62bc4baSyz147064 /* 42d62bc4baSyz147064 * datalink attribute structure 43d62bc4baSyz147064 */ 44d62bc4baSyz147064 typedef struct dlmgmt_linkattr_s { 45d62bc4baSyz147064 struct dlmgmt_linkattr_s *lp_next; 46d62bc4baSyz147064 struct dlmgmt_linkattr_s *lp_prev; 47d62bc4baSyz147064 char lp_name[MAXLINKATTRLEN]; 48d62bc4baSyz147064 void *lp_val; 49d62bc4baSyz147064 dladm_datatype_t lp_type; 50d62bc4baSyz147064 uint_t lp_sz; 5162ee1d25SArtem Kachitchkine boolean_t lp_linkprop; 52d62bc4baSyz147064 } dlmgmt_linkattr_t; 53d62bc4baSyz147064 54d62bc4baSyz147064 /* 55d62bc4baSyz147064 * datalink structure 56d62bc4baSyz147064 */ 57d62bc4baSyz147064 typedef struct dlmgmt_link_s { 58d62bc4baSyz147064 dlmgmt_linkattr_t *ll_head; 59d62bc4baSyz147064 char ll_link[MAXLINKNAMELEN]; 60d62bc4baSyz147064 datalink_class_t ll_class; 61d62bc4baSyz147064 uint32_t ll_media; 62d62bc4baSyz147064 datalink_id_t ll_linkid; 632b24ab6bSSebastien Roy zoneid_t ll_zoneid; 642b24ab6bSSebastien Roy boolean_t ll_onloan; 652b24ab6bSSebastien Roy avl_node_t ll_name_node; 662b24ab6bSSebastien Roy avl_node_t ll_id_node; 672b24ab6bSSebastien Roy avl_node_t ll_loan_node; 68d62bc4baSyz147064 uint32_t ll_flags; 69d62bc4baSyz147064 uint32_t ll_gen; /* generation number */ 70d62bc4baSyz147064 } dlmgmt_link_t; 71d62bc4baSyz147064 72d62bc4baSyz147064 /* 73d62bc4baSyz147064 * datalink configuration request structure 74d62bc4baSyz147064 */ 75d62bc4baSyz147064 typedef struct dlmgmt_dlconf_s { 76d62bc4baSyz147064 dlmgmt_linkattr_t *ld_head; 77d62bc4baSyz147064 char ld_link[MAXLINKNAMELEN]; 78d62bc4baSyz147064 datalink_id_t ld_linkid; 79d62bc4baSyz147064 datalink_class_t ld_class; 80d62bc4baSyz147064 uint32_t ld_media; 81d62bc4baSyz147064 int ld_id; 822b24ab6bSSebastien Roy zoneid_t ld_zoneid; 83d62bc4baSyz147064 uint32_t ld_gen; 84d62bc4baSyz147064 avl_node_t ld_node; 85d62bc4baSyz147064 } dlmgmt_dlconf_t; 86d62bc4baSyz147064 87d62bc4baSyz147064 extern boolean_t debug; 88d62bc4baSyz147064 extern const char *progname; 892b24ab6bSSebastien Roy extern char cachefile[]; 904ac67f02SAnurag S. Maskey extern dladm_handle_t dld_handle; 912b24ab6bSSebastien Roy extern datalink_id_t dlmgmt_nextlinkid; 92d62bc4baSyz147064 extern avl_tree_t dlmgmt_name_avl; 93d62bc4baSyz147064 extern avl_tree_t dlmgmt_id_avl; 942b24ab6bSSebastien Roy extern avl_tree_t dlmgmt_loan_avl; 95d62bc4baSyz147064 extern avl_tree_t dlmgmt_dlconf_avl; 96d62bc4baSyz147064 97d62bc4baSyz147064 boolean_t linkattr_equal(dlmgmt_linkattr_t **, const char *, void *, 98d62bc4baSyz147064 size_t); 992b24ab6bSSebastien Roy dlmgmt_linkattr_t *linkattr_find(dlmgmt_linkattr_t *, const char *); 1002b24ab6bSSebastien Roy void linkattr_unset(dlmgmt_linkattr_t **, const char *); 101d62bc4baSyz147064 int linkattr_set(dlmgmt_linkattr_t **, const char *, void *, 102d62bc4baSyz147064 size_t, dladm_datatype_t); 103d62bc4baSyz147064 int linkattr_get(dlmgmt_linkattr_t **, const char *, void **, 104d62bc4baSyz147064 size_t *, dladm_datatype_t *); 105*32715170SCathy Zhou void linkattr_destroy(dlmgmt_link_t *); 106d62bc4baSyz147064 107d62bc4baSyz147064 void link_destroy(dlmgmt_link_t *); 1082b24ab6bSSebastien Roy int link_activate(dlmgmt_link_t *); 1092b24ab6bSSebastien Roy boolean_t link_is_visible(dlmgmt_link_t *, zoneid_t); 1102b24ab6bSSebastien Roy dlmgmt_link_t *link_by_id(datalink_id_t, zoneid_t); 1112b24ab6bSSebastien Roy dlmgmt_link_t *link_by_name(const char *, zoneid_t); 112d62bc4baSyz147064 int dlmgmt_create_common(const char *, datalink_class_t, 1132b24ab6bSSebastien Roy uint32_t, zoneid_t, uint32_t, dlmgmt_link_t **); 114d62bc4baSyz147064 int dlmgmt_destroy_common(dlmgmt_link_t *, uint32_t); 1152b24ab6bSSebastien Roy int dlmgmt_getattr_common(dlmgmt_linkattr_t **, const char *, 116024b0a25Sseb dlmgmt_getattr_retval_t *); 117d62bc4baSyz147064 118d62bc4baSyz147064 void dlmgmt_advance(dlmgmt_link_t *); 119d62bc4baSyz147064 void dlmgmt_table_lock(boolean_t); 120d62bc4baSyz147064 void dlmgmt_table_unlock(); 121d62bc4baSyz147064 122d62bc4baSyz147064 int dlconf_create(const char *, datalink_id_t, datalink_class_t, 1232b24ab6bSSebastien Roy uint32_t, zoneid_t, dlmgmt_dlconf_t **); 124d62bc4baSyz147064 void dlconf_destroy(dlmgmt_dlconf_t *); 125d62bc4baSyz147064 void dlmgmt_advance_dlconfid(dlmgmt_dlconf_t *); 126d62bc4baSyz147064 void dlmgmt_dlconf_table_lock(boolean_t); 127d62bc4baSyz147064 void dlmgmt_dlconf_table_unlock(void); 128d62bc4baSyz147064 1292b24ab6bSSebastien Roy int dlmgmt_generate_name(const char *, char *, size_t, zoneid_t); 130d62bc4baSyz147064 1312b24ab6bSSebastien Roy void dlmgmt_linktable_init(void); 132d62bc4baSyz147064 void dlmgmt_linktable_fini(void); 133d62bc4baSyz147064 1342b24ab6bSSebastien Roy int dlmgmt_zone_init(zoneid_t); 1352b24ab6bSSebastien Roy int dlmgmt_elevate_privileges(void); 1362b24ab6bSSebastien Roy int dlmgmt_drop_privileges(); 137d62bc4baSyz147064 void dlmgmt_handler(void *, char *, size_t, door_desc_t *, uint_t); 138d62bc4baSyz147064 void dlmgmt_log(int, const char *, ...); 1392b24ab6bSSebastien Roy int dlmgmt_write_db_entry(const char *, dlmgmt_link_t *, uint32_t); 1402b24ab6bSSebastien Roy int dlmgmt_delete_db_entry(dlmgmt_link_t *, uint32_t); 1412b24ab6bSSebastien Roy int dlmgmt_db_init(zoneid_t); 1422b24ab6bSSebastien Roy void dlmgmt_db_fini(zoneid_t); 143b9e076dcSyz147064 144d62bc4baSyz147064 #ifdef __cplusplus 145d62bc4baSyz147064 } 146d62bc4baSyz147064 #endif 147d62bc4baSyz147064 148d62bc4baSyz147064 #endif /* _DLMGMT_IMPL_H */ 149