1 /*- 2 * Copyright (c) 1996 Charles D. Cranor and Washington University. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by Charles D. Cranor and 16 * Washington University. 17 * 4. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 * $NetBSD: natm.h,v 1.1 1996/07/04 03:20:12 chuck Exp $ 32 * $FreeBSD$ 33 */ 34 35 /* 36 * natm.h: native mode atm 37 */ 38 39 /* 40 * supported protocols 41 */ 42 #define PROTO_NATMAAL0 1 43 #define PROTO_NATMAAL5 2 44 45 /* 46 * sockaddr_natm 47 */ 48 49 struct sockaddr_natm { 50 unsigned char snatm_len; /* length */ 51 sa_family_t snatm_family; /* AF_NATM */ 52 char snatm_if[IFNAMSIZ]; /* interface name */ 53 u_int16_t snatm_vci; /* vci */ 54 u_int8_t snatm_vpi; /* vpi */ 55 }; 56 57 #ifdef _KERNEL 58 59 /* 60 * natm protocol control block 61 */ 62 struct natmpcb { 63 LIST_ENTRY(natmpcb) pcblist; /* list pointers */ 64 u_int npcb_inq; /* # of our pkts in proto q */ 65 struct socket *npcb_socket; /* backpointer to socket */ 66 struct ifnet *npcb_ifp; /* pointer to hardware */ 67 struct in_addr ipaddr; /* remote IP address, if APCB_IP */ 68 u_int16_t npcb_vci; /* VCI */ 69 u_int8_t npcb_vpi; /* VPI */ 70 u_int8_t npcb_flags; /* flags */ 71 }; 72 73 /* flags */ 74 #define NPCB_FREE 0x01 /* free (not on any list) */ 75 #define NPCB_CONNECTED 0x02 /* connected */ 76 #define NPCB_IP 0x04 /* used by IP */ 77 #define NPCB_DRAIN 0x08 /* destroy as soon as inq == 0 */ 78 79 /* flag arg to npcb_free */ 80 #define NPCB_REMOVE 0 /* remove from global list */ 81 #define NPCB_DESTROY 1 /* destroy and be free */ 82 83 LIST_HEAD(npcblist, natmpcb); 84 85 /* global data structures */ 86 87 extern struct mtx natm_mtx; /* global netnatm lock */ 88 extern struct npcblist natm_pcbs; /* global list of pcbs */ 89 #define NATM_STAT 90 #ifdef NATM_STAT 91 extern u_int natm_sodropcnt; 92 extern u_int natm_sodropbytes; /* account of droppage */ 93 extern u_int natm_sookcnt; 94 extern u_int natm_sookbytes; /* account of ok */ 95 #endif 96 97 /* locking macros */ 98 #define NATM_LOCK_INIT() mtx_init(&natm_mtx, "natm_mtx", NULL, MTX_DEF) 99 #define NATM_LOCK() mtx_lock(&natm_mtx) 100 #define NATM_UNLOCK() mtx_unlock(&natm_mtx) 101 #define NATM_LOCK_ASSERT() mtx_assert(&natm_mtx, MA_OWNED) 102 103 /* external functions */ 104 105 /* natm_pcb.c */ 106 struct natmpcb *npcb_alloc(int); 107 void npcb_free(struct natmpcb *, int); 108 struct natmpcb *npcb_add(struct natmpcb *, struct ifnet *, uint16_t, uint8_t); 109 110 /* natm.c */ 111 extern struct pr_usrreqs natm_usrreqs; 112 113 #ifdef SYSCTL_HANDLER_ARGS 114 int natm0_sysctl(SYSCTL_HANDLER_ARGS); 115 int natm5_sysctl(SYSCTL_HANDLER_ARGS); 116 #endif 117 118 void natmintr(struct mbuf *); 119 120 #endif 121