Add config for vendor-class and request-options

When using dynamic (dhcp) addressing for IPv4, allow the vendor-class
and list of requested options to be configured, along with specific
defaults:
    vendor-class default is "OpenLAN"
    requested options default is [ 43, 60, 224 ]

These defaults enable support for cloud discovery FQDN (224) and the
DHCP-VSI feature (43, 60)

Fixes: WIFI-14271
Signed-off-by: Paul White <paul@shasta.cloud>
This commit is contained in:
Paul White
2024-11-08 20:28:32 +00:00
committed by John Crispin
parent a21635b230
commit 44da3d651e
7 changed files with 143 additions and 1 deletions

View File

@@ -20,7 +20,6 @@ set network.{{ afname }}.auto={{ interface.auto_start }}
set network.{{ afname }}.proto=static
{% elif ((length(afnames) == 1 || afidx == 0) && ipv4_mode == 'dynamic'): %}
set network.{{ afname }}.proto=dhcp
set network.{{ afname }}.reqopts='43 224'
{% elif ((length(afnames) == 1 || afidx == 1) && ipv6_mode == 'dynamic'): %}
set network.{{ afname }}.proto=dhcpv6
{% else %}

View File

@@ -7,6 +7,10 @@ set network.{{ name }}.gateway={{ ipv4.gateway }}
{% else %}
set network.{{ name }}.peerdns={{ b(!length(ipv4.use_dns)) }}
{% endif %}
{% if (ipv4_mode == 'dynamic'): %}
set network.{{ name }}.vendorid={{ ipv4.vendor_class }}
set network.{{ name }}.reqopts='{{ join(' ', ipv4.request_options) }}'
{% endif %}
{% for (let dns in ipv4.use_dns): %}
add_list network.{{ name }}.dns={{ dns }}
{% endfor %}

View File

@@ -36,6 +36,24 @@ properties:
default: true
examples:
- true
vendor-class:
description:
Include the provided vendor-class inside DHCP requests
type: string
default: OpenLAN
examples:
- OpenLAN
request-options:
description:
Define additional DHCP options to request inside DHCP requests
type: array
default: [43, 60, 224]
items:
type: integer
minimum: 1
maximum: 255
examples:
- 43
use-dns:
description:
Define which DNS servers shall be used. This can either be a list of

View File

@@ -1985,6 +1985,54 @@ function instantiateInterfaceIpv4(location, value, errors) {
obj.send_hostname = true;
}
function parseVendorClass(location, value, errors) {
if (type(value) != "string")
push(errors, [ location, "must be of type string" ]);
return value;
}
if (exists(value, "vendor-class")) {
obj.vendor_class = parseVendorClass(location + "/vendor-class", value["vendor-class"], errors);
}
else {
obj.vendor_class = "OpenLAN";
}
function parseRequestOptions(location, value, errors) {
if (type(value) == "array") {
function parseItem(location, value, errors) {
if (type(value) in [ "int", "double" ]) {
if (value > 255)
push(errors, [ location, "must be lower than or equal to 255" ]);
if (value < 1)
push(errors, [ location, "must be bigger than or equal to 1" ]);
}
if (type(value) != "int")
push(errors, [ location, "must be of type integer" ]);
return value;
}
return map(value, (item, i) => parseItem(location + "/" + i, item, errors));
}
if (type(value) != "array")
push(errors, [ location, "must be of type array" ]);
return value;
}
if (exists(value, "request-options")) {
obj.request_options = parseRequestOptions(location + "/request-options", value["request-options"], errors);
}
else {
obj.request_options = [ 43, 60, 224 ];
}
function parseUseDns(location, value, errors) {
if (type(value) == "array") {
function parseItem(location, value, errors) {

View File

@@ -1049,6 +1049,31 @@
true
]
},
"vendor-class": {
"description": "Include the provided vendor-class inside DHCP requests",
"type": "string",
"default": "OpenLAN",
"examples": [
"OpenLAN"
]
},
"request-options": {
"description": "Define additional DHCP options to request inside DHCP requests",
"type": "array",
"default": [
43,
60,
224
],
"items": {
"type": "integer",
"minimum": 1,
"maximum": 255,
"examples": [
43
]
}
},
"use-dns": {
"description": "Define which DNS servers shall be used. This can either be a list of static IPv4 addresse or dhcp (use the server provided by the DHCP lease)",
"type": "array",

View File

@@ -840,6 +840,29 @@
true
]
},
"vendor-class": {
"type": "string",
"default": "OpenLAN",
"examples": [
"OpenLAN"
]
},
"request-options": {
"type": "array",
"default": [
43,
60,
224
],
"items": {
"type": "integer",
"minimum": 1,
"maximum": 255,
"examples": [
43
]
}
},
"use-dns": {
"type": "array",
"items": {

View File

@@ -947,6 +947,31 @@
true
]
},
"vendor-class": {
"description": "Include the provided vendor-class inside DHCP requests",
"type": "string",
"default": "OpenLAN",
"examples": [
"OpenLAN"
]
},
"request-options": {
"description": "Define additional DHCP options to request inside DHCP requests",
"type": "array",
"default": [
43,
60,
224
],
"items": {
"type": "integer",
"minimum": 1,
"maximum": 255,
"examples": [
43
]
}
},
"use-dns": {
"description": "Define which DNS servers shall be used. This can either be a list of static IPv4 addresse or dhcp (use the server provided by the DHCP lease)",
"type": "array",