?? dhcp.h
字號:
#ifndef __DHCP_H__
#define __DHCP_H__
#include <inetLib.h>
/**
* port
*/
#define DHCP_CLIENT_PORT 68
#define DHCP_SERVER_PORT 67
/**
* packet
*/
#define BOOT_REQUEST 1
#define BOOT_REPLY 2
#define HTYPE_ETHER 1
#define ETHER_ADDR_LEN 6
#define ETH_IP 0x0800
#define DHCP_HADDR_LEN 16
#define DHCP_SNAME_LEN 64
#define DHCP_FILE_LEN 128
#define IP_HEADER_LEN 20
#define UDP_HEADER_LEN 8
#define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */\
20 + /* IP header */\
8) /* UDP header */
#define DHCP_FIXED_NON_UDP 236
/* Everything but options. */
#define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD)
#define DHCP_MTU_MAX 1500 /* ethernet */
#define DHCP_MIN_LEN 548
#define DHCP_OPTION_LEN (DHCP_MIN_LEN - DHCP_FIXED_NON_UDP)
#define DHCP_MAX_SIZE 576
/* broadcast flag 16 bits */
#define FLAG_BROADCAST "\x80\x00"
/* magic cookie 99.130.83.99 */
#define DHCP_OPTIONS_COOKIE "\x63\x82\x53\x63"
#define DHCP_OPTION_INDEX (4 + 3)
/* DHCP message types */
#define DHCPDISCOVER 1
#define DHCPOFFER 2
#define DHCPREQUEST 3
#define DHCPDECLINE 4
#define DHCPACK 5
#define DHCPNAK 6
#define DHCPRELEASE 7
#define DHCP_SUBMASK_OPTION 1
#define DHCP_ROUTER_OPTION 3
#define DHCP_REQIP_OPTION 50
#define DHCP_LEASE_OPTION 51
#define DHCP_MSGTYPE_OPTION 53
#define DHCP_SERVERID_OPTION 54
#define DHCP_REQPARAM_OPTION 55
#define DHCP_MAXSIZE_OPTION 57
#define DHCP_CLIENTID_OPTION 61
#define DHCP_HOST_NAME 12
#define DHCP_END_OPTION 255
#define DHCP_OK 1
#define DHCP_ERROR -1
#define DHCP_RETRY 0
#define DHCP_TIMEOUT 4
typedef struct {
unsigned char op; /* Message opcode/type */
unsigned char htype; /* Hardware addr type */
unsigned char hlen; /* Hardware addr length */
unsigned char hops; /* Number of relay agent hops from client */
unsigned int xid; /* Transaction ID */
unsigned short secs; /* Seconds since client started looking */
unsigned char flags[2]; /* Flag bits */
struct in_addr ciaddr; /* Client IP address (if already in use) */
struct in_addr yiaddr; /* Client IP address */
struct in_addr siaddr; /* IP address of next server to talk to */
struct in_addr giaddr; /* DHCP relay agent IP address */
unsigned char chaddr [DHCP_HADDR_LEN]; /* Client hardware address */
char sname [DHCP_SNAME_LEN]; /* Server name */
char file [DHCP_FILE_LEN]; /* Boot filename */
unsigned char options [DHCP_OPTION_LEN];
/* Optional parameters (actual length dependent on MTU) */
} s_dhcppacket;
extern int DhcpAllocate();
extern int RequestNewAddr();
extern void InitDhcpServerAddr(unsigned char);
extern int RenewDhcpLease();
extern int RequestPreAddr(int, unsigned char);
extern int InitWithKnownIP();
#endif /* __DHCP_H__ */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -