Add new feature device-to-device linking (dtdlink)

The dtdlink interface is vlan 2 on eth0 and is used for linking two or more devices together.

This will allow for band-to-band repeaters, sector antenna setups, etc.

see BBHN->ticket:28
This commit is contained in:
Conrad Lara - KG6JEI 2014-04-08 23:19:45 -07:00
parent f5f4da5350
commit a4dd9a9bdd
10 changed files with 118 additions and 0 deletions

View File

@ -23,3 +23,5 @@ olsrd_gw = 0
wan_proto = dhcp
wan_dns1 = 8.8.8.8
wan_dns2 = 8.8.4.4
dtdlink_ip=10.<DTDMAC>

View File

@ -23,3 +23,6 @@ olsrd_gw = 0
wan_proto = dhcp
wan_dns1 = 8.8.8.8
wan_dns2 = 8.8.4.4
dtdlink_ip=10.<DTDMAC>

View File

@ -31,6 +31,13 @@ config zone
option masq 1
option mtu_fix 1
config zone
option name dtdlink
option network 'dtdlink'
option input REJECT
option output ACCEPT
option forward REJECT
option mtu_fix 1
config forwarding
option src lan
@ -44,6 +51,17 @@ config forwarding
option src wifi
option dest wifi
config forwarding
option src lan
option dest dtdlink
config forwarding
option src wifi
option dest dtdlink
config forwarding
option src dtdlink
option dest wifi
# Allow IPv4 ping
config rule
@ -54,6 +72,14 @@ config rule
option family ipv4
option target ACCEPT
config rule
option name Allow-Ping
option src dtdlink
option proto icmp
option icmp_type echo-request
option family ipv4
option target ACCEPT
config include
option path /etc/firewall.user
@ -100,3 +126,33 @@ config rule
option proto tcp
option target ACCEPT
config rule
option src dtdlink
option dest_port 2222
option proto tcp
option target ACCEPT
config rule
option src dtdlink
option dest_port 8080
option proto tcp
option target ACCEPT
config rule
option src dtdlink
option dest_port 698
option proto udp
option target ACCEPT
config rule
option src dtdlink
option dest_port 1978
option proto tcp
option target ACCEPT
config rule
option src dtdlink
option dest_port 23
option proto tcp
option target ACCEPT

View File

@ -32,3 +32,9 @@ config interface wifi
option ipaddr <wifi_ip>
option netmask <wifi_mask>
#### device to device configuration
config interface dtdlink
option ifname "eth0.2"
option proto static
option ipaddr <dtdlink_ip>
option netmask 255.0.0.0

View File

@ -6,6 +6,7 @@ config olsrd
#option MainIp '<wifi_ip>'
option RtTable '30'
option RtTableDefault '31'
option LinkQualityAlgorithm 'etx_ffeth'
config LoadPlugin
option library 'olsrd_arprefresh.so.0.1'
@ -31,3 +32,7 @@ config LoadPlugin
config Interface
list interface 'wifi'
config Interface
list interface 'dtdlink'
option Mode 'ether'

View File

@ -0,0 +1,8 @@
# This script is run when the node is in NAT mode to
# setup NAT only from eth0 interface on dtdlink interface
# allowing all other traffic to transport as is.
iptables -t nat -A zone_lan_prerouting -j MARK --set-xmark 0xe/0xffffffff
iptables -t nat -A zone_dtdlink_nat -m mark --mark 0xe -j MASQUERADE

View File

@ -38,6 +38,7 @@ die "'$config' is not a valid configuration\n" unless -f "/etc/config.$config/_s
$node = nvram_get("node");
$tactical = nvram_get("tactical");
$mac2 = mac2ip(get_mac("wlan0"), 0);
$dtdmac = mac2ip(get_mac("eth0"), 0);
unless($auto)
{
@ -84,6 +85,7 @@ foreach $line (`cat /etc/config.$config/_setup`)
next if $line =~ /^\s*$/;
$line =~ s/<NODE>/$node/;
$line =~ s/<MAC2>/$mac2/;
$line =~ s/<DTDMAC>/$dtdmac/;
$line =~ /^(\w+)\s*=\s*(.*)$/;
$cfg{$1} = $2;
}
@ -175,6 +177,7 @@ if($do_basic)
$line =~ s/<NODE>/$node/;
$line =~ s/<MAC2>/$mac2/;
$line =~ s/<DTDMAC>/$dtdmac/;
$delparm = 0;
while(($parm) = $line =~ /^[^\#].*<(\S+)>/)
@ -265,15 +268,29 @@ if($cfg{dmz_mode}) {
print FILE "\nconfig forwarding\n";
print FILE " option src wifi\n";
print FILE " option dest lan\n";
print FILE "\n";
print FILE "\nconfig forwarding\n";
print FILE " option src dtdlink\n";
print FILE " option dest lan\n";
system "uci set firewall.\@zone\[2\].masq=0";
system "uci commit";
} else {
print FILE "\n";
print FILE "config 'include'\n";
print FILE " option 'path' '/etc/firewall.dtdlink'\n";
print FILE " option 'reload' '1'\n";
}
if ($cfg{olsrd_gw}) {
print FILE "\nconfig forwarding\n";
print FILE " option src wifi\n";
print FILE " option dest wan\n";
print FILE "\n";
print FILE "\nconfig forwarding\n";
print FILE " option src dtdlink\n";
print FILE " option dest wan\n";
}
foreach(`cat $portfile`)

View File

@ -65,4 +65,22 @@ if($node eq "")
$commit = 1;
}
chomp ($dtdmac = `uci -c /etc/local/uci/ -q get hsmmmesh.settings.dtdmac`);
if($dtdmac eq "")
{
open(FILE, "/sbin/ifconfig eth0 |") or fail("ERROR: eth0 mac not available");
while(<FILE>)
{
next unless /\w\w:\w\w:\w\w:(\w\w):(\w\w):(\w\w)/;
$dtdmac = join ".", hex $1, hex $2, hex $3;
last;
}
close(FILE);
system "uci -c /etc/local/uci/ set hsmmmesh.settings.dtdmac=$dtdmac";
$commit = 1;
}
system "uci -c /etc/local/uci/ commit" if $commit;

View File

@ -492,6 +492,7 @@ sub load_cfg
#my $mac2 = nvram_get("mac2");
my $node = nvram_get("node");
my $mac2 = mac2ip(get_mac("wlan0"), 0);
my $dtdmac = mac2ip(get_mac("eth0"), 0);
open(FILE, $_[0]) or return 0;
while(defined ($line = <FILE>))
{
@ -499,6 +500,7 @@ sub load_cfg
next if $line =~ /^\s*$/;
$line =~ s/<NODE>/$node/;
$line =~ s/<MAC2>/$mac2/;
$line =~ s/<DTDMAC>/$dtdmac/;
$line =~ /^(\w+)\s*=\s*(.*)$/;
$cfg{$1} = $2;
}

View File

@ -719,6 +719,7 @@ print "</table>\n";
push @hidden, "<input type=hidden name=oldconfig value='$oldconfig'>";
push @hidden, "<input type=hidden name=reload value=1>";
push @hidden, "<input type=hidden name=dtdlink_ip value='$dtdlink_ip'>";
foreach(@hidden) { print "$_\n" }
print "</form></center>\n";