iso88025.h revision 74407
144165Sjulian/*
244165Sjulian * Copyright (c) 1998, Larry Lile
344165Sjulian * All rights reserved.
444165Sjulian *
544165Sjulian * For latest sources and information on this driver, please
644165Sjulian * go to http://anarchy.stdio.com.
744165Sjulian *
844165Sjulian * Questions, comments or suggestions should be directed to
944165Sjulian * Larry Lile <lile@stdio.com>.
1044165Sjulian *
1144165Sjulian * Redistribution and use in source and binary forms, with or without
1244165Sjulian * modification, are permitted provided that the following conditions
1344165Sjulian * are met:
1444165Sjulian * 1. Redistributions of source code must retain the above copyright
1544165Sjulian *    notice unmodified, this list of conditions, and the following
1644165Sjulian *    disclaimer.
1744165Sjulian * 2. Redistributions in binary form must reproduce the above copyright
1844165Sjulian *    notice, this list of conditions and the following disclaimer in the
1944165Sjulian *    documentation and/or other materials provided with the distribution.
2044165Sjulian *
2144165Sjulian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2244165Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2344165Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2444165Sjulian * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2544165Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2644165Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2744165Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2844165Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2944165Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3044165Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3144165Sjulian * SUCH DAMAGE.
3244165Sjulian *
3350477Speter * $FreeBSD: head/sys/net/iso88025.h 74407 2001-03-18 05:41:07Z mdodd $
3444165Sjulian *
3544165Sjulian * Information gathered from tokenring@freebsd, /sys/net/ethernet.h and
3644165Sjulian * the Mach token ring driver.
3744165Sjulian */
3844165Sjulian
3944165Sjulian/*
4044165Sjulian * Fundamental constants relating to iso 802.5
4144165Sjulian */
4244165Sjulian
4344165Sjulian#ifndef _NET_ISO88025_H_
4444165Sjulian#define _NET_ISO88025_H_
4544165Sjulian
4644165Sjulian/*
4758313Slile * General ISO 802.5 definitions
4844165Sjulian */
4944165Sjulian#define	ISO88025_ADDR_LEN	6
5058313Slile#define ISO88025_HDR_LEN	(ISO88025_CF_LEN + (ISO88025_ADDR_LEN * 2))
5158313Slile#define ISO88025_CF_LEN		2
5258313Slile#define RCF_LEN			2
5358313Slile#define RIF_MAX_RD		14
5458313Slile#define RIF_MAX_LEN		16
5544165Sjulian
5658313Slile#define TR_AC			0x10
5758313Slile#define TR_LLC_FRAME		0x40
5844165Sjulian
5958313Slile#define TR_4MBPS		4000000
6058313Slile#define TR_16MBPS		16000000
6158313Slile#define TR_100MBPS		100000000
6244165Sjulian
6344165Sjulian/*
6458313Slile * Source routing
6544165Sjulian */
6658313Slile#define	TR_RII			0x80
6758313Slile#define TR_RCF_BCST_MASK	0xe000
6858313Slile#define TR_RCF_LEN_MASK		0x1f00
6958313Slile#define TR_RCF_DIR		0x0080
7058313Slile#define TR_RCF_LF_MASK		0x0070
7144165Sjulian
7258313Slile#define TR_RCF_RIFLEN(x)	((ntohs(x) & TR_RCF_LEN_MASK) >> 8)
7358313Slile
7444165Sjulian/*
7558313Slile * Minimum and maximum packet payload lengths.
7644165Sjulian */
7758313Slile#define	ISO88025_MIN_LEN	0
7874407Smdodd#define	ISO88025_MAX_LEN_4	4464
7974407Smdodd#define	ISO88025_MAX_LEN_16	17960
8074407Smdodd#define	ISO88025_MAX_LEN	ISO88025_MAX_LEN_16
8144165Sjulian
8244165Sjulian/*
8344165Sjulian * A macro to validate a length with
8444165Sjulian */
8544165Sjulian#define	ISO88025_IS_VALID_LEN(foo)	\
8644165Sjulian	((foo) >= ISO88025_MIN_LEN && (foo) <= ISO88025_MAX_LEN)
8744165Sjulian
8844165Sjulian/*
8958313Slile * ISO 802.5 physical header
9044165Sjulian */
9144165Sjulianstruct iso88025_header {
9274407Smdodd	u_int8_t	ac;				    /* access control field */
9374407Smdodd	u_int8_t	fc;				    /* frame control field */
9474407Smdodd	u_int8_t	iso88025_dhost[ISO88025_ADDR_LEN];  /* destination address */
9574407Smdodd	u_int8_t	iso88025_shost[ISO88025_ADDR_LEN];  /* source address */
9674407Smdodd	u_int16_t	rcf;				    /* route control field */
9774407Smdodd	u_int16_t	rd[RIF_MAX_RD];			    /* routing designators */
9874407Smdodd} __attribute__ ((__packed__));
9944165Sjulian
10074407Smdoddstruct iso88025_rif {
10174407Smdodd	u_int16_t	rcf;				    /* route control field */
10274407Smdodd	u_int16_t	rd[RIF_MAX_RD];			    /* routing designators */
10374407Smdodd} __attribute__ ((__packed__));
10474407Smdodd
10544627Sjulianstruct iso88025_sockaddr_data {
10644627Sjulian	u_char ether_dhost[ISO88025_ADDR_LEN];
10744627Sjulian	u_char ether_shost[ISO88025_ADDR_LEN];
10844627Sjulian	u_char ac;
10944627Sjulian	u_char fc;
11044627Sjulian};
11144627Sjulian
11244165Sjulian/*
11344165Sjulian * Structure of a 48-bit iso 802.5 address.
11444165Sjulian *  ( We could also add the 16 bit addresses as a union)
11544165Sjulian */
11644165Sjulianstruct	iso88025_addr {
11744165Sjulian	u_char octet[ISO88025_ADDR_LEN];
11844165Sjulian};
11944165Sjulian
12058313Slile#define ISO88025_MAX_MTU	18000
12158313Slile#define ISO88025_DEFAULT_MTU	1500
12244165Sjulian#define senderr(e) { error = (e); goto bad;}
12344165Sjulian
12474407Smdoddvoid	iso88025_ifattach	(struct ifnet *);
12574407Smdoddvoid	iso88025_ifdetach	(struct ifnet *, int);
12674407Smdoddint	iso88025_ioctl		(struct ifnet *, int , caddr_t );
12774407Smdoddint	iso88025_output		(struct ifnet *, struct mbuf *, struct sockaddr *,
12874407Smdodd				 struct rtentry *);
12974407Smdoddvoid	iso88025_input		(struct ifnet *, struct iso88025_header *,
13074407Smdodd				 struct mbuf *);
13144165Sjulian
13244165Sjulian#endif
133