1NE_IADDR_MAKE(3) neon API reference NE_IADDR_MAKE(3)
2
3
4
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
10 #include <ne_socket.h>
11
12 typedef enum {
13 ne_iaddr_ipv4 = 0,
14 ne_iaddr_ipv6
15 } ne_iaddr_type;
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
30 ne_iaddr_make creates an ne_inet_addr object from a raw binary network
31 address; for instance the four bytes 0x7f 0x00 0x00 0x01 represent the
32 IPv4 address 127.0.0.1. The object returned is suitable for passing to
33 ne_sock_connect. A binary IPv4 address contains four bytes; a binary
34 IPv6 address contains sixteen bytes; addresses passed must be in
35 network byte order.
36
37 ne_iaddr_cmp can be used to compare two network addresses; returning
38 zero only if they are identical. The addresses need not be of the same
39 address type; if the addresses are not of the same type, the return
40 value is guaranteed to be non-zero.
41
42 ne_iaddr_print can be used to print the human-readable string
43 representation of a network address into a buffer, for instance the
44 string "127.0.0.1".
45
46 ne_iaddr_typeof returns the type of the given network address.
47
48 ne_iaddr_free releases the memory associated with a network address
49 object.
50
52 ne_iaddr_make returns NULL if the address type passed is not supported
53 (for instance on a platform which does not support IPv6).
54
55 ne_iaddr_print returns the buffer pointer, and never NULL.
56
58 The following example connects a socket to port 80 at the address
59 127.0.0.1.
60
61 unsigned char addr[] = "\0x7f\0x00\0x00\0x01";
62 ne_inet_addr *ia;
63
64 ia = ne_iaddr_make(ne_iaddr_ipv4, addr);
65 if (ia != NULL) {
66 ne_socket *sock = ne_sock_connect(ia, 80);
67 ne_iaddr_free(ia);
68 /* ... */
69 } else {
70 /* ... */
71 }
72
74 ne_addr_resolve
75
77 Joe Orton <neon@lists.manyfish.co.uk>
78 Author.
79
81neon 0.29.3 11 January 2010 NE_IADDR_MAKE(3)