📄 dhcp_comm.h
字号:
unsigned int retryTO;
unsigned int leaseTime;
unsigned int leaseRenewTime;
unsigned int leaseRebindTime;
}St_DhcpProxy;
/*
* This structure contains information for a relay agent used to
* communicate with DHCP clients or servers on other networks.
*/
typedef struct dhcp_relay
{
struct in_addr server; /* IP address of DHCP server in CSN */
/*struct in_addr server_mask;*/ /* netmask of DHCP server in CSN */
}St_DhcpRelay;
/*
* This structure defines the components of an address pool entry.
* The DHCP server issues leases for individual IP addresses from
* the address pool.
*/
typedef struct dhcp_lap_pool
{
unsigned int status; /* status of this lap pool */
unsigned int index; /* 0...DHCP_MAX_NUM_LAP_POOL-1 */
unsigned int cmIndex;/* kept from CM */
/* network order returned by inet_addr() */
unsigned int subnet; /* subnet */
unsigned int subnet_mask; /* subnet mask */
unsigned int startAddr; /* first IP address in range */
unsigned int endAddr; /* last IP address in range */
}St_DhcpLapPool;
/*
* DHCP CM data
*/
#define DHCP_MAX_NUM_LAP_POOL 32
#define DHCP_MAX_NUM_SERVER 6
typedef struct dhcp_cm
{
/* proxy */
BOOL lapEnabled;
char sname [MAX_SNAME + 1]; /* server host name */
struct dhcp_proxy proxy;
/* lap pool information when lapEnabled */
unsigned int lapPoolNum; /* dhcp lap pool num for GW proxy lap func, <= DHCP_MAX_NUM_LAP_POOL*/
struct dhcp_lap_pool lapPool[DHCP_MAX_NUM_LAP_POOL];
/* relay information */
BOOL relayEnabled;
unsigned int relayNum; /* dhcp server num for GW relay func */
struct dhcp_relay relay[DHCP_MAX_NUM_SERVER];
}St_DhcpCm;
/*
* DHCP Global data
*/
typedef struct dhcp_global_config
{
/* global */
int dhcpMaxHops; /* max hops */
int dhcpServerPort; /* server port */
int dhcpClientPort; /* client port */
int dhcpMaxMsgSize; /* max msg size */
unsigned int dhcpDefaultLease; /* Default for default lease length */
unsigned int dhcpMaxLease; /* Default maximum lease length */
unsigned int localIp;
unsigned int mixed_subnet;
/*AEP_TMR_ID tmrId;*/ /* dhcp to monitor lease time to client */
St_DhcpCm cm;
}St_DhcpGlobalCfg;
extern St_DhcpGlobalCfg gDhcpGlobalCfg;
typedef struct dhcp_proxy_stat
{
/* proxy */
unsigned int rxDiscover;
unsigned int rxRequest;
unsigned int rxDecline;
unsigned int rxRelease;
unsigned int rxInform;
unsigned int txOffer;
unsigned int txAck;
unsigned int txNak;
unsigned int relDueToLeaseTO;
unsigned int relDueToMsInit;
unsigned int failDueToNoResource;
unsigned int failDueToMsTO;
}St_DhcpProxyStat;
typedef struct dhcp_relay_stat
{
/* MS <--------> GW <-------> Server */
unsigned int rxDiscoverFromMs;
unsigned int txDiscoverToSvr;
unsigned int rxRequestFromMs;
unsigned int txRequestToSvr;
unsigned int rxDeclineFromMs;
unsigned int txDeclineToSvr;
unsigned int rxReleaseFromMs;
unsigned int txReleaseToSvr;
unsigned int rxInformFromMs;
unsigned int txInformToSvr;
unsigned int rxOfferFromSvr;
unsigned int txOfferToMs;
unsigned int rxAckFromSvr;
unsigned int txAckToMs;
unsigned int rxNakFromSvr;
unsigned int txNakToMs;
unsigned int relDueToLeaseTO;
unsigned int relDueToMsInit;
}St_DhcpRelayStat;
typedef struct dhcp_stat
{
unsigned int actProxy;
unsigned int actProxyLap;
unsigned int actRelay;
St_DhcpProxyStat proxyStat;
St_DhcpRelayStat relayStat;
}St_DhcpStat;
extern St_DhcpStat gDhcpStat;
extern unsigned int gNumBinded;
extern struct msg dhcpsMsgIn;
extern struct msg dhcpsMsgOut;
extern struct buf_vec sbufvec[];
/*extern SEM_ID dhcpMutexSem;*/
extern St_DhcpStat gDhcpStat;
extern St_DhcpGlobalCfg gDhcpGlobalCfg;
extern GW_UP_DHCP_MSG *gpGwUpDhcpMsgOut;
extern St_DhcpRes_List gDhcpResLapFreeList[DHCP_MAX_NUM_LAP_POOL];
extern St_DhcpBinding_List gDhcpBindMonList[DHCP_MONITOR_HASH_LEN];
extern St_DhcpBinding_List gDhcpBindIpList[DHCP_IP_HASH_LEN];
extern St_DhcpBinding_List gDhcpBindMonTmpList[DHCP_MONITOR_HASH_LEN];
extern int AEP_DhcpInit(St_DhcpCm *pDhcpCm,unsigned int reInit);
extern char * pickup_opt (struct dhcp *, int, char);
extern time_t dhcp_time (time_t *timer);
extern u_short dhcp_checksum(u_short * pAddr, int len);
extern BOOL check_ipsum (struct ip *pIph);
extern int check_udpsum(struct ip *pIph, struct udphdr * pUdph);
extern u_short get_ipsum(struct ip *pIph);
extern u_short get_udpsum(struct ip *pIph,struct udphdr *pUdph);
extern St_DhcpRes* AEP_DhcpAllocRes(unsigned int dhcp_acting);
extern St_DhcpRes* AEP_DhcpAllocResLap(unsigned int subnet);
extern St_DhcpBinding* AEP_DhcpAllocBinding(St_DhcpRes *pRes,St_AepUeCtxt *pUeCtxt);
extern int AEP_DhcpFreeRes(St_DhcpRes *pRes);
extern int AEP_DhcpFreeBinding(St_DhcpBinding *pBinding);
extern int AEP_DhcpBindSetHash(St_DhcpBinding *pBinding,struct client_id *pCid,GW_UP_DHCP_MSG *pDhcpMsgIn);
extern int AEP_DhcpUpdateFsmState(St_DhcpBinding *pBinding,unsigned int msgType);
extern int AEP_DhcpFreeWRingBuf();
extern int AEP_DhcpGetWRingBuf(int maxSize,GW_UP_DHCP_MSG *pDhcpMsgIn,GWUPMSGTYPE msgType);
extern St_DhcpBinding* AEP_DhcpBind_Lookup_By_Cid_Haddr(struct client_id *pCid,
struct chaddr *pHaddr,unsigned int cidFlag);
extern void dump_cid_haddr(struct client_id *pCid,struct chaddr *pHaddr);
#define checksum dhcp_checksum
#define DHCP_PRINT_FLAG() do {\
printf("**********************************************************************************\n");\
}while(0)
#define DHCP_PRINT_FLAG2(index) do {\
printf("%4d******************************************************************************\n",index);\
}while(0)
#define DHCP_PRINT_CID(pBinding) do {\
DHCP_ASSERT(DHCP_BINDING_GOOD(pBinding));\
printf("cid 0x%02x%02x%02x-%02x%02x%02x, idtype %d, idlen %d\n",\
pBinding->cid.id[0],pBinding->cid.id[1],pBinding->cid.id[2],\
pBinding->cid.id[3],pBinding->cid.id[4],pBinding->cid.id[5],\
pBinding->cid.idtype,pBinding->cid.idlen);\
}while(0)
#define DHCP_PRINT_CHADDR(pBinding) do {\
DHCP_ASSERT(DHCP_BINDING_GOOD(pBinding));\
printf("chaddr 0x%02x%02x%02x-%02x%02x%02x, htype %d, hlen %d\n",\
pBinding->haddr.haddr[0],pBinding->haddr.haddr[1],pBinding->haddr.haddr[2],\
pBinding->haddr.haddr[3],pBinding->haddr.haddr[4],pBinding->haddr.haddr[5],\
pBinding->haddr.htype,pBinding->haddr.hlen); \
}while(0)
#define DHCP_PRINT_R1MAC(pBinding) do {\
DHCP_ASSERT(DHCP_BINDING_GOOD(pBinding));\
printf("\tr1MacAddr 0x%02x%02x%02x-%02x%02x%02x\n",\
pBinding->r1MacAddr[0],pBinding->r1MacAddr[1],pBinding->r1MacAddr[2],\
pBinding->r1MacAddr[3],pBinding->r1MacAddr[4],pBinding->r1MacAddr[5]);\
}while(0)
#define DHCP_PRINT_STATE(pBinding) do {\
DHCP_ASSERT(DHCP_BINDING_GOOD(pBinding));\
printf("\tstate %d - %s\n",pBinding->state,gDhcpStateString[pBinding->state]);\
}while(0)
#define DHCP_PRINT_HASH(pBinding) do {\
DHCP_ASSERT(DHCP_BINDING_GOOD(pBinding));\
printf("\thashed 0x%x\n", pBinding->hashed);\
if(DHCP_NODE_HASH_IS_SET(pBinding,DHCP_NODE_HASH_CID)) {printf("\thashKey_cid %d",pBinding->hashKey_cid);}; \
if(DHCP_NODE_HASH_IS_SET(pBinding,DHCP_NODE_HASH_R1)) {printf("\thashKey_r1 %d",pBinding->hashKey_r1);}; \
if(DHCP_NODE_HASH_IS_SET(pBinding,DHCP_NODE_HASH_MON)) {printf("\thashKey_mon %d",pBinding->hashKey_mon);}; \
if(DHCP_NODE_HASH_IS_SET(pBinding,DHCP_NODE_HASH_HADDR)) {printf("\thashKey_haddr %d",pBinding->hashKey_haddr);}; \
if(DHCP_NODE_HASH_IS_SET(pBinding,DHCP_NODE_HASH_IP)) {printf("\thashKey_ip %d",pBinding->hashKey_ip);}; \
if(DHCP_NODE_HASH_IS_SET(pBinding,DHCP_NODE_HASH_XID)) {printf("\thashKey_xid %d",pBinding->hashKey_xid);}; \
printf("\n"); \
}while(0)
#define DHCP_PRINT_EPOCH(pBinding) do {\
DHCP_ASSERT(DHCP_BINDING_GOOD(pBinding));\
printf("\texpire_epoch %d renew_epoch %d temp_epoch %d(reason %d)\n",pBinding->expire_epoch,pBinding->renew_epoch,pBinding->temp_epoch,pBinding->temp_epoch_reason);\
}while(0)
#define DHCP_PRINT_SUBNET(pBinding) do{\
DHCP_ASSERT(DHCP_BINDING_GOOD(pBinding));\
if(pBinding->subnet_reqed) {printf("\tsubnet 0x%x \n",pBinding->subnet);};\
}while(0)
#define DHCP_PRINT_VENDOR_ID(pBinding) do{\
DHCP_ASSERT(DHCP_BINDING_GOOD(pBinding));\
if(pBinding->vendor_id.len) {printf("\tvendor_id %s\n",pBinding->vendor_id.id};\
}while(0)
#define DHCP_PRINT_USER_ID(pBinding) do{\
DHCP_ASSERT(DHCP_BINDING_GOOD(pBinding));\
if(pBinding->user_id.len) {printf("\tuser_id %s\n",pBinding->user_id.id};\
}while(0)
#define DHCP_PRINT_RES(pRes) do{\
DHCP_ASSERT(DHCP_RES_GOOD(pRes));\
printf("\tRES-> dhcp_acting %d - %s\n",pRes->dhcp_acting,(pRes->dhcp_acting==1)?"Proxy":((pRes->dhcp_acting==2)?"Proxy_Lap":"Relay"));\
if(DHCP_ISSET(pRes->valid,S_DNS_DOMAIN)) printf("\t\tdns domain name %s\n",gDhcpClientGlobalConfig.domainName);\
if(DHCP_ISSET(pRes->valid,S_IP_ADDR)) printf("\t\tip 0x%lx\n",pRes->ip_addr.s_addr);\
if(DHCP_ISSET(pRes->valid,S_SIADDR)) printf("\t\tserver ip 0x%lx\n",pRes->siaddr.s_addr);\
if(DHCP_ISSET(pRes->valid,S_SUBNET_MASK)) printf("\t\tsunet mask 0x%lx\n",pRes->subnet_mask.s_addr);\
if(DHCP_ISSET(pRes->valid,S_ROUTER)) printf("\t\trouter 0x%lx\n",pRes->router.addr[0].s_addr);\
if(DHCP_ISSET(pRes->valid,S_DNS_SERVER)) { \
printf("\t\tdns server primary 0x%lx\n",pRes->dns_server.addr[0].s_addr);\
if(pRes->dns_server.num == 2) \
printf("\t\tdns server secondary 0x%lx\n",pRes->dns_server.addr[1].s_addr);\
}\
if(DHCP_ISSET(pRes->valid,S_DEFAULT_LEASE)) printf("\t\tdefault lease %ld\n",pRes->default_lease);\
if(DHCP_ISSET(pRes->valid,S_MAX_LEASE)) printf("\t\tmax lease %ld\n",pRes->max_lease);\
if(DHCP_ISSET(pRes->valid,S_DHCP_T1)) printf("\t\tt1 %d\n",pRes->dhcp_t1);\
if(DHCP_ISSET(pRes->valid,S_DHCP_T2)) printf("\t\tt2 %d\n",pRes->dhcp_t2);\
printf("\t\treq lease %ld\n",pRes->req_lease);\
printf("\t\toffer lease %ld\n",pRes->offer_lease);\
}while(0)
#define DHCP_PRINT_RES1(pBinding) do { \
DHCP_ASSERT(DHCP_BINDING_GOOD(pBinding)); \
if(pBinding->pRes) {DHCP_PRINT_RES(pBinding->pRes);} \
}while(0)
extern int AEP_DhcpDumpAllRes();
extern int AEP_DhcpDumpAllBinding();
extern int AEP_DhcpDumpRes(St_DhcpRes *pRes);
extern int AEP_DhcpDumpBinding(unsigned char *pCid,unsigned char *pHaddr);
extern int AEP_DhcpDumpBinding2(unsigned int ipAddr);
extern int AEP_DhcpDumpBinding3(St_DhcpBinding *pBinding);
#define DEBUG_DUMP_CID_HADDR(pCid,pHaddr) do {dump_cid_haddr(pCid,pHaddr);}while(0)
#define DEBUG_UT_DHCP_BINDING(pBinding) do {AEP_DhcpDumpBinding3(pBinding);}while(0)
#define DEBUG_UT_DHCP(str,pDhcp,offset) do{TRACE0(str);DUMP0(pDhcp,DFLTDHCPLEN-DFLTOPTLEN+offset);}while(0)
#ifdef __cplusplus
}
#endif
#endif /*_DHCP_COMM_H_*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -