-
Notifications
You must be signed in to change notification settings - Fork 94
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
4 changed files
with
112 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,40 @@ | ||
# | ||
# Copyright (C) 2006-2014 OpenWrt.org | ||
# | ||
# This is free software, licensed under the GNU General Public License v3. | ||
# | ||
|
||
include $(TOPDIR)/rules.mk | ||
|
||
LIME_BUILDDATE:=$(shell date +%Y%m%d_%H%M) | ||
LIME_CODENAME:=bigbang | ||
|
||
GIT_COMMIT_DATE:=$(shell git log -n 1 --pretty=%ad --date=short . ) | ||
GIT_COMMIT_TSTAMP:=$(shell git log -n 1 --pretty=%at . ) | ||
|
||
PKG_NAME:=lime-hwd-ground-routing | ||
PKG_VERSION=$(GIT_COMMIT_DATE)-$(GIT_COMMIT_TSTAMP) | ||
|
||
include $(INCLUDE_DIR)/package.mk | ||
|
||
define Package/$(PKG_NAME) | ||
TITLE:=Manage 802.1q VLANs for ground routing | ||
CATEGORY:=LiMe | ||
URL:=http://libre-mesh.org | ||
DEPENDS:=+lime-system +lua +libuci-lua | ||
endef | ||
|
||
define Build/Compile | ||
@rm -rf ./build || true | ||
@cp -r ./src ./build | ||
@sed -i '/^\s*--!.*/d' build/*.lua || true | ||
@sed -i '/^\s*#\[Doc\]/d' build/*.sh || true | ||
endef | ||
|
||
define Package/$(PKG_NAME)/install | ||
@mkdir -p $(1)/usr/lib/lua/lime/hwd || true | ||
$(CP) ./build/ground_routing.lua $(1)/usr/lib/lua/lime/hwd/ground_routing.lua | ||
@chmod +x $(1)/usr/lib/lua/lime/hwd/ground_routing.lua | ||
endef | ||
|
||
$(eval $(call BuildPackage,$(PKG_NAME))) |
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,61 @@ | ||
#!/usr/bin/lua | ||
|
||
local libuci = require("uci") | ||
local hardware_detection = require("lime.hardware_detection") | ||
local config = require("lime.config") | ||
local utils = require("lime.utils") | ||
|
||
local ground_routing = {} | ||
|
||
ground_routing.sectionNamePrefix = hardware_detection.sectionNamePrefix.."ground_routing_" | ||
|
||
function ground_routing.clean() | ||
function cleanGrSection(section) | ||
local sectionName = section[".name"] | ||
local isGr = utils.stringStarts(sectionName, ground_routing.sectionNamePrefix) | ||
local autogenerated = config.autogenerable(sectionName) | ||
|
||
if ( isGr and autogenerated ) then config.delete(section[".name"]) end | ||
end | ||
|
||
config.foreach("net", cleanGrSection) | ||
|
||
local uci = libuci:cursor() | ||
uci:foreach("network", "switch_vlan", cleanGrSection) | ||
end | ||
|
||
function ground_routing.detect_hardware() | ||
function parse_gr(section) | ||
local vlan = section["vlan"] | ||
local switchName = section["switch"] | ||
|
||
if switchName then | ||
local secname = ground_routing.sectionNamePrefix.."network_"..section[".name"].."_"..switchName.."_"..vlan | ||
local ports = "" | ||
for _,p in pairs(section["switch_ports"]) do ports = ports..p.."t " end | ||
|
||
local uci = libuci:cursor() | ||
uci:set("network", secname, "switch_vlan") | ||
uci:set("network", secname, "device", switchName) | ||
uci:set("network", secname, "vlan", vlan) | ||
uci:set("network", secname, "ports", ports) | ||
uci:save("network") | ||
end | ||
|
||
local basedev = section["basedev"] | ||
if basedev then | ||
local secname = ground_routing.sectionNamePrefix.."network_"..section[".name"].."_"..basedev.."_"..vlan | ||
|
||
local uci = libuci:cursor() | ||
uci:set("network", secname, "device") | ||
uci:set("network", secname, "type", "8021q") | ||
uci:set("network", secname, "name", basedev.."."..vlan) | ||
uci:set("network", secname, "vid", vlan) | ||
uci:save("network") | ||
end | ||
end | ||
|
||
config.foreach("hwd_gr", parse_gr) | ||
end | ||
|
||
return ground_routing |
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
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