-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
11,673 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
SUBDIRS = include lib stp stpctl | ||
|
||
INCLUDES = -I $(top_srcdir) -I ./include | ||
|
||
bin_PROGRAMS = stpd | ||
|
||
if DEBUG | ||
DBGFLAGS = -ggdb -DDEBUG | ||
else | ||
DBGFLAGS = -g -DNDEBUG | ||
endif | ||
|
||
stpd_SOURCES = stpd_main.cpp stpsync/stp_sync.cpp | ||
|
||
stpd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(COV_CFLAGS) | ||
stpd_LDADD = -lhiredis -lswsscommon \ | ||
$(LIBDAEMON_LIBS) \ | ||
lib/libcommonstp.a \ | ||
stp/libstp.a \ | ||
lib/libcommonstp.a \ | ||
/usr/lib/x86_64-linux-gnu/libevent.a \ | ||
$(COV_LDFLAGS) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
libtoolize --force --copy && | ||
autoreconf --force --install -I m4 | ||
rm -Rf autom4te.cache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
AC_INIT([sonic-stp],[1.0.0]) | ||
AC_CONFIG_SRCDIR([]) | ||
AC_CONFIG_AUX_DIR(config) | ||
AM_CONFIG_HEADER(config.h) | ||
AM_INIT_AUTOMAKE([foreign]) | ||
AC_LANG_C | ||
AC_LANG([C++]) | ||
AC_PROG_CC | ||
AC_PROG_CXX | ||
AC_PROG_LIBTOOL | ||
AC_HEADER_STDC | ||
|
||
#AC_CHECK_LIB([hiredis], [redisConnect],, | ||
# AC_MSG_ERROR([libhiredis is not installed.])) | ||
|
||
#AC_CHECK_LIB([nl-genl-3], [genl_connect]) | ||
|
||
AC_ARG_ENABLE(debug, | ||
[ --enable-debug Compile with debugging flags], | ||
[case "${enableval}" in | ||
yes) debug=true ;; | ||
no) debug=false ;; | ||
*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;; | ||
esac],[debug=false]) | ||
AM_CONDITIONAL(DEBUG, test x$debug = xtrue) | ||
|
||
AC_ARG_ENABLE(gtest, | ||
[ --enable-gtest Compile with googletest flags], | ||
[case "${enableval}" in | ||
yes) gtest=true ;; | ||
no) gtest=false ;; | ||
*) AC_MSG_ERROR(bad value ${enableval} for --enable-gtest) ;; | ||
esac],[gtest=false]) | ||
AM_CONDITIONAL(GTEST, test x$gtest = xtrue) | ||
|
||
CFLAGS_COMMON="-std=c++11 -Wall -fPIC -Wno-write-strings -I/usr/include/libnl3 -I/usr/include/swss -I/usr/include" | ||
|
||
CFLAGS_COMMON+=" -Werror" | ||
|
||
AC_SUBST(CFLAGS_COMMON) | ||
|
||
AC_CONFIG_FILES([ | ||
include/Makefile | ||
lib/Makefile | ||
stp/Makefile | ||
stpctl/Makefile | ||
Makefile | ||
]) | ||
|
||
AC_OUTPUT | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
sonic (1.0.0) stable; urgency=medium | ||
|
||
* Initial release. | ||
|
||
-- STP <@broadcom.com> Fri, 26 Apr 2019 12:00:00 -0800 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Source: sonic | ||
Maintainer: Broadcom | ||
Section: net | ||
Priority: optional | ||
Build-Depends: dh-exec (>=0.3), debhelper (>= 9), autotools-dev | ||
Standards-Version: 1.0.0 | ||
|
||
Package: stp | ||
Architecture: any | ||
Depends: ${shlibs:Depends} | ||
Description: This package contains STP for SONiC project. | ||
|
||
Package: stp-dbg | ||
Architecture: any | ||
Section: debug | ||
Priority: extra | ||
Depends: stp (=${binary:Version}) | ||
Description: debugging symbols for stp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/make -f | ||
# See debhelper(7) (uncomment to enable) | ||
# output every command that modifies files on the build system. | ||
#export DH_VERBOSE = 1 | ||
|
||
# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/* | ||
DPKG_EXPORT_BUILDFLAGS = 1 | ||
include /usr/share/dpkg/default.mk | ||
|
||
# see FEATURE AREAS in dpkg-buildflags(1) | ||
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all | ||
|
||
# see ENVIRONMENT in dpkg-buildflags(1) | ||
# package maintainers to append CFLAGS | ||
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic | ||
# package maintainers to append LDFLAGS | ||
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed | ||
|
||
|
||
# main packaging script based on dh7 syntax | ||
%: | ||
dh $@ --with autotools-dev | ||
|
||
# dh_make generated override targets | ||
# This is example for Cmake (See https://bugs.debian.org/641051 ) | ||
#override_dh_auto_configure: | ||
# dh_auto_configure -- \ | ||
# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) | ||
|
||
override_dh_auto_install: | ||
dh_auto_install --destdir=debian/stp | ||
ifeq ($(SONIC_COVERAGE_ON),y) | ||
find . -name "*.gcno" | sed 's|.*|tar -uvf debian/gcov_stp_$(shell date '+%y%m%d_%H%M').tar &|g'|sh | ||
endif | ||
|
||
override_dh_strip: | ||
dh_strip --dbg-package=stp-dbg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
MAINTAINERCLEANFILES = Makefile.in | ||
|
||
stpincludedir = $(includedir) | ||
nobase_stpinclude_HEADERS = stp_ipc.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
* Copyright 2019 Broadcom. The term "Broadcom" refers to Broadcom Inc. and/or | ||
* its subsidiaries. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef __L2_H__ | ||
#define __L2_H__ | ||
|
||
/* definitions -------------------------------------------------------------- */ | ||
|
||
#undef BYTE | ||
#define BYTE unsigned char | ||
#undef USHORT | ||
#define USHORT unsigned short | ||
#undef UINT8 | ||
#define UINT8 uint8_t | ||
#undef UINT16 | ||
#define UINT16 uint16_t | ||
#undef UINT32 | ||
#define UINT32 uint32_t | ||
#undef UINT | ||
#define UINT unsigned int | ||
#undef INT32 | ||
#define INT32 int32_t | ||
|
||
|
||
// --------------------------- | ||
// VLAN_ID structure (32-bit value) | ||
// --------------------------- | ||
typedef UINT16 VLAN_ID; | ||
|
||
#define MIN_VLAN_ID 1 | ||
#define MAX_VLAN_ID 4095 | ||
#define VLAN_ID_INVALID (MAX_VLAN_ID+1) | ||
#define L2_ETH_ADD_LEN 6 | ||
|
||
#define VLAN_ID_TAG_BITS 0xFFF | ||
#define GET_VLAN_ID_TAG(vlan_id) (vlan_id & VLAN_ID_TAG_BITS) | ||
#define IS_VALID_VLAN(vlan_id) ((GET_VLAN_ID_TAG(vlan_id) >= MIN_VLAN_ID) \ | ||
&& (GET_VLAN_ID_TAG(vlan_id) < MAX_VLAN_ID)) | ||
|
||
|
||
/* enums -------------------------------------------------------------------- */ | ||
|
||
enum L2_PORT_STATE | ||
{ | ||
DISABLED = 0, | ||
BLOCKING = 1, | ||
LISTENING = 2, | ||
LEARNING = 3, | ||
FORWARDING = 4, | ||
L2_MAX_PORT_STATE = 5 | ||
}; | ||
|
||
|
||
enum SNAP_PROTOCOL_ID | ||
{ | ||
SNAP_CISCO_PVST_ID = (0x010b), | ||
}; | ||
|
||
enum LLC_FRAME_TYPE | ||
{ | ||
UNNUMBERED_INFORMATION = 3, | ||
}; | ||
|
||
|
||
enum SAP_TYPES | ||
{ | ||
LSAP_SNAP_LLC = 0xaa, | ||
LSAP_BRIDGE_SPANNING_TREE_PROTOCOL = 0x42, | ||
}; | ||
|
||
/* structures --------------------------------------------------------------- */ | ||
|
||
typedef struct LLC_HEADER | ||
{ | ||
BYTE destination_address_DSAP; | ||
BYTE source_address_SSAP; | ||
BYTE llc_frame_type; | ||
} __attribute__((__packed__)) LLC_HEADER; | ||
|
||
typedef struct SNAP_HEADER | ||
{ | ||
BYTE destination_address_DSAP; | ||
BYTE source_address_SSAP; | ||
|
||
BYTE llc_frame_type; | ||
|
||
BYTE protocol_id_filler[3]; | ||
UINT16 protocol_id; | ||
} __attribute__((__packed__)) SNAP_HEADER; | ||
|
||
typedef struct MAC_ADDRESS | ||
{ | ||
UINT32 _ulong; | ||
UINT16 _ushort; | ||
}__attribute__ ((packed))MAC_ADDRESS; | ||
|
||
#define COPY_MAC(sptr_mac2, sptr_mac1) \ | ||
(memcpy(sptr_mac2, sptr_mac1, sizeof(MAC_ADDRESS))) | ||
|
||
#define NET_TO_HOST_MAC(sptr_dst_mac, sptr_src_mac) \ | ||
((MAC_ADDRESS *)(sptr_dst_mac))->_ulong = ntohl(((MAC_ADDRESS *)(sptr_src_mac))->_ulong); \ | ||
((MAC_ADDRESS *)(sptr_dst_mac))->_ushort = ntohs(((MAC_ADDRESS *)(sptr_src_mac))->_ushort); | ||
|
||
/* copies src mac to dst mac and converts to network byte ordering */ | ||
#define HOST_TO_NET_MAC(sptr_dst_mac, sptr_src_mac) \ | ||
((MAC_ADDRESS *)(sptr_dst_mac))->_ulong = htonl(((MAC_ADDRESS *)(sptr_src_mac))->_ulong); \ | ||
((MAC_ADDRESS *)(sptr_dst_mac))->_ushort = htons(((MAC_ADDRESS *)(sptr_src_mac))->_ushort); | ||
|
||
typedef struct MAC_HEADER | ||
{ | ||
MAC_ADDRESS destination_address; | ||
MAC_ADDRESS source_address; | ||
|
||
USHORT length; | ||
} __attribute__((__packed__)) MAC_HEADER; | ||
|
||
|
||
#define STP_BPDU_OFFSET (sizeof(MAC_HEADER) + sizeof(LLC_HEADER)) | ||
#define PVST_BPDU_OFFSET (sizeof(MAC_HEADER) + sizeof(SNAP_HEADER)) | ||
|
||
#define STP_MAX_PKT_LEN 68 | ||
#define VLAN_HEADER_LEN 4 //4 bytes | ||
|
||
#endif //__L2_H__ |
Oops, something went wrong.