89 lines
1.9 KiB
C
89 lines
1.9 KiB
C
//
|
|
// Created by xajhuang on 2023/4/19.
|
|
//
|
|
|
|
#ifndef VCPE_MAIN_H
|
|
#define VCPE_MAIN_H
|
|
|
|
#include <gtk/gtk.h>
|
|
#include "uthash/uthash.h"
|
|
#include "rfc2131.h"
|
|
|
|
typedef enum {
|
|
COL_INDEX = 0,
|
|
COL_VNI,
|
|
COL_MAC,
|
|
COL_HOSTNAME,
|
|
COL_DISCOVER,
|
|
COL_OFFER,
|
|
COL_REQUEST,
|
|
COL_ACK,
|
|
COL_RESULT,
|
|
COL_STATUS,
|
|
|
|
COL_ATTR_EDITABLE,
|
|
COL_ATTR_VISIABLE,
|
|
NUM_COLS
|
|
} COL_NAME;
|
|
|
|
typedef enum {
|
|
COL_DHCP_ITEM = 0,
|
|
COL_DHCP_VALUE,
|
|
|
|
COL_ITEM_ATTR_VISIABLE,
|
|
COL_VALUE_ATTR_VISIABLE,
|
|
NUM_DHCP_COLS
|
|
} COL_DHCP_INFO_NAME;
|
|
|
|
typedef enum {
|
|
STEP_BEGIN = 0,
|
|
STEP_DISCOVER,
|
|
STEP_OFFER,
|
|
STEP_REQUEST,
|
|
STEP_ACK,
|
|
STEP_END,
|
|
} DHCP_STEP;
|
|
|
|
typedef enum {
|
|
STA_WAIT_START = 0,
|
|
STA_SEND_REQ,
|
|
STA_RECV_RSP
|
|
} DHCP_STATUS;
|
|
|
|
typedef struct {
|
|
U8 *p;
|
|
int buf_size;
|
|
unsigned int tm;
|
|
} BUF_INFO, *PBUF_INFO;
|
|
|
|
typedef struct {
|
|
U32 index;
|
|
U32 vni;
|
|
U8 mac[6];
|
|
S8 hostname[64];
|
|
DHCP_STEP step;
|
|
DHCP_STATUS status;
|
|
BUF_INFO pDiscBuf;
|
|
BUF_INFO pOfferBuf;
|
|
BUF_INFO pReqBuf;
|
|
BUF_INFO pAckBuf;
|
|
DHCP_RSP offerRsp;
|
|
DHCP_RSP ackRsp;
|
|
S8 treeId[32];
|
|
UT_hash_handle hh;
|
|
} DHCP_INFO, *PDHCP_INFO;
|
|
|
|
U32 rand_number();
|
|
PDHCP_INFO get_dhcp_info_by_id(U32 xid);
|
|
int dhcp_tools_init_network(const char *pNicName);
|
|
U8 *dhcp_create_discover_req(PDHCP_INFO pInfo, int *pOutSize);
|
|
U8 *dhcp_create_request_req(PDHCP_INFO pInfo, int *pOutSize);
|
|
int cacheDhcpOfferBuffer(PDHCP_INFO pInfo, U8 *pBuf, int size);
|
|
int cacheDhcpAckBuffer(PDHCP_INFO pInfo, U8 *pBuf, int size);
|
|
void details_wnd_create(GtkBuilder *builder);
|
|
void details_wnd_show(PDHCP_INFO pInfo);
|
|
void hex_wnd_create(GtkBuilder *builder);
|
|
void hex_wnd_show(PDHCP_INFO pInfo);
|
|
GtkBuilder *get_main_builder();
|
|
#endif //VCPE_MAIN_H
|