Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 155a6b8ffc33b073b9bc0b0d9ec80b13 > files > 60

lib64neon0.27-devel-0.28.0-1mdv2008.1.x86_64.rpm

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>ne_iaddr_make</title><link rel="stylesheet" href="../manual.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="neon HTTP/WebDAV client library"><link rel="up" href="ref.html" title="neon API reference"><link rel="prev" href="refi18n.html" title="ne_i18n_init"><link rel="next" href="refalloc.html" title="ne_malloc"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">ne_iaddr_make</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="refi18n.html">Prev</a> </td><th width="60%" align="center">neon API reference</th><td width="20%" align="right"> <a accesskey="n" href="refalloc.html">Next</a></td></tr></table><hr></div><div class="refentry" lang="en"><a name="refiaddr"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ne_iaddr_make, ne_iaddr_cmp, ne_iaddr_print, ne_iaddr_typeof, ne_iaddr_free — functions to manipulate and compare network addresses</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;ne_socket.h&gt;

typedef enum {
    ne_iaddr_ipv4 = 0,
    ne_iaddr_ipv6
} <em class="type">ne_iaddr_type</em>;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">ne_inet_addr *<b class="fsfunc">ne_iaddr_make</b>(</code></td><td>ne_iaddr_type  </td><td><var class="pdparam">type</var>, </td></tr><tr><td> </td><td>const unsigned char * </td><td><var class="pdparam">raw</var><code>)</code>;</td></tr></table><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">int <b class="fsfunc">ne_iaddr_cmp</b>(</code></td><td>const ne_inet_addr * </td><td><var class="pdparam">ia1</var>, </td></tr><tr><td> </td><td>const ne_inet_addr * </td><td><var class="pdparam">ia2</var><code>)</code>;</td></tr></table><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">char *<b class="fsfunc">ne_iaddr_print</b>(</code></td><td>const ne_inet_addr * </td><td><var class="pdparam">ia</var>, </td></tr><tr><td> </td><td>char * </td><td><var class="pdparam">buffer</var>, </td></tr><tr><td> </td><td>size_t  </td><td><var class="pdparam">bufsiz</var><code>)</code>;</td></tr></table><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" style="padding-bottom: 1em"><tr><td><code class="funcdef">ne_iaddr_type <b class="fsfunc">ne_iaddr_typeof</b>(</code></td><td>const ne_inet_addr * </td><td><var class="pdparam">ia</var><code>)</code>;</td></tr></table><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0"><tr><td><code class="funcdef">void <b class="fsfunc">ne_iaddr_free</b>(</code></td><td>const ne_inet_addr * </td><td><var class="pdparam">ia</var><code>)</code>;</td></tr></table></div></div><div class="refsect1" lang="en"><a name="id349134"></a><h2>Description</h2><p><code class="function">ne_iaddr_make</code> creates an
    <em class="type">ne_inet_addr</em> object from a raw binary network
    address; for instance the four bytes <code class="literal">0x7f 0x00 0x00
    0x01</code> represent the IPv4 address
    <code class="literal">127.0.0.1</code>.  The object returned is suitable for
    passing to <code class="function">ne_sock_connect</code>.  A binary IPv4
    address contains four bytes; a binary IPv6 address contains
    sixteen bytes; addresses passed must be in network byte
    order.</p><p><code class="function">ne_iaddr_cmp</code> can be used to compare two
    network addresses; returning zero only if they are identical.  The
    addresses need not be of the same address type; if the addresses
    are not of the same type, the return value is guaranteed to be
    non-zero.</p><p><code class="function">ne_iaddr_print</code> can be used to print the
    human-readable string representation of a network address into a
    buffer, for instance the string
    <code class="literal">"127.0.0.1"</code>.</p><p><code class="function">ne_iaddr_typeof</code> returns the type of the
    given network address.</p><p><code class="function">ne_iaddr_free</code> releases the memory
    associated with a network address object.</p></div><div class="refsect1" lang="en"><a name="id349214"></a><h2>Return value</h2><p><code class="function">ne_iaddr_make</code> returns <code class="literal">NULL</code> if the
    address type passed is not supported (for instance on a platform
    which does not support IPv6).</p><p><code class="function">ne_iaddr_print</code> returns the
    <code class="parameter">buffer</code> pointer, and never <code class="literal">NULL</code>.</p></div><div class="refsect1" lang="en"><a name="id349255"></a><h2>Examples</h2><p>The following example connects a socket to port 80 at the
    address <code class="literal">127.0.0.1</code>.</p><pre class="programlisting">unsigned char addr[] = "\0x7f\0x00\0x00\0x01";
ne_inet_addr *ia;

ia = ne_iaddr_make(ne_iaddr_ipv4, addr);
if (ia != NULL) {
    ne_socket *sock = ne_sock_connect(ia, 80);
    ne_iaddr_free(ia);
    /* ... */
} else {
    /* ... */
}</pre></div><div class="refsect1" lang="en"><a name="id349279"></a><h2>See also</h2><p><a class="xref" href="refresolve.html#ne_addr_resolve">ne_addr_resolve</a></p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="refi18n.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ref.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="refalloc.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ne_i18n_init </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> ne_malloc</td></tr></table></div></body></html>