blob: 508f2b43d2f72a7b67fcd49a607cda5dbf075a44 [file] [log] [blame]
William A. Kennington III7d6fa422021-02-08 17:04:02 -08001#!/bin/bash
2source "$(dirname "${BASH_SOURCE[0]}")"/ncsid_lib.sh
3
William A. Kennington III7d6fa422021-02-08 17:04:02 -08004HandleDHCP6() {
5 local op="$1"
6
7 if [ "$op" = "bound" ]; then
8 echo "INTF: $interface" >&2
9 echo "IP: $ipv6/128" >&2
10
11 local disc
William A. Kennington IIIb163a2c2021-05-20 17:33:01 -070012 if ! disc="$(DiscoverRouter6 "$interface" 5 1000)"; then
William A. Kennington III7d6fa422021-02-08 17:04:02 -080013 echo "Failed to discover router" >&2
14 return 1
15 fi
16 local vars
17 vars="$(echo "$disc" | JSONToVars)" || return
18 eval "$vars" || return
19 echo "GW: $router_ip" >&2
20 echo "GW_MAC: $router_mac" >&2
21
22 SuppressTerm
23 local service='xyz.openbmc_project.Network'
24 local rc=0
25 UpdateIP "$service" "$interface" "$ipv6" '128' && \
26 UpdateGateway "$service" "$router_ip" && \
27 UpdateNeighbor "$service" "$interface" "$router_ip" "$router_mac" || \
28 rc=$?
29 UnsuppressTerm
30 touch /run/dhcp6.done
31 return $rc
32 fi
33}
34
35Main() {
36 set -o nounset
37 set -o errexit
38 set -o pipefail
39
40 InitTerm
41 HandleDHCP6 "$@"
42}
43
44return 0 2>/dev/null
45Main "$@"