summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2015-09-10 08:55:03 +0000
committermpi <mpi@openbsd.org>2015-09-10 08:55:03 +0000
commitaf64ca04ddea5268314889383049c2fb82e3f450 (patch)
tree5839f388d54666bc2585912b97bc4dc468a115c3 /lib/libc
parentAnother trivial if_put addition. OK dlg@ (diff)
downloadwireguard-openbsd-af64ca04ddea5268314889383049c2fb82e3f450.tar.xz
wireguard-openbsd-af64ca04ddea5268314889383049c2fb82e3f450.zip
Remove link_addr(3). A function to encode the name of an interface in
a sockaddr_dl is a questionnable interface. But now it makes it harder to properly reference ifp becauses of this. Set sdl_index to the index of the corresponding interface when constructing a routing message. Ridding previous libc crank. ok guenther@, deraadt@, dlg@
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/Symbols.list1
-rw-r--r--lib/libc/net/Makefile.inc5
-rw-r--r--lib/libc/net/link_ntoa.3 (renamed from lib/libc/net/link_addr.3)59
-rw-r--r--lib/libc/net/linkaddr.c80
4 files changed, 8 insertions, 137 deletions
diff --git a/lib/libc/Symbols.list b/lib/libc/Symbols.list
index 3b215f91528..c1ffe5c2375 100644
--- a/lib/libc/Symbols.list
+++ b/lib/libc/Symbols.list
@@ -1139,7 +1139,6 @@ inet_ntop
inet_pton
iruserok
iruserok_sa
-link_addr
link_ntoa
ntohl
ntohs
diff --git a/lib/libc/net/Makefile.inc b/lib/libc/net/Makefile.inc
index b063c4a1fad..b4d99987c5d 100644
--- a/lib/libc/net/Makefile.inc
+++ b/lib/libc/net/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.56 2014/08/31 02:27:37 guenther Exp $
+# $OpenBSD: Makefile.inc,v 1.57 2015/09/10 08:55:03 mpi Exp $
# net sources
.PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/net ${LIBCSRCDIR}/net
@@ -32,7 +32,7 @@ MAN+= byteorder.3 ethers.3 gai_strerror.3 getaddrinfo.3 gethostbyname.3 \
getifaddrs.3 getnameinfo.3 getnetent.3 getpeereid.3 getprotoent.3 \
getrrsetbyname.3 getservent.3 htonl.3 if_indextoname.3 \
inet_addr.3 inet_lnaof.3 inet_net.3 inet_ntop.3 \
- inet6_opt_init.3 inet6_rth_space.3 link_addr.3 \
+ inet6_opt_init.3 inet6_rth_space.3 link_ntoa.3 \
rcmd.3 rcmdsh.3 resolver.3 sockatmark.3
MLINKS+=byteorder.3 htobe16.3 byteorder.3 htobe32.3 byteorder.3 htobe64.3 \
@@ -70,7 +70,6 @@ MLINKS+=inet_addr.3 inet_aton.3 inet_addr.3 inet_network.3 \
MLINKS+=inet_lnaof.3 inet_makeaddr.3 inet_lnaof.3 inet_netof.3
MLINKS+=inet_ntop.3 inet_pton.3
MLINKS+=inet_net.3 inet_net_ntop.3 inet_net.3 inet_net_pton.3
-MLINKS+=link_addr.3 link_ntoa.3
MLINKS+=rcmd.3 iruserok.3 rcmd.3 rresvport.3 rcmd.3 ruserok.3 \
rcmd.3 rresvport_af.3 rcmd.3 rcmd_af.3 rcmd.3 iruserok_sa.3
MLINKS+=resolver.3 dn_comp.3 resolver.3 dn_expand.3 resolver.3 res_init.3 \
diff --git a/lib/libc/net/link_addr.3 b/lib/libc/net/link_ntoa.3
index f234fe84cc8..67a412dbc81 100644
--- a/lib/libc/net/link_addr.3
+++ b/lib/libc/net/link_ntoa.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: link_addr.3,v 1.13 2013/06/05 03:39:23 tedu Exp $
+.\" $OpenBSD: link_ntoa.3,v 1.1 2015/09/10 08:55:03 mpi Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
@@ -30,29 +30,22 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: June 5 2013 $
-.Dt LINK_ADDR 3
+.Dd $Mdocdate: September 10 2015 $
+.Dt LINK_NTOA 3
.Os
.Sh NAME
-.Nm link_addr ,
.Nm link_ntoa
.Nd elementary address specification routines for link level access
.Sh SYNOPSIS
.In sys/types.h
.In sys/socket.h
.In net/if_dl.h
-.Ft void
-.Fn link_addr "const char *addr" "struct sockaddr_dl *sdl"
.Ft char *
.Fn link_ntoa "const struct sockaddr_dl *sdl"
.Sh DESCRIPTION
The
-.Fn link_addr
-function interprets character strings representing
-link-level addresses, returning binary information suitable
-for use in system calls.
.Fn link_ntoa
-takes
+function takes
a link-level
address and returns an
.Tn ASCII
@@ -61,59 +54,21 @@ including the link level address itself, and the interface name
or number, if present.
This facility is experimental and is
still subject to change.
-.Pp
-For
-.Fn link_addr ,
-the string
-.Fa addr
-may contain
-an optional network interface identifier of the form
-.Dq name unit-number ,
-suitable for the first argument to
-.Xr ifconfig 8 ,
-followed in all cases by a colon and
-an interface address in the form of
-groups of hexadecimal digits
-separated by periods.
-Each group represents a byte of address;
-address bytes are filled left to right from
-low order bytes through high order bytes.
-.Pp
-.\" A regular expression may make this format clearer:
-.\" .Bd -literal -offset indent
-.\" ([a-z]+[0-9]+:)?[0-9a-f]+(\e.[0-9a-f]+)*
-.\" .Ed
-.\" .Pp
-Thus
-.Li le0:8.0.9.13.d.30
-represents an Ethernet address
-to be transmitted on the first Lance Ethernet interface.
.Sh RETURN VALUES
.Fn link_ntoa
always returns a NUL-terminated string.
-.Fn link_addr
-has no return value.
-(See
-.Sx BUGS . )
.Sh SEE ALSO
.Xr ifconfig 8
.Sh HISTORY
The
-.Fn link_addr
-and
.Fn link_ntoa
-functions appeared in
+function appeared in
.Bx 4.3 Reno .
.Sh BUGS
The returned values for
.Fn link_ntoa
reside in a static memory area.
.Pp
-The function
-.Fn link_addr
-should diagnose improperly formed input, and there should be an unambiguous
-way to recognize this.
-.Pp
If the
.Fa sdl_len
field of the link socket address
@@ -121,7 +76,3 @@ field of the link socket address
is 0,
.Fn link_ntoa
will not insert a colon before the interface address bytes.
-If this translated address is given to
-.Fn link_addr
-without inserting an initial colon,
-the latter will not interpret it correctly.
diff --git a/lib/libc/net/linkaddr.c b/lib/libc/net/linkaddr.c
index ac96f3acdf3..8f90aca8f52 100644
--- a/lib/libc/net/linkaddr.c
+++ b/lib/libc/net/linkaddr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linkaddr.c,v 1.5 2005/08/06 20:30:03 espie Exp $ */
+/* $OpenBSD: linkaddr.c,v 1.6 2015/09/10 08:55:03 mpi Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -33,84 +33,6 @@
#include <net/if_dl.h>
#include <string.h>
-/* States*/
-#define NAMING 0
-#define GOTONE 1
-#define GOTTWO 2
-#define RESET 3
-/* Inputs */
-#define DIGIT (4*0)
-#define END (4*1)
-#define DELIM (4*2)
-#define LETTER (4*3)
-
-void
-link_addr(const char *addr, struct sockaddr_dl *sdl)
-{
- char *cp = sdl->sdl_data;
- char *cplim = sdl->sdl_len + (char *)sdl;
- int byte = 0, state = NAMING, new;
-
- bzero((char *)&sdl->sdl_family, sdl->sdl_len - 1);
- sdl->sdl_family = AF_LINK;
- do {
- state &= ~LETTER;
- 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 if (state == NAMING &&
- (((*addr >= 'A') && (*addr <= 'Z')) ||
- ((*addr >= 'a') && (*addr <= 'z'))))
- state |= LETTER;
- else
- state |= DELIM;
- addr++;
- switch (state /* | INPUT */) {
- case NAMING | DIGIT:
- case NAMING | LETTER:
- *cp++ = addr[-1];
- continue;
- case NAMING | DELIM:
- state = RESET;
- sdl->sdl_nlen = cp - sdl->sdl_data;
- continue;
- case GOTTWO | DIGIT:
- *cp++ = byte;
- /* FALLTHROUGH */
- case RESET | DIGIT:
- state = GOTONE;
- byte = new;
- continue;
- case GOTONE | DIGIT:
- state = GOTTWO;
- byte = new + (byte << 4);
- continue;
- default: /* | DELIM */
- state = RESET;
- *cp++ = byte;
- byte = 0;
- continue;
- case GOTONE | END:
- case GOTTWO | END:
- *cp++ = byte;
- /* FALLTHROUGH */
- case RESET | END:
- break;
- }
- break;
- } while (cp < cplim);
- sdl->sdl_alen = cp - LLADDR(sdl);
- new = cp - (char *)sdl;
- if (new > sizeof(*sdl))
- sdl->sdl_len = new;
- return;
-}
-
static char hexlist[] = "0123456789abcdef";
char *