diff options
author | mickey <> | 1996-08-16 09:47:06 +0000 |
---|---|---|
committer | mickey <> | 1996-08-16 09:47:06 +0000 |
commit | e13f6d5c18a6f30a6aaf70a2b311c0e6a9e5cf32 (patch) | |
tree | 21f4a72c72f1f5709fa736688b2dba46f1793784 | |
parent | 68389754d2afbc35f700de434b25b47b34a72a1a (diff) | |
download | openbsd-e13f6d5c18a6f30a6aaf70a2b311c0e6a9e5cf32.tar.gz openbsd-e13f6d5c18a6f30a6aaf70a2b311c0e6a9e5cf32.tar.bz2 openbsd-e13f6d5c18a6f30a6aaf70a2b311c0e6a9e5cf32.zip |
ipx.
-rw-r--r-- | src/lib/libc/net/Makefile.inc | 5 | ||||
-rw-r--r-- | src/lib/libc/net/ipx.3 | 126 | ||||
-rw-r--r-- | src/lib/libc/net/ipx_addr.c | 227 | ||||
-rw-r--r-- | src/lib/libc/net/ipx_ntoa.c | 58 |
4 files changed, 415 insertions, 1 deletions
diff --git a/src/lib/libc/net/Makefile.inc b/src/lib/libc/net/Makefile.inc index dcaebd2376..910462dd8e 100644 --- a/src/lib/libc/net/Makefile.inc +++ b/src/lib/libc/net/Makefile.inc | |||
@@ -1,3 +1,4 @@ | |||
1 | # $OpenBSD: Makefile.inc,v 1.5 1996/08/16 09:47:01 mickey Exp $ | ||
1 | # $NetBSD: Makefile.inc,v 1.24 1996/02/02 15:22:14 mrg Exp $ | 2 | # $NetBSD: Makefile.inc,v 1.24 1996/02/02 15:22:14 mrg Exp $ |
2 | # @(#)Makefile.inc 8.2 (Berkeley) 9/5/93 | 3 | # @(#)Makefile.inc 8.2 (Berkeley) 9/5/93 |
3 | 4 | ||
@@ -8,6 +9,7 @@ SRCS+= gethostnamadr.c getnetbyaddr.c getnetbyname.c getnetent.c \ | |||
8 | getproto.c getprotoent.c getprotoname.c getservbyname.c \ | 9 | getproto.c getprotoent.c getprotoname.c getservbyname.c \ |
9 | getservbyport.c getservent.c herror.c inet_addr.c inet_lnaof.c \ | 10 | getservbyport.c getservent.c herror.c inet_addr.c inet_lnaof.c \ |
10 | inet_makeaddr.c inet_netof.c inet_network.c inet_ntoa.c \ | 11 | inet_makeaddr.c inet_netof.c inet_network.c inet_ntoa.c \ |
12 | ipx_addr.c ipx_ntoa.c \ | ||
11 | iso_addr.c linkaddr.c ns_addr.c ns_ntoa.c nsap_addr.c rcmd.c recv.c \ | 13 | iso_addr.c linkaddr.c ns_addr.c ns_ntoa.c nsap_addr.c rcmd.c recv.c \ |
12 | res_comp.c res_debug.c res_init.c res_mkquery.c res_query.c \ | 14 | res_comp.c res_debug.c res_init.c res_mkquery.c res_query.c \ |
13 | res_send.c send.c sethostent.c ethers.c | 15 | res_send.c send.c sethostent.c ethers.c |
@@ -19,7 +21,7 @@ SRCS+= gethostnamadr.c getnetbyaddr.c getnetbyname.c getnetent.c \ | |||
19 | .include "${.CURDIR}/arch/${MACHINE_ARCH}/net/Makefile.inc" | 21 | .include "${.CURDIR}/arch/${MACHINE_ARCH}/net/Makefile.inc" |
20 | 22 | ||
21 | MAN+= byteorder.3 ethers.3 gethostbyname.3 getnetent.3 getprotoent.3 \ | 23 | MAN+= byteorder.3 ethers.3 gethostbyname.3 getnetent.3 getprotoent.3 \ |
22 | getservent.3 inet.3 iso_addr.3 link_addr.3 ns.3 rcmd.3 resolver.3 | 24 | getservent.3 inet.3 iso_addr.3 link_addr.3 ns.3 ipx.3 rcmd.3 resolver.3 |
23 | 25 | ||
24 | MLINKS+=byteorder.3 htonl.3 byteorder.3 htons.3 byteorder.3 ntohl.3 \ | 26 | MLINKS+=byteorder.3 htonl.3 byteorder.3 htons.3 byteorder.3 ntohl.3 \ |
25 | byteorder.3 ntohs.3 | 27 | byteorder.3 ntohs.3 |
@@ -40,6 +42,7 @@ MLINKS+=inet.3 addr.3 inet.3 inet_addr.3 inet.3 inet_aton.3 \ | |||
40 | inet.3 ntoa.3 | 42 | inet.3 ntoa.3 |
41 | MLINKS+=iso_addr.3 iso_ntoa.3 | 43 | MLINKS+=iso_addr.3 iso_ntoa.3 |
42 | MLINKS+=link_addr.3 link_ntoa.3 | 44 | MLINKS+=link_addr.3 link_ntoa.3 |
45 | MLINKS+=ipx.3 ipx_addr.3 ipx.3 ipx_ntoa.3 | ||
43 | MLINKS+=ns.3 ns_addr.3 ns.3 ns_ntoa.3 | 46 | MLINKS+=ns.3 ns_addr.3 ns.3 ns_ntoa.3 |
44 | MLINKS+=rcmd.3 iruserok.3 rcmd.3 rresvport.3 rcmd.3 ruserok.3 | 47 | MLINKS+=rcmd.3 iruserok.3 rcmd.3 rresvport.3 rcmd.3 ruserok.3 |
45 | MLINKS+=resolver.3 dn_comp.3 resolver.3 dn_expand.3 resolver.3 res_init.3 \ | 48 | MLINKS+=resolver.3 dn_comp.3 resolver.3 dn_expand.3 resolver.3 res_init.3 \ |
diff --git a/src/lib/libc/net/ipx.3 b/src/lib/libc/net/ipx.3 new file mode 100644 index 0000000000..f64dce163e --- /dev/null +++ b/src/lib/libc/net/ipx.3 | |||
@@ -0,0 +1,126 @@ | |||
1 | .\" $OpenBSD: ipx.3,v 1.1 1996/08/16 09:47:04 mickey Exp $ | ||
2 | .\" Copyright (c) 1986, 1991, 1993 | ||
3 | .\" The Regents of the University of California. All rights reserved. | ||
4 | .\" | ||
5 | .\" Redistribution and use in source and binary forms, with or without | ||
6 | .\" modification, are permitted provided that the following conditions | ||
7 | .\" are met: | ||
8 | .\" 1. Redistributions of source code must retain the above copyright | ||
9 | .\" notice, this list of conditions and the following disclaimer. | ||
10 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
11 | .\" notice, this list of conditions and the following disclaimer in the | ||
12 | .\" documentation and/or other materials provided with the distribution. | ||
13 | .\" 3. All advertising materials mentioning features or use of this software | ||
14 | .\" must display the following acknowledgement: | ||
15 | .\" This product includes software developed by the University of | ||
16 | .\" California, Berkeley and its contributors. | ||
17 | .\" 4. Neither the name of the University nor the names of its contributors | ||
18 | .\" may be used to endorse or promote products derived from this software | ||
19 | .\" without specific prior written permission. | ||
20 | .\" | ||
21 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
22 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
23 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
24 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
25 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
26 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
27 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
29 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
30 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
31 | .\" SUCH DAMAGE. | ||
32 | .\" | ||
33 | .\" | ||
34 | .Dd June 4, 1993 | ||
35 | .Dt IPX 3 | ||
36 | .Os OpenBSD 1.2 | ||
37 | .Sh NAME | ||
38 | .Nm ipx_addr , | ||
39 | .Nm ipx_ntoa | ||
40 | .Nd IPX address conversion routines | ||
41 | .Sh SYNOPSIS | ||
42 | .Fd #include <sys/types.h> | ||
43 | .Fd #include <netipx/ipx.h> | ||
44 | .Ft struct ipx_addr | ||
45 | .Fn ipx_addr "char *cp" | ||
46 | .Ft char * | ||
47 | .Fn ipx_ntoa "struct ipx_addr ipx" | ||
48 | .Sh DESCRIPTION | ||
49 | The routine | ||
50 | .Fn ipx_addr | ||
51 | interprets character strings representing | ||
52 | .Tn IPX | ||
53 | addresses, returning binary information suitable | ||
54 | for use in system calls. | ||
55 | The routine | ||
56 | .Fn ipx_ntoa | ||
57 | takes | ||
58 | .Tn IPX | ||
59 | addresses and returns | ||
60 | .Tn ASCII | ||
61 | strings representing the address in a | ||
62 | notation in common use: | ||
63 | .Bd -filled -offset indent | ||
64 | <network number>.<host number>.<port number> | ||
65 | .Ed | ||
66 | .Pp | ||
67 | Trailing zero fields are suppressed, and each number is printed in hexadecimal, | ||
68 | in a format suitable for input to | ||
69 | .Fn ipx_addr . | ||
70 | Any fields lacking super-decimal digits will have a | ||
71 | trailing | ||
72 | .Ql H | ||
73 | appended. | ||
74 | .Pp | ||
75 | An effort has been made to insure that | ||
76 | .Fn ipx_addr | ||
77 | be compatible with most formats in common use. | ||
78 | It will first separate an address into 1 to 3 fields using a single delimiter | ||
79 | chosen from | ||
80 | period | ||
81 | .Ql \&. , | ||
82 | colon | ||
83 | .Ql \&: | ||
84 | or pound-sign | ||
85 | .Ql \&# . | ||
86 | Each field is then examined for byte separators (colon or period). | ||
87 | If there are byte separators, each subfield separated is taken to be | ||
88 | a small hexadecimal number, and the entirety is taken as a network-byte-ordered | ||
89 | quantity to be zero extended in the high-network-order bytes. | ||
90 | Next, the field is inspected for hyphens, in which case | ||
91 | the field is assumed to be a number in decimal notation | ||
92 | with hyphens separating the millenia. | ||
93 | Next, the field is assumed to be a number: | ||
94 | It is interpreted | ||
95 | as hexadecimal if there is a leading | ||
96 | .Ql 0x | ||
97 | (as in C), | ||
98 | a trailing | ||
99 | .Ql H | ||
100 | (as in Mesa), or there are any super-decimal digits present. | ||
101 | It is interpreted as octal is there is a leading | ||
102 | .Ql 0 | ||
103 | and there are no super-octal digits. | ||
104 | Otherwise, it is converted as a decimal number. | ||
105 | .Sh RETURN VALUES | ||
106 | None. (See | ||
107 | .Sx BUGS . ) | ||
108 | .Sh SEE ALSO | ||
109 | .Xr ns 4 , | ||
110 | .Xr hosts 5 , | ||
111 | .Xr networks 5 | ||
112 | .Sh HISTORY | ||
113 | The precursor | ||
114 | .Fn ns_addr | ||
115 | and | ||
116 | .Fn ns_toa | ||
117 | functions appeared in | ||
118 | .Bx 4.3 . | ||
119 | .Sh BUGS | ||
120 | The string returned by | ||
121 | .Fn ipx_ntoa | ||
122 | resides in a static memory area. | ||
123 | The function | ||
124 | .Fn ipx_addr | ||
125 | should diagnose improperly formed input, and there should be an unambiguous | ||
126 | way to recognize this. | ||
diff --git a/src/lib/libc/net/ipx_addr.c b/src/lib/libc/net/ipx_addr.c new file mode 100644 index 0000000000..c4ca5f12bd --- /dev/null +++ b/src/lib/libc/net/ipx_addr.c | |||
@@ -0,0 +1,227 @@ | |||
1 | /* $OpenBSD: ipx_addr.c,v 1.1 1996/08/16 09:47:05 mickey Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1986, 1993 | ||
5 | * The Regents of the University of California. All rights reserved. | ||
6 | * | ||
7 | * This code is derived from software contributed to Berkeley by | ||
8 | * J.Q. Johnson. | ||
9 | * | ||
10 | * Redistribution and use in source and binary forms, with or without | ||
11 | * modification, are permitted provided that the following conditions | ||
12 | * are met: | ||
13 | * 1. Redistributions of source code must retain the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. All advertising materials mentioning features or use of this software | ||
19 | * must display the following acknowledgement: | ||
20 | * This product includes software developed by the University of | ||
21 | * California, Berkeley and its contributors. | ||
22 | * 4. Neither the name of the University nor the names of its contributors | ||
23 | * may be used to endorse or promote products derived from this software | ||
24 | * without specific prior written permission. | ||
25 | * | ||
26 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
36 | * SUCH DAMAGE. | ||
37 | * | ||
38 | * from @(#)ipx_addr.c | ||
39 | */ | ||
40 | |||
41 | #include <sys/param.h> | ||
42 | #include <netipx/ipx.h> | ||
43 | #include <stdio.h> | ||
44 | #include <string.h> | ||
45 | |||
46 | static struct ipx_addr addr, zero_addr; | ||
47 | |||
48 | static void Field(), cvtbase(); | ||
49 | |||
50 | struct ipx_addr | ||
51 | ipx_addr(name) | ||
52 | const char *name; | ||
53 | { | ||
54 | char separator; | ||
55 | char *hostname, *socketname, *cp; | ||
56 | char buf[50]; | ||
57 | |||
58 | (void)strncpy(buf, name, sizeof(buf) - 1); | ||
59 | buf[sizeof(buf) - 1] = '\0'; | ||
60 | |||
61 | /* | ||
62 | * First, figure out what he intends as a field separtor. | ||
63 | * Despite the way this routine is written, the prefered | ||
64 | * form 2-272.AA001234H.01777, i.e. XDE standard. | ||
65 | * Great efforts are made to insure backward compatability. | ||
66 | */ | ||
67 | if (hostname = strchr(buf, '#')) | ||
68 | separator = '#'; | ||
69 | else { | ||
70 | hostname = strchr(buf, '.'); | ||
71 | if ((cp = strchr(buf, ':')) && | ||
72 | ((hostname && cp < hostname) || (hostname == 0))) { | ||
73 | hostname = cp; | ||
74 | separator = ':'; | ||
75 | } else | ||
76 | separator = '.'; | ||
77 | } | ||
78 | if (hostname) | ||
79 | *hostname++ = 0; | ||
80 | |||
81 | addr = zero_addr; | ||
82 | Field(buf, addr.ipx_net.c_net, 4); | ||
83 | if (hostname == 0) | ||
84 | return (addr); /* No separator means net only */ | ||
85 | |||
86 | socketname = strchr(hostname, separator); | ||
87 | if (socketname) { | ||
88 | *socketname++ = 0; | ||
89 | Field(socketname, (u_char *)&addr.ipx_port, 2); | ||
90 | } | ||
91 | |||
92 | Field(hostname, addr.ipx_host.c_host, 6); | ||
93 | |||
94 | return (addr); | ||
95 | } | ||
96 | |||
97 | static void | ||
98 | Field(buf, out, len) | ||
99 | char *buf; | ||
100 | u_char *out; | ||
101 | int len; | ||
102 | { | ||
103 | register char *bp = buf; | ||
104 | int i, ibase, base16 = 0, base10 = 0, clen = 0; | ||
105 | int hb[6], *hp; | ||
106 | char *fmt; | ||
107 | |||
108 | /* | ||
109 | * first try 2-273#2-852-151-014#socket | ||
110 | */ | ||
111 | if ((*buf != '-') && | ||
112 | (1 < (i = sscanf(buf, "%d-%d-%d-%d-%d", | ||
113 | &hb[0], &hb[1], &hb[2], &hb[3], &hb[4])))) { | ||
114 | cvtbase(1000L, 256, hb, i, out, len); | ||
115 | return; | ||
116 | } | ||
117 | /* | ||
118 | * try form 8E1#0.0.AA.0.5E.E6#socket | ||
119 | */ | ||
120 | if (1 < (i = sscanf(buf,"%x.%x.%x.%x.%x.%x", | ||
121 | &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) { | ||
122 | cvtbase(256L, 256, hb, i, out, len); | ||
123 | return; | ||
124 | } | ||
125 | /* | ||
126 | * try form 8E1#0:0:AA:0:5E:E6#socket | ||
127 | */ | ||
128 | if (1 < (i = sscanf(buf,"%x:%x:%x:%x:%x:%x", | ||
129 | &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) { | ||
130 | cvtbase(256L, 256, hb, i, out, len); | ||
131 | return; | ||
132 | } | ||
133 | /* | ||
134 | * This is REALLY stretching it but there was a | ||
135 | * comma notation separting shorts -- definitely non standard | ||
136 | */ | ||
137 | if (1 < (i = sscanf(buf,"%x,%x,%x", | ||
138 | &hb[0], &hb[1], &hb[2]))) { | ||
139 | hb[0] = htons(hb[0]); hb[1] = htons(hb[1]); | ||
140 | hb[2] = htons(hb[2]); | ||
141 | cvtbase(65536L, 256, hb, i, out, len); | ||
142 | return; | ||
143 | } | ||
144 | |||
145 | /* Need to decide if base 10, 16 or 8 */ | ||
146 | while (*bp) switch (*bp++) { | ||
147 | |||
148 | case '0': case '1': case '2': case '3': case '4': case '5': | ||
149 | case '6': case '7': case '-': | ||
150 | break; | ||
151 | |||
152 | case '8': case '9': | ||
153 | base10 = 1; | ||
154 | break; | ||
155 | |||
156 | case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': | ||
157 | case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': | ||
158 | base16 = 1; | ||
159 | break; | ||
160 | |||
161 | case 'x': case 'X': | ||
162 | *--bp = '0'; | ||
163 | base16 = 1; | ||
164 | break; | ||
165 | |||
166 | case 'h': case 'H': | ||
167 | base16 = 1; | ||
168 | /* fall into */ | ||
169 | |||
170 | default: | ||
171 | *--bp = 0; /* Ends Loop */ | ||
172 | } | ||
173 | if (base16) { | ||
174 | fmt = "%3x"; | ||
175 | ibase = 4096; | ||
176 | } else if (base10 == 0 && *buf == '0') { | ||
177 | fmt = "%3o"; | ||
178 | ibase = 512; | ||
179 | } else { | ||
180 | fmt = "%3d"; | ||
181 | ibase = 1000; | ||
182 | } | ||
183 | |||
184 | for (bp = buf; *bp++; ) clen++; | ||
185 | if (clen == 0) clen++; | ||
186 | if (clen > 18) clen = 18; | ||
187 | i = ((clen - 1) / 3) + 1; | ||
188 | bp = clen + buf - 3; | ||
189 | hp = hb + i - 1; | ||
190 | |||
191 | while (hp > hb) { | ||
192 | (void)sscanf(bp, fmt, hp); | ||
193 | bp[0] = 0; | ||
194 | hp--; | ||
195 | bp -= 3; | ||
196 | } | ||
197 | (void)sscanf(buf, fmt, hp); | ||
198 | cvtbase((long)ibase, 256, hb, i, out, len); | ||
199 | } | ||
200 | |||
201 | static void | ||
202 | cvtbase(oldbase,newbase,input,inlen,result,reslen) | ||
203 | long oldbase; | ||
204 | int newbase; | ||
205 | int input[]; | ||
206 | int inlen; | ||
207 | unsigned char result[]; | ||
208 | int reslen; | ||
209 | { | ||
210 | int d, e; | ||
211 | long sum; | ||
212 | |||
213 | e = 1; | ||
214 | while (e > 0 && reslen > 0) { | ||
215 | d = 0; e = 0; sum = 0; | ||
216 | /* long division: input=input/newbase */ | ||
217 | while (d < inlen) { | ||
218 | sum = sum*oldbase + (long) input[d]; | ||
219 | e += (sum > 0); | ||
220 | input[d++] = sum / newbase; | ||
221 | sum %= newbase; | ||
222 | } | ||
223 | result[--reslen] = sum; /* accumulate remainder */ | ||
224 | } | ||
225 | for (d=0; d < reslen; d++) | ||
226 | result[d] = 0; | ||
227 | } | ||
diff --git a/src/lib/libc/net/ipx_ntoa.c b/src/lib/libc/net/ipx_ntoa.c new file mode 100644 index 0000000000..4f59321e89 --- /dev/null +++ b/src/lib/libc/net/ipx_ntoa.c | |||
@@ -0,0 +1,58 @@ | |||
1 | /* $OpenBSD: ipx_ntoa.c,v 1.1 1996/08/16 09:47:06 mickey Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1986, 1993 | ||
5 | * The Regents of the University of California. All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. All advertising materials mentioning features or use of this software | ||
16 | * must display the following acknowledgement: | ||
17 | * This product includes software developed by the University of | ||
18 | * California, Berkeley and its contributors. | ||
19 | * 4. Neither the name of the University nor the names of its contributors | ||
20 | * may be used to endorse or promote products derived from this software | ||
21 | * without specific prior written permission. | ||
22 | * | ||
23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
33 | * SUCH DAMAGE. | ||
34 | * | ||
35 | * from @(#)ipx_ntoa.c | ||
36 | */ | ||
37 | |||
38 | #include <sys/param.h> | ||
39 | #include <netipx/ipx.h> | ||
40 | #include <stdio.h> | ||
41 | |||
42 | char * | ||
43 | ipx_ntoa(addr) | ||
44 | struct ipx_addr addr; | ||
45 | { | ||
46 | static char obuf[] = "xxxx.xx:xx:xx:xx:xx:xx.uuuuu"; | ||
47 | |||
48 | sprintf(obuf, "%8xH.%02x:%02x:%02x:%02x:%02x:%02x.%u", | ||
49 | ntohl(addr.ipx_net.l_net), | ||
50 | addr.ipx_host.c_host[0], | ||
51 | addr.ipx_host.c_host[1], | ||
52 | addr.ipx_host.c_host[2], | ||
53 | addr.ipx_host.c_host[3], | ||
54 | addr.ipx_host.c_host[4], | ||
55 | addr.ipx_host.c_host[5], | ||
56 | ntohs(addr.ipx_port)); | ||
57 | return (obuf); | ||
58 | } | ||