diff options
author | meurisa <alexander.meuris@technicolor.com> | 2019-04-12 09:56:28 +0200 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2019-04-15 22:31:38 +0200 |
commit | 08989e46b9030671ce57b8872538d40e2ddcbbe0 (patch) | |
tree | c0119c3ca57b572adcfa6462d34411a6e0c2f0ac /scripts | |
parent | bfd4de3666901070d805878e55b02417fef6277c (diff) | |
download | netifd-08989e46b9030671ce57b8872538d40e2ddcbbe0.tar.gz |
interface: add neighbor config support
The neighbor or neighbor6 network section makes neighbours
configurable via UCI or proto shell handlers. It allows to
install neighbor proxy entries or static neighbor entries
The neighbor or neighbor6 section has the following types:
interface : declares the logical OpenWrt interface
ipaddr : the ip address of the neighbor
mac : the mac address of the neighbor
proxy : specifies whether the neighbor ia a proxy
entry (can be 1 or 0)
router : specifies whether the neighbor is a router
(can be 1 or 0)
Signed-off-by: Alexander Meuris <meurisalexander@gmail.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/netifd-proto.sh | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/scripts/netifd-proto.sh b/scripts/netifd-proto.sh index 31df91f..87d337d 100644 --- a/scripts/netifd-proto.sh +++ b/scripts/netifd-proto.sh @@ -64,6 +64,8 @@ proto_init_update() { PROTO_PREFIX6= PROTO_DNS= PROTO_DNS_SEARCH= + PROTO_NEIGHBOR= + PROTO_NEIGHBOR6= json_init json_add_int action 0 [ -n "$ifname" -a "*" != "$ifname" ] && json_add_string "ifname" "$ifname" @@ -133,6 +135,23 @@ proto_add_ipv6_address() { append PROTO_IP6ADDR "$address/$mask/$preferred/$valid/$offlink/$class" } +proto_add_ipv4_neighbor(){ + local address="$1" + local mac="$2" + local proxy="$3" + + append PROTO_NEIGHBOR "$address/$mac/$proxy" +} + +proto_add_ipv6_neighbor(){ + local address="$1" + local mac="$2" + local proxy="$3" + local router="$4" + + append PROTO_NEIGHBOR6 "$address/$mac/$proxy/$router" +} + proto_add_ipv4_route() { local target="$1" local mask="$2" @@ -218,6 +237,43 @@ _proto_push_string() { json_add_string "" "$1" } +_proto_push_ipv4_neighbor(){ + local str="$1" + local address mac proxy + + address="${str%%/*}" + str="${str#*/}" + mac="${str%%/*}" + str="${str#*/}" + proxy="${str%%/*}" + + json_add_object "" + json_add_string ipaddr "$address" + [ -n "$mac" ] && json_add_string mac "$mac" + [ -n "$proxy" ] && json_add_boolean proxy "$proxy" + json_close_object +} + +_proto_push_ipv6_neighbor(){ + local str="$1" + local address mac proxy router + + address="${str%%/*}" + str="${str#*/}" + mac="${str%%/*}" + str="${str#*/}" + proxy="${str%%/*}" + str="${str#*/}" + router="${str%%/*}" + + json_add_object "" + json_add_string ipaddr "$address" + [ -n "$mac" ] && json_add_string mac "$mac" + [ -n "$proxy" ] && json_add_boolean proxy "$proxy" + [ -n "$router" ] && json_add_boolean router "$router" + json_close_object +} + _proto_push_route() { local str="$1"; local target="${str%%/*}" @@ -277,6 +333,8 @@ proto_send_update() { _proto_push_array "ip6prefix" "$PROTO_PREFIX6" _proto_push_string _proto_push_array "dns" "$PROTO_DNS" _proto_push_string _proto_push_array "dns_search" "$PROTO_DNS_SEARCH" _proto_push_string + _proto_push_array "neighbor" "$PROTO_NEIGHBOR" _proto_push_ipv4_neighbor + _proto_push_array "neighbor6" "$PROTO_NEIGHBOR6" _proto_push_ipv6_neighbor _proto_notify "$interface" } |