📄 dhcp_8h-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Procyon AVRlib: net/dhcp.h Source File</title><link href="dox.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.2 --><div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div><div class="nav"><a class="el" href="dir_000001.html">net</a></div><h1>dhcp.h</h1><a href="dhcp_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*! \file dhcp.h \brief DHCP Protocol Library. */</span>00002 <span class="comment">//*****************************************************************************</span>00003 <span class="comment">//</span>00004 <span class="comment">// File Name : 'dhcp.h'</span>00005 <span class="comment">// Title : DHCP Protocol Library</span>00006 <span class="comment">// Author : Pascal Stang</span>00007 <span class="comment">// Created : 9/17/2005</span>00008 <span class="comment">// Revised : 9/17/2005</span>00009 <span class="comment">// Version : 0.1</span>00010 <span class="comment">// Target MCU : Atmel AVR series</span>00011 <span class="comment">// Editor Tabs : 4</span>00012 <span class="comment">//</span><span class="comment"></span>00013 <span class="comment">/// \ingroup network</span>00014 <span class="comment">/// \defgroup dhcp DHCP Protocol Library (dhcp.c)</span>00015 <span class="comment">/// \code #include "net/dhcp.h" \endcode</span>00016 <span class="comment">/// \par Description</span>00017 <span class="comment">/// This library provides a limited implementation of DHCP (Dynamic Host</span>00018 <span class="comment">/// Configuration Protocol) as described in RFC2131. DHCP allows a</span>00019 <span class="comment">/// network device to automatically obtain an IP address and other network</span>00020 <span class="comment">/// configuration settings from a DHCP server.</span>00021 <span class="comment">/// </span>00022 <span class="comment">/// \note This code is currently below version 1.0, and therefore is considered</span>00023 <span class="comment">/// to be lacking in some functionality or documentation, or may not be fully</span>00024 <span class="comment">/// tested. Nonetheless, you can expect most functions to work.</span>00025 <span class="comment">///</span>00026 <span class="comment"></span><span class="comment">// This code is distributed under the GNU Public License</span>00027 <span class="comment">// which can be found at http://www.gnu.org/licenses/gpl.txt</span>00028 <span class="comment">//*****************************************************************************</span><span class="comment"></span>00029 <span class="comment">//@{</span>00030 <span class="comment"></span>00031 <span class="preprocessor">#ifndef DHCP_H</span>00032 <span class="preprocessor"></span><span class="preprocessor">#define DHCP_H</span>00033 <span class="preprocessor"></span>00034 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span>00035 <span class="preprocessor">#include "<a class="code" href="net_8h.html">net.h</a>"</span>00036 00037 <span class="comment">//#define DHCP_DEBUG_PRINT</span>00038 <span class="comment">//#define DHCP_DEBUG</span>00039 <span class="comment"></span>00040 <span class="comment">/// Bootp Header (DHCP is transported by BOOTP/UDP/IP)</span><a name="l00041"></a><a class="code" href="structnetBootpHeader.html">00041</a> <span class="comment"></span><span class="keyword">struct </span><a class="code" href="structnetBootpHeader.html">netBootpHeader</a>00042 {<a name="l00043"></a><a class="code" href="structnetBootpHeader.html#o0">00043</a> uint8_t <a class="code" href="structnetBootpHeader.html#o0">op</a>; <span class="comment">///< Message op-code / message type</span><a name="l00044"></a><a class="code" href="structnetBootpHeader.html#o1">00044</a> <span class="comment"></span> uint8_t <a class="code" href="structnetBootpHeader.html#o1">htype</a>; <span class="comment">///< Hardware address type (Ethernet=1)</span><a name="l00045"></a><a class="code" href="structnetBootpHeader.html#o2">00045</a> <span class="comment"></span> uint8_t <a class="code" href="structnetBootpHeader.html#o2">hlen</a>; <span class="comment">///< Hardware address length (Ethernet=6 byte MAC addr)</span><a name="l00046"></a><a class="code" href="structnetBootpHeader.html#o3">00046</a> <span class="comment"></span> uint8_t <a class="code" href="structnetBootpHeader.html#o3">hops</a>; <span class="comment">///< hop count (client set to zero)</span><a name="l00047"></a><a class="code" href="structnetBootpHeader.html#o4">00047</a> <span class="comment"></span> uint32_t <a class="code" href="structnetBootpHeader.html#o4">xid</a>; <span class="comment">///< Transaction ID (randomly chosen by client, must remain same)</span><a name="l00048"></a><a class="code" href="structnetBootpHeader.html#o5">00048</a> <span class="comment"></span> uint16_t <a class="code" href="structnetBootpHeader.html#o5">secs</a>; <span class="comment">///< Seconds elapsed since DHCP negotiation began (filled by client)</span><a name="l00049"></a><a class="code" href="structnetBootpHeader.html#o6">00049</a> <span class="comment"></span> uint16_t <a class="code" href="structnetBootpHeader.html#o6">flags</a>; <span class="comment">///< Flags</span><a name="l00050"></a><a class="code" href="structnetBootpHeader.html#o7">00050</a> <span class="comment"></span> uint32_t <a class="code" href="structnetBootpHeader.html#o7">ciaddr</a>; <span class="comment">///< Client IP address (filled only if already bound, renewing, or rebinding)</span><a name="l00051"></a><a class="code" href="structnetBootpHeader.html#o8">00051</a> <span class="comment"></span> uint32_t <a class="code" href="structnetBootpHeader.html#o8">yiaddr</a>; <span class="comment">///< 'Your' IP address (client)</span><a name="l00052"></a><a class="code" href="structnetBootpHeader.html#o9">00052</a> <span class="comment"></span> uint32_t <a class="code" href="structnetBootpHeader.html#o9">siaddr</a>; <span class="comment">///< Server IP address</span><a name="l00053"></a><a class="code" href="structnetBootpHeader.html#o10">00053</a> <span class="comment"></span> uint32_t <a class="code" href="structnetBootpHeader.html#o10">giaddr</a>; <span class="comment">///< Gateway IP address</span><a name="l00054"></a><a class="code" href="structnetBootpHeader.html#o11">00054</a> <span class="comment"></span> uint8_t <a class="code" href="structnetBootpHeader.html#o11">chaddr</a>[16]; <span class="comment">///< Client Hardware Address</span><a name="l00055"></a><a class="code" href="structnetBootpHeader.html#o12">00055</a> <span class="comment"></span> uint8_t <a class="code" href="structnetBootpHeader.html#o12">sname</a>[64]; <span class="comment">///< Server Host Name</span><a name="l00056"></a><a class="code" href="structnetBootpHeader.html#o13">00056</a> <span class="comment"></span> uint8_t <a class="code" href="structnetBootpHeader.html#o13">file</a>[128]; <span class="comment">///< Boot file name (null-term string)</span>00057 <span class="comment"></span>} <a class="code" href="group__dhcp.html#ga41">GNUC_PACKED</a>;00058 <a name="l00059"></a><a class="code" href="group__dhcp.html#ga9">00059</a> <span class="preprocessor">#define BOOTP_HEADER_LEN 236 </span><span class="comment">///< length of BOOTP header not including options</span>00060 <span class="comment"></span><a name="l00061"></a><a class="code" href="group__dhcp.html#ga10">00061</a> <span class="preprocessor">#define BOOTP_OP_BOOTREQUEST 1 </span><span class="comment">///< BOOTP Request operation (message from client to server)</span><a name="l00062"></a><a class="code" href="group__dhcp.html#ga11">00062</a> <span class="comment"></span>#define BOOTP_OP_BOOTREPLY 2 <span class="comment">///< BOOTP Reply operation (message from server to client)</span>00063 <span class="comment"></span>00064 <span class="preprocessor">#define BOOTP_HTYPE_ETHERNET 1</span>00065 <span class="preprocessor"></span><span class="preprocessor">#define BOOTP_HLEN_ETHERNET 6</span>00066 <span class="preprocessor"></span><span class="comment"></span>00067 <span class="comment">/// DHCP Header</span><a name="l00068"></a><a class="code" href="structnetDhcpHeader.html">00068</a> <span class="comment"></span><span class="keyword">struct </span><a class="code" href="structnetDhcpHeader.html">netDhcpHeader</a>00069 {<a name="l00070"></a><a class="code" href="structnetDhcpHeader.html#o0">00070</a> <span class="keyword">struct </span><a class="code" href="structnetBootpHeader.html">netBootpHeader</a> bootp; <span class="comment">///< BOOTP header</span><a name="l00071"></a><a class="code" href="structnetDhcpHeader.html#o1">00071</a> <span class="comment"></span> uint32_t <a class="code" href="structnetDhcpHeader.html#o1">cookie</a>; <span class="comment">///< magic cookie value</span><a name="l00072"></a><a class="code" href="structnetDhcpHeader.html#o2">00072</a> <span class="comment"></span> uint8_t <a class="code" href="structnetDhcpHeader.html#o2">options</a>[]; <span class="comment">///< DHCP options</span>00073 <span class="comment"></span>} <a class="code" href="group__dhcp.html#ga41">GNUC_PACKED</a>;00074 <a name="l00075"></a><a class="code" href="group__dhcp.html#ga14">00075</a> <span class="preprocessor">#define DHCP_HEADER_LEN 240 </span><span class="comment">///< length of DHCP header not including options</span>00076 <span class="comment"></span><a name="l00077"></a><a class="code" href="group__dhcp.html#ga15">00077</a> <span class="preprocessor">#define DHCP_UDP_SERVER_PORT 67 </span><span class="comment">///< UDP port where DHCP requests should be sent</span>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -