?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 6

Line No. Rev Author Line
1 6 kaklik <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3 <title>Procyon AVRlib: net/dhcp.h Source File</title>
4 <link href="dox.css" rel="stylesheet" type="text/css">
5 </head><body>
6 <!-- Generated by Doxygen 1.4.2 -->
7 <div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
8 <div class="nav">
9 <a class="el" href="dir_000001.html">net</a></div>
10 <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>
11 00002 <span class="comment">//*****************************************************************************</span>
12 00003 <span class="comment">//</span>
13 00004 <span class="comment">// File Name : 'dhcp.h'</span>
14 00005 <span class="comment">// Title : DHCP Protocol Library</span>
15 00006 <span class="comment">// Author : Pascal Stang</span>
16 00007 <span class="comment">// Created : 9/17/2005</span>
17 00008 <span class="comment">// Revised : 9/17/2005</span>
18 00009 <span class="comment">// Version : 0.1</span>
19 00010 <span class="comment">// Target MCU : Atmel AVR series</span>
20 00011 <span class="comment">// Editor Tabs : 4</span>
21 00012 <span class="comment">//</span><span class="comment"></span>
22 00013 <span class="comment">/// \ingroup network</span>
23 00014 <span class="comment">/// \defgroup dhcp DHCP Protocol Library (dhcp.c)</span>
24 00015 <span class="comment">/// \code #include "net/dhcp.h" \endcode</span>
25 00016 <span class="comment">/// \par Description</span>
26 00017 <span class="comment">/// This library provides a limited implementation of DHCP (Dynamic Host</span>
27 00018 <span class="comment">/// Configuration Protocol) as described in RFC2131. DHCP allows a</span>
28 00019 <span class="comment">/// network device to automatically obtain an IP address and other network</span>
29 00020 <span class="comment">/// configuration settings from a DHCP server.</span>
30 00021 <span class="comment">/// </span>
31 00022 <span class="comment">/// \note This code is currently below version 1.0, and therefore is considered</span>
32 00023 <span class="comment">/// to be lacking in some functionality or documentation, or may not be fully</span>
33 00024 <span class="comment">/// tested. Nonetheless, you can expect most functions to work.</span>
34 00025 <span class="comment">///</span>
35 00026 <span class="comment"></span><span class="comment">// This code is distributed under the GNU Public License</span>
36 00027 <span class="comment">// which can be found at http://www.gnu.org/licenses/gpl.txt</span>
37 00028 <span class="comment">//*****************************************************************************</span><span class="comment"></span>
38 00029 <span class="comment">//@{</span>
39 00030 <span class="comment"></span>
40 00031 <span class="preprocessor">#ifndef DHCP_H</span>
41 00032 <span class="preprocessor"></span><span class="preprocessor">#define DHCP_H</span>
42 00033 <span class="preprocessor"></span>
43 00034 <span class="preprocessor">#include "<a class="code" href="global_8h.html">global.h</a>"</span>
44 00035 <span class="preprocessor">#include "<a class="code" href="net_8h.html">net.h</a>"</span>
45 00036
46 00037 <span class="comment">//#define DHCP_DEBUG_PRINT</span>
47 00038 <span class="comment">//#define DHCP_DEBUG</span>
48 00039 <span class="comment"></span>
49 00040 <span class="comment">/// Bootp Header (DHCP is transported by BOOTP/UDP/IP)</span>
50 <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>
51 00042 {
52 <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">///&lt; Message op-code / message type</span>
53 <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">///&lt; Hardware address type (Ethernet=1)</span>
54 <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">///&lt; Hardware address length (Ethernet=6 byte MAC addr)</span>
55 <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">///&lt; hop count (client set to zero)</span>
56 <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">///&lt; Transaction ID (randomly chosen by client, must remain same)</span>
57 <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">///&lt; Seconds elapsed since DHCP negotiation began (filled by client)</span>
58 <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">///&lt; Flags</span>
59 <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">///&lt; Client IP address (filled only if already bound, renewing, or rebinding)</span>
60 <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">///&lt; 'Your' IP address (client)</span>
61 <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">///&lt; Server IP address</span>
62 <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">///&lt; Gateway IP address</span>
63 <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">///&lt; Client Hardware Address</span>
64 <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">///&lt; Server Host Name</span>
65 <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">///&lt; Boot file name (null-term string)</span>
66 00057 <span class="comment"></span>} <a class="code" href="group__dhcp.html#ga41">GNUC_PACKED</a>;
67 00058
68 <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">///&lt; length of BOOTP header not including options</span>
69 00060 <span class="comment"></span>
70 <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">///&lt; BOOTP Request operation (message from client to server)</span>
71 <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">///&lt; BOOTP Reply operation (message from server to client)</span>
72 00063 <span class="comment"></span>
73 00064 <span class="preprocessor">#define BOOTP_HTYPE_ETHERNET 1</span>
74 00065 <span class="preprocessor"></span><span class="preprocessor">#define BOOTP_HLEN_ETHERNET 6</span>
75 00066 <span class="preprocessor"></span><span class="comment"></span>
76 00067 <span class="comment">/// DHCP Header</span>
77 <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>
78 00069 {
79 <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">///&lt; BOOTP header</span>
80 <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">///&lt; magic cookie value</span>
81 <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">///&lt; DHCP options</span>
82 00073 <span class="comment"></span>} <a class="code" href="group__dhcp.html#ga41">GNUC_PACKED</a>;
83 00074
84 <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">///&lt; length of DHCP header not including options</span>
85 00076 <span class="comment"></span>
86 <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">///&lt; UDP port where DHCP requests should be sent</span>
87 <a name="l00078"></a><a class="code" href="group__dhcp.html#ga16">00078</a> <span class="comment"></span>#define DHCP_UDP_CLIENT_PORT 68 <span class="comment">///&lt; UDP port clients will receive DHCP replies</span>
88 00079 <span class="comment"></span>
89 00080
90 <a name="l00081"></a><a class="code" href="group__dhcp.html#ga17">00081</a> <span class="preprocessor">#define DHCP_OPT_PAD 0 </span><span class="comment">///&lt; token padding value (make be skipped)</span>
91 <a name="l00082"></a><a class="code" href="group__dhcp.html#ga18">00082</a> <span class="comment"></span>#define DHCP_OPT_NETMASK 1 <span class="comment">///&lt; subnet mask client should use (4 byte mask)</span>
92 <a name="l00083"></a><a class="code" href="group__dhcp.html#ga19">00083</a> <span class="comment"></span>#define DHCP_OPT_ROUTERS 3 <span class="comment">///&lt; routers client should use (IP addr list)</span>
93 <a name="l00084"></a><a class="code" href="group__dhcp.html#ga20">00084</a> <span class="comment"></span>#define DHCP_OPT_TIMESERVERS 4 <span class="comment">///&lt; time servers client should use (IP addr list)</span>
94 <a name="l00085"></a><a class="code" href="group__dhcp.html#ga21">00085</a> <span class="comment"></span>#define DHCP_OPT_NAMESERVERS 5 <span class="comment">///&lt; name servers client should use (IP addr list)</span>
95 <a name="l00086"></a><a class="code" href="group__dhcp.html#ga22">00086</a> <span class="comment"></span>#define DHCP_OPT_DNSSERVERS 6 <span class="comment">///&lt; DNS servers client should use (IP addr list)</span>
96 <a name="l00087"></a><a class="code" href="group__dhcp.html#ga23">00087</a> <span class="comment"></span>#define DHCP_OPT_HOSTNAME 12 <span class="comment">///&lt; host name client should use (string)</span>
97 <a name="l00088"></a><a class="code" href="group__dhcp.html#ga24">00088</a> <span class="comment"></span>#define DHCP_OPT_DOMAINNAME 15 <span class="comment">///&lt; domain name client should use (string)</span>
98 <a name="l00089"></a><a class="code" href="group__dhcp.html#ga25">00089</a> <span class="comment"></span>#define DHCP_OPT_REQUESTEDIP 50 <span class="comment">///&lt; IP address requested by client (IP address)</span>
99 <a name="l00090"></a><a class="code" href="group__dhcp.html#ga26">00090</a> <span class="comment"></span>#define DHCP_OPT_LEASETIME 51 <span class="comment">///&lt; DHCP Lease Time (uint32 seconds)</span>
100 <a name="l00091"></a><a class="code" href="group__dhcp.html#ga27">00091</a> <span class="comment"></span>#define DHCP_OPT_DHCPMSGTYPE 53 <span class="comment">///&lt; DHCP message type (1 byte)</span>
101 <a name="l00092"></a><a class="code" href="group__dhcp.html#ga28">00092</a> <span class="comment"></span>#define DHCP_OPT_SERVERID 54 <span class="comment">///&lt; Server Identifier (IP address)</span>
102 <a name="l00093"></a><a class="code" href="group__dhcp.html#ga29">00093</a> <span class="comment"></span>#define DHCP_OPT_PARAMREQLIST 55 <span class="comment">///&lt; Paramerter Request List (n OPT codes)</span>
103 <a name="l00094"></a><a class="code" href="group__dhcp.html#ga30">00094</a> <span class="comment"></span>#define DHCP_OPT_RENEWALTIME 58 <span class="comment">///&lt; DHCP Lease Renewal Time (uint32 seconds)</span>
104 <a name="l00095"></a><a class="code" href="group__dhcp.html#ga31">00095</a> <span class="comment"></span>#define DHCP_OPT_REBINDTIME 59 <span class="comment">///&lt; DHCP Lease Rebinding Time (uint32 seconds)</span>
105 <a name="l00096"></a><a class="code" href="group__dhcp.html#ga32">00096</a> <span class="comment"></span>#define DHCP_OPT_END 255 <span class="comment">///&lt; token end value (marks end of options list)</span>
106 00097 <span class="comment"></span>
107 <a name="l00098"></a><a class="code" href="group__dhcp.html#ga33">00098</a> <span class="preprocessor">#define DHCP_MSG_DHCPDISCOVER 1 </span><span class="comment">///&lt; DISCOVER is broadcast by client to solicit OFFER from any/all DHCP servers.</span>
108 <a name="l00099"></a><a class="code" href="group__dhcp.html#ga34">00099</a> <span class="comment"></span>#define DHCP_MSG_DHCPOFFER 2 <span class="comment">///&lt; OFFER(s) are made to client by server to offer IP address and config info.</span>
109 <a name="l00100"></a><a class="code" href="group__dhcp.html#ga35">00100</a> <span class="comment"></span>#define DHCP_MSG_DHCPREQUEST 3 <span class="comment">///&lt; REQUEST is made my client in response to best/favorite OFFER message.</span>
110 <a name="l00101"></a><a class="code" href="group__dhcp.html#ga36">00101</a> <span class="comment"></span>#define DHCP_MSG_DHCPDECLINE 4 <span class="comment">///&lt; DECLINE may be sent by client to server to indicate IP already in use.</span>
111 <a name="l00102"></a><a class="code" href="group__dhcp.html#ga37">00102</a> <span class="comment"></span>#define DHCP_MSG_DHCPACK 5 <span class="comment">///&lt; ACK is sent to client by server in confirmation of REQUEST, contains config and IP.</span>
112 <a name="l00103"></a><a class="code" href="group__dhcp.html#ga38">00103</a> <span class="comment"></span>#define DHCP_MSG_DHCPNAK 6 <span class="comment">///&lt; NAK is sent to client by server to indicate problem with REQUEST.</span>
113 <a name="l00104"></a><a class="code" href="group__dhcp.html#ga39">00104</a> <span class="comment"></span>#define DHCP_MSG_DHCPRELEASE 7 <span class="comment">///&lt; RELEASE is sent by client to server to relinquish DHCP lease on IP address, etc.</span>
114 <a name="l00105"></a><a class="code" href="group__dhcp.html#ga40">00105</a> <span class="comment"></span>#define DHCP_MSG_DHCPINFORM 8 <span class="comment">///&lt; INFORM is sent by client to server to request config info, IP address configured locally.</span>
115 00106 <span class="comment"></span>
116 00107 <span class="comment"></span>
117 00108 <span class="comment">/*! Initialize DHCP system.</span>
118 00109 <span class="comment"> Prepares DHCP for use and initializes lease time to zero. */</span>
119 00110 <span class="keywordtype">void</span> <a class="code" href="group__dhcp.html#ga1">dhcpInit</a>(<span class="keywordtype">void</span>);
120 00111 <span class="comment"></span>
121 00112 <span class="comment">/*! Processes incoming DHCP packets from UDP port 68.</span>
122 00113 <span class="comment"> This function is to be called by the stack when a DHCP packet</span>
123 00114 <span class="comment"> arrives over the network. The DHCP packet will be parsed, handled,</span>
124 00115 <span class="comment"> and a response will be generated and sent if needed. When the DHCP</span>
125 00116 <span class="comment"> process completes, the IP addressing will be automatically updated. */</span>
126 00117 <span class="keywordtype">void</span> <a class="code" href="group__dhcp.html#ga2">dhcpIn</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> len, <span class="keyword">struct</span> <a class="code" href="structnetDhcpHeader.html">netDhcpHeader</a>* packet);
127 00118 <span class="comment"></span>
128 00119 <span class="comment">/*! Request DHCP assigned network parameters.</span>
129 00120 <span class="comment"> This function begins the DHCP process. The remainder of operations</span>
130 00121 <span class="comment"> are handled in dhcpIn(). */</span>
131 00122 <span class="keywordtype">void</span> <a class="code" href="group__dhcp.html#ga3">dhcpRequest</a>(<span class="keywordtype">void</span>);
132 00123 <span class="comment"></span>
133 00124 <span class="comment">/*! Release DHCP lease and assigned network parameters.</span>
134 00125 <span class="comment"> This function releases the DHCP assigned address and allows the</span>
135 00126 <span class="comment"> DHCP server to reallocate it. */</span>
136 00127 <span class="keywordtype">void</span> <a class="code" href="group__dhcp.html#ga4">dhcpRelease</a>(<span class="keywordtype">void</span>);
137 00128 <span class="comment"></span>
138 00129 <span class="comment">/*! Periodic DHCP maintenance.</span>
139 00130 <span class="comment"> This function is to be called once per second and will </span>
140 00131 <span class="comment"> expire the DHCP lease. */</span>
141 00132 <span class="keywordtype">void</span> <a class="code" href="group__dhcp.html#ga5">dhcpTimer</a>(<span class="keywordtype">void</span>);
142 00133 <span class="comment"></span>
143 00134 <span class="comment">/*! Get a DHCP option from the option list.</span>
144 00135 <span class="comment"> \param options is a pointer to the options field of a DHCP packet.</span>
145 00136 <span class="comment"> \param optcode is the desired option number to retrieve.</span>
146 00137 <span class="comment"> \param optlen is the maximum data length that should be retrieved (less data will be retrieved if option is shorter).</span>
147 00138 <span class="comment"> \param optvalptr is a pointer to where the option value will be stored.</span>
148 00139 <span class="comment"> \return actual length of the option data, as stored in the options list. */</span>
149 00140 uint8_t <a class="code" href="group__dhcp.html#ga6">dhcpGetOption</a>(uint8_t* options, uint8_t optcode, uint8_t optlen, <span class="keywordtype">void</span>* optvalptr);
150 00141 <span class="comment"></span>
151 00142 <span class="comment">/*! Set a DHCP option in the option list.</span>
152 00143 <span class="comment"> \param options is a pointer to the options field of a DHCP packet.</span>
153 00144 <span class="comment"> \param optcode is the option number to write.</span>
154 00145 <span class="comment"> \param optlen is the data length of the option value.</span>
155 00146 <span class="comment"> \param optvalptr is a pointer to the option data to be read.</span>
156 00147 <span class="comment"> \return pointer to write location of the next option. */</span>
157 00148 uint8_t* <a class="code" href="group__dhcp.html#ga7">dhcpSetOption</a>(uint8_t* options, uint8_t optcode, uint8_t optlen, <span class="keywordtype">void</span>* optvalptr);
158 00149 <span class="comment"></span>
159 00150 <span class="comment">/*! Print diagnotic information about BOOTP/DHCP packet.</span>
160 00151 <span class="comment">*/</span>
161 00152 <span class="keywordtype">void</span> <a class="code" href="group__dhcp.html#ga8">dhcpPrintHeader</a>(<span class="keyword">struct</span> <a class="code" href="structnetDhcpHeader.html">netDhcpHeader</a>* packet);
162 00153
163 00154 <span class="preprocessor">#endif</span>
164 00155 <span class="preprocessor"></span><span class="comment">//@}</span>
165 00156 <span class="comment"></span>
166 </pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 29 03:41:07 2006 for Procyon AVRlib by&nbsp;
167 <a href="http://www.doxygen.org/index.html">
168 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address>
169 </body>
170 </html>
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3