1*10491SRishi.Srivatsavai@Sun.COM /************************************************************************ 2*10491SRishi.Srivatsavai@Sun.COM * RSTP library - Rapid Spanning Tree (802.1t, 802.1w) 3*10491SRishi.Srivatsavai@Sun.COM * Copyright (C) 2001-2003 Optical Access 4*10491SRishi.Srivatsavai@Sun.COM * Author: Alex Rozin 5*10491SRishi.Srivatsavai@Sun.COM * 6*10491SRishi.Srivatsavai@Sun.COM * This file is part of RSTP library. 7*10491SRishi.Srivatsavai@Sun.COM * 8*10491SRishi.Srivatsavai@Sun.COM * RSTP library is free software; you can redistribute it and/or modify it 9*10491SRishi.Srivatsavai@Sun.COM * under the terms of the GNU Lesser General Public License as published by the 10*10491SRishi.Srivatsavai@Sun.COM * Free Software Foundation; version 2.1 11*10491SRishi.Srivatsavai@Sun.COM * 12*10491SRishi.Srivatsavai@Sun.COM * RSTP library is distributed in the hope that it will be useful, but 13*10491SRishi.Srivatsavai@Sun.COM * WITHOUT ANY WARRANTY; without even the implied warranty of 14*10491SRishi.Srivatsavai@Sun.COM * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 15*10491SRishi.Srivatsavai@Sun.COM * General Public License for more details. 16*10491SRishi.Srivatsavai@Sun.COM * 17*10491SRishi.Srivatsavai@Sun.COM * You should have received a copy of the GNU Lesser General Public License 18*10491SRishi.Srivatsavai@Sun.COM * along with RSTP library; see the file COPYING. If not, write to the Free 19*10491SRishi.Srivatsavai@Sun.COM * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 20*10491SRishi.Srivatsavai@Sun.COM * 02111-1307, USA. 21*10491SRishi.Srivatsavai@Sun.COM **********************************************************************/ 22*10491SRishi.Srivatsavai@Sun.COM 23*10491SRishi.Srivatsavai@Sun.COM /* BPDU formats: 9.1 - 9.3, 17.28 */ 24*10491SRishi.Srivatsavai@Sun.COM 25*10491SRishi.Srivatsavai@Sun.COM #ifndef _STP_BPDU_H__ 26*10491SRishi.Srivatsavai@Sun.COM #define _STP_BPDU_H__ 27*10491SRishi.Srivatsavai@Sun.COM 28*10491SRishi.Srivatsavai@Sun.COM #define MIN_BPDU 7 29*10491SRishi.Srivatsavai@Sun.COM #define BPDU_L_SAP 0x42 30*10491SRishi.Srivatsavai@Sun.COM #define LLC_UI 0x03 31*10491SRishi.Srivatsavai@Sun.COM #define BPDU_PROTOCOL_ID 0x0000 32*10491SRishi.Srivatsavai@Sun.COM #define BPDU_VERSION_ID 0x00 33*10491SRishi.Srivatsavai@Sun.COM #define BPDU_VERSION_RAPID_ID 0x02 34*10491SRishi.Srivatsavai@Sun.COM 35*10491SRishi.Srivatsavai@Sun.COM #define BPDU_TOPO_CHANGE_TYPE 0x80 36*10491SRishi.Srivatsavai@Sun.COM #define BPDU_CONFIG_TYPE 0x00 37*10491SRishi.Srivatsavai@Sun.COM #define BPDU_RSTP 0x02 38*10491SRishi.Srivatsavai@Sun.COM 39*10491SRishi.Srivatsavai@Sun.COM #define TOPOLOGY_CHANGE_BIT 0x01 40*10491SRishi.Srivatsavai@Sun.COM #define PROPOSAL_BIT 0x02 41*10491SRishi.Srivatsavai@Sun.COM #define PORT_ROLE_OFFS 2 /* 0x04 & 0x08 */ 42*10491SRishi.Srivatsavai@Sun.COM #define PORT_ROLE_MASK (0x03 << PORT_ROLE_OFFS) 43*10491SRishi.Srivatsavai@Sun.COM #define LEARN_BIT 0x10 44*10491SRishi.Srivatsavai@Sun.COM #define FORWARD_BIT 0x20 45*10491SRishi.Srivatsavai@Sun.COM #define AGREEMENT_BIT 0x40 46*10491SRishi.Srivatsavai@Sun.COM #define TOPOLOGY_CHANGE_ACK_BIT 0x80 47*10491SRishi.Srivatsavai@Sun.COM 48*10491SRishi.Srivatsavai@Sun.COM #define RSTP_PORT_ROLE_UNKN 0x00 49*10491SRishi.Srivatsavai@Sun.COM #define RSTP_PORT_ROLE_ALTBACK 0x01 50*10491SRishi.Srivatsavai@Sun.COM #define RSTP_PORT_ROLE_ROOT 0x02 51*10491SRishi.Srivatsavai@Sun.COM #define RSTP_PORT_ROLE_DESGN 0x03 52*10491SRishi.Srivatsavai@Sun.COM 53*10491SRishi.Srivatsavai@Sun.COM typedef struct mac_header_t { 54*10491SRishi.Srivatsavai@Sun.COM unsigned char dst_mac[6]; 55*10491SRishi.Srivatsavai@Sun.COM unsigned char src_mac[6]; 56*10491SRishi.Srivatsavai@Sun.COM } MAC_HEADER_T; 57*10491SRishi.Srivatsavai@Sun.COM 58*10491SRishi.Srivatsavai@Sun.COM typedef struct eth_header_t { 59*10491SRishi.Srivatsavai@Sun.COM unsigned char len8023[2]; 60*10491SRishi.Srivatsavai@Sun.COM unsigned char dsap; 61*10491SRishi.Srivatsavai@Sun.COM unsigned char ssap; 62*10491SRishi.Srivatsavai@Sun.COM unsigned char llc; 63*10491SRishi.Srivatsavai@Sun.COM } ETH_HEADER_T; 64*10491SRishi.Srivatsavai@Sun.COM 65*10491SRishi.Srivatsavai@Sun.COM typedef struct bpdu_header_t { 66*10491SRishi.Srivatsavai@Sun.COM unsigned char protocol[2]; 67*10491SRishi.Srivatsavai@Sun.COM unsigned char version; 68*10491SRishi.Srivatsavai@Sun.COM unsigned char bpdu_type; 69*10491SRishi.Srivatsavai@Sun.COM } BPDU_HEADER_T; 70*10491SRishi.Srivatsavai@Sun.COM 71*10491SRishi.Srivatsavai@Sun.COM typedef struct bpdu_body_t { 72*10491SRishi.Srivatsavai@Sun.COM unsigned char flags; 73*10491SRishi.Srivatsavai@Sun.COM unsigned char root_id[8]; 74*10491SRishi.Srivatsavai@Sun.COM unsigned char root_path_cost[4]; 75*10491SRishi.Srivatsavai@Sun.COM unsigned char bridge_id[8]; 76*10491SRishi.Srivatsavai@Sun.COM unsigned char port_id[2]; 77*10491SRishi.Srivatsavai@Sun.COM unsigned char message_age[2]; 78*10491SRishi.Srivatsavai@Sun.COM unsigned char max_age[2]; 79*10491SRishi.Srivatsavai@Sun.COM unsigned char hello_time[2]; 80*10491SRishi.Srivatsavai@Sun.COM unsigned char forward_delay[2]; 81*10491SRishi.Srivatsavai@Sun.COM } BPDU_BODY_T; 82*10491SRishi.Srivatsavai@Sun.COM 83*10491SRishi.Srivatsavai@Sun.COM typedef struct stp_bpdu_t { 84*10491SRishi.Srivatsavai@Sun.COM ETH_HEADER_T eth; 85*10491SRishi.Srivatsavai@Sun.COM BPDU_HEADER_T hdr; 86*10491SRishi.Srivatsavai@Sun.COM BPDU_BODY_T body; 87*10491SRishi.Srivatsavai@Sun.COM unsigned char ver_1_len[2]; 88*10491SRishi.Srivatsavai@Sun.COM } BPDU_T; 89*10491SRishi.Srivatsavai@Sun.COM 90*10491SRishi.Srivatsavai@Sun.COM #endif /* _STP_BPDU_H__ */ 91