1*4eaa4710SRishi Srivatsavai /* 2*4eaa4710SRishi Srivatsavai * CDDL HEADER START 3*4eaa4710SRishi Srivatsavai * 4*4eaa4710SRishi Srivatsavai * The contents of this file are subject to the terms of the 5*4eaa4710SRishi Srivatsavai * Common Development and Distribution License (the "License"). 6*4eaa4710SRishi Srivatsavai * You may not use this file except in compliance with the License. 7*4eaa4710SRishi Srivatsavai * 8*4eaa4710SRishi Srivatsavai * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*4eaa4710SRishi Srivatsavai * or http://www.opensolaris.org/os/licensing. 10*4eaa4710SRishi Srivatsavai * See the License for the specific language governing permissions 11*4eaa4710SRishi Srivatsavai * and limitations under the License. 12*4eaa4710SRishi Srivatsavai * 13*4eaa4710SRishi Srivatsavai * When distributing Covered Code, include this CDDL HEADER in each 14*4eaa4710SRishi Srivatsavai * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*4eaa4710SRishi Srivatsavai * If applicable, add the following below this CDDL HEADER, with the 16*4eaa4710SRishi Srivatsavai * fields enclosed by brackets "[]" replaced with your own identifying 17*4eaa4710SRishi Srivatsavai * information: Portions Copyright [yyyy] [name of copyright owner] 18*4eaa4710SRishi Srivatsavai * 19*4eaa4710SRishi Srivatsavai * CDDL HEADER END 20*4eaa4710SRishi Srivatsavai */ 21*4eaa4710SRishi Srivatsavai /* 22*4eaa4710SRishi Srivatsavai * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23*4eaa4710SRishi Srivatsavai * Use is subject to license terms. 24*4eaa4710SRishi Srivatsavai */ 25*4eaa4710SRishi Srivatsavai 26*4eaa4710SRishi Srivatsavai #ifndef _LIBDLBRIDGE_H 27*4eaa4710SRishi Srivatsavai #define _LIBDLBRIDGE_H 28*4eaa4710SRishi Srivatsavai 29*4eaa4710SRishi Srivatsavai /* 30*4eaa4710SRishi Srivatsavai * This file includes structures, macros and routines used by bridge 31*4eaa4710SRishi Srivatsavai * administration. 32*4eaa4710SRishi Srivatsavai */ 33*4eaa4710SRishi Srivatsavai 34*4eaa4710SRishi Srivatsavai #include <sys/types.h> 35*4eaa4710SRishi Srivatsavai #include <libdladm.h> 36*4eaa4710SRishi Srivatsavai #include <uid_stp.h> 37*4eaa4710SRishi Srivatsavai #include <net/bridge.h> 38*4eaa4710SRishi Srivatsavai #include <net/trill.h> 39*4eaa4710SRishi Srivatsavai 40*4eaa4710SRishi Srivatsavai #ifdef __cplusplus 41*4eaa4710SRishi Srivatsavai extern "C" { 42*4eaa4710SRishi Srivatsavai #endif 43*4eaa4710SRishi Srivatsavai 44*4eaa4710SRishi Srivatsavai typedef enum { 45*4eaa4710SRishi Srivatsavai DLADM_BRIDGE_PROT_UNKNOWN = 0, /* internal only */ 46*4eaa4710SRishi Srivatsavai DLADM_BRIDGE_PROT_STP, 47*4eaa4710SRishi Srivatsavai DLADM_BRIDGE_PROT_TRILL 48*4eaa4710SRishi Srivatsavai } dladm_bridge_prot_t; 49*4eaa4710SRishi Srivatsavai 50*4eaa4710SRishi Srivatsavai /* Utility functions to accept bridge protection options */ 51*4eaa4710SRishi Srivatsavai extern dladm_status_t dladm_bridge_str2prot(const char *, 52*4eaa4710SRishi Srivatsavai dladm_bridge_prot_t *); 53*4eaa4710SRishi Srivatsavai extern const char *dladm_bridge_prot2str(dladm_bridge_prot_t); 54*4eaa4710SRishi Srivatsavai 55*4eaa4710SRishi Srivatsavai /* Retrieve bridge properties from SMF */ 56*4eaa4710SRishi Srivatsavai extern dladm_status_t dladm_bridge_get_properties(const char *, 57*4eaa4710SRishi Srivatsavai UID_STP_CFG_T *, dladm_bridge_prot_t *); 58*4eaa4710SRishi Srivatsavai extern dladm_status_t dladm_bridge_run_properties(const char *, 59*4eaa4710SRishi Srivatsavai UID_STP_CFG_T *, dladm_bridge_prot_t *); 60*4eaa4710SRishi Srivatsavai 61*4eaa4710SRishi Srivatsavai /* Create new bridge and configure SMF properties */ 62*4eaa4710SRishi Srivatsavai extern dladm_status_t dladm_bridge_configure(dladm_handle_t, const char *, 63*4eaa4710SRishi Srivatsavai const UID_STP_CFG_T *, dladm_bridge_prot_t, uint32_t); 64*4eaa4710SRishi Srivatsavai 65*4eaa4710SRishi Srivatsavai /* Enable a newly created bridge in SMF */ 66*4eaa4710SRishi Srivatsavai extern dladm_status_t dladm_bridge_enable(const char *); 67*4eaa4710SRishi Srivatsavai /* Delete a previously created bridge */ 68*4eaa4710SRishi Srivatsavai extern dladm_status_t dladm_bridge_delete(dladm_handle_t, const char *, 69*4eaa4710SRishi Srivatsavai uint32_t); 70*4eaa4710SRishi Srivatsavai 71*4eaa4710SRishi Srivatsavai /* Retrieve bridge state from running bridge daemon and get bridge port list */ 72*4eaa4710SRishi Srivatsavai extern dladm_status_t dladm_bridge_state(const char *, UID_STP_STATE_T *); 73*4eaa4710SRishi Srivatsavai extern datalink_id_t *dladm_bridge_get_portlist(const char *, uint_t *); 74*4eaa4710SRishi Srivatsavai extern void dladm_bridge_free_portlist(datalink_id_t *); 75*4eaa4710SRishi Srivatsavai 76*4eaa4710SRishi Srivatsavai /* Set/remove bridge link membership and retreive bridge from member link */ 77*4eaa4710SRishi Srivatsavai extern dladm_status_t dladm_bridge_setlink(dladm_handle_t, datalink_id_t, 78*4eaa4710SRishi Srivatsavai const char *); 79*4eaa4710SRishi Srivatsavai extern dladm_status_t dladm_bridge_getlink(dladm_handle_t, datalink_id_t, 80*4eaa4710SRishi Srivatsavai char *, size_t); 81*4eaa4710SRishi Srivatsavai 82*4eaa4710SRishi Srivatsavai /* Retrieve bridge port status */ 83*4eaa4710SRishi Srivatsavai extern dladm_status_t dladm_bridge_link_state(dladm_handle_t, datalink_id_t, 84*4eaa4710SRishi Srivatsavai UID_STP_PORT_STATE_T *); 85*4eaa4710SRishi Srivatsavai /* Check valid bridge name */ 86*4eaa4710SRishi Srivatsavai extern boolean_t dladm_valid_bridgename(const char *); 87*4eaa4710SRishi Srivatsavai /* Convert bridge observability node name to bridge name */ 88*4eaa4710SRishi Srivatsavai extern boolean_t dladm_observe_to_bridge(char *); 89*4eaa4710SRishi Srivatsavai /* Retrieve bridge forwarding table entries */ 90*4eaa4710SRishi Srivatsavai extern bridge_listfwd_t *dladm_bridge_get_fwdtable(dladm_handle_t, const char *, 91*4eaa4710SRishi Srivatsavai uint_t *); 92*4eaa4710SRishi Srivatsavai extern void dladm_bridge_free_fwdtable(bridge_listfwd_t *); 93*4eaa4710SRishi Srivatsavai 94*4eaa4710SRishi Srivatsavai /* Retrive TRILL nicknames list */ 95*4eaa4710SRishi Srivatsavai extern trill_listnick_t *dladm_bridge_get_trillnick(const char *, uint_t *); 96*4eaa4710SRishi Srivatsavai extern void dladm_bridge_free_trillnick(trill_listnick_t *); 97*4eaa4710SRishi Srivatsavai /* Store and retrieve TRILL nickname from TRILL SMF service configuration */ 98*4eaa4710SRishi Srivatsavai extern uint16_t dladm_bridge_get_nick(const char *); 99*4eaa4710SRishi Srivatsavai extern void dladm_bridge_set_nick(const char *, uint16_t); 100*4eaa4710SRishi Srivatsavai /* Retrieve undocumented private properties from bridge SMF service config */ 101*4eaa4710SRishi Srivatsavai extern dladm_status_t dladm_bridge_get_privprop(const char *, 102*4eaa4710SRishi Srivatsavai boolean_t *, uint32_t *); 103*4eaa4710SRishi Srivatsavai 104*4eaa4710SRishi Srivatsavai /* Internal to libdladm */ 105*4eaa4710SRishi Srivatsavai extern dladm_status_t dladm_bridge_get_port_cfg(dladm_handle_t, datalink_id_t, 106*4eaa4710SRishi Srivatsavai int, int *); 107*4eaa4710SRishi Srivatsavai extern dladm_status_t dladm_bridge_get_forwarding(dladm_handle_t, 108*4eaa4710SRishi Srivatsavai datalink_id_t, uint_t *); 109*4eaa4710SRishi Srivatsavai extern dladm_status_t dladm_bridge_refresh(dladm_handle_t, datalink_id_t); 110*4eaa4710SRishi Srivatsavai 111*4eaa4710SRishi Srivatsavai /* Bridge connection; used only between libdladm and bridged for status */ 112*4eaa4710SRishi Srivatsavai #define DOOR_DIRNAME "/var/run/bridge_door" 113*4eaa4710SRishi Srivatsavai typedef enum bridge_door_type_e { 114*4eaa4710SRishi Srivatsavai bdcBridgeGetConfig, 115*4eaa4710SRishi Srivatsavai bdcBridgeGetState, 116*4eaa4710SRishi Srivatsavai bdcBridgeGetPorts, 117*4eaa4710SRishi Srivatsavai bdcBridgeGetRefreshCount, 118*4eaa4710SRishi Srivatsavai bdcPortGetConfig, 119*4eaa4710SRishi Srivatsavai bdcPortGetState, 120*4eaa4710SRishi Srivatsavai bdcPortGetForwarding 121*4eaa4710SRishi Srivatsavai } bridge_door_type_t; 122*4eaa4710SRishi Srivatsavai 123*4eaa4710SRishi Srivatsavai typedef struct bridge_door_cmd_s { 124*4eaa4710SRishi Srivatsavai bridge_door_type_t bdc_type; 125*4eaa4710SRishi Srivatsavai datalink_id_t bdc_linkid; 126*4eaa4710SRishi Srivatsavai } bridge_door_cmd_t; 127*4eaa4710SRishi Srivatsavai 128*4eaa4710SRishi Srivatsavai typedef struct bridge_door_cfg_s { 129*4eaa4710SRishi Srivatsavai UID_STP_CFG_T bdcf_cfg; 130*4eaa4710SRishi Srivatsavai dladm_bridge_prot_t bdcf_prot; 131*4eaa4710SRishi Srivatsavai } bridge_door_cfg_t; 132*4eaa4710SRishi Srivatsavai 133*4eaa4710SRishi Srivatsavai #ifdef __cplusplus 134*4eaa4710SRishi Srivatsavai } 135*4eaa4710SRishi Srivatsavai #endif 136*4eaa4710SRishi Srivatsavai 137*4eaa4710SRishi Srivatsavai #endif /* _LIBDLBRIDGE_H */ 138