File: refiaddr.html

package info (click to toggle)
tla 1.3.5%2Bdfsg1-2
  • links: PTS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 22,292 kB
  • ctags: 11,952
  • sloc: ansic: 149,771; sh: 16,009; xml: 2,689; lisp: 1,927; makefile: 1,064; cpp: 363; tcl: 230; awk: 48; sed: 25
file content (36 lines) | stat: -rw-r--r-- 5,551 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>ne_iaddr_make</title><link rel="stylesheet" href="../manual.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="neon HTTP/WebDAV client library"><link rel="up" href="ref.html" title="neon API reference"><link rel="previous" href="refgetst.html" title="ne_get_status"><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="refgetst.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><div></div></div><div class="refnamediv"><h2>Name</h2><p>ne_iaddr_make, ne_iaddr_cmp, ne_iaddr_print, ne_iaddr_free &#8212; 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
} <i class="type">ne_iaddr_type</i>;</pre><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="funcprototype"><code><code xmlns="" class="funcdef">ne_inet_addr *<b class="fsfunc">ne_iaddr_make</b>(</code>ne_iaddr_type <var xmlns="" class="pdparam">type</var>, const unsigned char *<var xmlns="" class="pdparam">raw</var><code xmlns="">)</code>;</code></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="funcprototype"><code><code xmlns="" class="funcdef">int <b class="fsfunc">ne_iaddr_cmp</b>(</code>const ne_inet_addr *<var xmlns="" class="pdparam">i1</var>, const ne_inet_addr *<var xmlns="" class="pdparam">i2</var><code xmlns="">)</code>;</code></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="funcprototype"><code><code xmlns="" class="funcdef">char *<b class="fsfunc">ne_iaddr_print</b>(</code>const ne_inet_addr *<var xmlns="" class="pdparam">ia</var>, char *<var xmlns="" class="pdparam">buffer</var>, size_t <var xmlns="" class="pdparam">bufsiz</var><code xmlns="">)</code>;</code></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="funcprototype"><code><code xmlns="" class="funcdef">void <b class="fsfunc">ne_iaddr_free</b>(</code>const ne_inet_addr *<var xmlns="" class="pdparam">addr</var><code xmlns="">)</code>;</code></div></div></div><div class="refsect1" lang="en"><a name="id3026080"></a><h2>Description</h2><p><tt class="function">ne_iaddr_make</tt> creates an
    <i class="type">ne_inet_addr</i> object from a raw binary network
    address; for instance the four bytes <tt class="literal">0x7f 0x00 0x00
    0x01</tt> represent the IPv4 address
    <tt class="literal">127.0.0.1</tt>.  The object returned is suitable for
    passing to <tt class="function">ne_sock_connect</tt>.  A binary IPv4
    address contains four bytes; a binary IPv6 address contains
    sixteen bytes; addresses passed must be in network byte
    order.</p><p><tt class="function">ne_iaddr_cmp</tt> 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><tt class="function">ne_iaddr_print</tt> can be used to print the
    human-readable string representation of a network address into a
    buffer, for instance the string
    <tt class="literal">"127.0.0.1"</tt>.</p><p><tt class="function">ne_iaddr_free</tt> releases the memory
    associated with a network address object.</p></div><div class="refsect1" lang="en"><a name="id3026159"></a><h2>Return value</h2><p><tt class="function">ne_iaddr_make</tt> returns <tt class="literal">NULL</tt> if the
    address type passed is not supported (for instance on a platform
    which does not support IPv6).</p><p><tt class="function">ne_iaddr_print</tt> returns the
    <tt class="parameter">buffer</tt> pointer, and never <tt class="literal">NULL</tt>.</p></div><div class="refsect1" lang="en"><a name="id3026204"></a><h2>Examples</h2><p>The following example connects a socket to port 80 at the
    address <tt class="literal">127.0.0.1</tt>.</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="id3026230"></a><h2>See also</h2><p><a 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="refgetst.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_get_status</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>