Allow "-w" and/or "-R" to be specified either when doing a live capture
[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.11 2000/01/07 22:05:43 guy 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 /*
28  * Low-order bits of first (extended) or only (basic) octet of control
29  * field, specifying the frame type.
30  */
31 #define XDLC_I          0x00    /* Information frames */
32 #define XDLC_S          0x01    /* Supervisory frames */
33 #define XDLC_U          0x03    /* Unnumbered frames */
34
35 /*
36  * U-format modifiers.
37  */
38 #define XDLC_U_MODIFIER_MASK    0xEC
39 #define XDLC_UI         0x00    /* Unnumbered Information */
40 #define XDLC_UP         0x20    /* Unnumbered Poll */
41 #define XDLC_DISC       0x40    /* Disconnect (command) */
42 #define XDLC_RD         0x40    /* Request Disconnect (response) */
43 #define XDLC_UA         0x60    /* Unnumbered Acknowledge */
44 #define XDLC_SNRM       0x80    /* Set Normal Response Mode */
45 #define XDLC_TEST       0xE0    /* Test */
46 #define XDLC_SIM        0x04    /* Set Initialization Mode (command) */
47 #define XDLC_RIM        0x04    /* Request Initialization Mode (response) */
48 #define XDLC_FRMR       0x84    /* Frame reject */
49 #define XDLC_CFGR       0xC4    /* Configure */
50 #define XDLC_SARM       0x0C    /* Set Asynchronous Response Mode (command) */
51 #define XDLC_DM         0x0C    /* Disconnected mode (response) */
52 #define XDLC_SABM       0x2C    /* Set Asynchronous Balanced Mode */
53 #define XDLC_SARME      0x4C    /* Set Asynchronous Response Mode Extended */
54 #define XDLC_SABME      0x6C    /* Set Asynchronous Balanced Mode Extended */
55 #define XDLC_RESET      0x8C    /* Reset */
56 #define XDLC_XID        0xAC    /* Exchange identification */
57 #define XDLC_SNRME      0xCC    /* Set Normal Response Mode Extended */
58 #define XDLC_BCN        0xEC    /* Beacon */
59
60 /*
61  * This macro takes the control field of an xDLC frame, as returned by
62  * "get_xdlc_control()" or "dissect_xdlc_control()", and evaluates to
63  * TRUE if the frame has a payload (i.e., if it's an Information or
64  * Unnumbered Information frame) and FALSE if it doesn't.
65  */
66 #define XDLC_HAS_PAYLOAD(control) \
67         (((control) & 0x1) == XDLC_I || (control) == (XDLC_UI|XDLC_U))
68
69 /*
70  * This macro takes the control field of an xDLC frame, and a flag saying
71  * whether we're doing basic or extended operation, and evaluates to
72  * the length of that field (if it's an Unnumbered frame, or we're not
73  * in extended mode, it's 1 byte long, otherwise it's 2 bytes long).
74  */
75 #define XDLC_CONTROL_LEN(control, is_extended) \
76         ((((control) & 0x3) == XDLC_U || !(is_extended)) ? 1 : 2)
77
78 int get_xdlc_control(const u_char *pd, int offset, int is_response,
79   int extended);
80
81 int dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
82   proto_tree *xdlc_tree, int hf_xdlc_control, gint ett_xdlc_control,
83   int is_response, int extended);