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