Debian Codegraph @

deps/libneon/doc/man/ne_iaddr_make.3

raw
1 '\" t
2 .\" Title: ne_iaddr_make
3 .\" Author:
4 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
5 .\" Date: 3 May 2011
6 .\" Manual: neon API reference
7 .\" Source: neon 0.29.6
8 .\" Language: English
9 .\"
10 .TH "NE_IADDR_MAKE" "3" "3 May 2011" "neon 0.29.6" "neon API reference"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 ne_iaddr_make, ne_iaddr_cmp, ne_iaddr_print, ne_iaddr_typeof, ne_iaddr_parse, ne_iaddr_raw, ne_iaddr_reverse, ne_iaddr_free \- functions to manipulate network addresses
32 .SH "SYNOPSIS"
33 .sp
34 .ft B
35 .nf
36 #include <ne_socket\&.h>
37
38 typedef enum {
39 ne_iaddr_ipv4 = 0,
40 ne_iaddr_ipv6
41 } ne_iaddr_type;
42 .fi
43 .ft
44 .HP \w'ne_inet_addr\ *ne_iaddr_make('u
45 .BI "ne_inet_addr *ne_iaddr_make(ne_iaddr_type\ " "type" ", const\ unsigned\ char\ *" "raw" ");"
46 .HP \w'int\ ne_iaddr_cmp('u
47 .BI "int ne_iaddr_cmp(const\ ne_inet_addr\ *" "ia1" ", const\ ne_inet_addr\ *" "ia2" ");"
48 .HP \w'char\ *ne_iaddr_print('u
49 .BI "char *ne_iaddr_print(const\ ne_inet_addr\ *" "ia" ", char\ *" "buffer" ", size_t\ " "bufsiz" ");"
50 .HP \w'ne_iaddr_type\ ne_iaddr_typeof('u
51 .BI "ne_iaddr_type ne_iaddr_typeof(const\ ne_inet_addr\ *" "ia" ");"
52 .HP \w'ne_inet_addr\ *ne_iaddr_parse('u
53 .BI "ne_inet_addr *ne_iaddr_parse(const\ char\ *" "address" ", ne_iaddr_type\ " "type" ");"
54 .HP \w'unsigned\ char\ *ne_iaddr_raw('u
55 .BI "unsigned char *ne_iaddr_raw(const\ ne_inet_addr\ *" "ia" ", unsigned\ char\ *" "buffer" ");"
56 .HP \w'int\ ne_iaddr_reverse('u
57 .BI "int ne_iaddr_reverse(const\ ne_inet_addr\ *" "ia" ", char\ *" "buffer" ", size_t\ " "buflen" ");"
58 .HP \w'void\ ne_iaddr_free('u
59 .BI "void ne_iaddr_free(const\ ne_inet_addr\ *" "ia" ");"
60 .SH "DESCRIPTION"
61 .PP
62 \fBne_iaddr_make\fR
63 creates an
64 \fBne_inet_addr\fR
65 object from a raw binary network address; for instance the four bytes
66 0x7f 0x00 0x00 0x01
67 represent the IPv4 address
68 127\&.0\&.0\&.1\&. The object returned is suitable for passing to
69 \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\&.
70 .PP
71 \fBne_iaddr_cmp\fR
72 compares two network address objects; returning zero only if they are identical\&. The objects need not have the same address type; if the addresses are not of the same type, the return value is guaranteed to be non\-zero\&.
73 .PP
74 \fBne_iaddr_print\fR
75 prints a human\-readable string representation of a network address into a buffer, for instance the string
76 "127\&.0\&.0\&.1"\&.
77 .PP
78 \fBne_iaddr_typeof\fR
79 returns the type of the given network address object\&.
80 .PP
81 \fBne_iaddr_parse\fR
82 parses a string representation of a network address (such as
83 "127\&.0\&.0\&.1"
84 and creates a network address object to represent the parsed address\&.
85 .PP
86 \fBne_iaddr_raw\fR
87 writes the raw byte representation of a network address to the provided buffer\&. The bytes are written in network byte order; the buffer must be of suitable length for the type of address (4 bytes for an IPv4 address, 16 bytes for an IPv6 address)\&.
88 .PP
89 \fBne_iaddr_reverse\fR
90 performs a reverse name lookup on the address object, writing the (first) hostname associated with the IP address to the provided buffer\&. If the hostname is longer than the buffer it will be silently truncated; on success the string written to the buffer is always
91 NUL\-terminated\&.
92 .PP
93 \fBne_iaddr_free\fR
94 releases the memory associated with a network address object\&.
95 .SH "RETURN VALUE"
96 .PP
97 \fBne_iaddr_make\fR
98 returns
99 NULL
100 if the address type passed is not supported (for instance on a platform which does not support IPv6)\&.
101 .PP
102 \fBne_iaddr_print\fR
103 returns the
104 \fIbuffer\fR
105 pointer, and never
106 NULL\&.
107 .PP
108 \fBne_iaddr_parse\fR
109 returns a network address object on success, or
110 NULL
111 on failure to parse the
112 \fIaddress\fR
113 parameter\&.
114 .PP
115 \fBne_iaddr_reverse\fR
116 returns zero on success or non\-zero if no hostname is associated with the address\&.
117 .PP
118 \fBne_iaddr_raw\fR
119 returns the
120 \fIbuffer\fR
121 parameter, and never
122 NULL\&.
123 .SH "EXAMPLES"
124 .PP
125 The following example connects a socket to port 80 at the address
126 127\&.0\&.0\&.1\&.
127 .sp
128 .if n \{\
129 .RS 4
130 .\}
131 .nf
132 unsigned char addr[] = "\e0x7f\e0x00\e0x00\e0x01";
133 ne_inet_addr *ia;
134
135 ia = ne_iaddr_make(ne_iaddr_ipv4, addr);
136 if (ia != NULL) {
137 ne_socket *sock = ne_sock_connect(ia, 80);
138 ne_iaddr_free(ia);
139 /* \&.\&.\&. */
140 } else {
141 /* \&.\&.\&. */
142 }
143 .fi
144 .if n \{\
145 .RE
146 .\}
147 .SH "SEE ALSO"
148 .PP
149 ne_addr_resolve
150 .SH "AUTHOR"
151 .PP
152 \fBJoe Orton\fR <\&[email protected]\&>
153 .RS 4
154 Author.
155 .RE
156 .SH "COPYRIGHT"
157 .br