From Jesper Peterson:
[obnox/wireshark/wip.git] / xdlc.h
1 /* xdlc.h
2  * Define *DLC frame types, and routine to dissect the control field of
3  * a *DLC frame.
4  *
5  * $Id: xdlc.h,v 1.17 2002/08/28 21:00:41 jmayer Exp $
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@zing.org>
9  * Copyright 1998 Gerald Combs
10  *
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifndef __XDLC_H__
28 #define __XDLC_H__
29
30 /*
31  * Low-order bits of first (extended) or only (basic) octet of control
32  * field, specifying the frame type.
33  */
34 #define XDLC_I          0x00    /* Information frames */
35 #define XDLC_S          0x01    /* Supervisory frames */
36 #define XDLC_U          0x03    /* Unnumbered frames */
37
38 /*
39  * U-format modifiers.
40  */
41 #define XDLC_U_MODIFIER_MASK    0xEC
42 #define XDLC_UI         0x00    /* Unnumbered Information */
43 #define XDLC_UP         0x20    /* Unnumbered Poll */
44 #define XDLC_DISC       0x40    /* Disconnect (command) */
45 #define XDLC_RD         0x40    /* Request Disconnect (response) */
46 #define XDLC_UA         0x60    /* Unnumbered Acknowledge */
47 #define XDLC_SNRM       0x80    /* Set Normal Response Mode */
48 #define XDLC_TEST       0xE0    /* Test */
49 #define XDLC_SIM        0x04    /* Set Initialization Mode (command) */
50 #define XDLC_RIM        0x04    /* Request Initialization Mode (response) */
51 #define XDLC_FRMR       0x84    /* Frame reject */
52 #define XDLC_CFGR       0xC4    /* Configure */
53 #define XDLC_SARM       0x0C    /* Set Asynchronous Response Mode (command) */
54 #define XDLC_DM         0x0C    /* Disconnected mode (response) */
55 #define XDLC_SABM       0x2C    /* Set Asynchronous Balanced Mode */
56 #define XDLC_SARME      0x4C    /* Set Asynchronous Response Mode Extended */
57 #define XDLC_SABME      0x6C    /* Set Asynchronous Balanced Mode Extended */
58 #define XDLC_RESET      0x8C    /* Reset */
59 #define XDLC_XID        0xAC    /* Exchange identification */
60 #define XDLC_SNRME      0xCC    /* Set Normal Response Mode Extended */
61 #define XDLC_BCN        0xEC    /* Beacon */
62
63 /*
64  * This macro takes the control field of an xDLC frame, as returned by
65  * "get_xdlc_control()" or "dissect_xdlc_control()", and evaluates to
66  * TRUE if the frame is an "information" frame and FALSE if it isn't.
67  * Note that frames other than information frames can have data in them,
68  * e.g. TEST frames.
69  */
70 #define XDLC_IS_INFORMATION(control) \
71         (((control) & 0x1) == XDLC_I || (control) == (XDLC_UI|XDLC_U))
72
73 /*
74  * This macro takes the control field of an xDLC frame, and a flag saying
75  * whether we're doing basic or extended operation, and evaluates to
76  * the length of that field (if it's an Unnumbered frame, or we're not
77  * in extended mode, it's 1 byte long, otherwise it's 2 bytes long).
78  */
79 #define XDLC_CONTROL_LEN(control, is_extended) \
80         ((((control) & 0x3) == XDLC_U || !(is_extended)) ? 1 : 2)
81
82 int get_xdlc_control(const guchar *pd, int offset,
83   int extended);
84
85 int dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
86   proto_tree *xdlc_tree, int hf_xdlc_control, gint ett_xdlc_control,
87   int is_response, int extended);
88
89 #endif