1 0 stevel /* 2 0 stevel * CDDL HEADER START 3 0 stevel * 4 0 stevel * The contents of this file are subject to the terms of the 5 2311 seb * Common Development and Distribution License (the "License"). 6 2311 seb * You may not use this file except in compliance with the License. 7 0 stevel * 8 0 stevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 0 stevel * or http://www.opensolaris.org/os/licensing. 10 0 stevel * See the License for the specific language governing permissions 11 0 stevel * and limitations under the License. 12 0 stevel * 13 0 stevel * When distributing Covered Code, include this CDDL HEADER in each 14 0 stevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 0 stevel * If applicable, add the following below this CDDL HEADER, with the 16 0 stevel * fields enclosed by brackets "[]" replaced with your own identifying 17 0 stevel * information: Portions Copyright [yyyy] [name of copyright owner] 18 0 stevel * 19 0 stevel * CDDL HEADER END 20 0 stevel */ 21 0 stevel /* 22 9055 Michael * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 0 stevel * Use is subject to license terms. 24 0 stevel */ 25 0 stevel 26 0 stevel #ifndef _LIBDLADM_H 27 0 stevel #define _LIBDLADM_H 28 5895 yz147064 29 8275 Eric #include <sys/dls_mgmt.h> 30 10734 Eric #include <sys/dld.h> 31 5895 yz147064 #include <sys/dlpi.h> 32 0 stevel 33 3871 yz147064 /* 34 3871 yz147064 * This file includes structures, macros and common routines shared by all 35 3871 yz147064 * data-link administration, and routines which do not directly administrate 36 3871 yz147064 * links. For example, dladm_status2str(). 37 3871 yz147064 */ 38 0 stevel 39 0 stevel #ifdef __cplusplus 40 0 stevel extern "C" { 41 0 stevel #endif 42 0 stevel 43 5895 yz147064 #define LINKID_STR_WIDTH 10 44 3147 xc151355 #define DLADM_STRSIZE 256 45 5895 yz147064 46 5895 yz147064 /* 47 5895 yz147064 * option flags taken by the libdladm functions 48 5895 yz147064 * 49 5895 yz147064 * - DLADM_OPT_ACTIVE: 50 5895 yz147064 * The function requests to bringup some configuration that only take 51 5895 yz147064 * effect on active system (not persistent). 52 5895 yz147064 * 53 5895 yz147064 * - DLADM_OPT_PERSIST: 54 5895 yz147064 * The function requests to persist some configuration. 55 5895 yz147064 * 56 5895 yz147064 * - DLADM_OPT_CREATE: 57 5895 yz147064 * Today, only used by dladm_set_secobj() - requests to create a secobj. 58 5895 yz147064 * 59 5895 yz147064 * - DLADM_OPT_FORCE: 60 5895 yz147064 * The function requests to execute a specific operation forcefully. 61 5895 yz147064 * 62 5895 yz147064 * - DLADM_OPT_PREFIX: 63 5895 yz147064 * The function requests to generate a link name using the specified prefix. 64 8275 Eric * 65 8275 Eric * - DLADM_OPT_VLAN: 66 8275 Eric * Signifies VLAN creation code path 67 8275 Eric * 68 8275 Eric * - DLADM_OPT_HWRINGS: 69 8275 Eric * Requires a hardware group of rings when creating a vnic. 70 10491 Rishi * 71 10491 Rishi * - DLADM_OPT_NOREFRESH: 72 10491 Rishi * Do not refresh the daemon after setting parameter (used by STP mcheck). 73 5895 yz147064 */ 74 5895 yz147064 #define DLADM_OPT_ACTIVE 0x00000001 75 5895 yz147064 #define DLADM_OPT_PERSIST 0x00000002 76 5895 yz147064 #define DLADM_OPT_CREATE 0x00000004 77 5895 yz147064 #define DLADM_OPT_FORCE 0x00000008 78 5895 yz147064 #define DLADM_OPT_PREFIX 0x00000010 79 8275 Eric #define DLADM_OPT_ANCHOR 0x00000020 80 8275 Eric #define DLADM_OPT_VLAN 0x00000040 81 8275 Eric #define DLADM_OPT_HWRINGS 0x00000080 82 10491 Rishi #define DLADM_OPT_NOREFRESH 0x00000100 83 5895 yz147064 84 5895 yz147064 #define DLADM_WALK_TERMINATE 0 85 5895 yz147064 #define DLADM_WALK_CONTINUE -1 86 8275 Eric 87 8275 Eric #define DLADM_MAX_ARG_CNT 32 88 8275 Eric #define DLADM_MAX_ARG_VALS 32 89 3147 xc151355 90 3147 xc151355 typedef enum { 91 3147 xc151355 DLADM_STATUS_OK = 0, 92 3147 xc151355 DLADM_STATUS_BADARG, 93 3147 xc151355 DLADM_STATUS_FAILED, 94 3147 xc151355 DLADM_STATUS_TOOSMALL, 95 3147 xc151355 DLADM_STATUS_NOTSUP, 96 3147 xc151355 DLADM_STATUS_NOTFOUND, 97 3147 xc151355 DLADM_STATUS_BADVAL, 98 3147 xc151355 DLADM_STATUS_NOMEM, 99 3147 xc151355 DLADM_STATUS_EXIST, 100 3147 xc151355 DLADM_STATUS_LINKINVAL, 101 3147 xc151355 DLADM_STATUS_PROPRDONLY, 102 3147 xc151355 DLADM_STATUS_BADVALCNT, 103 3147 xc151355 DLADM_STATUS_DBNOTFOUND, 104 3147 xc151355 DLADM_STATUS_DENIED, 105 3448 dh155122 DLADM_STATUS_IOERR, 106 3871 yz147064 DLADM_STATUS_TEMPONLY, 107 3871 yz147064 DLADM_STATUS_TIMEDOUT, 108 3871 yz147064 DLADM_STATUS_ISCONN, 109 3871 yz147064 DLADM_STATUS_NOTCONN, 110 3871 yz147064 DLADM_STATUS_REPOSITORYINVAL, 111 3871 yz147064 DLADM_STATUS_MACADDRINVAL, 112 5084 johnlev DLADM_STATUS_KEYINVAL, 113 5084 johnlev DLADM_STATUS_INVALIDMACADDRLEN, 114 5084 johnlev DLADM_STATUS_INVALIDMACADDRTYPE, 115 5895 yz147064 DLADM_STATUS_LINKBUSY, 116 5895 yz147064 DLADM_STATUS_VIDINVAL, 117 5895 yz147064 DLADM_STATUS_NONOTIF, 118 7776 Sowmini DLADM_STATUS_TRYAGAIN, 119 10616 Sebastien DLADM_STATUS_IPTUNTYPE, 120 10616 Sebastien DLADM_STATUS_IPTUNTYPEREQD, 121 10616 Sebastien DLADM_STATUS_BADIPTUNLADDR, 122 10616 Sebastien DLADM_STATUS_BADIPTUNRADDR, 123 10616 Sebastien DLADM_STATUS_ADDRINUSE, 124 8275 Eric DLADM_STATUS_BADTIMEVAL, 125 8275 Eric DLADM_STATUS_INVALIDMACADDR, 126 8275 Eric DLADM_STATUS_INVALIDMACADDRNIC, 127 8275 Eric DLADM_STATUS_INVALIDMACADDRINUSE, 128 8275 Eric DLADM_STATUS_MACFACTORYSLOTINVALID, 129 8275 Eric DLADM_STATUS_MACFACTORYSLOTUSED, 130 8275 Eric DLADM_STATUS_MACFACTORYSLOTALLUSED, 131 8275 Eric DLADM_STATUS_MACFACTORYNOTSUP, 132 8275 Eric DLADM_STATUS_INVALIDMACPREFIX, 133 8275 Eric DLADM_STATUS_INVALIDMACPREFIXLEN, 134 8275 Eric DLADM_STATUS_CPUMAX, 135 8275 Eric DLADM_STATUS_CPUERR, 136 8275 Eric DLADM_STATUS_CPUNOTONLINE, 137 8275 Eric DLADM_STATUS_DB_NOTFOUND, 138 8275 Eric DLADM_STATUS_DB_PARSE_ERR, 139 8275 Eric DLADM_STATUS_PROP_PARSE_ERR, 140 8275 Eric DLADM_STATUS_ATTR_PARSE_ERR, 141 8275 Eric DLADM_STATUS_FLOW_DB_ERR, 142 8275 Eric DLADM_STATUS_FLOW_DB_OPEN_ERR, 143 8275 Eric DLADM_STATUS_FLOW_DB_PARSE_ERR, 144 8275 Eric DLADM_STATUS_FLOWPROP_DB_PARSE_ERR, 145 8275 Eric DLADM_STATUS_FLOW_ADD_ERR, 146 8275 Eric DLADM_STATUS_FLOW_WALK_ERR, 147 8275 Eric DLADM_STATUS_FLOW_IDENTICAL, 148 8275 Eric DLADM_STATUS_FLOW_INCOMPATIBLE, 149 8275 Eric DLADM_STATUS_FLOW_EXISTS, 150 8275 Eric DLADM_STATUS_PERSIST_FLOW_EXISTS, 151 8275 Eric DLADM_STATUS_INVALID_IP, 152 8275 Eric DLADM_STATUS_INVALID_PREFIXLEN, 153 8275 Eric DLADM_STATUS_INVALID_PROTOCOL, 154 8275 Eric DLADM_STATUS_INVALID_PORT, 155 8275 Eric DLADM_STATUS_INVALID_DSF, 156 8275 Eric DLADM_STATUS_INVALID_DSFMASK, 157 8275 Eric DLADM_STATUS_INVALID_MACMARGIN, 158 8275 Eric DLADM_STATUS_NOTDEFINED, 159 8275 Eric DLADM_STATUS_BADPROP, 160 8275 Eric DLADM_STATUS_MINMAXBW, 161 10491 Rishi DLADM_STATUS_NO_HWRINGS, 162 10491 Rishi DLADM_STATUS_PERMONLY, 163 10491 Rishi DLADM_STATUS_OPTMISSING 164 3147 xc151355 } dladm_status_t; 165 3147 xc151355 166 3147 xc151355 typedef enum { 167 5895 yz147064 DLADM_TYPE_STR, 168 5895 yz147064 DLADM_TYPE_BOOLEAN, 169 5895 yz147064 DLADM_TYPE_UINT64 170 5895 yz147064 } dladm_datatype_t; 171 5895 yz147064 172 5895 yz147064 typedef int dladm_conf_t; 173 5895 yz147064 #define DLADM_INVALID_CONF 0 174 3147 xc151355 175 8453 Anurag /* opaque dladm handle to libdladm functions */ 176 8453 Anurag struct dladm_handle; 177 8453 Anurag typedef struct dladm_handle *dladm_handle_t; 178 8453 Anurag 179 8453 Anurag /* open/close handle */ 180 8453 Anurag extern dladm_status_t dladm_open(dladm_handle_t *); 181 8453 Anurag extern void dladm_close(dladm_handle_t); 182 8453 Anurag 183 8453 Anurag /* 184 8453 Anurag * retrieve the dld file descriptor from handle, only libdladm and 185 8453 Anurag * dlmgmtd are given access to the door file descriptor. 186 8453 Anurag */ 187 8453 Anurag extern int dladm_dld_fd(dladm_handle_t); 188 8453 Anurag 189 8275 Eric typedef struct dladm_arg_info { 190 8275 Eric const char *ai_name; 191 8275 Eric char *ai_val[DLADM_MAX_ARG_VALS]; 192 8275 Eric uint_t ai_count; 193 8275 Eric } dladm_arg_info_t; 194 8275 Eric 195 8275 Eric typedef struct dladm_arg_list { 196 8275 Eric dladm_arg_info_t al_info[DLADM_MAX_ARG_CNT]; 197 8275 Eric uint_t al_count; 198 8275 Eric char *al_buf; 199 8275 Eric } dladm_arg_list_t; 200 8275 Eric 201 8275 Eric typedef enum { 202 8275 Eric DLADM_LOGTYPE_LINK = 1, 203 8275 Eric DLADM_LOGTYPE_FLOW 204 8275 Eric } dladm_logtype_t; 205 8275 Eric 206 8275 Eric typedef struct dladm_usage { 207 8275 Eric char du_name[MAXLINKNAMELEN]; 208 8275 Eric uint64_t du_duration; 209 8275 Eric uint64_t du_stime; 210 8275 Eric uint64_t du_etime; 211 8275 Eric uint64_t du_ipackets; 212 8275 Eric uint64_t du_rbytes; 213 8275 Eric uint64_t du_opackets; 214 8275 Eric uint64_t du_obytes; 215 8275 Eric uint64_t du_bandwidth; 216 8275 Eric boolean_t du_last; 217 8275 Eric } dladm_usage_t; 218 8275 Eric 219 3147 xc151355 extern const char *dladm_status2str(dladm_status_t, char *); 220 3871 yz147064 extern dladm_status_t dladm_set_rootdir(const char *); 221 5895 yz147064 extern const char *dladm_class2str(datalink_class_t, char *); 222 5895 yz147064 extern const char *dladm_media2str(uint32_t, char *); 223 9815 Rishi extern uint32_t dladm_str2media(const char *); 224 5895 yz147064 extern boolean_t dladm_valid_linkname(const char *); 225 9055 Michael extern boolean_t dladm_str2interval(char *, uint32_t *); 226 8275 Eric extern dladm_status_t dladm_str2bw(char *, uint64_t *); 227 8275 Eric extern const char *dladm_bw2str(int64_t, char *); 228 10734 Eric extern dladm_status_t dladm_str2pri(char *, mac_priority_level_t *); 229 10734 Eric extern const char *dladm_pri2str(mac_priority_level_t, char *); 230 10734 Eric extern dladm_status_t dladm_str2protect(char *, uint32_t *); 231 10734 Eric extern const char *dladm_protect2str(uint32_t, char *); 232 10734 Eric extern dladm_status_t dladm_str2ipv4addr(char *, void *); 233 10734 Eric extern const char *dladm_ipv4addr2str(void *, char *); 234 8275 Eric 235 8275 Eric extern dladm_status_t dladm_parse_flow_props(char *, dladm_arg_list_t **, 236 8275 Eric boolean_t); 237 8275 Eric extern dladm_status_t dladm_parse_link_props(char *, dladm_arg_list_t **, 238 8275 Eric boolean_t); 239 8275 Eric extern void dladm_free_props(dladm_arg_list_t *); 240 8275 Eric extern dladm_status_t dladm_parse_flow_attrs(char *, dladm_arg_list_t **, 241 8275 Eric boolean_t); 242 8275 Eric extern void dladm_free_attrs(dladm_arg_list_t *); 243 8275 Eric 244 8453 Anurag extern dladm_status_t dladm_start_usagelog(dladm_handle_t, dladm_logtype_t, 245 8453 Anurag uint_t); 246 8453 Anurag extern dladm_status_t dladm_stop_usagelog(dladm_handle_t, dladm_logtype_t); 247 8275 Eric extern dladm_status_t dladm_walk_usage_res(int (*)(dladm_usage_t *, void *), 248 8275 Eric int, char *, char *, char *, char *, void *); 249 8275 Eric extern dladm_status_t dladm_walk_usage_time(int (*)(dladm_usage_t *, void *), 250 8275 Eric int, char *, char *, char *, void *); 251 8275 Eric extern dladm_status_t dladm_usage_summary(int (*)(dladm_usage_t *, void *), 252 8275 Eric int, char *, void *); 253 8275 Eric extern dladm_status_t dladm_usage_dates(int (*)(dladm_usage_t *, void *), 254 8275 Eric int, char *, char *, void *); 255 10616 Sebastien extern dladm_status_t dladm_zone_boot(dladm_handle_t, zoneid_t); 256 10616 Sebastien extern dladm_status_t dladm_zone_halt(dladm_handle_t, zoneid_t); 257 0 stevel 258 0 stevel #ifdef __cplusplus 259 0 stevel } 260 0 stevel #endif 261 0 stevel 262 0 stevel #endif /* _LIBDLADM_H */ 263