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