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 /*
23*4eaa4710SRishi Srivatsavai  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24*4eaa4710SRishi Srivatsavai  * Use is subject to license terms.
25*4eaa4710SRishi Srivatsavai  */
26*4eaa4710SRishi Srivatsavai 
27*4eaa4710SRishi Srivatsavai #ifndef _BRIDGED_GLOBAL_H
28*4eaa4710SRishi Srivatsavai #define	_BRIDGED_GLOBAL_H
29*4eaa4710SRishi Srivatsavai 
30*4eaa4710SRishi Srivatsavai /*
31*4eaa4710SRishi Srivatsavai  * Globally visible symbols within the "bridged" bridging daemon
32*4eaa4710SRishi Srivatsavai  */
33*4eaa4710SRishi Srivatsavai 
34*4eaa4710SRishi Srivatsavai #include <sys/types.h>
35*4eaa4710SRishi Srivatsavai #include <sys/ethernet.h>
36*4eaa4710SRishi Srivatsavai #include <net/bridge.h>
37*4eaa4710SRishi Srivatsavai #include <libdlpi.h>
38*4eaa4710SRishi Srivatsavai #include <libdladm.h>
39*4eaa4710SRishi Srivatsavai #include <libdlbridge.h>
40*4eaa4710SRishi Srivatsavai 
41*4eaa4710SRishi Srivatsavai #ifdef __cplusplus
42*4eaa4710SRishi Srivatsavai extern "C" {
43*4eaa4710SRishi Srivatsavai #endif
44*4eaa4710SRishi Srivatsavai 
45*4eaa4710SRishi Srivatsavai struct portdata {
46*4eaa4710SRishi Srivatsavai 	int vlan_id;
47*4eaa4710SRishi Srivatsavai 	int port_index;
48*4eaa4710SRishi Srivatsavai 	unsigned int speed;
49*4eaa4710SRishi Srivatsavai 	boolean_t phys_status;		/* physical layer status */
50*4eaa4710SRishi Srivatsavai 	boolean_t admin_status;		/* administrative status */
51*4eaa4710SRishi Srivatsavai 	boolean_t kern_added;		/* set when added to kernel bridge */
52*4eaa4710SRishi Srivatsavai 	boolean_t stp_added;		/* set when added to STP machine */
53*4eaa4710SRishi Srivatsavai 	boolean_t referenced;		/* used for refresh */
54*4eaa4710SRishi Srivatsavai 	boolean_t sdu_failed;		/* set for non-matching max SDU */
55*4eaa4710SRishi Srivatsavai 	boolean_t admin_non_stp;	/* copy of STP library config */
56*4eaa4710SRishi Srivatsavai 	boolean_t bpdu_protect;		/* BPDU seen when non-STP */
57*4eaa4710SRishi Srivatsavai 	bridge_state_t state;
58*4eaa4710SRishi Srivatsavai 	dlpi_handle_t dlpi;
59*4eaa4710SRishi Srivatsavai 	dlpi_notifyid_t notifyid;
60*4eaa4710SRishi Srivatsavai 	datalink_id_t linkid;
61*4eaa4710SRishi Srivatsavai 	const char *name;
62*4eaa4710SRishi Srivatsavai 	uchar_t mac_addr[ETHERADDRL];
63*4eaa4710SRishi Srivatsavai };
64*4eaa4710SRishi Srivatsavai 
65*4eaa4710SRishi Srivatsavai /* Number of reserved (internal) fdarray entries */
66*4eaa4710SRishi Srivatsavai #define	FDOFFSET	2
67*4eaa4710SRishi Srivatsavai 
68*4eaa4710SRishi Srivatsavai /* main.c */
69*4eaa4710SRishi Srivatsavai extern int lock_engine(void);
70*4eaa4710SRishi Srivatsavai extern void unlock_engine(void);
71*4eaa4710SRishi Srivatsavai extern ssize_t strioctl(int, int, void *, size_t);
72*4eaa4710SRishi Srivatsavai extern struct portdata *find_by_linkid(datalink_id_t);
73*4eaa4710SRishi Srivatsavai extern void get_dladm_speed(struct portdata *);
74*4eaa4710SRishi Srivatsavai extern void enable_forwarding(struct portdata *);
75*4eaa4710SRishi Srivatsavai extern boolean_t debugging;
76*4eaa4710SRishi Srivatsavai extern uint32_t tablemax;
77*4eaa4710SRishi Srivatsavai extern const char *instance_name;
78*4eaa4710SRishi Srivatsavai extern dladm_handle_t dlhandle;
79*4eaa4710SRishi Srivatsavai extern boolean_t shutting_down;
80*4eaa4710SRishi Srivatsavai extern struct pollfd *fdarray;
81*4eaa4710SRishi Srivatsavai 
82*4eaa4710SRishi Srivatsavai /* door.c */
83*4eaa4710SRishi Srivatsavai extern void init_door(void);
84*4eaa4710SRishi Srivatsavai 
85*4eaa4710SRishi Srivatsavai /* dlpi.c */
86*4eaa4710SRishi Srivatsavai extern boolean_t port_dlpi_open(const char *, struct portdata *,
87*4eaa4710SRishi Srivatsavai     datalink_class_t);
88*4eaa4710SRishi Srivatsavai 
89*4eaa4710SRishi Srivatsavai /* rstp.c */
90*4eaa4710SRishi Srivatsavai extern void rstp_init(void);
91*4eaa4710SRishi Srivatsavai extern void rstp_refresh(void);
92*4eaa4710SRishi Srivatsavai extern void rstp_change_mac(struct portdata *, const unsigned char *);
93*4eaa4710SRishi Srivatsavai extern boolean_t rstp_add_port(struct portdata *);
94*4eaa4710SRishi Srivatsavai 
95*4eaa4710SRishi Srivatsavai /* events.c */
96*4eaa4710SRishi Srivatsavai extern void open_bridge_control(void);
97*4eaa4710SRishi Srivatsavai extern void event_loop(void);
98*4eaa4710SRishi Srivatsavai extern int refresh_count;
99*4eaa4710SRishi Srivatsavai extern dladm_bridge_prot_t protect;
100*4eaa4710SRishi Srivatsavai extern uint_t nextport;
101*4eaa4710SRishi Srivatsavai extern struct portdata **allports;
102*4eaa4710SRishi Srivatsavai extern int control_fd;
103*4eaa4710SRishi Srivatsavai 
104*4eaa4710SRishi Srivatsavai #ifdef __cplusplus
105*4eaa4710SRishi Srivatsavai }
106*4eaa4710SRishi Srivatsavai #endif
107*4eaa4710SRishi Srivatsavai 
108*4eaa4710SRishi Srivatsavai #endif /* _BRIDGED_GLOBAL_H */