Subject: some fallout from netns/netccitt removal
To: None <current-users@netbsd.org>
From: Kurt Schreiner <ks@ub.uni-mainz.de>
List: current-users
Date: 08/26/2006 11:49:19
--2oS5YaxWCcQjTEyO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
after /usr/include/{netns,netccitt} are no more, route(8) fails to compile
compaining about undefined functions/structures etc.
The attached patch remedies this.
Kurt
--2oS5YaxWCcQjTEyO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="route.diff"
Common subdirectories: ../old/CVS and ../new/CVS
diff -uN ../old/Makefile ../new/Makefile
--- ../old/Makefile 2006-08-26 11:22:26.000000000 +0200
+++ ../new/Makefile 2006-08-26 11:41:43.000000000 +0200
@@ -5,7 +5,7 @@
PROG= route
MAN= route.8
-SRCS= route.c show.c keywords.c ccitt_addr.c
+SRCS= route.c show.c keywords.c
.if (${USE_INET6} != "no")
CPPFLAGS+=-DINET6
diff -uN ../old/ccitt_addr.c ../new/ccitt_addr.c
--- ../old/ccitt_addr.c 2005-08-10 10:11:01.000000000 +0200
+++ ../new/ccitt_addr.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,177 +0,0 @@
-/* $NetBSD: ccitt_addr.c,v 1.15 2005/08/09 19:43:24 ginsbach Exp $ */
-
-/*
- * Copyright (c) 1990, 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. 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.
- *
- * @(#)ccitt_addr.c 8.2 (Berkeley) 4/28/95
- */
-
-/*
- * parse CCITT addresses
- *
- * Addresses must have the format: [hpr],x121address[,userdata][,protocol]
- * items enclosed with square brackets are optional
- * 'h' or 'p' means hi priority (packet size = 128; specific to Datapac
- * and necessary only for X.25(76) and non-negotiating X.25(80) DTE's)
- * 'r' means reverse charge (remote DTE pays for call).
- * The x121address consists of an optional netid and dot, followed
- * by a dte address.
- *
- * Frank Pronk
- * The University of British Columbia
- * Laboratory for Computational Vision
- * Copyright (c) 1984
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netccitt/x25.h>
-
-#include "extern.h"
-
-static char *copychar(char *, char *);
-
-int
-ccitt_addr(char *addr, struct sockaddr_x25 *xp)
-{
- char *p, *ap, *limit;
- int havenet = 0;
-
- memset(xp, 0, sizeof(*xp));
- xp->x25_family = AF_CCITT;
- xp->x25_len = sizeof(*xp);
- p = addr;
-
- /*
- * process optional priority and reverse charging flags
- */
-
- if (*p == 'p' || *p == 'r' || *p == 'h') {
- while (*p == 'p' || *p == 'r' || *p == 'h') {
- if (*p == 'p' || *p == 'h')
- xp->x25_opts.op_psize = X25_PS128;
- else if (*p == 'r')
- xp->x25_opts.op_flags |= X25_REVERSE_CHARGE;
- p++;
- }
- if (*p != ',')
- return (0);
- p++;
- }
- if (*p == '\0')
- return (0);
-
- /*
- * [network id:]X.121 address
- */
-
- ap = xp->x25_addr;
- limit = ap + sizeof(xp->x25_addr) - 1;
- while (*p) {
- if (*p == ',')
- break;
- if (*p == '.' || *p == ':') {
- if (havenet)
- return (0);
- havenet++;
- xp->x25_net = atoi(xp->x25_addr);
- p++;
- ap = xp->x25_addr;
- *ap = '\0';
- }
- if (*p < '0' || *p > '9')
- return (0);
- if (ap >= limit)
- return (0);
- *ap++ = *p++;
- }
- if (*p == '\0')
- return (1);
-
- /*
- * optional user data, bytes 4 to 16
- */
-
- p++;
- ap = xp->x25_udata + 4; /* first four bytes are protocol id */
- limit = ap + sizeof(xp->x25_udata) - 4;
- xp->x25_udlen = 4;
- while (*p) {
- if (*p == ',')
- break;
- if (ap >= limit)
- return (0);
- p = copychar (p, ap++);
- xp->x25_udlen++;
- }
- if (xp->x25_udlen == 4)
- xp->x25_udlen = 0;
- if (*p == '\0')
- return (1);
-
- p++;
- ap = xp->x25_udata; /* protocol id */
- limit = ap + (xp->x25_udlen ? 4 : sizeof(xp->x25_udata));
- while (*p) {
- if (*p == ',')
- return (0);
- if (ap >= limit)
- return (0);
- p = copychar (p, ap++);
- }
- if (xp->x25_udlen == 0)
- xp->x25_udlen = ap - xp->x25_udata;
- return (1);
-}
-
-static char *
-copychar(char *from, char *to)
-{
- int n;
-
- if (*from != '\\' || from[1] < '0' || from[1] > '7') {
- *to = *from++;
- return (from);
- }
- n = *++from - '0';
- from++;
- if (*from >= '0' && *from <= '7') {
- int n1;
-
- n = n*8 + *from++ - '0';
- if (*from >= '0' && *from <= '7' &&
- (n1 = n*8 + *from-'0') < 256) {
- n = n1;
- from++;
- }
- }
- *to = n;
- return (from);
-}
diff -uN ../old/extern.h ../new/extern.h
--- ../old/extern.h 2006-08-26 11:39:47.000000000 +0200
+++ ../new/extern.h 2006-08-26 11:41:43.000000000 +0200
@@ -30,15 +30,10 @@
*/
struct sockaddr;
-struct sockaddr_x25;
-struct sockaddr_ns;
/* show.c */
void show(int, char **);
-/* ccitt_addr.c */
-int ccitt_addr(char *, struct sockaddr_x25 *);
-
/* route.c */
extern int nflag, Sflag;
#define NOTDEFSTRING "0.0.0.0/xxx.xxx.xxx.xxx\0"
@@ -47,5 +42,4 @@
char *netmask_string(struct sockaddr *, int, int);
const char *routename(struct sockaddr *, struct sockaddr *, int);
const char *netname(struct sockaddr *, struct sockaddr *);
-const char *ns_print(struct sockaddr_ns *);
void usage(const char *)__attribute__((__noreturn__));
diff -uN ../old/keywords.c ../new/keywords.c
--- ../old/keywords.c 2006-08-26 11:22:26.000000000 +0200
+++ ../new/keywords.c 2006-08-26 11:41:43.000000000 +0200
@@ -53,8 +53,6 @@
{"show", K_SHOW},
{"ssthresh", K_SSTHRESH},
{"static", K_STATIC},
- {"x25", K_X25},
- {"xns", K_XNS},
{"xresolve", K_XRESOLVE},
{"flushall", K_FLUSHALL},
{0, 0}
diff -uN ../old/keywords.h ../new/keywords.h
--- ../old/keywords.h 2006-08-26 11:22:26.000000000 +0200
+++ ../new/keywords.h 2006-08-26 11:41:43.000000000 +0200
@@ -53,8 +53,6 @@
#define K_SHOW 43
#define K_SSTHRESH 44
#define K_STATIC 45
-#define K_X25 46
-#define K_XNS 47
#define K_XRESOLVE 48
#define K_FLUSHALL 49
#define K_NOCLONED 50
diff -uN ../old/keywords.sh ../new/keywords.sh
--- ../old/keywords.sh 2006-08-26 11:22:27.000000000 +0200
+++ ../new/keywords.sh 2006-08-26 11:41:43.000000000 +0200
@@ -53,8 +53,6 @@
show
ssthresh
static
-x25
-xns
xresolve
flushall
_EOF_
diff -uN ../old/route.c ../new/route.c
--- ../old/route.c 2006-08-26 11:22:33.000000000 +0200
+++ ../new/route.c 2006-08-26 11:41:43.000000000 +0200
@@ -56,9 +56,7 @@
#include <net80211/ieee80211_netbsd.h>
#include <netinet/in.h>
#include <netatalk/at.h>
-#include <netns/ns.h>
#include <netiso/iso.h>
-#include <netccitt/x25.h>
#include <arpa/inet.h>
#include <netdb.h>
@@ -89,7 +87,6 @@
static int flushroutes(int, char *[], int);
static int prefixlen(const char *);
#ifndef SMALL
-static int x25_makemask(void);
static void interfaces(void);
static void monitor(void);
static int print_getmsg(struct rt_msghdr *, int);
@@ -113,9 +110,7 @@
struct sockaddr_at sat;
struct sockaddr_dl sdl;
#ifndef SMALL
- struct sockaddr_ns sns;
struct sockaddr_iso siso;
- struct sockaddr_x25 sx25;
#endif /* SMALL */
} so_dst, so_gate, so_mask, so_genmask, so_ifa, so_ifp;
@@ -271,9 +266,6 @@
case K_ATALK:
af = AF_APPLETALK;
break;
- case K_XNS:
- af = AF_NS;
- break;
#endif /* SMALL */
case K_LINK:
af = AF_LINK;
@@ -283,8 +275,6 @@
case K_OSI:
af = AF_ISO;
break;
- case K_X25:
- af = AF_CCITT;
#endif /* SMALL */
default:
goto bad;
@@ -600,9 +590,6 @@
#endif
#ifndef SMALL
- case AF_NS:
- return (ns_print((struct sockaddr_ns *)sa));
-
case AF_ISO:
(void)snprintf(line, sizeof line, "iso %s",
iso_ntoa(&((struct sockaddr_iso *)sa)->siso_addr));
@@ -759,9 +746,6 @@
#endif
#ifndef SMALL
- case AF_NS:
- return (ns_print((struct sockaddr_ns *)sa));
-
case AF_ISO:
(void)snprintf(line, sizeof line, "iso %s",
iso_ntoa(&((struct sockaddr_iso *)sa)->siso_addr));
@@ -875,15 +859,6 @@
aflen = sizeof(struct sockaddr_iso);
break;
- case K_X25:
- af = AF_CCITT;
- aflen = sizeof(struct sockaddr_x25);
- break;
-
- case K_XNS:
- af = AF_NS;
- aflen = sizeof(struct sockaddr_ns);
- break;
#endif /* SMALL */
case K_IFACE:
@@ -1269,18 +1244,6 @@
#endif
#ifndef SMALL
- case AF_NS:
- if (which == RTA_DST) {
- struct sockaddr_ns *sms = &(so_mask.sns);
- memset(sms, 0, sizeof(*sms));
- sms->sns_family = 0;
- sms->sns_len = 6;
- sms->sns_addr.x_net = *(union ns_net *)ns_bh;
- rtm_addrs |= RTA_NETMASK;
- }
- su->sns.sns_addr = ns_addr(s);
- return (!ns_nullhost(su->sns.sns_addr));
-
case AF_OSI:
su->siso.siso_addr = *iso_addr(s);
if (which == RTA_NETMASK || which == RTA_GENMASK) {
@@ -1291,9 +1254,6 @@
}
return (1);
- case AF_CCITT:
- ccitt_addr(s, &su->sx25);
- return (which == RTA_DST ? x25_makemask() : 1);
#endif /* SMALL */
case PF_ROUTE:
@@ -1427,66 +1387,6 @@
}
#ifndef SMALL
-int
-x25_makemask(void)
-{
- char *cp;
-
- if ((rtm_addrs & RTA_NETMASK) == 0) {
- rtm_addrs |= RTA_NETMASK;
- for (cp = (char *)&so_mask.sx25.x25_net;
- cp < &so_mask.sx25.x25_opts.op_flags; cp++)
- *cp = -1;
- so_mask.sx25.x25_len = (u_char)&(((sup)0)->sx25.x25_opts);
- }
- return 0;
-}
-
-
-const char *
-ns_print(struct sockaddr_ns *sns)
-{
- struct ns_addr work;
- union { union ns_net net_e; u_int32_t int32_t_e; } net;
- u_short port;
- static char mybuf[50], cport[10], chost[25];
- const char *host = "";
- char *p;
- u_char *q;
-
- work = sns->sns_addr;
- port = ntohs(work.x_port);
- work.x_port = 0;
- net.net_e = work.x_net;
- if (ns_nullhost(work) && net.int32_t_e == 0) {
- if (!port)
- return ("*.*");
- (void)snprintf(mybuf, sizeof mybuf, "*.%XH", port);
- return (mybuf);
- }
-
- if (memcmp(ns_bh, work.x_host.c_host, 6) == 0)
- host = "any";
- else if (memcmp(ns_nullh, work.x_host.c_host, 6) == 0)
- host = "*";
- else {
- q = work.x_host.c_host;
- (void)snprintf(chost, sizeof chost, "%02X%02X%02X%02X%02X%02XH",
- q[0], q[1], q[2], q[3], q[4], q[5]);
- for (p = chost; *p == '0' && p < chost + 12; p++)
- /* void */;
- host = p;
- }
- if (port)
- (void)snprintf(cport, sizeof cport, ".%XH", htons(port));
- else
- *cport = 0;
-
- (void)snprintf(mybuf, sizeof mybuf, "%XH.%s%s",
- (u_int32_t)ntohl(net.int32_t_e), host, cport);
- return (mybuf);
-}
-
static void
interfaces(void)
{
@@ -1648,8 +1548,6 @@
#endif
#ifndef SMALL
case AF_APPLETALK:
- case AF_NS:
- case AF_CCITT:
#endif /* SMALL */
case 0:
return;
@@ -2106,10 +2004,6 @@
(void)printf("%s: iso %s; ",
which, iso_ntoa(&su->siso.siso_addr));
break;
- case AF_NS:
- (void)printf("%s: xns %s; ",
- which, ns_ntoa(su->sns.sns_addr));
- break;
#endif /* SMALL */
default:
(void)printf("%s: (%d) %s; ",
diff -uN ../old/show.c ../new/show.c
--- ../old/show.c 2006-08-26 11:22:35.000000000 +0200
+++ ../new/show.c 2006-08-26 11:41:43.000000000 +0200
@@ -48,7 +48,9 @@
#include <net/if_types.h>
#include <net/route.h>
#include <netinet/in.h>
+#if 0
#include <netns/ns.h>
+#endif
#include <sys/sysctl.h>
@@ -128,9 +130,6 @@
case K_ATALK:
af = AF_APPLETALK;
break;
- case K_XNS:
- af = AF_NS;
- break;
#endif /* SMALL */
#if 0
/* XXX Links are never destinations */
@@ -143,8 +142,6 @@
case K_OSI:
af = AF_ISO;
break;
- case K_X25:
- af = AF_CCITT;
#endif /* SMALL */
default:
goto bad;
@@ -288,15 +285,9 @@
break;
#endif /* INET6 */
#ifndef SMALL
- case AF_NS:
- afname = "XNS";
- break;
case AF_ISO:
afname = "ISO";
break;
- case AF_CCITT:
- afname = "X.25";
- break;
#endif /* SMALL */
case AF_APPLETALK:
afname = "AppleTalk";
@@ -340,12 +331,6 @@
break;
#endif /* INET6 */
-#ifndef SMALL
- case AF_NS:
- cp = ns_print((struct sockaddr_ns *)sa);
- break;
-#endif /* SMALL */
-
default:
{
u_char *s = (u_char *)sa->sa_data, *slim;
--2oS5YaxWCcQjTEyO--