xref: /original-bsd/lib/libc/net/ns.3 (revision c3e32dec)
1.\" Copyright (c) 1986, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)ns.3	8.1 (Berkeley) 06/04/93
7.\"
8.Dd
9.Dt NS 3
10.Os BSD 4.3
11.Sh NAME
12.Nm ns_addr ,
13.Nm ns_ntoa
14.Nd Xerox
15.Tn NS Ns (tm)
16address conversion routines
17.Sh SYNOPSIS
18.Fd #include <sys/types.h>
19.Fd #include <netns/ns.h>
20.Ft struct ns_addr
21.Fn ns_addr "char *cp"
22.Ft char *
23.Fn ns_ntoa "struct ns_addr ns"
24.Sh DESCRIPTION
25The routine
26.Fn ns_addr
27interprets character strings representing
28.Tn XNS
29addresses, returning binary information suitable
30for use in system calls.
31The routine
32.Fn ns_ntoa
33takes
34.Tn XNS
35addresses and returns
36.Tn ASCII
37strings representing the address in a
38notation in common use in the Xerox Development Environment:
39.Bd -filled -offset indent
40<network number>.<host number>.<port number>
41.Ed
42.Pp
43Trailing zero fields are suppressed, and each number is printed in hexadecimal,
44in a format suitable for input to
45.Fn ns_addr .
46Any fields lacking super-decimal digits will have a
47trailing
48.Ql H
49appended.
50.Pp
51Unfortunately, no universal standard exists for representing
52.Tn XNS
53addresses.
54An effort has been made to insure that
55.Fn ns_addr
56be compatible with most formats in common use.
57It will first separate an address into 1 to 3 fields using a single delimiter
58chosen from
59period
60.Ql \&. ,
61colon
62.Ql \&:
63or pound-sign
64.Ql \&# .
65Each field is then examined for byte separators (colon or period).
66If there are byte separators, each subfield separated is taken to be
67a small hexadecimal number, and the entirety is taken as a network-byte-ordered
68quantity to be zero extended in the high-network-order bytes.
69Next, the field is inspected for hyphens, in which case
70the field is assumed to be a number in decimal notation
71with hyphens separating the millenia.
72Next, the field is assumed to be a number:
73It is interpreted
74as hexadecimal if there is a leading
75.Ql 0x
76(as in C),
77a trailing
78.Ql H
79(as in Mesa), or there are any super-decimal digits present.
80It is interpreted as octal is there is a leading
81.Ql 0
82and there are no super-octal digits.
83Otherwise, it is converted as a decimal number.
84.Sh RETURN VALUES
85None. (See
86.Sx BUGS . )
87.Sh SEE ALSO
88.Xr hosts 5 ,
89.Xr networks 5 ,
90.Sh HISTORY
91The
92.Fn ns_addr
93and
94.Fn ns_toa
95functions appeared in
96.Bx 4.3 .
97.Sh BUGS
98The string returned by
99.Fn ns_ntoa
100resides in a static memory area.
101The function
102.Fn ns_addr
103should diagnose improperly formed input, and there should be an unambiguous
104way to recognize this.
105