if_llc.h revision 93366
193366Smdodd/*	$NetBSD: if_llc.h,v 1.12 1999/11/19 20:41:19 thorpej Exp $	*/
293366Smdodd
31541Srgrimes/*
41541Srgrimes * Copyright (c) 1988, 1993
51541Srgrimes *	The Regents of the University of California.  All rights reserved.
61541Srgrimes *
71541Srgrimes * Redistribution and use in source and binary forms, with or without
81541Srgrimes * modification, are permitted provided that the following conditions
91541Srgrimes * are met:
101541Srgrimes * 1. Redistributions of source code must retain the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer.
121541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
131541Srgrimes *    notice, this list of conditions and the following disclaimer in the
141541Srgrimes *    documentation and/or other materials provided with the distribution.
151541Srgrimes * 3. All advertising materials mentioning features or use of this software
161541Srgrimes *    must display the following acknowledgement:
171541Srgrimes *	This product includes software developed by the University of
181541Srgrimes *	California, Berkeley and its contributors.
191541Srgrimes * 4. Neither the name of the University nor the names of its contributors
201541Srgrimes *    may be used to endorse or promote products derived from this software
211541Srgrimes *    without specific prior written permission.
221541Srgrimes *
231541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
241541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
251541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
261541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
271541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
281541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
291541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
301541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
311541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
321541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
331541Srgrimes * SUCH DAMAGE.
341541Srgrimes *
3593366Smdodd *	@(#)if_llc.h	8.1 (Berkeley) 6/10/93
3650477Speter * $FreeBSD: head/sys/net/if_llc.h 93366 2002-03-29 06:58:45Z mdodd $
371541Srgrimes */
381541Srgrimes
392168Spaul#ifndef _NET_IF_LLC_H_
402168Spaul#define _NET_IF_LLC_H_
412168Spaul
421541Srgrimes/*
431541Srgrimes * IEEE 802.2 Link Level Control headers, for use in conjunction with
441541Srgrimes * 802.{3,4,5} media access control methods.
451541Srgrimes *
4693366Smdodd * Headers here do not use bit fields due to shortcommings in many
471541Srgrimes * compilers.
481541Srgrimes */
491541Srgrimes
501541Srgrimesstruct llc {
5193366Smdodd	u_int8_t llc_dsap;
5293366Smdodd	u_int8_t llc_ssap;
531541Srgrimes	union {
541541Srgrimes	    struct {
5593366Smdodd		u_int8_t control;
5693366Smdodd		u_int8_t format_id;
5793366Smdodd		u_int8_t class;
5893366Smdodd		u_int8_t window_x2;
5993366Smdodd	    } type_u __attribute__((__packed__));
601541Srgrimes	    struct {
6193366Smdodd		u_int8_t num_snd_x2;
6293366Smdodd		u_int8_t num_rcv_x2;
6393366Smdodd	    } type_i __attribute__((__packed__));
641541Srgrimes	    struct {
6593366Smdodd		u_int8_t control;
6693366Smdodd		u_int8_t num_rcv_x2;
6793366Smdodd	    } type_s __attribute__((__packed__));
681541Srgrimes	    struct {
6993366Smdodd	        u_int8_t control;
7093366Smdodd		/*
7193366Smdodd		 * We cannot put the following fields in a structure because
7293366Smdodd		 * the structure rounding might cause padding.
7393366Smdodd		 */
7493366Smdodd		u_int8_t frmr_rej_pdu0;
7593366Smdodd		u_int8_t frmr_rej_pdu1;
7693366Smdodd		u_int8_t frmr_control;
7793366Smdodd		u_int8_t frmr_control_ext;
7893366Smdodd		u_int8_t frmr_cause;
7993366Smdodd	    } type_frmr __attribute__((__packed__));
801541Srgrimes	    struct {
8193366Smdodd		u_int8_t  control;
8293366Smdodd		u_int8_t  org_code[3];
8393366Smdodd		u_int16_t ether_type;
8493366Smdodd	    } type_snap __attribute__((__packed__));
851541Srgrimes	    struct {
8693366Smdodd		u_int8_t control;
8793366Smdodd		u_int8_t control_ext;
8893366Smdodd	    } type_raw __attribute__((__packed__));
8993366Smdodd	} llc_un /* XXX __attribute__((__packed__)) ??? */;
9093366Smdodd} __attribute__((__packed__));
911541Srgrimes
9293366Smdoddstruct frmrinfo {
9393366Smdodd	u_int8_t frmr_rej_pdu0;
9493366Smdodd	u_int8_t frmr_rej_pdu1;
9593366Smdodd	u_int8_t frmr_control;
9693366Smdodd	u_int8_t frmr_control_ext;
9793366Smdodd	u_int8_t frmr_cause;
9893366Smdodd} __attribute__((__packed__));
9993366Smdodd
10093366Smdodd#define	llc_control		llc_un.type_u.control
10193366Smdodd#define	llc_control_ext		llc_un.type_raw.control_ext
10293366Smdodd#define	llc_fid			llc_un.type_u.format_id
10393366Smdodd#define	llc_class		llc_un.type_u.class
10493366Smdodd#define	llc_window		llc_un.type_u.window_x2
10593366Smdodd#define	llc_frmrinfo 		llc_un.type_frmr.frmr_rej_pdu0
10693366Smdodd#define	llc_frmr_pdu0		llc_un.type_frmr.frmr_rej_pdu0
10793366Smdodd#define	llc_frmr_pdu1		llc_un.type_frmr.frmr_rej_pdu1
10893366Smdodd#define	llc_frmr_control	llc_un.type_frmr.frmr_control
10993366Smdodd#define	llc_frmr_control_ext	llc_un.type_frmr.frmr_control_ext
11093366Smdodd#define	llc_frmr_cause		llc_un.type_frmr.frmr_cause
11193366Smdodd#define	llc_snap		llc_un.type_snap
11293366Smdodd
1131541Srgrimes/*
1141541Srgrimes * Don't use sizeof(struct llc_un) for LLC header sizes
1151541Srgrimes */
1161541Srgrimes#define LLC_ISFRAMELEN 4
1171541Srgrimes#define LLC_UFRAMELEN  3
1181541Srgrimes#define LLC_FRMRLEN    7
11993366Smdodd#define LLC_SNAPFRAMELEN 8
1201541Srgrimes
1211541Srgrimes/*
1221541Srgrimes * Unnumbered LLC format commands
1231541Srgrimes */
1241541Srgrimes#define LLC_UI		0x3
1251541Srgrimes#define LLC_UI_P	0x13
1261541Srgrimes#define LLC_DISC	0x43
1271541Srgrimes#define	LLC_DISC_P	0x53
1281541Srgrimes#define LLC_UA		0x63
1291541Srgrimes#define LLC_UA_P	0x73
1301541Srgrimes#define LLC_TEST	0xe3
1311541Srgrimes#define LLC_TEST_P	0xf3
1321541Srgrimes#define LLC_FRMR	0x87
1331541Srgrimes#define	LLC_FRMR_P	0x97
1341541Srgrimes#define LLC_DM		0x0f
1351541Srgrimes#define	LLC_DM_P	0x1f
1361541Srgrimes#define LLC_XID		0xaf
1371541Srgrimes#define LLC_XID_P	0xbf
1381541Srgrimes#define LLC_SABME	0x6f
1391541Srgrimes#define LLC_SABME_P	0x7f
1401541Srgrimes
1411541Srgrimes/*
1421541Srgrimes * Supervisory LLC commands
1431541Srgrimes */
1441541Srgrimes#define	LLC_RR		0x01
1451541Srgrimes#define	LLC_RNR		0x05
1461541Srgrimes#define	LLC_REJ		0x09
1471541Srgrimes
1481541Srgrimes/*
1491541Srgrimes * Info format - dummy only
1501541Srgrimes */
1511541Srgrimes#define	LLC_INFO	0x00
1521541Srgrimes
1531541Srgrimes/*
1541541Srgrimes * ISO PDTR 10178 contains among others
1551541Srgrimes */
1561541Srgrimes#define LLC_X25_LSAP	0x7e
1571541Srgrimes#define LLC_SNAP_LSAP	0xaa
1581541Srgrimes#define LLC_ISO_LSAP	0xfe
1591541Srgrimes
16093366Smdodd#endif /* _NET_IF_LLC_H_ */
161