OCT 1.删除无用变量 2.添加dhcp_tools请求参数类型

This commit is contained in:
dongwenze 2023-05-05 10:15:08 +08:00
parent 9d6dae9171
commit 4285e264da
2 changed files with 11 additions and 8 deletions

View File

@ -119,7 +119,6 @@ static void add_dhcp_tree_colums(GtkWidget *treeView) {
#define ADD_SUB_OPTION(code, len, val) \ #define ADD_SUB_OPTION(code, len, val) \
do { \ do { \
int count_flag = 0; \ int count_flag = 0; \
char *p; \
gtk_tree_store_append(store, &iterOpt, &iterSub); \ gtk_tree_store_append(store, &iterOpt, &iterSub); \
s = sdsempty(); \ s = sdsempty(); \
sprintf(s, "%u", (len)); \ sprintf(s, "%u", (len)); \
@ -135,9 +134,12 @@ static void add_dhcp_tree_colums(GtkWidget *treeView) {
do { \ do { \
gtk_tree_store_append(store, &iterOpt, &iterSub); \ gtk_tree_store_append(store, &iterOpt, &iterSub); \
s = sdsempty(); \ s = sdsempty(); \
sprintf(s, "(%u) %s", (val)[count_flag], dhcp_get_opName((val)[count_flag]));\ t = sdsempty(); \
gtk_tree_store_set(store, &iterOpt, 0, dhcp_get_opName(code), 1, s, -1);\ 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(s); \
sdsfree(t); \
count_flag++; \ count_flag++; \
} while(count_flag != (len)); \ } while(count_flag != (len)); \
break; \ break; \
@ -165,7 +167,7 @@ static void add_dhcp_tree_colums(GtkWidget *treeView) {
s = sdsempty(); \ s = sdsempty(); \
if((code) == OPT_MESSAGETYPE) { \ if((code) == OPT_MESSAGETYPE) { \
gtk_tree_store_set(store, &iterOpt, 0, dhcp_get_opName(code), 1, g_mess_info[(val)[0]], -1);\ gtk_tree_store_set(store, &iterOpt, 0, dhcp_get_opName(code), 1, g_mess_info[(val)[0]], -1);\
} \ } \
sdsfree(s); \ sdsfree(s); \
break; \ break; \
default: \ default: \
@ -176,7 +178,7 @@ static void add_dhcp_tree_colums(GtkWidget *treeView) {
static void create_dhcp_tree_mode(PDHCP_PACKAGE p, GtkWidget *treeView) { static void create_dhcp_tree_mode(PDHCP_PACKAGE p, GtkWidget *treeView) {
// 填充右上侧 TreeView 协议数据 // 填充右上侧 TreeView 协议数据
sds s; sds s, t;
GtkTreeIter iter, iterSub, iterOpt; GtkTreeIter iter, iterSub, iterOpt;
GtkTreeStore *store = gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_STRING); 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"}; 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)); ADD_SUB_STRING("Relay agent IP address", inet_ntoa(*(struct in_addr*)&p->dhcp.giaddr));
s = sdsempty(); s = sdsempty();
MAC_TO_STR(p->dhcp.chaddr, s); MAC_TO_STR(p->dhcp.chaddr, s);
ADD_SUB_STRING("Destination", s); ADD_SUB_STRING("Client MAC address", s);
sdsfree(s); sdsfree(s);
if(strlen(p->dhcp.sname) != 0) if(p->dhcp.sname[0] != '\0')
ADD_SUB_STRING("Server host name", p->dhcp.sname); ADD_SUB_STRING("Server host name", p->dhcp.sname);
else else
ADD_SUB_STRING("Server host name", "not given"); 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); ADD_SUB_STRING("Boot file name", p->dhcp.file);
else else
ADD_SUB_STRING("Boot file name", "not given"); ADD_SUB_STRING("Boot file name", "not given");

View File

@ -105,6 +105,7 @@ static const DHCP_OPTION_CFG g_opCfg[] = {
{"SubnetSelectionOption", OPT_SUBNETSELECTION, 3, TRUE }, {"SubnetSelectionOption", OPT_SUBNETSELECTION, 3, TRUE },
{"DomainSearch", OPT_DOMAINSEARCH, 1, TRUE }, {"DomainSearch", OPT_DOMAINSEARCH, 1, TRUE },
{"SIPServersDHCPOption", OPT_SIPSERVERSDHCP, 1, TRUE }, {"SIPServersDHCPOption", OPT_SIPSERVERSDHCP, 1, TRUE },
{"ClasslessStaticRoute", OPT_CLASSLESSSTATICROUTE, 1, TRUE },
{"CCC", OPT_CCC, 1, TRUE }, {"CCC", OPT_CCC, 1, TRUE },
{"TFTPServerIPaddress", OPT_TFPTSERVERIPADDRESS, 3, TRUE }, {"TFTPServerIPaddress", OPT_TFPTSERVERIPADDRESS, 3, TRUE },
{"CallServerIPaddress", OPT_CALLSERVERIPADDRESS, 3, TRUE }, {"CallServerIPaddress", OPT_CALLSERVERIPADDRESS, 3, TRUE },