.\" Title: ne_iaddr_make
.\" Author:
.\" Generator: DocBook XSL Stylesheets v1.72.0
.\" Date: 14 July 2007
.\" Manual: neon API reference
.\" Source: neon 0.26.4
.\"
.TH "NE_IADDR_MAKE" "3" "14 July 2007" "neon 0.26.4" "neon API reference"
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.SH "NAME"
ne_iaddr_make, ne_iaddr_cmp, ne_iaddr_print, ne_iaddr_typeof, ne_iaddr_free \- functions to manipulate and compare network addresses
.SH "SYNOPSIS"
.sp
.ft B
.nf
#include
typedef enum {
ne_iaddr_ipv4 = 0,
ne_iaddr_ipv6
} ne_iaddr_type;
.fi
.ft
.HP 28
.BI "ne_inet_addr *ne_iaddr_make(ne_iaddr_type\ " "type" ", const\ unsigned\ char\ *" "raw" ");"
.HP 17
.BI "int ne_iaddr_cmp(const\ ne_inet_addr\ *" "ia1" ", const\ ne_inet_addr\ *" "ia2" ");"
.HP 21
.BI "char *ne_iaddr_print(const\ ne_inet_addr\ *" "ia" ", char\ *" "buffer" ", size_t\ " "bufsiz" ");"
.HP 30
.BI "ne_iaddr_type ne_iaddr_typeof(const\ ne_inet_addr\ *" "ia" ");"
.HP 19
.BI "void ne_iaddr_free(const\ ne_inet_addr\ *" "ia" ");"
.SH "DESCRIPTION"
.PP
\fBne_iaddr_make\fR
creates an
\fBne_inet_addr\fR
object from a raw binary network address; for instance the four bytes
0x7f 0x00 0x00 0x01
represent the IPv4 address
127.0.0.1. The object returned is suitable for passing to
\fBne_sock_connect\fR. A binary IPv4 address contains four bytes; a binary IPv6 address contains sixteen bytes; addresses passed must be in network byte order.
.PP
\fBne_iaddr_cmp\fR
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.
.PP
\fBne_iaddr_print\fR
can be used to print the human\-readable string representation of a network address into a buffer, for instance the string
"127.0.0.1".
.PP
\fBne_iaddr_typeof\fR
returns the type of the given network address.
.PP
\fBne_iaddr_free\fR
releases the memory associated with a network address object.
.SH "RETURN VALUE"
.PP
\fBne_iaddr_make\fR
returns
NULL
if the address type passed is not supported (for instance on a platform which does not support IPv6).
.PP
\fBne_iaddr_print\fR
returns the
\fIbuffer\fR
pointer, and never
NULL.
.SH "EXAMPLES"
.PP
The following example connects a socket to port 80 at the address
127.0.0.1.
.sp
.RS 4
.nf
unsigned char addr[] = "\e0x7f\e0x00\e0x00\e0x01";
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 {
/* ... */
}
.fi
.RE
.SH "SEE ALSO"
.PP
ne_addr_resolve
.SH "AUTHOR"
.PP
\fBJoe Orton\fR <\&neon@webdav.org\&>
.sp -1n
.IP "" 4
Author.
.SH "COPYRIGHT"