1 /* 2 * ng_h4_var.h 3 */ 4 5 /*- 6 * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com> 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * $Id: ng_h4_var.h,v 1.5 2005/10/31 17:57:43 max Exp $ 31 * $FreeBSD: head/sys/netgraph/bluetooth/drivers/h4/ng_h4_var.h 171818 2007-08-13 17:19:28Z emax $ 32 * 33 * Based on: 34 * --------- 35 * 36 * FreeBSD: src/sys/netgraph/ng_tty.h 37 * Author: Archie Cobbs <archie@freebsd.org> 38 */ 39 40 #ifndef _NETGRAPH_H4_VAR_H_ 41 #define _NETGRAPH_H4_VAR_H_ 42 43 /* 44 * Malloc declaration 45 */ 46 47 #ifndef NG_SEPARATE_MALLOC 48 #if MALLOC_DECLARE 49 MALLOC_DECLARE(M_NETGRAPH_H4); 50 #endif 51 #else 52 #define M_NETGRAPH_H4 M_NETGRAPH 53 #endif /* NG_SEPARATE_MALLOC */ 54 55 /* 56 * Debug 57 */ 58 59 #define NG_H4_ALERT if (sc->debug >= NG_H4_ALERT_LEVEL) kprintf 60 #define NG_H4_ERR if (sc->debug >= NG_H4_ERR_LEVEL) kprintf 61 #define NG_H4_WARN if (sc->debug >= NG_H4_WARN_LEVEL) kprintf 62 #define NG_H4_INFO if (sc->debug >= NG_H4_INFO_LEVEL) kprintf 63 64 #define NG_H4_HIWATER 256 /* High water mark on output */ 65 66 /* 67 * Per-node private info 68 */ 69 70 typedef struct ng_h4_info { 71 struct tty *tp; /* Terminal device */ 72 node_p node; /* Netgraph node */ 73 74 ng_h4_node_debug_ep debug; /* Debug level */ 75 ng_h4_node_state_ep state; /* State */ 76 77 ng_h4_node_stat_ep stat; 78 #define NG_H4_STAT_PCKTS_SENT(s) (s).pckts_sent ++ 79 #define NG_H4_STAT_BYTES_SENT(s, n) (s).bytes_sent += (n) 80 #define NG_H4_STAT_PCKTS_RECV(s) (s).pckts_recv ++ 81 #define NG_H4_STAT_BYTES_RECV(s, n) (s).bytes_recv += (n) 82 #define NG_H4_STAT_OERROR(s) (s).oerrors ++ 83 #define NG_H4_STAT_IERROR(s) (s).ierrors ++ 84 #define NG_H4_STAT_RESET(s) bzero(&(s), sizeof((s))) 85 86 struct ifqueue outq; /* Queue of outgoing mbuf's */ 87 #define NG_H4_DEFAULTQLEN 12 /* XXX max number of mbuf's in outq */ 88 #define NG_H4_LOCK(sc) crit_enter(); 89 #define NG_H4_UNLOCK(sc) crit_exit(); 90 91 #define NG_H4_IBUF_SIZE 1024 /* XXX must be big enough to hold full 92 frame */ 93 u_int8_t ibuf[NG_H4_IBUF_SIZE]; /* Incoming data */ 94 u_int32_t got; /* Number of bytes we have received */ 95 u_int32_t want; /* Number of bytes we want to receive */ 96 97 hook_p hook; /* Upstream hook */ 98 struct callout timo; /* See man timeout(9) */ 99 100 u_int8_t dying; /* are we dying? */ 101 } ng_h4_info_t; 102 typedef ng_h4_info_t * ng_h4_info_p; 103 104 #endif /* _NETGRAPH_H4_VAR_H_ */ 105 106