neon API reference NEIADRMAKE(3)
NAME
neiaddrmake, neiaddrcmp, neiaddrprint,
neiaddrtypeof, neiaddrfree - functions to manipulate and
compare network addresses
SYNOPSIS
#include
typedef enum {
neiaddripv4 = 0,
neiaddripv6 } neiaddrtype;
neinetaddr *neiaddrmake (neiaddrtype type,
const unsigned char *raw);
int neiaddrcmp (const neinetaddr *ia1,
const neinetaddr *ia2);
char *neiaddrprint (const neinetaddr *ia, char *buffer,
sizet bufsiz);
neiaddrtype neiaddrtypeof (const neinetaddr *ia);
void neiaddrfree (const neinetaddr *ia);
DESCRIPTION
neiaddrmake creates an neinetaddr 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 ob-
ject returned is suitable for passing to nesockconnect. A
binary IPv4 address contains four bytes; a binary IPv6 ad-
dress contains sixteen bytes; addresses passed must be in
network byte order.
neiaddrcmp 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.
neiaddrprint 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".
neiaddrtypeof returns the type of the given network ad-
dress.
neon 0.25.5 Last change: 20 January 2006 1
neon API reference NEIADRMAKE(3)
neiaddrfree releases the memory associated with a network
address object.
RETURN VALUE
neiaddrmake returns NUL if the address type passed is not
supported (for instance on a platform which does not support
IPv6).
neiaddrprint returns the buffer pointer, and never NUL.
EXAMPLES
The following example connects a socket to port 80 at the
address 127.0.0.1.
unsigned char addr[] = "\0x7f\0x00\0x00\0x01";
neinetaddr *ia;
ia = neiaddrmake(neiaddripv4, addr);
if (ia != NUL) {
nesocket *sock = nesockconnect(ia, 80);
neiaddrfree(ia);
/* ... */
} else {
/* ... */
}
SEE ALSO
neaddrresolve(3)
AUTHOR
Joe Orton .
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
neon 0.25.5 Last change: 20 January 2006 2
neon API reference NEIADRMAKE(3)
ATRIBUTE TYPE ATRIBUTE VALUE
Availability SUNWneon
Interface Stability Volatile
NOTES
Source for Neon is available on http:/opensolaris.org.
neon 0.25.5 Last change: 20 January 2006 3
|