Merge from vendor branch BIND:
[dragonfly.git] / lib / libc / net / ns.3
1 .\" Copyright (c) 1986, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)ns.3        8.1 (Berkeley) 6/4/93
33 .\" $FreeBSD: src/lib/libc/net/ns.3,v 1.5.2.5 2001/12/14 18:33:55 ru Exp $
34 .\" $DragonFly: src/lib/libc/net/ns.3,v 1.2 2003/06/17 04:26:44 dillon Exp $
35 .\"
36 .Dd June 4, 1993
37 .Dt NS 3
38 .Os
39 .Sh NAME
40 .Nm ns_addr ,
41 .Nm ns_ntoa
42 .Nd Xerox
43 .Tn NS Ns (tm)
44 address conversion routines
45 .Sh LIBRARY
46 .Lb libc
47 .Sh SYNOPSIS
48 .In sys/types.h
49 .In netns/ns.h
50 .Ft struct ns_addr
51 .Fn ns_addr "char *cp"
52 .Ft char *
53 .Fn ns_ntoa "struct ns_addr ns"
54 .Sh DESCRIPTION
55 The routine
56 .Fn ns_addr
57 interprets character strings representing
58 .Tn XNS
59 addresses, returning binary information suitable
60 for use in system calls.
61 The routine
62 .Fn ns_ntoa
63 takes
64 .Tn XNS
65 addresses and returns
66 .Tn ASCII
67 strings representing the address in a
68 notation in common use in the Xerox Development Environment:
69 .Bd -ragged -offset indent
70 <network number>.<host number>.<port number>
71 .Ed
72 .Pp
73 Trailing zero fields are suppressed, and each number is printed in hexadecimal,
74 in a format suitable for input to
75 .Fn ns_addr .
76 Any fields lacking super-decimal digits will have a
77 trailing
78 .Ql H
79 appended.
80 .Pp
81 Unfortunately, no universal standard exists for representing
82 .Tn XNS
83 addresses.
84 An effort has been made to insure that
85 .Fn ns_addr
86 be compatible with most formats in common use.
87 It will first separate an address into 1 to 3 fields using a single delimiter
88 chosen from
89 period
90 .Ql \&. ,
91 colon
92 .Ql \&:
93 or pound-sign
94 .Ql \&# .
95 Each field is then examined for byte separators (colon or period).
96 If there are byte separators, each subfield separated is taken to be
97 a small hexadecimal number, and the entirety is taken as a network-byte-ordered
98 quantity to be zero extended in the high-network-order bytes.
99 Next, the field is inspected for hyphens, in which case
100 the field is assumed to be a number in decimal notation
101 with hyphens separating the millenia.
102 Next, the field is assumed to be a number:
103 It is interpreted
104 as hexadecimal if there is a leading
105 .Ql 0x
106 (as in C),
107 a trailing
108 .Ql H
109 (as in Mesa), or there are any super-decimal digits present.
110 It is interpreted as octal is there is a leading
111 .Ql 0
112 and there are no super-octal digits.
113 Otherwise, it is converted as a decimal number.
114 .Sh RETURN VALUES
115 None. (See
116 .Sx BUGS . )
117 .Sh SEE ALSO
118 .Xr hosts 5 ,
119 .Xr networks 5
120 .Sh HISTORY
121 The
122 .Fn ns_addr
123 and
124 .Fn ns_toa
125 functions appeared in
126 .Bx 4.3 .
127 .Sh BUGS
128 The string returned by
129 .Fn ns_ntoa
130 resides in a static memory area.
131 The function
132 .Fn ns_addr
133 should diagnose improperly formed input, and there should be an unambiguous
134 way to recognize this.