2014-03-09 13:23:27 +00:00
|
|
|
/* packet-pdc.c
|
|
|
|
* Routines for PDC dissection
|
|
|
|
* Copyright 2014, Antony Bridle <antony.bridle@nats.co.uk>
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <config.h>
|
|
|
|
#include <epan/prefs.h>
|
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/dissectors/packet-tcp.h>
|
2014-03-17 15:54:08 +00:00
|
|
|
|
|
|
|
void proto_register_pdc(void);
|
|
|
|
void proto_reg_handoff_pdc(void);
|
|
|
|
|
2014-03-09 13:23:27 +00:00
|
|
|
/*PDC Protocol*/
|
|
|
|
#define PDC_PROCOTOL "PDC"
|
|
|
|
|
|
|
|
/* PDC version */
|
|
|
|
#define PDC_VERSION 2
|
|
|
|
|
|
|
|
#define SIMPDU 1
|
|
|
|
#define RSMPDU 2
|
|
|
|
#define DRMPDU 3
|
|
|
|
#define DTMPDU 4
|
|
|
|
#define ADMPDU 5
|
|
|
|
#define EDMPDU 6
|
|
|
|
#define AKMPDU 8
|
|
|
|
|
|
|
|
/*Variable length Parameter Codes*/
|
2014-04-01 03:12:20 +00:00
|
|
|
#define PARAM_CODE_VERSION 2
|
2014-03-09 13:23:27 +00:00
|
|
|
#define PARAM_CODE_REFERENCES 3
|
|
|
|
#define PARAM_CODE_TRANSPORT 4
|
|
|
|
|
|
|
|
/* required for the TCP split packet combining */
|
|
|
|
#define PDC_MSG_SIZE_FIELD_LENGTH 2 /* minimum amount of data to find out how big the split packet should be when recombined */
|
|
|
|
#define FRAME_HEADER_LEN 8
|
|
|
|
|
|
|
|
/* global handle for calling asterix decoder if required */
|
2014-04-01 03:12:20 +00:00
|
|
|
static dissector_handle_t asterix_handle;
|
|
|
|
|
|
|
|
static int proto_pdc = -1;
|
|
|
|
static guint gPREF_PORT_NUM_TCP = 0;
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
/*HF Declarations*/
|
|
|
|
static gint hf_pdc_len = -1;
|
|
|
|
static gint hf_pdc_mpdu_code = -1;
|
|
|
|
static gint hf_pdc_credit = -1;
|
|
|
|
static gint hf_pdc_simpdu_state = -1;
|
|
|
|
static gint hf_pdc_yr_admu_nr =-1;
|
|
|
|
static gint hf_pdc_akmpdu_mns = -1;
|
|
|
|
static gint hf_pdc_akmpdu_cdt = -1;
|
|
|
|
static gint hf_pdc_simpdu_var = -1;
|
|
|
|
static gint hf_pdc_simpdu_var_len = -1;
|
|
|
|
static gint hf_pdc_simpdu_param = -1;
|
|
|
|
static gint hf_pdc_simpdu_var_version = -1;
|
|
|
|
static gint hf_pdc_simpdu_var_REFSRC = -1;
|
|
|
|
static gint hf_pdc_simpdu_var_REFDEST = -1;
|
|
|
|
static gint hf_pdc_simpdu_var_TSEL = -1;
|
|
|
|
static gint hf_pdc_drmpdu_abort = -1;
|
|
|
|
static gint hf_pdc_drmpdu_reason = -1;
|
|
|
|
static gint hf_pdc_drmpdu_mode = -1;
|
|
|
|
static gint hf_pdc_drmpdu_init = -1;
|
|
|
|
static gint hf_pdc_dtmpdu_user_size =-1;
|
|
|
|
static gint hf_pdc_admpdu_admpdunr = -1;
|
|
|
|
static gint hf_pdc_admpdu_size = -1;
|
|
|
|
|
|
|
|
/*Tree Declarations*/
|
|
|
|
static gint ett_pdc = -1;
|
|
|
|
static gint ett_pdc_simpdu_var = -1;
|
|
|
|
|
|
|
|
|
|
|
|
/*Value String Declarations*/
|
|
|
|
static const value_string valstr_simpdu_state[] = {
|
2014-04-01 03:12:20 +00:00
|
|
|
{ 1, "Operational" },
|
|
|
|
{ 2, "Standby" },
|
|
|
|
{ 3, "Master" },
|
|
|
|
{ 4, "Slave" },
|
|
|
|
{ 5, "Single" },
|
|
|
|
{ 0, NULL }
|
2014-03-09 13:23:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string valstr_simpdu_param[] = {
|
2014-04-01 03:12:20 +00:00
|
|
|
{ 2, "Version Number" },
|
|
|
|
{ 3, "References" },
|
|
|
|
{ 4, "Transport Selector" },
|
|
|
|
{ 0, NULL }
|
2014-03-09 13:23:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string valstr_mpdus[] = {
|
2014-04-01 03:12:20 +00:00
|
|
|
{ 1, "State Information" },
|
|
|
|
{ 2, "Request State" },
|
|
|
|
{ 3, "Disconnect Request" },
|
|
|
|
{ 4, "Data" },
|
|
|
|
{ 5, "Acknowledged Data" },
|
|
|
|
{ 6, "Expedited Data" },
|
|
|
|
{ 8, "Data Acknowledgement" },
|
|
|
|
{ 0, NULL }
|
2014-03-09 13:23:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string valstr_drmpdu_abort[] = {
|
2014-04-01 03:12:20 +00:00
|
|
|
{ 0, "Orderly Release" },
|
|
|
|
{ 1, "Abortive Release" },
|
|
|
|
{ 0, NULL }
|
2014-03-09 13:23:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string valstr_drmpdu_mode[] = {
|
2014-04-01 03:12:20 +00:00
|
|
|
{ 0, "Node Shutdown" },
|
|
|
|
{ 7, "PDC Release"},
|
|
|
|
{ 0, NULL }
|
2014-03-09 13:23:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string valstr_drmpdu_initatior[] = {
|
2014-04-01 03:12:20 +00:00
|
|
|
{ 0, "Server" },
|
|
|
|
{ 15, "Client"},
|
|
|
|
{ 0, NULL }
|
2014-03-09 13:23:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string valstr_drmpdu_reason[] = {
|
2014-04-01 03:12:20 +00:00
|
|
|
{ 0, "Reason Not Specified" },
|
|
|
|
{ 1, "Normal Disconnect Initiated by the MS-User" },
|
|
|
|
{ 2, "Protocol Error" },
|
|
|
|
{ 3, "Connection Request Refused" },
|
|
|
|
{ 4, "The Remote Operational MS Entity Does Not Respond" },
|
|
|
|
{ 5, "The Protocol Version Is Not Supported" },
|
|
|
|
{ 6, "Mismatched References" },
|
|
|
|
{ 0, NULL }
|
2014-03-09 13:23:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* start of functions here */
|
|
|
|
static int dissect_simpdu(tvbuff_t *tvb, proto_tree *tree, guint16 offset, guint8 lenIndicator)
|
|
|
|
{
|
2014-04-01 03:12:20 +00:00
|
|
|
guint16 bytesProcessed;
|
|
|
|
guint8 paramCode;
|
2014-03-09 13:23:27 +00:00
|
|
|
proto_item *simpduItem;
|
|
|
|
proto_tree *simpduVarTree;
|
|
|
|
proto_tree *simpduVarTree1;
|
|
|
|
|
|
|
|
bytesProcessed = 0;
|
|
|
|
|
|
|
|
/*Add the Credit allocation*/
|
|
|
|
proto_tree_add_item(tree, hf_pdc_credit, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2014-04-01 03:12:20 +00:00
|
|
|
bytesProcessed += 1;
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
/*Add the State*/
|
|
|
|
proto_tree_add_item(tree, hf_pdc_simpdu_state, tvb, offset + bytesProcessed , 1, ENC_BIG_ENDIAN);
|
2014-04-01 03:12:20 +00:00
|
|
|
bytesProcessed += 1;
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
/*Add the YR-ADMU-NR*/
|
|
|
|
proto_tree_add_item(tree, hf_pdc_yr_admu_nr, tvb, offset + bytesProcessed , 4, ENC_BIG_ENDIAN);
|
|
|
|
bytesProcessed += 4;
|
|
|
|
|
2014-04-01 03:12:20 +00:00
|
|
|
/*Determine what's in the variable part*/
|
|
|
|
if (lenIndicator > 7)
|
2014-03-09 13:23:27 +00:00
|
|
|
{
|
|
|
|
/*Add the Variable Length Tree*/
|
|
|
|
simpduItem = proto_tree_add_item (tree, hf_pdc_simpdu_var, tvb, offset + bytesProcessed, lenIndicator - 7, ENC_NA);
|
|
|
|
simpduVarTree = proto_item_add_subtree (simpduItem, ett_pdc_simpdu_var);
|
|
|
|
|
2014-04-01 03:12:20 +00:00
|
|
|
while ((offset + bytesProcessed) < ( lenIndicator + 1 ))
|
2014-03-09 13:23:27 +00:00
|
|
|
{
|
|
|
|
/*Get the parameter code*/
|
2014-04-01 03:12:20 +00:00
|
|
|
paramCode = tvb_get_guint8(tvb, offset + bytesProcessed);
|
|
|
|
simpduItem = proto_tree_add_item (simpduVarTree, hf_pdc_simpdu_param, tvb, offset + bytesProcessed, 1, ENC_NA);
|
2014-03-09 13:23:27 +00:00
|
|
|
simpduVarTree1 = proto_item_add_subtree (simpduItem, ett_pdc_simpdu_var);
|
2014-04-01 03:12:20 +00:00
|
|
|
bytesProcessed += 1;
|
2014-03-09 13:23:27 +00:00
|
|
|
switch (paramCode)
|
|
|
|
{
|
|
|
|
case PARAM_CODE_VERSION:
|
2014-04-01 03:12:20 +00:00
|
|
|
proto_tree_add_item(simpduVarTree1, hf_pdc_simpdu_var_len, tvb, offset + bytesProcessed, 1, ENC_NA);
|
|
|
|
proto_tree_add_item(simpduVarTree1, hf_pdc_simpdu_var_version, tvb, offset + bytesProcessed + 1, 1, ENC_NA);
|
2014-03-09 13:23:27 +00:00
|
|
|
bytesProcessed += 2;
|
|
|
|
break;
|
|
|
|
case PARAM_CODE_REFERENCES:
|
2014-04-01 03:12:20 +00:00
|
|
|
proto_tree_add_item(simpduVarTree1, hf_pdc_simpdu_var_len, tvb, offset + bytesProcessed, 1, ENC_NA);
|
|
|
|
proto_tree_add_item(simpduVarTree1, hf_pdc_simpdu_var_REFSRC, tvb, offset + bytesProcessed + 1, 2, ENC_NA);
|
|
|
|
proto_tree_add_item(simpduVarTree1, hf_pdc_simpdu_var_REFDEST, tvb, offset + bytesProcessed + 3, 2, ENC_NA);
|
2014-03-09 13:23:27 +00:00
|
|
|
bytesProcessed += 5;
|
|
|
|
break;
|
|
|
|
case PARAM_CODE_TRANSPORT:
|
2014-04-01 03:12:20 +00:00
|
|
|
proto_tree_add_item(simpduVarTree1, hf_pdc_simpdu_var_len, tvb, offset + bytesProcessed, 1, ENC_NA);
|
|
|
|
proto_tree_add_item(simpduVarTree1, hf_pdc_simpdu_var_TSEL, tvb, offset + bytesProcessed + 1, 2, ENC_NA);
|
2014-03-09 13:23:27 +00:00
|
|
|
bytesProcessed += 3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} /* end of whileloop */
|
|
|
|
}
|
|
|
|
return (bytesProcessed);
|
2014-03-17 15:54:08 +00:00
|
|
|
}
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
static int dissect_rsmpdu(void)
|
|
|
|
{
|
|
|
|
return (0);
|
2014-03-17 15:54:08 +00:00
|
|
|
}
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
static int dissect_drmpdu(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
|
|
|
|
{
|
|
|
|
/*DR-MPDU*/
|
2014-04-01 03:12:20 +00:00
|
|
|
proto_tree_add_item(tree, hf_pdc_drmpdu_abort, tvb, offset, 1, ENC_NA);
|
|
|
|
proto_tree_add_item(tree, hf_pdc_drmpdu_mode, tvb, offset, 1, ENC_NA);
|
|
|
|
proto_tree_add_item(tree, hf_pdc_drmpdu_init, tvb, offset, 1, ENC_NA);
|
2014-03-09 13:23:27 +00:00
|
|
|
proto_tree_add_item(tree, hf_pdc_drmpdu_reason, tvb, offset + 1, 1, ENC_NA);
|
|
|
|
|
|
|
|
return (2);
|
2014-03-17 15:54:08 +00:00
|
|
|
}
|
2014-03-09 13:23:27 +00:00
|
|
|
|
2014-04-02 00:36:58 +00:00
|
|
|
static int dissect_admpdu(tvbuff_t *tvb, proto_tree *parent_tree, proto_tree *tree, guint16 offset, packet_info *pinfo)
|
2014-03-09 13:23:27 +00:00
|
|
|
{
|
2014-04-01 03:12:20 +00:00
|
|
|
guint16 userDataLen;
|
|
|
|
guint16 returnLen;
|
|
|
|
tvbuff_t *asterixTVB;
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
/*Add the ad*/
|
|
|
|
proto_tree_add_item(tree, hf_pdc_admpdu_admpdunr, tvb, offset, 4, ENC_BIG_ENDIAN);
|
|
|
|
offset += 4;
|
|
|
|
|
|
|
|
if (PDC_VERSION == 2)
|
|
|
|
{
|
|
|
|
proto_tree_add_item(tree, hf_pdc_admpdu_size, tvb, offset, 2, ENC_BIG_ENDIAN);
|
|
|
|
/* length of user data field */
|
|
|
|
userDataLen = tvb_get_ntohs(tvb, offset);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
returnLen = userDataLen + 6;
|
2014-06-06 14:35:50 +00:00
|
|
|
asterixTVB = tvb_new_subset_length(tvb, offset, userDataLen);
|
2014-03-09 13:23:27 +00:00
|
|
|
|
2014-04-01 03:12:20 +00:00
|
|
|
if (asterix_handle != NULL)
|
2014-04-02 00:36:58 +00:00
|
|
|
call_dissector(asterix_handle, asterixTVB, pinfo, parent_tree);
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
return (returnLen);
|
|
|
|
}
|
|
|
|
return (2);
|
2014-03-17 15:54:08 +00:00
|
|
|
}
|
2014-03-09 13:23:27 +00:00
|
|
|
|
2014-04-02 00:36:58 +00:00
|
|
|
static int dissect_dtmpdu(tvbuff_t *tvb, proto_tree *parent_tree, proto_tree *tree, guint16 offset, packet_info *pinfo)
|
2014-03-09 13:23:27 +00:00
|
|
|
{
|
2014-04-01 03:12:20 +00:00
|
|
|
guint16 userDataLen;
|
|
|
|
guint16 returnLen;
|
|
|
|
tvbuff_t *asterixTVB;
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
if (PDC_VERSION == 2)
|
|
|
|
{
|
|
|
|
proto_tree_add_item(tree, hf_pdc_dtmpdu_user_size, tvb, offset, 2, ENC_BIG_ENDIAN);
|
|
|
|
/* length of user data field */
|
|
|
|
userDataLen = tvb_get_ntohs(tvb, 2);
|
2014-04-01 03:12:20 +00:00
|
|
|
returnLen = userDataLen + 2;
|
2014-06-06 14:35:50 +00:00
|
|
|
asterixTVB = tvb_new_subset_length(tvb, offset + 2, userDataLen);
|
2014-03-09 13:23:27 +00:00
|
|
|
|
2014-04-01 03:12:20 +00:00
|
|
|
if (asterix_handle != NULL)
|
2014-04-02 00:36:58 +00:00
|
|
|
call_dissector(asterix_handle, asterixTVB, pinfo, parent_tree);
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
return (returnLen);
|
|
|
|
}
|
|
|
|
return (2);
|
2014-03-17 15:54:08 +00:00
|
|
|
}
|
2014-03-09 13:23:27 +00:00
|
|
|
|
2014-04-02 00:36:58 +00:00
|
|
|
static int dissect_edmpdu(tvbuff_t *tvb, proto_tree *parent_tree, proto_tree *tree, guint16 offset, packet_info *pinfo)
|
2014-03-09 13:23:27 +00:00
|
|
|
{
|
2014-04-01 03:12:20 +00:00
|
|
|
guint16 userDataLen;
|
|
|
|
guint16 returnLen;
|
|
|
|
tvbuff_t *asterixTVB;
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
if (PDC_VERSION == 2)
|
|
|
|
{
|
|
|
|
proto_tree_add_item(tree, hf_pdc_dtmpdu_user_size, tvb, offset, 2, ENC_BIG_ENDIAN);
|
|
|
|
/* length of user data field */
|
|
|
|
userDataLen = tvb_get_ntohs(tvb, 2);
|
2014-04-01 03:12:20 +00:00
|
|
|
returnLen = userDataLen + 2;
|
2014-06-06 14:35:50 +00:00
|
|
|
asterixTVB = tvb_new_subset_length(tvb, offset + 2, userDataLen);
|
2014-03-09 13:23:27 +00:00
|
|
|
|
2014-04-01 03:12:20 +00:00
|
|
|
if (asterix_handle != NULL)
|
2014-04-02 00:36:58 +00:00
|
|
|
call_dissector(asterix_handle, asterixTVB, pinfo, parent_tree);
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
return (returnLen);
|
|
|
|
}
|
|
|
|
return 2;
|
2014-03-17 15:54:08 +00:00
|
|
|
}
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
static int dissect_akmpdu(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
|
|
|
|
{
|
2014-04-01 03:12:20 +00:00
|
|
|
proto_tree_add_item(tree, hf_pdc_akmpdu_mns, tvb, offset, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(tree, hf_pdc_akmpdu_cdt, tvb, offset, 2, ENC_BIG_ENDIAN);
|
2014-03-09 13:23:27 +00:00
|
|
|
proto_tree_add_item(tree, hf_pdc_yr_admu_nr, tvb, offset + 2, 4, ENC_BIG_ENDIAN);
|
|
|
|
return (6);
|
2014-03-17 15:54:08 +00:00
|
|
|
}
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
static int dissect_pdc_packet(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo)
|
|
|
|
{
|
2014-04-01 03:12:20 +00:00
|
|
|
guint i = 0;
|
|
|
|
guint8 len_indicator;
|
|
|
|
guint8 mpduCode;
|
|
|
|
guint16 length;
|
2014-03-09 13:23:27 +00:00
|
|
|
proto_item *pdcPacketItem;
|
|
|
|
proto_tree *pdcPacketTree;
|
|
|
|
|
|
|
|
length = 0;
|
|
|
|
|
|
|
|
/*Get the length indictor and the MPDU Code*/
|
2014-04-01 03:12:20 +00:00
|
|
|
len_indicator = tvb_get_guint8 (tvb, i);
|
|
|
|
mpduCode = tvb_get_guint8 (tvb, i + 1);
|
|
|
|
length += 2;
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
/*Add the PDC Tree*/
|
|
|
|
pdcPacketItem = proto_tree_add_item (tree, proto_pdc, tvb, i, len_indicator + 1, ENC_NA);
|
|
|
|
pdcPacketTree = proto_item_add_subtree (pdcPacketItem, ett_pdc);
|
|
|
|
|
|
|
|
/*Add the Length and packet type*/
|
|
|
|
proto_tree_add_item(pdcPacketTree, hf_pdc_len, tvb, i, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(pdcPacketTree, hf_pdc_mpdu_code, tvb, i + 1, 1, ENC_BIG_ENDIAN);
|
|
|
|
|
|
|
|
/*Call the correct dissecting function*/
|
2014-04-01 03:12:20 +00:00
|
|
|
switch (mpduCode)
|
2014-03-09 13:23:27 +00:00
|
|
|
{
|
|
|
|
case SIMPDU:
|
|
|
|
length += dissect_simpdu(tvb, pdcPacketTree, length, len_indicator);
|
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "SIMPDU");
|
|
|
|
break;
|
|
|
|
case RSMPDU:
|
|
|
|
length += dissect_rsmpdu();
|
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "RSMPDU");
|
|
|
|
break;
|
|
|
|
case DRMPDU:
|
|
|
|
length += dissect_drmpdu(tvb, pdcPacketTree, length);
|
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "DRMPDU");
|
|
|
|
break;
|
|
|
|
case DTMPDU:
|
2014-04-02 00:36:58 +00:00
|
|
|
length += dissect_dtmpdu(tvb, tree, pdcPacketTree, length, pinfo);
|
2014-03-09 13:23:27 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "DTMPDU");
|
|
|
|
break;
|
|
|
|
case ADMPDU:
|
2014-04-02 00:36:58 +00:00
|
|
|
length += dissect_admpdu(tvb, tree, pdcPacketTree, length, pinfo);
|
2014-03-09 13:23:27 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "ADMPDU");
|
|
|
|
break;
|
|
|
|
case EDMPDU:
|
2014-04-02 00:36:58 +00:00
|
|
|
length += dissect_edmpdu(tvb, tree, pdcPacketTree, length, pinfo);
|
2014-03-09 13:23:27 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "EDMPDU");
|
|
|
|
break;
|
|
|
|
case AKMPDU:
|
|
|
|
length += dissect_akmpdu(tvb, pdcPacketTree, length);
|
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "AKMPDU");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
};
|
2014-04-01 03:12:20 +00:00
|
|
|
return (length); /* XXX: returned length ignored by caller: Remove keeping track of data rocessed ? */
|
|
|
|
/* col_set_str() could then be done separately with 'if (tree)' around the dissection */
|
2014-03-17 15:54:08 +00:00
|
|
|
}
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
/* Actual dissector bits and bytes done here */
|
2014-04-01 03:12:20 +00:00
|
|
|
static int dissect_pdc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
|
2014-03-09 13:23:27 +00:00
|
|
|
{
|
|
|
|
/*Set the Column*/
|
2014-04-01 03:12:20 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, PDC_PROCOTOL );
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2014-03-09 13:23:27 +00:00
|
|
|
|
2014-04-01 03:12:20 +00:00
|
|
|
dissect_pdc_packet(tvb, tree, pinfo);
|
2014-03-09 13:23:27 +00:00
|
|
|
|
2014-04-01 03:12:20 +00:00
|
|
|
return tvb_reported_length(tvb);
|
2014-03-17 15:54:08 +00:00
|
|
|
}
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
/* function to provide TCP split packet combiner with size of packet */
|
|
|
|
static guint get_pdc_message_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
|
|
|
|
{
|
2014-04-01 03:12:20 +00:00
|
|
|
guint size;
|
|
|
|
guint extra;
|
|
|
|
guint8 mpdu_type;
|
|
|
|
|
|
|
|
mpdu_type = tvb_get_guint8(tvb, offset+1);
|
2014-03-09 13:23:27 +00:00
|
|
|
switch (mpdu_type)
|
|
|
|
{
|
|
|
|
case SIMPDU:
|
2014-04-01 03:12:20 +00:00
|
|
|
size = tvb_get_guint8(tvb, offset);
|
|
|
|
extra = 1;
|
2014-03-09 13:23:27 +00:00
|
|
|
break;
|
|
|
|
case RSMPDU:
|
2014-04-01 03:12:20 +00:00
|
|
|
size = tvb_get_guint8(tvb, offset);
|
|
|
|
extra = 1;
|
2014-03-09 13:23:27 +00:00
|
|
|
break;
|
|
|
|
case DRMPDU:
|
2014-04-01 03:12:20 +00:00
|
|
|
size = tvb_get_guint8(tvb, offset);
|
|
|
|
extra = 1;
|
2014-03-09 13:23:27 +00:00
|
|
|
break;
|
|
|
|
case DTMPDU:
|
2014-04-01 03:12:20 +00:00
|
|
|
size = tvb_get_ntohs(tvb, offset+2);
|
|
|
|
extra = 4;
|
2014-03-09 13:23:27 +00:00
|
|
|
break;
|
|
|
|
case ADMPDU:
|
2014-04-01 03:12:20 +00:00
|
|
|
size = tvb_get_ntohs(tvb, offset+6);
|
|
|
|
extra = 8;
|
2014-03-09 13:23:27 +00:00
|
|
|
break;
|
|
|
|
case EDMPDU:
|
2014-04-01 03:12:20 +00:00
|
|
|
size = tvb_get_guint8(tvb, offset);
|
|
|
|
extra = 1;
|
2014-03-09 13:23:27 +00:00
|
|
|
break;
|
|
|
|
case AKMPDU:
|
2014-04-01 03:12:20 +00:00
|
|
|
size = tvb_get_guint8(tvb, offset)+1;
|
|
|
|
extra = 0;
|
2014-03-09 13:23:27 +00:00
|
|
|
break;
|
|
|
|
default:
|
2014-04-01 03:12:20 +00:00
|
|
|
size = 0;
|
|
|
|
extra = 0;
|
2014-03-09 13:23:27 +00:00
|
|
|
}
|
2014-04-01 03:12:20 +00:00
|
|
|
return size + extra;
|
2014-03-17 15:54:08 +00:00
|
|
|
}
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
/* top level call to recombine split tcp packets */
|
|
|
|
|
|
|
|
static void tcp_dissect_pdc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2014-04-01 03:12:20 +00:00
|
|
|
guint8 mpdu_type;
|
|
|
|
guint8 minimum_bytes;
|
|
|
|
|
|
|
|
mpdu_type = tvb_get_guint8(tvb,1);
|
2014-03-09 13:23:27 +00:00
|
|
|
switch (mpdu_type)
|
|
|
|
{
|
|
|
|
case SIMPDU:
|
2014-04-01 03:12:20 +00:00
|
|
|
minimum_bytes = 2;
|
2014-03-09 13:23:27 +00:00
|
|
|
break;
|
|
|
|
case RSMPDU:
|
2014-04-01 03:12:20 +00:00
|
|
|
minimum_bytes = 2;
|
2014-03-09 13:23:27 +00:00
|
|
|
break;
|
|
|
|
case DRMPDU:
|
2014-04-01 03:12:20 +00:00
|
|
|
minimum_bytes = 2;
|
2014-03-09 13:23:27 +00:00
|
|
|
break;
|
|
|
|
case DTMPDU:
|
2014-04-01 03:12:20 +00:00
|
|
|
minimum_bytes = 4;
|
2014-03-09 13:23:27 +00:00
|
|
|
break;
|
|
|
|
case ADMPDU:
|
2014-04-01 03:12:20 +00:00
|
|
|
minimum_bytes = 8;
|
2014-03-09 13:23:27 +00:00
|
|
|
break;
|
|
|
|
case EDMPDU:
|
2014-04-01 03:12:20 +00:00
|
|
|
minimum_bytes = 2;
|
2014-03-09 13:23:27 +00:00
|
|
|
break;
|
|
|
|
case AKMPDU:
|
2014-04-01 03:12:20 +00:00
|
|
|
minimum_bytes = 2;
|
2014-03-09 13:23:27 +00:00
|
|
|
break;
|
|
|
|
default:
|
2014-04-01 03:12:20 +00:00
|
|
|
minimum_bytes = 2;
|
2014-03-09 13:23:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, minimum_bytes, get_pdc_message_len, dissect_pdc, NULL);
|
2014-03-17 15:54:08 +00:00
|
|
|
}
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
void proto_register_pdc(void)
|
|
|
|
{
|
|
|
|
module_t *pdc_pref_module;
|
|
|
|
|
|
|
|
static hf_register_info hf[] =
|
|
|
|
{
|
2014-04-01 03:12:20 +00:00
|
|
|
{ &hf_pdc_len,
|
|
|
|
{ "Length Indicator", "pdc.li",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_mpdu_code,
|
|
|
|
{ "MPDU code", "pdc.mpducode",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(valstr_mpdus), 0x0, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_credit,
|
|
|
|
{ "Credit", "pdc.cdt",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_yr_admu_nr,
|
|
|
|
{ "YR-ADMU-NR", "pdc.yradmunr",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL , HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_simpdu_state,
|
|
|
|
{ "State", "pdc.state",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(valstr_simpdu_state), 0x0, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_akmpdu_mns,
|
|
|
|
{ "MNS", "pdc.akmpdu.mns",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x8000, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_akmpdu_cdt,
|
|
|
|
{ "CDT", "pdc.akmpdu.cdt",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x07FF, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_simpdu_var,
|
|
|
|
{ "Variable Part", "pdc.simpdu.variable",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_simpdu_param,
|
|
|
|
{ "Parameter", "pdc.simpdu.param",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(valstr_simpdu_param), 0x0, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_simpdu_var_len,
|
|
|
|
{ "Length", "pdc.simpdu.variable.length",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_simpdu_var_version,
|
|
|
|
{ "PDC Version Number", "pdc.simpdu.variable.version",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_simpdu_var_REFSRC,
|
|
|
|
{ "Reference Source", "pdc.simpdu.variable.refsrc",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0,NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_simpdu_var_REFDEST,
|
|
|
|
{ "Reference Destination", "pdc.simpdu.variable.refdst",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0,NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_simpdu_var_TSEL,
|
|
|
|
{ "Transport Selector", "pdc.simpdu.tsel",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_drmpdu_abort,
|
|
|
|
{ "Abort", "pdc.drmpdu.abort",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(valstr_drmpdu_abort), 0x80, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_drmpdu_reason,
|
|
|
|
{ "Reason", "pdc.drmpdu.reason",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(valstr_drmpdu_reason), 0x0, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_drmpdu_mode,
|
|
|
|
{ "Mode", "pdc.drmpdu.mode",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(valstr_drmpdu_mode), 0x70, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_drmpdu_init,
|
|
|
|
{ "Reason", "pdc.drmpdu.init",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(valstr_drmpdu_initatior), 0x0F, NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_dtmpdu_user_size,
|
|
|
|
{ "User Data Length", "pdc.dtmpdu.usersize",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0, NULL , HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_admpdu_admpdunr,
|
|
|
|
{ "AD-MPDU-NR", "pdc.admpdu.admpdunr",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL , HFILL }},
|
|
|
|
|
|
|
|
{ &hf_pdc_admpdu_size,
|
|
|
|
{ "User Data Size", "pdc.admpdu.usersize",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0, NULL , HFILL }},
|
2014-03-09 13:23:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Setup protocol subtree array */
|
|
|
|
static gint *ett[] = {
|
2014-04-01 03:12:20 +00:00
|
|
|
&ett_pdc,
|
|
|
|
&ett_pdc_simpdu_var
|
2014-03-09 13:23:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
proto_pdc = proto_register_protocol (
|
2014-04-01 03:12:20 +00:00
|
|
|
"PDC Protocol", /* name */
|
|
|
|
"PDC", /* short name */
|
|
|
|
"pdc" /* abbrev */
|
|
|
|
);
|
2014-03-09 13:23:27 +00:00
|
|
|
|
|
|
|
/*Required Function Calls to register the header fields and subtrees used*/
|
|
|
|
proto_register_field_array(proto_pdc, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
|
|
|
|
/*Register Preferences Module*/
|
|
|
|
pdc_pref_module = prefs_register_protocol(proto_pdc, proto_reg_handoff_pdc);
|
|
|
|
|
|
|
|
/*Register Preferences*/
|
|
|
|
prefs_register_uint_preference(pdc_pref_module, "tcp.port", "PDC Port", "PDC Port if other then the default", 10, &gPREF_PORT_NUM_TCP);
|
2014-03-17 15:54:08 +00:00
|
|
|
}
|
2014-03-09 13:23:27 +00:00
|
|
|
|
2014-04-01 03:12:20 +00:00
|
|
|
/* Function to add pdc dissector to tcp.port dissector table and to get handle for asterix dissector */
|
|
|
|
void proto_reg_handoff_pdc(void)
|
|
|
|
{
|
|
|
|
static dissector_handle_t pdc_tcp_handle;
|
|
|
|
static int pdc_tcp_port;
|
|
|
|
static gboolean initialized = FALSE;
|
|
|
|
|
|
|
|
if (! initialized)
|
|
|
|
{
|
|
|
|
asterix_handle = find_dissector("asterix");
|
|
|
|
pdc_tcp_handle = create_dissector_handle(tcp_dissect_pdc, proto_pdc);
|
2014-06-20 16:43:28 +00:00
|
|
|
dissector_add_for_decode_as("tcp.port", pdc_tcp_handle);
|
2014-04-01 03:12:20 +00:00
|
|
|
initialized = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pdc_tcp_port != 0)
|
|
|
|
dissector_delete_uint("tcp.port", pdc_tcp_port, pdc_tcp_handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
pdc_tcp_port = gPREF_PORT_NUM_TCP;
|
|
|
|
if (pdc_tcp_port != 0)
|
|
|
|
dissector_add_uint("tcp.port", pdc_tcp_port, pdc_tcp_handle);
|
|
|
|
}
|
|
|
|
|
2014-03-09 13:23:27 +00:00
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
2014-03-10 08:55:15 +00:00
|
|
|
*/
|