Deleted Added
full compact
ng_tty.c (68876) ng_tty.c (69922)
1
2/*
3 * ng_tty.c
4 *
5 * Copyright (c) 1996-1999 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and

--- 22 unchanged lines hidden (view full) ---

31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 *
37 * Author: Archie Cobbs <archie@freebsd.org>
38 *
1
2/*
3 * ng_tty.c
4 *
5 * Copyright (c) 1996-1999 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and

--- 22 unchanged lines hidden (view full) ---

31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 *
37 * Author: Archie Cobbs <archie@freebsd.org>
38 *
39 * $FreeBSD: head/sys/netgraph/ng_tty.c 68876 2000-11-18 15:17:43Z dwmalone $
39 * $FreeBSD: head/sys/netgraph/ng_tty.c 69922 2000-12-12 18:52:14Z julian $
40 * $Whistle: ng_tty.c,v 1.21 1999/11/01 09:24:52 julian Exp $
41 */
42
43/*
44 * This file implements a terminal line discipline that is also a
45 * netgraph node. Installing this line discipline on a terminal device
46 * instantiates a new netgraph node of this type, which allows access
47 * to the device via the "hook" hook of the node.

--- 81 unchanged lines hidden (view full) ---

129static int ngt_input(int c, struct tty *tp);
130static int ngt_start(struct tty *tp);
131
132/* Netgraph methods */
133static ng_constructor_t ngt_constructor;
134static ng_rcvmsg_t ngt_rcvmsg;
135static ng_shutdown_t ngt_shutdown;
136static ng_newhook_t ngt_newhook;
40 * $Whistle: ng_tty.c,v 1.21 1999/11/01 09:24:52 julian Exp $
41 */
42
43/*
44 * This file implements a terminal line discipline that is also a
45 * netgraph node. Installing this line discipline on a terminal device
46 * instantiates a new netgraph node of this type, which allows access
47 * to the device via the "hook" hook of the node.

--- 81 unchanged lines hidden (view full) ---

129static int ngt_input(int c, struct tty *tp);
130static int ngt_start(struct tty *tp);
131
132/* Netgraph methods */
133static ng_constructor_t ngt_constructor;
134static ng_rcvmsg_t ngt_rcvmsg;
135static ng_shutdown_t ngt_shutdown;
136static ng_newhook_t ngt_newhook;
137static ng_connect_t ngt_connect;
137static ng_rcvdata_t ngt_rcvdata;
138static ng_disconnect_t ngt_disconnect;
139static int ngt_mod_event(module_t mod, int event, void *data);
140
141/* Other stuff */
142static void ngt_timeout(void *arg);
143
144#define ERROUT(x) do { error = (x); goto done; } while (0)

--- 16 unchanged lines hidden (view full) ---

161 NG_VERSION,
162 NG_TTY_NODE_TYPE,
163 ngt_mod_event,
164 ngt_constructor,
165 ngt_rcvmsg,
166 ngt_shutdown,
167 ngt_newhook,
168 NULL,
138static ng_rcvdata_t ngt_rcvdata;
139static ng_disconnect_t ngt_disconnect;
140static int ngt_mod_event(module_t mod, int event, void *data);
141
142/* Other stuff */
143static void ngt_timeout(void *arg);
144
145#define ERROUT(x) do { error = (x); goto done; } while (0)

--- 16 unchanged lines hidden (view full) ---

162 NG_VERSION,
163 NG_TTY_NODE_TYPE,
164 ngt_mod_event,
165 ngt_constructor,
166 ngt_rcvmsg,
167 ngt_shutdown,
168 ngt_newhook,
169 NULL,
169 NULL,
170 ngt_connect,
170 ngt_rcvdata,
171 ngt_rcvdata,
171 ngt_rcvdata,
172 ngt_disconnect,
173 NULL
174};
175NETGRAPH_INIT(tty, &typestruct);
176
177static int ngt_unit;
178static int ngt_nodeop_ok; /* OK to create/remove node */
179static int ngt_ldisc;

--- 209 unchanged lines hidden (view full) ---

389 *mtod(m, u_char *) = c;
390 m->m_data++;
391 m->m_len++;
392 m->m_pkthdr.len++;
393
394 /* Ship off mbuf if it's time */
395 if (sc->hotchar == -1 || c == sc->hotchar || m->m_len >= MHLEN) {
396 m->m_data = m->m_pktdat;
172 ngt_disconnect,
173 NULL
174};
175NETGRAPH_INIT(tty, &typestruct);
176
177static int ngt_unit;
178static int ngt_nodeop_ok; /* OK to create/remove node */
179static int ngt_ldisc;

--- 209 unchanged lines hidden (view full) ---

389 *mtod(m, u_char *) = c;
390 m->m_data++;
391 m->m_len++;
392 m->m_pkthdr.len++;
393
394 /* Ship off mbuf if it's time */
395 if (sc->hotchar == -1 || c == sc->hotchar || m->m_len >= MHLEN) {
396 m->m_data = m->m_pktdat;
397 error = ng_queue_data(sc->hook, m, NULL);
397 NG_SEND_DATA_ONLY(error, sc->hook, m);
398 sc->m = NULL;
399 }
400done:
401 splx(s);
402 return (error);
403}
404
405/*

--- 110 unchanged lines hidden (view full) ---

516 ERROUT(EISCONN);
517 sc->hook = hook;
518done:
519 splx(s);
520 return (error);
521}
522
523/*
398 sc->m = NULL;
399 }
400done:
401 splx(s);
402 return (error);
403}
404
405/*

--- 110 unchanged lines hidden (view full) ---

516 ERROUT(EISCONN);
517 sc->hook = hook;
518done:
519 splx(s);
520 return (error);
521}
522
523/*
524 * set the hooks into queueing mode (for outgoing packets)
525 */
526static int
527ngt_connect(hook_p hook)
528{
529 hook->peer->flags |= HK_QUEUE;
530 return (0);
531}
532
533/*
524 * Disconnect the hook
525 */
526static int
527ngt_disconnect(hook_p hook)
528{
529 const sc_p sc = hook->node->private;
530 int s;
531

--- 30 unchanged lines hidden (view full) ---

562}
563
564/*
565 * Receive incoming data from netgraph system. Put it on our
566 * output queue and start output if necessary.
567 */
568static int
569ngt_rcvdata(hook_p hook, struct mbuf *m, meta_p meta,
534 * Disconnect the hook
535 */
536static int
537ngt_disconnect(hook_p hook)
538{
539 const sc_p sc = hook->node->private;
540 int s;
541

--- 30 unchanged lines hidden (view full) ---

572}
573
574/*
575 * Receive incoming data from netgraph system. Put it on our
576 * output queue and start output if necessary.
577 */
578static int
579ngt_rcvdata(hook_p hook, struct mbuf *m, meta_p meta,
570 struct mbuf **ret_m, meta_p *ret_meta)
580 struct mbuf **ret_m, meta_p *ret_meta, struct ng_mesg **resp)
571{
572 const sc_p sc = hook->node->private;
573 int s, error = 0;
574
575 if (hook != sc->hook)
576 panic(__FUNCTION__);
577 NG_FREE_META(meta);
578 s = spltty();

--- 109 unchanged lines hidden ---
581{
582 const sc_p sc = hook->node->private;
583 int s, error = 0;
584
585 if (hook != sc->hook)
586 panic(__FUNCTION__);
587 NG_FREE_META(meta);
588 s = spltty();

--- 109 unchanged lines hidden ---