xref: /titanic_41/usr/src/lib/libdladm/common/libdlbridge.h (revision a31148363f598def767ac48c5d82e1572e44b935)
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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _LIBDLBRIDGE_H
27 #define	_LIBDLBRIDGE_H
28 
29 /*
30  * This file includes structures, macros and routines used by bridge
31  * administration.
32  */
33 
34 #include <sys/types.h>
35 #include <libdladm.h>
36 #include <uid_stp.h>
37 #include <net/bridge.h>
38 #include <net/trill.h>
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 typedef enum {
45 	DLADM_BRIDGE_PROT_UNKNOWN = 0,	/* internal only */
46 	DLADM_BRIDGE_PROT_STP,
47 	DLADM_BRIDGE_PROT_TRILL
48 } dladm_bridge_prot_t;
49 
50 /* Utility functions to accept bridge protection options */
51 extern dladm_status_t	dladm_bridge_str2prot(const char *,
52     dladm_bridge_prot_t *);
53 extern const char	*dladm_bridge_prot2str(dladm_bridge_prot_t);
54 
55 /* Retrieve bridge properties from SMF */
56 extern dladm_status_t	dladm_bridge_get_properties(const char *,
57     UID_STP_CFG_T *, dladm_bridge_prot_t *);
58 extern dladm_status_t	dladm_bridge_run_properties(const char *,
59     UID_STP_CFG_T *, dladm_bridge_prot_t *);
60 
61 /* Create new bridge and configure SMF properties */
62 extern dladm_status_t	dladm_bridge_configure(dladm_handle_t, const char *,
63     const UID_STP_CFG_T *, dladm_bridge_prot_t, uint32_t);
64 
65 /* Enable a newly created bridge in SMF */
66 extern dladm_status_t	dladm_bridge_enable(const char *);
67 /* Delete a previously created bridge */
68 extern dladm_status_t	dladm_bridge_delete(dladm_handle_t, const char *,
69     uint32_t);
70 
71 /* Retrieve bridge state from running bridge daemon and get bridge port list */
72 extern dladm_status_t	dladm_bridge_state(const char *, UID_STP_STATE_T *);
73 extern datalink_id_t	*dladm_bridge_get_portlist(const char *, uint_t *);
74 extern void		dladm_bridge_free_portlist(datalink_id_t *);
75 
76 /* Set/remove bridge link membership and retreive bridge from member link */
77 extern dladm_status_t	dladm_bridge_setlink(dladm_handle_t, datalink_id_t,
78     const char *);
79 extern dladm_status_t	dladm_bridge_getlink(dladm_handle_t, datalink_id_t,
80     char *, size_t);
81 
82 /* Retrieve bridge port status */
83 extern dladm_status_t	dladm_bridge_link_state(dladm_handle_t, datalink_id_t,
84     UID_STP_PORT_STATE_T *);
85 /* Check valid bridge name */
86 extern boolean_t	dladm_valid_bridgename(const char *);
87 /* Convert bridge observability node name to bridge name */
88 extern boolean_t	dladm_observe_to_bridge(char *);
89 /* Retrieve bridge forwarding table entries */
90 extern bridge_listfwd_t	*dladm_bridge_get_fwdtable(dladm_handle_t, const char *,
91     uint_t *);
92 extern void		dladm_bridge_free_fwdtable(bridge_listfwd_t *);
93 
94 /* Retrive TRILL nicknames list */
95 extern trill_listnick_t *dladm_bridge_get_trillnick(const char *, uint_t *);
96 extern void		dladm_bridge_free_trillnick(trill_listnick_t *);
97 /* Store and retrieve TRILL nickname from TRILL SMF service configuration  */
98 extern uint16_t		dladm_bridge_get_nick(const char *);
99 extern void		dladm_bridge_set_nick(const char *, uint16_t);
100 /* Retrieve undocumented private properties from bridge SMF service config */
101 extern dladm_status_t	dladm_bridge_get_privprop(const char *,
102     boolean_t *, uint32_t *);
103 
104 /* Internal to libdladm */
105 extern dladm_status_t	dladm_bridge_get_port_cfg(dladm_handle_t, datalink_id_t,
106     int, int *);
107 extern dladm_status_t	dladm_bridge_get_forwarding(dladm_handle_t,
108     datalink_id_t, uint_t *);
109 extern dladm_status_t	dladm_bridge_refresh(dladm_handle_t, datalink_id_t);
110 
111 /* Bridge connection; used only between libdladm and bridged for status */
112 #define	DOOR_DIRNAME	"/var/run/bridge_door"
113 typedef enum bridge_door_type_e {
114 	bdcBridgeGetConfig,
115 	bdcBridgeGetState,
116 	bdcBridgeGetPorts,
117 	bdcBridgeGetRefreshCount,
118 	bdcPortGetConfig,
119 	bdcPortGetState,
120 	bdcPortGetForwarding
121 } bridge_door_type_t;
122 
123 typedef struct bridge_door_cmd_s {
124 	bridge_door_type_t bdc_type;
125 	datalink_id_t bdc_linkid;
126 } bridge_door_cmd_t;
127 
128 typedef struct bridge_door_cfg_s {
129 	UID_STP_CFG_T		bdcf_cfg;
130 	dladm_bridge_prot_t	bdcf_prot;
131 } bridge_door_cfg_t;
132 
133 #ifdef	__cplusplus
134 }
135 #endif
136 
137 #endif	/* _LIBDLBRIDGE_H */
138