gluon-mesh-batman-adv-*: add gluon_mesh protocol handlers

This commit is contained in:
Matthias Schiffer 2016-08-30 01:02:50 +02:00
parent 5cd6295265
commit b7380decc2
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
5 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,3 @@
#!/bin/sh
exec /lib/gluon/mesh-batman-adv-core/config_mesh_interface setup 1528

View File

@ -0,0 +1,3 @@
#!/bin/sh
exec /lib/gluon/mesh-batman-adv-core/config_mesh_interface teardown

View File

@ -0,0 +1,3 @@
#!/bin/sh
exec /lib/gluon/mesh-batman-adv-core/config_mesh_interface setup 1532

View File

@ -0,0 +1,3 @@
#!/bin/sh
exec /lib/gluon/mesh-batman-adv-core/config_mesh_interface teardown

View File

@ -0,0 +1,44 @@
#!/usr/bin/lua
local util = require 'gluon.util'
local fs = require 'nixio.fs'
local ifname = os.getenv('IFNAME')
local cmd = arg[1]
if cmd == 'setup' then
local fixed_mtu = tonumber(os.getenv('FIXED_MTU')) or 0
local transitive = tonumber(os.getenv('TRANSITIVE')) or 0
local mtu = tonumber(arg[2])
if fixed_mtu == 0 then
local lower = fs.glob('/sys/class/net/' .. ifname .. '/lower_*/wireless')()
if lower then
lower = lower:match('/lower_([^/]+)/wireless$')
util.exec('ip', 'link', 'set', 'dev', lower, 'mtu', tostring(mtu+4))
end
util.exec('ip', 'link', 'set', 'dev', ifname, 'mtu', tostring(mtu))
end
local file = assert(io.open('/sys/class/net/' .. ifname .. '/batman_adv/mesh_iface', 'w'))
file:write('bat0')
file:close()
file = assert(io.open('/sys/class/net/' .. ifname .. '/batman_adv/no_rebroadcast', 'w'))
file:write(tostring(transitive))
file:close()
elseif cmd == 'teardown' then
local file = io.open('/sys/class/net/' .. ifname .. '/batman_adv/mesh_iface', 'w')
if file then
file:write('none')
file:close()
end
end