blob: c913ebeafdb8cdf7aced4915acc39a9eded50ecd [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
William A. Kennington IIIa7af2e02022-02-13 22:47:39 -080025 SetStatic "$service" "$interface" && \
26 UpdateIP "$service" "$interface" "$ipv6" '128' && \
William A. Kennington III2d6858d2022-02-11 03:08:25 -080027 UpdateGateway "$service" "$interface" "$router_ip" && \
William A. Kennington III7d6fa422021-02-08 17:04:02 -080028 UpdateNeighbor "$service" "$interface" "$router_ip" "$router_mac" || \
29 rc=$?
30 UnsuppressTerm
31 touch /run/dhcp6.done
32 return $rc
33 fi
34}
35
36Main() {
37 set -o nounset
38 set -o errexit
39 set -o pipefail
40
41 InitTerm
42 HandleDHCP6 "$@"
43}
44
45return 0 2>/dev/null
46Main "$@"