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