1NE_IADDR_MAKE(3)              neon API reference              NE_IADDR_MAKE(3)
2
3
4

NAME

6       ne_iaddr_make,     ne_iaddr_cmp,    ne_iaddr_print,    ne_iaddr_typeof,
7       ne_iaddr_free - functions to manipulate and compare network addresses
8

SYNOPSIS

10       #include <ne_socket.h>
11
12       typedef enum {
13           ne_iaddr_ipv4 = 0,
14           ne_iaddr_ipv6 } ne_iaddr_type;
15
16
17       ne_inet_addr *ne_iaddr_make (ne_iaddr_type type,
18                                    const unsigned char *raw);
19
20       int ne_iaddr_cmp (const ne_inet_addr *ia1, const ne_inet_addr *ia2);
21
22       char *ne_iaddr_print (const ne_inet_addr *ia, char *buffer,
23                             size_t bufsiz);
24
25       ne_iaddr_type ne_iaddr_typeof (const ne_inet_addr *ia);
26
27       void ne_iaddr_free (const ne_inet_addr *ia);
28
29

DESCRIPTION

31       ne_iaddr_make creates an ne_inet_addr object from a raw binary  network
32       address;  for instance the four bytes 0x7f 0x00 0x00 0x01 represent the
33       IPv4 address 127.0.0.1. The object returned is suitable for passing  to
34       ne_sock_connect.  A  binary  IPv4 address contains four bytes; a binary
35       IPv6 address contains sixteen bytes; addresses passed must be  in  net‐
36       work byte order.
37
38
39       ne_iaddr_cmp  can  be  used to compare two network addresses; returning
40       zero only if they are identical. The addresses need not be of the  same
41       address  type;  if  the  addresses are not of the same type, the return
42       value is guaranteed to be non-zero.
43
44
45       ne_iaddr_print can be used to print the human-readable string represen‐
46       tation  of  a  network  address  into a buffer, for instance the string
47       "127.0.0.1".
48
49
50       ne_iaddr_typeof returns the type of the given network address.
51
52
53       ne_iaddr_free releases the memory associated with a network address ob‐
54       ject.
55
56

RETURN VALUE

58       ne_iaddr_make  returns NULL if the address type passed is not supported
59       (for instance on a platform which does not support IPv6).
60
61
62       ne_iaddr_print returns the buffer pointer, and never NULL.
63
64

EXAMPLES

66       The following example connects a socket  to  port  80  at  the  address
67       127.0.0.1.
68
69       unsigned char addr[] = "\0x7f\0x00\0x00\0x01";
70       ne_inet_addr *ia;
71
72       ia = ne_iaddr_make(ne_iaddr_ipv4, addr);
73       if (ia != NULL) {
74           ne_socket *sock = ne_sock_connect(ia, 80);
75           ne_iaddr_free(ia);
76           /* ... */
77       } else {
78           /* ... */
79       }
80
81

SEE ALSO

83       ne_addr_resolve(3)
84
85

AUTHOR

87       Joe Orton <neon@webdav.org>.
88
89
90
91neon 0.25.5                     20 January 2006               NE_IADDR_MAKE(3)
Impressum