parent
47c3f0b4f6
commit
34b91e6efc
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
COL_INDEX = 0,
|
COL_INDEX = 0,
|
||||||
|
COL_VNI,
|
||||||
COL_MAC,
|
COL_MAC,
|
||||||
COL_HOSTNAME,
|
COL_HOSTNAME,
|
||||||
COL_DISCOVER,
|
COL_DISCOVER,
|
||||||
|
@ -20,6 +21,7 @@ typedef enum {
|
||||||
COL_STATUS,
|
COL_STATUS,
|
||||||
|
|
||||||
COL_ATTR_EDITABLE,
|
COL_ATTR_EDITABLE,
|
||||||
|
COL_ATTR_VISIABLE,
|
||||||
NUM_COLS
|
NUM_COLS
|
||||||
} COL_NAME;
|
} COL_NAME;
|
||||||
|
|
||||||
|
@ -44,19 +46,19 @@ typedef struct {
|
||||||
} BUF_INFO, *PBUF_INFO;
|
} BUF_INFO, *PBUF_INFO;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
U32 index;
|
U32 index;
|
||||||
U32 vni;
|
U32 vni;
|
||||||
U8 mac[6];
|
U8 mac[6];
|
||||||
S8 hostname[64];
|
S8 hostname[64];
|
||||||
DHCP_STEP step;
|
DHCP_STEP step;
|
||||||
DHCP_STATUS status;
|
DHCP_STATUS status;
|
||||||
BUF_INFO pDiscBuf;
|
BUF_INFO pDiscBuf;
|
||||||
BUF_INFO pOfferBuf;
|
BUF_INFO pOfferBuf;
|
||||||
BUF_INFO pReqBuf;
|
BUF_INFO pReqBuf;
|
||||||
BUF_INFO pAckBuf;
|
BUF_INFO pAckBuf;
|
||||||
DHCP_RSP offerRsp;
|
DHCP_RSP offerRsp;
|
||||||
DHCP_RSP ackRsp;
|
DHCP_RSP ackRsp;
|
||||||
UT_hash_handle hh;
|
UT_hash_handle hh;
|
||||||
} DHCP_INFO, *PDHCP_INFO;
|
} DHCP_INFO, *PDHCP_INFO;
|
||||||
|
|
||||||
U32 rand_number();
|
U32 rand_number();
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
//
|
//
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <zlog.h>
|
#include <zlog.h>
|
||||||
#include "common.h"
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "task_manager.h"
|
#include "task_manager.h"
|
||||||
|
@ -44,8 +43,7 @@ static void load_css(void) {
|
||||||
display = gdk_display_get_default();
|
display = gdk_display_get_default();
|
||||||
screen = gdk_display_get_default_screen(display);
|
screen = gdk_display_get_default_screen(display);
|
||||||
|
|
||||||
gtk_style_context_add_provider_for_screen(screen,
|
gtk_style_context_add_provider_for_screen(screen, GTK_STYLE_PROVIDER(provider),
|
||||||
GTK_STYLE_PROVIDER(provider),
|
|
||||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
|
||||||
gtk_css_provider_load_from_file(provider, css_fp, &error);
|
gtk_css_provider_load_from_file(provider, css_fp, &error);
|
||||||
|
@ -74,40 +72,66 @@ static void tree_view_data_store_create() {
|
||||||
int i, j;
|
int i, j;
|
||||||
PDHCP_INFO pInfo, pTemp;
|
PDHCP_INFO pInfo, pTemp;
|
||||||
GtkTreeIter iter, iter_child, iter_sub;
|
GtkTreeIter iter, iter_child, iter_sub;
|
||||||
GtkWidget *view = GTK_WIDGET(gtk_builder_get_object(g_mainBuilder, "treeResult"));
|
GtkWidget *view = GTK_WIDGET(gtk_builder_get_object(g_mainBuilder, "treeResult"));
|
||||||
GtkListStore *store = GTK_LIST_STORE(gtk_builder_get_object(g_mainBuilder, "tsDhcpInfo"));
|
GtkTreeStore *store = GTK_TREE_STORE(gtk_builder_get_object(g_mainBuilder, "tsDhcpInfo"));
|
||||||
|
GtkWidget *vniStart = GTK_WIDGET(gtk_builder_get_object(g_mainBuilder, "sbVni"));
|
||||||
|
GtkWidget *numRequest = GTK_WIDGET(gtk_builder_get_object(g_mainBuilder, "sbReqNum"));
|
||||||
|
int nRequest = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(numRequest));
|
||||||
|
int nVni = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(vniStart));
|
||||||
|
|
||||||
gtk_tree_view_set_model(GTK_TREE_VIEW(view), NULL);
|
gtk_tree_view_set_model(GTK_TREE_VIEW(view), NULL);
|
||||||
gtk_list_store_clear(store);
|
gtk_tree_store_clear(store);
|
||||||
|
|
||||||
HASH_ITER(hh, g_pDhcpInfo, pInfo, pTemp) {
|
for (i = 0; i < nRequest; i++) {
|
||||||
char mac[24] = {0};
|
int isCreateRoot = FALSE;
|
||||||
sprintf(mac,
|
|
||||||
"%02X:%02X:%02X:%02X:%02X:%02X",
|
|
||||||
pInfo->mac[0],
|
|
||||||
pInfo->mac[1],
|
|
||||||
pInfo->mac[2],
|
|
||||||
pInfo->mac[3],
|
|
||||||
pInfo->mac[4],
|
|
||||||
pInfo->mac[5]);
|
|
||||||
|
|
||||||
gtk_list_store_append(store, &iter);
|
HASH_ITER(hh, g_pDhcpInfo, pInfo, pTemp) {
|
||||||
|
if (pInfo->vni == (nVni + i)) {
|
||||||
|
char idx[64] = {0};
|
||||||
|
char mac[24] = {0};
|
||||||
|
sprintf(mac, "%02X:%02X:%02X:%02X:%02X:%02X", pInfo->mac[0], pInfo->mac[1], pInfo->mac[2],
|
||||||
|
pInfo->mac[3], pInfo->mac[4], pInfo->mac[5]);
|
||||||
|
|
||||||
// clang-format off
|
if (!isCreateRoot) {
|
||||||
gtk_list_store_set(store,
|
sprintf(idx, "VNI %d", nVni + i);
|
||||||
|
// 创建根节点
|
||||||
|
gtk_tree_store_append(store, &iter, NULL);
|
||||||
|
// clang-format off
|
||||||
|
gtk_tree_store_set(store,
|
||||||
&iter,
|
&iter,
|
||||||
COL_INDEX, pInfo->index,
|
COL_INDEX, idx,
|
||||||
COL_MAC, mac,
|
|
||||||
COL_HOSTNAME, pInfo->hostname,
|
|
||||||
COL_DISCOVER, calc_step_progress(pInfo, STEP_DISCOVER),
|
|
||||||
COL_OFFER, calc_step_progress(pInfo, STEP_OFFER),
|
|
||||||
COL_REQUEST, calc_step_progress(pInfo, STEP_REQUEST),
|
|
||||||
COL_ACK, calc_step_progress(pInfo, STEP_ACK),
|
|
||||||
COL_RESULT, "",
|
COL_RESULT, "",
|
||||||
COL_STATUS, calc_total_progress(pInfo),
|
COL_STATUS, calc_total_progress(pInfo),
|
||||||
COL_ATTR_EDITABLE, FALSE,
|
COL_ATTR_EDITABLE, FALSE,
|
||||||
|
COL_ATTR_VISIABLE, FALSE,
|
||||||
-1);
|
-1);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
isCreateRoot = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_tree_store_append(store, &iter_child, &iter);
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
// 创建子节点
|
||||||
|
memset(idx, 0, 64);
|
||||||
|
sprintf(idx, "%u", pInfo->index);
|
||||||
|
gtk_tree_store_set(store,
|
||||||
|
&iter_child,
|
||||||
|
COL_INDEX, idx,
|
||||||
|
COL_MAC, mac,
|
||||||
|
COL_HOSTNAME, pInfo->hostname,
|
||||||
|
COL_DISCOVER, calc_step_progress(pInfo, STEP_DISCOVER),
|
||||||
|
COL_OFFER, calc_step_progress(pInfo, STEP_OFFER),
|
||||||
|
COL_REQUEST, calc_step_progress(pInfo, STEP_REQUEST),
|
||||||
|
COL_ACK, calc_step_progress(pInfo, STEP_ACK),
|
||||||
|
COL_RESULT, "",
|
||||||
|
COL_STATUS, calc_total_progress(pInfo),
|
||||||
|
COL_ATTR_EDITABLE, FALSE,
|
||||||
|
COL_ATTR_VISIABLE, TRUE,
|
||||||
|
-1);
|
||||||
|
// clang-format on
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));
|
gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));
|
||||||
|
@ -165,9 +189,10 @@ static void tree_view_data_store_create() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean tree_view_data_store_upgade(gpointer pInfo) {
|
static gboolean tree_view_data_store_upgade(gpointer pInfo) {
|
||||||
|
#if 0
|
||||||
char buf[32] = {0};
|
char buf[32] = {0};
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
GtkListStore *store = GTK_LIST_STORE(gtk_builder_get_object(g_mainBuilder, "tsDhcpInfo"));
|
GtkTreeStore *store = GTK_TREE_STORE(gtk_builder_get_object(g_mainBuilder, "tsDhcpInfo"));
|
||||||
|
|
||||||
if (!pInfo) {
|
if (!pInfo) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -177,7 +202,7 @@ static gboolean tree_view_data_store_upgade(gpointer pInfo) {
|
||||||
|
|
||||||
if (gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(store), &iter, buf)) {
|
if (gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(store), &iter, buf)) {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
gtk_list_store_set(store,
|
gtk_tree_store_set(store,
|
||||||
&iter,
|
&iter,
|
||||||
COL_DISCOVER, calc_step_progress(pInfo, STEP_DISCOVER),
|
COL_DISCOVER, calc_step_progress(pInfo, STEP_DISCOVER),
|
||||||
COL_OFFER, calc_step_progress(pInfo, STEP_OFFER),
|
COL_OFFER, calc_step_progress(pInfo, STEP_OFFER),
|
||||||
|
@ -186,10 +211,11 @@ static gboolean tree_view_data_store_upgade(gpointer pInfo) {
|
||||||
COL_RESULT, "",
|
COL_RESULT, "",
|
||||||
COL_STATUS, calc_total_progress(pInfo),
|
COL_STATUS, calc_total_progress(pInfo),
|
||||||
COL_ATTR_EDITABLE, FALSE,
|
COL_ATTR_EDITABLE, FALSE,
|
||||||
|
COL_ATTR_VISIABLE, TRUE,
|
||||||
-1);
|
-1);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +236,7 @@ int cacheDhcpOfferBuffer(PDHCP_INFO pInfo, U8 *pBuf, int size) {
|
||||||
return -ERR_MALLOC_MEMORY;
|
return -ERR_MALLOC_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *dhcpThreadCb(void *pData) {
|
_Noreturn static void *dhcpThreadCb(void *pData) {
|
||||||
U8 *pkg;
|
U8 *pkg;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
PDHCP_INFO pInfo, pTemp;
|
PDHCP_INFO pInfo, pTemp;
|
||||||
|
@ -286,7 +312,6 @@ static void *dhcpThreadCb(void *pData) {
|
||||||
|
|
||||||
LOG_MSG(debug, "DHCP status mathine exit......\n");
|
LOG_MSG(debug, "DHCP status mathine exit......\n");
|
||||||
g_thread_exit(NULL);
|
g_thread_exit(NULL);
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cleanupDHCPInfo() {
|
static void cleanupDHCPInfo() {
|
||||||
|
@ -341,28 +366,28 @@ G_MODULE_EXPORT void __mainWnd_on_tb_start(GObject *object, gpointer user_data)
|
||||||
for (i = 0; i < nRequest; i++) {
|
for (i = 0; i < nRequest; i++) {
|
||||||
for (j = 0; j < nVniCnt; j++) {
|
for (j = 0; j < nVniCnt; j++) {
|
||||||
U32 macAddr = macVal + index;
|
U32 macAddr = macVal + index;
|
||||||
pInfo = (PDHCP_INFO)malloc(sizeof(DHCP_INFO));
|
pInfo = (PDHCP_INFO)malloc(sizeof(DHCP_INFO));
|
||||||
|
|
||||||
if (pInfo == NULL) {
|
if (pInfo == NULL) {
|
||||||
fprintf(stderr, "Malloc %lu bytes memory error of %d\n", sizeof(DHCP_INFO), i);
|
fprintf(stderr, "Malloc %lu bytes memory error of %d\n", sizeof(DHCP_INFO), i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(pInfo, 0, sizeof(DHCP_INFO));
|
memset(pInfo, 0, sizeof(DHCP_INFO));
|
||||||
pInfo->index = index;
|
pInfo->index = index;
|
||||||
pInfo->vni = nVni + i;
|
pInfo->vni = nVni + i;
|
||||||
pInfo->mac[0] = mac[0];
|
pInfo->mac[0] = mac[0];
|
||||||
pInfo->mac[1] = mac[1];
|
pInfo->mac[1] = mac[1];
|
||||||
pInfo->mac[2] = (macAddr & 0xFF000000) >> 24;
|
pInfo->mac[2] = (macAddr & 0xFF000000) >> 24;
|
||||||
pInfo->mac[3] = (macAddr & 0xFF0000) >> 16;
|
pInfo->mac[3] = (macAddr & 0xFF0000) >> 16;
|
||||||
pInfo->mac[4] = (macAddr & 0xFF00) >> 8;
|
pInfo->mac[4] = (macAddr & 0xFF00) >> 8;
|
||||||
pInfo->mac[5] = (macAddr & 0xFF);
|
pInfo->mac[5] = (macAddr & 0xFF);
|
||||||
|
|
||||||
sprintf(pInfo->hostname, "%s_%u", strPreHostname, pInfo->vni + index);
|
sprintf(pInfo->hostname, "%s_%u", strPreHostname, pInfo->vni + index);
|
||||||
pInfo->step = STEP_BEGIN;
|
pInfo->step = STEP_BEGIN;
|
||||||
pInfo->status = STA_WAIT_START;
|
pInfo->status = STA_WAIT_START;
|
||||||
|
|
||||||
HASH_ADD_INT(g_pDhcpInfo, index, pInfo);
|
HASH_ADD_INT(g_pDhcpInfo, index, pInfo);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,11 @@
|
||||||
<column type="gchararray"/>
|
<column type="gchararray"/>
|
||||||
</columns>
|
</columns>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkListStore" id="tsDhcpInfo">
|
<object class="GtkTreeStore" id="tsDhcpInfo">
|
||||||
<columns>
|
<columns>
|
||||||
<!-- column-name cIndex -->
|
<!-- column-name cIndex -->
|
||||||
|
<column type="gchararray"/>
|
||||||
|
<!-- column-name cVni -->
|
||||||
<column type="guint"/>
|
<column type="guint"/>
|
||||||
<!-- column-name cMac -->
|
<!-- column-name cMac -->
|
||||||
<column type="gchararray"/>
|
<column type="gchararray"/>
|
||||||
|
@ -30,6 +32,8 @@
|
||||||
<column type="gfloat"/>
|
<column type="gfloat"/>
|
||||||
<!-- column-name cAttrPrgTest -->
|
<!-- column-name cAttrPrgTest -->
|
||||||
<column type="gboolean"/>
|
<column type="gboolean"/>
|
||||||
|
<!-- column-name cAttrVisialbe -->
|
||||||
|
<column type="gboolean"/>
|
||||||
</columns>
|
</columns>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkWindow" id="wndMain">
|
<object class="GtkWindow" id="wndMain">
|
||||||
|
@ -421,6 +425,19 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeViewColumn" id="tvcVni">
|
||||||
|
<property name="visible">False</property>
|
||||||
|
<property name="title">VNI</property>
|
||||||
|
<property name="alignment">0.5</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCellRendererText" id="cellrenderertext4"/>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="text">1</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkTreeViewColumn" id="tvcMac">
|
<object class="GtkTreeViewColumn" id="tvcMac">
|
||||||
<property name="title">MAC</property>
|
<property name="title">MAC</property>
|
||||||
|
@ -428,7 +445,8 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext2"/>
|
<object class="GtkCellRendererText" id="cellrenderertext2"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="text">1</attribute>
|
<attribute name="visible">11</attribute>
|
||||||
|
<attribute name="text">2</attribute>
|
||||||
</attributes>
|
</attributes>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -440,7 +458,8 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText" id="cellrenderertext3"/>
|
<object class="GtkCellRendererText" id="cellrenderertext3"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="text">2</attribute>
|
<attribute name="visible">11</attribute>
|
||||||
|
<attribute name="text">3</attribute>
|
||||||
</attributes>
|
</attributes>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -454,8 +473,9 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererToggle" id="crDiscover"/>
|
<object class="GtkCellRendererToggle" id="crDiscover"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="sensitive">9</attribute>
|
<attribute name="sensitive">10</attribute>
|
||||||
<attribute name="active">3</attribute>
|
<attribute name="visible">11</attribute>
|
||||||
|
<attribute name="active">4</attribute>
|
||||||
</attributes>
|
</attributes>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -469,8 +489,9 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererToggle" id="crOffer"/>
|
<object class="GtkCellRendererToggle" id="crOffer"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="sensitive">9</attribute>
|
<attribute name="sensitive">10</attribute>
|
||||||
<attribute name="active">4</attribute>
|
<attribute name="visible">11</attribute>
|
||||||
|
<attribute name="active">5</attribute>
|
||||||
</attributes>
|
</attributes>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -484,8 +505,9 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererToggle" id="crRequest"/>
|
<object class="GtkCellRendererToggle" id="crRequest"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="sensitive">9</attribute>
|
<attribute name="sensitive">10</attribute>
|
||||||
<attribute name="active">5</attribute>
|
<attribute name="visible">11</attribute>
|
||||||
|
<attribute name="active">6</attribute>
|
||||||
</attributes>
|
</attributes>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -499,8 +521,9 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererToggle" id="crAck"/>
|
<object class="GtkCellRendererToggle" id="crAck"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="sensitive">9</attribute>
|
<attribute name="sensitive">10</attribute>
|
||||||
<attribute name="active">6</attribute>
|
<attribute name="visible">11</attribute>
|
||||||
|
<attribute name="active">7</attribute>
|
||||||
</attributes>
|
</attributes>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -514,7 +537,7 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText" id="crResult"/>
|
<object class="GtkCellRendererText" id="crResult"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="text">7</attribute>
|
<attribute name="text">8</attribute>
|
||||||
</attributes>
|
</attributes>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -528,7 +551,7 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererProgress" id="cellrendererprogress1"/>
|
<object class="GtkCellRendererProgress" id="cellrendererprogress1"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="value">8</attribute>
|
<attribute name="value">9</attribute>
|
||||||
</attributes>
|
</attributes>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
Loading…
Reference in New Issue