From 4285e264da030a8c397f6c8449bc4f88a8cdfeec Mon Sep 17 00:00:00 2001
From: dongwenze <dongwenze@cmhi.chinamobile.com>
Date: Fri, 5 May 2023 10:15:08 +0800
Subject: [PATCH] =?UTF-8?q?OCT=201.=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?=
 =?UTF-8?q?=E5=8F=98=E9=87=8F=202.=E6=B7=BB=E5=8A=A0dhcp=5Ftools=E8=AF=B7?=
 =?UTF-8?q?=E6=B1=82=E5=8F=82=E6=95=B0=E7=B1=BB=E5=9E=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 dhcp_tools/detail_wnd.c          | 18 ++++++++++--------
 srcs/service/dhcpd/dhcp_option.c |  1 +
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/dhcp_tools/detail_wnd.c b/dhcp_tools/detail_wnd.c
index d141a9d..e9371b4 100644
--- a/dhcp_tools/detail_wnd.c
+++ b/dhcp_tools/detail_wnd.c
@@ -119,7 +119,6 @@ static void add_dhcp_tree_colums(GtkWidget *treeView) {
 #define ADD_SUB_OPTION(code, len, val)                                                      \
     do {                                                                                    \
         int count_flag = 0;                                                                 \
-        char *p;                                                                            \
         gtk_tree_store_append(store, &iterOpt, &iterSub);                                   \
         s = sdsempty();                                                                     \
         sprintf(s, "%u", (len));                                                            \
@@ -135,9 +134,12 @@ static void add_dhcp_tree_colums(GtkWidget *treeView) {
                 do {                                                                        \
                     gtk_tree_store_append(store, &iterOpt, &iterSub);                       \
                     s = sdsempty();                                                         \
-                    sprintf(s, "(%u) %s", (val)[count_flag], dhcp_get_opName((val)[count_flag]));\
-                    gtk_tree_store_set(store, &iterOpt, 0, dhcp_get_opName(code), 1, s, -1);\
+                    t = sdsempty();                                                         \
+                    sprintf(s, "(%u) %s", (val)[count_flag], dhcp_get_opName((val)[count_flag])); \
+                    sprintf(t, "%s Item", dhcp_get_opName(code));                           \
+                    gtk_tree_store_set(store, &iterOpt, 0, t, 1, s, -1);\
                     sdsfree(s);                                                             \
+                    sdsfree(t);                                                             \
                     count_flag++;                                                           \
                 } while(count_flag != (len));                                               \
                 break;                                                                      \
@@ -165,7 +167,7 @@ static void add_dhcp_tree_colums(GtkWidget *treeView) {
                 s = sdsempty();                                                             \
                 if((code) == OPT_MESSAGETYPE) {                                             \
                     gtk_tree_store_set(store, &iterOpt, 0, dhcp_get_opName(code), 1, g_mess_info[(val)[0]], -1);\
-                }                    \
+                }                                                                           \
                 sdsfree(s);                                                                 \
                 break;                                                                      \
             default:                                                                        \
@@ -176,7 +178,7 @@ static void add_dhcp_tree_colums(GtkWidget *treeView) {
 
 static void create_dhcp_tree_mode(PDHCP_PACKAGE p, GtkWidget *treeView) {
     // 填充右上侧 TreeView 协议数据
-    sds           s;
+    sds           s, t;
     GtkTreeIter   iter, iterSub, iterOpt;
     GtkTreeStore *store       = gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
     const char   *itemTitle[] = {"Ethernet II", "802.1Q Virtual LAN", "IP Version 4", "UDP", "DHCP"};
@@ -261,15 +263,15 @@ static void create_dhcp_tree_mode(PDHCP_PACKAGE p, GtkWidget *treeView) {
     ADD_SUB_STRING("Relay agent IP address", inet_ntoa(*(struct in_addr*)&p->dhcp.giaddr));
     s = sdsempty();
     MAC_TO_STR(p->dhcp.chaddr, s);
-    ADD_SUB_STRING("Destination", s);
+    ADD_SUB_STRING("Client MAC address", s);
     sdsfree(s);
 
-    if(strlen(p->dhcp.sname) != 0)
+    if(p->dhcp.sname[0] != '\0')
         ADD_SUB_STRING("Server host name", p->dhcp.sname);
     else
         ADD_SUB_STRING("Server host name", "not given");
 
-    if(strlen(p->dhcp.file) != 0)
+    if(p->dhcp.file[0] != '\0')
         ADD_SUB_STRING("Boot file name", p->dhcp.file);
     else
         ADD_SUB_STRING("Boot file name", "not given");
diff --git a/srcs/service/dhcpd/dhcp_option.c b/srcs/service/dhcpd/dhcp_option.c
index 9580056..e0888eb 100644
--- a/srcs/service/dhcpd/dhcp_option.c
+++ b/srcs/service/dhcpd/dhcp_option.c
@@ -105,6 +105,7 @@ static const DHCP_OPTION_CFG g_opCfg[] = {
     {"SubnetSelectionOption",           OPT_SUBNETSELECTION,        3, TRUE },
     {"DomainSearch",                    OPT_DOMAINSEARCH,           1, TRUE },
     {"SIPServersDHCPOption",            OPT_SIPSERVERSDHCP,         1, TRUE },
+    {"ClasslessStaticRoute",            OPT_CLASSLESSSTATICROUTE,   1, TRUE },
     {"CCC",                             OPT_CCC,                    1, TRUE },
     {"TFTPServerIPaddress",             OPT_TFPTSERVERIPADDRESS,    3, TRUE },
     {"CallServerIPaddress",             OPT_CALLSERVERIPADDRESS,    3, TRUE },