summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorderaadt <>2013-12-17 16:34:05 +0000
committerderaadt <>2013-12-17 16:34:05 +0000
commitd8a859e047747940bda25e0117035deac310f330 (patch)
treeb7f15e081e0d1355ca5dd56edb548a514ca7a562
parentc7fda965b6d5f900572cfc2fb6cca301173bd389 (diff)
downloadopenbsd-d8a859e047747940bda25e0117035deac310f330.tar.gz
openbsd-d8a859e047747940bda25e0117035deac310f330.tar.bz2
openbsd-d8a859e047747940bda25e0117035deac310f330.zip
inet_nsap_ntoa() and inet_nsap_addr() go away. Unused APIs from darker
days.
-rw-r--r--src/lib/libc/net/Makefile.inc10
-rw-r--r--src/lib/libc/net/nsap_addr.c94
2 files changed, 4 insertions, 100 deletions
diff --git a/src/lib/libc/net/Makefile.inc b/src/lib/libc/net/Makefile.inc
index 48279d2423..580df4444a 100644
--- a/src/lib/libc/net/Makefile.inc
+++ b/src/lib/libc/net/Makefile.inc
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile.inc,v 1.49 2012/01/17 02:33:20 deraadt Exp $ 1# $OpenBSD: Makefile.inc,v 1.50 2013/12/17 16:34:05 deraadt Exp $
2 2
3# net sources 3# net sources
4.PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/net ${LIBCSRCDIR}/net 4.PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/net ${LIBCSRCDIR}/net
@@ -12,11 +12,9 @@ SRCS+= base64.c freeaddrinfo.c gai_strerror.c getaddrinfo.c gethostnamadr.c \
12 herror.c if_indextoname.c if_nameindex.c if_nametoindex.c inet_addr.c \ 12 herror.c if_indextoname.c if_nameindex.c if_nametoindex.c inet_addr.c \
13 inet_lnaof.c inet_makeaddr.c inet_neta.c inet_netof.c inet_network.c \ 13 inet_lnaof.c inet_makeaddr.c inet_neta.c inet_netof.c inet_network.c \
14 inet_net_ntop.c inet_net_pton.c inet_ntoa.c inet_ntop.c inet_pton.c \ 14 inet_net_ntop.c inet_net_pton.c inet_ntoa.c inet_ntop.c inet_pton.c \
15 linkaddr.c nsap_addr.c \ 15 linkaddr.c rcmd.c ruserok.c rresvport.c recv.c res_comp.c res_data.c \
16 rcmd.c ruserok.c rresvport.c recv.c res_comp.c res_data.c res_debug.c \ 16 res_debug.c res_debug_syms.c res_init.c res_mkquery.c res_query.c \
17 res_debug_syms.c \ 17 res_random.c res_send.c send.c sethostent.c ethers.c rcmdsh.c
18 res_init.c res_mkquery.c res_query.c res_random.c res_send.c send.c \
19 sethostent.c ethers.c rcmdsh.c
20 18
21# IPv6 19# IPv6
22SRCS+= ip6opt.c rthdr.c vars6.c 20SRCS+= ip6opt.c rthdr.c vars6.c
diff --git a/src/lib/libc/net/nsap_addr.c b/src/lib/libc/net/nsap_addr.c
deleted file mode 100644
index 8cfe86f475..0000000000
--- a/src/lib/libc/net/nsap_addr.c
+++ /dev/null
@@ -1,94 +0,0 @@
1/* $OpenBSD: nsap_addr.c,v 1.7 2006/03/31 05:35:44 deraadt Exp $ */
2
3/*
4 * Copyright (c) 1996 by Internet Software Consortium.
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
11 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
12 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
13 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
16 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
17 * SOFTWARE.
18 */
19
20#include <sys/types.h>
21#include <sys/param.h>
22#include <sys/socket.h>
23#include <netinet/in.h>
24#include <arpa/nameser.h>
25#include <ctype.h>
26#include <resolv.h>
27
28static u_char
29xtob(int c)
30{
31 return (c - (((c >= '0') && (c <= '9')) ? '0' : '7'));
32}
33
34u_int
35inet_nsap_addr(const char *ascii, u_char *binary, int maxlen)
36{
37 u_char c, nib;
38 u_int len = 0;
39
40 while ((c = *ascii++) != '\0' && len < maxlen) {
41 if (c == '.' || c == '+' || c == '/')
42 continue;
43 if (!isascii(c))
44 return (0);
45 if (islower(c))
46 c = (u_char)toupper(c);
47 if (isxdigit(c)) {
48 nib = xtob(c);
49 if ((c = *ascii++)) {
50 c = (u_char)toupper(c);
51 if (isxdigit(c)) {
52 *binary++ = (nib << 4) | xtob(c);
53 len++;
54 } else
55 return (0);
56 }
57 else
58 return (0);
59 }
60 else
61 return (0);
62 }
63 return (len);
64}
65
66char *
67inet_nsap_ntoa(int binlen, const u_char *binary, char *ascii)
68{
69 int nib;
70 int i;
71 static char tmpbuf[255*3];
72 char *start;
73
74 if (ascii)
75 start = ascii;
76 else {
77 ascii = tmpbuf;
78 start = tmpbuf;
79 }
80
81 if (binlen > 255)
82 binlen = 255;
83
84 for (i = 0; i < binlen; i++) {
85 nib = *binary >> 4;
86 *ascii++ = nib + (nib < 10 ? '0' : '7');
87 nib = *binary++ & 0x0f;
88 *ascii++ = nib + (nib < 10 ? '0' : '7');
89 if (((i % 2) == 0 && (i + 1) < binlen))
90 *ascii++ = '.';
91 }
92 *ascii = '\0';
93 return (start);
94}