Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Commit

Permalink
scripts: prplmesh_utils.sh platform_db support
Browse files Browse the repository at this point in the history
Add platform_db automatic creation by prplmesh_utils.sh according to the
mode in which the script is invoked, and write that to
/tmp/prplmesh_platform_db.

While we're at it, change eth0 to sim-eth0 since if
prplmesh_utils.sh runs on the host, it will mess up networking.
Using a ~unique name for the dummy interface is good practice anyhow,
and allows us to run the same script in both containers and hosts.
Changing wlan0/2 to sim-wlan0/2 will be done in a separate commit.

Signed-off-by: Tomer Eliyahu <[email protected]>
  • Loading branch information
Tomer Eliyahu committed Jul 5, 2019
1 parent 15727b6 commit d16115c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 16 deletions.
2 changes: 1 addition & 1 deletion agent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ elseif (TARGET_PLATFORM STREQUAL "linux")
set(BEEROCKS_TMP_PATH "/tmp/$ENV{USER}/beerocks")
set(BEEROCKS_NOTIFY 0)
set(BEEROCKS_BRIDGE_IFACE "br-lan")
set(BEEROCKS_BH_WIRE_IFACE "eth0")
set(BEEROCKS_BH_WIRE_IFACE "sim-eth0")
set(BEEROCKS_REPEATER_MODE 0)
set(BEEROCKS_AUTOMATIC_CREDENTIALS_UNIFY 0)
set(BEEROCKS_STOP_ON_FAILURE_ATTEMPTS 1)
Expand Down
8 changes: 8 additions & 0 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@ include(GNUInstallDirs)

if (TARGET_PLATFORM STREQUAL "ugw")
add_definitions(-DBEEROCKS_UGW)
set(BEEROCKS_BRIDGE_IFACE "br-lan")
set(BEEROCKS_BH_WIRE_IFACE "eth1")
elseif (TARGET_PLATFORM STREQUAL "rdkb")
add_definitions(-DBEEROCKS_RDKB)
set(BEEROCKS_BRIDGE_IFACE "brlan0")
set(BEEROCKS_BH_WIRE_IFACE "nsgmii0")
set(CMAKE_SKIP_RPATH TRUE)
elseif (TARGET_PLATFORM STREQUAL "linux")
add_definitions(-DBEEROCKS_LINUX)
set(BEEROCKS_BRIDGE_IFACE "br-lan")
set(BEEROCKS_BH_WIRE_IFACE "sim-eth0")
endif()

list (FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir)
Expand Down
52 changes: 39 additions & 13 deletions common/beerocks/scripts/prplmesh_utils.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,42 @@ killall_program() {
done
}

prplmesh_platform_db_init() {
management_mode=${1-Multi-AP-Controller-and-Agent}
operating_mode=${2-Gateway}

mkdir -p @PLATFORM_DB_PATH_TEMP@/
{
echo -e "management_mode=${management_mode}"
echo -e "operating_mode=${operating_mode}"
echo -e "wired_backhaul=1"
} > @PLATFORM_DB_PATH_TEMP@/prplmesh_platform_db
}

platform_init_dummy() {
echo "platform dummy mode init..."
run ip link add wlan0 type dummy
run ip link add wlan2 type dummy
run ip link add eth1 type dummy
run brctl addbr br-lan
run brctl addif br-lan eth1
run brctl addif br-lan wlan0
run brctl addif br-lan wlan2
run ip link set eth1 up
run ip link add @BEEROCKS_BH_WIRE_IFACE@ type dummy
run brctl addbr @BEEROCKS_BRIDGE_IFACE@
run brctl addif @BEEROCKS_BRIDGE_IFACE@ @BEEROCKS_BH_WIRE_IFACE@
run brctl addif @BEEROCKS_BRIDGE_IFACE@ wlan0
run brctl addif @BEEROCKS_BRIDGE_IFACE@ wlan2
run ip link set @BEEROCKS_BH_WIRE_IFACE@ up
run ip link set wlan0 up
run ip link set wlan2 up
run ip link set br-lan up
run ip link set @BEEROCKS_BRIDGE_IFACE@ up
echo "Done"
}

platform_deinit_dummy() {
echo "platform dummy mode de-init..."
ip link set br-lan down
brctl delbr br-lan
ip link set eth1 down
ip link set @BEEROCKS_BRIDGE_IFACE@ down
brctl delbr @BEEROCKS_BRIDGE_IFACE@
ip link set @BEEROCKS_BH_WIRE_IFACE@ down
ip link set wlan0 down
ip link set wlan2 down
ip link del eth1
ip link del @BEEROCKS_BH_WIRE_IFACE@
ip link del wlan0
ip link del wlan2
echo "Done"
Expand Down Expand Up @@ -96,8 +108,22 @@ start_function() {

[ "@BWL_TYPE@" = "DUMMY" ] && [ "$PLATFORM_INIT" == "true" ] && platform_init_dummy
[ "@BTL_TYPE@" = "LOCAL_BUS" ] && prplmesh_framework_init
[ "$PRPLMESH_MODE" = "CA" -o "$PRPLMESH_MODE" = "C" ] && prplmesh_controller_start
[ "$PRPLMESH_MODE" = "CA" -o "$PRPLMESH_MODE" = "A" ] && prplmesh_agent_start
case "$PRPLMESH_MODE" in
CA | ca)
prplmesh_platform_db_init "Multi-AP-Controller-and-Agent"
prplmesh_controller_start
prplmesh_agent_start
;;
C | c)
prplmesh_platform_db_init "Multi-AP-Controller"
prplmesh_controller_start
;;
A | a)
prplmesh_platform_db_init "Multi-AP-Agent" "WDS-Repeater"
prplmesh_agent_start
;;
* ) err "unsupported mode: $PRPLMESH_MODE"; usage; exit 1 ;;
esac
}

stop_function() {
Expand Down
6 changes: 4 additions & 2 deletions framework/platform/bpl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ elseif (TARGET_PLATFORM STREQUAL "linux")

file(GLOB_RECURSE bpl_platform_sources ${MODULE_PATH}/linux/*.c*)

add_definitions(-DPLATFORM_DB_PATH="${CMAKE_INSTALL_PREFIX}/share/prplmesh_platform_db")
add_definitions(-DPLATFORM_DB_PATH_TEMP="/tmp/prplmesh_platform_db")
set(PLATFORM_DB_PATH ${CMAKE_INSTALL_PREFIX}/share)
set(PLATFORM_DB_PATH_TEMP /tmp)
add_definitions(-DPLATFORM_DB_PATH="${PLATFORM_DB_PATH}/prplmesh_platform_db")
add_definitions(-DPLATFORM_DB_PATH_TEMP="${PLATFORM_DB_PATH_TEMP}/prplmesh_platform_db")
install(FILES "${MODULE_PATH}/linux/prplmesh_platform_db" DESTINATION ${CMAKE_INSTALL_PREFIX}/share)
else()

Expand Down
5 changes: 5 additions & 0 deletions tools/docker/runner/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ run() {
run ip link add br-lan type bridge
run ip link add wlan0 type dummy up
run ip link add wlan2 type dummy up
run ip link add sim-eth0 type dummy up
run ip link set sim-eth0 master br-lan
run ip link set eth0 master br-lan
run ip link set wlan0 master br-lan
run ip link set wlan2 master br-lan
run ifconfig eth0 0.0.0.0
run ifconfig sim-eth0 up
run ifconfig wlan0 up
run ifconfig wlan2 up
run ifconfig br-lan ${1} up

shift
Expand Down

0 comments on commit d16115c

Please sign in to comment.