From owner-dev-commits-src-all@freebsd.org Thu Sep 30 02:00:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B7D596A8531; Thu, 30 Sep 2021 02:00:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HKbzf4sKfz3pDk; Thu, 30 Sep 2021 02:00:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8661522FB7; Thu, 30 Sep 2021 02:00:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 18U20EoV084734; Thu, 30 Sep 2021 02:00:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18U20EZD084710; Thu, 30 Sep 2021 02:00:14 GMT (envelope-from git) Date: Thu, 30 Sep 2021 02:00:14 GMT Message-Id: <202109300200.18U20EZD084710@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 79a100e28e3c - main - bluetooth: complete removal of ng_h4 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 79a100e28e3c814773bb4c1826cfa25fbe31140e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Sep 2021 02:00:14 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=79a100e28e3c814773bb4c1826cfa25fbe31140e commit 79a100e28e3c814773bb4c1826cfa25fbe31140e Author: Warner Losh AuthorDate: 2021-09-05 18:41:16 +0000 Commit: Warner Losh CommitDate: 2021-09-30 02:00:02 +0000 bluetooth: complete removal of ng_h4 The ng_h4 module was disconnected 13 years ago when the tty later was locked by Ed. It completely fails to compile, and has a number of false positives for Giant use. Remove it for lack of interest. Bluetooth has largely (completely?) moved on from bluetooth over UART transport. OK'd by: emax Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D31846 --- ObsoleteFiles.inc | 3 + share/man/man4/Makefile | 1 - share/man/man4/netgraph.4 | 3 +- share/man/man4/ng_h4.4 | 123 --- share/man/man5/bluetooth.device.conf.5 | 3 +- sys/conf/files | 1 - sys/modules/netgraph/bluetooth/h4/Makefile | 12 - sys/netgraph/bluetooth/drivers/h4/TODO | 13 - sys/netgraph/bluetooth/drivers/h4/ng_h4.c | 1020 ------------------------ sys/netgraph/bluetooth/drivers/h4/ng_h4_prse.h | 125 --- sys/netgraph/bluetooth/drivers/h4/ng_h4_var.h | 104 --- sys/netgraph/bluetooth/include/ng_h4.h | 114 --- 12 files changed, 5 insertions(+), 1517 deletions(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index 19e0428a5017..4a0d2fe1b7ea 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -40,6 +40,9 @@ # xargs -n1 | sort | uniq -d; # done +# 20210929: Remove ng_h4 +OLD_FILES+=usr/share/man/man4/ng_h4.4.gz + # 20210923: rename boot(9) to kern_reboot(9) OLD_FILES+=usr/share/man/man9/boot.9.gz diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 4dad9b11ec22..421de8728a05 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -353,7 +353,6 @@ MAN= aac.4 \ ng_frame_relay.4 \ ng_gif.4 \ ng_gif_demux.4 \ - ng_h4.4 \ ng_hci.4 \ ng_hole.4 \ ng_hub.4 \ diff --git a/share/man/man4/netgraph.4 b/share/man/man4/netgraph.4 index 6b850e27762a..bed412193f6b 100644 --- a/share/man/man4/netgraph.4 +++ b/share/man/man4/netgraph.4 @@ -36,7 +36,7 @@ .\" $Whistle: netgraph.4,v 1.7 1999/01/28 23:54:52 julian Exp $ .\" $FreeBSD$ .\" -.Dd January 9, 2021 +.Dd September 29, 2021 .Dt NETGRAPH 4 .Os .Sh NAME @@ -1433,7 +1433,6 @@ common networking problems, solved using .Xr ng_frame_relay 4 , .Xr ng_gif 4 , .Xr ng_gif_demux 4 , -.Xr ng_h4 4 , .Xr ng_hci 4 , .Xr ng_hole 4 , .Xr ng_hub 4 , diff --git a/share/man/man4/ng_h4.4 b/share/man/man4/ng_h4.4 deleted file mode 100644 index bb539a230eba..000000000000 --- a/share/man/man4/ng_h4.4 +++ /dev/null @@ -1,123 +0,0 @@ -.\" Copyright (c) 2001-2002 Maksim Yevmenkin -.\" 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 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: ng_h4.4,v 1.2 2003/05/21 19:37:35 max Exp $ -.\" $FreeBSD$ -.\" -.Dd June 14, 2002 -.Dt NG_H4 4 -.Os -.Sh NAME -.Nm ng_h4 -.Nd Netgraph node type that is also an H4 line discipline -.Sh SYNOPSIS -.In sys/types.h -.In netgraph/bluetooth/include/ng_h4.h -.Sh DESCRIPTION -The -.Nm h4 -node type is both a persistent Netgraph node type and a H4 line -discipline. -It implements a Bluetooth HCI UART transport layer as -per chapter H4 of the Bluetooth Specification Book v1.1. -A new node is created when the corresponding line discipline, -.Dv H4DISC , -is registered on a tty device (see -.Xr tty 4 ) . -.Pp -The node has a single hook called -.Dv hook . -Incoming bytes received on the tty device are re-assembled into -HCI frames (according to the length). -Full HCI frames are sent out on the hook. -HCI frames received on -.Dv hook -are transmitted out on the tty device. -No modification to the data is performed in either direction. -While the line discipline is installed on a tty, the normal -read and write operations are unavailable, returning -.Er EIO . -.Pp -Information about the node is available via the netgraph -.Xr ioctl 2 -command -.Dv NGIOCGINFO . -This command returns a -.Vt "struct nodeinfo" -similar to the -.Dv NGM_NODEINFO -.Xr netgraph 4 -control message. -.Sh HOOKS -This node type supports the following hooks: -.Bl -tag -width ".Va hook" -.It Va hook -single HCI frame contained in single -.Vt mbuf -structure. -.El -.Sh CONTROL MESSAGES -This node type supports the generic control messages, plus the following: -.Bl -tag -width foo -.It Dv NGM_H4_NODE_RESET -Reset the node. -.It Dv NGM_H4_NODE_GET_STATE -Returns current receiving state for the node. -.It Dv NGM_H4_NODE_GET_DEBUG -Returns an integer containing the current debug level for the node. -.It Dv NGM_H4_NODE_SET_DEBUG -This command takes an integer argument and sets current debug level -for the node. -.It Dv NGM_H4_NODE_GET_QLEN -Returns current length of outgoing queue for the node. -.It Dv NGM_H4_NODE_SET_QLEN -This command takes an integer argument and sets maximum length of -outgoing queue for the node. -.It Dv NGM_H4_NODE_GET_STAT -Returns various statistic information for the node, such as: number of -bytes (frames) sent, number of bytes (frames) received and number of -input (output) errors. -.It Dv NGM_H4_NODE_RESET_STAT -Reset all statistic counters to zero. -.El -.Sh SHUTDOWN -This node shuts down when the corresponding device is closed -(or the line discipline is uninstalled on the device). -.Sh SEE ALSO -.Xr ioctl 2 , -.Xr netgraph 4 , -.Xr tty 4 , -.Xr ngctl 8 -.Sh HISTORY -The -.Nm h4 -node type was implemented in -.Fx 5.0 . -.Sh AUTHORS -.An Maksim Yevmenkin Aq Mt m_evmenkin@yahoo.com -.Sh BUGS -This node still uses -.Xr spltty 9 -to lock tty layer. -This is wrong. diff --git a/share/man/man5/bluetooth.device.conf.5 b/share/man/man5/bluetooth.device.conf.5 index 681bbd693146..f2f5bcdc8685 100644 --- a/share/man/man5/bluetooth.device.conf.5 +++ b/share/man/man5/bluetooth.device.conf.5 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 9, 2021 +.Dd September 29, 2021 .Dt BLUETOOTH.DEVICE.CONF 5 .Os .Sh NAME @@ -173,7 +173,6 @@ The file should be used to specify configuration parameters overrides for the second USB Bluetooth device. .Sh SEE ALSO -.Xr ng_h4 4 , .Xr ng_hci 4 , .Xr ng_l2cap 4 , .Xr ng_ubt 4 , diff --git a/sys/conf/files b/sys/conf/files index 828953628eda..fd91666f3718 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -4253,7 +4253,6 @@ netgraph/atm/sscop/ng_sscop.c optional ngatm_sscop \ netgraph/atm/uni/ng_uni.c optional ngatm_uni \ compile-with "${NORMAL_C} -I$S/contrib/ngatm" netgraph/bluetooth/common/ng_bluetooth.c optional netgraph_bluetooth -netgraph/bluetooth/drivers/h4/ng_h4.c optional netgraph_bluetooth_h4 netgraph/bluetooth/drivers/ubt/ng_ubt.c optional netgraph_bluetooth_ubt usb netgraph/bluetooth/drivers/ubt/ng_ubt_intel.c optional netgraph_bluetooth_ubt usb netgraph/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c optional netgraph_bluetooth_ubtbcmfw usb diff --git a/sys/modules/netgraph/bluetooth/h4/Makefile b/sys/modules/netgraph/bluetooth/h4/Makefile deleted file mode 100644 index 808f44c9dd2c..000000000000 --- a/sys/modules/netgraph/bluetooth/h4/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# $Id: Makefile,v 1.1 2002/11/24 20:40:04 max Exp $ -# $FreeBSD$ - -.PATH: ${SRCTOP}/sys/netgraph/bluetooth/drivers/h4 - -CFLAGS+= -I${SRCTOP}/sys/netgraph/bluetooth/include \ - -I${SRCTOP}/sys/netgraph/bluetooth/drivers/h4 - -KMOD= ng_h4 -SRCS= ng_h4.c - -.include diff --git a/sys/netgraph/bluetooth/drivers/h4/TODO b/sys/netgraph/bluetooth/drivers/h4/TODO deleted file mode 100644 index 0862688c19d9..000000000000 --- a/sys/netgraph/bluetooth/drivers/h4/TODO +++ /dev/null @@ -1,13 +0,0 @@ -$Id: TODO,v 1.2 2004/08/23 18:08:15 max Exp $ -$FreeBSD$ - -FIXME/TODO list - -This is a list of open issues for H4 node - -1) Locking/SMP - - External code now uses ng_send_fn to inject data into Netgraph, but - i still use splXXX to lock tty level. this is wrong and should be - fixed! - diff --git a/sys/netgraph/bluetooth/drivers/h4/ng_h4.c b/sys/netgraph/bluetooth/drivers/h4/ng_h4.c deleted file mode 100644 index 11560b7c6681..000000000000 --- a/sys/netgraph/bluetooth/drivers/h4/ng_h4.c +++ /dev/null @@ -1,1020 +0,0 @@ -/* - * ng_h4.c - */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001-2002 Maksim Yevmenkin - * 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 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: ng_h4.c,v 1.10 2005/10/31 17:57:43 max Exp $ - * $FreeBSD$ - * - * Based on: - * --------- - * - * FreeBSD: src/sys/netgraph/ng_tty.c - * Author: Archie Cobbs - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/***************************************************************************** - ***************************************************************************** - ** This node implements a Bluetooth HCI UART transport layer as per chapter - ** H4 of the Bluetooth Specification Book v1.1. It is a terminal line - ** discipline that is also a netgraph node. Installing this line discipline - ** on a terminal device instantiates a new netgraph node of this type, which - ** allows access to the device via the "hook" hook of the node. - ** - ** Once the line discipline is installed, you can find out the name of the - ** corresponding netgraph node via a NGIOCGINFO ioctl(). - ***************************************************************************** - *****************************************************************************/ - -/* MALLOC define */ -#ifndef NG_SEPARATE_MALLOC -MALLOC_DEFINE(M_NETGRAPH_H4, "netgraph_h4", "Netgraph Bluetooth H4 node"); -#else -#define M_NETGRAPH_H4 M_NETGRAPH -#endif /* NG_SEPARATE_MALLOC */ - -/* Line discipline methods */ -static int ng_h4_open (struct cdev *, struct tty *); -static int ng_h4_close (struct tty *, int); -static int ng_h4_read (struct tty *, struct uio *, int); -static int ng_h4_write (struct tty *, struct uio *, int); -static int ng_h4_input (int, struct tty *); -static int ng_h4_start (struct tty *); -static int ng_h4_ioctl (struct tty *, u_long, caddr_t, - int, struct thread *); - -/* Line discipline descriptor */ -static struct linesw ng_h4_disc = { - ng_h4_open, /* open */ - ng_h4_close, /* close */ - ng_h4_read, /* read */ - ng_h4_write, /* write */ - ng_h4_ioctl, /* ioctl */ - ng_h4_input, /* input */ - ng_h4_start, /* start */ - ttymodem /* modem */ -}; - -/* Netgraph methods */ -static ng_constructor_t ng_h4_constructor; -static ng_rcvmsg_t ng_h4_rcvmsg; -static ng_shutdown_t ng_h4_shutdown; -static ng_newhook_t ng_h4_newhook; -static ng_connect_t ng_h4_connect; -static ng_rcvdata_t ng_h4_rcvdata; -static ng_disconnect_t ng_h4_disconnect; - -/* Other stuff */ -static void ng_h4_process_timeout (node_p, hook_p, void *, int); -static int ng_h4_mod_event (module_t, int, void *); - -/* Netgraph node type descriptor */ -static struct ng_type typestruct = { - .version = NG_ABI_VERSION, - .name = NG_H4_NODE_TYPE, - .mod_event = ng_h4_mod_event, - .constructor = ng_h4_constructor, - .rcvmsg = ng_h4_rcvmsg, - .shutdown = ng_h4_shutdown, - .newhook = ng_h4_newhook, - .connect = ng_h4_connect, - .rcvdata = ng_h4_rcvdata, - .disconnect = ng_h4_disconnect, - .cmdlist = ng_h4_cmdlist -}; -NETGRAPH_INIT(h4, &typestruct); -MODULE_VERSION(ng_h4, NG_BLUETOOTH_VERSION); - -static int ng_h4_node = 0; - -/***************************************************************************** - ***************************************************************************** - ** Line discipline methods - ***************************************************************************** - *****************************************************************************/ - -/* - * Set our line discipline on the tty. - */ - -static int -ng_h4_open(struct cdev *dev, struct tty *tp) -{ - struct thread *td = curthread; - char name[NG_NODESIZ]; - ng_h4_info_p sc = NULL; - int error; - - /* Super-user only */ - error = priv_check(td, PRIV_NETGRAPH_TTY); /* XXX */ - if (error != 0) - return (error); - - /* Initialize private struct */ - sc = malloc(sizeof(*sc), M_NETGRAPH_H4, M_NOWAIT|M_ZERO); - if (sc == NULL) - return (ENOMEM); - - sc->tp = tp; - sc->debug = NG_H4_WARN_LEVEL; - - sc->state = NG_H4_W4_PKT_IND; - sc->want = 1; - sc->got = 0; - - mtx_init(&sc->outq.ifq_mtx, "ng_h4 node+queue", NULL, MTX_DEF); - IFQ_SET_MAXLEN(&sc->outq, NG_H4_DEFAULTQLEN); - ng_callout_init(&sc->timo); - - NG_H4_LOCK(sc); - - /* Setup netgraph node */ - error = ng_make_node_common(&typestruct, &sc->node); - if (error != 0) { - NG_H4_UNLOCK(sc); - - printf("%s: Unable to create new node!\n", __func__); - - mtx_destroy(&sc->outq.ifq_mtx); - bzero(sc, sizeof(*sc)); - free(sc, M_NETGRAPH_H4); - - return (error); - } - - /* Assign node its name */ - snprintf(name, sizeof(name), "%s%d", typestruct.name, ng_h4_node ++); - - error = ng_name_node(sc->node, name); - if (error != 0) { - NG_H4_UNLOCK(sc); - - printf("%s: %s - node name exists?\n", __func__, name); - - NG_NODE_UNREF(sc->node); - mtx_destroy(&sc->outq.ifq_mtx); - bzero(sc, sizeof(*sc)); - free(sc, M_NETGRAPH_H4); - - return (error); - } - - /* Set back pointers */ - NG_NODE_SET_PRIVATE(sc->node, sc); - tp->t_lsc = (caddr_t) sc; - - /* The node has to be a WRITER because data can change node status */ - NG_NODE_FORCE_WRITER(sc->node); - - /* - * Pre-allocate cblocks to the an appropriate amount. - * I'm not sure what is appropriate. - */ - - ttyflush(tp, FREAD | FWRITE); - clist_alloc_cblocks(&tp->t_canq, 0, 0); - clist_alloc_cblocks(&tp->t_rawq, 0, 0); - clist_alloc_cblocks(&tp->t_outq, - MLEN + NG_H4_HIWATER, MLEN + NG_H4_HIWATER); - - NG_H4_UNLOCK(sc); - - return (error); -} /* ng_h4_open */ - -/* - * Line specific close routine, called from device close routine - * and from ttioctl. This causes the node to be destroyed as well. - */ - -static int -ng_h4_close(struct tty *tp, int flag) -{ - ng_h4_info_p sc = (ng_h4_info_p) tp->t_lsc; - - ttyflush(tp, FREAD | FWRITE); - clist_free_cblocks(&tp->t_outq); - - if (sc != NULL) { - NG_H4_LOCK(sc); - - if (callout_pending(&sc->timo)) - ng_uncallout(&sc->timo, sc->node); - - tp->t_lsc = NULL; - sc->dying = 1; - - NG_H4_UNLOCK(sc); - - ng_rmnode_self(sc->node); - } - - return (0); -} /* ng_h4_close */ - -/* - * Once the device has been turned into a node, we don't allow reading. - */ - -static int -ng_h4_read(struct tty *tp, struct uio *uio, int flag) -{ - return (EIO); -} /* ng_h4_read */ - -/* - * Once the device has been turned into a node, we don't allow writing. - */ - -static int -ng_h4_write(struct tty *tp, struct uio *uio, int flag) -{ - return (EIO); -} /* ng_h4_write */ - -/* - * We implement the NGIOCGINFO ioctl() defined in ng_message.h. - */ - -static int -ng_h4_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, - struct thread *td) -{ - ng_h4_info_p sc = (ng_h4_info_p) tp->t_lsc; - int error = 0; - - if (sc == NULL) - return (ENXIO); - - NG_H4_LOCK(sc); - - switch (cmd) { - case NGIOCGINFO: -#undef NI -#define NI(x) ((struct nodeinfo *)(x)) - - bzero(data, sizeof(*NI(data))); - - if (NG_NODE_HAS_NAME(sc->node)) - strncpy(NI(data)->name, NG_NODE_NAME(sc->node), - sizeof(NI(data)->name) - 1); - - strncpy(NI(data)->type, sc->node->nd_type->name, - sizeof(NI(data)->type) - 1); - - NI(data)->id = (u_int32_t) ng_node2ID(sc->node); - NI(data)->hooks = NG_NODE_NUMHOOKS(sc->node); - break; - - default: - error = ENOIOCTL; - break; - } - - NG_H4_UNLOCK(sc); - - return (error); -} /* ng_h4_ioctl */ - -/* - * Receive data coming from the device. We get one character at a time, which - * is kindof silly. - */ - -static int -ng_h4_input(int c, struct tty *tp) -{ - ng_h4_info_p sc = (ng_h4_info_p) tp->t_lsc; - - if (sc == NULL || tp != sc->tp || - sc->node == NULL || NG_NODE_NOT_VALID(sc->node)) - return (0); - - NG_H4_LOCK(sc); - - /* Check for error conditions */ - if ((tp->t_state & TS_CONNECTED) == 0) { - NG_H4_INFO("%s: %s - no carrier\n", __func__, - NG_NODE_NAME(sc->node)); - - sc->state = NG_H4_W4_PKT_IND; - sc->want = 1; - sc->got = 0; - - NG_H4_UNLOCK(sc); - - return (0); /* XXX Loss of synchronization here! */ - } - - /* Check for framing error or overrun on this char */ - if (c & TTY_ERRORMASK) { - NG_H4_ERR("%s: %s - line error %#x, c=%#x\n", __func__, - NG_NODE_NAME(sc->node), c & TTY_ERRORMASK, - c & TTY_CHARMASK); - - NG_H4_STAT_IERROR(sc->stat); - - sc->state = NG_H4_W4_PKT_IND; - sc->want = 1; - sc->got = 0; - - NG_H4_UNLOCK(sc); - - return (0); /* XXX Loss of synchronization here! */ - } - - NG_H4_STAT_BYTES_RECV(sc->stat, 1); - - /* Append char to mbuf */ - if (sc->got >= sizeof(sc->ibuf)) { - NG_H4_ALERT("%s: %s - input buffer overflow, c=%#x, got=%d\n", - __func__, NG_NODE_NAME(sc->node), c & TTY_CHARMASK, - sc->got); - - NG_H4_STAT_IERROR(sc->stat); - - sc->state = NG_H4_W4_PKT_IND; - sc->want = 1; - sc->got = 0; - - NG_H4_UNLOCK(sc); - - return (0); /* XXX Loss of synchronization here! */ - } - - sc->ibuf[sc->got ++] = (c & TTY_CHARMASK); - - NG_H4_INFO("%s: %s - got char %#x, want=%d, got=%d\n", __func__, - NG_NODE_NAME(sc->node), c, sc->want, sc->got); - - if (sc->got < sc->want) { - NG_H4_UNLOCK(sc); - - return (0); /* Wait for more */ - } - - switch (sc->state) { - /* Got packet indicator */ - case NG_H4_W4_PKT_IND: - NG_H4_INFO("%s: %s - got packet indicator %#x\n", __func__, - NG_NODE_NAME(sc->node), sc->ibuf[0]); - - sc->state = NG_H4_W4_PKT_HDR; - - /* - * Since packet indicator included in the packet header - * just set sc->want to sizeof(packet header). - */ - - switch (sc->ibuf[0]) { - case NG_HCI_ACL_DATA_PKT: - sc->want = sizeof(ng_hci_acldata_pkt_t); - break; - - case NG_HCI_SCO_DATA_PKT: - sc->want = sizeof(ng_hci_scodata_pkt_t); - break; - - case NG_HCI_EVENT_PKT: - sc->want = sizeof(ng_hci_event_pkt_t); - break; - - default: - NG_H4_WARN("%s: %s - ignoring unknown packet " \ - "type=%#x\n", __func__, NG_NODE_NAME(sc->node), - sc->ibuf[0]); - - NG_H4_STAT_IERROR(sc->stat); - - sc->state = NG_H4_W4_PKT_IND; - sc->want = 1; - sc->got = 0; - break; - } - break; - - /* Got packet header */ - case NG_H4_W4_PKT_HDR: - sc->state = NG_H4_W4_PKT_DATA; - - switch (sc->ibuf[0]) { - case NG_HCI_ACL_DATA_PKT: - c = le16toh(((ng_hci_acldata_pkt_t *) - (sc->ibuf))->length); - break; - - case NG_HCI_SCO_DATA_PKT: - c = ((ng_hci_scodata_pkt_t *)(sc->ibuf))->length; - break; - - case NG_HCI_EVENT_PKT: - c = ((ng_hci_event_pkt_t *)(sc->ibuf))->length; - break; - - default: - KASSERT((0), ("Invalid packet type=%#x\n", - sc->ibuf[0])); - break; - } - - NG_H4_INFO("%s: %s - got packet header, packet type=%#x, " \ - "packet size=%d, payload size=%d\n", __func__, - NG_NODE_NAME(sc->node), sc->ibuf[0], sc->got, c); - - if (c > 0) { - sc->want += c; - - /* - * Try to prevent possible buffer overrun - * - * XXX I'm *really* confused here. It turns out - * that Xircom card sends us packets with length - * greater then 512 bytes! This is greater then - * our old receive buffer (ibuf) size. In the same - * time the card demands from us *not* to send - * packets greater then 192 bytes. Weird! How the - * hell i should know how big *receive* buffer - * should be? For now increase receiving buffer - * size to 1K and add the following check. - */ - - if (sc->want >= sizeof(sc->ibuf)) { - int b; - - NG_H4_ALERT("%s: %s - packet too big for " \ - "buffer, type=%#x, got=%d, want=%d, " \ - "length=%d\n", __func__, - NG_NODE_NAME(sc->node), sc->ibuf[0], - sc->got, sc->want, c); - - NG_H4_ALERT("Packet header:\n"); - for (b = 0; b < sc->got; b++) - NG_H4_ALERT("%#x ", sc->ibuf[b]); - NG_H4_ALERT("\n"); - - /* Reset state */ - NG_H4_STAT_IERROR(sc->stat); - - sc->state = NG_H4_W4_PKT_IND; - sc->want = 1; - sc->got = 0; - } - - break; - } - - /* else FALLTHROUGH and deliver frame */ - /* XXX Is this true? Should we deliver empty frame? */ - - /* Got packet data */ - case NG_H4_W4_PKT_DATA: - NG_H4_INFO("%s: %s - got full packet, packet type=%#x, " \ - "packet size=%d\n", __func__, - NG_NODE_NAME(sc->node), sc->ibuf[0], sc->got); - - if (sc->hook != NULL && NG_HOOK_IS_VALID(sc->hook)) { - struct mbuf *m = NULL; - - MGETHDR(m, M_NOWAIT, MT_DATA); - if (m != NULL) { - m->m_pkthdr.len = 0; - - /* XXX m_copyback() is stupid */ - m->m_len = min(MHLEN, sc->got); - - m_copyback(m, 0, sc->got, sc->ibuf); - NG_SEND_DATA_ONLY(c, sc->hook, m); - } else { - NG_H4_ERR("%s: %s - could not get mbuf\n", - __func__, NG_NODE_NAME(sc->node)); - - NG_H4_STAT_IERROR(sc->stat); - } - } - - sc->state = NG_H4_W4_PKT_IND; - sc->want = 1; - sc->got = 0; - - NG_H4_STAT_PCKTS_RECV(sc->stat); - break; - - default: - KASSERT((0), ("Invalid H4 node state=%d", sc->state)); - break; - } - - NG_H4_UNLOCK(sc); - - return (0); -} /* ng_h4_input */ - -/* - * This is called when the device driver is ready for more output. Called from - * tty system. - */ - -static int -ng_h4_start(struct tty *tp) -{ - ng_h4_info_p sc = (ng_h4_info_p) tp->t_lsc; - struct mbuf *m = NULL; - int size; - - if (sc == NULL || tp != sc->tp || - sc->node == NULL || NG_NODE_NOT_VALID(sc->node)) - return (0); - -#if 0 - while (tp->t_outq.c_cc < NG_H4_HIWATER) { /* XXX 2.2 specific ? */ -#else - while (1) { -#endif - /* Remove first mbuf from queue */ - IF_DEQUEUE(&sc->outq, m); - if (m == NULL) - break; - - /* Send as much of it as possible */ - while (m != NULL) { - size = m->m_len - b_to_q(mtod(m, u_char *), - m->m_len, &tp->t_outq); - - NG_H4_LOCK(sc); - NG_H4_STAT_BYTES_SENT(sc->stat, size); - NG_H4_UNLOCK(sc); - - m->m_data += size; - m->m_len -= size; - if (m->m_len > 0) - break; /* device can't take no more */ - - m = m_free(m); - } - - /* Put remainder of mbuf chain (if any) back on queue */ - if (m != NULL) { - IF_PREPEND(&sc->outq, m); - break; - } - - /* Full packet has been sent */ - NG_H4_LOCK(sc); - NG_H4_STAT_PCKTS_SENT(sc->stat); - NG_H4_UNLOCK(sc); - } - - /* - * Call output process whether or not there is any output. We are - * being called in lieu of ttstart and must do what it would. - */ - - tt_oproc(sc->tp); - - /* - * This timeout is needed for operation on a pseudo-tty, because the - * pty code doesn't call pppstart after it has drained the t_outq. - */ - - NG_H4_LOCK(sc); - - if (!IFQ_IS_EMPTY(&sc->outq) && !callout_pending(&sc->timo)) - ng_callout(&sc->timo, sc->node, NULL, 1, - ng_h4_process_timeout, NULL, 0); - - NG_H4_UNLOCK(sc); - - return (0); -} /* ng_h4_start */ - -/***************************************************************************** - ***************************************************************************** - ** Netgraph node methods - ***************************************************************************** - *****************************************************************************/ - -/* - * Initialize a new node of this type. We only allow nodes to be created as - * a result of setting the line discipline on a tty, so always return an error - * if not. - */ - -static int -ng_h4_constructor(node_p node) -{ - return (EOPNOTSUPP); -} /* ng_h4_constructor */ - -/* - * Add a new hook. There can only be one. - */ - -static int -ng_h4_newhook(node_p node, hook_p hook, const char *name) -{ - ng_h4_info_p sc = (ng_h4_info_p) NG_NODE_PRIVATE(node); - - if (strcmp(name, NG_H4_HOOK) != 0) - return (EINVAL); - - NG_H4_LOCK(sc); - - if (sc->hook != NULL) { - NG_H4_UNLOCK(sc); - return (EISCONN); - } - sc->hook = hook; - - NG_H4_UNLOCK(sc); - - return (0); -} /* ng_h4_newhook */ - -/* - * Connect hook. Just say yes. - */ - -static int -ng_h4_connect(hook_p hook) -{ - ng_h4_info_p sc = (ng_h4_info_p) NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); - - if (hook != sc->hook) - panic("%s: hook != sc->hook\n", __func__); - - NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook)); - NG_HOOK_FORCE_QUEUE(hook); - - return (0); *** 681 LINES SKIPPED ***