2013-01-13 17:35:09 +00:00
|
|
|
#!/bin/sh
|
|
|
|
[ -z "$2" ] && echo "Error: should be run by odhcpc6c" && exit 1
|
|
|
|
. /lib/functions.sh
|
|
|
|
. /lib/netifd/netifd-proto.sh
|
|
|
|
|
|
|
|
setup_interface () {
|
|
|
|
local device="$1"
|
|
|
|
proto_init_update "*" 1
|
|
|
|
|
2013-02-01 12:28:39 +00:00
|
|
|
# Merge RA-DNS
|
|
|
|
for radns in $RA_DNS; do
|
|
|
|
local duplicate=0
|
|
|
|
for dns in $RDNSS; do
|
|
|
|
[ "$radns" = "$dns" ] && duplicate=1
|
|
|
|
done
|
|
|
|
[ "$duplicate" = 0 ] && RDNSS="$RDNSS $radns"
|
|
|
|
done
|
|
|
|
|
2013-01-13 17:35:09 +00:00
|
|
|
for dns in $RDNSS; do
|
|
|
|
proto_add_dns_server "$dns"
|
|
|
|
done
|
|
|
|
|
|
|
|
for domain in $DOMAINS; do
|
|
|
|
proto_add_dns_search "$domain"
|
|
|
|
done
|
|
|
|
|
|
|
|
for prefix in $PREFIXES; do
|
|
|
|
proto_add_ipv6_prefix "$prefix"
|
|
|
|
done
|
|
|
|
|
2013-02-12 08:23:54 +00:00
|
|
|
[ -n "$USERPREFIX" ] && proto_add_ipv6_prefix "$USERPREFIX"
|
|
|
|
|
2013-02-01 12:28:39 +00:00
|
|
|
# Merge addresses
|
|
|
|
for entry in $RA_ADDRESSES; do
|
|
|
|
local duplicate=0
|
|
|
|
local addr="${entry%%/*}"
|
|
|
|
for dentry in $ADDRESSES; do
|
|
|
|
local daddr="${dentry%%/*}"
|
|
|
|
[ "$addr" = "$daddr" ] && duplicate=1
|
|
|
|
done
|
|
|
|
[ "$duplicate" = "0" ] && ADDRESSES="$ADDRESSES $entry"
|
|
|
|
done
|
|
|
|
|
|
|
|
for entry in $ADDRESSES; do
|
|
|
|
local addr="${entry%%/*}"
|
|
|
|
entry="${entry#*/}"
|
|
|
|
local mask="${entry%%,*}"
|
|
|
|
entry="${entry#*,}"
|
|
|
|
local preferred="${entry%%,*}"
|
|
|
|
entry="${entry#*,}"
|
|
|
|
local valid="${entry%%,*}"
|
|
|
|
|
|
|
|
proto_add_ipv6_address "$addr" "$mask" "$preferred" "$valid" 1
|
|
|
|
done
|
|
|
|
|
|
|
|
for entry in $RA_ROUTES; do
|
|
|
|
local addr="${entry%%/*}"
|
|
|
|
entry="${entry#*/}"
|
|
|
|
local mask="${entry%%,*}"
|
|
|
|
entry="${entry#*,}"
|
|
|
|
local gw="${entry%%,*}"
|
|
|
|
entry="${entry#*,}"
|
|
|
|
local valid="${entry%%,*}"
|
|
|
|
entry="${entry#*,}"
|
|
|
|
local metric="${entry%%,*}"
|
|
|
|
|
|
|
|
proto_add_ipv6_route "$addr" "$mask" "$gw" "$metric" "$valid"
|
|
|
|
done
|
|
|
|
|
2013-01-13 17:35:09 +00:00
|
|
|
proto_send_update "$INTERFACE"
|
|
|
|
|
|
|
|
# TODO: $SNTP_IP $SIP_IP $SNTP_FQDN $SIP_DOMAIN
|
|
|
|
}
|
|
|
|
|
|
|
|
teardown_interface() {
|
|
|
|
proto_init_update "*" 0
|
|
|
|
proto_send_update "$INTERFACE"
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$2" in
|
2013-05-06 10:20:43 +00:00
|
|
|
bound)
|
|
|
|
teardown_interface "$1"
|
|
|
|
setup_interface "$1"
|
|
|
|
;;
|
|
|
|
informed|updated|rebound|ra-updated)
|
2013-01-13 17:35:09 +00:00
|
|
|
setup_interface "$1"
|
|
|
|
;;
|
2013-01-28 13:53:43 +00:00
|
|
|
started|stopped|unbound)
|
2013-01-13 17:35:09 +00:00
|
|
|
teardown_interface "$1"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# user rules
|
|
|
|
[ -f /etc/odhcp6c.user ] && . /etc/odhcp6c.user
|
|
|
|
|
|
|
|
exit 0
|