William A. Kennington III | 7d6fa42 | 2021-02-08 17:04:02 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | source "$(dirname "${BASH_SOURCE[0]}")"/ncsid_lib.sh |
| 3 | |
William A. Kennington III | 7d6fa42 | 2021-02-08 17:04:02 -0800 | [diff] [blame] | 4 | HandleDHCP6() { |
| 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 III | b163a2c | 2021-05-20 17:33:01 -0700 | [diff] [blame] | 12 | if ! disc="$(DiscoverRouter6 "$interface" 5 1000)"; then |
William A. Kennington III | 7d6fa42 | 2021-02-08 17:04:02 -0800 | [diff] [blame] | 13 | 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 III | 2d6858d | 2022-02-11 03:08:25 -0800 | [diff] [blame^] | 26 | UpdateGateway "$service" "$interface" "$router_ip" && \ |
William A. Kennington III | 7d6fa42 | 2021-02-08 17:04:02 -0800 | [diff] [blame] | 27 | UpdateNeighbor "$service" "$interface" "$router_ip" "$router_mac" || \ |
| 28 | rc=$? |
| 29 | UnsuppressTerm |
| 30 | touch /run/dhcp6.done |
| 31 | return $rc |
| 32 | fi |
| 33 | } |
| 34 | |
| 35 | Main() { |
| 36 | set -o nounset |
| 37 | set -o errexit |
| 38 | set -o pipefail |
| 39 | |
| 40 | InitTerm |
| 41 | HandleDHCP6 "$@" |
| 42 | } |
| 43 | |
| 44 | return 0 2>/dev/null |
| 45 | Main "$@" |