1139823Simp/*- 225603Skjc * Copyright (c) 1996 Charles D. Cranor and Washington University. 325603Skjc * All rights reserved. 425603Skjc * 525603Skjc * Redistribution and use in source and binary forms, with or without 625603Skjc * modification, are permitted provided that the following conditions 725603Skjc * are met: 825603Skjc * 1. Redistributions of source code must retain the above copyright 925603Skjc * notice, this list of conditions and the following disclaimer. 1025603Skjc * 2. Redistributions in binary form must reproduce the above copyright 1125603Skjc * notice, this list of conditions and the following disclaimer in the 1225603Skjc * documentation and/or other materials provided with the distribution. 1325603Skjc * 3. All advertising materials mentioning features or use of this software 1425603Skjc * must display the following acknowledgement: 1525603Skjc * This product includes software developed by Charles D. Cranor and 1625603Skjc * Washington University. 1725603Skjc * 4. The name of the author may not be used to endorse or promote products 1825603Skjc * derived from this software without specific prior written permission. 1925603Skjc * 2025603Skjc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2125603Skjc * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2225603Skjc * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2325603Skjc * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2425603Skjc * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2525603Skjc * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2625603Skjc * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2725603Skjc * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2825603Skjc * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2925603Skjc * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30165900Srwatson * 31165900Srwatson * $NetBSD: natm.h,v 1.1 1996/07/04 03:20:12 chuck Exp $ 32165900Srwatson * $FreeBSD$ 3325603Skjc */ 3425603Skjc 3525603Skjc/* 3625603Skjc * natm.h: native mode atm 3725603Skjc */ 3825603Skjc 3925603Skjc/* 4025603Skjc * supported protocols 4125603Skjc */ 42118541Sharti#define PROTO_NATMAAL0 1 43118541Sharti#define PROTO_NATMAAL5 2 4425603Skjc 4525603Skjc/* 4625603Skjc * sockaddr_natm 4725603Skjc */ 4825603Skjc 4925603Skjcstruct sockaddr_natm { 50118541Sharti unsigned char snatm_len; /* length */ 51118541Sharti sa_family_t snatm_family; /* AF_NATM */ 52118541Sharti char snatm_if[IFNAMSIZ]; /* interface name */ 53118541Sharti u_int16_t snatm_vci; /* vci */ 54118541Sharti u_int8_t snatm_vpi; /* vpi */ 5525603Skjc}; 5625603Skjc 5725603Skjc#ifdef _KERNEL 5825603Skjc 5925603Skjc/* 6025603Skjc * natm protocol control block 6125603Skjc */ 6225603Skjcstruct natmpcb { 63118541Sharti LIST_ENTRY(natmpcb) pcblist; /* list pointers */ 64118541Sharti u_int npcb_inq; /* # of our pkts in proto q */ 65118541Sharti struct socket *npcb_socket; /* backpointer to socket */ 66118541Sharti struct ifnet *npcb_ifp; /* pointer to hardware */ 67118541Sharti struct in_addr ipaddr; /* remote IP address, if APCB_IP */ 68118541Sharti u_int16_t npcb_vci; /* VCI */ 69118541Sharti u_int8_t npcb_vpi; /* VPI */ 70118541Sharti u_int8_t npcb_flags; /* flags */ 7125603Skjc}; 7225603Skjc 7325603Skjc/* flags */ 74118541Sharti#define NPCB_FREE 0x01 /* free (not on any list) */ 75118541Sharti#define NPCB_CONNECTED 0x02 /* connected */ 76118541Sharti#define NPCB_IP 0x04 /* used by IP */ 77168776Spjd#define NPCB_DRAIN 0x08 /* destroy as soon as inq == 0 */ 7825603Skjc 7925603Skjc/* flag arg to npcb_free */ 80118541Sharti#define NPCB_REMOVE 0 /* remove from global list */ 81118541Sharti#define NPCB_DESTROY 1 /* destroy and be free */ 8225603Skjc 8360938SjakeLIST_HEAD(npcblist, natmpcb); 8425603Skjc 8525603Skjc/* global data structures */ 8625603Skjc 87148125Srwatsonextern struct mtx natm_mtx; /* global netnatm lock */ 8831885Sbdeextern struct npcblist natm_pcbs; /* global list of pcbs */ 8925603Skjc#define NATM_STAT 9025603Skjc#ifdef NATM_STAT 91118541Shartiextern u_int natm_sodropcnt; 92118541Shartiextern u_int natm_sodropbytes; /* account of droppage */ 93118541Shartiextern u_int natm_sookcnt; 94118541Shartiextern u_int natm_sookbytes; /* account of ok */ 9525603Skjc#endif 9625603Skjc 97148125Srwatson/* locking macros */ 98148125Srwatson#define NATM_LOCK_INIT() mtx_init(&natm_mtx, "natm_mtx", NULL, MTX_DEF) 99148125Srwatson#define NATM_LOCK() mtx_lock(&natm_mtx) 100148125Srwatson#define NATM_UNLOCK() mtx_unlock(&natm_mtx) 101148125Srwatson#define NATM_LOCK_ASSERT() mtx_assert(&natm_mtx, MA_OWNED) 102148125Srwatson 10325603Skjc/* external functions */ 10425603Skjc 10525603Skjc/* natm_pcb.c */ 10692745Salfredstruct natmpcb *npcb_alloc(int); 10792745Salfredvoid npcb_free(struct natmpcb *, int); 108118541Shartistruct natmpcb *npcb_add(struct natmpcb *, struct ifnet *, uint16_t, uint8_t); 10925603Skjc 11025603Skjc/* natm.c */ 11125603Skjcextern struct pr_usrreqs natm_usrreqs; 112118541Sharti 113118541Sharti#ifdef SYSCTL_HANDLER_ARGS 114118541Shartiint natm0_sysctl(SYSCTL_HANDLER_ARGS); 115118541Shartiint natm5_sysctl(SYSCTL_HANDLER_ARGS); 116118541Sharti#endif 117118541Sharti 118111888Sjlemonvoid natmintr(struct mbuf *); 11925603Skjc 12025603Skjc#endif 121