aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>1999-08-23 22:47:13 +0000
committerGuy Harris <guy@alum.mit.edu>1999-08-23 22:47:13 +0000
commit397b2be709acf1afba6ec8455d4096ff54dab2b7 (patch)
tree86a97861f770195320f784b948fc6b3b6860efcb
parent42aba512c6d1972243b938dc181d5229e42b87f0 (diff)
The only LLC frame types that should be dissected based on their SAP or,
if the SAPs are SNAP, based on their ethertype are I frames and UI frames; others don't have payload to be dissected as belonging to other protocols. svn path=/trunk/; revision=555
-rw-r--r--packet-llc.c113
-rw-r--r--xdlc.c76
-rw-r--r--xdlc.h30
3 files changed, 154 insertions, 65 deletions
diff --git a/packet-llc.c b/packet-llc.c
index baeffc5779..819cd1b65a 100644
--- a/packet-llc.c
+++ b/packet-llc.c
@@ -2,7 +2,7 @@
* Routines for IEEE 802.2 LLC layer
* Gilbert Ramirez <gramirez@tivoli.com>
*
- * $Id: packet-llc.c,v 1.19 1999/08/10 20:05:40 guy Exp $
+ * $Id: packet-llc.c,v 1.20 1999/08/23 22:47:13 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@@ -162,29 +162,59 @@ sap_dissect_func(u_char sap) {
void
capture_llc(const u_char *pd, int offset, guint32 cap_len, packet_counts *ld) {
- guint16 etype;
int is_snap;
+ int control;
+ guint16 etype;
capture_func_t *capture;
is_snap = (pd[offset] == 0xAA) && (pd[offset+1] == 0xAA);
- if (is_snap) {
- etype = (pd[offset+6] << 8) | pd[offset+7];
- offset += 8;
- capture_ethertype(etype, offset, pd, cap_len, ld);
- }
- else {
- capture = sap_capture_func(pd[offset]);
- /* non-SNAP */
- offset += 3;
+ /*
+ * The low-order bit of the SSAP apparently determines whether this
+ * is a request or a response. (RFC 1390, "Transmission of IP and
+ * ARP over FDDI Networks", says
+ *
+ * Command frames are identified by having the low order
+ * bit of the SSAP address reset to zero. Response frames
+ * have the low order bit of the SSAP address set to one.
+ *
+ * and a page I've seen seems to imply that's part of 802.2.)
+ *
+ * XXX - that page also implies that LLC Type 2 always uses
+ * 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);
- if (capture) {
- capture(pd, offset, cap_len, ld);
+ if (is_snap) {
+ if (control == XDLC_I || control == (XDLC_U|XDLC_UI)) {
+ /*
+ * Unnumbered Information - analyze it based on
+ * the Ethernet packet type.
+ */
+ etype = (pd[offset+6] << 8) | pd[offset+7];
+ offset += 8;
+ capture_ethertype(etype, offset, pd, cap_len, ld);
}
- else {
- ld->other++;
+ }
+ else {
+ if (control == XDLC_I || control == (XDLC_U|XDLC_UI)) {
+ /*
+ * Unnumbered Information - analyze it based on
+ * the DSAP.
+ */
+ capture = sap_capture_func(pd[offset]);
+
+ /* non-SNAP */
+ offset += 3;
+
+ if (capture) {
+ capture(pd, offset, cap_len, ld);
+ }
+ else {
+ ld->other++;
+ }
}
-
}
}
@@ -193,8 +223,9 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
proto_tree *llc_tree = NULL;
proto_item *ti;
- guint16 etype;
int is_snap;
+ int control;
+ guint16 etype;
dissect_func_t *dissect;
is_snap = (pd[offset] == 0xAA) && (pd[offset+1] == 0xAA);
@@ -226,17 +257,13 @@ 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?
*/
- dissect_xdlc_control(pd, offset+2, fd, llc_tree, hf_llc_ctrl,
+ control = 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
* "dissect_xdlc_control()" put in the COL_INFO column, rather
* than overwriting it?
- *
- * XXX - we shouldn't, as far as I know, pass S frames to
- * "ethertype" or "dissect", and we may have to treat I frames
- * differently from U frames.
*/
if (is_snap) {
if (check_col(fd, COL_INFO)) {
@@ -246,10 +273,17 @@ 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]);
}
- etype = pntohs(&pd[offset+6]);
- offset += 8;
- /* w/o even checking, assume OUI is ethertype */
- ethertype(etype, offset, pd, fd, tree, llc_tree, hf_llc_type);
+ if (control == (XDLC_U|XDLC_UI)) {
+ /*
+ * Unnumbered Information - dissect it based on
+ * the Ethernet packet type.
+ */
+ etype = pntohs(&pd[offset+6]);
+ offset += 8;
+ /* w/o even checking, assume OUI is ethertype */
+ ethertype(etype, offset, pd, fd, tree, llc_tree,
+ hf_llc_type);
+ }
}
else {
if (check_col(fd, COL_INFO)) {
@@ -257,18 +291,23 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
val_to_str(pd[offset], sap_vals, "%02x"));
}
- dissect = sap_dissect_func(pd[offset]);
-
- /* non-SNAP */
- offset += 3;
-
- if (dissect) {
- dissect(pd, offset, fd, tree);
+ if (control == (XDLC_U|XDLC_UI)) {
+ /*
+ * Unnumbered Information - dissect it based on
+ * the DSAP.
+ */
+ dissect = sap_dissect_func(pd[offset]);
+
+ /* non-SNAP */
+ offset += 3;
+
+ if (dissect) {
+ dissect(pd, offset, fd, tree);
+ }
+ else {
+ dissect_data(pd, offset, fd, tree);
+ }
}
- else {
- dissect_data(pd, offset, fd, tree);
- }
-
}
}
diff --git a/xdlc.c b/xdlc.c
index 966d80cb67..896b52ab33 100644
--- a/xdlc.c
+++ b/xdlc.c
@@ -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.3 1999/08/16 05:54:32 guy Exp $
+ * $Id: xdlc.c,v 1.4 1999/08/23 22:47:13 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@@ -74,31 +74,6 @@ static const value_string stype_vals[] = {
{ 0, NULL }
};
-/*
- * 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 modifier_short_vals_cmd[] = {
{ XDLC_UI, "UI" },
{ XDLC_UP, "UP" },
@@ -184,6 +159,47 @@ static const value_string modifier_vals_resp[] = {
};
int
+get_xdlc_control(const u_char *pd, int offset, int is_response, int is_extended)
+{
+ guint16 control;
+
+ switch (pd[offset] & 0x03) {
+
+ case XDLC_S:
+ /*
+ * Supervisory frame.
+ */
+ return XDLC_S;
+
+ case XDLC_U:
+ /*
+ * Unnumbered frame.
+ *
+ * XXX - is this two octets, with a P/F bit, in HDLC extended
+ * operation? It's one octet in LLC, even though the control
+ * field of I and S frames is a 2-byte extended-operation field
+ * in LLC. Given that there are no sequence numbers in the
+ * control field of a U frame, there doesn't appear to be any
+ * need for it to be 2 bytes in extended operation.
+ */
+ 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.
+ */
+ return control & (XDLC_U_MODIFIER_MASK|0x03);
+
+ default:
+ /*
+ * Information frame.
+ */
+ return XDLC_I;
+ }
+}
+
+int
dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
proto_tree *xdlc_tree, int hf_xdlc_control,
int is_response, int is_extended)
@@ -331,7 +347,13 @@ dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
decode_boolean_bitfield(control, 0x03, 1*8,
"Unnumbered frame", NULL));
}
- return XDLC_U;
+
+ /*
+ * Return the modifier as well as the XDLC_U bits, so that
+ * our caller knows whether the packet is UI or something
+ * else.
+ */
+ return control & (XDLC_U_MODIFIER_MASK|0x03);
default:
/*
diff --git a/xdlc.h b/xdlc.h
index cbc699a37b..3f2bc0e8bf 100644
--- a/xdlc.h
+++ b/xdlc.h
@@ -2,7 +2,7 @@
* Define *DLC frame types, and routine to dissect the control field of
* a *DLC frame.
*
- * $Id: xdlc.h,v 1.1 1999/08/04 04:37:46 guy Exp $
+ * $Id: xdlc.h,v 1.2 1999/08/23 22:47:13 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@@ -32,5 +32,33 @@
#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);
+
int dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
proto_tree *xdlc_tree, int hf_xdlc_control, int is_response, int extended);