iso88025.h revision 112297
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 112297 2003-03-15 22:52:23Z 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 */ 98103844Salfred} __packed; 9944165Sjulian 10074407Smdoddstruct iso88025_rif { 10174407Smdodd u_int16_t rcf; /* route control field */ 10274407Smdodd u_int16_t rd[RIF_MAX_RD]; /* routing designators */ 103103844Salfred} __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 11296184Skbyancstruct iso88025_sockaddr_dl_data { 11396184Skbyanc u_short trld_rcf; 11496184Skbyanc u_short *trld_route[RIF_MAX_LEN]; 11596184Skbyanc}; 11696184Skbyanc 11796400Skbyanc#define ISO88025_MAX(a, b) (((a)>(b))?(a):(b)) 11896184Skbyanc#define SDL_ISO88025(s) ((struct iso88025_sockaddr_dl_data *) \ 11996203Skbyanc ((s)->sdl_data + \ 12096400Skbyanc ISO88025_MAX((s)->sdl_nlen + (s)->sdl_alen + \ 12196203Skbyanc (s)->sdl_slen, 12))) 12296184Skbyanc 12344165Sjulian/* 12444165Sjulian * Structure of a 48-bit iso 802.5 address. 12544165Sjulian * ( We could also add the 16 bit addresses as a union) 12644165Sjulian */ 12744165Sjulianstruct iso88025_addr { 12844165Sjulian u_char octet[ISO88025_ADDR_LEN]; 12944165Sjulian}; 13044165Sjulian 13158313Slile#define ISO88025_MAX_MTU 18000 13258313Slile#define ISO88025_DEFAULT_MTU 1500 13344165Sjulian 134112297Smdodd#define ISO88025_BPF_UNSUPPORTED 0 135112297Smdodd#define ISO88025_BPF_SUPPORTED 1 136112297Smdodd 137112297Smdoddvoid iso88025_ifattach (struct ifnet *, int); 13874407Smdoddvoid iso88025_ifdetach (struct ifnet *, int); 13974407Smdoddint iso88025_ioctl (struct ifnet *, int , caddr_t ); 14074407Smdoddint iso88025_output (struct ifnet *, struct mbuf *, struct sockaddr *, 14174407Smdodd struct rtentry *); 14274407Smdoddvoid iso88025_input (struct ifnet *, struct iso88025_header *, 14374407Smdodd struct mbuf *); 14444165Sjulian 14544165Sjulian#endif 146