rt-thread-official/components/net/uip/doc/html/a00148.html

635 lines
32 KiB
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>uIP 1.0: uIP conversion functions</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<h1>uIP conversion functions<br>
<small>
[<a class="el" href="a00150.html">The uIP TCP/IP stack</a>]</small>
</h1><hr><a name="_details"></a><h2>Detailed Description</h2>
These functions can be used for converting between different data formats used by uIP.
<p>
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Defines</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(addr, addr0, addr1, addr2, addr3)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Construct an IP address from four bytes. <a href="#g87f0b54ade0d159fba495089128a4932"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00148.html#g53fbda0e8c31d4882294c8dc3cb5f487">uip_ip6addr</a>(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Construct an IPv6 address from eight 16-bit words. <a href="#g53fbda0e8c31d4882294c8dc3cb5f487"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00148.html#g769512993b7b27271909d6daa4748b60">uip_ipaddr_copy</a>(dest, src)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Copy an IP address to another IP address. <a href="#g769512993b7b27271909d6daa4748b60"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00148.html#g210e629f7252e4bc8458cbdf260b3318">uip_ipaddr_cmp</a>(addr1, addr2)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Compare two IP addresses. <a href="#g210e629f7252e4bc8458cbdf260b3318"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00148.html#g6b16e0bac41821c1fbe0c267071642f0">uip_ipaddr_maskcmp</a>(addr1, addr2, mask)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Compare two IP addresses with netmasks. <a href="#g6b16e0bac41821c1fbe0c267071642f0"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00148.html#g969d7fff37a979737da045e0d538a9bd">uip_ipaddr_mask</a>(dest, src, mask)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Mask out the network part of an IP address. <a href="#g969d7fff37a979737da045e0d538a9bd"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00148.html#g22fa0681cd463191d7a01fe85d86996f">uip_ipaddr1</a>(addr)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Pick the first octet of an IP address. <a href="#g22fa0681cd463191d7a01fe85d86996f"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00148.html#gffcd2fbe181e2aaefbf970551c302af5">uip_ipaddr2</a>(addr)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Pick the second octet of an IP address. <a href="#gffcd2fbe181e2aaefbf970551c302af5"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00148.html#ge23534479ead15af8ff08ace26a47fb5">uip_ipaddr3</a>(addr)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Pick the third octet of an IP address. <a href="#ge23534479ead15af8ff08ace26a47fb5"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00148.html#g165b603ec150e26efec7be199c9c2901">uip_ipaddr4</a>(addr)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Pick the fourth octet of an IP address. <a href="#g165b603ec150e26efec7be199c9c2901"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(n)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Convert 16-bit quantity from host byte order to network byte order. <a href="#g69a7a4951ff21b302267532c21ee78fc"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g118e9d76568ab81ad97f138d4ea1ddd2"></a><!-- doxytag: member="uipconvfunc::ntohs" ref="g118e9d76568ab81ad97f138d4ea1ddd2" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00148.html#g118e9d76568ab81ad97f138d4ea1ddd2">ntohs</a>&nbsp;&nbsp;&nbsp;htons</td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons</a> (<a class="el" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> val)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Convert 16-bit quantity from host byte order to network byte order. <a href="#ga22b04cac8cf283ca12f028578bebc06"></a><br></td></tr>
</table>
<hr><h2>Define Documentation</h2>
<a class="anchor" name="g69a7a4951ff21b302267532c21ee78fc"></a><!-- doxytag: member="uip.h::HTONS" ref="g69a7a4951ff21b302267532c21ee78fc" args="(n)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">#define HTONS </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">n&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Convert 16-bit quantity from host byte order to network byte order.
<p>
This macro is primarily used for converting constants from host byte order to network byte order. For converting variables to network byte order, use the <a class="el" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons()</a> function instead. <dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00048.html#a6">dhcpc.c</a>, <a class="el" href="a00036.html#a103">hello-world.c</a>, <a class="el" href="a00046.html#a139">resolv.c</a>, <a class="el" href="a00038.html#a191">smtp.c</a>, and <a class="el" href="a00044.html#a219">telnetd.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00202.html#l01070">1070</a> of file <a class="el" href="a00202.html">uip.h</a>.
<p>
Referenced by <a class="el" href="a00170.html#l00041">hello_world_init()</a>, <a class="el" href="a00201.html#l01882">htons()</a>, <a class="el" href="a00184.html#l00333">httpd_init()</a>, <a class="el" href="a00172.html#l00331">resolv_appcall()</a>, <a class="el" href="a00172.html#l00438">resolv_conf()</a>, <a class="el" href="a00174.html#l00233">smtp_send()</a>, <a class="el" href="a00204.html#l00278">uip_arp_arpin()</a>, and <a class="el" href="a00201.html#l00682">uip_process()</a>. </td>
</tr>
</table>
<a class="anchor" name="g53fbda0e8c31d4882294c8dc3cb5f487"></a><!-- doxytag: member="uip.h::uip_ip6addr" ref="g53fbda0e8c31d4882294c8dc3cb5f487" args="(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">#define uip_ip6addr </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">addr, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>addr0, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>addr1, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>addr2, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>addr3, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>addr4, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>addr5, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>addr6, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>addr7&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Construct an IPv6 address from eight 16-bit words.
<p>
This function constructs an IPv6 address.
<p>
Definition at line <a class="el" href="a00202.html#l00852">852</a> of file <a class="el" href="a00202.html">uip.h</a>. </td>
</tr>
</table>
<a class="anchor" name="g87f0b54ade0d159fba495089128a4932"></a><!-- doxytag: member="uip.h::uip_ipaddr" ref="g87f0b54ade0d159fba495089128a4932" args="(addr, addr0, addr1, addr2, addr3)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">#define uip_ipaddr </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">addr, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>addr0, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>addr1, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>addr2, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>addr3&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Construct an IP address from four bytes.
<p>
This function constructs an IP address of the type that uIP handles internally from four bytes. The function is handy for specifying IP addresses to use with e.g. the <a class="el" href="a00147.html#g8096b0c4b543dc408f4dd031ddae7240">uip_connect()</a> function.<p>
Example: <div class="fragment"><pre class="fragment"> <a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> ipaddr;
<span class="keyword">struct </span><a class="code" href="a00088.html">uip_conn</a> *c;
<a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(&amp;ipaddr, 192,168,1,2);
c = <a class="code" href="a00147.html#g8096b0c4b543dc408f4dd031ddae7240">uip_connect</a>(&amp;ipaddr, <a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(80));
</pre></div><p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>addr</em>&nbsp;</td><td>A pointer to a uip_ipaddr_t variable that will be filled in with the IP address.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>addr0</em>&nbsp;</td><td>The first octet of the IP address. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>addr1</em>&nbsp;</td><td>The second octet of the IP address. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>addr2</em>&nbsp;</td><td>The third octet of the IP address. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>addr3</em>&nbsp;</td><td>The forth octet of the IP address. </td></tr>
</table>
</dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00048.html#a36">dhcpc.c</a>, <a class="el" href="a00042.html#a65">example-mainloop-with-arp.c</a>, and <a class="el" href="a00043.html#a89">example-mainloop-without-arp.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00202.html#l00840">840</a> of file <a class="el" href="a00202.html">uip.h</a>. </td>
</tr>
</table>
<a class="anchor" name="g22fa0681cd463191d7a01fe85d86996f"></a><!-- doxytag: member="uip.h::uip_ipaddr1" ref="g22fa0681cd463191d7a01fe85d86996f" args="(addr)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">#define uip_ipaddr1 </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">addr&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Pick the first octet of an IP address.
<p>
Picks out the first octet of an IP address.<p>
Example: <div class="fragment"><pre class="fragment"> <a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> ipaddr;
<a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> octet;
<a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(&amp;ipaddr, 1,2,3,4);
octet = <a class="code" href="a00148.html#g22fa0681cd463191d7a01fe85d86996f">uip_ipaddr1</a>(&amp;ipaddr);
</pre></div><p>
In the example above, the variable "octet" will contain the value 1. <dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00048.html#a28">dhcpc.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00202.html#l00995">995</a> of file <a class="el" href="a00202.html">uip.h</a>. </td>
</tr>
</table>
<a class="anchor" name="gffcd2fbe181e2aaefbf970551c302af5"></a><!-- doxytag: member="uip.h::uip_ipaddr2" ref="gffcd2fbe181e2aaefbf970551c302af5" args="(addr)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">#define uip_ipaddr2 </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">addr&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Pick the second octet of an IP address.
<p>
Picks out the second octet of an IP address.<p>
Example: <div class="fragment"><pre class="fragment"> <a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> ipaddr;
<a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> octet;
<a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(&amp;ipaddr, 1,2,3,4);
octet = <a class="code" href="a00148.html#gffcd2fbe181e2aaefbf970551c302af5">uip_ipaddr2</a>(&amp;ipaddr);
</pre></div><p>
In the example above, the variable "octet" will contain the value 2. <dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00048.html#a29">dhcpc.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00202.html#l01015">1015</a> of file <a class="el" href="a00202.html">uip.h</a>. </td>
</tr>
</table>
<a class="anchor" name="ge23534479ead15af8ff08ace26a47fb5"></a><!-- doxytag: member="uip.h::uip_ipaddr3" ref="ge23534479ead15af8ff08ace26a47fb5" args="(addr)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">#define uip_ipaddr3 </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">addr&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Pick the third octet of an IP address.
<p>
Picks out the third octet of an IP address.<p>
Example: <div class="fragment"><pre class="fragment"> <a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> ipaddr;
<a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> octet;
<a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(&amp;ipaddr, 1,2,3,4);
octet = <a class="code" href="a00148.html#ge23534479ead15af8ff08ace26a47fb5">uip_ipaddr3</a>(&amp;ipaddr);
</pre></div><p>
In the example above, the variable "octet" will contain the value 3. <dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00048.html#a30">dhcpc.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00202.html#l01035">1035</a> of file <a class="el" href="a00202.html">uip.h</a>. </td>
</tr>
</table>
<a class="anchor" name="g165b603ec150e26efec7be199c9c2901"></a><!-- doxytag: member="uip.h::uip_ipaddr4" ref="g165b603ec150e26efec7be199c9c2901" args="(addr)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">#define uip_ipaddr4 </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">addr&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Pick the fourth octet of an IP address.
<p>
Picks out the fourth octet of an IP address.<p>
Example: <div class="fragment"><pre class="fragment"> <a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> ipaddr;
<a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> octet;
<a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(&amp;ipaddr, 1,2,3,4);
octet = <a class="code" href="a00148.html#g165b603ec150e26efec7be199c9c2901">uip_ipaddr4</a>(&amp;ipaddr);
</pre></div><p>
In the example above, the variable "octet" will contain the value 4. <dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00048.html#a31">dhcpc.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00202.html#l01055">1055</a> of file <a class="el" href="a00202.html">uip.h</a>. </td>
</tr>
</table>
<a class="anchor" name="g210e629f7252e4bc8458cbdf260b3318"></a><!-- doxytag: member="uip.h::uip_ipaddr_cmp" ref="g210e629f7252e4bc8458cbdf260b3318" args="(addr1, addr2)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">#define uip_ipaddr_cmp </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">addr1, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>addr2&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Compare two IP addresses.
<p>
Compares two IP addresses.<p>
Example: <div class="fragment"><pre class="fragment"> <a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> ipaddr1, ipaddr2;
<a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(&amp;ipaddr1, 192,16,1,2);
<span class="keywordflow">if</span>(<a class="code" href="a00148.html#g210e629f7252e4bc8458cbdf260b3318">uip_ipaddr_cmp</a>(&amp;ipaddr2, &amp;ipaddr1)) {
printf(<span class="stringliteral">"They are the same"</span>);
}
</pre></div><p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>addr1</em>&nbsp;</td><td>The first IP address. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>addr2</em>&nbsp;</td><td>The second IP address. </td></tr>
</table>
</dl>
<p>
Definition at line <a class="el" href="a00202.html#l00911">911</a> of file <a class="el" href="a00202.html">uip.h</a>.
<p>
Referenced by <a class="el" href="a00204.html#l00278">uip_arp_arpin()</a>, <a class="el" href="a00204.html#l00354">uip_arp_out()</a>, and <a class="el" href="a00201.html#l00682">uip_process()</a>. </td>
</tr>
</table>
<a class="anchor" name="g769512993b7b27271909d6daa4748b60"></a><!-- doxytag: member="uip.h::uip_ipaddr_copy" ref="g769512993b7b27271909d6daa4748b60" args="(dest, src)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">#define uip_ipaddr_copy </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">dest, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>src&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Copy an IP address to another IP address.
<p>
Copies an IP address from one place to another.<p>
Example: <div class="fragment"><pre class="fragment"> <a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> ipaddr1, ipaddr2;
<a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(&amp;ipaddr1, 192,16,1,2);
<a class="code" href="a00148.html#g769512993b7b27271909d6daa4748b60">uip_ipaddr_copy</a>(&amp;ipaddr2, &amp;ipaddr1);
</pre></div><p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>dest</em>&nbsp;</td><td>The destination for the copy. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>src</em>&nbsp;</td><td>The source from where to copy. </td></tr>
</table>
</dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00038.html#a187">smtp.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00202.html#l00882">882</a> of file <a class="el" href="a00202.html">uip.h</a>.
<p>
Referenced by <a class="el" href="a00174.html#l00216">smtp_configure()</a>, <a class="el" href="a00204.html#l00354">uip_arp_out()</a>, and <a class="el" href="a00201.html#l00682">uip_process()</a>. </td>
</tr>
</table>
<a class="anchor" name="g969d7fff37a979737da045e0d538a9bd"></a><!-- doxytag: member="uip.h::uip_ipaddr_mask" ref="g969d7fff37a979737da045e0d538a9bd" args="(dest, src, mask)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">#define uip_ipaddr_mask </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">dest, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>src, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>mask&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Mask out the network part of an IP address.
<p>
Masks out the network part of an IP address, given the address and the netmask.<p>
Example: <div class="fragment"><pre class="fragment"> <a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> ipaddr1, ipaddr2, netmask;
<a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(&amp;ipaddr1, 192,16,1,2);
<a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(&amp;netmask, 255,255,255,0);
<a class="code" href="a00148.html#g969d7fff37a979737da045e0d538a9bd">uip_ipaddr_mask</a>(&amp;ipaddr2, &amp;ipaddr1, &amp;netmask);
</pre></div><p>
In the example above, the variable "ipaddr2" will contain the IP address 192.168.1.0.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>dest</em>&nbsp;</td><td>Where the result is to be placed. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>src</em>&nbsp;</td><td>The IP address. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>mask</em>&nbsp;</td><td>The netmask. </td></tr>
</table>
</dl>
<p>
Definition at line <a class="el" href="a00202.html#l00972">972</a> of file <a class="el" href="a00202.html">uip.h</a>. </td>
</tr>
</table>
<a class="anchor" name="g6b16e0bac41821c1fbe0c267071642f0"></a><!-- doxytag: member="uip.h::uip_ipaddr_maskcmp" ref="g6b16e0bac41821c1fbe0c267071642f0" args="(addr1, addr2, mask)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">#define uip_ipaddr_maskcmp </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">addr1, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>addr2, <tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>mask&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Compare two IP addresses with netmasks.
<p>
Compares two IP addresses with netmasks. The masks are used to mask out the bits that are to be compared.<p>
Example: <div class="fragment"><pre class="fragment"> <a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> ipaddr1, ipaddr2, mask;
<a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(&amp;mask, 255,255,255,0);
<a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(&amp;ipaddr1, 192,16,1,2);
<a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(&amp;ipaddr2, 192,16,1,3);
<span class="keywordflow">if</span>(<a class="code" href="a00148.html#g6b16e0bac41821c1fbe0c267071642f0">uip_ipaddr_maskcmp</a>(&amp;ipaddr1, &amp;ipaddr2, &amp;mask)) {
printf(<span class="stringliteral">"They are the same"</span>);
}
</pre></div><p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>addr1</em>&nbsp;</td><td>The first IP address. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>addr2</em>&nbsp;</td><td>The second IP address. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>mask</em>&nbsp;</td><td>The netmask. </td></tr>
</table>
</dl>
<p>
Definition at line <a class="el" href="a00202.html#l00941">941</a> of file <a class="el" href="a00202.html">uip.h</a>.
<p>
Referenced by <a class="el" href="a00204.html#l00354">uip_arp_out()</a>. </td>
</tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="ga22b04cac8cf283ca12f028578bebc06"></a><!-- doxytag: member="uip.h::htons" ref="ga22b04cac8cf283ca12f028578bebc06" args="(u16_t val)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"><a class="el" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> htons </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a>&nbsp;</td>
<td class="mdname1" valign="top" nowrap> <em>val</em> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Convert 16-bit quantity from host byte order to network byte order.
<p>
This function is primarily used for converting variables from host byte order to network byte order. For converting constants to network byte order, use the <a class="el" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS()</a> macro instead. <dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="a00042.html#a70">example-mainloop-with-arp.c</a>, <a class="el" href="a00046.html#a137">resolv.c</a>, and <a class="el" href="a00040.html#a274">webclient.c</a>.</dl>
<p>
Definition at line <a class="el" href="a00201.html#l01882">1882</a> of file <a class="el" href="a00201.html">uip.c</a>.
<p>
References <a class="el" href="a00202.html#l01070">HTONS</a>.
<p>
Referenced by <a class="el" href="a00201.html#l00311">uip_chksum()</a>, <a class="el" href="a00201.html#l00407">uip_connect()</a>, <a class="el" href="a00201.html#l00318">uip_ipchksum()</a>, <a class="el" href="a00201.html#l00473">uip_udp_new()</a>, and <a class="el" href="a00180.html#l00140">webclient_get()</a>. </td>
</tr>
</table>
<hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>