natm.h revision 25603
125603Skjc/* $NetBSD: natm.h,v 1.1 1996/07/04 03:20:12 chuck Exp $ */ 225603Skjc 325603Skjc/* 425603Skjc * 525603Skjc * Copyright (c) 1996 Charles D. Cranor and Washington University. 625603Skjc * All rights reserved. 725603Skjc * 825603Skjc * Redistribution and use in source and binary forms, with or without 925603Skjc * modification, are permitted provided that the following conditions 1025603Skjc * are met: 1125603Skjc * 1. Redistributions of source code must retain the above copyright 1225603Skjc * notice, this list of conditions and the following disclaimer. 1325603Skjc * 2. Redistributions in binary form must reproduce the above copyright 1425603Skjc * notice, this list of conditions and the following disclaimer in the 1525603Skjc * documentation and/or other materials provided with the distribution. 1625603Skjc * 3. All advertising materials mentioning features or use of this software 1725603Skjc * must display the following acknowledgement: 1825603Skjc * This product includes software developed by Charles D. Cranor and 1925603Skjc * Washington University. 2025603Skjc * 4. The name of the author may not be used to endorse or promote products 2125603Skjc * derived from this software without specific prior written permission. 2225603Skjc * 2325603Skjc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2425603Skjc * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2525603Skjc * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2625603Skjc * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2725603Skjc * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2825603Skjc * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2925603Skjc * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3025603Skjc * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3125603Skjc * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3225603Skjc * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3325603Skjc */ 3425603Skjc 3525603Skjc/* 3625603Skjc * natm.h: native mode atm 3725603Skjc */ 3825603Skjc 3925603Skjc 4025603Skjc/* 4125603Skjc * supported protocols 4225603Skjc */ 4325603Skjc 4425603Skjc#define PROTO_NATMAAL0 1 4525603Skjc#define PROTO_NATMAAL5 2 4625603Skjc 4725603Skjc/* 4825603Skjc * sockaddr_natm 4925603Skjc */ 5025603Skjc 5125603Skjcstruct sockaddr_natm { 5225603Skjc u_int8_t snatm_len; /* length */ 5325603Skjc u_int8_t snatm_family; /* AF_NATM */ 5425603Skjc char snatm_if[IFNAMSIZ]; /* interface name */ 5525603Skjc u_int16_t snatm_vci; /* vci */ 5625603Skjc u_int8_t snatm_vpi; /* vpi */ 5725603Skjc}; 5825603Skjc 5925603Skjc 6025603Skjc#if defined(__FreeBSD__) && defined(KERNEL) 6125603Skjc 6225603Skjc#ifndef _KERNEL 6325603Skjc#define _KERNEL 6425603Skjc#endif 6525603Skjc 6625603Skjc#define SPLSOFTNET() splnet() 6725603Skjc 6825603Skjc#elif defined(__NetBSD__) || defined(__OpenBSD__) 6925603Skjc 7025603Skjc#define SPLSOFTNET() splsoftnet() 7125603Skjc 7225603Skjc#endif 7325603Skjc 7425603Skjc#ifdef _KERNEL 7525603Skjc 7625603Skjc/* 7725603Skjc * natm protocol control block 7825603Skjc */ 7925603Skjc 8025603Skjcstruct natmpcb { 8125603Skjc LIST_ENTRY(natmpcb) pcblist; /* list pointers */ 8225603Skjc u_int npcb_inq; /* # of our pkts in proto q */ 8325603Skjc struct socket *npcb_socket; /* backpointer to socket */ 8425603Skjc struct ifnet *npcb_ifp; /* pointer to hardware */ 8525603Skjc struct in_addr ipaddr; /* remote IP address, if APCB_IP */ 8625603Skjc u_int16_t npcb_vci; /* VCI */ 8725603Skjc u_int8_t npcb_vpi; /* VPI */ 8825603Skjc u_int8_t npcb_flags; /* flags */ 8925603Skjc}; 9025603Skjc 9125603Skjc/* flags */ 9225603Skjc#define NPCB_FREE 0x01 /* free (not on any list) */ 9325603Skjc#define NPCB_CONNECTED 0x02 /* connected */ 9425603Skjc#define NPCB_IP 0x04 /* used by IP */ 9525603Skjc#define NPCB_DRAIN 0x08 /* destory as soon as inq == 0 */ 9625603Skjc#define NPCB_RAW 0x10 /* in 'raw' mode? */ 9725603Skjc 9825603Skjc/* flag arg to npcb_free */ 9925603Skjc#define NPCB_REMOVE 0 /* remove from global list */ 10025603Skjc#define NPCB_DESTROY 1 /* destroy and be free */ 10125603Skjc 10225603Skjc/* 10325603Skjc * NPCB_RAWCC is a hack which applies to connections in 'raw' mode. it 10425603Skjc * is used to override the sbspace() macro when you *really* don't want 10525603Skjc * to drop rcv data. the recv socket buffer size is raised to this value. 10625603Skjc * 10725603Skjc * XXX: socket buffering needs to be looked at. 10825603Skjc */ 10925603Skjc 11025603Skjc#define NPCB_RAWCC (1024*1024) /* 1MB */ 11125603Skjc 11225603SkjcLIST_HEAD(npcblist, natmpcb); 11325603Skjc 11425603Skjc/* global data structures */ 11525603Skjc 11625603Skjcstruct npcblist natm_pcbs; /* global list of pcbs */ 11725603Skjcextern struct ifqueue natmintrq; /* natm packet input queue */ 11825603Skjc#define NATM_STAT 11925603Skjc#ifdef NATM_STAT 12025603Skjcextern u_int natm_sodropcnt, 12125603Skjc natm_sodropbytes; /* account of droppage */ 12225603Skjcextern u_int natm_sookcnt, 12325603Skjc natm_sookbytes; /* account of ok */ 12425603Skjc#endif 12525603Skjc 12625603Skjc/* atm_rawioctl: kernel's version of SIOCRAWATM [for internal use only!] */ 12725603Skjcstruct atm_rawioctl { 12825603Skjc struct natmpcb *npcb; 12925603Skjc int rawvalue; 13025603Skjc}; 13125603Skjc#define SIOCXRAWATM _IOWR('a', 125, struct atm_rawioctl) 13225603Skjc 13325603Skjc/* external functions */ 13425603Skjc 13525603Skjc/* natm_pcb.c */ 13625603Skjcstruct natmpcb *npcb_alloc __P((int)); 13725603Skjcvoid npcb_free __P((struct natmpcb *, int)); 13825603Skjcstruct natmpcb *npcb_add __P((struct natmpcb *, struct ifnet *, int, int)); 13925603Skjc 14025603Skjc/* natm.c */ 14125603Skjc#if defined(__NetBSD__) || defined(__OpenBSD__) 14225603Skjcint natm_usrreq __P((struct socket *, int, struct mbuf *, 14325603Skjc struct mbuf *, struct mbuf *, struct proc *)); 14425603Skjc#elif defined(__FreeBSD__) 14525603Skjc#if __FreeBSD__ > 2 14625603Skjc/* 14725603Skjc * FreeBSD new usrreqs style appeared since 2.2. compatibility to old style 14825603Skjc * has gone since 3.0. 14925603Skjc */ 15025603Skjc#define FREEBSD_USRREQS 15125603Skjcextern struct pr_usrreqs natm_usrreqs; 15225603Skjc#else /* !( __FreeBSD__ > 2) */ 15325603Skjcint natm_usrreq __P((struct socket *, int, struct mbuf *, 15425603Skjc struct mbuf *, struct mbuf *)); 15525603Skjc#endif /* !( __FreeBSD__ > 2) */ 15625603Skjc#endif 15725603Skjcint natm0_sysctl __P((int *, u_int, void *, size_t *, void *, size_t)); 15825603Skjcint natm5_sysctl __P((int *, u_int, void *, size_t *, void *, size_t)); 15925603Skjcvoid natmintr __P((void)); 16025603Skjc 16125603Skjc#endif 162