summaryrefslogtreecommitdiff
path: root/data/templates/dhcp-client
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-11-19 21:43:15 +0100
committerChristian Breunig <christian@breunig.cc>2023-11-19 21:43:15 +0100
commitbed1cd01904ef89b5d31bd47de0f230214900f16 (patch)
tree46744c0454a3656cfa57dadeed8d19bf556e94f5 /data/templates/dhcp-client
parent7721e43e8b684e9b46c7294e961f57f9d5f1baf3 (diff)
downloadvyos-1x-bed1cd01904ef89b5d31bd47de0f230214900f16.tar.gz
vyos-1x-bed1cd01904ef89b5d31bd47de0f230214900f16.zip
dhcp-client: T5760: add constraints for dhclient string options
The string data type specifies either an NVT ASCII string enclosed in double quotes, or a series of octets specified in hexadecimal, separated by colons. For example: set interfaces ethernet eth0 dhcp-options client-id CLIENT-FOO or set interfaces ethernet eth0 dhcp-options client-id 43:4c:49:45:54:2d:46:4f:4f As of now there was no input validation performed.
Diffstat (limited to 'data/templates/dhcp-client')
-rw-r--r--data/templates/dhcp-client/ipv4.j215
1 files changed, 11 insertions, 4 deletions
diff --git a/data/templates/dhcp-client/ipv4.j2 b/data/templates/dhcp-client/ipv4.j2
index cc5ddf09c..4a5d5e54d 100644
--- a/data/templates/dhcp-client/ipv4.j2
+++ b/data/templates/dhcp-client/ipv4.j2
@@ -9,14 +9,21 @@ interface "{{ ifname }}" {
send host-name "{{ dhcp_options.host_name }}";
{% if dhcp_options.client_id is vyos_defined %}
{% set client_id = dhcp_options.client_id %}
-{# Use HEX representation of client-id as it is send in MAC-address style using hex characters. If not HEX, use double quotes ASCII format #}
-{% if not dhcp_options.client_id.split(':') | length >= 5 %}
-{% set client_id = '"' + dhcp_options.client_id + '"' %}
+{# Use HEX representation of client-id as it is send in MAC-address style using hex characters. #}
+{# If not HEX, use double quotes ASCII format #}
+{% if not client_id.split(':') | length >= 3 %}
+{% set client_id = '"' ~ dhcp_options.client_id ~ '"' %}
{% endif %}
send dhcp-client-identifier {{ client_id }};
{% endif %}
{% if dhcp_options.vendor_class_id is vyos_defined %}
- send vendor-class-identifier "{{ dhcp_options.vendor_class_id }}";
+{% set vendor_class_id = dhcp_options.vendor_class_id %}
+{# Use HEX representation of client-id as it is send in MAC-address style using hex characters. #}
+{# If not HEX, use double quotes ASCII format #}
+{% if not vendor_class_id.split(':') | length >= 3 %}
+{% set vendor_class_id = '"' ~ dhcp_options.vendor_class_id ~ '"' %}
+{% endif %}
+ send vendor-class-identifier {{ vendor_class_id }};
{% endif %}
# The request statement causes the client to request that any server responding to the
# client send the client its values for the specified options.