if_atm.h revision 37939
125603Skjc/*      $NetBSD: if_atm.h,v 1.7 1996/11/09 23:02:27 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 * net/if_atm.h
3725603Skjc */
3825603Skjc
3925603Skjc#if (defined(__FreeBSD__) || defined(__bsdi__)) && defined(KERNEL)
4025603Skjc#ifndef _KERNEL
4125603Skjc#define _KERNEL
4225603Skjc#endif
4325603Skjc#endif /* freebsd doesn't define _KERNEL */
4425603Skjc
4537939Skjc#ifndef NO_ATM_PVCEXT
4637939Skjc/*
4737939Skjc * ATM_PVCEXT enables PVC extention: VP/VC shaping
4837939Skjc * and PVC shadow interfaces.
4937939Skjc */
5037939Skjc#define ATM_PVCEXT	/* enable pvc extention */
5137939Skjc#endif
5237939Skjc
5325603Skjc#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
5425603Skjc#define RTALLOC1(A,B)		rtalloc1((A),(B))
5525603Skjc#elif defined(__FreeBSD__)
5625603Skjc#define RTALLOC1(A,B)		rtalloc1((A),(B),0UL)
5725603Skjc#endif
5825603Skjc
5925603Skjc/*
6025603Skjc * pseudo header for packet transmission
6125603Skjc */
6225603Skjcstruct atm_pseudohdr {
6325603Skjc  u_int8_t atm_ph[4];	/* flags+VPI+VCI1(msb)+VCI2(lsb) */
6425603Skjc};
6525603Skjc
6625603Skjc#define ATM_PH_FLAGS(X)	((X)->atm_ph[0])
6725603Skjc#define ATM_PH_VPI(X)	((X)->atm_ph[1])
6825603Skjc#define ATM_PH_VCI(X)	((((X)->atm_ph[2]) << 8) | ((X)->atm_ph[3]))
6925603Skjc#define ATM_PH_SETVCI(X,V) { \
7025603Skjc	(X)->atm_ph[2] = ((V) >> 8) & 0xff; \
7125603Skjc	(X)->atm_ph[3] = ((V) & 0xff); \
7225603Skjc}
7325603Skjc
7425603Skjc#define ATM_PH_AAL5    0x01	/* use AAL5? (0 == aal0) */
7525603Skjc#define ATM_PH_LLCSNAP 0x02	/* use the LLC SNAP encoding (iff aal5) */
7625603Skjc
7737939Skjc#ifdef ATM_PVCEXT
7837939Skjc#define ATM_PH_INERNAL  0x20	/* reserve for kernel internal use */
7937939Skjc#endif
8025603Skjc#define ATM_PH_DRIVER7  0x40	/* reserve for driver's use */
8125603Skjc#define ATM_PH_DRIVER8  0x80	/* reserve for driver's use */
8225603Skjc
8325603Skjc#define ATMMTU		9180	/* ATM MTU size for IP */
8425603Skjc				/* XXX: could be 9188 with LLC/SNAP according
8525603Skjc					to comer */
8625603Skjc
8725603Skjc/* user's ioctl hook for raw atm mode */
8825603Skjc#define SIOCRAWATM	_IOWR('a', 122, int)	/* set driver's raw mode */
8925603Skjc
9025603Skjc/* atm_pseudoioctl: turns on and off RX VCIs  [for internal use only!] */
9125603Skjcstruct atm_pseudoioctl {
9225603Skjc  struct atm_pseudohdr aph;
9325603Skjc  void *rxhand;
9425603Skjc};
9525603Skjc#define SIOCATMENA	_IOWR('a', 123, struct atm_pseudoioctl) /* enable */
9625603Skjc#define SIOCATMDIS	_IOWR('a', 124, struct atm_pseudoioctl) /* disable */
9725603Skjc
9837939Skjc#ifdef ATM_PVCEXT
9937939Skjc
10037939Skjc/* structure to control PVC transmitter */
10137939Skjcstruct pvctxreq {
10237939Skjc    /* first entry must be compatible with struct ifreq */
10337939Skjc    char pvc_ifname[IFNAMSIZ];		/* if name, e.g. "en0" */
10437939Skjc    struct atm_pseudohdr pvc_aph;	/* (flags) + vpi:vci */
10537939Skjc    struct atm_pseudohdr pvc_joint;	/* for vp shaping: another vc
10637939Skjc					   to share the shaper */
10737939Skjc    int pvc_pcr;			/* peak cell rate (shaper value) */
10837939Skjc};
10937939Skjc
11037939Skjc/* use ifioctl for now */
11137939Skjc#define SIOCSPVCTX	_IOWR('i', 95, struct pvctxreq)
11237939Skjc#define SIOCGPVCTX	_IOWR('i', 96, struct pvctxreq)
11337939Skjc#define SIOCSPVCSIF	_IOWR('i', 97, struct ifreq)
11437939Skjc#define SIOCGPVCSIF	_IOWR('i', 98, struct ifreq)
11537939Skjc
11637939Skjc#ifdef _KERNEL
11737939Skjc#define ATM_PH_PVCSIF	ATM_PH_INERNAL	/* pvc shadow interface */
11837939Skjc#endif
11937939Skjc#endif /* ATM_PVCEXT */
12037939Skjc
12125603Skjc/*
12225603Skjc * XXX forget all the garbage in if_llc.h and do it the easy way
12325603Skjc */
12425603Skjc
12525603Skjc#define ATMLLC_HDR "\252\252\3\0\0\0"
12625603Skjcstruct atmllc {
12725603Skjc  u_int8_t llchdr[6];	/* aa.aa.03.00.00.00 */
12825603Skjc  u_int8_t type[2];	/* "ethernet" type */
12925603Skjc};
13025603Skjc
13125603Skjc/* ATM_LLC macros: note type code in host byte order */
13225603Skjc#define ATM_LLC_TYPE(X) (((X)->type[0] << 8) | ((X)->type[1]))
13325603Skjc#define ATM_LLC_SETTYPE(X,V) { \
13425603Skjc	(X)->type[1] = ((V) >> 8) & 0xff; \
13525603Skjc	(X)->type[0] = ((V) & 0xff); \
13625603Skjc}
13725603Skjc
13825603Skjc#ifdef _KERNEL
13925603Skjcvoid	atm_ifattach __P((struct ifnet *));
14025603Skjcvoid	atm_input __P((struct ifnet *, struct atm_pseudohdr *,
14125603Skjc		struct mbuf *, void *));
14225603Skjcint	atm_output __P((struct ifnet *, struct mbuf *, struct sockaddr *,
14325603Skjc		struct rtentry *));
14425603Skjc#endif
14537939Skjc#ifdef ATM_PVCEXT
14637939Skjcchar *shadow2if __P((char *));
14737939Skjc#ifdef _KERNEL
14837939Skjcstruct ifnet *pvc_attach __P((struct ifnet *));
14937939Skjcint pvc_setaph __P((struct ifnet *, struct atm_pseudohdr *));
15037939Skjc#endif
15137939Skjc#endif
152