proto_config_add_string 'ipaddr:ipaddr'
proto_config_add_string 'hostname:hostname'
proto_config_add_string clientid
+ proto_config_add_string sendclientid
proto_config_add_string vendorid
proto_config_add_boolean 'broadcast:bool'
proto_config_add_boolean 'norelease:bool'
local config="$1"
local iface="$2"
- local ipaddr hostname clientid vendorid broadcast norelease reqopts defaultreqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute timeout retry tryagain
- json_get_vars ipaddr hostname clientid vendorid broadcast norelease reqopts defaultreqopts iface6rd delegate zone6rd zone mtu6rd customroutes classlessroute timeout retry tryagain
+ local ipaddr hostname clientid sendclientid vendorid broadcast norelease reqopts defaultreqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute timeout retry tryagain
+ json_get_vars ipaddr hostname clientid sendclientid vendorid broadcast norelease reqopts defaultreqopts iface6rd delegate zone6rd zone mtu6rd customroutes classlessroute timeout retry tryagain
local opt dhcpopts
for opt in $reqopts; do
[ "$defaultreqopts" = 0 ] && defaultreqopts="-o" || defaultreqopts=
[ "$broadcast" = 1 ] && broadcast="-B" || broadcast=
[ "$norelease" = 1 ] && norelease="" || norelease="-R"
- [ -n "$clientid" ] && {
- clientid="$(hexdump_2hex "$clientid")"
- [ -z "$clientid" ] && logger -p warn -t dhcp "$iface: ignoring invalid clientid value"
- }
- [ -z "$clientid" ] && clientid="$(proto_dhcp_get_default_clientid "$iface")"
- [ -n "$clientid" ] && clientid="-x 0x3d:$clientid"
+ case "$sendclientid" in
+ global)
+ clientid="$(proto_dhcp_get_default_clientid "$iface")"
+ ;;
+ hardware)
+ clientid=''
+ ;;
+ none)
+ clientid='-C'
+ ;;
+ auto|\
+ *)
+ [ -n "$clientid" ] && {
+ clientid="$(hexdump_2hex "$clientid")"
+ [ -z "$clientid" ] && {
+ logger -p warn -t dhcp "$iface: ignoring invalid clientid value"
+ }
+ }
+ [ -z "$clientid" ] && clientid="$(proto_dhcp_get_default_clientid "$iface")"
+ ;;
+ esac
+ [ -n "${clientid##-C}" ] && clientid="-x 0x3d:$clientid"
[ -n "$vendorid" ] && append dhcpopts "-x 0x3c:$(echo -n "$vendorid" | hexdump -ve '1/1 "%02x"')"
[ -n "$iface6rd" ] && proto_export "IFACE6RD=$iface6rd"
[ "$iface6rd" != 0 -a -f /lib/netifd/proto/6rd.sh ] && append dhcpopts "-O 212"
proto_config_add_string 'reqaddress:or("try","force","none")'
proto_config_add_string reqprefix
proto_config_add_string clientid
+ proto_config_add_string 'sendclientid:or("auto","global","hardware")'
proto_config_add_string 'reqopts:list(uinteger)'
proto_config_add_string 'defaultreqopts:bool'
proto_config_add_string 'noslaaconly:bool'
proto_config_add_boolean dynamic
}
+proto_dhcpv6_get_default_duid() {
+ local duid="$(uci_get network @globals[0] dhcp_default_duid)"
+ [ -n "$duid" ] && {
+ duid="$(hexdump_2hex "$duid")"
+ [ -z "$duid" ] && {
+ logger -p warn -t dhcpv6 "$iface: ignoring invalid dhcp_default_duid value"
+ }
+ }
+ [ -z "$duid" ] && return
+ echo -n $duid
+}
+
proto_dhcpv6_add_prefix() {
append "$3" "$1"
}
local config="$1"
local iface="$2"
- local reqaddress reqprefix clientid reqopts defaultreqopts
+ local reqaddress reqprefix clientid sendclientid reqopts defaultreqopts
local noslaaconly forceprefix extendprefix norelease strict_rfc7550
local noserverunicast noclientfqdn noacceptreconfig iface_dslite
local iface_map iface_464xlat ip6ifaceid userclass vendorclass
local ip6prefix ip6prefixes
- json_get_vars reqaddress reqprefix clientid reqopts defaultreqopts
+ json_get_vars reqaddress reqprefix clientid sendclientid reqopts defaultreqopts
json_get_vars noslaaconly forceprefix extendprefix norelease strict_rfc7550
json_get_vars noserverunicast noclientfqdn noacceptreconfig iface_dslite
json_get_vars iface_map iface_464xlat ip6ifaceid userclass vendorclass
append opts "-P$reqprefix"
}
- [ -n "$clientid" ] && {
- clientid="$(hexdump_2hex "$clientid")"
- [ -z "$clientid" ] && logger -p warn -t dhcpv6 "$iface: ignoring invalid clientid value"
- }
- [ -z "$clientid" ] && clientid="$(uci_get network @globals[0] dhcp_default_duid)"
- [ -n "$clientid" ] && {
- clientid="$(hexdump_2hex "$clientid")"
- [ -z "$clientid" ] && logger -p warn -t dhcpv6 "$iface: ignoring invalid dhcp_default_duid value"
- }
+ case "$sendclientid" in
+ global)
+ clientid="$(proto_dhcpv6_get_default_duid)"
+ ;;
+ hardware)
+ clientid=''
+ ;;
+ auto|\
+ *)
+ [ -n "$clientid" ] && {
+ clientid="$(hexdump_2hex "$clientid")"
+ [ -z "$clientid" ] && {
+ logger -p warn -t dhcpv6 "$iface: ignoring invalid clientid value"
+ }
+ }
+ [ -z "$clientid" ] && clientid="$(proto_dhcpv6_get_default_duid)"
+ ;;
+ esac
[ -n "$clientid" ] && append opts "-c$clientid"
[ "$defaultreqopts" = "0" ] && append opts "-R"