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

📄 dhcp.h

📁 ATmega103、ATmega128做的开发板web server源码
💻 H
字号:
/******************************************************************
* dhcp.h:
* 
* Copyright (c) 2001 Atmel Corporation.
* All Rights Reserved.
*
* You are autorized to use, copy and distribute this software only at 
* a single site (the term "site" meaning a single company location). 
* This copyright notice must be included in any copy, modification 
* or portion of this software merged into another program.
* 
* This software is licenced solely for use with Atmel AVR micro 
* controller family. The software may not be modified to execute on 
* any other microcontroller architectures
*
* This software is provided "as is"; Without warranties either express
* or implied, including any warranty regarding merchantability, 
* fitness for a particular purpose or noninfringement. 
*
* In no event shall Atmel or its suppliers be liable for any special, 
* indirect,incidential or concequential damages resulting from the 
* use or inability to use this software.
*
* Revision history:
*
* January 17, 2001:   Version 1.0   Created by JB
* July 13, 2001		  Version 1.2     JB
* 					- Changed to IAR compiler V2.25
*					- Renamed flash file functions to avoid conflict with 
*					  standard file I/O names	
*					- Bug fixes in HTTP
*					- Speed optimization in TCP 
*
*
*******************************************************************/

/*field offsets*/
#define DHCP_FIELD_OP           0
#define DHCP_FIELD_HTYPE        1
#define DHCP_FIELD_HLEN         2
#define DHCP_FIELD_HOPS         3
#define DHCP_FIELD_XID          4
#define DHCP_FIELD_SECS         8 
#define DHCP_FIELD_FLAGS        10
#define DHCP_FIELD_CIADDR       12
#define DHCP_FIELD_YIADDR       16
#define DHCP_FIELD_SIADDR       20
#define DHCP_FIELD_GIADDR       24
#define DHCP_FIELD_CHADDR       28
#define DHCP_FIELD_SNAME        44
#define DHCP_FIELD_FILE         108
#define DHCP_FIELD_OPTIONS      236

/*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

/*options*/
#define DHCP_OPTION_REQIP       50
#define DHCP_OPTION_LEASETIME   51
#define DHCP_OPTION_MSGTYPE     53
#define DHCP_OPTION_SERVERID    54  
#define DHCP_OPTION_CLIENTID    61
#define DHCP_OPTION_END         255

/*"magic cookie", written at the start of the option field*/ 
#define DHCP_MAGIC_COOKIE0      99
#define DHCP_MAGIC_COOKIE1      130
#define DHCP_MAGIC_COOKIE2      83
#define DHCP_MAGIC_COOKIE3      99

/*the address in the EEPROM where the obtained IP-address is stored*/
#define DHCP_EEADDRESS          0

/*number of retransmitions*/
#define DHCP_RETRAN 	        2 

/*used to calculate when the various states should be entered*/
#define DHCP_T1                 1/2  //from state BOUND to RENEWING
#define DHCP_T2                 3/4  //from state RENEWING to REBINDING
#define DHCP_TIMEOUT            1/3  //from state REBINDING to INIT
#define DHCP_MINUTE             1053 //(clock frequency / clock divider)*(60 seconds / 8bit counter)


/*must be initialy to obtain an IP address, must thereafter be polled*/
void DHCP(void);
/*should be called on timer0 interrupt*/
void checkDHCP(void);
/*waits for a packet on port 68, or timeout, when timeout ocures depends on the time parameter*/
unsigned char wait(unsigned char time);
/*sends a discover message*/
void sendDHCPDISCOVER(void);
/*sends a request message*/
void sendDHCPREQUEST(void);
/*construct the standard header fields in a dhcp message*/
void stdDHCPMessage(void);
/*finds an option in the received dhcp message*/
int findOption(unsigned char opt);
/*checks if the recevied XID is valid*/
unsigned char checkXID(void);
/*calculates when transmition from state BOUND to RENEWING should occur*/
void calcT1(void);
/*returns integer in EEPROM address ADR*/
unsigned int EEGetInt(unsigned int adr);
/*writes integer into EEPROM address ADR*/
void EEPutInt(unsigned int adr,unsigned int var16);

⌨️ 快捷键说明

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