git: ec6f10e0cc6c - main - misc/dahdi-kmod: Remove expired port:
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 21 Mar 2023 00:02:07 UTC
The branch main has been updated by bofh:
URL: https://cgit.FreeBSD.org/ports/commit/?id=ec6f10e0cc6c6befdb0489f0b301ec68c1af7faf
commit ec6f10e0cc6c6befdb0489f0b301ec68c1af7faf
Author: Muhammad Moinur Rahman <bofh@FreeBSD.org>
AuthorDate: 2023-03-20 23:24:49 +0000
Commit: Muhammad Moinur Rahman <bofh@FreeBSD.org>
CommitDate: 2023-03-21 00:01:38 +0000
misc/dahdi-kmod: Remove expired port:
2023-03-21 misc/dahdi-kmod: Broken since 2021
---
MOVED | 1 +
misc/Makefile | 1 -
misc/dahdi-kmod/Makefile | 79 --
misc/dahdi-kmod/distinfo | 16 -
misc/dahdi-kmod/files/dahdi.in | 79 --
misc/dahdi-kmod/files/patch-bchan | 170 ----
misc/dahdi-kmod/files/patch-clang | 18 -
misc/dahdi-kmod/files/patch-dahdi-iface | 939 ---------------------
misc/dahdi-kmod/files/patch-flush_workqueue | 91 --
.../files/patch-freebsd-drivers-dahdi-dahdi-base.c | 45 -
...tch-freebsd-drivers-dahdi-dahdi_dynamic_ethmf.c | 11 -
.../patch-freebsd-drivers-dahdi-wctc4xxp-base.c | 55 --
.../patch-freebsd-drivers-dahdi-wcte12xp-base.c | 14 -
.../files/patch-freebsd-freebsd-dahdi-Makefile | 14 -
.../files/patch-freebsd-freebsd-dahdi-bsd-compat.c | 14 -
.../patch-freebsd-freebsd-dahdi-ng_dahdi_iface.c | 17 -
.../files/patch-freebsd-include-dahdi-compat-bsd.h | 34 -
.../files/patch-freebsd-include-stdbool.h | 20 -
.../files/patch-freebsd__freebsd__Makefile.inc | 8 -
.../files/patch-include_dahdi_compat_bsd.h | 11 -
misc/dahdi-kmod/files/patch-ithread | 26 -
misc/dahdi-kmod/files/patch-mbuf | 49 --
misc/dahdi-kmod/files/patch-oslec | 29 -
misc/dahdi-kmod/files/patch-zaphfc | 883 -------------------
misc/dahdi-kmod/pkg-descr | 3 -
misc/dahdi-kmod/pkg-plist | 28 -
26 files changed, 1 insertion(+), 2654 deletions(-)
diff --git a/MOVED b/MOVED
index 0e429ef0b7ed..f698c0a66c43 100644
--- a/MOVED
+++ b/MOVED
@@ -17804,3 +17804,4 @@ graphics/py-open3d-python||2023-03-19|Has expired: Broken since 2020
devel/libzrtpcpp||2023-03-20|Has expired: Broken since 2021
devel/riscv64-gcc||2023-03-20|Has expired: Unsupported version and users should move to devel/freebsd-gcc12@riscv64
devel/frama-c||2023-03-20|Has expired: Broken since 2021
+misc/dahdi-kmod||2023-03-20|Has expired: Broken since 2021
diff --git a/misc/Makefile b/misc/Makefile
index 21d1f1cc12cd..27a2f973e5b8 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -71,7 +71,6 @@
SUBDIR += ctm
SUBDIR += cuttlefish
SUBDIR += dahdi
- SUBDIR += dahdi-kmod
SUBDIR += dahdi-kmod26
SUBDIR += darknet
SUBDIR += dartsim
diff --git a/misc/dahdi-kmod/Makefile b/misc/dahdi-kmod/Makefile
deleted file mode 100644
index 4066f8ba3bdd..000000000000
--- a/misc/dahdi-kmod/Makefile
+++ /dev/null
@@ -1,79 +0,0 @@
-PORTNAME= dahdi-kmod
-PORTVERSION= ${DAHDI_VERSION:S/-//g}
-PORTREVISION= 7
-CATEGORIES= misc
-MASTER_SITES= LOCAL/fjoe \
- http://downloads.digium.com/pub/telephony/firmware/releases/:firmware
-DISTNAME= dahdi-freebsd-complete-${DAHDI_VERSION}+${DAHDI_TOOLS_VERSION}
-DISTFILES= ${DISTNAME}${EXTRACT_SUFX}\
- oslec-linux-${OSLEC_VERSION}${EXTRACT_SUFX}\
- zaphfc-${ZAPHFC_VERSION}${EXTRACT_SUFX}
-
-MAINTAINER= dgilbert@eicat.ca
-COMMENT= Digium/Asterisk Hardware Device Interface
-WWW= https://svn.digium.com/svn/dahdi/freebsd/
-
-BROKEN= does not compile: use of undeclared identifier 'SX_NOADAPTIVE'
-DEPRECATED= Broken since 2021
-EXPIRATION_DATE= 2023-03-21
-
-RUN_DEPENDS= ${LOCALBASE}/sbin/dahdi_cfg:misc/dahdi
-
-ONLY_FOR_ARCHS= amd64 i386 powerpc64 sparc64
-
-DAHDI_VERSION= 2.4.0-rc5
-DAHDI_TOOLS_VERSION= 2.4.0-rc1
-OSLEC_VERSION= 2.6.35.4
-ZAPHFC_VERSION= r5
-
-FIRMWARES= OCT6114_064 OCT6114_128 TC400M HX8 ${_vpmadt032}
-OCT6114_064_VERSION= 1.05.01
-OCT6114_128_VERSION= 1.05.01
-TC400M_VERSION= MR6.12
-HX8_VERSION= 2.06
-VPMADT032_NAME= dahdi-fwload-vpmadt032
-VPMADT032_DIR= dahdi_vpmadt032_loader
-VPMADT032_VERSION= 1.25.0
-
-WRKSRC= ${WRKDIR}/${DISTNAME}/freebsd
-EXTRA_PATCHES= ${WRKDIR}/zaphfc-${ZAPHFC_VERSION}
-PATCH_STRIP= -p1
-MAKEFILE= BSDmakefile
-USE_RC_SUBR= dahdi
-MAKE_ARGS= ADDITIONAL_DRIVERS="wcb1xxp" NO_FETCH=yes DEPEND_MP= WERROR=
-GROUPS= dahdi
-
-CONFLICTS= zaptel dahdi-kmod26
-
-USES= kmod uidfix
-
-KMODDIR= ${PREFIX}/lib/dahdi
-
-.include <bsd.port.pre.mk>
-
-.if ${ARCH} == "amd64" || ${ARCH} == "i386"
-PLIST_SUB+= X86=""
-_vpmadt032= VPMADT032
-.else
-PLIST_SUB+= X86="@comment "
-.endif
-
-.for _f in ${FIRMWARES}
-${_f}_NAME?= dahdi-fw-${_f:tl:S/_/-/g}
-${_f}_DIR?= ${${_f}_NAME}.bin
-${_f}_DISTFILE= ${${_f}_NAME}-${${_f}_VERSION}.tar.gz
-DISTFILES+= ${${_f}_DISTFILE}:firmware
-.endfor
-
-post-extract:
- @${LN} -s ../../../linux-${OSLEC_VERSION}/drivers/staging ${WRKSRC}/drivers
-.for _f in ${FIRMWARES}
- ${CP} ${DISTDIR}/${${_f}_DISTFILE} ${WRKSRC}/freebsd/${${_f}_DIR}
-.endfor
-
-fw-versions: extract
-.for _v in ${FIRMWARES:=_VERSION}
- @${ECHO_CMD} "${_v}=`${MAKE} -V ${_v} -f ${WRKSRC}/firmware.mk`"
-.endfor
-
-.include <bsd.port.post.mk>
diff --git a/misc/dahdi-kmod/distinfo b/misc/dahdi-kmod/distinfo
deleted file mode 100644
index bca62c47438e..000000000000
--- a/misc/dahdi-kmod/distinfo
+++ /dev/null
@@ -1,16 +0,0 @@
-SHA256 (dahdi-freebsd-complete-2.4.0-rc5+2.4.0-rc1.tar.gz) = f364a13d10aa67ac26eb68babfcd4aa2a789f6ce074a923e20192f12fa02e3d2
-SIZE (dahdi-freebsd-complete-2.4.0-rc5+2.4.0-rc1.tar.gz) = 2049189
-SHA256 (oslec-linux-2.6.35.4.tar.gz) = 01cfaa1ca64056c822d1a3ebf4f7b3c81127cd7b308ad5b0738ff4eb2026e261
-SIZE (oslec-linux-2.6.35.4.tar.gz) = 12057
-SHA256 (zaphfc-r5.tar.gz) = 7e809b62dcc2bd3caf2e5a882390051b881eb08d37fea1733d7fb55e80bc6756
-SIZE (zaphfc-r5.tar.gz) = 15639
-SHA256 (dahdi-fw-oct6114-064-1.05.01.tar.gz) = 56bac1f2024c76ecf9b6f40992eeea29a1fbee676bb2a37a058179bacfbb1c91
-SIZE (dahdi-fw-oct6114-064-1.05.01.tar.gz) = 165869
-SHA256 (dahdi-fw-oct6114-128-1.05.01.tar.gz) = e1146749d205c41603b9b76852c3f8104dac233d0025d700db24504d10c99775
-SIZE (dahdi-fw-oct6114-128-1.05.01.tar.gz) = 165849
-SHA256 (dahdi-fw-tc400m-MR6.12.tar.gz) = 11dd8d009809e41fc9a3a36766f59ff73d29075eede5b8724331d9a6e5259774
-SIZE (dahdi-fw-tc400m-MR6.12.tar.gz) = 1750035
-SHA256 (dahdi-fw-hx8-2.06.tar.gz) = 449ab3fd03d55d808e999efb7677cd04de202b92c9fcb039539a7e48a39a80f5
-SIZE (dahdi-fw-hx8-2.06.tar.gz) = 29252
-SHA256 (dahdi-fwload-vpmadt032-1.25.0.tar.gz) = 3ff26cf80555fd7470b43a87c51d03c1db2a75abcd4561d79f69b6c48298e4a1
-SIZE (dahdi-fwload-vpmadt032-1.25.0.tar.gz) = 149360
diff --git a/misc/dahdi-kmod/files/dahdi.in b/misc/dahdi-kmod/files/dahdi.in
deleted file mode 100644
index 6122bba0f387..000000000000
--- a/misc/dahdi-kmod/files/dahdi.in
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/bin/sh
-
-# PROVIDE: dahdi
-# REQUIRE: NETWORKING
-# KEYWORD: shutdown
-# BEFORE: asterisk
-#
-# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
-# to enable this service:
-#
-# dahdi_enable (bool): YES/NO (default: NO)
-# dahdi_modules (list of strings): dahdi modules to load at boot (default: dahdi)
-#
-# Valid modules are:
-# - dahdi
-# - dahdi_transcode
-# - wcb4xxp
-# - wcfxo
-# - wct4xxp
-# - wctc4xxp
-# - wctdm
-# - wctdm24xxp
-# - wcte11xp
-# - wcte12xp
-#
-# Example:
-#
-# dahdi_enable="YES"
-# dahdi_modules="wct4xxp"
-#
-
-. /etc/rc.subr
-
-name="dahdi"
-rcvar=dahdi_enable
-
-start_cmd="dahdi_start"
-stop_cmd="dahdi_stop"
-load_rc_config $name
-: ${dahdi_enable="NO"}
-: ${dahdi_modules="dahdi"}
-
-kmod_dir=%%PREFIX%%/lib/dahdi
-# reverse list
-for m in ${dahdi_modules}; do
- dahdi_modules_unload="$m ${dahdi_modules_unload}"
-done
-
-dahdi_start()
-{
- echo "Starting ${name}."
-
- # load kernel modules
- kldconfig -mf ${kmod_dir}
- for m in ${dahdi_modules}; do
- kldload $m || exit 1
- done
-
- # configure devfs
- devfs rule apply path 'dahdi/*' mode 0664 user root group dahdi
-
- # run configuration utilities
- /bin/sleep 5
- %%PREFIX%%/sbin/dahdi_cfg
- if [ -r %%PREFIX%%/etc/fxotune.conf ]; then
- echo "Starting fxotune."
- %%PREFIX%%/sbin/fxotune -s
- fi
-}
-
-dahdi_stop()
-{
- echo -n " ${name}"
- for m in ${dahdi_modules_unload}; do
- kldunload $m
- done
-}
-
-run_rc_command "$1"
diff --git a/misc/dahdi-kmod/files/patch-bchan b/misc/dahdi-kmod/files/patch-bchan
deleted file mode 100644
index 4aa35a8b8163..000000000000
--- a/misc/dahdi-kmod/files/patch-bchan
+++ /dev/null
@@ -1,170 +0,0 @@
-# Translate the D channels to a standard channel data.
-# The HFC chipset provides us the D channel as data, but
-# Zaptel expects it as a standard channel with 1000 samples
-# per second.
-
-Index: freebsd/include/dahdi/dahdi_config.h
-===================================================================
---- freebsd/include/dahdi/dahdi_config.h (revision 8781)
-+++ freebsd/include/dahdi/dahdi_config.h (working copy)
-@@ -180,7 +180,13 @@
- */
- /* #define OPTIMIZE_CHANMUTE */
-
-+/*
-+ * Uncomment the following for BRI D channels
-+ *
-+ */
-+#define CONFIG_DAHDI_BRI_DCHANS
-
-+
- /*
- * Pass DAHDI_AUDIOMODE to channel driver as well
- */
-Index: freebsd/include/dahdi/kernel.h
-===================================================================
---- freebsd/include/dahdi/kernel.h (revision 8781)
-+++ freebsd/include/dahdi/kernel.h (working copy)
-@@ -426,6 +426,13 @@
- int statcount;
- int lastnumbufs;
- #endif
-+#ifdef CONFIG_DAHDI_BRI_DCHANS
-+ int bytes2receive;
-+ int maxbytes2transmit; /* size of the tx buffer in the card driver */
-+ int bytes2transmit;
-+ int eofrx;
-+ int eoftx;
-+#endif
- spinlock_t lock;
- char name[40];
- /* Specified by DAHDI */
-@@ -738,6 +745,9 @@
- DAHDI_FLAGBIT_LOOPED = 18, /*!< Loopback the receive data from the channel to the transmit */
- DAHDI_FLAGBIT_MTP2 = 19, /*!< Repeats last message in buffer and also discards repeating messages sent to us */
- DAHDI_FLAGBIT_HDLC56 = 20, /*!< Sets the given channel (if in HDLC mode) to use 56K HDLC instead of 64K */
-+#if defined(CONFIG_DAHDI_BRI_DCHANS)
-+ DAHDI_FLAGBIT_BRIDCHAN = 21, /*!< hardhdlc-like handling of the D channel */
-+#endif
- };
-
- struct dahdi_count {
-@@ -788,6 +798,7 @@
- #define DAHDI_FLAG_LOOPED DAHDI_FLAG(LOOPED)
- #define DAHDI_FLAG_MTP2 DAHDI_FLAG(MTP2)
- #define DAHDI_FLAG_HDLC56 DAHDI_FLAG(HDLC56)
-+#define DAHDI_FLAG_BRIDCHAN DAHDI_FLAG(BRIDCHAN)
-
- struct dahdi_span {
- spinlock_t lock;
-Index: freebsd/drivers/dahdi/dahdi-base.c
-===================================================================
---- freebsd/drivers/dahdi/dahdi-base.c (revision 8860)
-+++ freebsd/drivers/dahdi/dahdi-base.c (working copy)
-@@ -6884,11 +6881,40 @@
- *(txb++) = fasthdlc_tx_run_nocheck(&ms->txhdlc);
- }
- bytes -= left;
-+#ifdef CONFIG_DAHDI_BRI_DCHANS
-+ } else if (test_bit(DAHDI_FLAGBIT_BRIDCHAN, &ms->flags)) {
-+ /*
-+ * Let's get this right, we want to transmit complete frames only.
-+ * The card driver will do the dirty HDLC work for us.
-+ * txb (transmit buffer) is supposed to be big enough to store one frame
-+ * we will make this as big as the D fifo (1KB or 2KB)
-+ */
-+
-+ /* there are 'left' bytes in the user buffer left to transmit */
-+ left = ms->writen[ms->outwritebuf] - ms->writeidx[ms->outwritebuf] - 2;
-+ if (left > ms->maxbytes2transmit) {
-+ memcpy(txb, buf + ms->writeidx[ms->outwritebuf], ms->maxbytes2transmit);
-+ ms->writeidx[ms->outwritebuf] += ms->maxbytes2transmit;
-+ txb += ms->maxbytes2transmit;
-+ ms->bytes2transmit = ms->maxbytes2transmit;
-+ ms->eoftx = 0;
-+ } else {
-+ memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
-+ ms->writeidx[ms->outwritebuf] += left + 2;
-+ txb += left + 2;
-+ ms->bytes2transmit = left;
-+ ms->eoftx = 1;
-+ }
-+ bytes = 0;
-+#endif
- } else {
- memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
- ms->writeidx[ms->outwritebuf]+=left;
- txb += left;
- bytes -= left;
-+#if defined(CONFIG_DAHDI_BRI_DCHANS)
-+ ms->bytes2transmit=DAHDI_CHUNKSIZE;
-+#endif
- }
- /* Check buffer status */
- if (ms->writeidx[ms->outwritebuf] >= ms->writen[ms->outwritebuf]) {
-@@ -6947,6 +6973,17 @@
- /* Transmit a flag if this is an HDLC channel */
- if (ms->flags & DAHDI_FLAG_HDLC)
- fasthdlc_tx_frame_nocheck(&ms->txhdlc);
-+#if defined(CONFIG_DAHDI_BRI_DCHANS)
-+ if (test_bit(DAHDI_FLAGBIT_BRIDCHAN, &ms->flags)) {
-+ // if (ms->bytes2transmit > 0) {
-+ // txb += 2;
-+ // ms->bytes2transmit -= 2;
-+ bytes=0;
-+ ms->eoftx = 1;
-+// printk(KERN_CRIT "zaptel EOF(%d) bytes2transmit %d\n",ms->eoftx,ms->bytes2transmit);
-+ // }
-+ }
-+#endif
- #ifdef CONFIG_DAHDI_NET
- if (ms->flags & DAHDI_FLAG_NETDEV)
- netif_wake_queue(ztchan_to_dev(ms));
-@@ -7007,6 +7044,12 @@
- memset(txb, 0xFF, bytes);
- }
- bytes = 0;
-+#if defined(CONFIG_DAHDI_BRI_DCHANS)
-+ } else if (test_bit(DAHDI_FLAGBIT_BRIDCHAN, &ms->flags)) {
-+ ms->bytes2transmit = 0;
-+ ms->eoftx = 0;
-+ bytes = 0;
-+#endif
- } else {
- memset(txb, DAHDI_LIN2X(0, ms), bytes); /* Lastly we use silence on telephony channels */
- bytes = 0;
-@@ -7905,6 +7948,14 @@
- int left, x;
-
-
-+#if defined(CONFIG_DAHDI_BRI_DCHANS)
-+ if (test_bit(DAHDI_FLAGBIT_BRIDCHAN, &ms->flags)) {
-+ bytes = ms->bytes2receive;
-+ if (bytes < 1) return;
-+// printk(KERN_CRIT "bytes2receive %d\n",ms->bytes2receive);
-+ }
-+#endif
-+
- while(bytes) {
- #if defined(CONFIG_DAHDI_NET) || defined(CONFIG_DAHDI_PPP)
- skb = NULL;
-@@ -7962,6 +8013,19 @@
- }
- }
- }
-+#ifdef CONFIG_DAHDI_BRI_DCHANS
-+ } else if (test_bit(DAHDI_FLAGBIT_BRIDCHAN, &ms->flags)) {
-+ memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
-+ rxb += left;
-+ ms->readidx[ms->inreadbuf] += left;
-+ bytes -= left;
-+ if (ms->eofrx == 1) {
-+ eof=1;
-+ }
-+// printk(KERN_CRIT "receiving %d bytes\n",ms->bytes2receive);
-+ ms->bytes2receive = 0;
-+ ms->eofrx = 0;
-+#endif
- } else {
- /* Not HDLC */
- memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
diff --git a/misc/dahdi-kmod/files/patch-clang b/misc/dahdi-kmod/files/patch-clang
deleted file mode 100644
index a93238716a13..000000000000
--- a/misc/dahdi-kmod/files/patch-clang
+++ /dev/null
@@ -1,18 +0,0 @@
---- freebsd/freebsd/wcb4xxp/Makefile.orig 2015-01-28 06:35:48.000000000 +0600
-+++ freebsd/freebsd/wcb4xxp/Makefile 2015-01-28 06:44:25.000000000 +0600
-@@ -5,5 +5,6 @@
- KMOD= wcb4xxp
- SRCS= base.c
- SRCS+= device_if.h bus_if.h pci_if.h
-+CFLAGS.clang= -Wno-unused-command-line-argument
-
- .include <bsd.kmod.mk>
---- freebsd/freebsd/wcte11xp/Makefile.orig 2015-01-28 06:44:53.000000000 +0600
-+++ freebsd/freebsd/wcte11xp/Makefile 2015-01-28 06:53:29.000000000 +0600
-@@ -6,5 +6,6 @@
- SRCS= wcte11xp.c
- SRCS+= device_if.h bus_if.h pci_if.h
- CFLAGS= --param inline-unit-growth=100
-+CFLAGS.clang= -Wno-unused-command-line-argument
-
- .include <bsd.kmod.mk>
diff --git a/misc/dahdi-kmod/files/patch-dahdi-iface b/misc/dahdi-kmod/files/patch-dahdi-iface
deleted file mode 100644
index 86501da5bfe7..000000000000
--- a/misc/dahdi-kmod/files/patch-dahdi-iface
+++ /dev/null
@@ -1,939 +0,0 @@
-Index: freebsd/include/dahdi/kernel.h
-===================================================================
---- freebsd/include/dahdi/kernel.h (revision 10321)
-+++ freebsd/include/dahdi/kernel.h (working copy)
-@@ -468,6 +468,7 @@
- struct cdev *dev; /*!< Device structure */
- struct cdev *file; /*!< File structure */
- int file_flags;
-+ struct dahdi_iface *iface;
- #else
- struct file *file; /*!< File structure */
- #endif
-@@ -1361,4 +1362,8 @@
-
- void dahdi_poll_wait(struct file *file, struct pollinfo *sel, struct poll_table_struct *wait_table);
-
-+int dahdi_net_chan_init(struct dahdi_chan *chan, int numbufs);
-+void dahdi_net_chan_destroy(struct dahdi_chan *chan);
-+void dahdi_net_chan_xmit(struct dahdi_chan *chan);
-+
- #endif /* _DAHDI_KERNEL_H */
-Index: freebsd/freebsd/dahdi/ng_dahdi_iface.c
-===================================================================
---- freebsd/freebsd/dahdi/ng_dahdi_iface.c (revision 0)
-+++ freebsd/freebsd/dahdi/ng_dahdi_iface.c (revision 10329)
-@@ -0,0 +1,605 @@
-+/*-
-+ * Copyright (c) 2011 The FreeBSD Foundation
-+ * All rights reserved.
-+ *
-+ * This software was developed by Max Khon.
-+ *
-+ * 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 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 AUTHOR 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.
-+ *
-+ * $Id$
-+ */
-+
-+#include <sys/types.h>
-+#include <sys/mbuf.h>
-+#include <sys/linker.h>
-+#include <sys/syscallsubr.h>
-+#include <sys/taskqueue.h>
-+
-+#include <netgraph/ng_message.h>
-+#include <netgraph/netgraph.h>
-+
-+#include <netinet/in.h>
-+#include <netgraph/ng_cisco.h>
-+#include <netgraph/ng_iface.h>
-+
-+#include <dahdi/kernel.h>
-+
-+#include "ng_dahdi_iface.h"
-+
-+#define module_printk(level, fmt, args...) printk(level "%s: " fmt, THIS_MODULE->name, ## args)
-+
-+#if __FreeBSD_version < 800000
-+struct ng_node *ng_name2noderef(struct ng_node *node, const char *name);
-+#endif
-+
-+#define DAHDI_IFACE_HOOK_UPPER "upper"
-+
-+static ng_rcvmsg_t ng_dahdi_iface_rcvmsg;
-+static ng_shutdown_t ng_dahdi_iface_shutdown;
-+static ng_newhook_t ng_dahdi_iface_newhook;
-+static ng_disconnect_t ng_dahdi_iface_disconnect;
-+static ng_rcvdata_t ng_dahdi_iface_rcvdata;
-+
-+static struct ng_type ng_dahdi_iface_typestruct = {
-+ .version = NG_ABI_VERSION,
-+ .name = "ng_dahdi_iface",
-+ .rcvmsg = ng_dahdi_iface_rcvmsg,
-+ .shutdown = ng_dahdi_iface_shutdown,
-+ .newhook = ng_dahdi_iface_newhook,
-+ .rcvdata = ng_dahdi_iface_rcvdata,
-+ .disconnect = ng_dahdi_iface_disconnect,
-+};
-+NETGRAPH_INIT(dahdi_iface, &ng_dahdi_iface_typestruct);
-+
-+static void dahdi_iface_rx_task(void *context, int pending);
-+
-+/**
-+ * iface struct
-+ */
-+struct dahdi_iface {
-+ struct dahdi_chan *chan; /**< dahdi master channel associated with the iface */
-+ struct taskqueue *rx_taskqueue; /**< rx task queue */
-+ struct task rx_task; /**< rx task */
-+ struct ng_node *node; /**< our netgraph node */
-+ struct ng_hook *upper; /**< our upper hook */
-+ char path[64]; /**< iface node path */
-+};
-+
-+/**
-+ * Create iface struct
-+ */
-+static struct dahdi_iface *
-+dahdi_iface_alloc(struct dahdi_chan *chan)
-+{
-+ struct dahdi_iface *iface;
-+
-+ iface = malloc(sizeof(*iface), M_DAHDI, M_WAITOK | M_ZERO);
-+ iface->chan = chan;
-+ iface->rx_taskqueue = taskqueue_create_fast("dahdi_iface_taskq", M_WAITOK,
-+ taskqueue_thread_enqueue, &iface->rx_taskqueue);
-+ taskqueue_start_threads(&iface->rx_taskqueue, 1, PI_NET, "%s taskq", chan->name);
-+ TASK_INIT(&iface->rx_task, 0, dahdi_iface_rx_task, chan);
-+ return iface;
-+}
-+
-+/**
-+ * Free iface struct
-+ */
-+static void
-+dahdi_iface_free(struct dahdi_iface *iface)
-+{
-+ taskqueue_free(iface->rx_taskqueue);
-+ free(iface, M_DAHDI);
-+}
-+
-+/**
-+ * Ensure that specified netgraph type is available
-+ */
-+static int
-+ng_ensure_type(const char *type)
-+{
-+ int error;
-+ int fileid;
-+ char filename[NG_TYPESIZ + 3];
-+
-+ if (ng_findtype(type) != NULL)
-+ return (0);
-+
-+ /* Not found, try to load it as a loadable module. */
-+ snprintf(filename, sizeof(filename), "ng_%s", type);
-+ error = kern_kldload(curthread, filename, &fileid);
-+ if (error != 0)
-+ return (-1);
-+
-+ /* See if type has been loaded successfully. */
-+ if (ng_findtype(type) == NULL) {
-+ (void)kern_kldunload(curthread, fileid, LINKER_UNLOAD_NORMAL);
-+ return (-1);
-+ }
-+
-+ return (0);
-+}
-+
-+/**
-+ * Connect hooks
-+ */
-+static void
-+dahdi_iface_connect_node_path(struct ng_node *node, const char *ourpath,
-+ const char *path, const char *ourhook, const char *peerhook)
-+{
-+ int error;
-+ struct ng_mesg *msg;
-+ struct ngm_connect *nc;
-+
-+ NG_MKMESSAGE(msg, NGM_GENERIC_COOKIE, NGM_CONNECT, sizeof(*nc), M_WAITOK);
-+ if (msg == NULL) {
-+ printf("dahdi_iface(%s): Error: can not allocate NGM_CONNECT message (ignored)\n",
-+ NG_NODE_NAME(node));
-+ return;
-+ }
-+ nc = (struct ngm_connect *) msg->data;
-+ strlcpy(nc->path, path, sizeof(nc->path));
-+ strlcpy(nc->ourhook, ourhook, sizeof(nc->ourhook));
-+ strlcpy(nc->peerhook, peerhook, sizeof(nc->peerhook));
-+ NG_SEND_MSG_PATH(error, node, msg, __DECONST(char *, ourpath), NG_NODE_ID(node));
-+ if (error) {
-+ printf("dahdi_iface(%s): Error: NGM_CONNECT(%s<->%s): error %d (ignored)\n",
-+ NG_NODE_NAME(node), ourhook, peerhook, error);
-+ return;
-+ }
-+}
-+
-+/**
-+ * Shutdown node specified by path
-+ */
-+static void
-+dahdi_iface_shutdown_node_path(struct ng_node *node, const char *path)
-+{
-+ int error;
-+ struct ng_mesg *msg;
-+
-+ if (path[0] == '\0')
-+ return;
-+
-+ NG_MKMESSAGE(msg, NGM_GENERIC_COOKIE, NGM_SHUTDOWN, 0, M_WAITOK);
-+ NG_SEND_MSG_PATH(error, node, msg, __DECONST(char *, path), NG_NODE_ID(node));
-+ if (error) {
-+ printf("dahdi_iface(%s): Error: NGM_SHUTDOWN: error %d (ignored)\n",
-+ NG_NODE_NAME(node), error);
-+ return;
-+ }
-+}
-+
-+/**
-+ * Create a netgraph node and connect it to ng_iface instance
-+ *
-+ * @return 0 on success, -1 on error
-+ */
-+int
-+dahdi_iface_create(struct dahdi_chan *chan)
-+{
-+ struct dahdi_iface *iface = NULL;
-+ struct ng_node *node;
-+ struct ng_mesg *msg;
-+ char node_name[64];
-+ int error;
-+ struct ngm_mkpeer *ngm_mkpeer;
-+
-+ /* check if DAHDI netgraph node for that device already exists */
-+ snprintf(node_name, sizeof(node_name), "dahdi@%s", chan->name);
-+ node = ng_name2noderef(NULL, node_name);
-+ if (node != NULL) {
-+ printf("dahdi_iface(%s): existing netgraph node\n", NG_NODE_NAME(node));
-+ NG_NODE_UNREF(node);
-+ return (0);
-+ }
-+
-+ /* create new network device */
-+ iface = dahdi_iface_alloc(chan);
-+ if (iface == NULL) {
-+ printf("dahdi_iface(%s): Error: Failed to create iface struct\n",
-+ node_name);
-+ return (0);
-+ }
-+ chan->iface = iface;
-+
-+ /* create new DAHDI netgraph node */
-+ if (ng_make_node_common(&ng_dahdi_iface_typestruct, &node) != 0) {
-+ printf("dahdi_iface(%s): Error: Failed to create netgraph node\n",
-+ node_name);
-+ goto error;
-+ }
-+ iface->node = node;
-+ NG_NODE_SET_PRIVATE(node, iface);
-+ if (ng_name_node(node, node_name) != 0) {
-+ printf("dahdi_iface(%s): Error: Failed to set netgraph node name\n",
-+ node_name);
-+ goto error;
-+ }
-+
-+ /* create HDLC encapsulation layer peer node */
-+ if (ng_ensure_type(NG_CISCO_NODE_TYPE) < 0) {
-+ printf("dahdi_iface(%s): Error: Failed to load %s netgraph type\n",
-+ NG_NODE_NAME(node), NG_CISCO_NODE_TYPE);
-+ goto error;
-+ }
-+
-+ NG_MKMESSAGE(msg, NGM_GENERIC_COOKIE, NGM_MKPEER, sizeof(*ngm_mkpeer), M_WAITOK);
-+ ngm_mkpeer = (struct ngm_mkpeer *) msg->data;
-+ strlcpy(ngm_mkpeer->type, NG_CISCO_NODE_TYPE, sizeof(ngm_mkpeer->type));
-+ strlcpy(ngm_mkpeer->ourhook, DAHDI_IFACE_HOOK_UPPER, sizeof(ngm_mkpeer->ourhook));
-+ strlcpy(ngm_mkpeer->peerhook, NG_CISCO_HOOK_DOWNSTREAM, sizeof(ngm_mkpeer->peerhook));
-+ NG_SEND_MSG_ID(error, node, msg, NG_NODE_ID(node), NG_NODE_ID(node));
-+ if (error) {
-+ printf("dahdi_iface(%s): Error: NGM_MKPEER: error %d (%s)\n",
-+ NG_NODE_NAME(node), error, NG_CISCO_NODE_TYPE);
-+ goto error;
-+ }
-+
-+ /* create network iface peer node */
-+ if (ng_ensure_type(NG_IFACE_NODE_TYPE) < 0) {
-+ printf("dahdi_iface(%s): Error: Failed to load %s netgraph type\n",
-+ NG_NODE_NAME(node), NG_IFACE_NODE_TYPE);
-+ goto error;
-+ }
-+
-+ NG_MKMESSAGE(msg, NGM_GENERIC_COOKIE, NGM_MKPEER, sizeof(*ngm_mkpeer), M_WAITOK);
-+ ngm_mkpeer = (struct ngm_mkpeer *) msg->data;
-+ strlcpy(ngm_mkpeer->type, NG_IFACE_NODE_TYPE, sizeof(ngm_mkpeer->type));
-+ strlcpy(ngm_mkpeer->ourhook, NG_CISCO_HOOK_INET, sizeof(ngm_mkpeer->ourhook));
-+ strlcpy(ngm_mkpeer->peerhook, NG_IFACE_HOOK_INET, sizeof(ngm_mkpeer->peerhook));
-+ NG_SEND_MSG_PATH(error, node, msg, DAHDI_IFACE_HOOK_UPPER, NG_NODE_ID(node));
-+ if (error) {
-+ printf("dahdi_iface(%s): Error: NGM_MKPEER: error %d (%s)\n",
-+ NG_NODE_NAME(node), error, NG_IFACE_NODE_TYPE);
-+ goto error;
-+ }
-+ snprintf(iface->path, sizeof(iface->path), "%s.%s",
-+ DAHDI_IFACE_HOOK_UPPER, NG_CISCO_HOOK_INET);
-+
-+ /* connect other hooks */
-+ dahdi_iface_connect_node_path(node, DAHDI_IFACE_HOOK_UPPER,
-+ NG_CISCO_HOOK_INET, NG_CISCO_HOOK_INET6, NG_IFACE_HOOK_INET6);
-+ dahdi_iface_connect_node_path(node, DAHDI_IFACE_HOOK_UPPER,
-+ NG_CISCO_HOOK_INET, NG_CISCO_HOOK_APPLETALK, NG_IFACE_HOOK_ATALK);
-+ dahdi_iface_connect_node_path(node, DAHDI_IFACE_HOOK_UPPER,
-+ NG_CISCO_HOOK_INET, NG_CISCO_HOOK_IPX, NG_IFACE_HOOK_IPX);
-+
-+ /* get iface name */
-+ NG_MKMESSAGE(msg, NGM_IFACE_COOKIE, NGM_IFACE_GET_IFNAME, 0, M_WAITOK);
-+ NG_SEND_MSG_PATH(error, node, msg, iface->path, NG_NODE_ID(node));
-+ if (error) {
-+ printf("dahdi_iface(%s): Error: NGM_MKPEER: error %d (%s)\n",
-+ NG_NODE_NAME(node), error, NG_IFACE_NODE_TYPE);
-+ goto error;
-+ }
-+
-+ printf("dahdi_iface(%s): new netgraph node\n",
-+ NG_NODE_NAME(node));
-+
-+ /* setup channel */
-+ if (dahdi_net_chan_init(chan, DAHDI_DEFAULT_NUM_BUFS * 8)) {
-+ printf("dahdi_iface(%s): Error: Failed to initialize channel\n",
-+ NG_NODE_NAME(node));
-+ goto error;
-+ }
-+
-+ return (0);
-+
-+error:
-+ if (iface != NULL) {
-+ if (iface->node != NULL) {
-+ dahdi_iface_shutdown_node_path(iface->node, iface->path);
-+ NG_NODE_UNREF(iface->node);
-+ iface->node = NULL;
-+ }
-+
-+ dahdi_iface_free(iface);
-+ chan->iface = NULL;
-+ }
-+ return (-1);
-+}
-+
-+/**
-+ * Destroy a netgraph node and ng_iface instance associated with it
-+ */
-+void
-+dahdi_iface_destroy(struct dahdi_chan *chan)
-+{
-+ struct dahdi_iface *iface;
-+
-+ if ((iface = chan->iface) == NULL || iface->node == NULL)
-+ return;
-+
-+ /* shutdown HDLC encapsulation layer peer node */
-+ if (iface->upper != NULL) {
-+ dahdi_iface_shutdown_node_path(iface->node, iface->path);
-+ dahdi_iface_shutdown_node_path(iface->node, DAHDI_IFACE_HOOK_UPPER);
-+ }
-+
-+ NG_NODE_REALLY_DIE(iface->node); /* Force real removal of node */
-+ ng_rmnode_self(iface->node);
-+
-+ dahdi_net_chan_destroy(chan);
-+ chan->iface = NULL;
-+ chan->flags &= ~DAHDI_FLAG_NETDEV;
-+}
-+
-+/**
-+ * Enqueues a task to receive the data frame from the synchronous line
-+ *
-+ * It is not possible to send the received data frame from dahdi_receive()
-+ * context because it can be run in the filter thread context and mbuf
-+ * allocation is not possible because of that.
-+ */
-+void
-+dahdi_iface_rx(struct dahdi_chan *chan)
-+{
-+ struct dahdi_iface *iface;
-+ int oldreadbuf;
-+
-+ if ((iface = chan->iface) == NULL)
-+ return;
-+
-+ /* switch buffers */
-+ if ((oldreadbuf = chan->inreadbuf) >= 0) {
-+ chan->inreadbuf = (chan->inreadbuf + 1) % chan->numbufs;
-+ if (chan->inreadbuf == chan->outreadbuf)
-+ chan->inreadbuf = -1; /* no more buffers to receive to */
-+ if (chan->outreadbuf < 0)
-+ chan->outreadbuf = oldreadbuf; /* new buffer to read from */
-+ }
-+
-+ taskqueue_enqueue_fast(iface->rx_taskqueue, &iface->rx_task);
-+}
-+
-+/**
-+ * Receive data frame from the synchronous line
-+ *
-+ * Receives data frame from the synchronous line and sends it up to the upstream.
-+ */
-+static void
-+dahdi_iface_rx_task(void *context, int pending)
-+{
-+ struct dahdi_chan *chan = context;
-+ struct dahdi_iface *iface;
-+ unsigned long flags;
-+ int oldreadbuf;
-+
-+ if ((iface = chan->iface) == NULL)
-+ return;
-+
-+ spin_lock_irqsave(&chan->lock, flags);
-+ while ((oldreadbuf = chan->outreadbuf) >= 0) {
-+ struct mbuf *m = NULL;
-+
-+ /* read frame */
-+ if (iface->upper != NULL && chan->readn[chan->outreadbuf] > 1) {
-+
-+ /* Drop the FCS */
-+ chan->readn[chan->outreadbuf] -= 2;
-+
-+ MGETHDR(m, M_NOWAIT, MT_DATA);
-+ if (m != NULL) {
-+ if (chan->readn[chan->outreadbuf] >= MINCLSIZE) {
-+ MCLGET(m, M_NOWAIT);
-+ }
-+
-+ /* copy data */
-+ m_append(m, chan->readn[chan->outreadbuf], chan->readbuf[chan->outreadbuf]);
-+ }
-+ }
-+
-+ /* switch buffers */
-+ chan->readn[chan->outreadbuf] = 0;
-+ chan->readidx[chan->outreadbuf] = 0;
-+ chan->outreadbuf = (chan->outreadbuf + 1) % chan->numbufs;
-+ if (chan->outreadbuf == chan->inreadbuf)
-+ chan->outreadbuf = -1; /* no more buffers to read from */
-+ if (chan->inreadbuf < 0)
-+ chan->inreadbuf = oldreadbuf; /* new buffer to read to */
-+
-+ if (m != NULL) {
-+ int error;
-+
-+ spin_unlock_irqrestore(&chan->lock, flags);
-+ NG_SEND_DATA_ONLY(error, iface->upper, m);
-+ spin_lock_irqsave(&chan->lock, flags);
-+ }
-+ }
-+ spin_unlock_irqrestore(&chan->lock, flags);
-+}
-+
-+/**
-+ * Abort receiving a data frame
-+ */
-+void
-+dahdi_iface_abort(struct dahdi_chan *chan, int event)
-+{
-+ /* nothing to do */
-+#if 0
-+ module_printk(KERN_DEBUG, "%s: event %d\n", __func__, event);
-+#endif
-+}
-+
-+/**
-+ * Wake up transmitter
-+ */
-+void
-+dahdi_iface_wakeup_tx(struct dahdi_chan *chan)
-+{
-+ /* XXX not implemented */
-+}
-+
-+/**
-+ * Receive an incoming control message
-+ */
-+static int
-+ng_dahdi_iface_rcvmsg(struct ng_node *node, struct ng_item *item, struct ng_hook *lasthook)
-+{
-+ /* struct dahdi_iface *iface = NG_NODE_PRIVATE(node); */
-+ struct ng_mesg *msg, *resp = NULL;
-+ int error = 0;
-+
-+ NGI_GET_MSG(item, msg);
-+ switch (msg->header.typecookie) {
-+ case NGM_IFACE_COOKIE:
-+ switch (msg->header.cmd) {
-+ case NGM_IFACE_GET_IFNAME:
-+ printf("dahdi_iface(%s): interface %s\n",
-+ NG_NODE_NAME(node), msg->data);
-+ break;
-+ default:
-+ error = EINVAL;
-+ break;
-+ }
-+ break;
-+ default:
-+ error = EINVAL;
-+ break;
-+ }
-+ NG_RESPOND_MSG(error, node, item, resp);
-+ NG_FREE_MSG(msg);
-+ return (error);
-+}
-+
-+/**
-+ * Shutdown node
-+ *
-+ * Reset the node but does not remove it unless the REALLY_DIE flag is set.
-+ */
-+static int
-+ng_dahdi_iface_shutdown(struct ng_node *node)
-+{
-+ struct dahdi_iface *iface = NG_NODE_PRIVATE(node);
-+
-+ if (node->nd_flags & NGF_REALLY_DIE) {
-+ /* destroy the node itself */
-+ printf("dahdi_iface(%s): destroying netgraph node\n",
-+ NG_NODE_NAME(node));
-+ NG_NODE_SET_PRIVATE(node, NULL);
-+ NG_NODE_UNREF(node);
*** 1873 LINES SKIPPED ***