blob: cfed671f8d5ee1cc50f6ba0b3c453ba6021bcb20 [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' && \
William A. Kennington III2d6858d2022-02-11 03:08:25 -080026 UpdateGateway "$service" "$interface" "$router_ip" && \
William A. Kennington III7d6fa422021-02-08 17:04:02 -080027 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 "$@"