diff --git a/renderer/templates/interface/common.uc b/renderer/templates/interface/common.uc index 7b86cd1..535f239 100644 --- a/renderer/templates/interface/common.uc +++ b/renderer/templates/interface/common.uc @@ -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 %} diff --git a/renderer/templates/interface/ipv4.uc b/renderer/templates/interface/ipv4.uc index ea1346e..1065430 100644 --- a/renderer/templates/interface/ipv4.uc +++ b/renderer/templates/interface/ipv4.uc @@ -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 %} diff --git a/schema/interface.ipv4.yml b/schema/interface.ipv4.yml index 90161d5..e1bfb86 100644 --- a/schema/interface.ipv4.yml +++ b/schema/interface.ipv4.yml @@ -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 diff --git a/schemareader.uc b/schemareader.uc index c11f69f..35081de 100644 --- a/schemareader.uc +++ b/schemareader.uc @@ -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) { diff --git a/ucentral.schema.full.json b/ucentral.schema.full.json index b0c4172..42ef9fd 100644 --- a/ucentral.schema.full.json +++ b/ucentral.schema.full.json @@ -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", diff --git a/ucentral.schema.json b/ucentral.schema.json index 0620fa4..79ba7f3 100644 --- a/ucentral.schema.json +++ b/ucentral.schema.json @@ -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": { diff --git a/ucentral.schema.pretty.json b/ucentral.schema.pretty.json index f9bfd64..3b948d6 100644 --- a/ucentral.schema.pretty.json +++ b/ucentral.schema.pretty.json @@ -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",