2012-01-19 02:58:53 +00:00
|
|
|
/* Routines for MAC LTE format files with context info as header.
|
|
|
|
*
|
|
|
|
* Martin Mathieson
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-12 11:23:27 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2012-01-19 02:58:53 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2012-01-19 02:58:53 +00:00
|
|
|
|
|
|
|
#include <epan/packet.h>
|
2016-01-25 01:10:20 +00:00
|
|
|
#include <epan/proto_data.h>
|
2012-01-19 02:58:53 +00:00
|
|
|
#include "packet-mac-lte.h"
|
|
|
|
|
2013-12-14 16:09:57 +00:00
|
|
|
void proto_register_mac_lte_framed(void);
|
2012-01-19 02:58:53 +00:00
|
|
|
|
|
|
|
/* Initialize the protocol and registered fields. */
|
|
|
|
static int proto_mac_lte_framed = -1;
|
|
|
|
|
|
|
|
extern int proto_mac_lte;
|
|
|
|
|
|
|
|
/* Main dissection function. */
|
2015-11-23 03:59:08 +00:00
|
|
|
static int dissect_mac_lte_framed(tvbuff_t *tvb, packet_info *pinfo,
|
|
|
|
proto_tree *tree, void* data _U_)
|
2012-01-19 02:58:53 +00:00
|
|
|
{
|
|
|
|
gint offset = 0;
|
|
|
|
struct mac_lte_info *p_mac_lte_info;
|
|
|
|
tvbuff_t *mac_tvb;
|
|
|
|
gboolean infoAlreadySet = FALSE;
|
2012-01-25 03:40:07 +00:00
|
|
|
|
|
|
|
/* Need to find enabled mac-lte dissector */
|
2012-01-19 02:58:53 +00:00
|
|
|
dissector_handle_t mac_lte_handle = find_dissector("mac-lte");
|
|
|
|
if (!mac_lte_handle) {
|
2015-11-23 03:59:08 +00:00
|
|
|
return 0;
|
2012-01-19 02:58:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Do this again on re-dissection to re-discover offset of actual PDU */
|
|
|
|
|
|
|
|
/* Needs to be at least as long as:
|
|
|
|
- fixed header bytes
|
|
|
|
- tag for data
|
|
|
|
- at least one byte of MAC PDU payload */
|
2014-11-21 14:54:59 +00:00
|
|
|
if ((size_t)tvb_reported_length_remaining(tvb, offset) < (3+2)) {
|
2015-11-23 03:59:08 +00:00
|
|
|
return 5;
|
2012-01-19 02:58:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If redissecting, use previous info struct (if available) */
|
2013-11-23 02:20:13 +00:00
|
|
|
p_mac_lte_info = (struct mac_lte_info*)p_get_proto_data(wmem_file_scope(), pinfo, proto_mac_lte, 0);
|
2012-01-19 02:58:53 +00:00
|
|
|
if (p_mac_lte_info == NULL) {
|
|
|
|
/* Allocate new info struct for this frame */
|
2013-09-15 15:11:11 +00:00
|
|
|
p_mac_lte_info = (struct mac_lte_info*)wmem_alloc0(wmem_file_scope(), sizeof(struct mac_lte_info));
|
2012-01-19 02:58:53 +00:00
|
|
|
infoAlreadySet = FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
infoAlreadySet = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Dissect the fields to populate p_mac_lte */
|
2018-04-12 13:13:50 +00:00
|
|
|
if (!dissect_mac_lte_context_fields(p_mac_lte_info, tvb, pinfo, tree, &offset)) {
|
2015-11-23 03:59:08 +00:00
|
|
|
return offset;
|
2012-01-19 02:58:53 +00:00
|
|
|
}
|
|
|
|
|
2012-01-25 03:40:07 +00:00
|
|
|
/* Store info in packet (first time) */
|
2012-01-19 02:58:53 +00:00
|
|
|
if (!infoAlreadySet) {
|
2013-11-23 02:20:13 +00:00
|
|
|
p_add_proto_data(wmem_file_scope(), pinfo, proto_mac_lte, 0, p_mac_lte_info);
|
2012-01-19 02:58:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************/
|
|
|
|
/* OK, now dissect as MAC LTE */
|
|
|
|
|
|
|
|
/* Create tvb that starts at actual MAC PDU */
|
2013-02-19 23:17:07 +00:00
|
|
|
mac_tvb = tvb_new_subset_remaining(tvb, offset);
|
2012-09-11 08:28:07 +00:00
|
|
|
call_dissector_only(mac_lte_handle, mac_tvb, pinfo, tree, NULL);
|
2015-11-23 03:59:08 +00:00
|
|
|
return tvb_captured_length(tvb);
|
2012-01-19 02:58:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void proto_register_mac_lte_framed(void)
|
|
|
|
{
|
|
|
|
/* Register protocol. */
|
|
|
|
proto_mac_lte_framed = proto_register_protocol("mac-lte-framed", "MAC-LTE-FRAMED", "mac-lte-framed");
|
|
|
|
|
|
|
|
/* Allow other dissectors to find this one by name. */
|
2015-12-09 04:04:01 +00:00
|
|
|
register_dissector("mac-lte-framed", dissect_mac_lte_framed, proto_mac_lte_framed);
|
2012-01-19 02:58:53 +00:00
|
|
|
}
|
|
|
|
|
2014-09-29 18:07:49 +00:00
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2014-09-29 18:07:49 +00:00
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|