1/* Copyright (C) 1997-2025 Free Software Foundation, Inc.
  2   This file is part of the GNU C Library.
  3
  4   The GNU C Library is free software; you can redistribute it and/or
  5   modify it under the terms of the GNU Lesser General Public
  6   License as published by the Free Software Foundation; either
  7   version 2.1 of the License, or (at your option) any later version.
  8
  9   The GNU C Library is distributed in the hope that it will be useful,
 10   but WITHOUT ANY WARRANTY; without even the implied warranty of
 11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12   Lesser General Public License for more details.
 13
 14   You should have received a copy of the GNU Lesser General Public
 15   License along with the GNU C Library; if not, see
 16   <https://www.gnu.org/licenses/>.  */
 17
 18#ifndef _NETINET_IF_TR_H
 19#define	_NETINET_IF_TR_H 1
 20
 21#include <sys/types.h>
 22#include <stdint.h>
 23
 24/* IEEE 802.5 Token-Ring magic constants.  The frame sizes omit the preamble
 25   and FCS/CRC (frame check sequence). */
 26#define TR_ALEN		6		/* Octets in one token-ring addr */
 27#define TR_HLEN 	(sizeof (struct trh_hdr) + sizeof (struct trllc))
 28#define AC		0x10
 29#define LLC_FRAME 	0x40
 30
 31/* LLC and SNAP constants */
 32#define EXTENDED_SAP 	0xAA
 33#define UI_CMD       	0x03
 34
 35/* This is an Token-Ring frame header. */
 36struct trh_hdr
 37{
 38  uint8_t  ac;			/* access control field */
 39  uint8_t  fc;			/* frame control field */
 40  uint8_t  daddr[TR_ALEN];	/* destination address */
 41  uint8_t  saddr[TR_ALEN];	/* source address */
 42  uint16_t rcf;			/* route control field */
 43  uint16_t rseg[8];		/* routing registers */
 44};
 45
 46/* This is an Token-Ring LLC structure */
 47struct trllc
 48{
 49  uint8_t  dsap;		/* destination SAP */
 50  uint8_t  ssap;		/* source SAP */
 51  uint8_t  llc;			/* LLC control field */
 52  uint8_t  protid[3];		/* protocol id */
 53  uint16_t ethertype;		/* ether type field */
 54};
 55
 56/* Token-Ring statistics collection data. */
 57struct tr_statistics
 58{
 59  unsigned long rx_packets;     /* total packets received	*/
 60  unsigned long tx_packets;	/* total packets transmitted	*/
 61  unsigned long rx_bytes;	/* total bytes received   	*/
 62  unsigned long tx_bytes;	/* total bytes transmitted	*/
 63  unsigned long rx_errors;	/* bad packets received		*/
 64  unsigned long tx_errors;	/* packet transmit problems	*/
 65  unsigned long rx_dropped;	/* no space in linux buffers	*/
 66  unsigned long tx_dropped;	/* no space available in linux	*/
 67  unsigned long multicast;	/* multicast packets received	*/
 68  unsigned long transmit_collision;
 69
 70  /* detailed Token-Ring errors. See IBM Token-Ring Network
 71     Architecture for more info */
 72
 73  unsigned long line_errors;
 74  unsigned long internal_errors;
 75  unsigned long burst_errors;
 76  unsigned long A_C_errors;
 77  unsigned long abort_delimiters;
 78  unsigned long lost_frames;
 79  unsigned long recv_congest_count;
 80  unsigned long frame_copied_errors;
 81  unsigned long frequency_errors;
 82  unsigned long token_errors;
 83  unsigned long dummy1;
 84};
 85
 86/* source routing stuff */
 87#define TR_RII 			0x80
 88#define TR_RCF_DIR_BIT 		0x80
 89#define TR_RCF_LEN_MASK 	0x1f00
 90#define TR_RCF_BROADCAST 	0x8000	/* all-routes broadcast */
 91#define TR_RCF_LIMITED_BROADCAST 0xC000	/* single-route broadcast */
 92#define TR_RCF_FRAME2K 		0x20
 93#define TR_RCF_BROADCAST_MASK 	0xC000
 94#define TR_MAXRIFLEN 		18
 95
 96#ifdef __USE_MISC
 97
 98struct trn_hdr
 99{
100  uint8_t trn_ac;                /* access control field */
101  uint8_t trn_fc;                /* field control field */
102  uint8_t trn_dhost[TR_ALEN];    /* destination host */
103  uint8_t trn_shost[TR_ALEN];    /* source host */
104  uint16_t trn_rcf;              /* route control field */
105  uint16_t trn_rseg[8];          /* routing registers */
106};
107
108#endif
109
110#endif	/* netinet/if_tr.h */