From b05a69ec546f1d5617e3c149143cc161fd8fb8e9 Mon Sep 17 00:00:00 2001 From: Amin Ben Romdhane Date: Wed, 29 Nov 2023 15:45:02 +0000 Subject: [PATCH] B#12795: don't convert clientid option to hex --- libbbfdm-api/dmcommon.c | 1 + libbbfdm/dmtree/tr181/dhcpv4.c | 6 +++--- test/files/etc/config/network | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libbbfdm-api/dmcommon.c b/libbbfdm-api/dmcommon.c index aeaabd08..d9946e73 100644 --- a/libbbfdm-api/dmcommon.c +++ b/libbbfdm-api/dmcommon.c @@ -125,6 +125,7 @@ struct dhcp_options_type DHCP_OPTIONS_ARRAY[] = { {"", 58, OPTION_INT, 4}, /* DHCP_RENEWAL_TIME */ {"", 59, OPTION_INT, 4}, /* DHCP_REBINDING_TIME */ {"vendor", 60, OPTION_STRING, 0}, /* DHCP_VENDOR */ +{"", 61, OPTION_HEX, 1}, /* DHCP_CLIENT_IDENTIFIER */ {"", 65, OPTION_IP, 4}, /* DHCP_NIS_SERVER_ADDR */ {"tftp", 66, OPTION_STRING, 0}, /* DHCP_TFTP_SERVER_NAME */ {"bootfile", 67, OPTION_STRING, 0}, /* DHCP_BOOT_FILE */ diff --git a/libbbfdm/dmtree/tr181/dhcpv4.c b/libbbfdm/dmtree/tr181/dhcpv4.c index 2a838d9a..9999248f 100644 --- a/libbbfdm/dmtree/tr181/dhcpv4.c +++ b/libbbfdm/dmtree/tr181/dhcpv4.c @@ -2641,7 +2641,7 @@ static int set_DHCPv4ClientSentOption_Enable(char *refparam, struct dmctx *ctx, char str[256] = {0}; convert_hex_to_string(dhcp_client_s->value, str, sizeof(str)); - dmuci_set_value_by_section(dhcp_client_s->client_sect, option_name, b ? str : ""); + dmuci_set_value_by_section(dhcp_client_s->client_sect, option_name, b ? (DM_STRTOL(dhcp_client_s->option_tag) == DHCP_OPTION_CLIENTID) ? dhcp_client_s->value : str : ""); } } @@ -2716,7 +2716,7 @@ static int set_DHCPv4ClientSentOption_Tag(char *refparam, struct dmctx *ctx, voi dmuci_set_value_by_section(dhcp_client_s->client_sect, "sendopts", sendopts); } else { convert_hex_to_string(dhcp_client_s->value, str, sizeof(str)); - dmuci_set_value_by_section(dhcp_client_s->client_sect, option_name, str); + dmuci_set_value_by_section(dhcp_client_s->client_sect, option_name, (DM_STRTOL(value) == DHCP_OPTION_CLIENTID) ? dhcp_client_s->value : str); } } } @@ -2771,7 +2771,7 @@ static int set_DHCPv4ClientSentOption_Value(char *refparam, struct dmctx *ctx, v dmuci_set_value_by_section(dhcp_client_s->client_sect, "sendopts", sendopts); } else { convert_hex_to_string(value, str, sizeof(str)); - dmuci_set_value_by_section(dhcp_client_s->client_sect, option_name, str); + dmuci_set_value_by_section(dhcp_client_s->client_sect, option_name, (DM_STRTOL(dhcp_client_s->option_tag) == DHCP_OPTION_CLIENTID) ? value : str); } } } diff --git a/test/files/etc/config/network b/test/files/etc/config/network index d8811600..0c097fe0 100644 --- a/test/files/etc/config/network +++ b/test/files/etc/config/network @@ -29,7 +29,7 @@ config interface 'wan' option proto 'dhcp' option hostname 'iopsysWrt-44D43771B810' option vendorid 'dslforum.org' - option clientid '44:D4:37:71:B8:10' + option clientid '01:44:D4:37:71:B8:10' option device 'eth0' option reqopts '12 43 55' option sendopts '0x38:6661696c20746f20636f6e6e656374 125:00:00:0D:E9:1C:01:06:34:34:44:34:33:37:02:0B:59:30:37:32:31:31:34:30:30:38:36:03:05:45:41:47:4C:45 lease:3600 41:C0A80A0C0A0C013F2D2D2D15 router:10.10.10.8,35.35.40.45,192.168.11.11'