⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dhcp.h

📁 wimax bs模拟器
💻 H
📖 第 1 页 / 共 2 页
字号:
													   or category of user or applications it represents.  A DHCP server
													   uses the User Class option to choose the address pool it allocates an
													   address from and/or to select any other configuration option.
													***/
#define _DHCP_SUBNET_SELECTION_TAG 	 ((char)118) /*** RFC 3011 Subnet Selection Option Definition
													   The subnet selection option is a DHCP option.  The option contains a
													   single IPv4 address that is the address of a subnet.  The value for
													   the subnet address is determined by taking any IPv4 address on the
													   subnet and ANDing that address with the subnet mask 
													   When the DHCP server is configured to respond
													   to this option, is allocating an address, and this option is present
													   then the DHCP server MUST allocate the address on either:

													   o the subnet specified in the subnet selection option, or;

													   o a subnet on the same network segment as the subnet specified in the
													     subnet selection option.
													 ***/

#define _DHCP_END_TAG                   ((char)255)

#define _DHCP_LAST_OPTION 		_DHCP_SUBNET_SELECTION_TAG
#define _DHCP_MAX_OPTLEN 		255

#define DHCP_MAX_TAG_NUM     (_DHCP_LAST_OPTION + 1)
#define DHCP_OPT_MASK_SIZE     (DHCP_MAX_TAG_NUM / 8 + 1 )

/* 
 * Hardware type values from the arp section of the assigned numbers RFC. 
 * (Frequently used as client identifier types).
 */
#define ETHER           1       /* Ethernet (10Mb) */
#define EXPETHER        2       /* Experimental Ethernet (3Mb) */
#define AX25            3       /* Amateur Radio AX.25 */
#define PRONET          4       /* Proteon ProNET Token Ring */
#define CHAOS           5       /* Chaos */
#define IEEE802         6       /* IEEE 802 Networks */
#define ARCNET          7       /* ARCNET */
#define HYPERCH         8       /* Hyperchannel */
#define LANSTAR         9       /* Lanstar */
#define AUTONET         10      /* Autonet Short Address */
#define LOCALTALK       11      /* LocalTalk */
#define LOCALNET        12      /* LocalNet */
#define ULTRALINK 	13 	/* Ultra link */
#define FRAMERELAY 	15 	/* Frame Relay */
#define SERIAL 		20 	/* Serial Line */
#define DNS_NAME        128     /* DNS name */

/* Definitions for DHCP message format. */
#define MAX_HLEN      16    /* maximum length of haddr field */
#define MAX_SNAME     64
#define MAX_FILE     128
#define DFLTOPTLEN   312
#define BOOTPOPTLEN   64
#define MAXOPT      0xff
#define INFINITY    0xffffffff


/* DHCP message format. */
typedef struct dhcp
{
	unsigned char       op;             /* packet type */
	unsigned char       htype;          /* Link-level interface address type */
	unsigned char       hlen;   /* Link-level interface address length */
	unsigned char       hops;           /* Hops through DHCP relay agents */
	unsigned long       xid;            /* transaction ID */
	unsigned short      secs;   /* seconds since lease negotiation started */
	unsigned short      flags;
	struct in_addr      ciaddr;         /* Client's current IP address */
	struct in_addr      yiaddr;         /* Client's assigned IP address */
	struct in_addr      siaddr;         /* Address of (tftp) server */
	struct in_addr      giaddr;         /* Address of relay agent */
	char                chaddr [MAX_HLEN];      /* Client's hardware address */
	char                sname [MAX_SNAME];      /* Host name of DHCP server */
	char                file [MAX_FILE];        /* File name of boot image */
	char                options [DFLTOPTLEN];   /* DHCP message options */
}DHCP_MSG;

/* Tests for flags field of DHCP messages. */
#define ISBRDCST(X)   ((X & htons(0x8000)) != 0)
#define SETBRDCST(X)  ((X) |= htons(0x8000))

/* pseudo udp header for checksum. */
struct ps_udph
{
	struct in_addr      srcip;
	struct in_addr      dstip;
	char                zero;
	char                prto;
	short               ulen;
};


#define ETHERHL  sizeof(struct ether_header)  /* ethernet header length */
#define IPHL     sizeof(struct ip)            /* IP header length */
#define UDPHL    sizeof(struct udphdr)        /* UDP header length */


/* Definitions for processing incoming DHCP messages. */
#define DHCP_MSG_SIZE (DFLTDHCPLEN + UDPHL + IPHL)
#define MESSAGE_RING_SIZE (10 * DHCP_MSG_SIZE)
#define DFLTDHCPLEN   sizeof (struct dhcp)   /* default DHCP message size */
#define DFLTBOOTPLEN  (DFLTDHCPLEN - DFLTOPTLEN + BOOTPOPTLEN)
#define DHCPLEN(UDP)  (ntohs(UDP->uh_ulen) - UDPHL)  /* get DHCP msg size */
                                                     /* from UDP header */
#define OPTBODY(TAGP)  ( ( (char *)TAGP) + 2)   /* get DHCP option contents */
#define DHCPOPTLEN(TAGP) ((UINT8) * ( ((char *)TAGP) + 1)) /* option length */

/* handle the word alignment. */
#define   GETHS(PTR)  (*((u_char *)PTR)*256 + *(((u_char *)PTR)+1))
#define   GETHL(PTR)  (*((u_char *)PTR)*256*256*256 + *(((u_char *)PTR)+1)*256*256 +\
                       *(((u_char *)PTR)+2)*256 + *(((u_char *)PTR)+3))

#define BOOTREQUEST		1
#define BOOTREPLY		2

/*
 * DHCP/BOOTP magic cookie defined in RFC 1048
 */
#define RFC1048_MAGIC { 99, 130, 83, 99 }
#define MAGIC_LEN  4

/* 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 DHCPINFORM             8
#define BOOTP                  0

/* Classification of DHCP message fields */
#define FILE_ISOPT             1
#define SNAME_ISOPT            2
#define BOTH_AREOPT            FILE_ISOPT + SNAME_ISOPT



#ifdef __cplusplus
}
#endif

#endif /*_DHCP_H_*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -