Commit ba6d1e08 authored by Gio's avatar Gio

add lime-proto-bgp stub

parent 50b0296b
#
# 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-proto-bgp
PKG_VERSION=$(GIT_COMMIT_DATE)-$(GIT_COMMIT_TSTAMP)
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
TITLE:=LiMe BGP proto support
CATEGORY:=LiMe
MAINTAINER:=Gioacchino Mazzurco <gio@diveni.re>
URL:=http://libre-mesh.org
DEPENDS:=+bird4 +bird6 +lime-system +lua
endef
define Build/Compile
@rm -rf ./build || true
@cp -r ./src ./build
@sed -i '/^--!.*/d' build/*.lua
endef
define Package/$(PKG_NAME)/install
@mkdir -p $(1)/usr/lib/lua/lime/proto || true
$(CP) ./build/bgp.lua $(1)/usr/lib/lua/lime/proto/
endef
$(eval $(call BuildPackage,$(PKG_NAME)))
#!/usr/bin/lua
local network = require("lime.network")
local config = require("lime.config")
local fs = require("nixio.fs")
local utils = require("lime.utils")
local wireless = require("lime.wireless")
proto = {}
proto.configured = false
function proto.configure(args)
if proto.configured then return end
proto.configured = true
local ipv4, ipv6 = network.primary_address()
local localAS = 97922
local bgpPeers = {{ip="10.1.152.10", as=37922}}
local base_template = [[
router id $1;
protocol kernel {
learn;
scan time 20;
export all;
}
]]
local peer_template = [[
protocol bgp {
import all;
export all;
local as $localAS;
neighbor $1 as $2;
}
]]
for _,peer in pairs(bgpPeers) do
base_template = base_template .. utils.expandVars(peer_template, peer)
end
fs.writefile("/etc/bird4.conf", utils.expandVars(base_template, ipv4:host():string()))
end
function proto.setup_interface(ifname, args)
end
function proto.apply()
os.execute("/etc/init.d/bird4 restart")
os.execute("/etc/init.d/bird6 restart")
end
return proto
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment