Have "get_xdlc_control()" and "dissect_xdlc_control()" just return a

Boolean indicating whether the frame has any payload to dissect or not.

svn path=/trunk/; revision=556
This commit is contained in:
Guy Harris 1999-08-23 23:24:36 +00:00
parent 397b2be709
commit 9fc0d3aefe
3 changed files with 59 additions and 59 deletions

View File

@ -2,7 +2,7 @@
* Routines for IEEE 802.2 LLC layer
* Gilbert Ramirez <gramirez@tivoli.com>
*
* $Id: packet-llc.c,v 1.20 1999/08/23 22:47:13 guy Exp $
* $Id: packet-llc.c,v 1.21 1999/08/23 23:24:35 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -163,7 +163,7 @@ void
capture_llc(const u_char *pd, int offset, guint32 cap_len, packet_counts *ld) {
int is_snap;
int control;
int has_payload;
guint16 etype;
capture_func_t *capture;
@ -184,13 +184,12 @@ capture_llc(const u_char *pd, int offset, guint32 cap_len, packet_counts *ld) {
* extended operation, so we don't need to determine whether
* it's basic or extended operation; is that the case?
*/
control = get_xdlc_control(pd, offset+2, pd[offset+1] & 0x01, TRUE);
has_payload = get_xdlc_control(pd, offset+2, pd[offset+1] & 0x01, TRUE);
if (is_snap) {
if (control == XDLC_I || control == (XDLC_U|XDLC_UI)) {
if (has_payload) {
/*
* Unnumbered Information - analyze it based on
* the Ethernet packet type.
* This frame has a payload to be analyzed.
*/
etype = (pd[offset+6] << 8) | pd[offset+7];
offset += 8;
@ -198,10 +197,9 @@ capture_llc(const u_char *pd, int offset, guint32 cap_len, packet_counts *ld) {
}
}
else {
if (control == XDLC_I || control == (XDLC_U|XDLC_UI)) {
if (has_payload) {
/*
* Unnumbered Information - analyze it based on
* the DSAP.
* This frame has a payload to be analyzed.
*/
capture = sap_capture_func(pd[offset]);
@ -224,7 +222,7 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
proto_tree *llc_tree = NULL;
proto_item *ti;
int is_snap;
int control;
int has_payload;
guint16 etype;
dissect_func_t *dissect;
@ -257,8 +255,8 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
* extended operation, so we don't need to determine whether
* it's basic or extended operation; is that the case?
*/
control = dissect_xdlc_control(pd, offset+2, fd, llc_tree, hf_llc_ctrl,
pd[offset+1] & 0x01, TRUE);
has_payload = dissect_xdlc_control(pd, offset+2, fd, llc_tree,
hf_llc_ctrl, pd[offset+1] & 0x01, TRUE);
/*
* XXX - do we want to append the SAP information to the stuff
@ -273,10 +271,9 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
proto_tree_add_item(llc_tree, hf_llc_oui, offset+3, 3,
pd[offset+3] << 16 | pd[offset+4] << 8 | pd[offset+5]);
}
if (control == (XDLC_U|XDLC_UI)) {
if (has_payload) {
/*
* Unnumbered Information - dissect it based on
* the Ethernet packet type.
* This frame has a payload to be analyzed.
*/
etype = pntohs(&pd[offset+6]);
offset += 8;
@ -291,10 +288,9 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
val_to_str(pd[offset], sap_vals, "%02x"));
}
if (control == (XDLC_U|XDLC_UI)) {
if (has_payload) {
/*
* Unnumbered Information - dissect it based on
* the DSAP.
* This frame has a payload to be analyzed.
*/
dissect = sap_dissect_func(pd[offset]);

59
xdlc.c
View File

@ -2,7 +2,7 @@
* Routines for use by various SDLC-derived protocols, such as HDLC
* and its derivatives LAPB, IEEE 802.2 LLC, etc..
*
* $Id: xdlc.c,v 1.4 1999/08/23 22:47:13 guy Exp $
* $Id: xdlc.c,v 1.5 1999/08/23 23:24:36 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -66,6 +66,31 @@
#define XDLC_REJ 0x08 /* Reject */
#define XDLC_SREJ 0x0C /* Selective reject */
/*
* U-format modifiers.
*/
#define XDLC_U_MODIFIER_MASK 0xEC
#define XDLC_UI 0x00 /* Unnumbered Information */
#define XDLC_UP 0x20 /* Unnumbered Poll */
#define XDLC_DISC 0x40 /* Disconnect (command) */
#define XDLC_RD 0x40 /* Request Disconnect (response) */
#define XDLC_UA 0x60 /* Unnumbered Acknowledge */
#define XDLC_SNRM 0x80 /* Set Normal Response Mode */
#define XDLC_TEST 0xC0 /* Test */
#define XDLC_SIM 0x04 /* Set Initialization Mode (command) */
#define XDLC_RIM 0x04 /* Request Initialization Mode (response) */
#define XDLC_FRMR 0x84 /* Frame reject */
#define XDLC_CFGR 0xC4 /* Configure */
#define XDLC_SARM 0x0C /* Set Asynchronous Response Mode (command) */
#define XDLC_DM 0x0C /* Disconnected mode (response) */
#define XDLC_SABM 0x2C /* Set Asynchronous Balanced Mode */
#define XDLC_SARME 0x4C /* Set Asynchronous Response Mode Extended */
#define XDLC_SABME 0x6C /* Set Asynchronous Balanced Mode Extended */
#define XDLC_RESET 0x8C /* Reset */
#define XDLC_XID 0xAC /* Exchange identification */
#define XDLC_SNRME 0xCC /* Set Normal Response Mode Extended */
#define XDLC_BCN 0xEC /* Beacon */
static const value_string stype_vals[] = {
{ XDLC_RR, "Receiver ready" },
{ XDLC_RNR, "Receiver not ready" },
@ -167,9 +192,9 @@ get_xdlc_control(const u_char *pd, int offset, int is_response, int is_extended)
case XDLC_S:
/*
* Supervisory frame.
* Supervisory frame - no higher-layer payload.
*/
return XDLC_S;
return FALSE;
case XDLC_U:
/*
@ -185,17 +210,15 @@ get_xdlc_control(const u_char *pd, int offset, int is_response, int is_extended)
control = pd[offset];
/*
* Return the modifier as well as the XDLC_U bits, so that
* our caller knows whether the packet is UI or something
* else.
* This frame has payload only if it's a UI frame.
*/
return control & (XDLC_U_MODIFIER_MASK|0x03);
return (control & XDLC_U_MODIFIER_MASK) == XDLC_UI;
default:
/*
* Information frame.
* Information frame - has higher-layer payload.
*/
return XDLC_I;
return TRUE;
}
}
@ -297,7 +320,11 @@ dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
"Supervisory frame", NULL));
}
}
return XDLC_S;
/*
* Supervisory frames have no higher-layer payload to be analyzed.
*/
return FALSE;
case XDLC_U:
/*
@ -349,11 +376,9 @@ dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
}
/*
* Return the modifier as well as the XDLC_U bits, so that
* our caller knows whether the packet is UI or something
* else.
* This frame has payload only if it's a UI frame.
*/
return control & (XDLC_U_MODIFIER_MASK|0x03);
return (control & XDLC_U_MODIFIER_MASK) == XDLC_UI;
default:
/*
@ -415,6 +440,10 @@ dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
NULL, "Information frame"));
}
}
return XDLC_I;
/*
* Information frames have higher-layer payload to be analyzed.
*/
return TRUE;
}
}

27
xdlc.h
View File

@ -2,7 +2,7 @@
* Define *DLC frame types, and routine to dissect the control field of
* a *DLC frame.
*
* $Id: xdlc.h,v 1.2 1999/08/23 22:47:13 guy Exp $
* $Id: xdlc.h,v 1.3 1999/08/23 23:24:36 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -32,31 +32,6 @@
#define XDLC_S 0x01 /* Supervisory frames */
#define XDLC_U 0x03 /* Unnumbered frames */
/*
* U-format modifiers.
*/
#define XDLC_U_MODIFIER_MASK 0xEC
#define XDLC_UI 0x00 /* Unnumbered Information */
#define XDLC_UP 0x20 /* Unnumbered Poll */
#define XDLC_DISC 0x40 /* Disconnect (command) */
#define XDLC_RD 0x40 /* Request Disconnect (response) */
#define XDLC_UA 0x60 /* Unnumbered Acknowledge */
#define XDLC_SNRM 0x80 /* Set Normal Response Mode */
#define XDLC_TEST 0xC0 /* Test */
#define XDLC_SIM 0x04 /* Set Initialization Mode (command) */
#define XDLC_RIM 0x04 /* Request Initialization Mode (response) */
#define XDLC_FRMR 0x84 /* Frame reject */
#define XDLC_CFGR 0xC4 /* Configure */
#define XDLC_SARM 0x0C /* Set Asynchronous Response Mode (command) */
#define XDLC_DM 0x0C /* Disconnected mode (response) */
#define XDLC_SABM 0x2C /* Set Asynchronous Balanced Mode */
#define XDLC_SARME 0x4C /* Set Asynchronous Response Mode Extended */
#define XDLC_SABME 0x6C /* Set Asynchronous Balanced Mode Extended */
#define XDLC_RESET 0x8C /* Reset */
#define XDLC_XID 0xAC /* Exchange identification */
#define XDLC_SNRME 0xCC /* Set Normal Response Mode Extended */
#define XDLC_BCN 0xEC /* Beacon */
int get_xdlc_control(const u_char *pd, int offset, int is_response,
int extended);