Remove NS and ISO stuff.
This commit is contained in:
parent
c7abac8042
commit
243fd46542
@ -13,14 +13,12 @@ SRCS+= addr2ascii.c ascii2addr.c base64.c ether_addr.c getaddrinfo.c \
|
||||
if_indextoname.c if_nameindex.c if_nametoindex.c inet_lnaof.c \
|
||||
inet_makeaddr.c inet_net_ntop.c inet_net_pton.c inet_neta.c \
|
||||
inet_netof.c inet_network.c inet_ntoa.c inet_ntop.c \
|
||||
inet_pton.c ip6opt.c linkaddr.c map_v4v6.c name6.c ns_addr.c \
|
||||
ns_name.c ns_netint.c \
|
||||
ns_ntoa.c ns_parse.c ns_print.c ns_ttl.c \
|
||||
inet_pton.c ip6opt.c linkaddr.c map_v4v6.c name6.c \
|
||||
ns_name.c ns_netint.c ns_parse.c ns_print.c ns_ttl.c \
|
||||
nsdispatch.c nslexer.c nsparser.c \
|
||||
nsap_addr.c rcmd.c rcmdsh.c recv.c res_comp.c res_data.c res_debug.c \
|
||||
res_init.c res_mkquery.c res_mkupdate.c res_query.c res_send.c \
|
||||
res_update.c rthdr.c send.c sockatmark.c vars.c
|
||||
# not supported: iso_addr.c
|
||||
|
||||
CFLAGS+=-DINET6 -I${.OBJDIR}
|
||||
|
||||
@ -48,7 +46,6 @@ MAN+= addr2ascii.3 byteorder.3 ethers.3 getaddrinfo.3 gethostbyname.3 \
|
||||
inet.3 inet_net.3 \
|
||||
inet6_option_space.3 inet6_rthdr_space.3 linkaddr.3 \
|
||||
nsdispatch.3 rcmd.3 rcmdsh.3 resolver.3 sockatmark.3
|
||||
# not installed: iso_addr.3 ns.3
|
||||
|
||||
MLINKS+=addr2ascii.3 ascii2addr.3
|
||||
MLINKS+=byteorder.3 htonl.3 byteorder.3 htons.3 byteorder.3 ntohl.3 \
|
||||
@ -89,7 +86,6 @@ MLINKS+=inet6_option_space.3 inet6_option_alloc.3 \
|
||||
inet6_rthdr_space.3 inet6_rthdr_reverse.3 \
|
||||
inet6_rthdr_space.3 inet6_rthdr_segments.3
|
||||
MLINKS+=linkaddr.3 link_addr.3 linkaddr.3 link_ntoa.3
|
||||
#MLINKS+=ns.3 ns_addr.3 ns.3 ns_ntoa.3
|
||||
MLINKS+=rcmd.3 iruserok.3 rcmd.3 iruserok_sa.3 \
|
||||
rcmd.3 rcmd_af.3 \
|
||||
rcmd.3 rresvport.3 rcmd.3 rresvport_af.3 \
|
||||
|
@ -1,117 +0,0 @@
|
||||
.\" Copyright (c) 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by the University of
|
||||
.\" California, Berkeley and its contributors.
|
||||
.\" 4. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)iso_addr.3 8.1 (Berkeley) 6/4/93
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd June 4, 1993
|
||||
.Dt ISO_ADDR 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm iso_addr ,
|
||||
.Nm iso_ntoa
|
||||
.Nd "elementary network address conversion routines for Open System Interconnection
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In sys/types.h
|
||||
.In netiso/iso.h
|
||||
.Ft struct iso_addr *
|
||||
.Fn iso_addr "char *cp"
|
||||
.Ft char *
|
||||
.Fn iso_ntoa "struct iso_addr *isoa"
|
||||
.Sh DESCRIPTION
|
||||
The routine
|
||||
.Fn iso_addr
|
||||
interprets character strings representing
|
||||
.Tn OSI
|
||||
addresses, returning binary information suitable
|
||||
for use in system calls.
|
||||
The routine
|
||||
.Fn iso_ntoa
|
||||
takes
|
||||
.Tn OSI
|
||||
addresses and returns
|
||||
.Tn ASCII
|
||||
strings representing NSAPs (network service
|
||||
access points) in a
|
||||
notation inverse to that accepted by
|
||||
.Fn iso_addr .
|
||||
.Pp
|
||||
Unfortunately, no universal standard exists for representing
|
||||
.Tn OSI
|
||||
network addresses.
|
||||
.Pp
|
||||
The format employed by
|
||||
.Fn iso_addr
|
||||
is a sequence of hexadecimal
|
||||
.Dq digits
|
||||
(optionally separated by periods),
|
||||
of the form:
|
||||
.Bd -ragged -offset indent
|
||||
<hex digits>.<hex digits>.<hex digits>
|
||||
.Ed
|
||||
.Pp
|
||||
Each pair of hexadecimal digits represents a byte
|
||||
with the leading digit indicating the higher-ordered bits.
|
||||
A period following an even number of bytes has no
|
||||
effect (but may be used to increase legibility).
|
||||
A period following an odd number of bytes has the
|
||||
effect of causing the byte of address being translated
|
||||
to have its higher order bits filled with zeros.
|
||||
.Sh RETURN VALUES
|
||||
The
|
||||
.Fn iso_ntoa
|
||||
function
|
||||
always returns a null terminated string.
|
||||
The
|
||||
.Fn iso_addr
|
||||
function
|
||||
always returns a pointer to a struct iso_addr.
|
||||
(See
|
||||
.Sx BUGS . )
|
||||
.Sh SEE ALSO
|
||||
.Xr iso 4
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Fn iso_addr
|
||||
and
|
||||
.Fn iso_ntoa
|
||||
functions appeared in
|
||||
.Bx 4.3 Reno .
|
||||
.Sh BUGS
|
||||
The returned values
|
||||
reside in a static memory area.
|
||||
.Pp
|
||||
The function
|
||||
.Fn iso_addr
|
||||
should diagnose improperly formed input, and there should be an unambiguous
|
||||
way to recognize this.
|
@ -1,119 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)iso_addr.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <netiso/iso.h>
|
||||
#include <string.h>
|
||||
|
||||
/* States*/
|
||||
#define VIRGIN 0
|
||||
#define GOTONE 1
|
||||
#define GOTTWO 2
|
||||
/* Inputs */
|
||||
#define DIGIT (4*0)
|
||||
#define END (4*1)
|
||||
#define DELIM (4*2)
|
||||
|
||||
struct iso_addr *
|
||||
iso_addr(addr)
|
||||
const char *addr;
|
||||
{
|
||||
static struct iso_addr out_addr;
|
||||
char *cp = out_addr.isoa_genaddr;
|
||||
char *cplim = cp + sizeof(out_addr.isoa_genaddr);
|
||||
int byte = 0, state = VIRGIN, new;
|
||||
|
||||
bzero((char *)&out_addr, sizeof(out_addr));
|
||||
do {
|
||||
if ((*addr >= '0') && (*addr <= '9')) {
|
||||
new = *addr - '0';
|
||||
} else if ((*addr >= 'a') && (*addr <= 'f')) {
|
||||
new = *addr - 'a' + 10;
|
||||
} else if ((*addr >= 'A') && (*addr <= 'F')) {
|
||||
new = *addr - 'A' + 10;
|
||||
} else if (*addr == 0)
|
||||
state |= END;
|
||||
else
|
||||
state |= DELIM;
|
||||
addr++;
|
||||
switch (state /* | INPUT */) {
|
||||
case GOTTWO | DIGIT:
|
||||
*cp++ = byte; /*FALLTHROUGH*/
|
||||
case VIRGIN | DIGIT:
|
||||
state = GOTONE; byte = new; continue;
|
||||
case GOTONE | DIGIT:
|
||||
state = GOTTWO; byte = new + (byte << 4); continue;
|
||||
default: /* | DELIM */
|
||||
state = VIRGIN; *cp++ = byte; byte = 0; continue;
|
||||
case GOTONE | END:
|
||||
case GOTTWO | END:
|
||||
*cp++ = byte; /* FALLTHROUGH */
|
||||
case VIRGIN | END:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
} while (cp < cplim);
|
||||
out_addr.isoa_len = cp - out_addr.isoa_genaddr;
|
||||
return (&out_addr);
|
||||
}
|
||||
|
||||
static char hexlist[] = "0123456789abcdef";
|
||||
|
||||
char *
|
||||
iso_ntoa(isoa)
|
||||
const struct iso_addr *isoa;
|
||||
{
|
||||
static char tmpbuf[sizeof(isoa->isoa_genaddr)*3];
|
||||
const u_char *binary;
|
||||
char *cp;
|
||||
int i;
|
||||
|
||||
binary = isoa->isoa_genaddr;
|
||||
cp = tmpbuf;
|
||||
|
||||
for (i = 0; i < isoa->isoa_len; i++) {
|
||||
*cp++ = hexlist[*binary >> 4];
|
||||
*cp++ = hexlist[*binary++ & 0xf];
|
||||
|
||||
if ((((i % 2) == 0) && ((i + 1) < isoa->isoa_len)))
|
||||
*cp++ = '.';
|
||||
}
|
||||
*cp = '\0';
|
||||
return tmpbuf;
|
||||
}
|
@ -1,133 +0,0 @@
|
||||
.\" Copyright (c) 1986, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by the University of
|
||||
.\" California, Berkeley and its contributors.
|
||||
.\" 4. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)ns.3 8.1 (Berkeley) 6/4/93
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd June 4, 1993
|
||||
.Dt NS 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm ns_addr ,
|
||||
.Nm ns_ntoa
|
||||
.Nd Xerox
|
||||
.Tn NS Ns (tm)
|
||||
address conversion routines
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In sys/types.h
|
||||
.In netns/ns.h
|
||||
.Ft struct ns_addr
|
||||
.Fn ns_addr "char *cp"
|
||||
.Ft char *
|
||||
.Fn ns_ntoa "struct ns_addr ns"
|
||||
.Sh DESCRIPTION
|
||||
The routine
|
||||
.Fn ns_addr
|
||||
interprets character strings representing
|
||||
.Tn XNS
|
||||
addresses, returning binary information suitable
|
||||
for use in system calls.
|
||||
The routine
|
||||
.Fn ns_ntoa
|
||||
takes
|
||||
.Tn XNS
|
||||
addresses and returns
|
||||
.Tn ASCII
|
||||
strings representing the address in a
|
||||
notation in common use in the Xerox Development Environment:
|
||||
.Bd -ragged -offset indent
|
||||
<network number>.<host number>.<port number>
|
||||
.Ed
|
||||
.Pp
|
||||
Trailing zero fields are suppressed, and each number is printed in hexadecimal,
|
||||
in a format suitable for input to
|
||||
.Fn ns_addr .
|
||||
Any fields lacking super-decimal digits will have a
|
||||
trailing
|
||||
.Ql H
|
||||
appended.
|
||||
.Pp
|
||||
Unfortunately, no universal standard exists for representing
|
||||
.Tn XNS
|
||||
addresses.
|
||||
An effort has been made to insure that
|
||||
.Fn ns_addr
|
||||
be compatible with most formats in common use.
|
||||
It will first separate an address into 1 to 3 fields using a single delimiter
|
||||
chosen from
|
||||
period
|
||||
.Ql \&. ,
|
||||
colon
|
||||
.Ql \&:
|
||||
or pound-sign
|
||||
.Ql \&# .
|
||||
Each field is then examined for byte separators (colon or period).
|
||||
If there are byte separators, each subfield separated is taken to be
|
||||
a small hexadecimal number, and the entirety is taken as a network-byte-ordered
|
||||
quantity to be zero extended in the high-network-order bytes.
|
||||
Next, the field is inspected for hyphens, in which case
|
||||
the field is assumed to be a number in decimal notation
|
||||
with hyphens separating the millenia.
|
||||
Next, the field is assumed to be a number:
|
||||
It is interpreted
|
||||
as hexadecimal if there is a leading
|
||||
.Ql 0x
|
||||
(as in C),
|
||||
a trailing
|
||||
.Ql H
|
||||
(as in Mesa), or there are any super-decimal digits present.
|
||||
It is interpreted as octal is there is a leading
|
||||
.Ql 0
|
||||
and there are no super-octal digits.
|
||||
Otherwise, it is converted as a decimal number.
|
||||
.Sh RETURN VALUES
|
||||
None. (See
|
||||
.Sx BUGS . )
|
||||
.Sh SEE ALSO
|
||||
.Xr hosts 5 ,
|
||||
.Xr networks 5
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Fn ns_addr
|
||||
and
|
||||
.Fn ns_toa
|
||||
functions appeared in
|
||||
.Bx 4.3 .
|
||||
.Sh BUGS
|
||||
The string returned by
|
||||
.Fn ns_ntoa
|
||||
resides in a static memory area.
|
||||
The function
|
||||
.Fn ns_addr
|
||||
should diagnose improperly formed input, and there should be an unambiguous
|
||||
way to recognize this.
|
@ -1,239 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1986, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* J.Q. Johnson.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)ns_addr.c 8.1 (Berkeley) 6/7/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netns/ns.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static struct ns_addr addr, zero_addr;
|
||||
|
||||
static void Field(), cvtbase();
|
||||
|
||||
struct ns_addr
|
||||
ns_addr(name)
|
||||
const char *name;
|
||||
{
|
||||
char separator;
|
||||
char *hostname, *socketname, *cp;
|
||||
char buf[50];
|
||||
|
||||
(void)strncpy(buf, name, sizeof(buf) - 1);
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
|
||||
/*
|
||||
* First, figure out what he intends as a field separtor.
|
||||
* Despite the way this routine is written, the preferred
|
||||
* form 2-272.AA001234H.01777, i.e. XDE standard.
|
||||
* Great efforts are made to insure backward compatibility.
|
||||
*/
|
||||
if ((hostname = strchr(buf, '#')) != NULL)
|
||||
separator = '#';
|
||||
else {
|
||||
hostname = strchr(buf, '.');
|
||||
if ((cp = strchr(buf, ':')) &&
|
||||
((hostname && cp < hostname) || (hostname == 0))) {
|
||||
hostname = cp;
|
||||
separator = ':';
|
||||
} else
|
||||
separator = '.';
|
||||
}
|
||||
if (hostname)
|
||||
*hostname++ = 0;
|
||||
|
||||
addr = zero_addr;
|
||||
Field(buf, addr.x_net.c_net, 4);
|
||||
if (hostname == 0)
|
||||
return (addr); /* No separator means net only */
|
||||
|
||||
socketname = strchr(hostname, separator);
|
||||
if (socketname) {
|
||||
*socketname++ = 0;
|
||||
Field(socketname, (u_char *)&addr.x_port, 2);
|
||||
}
|
||||
|
||||
Field(hostname, addr.x_host.c_host, 6);
|
||||
|
||||
return (addr);
|
||||
}
|
||||
|
||||
static void
|
||||
Field(buf, out, len)
|
||||
char *buf;
|
||||
u_char *out;
|
||||
int len;
|
||||
{
|
||||
char *bp = buf;
|
||||
int i, ibase, base16 = 0, base10 = 0, clen = 0;
|
||||
int hb[6], *hp;
|
||||
|
||||
/*
|
||||
* first try 2-273#2-852-151-014#socket
|
||||
*/
|
||||
if ((*buf != '-') &&
|
||||
(1 < (i = sscanf(buf, "%d-%d-%d-%d-%d",
|
||||
&hb[0], &hb[1], &hb[2], &hb[3], &hb[4])))) {
|
||||
cvtbase(1000L, 256, hb, i, out, len);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* try form 8E1#0.0.AA.0.5E.E6#socket
|
||||
*/
|
||||
if (1 < (i = sscanf(buf,"%x.%x.%x.%x.%x.%x",
|
||||
&hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) {
|
||||
cvtbase(256L, 256, hb, i, out, len);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* try form 8E1#0:0:AA:0:5E:E6#socket
|
||||
*/
|
||||
if (1 < (i = sscanf(buf,"%x:%x:%x:%x:%x:%x",
|
||||
&hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) {
|
||||
cvtbase(256L, 256, hb, i, out, len);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* This is REALLY stretching it but there was a
|
||||
* comma notation separting shorts -- definitely non standard
|
||||
*/
|
||||
if (1 < (i = sscanf(buf,"%x,%x,%x",
|
||||
&hb[0], &hb[1], &hb[2]))) {
|
||||
hb[0] = htons(hb[0]); hb[1] = htons(hb[1]);
|
||||
hb[2] = htons(hb[2]);
|
||||
cvtbase(65536L, 256, hb, i, out, len);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Need to decide if base 10, 16 or 8 */
|
||||
while (*bp) switch (*bp++) {
|
||||
|
||||
case '0': case '1': case '2': case '3': case '4': case '5':
|
||||
case '6': case '7': case '-':
|
||||
break;
|
||||
|
||||
case '8': case '9':
|
||||
base10 = 1;
|
||||
break;
|
||||
|
||||
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
|
||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
||||
base16 = 1;
|
||||
break;
|
||||
|
||||
case 'x': case 'X':
|
||||
*--bp = '0';
|
||||
base16 = 1;
|
||||
break;
|
||||
|
||||
case 'h': case 'H':
|
||||
base16 = 1;
|
||||
/* FALLTHROUGH */
|
||||
|
||||
default:
|
||||
*--bp = 0; /* Ends Loop */
|
||||
}
|
||||
if (base16) {
|
||||
ibase = 4096;
|
||||
} else if (base10 == 0 && *buf == '0') {
|
||||
ibase = 512;
|
||||
} else {
|
||||
base10 = 1;
|
||||
ibase = 1000;
|
||||
}
|
||||
|
||||
for (bp = buf; *bp++; ) clen++;
|
||||
if (clen == 0) clen++;
|
||||
if (clen > 18) clen = 18;
|
||||
i = ((clen - 1) / 3) + 1;
|
||||
bp = clen + buf - 3;
|
||||
hp = hb + i - 1;
|
||||
|
||||
while (hp > hb) {
|
||||
if (base16)
|
||||
(void)sscanf(bp, "%3x", hp);
|
||||
else if (base10)
|
||||
(void)sscanf(bp, "%3d", hp);
|
||||
else
|
||||
(void)sscanf(bp, "%3o", hp);
|
||||
|
||||
bp[0] = 0;
|
||||
hp--;
|
||||
bp -= 3;
|
||||
}
|
||||
if (base16)
|
||||
(void)sscanf(buf, "%3x", hp);
|
||||
else if (base10)
|
||||
(void)sscanf(buf, "%3d", hp);
|
||||
else
|
||||
(void)sscanf(buf, "%3o", hp);
|
||||
|
||||
cvtbase((long)ibase, 256, hb, i, out, len);
|
||||
}
|
||||
|
||||
static void
|
||||
cvtbase(oldbase,newbase,input,inlen,result,reslen)
|
||||
long oldbase;
|
||||
int newbase;
|
||||
int input[];
|
||||
int inlen;
|
||||
unsigned char result[];
|
||||
int reslen;
|
||||
{
|
||||
int d, e;
|
||||
long sum;
|
||||
|
||||
e = 1;
|
||||
while (e > 0 && reslen > 0) {
|
||||
d = 0; e = 0; sum = 0;
|
||||
/* long division: input=input/newbase */
|
||||
while (d < inlen) {
|
||||
sum = sum*oldbase + (long) input[d];
|
||||
e += (sum > 0);
|
||||
input[d++] = sum / newbase;
|
||||
sum %= newbase;
|
||||
}
|
||||
result[--reslen] = sum; /* accumulate remainder */
|
||||
}
|
||||
for (d=0; d < reslen; d++)
|
||||
result[d] = 0;
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1986, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)ns_ntoa.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netns/ns.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char *
|
||||
ns_ntoa(addr)
|
||||
struct ns_addr addr;
|
||||
{
|
||||
static char obuf[40];
|
||||
union { union ns_net net_e; u_long long_e; } net;
|
||||
u_short port = htons(addr.x_port);
|
||||
char *cp;
|
||||
char *cp2;
|
||||
u_char *up = addr.x_host.c_host;
|
||||
u_char *uplim = up + 6;
|
||||
static char *spectHex();
|
||||
|
||||
net.net_e = addr.x_net;
|
||||
sprintf(obuf, "%lx", (u_long)ntohl(net.long_e));
|
||||
cp = spectHex(obuf);
|
||||
cp2 = cp + 1;
|
||||
while (*up==0 && up < uplim) up++;
|
||||
if (up == uplim) {
|
||||
if (port) {
|
||||
sprintf(cp, ".0");
|
||||
cp += 2;
|
||||
}
|
||||
} else {
|
||||
sprintf(cp, ".%x", *up++);
|
||||
while (up < uplim) {
|
||||
while (*cp) cp++;
|
||||
sprintf(cp, "%02x", *up++);
|
||||
}
|
||||
cp = spectHex(cp2);
|
||||
}
|
||||
if (port) {
|
||||
sprintf(cp, ".%x", port);
|
||||
spectHex(cp + 1);
|
||||
}
|
||||
return (obuf);
|
||||
}
|
||||
|
||||
static char *
|
||||
spectHex(p0)
|
||||
char *p0;
|
||||
{
|
||||
int ok = 0;
|
||||
int nonzero = 0;
|
||||
char *p = p0;
|
||||
for (; *p; p++) switch (*p) {
|
||||
|
||||
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
|
||||
*p += ('A' - 'a');
|
||||
/* FALLTHROUGH */
|
||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
||||
ok = 1;
|
||||
case '1': case '2': case '3': case '4': case '5':
|
||||
case '6': case '7': case '8': case '9':
|
||||
nonzero = 1;
|
||||
}
|
||||
if (nonzero && !ok) { *p++ = 'H'; *p = 0; }
|
||||
return (p);
|
||||
}
|
@ -64,27 +64,10 @@ The currently understood formats are:
|
||||
PF_LOCAL Host-internal protocols, formerly called PF_UNIX,
|
||||
PF_UNIX Host-internal protocols, deprecated, use PF_LOCAL,
|
||||
PF_INET Internet version 4 protocols,
|
||||
PF_IMPLINK ARPAnet IMP addresses,
|
||||
PF_PUP PUP protocols, like BSP,
|
||||
PF_CHAOS MIT CHAOS protocols,
|
||||
PF_NS Xerox Network Systems protocols,
|
||||
PF_ISO ISO protocols,
|
||||
PF_OSI Open Systems Interconnection protocols,
|
||||
PF_ECMA European Computer Manufacturers,
|
||||
PF_DATAKIT Datakit protocols,
|
||||
PF_CCITT ITU-T protocols, like X.25,
|
||||
PF_SNA IBM SNA,
|
||||
PF_DECnet DECnet,
|
||||
PF_DLI DEC Direct Data Link Interface protocol,
|
||||
PF_LAT LAT protocol,
|
||||
PF_HYLINK NSC Hyperchannel,
|
||||
PF_APPLETALK AppleTalk protocols,
|
||||
PF_ROUTE Internal Routing protocol,
|
||||
PF_LINK Link layer interface,
|
||||
PF_XTP eXpress Transfer Protocol,
|
||||
PF_COIP Connection-Oriented IP, aka ST II,
|
||||
PF_CNT Computer Network Technology,
|
||||
PF_SIP Simple Internet Protocol,
|
||||
PF_IPX Novell Internet Packet eXchange protocol,
|
||||
PF_RTIP Help Identify RTIP packets,
|
||||
PF_PIP Help Identify PIP packets,
|
||||
@ -125,9 +108,7 @@ socket may provide a sequenced, reliable,
|
||||
two-way connection-based data transmission path for datagrams
|
||||
of fixed maximum length; a consumer may be required to read
|
||||
an entire packet with each read system call.
|
||||
This facility is protocol specific, and presently implemented
|
||||
only for
|
||||
.Dv PF_NS .
|
||||
This facility is protocol specific, and presently unimplemented.
|
||||
.Dv SOCK_RAW
|
||||
sockets provide access to internal network protocols and interfaces.
|
||||
The types
|
||||
|
Loading…
x
Reference in New Issue
Block a user