From 659ad40dbdb8f6729b6c8d9eb9e4fe333141d97b Mon Sep 17 00:00:00 2001 From: Andras Elso Date: Tue, 3 Mar 2020 01:38:03 +0100 Subject: dhcp-server: T2062: Fix static route bytes --- src/conf_mode/dhcp_server.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/conf_mode/dhcp_server.py') diff --git a/src/conf_mode/dhcp_server.py b/src/conf_mode/dhcp_server.py index bf86e484b..0c7990105 100755 --- a/src/conf_mode/dhcp_server.py +++ b/src/conf_mode/dhcp_server.py @@ -594,17 +594,14 @@ def get_config(): # add netmask string = str(net.prefixlen) + ',' # add network bytes - bytes = str(net.network_address).split('.') - for b in bytes: - if b != '0': - string += b + ',' + if net.prefixlen: + width = net.prefixlen // 8 + if net.prefixlen % 8: + width += 1 + string += ','.join(map(str,tuple(net.network_address.packed)[:width])) + ',' # add router bytes - bytes = subnet['static_router'].split('.') - for b in bytes: - string += b - if b is not bytes[-1]: - string += ',' + string += ','.join(subnet['static_router'].split('.')) subnet['static_route'] = string -- cgit v1.2.3