* Routines for IEEE 802.2 LLC layer
* Gilbert Ramirez <gram@alumni.rice.edu>
*
- * $Id: packet-llc.c,v 1.95 2002/01/21 07:36:37 guy Exp $
+ * $Id: packet-llc.c,v 1.99 2002/08/02 23:35:53 jmayer Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
# include "config.h"
#endif
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
#include <glib.h>
#include <epan/packet.h>
#include "oui.h"
#include "etypes.h"
#include "llcsaps.h"
#include "bridged_pids.h"
+#include "ppptypes.h"
#include "packet-ip.h"
#include "packet-ipx.h"
#include "packet-netbios.h"
#include "packet-llc.h"
+#define UDP_PORT_LLC1 12000
+#define UDP_PORT_LLC2 12001
+#define UDP_PORT_LLC3 12002
+#define UDP_PORT_LLC4 12003
+#define UDP_PORT_LLC5 12004
+
static int proto_llc = -1;
static int hf_llc_dsap = -1;
static int hf_llc_ssap = -1;
static dissector_handle_t tr_handle;
static dissector_handle_t data_handle;
-typedef void (capture_func_t)(const u_char *, int, int, packet_counts *);
-
-/* The SAP info is split into two tables, one value_string table and one
- * table of sap_info. This is so that the value_string can be used in the
- * header field registration.
- */
-struct sap_info {
- guint8 sap;
- capture_func_t *capture_func;
-};
-
/*
* Group/Individual bit, in the DSAP.
*/
{ 0x00, NULL }
};
-static struct sap_info saps[] = {
- { SAP_IP, capture_ip },
- { SAP_NETWARE, capture_ipx },
- { SAP_NETBIOS, capture_netbios },
- { 0x00, NULL}
-};
-
/*
* See
*
{ 0, NULL }
};
-static capture_func_t *
-sap_capture_func(u_char sap) {
- int i=0;
-
- /* look for the second record where sap == 0, which should
- * be the last record
- */
- while (saps[i].sap > 0 || i == 0) {
- if (saps[i].sap == sap) {
- return saps[i].capture_func;
- }
- i++;
- }
- return NULL;
-}
-
void
-capture_llc(const u_char *pd, int offset, int len, packet_counts *ld) {
+capture_llc(const guchar *pd, int offset, int len, packet_counts *ld) {
int is_snap;
guint16 control;
int llc_header_len;
guint32 oui;
guint16 etype;
- capture_func_t *capture;
if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
ld->other++;
* 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] & SSAP_CR_BIT,
- TRUE);
+ control = get_xdlc_control(pd, offset+2, pd[offset+1] & SSAP_CR_BIT);
llc_header_len += XDLC_CONTROL_LEN(control, TRUE);
if (is_snap)
llc_header_len += 5; /* 3 bytes of OUI, 2 bytes of protocol ID */
}
}
else {
+ /* non-SNAP */
if (XDLC_IS_INFORMATION(control)) {
- capture = sap_capture_func(pd[offset]);
+ switch (pd[offset]) {
- /* non-SNAP */
- offset += llc_header_len;
+ case SAP_IP:
+ capture_ip(pd, offset + llc_header_len, len,
+ ld);
+ break;
- if (capture) {
- capture(pd, offset, len, ld);
- }
- else {
+ case SAP_NETWARE:
+ capture_ipx(ld);
+ break;
+
+ case SAP_NETBIOS:
+ capture_netbios(ld);
+ break;
+
+ default:
ld->other++;
+ break;
}
}
}
llc_handle = find_dissector("llc");
dissector_add("wtap_encap", WTAP_ENCAP_ATM_RFC1483, llc_handle);
+ /* RFC 2043 */
+ dissector_add("ppp.protocol", PPP_LLC, llc_handle);
+ /* RFC 2353 */
+ dissector_add("udp.port", UDP_PORT_LLC1, llc_handle);
+ dissector_add("udp.port", UDP_PORT_LLC2, llc_handle);
+ dissector_add("udp.port", UDP_PORT_LLC3, llc_handle);
+ dissector_add("udp.port", UDP_PORT_LLC4, llc_handle);
+ dissector_add("udp.port", UDP_PORT_LLC5, llc_handle);
}