From 7f31ff4f937cb0e17224ee7d8e11dd7d2a690462 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Tue, 30 Jun 2009 07:35:13 +0000 Subject: Simplify Makefile. No change of the resultant package. --- net/openbgpd/Makefile | 51 +- net/openbgpd/files/patch-Makefile | 12 + net/openbgpd/files/patch-Makefile.inc | 12 + net/openbgpd/files/patch-bgpctl_Makefile | 27 +- net/openbgpd/files/patch-bgpctl_bgpctl.8 | 12 +- net/openbgpd/files/patch-bgpctl_bgpctl.c | 56 +- net/openbgpd/files/patch-bgpctl_irr_parser.c | 16 + net/openbgpd/files/patch-bgpctl_irrfilter.c | 18 + net/openbgpd/files/patch-bgpctl_irrfilter.h | 19 + net/openbgpd/files/patch-bgpctl_parser.c | 19 + net/openbgpd/files/patch-bgpd_Makefile | 32 ++ net/openbgpd/files/patch-bgpd_bgpd.8 | 16 +- net/openbgpd/files/patch-bgpd_bgpd.conf.5 | 16 +- net/openbgpd/files/patch-bgpd_bgpd.h | 56 +- net/openbgpd/files/patch-bgpd_carp.c | 80 ++- net/openbgpd/files/patch-bgpd_kroute.c | 34 +- net/openbgpd/files/patch-bgpd_parse.y | 16 +- net/openbgpd/files/patch-bgpd_printconf.c | 27 +- net/openbgpd/files/patch-bgpd_rde_attr.c | 32 +- net/openbgpd/files/patch-bgpd_rde_filter.c | 14 + net/openbgpd/files/patch-bgpd_rde_prefix.c | 17 + net/openbgpd/files/patch-bgpd_rde_rib.c | 25 +- net/openbgpd/files/patch-bgpd_rde_update.c | 27 +- net/openbgpd/files/patch-bgpd_session.c | 10 +- net/openbgpd/files/patch-bgpd_util.c | 14 +- .../files/patch-openbsd-compat_fmt_scaled.c | 275 +++++++++ net/openbgpd/files/patch-openbsd-compat_hash.h | 134 +++++ net/openbgpd/files/patch-openbsd-compat_if_media.h | 619 +++++++++++++++++++++ .../files/patch-openbsd-compat_openbsd-compat.h | 30 + .../files/patch-openbsd-compat_pfkey_compat.c | 34 ++ net/openbgpd/files/patch-openbsd-compat_util.h | 126 +++++ 31 files changed, 1635 insertions(+), 241 deletions(-) create mode 100644 net/openbgpd/files/patch-Makefile create mode 100644 net/openbgpd/files/patch-Makefile.inc create mode 100644 net/openbgpd/files/patch-bgpctl_irr_parser.c create mode 100644 net/openbgpd/files/patch-bgpctl_irrfilter.c create mode 100644 net/openbgpd/files/patch-bgpctl_irrfilter.h create mode 100644 net/openbgpd/files/patch-bgpctl_parser.c create mode 100644 net/openbgpd/files/patch-bgpd_Makefile create mode 100644 net/openbgpd/files/patch-bgpd_rde_filter.c create mode 100644 net/openbgpd/files/patch-bgpd_rde_prefix.c create mode 100644 net/openbgpd/files/patch-openbsd-compat_fmt_scaled.c create mode 100644 net/openbgpd/files/patch-openbsd-compat_hash.h create mode 100644 net/openbgpd/files/patch-openbsd-compat_if_media.h create mode 100644 net/openbgpd/files/patch-openbsd-compat_openbsd-compat.h create mode 100644 net/openbgpd/files/patch-openbsd-compat_pfkey_compat.c create mode 100644 net/openbgpd/files/patch-openbsd-compat_util.h (limited to 'net/openbgpd') diff --git a/net/openbgpd/Makefile b/net/openbgpd/Makefile index c616c37fc2f9..97e851813290 100644 --- a/net/openbgpd/Makefile +++ b/net/openbgpd/Makefile @@ -8,13 +8,10 @@ PORTNAME= openbgpd PORTVERSION= 4.4.1 CATEGORIES= net -MASTER_SITES= ftp://ftp.openbsd.org/pub/OpenBSD/OpenBGPD/:openbsd \ - ${MASTER_SITE_LOCAL:S/$/:freebsd/g} -MASTER_SITE_SUBDIR= flz/openbgpd/:freebsd -DISTFILES= ${PORTNAME}-${PORTVERSION}.tgz:openbsd,freebsd \ - if_media.h:freebsd hash.h:freebsd strtonum.c:freebsd +MASTER_SITES= ${MASTER_SITE_OPENBSD} +MASTER_SITE_SUBDIR= OpenBGPD +EXTRACT_SUFX= .tgz DIST_SUBDIR= openbgpd -EXTRACT_ONLY= ${PORTNAME}-${PORTVERSION}.tgz MAINTAINER= hrs@FreeBSD.org COMMENT= Free implementation of the Border Gateway Protocol, Version 4 @@ -24,25 +21,11 @@ CONFLICTS= zebra-[0-9]* quagga-[0-9]* WRKSRC= ${WRKDIR} MANCOMPRESSED= yes USE_RC_SUBR= openbgpd.sh -MAKE_ENV= BINDIR="${PREFIX}/sbin" \ - MANDIR="${PREFIX}/man/man" -COPTS+= -DRTA_LABEL=0 - -PLIST_FILES= sbin/bgpctl \ - sbin/bgpd - +PLIST_FILES= sbin/bgpctl sbin/bgpd SUB_FILES= pkg-message MAN5= bgpd.conf.5 -MAN8= bgpctl.8 \ - bgpd.8 - -SUBDIRS= bgpd \ - bgpctl - -post-extract: - @${CP} ${DISTDIR}/${DIST_SUBDIR}/if_media.h ${WRKSRC}/bgpctl/ - @${CP} ${DISTDIR}/${DIST_SUBDIR}/hash.h ${WRKSRC}/bgpd/ +MAN8= bgpctl.8 bgpd.8 post-patch: @${REINPLACE_CMD} -e "s|%%PREFIX%%|${PREFIX}|g" \ @@ -50,30 +33,6 @@ post-patch: ${WRKSRC}/bgpd/bgpd.h \ ${WRKSRC}/bgpd/bgpd.conf.5 \ ${WRKSRC}/bgpctl/bgpctl.8 - @${REINPLACE_CMD} -e "s|__dead||" \ - ${WRKSRC}/bgpd/bgpd.c \ - ${WRKSRC}/bgpd/bgpd.h \ - ${WRKSRC}/bgpctl/bgpctl.c \ - ${WRKSRC}/bgpctl/irrfilter.h \ - ${WRKSRC}/bgpctl/irrfilter.c - @${REINPLACE_CMD} -e "s||\"if_media.h\"|" ${WRKSRC}/bgpctl/bgpctl.c - @${REINPLACE_CMD} -e "s|pfkey.c|pfkey_compat.c|" ${WRKSRC}/bgpd/Makefile - @${REINPLACE_CMD} -e "s|sys/hash.h|hash.h|" \ - ${WRKSRC}/bgpd/rde_attr.c \ - ${WRKSRC}/bgpd/rde_rib.c \ - ${WRKSRC}/bgpd/rde_update.c - @${REINPLACE_CMD} -e "s|RTLABEL_LEN|PFTABLE_LEN|" ${WRKSRC}/bgpd/bgpd.h - @${REINPLACE_CMD} -e "s|ulong|unsigned\ long|" ${WRKSRC}/bgpctl/irr_parser.c - -do-build: -.for i in ${SUBDIRS} - cd ${WRKSRC}/$i && ${MAKE} COPTS="${COPTS}" -.endfor - -do-install: -.for i in ${SUBDIRS} - cd ${WRKSRC}/$i && ${MAKE} ${INSTALL_TARGET} ${MAKE_ENV} -.endfor post-install: @${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL diff --git a/net/openbgpd/files/patch-Makefile b/net/openbgpd/files/patch-Makefile new file mode 100644 index 000000000000..77ae22e026e6 --- /dev/null +++ b/net/openbgpd/files/patch-Makefile @@ -0,0 +1,12 @@ +Index: Makefile +=================================================================== +RCS file: Makefile +diff -N Makefile +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ Makefile 30 Jun 2009 07:07:55 -0000 1.2 +@@ -0,0 +1,5 @@ ++# $hrs: openbgpd/Makefile,v 1.2 2009/06/30 07:07:55 hrs Exp $ ++ ++SUBDIR= bgpd bgpctl ++ ++.include diff --git a/net/openbgpd/files/patch-Makefile.inc b/net/openbgpd/files/patch-Makefile.inc new file mode 100644 index 000000000000..36527106cc89 --- /dev/null +++ b/net/openbgpd/files/patch-Makefile.inc @@ -0,0 +1,12 @@ +Index: Makefile.inc +=================================================================== +RCS file: Makefile.inc +diff -N Makefile.inc +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ Makefile.inc 30 Jun 2009 07:19:13 -0000 1.2 +@@ -0,0 +1,5 @@ ++# $hrs: openbgpd/Makefile.inc,v 1.2 2009/06/30 07:19:13 hrs Exp $ ++ ++PREFIX?= /usr/local ++BINDIR?= ${PREFIX}/sbin ++MANDIR?= ${PREFIX}/man/man diff --git a/net/openbgpd/files/patch-bgpctl_Makefile b/net/openbgpd/files/patch-bgpctl_Makefile index d3c1aca3f17e..f39d97bcf14e 100644 --- a/net/openbgpd/files/patch-bgpctl_Makefile +++ b/net/openbgpd/files/patch-bgpctl_Makefile @@ -1,10 +1,29 @@ ---- bgpctl/Makefile 2007-03-03 12:45:30.000000000 +0100 -+++ bgpctl/Makefile 2008-03-18 13:27:29.000000000 +0100 -@@ -6,6 +6,7 @@ - SRCS= bgpctl.c parser.c buffer.c imsg.c util.c +Index: bgpctl/Makefile +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpctl/Makefile,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpctl/Makefile 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpctl/Makefile 30 Jun 2009 06:40:05 -0000 1.2 +@@ -1,17 +1,18 @@ + # $OpenBSD: Makefile,v 1.10 2007/12/20 17:08:48 henning Exp $ + +-.PATH: ${.CURDIR}/../bgpd ++.PATH: ${.CURDIR}/../bgpd ${.CURDIR}/../openbsd-compat + + PROG= bgpctl + SRCS= bgpctl.c parser.c buffer.c imsg.c util.c timer.c SRCS+= irrfilter.c whois.c irr_asset.c irr_prefix.c irr_output.c SRCS+= irr_parser.c +SRCS+= fmt_scaled.c CFLAGS+= -Wall CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes CFLAGS+= -Wmissing-declarations + CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual + CFLAGS+= -Wsign-compare +-CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../bgpd ++CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../bgpd -I${.CURDIR}/../openbsd-compat + MAN= bgpctl.8 + LDADD= -lutil + DPADD+= ${LIBUTIL} diff --git a/net/openbgpd/files/patch-bgpctl_bgpctl.8 b/net/openbgpd/files/patch-bgpctl_bgpctl.8 index 1cdd3fec17fc..e90455ce1826 100644 --- a/net/openbgpd/files/patch-bgpctl_bgpctl.8 +++ b/net/openbgpd/files/patch-bgpctl_bgpctl.8 @@ -1,6 +1,12 @@ ---- bgpctl/bgpctl.8 2007-05-31 21:20:22.000000000 +0200 -+++ bgpctl/bgpctl.8 2008-03-18 14:51:41.000000000 +0100 -@@ -240,7 +240,7 @@ +Index: bgpctl/bgpctl.8 +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpctl/bgpctl.8,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpctl/bgpctl.8 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpctl/bgpctl.8 30 Jun 2009 06:40:05 -0000 1.2 +@@ -244,7 +244,7 @@ in a terse format. .El .Sh FILES .Bl -tag -width "/var/run/bgpd.sockXXX" -compact diff --git a/net/openbgpd/files/patch-bgpctl_bgpctl.c b/net/openbgpd/files/patch-bgpctl_bgpctl.c index 5cdfa29bea4c..4d48e132522b 100644 --- a/net/openbgpd/files/patch-bgpctl_bgpctl.c +++ b/net/openbgpd/files/patch-bgpctl_bgpctl.c @@ -1,45 +1,55 @@ ---- bgpctl/bgpctl.c.orig 2009-01-16 23:03:29.000000000 +0900 -+++ bgpctl/bgpctl.c 2009-06-24 01:26:24.000000000 +0900 -@@ -20,7 +20,6 @@ +Index: bgpctl/bgpctl.c +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpctl/bgpctl.c,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpctl/bgpctl.c 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpctl/bgpctl.c 30 Jun 2009 06:40:06 -0000 1.2 +@@ -16,11 +16,19 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#if defined(__FreeBSD__) /* compat */ ++#include "openbsd-compat.h" ++#endif /* defined(__FreeBSD__) */ ++ + #include #include #include #include --#include ++#if defined(__FreeBSD__) /* net/if_media.h */ ++#include "if_media.h" ++#else + #include ++#endif /* defined(__FreeBSD__) */ #include #include -@@ -29,14 +28,20 @@ +@@ -29,7 +37,11 @@ #include #include #include --#include ++#if defined(__FreeBSD__) /* util.h */ ++#include "util.h" ++#else + #include ++#endif /* defined(__FreeBSD__) */ #include "bgpd.h" #include "session.h" - #include "rde.h" - #include "log.h" +@@ -38,6 +50,10 @@ #include "parser.h" -+#include "util.h" #include "irrfilter.h" -+#include "if_media.h" -+#include "compat-openbsd.h" -+ + +#if defined(__FreeBSD__) /* FreeBSD has no LINK_STATE_IS_UP macro. */ +#define LINK_STATE_IS_UP(_s) ((_s) >= LINK_STATE_UP) +#endif /* defined(__FreeBSD__) */ - ++ enum neighbor_views { NV_DEFAULT, -@@ -84,7 +89,7 @@ - - struct imsgbuf *ibuf; - --__dead void -+ void - usage(void) - { - extern char *__progname; -@@ -677,7 +682,7 @@ + NV_TIMERS +@@ -677,7 +693,7 @@ print_neighbor_msgstats(struct peer *p) } void diff --git a/net/openbgpd/files/patch-bgpctl_irr_parser.c b/net/openbgpd/files/patch-bgpctl_irr_parser.c new file mode 100644 index 000000000000..a24d580b0c13 --- /dev/null +++ b/net/openbgpd/files/patch-bgpctl_irr_parser.c @@ -0,0 +1,16 @@ +Index: bgpctl/irr_parser.c +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpctl/irr_parser.c,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpctl/irr_parser.c 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpctl/irr_parser.c 30 Jun 2009 06:40:06 -0000 1.2 +@@ -18,6 +18,7 @@ + + #include + #include ++ + #include + #include + #include diff --git a/net/openbgpd/files/patch-bgpctl_irrfilter.c b/net/openbgpd/files/patch-bgpctl_irrfilter.c new file mode 100644 index 000000000000..458351db3f29 --- /dev/null +++ b/net/openbgpd/files/patch-bgpctl_irrfilter.c @@ -0,0 +1,18 @@ +Index: bgpctl/irrfilter.c +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpctl/irrfilter.c,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpctl/irrfilter.c 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpctl/irrfilter.c 30 Jun 2009 06:40:06 -0000 1.2 +@@ -15,6 +15,9 @@ + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ ++#if defined(__FreeBSD__) /* compat */ ++#include "openbsd-compat.h" ++#endif /* defined(__FreeBSD__) */ + + #include + #include diff --git a/net/openbgpd/files/patch-bgpctl_irrfilter.h b/net/openbgpd/files/patch-bgpctl_irrfilter.h new file mode 100644 index 000000000000..bffc8bd24629 --- /dev/null +++ b/net/openbgpd/files/patch-bgpctl_irrfilter.h @@ -0,0 +1,19 @@ +Index: bgpctl/irrfilter.h +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpctl/irrfilter.h,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpctl/irrfilter.h 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpctl/irrfilter.h 30 Jun 2009 06:40:06 -0000 1.2 +@@ -16,6 +16,10 @@ + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#if defined(__FreeBSD__) /* compat */ ++#include "openbsd-compat.h" ++#endif /* defined(__FreeBSD__) */ ++ + #include + #include + #include diff --git a/net/openbgpd/files/patch-bgpctl_parser.c b/net/openbgpd/files/patch-bgpctl_parser.c new file mode 100644 index 000000000000..da0571bd66ef --- /dev/null +++ b/net/openbgpd/files/patch-bgpctl_parser.c @@ -0,0 +1,19 @@ +Index: bgpctl/parser.c +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpctl/parser.c,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpctl/parser.c 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpctl/parser.c 30 Jun 2009 06:40:06 -0000 1.2 +@@ -16,6 +16,10 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#if defined(__FreeBSD__) /* compat */ ++#include "openbsd-compat.h" ++#endif /* defined(__FreeBSD__) */ ++ + #include + #include + diff --git a/net/openbgpd/files/patch-bgpd_Makefile b/net/openbgpd/files/patch-bgpd_Makefile new file mode 100644 index 000000000000..74a6df5c809c --- /dev/null +++ b/net/openbgpd/files/patch-bgpd_Makefile @@ -0,0 +1,32 @@ +Index: bgpd/Makefile +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpd/Makefile,v +retrieving revision 1.1.1.1 +retrieving revision 1.3 +diff -u -p -r1.1.1.1 -r1.3 +--- bgpd/Makefile 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpd/Makefile 30 Jun 2009 06:56:51 -0000 1.3 +@@ -1,17 +1,20 @@ + # $OpenBSD: Makefile,v 1.27 2007/12/20 17:08:47 henning Exp $ + +-.PATH: ${.CURDIR}/.. ++.PATH: ${.CURDIR}/.. ${.CURDIR}/../openbsd-compat ++ ++CONFFILE?= /etc/bgpd.h + + PROG= bgpd + SRCS= bgpd.c buffer.c session.c log.c parse.y config.c imsg.c \ + rde.c rde_rib.c rde_decide.c rde_prefix.c mrt.c kroute.c \ +- control.c pfkey.c rde_update.c rde_attr.c printconf.c \ ++ control.c pfkey_compat.c rde_update.c rde_attr.c printconf.c \ + rde_filter.c pftable.c name2id.c util.c carp.c timer.c +-CFLAGS+= -Wall -I${.CURDIR} ++CFLAGS+= -Wall -I${.CURDIR} -I${.CURDIR}/../openbsd-compat + CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes + CFLAGS+= -Wmissing-declarations + CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual + CFLAGS+= -Wsign-compare ++CFLAGS+= -DCONFFILE=\"${CONFFILE}\" + YFLAGS= + MAN= bgpd.8 bgpd.conf.5 + diff --git a/net/openbgpd/files/patch-bgpd_bgpd.8 b/net/openbgpd/files/patch-bgpd_bgpd.8 index a13141fb74d2..ab2a2be61929 100644 --- a/net/openbgpd/files/patch-bgpd_bgpd.8 +++ b/net/openbgpd/files/patch-bgpd_bgpd.8 @@ -1,6 +1,12 @@ ---- bgpd/bgpd.8 2007-05-31 21:20:22.000000000 +0200 -+++ bgpd/bgpd.8 2008-03-18 14:54:19.000000000 +0100 -@@ -48,9 +48,9 @@ +Index: bgpd/bgpd.8 +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpd/bgpd.8,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpd/bgpd.8 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpd/bgpd.8 30 Jun 2009 06:40:07 -0000 1.2 +@@ -48,9 +48,9 @@ Please refer to that document for more i .Nm is usually started at boot time, and can be enabled by setting the following in @@ -12,7 +18,7 @@ .Pp See .Xr rc 8 -@@ -117,7 +117,7 @@ +@@ -117,7 +117,7 @@ Use .Ar file as the configuration file, instead of the default @@ -21,7 +27,7 @@ .It Fl n Configtest mode. Only check the configuration file for validity. -@@ -135,7 +135,7 @@ +@@ -135,7 +135,7 @@ Produce more verbose output. .El .Sh FILES .Bl -tag -width "/var/run/bgpd.sockXXX" -compact diff --git a/net/openbgpd/files/patch-bgpd_bgpd.conf.5 b/net/openbgpd/files/patch-bgpd_bgpd.conf.5 index 40b519c40bc6..160ef81ec5d1 100644 --- a/net/openbgpd/files/patch-bgpd_bgpd.conf.5 +++ b/net/openbgpd/files/patch-bgpd_bgpd.conf.5 @@ -1,6 +1,12 @@ ---- bgpd/bgpd.conf.5 2007-05-31 21:20:22.000000000 +0200 -+++ bgpd/bgpd.conf.5 2008-03-18 14:55:31.000000000 +0100 -@@ -611,11 +611,11 @@ +Index: bgpd/bgpd.conf.5 +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpd/bgpd.conf.5,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpd/bgpd.conf.5 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpd/bgpd.conf.5 30 Jun 2009 06:40:07 -0000 1.2 +@@ -611,11 +611,11 @@ is responsible for managing the session With .Xr isakmpd 8 , it is sufficient to copy the peer's public key, found in @@ -14,8 +20,8 @@ The local public key must be copied to the peer in the same way. As .Xr bgpd 8 -@@ -1133,8 +1133,8 @@ - is a local non-transitive attribute and a bgpd-specific extension. +@@ -1137,8 +1137,8 @@ For prefixes with equally long paths, th + is selected. .El .Sh FILES -.Bl -tag -width "/etc/bgpd.conf" -compact diff --git a/net/openbgpd/files/patch-bgpd_bgpd.h b/net/openbgpd/files/patch-bgpd_bgpd.h index 64824eb9fee1..992274118267 100644 --- a/net/openbgpd/files/patch-bgpd_bgpd.h +++ b/net/openbgpd/files/patch-bgpd_bgpd.h @@ -1,50 +1,24 @@ ---- bgpd/bgpd.h.orig Thu Jul 19 12:52:38 2007 -+++ bgpd/bgpd.h Thu Jul 19 12:52:28 2007 -@@ -30,9 +30,11 @@ +Index: bgpd/bgpd.h +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpd/bgpd.h,v +retrieving revision 1.1.1.1 +retrieving revision 1.3 +diff -u -p -r1.1.1.1 -r1.3 +--- bgpd/bgpd.h 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpd/bgpd.h 30 Jun 2009 06:56:51 -0000 1.3 +@@ -30,9 +30,15 @@ #include #include -+#define RTA_LABEL 0 ++#if defined(__FreeBSD__) /* compat */ ++#include "openbsd-compat.h" ++#endif /* defined(__FreeBSD__) */ + #define BGP_VERSION 4 #define BGP_PORT 179 --#define CONFFILE "/etc/bgpd.conf" -+#define CONFFILE "%%PREFIX%%/etc/bgpd.conf" ++#ifndef CONFFILE + #define CONFFILE "/etc/bgpd.conf" ++#endif /* !CONFFILE */ #define BGPD_USER "_bgpd" #define PEER_DESCR_LEN 32 #define PFTABLE_LEN 16 -@@ -467,12 +469,12 @@ - - struct kroute_label { - struct kroute kr; -- char label[RTLABEL_LEN]; -+ char label[PFTABLE_LEN]; - }; - - struct kroute6_label { - struct kroute6 kr; -- char label[RTLABEL_LEN]; -+ char label[PFTABLE_LEN]; - }; - - #define F_RIB_ELIGIBLE 0x01 -@@ -644,7 +646,7 @@ - struct bgpd_addr nexthop; - struct filter_community community; - char pftable[PFTABLE_LEN]; -- char rtlabel[RTLABEL_LEN]; -+ char rtlabel[PFTABLE_LEN]; - } action; - enum action_types type; - }; -@@ -709,8 +711,8 @@ - void log_warnx(const char *, ...); - void log_info(const char *, ...); - void log_debug(const char *, ...); --void fatal(const char *) __dead; --void fatalx(const char *) __dead; -+void fatal(const char *) ; -+void fatalx(const char *) ; - - /* parse.y */ - int cmdline_symset(char *); diff --git a/net/openbgpd/files/patch-bgpd_carp.c b/net/openbgpd/files/patch-bgpd_carp.c index fee9e485761e..0edf5e072162 100644 --- a/net/openbgpd/files/patch-bgpd_carp.c +++ b/net/openbgpd/files/patch-bgpd_carp.c @@ -1,58 +1,42 @@ ---- bgpd/carp.c 2007-04-23 16:52:28.000000000 +0200 -+++ bgpd/carp.c 2008-03-18 13:27:29.000000000 +0100 -@@ -102,28 +102,7 @@ +Index: bgpd/carp.c +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpd/carp.c,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpd/carp.c 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpd/carp.c 30 Jun 2009 06:40:07 -0000 1.2 +@@ -102,6 +102,9 @@ carp_demote_shutdown(void) int carp_demote_get(char *group) { -- int s; -- struct ifgroupreq ifgr; -- -- if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { -- log_warn("carp_demote_get: socket"); -- return (-1); -- } -- -- bzero(&ifgr, sizeof(ifgr)); -- strlcpy(ifgr.ifgr_name, group, sizeof(ifgr.ifgr_name)); -- -- if (ioctl(s, SIOCGIFGATTR, (caddr_t)&ifgr) == -1) { -- if (errno == ENOENT) -- log_warnx("group \"%s\" does not exist", group); -- else -- log_warn("carp_demote_get: ioctl"); -- close(s); - return (-1); -- } -- -- close(s); -- return ((int)ifgr.ifgr_attrib.ifg_carp_demoted); ++#if defined(__FreeBSD__) /* FreeBSD does not have support for CARP */ ++ return (-1); ++#else + int s; + struct ifgroupreq ifgr; + +@@ -124,6 +127,7 @@ carp_demote_get(char *group) + + close(s); + return ((int)ifgr.ifgr_attrib.ifg_carp_demoted); ++#endif /* defined(__FreeBSD__) */ } int -@@ -156,26 +135,5 @@ +@@ -156,6 +160,9 @@ carp_demote_set(char *group, int demote) int carp_demote_ioctl(char *group, int demote) { -- int s, res; -- struct ifgroupreq ifgr; -- -- if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { -- log_warn("carp_demote_get: socket"); - return (-1); -- } -- -- bzero(&ifgr, sizeof(ifgr)); -- strlcpy(ifgr.ifgr_name, group, sizeof(ifgr.ifgr_name)); -- ifgr.ifgr_attrib.ifg_carp_demoted = demote; -- -- if ((res = ioctl(s, SIOCSIFGATTR, (caddr_t)&ifgr)) == -1) -- log_warn("unable to %s the demote state " -- "of group '%s'", (demote > 0) ? "increment" : "decrement", -- group); -- else -- log_info("%s the demote state of group '%s'", -- (demote > 0) ? "incremented" : "decremented", group); -- -- close(s); -- return (res); ++#if defined(__FreeBSD__) /* FreeBSD does not have support for CARP */ ++ return (-1); ++#else + int s, res; + struct ifgroupreq ifgr; + +@@ -178,4 +185,5 @@ carp_demote_ioctl(char *group, int demot + + close(s); + return (res); ++#endif /* defined(__FreeBSD__) */ } diff --git a/net/openbgpd/files/patch-bgpd_kroute.c b/net/openbgpd/files/patch-bgpd_kroute.c index c4eb9b6e56fb..11431fb1545e 100644 --- a/net/openbgpd/files/patch-bgpd_kroute.c +++ b/net/openbgpd/files/patch-bgpd_kroute.c @@ -1,6 +1,12 @@ ---- bgpd/kroute.c.orig 2009-01-16 23:03:20.000000000 +0900 -+++ bgpd/kroute.c 2009-06-22 14:53:15.000000000 +0900 -@@ -1747,7 +1747,9 @@ +Index: bgpd/kroute.c +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpd/kroute.c,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpd/kroute.c 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpd/kroute.c 30 Jun 2009 06:40:07 -0000 1.2 +@@ -1747,7 +1747,9 @@ send_rtmsg(int fd, int action, struct kr struct sockaddr_in prefix; struct sockaddr_in nexthop; struct sockaddr_in mask; @@ -10,7 +16,7 @@ int iovcnt = 0; if (kr_state.fib_sync == 0) -@@ -1757,9 +1759,13 @@ +@@ -1757,9 +1759,13 @@ send_rtmsg(int fd, int action, struct kr bzero(&hdr, sizeof(hdr)); hdr.rtm_version = RTM_VERSION; hdr.rtm_type = action; @@ -24,7 +30,7 @@ if (kroute->flags & F_BLACKHOLE) hdr.rtm_flags |= RTF_BLACKHOLE; if (kroute->flags & F_REJECT) -@@ -1809,6 +1815,7 @@ +@@ -1809,6 +1815,7 @@ send_rtmsg(int fd, int action, struct kr iov[iovcnt++].iov_len = sizeof(mask); if (kroute->labelid) { @@ -32,7 +38,7 @@ bzero(&label, sizeof(label)); label.sr_len = sizeof(label); strlcpy(label.sr_label, rtlabel_id2name(kroute->labelid), -@@ -1819,6 +1826,7 @@ +@@ -1819,6 +1826,7 @@ send_rtmsg(int fd, int action, struct kr /* adjust iovec */ iov[iovcnt].iov_base = &label; iov[iovcnt++].iov_len = sizeof(label); @@ -40,7 +46,7 @@ } retry: -@@ -1860,7 +1868,9 @@ +@@ -1860,7 +1868,9 @@ send_rt6msg(int fd, int action, struct k struct sockaddr_in6 prefix; struct sockaddr_in6 nexthop; struct sockaddr_in6 mask; @@ -50,7 +56,7 @@ int iovcnt = 0; if (kr_state.fib_sync == 0) -@@ -1870,7 +1880,9 @@ +@@ -1870,7 +1880,9 @@ send_rt6msg(int fd, int action, struct k bzero(&hdr, sizeof(hdr)); hdr.rtm_version = RTM_VERSION; hdr.rtm_type = action; @@ -60,7 +66,7 @@ hdr.rtm_flags = RTF_PROTO1; if (kroute->flags & F_BLACKHOLE) hdr.rtm_flags |= RTF_BLACKHOLE; -@@ -1924,6 +1936,7 @@ +@@ -1924,6 +1936,7 @@ send_rt6msg(int fd, int action, struct k iov[iovcnt++].iov_len = sizeof(mask); if (kroute->labelid) { @@ -68,7 +74,7 @@ bzero(&label, sizeof(label)); label.sr_len = sizeof(label); strlcpy(label.sr_label, rtlabel_id2name(kroute->labelid), -@@ -1934,6 +1947,7 @@ +@@ -1934,6 +1947,7 @@ send_rt6msg(int fd, int action, struct k /* adjust iovec */ iov[iovcnt].iov_base = &label; iov[iovcnt++].iov_len = sizeof(label); @@ -76,7 +82,7 @@ } retry: -@@ -1970,8 +1984,8 @@ +@@ -1970,8 +1984,8 @@ retry: int fetchtable(u_int rtableid, int connected_only) { @@ -87,7 +93,7 @@ char *buf, *next, *lim; struct rt_msghdr *rtm; struct sockaddr *sa, *gw, *rti_info[RTAX_MAX]; -@@ -1986,9 +2000,8 @@ +@@ -1986,9 +2000,8 @@ fetchtable(u_int rtableid, int connected mib[3] = 0; mib[4] = NET_RT_DUMP; mib[5] = 0; @@ -98,7 +104,7 @@ if (rtableid != 0 && errno == EINVAL) /* table nonexistent */ return (0); log_warn("sysctl"); -@@ -1998,7 +2011,7 @@ +@@ -1998,7 +2011,7 @@ fetchtable(u_int rtableid, int connected log_warn("fetchtable"); return (-1); } @@ -107,7 +113,7 @@ log_warn("sysctl"); free(buf); return (-1); -@@ -2252,12 +2265,14 @@ +@@ -2252,12 +2265,14 @@ dispatch_rtmsg(void) continue; connected_only = 0; diff --git a/net/openbgpd/files/patch-bgpd_parse.y b/net/openbgpd/files/patch-bgpd_parse.y index b44615764edc..84b2d3ba0c09 100644 --- a/net/openbgpd/files/patch-bgpd_parse.y +++ b/net/openbgpd/files/patch-bgpd_parse.y @@ -1,10 +1,16 @@ ---- bgpd/parse.y.orig 2009-01-16 23:03:20.000000000 +0900 -+++ bgpd/parse.y 2009-06-22 14:49:56.000000000 +0900 -@@ -523,11 +523,16 @@ +Index: bgpd/parse.y +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpd/parse.y,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpd/parse.y 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpd/parse.y 30 Jun 2009 06:40:07 -0000 1.2 +@@ -523,11 +523,16 @@ conf_main : AS as4number { free($4); } | RTABLE NUMBER { -+#ifdef __FreeBSD__ ++#if defined(__FreeBSD__) /* FreeBSD does not support RTABLE */ + yyerror("rtable id not supported in FreeBSD, yet"); + YYERROR; +#else @@ -13,7 +19,7 @@ YYERROR; } conf->rtableid = $2; -+#endif /* __FreeBSD__ */ ++#endif /* defined(__FreeBSD__) */ } ; diff --git a/net/openbgpd/files/patch-bgpd_printconf.c b/net/openbgpd/files/patch-bgpd_printconf.c index 13c49d806fbc..c511f3fd450b 100644 --- a/net/openbgpd/files/patch-bgpd_printconf.c +++ b/net/openbgpd/files/patch-bgpd_printconf.c @@ -1,11 +1,18 @@ ---- bgpd/printconf.c 2008-03-18 15:24:06.000000000 +0100 -+++ bgpd/printconf.c 2008-03-18 13:27:29.000000000 +0100 -@@ -24,6 +24,8 @@ - #include "mrt.h" - #include "session.h" - +Index: bgpd/printconf.c +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpd/printconf.c,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpd/printconf.c 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpd/printconf.c 30 Jun 2009 06:40:07 -0000 1.2 +@@ -19,6 +19,9 @@ + #include + #include + #include ++#if defined(__FreeBSD__) /* limits.h */ +#include -+ - void print_op(enum comp_ops); - void print_community(int, int); - void print_set(struct filter_set_head *); ++#endif + + #include "bgpd.h" + #include "mrt.h" diff --git a/net/openbgpd/files/patch-bgpd_rde_attr.c b/net/openbgpd/files/patch-bgpd_rde_attr.c index cc1b62d1a386..db5f385ca624 100644 --- a/net/openbgpd/files/patch-bgpd_rde_attr.c +++ b/net/openbgpd/files/patch-bgpd_rde_attr.c @@ -1,20 +1,30 @@ ---- bgpd/rde_attr.c 2007-05-22 16:03:31.000000000 +0200 -+++ bgpd/rde_attr.c 2008-03-18 15:30:31.000000000 +0100 -@@ -17,7 +17,6 @@ +Index: bgpd/rde_attr.c +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpd/rde_attr.c,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpd/rde_attr.c 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpd/rde_attr.c 30 Jun 2009 06:40:07 -0000 1.2 +@@ -17,7 +17,11 @@ */ #include --#include ++#if defined(__FreeBSD__) /* sys/hash.h */ ++#include "hash.h" ++#else + #include ++#endif /* defined(__FreeBSD__) */ #include #include -@@ -28,6 +27,9 @@ +@@ -25,6 +29,9 @@ + #include + #include + #include ++#if defined(__FreeBSD__) /* limits.h */ ++#include ++#endif /* defined(__FreeBSD__) */ #include "bgpd.h" #include "rde.h" -+#include "hash.h" -+ -+#include - - int - attr_write(void *p, u_int16_t p_len, u_int8_t flags, u_int8_t type, diff --git a/net/openbgpd/files/patch-bgpd_rde_filter.c b/net/openbgpd/files/patch-bgpd_rde_filter.c new file mode 100644 index 000000000000..a26ad64e42c9 --- /dev/null +++ b/net/openbgpd/files/patch-bgpd_rde_filter.c @@ -0,0 +1,14 @@ +Index: bgpd/rde_filter.c +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpd/rde_filter.c,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpd/rde_filter.c 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpd/rde_filter.c 30 Jun 2009 06:51:37 -0000 1.2 +@@ -614,4 +614,5 @@ filterset_name(enum action_types type) + } + + fatalx("filterset_name: got lost"); ++ return (NULL); /* NOT REACHED */ + } diff --git a/net/openbgpd/files/patch-bgpd_rde_prefix.c b/net/openbgpd/files/patch-bgpd_rde_prefix.c new file mode 100644 index 000000000000..ff797e126604 --- /dev/null +++ b/net/openbgpd/files/patch-bgpd_rde_prefix.c @@ -0,0 +1,17 @@ +Index: bgpd/rde_prefix.c +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpd/rde_prefix.c,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpd/rde_prefix.c 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpd/rde_prefix.c 30 Jun 2009 06:42:23 -0000 1.2 +@@ -365,7 +365,7 @@ pt_free(struct pt_entry *pte) + static struct pt_entry * + pt_restart(struct pt_context *ctx) + { +- struct pt_entry *tmp, *prev = NULL; ++ struct pt_entry *tmp = NULL, *prev = NULL; + int comp; + + /* first select correct tree */ diff --git a/net/openbgpd/files/patch-bgpd_rde_rib.c b/net/openbgpd/files/patch-bgpd_rde_rib.c index b5a329b7f017..86c48091c90d 100644 --- a/net/openbgpd/files/patch-bgpd_rde_rib.c +++ b/net/openbgpd/files/patch-bgpd_rde_rib.c @@ -1,17 +1,20 @@ ---- bgpd/rde_rib.c 2008-03-18 15:39:58.000000000 +0100 -+++ bgpd/rde_rib.c 2008-03-18 15:31:36.000000000 +0100 -@@ -18,13 +18,13 @@ +Index: bgpd/rde_rib.c +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpd/rde_rib.c,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpd/rde_rib.c 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpd/rde_rib.c 30 Jun 2009 06:40:07 -0000 1.2 +@@ -18,7 +18,11 @@ #include #include --#include ++#if defined(__FreeBSD__) /* sys/hash.h */ ++#include "hash.h" ++#else + #include ++#endif /* defined(__FreeBSD__) */ #include #include - - #include "bgpd.h" - #include "rde.h" -+#include "hash.h" - - /* - * BGP RIB -- Routing Information Base diff --git a/net/openbgpd/files/patch-bgpd_rde_update.c b/net/openbgpd/files/patch-bgpd_rde_update.c index 81d786c3e868..05514097c69f 100644 --- a/net/openbgpd/files/patch-bgpd_rde_update.c +++ b/net/openbgpd/files/patch-bgpd_rde_update.c @@ -1,19 +1,26 @@ ---- bgpd/rde_update.c 2008-03-18 15:40:50.000000000 +0100 -+++ bgpd/rde_update.c 2008-03-18 15:32:21.000000000 +0100 -@@ -17,13 +17,15 @@ +Index: bgpd/rde_update.c +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpd/rde_update.c,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpd/rde_update.c 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpd/rde_update.c 30 Jun 2009 06:40:07 -0000 1.2 +@@ -17,10 +17,17 @@ */ #include #include --#include ++#if defined(__FreeBSD__) /* sys/hash.h */ ++#include "hash.h" ++#else + #include ++#endif /* defined(__FreeBSD__) */ #include #include ++#if defined(__FreeBSD__) /* limits.h */ ++#include ++#endif /* defined(__FreeBSD__) */ #include "bgpd.h" #include "rde.h" -+#include "hash.h" -+ -+#include - - in_addr_t up_get_nexthop(struct rde_peer *, struct rde_aspath *); - int up_generate_mp_reach(struct rde_peer *, struct update_attr *, diff --git a/net/openbgpd/files/patch-bgpd_session.c b/net/openbgpd/files/patch-bgpd_session.c index 4bcaad94d8b7..2106b5550436 100644 --- a/net/openbgpd/files/patch-bgpd_session.c +++ b/net/openbgpd/files/patch-bgpd_session.c @@ -1,5 +1,11 @@ ---- bgpd/session.c 2008-03-18 15:24:06.000000000 +0100 -+++ bgpd/session.c 2008-03-18 13:27:29.000000000 +0100 +Index: bgpd/session.c +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpd/session.c,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpd/session.c 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpd/session.c 30 Jun 2009 06:40:07 -0000 1.2 @@ -52,6 +52,10 @@ #define PFD_SOCK_RCTL 4 #define PFD_LISTENERS_START 5 diff --git a/net/openbgpd/files/patch-bgpd_util.c b/net/openbgpd/files/patch-bgpd_util.c index cc25aeab5c70..defdb995ee60 100644 --- a/net/openbgpd/files/patch-bgpd_util.c +++ b/net/openbgpd/files/patch-bgpd_util.c @@ -1,10 +1,18 @@ ---- bgpd/util.c 2008-03-18 15:24:06.000000000 +0100 -+++ bgpd/util.c 2008-03-18 13:27:29.000000000 +0100 -@@ -18,6 +18,7 @@ +Index: bgpd/util.c +=================================================================== +RCS file: /home/cvs/private/hrs/openbgpd/bgpd/util.c,v +retrieving revision 1.1.1.1 +retrieving revision 1.2 +diff -u -p -r1.1.1.1 -r1.2 +--- bgpd/util.c 30 Jun 2009 05:46:15 -0000 1.1.1.1 ++++ bgpd/util.c 30 Jun 2009 06:40:07 -0000 1.2 +@@ -18,6 +18,9 @@ */ #include #include ++#if defined(__FreeBSD__) /* sys/limits.h */ +#include ++#endif /* defined(__FreeBSD__) */ #include #include #include diff --git a/net/openbgpd/files/patch-openbsd-compat_fmt_scaled.c b/net/openbgpd/files/patch-openbsd-compat_fmt_scaled.c new file mode 100644 index 000000000000..65407211cbc8 --- /dev/null +++ b/net/openbgpd/files/patch-openbsd-compat_fmt_scaled.c @@ -0,0 +1,275 @@ +Index: openbsd-compat/fmt_scaled.c +=================================================================== +RCS file: openbsd-compat/fmt_scaled.c +diff -N openbsd-compat/fmt_scaled.c +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ openbsd-compat/fmt_scaled.c 30 Jun 2009 06:40:07 -0000 1.1 +@@ -0,0 +1,268 @@ ++/* $OpenBSD: fmt_scaled.c,v 1.9 2007/03/20 03:42:52 tedu Exp $ */ ++ ++/* ++ * Copyright (c) 2001, 2002, 2003 Ian F. Darwin. 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. The name of the author may not be used to endorse or promote products ++ * derived from this software without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. ++ */ ++ ++/* ++ * fmt_scaled: Format numbers scaled for human comprehension ++ * scan_scaled: Scan numbers in this format. ++ * ++ * "Human-readable" output uses 4 digits max, and puts a unit suffix at ++ * the end. Makes output compact and easy-to-read esp. on huge disks. ++ * Formatting code was originally in OpenBSD "df", converted to library routine. ++ * Scanning code written for OpenBSD libutil. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "util.h" ++ ++typedef enum { ++ NONE = 0, KILO = 1, MEGA = 2, GIGA = 3, TERA = 4, PETA = 5, EXA = 6 ++} unit_type; ++ ++/* These three arrays MUST be in sync! XXX make a struct */ ++static unit_type units[] = { NONE, KILO, MEGA, GIGA, TERA, PETA, EXA }; ++static char scale_chars[] = "BKMGTPE"; ++static long long scale_factors[] = { ++ 1LL, ++ 1024LL, ++ 1024LL*1024, ++ 1024LL*1024*1024, ++ 1024LL*1024*1024*1024, ++ 1024LL*1024*1024*1024*1024, ++ 1024LL*1024*1024*1024*1024*1024, ++}; ++#define SCALE_LENGTH (sizeof(units)/sizeof(units[0])) ++ ++#define MAX_DIGITS (SCALE_LENGTH * 3) /* XXX strlen(sprintf("%lld", -1)? */ ++ ++/** Convert the given input string "scaled" into numeric in "result". ++ * Return 0 on success, -1 and errno set on error. ++ */ ++int ++scan_scaled(char *scaled, long long *result) ++{ ++ char *p = scaled; ++ int sign = 0; ++ unsigned int i, ndigits = 0, fract_digits = 0; ++ long long scale_fact = 1, whole = 0, fpart = 0; ++ ++ /* Skip leading whitespace */ ++ while (isascii(*p) && isspace(*p)) ++ ++p; ++ ++ /* Then at most one leading + or - */ ++ while (*p == '-' || *p == '+') { ++ if (*p == '-') { ++ if (sign) { ++ errno = EINVAL; ++ return -1; ++ } ++ sign = -1; ++ ++p; ++ } else if (*p == '+') { ++ if (sign) { ++ errno = EINVAL; ++ return -1; ++ } ++ sign = +1; ++ ++p; ++ } ++ } ++ ++ /* Main loop: Scan digits, find decimal point, if present. ++ * We don't allow exponentials, so no scientific notation ++ * (but note that E for Exa might look like e to some!). ++ * Advance 'p' to end, to get scale factor. ++ */ ++ for (; isascii(*p) && (isdigit(*p) || *p=='.'); ++p) { ++ if (*p == '.') { ++ if (fract_digits > 0) { /* oops, more than one '.' */ ++ errno = EINVAL; ++ return -1; ++ } ++ fract_digits = 1; ++ continue; ++ } ++ ++ i = (*p) - '0'; /* whew! finally a digit we can use */ ++ if (fract_digits > 0) { ++ if (fract_digits >= MAX_DIGITS-1) ++ /* ignore extra fractional digits */ ++ continue; ++ fract_digits++; /* for later scaling */ ++ fpart *= 10; ++ fpart += i; ++ } else { /* normal digit */ ++ if (++ndigits >= MAX_DIGITS) { ++ errno = ERANGE; ++ return -1; ++ } ++ whole *= 10; ++ whole += i; ++ } ++ } ++ ++ if (sign) { ++ whole *= sign; ++ fpart *= sign; ++ } ++ ++ /* If no scale factor given, we're done. fraction is discarded. */ ++ if (!*p) { ++ *result = whole; ++ return 0; ++ } ++ ++ /* Validate scale factor, and scale whole and fraction by it. */ ++ for (i = 0; i < SCALE_LENGTH; i++) { ++ ++ /** Are we there yet? */ ++ if (*p == scale_chars[i] || ++ *p == tolower(scale_chars[i])) { ++ ++ /* If it ends with alphanumerics after the scale char, bad. */ ++ if (isalnum(*(p+1))) { ++ errno = EINVAL; ++ return -1; ++ } ++ scale_fact = scale_factors[i]; ++ ++ /* scale whole part */ ++ whole *= scale_fact; ++ ++ /* truncate fpart so it does't overflow. ++ * then scale fractional part. ++ */ ++ while (fpart >= LLONG_MAX / scale_fact) { ++ fpart /= 10; ++ fract_digits--; ++ } ++ fpart *= scale_fact; ++ if (fract_digits > 0) { ++ for (i = 0; i < fract_digits -1; i++) ++ fpart /= 10; ++ } ++ whole += fpart; ++ *result = whole; ++ return 0; ++ } ++ } ++ errno = ERANGE; ++ return -1; ++} ++ ++/* Format the given "number" into human-readable form in "result". ++ * Result must point to an allocated buffer of length FMT_SCALED_STRSIZE. ++ * Return 0 on success, -1 and errno set if error. ++ */ ++int ++fmt_scaled(long long number, char *result) ++{ ++ long long abval, fract = 0; ++ unsigned int i; ++ unit_type unit = NONE; ++ ++ abval = (number < 0LL) ? -number : number; /* no long long_abs yet */ ++ ++ /* Not every negative long long has a positive representation. ++ * Also check for numbers that are just too darned big to format ++ */ ++ if (abval < 0 || abval / 1024 >= scale_factors[SCALE_LENGTH-1]) { ++ errno = ERANGE; ++ return -1; ++ } ++ ++ /* scale whole part; get unscaled fraction */ ++ for (i = 0; i < SCALE_LENGTH; i++) { ++ if (abval/1024 < scale_factors[i]) { ++ unit = units[i]; ++ fract = (i == 0) ? 0 : abval % scale_factors[i]; ++ number /= scale_factors[i]; ++ if (i > 0) ++ fract /= scale_factors[i - 1]; ++ break; ++ } ++ } ++ ++ fract = (10 * fract + 512) / 1024; ++ /* if the result would be >= 10, round main number */ ++ if (fract == 10) { ++ if (number >= 0) ++ number++; ++ else ++ number--; ++ fract = 0; ++ } ++ ++ if (number == 0) ++ strlcpy(result, "0B", FMT_SCALED_STRSIZE); ++ else if (unit == NONE || number >= 100 || number <= -100) { ++ if (fract >= 5) { ++ if (number >= 0) ++ number++; ++ else ++ number--; ++ } ++ (void)snprintf(result, FMT_SCALED_STRSIZE, "%lld%c", ++ number, scale_chars[unit]); ++ } else ++ (void)snprintf(result, FMT_SCALED_STRSIZE, "%lld.%1lld%c", ++ number, fract, scale_chars[unit]); ++ ++ return 0; ++} ++ ++#ifdef MAIN ++/* ++ * This is the original version of the program in the man page. ++ * Copy-and-paste whatever you need from it. ++ */ ++int ++main(int argc, char **argv) ++{ ++ char *cinput = "1.5K", buf[FMT_SCALED_STRSIZE]; ++ long long ninput = 10483892, result; ++ ++ if (scan_scaled(cinput, &result) == 0) ++ printf("\"%s\" -> %lld\n", cinput, result); ++ else ++ perror(cinput); ++ ++ if (fmt_scaled(ninput, buf) == 0) ++ printf("%lld -> \"%s\"\n", ninput, buf); ++ else ++ fprintf(stderr, "%lld invalid (%s)\n", ninput, strerror(errno)); ++ ++ return 0; ++} ++#endif diff --git a/net/openbgpd/files/patch-openbsd-compat_hash.h b/net/openbgpd/files/patch-openbsd-compat_hash.h new file mode 100644 index 000000000000..0ca34733d041 --- /dev/null +++ b/net/openbgpd/files/patch-openbsd-compat_hash.h @@ -0,0 +1,134 @@ +Index: openbsd-compat/hash.h +=================================================================== +RCS file: openbsd-compat/hash.h +diff -N openbsd-compat/hash.h +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ openbsd-compat/hash.h 30 Jun 2009 05:48:11 -0000 1.1 +@@ -0,0 +1,127 @@ ++/* $OpenBSD: hash.h,v 1.4 2004/05/25 18:37:23 jmc Exp $ */ ++ ++/* ++ * Copyright (c) 2001 Tobias Weingartner ++ * 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. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. ++ */ ++ ++#ifndef _SYS_HASH_H_ ++#define _SYS_HASH_H_ ++#include ++ ++/* ++ * Note: SMALL_KERNEL might be used to shrink these, right now I ++ * do not see the point, as my kernel did not grow appreciably when ++ * I switched to these from other inline code. This may have to be ++ * revisited when/if these functions become more prevalent in the ++ * kernel. ++ */ ++ ++/* Convenience */ ++#ifndef HASHINIT ++#define HASHINIT 5381 ++#define HASHSTEP(x,c) (((x << 5) + x) + (c)) ++#endif ++ ++/* ++ * Return a 32-bit hash of the given buffer. The init ++ * value should be 0, or the previous hash value to extend ++ * the previous hash. ++ */ ++static __inline uint32_t ++hash32_buf(const void *buf, size_t len, uint32_t hash) ++{ ++ const unsigned char *p = buf; ++ ++ while (len--) ++ hash = HASHSTEP(hash, *p++); ++ ++ return hash; ++} ++ ++/* ++ * Return a 32-bit hash of the given string. ++ */ ++static __inline uint32_t ++hash32_str(const void *buf, uint32_t hash) ++{ ++ const unsigned char *p = buf; ++ ++ while (*p) ++ hash = HASHSTEP(hash, *p++); ++ ++ return hash; ++} ++ ++/* ++ * Return a 32-bit hash of the given string, limited by N. ++ */ ++static __inline uint32_t ++hash32_strn(const void *buf, size_t len, uint32_t hash) ++{ ++ const unsigned char *p = buf; ++ ++ while (*p && len--) ++ hash = HASHSTEP(hash, *p++); ++ ++ return hash; ++} ++ ++/* ++ * Return a 32-bit hash of the given string terminated by C, ++ * (as well as 0). This is mainly here as a helper for the ++ * namei() hashing of path name parts. ++ */ ++static __inline uint32_t ++hash32_stre(const void *buf, int end, char **ep, uint32_t hash) ++{ ++ const unsigned char *p = buf; ++ ++ while (*p && (*p != end)) ++ hash = HASHSTEP(hash, *p++); ++ ++ if (ep) ++ *ep = (char *)p; ++ ++ return hash; ++} ++ ++/* ++ * Return a 32-bit hash of the given string, limited by N, ++ * and terminated by C (as well as 0). This is mainly here ++ * as a helper for the namei() hashing of path name parts. ++ */ ++static __inline uint32_t ++hash32_strne(const void *buf, size_t len, int end, char **ep, uint32_t hash) ++{ ++ const unsigned char *p = buf; ++ ++ while (*p && (*p != end) && len--) ++ hash = HASHSTEP(hash, *p++); ++ ++ if (ep) ++ *ep = (char *)p; ++ ++ return hash; ++} ++#endif /* !_SYS_HASH_H_ */ diff --git a/net/openbgpd/files/patch-openbsd-compat_if_media.h b/net/openbgpd/files/patch-openbsd-compat_if_media.h new file mode 100644 index 000000000000..ffd56e0cd429 --- /dev/null +++ b/net/openbgpd/files/patch-openbsd-compat_if_media.h @@ -0,0 +1,619 @@ +Index: openbsd-compat/if_media.h +=================================================================== +RCS file: openbsd-compat/if_media.h +diff -N openbsd-compat/if_media.h +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ openbsd-compat/if_media.h 30 Jun 2009 05:48:11 -0000 1.1 +@@ -0,0 +1,612 @@ ++/* $OpenBSD: if_media.h,v 1.17 2004/11/02 02:12:16 reyk Exp $ */ ++/* $NetBSD: if_media.h,v 1.22 2000/02/17 21:53:16 sommerfeld Exp $ */ ++ ++/*- ++ * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. ++ * All rights reserved. ++ * ++ * This code is derived from software contributed to The NetBSD Foundation ++ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, ++ * NASA Ames Research Center. ++ * ++ * 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 NetBSD ++ * Foundation, Inc. and its contributors. ++ * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. ++ */ ++ ++/* ++ * Copyright (c) 1997 ++ * Jonathan Stone and Jason R. Thorpe. All rights reserved. ++ * ++ * This software is derived from information provided by Matt Thomas. ++ * ++ * 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 Jonathan Stone ++ * and Jason R. Thorpe for the NetBSD Project. ++ * 4. The names of the authors may not be used to endorse or promote products ++ * derived from this software without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHOR 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. ++ */ ++ ++#ifndef _NET_IF_MEDIA_H_ ++#define _NET_IF_MEDIA_H_ ++ ++/* ++ * Prototypes and definitions for BSD/OS-compatible network interface ++ * media selection. ++ * ++ * Where it is safe to do so, this code strays slightly from the BSD/OS ++ * design. Software which uses the API (device drivers, basically) ++ * shouldn't notice any difference. ++ * ++ * Many thanks to Matt Thomas for providing the information necessary ++ * to implement this interface. ++ */ ++ ++#ifdef _KERNEL ++ ++#include ++ ++/* ++ * Driver callbacks for media status and change requests. ++ */ ++typedef int (*ifm_change_cb_t)(struct ifnet *ifp); ++typedef void (*ifm_stat_cb_t)(struct ifnet *ifp, struct ifmediareq *req); ++ ++/* ++ * In-kernel representation of a single supported media type. ++ */ ++struct ifmedia_entry { ++ TAILQ_ENTRY(ifmedia_entry) ifm_list; ++ int ifm_media; /* description of this media attachment */ ++ int ifm_data; /* for driver-specific use */ ++ void *ifm_aux; /* for driver-specific use */ ++}; ++ ++/* ++ * One of these goes into a network interface's softc structure. ++ * It is used to keep general media state. ++ */ ++struct ifmedia { ++ int ifm_mask; /* mask of changes we don't care about */ ++ int ifm_media; /* current user-set media word */ ++ struct ifmedia_entry *ifm_cur; /* currently selected media */ ++ TAILQ_HEAD(, ifmedia_entry) ifm_list; /* list of all supported media */ ++ ifm_change_cb_t ifm_change; /* media change driver callback */ ++ ifm_stat_cb_t ifm_status; /* media status driver callback */ ++}; ++ ++/* Initialize an interface's struct if_media field. */ ++void ifmedia_init(struct ifmedia *ifm, int dontcare_mask, ++ ifm_change_cb_t change_callback, ifm_stat_cb_t status_callback); ++ ++/* Add one supported medium to a struct ifmedia. */ ++void ifmedia_add(struct ifmedia *ifm, int mword, int data, void *aux); ++ ++/* Add an array (of ifmedia_entry) media to a struct ifmedia. */ ++void ifmedia_list_add(struct ifmedia *mp, struct ifmedia_entry *lp, ++ int count); ++ ++/* Set default media type on initialization. */ ++void ifmedia_set(struct ifmedia *ifm, int mword); ++ ++/* Common ioctl function for getting/setting media, called by driver. */ ++int ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, ++ struct ifmedia *ifm, u_long cmd); ++ ++/* Locate a media entry */ ++struct ifmedia_entry *ifmedia_match(struct ifmedia *ifm, ++ int flags, int mask); ++ ++/* Delete all media for a given media instance */ ++void ifmedia_delete_instance(struct ifmedia *, int); ++ ++/* Compute baudrate for a given media. */ ++int ifmedia_baudrate(int); ++#endif /*_KERNEL */ ++ ++/* ++ * if_media Options word: ++ * Bits Use ++ * ---- ------- ++ * 0-4 Media subtype MAX SUBTYPE == 31! ++ * 5-7 Media type ++ * 8-15 Type specific options ++ * 16-19 RFU ++ * 20-27 Shared (global) options ++ * 28-31 Instance ++ */ ++ ++/* ++ * Ethernet ++ */ ++#define IFM_ETHER 0x00000020 ++#define IFM_10_T 3 /* 10BaseT - RJ45 */ ++#define IFM_10_2 4 /* 10Base2 - Thinnet */ ++#define IFM_10_5 5 /* 10Base5 - AUI */ ++#define IFM_100_TX 6 /* 100BaseTX - RJ45 */ ++#define IFM_100_FX 7 /* 100BaseFX - Fiber */ ++#define IFM_100_T4 8 /* 100BaseT4 - 4 pair cat 3 */ ++#define IFM_100_VG 9 /* 100VG-AnyLAN */ ++#define IFM_100_T2 10 /* 100BaseT2 */ ++#define IFM_1000_SX 11 /* 1000BaseSX - multi-mode fiber */ ++#define IFM_10_STP 12 /* 10BaseT over shielded TP */ ++#define IFM_10_FL 13 /* 10BaseFL - Fiber */ ++#define IFM_1000_LX 14 /* 1000baseLX - single-mode fiber */ ++#define IFM_1000_CX 15 /* 1000baseCX - 150ohm STP */ ++#define IFM_1000_T 16 /* 1000baseT - 4 pair cat 5 */ ++#define IFM_1000_TX IFM_1000_T /* for backwards compatibility */ ++#define IFM_HPNA_1 17 /* HomePNA 1.0 (1Mb/s) */ ++ ++#define IFM_ETH_MASTER 0x00000100 /* master mode (1000baseT) */ ++ ++/* ++ * Token ring ++ */ ++#define IFM_TOKEN 0x00000040 ++#define IFM_TOK_STP4 3 /* Shielded twisted pair 4m - DB9 */ ++#define IFM_TOK_STP16 4 /* Shielded twisted pair 16m - DB9 */ ++#define IFM_TOK_UTP4 5 /* Unshielded twisted pair 4m - RJ45 */ ++#define IFM_TOK_UTP16 6 /* Unshielded twisted pair 16m - RJ45 */ ++#define IFM_TOK_ETR 0x00000200 /* Early token release */ ++#define IFM_TOK_SRCRT 0x00000400 /* Enable source routing features */ ++#define IFM_TOK_ALLR 0x00000800 /* All routes / Single route bcast */ ++ ++/* ++ * FDDI ++ */ ++#define IFM_FDDI 0x00000060 ++#define IFM_FDDI_SMF 3 /* Single-mode fiber */ ++#define IFM_FDDI_MMF 4 /* Multi-mode fiber */ ++#define IFM_FDDI_UTP 5 /* CDDI / UTP */ ++#define IFM_FDDI_DA 0x00000100 /* Dual attach / single attach */ ++ ++/* ++ * IEEE 802.11 Wireless ++ */ ++#define IFM_IEEE80211 0x00000080 ++#define IFM_IEEE80211_FH1 3 /* Frequency Hopping 1Mbps */ ++#define IFM_IEEE80211_FH2 4 /* Frequency Hopping 2Mbps */ ++#define IFM_IEEE80211_DS2 5 /* Direct Sequence 2Mbps */ ++#define IFM_IEEE80211_DS5 6 /* Direct Sequence 5Mbps*/ ++#define IFM_IEEE80211_DS11 7 /* Direct Sequence 11Mbps*/ ++#define IFM_IEEE80211_DS1 8 /* Direct Sequence 1Mbps*/ ++#define IFM_IEEE80211_DS22 9 /* Direct Sequence 22Mbps */ ++#define IFM_IEEE80211_OFDM6 10 /* OFDM 6Mbps */ ++#define IFM_IEEE80211_OFDM9 11 /* OFDM 9Mbps */ ++#define IFM_IEEE80211_OFDM12 12 /* OFDM 12Mbps */ ++#define IFM_IEEE80211_OFDM18 13 /* OFDM 18Mbps */ ++#define IFM_IEEE80211_OFDM24 14 /* OFDM 24Mbps */ ++#define IFM_IEEE80211_OFDM36 15 /* OFDM 36Mbps */ ++#define IFM_IEEE80211_OFDM48 16 /* OFDM 48Mbps */ ++#define IFM_IEEE80211_OFDM54 17 /* OFDM 54Mbps */ ++#define IFM_IEEE80211_OFDM72 18 /* OFDM 72Mbps */ ++ ++#define IFM_IEEE80211_ADHOC 0x100 /* Operate in Adhoc mode */ ++#define IFM_IEEE80211_HOSTAP 0x200 /* Operate in Host AP mode */ ++#define IFM_IEEE80211_IBSS 0x400 /* Operate in IBSS mode */ ++#define IFM_IEEE80211_IBSSMASTER 0x800 /* Operate as an IBSS master */ ++#define IFM_IEEE80211_MONITOR 0x1000 /* Operate in Monitor mode */ ++#define IFM_IEEE80211_TURBO 0x2000 /* Operate in Turbo mode */ ++ ++/* operating mode for multi-mode devices */ ++#define IFM_IEEE80211_11A 0x00010000 /* 5Ghz, OFDM mode */ ++#define IFM_IEEE80211_11B 0x00020000 /* Direct Sequence mode */ ++#define IFM_IEEE80211_11G 0x00030000 /* 2Ghz, CCK mode */ ++#define IFM_IEEE80211_FH 0x00040000 /* 2Ghz, GFSK mode */ ++ ++/* ++ * Digitally multiplexed "Carrier" Serial Interfaces ++ */ ++#define IFM_TDM 0x000000a0 ++#define IFM_TDM_T1 3 /* T1 B8ZS+ESF 24 ts */ ++#define IFM_TDM_T1_AMI 4 /* T1 AMI+SF 24 ts */ ++#define IFM_TDM_E1 5 /* E1 HDB3+G.703 clearchannel 32 ts */ ++#define IFM_TDM_E1_G704 6 /* E1 HDB3+G.703+G.704 channelized 31 ts */ ++#define IFM_TDM_E1_AMI 7 /* E1 AMI+G.703 32 ts */ ++#define IFM_TDM_E1_AMI_G704 8 /* E1 AMI+G.703+G.704 31 ts */ ++#define IFM_TDM_T3 9 /* T3 B3ZS+C-bit 672 ts */ ++#define IFM_TDM_T3_M13 10 /* T3 B3ZS+M13 672 ts */ ++#define IFM_TDM_E3 11 /* E3 HDB3+G.751 512? ts */ ++#define IFM_TDM_E3_G751 12 /* E3 G.751 512 ts */ ++#define IFM_TDM_E3_G832 13 /* E3 G.832 512 ts */ ++/* ++ * 6 major ways that networks talk: Drivers enforce independent selection, ++ * meaning, a driver will ensure that only one of these is set at a time. ++ */ ++#define IFM_TDM_HDLC_CRC16 0x0100 /* Use 16-bit CRC for HDLC instead */ ++#define IFM_TDM_PPP 0x0200 /* SPPP (dumb) */ ++#define IFM_TDM_FR_ANSI 0x0400 /* Frame Relay + LMI ANSI "Annex D" */ ++#define IFM_TDM_FR_CISCO 0x0800 /* Frame Relay + LMI Cisco */ ++#define IFM_TDM_FR_ITU 0x1000 /* Frame Relay + LMI ITU "Q933A" */ ++ ++/* ++ * Common Access Redundancy Protocol ++ */ ++#define IFM_CARP 0x000000c0 ++ ++/* ++ * Shared media sub-types ++ */ ++#define IFM_AUTO 0 /* Autoselect best media */ ++#define IFM_MANUAL 1 /* Jumper/dipswitch selects media */ ++#define IFM_NONE 2 /* Deselect all media */ ++ ++/* ++ * Shared options ++ */ ++#define IFM_FDX 0x00100000 /* Force full duplex */ ++#define IFM_HDX 0x00200000 /* Force half duplex */ ++#define IFM_FLOW 0x00400000 /* enable hardware flow control */ ++#define IFM_FLAG0 0x01000000 /* Driver defined flag */ ++#define IFM_FLAG1 0x02000000 /* Driver defined flag */ ++#define IFM_FLAG2 0x04000000 /* Driver defined flag */ ++#define IFM_LOOP 0x08000000 /* Put hardware in loopback */ ++ ++/* ++ * Masks ++ */ ++#define IFM_NMASK 0x000000e0 /* Network type */ ++#define IFM_TMASK 0x0000001f /* Media sub-type */ ++#define IFM_IMASK 0xf0000000 /* Instance */ ++#define IFM_ISHIFT 28 /* Instance shift */ ++#define IFM_OMASK 0x0000ff00 /* Type specific options */ ++#define IFM_MMASK 0x00070000 /* Mode */ ++#define IFM_MSHIFT 16 /* Mode shift */ ++#define IFM_GMASK 0x0ff00000 /* Global options */ ++ ++#define IFM_NMIN IFM_ETHER /* lowest Network type */ ++#define IFM_NMAX IFM_NMASK /* highest Network type */ ++ ++/* ++ * Status bits ++ */ ++#define IFM_AVALID 0x00000001 /* Active bit valid */ ++#define IFM_ACTIVE 0x00000002 /* Interface attached to working net */ ++ ++/* Mask of "status valid" bits, for ifconfig(8). */ ++#define IFM_STATUS_VALID IFM_AVALID ++ ++/* List of "status valid" bits, for ifconfig(8). */ ++#define IFM_STATUS_VALID_LIST { \ ++ IFM_AVALID, \ ++ 0 \ ++} ++ ++/* ++ * Macros to extract various bits of information from the media word. ++ */ ++#define IFM_TYPE(x) ((x) & IFM_NMASK) ++#define IFM_SUBTYPE(x) ((x) & IFM_TMASK) ++#define IFM_INST(x) (((x) & IFM_IMASK) >> IFM_ISHIFT) ++#define IFM_OPTIONS(x) ((x) & (IFM_OMASK|IFM_GMASK)) ++#define IFM_MODE(x) ((x) & IFM_MMASK) ++ ++#define IFM_INST_MAX IFM_INST(IFM_IMASK) ++#define IFM_INST_ANY (-1) ++ ++/* ++ * Macro to create a media word. ++ */ ++#define IFM_MAKEWORD(type, subtype, options, instance) \ ++ ((type) | (subtype) | (options) | ((instance) << IFM_ISHIFT)) ++#define IFM_MAKEMODE(mode) \ ++ (((mode) << IFM_MSHIFT) & IFM_MMASK) ++/* ++ * NetBSD extension not defined in the BSDI API. This is used in various ++ * places to get the canonical description for a given type/subtype. ++ * ++ * In the subtype and mediaopt descriptions, the valid TYPE bits are OR'd ++ * in to indicate which TYPE the subtype/option corresponds to. If no ++ * TYPE is present, it is a shared media/mediaopt. ++ * ++ * Note that these are parsed case-insensitive. ++ * ++ * Order is important. The first matching entry is the canonical name ++ * for a media type; subsequent matches are aliases. ++ */ ++struct ifmedia_description { ++ int ifmt_word; /* word value; may be masked */ ++ const char *ifmt_string; /* description */ ++}; ++ ++#define IFM_TYPE_DESCRIPTIONS { \ ++ { IFM_ETHER, "Ethernet" }, \ ++ { IFM_ETHER, "ether" }, \ ++ { IFM_TOKEN, "TokenRing" }, \ ++ { IFM_TOKEN, "token" }, \ ++ { IFM_FDDI, "FDDI" }, \ ++ { IFM_IEEE80211, "IEEE802.11" }, \ ++ { IFM_TDM, "TDM" }, \ ++ { IFM_CARP, "CARP" }, \ ++ { 0, NULL }, \ ++} ++ ++#define IFM_TYPE_MATCH(dt, t) \ ++ (IFM_TYPE((dt)) == 0 || IFM_TYPE((dt)) == IFM_TYPE((t))) ++ ++#define IFM_SUBTYPE_DESCRIPTIONS { \ ++ { IFM_AUTO, "autoselect" }, \ ++ { IFM_AUTO, "auto" }, \ ++ { IFM_MANUAL, "manual" }, \ ++ { IFM_NONE, "none" }, \ ++ \ ++ { IFM_ETHER|IFM_10_T, "10baseT" }, \ ++ { IFM_ETHER|IFM_10_T, "10baseT/UTP" }, \ ++ { IFM_ETHER|IFM_10_T, "UTP" }, \ ++ { IFM_ETHER|IFM_10_T, "10UTP" }, \ ++ { IFM_ETHER|IFM_10_2, "10base2" }, \ ++ { IFM_ETHER|IFM_10_2, "10base2/BNC" }, \ ++ { IFM_ETHER|IFM_10_2, "BNC" }, \ ++ { IFM_ETHER|IFM_10_2, "10BNC" }, \ ++ { IFM_ETHER|IFM_10_5, "10base5" }, \ ++ { IFM_ETHER|IFM_10_5, "10base5/AUI" }, \ ++ { IFM_ETHER|IFM_10_5, "AUI" }, \ ++ { IFM_ETHER|IFM_10_5, "10AUI" }, \ ++ { IFM_ETHER|IFM_100_TX, "100baseTX" }, \ ++ { IFM_ETHER|IFM_100_TX, "100TX" }, \ ++ { IFM_ETHER|IFM_100_FX, "100baseFX" }, \ ++ { IFM_ETHER|IFM_100_FX, "100FX" }, \ ++ { IFM_ETHER|IFM_100_T4, "100baseT4" }, \ ++ { IFM_ETHER|IFM_100_T4, "100T4" }, \ ++ { IFM_ETHER|IFM_100_VG, "100baseVG" }, \ ++ { IFM_ETHER|IFM_100_VG, "100VG" }, \ ++ { IFM_ETHER|IFM_100_T2, "100baseT2" }, \ ++ { IFM_ETHER|IFM_100_T2, "100T2" }, \ ++ { IFM_ETHER|IFM_1000_SX, "1000baseSX" }, \ ++ { IFM_ETHER|IFM_1000_SX, "1000SX" }, \ ++ { IFM_ETHER|IFM_10_STP, "10baseSTP" }, \ ++ { IFM_ETHER|IFM_10_STP, "STP" }, \ ++ { IFM_ETHER|IFM_10_STP, "10STP" }, \ ++ { IFM_ETHER|IFM_10_FL, "10baseFL" }, \ ++ { IFM_ETHER|IFM_10_FL, "FL" }, \ ++ { IFM_ETHER|IFM_10_FL, "10FL" }, \ ++ { IFM_ETHER|IFM_1000_LX, "1000baseLX" }, \ ++ { IFM_ETHER|IFM_1000_LX, "1000LX" }, \ ++ { IFM_ETHER|IFM_1000_CX, "1000baseCX" }, \ ++ { IFM_ETHER|IFM_1000_CX, "1000CX" }, \ ++ { IFM_ETHER|IFM_1000_T, "1000baseT" }, \ ++ { IFM_ETHER|IFM_1000_T, "1000T" }, \ ++ { IFM_ETHER|IFM_1000_T, "1000baseTX" }, \ ++ { IFM_ETHER|IFM_1000_T, "1000TX" }, \ ++ { IFM_ETHER|IFM_HPNA_1, "HomePNA1" }, \ ++ { IFM_ETHER|IFM_HPNA_1, "HPNA1" }, \ ++ \ ++ { IFM_TOKEN|IFM_TOK_STP4, "DB9/4Mbit" }, \ ++ { IFM_TOKEN|IFM_TOK_STP4, "4STP" }, \ ++ { IFM_TOKEN|IFM_TOK_STP16, "DB9/16Mbit" }, \ ++ { IFM_TOKEN|IFM_TOK_STP16, "16STP" }, \ ++ { IFM_TOKEN|IFM_TOK_UTP4, "UTP/4Mbit" }, \ ++ { IFM_TOKEN|IFM_TOK_UTP4, "4UTP" }, \ ++ { IFM_TOKEN|IFM_TOK_UTP16, "UTP/16Mbit" }, \ ++ { IFM_TOKEN|IFM_TOK_UTP16, "16UTP" }, \ ++ \ ++ { IFM_FDDI|IFM_FDDI_SMF, "Single-mode" }, \ ++ { IFM_FDDI|IFM_FDDI_SMF, "SMF" }, \ ++ { IFM_FDDI|IFM_FDDI_MMF, "Multi-mode" }, \ ++ { IFM_FDDI|IFM_FDDI_MMF, "MMF" }, \ ++ { IFM_FDDI|IFM_FDDI_UTP, "UTP" }, \ ++ { IFM_FDDI|IFM_FDDI_UTP, "CDDI" }, \ ++ \ ++ { IFM_IEEE80211|IFM_IEEE80211_FH1, "FH1" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_FH2, "FH2" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_DS2, "DS2" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_DS5, "DS5" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_DS11, "DS11" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_DS1, "DS1" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_DS22, "DS22" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM6, "OFDM6" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM9, "OFDM9" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM12, "OFDM12" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM18, "OFDM18" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM24, "OFDM24" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM36, "OFDM36" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM48, "OFDM48" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM54, "OFDM54" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM72, "OFDM72" }, \ ++ \ ++ { IFM_TDM|IFM_TDM_T1, "t1" }, \ ++ { IFM_TDM|IFM_TDM_T1_AMI, "t1-ami" }, \ ++ { IFM_TDM|IFM_TDM_E1, "e1" }, \ ++ { IFM_TDM|IFM_TDM_E1_G704, "e1-g.704" }, \ ++ { IFM_TDM|IFM_TDM_E1_AMI, "e1-ami" }, \ ++ { IFM_TDM|IFM_TDM_E1_AMI_G704, "e1-ami-g.704" }, \ ++ { IFM_TDM|IFM_TDM_T3, "t3" }, \ ++ { IFM_TDM|IFM_TDM_T3_M13, "t3-m13" }, \ ++ { IFM_TDM|IFM_TDM_E3, "e3" }, \ ++ { IFM_TDM|IFM_TDM_E3_G751, "e3-g.751" }, \ ++ { IFM_TDM|IFM_TDM_E3_G832, "e3-g.832" }, \ ++ \ ++ { 0, NULL }, \ ++} ++ ++#define IFM_MODE_DESCRIPTIONS { \ ++ { IFM_AUTO, "autoselect" }, \ ++ { IFM_AUTO, "auto" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_11A, "11a" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_11B, "11b" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_11G, "11g" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_FH, "fh" }, \ ++ { 0, NULL }, \ ++} ++ ++#define IFM_OPTION_DESCRIPTIONS { \ ++ { IFM_FDX, "full-duplex" }, \ ++ { IFM_FDX, "fdx" }, \ ++ { IFM_HDX, "half-duplex" }, \ ++ { IFM_HDX, "hdx" }, \ ++ { IFM_FLAG0, "flag0" }, \ ++ { IFM_FLAG1, "flag1" }, \ ++ { IFM_FLAG2, "flag2" }, \ ++ { IFM_LOOP, "loopback" }, \ ++ { IFM_LOOP, "hw-loopback"}, \ ++ { IFM_LOOP, "loop" }, \ ++ \ ++ { IFM_ETHER|IFM_ETH_MASTER, "master" }, \ ++ \ ++ { IFM_TOKEN|IFM_TOK_ETR, "EarlyTokenRelease" }, \ ++ { IFM_TOKEN|IFM_TOK_ETR, "ETR" }, \ ++ { IFM_TOKEN|IFM_TOK_SRCRT, "SourceRouting" }, \ ++ { IFM_TOKEN|IFM_TOK_SRCRT, "SRCRT" }, \ ++ { IFM_TOKEN|IFM_TOK_ALLR, "AllRoutes" }, \ ++ { IFM_TOKEN|IFM_TOK_ALLR, "ALLR" }, \ ++ \ ++ { IFM_FDDI|IFM_FDDI_DA, "dual-attach" }, \ ++ { IFM_FDDI|IFM_FDDI_DA, "das" }, \ ++ \ ++ { IFM_IEEE80211|IFM_IEEE80211_ADHOC, "adhoc" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_HOSTAP, "hostap" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_IBSS, "ibss" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_IBSSMASTER, "ibss-master" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_MONITOR, "monitor" }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_TURBO, "turbo" }, \ ++ \ ++ { IFM_TDM|IFM_TDM_HDLC_CRC16, "hdlc-crc16" }, \ ++ { IFM_TDM|IFM_TDM_PPP, "ppp" }, \ ++ { IFM_TDM|IFM_TDM_FR_ANSI, "framerelay-ansi" }, \ ++ { IFM_TDM|IFM_TDM_FR_CISCO, "framerelay-cisco" }, \ ++ { IFM_TDM|IFM_TDM_FR_ANSI, "framerelay-itu" }, \ ++ \ ++ { 0, NULL }, \ ++} ++ ++/* ++ * Baudrate descriptions for the various media types. ++ */ ++struct ifmedia_baudrate { ++ int ifmb_word; /* media word */ ++ int ifmb_baudrate; /* corresponding baudrate */ ++}; ++ ++#define IFM_BAUDRATE_DESCRIPTIONS { \ ++ { IFM_ETHER|IFM_10_T, IF_Mbps(10) }, \ ++ { IFM_ETHER|IFM_10_2, IF_Mbps(10) }, \ ++ { IFM_ETHER|IFM_10_5, IF_Mbps(10) }, \ ++ { IFM_ETHER|IFM_100_TX, IF_Mbps(100) }, \ ++ { IFM_ETHER|IFM_100_FX, IF_Mbps(100) }, \ ++ { IFM_ETHER|IFM_100_T4, IF_Mbps(100) }, \ ++ { IFM_ETHER|IFM_100_VG, IF_Mbps(100) }, \ ++ { IFM_ETHER|IFM_100_T2, IF_Mbps(100) }, \ ++ { IFM_ETHER|IFM_1000_SX, IF_Mbps(1000) }, \ ++ { IFM_ETHER|IFM_10_STP, IF_Mbps(10) }, \ ++ { IFM_ETHER|IFM_10_FL, IF_Mbps(10) }, \ ++ { IFM_ETHER|IFM_1000_LX, IF_Mbps(1000) }, \ ++ { IFM_ETHER|IFM_1000_CX, IF_Mbps(1000) }, \ ++ { IFM_ETHER|IFM_1000_T, IF_Mbps(1000) }, \ ++ { IFM_ETHER|IFM_HPNA_1, IF_Mbps(1) }, \ ++ \ ++ { IFM_TOKEN|IFM_TOK_STP4, IF_Mbps(4) }, \ ++ { IFM_TOKEN|IFM_TOK_STP16, IF_Mbps(16) }, \ ++ { IFM_TOKEN|IFM_TOK_UTP4, IF_Mbps(4) }, \ ++ { IFM_TOKEN|IFM_TOK_UTP16, IF_Mbps(16) }, \ ++ \ ++ { IFM_FDDI|IFM_FDDI_SMF, IF_Mbps(100) }, \ ++ { IFM_FDDI|IFM_FDDI_MMF, IF_Mbps(100) }, \ ++ { IFM_FDDI|IFM_FDDI_UTP, IF_Mbps(100) }, \ ++ \ ++ { IFM_IEEE80211|IFM_IEEE80211_FH1, IF_Mbps(1) }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_FH2, IF_Mbps(2) }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_DS1, IF_Mbps(1) }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_DS2, IF_Mbps(2) }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_DS5, IF_Mbps(5) }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_DS11, IF_Mbps(11) }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_DS22, IF_Mbps(22) }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM6, IF_Mbps(6) }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM9, IF_Mbps(9) }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM12, IF_Mbps(12) }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM18, IF_Mbps(18) }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM24, IF_Mbps(24) }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM36, IF_Mbps(36) }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM48, IF_Mbps(48) }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM54, IF_Mbps(54) }, \ ++ { IFM_IEEE80211|IFM_IEEE80211_OFDM72, IF_Mbps(72) }, \ ++ \ ++ { IFM_TDM|IFM_TDM_T1, IF_Kbps(1536) }, \ ++ { IFM_TDM|IFM_TDM_T1_AMI, IF_Kbps(1536) }, \ ++ { IFM_TDM|IFM_TDM_E1, IF_Kbps(2048) }, \ ++ { IFM_TDM|IFM_TDM_E1_G704, IF_Kbps(2048) }, \ ++ { IFM_TDM|IFM_TDM_E1_AMI, IF_Kbps(2048) }, \ ++ { IFM_TDM|IFM_TDM_E1_AMI_G704, IF_Kbps(2048) }, \ ++ { IFM_TDM|IFM_TDM_T3, IF_Kbps(44736) }, \ ++ { IFM_TDM|IFM_TDM_T3_M13, IF_Kbps(44736) }, \ ++ { IFM_TDM|IFM_TDM_E3, IF_Kbps(34368) }, \ ++ { IFM_TDM|IFM_TDM_E3_G751, IF_Kbps(34368) }, \ ++ { IFM_TDM|IFM_TDM_E3_G832, IF_Kbps(34368) }, \ ++ \ ++ { 0, 0 }, \ ++} ++ ++/* ++ * Status bit descriptions for the various media types. ++ */ ++struct ifmedia_status_description { ++ int ifms_type; ++ int ifms_valid; ++ int ifms_bit; ++ const char *ifms_string[2]; ++}; ++ ++#define IFM_STATUS_DESC(ifms, bit) \ ++ (ifms)->ifms_string[((ifms)->ifms_bit & (bit)) ? 1 : 0] ++ ++#define IFM_STATUS_DESCRIPTIONS { \ ++ { IFM_ETHER, IFM_AVALID, IFM_ACTIVE, \ ++ { "no carrier", "active" } }, \ ++ { IFM_FDDI, IFM_AVALID, IFM_ACTIVE, \ ++ { "no ring", "inserted" } }, \ ++ { IFM_TOKEN, IFM_AVALID, IFM_ACTIVE, \ ++ { "no ring", "inserted" } }, \ ++ { IFM_IEEE80211, IFM_AVALID, IFM_ACTIVE, \ ++ { "no network", "active" } }, \ ++ { IFM_TDM, IFM_AVALID, IFM_ACTIVE, \ ++ { "no carrier", "active" } }, \ ++ { IFM_CARP, IFM_AVALID, IFM_ACTIVE, \ ++ { "backup", "master" } }, \ ++ { 0, 0, 0, \ ++ { NULL, NULL } } \ ++} ++#endif /* _NET_IF_MEDIA_H_ */ diff --git a/net/openbgpd/files/patch-openbsd-compat_openbsd-compat.h b/net/openbgpd/files/patch-openbsd-compat_openbsd-compat.h new file mode 100644 index 000000000000..01a61866c27e --- /dev/null +++ b/net/openbgpd/files/patch-openbsd-compat_openbsd-compat.h @@ -0,0 +1,30 @@ +Index: openbsd-compat/openbsd-compat.h +=================================================================== +RCS file: openbsd-compat/openbsd-compat.h +diff -N openbsd-compat/openbsd-compat.h +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ openbsd-compat/openbsd-compat.h 30 Jun 2009 06:52:12 -0000 1.2 +@@ -0,0 +1,23 @@ ++/* ++ * $hrs: openbgpd/openbsd-compat/openbsd-compat.h,v 1.2 2009/06/30 06:52:12 hrs Exp $ ++ */ ++ ++#ifndef _OPENBSD_COMPAT_H ++#define _OPENBSD_COMPAT_H ++ ++#define __dead ++ ++/* bgpctl/bgpctl.c */ ++#include ++#define betoh64(x) (be64toh(x)) ++ ++/* bgpd/irrfilter.c */ ++typedef unsigned long ulong; ++ ++/* bgpd/bgpd.c */ ++#ifndef RTLABEL_LEN /* defined in net/pfvar.h */ ++#define RTLABEL_LEN 32 ++#endif ++#define RTA_LABEL 0 ++ ++#endif /* _OPENBSD_COMPAT_H */ diff --git a/net/openbgpd/files/patch-openbsd-compat_pfkey_compat.c b/net/openbgpd/files/patch-openbsd-compat_pfkey_compat.c new file mode 100644 index 000000000000..d7754e350646 --- /dev/null +++ b/net/openbgpd/files/patch-openbsd-compat_pfkey_compat.c @@ -0,0 +1,34 @@ +Index: openbsd-compat/pfkey_compat.c +=================================================================== +RCS file: openbsd-compat/pfkey_compat.c +diff -N openbsd-compat/pfkey_compat.c +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ openbsd-compat/pfkey_compat.c 30 Jun 2009 06:40:07 -0000 1.1 +@@ -0,0 +1,27 @@ ++#include "bgpd.h" ++#include "session.h" ++ ++int ++pfkey_establish(struct peer *p) ++{ ++ if (p->conf.auth.method) ++ return (-1); ++ return (0); ++} ++ ++int ++pfkey_remove(struct peer *p) ++{ ++ if (p->conf.auth.method) ++ return (-1); ++ return (0); ++} ++ ++int ++pfkey_init(struct bgpd_sysdep *sysdep) ++{ ++ log_warnx("no kernel support for PF_KEY"); ++ sysdep->no_pfkey = 1; ++ return (0); ++} ++ diff --git a/net/openbgpd/files/patch-openbsd-compat_util.h b/net/openbgpd/files/patch-openbsd-compat_util.h new file mode 100644 index 000000000000..c2de585e338a --- /dev/null +++ b/net/openbgpd/files/patch-openbsd-compat_util.h @@ -0,0 +1,126 @@ +Index: openbsd-compat/util.h +=================================================================== +RCS file: openbsd-compat/util.h +diff -N openbsd-compat/util.h +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ openbsd-compat/util.h 30 Jun 2009 06:40:07 -0000 1.1 +@@ -0,0 +1,119 @@ ++/* $OpenBSD: util.h,v 1.27 2006/06/14 02:14:25 krw Exp $ */ ++/* $NetBSD: util.h,v 1.2 1996/05/16 07:00:22 thorpej Exp $ */ ++ ++/*- ++ * Copyright (c) 1995 ++ * The Regents of the University of California. All rights reserved. ++ * Portions Copyright (c) 1996, Jason Downs. 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. ++ */ ++ ++#ifndef _UTIL_H_ ++#define _UTIL_H_ ++ ++#include ++#include ++ ++/* ++ * fparseln() specific operation flags. ++ */ ++#define FPARSELN_UNESCESC 0x01 ++#define FPARSELN_UNESCCONT 0x02 ++#define FPARSELN_UNESCCOMM 0x04 ++#define FPARSELN_UNESCREST 0x08 ++#define FPARSELN_UNESCALL 0x0f ++ ++/* ++ * opendev() specific operation flags. ++ */ ++#define OPENDEV_PART 0x01 /* Try to open the raw partition. */ ++#define OPENDEV_BLCK 0x04 /* Open block, not character device. */ ++ ++/* ++ * uucplock(3) specific flags. ++ */ ++#define UU_LOCK_INUSE (1) ++#define UU_LOCK_OK (0) ++#define UU_LOCK_OPEN_ERR (-1) ++#define UU_LOCK_READ_ERR (-2) ++#define UU_LOCK_CREAT_ERR (-3) ++#define UU_LOCK_WRITE_ERR (-4) ++#define UU_LOCK_LINK_ERR (-5) ++#define UU_LOCK_TRY_ERR (-6) ++#define UU_LOCK_OWNER_ERR (-7) ++ ++/* ++ * fmt_scaled(3) specific flags. ++ */ ++#define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */ ++ ++/* ++ * stub struct definitions. ++ */ ++struct __sFILE; ++struct login_cap; ++struct passwd; ++struct termios; ++struct utmp; ++struct winsize; ++ ++__BEGIN_DECLS ++char *fparseln(struct __sFILE *, size_t *, size_t *, const char[3], int); ++void login(struct utmp *); ++int login_tty(int); ++int logout(const char *); ++void logwtmp(const char *, const char *, const char *); ++int opendev(char *, int, int, char **); ++int pidfile(const char *); ++void pw_setdir(const char *); ++char *pw_file(const char *); ++int pw_lock(int retries); ++int pw_mkdb(char *, int); ++int pw_abort(void); ++void pw_init(void); ++void pw_edit(int, const char *); ++void pw_prompt(void); ++void pw_copy(int, int, const struct passwd *, const struct passwd *); ++int pw_scan(char *, struct passwd *, int *); ++void pw_error(const char *, int, int); ++int openpty(int *, int *, char *, struct termios *, struct winsize *); ++int opendisk(const char *path, int flags, char *buf, size_t buflen, ++ int iscooked); ++pid_t forkpty(int *, char *, struct termios *, struct winsize *); ++int getmaxpartitions(void); ++int getrawpartition(void); ++void login_fbtab(const char *, uid_t, gid_t); ++int login_check_expire(struct __sFILE *, struct passwd *, char *, int); ++char *readlabelfs(char *, int); ++const char *uu_lockerr(int _uu_lockresult); ++int uu_lock(const char *_ttyname); ++int uu_lock_txfr(const char *_ttyname, pid_t _pid); ++int uu_unlock(const char *_ttyname); ++int fmt_scaled(long long number, char *result); ++int scan_scaled(char *scaled, long long *result); ++__END_DECLS ++ ++#endif /* !_UTIL_H_ */ -- cgit v1.2.3