language
stringlengths 0
24
| filename
stringlengths 9
214
| code
stringlengths 99
9.93M
|
---|---|---|
C
|
wireshark/epan/dissectors/packet-simulcrypt.c
|
/* packet-simulcrypt.c
* Simulcrypt protocol interface as defined in ETSI TS 103.197 v 1.5.1
*
* ECMG <-> SCS support
* David Castleford, Orange Labs / France Telecom R&D
* Oct 2008
*
* EMMG <-> MUX support and generic interface support
* Copyright 2009, Stig Bjorlykke <[email protected]>
*
* EIS <-> SCS support, (P)SIG <-> MUX support, MUX <-> CiM support and (P) <-> CiP support
* Copyright 2010, Giuliano Fabris <[email protected]> / AppearTV
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#include "packet-tcp.h"
#define PROTO_TAG_SIMULCRYPT "SIMULCRYPT"
#define CA_SYSTEM_ID_MIKEY 0x9999 /* CA_system_ID corresponding to MIKEY ECM */
#define CA_SYSTEM_ID_MIKEY_PROTO "mikey" /* Protocol name to be used to "decode as" ECMs with CA_SYSTEM_ID_MIKEY */
void proto_register_simulcrypt(void);
/* Tecm_interpretation links ca_system_id to ecmg port and protocol name for dissection of
* ecm_datagram in ECM_Response message.
* Currently size is 1 as only have MIKEY protocol but could add extra protocols
* could add option in preferences for new ca_system_id for new protocol for example
*/
typedef struct Tecm_interpretation
{
int ca_system_id;
const char *protocol_name;
dissector_handle_t protocol_handle;
guint ecmg_port;
} ecm_interpretation;
#define ECM_MIKEY_INDEX 0 /* must agree with tab_ecm_inter initialization */
static ecm_interpretation tab_ecm_inter[] = {
{CA_SYSTEM_ID_MIKEY, CA_SYSTEM_ID_MIKEY_PROTO, NULL, -1}
};
#define ECM_INTERPRETATION_SIZE (sizeof(tab_ecm_inter)/sizeof(ecm_interpretation))
static int dissect_simulcrypt_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_);
static guint get_simulcrypt_message_len(packet_info *pinfo, tvbuff_t *tvb, int offset, void *data);
static void dissect_simulcrypt_data(proto_tree *simulcrypt_tree, proto_item *simulcrypt_item, packet_info *pinfo _U_,
tvbuff_t *tvb, proto_tree *tree, int offset,
int container_data_length, guint16 iftype, gboolean is_subtree);
/* Wireshark ID of the SIMULCRYPT protocol */
static guint proto_simulcrypt = -1;
/* Preferences (with default values) */
static int ca_system_id_mikey = CA_SYSTEM_ID_MIKEY; /* MIKEY ECM CA_system_ID */
/* MIKEY payload start bytes */
/*unsigned char mikey_start[3]={0x01,0x00,0x15};
* mikey_start[0]=0x01; first byte mikey payload (version)
* mikey_start[1]=0x00; second byte mikey payload (data type)
* mikey_start[2]=0x15; third byte (next payload)
*/
/* Dissector-internal values to determine interface, can be re-organized */
#define SIMULCRYPT_RESERVED 0
#define SIMULCRYPT_ECMG_SCS 1
#define SIMULCRYPT_EMMG_MUX 2
#define SIMULCRYPT_CPSIG_PSIG 3
#define SIMULCRYPT_EIS_SCS 4
#define SIMULCRYPT_PSIG_MUX 5
#define SIMULCRYPT_MUX_CIM 6
#define SIMULCRYPT_PSIG_CIP 7
#define SIMULCRYPT_USER_DEFINED 8
static const value_string interfacenames[] = {
{ SIMULCRYPT_RESERVED, "DVB reserved" },
{ SIMULCRYPT_ECMG_SCS, "ECMG <-> SCS" },
{ SIMULCRYPT_EMMG_MUX, "EMMG <-> MUX" },
{ SIMULCRYPT_CPSIG_PSIG, "C(P)SIG <-> (P)SIG" },
{ SIMULCRYPT_EIS_SCS, "EIS <-> SCS" },
{ SIMULCRYPT_PSIG_MUX, "(P)SIG <-> MUX" },
{ SIMULCRYPT_MUX_CIM, "Carousel in the MUX - CiM" },
{ SIMULCRYPT_PSIG_CIP, "Carousel in the (P) - CiP" },
{ SIMULCRYPT_USER_DEFINED, "User defined" },
{ 0, NULL }
};
/* Reserved 0x0000 */
#define SIMULCRYPT_ECMG_CHANNEL_SETUP 0x0001
#define SIMULCRYPT_ECMG_CHANNEL_TEST 0x0002
#define SIMULCRYPT_ECMG_CHANNEL_STATUS 0x0003
#define SIMULCRYPT_ECMG_CHANNEL_CLOSE 0x0004
#define SIMULCRYPT_ECMG_CHANNEL_ERROR 0x0005
/* Reserved 0x0006 - 0x0010 */
#define SIMULCRYPT_EMMG_CHANNEL_SETUP 0x0011
#define SIMULCRYPT_EMMG_CHANNEL_TEST 0x0012
#define SIMULCRYPT_EMMG_CHANNEL_STATUS 0x0013
#define SIMULCRYPT_EMMG_CHANNEL_CLOSE 0x0014
#define SIMULCRYPT_EMMG_CHANNEL_ERROR 0x0015
/* Reserved 0x0016 - 0x0100 */
#define SIMULCRYPT_ECMG_STREAM_SETUP 0x0101
#define SIMULCRYPT_ECMG_STREAM_TEST 0x0102
#define SIMULCRYPT_ECMG_STREAM_STATUS 0x0103
#define SIMULCRYPT_ECMG_STREAM_CLOSE_REQUEST 0x0104
#define SIMULCRYPT_ECMG_STREAM_CLOSE_RESPONSE 0x0105
#define SIMULCRYPT_ECMG_STREAM_ERROR 0x0106
/* Reserved 0x0107 - 0x0110 */
#define SIMULCRYPT_EMMG_STREAM_SETUP 0x0111
#define SIMULCRYPT_EMMG_STREAM_TEST 0x0112
#define SIMULCRYPT_EMMG_STREAM_STATUS 0x0113
#define SIMULCRYPT_EMMG_STREAM_CLOSE_REQUEST 0x0114
#define SIMULCRYPT_EMMG_STREAM_CLOSE_RESPONSE 0x0115
#define SIMULCRYPT_EMMG_STREAM_ERROR 0x0116
#define SIMULCRYPT_EMMG_STREAM_BW_REQUEST 0x0117
#define SIMULCRYPT_EMMG_STREAM_BW_ALLOCATION 0x0118
/* Reserved 0x0119 - 0x0200 */
#define SIMULCRYPT_ECMG_CW_PROVISION 0x0201
#define SIMULCRYPT_ECMG_ECM_RESPONSE 0x0202
/* Reserved 0x0203 - 0x0210 */
#define SIMULCRYPT_EMMG_DATA_PROVISION 0x0211
/* Reserved 0x0212 - 0x0300 */
/* Reserved 0x0322 - 0x0400 */
#define SIMULCRYPT_EIS_CHANNEL_SET_UP 0x0401
#define SIMULCRYPT_EIS_CHANNEL_TEST 0x0402
#define SIMULCRYPT_EIS_CHANNEL_STATUS 0x0403
#define SIMULCRYPT_EIS_CHANNEL_CLOSE 0x0404
#define SIMULCRYPT_EIS_CHANNEL_ERROR 0x0405
#define SIMULCRYPT_EIS_CHANNEL_RESET 0x0406
#define SIMULCRYPT_EIS_SCG_PROVISION 0x0408
#define SIMULCRYPT_EIS_SCG_TEST 0x0409
#define SIMULCRYPT_EIS_SCG_STATUS 0x040A
#define SIMULCRYPT_EIS_SCG_ERROR 0x040B
#define SIMULCRYPT_EIS_SCG_LIST_REQUEST 0x040C
#define SIMULCRYPT_EIS_SCG_LIST_RESPONSE 0x040D
#define SIMULCRYPT_PSIG_CHANNEL_SETUP 0x0411
#define SIMULCRYPT_PSIG_CHANNEL_TEST 0x0412
#define SIMULCRYPT_PSIG_CHANNEL_STATUS 0x0413
#define SIMULCRYPT_PSIG_CHANNEL_CLOSE 0x0414
#define SIMULCRYPT_PSIG_CHANNEL_ERROR 0x0415
#define SIMULCRYPT_PSIG_STREAM_SETUP 0x0421
#define SIMULCRYPT_PSIG_STREAM_TEST 0x0422
#define SIMULCRYPT_PSIG_STREAM_STATUS 0x0423
#define SIMULCRYPT_PSIG_STREAM_CLOSE_REQUEST 0x0424
#define SIMULCRYPT_PSIG_STREAM_CLOSE_RESPONSE 0x0425
#define SIMULCRYPT_PSIG_STREAM_ERROR 0x0426
#define SIMULCRYPT_PSIG_CIM_STREAM_SECTION_PROVISION 0x0431
#define SIMULCRYPT_PSIG_CIM_CHANNEL_RESET 0x0432
#define SIMULCRYPT_PSIG_CIM_STREAM_BW_REQUEST 0x0441
#define SIMULCRYPT_PSIG_CIM_STREAM_BW_ALLOCATION 0x0442
#define SIMULCRYPT_PSIG_CIM_STREAM_DATA_PROVISION 0x0443
/* User defined 0x8000 - 0xFFFF */
static const value_string messagetypenames[] = {
{ SIMULCRYPT_ECMG_CHANNEL_SETUP, "CHANNEL_SETUP" },
{ SIMULCRYPT_ECMG_CHANNEL_TEST, "CHANNEL_TEST" },
{ SIMULCRYPT_ECMG_CHANNEL_STATUS, "CHANNEL_STATUS" },
{ SIMULCRYPT_ECMG_CHANNEL_CLOSE, "CHANNEL_CLOSE" },
{ SIMULCRYPT_ECMG_CHANNEL_ERROR, "CHANNEL_ERROR" },
{ SIMULCRYPT_EMMG_CHANNEL_SETUP, "CHANNEL_SETUP" },
{ SIMULCRYPT_EMMG_CHANNEL_TEST, "CHANNEL_TEST" },
{ SIMULCRYPT_EMMG_CHANNEL_STATUS, "CHANNEL_STATUS" },
{ SIMULCRYPT_EMMG_CHANNEL_CLOSE, "CHANNEL_CLOSE" },
{ SIMULCRYPT_EMMG_CHANNEL_ERROR, "CHANNEL_ERROR" },
{ SIMULCRYPT_ECMG_STREAM_SETUP, "STREAM_SETUP" },
{ SIMULCRYPT_ECMG_STREAM_TEST, "STREAM_TEST" },
{ SIMULCRYPT_ECMG_STREAM_STATUS, "STREAM_STATUS" },
{ SIMULCRYPT_ECMG_STREAM_CLOSE_REQUEST, "STREAM_CLOSE_REQUEST" },
{ SIMULCRYPT_ECMG_STREAM_CLOSE_RESPONSE, "STREAM_CLOSE_RESPONSE" },
{ SIMULCRYPT_ECMG_STREAM_ERROR, "STREAM_ERROR" },
{ SIMULCRYPT_EMMG_STREAM_SETUP, "STREAM_SETUP" },
{ SIMULCRYPT_EMMG_STREAM_TEST, "STREAM_TEST" },
{ SIMULCRYPT_EMMG_STREAM_STATUS, "STREAM_STATUS" },
{ SIMULCRYPT_EMMG_STREAM_CLOSE_REQUEST, "STREAM_CLOSE_REQUEST" },
{ SIMULCRYPT_EMMG_STREAM_CLOSE_RESPONSE, "STREAM_CLOSE_RESPONSE" },
{ SIMULCRYPT_EMMG_STREAM_ERROR, "STREAM_ERROR" },
{ SIMULCRYPT_EMMG_STREAM_BW_REQUEST, "STREAM_BW_REQUEST" },
{ SIMULCRYPT_EMMG_STREAM_BW_ALLOCATION, "STREAM_BW_ALLOCATION" },
{ SIMULCRYPT_ECMG_CW_PROVISION, "CW_PROVISION" },
{ SIMULCRYPT_ECMG_ECM_RESPONSE, "ECM_RESPONSE" },
{ SIMULCRYPT_EMMG_DATA_PROVISION, "DATA_PROVISION" },
{ SIMULCRYPT_EIS_CHANNEL_SET_UP, "CHANNEL_SET_UP" },
{ SIMULCRYPT_EIS_CHANNEL_TEST, "CHANNEL_TEST" },
{ SIMULCRYPT_EIS_CHANNEL_STATUS, "CHANNEL_STATUS" },
{ SIMULCRYPT_EIS_CHANNEL_CLOSE, "CHANNEL_CLOSE" },
{ SIMULCRYPT_EIS_CHANNEL_ERROR, "CHANNEL_ERROR" },
{ SIMULCRYPT_EIS_CHANNEL_RESET, "CHANNEL_RESET" },
{ SIMULCRYPT_EIS_SCG_PROVISION, "SCG_PROVISION" },
{ SIMULCRYPT_EIS_SCG_TEST, "SCG_TEST" },
{ SIMULCRYPT_EIS_SCG_STATUS, "SCG_STATUS" },
{ SIMULCRYPT_EIS_SCG_ERROR, "SCG_ERROR" },
{ SIMULCRYPT_EIS_SCG_LIST_REQUEST, "SCG_LIST_REQUEST" },
{ SIMULCRYPT_EIS_SCG_LIST_RESPONSE, "SCG_LIST_RESPONSE" },
{ SIMULCRYPT_PSIG_CHANNEL_SETUP, "CHANNEL_SETUP" },
{ SIMULCRYPT_PSIG_CHANNEL_TEST, "CHANNEL_TEST" },
{ SIMULCRYPT_PSIG_CHANNEL_STATUS, "CHANNEL_STATUS" },
{ SIMULCRYPT_PSIG_CHANNEL_CLOSE, "CHANNEL_CLOSE" },
{ SIMULCRYPT_PSIG_CHANNEL_ERROR, "CHANNEL_ERROR" },
{ SIMULCRYPT_PSIG_STREAM_SETUP, "STREAM_SETUP" },
{ SIMULCRYPT_PSIG_STREAM_TEST, "STREAM_TEST" },
{ SIMULCRYPT_PSIG_STREAM_STATUS, "STREAM_STATUS" },
{ SIMULCRYPT_PSIG_STREAM_CLOSE_REQUEST, "STREAM_CLOSE_REQUEST" },
{ SIMULCRYPT_PSIG_STREAM_CLOSE_RESPONSE, "STREAM_CLOSE_RESPONSE" },
{ SIMULCRYPT_PSIG_STREAM_ERROR, "STREAM_ERROR" },
{ SIMULCRYPT_PSIG_CIM_STREAM_SECTION_PROVISION, "CIM_STREAM_SECTION_PROVISION"},
{ SIMULCRYPT_PSIG_CIM_CHANNEL_RESET, "CIM_CHANNEL_RESET"},
/* XXX: Following added (since they seem to have been missing) */
{ SIMULCRYPT_PSIG_CIM_STREAM_BW_REQUEST, "CIM_STREAM_BW_REQUEST"},
{ SIMULCRYPT_PSIG_CIM_STREAM_BW_ALLOCATION, "CIM_STREAM_BW_ALLOCATION"},
{ SIMULCRYPT_PSIG_CIM_STREAM_DATA_PROVISION, "CIM_STREAM_DATA_PROVISION"},
{ 0, NULL }
};
static value_string_ext messagetypenames_ext = VALUE_STRING_EXT_INIT(messagetypenames);
/* Simulcrypt ECMG Parameter Types */
#define SIMULCRYPT_ECMG_DVB_RESERVED 0x0000
#define SIMULCRYPT_ECMG_SUPER_CAS_ID 0x0001
#define SIMULCRYPT_ECMG_SECTION_TSPKT_FLAG 0x0002
#define SIMULCRYPT_ECMG_DELAY_START 0x0003
#define SIMULCRYPT_ECMG_DELAY_STOP 0x0004
#define SIMULCRYPT_ECMG_TRANSITION_DELAY_START 0x0005
#define SIMULCRYPT_ECMG_TRANSITION_DELAY_STOP 0x0006
#define SIMULCRYPT_ECMG_ECM_REP_PERIOD 0x0007
#define SIMULCRYPT_ECMG_MAX_STREAMS 0x0008
#define SIMULCRYPT_ECMG_MIN_CP_DURATION 0x0009
#define SIMULCRYPT_ECMG_LEAD_CW 0x000A
#define SIMULCRYPT_ECMG_CW_PER_MESSAGE 0x000B
#define SIMULCRYPT_ECMG_MAX_COMP_TIME 0x000C
#define SIMULCRYPT_ECMG_ACCESS_CRITERIA 0x000D
#define SIMULCRYPT_ECMG_ECM_CHANNEL_ID 0x000E
#define SIMULCRYPT_ECMG_ECM_STREAM_ID 0x000F
#define SIMULCRYPT_ECMG_NOMINAL_CP_DURATION 0x0010
#define SIMULCRYPT_ECMG_ACCESS_CRITERIA_TRANSFER_MODE 0x0011
#define SIMULCRYPT_ECMG_CP_NUMBER 0x0012
#define SIMULCRYPT_ECMG_CP_DURATION 0x0013
#define SIMULCRYPT_ECMG_CP_CW_COMBINATION 0x0014
#define SIMULCRYPT_ECMG_ECM_DATAGRAM 0x0015
#define SIMULCRYPT_ECMG_AC_DELAY_START 0x0016
#define SIMULCRYPT_ECMG_AC_DELAY_STOP 0x0017
#define SIMULCRYPT_ECMG_CW_ENCRYPTION 0x0018
#define SIMULCRYPT_ECMG_ECM_ID 0x0019
#define SIMULCRYPT_ECMG_ERROR_STATUS 0x7000
#define SIMULCRYPT_ECMG_ERROR_INFORMATION 0x7001
static const value_string ecmg_parametertypenames[] = {
{ SIMULCRYPT_ECMG_DVB_RESERVED, "DVB_RESERVED" },
{ SIMULCRYPT_ECMG_SUPER_CAS_ID, "SUPER_CAS_ID" },
{ SIMULCRYPT_ECMG_SECTION_TSPKT_FLAG, "SECTION_TSPKT_FLAG" },
{ SIMULCRYPT_ECMG_DELAY_START, "DELAY_START" },
{ SIMULCRYPT_ECMG_DELAY_STOP, "DELAY_STOP" },
{ SIMULCRYPT_ECMG_TRANSITION_DELAY_START, "TRANSITION_DELAY_START" },
{ SIMULCRYPT_ECMG_TRANSITION_DELAY_STOP, "TRANSITION_DELAY_STOP" },
{ SIMULCRYPT_ECMG_ECM_REP_PERIOD, "ECM_REP_PERIOD" },
{ SIMULCRYPT_ECMG_MAX_STREAMS, "MAX_STREAMS" },
{ SIMULCRYPT_ECMG_MIN_CP_DURATION, "MIN_CP_DURATION" },
{ SIMULCRYPT_ECMG_LEAD_CW, "LEAD_CW" },
{ SIMULCRYPT_ECMG_CW_PER_MESSAGE, "CW_PER_MESSAGE" },
{ SIMULCRYPT_ECMG_MAX_COMP_TIME, "MAX_COMP_TIME" },
{ SIMULCRYPT_ECMG_ACCESS_CRITERIA, "ACCESS_CRITERIA" },
{ SIMULCRYPT_ECMG_ECM_CHANNEL_ID, "ECM_CHANNEL_ID" },
{ SIMULCRYPT_ECMG_ECM_STREAM_ID, "ECM_STREAM_ID" },
{ SIMULCRYPT_ECMG_NOMINAL_CP_DURATION, "NOMINAL_CP_DURATION" },
{ SIMULCRYPT_ECMG_ACCESS_CRITERIA_TRANSFER_MODE, "ACCESS_CRITERIA_TRANSFER_MODE" },
{ SIMULCRYPT_ECMG_CP_NUMBER, "CP_NUMBER" },
{ SIMULCRYPT_ECMG_CP_DURATION, "CP_DURATION" },
{ SIMULCRYPT_ECMG_CP_CW_COMBINATION, "CP_CW_COMBINATION" },
{ SIMULCRYPT_ECMG_ECM_DATAGRAM, "ECM_DATAGRAM" },
{ SIMULCRYPT_ECMG_AC_DELAY_START, "AC_DELAY_START" },
{ SIMULCRYPT_ECMG_AC_DELAY_STOP, "AC_DELAY_STOP" },
{ SIMULCRYPT_ECMG_CW_ENCRYPTION, "CW_ENCRYPTION" },
{ SIMULCRYPT_ECMG_ECM_ID, "ECM_ID" },
{ SIMULCRYPT_ECMG_ERROR_STATUS, "ERROR_STATUS" },
{ SIMULCRYPT_ECMG_ERROR_INFORMATION, "ERROR_INFORMATION" },
{ 0, NULL }
};
static value_string_ext ecmg_parametertypenames_ext = VALUE_STRING_EXT_INIT(ecmg_parametertypenames);
/* Simulcrypt ECMG protocol error values */
static const value_string ecmg_error_values[] = {
{ 0x0000, "DVB Reserved" },
{ 0x0001, "Invalid message" },
{ 0x0002, "Unsupported protocol version" },
{ 0x0003, "Unknown message type value" },
{ 0x0004, "Message too long" },
{ 0x0005, "Unknown super CAS ID value" },
{ 0x0006, "Unknown ECM channel ID value" },
{ 0x0007, "Unknown ECM stream ID value" },
{ 0x0008, "Too many channels on this ECMG" },
{ 0x0009, "Too many ECM streams on this channel" },
{ 0x000A, "Too many ECM streams on this ECMG" },
{ 0x000B, "Not enough control words to compute ECM" },
{ 0x000C, "ECMG out of storage capacity" },
{ 0x000D, "ECMG out of computational resources" },
{ 0x000E, "Unknown parameter type value" },
{ 0x000F, "Inconsistent length for DVB parameter" },
{ 0x0010, "Missing mandatory DVB parameter" },
{ 0x0011, "Invalid value for DVB parameter" },
{ 0x0012, "Unknown ECM ID value" },
{ 0x0013, "ECM channel ID value already in use" },
{ 0x0014, "ECM stream ID value already in use" },
{ 0x0015, "ECM ID value already in use" },
{ 0x7000, "Unknown error" },
{ 0x7001, "Unrecoverable error" },
{ 0, NULL }
};
static value_string_ext ecmg_error_values_ext = VALUE_STRING_EXT_INIT(ecmg_error_values);
/* Simulcrypt EMMG Parameter Types */
#define SIMULCRYPT_EMMG_DVB_RESERVED 0x0000
#define SIMULCRYPT_EMMG_CLIENT_ID 0x0001
#define SIMULCRYPT_EMMG_SECTION_TSPKT_FLAG 0x0002
#define SIMULCRYPT_EMMG_DATA_CHANNEL_ID 0x0003
#define SIMULCRYPT_EMMG_DATA_STREAM_ID 0x0004
#define SIMULCRYPT_EMMG_DATAGRAM 0x0005
#define SIMULCRYPT_EMMG_BANDWIDTH 0x0006
#define SIMULCRYPT_EMMG_DATA_TYPE 0x0007
#define SIMULCRYPT_EMMG_DATA_ID 0x0008
#define SIMULCRYPT_EMMG_ERROR_STATUS 0x7000
#define SIMULCRYPT_EMMG_ERROR_INFORMATION 0x7001
static const value_string emmg_parametertypenames[] = {
{ SIMULCRYPT_EMMG_DVB_RESERVED, "DVB_RESERVED" },
{ SIMULCRYPT_EMMG_CLIENT_ID, "CLIENT_ID" },
{ SIMULCRYPT_EMMG_SECTION_TSPKT_FLAG, "SECTION_TSPKT_FLAG" },
{ SIMULCRYPT_EMMG_DATA_CHANNEL_ID, "DATA_CHANNEL_ID" },
{ SIMULCRYPT_EMMG_DATA_STREAM_ID, "DATA_STREAM_ID" },
{ SIMULCRYPT_EMMG_DATAGRAM, "DATAGRAM" },
{ SIMULCRYPT_EMMG_BANDWIDTH, "BANDWIDTH" },
{ SIMULCRYPT_EMMG_DATA_TYPE, "DATA_TYPE" },
{ SIMULCRYPT_EMMG_DATA_ID, "DATA_ID" },
{ SIMULCRYPT_EMMG_ERROR_STATUS, "ERROR_STATUS" },
{ SIMULCRYPT_EMMG_ERROR_INFORMATION, "ERROR_INFORMATION" },
{ 0, NULL }
};
static value_string_ext emmg_parametertypenames_ext = VALUE_STRING_EXT_INIT(emmg_parametertypenames);
/* Simulcrypt EMMG protocol error values */
static const value_string emmg_error_values[] = {
{ 0x0000, "DVB Reserved" },
{ 0x0001, "Invalid message" },
{ 0x0002, "Unsupported protocol version" },
{ 0x0003, "Unknown message type value" },
{ 0x0004, "Message too long" },
{ 0x0005, "Unknown data stream ID value" },
{ 0x0006, "Unknown data channel ID value" },
{ 0x0007, "Too many channels on this MUX" },
{ 0x0008, "Too many data streams on this channel" },
{ 0x0009, "Too many data streams on this MUX" },
{ 0x000A, "Unknown parameter type" },
{ 0x000B, "Inconsistent length for DVB parameter" },
{ 0x000C, "Missing mandatory DVB parameter" },
{ 0x000D, "Invalid value for DVB parameter" },
{ 0x000E, "Unknown client ID value" },
{ 0x000F, "Exceeded bandwidth" },
{ 0x0010, "Unknown data ID value" },
{ 0x0011, "Data channel ID value already in use" },
{ 0x0012, "Data stream ID value already in use" },
{ 0x0013, "Data ID value already in use" },
{ 0x0014, "Client ID value already in use" },
{ 0x7000, "Unknown error" },
{ 0x7001, "Unrecoverable error" },
{ 0, NULL }
};
static value_string_ext emmg_error_values_ext = VALUE_STRING_EXT_INIT(emmg_error_values);
/* Simulcrypt EIS Parameter Types */
#define SIMULCRYPT_EIS_DVB_RESERVED 0x0000
#define SIMULCRYPT_EIS_CHANNEL_ID 0x0001
#define SIMULCRYPT_EIS_SERVICE_FLAG 0x0002
#define SIMULCRYPT_EIS_COMPONENT_FLAG 0x0003
#define SIMULCRYPT_EIS_MAX_SCG 0x0004
#define SIMULCRYPT_EIS_ECM_GROUP 0x0005
#define SIMULCRYPT_EIS_SCG_ID 0x0006
#define SIMULCRYPT_EIS_SCG_REFERENCE_ID 0x0007
#define SIMULCRYPT_EIS_SUPER_CAS_ID 0x0008
#define SIMULCRYPT_EIS_ECM_ID 0x0009
#define SIMULCRYPT_EIS_ACCESS_CRITERIA 0x000A
#define SIMULCRYPT_EIS_ACTIVATION_TIME 0x000B
#define SIMULCRYPT_EIS_ACTIVATION_PENDING_FLAG 0x000C
#define SIMULCRYPT_EIS_COMPONENT_ID 0x000D
#define SIMULCRYPT_EIS_SERVICE_ID 0x000E
#define SIMULCRYPT_EIS_TRANSPORT_STREAM_ID 0x000F
#define SIMULCRYPT_EIS_AC_CHANGED_FLAG 0x0010
#define SIMULCRYPT_EIS_SCG_CURRENT_REFERENCE_ID 0x0011
#define SIMULCRYPT_EIS_SCG_PENDING_REFERENCE_ID 0x0012
#define SIMULCRYPT_EIS_CP_DURATION_FLAG 0x0013
#define SIMULCRYPT_EIS_RECOMMENDED_CP_DURATION 0x0014
#define SIMULCRYPT_EIS_SCG_NOMINAL_CP_DURATION 0x0015
#define SIMULCRYPT_EIS_ORIGINAL_NETWORK_ID 0x0016
#define SIMULCRYPT_EIS_ERROR_STATUS 0x7000
#define SIMULCRYPT_EIS_ERROR_INFORMATION 0x7001
#define SIMULCRYPT_EIS_ERROR_DESCRIPTION 0x7002
static const value_string eis_parametertypenames[] = {
{ SIMULCRYPT_EIS_DVB_RESERVED, "DVB_RESERVED" },
{ SIMULCRYPT_EIS_CHANNEL_ID, "EIS_CHANNEL_ID" },
{ SIMULCRYPT_EIS_SERVICE_FLAG, "SERVICE_FLAG" },
{ SIMULCRYPT_EIS_COMPONENT_FLAG, "COMPONENT_FLAG" },
{ SIMULCRYPT_EIS_MAX_SCG, "MAX_SCG" },
{ SIMULCRYPT_EIS_ECM_GROUP, "ECM_GROUP" },
{ SIMULCRYPT_EIS_SCG_ID, "SCG_ID" },
{ SIMULCRYPT_EIS_SCG_REFERENCE_ID, "SCG_REFERENCE_ID" },
{ SIMULCRYPT_EIS_SUPER_CAS_ID, "SUPER_CAS_ID" },
{ SIMULCRYPT_EIS_ECM_ID, "ECM_ID" },
{ SIMULCRYPT_EIS_ACCESS_CRITERIA, "ACCESS_CRITERIA" },
{ SIMULCRYPT_EIS_ACTIVATION_TIME, "ACTIVATION_TIME" },
{ SIMULCRYPT_EIS_ACTIVATION_PENDING_FLAG, "ACTIVATION_PENDING_FLAG" },
{ SIMULCRYPT_EIS_COMPONENT_ID, "COMPONENT_ID" },
{ SIMULCRYPT_EIS_SERVICE_ID, "SERVICE_ID" },
{ SIMULCRYPT_EIS_TRANSPORT_STREAM_ID, "TRANSPORT_STREAM_ID" },
{ SIMULCRYPT_EIS_AC_CHANGED_FLAG, "AC_CHANGED_FLAG" },
{ SIMULCRYPT_EIS_SCG_CURRENT_REFERENCE_ID, "SCG_CURRENT_REFERENCE_ID" },
{ SIMULCRYPT_EIS_SCG_PENDING_REFERENCE_ID, "SCG_PENDING_REFERENCE_ID" },
{ SIMULCRYPT_EIS_CP_DURATION_FLAG, "CP_DURATION_FLAG" },
{ SIMULCRYPT_EIS_RECOMMENDED_CP_DURATION, "RECOMMENDED_CP_DURATION" },
{ SIMULCRYPT_EIS_SCG_NOMINAL_CP_DURATION, "SCG_NOMINAL_CP_DURATION" },
{ SIMULCRYPT_EIS_ORIGINAL_NETWORK_ID, "ORIGINAL_NETWORK_ID" },
{ SIMULCRYPT_EIS_ERROR_STATUS, "ERROR_STATUS" },
{ SIMULCRYPT_EIS_ERROR_INFORMATION, "ERROR_INFORMATION" },
{ SIMULCRYPT_EIS_ERROR_DESCRIPTION, "ERROR_DESCRIPTION" },
{ 0, NULL }
};
static value_string_ext eis_parametertypenames_ext = VALUE_STRING_EXT_INIT(eis_parametertypenames);
/* Simulcrypt EIS protocol error values */
static const value_string eis_error_values[] = {
{ 0x0000, "DVB Reserved" },
{ 0x0001, "Invalid message" },
{ 0x0002, "Unsupported protocol version" },
{ 0x0003, "Unknown message_type value" },
{ 0x0004, "Message too long" },
{ 0x0005, "Inconsistent length for parameter" },
{ 0x0006, "Missing mandatory parameter" },
{ 0x0007, "Invalid value for parameter" },
{ 0x0008, "Unknown EIS_channel_ID value" },
{ 0x0009, "Unknown SCG_ID value" },
{ 0x000A, "Max SCGs already defined" },
{ 0x000B, "Service level SCG definitions not supportend" },
{ 0x000C, "Elementary Stream level SCG definitions not supported" },
{ 0x000D, "Activation_time possibly too soon for SCS to be accurate" },
{ 0x000E, "SCG definition cannot span transport boundaries" },
{ 0x000F, "A resource does not exist on this SCG" },
{ 0x0010, "A resource is already defined in an existing SCG" },
{ 0x0011, "SCG may not contain one or more content entries and no ECM_Group entries" },
{ 0x0012, "SCG may not contain one or more ECM_Group entries and no content entries" },
{ 0x0013, "EIS_channel_ID value already in use" },
{ 0x0014, "Unknown Super_CAS_Id" },
{ 0x7000, "Unknown error" },
{ 0x7001, "Unrecoverable error" },
{ 0, NULL }
};
static value_string_ext eis_error_values_ext = VALUE_STRING_EXT_INIT(eis_error_values);
/* Simulcrypt PSIG Parameter Types */
#define SIMULCRYPT_PSIG_DVB_RESERVED 0x0000
#define SIMULCRYPT_PSIG_PSIG_TYPE 0x0001
#define SIMULCRYPT_PSIG_CHANNEL_ID 0x0002
#define SIMULCRYPT_PSIG_STREAM_ID 0x0003
#define SIMULCRYPT_PSIG_TRANSPORT_STREAM_ID 0x0004
#define SIMULCRYPT_PSIG_ORIGINAL_NETWORK_ID 0x0005
#define SIMULCRYPT_PSIG_PACKET_ID 0x0006
#define SIMULCRYPT_PSIG_INTERFACE_MODE_CONFIGURATION 0x0007
#define SIMULCRYPT_PSIG_MAX_STREAM 0x0008
#define SIMULCRYPT_PSIG_TABLE_PERIOD_PAIR 0x0009
#define SIMULCRYPT_PSIG_MPEG_SECTION 0x000A
#define SIMULCRYPT_PSIG_REPETITION_RATE 0x000B
#define SIMULCRYPT_PSIG_ACTIVATION_TIME 0x000C
#define SIMULCRYPT_PSIG_DATAGRAM 0x000D
#define SIMULCRYPT_PSIG_BANDWIDTH 0x000E
#define SIMULCRYPT_PSIG_INITIAL_BANDWIDTH 0x000F
#define SIMULCRYPT_PSIG_MAX_COMP_TIME 0x0010
#define SIMULCRYPT_PSIG_ASI_INPUT_PACKET_ID 0x0011
#define SIMULCRYPT_PSIG_ERROR_STATUS 0x7000
#define SIMULCRYPT_PSIG_ERROR_INFORMATION 0x7001
static const value_string psig_parametertypenames[] = {
{ SIMULCRYPT_PSIG_DVB_RESERVED, "DVB_RESERVED" },
{ SIMULCRYPT_PSIG_PSIG_TYPE, "PSIG_TYPE" },
{ SIMULCRYPT_PSIG_CHANNEL_ID, "PSIG_CHANNEL_ID" },
{ SIMULCRYPT_PSIG_STREAM_ID, "STREAM_ID" },
{ SIMULCRYPT_PSIG_TRANSPORT_STREAM_ID, "TRANSPORT_STREAM_ID" },
{ SIMULCRYPT_PSIG_ORIGINAL_NETWORK_ID, "ORIGINAL_NETWORK_ID" },
{ SIMULCRYPT_PSIG_PACKET_ID, "PACKET_ID" },
{ SIMULCRYPT_PSIG_INTERFACE_MODE_CONFIGURATION, "INTERFACE_MODE_CONFIGURATION" },
{ SIMULCRYPT_PSIG_MAX_STREAM, "MAX_STREAM" },
{ SIMULCRYPT_PSIG_TABLE_PERIOD_PAIR, "TABLE_PERIOD_PAIR" },
{ SIMULCRYPT_PSIG_MPEG_SECTION, "MPEG_SECTION" },
{ SIMULCRYPT_PSIG_REPETITION_RATE, "REPETITION_RATE" },
{ SIMULCRYPT_PSIG_ACTIVATION_TIME, "ACTIVATION_TIME" },
{ SIMULCRYPT_PSIG_DATAGRAM, "DATAGRAM" },
{ SIMULCRYPT_PSIG_BANDWIDTH, "BANDWIDTH" },
{ SIMULCRYPT_PSIG_INITIAL_BANDWIDTH, "INITIAL_BANDWIDTH" },
{ SIMULCRYPT_PSIG_MAX_COMP_TIME, "MAX_COMP_TIME" },
{ SIMULCRYPT_PSIG_ASI_INPUT_PACKET_ID, "ASI_INPUT_PACKET_ID" },
{ SIMULCRYPT_PSIG_ERROR_STATUS, "ERROR_STATUS" },
{ SIMULCRYPT_PSIG_ERROR_INFORMATION, "ERROR_INFORMATION" },
{ 0, NULL }
};
static value_string_ext psig_parametertypenames_ext = VALUE_STRING_EXT_INIT(psig_parametertypenames);
#if 0
/* Simulcrypt PSIG protocol error values */
static const value_string psig_error_values[] = {
{ 0x0000, "DVB Reserved" },
{ 0x0001, "Invalid message" },
{ 0x0002, "Unsupported protocol version" },
{ 0x0003, "Unknown message_type value" },
{ 0x0004, "Message too long" },
{ 0x0005, "Unknown stream_ID value" },
{ 0x0006, "Unknown channel_ID value" },
{ 0x0007, "Too many channels on this MUX" },
{ 0x0008, "Too many data streams on this channel" },
{ 0x0009, "Too many data streams on this MUX" },
{ 0x000A, "Unknown parameter_type" },
{ 0x000B, "Inconsistent length for parameter" },
{ 0x000C, "Missing mandatory parameter" },
{ 0x000D, "Invalid value for parameter" },
{ 0x000E, "Inconsistent value of transport_stream_ID" },
{ 0x000F, "Inconsistent value of packet_ID" },
{ 0x0010, "channel_ID value already in use" },
{ 0x0011, "stream_ID value already in use" },
{ 0x0012, "Stream already open for this pair (transport_stream_ID, packet_ID)" },
{ 0x0013, "Overflow error when receiving the list of MPEG (CiM error type)" },
{ 0x0014, "Inconsistent format of TOT template (CiM error type)" },
{ 0x0015, "Warning: Difficulties in respecting the requested repetition_rates for the last 5 minutes (CiM error type)" },
{ 0x0016, "Warning: Difficulties in respecting the requested Bandwidth for the last 5 minutes (CiM error type)" },
{ 0x7000, "Unknown error" },
{ 0x7001, "Unrecoverable error" },
{ 0, NULL }
};
static value_string_ext psig_error_values_ext = VALUE_STRING_EXT_INIT(psig_error_values);
#endif
/* The following hf_* variables are used to hold the Wireshark IDs of
* our header fields; they are filled out when we call
* proto_register_field_array() in proto_register_simulcrypt()
*/
static gint hf_simulcrypt_header = -1;
static gint hf_simulcrypt_version = -1;
static gint hf_simulcrypt_message_type = -1;
static gint hf_simulcrypt_interface = -1;
static gint hf_simulcrypt_message_length = -1;
static gint hf_simulcrypt_message = -1;
static gint hf_simulcrypt_parameter = -1;
static gint hf_simulcrypt_parameter_type = -1;
static gint hf_simulcrypt_ecmg_parameter_type = -1;
static gint hf_simulcrypt_emmg_parameter_type = -1;
static gint hf_simulcrypt_parameter_length = -1;
static gint hf_simulcrypt_ca_system_id = -1;
static gint hf_simulcrypt_ca_subsystem_id = -1;
static gint hf_simulcrypt_super_cas_id = -1;
static gint hf_simulcrypt_section_tspkt_flag = -1;
static gint hf_simulcrypt_ecm_channel_id = -1;
static gint hf_simulcrypt_delay_start = -1;
static gint hf_simulcrypt_delay_stop = -1;
static gint hf_simulcrypt_ac_delay_start = -1;
static gint hf_simulcrypt_ac_delay_stop = -1;
static gint hf_simulcrypt_transition_delay_start = -1;
static gint hf_simulcrypt_transition_delay_stop = -1;
static gint hf_simulcrypt_ecm_rep_period = -1;
static gint hf_simulcrypt_max_streams = -1;
static gint hf_simulcrypt_min_cp_duration = -1;
static gint hf_simulcrypt_lead_cw = -1;
static gint hf_simulcrypt_cw_per_msg = -1;
static gint hf_simulcrypt_max_comp_time = -1;
static gint hf_simulcrypt_access_criteria = -1;
static gint hf_simulcrypt_ecm_stream_id = -1;
static gint hf_simulcrypt_nominal_cp_duration = -1;
static gint hf_simulcrypt_access_criteria_transfer_mode = -1;
static gint hf_simulcrypt_cp_number = -1;
static gint hf_simulcrypt_cp_duration = -1;
static gint hf_simulcrypt_cp_cw_combination = -1;
static gint hf_simulcrypt_ecm_datagram = -1;
static gint hf_simulcrypt_cw_encryption = -1;
static gint hf_simulcrypt_ecm_id = -1;
static gint hf_simulcrypt_client_id = -1;
static gint hf_simulcrypt_data_channel_id = -1;
static gint hf_simulcrypt_data_stream_id = -1;
static gint hf_simulcrypt_datagram = -1;
static gint hf_simulcrypt_bandwidth = -1;
static gint hf_simulcrypt_data_type = -1;
static gint hf_simulcrypt_data_id = -1;
static gint hf_simulcrypt_ecmg_error_status = -1;
static gint hf_simulcrypt_emmg_error_status = -1;
static gint hf_simulcrypt_error_information = -1;
static gint hf_simulcrypt_eis_parameter_type = -1;
static gint hf_simulcrypt_eis_channel_id = -1;
static gint hf_simulcrypt_service_flag = -1;
static gint hf_simulcrypt_component_flag = -1;
static gint hf_simulcrypt_max_scg = -1;
static gint hf_simulcrypt_ecm_group = -1;
static gint hf_simulcrypt_scg_id = -1;
static gint hf_simulcrypt_scg_reference_id = -1;
static gint hf_simulcrypt_activation_time = -1;
static gint hf_simulcrypt_year = -1;
static gint hf_simulcrypt_month = -1;
static gint hf_simulcrypt_day = -1;
static gint hf_simulcrypt_hour = -1;
static gint hf_simulcrypt_minute = -1;
static gint hf_simulcrypt_second = -1;
static gint hf_simulcrypt_hundredth_second = -1;
static gint hf_simulcrypt_activation_pending_flag = -1;
static gint hf_simulcrypt_component_id = -1;
static gint hf_simulcrypt_service_id = -1;
static gint hf_simulcrypt_transport_stream_id = -1;
static gint hf_simulcrypt_ac_changed_flag = -1;
static gint hf_simulcrypt_scg_current_reference_id = -1;
static gint hf_simulcrypt_scg_pending_reference_id = -1;
static gint hf_simulcrypt_cp_duration_flag = -1;
static gint hf_simulcrypt_recommended_cp_duration = -1;
static gint hf_simulcrypt_scg_nominal_cp_duration = -1;
static gint hf_simulcrypt_original_network_id = -1;
static gint hf_simulcrypt_eis_error_status = -1;
static gint hf_simulcrypt_error_description = -1;
static gint hf_simulcrypt_psig_parameter_type = -1;
static gint hf_simulcrypt_psig_type = -1;
static gint hf_simulcrypt_channel_id = -1;
static gint hf_simulcrypt_stream_id = -1;
static gint hf_simulcrypt_packet_id = -1;
static gint hf_simulcrypt_interface_mode_configuration = -1;
static gint hf_simulcrypt_max_stream = -1;
static gint hf_simulcrypt_table_period_pair = -1;
static gint hf_simulcrypt_mpeg_section = -1;
static gint hf_simulcrypt_repetition_rate = -1;
static gint hf_simulcrypt_initial_bandwidth = -1;
static gint hf_simulcrypt_asi_input_packet_id = -1;
static gint hf_simulcrypt_psig_error_status = -1;
static gint hf_simulcrypt_parameter_value = -1;
/* These are the ids of the subtrees that we may be creating */
static gint ett_simulcrypt = -1;
static gint ett_simulcrypt_header = -1;
static gint ett_simulcrypt_message = -1;
static gint ett_simulcrypt_parameter = -1;
static gint ett_simulcrypt_super_cas_id = -1;
static gint ett_simulcrypt_ecm_datagram = -1;
static gint ett_simulcrypt_ecm_group = -1;
static gint ett_simulcrypt_activation_time = -1;
static gint ett_simulcrypt_table_period_pair = -1;
#define FRAME_HEADER_LEN 8
/* The main dissecting routine */
static int
dissect_simulcrypt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, FRAME_HEADER_LEN,
get_simulcrypt_message_len, dissect_simulcrypt_message, data);
return tvb_captured_length(tvb);
}
/* Informative tree structure is shown here:
* TREE -
* - HEADER
* version
* message type
* message length
* - MESSAGE
* - TYPE of parameter
* length of parameter
value of parameter
- PARAMETER (optional branch for certain parameters only)
* parameter value sub items here
* End informative tree structure
*/
static guint16
get_interface (guint16 type)
{
int interface;
if (type >= 0x8000) {
return SIMULCRYPT_USER_DEFINED;
}
/* Hex values fetched from Table 3: Message-type values for command/response-based protocols */
switch (type & 0xFFF0) {
case 0x0000:
case 0x0100:
case 0x0200:
interface = SIMULCRYPT_ECMG_SCS;
break;
case 0x0010:
case 0x0110:
case 0x0210:
interface = SIMULCRYPT_EMMG_MUX;
break;
case 0x0310:
case 0x0320:
interface = SIMULCRYPT_CPSIG_PSIG;
break;
case 0x0400:
interface = SIMULCRYPT_EIS_SCS;
break;
case 0x0410:
case 0x0420:
interface = SIMULCRYPT_PSIG_MUX;
break;
case 0x0430:
interface = SIMULCRYPT_MUX_CIM;
break;
case 0x0440:
interface = SIMULCRYPT_PSIG_CIP;
break;
default:
interface = SIMULCRYPT_RESERVED;
break;
}
return interface;
}
static void
dissect_ecmg_parameter_value (proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, guint32 offset,
guint16 plen, guint16 ptype, gchar *pvalue_char)
{
proto_item *simulcrypt_item;
proto_tree *simulcrypt_super_cas_id_tree;
proto_tree *simulcrypt_ecm_datagram_tree;
tvbuff_t *next_tvb;
guint32 pvaluedec; /* parameter decimal value */
int ca_system_id;
guint i;
switch (ptype) {
case SIMULCRYPT_ECMG_SUPER_CAS_ID:
/* add super_cas_id item */
simulcrypt_item = proto_tree_add_item(tree, hf_simulcrypt_super_cas_id, tvb, offset, plen, ENC_BIG_ENDIAN); /* value item */
simulcrypt_super_cas_id_tree = proto_item_add_subtree(simulcrypt_item, ett_simulcrypt_super_cas_id);
/* Simulcrypt_super_cas_id_tree */
simulcrypt_item = proto_tree_add_item(simulcrypt_super_cas_id_tree, hf_simulcrypt_ca_system_id, tvb, offset, 2, ENC_BIG_ENDIAN );
/* Test for known CA_System_ID */
ca_system_id = tvb_get_ntohs(tvb,offset);
for(i=0;i<ECM_INTERPRETATION_SIZE;i++)
{
if(tab_ecm_inter[i].ca_system_id==ca_system_id)
{
tab_ecm_inter[i].ecmg_port=pinfo->destport;
proto_item_append_text(simulcrypt_item, ", Port %d, Protocol %s",tab_ecm_inter[i].ecmg_port, tab_ecm_inter[i].protocol_name);
break;
}
}
proto_tree_add_item(simulcrypt_super_cas_id_tree, hf_simulcrypt_ca_subsystem_id, tvb, offset+2, 2, ENC_BIG_ENDIAN );
break;
case SIMULCRYPT_ECMG_SECTION_TSPKT_FLAG:
proto_tree_add_item(tree, hf_simulcrypt_section_tspkt_flag, tvb, offset, plen, ENC_BIG_ENDIAN); /* value item */
break;
case SIMULCRYPT_ECMG_ECM_CHANNEL_ID:
proto_tree_add_item(tree, hf_simulcrypt_ecm_channel_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_DELAY_START:
proto_tree_add_item(tree, hf_simulcrypt_delay_start, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_DELAY_STOP:
proto_tree_add_item(tree, hf_simulcrypt_delay_stop, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_TRANSITION_DELAY_START:
proto_tree_add_item(tree, hf_simulcrypt_transition_delay_start, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_TRANSITION_DELAY_STOP:
proto_tree_add_item(tree, hf_simulcrypt_transition_delay_stop, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_AC_DELAY_START:
proto_tree_add_item(tree, hf_simulcrypt_ac_delay_start, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_AC_DELAY_STOP:
proto_tree_add_item(tree, hf_simulcrypt_ac_delay_stop, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_ECM_REP_PERIOD:
proto_tree_add_item(tree, hf_simulcrypt_ecm_rep_period, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_MAX_STREAMS:
proto_tree_add_item(tree, hf_simulcrypt_max_streams, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_MIN_CP_DURATION:
/* convert value to ms (in units 100 ms) */
pvaluedec = tvb_get_ntohs(tvb, offset); /* read 2 byte min CP duration value */
pvaluedec = pvaluedec*100; /* in ms now */
simulcrypt_item = proto_tree_add_item(tree, hf_simulcrypt_min_cp_duration, tvb, offset, plen, ENC_BIG_ENDIAN);
proto_item_append_text(simulcrypt_item, " (%d ms)",pvaluedec);
break;
case SIMULCRYPT_ECMG_LEAD_CW:
proto_tree_add_item(tree, hf_simulcrypt_lead_cw, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_CW_PER_MESSAGE:
proto_tree_add_item(tree, hf_simulcrypt_cw_per_msg, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_MAX_COMP_TIME:
proto_tree_add_item(tree, hf_simulcrypt_max_comp_time, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_ACCESS_CRITERIA:
proto_tree_add_item(tree, hf_simulcrypt_access_criteria, tvb, offset, plen, ENC_NA);
break;
case SIMULCRYPT_ECMG_ECM_STREAM_ID:
proto_tree_add_item(tree, hf_simulcrypt_ecm_stream_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_NOMINAL_CP_DURATION:
/* convert value to ms (in units 100 ms) */
pvaluedec = tvb_get_ntohs(tvb, offset); /* read 2 byte nominal CP duration value */
pvaluedec = pvaluedec*100; /* in ms now */
simulcrypt_item = proto_tree_add_item(tree, hf_simulcrypt_nominal_cp_duration, tvb, offset, plen, ENC_BIG_ENDIAN);
proto_item_append_text(simulcrypt_item, " (%d ms)", pvaluedec);
break;
case SIMULCRYPT_ECMG_ACCESS_CRITERIA_TRANSFER_MODE:
proto_tree_add_item(tree, hf_simulcrypt_access_criteria_transfer_mode, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_CP_NUMBER:
proto_tree_add_item(tree, hf_simulcrypt_cp_number, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_CP_DURATION:
/* convert value to ms (in units 100 ms) */
pvaluedec = tvb_get_ntohs(tvb, offset); /* read 2 byte CP duration value */
pvaluedec = pvaluedec*100; /* in ms now */
simulcrypt_item = proto_tree_add_item(tree, hf_simulcrypt_cp_duration, tvb, offset, plen, ENC_BIG_ENDIAN);
proto_item_append_text(simulcrypt_item, " (%d ms)", pvaluedec);
break;
case SIMULCRYPT_ECMG_CP_CW_COMBINATION:
proto_tree_add_item(tree, hf_simulcrypt_cp_cw_combination, tvb, offset, plen, ENC_NA);
break;
case SIMULCRYPT_ECMG_ECM_DATAGRAM:
simulcrypt_item = proto_tree_add_item(tree, hf_simulcrypt_ecm_datagram, tvb, offset, plen, ENC_NA);
/* Test srcport against table of ECMG ports & CA_System_ID for known protocol types */
for(i=0;i<ECM_INTERPRETATION_SIZE;i++)
{
if(tab_ecm_inter[i].ecmg_port==pinfo->srcport) /* ECMG source port */
{ /* recognise port & ca_system_id and hence protocol name for ECM datagram */
next_tvb = tvb_new_subset_remaining(tvb, offset);
simulcrypt_ecm_datagram_tree = proto_item_add_subtree(simulcrypt_item, ett_simulcrypt_ecm_datagram);
if(tab_ecm_inter[i].protocol_handle != NULL)
{
call_dissector(tab_ecm_inter[i].protocol_handle, next_tvb,pinfo, simulcrypt_ecm_datagram_tree);
}
break;
}
}
break;
case SIMULCRYPT_ECMG_CW_ENCRYPTION:
proto_tree_add_item(tree, hf_simulcrypt_cw_encryption, tvb, offset, plen, ENC_NA);
break;
case SIMULCRYPT_ECMG_ECM_ID:
proto_tree_add_item(tree, hf_simulcrypt_ecm_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_ERROR_STATUS:
proto_tree_add_item(tree, hf_simulcrypt_ecmg_error_status, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_ECMG_ERROR_INFORMATION:
proto_tree_add_item(tree, hf_simulcrypt_error_information, tvb, offset, plen, ENC_NA);
break;
default: /* Unknown parameter type */
proto_tree_add_string(tree, hf_simulcrypt_parameter_value, tvb, offset, plen, pvalue_char);
break;
} /* end parameter type switch */
}
static void
dissect_emmg_parameter_value (proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, guint32 offset,
guint16 plen, guint16 ptype, gchar *pvalue_char)
{
switch (ptype) {
case SIMULCRYPT_EMMG_CLIENT_ID:
proto_tree_add_item(tree, hf_simulcrypt_client_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EMMG_SECTION_TSPKT_FLAG:
proto_tree_add_item(tree, hf_simulcrypt_section_tspkt_flag, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EMMG_DATA_CHANNEL_ID:
proto_tree_add_item(tree, hf_simulcrypt_data_channel_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EMMG_DATA_STREAM_ID:
proto_tree_add_item(tree, hf_simulcrypt_data_stream_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EMMG_DATAGRAM:
proto_tree_add_item(tree, hf_simulcrypt_datagram, tvb, offset, plen, ENC_NA);
break;
case SIMULCRYPT_EMMG_BANDWIDTH:
proto_tree_add_item(tree, hf_simulcrypt_bandwidth, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EMMG_DATA_TYPE:
proto_tree_add_item(tree, hf_simulcrypt_data_type, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EMMG_DATA_ID:
proto_tree_add_item(tree, hf_simulcrypt_data_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EMMG_ERROR_STATUS:
proto_tree_add_item(tree, hf_simulcrypt_emmg_error_status, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EMMG_ERROR_INFORMATION:
proto_tree_add_item(tree, hf_simulcrypt_error_information, tvb, offset, plen, ENC_NA);
break;
default: /* Unknown parameter type */
proto_tree_add_string(tree, hf_simulcrypt_parameter_value, tvb, offset, plen, pvalue_char);
break;
} /* end parameter type switch */
}
static void
dissect_eis_parameter_value (proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, guint32 offset,
guint16 plen, guint16 ptype, gchar *pvalue_char)
{
proto_item *simulcrypt_item;
proto_tree *simulcrypt_super_cas_id_tree;
proto_tree *simulcrypt_ecm_group_tree;
proto_tree *simulcrypt_activation_time_tree;
guint32 pvaluedec; /* parameter decimal value */
int ca_system_id;
guint i;
switch (ptype) {
case SIMULCRYPT_EIS_CHANNEL_ID:
proto_tree_add_item(tree, hf_simulcrypt_eis_channel_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_SERVICE_FLAG:
proto_tree_add_item(tree, hf_simulcrypt_service_flag, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_COMPONENT_FLAG:
proto_tree_add_item(tree, hf_simulcrypt_component_flag, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_MAX_SCG:
proto_tree_add_item(tree, hf_simulcrypt_max_scg, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_ECM_GROUP:
/* add ECM_Group item */
simulcrypt_item = proto_tree_add_item(tree, hf_simulcrypt_ecm_group, tvb, offset, plen, ENC_NA); /* value item */
/* create subtree */
simulcrypt_ecm_group_tree = proto_item_add_subtree(simulcrypt_item, ett_simulcrypt_ecm_group);
/* dissect subtree */
dissect_simulcrypt_data(simulcrypt_ecm_group_tree, simulcrypt_item, pinfo, tvb, tree, offset, plen, SIMULCRYPT_EIS_SCS, TRUE);
break;
case SIMULCRYPT_EIS_SCG_ID:
proto_tree_add_item(tree, hf_simulcrypt_scg_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_SCG_REFERENCE_ID:
proto_tree_add_item(tree, hf_simulcrypt_scg_reference_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_SUPER_CAS_ID:
/* add super_cas_id item */
simulcrypt_item = proto_tree_add_item(tree, hf_simulcrypt_super_cas_id, tvb, offset, plen, ENC_BIG_ENDIAN); /* value item */
simulcrypt_super_cas_id_tree = proto_item_add_subtree(simulcrypt_item, ett_simulcrypt_super_cas_id);
/* Simulcrypt_super_cas_id_tree */
simulcrypt_item = proto_tree_add_item(simulcrypt_super_cas_id_tree, hf_simulcrypt_ca_system_id, tvb, offset, 2, ENC_BIG_ENDIAN );
/* Test for known CA_System_ID */
ca_system_id = tvb_get_ntohs(tvb,offset);
for(i=0;i<ECM_INTERPRETATION_SIZE;i++)
{
if(tab_ecm_inter[i].ca_system_id==ca_system_id)
{
tab_ecm_inter[i].ecmg_port=pinfo->destport;
proto_item_append_text(simulcrypt_item, ", Port %d, Protocol %s",tab_ecm_inter[i].ecmg_port, tab_ecm_inter[i].protocol_name);
break;
}
}
proto_tree_add_item(simulcrypt_super_cas_id_tree, hf_simulcrypt_ca_subsystem_id, tvb, offset+2, 2, ENC_BIG_ENDIAN );
break;
case SIMULCRYPT_EIS_ECM_ID:
proto_tree_add_item(tree, hf_simulcrypt_ecm_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_ACCESS_CRITERIA:
proto_tree_add_item(tree, hf_simulcrypt_access_criteria, tvb, offset, plen, ENC_NA);
break;
case SIMULCRYPT_EIS_ACTIVATION_TIME:
simulcrypt_item = proto_tree_add_item(tree, hf_simulcrypt_activation_time, tvb, offset, plen, ENC_NA); /* value item */
/* create subtree */
simulcrypt_activation_time_tree = proto_item_add_subtree(simulcrypt_item, ett_simulcrypt_activation_time);
/* dissect subtree */
proto_tree_add_item(simulcrypt_activation_time_tree, hf_simulcrypt_year, tvb, offset, 2, ENC_BIG_ENDIAN); /* first 2 bytes */
proto_tree_add_item(simulcrypt_activation_time_tree, hf_simulcrypt_month, tvb, offset+2, 1, ENC_BIG_ENDIAN); /* third byte */
proto_tree_add_item(simulcrypt_activation_time_tree, hf_simulcrypt_day, tvb, offset+3, 1, ENC_BIG_ENDIAN); /*fourth byte */
proto_tree_add_item(simulcrypt_activation_time_tree, hf_simulcrypt_hour, tvb, offset+4, 1, ENC_BIG_ENDIAN); /*fifth byte */
proto_tree_add_item(simulcrypt_activation_time_tree, hf_simulcrypt_minute, tvb, offset+5, 1, ENC_BIG_ENDIAN); /* sixth byte */
proto_tree_add_item(simulcrypt_activation_time_tree, hf_simulcrypt_second, tvb, offset+6, 1, ENC_BIG_ENDIAN); /* seventh byte */
proto_tree_add_item(simulcrypt_activation_time_tree, hf_simulcrypt_hundredth_second, tvb, offset+7, 1, ENC_BIG_ENDIAN); /* eighth byte */
break;
case SIMULCRYPT_EIS_ACTIVATION_PENDING_FLAG:
proto_tree_add_item(tree, hf_simulcrypt_activation_pending_flag, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_COMPONENT_ID:
proto_tree_add_item(tree, hf_simulcrypt_component_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_SERVICE_ID:
proto_tree_add_item(tree, hf_simulcrypt_service_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_TRANSPORT_STREAM_ID:
proto_tree_add_item(tree, hf_simulcrypt_transport_stream_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_AC_CHANGED_FLAG:
proto_tree_add_item(tree, hf_simulcrypt_ac_changed_flag, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_SCG_CURRENT_REFERENCE_ID:
proto_tree_add_item(tree, hf_simulcrypt_scg_current_reference_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_SCG_PENDING_REFERENCE_ID:
proto_tree_add_item(tree, hf_simulcrypt_scg_pending_reference_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_CP_DURATION_FLAG:
proto_tree_add_item(tree, hf_simulcrypt_cp_duration_flag, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_RECOMMENDED_CP_DURATION:
/* convert value to ms (in units 100 ms) */
pvaluedec = tvb_get_ntohs(tvb, offset); /* read 2 byte CP duration value */
pvaluedec = pvaluedec*100; /* in ms now */
simulcrypt_item = proto_tree_add_item(tree, hf_simulcrypt_recommended_cp_duration, tvb, offset, plen, ENC_BIG_ENDIAN);
proto_item_append_text(simulcrypt_item, " (%d ms)", pvaluedec);
break;
case SIMULCRYPT_EIS_SCG_NOMINAL_CP_DURATION:
/* convert value to ms (in units 100 ms) */
pvaluedec = tvb_get_ntohs(tvb, offset); /* read 2 byte CP duration value */
pvaluedec = pvaluedec*100; /* in ms now */
simulcrypt_item = proto_tree_add_item(tree, hf_simulcrypt_scg_nominal_cp_duration, tvb, offset, plen, ENC_BIG_ENDIAN);
proto_item_append_text(simulcrypt_item, " (%d ms)", pvaluedec);
break;
case SIMULCRYPT_EIS_ORIGINAL_NETWORK_ID:
proto_tree_add_item(tree, hf_simulcrypt_original_network_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_ERROR_STATUS:
proto_tree_add_item(tree, hf_simulcrypt_eis_error_status, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_ERROR_INFORMATION:
proto_tree_add_item(tree, hf_simulcrypt_error_information, tvb, offset, plen, ENC_NA);
break;
case SIMULCRYPT_EIS_ERROR_DESCRIPTION:
proto_tree_add_item(tree, hf_simulcrypt_error_description, tvb, offset, plen, ENC_ASCII);
break;
default: /* Unknown parameter type */
proto_tree_add_string(tree, hf_simulcrypt_parameter_value, tvb, offset, plen, pvalue_char);
break;
} /* end parameter type switch */
}
static void
dissect_psig_parameter_value (proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, guint32 offset,
guint16 plen, guint16 ptype, gchar *pvalue_char)
{
proto_tree *simulcrypt_psig_table_period_pair_tree;
proto_tree *simulcrypt_activation_time_tree;
proto_item *simulcrypt_item;
guint32 pvaluedec; /* parameter decimal value */
switch (ptype) {
case SIMULCRYPT_PSIG_PSIG_TYPE:
pvaluedec = tvb_get_guint8(tvb, offset);
simulcrypt_item = proto_tree_add_item(tree, hf_simulcrypt_psig_type, tvb, offset, plen, ENC_BIG_ENDIAN);
switch(pvaluedec){
case 1:
proto_item_append_text(simulcrypt_item, " (PSIG)");
break;
case 2:
proto_item_append_text(simulcrypt_item, " (SIG)");
break;
case 3:
proto_item_append_text(simulcrypt_item, " (PSISIG)");
break;
default:
break;
}
break;
case SIMULCRYPT_PSIG_CHANNEL_ID:
proto_tree_add_item(tree, hf_simulcrypt_channel_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_PSIG_STREAM_ID:
proto_tree_add_item(tree, hf_simulcrypt_stream_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_PSIG_TRANSPORT_STREAM_ID:
proto_tree_add_item(tree, hf_simulcrypt_transport_stream_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_PSIG_ORIGINAL_NETWORK_ID:
proto_tree_add_item(tree, hf_simulcrypt_original_network_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_PSIG_PACKET_ID:
proto_tree_add_item(tree, hf_simulcrypt_packet_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_PSIG_INTERFACE_MODE_CONFIGURATION:
proto_tree_add_item(tree, hf_simulcrypt_interface_mode_configuration, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_PSIG_MAX_STREAM:
proto_tree_add_item(tree, hf_simulcrypt_max_stream, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_PSIG_TABLE_PERIOD_PAIR:
simulcrypt_item = proto_tree_add_item(tree, hf_simulcrypt_table_period_pair, tvb, offset, plen, ENC_NA); /* value item */
/* create subtree */
simulcrypt_psig_table_period_pair_tree = proto_item_add_subtree(simulcrypt_item, ett_simulcrypt_table_period_pair);
/* dissect subtree */
dissect_simulcrypt_data(simulcrypt_psig_table_period_pair_tree, simulcrypt_item, pinfo, tvb, tree, offset, plen, SIMULCRYPT_MUX_CIM, TRUE);
break;
case SIMULCRYPT_PSIG_MPEG_SECTION:
proto_tree_add_item(tree, hf_simulcrypt_mpeg_section, tvb, offset, plen, ENC_NA);
break;
case SIMULCRYPT_PSIG_REPETITION_RATE:
proto_tree_add_item(tree, hf_simulcrypt_repetition_rate, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_PSIG_ACTIVATION_TIME:
simulcrypt_item = proto_tree_add_item(tree, hf_simulcrypt_activation_time, tvb, offset, plen, ENC_NA); /* value item */
/* create subtree */
simulcrypt_activation_time_tree = proto_item_add_subtree(simulcrypt_item, ett_simulcrypt_activation_time);
/* dissect subtree */
proto_tree_add_item(simulcrypt_activation_time_tree, hf_simulcrypt_year, tvb, offset, 2, ENC_BIG_ENDIAN); /* first 2 bytes */
proto_tree_add_item(simulcrypt_activation_time_tree, hf_simulcrypt_month, tvb, offset+2, 1, ENC_BIG_ENDIAN); /* third byte */
proto_tree_add_item(simulcrypt_activation_time_tree, hf_simulcrypt_day, tvb, offset+3, 1, ENC_BIG_ENDIAN); /*fourth byte */
proto_tree_add_item(simulcrypt_activation_time_tree, hf_simulcrypt_hour, tvb, offset+4, 1, ENC_BIG_ENDIAN); /*fifth byte */
proto_tree_add_item(simulcrypt_activation_time_tree, hf_simulcrypt_minute, tvb, offset+5, 1, ENC_BIG_ENDIAN); /* sixth byte */
proto_tree_add_item(simulcrypt_activation_time_tree, hf_simulcrypt_second, tvb, offset+6, 1, ENC_BIG_ENDIAN); /* seventh byte */
proto_tree_add_item(simulcrypt_activation_time_tree, hf_simulcrypt_hundredth_second, tvb, offset+7, 1, ENC_BIG_ENDIAN); /* eighth byte */
break;
case SIMULCRYPT_PSIG_DATAGRAM:
proto_tree_add_item(tree, hf_simulcrypt_datagram, tvb, offset, plen, ENC_NA);
break;
case SIMULCRYPT_PSIG_BANDWIDTH:
proto_tree_add_item(tree, hf_simulcrypt_bandwidth, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_PSIG_INITIAL_BANDWIDTH:
proto_tree_add_item(tree, hf_simulcrypt_initial_bandwidth, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_PSIG_MAX_COMP_TIME:
proto_tree_add_item(tree, hf_simulcrypt_max_comp_time, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_PSIG_ASI_INPUT_PACKET_ID:
proto_tree_add_item(tree, hf_simulcrypt_asi_input_packet_id, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_PSIG_ERROR_STATUS:
proto_tree_add_item(tree, hf_simulcrypt_psig_error_status, tvb, offset, plen, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_PSIG_ERROR_INFORMATION:
proto_tree_add_item(tree, hf_simulcrypt_error_information, tvb, offset, plen, ENC_NA);
break;
default: /* Unknown parameter type */
proto_tree_add_string(tree, hf_simulcrypt_parameter_value, tvb, offset, plen, pvalue_char);
break;
} /* end parameter type switch */
}
/* This method dissects fully reassembled messages */
static int
dissect_simulcrypt_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
proto_item *simulcrypt_item;
proto_tree *simulcrypt_tree;
proto_tree *simulcrypt_header_tree;
proto_tree *simulcrypt_message_tree;
guint16 type, iftype;
col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_TAG_SIMULCRYPT);
col_clear(pinfo->cinfo,COL_INFO);
/* get 2 byte type value */
type = tvb_get_ntohs(tvb, 1); /* 2 bytes starting at offset 1 are the message type */
iftype = get_interface (type);
col_add_fstr(pinfo->cinfo, COL_INFO, "%d > %d Info Type:[%s]",
pinfo->srcport, pinfo->destport,
val_to_str_ext(type, &messagetypenames_ext, "Unknown Type:0x%02x"));
if (tree)
{
/* we are being asked for details */
guint32 offset = 0;
guint32 msg_length;
simulcrypt_item = proto_tree_add_item(tree, proto_simulcrypt, tvb, 0, -1, ENC_NA);
simulcrypt_tree = proto_item_add_subtree(simulcrypt_item, ett_simulcrypt);
proto_item_append_text(simulcrypt_item, ", Interface: %s", val_to_str(iftype, interfacenames, "Unknown (0x%02x)"));
/* Simulcrypt_tree analysis */
/* we are being asked for details */
/* ADD HEADER BRANCH */
simulcrypt_item = proto_tree_add_item(simulcrypt_tree, hf_simulcrypt_header, tvb, offset, 5, ENC_NA );
simulcrypt_header_tree = proto_item_add_subtree(simulcrypt_item, ett_simulcrypt_header);
proto_item_append_text(simulcrypt_header_tree, ", Length: %s", "5 bytes"); /* add text to Header tree indicating Length 5 bytes */
/* Simulcrypt_header_tree analysis */
/* Message Version 1 Byte */
proto_tree_add_item(simulcrypt_header_tree, hf_simulcrypt_version, tvb, offset, 1, ENC_BIG_ENDIAN);
offset+=1;
/* Message Type 2 Bytes */
proto_tree_add_item(simulcrypt_header_tree, hf_simulcrypt_message_type, tvb, offset, 2, ENC_BIG_ENDIAN);
simulcrypt_item = proto_tree_add_uint_format_value(simulcrypt_header_tree, hf_simulcrypt_interface, tvb, offset, 2, iftype,
"%s", val_to_str_const(iftype, interfacenames, "Unknown"));
proto_item_set_generated (simulcrypt_item);
offset+=2;
/* Message Length 2 Bytes */
proto_tree_add_item(simulcrypt_header_tree, hf_simulcrypt_message_length, tvb, offset, 2, ENC_BIG_ENDIAN);
msg_length = tvb_get_ntohs(tvb, offset); /* read 2 byte message length value */
offset+=2;
/* ADD MESSAGE BRANCH */
simulcrypt_item = proto_tree_add_item(simulcrypt_tree, hf_simulcrypt_message, tvb, offset, -1, ENC_NA );
simulcrypt_message_tree = proto_item_add_subtree(simulcrypt_item, ett_simulcrypt_message);
proto_item_append_text(simulcrypt_message_tree, " containing TLV parameters"); /* add text to Message tree */
proto_item_append_text(simulcrypt_message_tree, ", Length: %d (bytes)", msg_length); /* add length info to message_tree */
/* end header details */
/* Simulcrypt_message_tree analysis */
/* we are being asked for details */
/* Navigate through message after header to find one or more parameters */
dissect_simulcrypt_data(simulcrypt_message_tree, simulcrypt_item, pinfo, tvb, tree, offset, (msg_length+5), iftype, FALSE); /* offset is from beginning of the 5 byte header */
} /* end tree */
return tvb_captured_length(tvb);
}
/* this method is used to dissect TLV parameters */
/* can be used both from the main tree (simulcrypt_message_tree) and the subtrees (created from TLV items) */
static void
dissect_simulcrypt_data(proto_tree *simulcrypt_tree, proto_item *simulcrypt_item, packet_info *pinfo _U_,
tvbuff_t *tvb, proto_tree *tree, int offset,
int container_data_length, guint16 iftype, gboolean is_subtree)
{
int subtree_offset = 0;
proto_tree *simulcrypt_parameter_tree;
int applied_offset;
if(is_subtree)
{
applied_offset = subtree_offset;
}
else
{
applied_offset = offset;
}
while (applied_offset < container_data_length)
{
guint16 plen; /* parameter length */
guint16 ptype; /* parameter type */
gchar *pvalue_char; /* parameter value string */
/* Parameter Type 2 Bytes */
ptype = tvb_get_ntohs(tvb, offset); /* read 2 byte type value */
/* Parameter Length 2 Bytes */
plen = tvb_get_ntohs(tvb, offset+2); /* read 2 byte length value */
/* Parameter Value plen Bytes */
pvalue_char = tvb_bytes_to_str(pinfo->pool, tvb, offset+4, plen);
simulcrypt_item = proto_tree_add_item(simulcrypt_tree, hf_simulcrypt_parameter, tvb, offset, plen+2+2, ENC_NA );
/* add length and value info to type */
switch (iftype) {
case SIMULCRYPT_ECMG_SCS:
proto_item_append_text(simulcrypt_item, ": Type=%s", val_to_str_ext(ptype, &ecmg_parametertypenames_ext, "Unknown Type:0x%02x"));
break;
case SIMULCRYPT_EMMG_MUX:
proto_item_append_text(simulcrypt_item, ": Type=%s", val_to_str_ext(ptype, &emmg_parametertypenames_ext, "Unknown Type:0x%02x"));
break;
case SIMULCRYPT_EIS_SCS:
proto_item_append_text(simulcrypt_item, ": Type=%s", val_to_str_ext(ptype, &eis_parametertypenames_ext, "Unknown Type:0x%02x"));
break;
case SIMULCRYPT_PSIG_MUX:
case SIMULCRYPT_MUX_CIM:
case SIMULCRYPT_PSIG_CIP:
proto_item_append_text(simulcrypt_item, ": Type=%s", val_to_str_ext(ptype, &psig_parametertypenames_ext, "Unknown Type:0x%02x"));
break;
default:
proto_item_append_text(simulcrypt_item, ": Type=0x%02x", ptype);
break;
}
proto_item_append_text(simulcrypt_item, ", Value Length=%d (bytes)", plen); /* add length info to parameter */
proto_item_append_text(simulcrypt_item, ", Value=0x%s", pvalue_char); /* add value info to parameter */
/* add subtree for parameter type, length and value items */
simulcrypt_parameter_tree = proto_item_add_subtree(simulcrypt_item, ett_simulcrypt_parameter); /* add subtree for Length and Value */
switch (iftype) { /* parameter type */
case SIMULCRYPT_ECMG_SCS:
proto_tree_add_item(simulcrypt_parameter_tree, hf_simulcrypt_ecmg_parameter_type, tvb, offset, 2, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EMMG_MUX:
proto_tree_add_item(simulcrypt_parameter_tree, hf_simulcrypt_emmg_parameter_type, tvb, offset, 2, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_EIS_SCS:
proto_tree_add_item(simulcrypt_parameter_tree, hf_simulcrypt_eis_parameter_type, tvb, offset, 2, ENC_BIG_ENDIAN);
break;
case SIMULCRYPT_PSIG_MUX:
case SIMULCRYPT_MUX_CIM:
case SIMULCRYPT_PSIG_CIP:
proto_tree_add_item(simulcrypt_parameter_tree, hf_simulcrypt_psig_parameter_type, tvb, offset, 2, ENC_BIG_ENDIAN);
break;
default:
proto_tree_add_item(simulcrypt_parameter_tree, hf_simulcrypt_parameter_type, tvb, offset, 2, ENC_BIG_ENDIAN);
break;
}
proto_tree_add_item(simulcrypt_parameter_tree, hf_simulcrypt_parameter_length, tvb, offset+2, 2, ENC_BIG_ENDIAN); /* length item */
offset += 2+2; /* offset --> parameter value */
switch (iftype) {
case SIMULCRYPT_ECMG_SCS:
dissect_ecmg_parameter_value (simulcrypt_parameter_tree, tvb, pinfo, offset, plen, ptype, pvalue_char);
break;
case SIMULCRYPT_EMMG_MUX:
dissect_emmg_parameter_value (simulcrypt_parameter_tree, tvb, pinfo, offset, plen, ptype, pvalue_char);
break;
case SIMULCRYPT_EIS_SCS:
dissect_eis_parameter_value (simulcrypt_parameter_tree, tvb, pinfo, offset, plen, ptype, pvalue_char);
break;
case SIMULCRYPT_PSIG_MUX:
case SIMULCRYPT_MUX_CIM:
case SIMULCRYPT_PSIG_CIP:
dissect_psig_parameter_value (simulcrypt_parameter_tree, tvb, pinfo, offset, plen, ptype, pvalue_char);
break;
default:
proto_tree_add_string(tree, hf_simulcrypt_parameter_value, tvb, offset, plen, pvalue_char);
break;
}
offset += plen;
subtree_offset += 2+2+plen;
if(is_subtree)
{
applied_offset = subtree_offset;
}
else
{
applied_offset = offset;
}
} /* end parameter tree details */
}
/* determine PDU length of protocol foo */
static guint
get_simulcrypt_message_len(packet_info *pinfo _U_, tvbuff_t *tvb,
int offset, void *data _U_)
{
guint iLg;
iLg = tvb_get_ntohs(tvb,offset+3); /*length is at offset 3 */
iLg += 5; /* add 1 byte version + 2 byte type + 2 byte length (simulcrypt "header" */
return iLg;
}
/* Clean out the ecm_interpretation port association whenever */
/* making a pass through a capture file to dissect all its packets */
/* (e.g., reading in a new capture file, changing a simulcrypt pref, */
/* or running a "filter packets" or "colorize packets" pass over the */
/* current capture file. */
static void
simulcrypt_init(void)
{
guint i;
for(i=0;i<ECM_INTERPRETATION_SIZE;i++)
{
tab_ecm_inter[i].ecmg_port = -1;
}
}
void proto_reg_handoff_simulcrypt(void);
void
proto_register_simulcrypt (void)
{
/* A header field is something you can search/filter on.
*
* We create a structure to register our fields. It consists of an
* array of hf_register_info structures, each of which are of the format
* {&(field id), {name, abbrev, type, display, strings, bitmask, blurb, HFILL}}.
*/
static hf_register_info hf[] =
{
{ &hf_simulcrypt_header,
{ "Header", "simulcrypt.header", FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_version,
{ "Version", "simulcrypt.version", FT_UINT8, BASE_HEX, NULL, 0x0, /* version 1 byte */
NULL, HFILL }},
{ &hf_simulcrypt_message_type,
{ "Message Type", "simulcrypt.message.type", FT_UINT16, BASE_HEX|BASE_EXT_STRING, &messagetypenames_ext, 0x0, /* type 2 bytes */
NULL, HFILL }},
{ &hf_simulcrypt_interface,
{ "Interface", "simulcrypt.message.interface", FT_UINT16, BASE_DEC, VALS(interfacenames), 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_message_length,
{ "Message Length", "simulcrypt.message.len", FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_byte_bytes, 0x0, /* length 2 bytes, print as decimal value */
NULL, HFILL }},
{ &hf_simulcrypt_message,
{ "Message", "simulcrypt.message", FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_parameter,
{ "Parameter", "simulcrypt.parameter", FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_parameter_type,
{ "Parameter Type", "simulcrypt.parameter.type", FT_UINT16, BASE_HEX, NULL, 0x0, /* type 2 bytes */
NULL, HFILL }},
{ &hf_simulcrypt_ecmg_parameter_type,
{ "Parameter Type", "simulcrypt.parameter.type", FT_UINT16, BASE_HEX | BASE_EXT_STRING, &ecmg_parametertypenames_ext, 0x0, /* type 2 bytes */
NULL, HFILL }},
{ &hf_simulcrypt_emmg_parameter_type,
{ "Parameter Type", "simulcrypt.parameter.type", FT_UINT16, BASE_HEX | BASE_EXT_STRING, &emmg_parametertypenames_ext, 0x0, /* type 2 bytes */
NULL, HFILL }},
{ &hf_simulcrypt_parameter_length,
{ "Parameter Length", "simulcrypt.parameter.len", FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_byte_bytes, 0x0, /* length 2 bytes, print as decimal value */
NULL, HFILL }},
{ &hf_simulcrypt_ca_system_id,
{ "CA System ID", "simulcrypt.parameter.ca_system_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_ca_subsystem_id,
{ "CA Subsystem ID", "simulcrypt.parameter.ca_subsystem_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_super_cas_id,
{ "SuperCAS ID", "simulcrypt.super_cas_id", FT_UINT32, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_section_tspkt_flag,
{ "Section TS pkt flag", "simulcrypt.section_tspkt_flag", FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_ecm_channel_id,
{ "ECM channel ID", "simulcrypt.ecm_channel_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_delay_start,
{ "Delay start", "simulcrypt.delay_start", FT_INT16, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_delay_stop,
{ "Delay stop", "simulcrypt.delay_stop", FT_INT16, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_ac_delay_start,
{ "AC delay start", "simulcrypt.ac_delay_start", FT_INT16, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_ac_delay_stop,
{ "AC delay stop", "simulcrypt.ac_delay_stop", FT_INT16, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_transition_delay_start,
{ "Transition delay start", "simulcrypt.transition_delay_start", FT_INT16, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_transition_delay_stop,
{ "Transition delay stop", "simulcrypt.transition_delay_stop", FT_INT16, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_ecm_rep_period,
{ "ECM repetition period", "simulcrypt.ecm_rep_period", FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_max_streams,
{ "Max streams", "simulcrypt.max_streams", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_min_cp_duration,
{ "Min CP duration", "simulcrypt.min_cp_duration", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_lead_cw,
{ "Lead CW", "simulcrypt.lead_cw", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_cw_per_msg,
{ "CW per msg", "simulcrypt.cw_per_msg", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_max_comp_time,
{ "Max comp time", "simulcrypt.max_comp_time", FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_access_criteria,
{ "Access criteria", "simulcrypt.access_criteria", FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_ecm_stream_id,
{ "ECM stream ID", "simulcrypt.ecm_stream_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_nominal_cp_duration,
{ "Nominal CP duration", "simulcrypt.nominal_cp_duration", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_access_criteria_transfer_mode,
{ "AC transfer mode", "simulcrypt.access_criteria_transfer_mode", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_cp_number,
{ "CP number", "simulcrypt.cp_number", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_cp_duration,
{ "CP duration", "simulcrypt.cp_duration", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_cp_cw_combination,
{ "CP CW combination", "simulcrypt.cp_cw_combination", FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_ecm_datagram,
{ "ECM datagram", "simulcrypt.ecm_datagram", FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_cw_encryption,
{ "CW encryption", "simulcrypt.cw_encryption", FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_ecm_id,
{ "ECM ID", "simulcrypt.ecm_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_client_id,
{ "Client ID", "simulcrypt.client_id", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_data_channel_id,
{ "Data Channel ID", "simulcrypt.data_channel_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_data_stream_id,
{ "Data Stream ID", "simulcrypt.data_stream_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_datagram,
{ "Datagram", "simulcrypt.datagram", FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_bandwidth,
{ "Bandwidth", "simulcrypt.bandwidth", FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_data_type,
{ "Data Type", "simulcrypt.data_type", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_data_id,
{ "Data ID", "simulcrypt.data_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_ecmg_error_status,
{ "Error status", "simulcrypt.error_status", FT_UINT16, BASE_DEC | BASE_EXT_STRING, &ecmg_error_values_ext, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_emmg_error_status,
{ "Error status", "simulcrypt.error_status", FT_UINT16, BASE_DEC | BASE_EXT_STRING, &emmg_error_values_ext, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_error_information,
{ "Error information", "simulcrypt.error_information", FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_eis_parameter_type,
{ "Parameter Type", "simulcrypt.parameter.type", FT_UINT16, BASE_HEX | BASE_EXT_STRING, &eis_parametertypenames_ext, 0x0, /* type 2 bytes */
NULL, HFILL }},
{ &hf_simulcrypt_eis_channel_id,
{ "EIS channel ID", "simulcrypt.parameter.eis_channel_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_service_flag,
{ "Service flag", "simulcrypt.parameter.service_flag", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_component_flag,
{ "Component flag", "simulcrypt.parameter.component_flag", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_max_scg,
{ "Max SCG", "simulcrypt.parameter.max_scg", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_ecm_group,
{ "ECM group", "simulcrypt.parameter.ecm_group", FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_scg_id,
{ "SCG ID", "simulcrypt.parameter.scg_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_scg_reference_id,
{ "SCG reference ID", "simulcrypt.parameter.scg_reference_id", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_activation_time,
{ "Activation time", "simulcrypt.parameter.activation_time", FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_year,
{ "Year", "simulcrypt.parameter.year", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_month,
{ "Month", "simulcrypt.parameter.month", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_day,
{ "Day", "simulcrypt.parameter.day", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_hour,
{ "Hour", "simulcrypt.parameter.hour", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_minute,
{ "Minute", "simulcrypt.parameter.minute", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_second,
{ "Second", "simulcrypt.parameter.second", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_hundredth_second,
{ "Hundredth_second", "simulcrypt.parameter.hundredth_second", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_activation_pending_flag,
{ "Activation pending flag", "simulcrypt.parameter.activation_pending_flag", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_component_id,
{ "Component ID", "simulcrypt.parameter.component_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_service_id,
{ "Service ID", "simulcrypt.parameter.service_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_transport_stream_id,
{ "Transport stream ID", "simulcrypt.parameter.transport_stream_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_ac_changed_flag,
{ "AC changed flag", "simulcrypt.parameter.ac_changed_flag", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_scg_current_reference_id,
{ "SCG current reference ID", "simulcrypt.parameter.scg_current_reference_id", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_scg_pending_reference_id,
{ "SCG pending reference ID", "simulcrypt.parameter.scg_pending_reference_id", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_cp_duration_flag,
{ "CP duration flag", "simulcrypt.parameter.cp_duration_flag", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_recommended_cp_duration,
{ "Recommended CP duration", "simulcrypt.parameter.recommended_cp_duration", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_scg_nominal_cp_duration,
{ "SCG nominal CP duration", "simulcrypt.parameter.scg_nominal_cp_duration", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_original_network_id,
{ "Original network ID", "simulcrypt.parameter.original_network_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_eis_error_status,
{ "Error status", "simulcrypt.error_status", FT_UINT16, BASE_DEC | BASE_EXT_STRING, &eis_error_values_ext, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_error_description,
{ "Error status", "simulcrypt.error_description", FT_STRING, BASE_NONE, NULL, 0x0, /* error_description --> ASCII byte string */
NULL, HFILL }},
{ &hf_simulcrypt_psig_parameter_type,
{ "Parameter Type", "simulcrypt.parameter.type", FT_UINT16, BASE_HEX | BASE_EXT_STRING, &psig_parametertypenames_ext, 0x0, /* type 2 bytes */
NULL, HFILL }},
{ &hf_simulcrypt_psig_type,
{ "PSIG type", "simulcrypt.parameter.psig_type", FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_channel_id,
{ "Channel ID", "simulcrypt.parameter.channel_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_stream_id,
{ "Stream ID", "simulcrypt.parameter.stream_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_packet_id,
{ "Packet ID", "simulcrypt.parameter.packet_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_interface_mode_configuration,
{ "Interface mode configuration", "simulcrypt.parameter.interface_mode_configuration", FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_max_stream,
{ "Max stream", "simulcrypt.parameter.max_stream", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_table_period_pair,
{ "Table period pair", "simulcrypt.parameter.table_period_pair", FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_mpeg_section,
{ "MPEG section", "simulcrypt.parameter.mpeg_section", FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_repetition_rate,
{ "Repetition rate", "simulcrypt.parameter.repetition_rate", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_initial_bandwidth,
{ "Initial bandwidth", "simulcrypt.parameter.initial_bandwidth", FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_kbps, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_asi_input_packet_id,
{ "ASI input packet ID", "simulcrypt.parameter.asi_input_packet_id", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_psig_error_status,
{ "Error status", "simulcrypt.parameter.error_status", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_simulcrypt_parameter_value,
{ "Parameter Value", "simulcrypt.parameter.value", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }}
};
static gint *ett[] =
{
&ett_simulcrypt,
&ett_simulcrypt_header,
&ett_simulcrypt_message,
&ett_simulcrypt_parameter,
&ett_simulcrypt_super_cas_id,
&ett_simulcrypt_ecm_datagram,
&ett_simulcrypt_ecm_group,
&ett_simulcrypt_activation_time,
&ett_simulcrypt_table_period_pair
};
module_t *simulcrypt_module;
/* execute protocol initialization only once */
proto_simulcrypt = proto_register_protocol ("SIMULCRYPT Protocol", "SIMULCRYPT", "simulcrypt");
proto_register_field_array (proto_simulcrypt, hf, array_length (hf));
proto_register_subtree_array (ett, array_length (ett));
register_init_routine(simulcrypt_init);
/* Register our configuration options for Simulcrypt, particularly our port. */
/* This registers our preferences; function proto_reg_handoff_simulcrypt is */
/* called when preferences are applied. */
simulcrypt_module = prefs_register_protocol(proto_simulcrypt, proto_reg_handoff_simulcrypt);
prefs_register_uint_preference(simulcrypt_module, "ca_system_id_mikey","MIKEY ECM CA_system_ID (in hex)",
"Set the CA_system_ID used to decode ECM datagram as MIKEY", 16, &ca_system_id_mikey);
}
/* this is run every time preferences are changed and also during Wireshark initialization */
void
proto_reg_handoff_simulcrypt(void)
{
static gboolean initialized=FALSE;
dissector_handle_t simulcrypt_handle;
guint i;
if (!initialized) {
simulcrypt_handle = create_dissector_handle(dissect_simulcrypt, proto_simulcrypt);
for(i=0;i<ECM_INTERPRETATION_SIZE;i++)
{
tab_ecm_inter[i].protocol_handle = find_dissector(tab_ecm_inter[i].protocol_name);
}
dissector_add_for_decode_as_with_preference("udp.port", simulcrypt_handle);
dissector_add_for_decode_as_with_preference("tcp.port", simulcrypt_handle);
initialized = TRUE;
}
/* update tab_ecm_inter table (always do this) */
tab_ecm_inter[ECM_MIKEY_INDEX].ca_system_id=ca_system_id_mikey;
}
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-sinecap.c
|
/* packet-sinecap.c
*
* Author: Nikolas Koesling, 2023 ([email protected])
* Description: Wireshark dissector for the SINEC AP protocol according to
* https://cache.industry.siemens.com/dl/files/274/22090274/att_83836/v1/447_840_840C_880_Computer_Link_General_Description.pdf
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#define PROTO_TAG_AP "SINEC-AP"
/* Min. telegram length for heuristic check */
#define TXP_MIN_TELEGRAM_LENGTH 22
/* Wireshark ID of the AP1 protocol */
static gint proto_ap = -1;
static gint hf_ap_protoid = -1;
static gint hf_ap_mpxadr = -1;
static gint hf_ap_comcls = -1;
static gint hf_ap_comcod = -1;
static gint hf_ap_modfr1 = -1;
static gint hf_ap_modfr2 = -1;
static gint hf_ap_errcls = -1;
static gint hf_ap_errcod = -1;
static gint hf_ap_rosctr = -1;
static gint hf_ap_sgsqnr = -1;
static gint hf_ap_tactid = -1;
static gint hf_ap_tasqnr = -1;
static gint hf_ap_spare = -1;
static gint hf_ap_pduref = -1;
static gint hf_ap_pduid = -1;
static gint hf_ap_pdulg = -1;
static gint hf_ap_parlg = -1;
static gint hf_ap_datlg = -1;
static gint ett_ap = -1;
static heur_dissector_list_t ap_heur_subdissector_list;
static const value_string vs_comcls[] = {
{0x0, "ACK without data"},
{0x4, "Serial transfer"},
{0, NULL}
};
static const value_string vs_protid[] = {
{0x0, "SINEC AP 1.0"},
{0, NULL}
};
static gboolean
dissect_ap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void *data _U_)
{
/*----------------- Heuristic Checks - Begin */
/* 1) check for minimum length */
if (tvb_captured_length(tvb) < TXP_MIN_TELEGRAM_LENGTH)
return FALSE;
/* 2) protocol id == 0 */
if (tvb_get_guint8(tvb, 0) != 0)
return FALSE;
/*----------------- Heuristic Checks - End */
col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_TAG_AP);
col_clear(pinfo->cinfo, COL_INFO);
guint8 comcls = tvb_get_guint8(tvb, 2);
gint offset = 16;
guint16 pdulg = tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN);
offset += 4;
guint16 datlg = tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN);
offset += 2;
ws_assert(offset == 22);
/* check pdu and data length */
if (pdulg != tvb_captured_length(tvb))
return FALSE;
if (datlg != tvb_captured_length(tvb) - 22)
return FALSE;
switch (comcls) {
case 0x0: {
// ack without data
col_append_fstr(pinfo->cinfo, COL_INFO, "%s", "ACK without data");
break;
}
case 0x4: {
// serial transfer
col_append_fstr(pinfo->cinfo, COL_INFO, "%s", "Serial transfer");
break;
}
default:
col_append_fstr(pinfo->cinfo, COL_INFO, "%s", "UNKNOWN command class");
}
proto_item *ap_item = proto_tree_add_item(tree, proto_ap, tvb, 0, -1, ENC_NA);
proto_tree *ap_tree = proto_item_add_subtree(ap_item, ett_ap);
offset = 0;
proto_tree_add_item(ap_tree, hf_ap_protoid, tvb, offset++, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ap_tree, hf_ap_mpxadr, tvb, offset++, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ap_tree, hf_ap_comcls, tvb, offset++, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ap_tree, hf_ap_comcod, tvb, offset++, 1, ENC_BIG_ENDIAN);
switch (comcls) {
case 0x0: {
// ack without data
proto_tree_add_item(ap_tree, hf_ap_errcls, tvb, offset++, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ap_tree, hf_ap_errcod, tvb, offset++, 1, ENC_BIG_ENDIAN);
break;
}
case 0x4: {
// serial transfer
proto_tree_add_item(ap_tree, hf_ap_modfr1, tvb, offset++, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ap_tree, hf_ap_modfr2, tvb, offset++, 1, ENC_BIG_ENDIAN);
break;
}
default:
proto_tree_add_item(ap_tree, hf_ap_modfr1, tvb, offset++, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ap_tree, hf_ap_modfr2, tvb, offset++, 1, ENC_BIG_ENDIAN);
}
proto_tree_add_item(ap_tree, hf_ap_rosctr, tvb, offset++, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ap_tree, hf_ap_sgsqnr, tvb, offset++, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ap_tree, hf_ap_tactid, tvb, offset++, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ap_tree, hf_ap_tasqnr, tvb, offset++, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ap_tree, hf_ap_spare, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(ap_tree, hf_ap_pduref, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(ap_tree, hf_ap_pduid, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(ap_tree, hf_ap_pdulg, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(ap_tree, hf_ap_parlg, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(ap_tree, hf_ap_datlg, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
ws_assert(offset == 22);
if (tvb_reported_length_remaining(tvb, offset) > 0) {
struct tvbuff *next_tvb = tvb_new_subset_remaining(tvb, offset);
heur_dtbl_entry_t *hdtbl_entry;
if (!dissector_try_heuristic(ap_heur_subdissector_list, next_tvb, pinfo, tree, &hdtbl_entry, NULL)) {
call_data_dissector(next_tvb, pinfo, tree);
}
}
return TRUE;
}
void
proto_register_ap(void)
{
static hf_register_info hf[] = {
{&hf_ap_protoid, {"PROTID", "sinecap.protid", FT_UINT8, BASE_HEX, VALS(vs_protid), 0x0, "Protocol version", HFILL}},
{&hf_ap_mpxadr, {"MPXADR", "sinecap.mpxadr", FT_UINT8, BASE_HEX, NULL, 0x0, "Multiplex address", HFILL}},
{&hf_ap_comcls, {"COMCLS", "sinecap.comcls", FT_UINT8, BASE_HEX, VALS(vs_comcls), 0x0, "Command class", HFILL}},
{&hf_ap_comcod, {"COMCOD", "sinecap.comcod", FT_UINT8, BASE_HEX, NULL, 0x0, "Command code", HFILL}},
{&hf_ap_modfr1, {"MODFR1", "sinecap.modfr1", FT_UINT8, BASE_HEX, NULL, 0x0, "Modifier 1", HFILL}},
{&hf_ap_errcls, {"ERRCLS", "sinecap.errcls", FT_UINT8, BASE_HEX, NULL, 0x0, "Error class", HFILL}},
{&hf_ap_modfr2, {"MODFR2", "sinecap.modfr2", FT_UINT8, BASE_HEX, NULL, 0x0, "Modifier 2", HFILL}},
{&hf_ap_errcod, {"ERRCOD", "sinecap.errcod", FT_UINT8, BASE_HEX, NULL, 0x0, "Error code", HFILL}},
{&hf_ap_rosctr, {"ROSCTR", "sinecap.rosctr", FT_UINT8, BASE_HEX, NULL, 0x0, "Remote operating service", HFILL}},
{&hf_ap_sgsqnr, {"SGSQNR", "sinecap.sgsqnr", FT_UINT8, BASE_HEX_DEC, NULL, 0x0, "Segment sequence number", HFILL}},
{&hf_ap_tactid, {"TACTID", "sinecap.tactid", FT_UINT8, BASE_HEX, NULL, 0x0, "Transaction identifier", HFILL}},
{&hf_ap_tasqnr, {"TASQNR", "sinecap.tasqnr", FT_UINT8, BASE_HEX, NULL, 0x0, "Transaction sequence number", HFILL}},
{&hf_ap_spare, {"SPARE", "sinecap.spare", FT_UINT16, BASE_HEX, NULL, 0x0, "Free space", HFILL}},
{&hf_ap_pduref, {"PDUREF", "sinecap.pduref", FT_UINT16, BASE_HEX, NULL, 0x0, "Protocol Data Unit reference", HFILL}},
{&hf_ap_pduid, {"PDUID", "sinecap.pduid", FT_UINT16, BASE_HEX, NULL, 0x0, "Protocol Data Unit identifier", HFILL}},
{&hf_ap_pdulg, {"PDULG", "sinecap.pdulg", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, "Protocol Data Unit length", HFILL}},
{&hf_ap_parlg, {"PARLG", "sinecap.parlg", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, "Parameter length", HFILL}},
{&hf_ap_datlg, {"DATLG", "sinecap.datlg", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, "Data length", HFILL}},
};
proto_ap = proto_register_protocol (
"SINEC AP Telegram", /* name */
"SINEC AP", /* short name */
"sinecap" /* filter_name */
);
static gint *ett[] = {
&ett_ap,
};
proto_register_field_array(proto_ap, hf, array_length(hf));
proto_register_subtree_array(ett, array_length (ett));
ap_heur_subdissector_list = register_heur_dissector_list("sinecap", proto_ap);
}
void
proto_reg_handoff_ap(void)
{
heur_dissector_add("cotp", dissect_ap, "SINEC AP Telegram over COTP", "sinecap", proto_ap, HEURISTIC_ENABLE);
heur_dissector_add("cotp_is", dissect_ap, "SINEC AP Telegram over COTP", "sinecap_is", proto_ap, HEURISTIC_ENABLE);
}
|
C
|
wireshark/epan/dissectors/packet-sip.c
|
/* packet-sip.c
* Routines for the Session Initiation Protocol (SIP) dissection.
* RFCs 3261-3264
*
* TODO:
* hf_ display filters for headers of SIP extension RFCs (ongoing)
*
* Copyright 2000, Heikki Vatiainen <[email protected]>
* Copyright 2001, Jean-Francois Mule <[email protected]>
* Copyright 2004, Anders Broman <[email protected]>
* Copyright 2011, Anders Broman <[email protected]>, Johan Wahl <[email protected]>
* Copyright 2018, Anders Broman <[email protected]>
* Copyright 2020, Atul Sharma <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/exported_pdu.h>
#include <epan/expert.h>
#include <epan/prefs.h>
#include <epan/req_resp_hdrs.h>
#include <epan/stat_tap_ui.h>
#include <epan/proto_data.h>
#include <epan/uat.h>
#include <epan/follow.h>
#include <epan/addr_resolv.h>
#include <epan/epan_dissect.h>
#include <epan/iana_charsets.h>
#include <wsutil/str_util.h>
#include <wsutil/wsgcrypt.h>
#include "packet-tls.h"
#include "packet-isup.h"
#include "packet-e164.h"
#include "packet-e212.h"
#include "packet-sip.h"
#include "packet-media-type.h"
#include "packet-acdr.h"
#include "packet-sdp.h" /* SDP needs a transport layer to determine request/response */
/* un-comment the following as well as this line in conversation.c, to enable debug printing */
/* #define DEBUG_CONVERSATION */
#include "conversation_debug.h"
#define TLS_PORT_SIP 5061
#define DEFAULT_SIP_PORT_RANGE "5060"
void proto_register_sip(void);
static gint sip_tap = -1;
static gint sip_follow_tap = -1;
static gint exported_pdu_tap = -1;
static dissector_handle_t sip_handle;
static dissector_handle_t sip_tcp_handle;
static dissector_handle_t sigcomp_handle;
static dissector_handle_t sip_diag_handle;
static dissector_handle_t sip_uri_userinfo_handle;
static dissector_handle_t sip_via_branch_handle;
static dissector_handle_t sip_via_be_route_handle;
/* Dissector to dissect the text part of an reason code */
static dissector_handle_t sip_reason_code_handle;
/* Initialize the protocol and registered fields */
static gint proto_sip = -1;
static gint proto_raw_sip = -1;
static gint hf_sip_raw_line = -1;
static gint hf_sip_msg_hdr = -1;
static gint hf_sip_Method = -1;
static gint hf_Request_Line = -1;
static gint hf_sip_ruri_display = -1;
static gint hf_sip_ruri = -1;
static gint hf_sip_ruri_user = -1;
static gint hf_sip_ruri_host = -1;
static gint hf_sip_ruri_port = -1;
static gint hf_sip_ruri_param = -1;
static gint hf_sip_Status_Code = -1;
static gint hf_sip_Status_Line = -1;
static gint hf_sip_display = -1;
static gint hf_sip_to_display = -1;
static gint hf_sip_to_addr = -1;
static gint hf_sip_to_user = -1;
static gint hf_sip_to_host = -1;
static gint hf_sip_to_port = -1;
static gint hf_sip_to_param = -1;
static gint hf_sip_to_tag = -1;
static gint hf_sip_from_display = -1;
static gint hf_sip_from_addr = -1;
static gint hf_sip_from_user = -1;
static gint hf_sip_from_host = -1;
static gint hf_sip_from_port = -1;
static gint hf_sip_from_param = -1;
static gint hf_sip_from_tag = -1;
static gint hf_sip_tag = -1;
static gint hf_sip_pai_display = -1;
static gint hf_sip_pai_addr = -1;
static gint hf_sip_pai_user = -1;
static gint hf_sip_pai_host = -1;
static gint hf_sip_pai_port = -1;
static gint hf_sip_pai_param = -1;
static gint hf_sip_pmiss_display = -1;
static gint hf_sip_pmiss_addr = -1;
static gint hf_sip_pmiss_user = -1;
static gint hf_sip_pmiss_host = -1;
static gint hf_sip_pmiss_port = -1;
static gint hf_sip_pmiss_param = -1;
static gint hf_sip_ppi_display = -1;
static gint hf_sip_ppi_addr = -1;
static gint hf_sip_ppi_user = -1;
static gint hf_sip_ppi_host = -1;
static gint hf_sip_ppi_port = -1;
static gint hf_sip_ppi_param = -1;
static gint hf_sip_tc_display = -1;
static gint hf_sip_tc_addr = -1;
static gint hf_sip_tc_user = -1;
static gint hf_sip_tc_host = -1;
static gint hf_sip_tc_port = -1;
static gint hf_sip_tc_param = -1;
static gint hf_sip_tc_turi = -1;
static gint hf_sip_contact_param = -1;
static gint hf_sip_resend = -1;
static gint hf_sip_original_frame = -1;
static gint hf_sip_matching_request_frame = -1;
static gint hf_sip_response_time = -1;
static gint hf_sip_release_time = -1;
static gint hf_sip_curi_display = -1;
static gint hf_sip_curi = -1;
static gint hf_sip_curi_user = -1;
static gint hf_sip_curi_host = -1;
static gint hf_sip_curi_port = -1;
static gint hf_sip_curi_param = -1;
static gint hf_sip_route_display = -1;
static gint hf_sip_route = -1;
static gint hf_sip_route_user = -1;
static gint hf_sip_route_host = -1;
static gint hf_sip_route_port = -1;
static gint hf_sip_route_param = -1;
static gint hf_sip_record_route_display = -1;
static gint hf_sip_record_route = -1;
static gint hf_sip_record_route_user = -1;
static gint hf_sip_record_route_host = -1;
static gint hf_sip_record_route_port = -1;
static gint hf_sip_record_route_param = -1;
static gint hf_sip_service_route_display = -1;
static gint hf_sip_service_route = -1;
static gint hf_sip_service_route_user = -1;
static gint hf_sip_service_route_host = -1;
static gint hf_sip_service_route_port = -1;
static gint hf_sip_service_route_param = -1;
static gint hf_sip_path_display = -1;
static gint hf_sip_path = -1;
static gint hf_sip_path_user = -1;
static gint hf_sip_path_host = -1;
static gint hf_sip_path_port = -1;
static gint hf_sip_path_param = -1;
static gint hf_sip_auth = -1;
static gint hf_sip_auth_scheme = -1;
static gint hf_sip_auth_digest_response = -1;
static gint hf_sip_auth_nc = -1;
static gint hf_sip_auth_username = -1;
static gint hf_sip_auth_realm = -1;
static gint hf_sip_auth_nonce = -1;
static gint hf_sip_auth_algorithm = -1;
static gint hf_sip_auth_opaque = -1;
static gint hf_sip_auth_qop = -1;
static gint hf_sip_auth_cnonce = -1;
static gint hf_sip_auth_uri = -1;
static gint hf_sip_auth_domain = -1;
static gint hf_sip_auth_stale = -1;
static gint hf_sip_auth_auts = -1;
static gint hf_sip_auth_rspauth = -1;
static gint hf_sip_auth_nextnonce = -1;
static gint hf_sip_auth_ik = -1;
static gint hf_sip_auth_ck = -1;
static gint hf_sip_cseq_seq_no = -1;
static gint hf_sip_cseq_method = -1;
static gint hf_sip_via_transport = -1;
static gint hf_sip_via_sent_by_address = -1;
static gint hf_sip_via_sent_by_port = -1;
static gint hf_sip_via_branch = -1;
static gint hf_sip_via_maddr = -1;
static gint hf_sip_via_rport = -1;
static gint hf_sip_via_received = -1;
static gint hf_sip_via_ttl = -1;
static gint hf_sip_via_comp = -1;
static gint hf_sip_via_sigcomp_id = -1;
static gint hf_sip_via_oc = -1;
static gint hf_sip_via_oc_val = -1;
static gint hf_sip_via_oc_algo = -1;
static gint hf_sip_via_oc_validity = -1;
static gint hf_sip_via_oc_seq = -1;
static gint hf_sip_oc_seq_timestamp = -1;
static gint hf_sip_via_be_route = -1;
static gint hf_sip_rack_rseq_no = -1;
static gint hf_sip_rack_cseq_no = -1;
static gint hf_sip_rack_cseq_method = -1;
static gint hf_sip_reason_protocols = -1;
static gint hf_sip_reason_cause_q850 = -1;
static gint hf_sip_reason_cause_sip = -1;
static gint hf_sip_reason_cause_other = -1;
static gint hf_sip_reason_text = -1;
static gint hf_sip_msg_body = -1;
static gint hf_sip_sec_mechanism = -1;
static gint hf_sip_sec_mechanism_alg = -1;
static gint hf_sip_sec_mechanism_ealg = -1;
static gint hf_sip_sec_mechanism_prot = -1;
static gint hf_sip_sec_mechanism_spi_c = -1;
static gint hf_sip_sec_mechanism_spi_s = -1;
static gint hf_sip_sec_mechanism_port1 = -1;
static gint hf_sip_sec_mechanism_port_c = -1;
static gint hf_sip_sec_mechanism_port2 = -1;
static gint hf_sip_sec_mechanism_port_s = -1;
static gint hf_sip_session_id_sess_id = -1;
static gint hf_sip_session_id_param = -1;
static gint hf_sip_session_id_local_uuid = -1;
static gint hf_sip_session_id_remote_uuid = -1;
static gint hf_sip_session_id_logme = -1;
static gint hf_sip_continuation = -1;
static gint hf_sip_feature_cap = -1;
static gint hf_sip_p_acc_net_i_acc_type = -1;
static gint hf_sip_p_acc_net_i_ucid_3gpp = -1;
static gint hf_sip_service_priority = -1;
static gint hf_sip_icid_value = -1;
static gint hf_sip_icid_gen_addr = -1;
static gint hf_sip_call_id_gen = -1;
/* Initialize the subtree pointers */
static gint ett_sip = -1;
static gint ett_sip_reqresp = -1;
static gint ett_sip_hdr = -1;
static gint ett_sip_ext_hdr = -1;
static gint ett_raw_text = -1;
static gint ett_sip_element = -1;
static gint ett_sip_hist = -1;
static gint ett_sip_uri = -1;
static gint ett_sip_contact_item = -1;
static gint ett_sip_message_body = -1;
static gint ett_sip_cseq = -1;
static gint ett_sip_via = -1;
static gint ett_sip_reason = -1;
static gint ett_sip_security_client = -1;
static gint ett_sip_security_server = -1;
static gint ett_sip_security_verify = -1;
static gint ett_sip_rack = -1;
static gint ett_sip_route = -1;
static gint ett_sip_record_route = -1;
static gint ett_sip_service_route = -1;
static gint ett_sip_path = -1;
static gint ett_sip_ruri = -1;
static gint ett_sip_to_uri = -1;
static gint ett_sip_curi = -1;
static gint ett_sip_from_uri = -1;
static gint ett_sip_pai_uri = -1;
static gint ett_sip_pmiss_uri = -1;
static gint ett_sip_ppi_uri = -1;
static gint ett_sip_tc_uri = -1;
static gint ett_sip_session_id = -1;
static gint ett_sip_p_access_net_info = -1;
static gint ett_sip_p_charging_vector = -1;
static gint ett_sip_feature_caps = -1;
static gint ett_sip_via_be_route = -1;
static expert_field ei_sip_unrecognized_header = EI_INIT;
static expert_field ei_sip_header_no_colon = EI_INIT;
static expert_field ei_sip_header_not_terminated = EI_INIT;
#if 0
static expert_field ei_sip_odd_register_response = EI_INIT;
#endif
static expert_field ei_sip_call_id_invalid = EI_INIT;
static expert_field ei_sip_sipsec_malformed = EI_INIT;
static expert_field ei_sip_via_sent_by_port = EI_INIT;
static expert_field ei_sip_content_length_invalid = EI_INIT;
static expert_field ei_sip_retry_after_invalid = EI_INIT;
static expert_field ei_sip_Status_Code_invalid = EI_INIT;
static expert_field ei_sip_authorization_invalid = EI_INIT;
static expert_field ei_sip_session_id_sess_id = EI_INIT;
/* patterns used for tvb_ws_mempbrk_pattern_guint8 */
static ws_mempbrk_pattern pbrk_comma_semi;
static ws_mempbrk_pattern pbrk_whitespace;
static ws_mempbrk_pattern pbrk_param_end;
static ws_mempbrk_pattern pbrk_param_end_colon_brackets;
static ws_mempbrk_pattern pbrk_header_end_dquote;
static ws_mempbrk_pattern pbrk_tab_sp_fslash;
static ws_mempbrk_pattern pbrk_addr_end;
static ws_mempbrk_pattern pbrk_via_param_end;
/* PUBLISH method added as per https://tools.ietf.org/html/draft-ietf-sip-publish-01 */
static const char *sip_methods[] = {
#define SIP_METHOD_INVALID 0
"<Invalid method>", /* Pad so that the real methods start at index 1 */
#define SIP_METHOD_ACK 1
"ACK",
#define SIP_METHOD_BYE 2
"BYE",
#define SIP_METHOD_CANCEL 3
"CANCEL",
#define SIP_METHOD_DO 4
"DO",
#define SIP_METHOD_INFO 5
"INFO",
#define SIP_METHOD_INVITE 6
"INVITE",
#define SIP_METHOD_MESSAGE 7
"MESSAGE",
#define SIP_METHOD_NOTIFY 8
"NOTIFY",
#define SIP_METHOD_OPTIONS 9
"OPTIONS",
#define SIP_METHOD_PRACK 10
"PRACK",
#define SIP_METHOD_QAUTH 11
"QAUTH",
#define SIP_METHOD_REFER 12
"REFER",
#define SIP_METHOD_REGISTER 13
"REGISTER",
#define SIP_METHOD_SPRACK 14
"SPRACK",
#define SIP_METHOD_SUBSCRIBE 15
"SUBSCRIBE",
#define SIP_METHOD_UPDATE 16
"UPDATE",
#define SIP_METHOD_PUBLISH 17
"PUBLISH"
};
/* from RFC 3261
* Updated with info from https://www.iana.org/assignments/sip-parameters
* (last updated 2009-11-11)
* Updated with: https://tools.ietf.org/html/draft-ietf-sip-resource-priority-05
*/
typedef struct {
const char *name;
const char *compact_name;
} sip_header_t;
static const sip_header_t sip_headers[] = {
{ "Unknown-header", NULL }, /* 0 Pad so that the real headers start at index 1 */
{ "Accept", NULL }, /* */
#define POS_ACCEPT 1
{ "Accept-Contact", "a" }, /* RFC3841 */
#define POS_ACCEPT_CONTACT 2
{ "Accept-Encoding", NULL }, /* */
#define POS_ACCEPT_ENCODING 3
{ "Accept-Language", NULL }, /* */
#define POS_ACCEPT_LANGUAGE 4
{ "Accept-Resource-Priority", NULL }, /* RFC4412 */
#define POS_ACCEPT_RESOURCE_PRIORITY 5
{ "Additional-Identity", NULL }, /* 3GPP TS 24.229 v16.7.0 */
#define POS_ADDITIONAL_IDENTITY 6
{ "Alert-Info", NULL },
#define POS_ALERT_INFO 7
{ "Allow", NULL },
#define POS_ALLOW 8
{ "Allow-Events", "u" }, /* RFC3265 */
#define POS_ALLOW_EVENTS 9
{ "Answer-Mode", NULL }, /* RFC5373 */
#define POS_ANSWER_MODE 10
{ "Attestation-Info", NULL }, /* [3GPP TS 24.229 v15.11.0] */
#define POS_ATTESTATION_INFO 11
{ "Authentication-Info", NULL },
#define POS_AUTHENTICATION_INFO 12
{ "Authorization", NULL }, /* */
#define POS_AUTHORIZATION 13
{ "Call-ID", "i" },
#define POS_CALL_ID 14
{ "Call-Info", NULL },
#define POS_CALL_INFO 15
{ "Cellular-Network-Info", NULL }, /* [3GPP TS 24.229 v13.9.0] */
#define POS_CELLULAR_NETWORK_INFO 16
{ "Contact", "m" },
#define POS_CONTACT 17
{ "Content-Disposition", NULL },
#define POS_CONTENT_DISPOSITION 18
{ "Content-Encoding", "e" }, /* */
#define POS_CONTENT_ENCODING 19
{ "Content-Language", NULL },
#define POS_CONTENT_LANGUAGE 20
{ "Content-Length", "l" },
#define POS_CONTENT_LENGTH 21
{ "Content-Type", "c" },
#define POS_CONTENT_TYPE 22
{ "CSeq", NULL },
#define POS_CSEQ 23
{ "Date", NULL }, /* */
#define POS_DATE 24
/* Encryption (Deprecated) [RFC3261] */
{ "Error-Info", NULL }, /* */
#define POS_ERROR_INFO 25
{ "Event", "o" }, /* */
#define POS_EVENT 26
{ "Expires", NULL }, /* */
#define POS_EXPIRES 27
{ "Feature-Caps", NULL }, /* RFC6809 */
#define POS_FEATURE_CAPS 28
{ "Flow-Timer", NULL }, /* RFC5626 */
#define POS_FLOW_TIMER 29
{ "From", "f" }, /* */
#define POS_FROM 30
{ "Geolocation", NULL }, /* */
#define POS_GEOLOCATION 31
{ "Geolocation-Error", NULL }, /* */
#define POS_GEOLOCATION_ERROR 32
{ "Geolocation-Routing", NULL }, /* */
#define POS_GEOLOCATION_ROUTING 33
/* Hide RFC3261 (deprecated)*/
{ "History-Info", NULL }, /* RFC4244 */
#define POS_HISTORY_INFO 34
{ "Identity", "y" }, /* RFC4474 */
#define POS_IDENTITY 35
{ "Identity-Info", "n" }, /* RFC4474 */
#define POS_IDENTITY_INFO 36
{ "Info-Package", NULL }, /* RFC-ietf-sipcore-info-events-10.txt */
#define POS_INFO_PKG 37
{ "In-Reply-To", NULL }, /* RFC3261 */
#define POS_IN_REPLY_TO 38
{ "Join", NULL }, /* RFC3911 */
#define POS_JOIN 39
{ "Max-Breadth", NULL }, /* RFC5393*/
#define POS_MAX_BREADTH 40
{ "Max-Forwards", NULL }, /* */
#define POS_MAX_FORWARDS 41
{ "MIME-Version", NULL }, /* */
#define POS_MIME_VERSION 42
{ "Min-Expires", NULL }, /* */
#define POS_MIN_EXPIRES 43
{ "Min-SE", NULL }, /* RFC4028 */
#define POS_MIN_SE 44
{ "Organization", NULL }, /* RFC3261 */
#define POS_ORGANIZATION 45
{ "Origination-Id", NULL }, /* [3GPP TS 24.229 v15.11.0] */
#define POS_ORIGINATION_ID 46
{ "P-Access-Network-Info", NULL }, /* RFC3455 */
#define POS_P_ACCESS_NETWORK_INFO 47
{ "P-Answer-State", NULL }, /* RFC4964 */
#define POS_P_ANSWER_STATE 48
{ "P-Asserted-Identity", NULL }, /* RFC3325 */
#define POS_P_ASSERTED_IDENTITY 49
{ "P-Asserted-Service", NULL }, /* RFC6050 */
#define POS_P_ASSERTED_SERV 50
{ "P-Associated-URI", NULL }, /* RFC3455 */
#define POS_P_ASSOCIATED_URI 51
{ "P-Called-Party-ID", NULL }, /* RFC3455 */
#define POS_P_CALLED_PARTY_ID 52
{ "P-Charge-Info", NULL }, /* RFC8496 */
#define POS_P_CHARGE_INFO 53
{ "P-Charging-Function-Addresses", NULL }, /* RFC3455 */
#define POS_P_CHARGING_FUNC_ADDRESSES 54
{ "P-Charging-Vector", NULL }, /* RFC3455 */
#define POS_P_CHARGING_VECTOR 55
{ "P-DCS-Trace-Party-ID", NULL }, /* RFC5503 */
#define POS_P_DCS_TRACE_PARTY_ID 56
{ "P-DCS-OSPS", NULL }, /* RFC5503 */
#define POS_P_DCS_OSPS 57
{ "P-DCS-Billing-Info", NULL }, /* RFC5503 */
#define POS_P_DCS_BILLING_INFO 58
{ "P-DCS-LAES", NULL }, /* RFC5503 */
#define POS_P_DCS_LAES 59
{ "P-DCS-Redirect", NULL }, /* RFC5503 */
#define POS_P_DCS_REDIRECT 60
{ "P-Early-Media", NULL }, /* RFC5009 */
#define POS_P_EARLY_MEDIA 61
{ "P-Media-Authorization", NULL }, /* RFC3313 */
#define POS_P_MEDIA_AUTHORIZATION 62
{ "P-Preferred-Identity", NULL }, /* RFC3325 */
#define POS_P_PREFERRED_IDENTITY 63
{ "P-Preferred-Service", NULL }, /* RFC6050 */
#define POS_P_PREFERRED_SERV 64
{ "P-Profile-Key", NULL }, /* RFC5002 */
#define POS_P_PROFILE_KEY 65
{ "P-Refused-URI-List", NULL }, /* RFC5318 */
#define POS_P_REFUSED_URI_LST 66
{ "P-Served-User", NULL }, /* RFC5502 */
#define POS_P_SERVED_USER 67
{ "P-User-Database", NULL }, /* RFC4457 */
#define POS_P_USER_DATABASE 68
{ "P-Visited-Network-ID", NULL }, /* RFC3455 */
#define POS_P_VISITED_NETWORK_ID 69
{ "Path", NULL }, /* RFC3327 */
#define POS_PATH 70
{ "Permission-Missing", NULL }, /* RFC5360 */
#define POS_PERMISSION_MISSING 71
{ "Policy-Contact", NULL }, /* RFC3261 */
#define POS_POLICY_CONTACT 72
{ "Policy-ID", NULL }, /* RFC3261 */
#define POS_POLICY_ID 73
{ "Priority", NULL }, /* RFC3261 */
#define POS_PRIORITY 74
{ "Priority-Share", NULL }, /* [3GPP TS 24.229 v13.16.0] */
#define POS_PRIORITY_SHARE 75
{ "Priv-Answer-Mode", NULL }, /* RFC5373 */
#define POS_PRIV_ANSWER_MODE 76
{ "Privacy", NULL }, /* RFC3323 */
#define POS_PRIVACY 77
{ "Proxy-Authenticate", NULL }, /* */
#define POS_PROXY_AUTHENTICATE 78
{ "Proxy-Authorization", NULL }, /* */
#define POS_PROXY_AUTHORIZATION 79
{ "Proxy-Require", NULL }, /* */
#define POS_PROXY_REQUIRE 80
{ "RAck", NULL }, /* RFC3262 */
#define POS_RACK 81
{ "Reason", NULL }, /* RFC3326 */
#define POS_REASON 82
{ "Reason-Phrase", NULL }, /* RFC3326 */
#define POS_REASON_PHRASE 83
{ "Record-Route", NULL }, /* */
#define POS_RECORD_ROUTE 84
{ "Recv-Info", NULL }, /* RFC6086 */
#define POS_RECV_INFO 85
{ "Refer-Sub", NULL }, /* RFC4488 */
#define POS_REFER_SUB 86
{ "Refer-To", "r" }, /* RFC3515 */
#define POS_REFER_TO 87
{ "Referred-By", "b" }, /* RFC3892 */
#define POS_REFERRED_BY 88
{ "Reject-Contact", "j" }, /* RFC3841 */
#define POS_REJECT_CONTACT 89
{ "Relayed-Charge", NULL }, /* [3GPP TS 24.229 v12.14.0] */
#define POS_RELAYED_CHARGE 90
{ "Replaces", NULL }, /* RFC3891 */
#define POS_REPLACES 91
{ "Reply-To", NULL }, /* RFC3261 */
#define POS_REPLY_TO 92
{ "Request-Disposition", "d" }, /* RFC3841 */
#define POS_REQUEST_DISPOSITION 93
{ "Require", NULL }, /* RFC3261 */
#define POS_REQUIRE 94
{ "Resource-Priority", NULL }, /* RFC4412 */
#define POS_RESOURCE_PRIORITY 95
{ "Resource-Share", NULL }, /* [3GPP TS 24.229 v13.7.0] */
#define POS_RESOURCE_SHARE 96
/*{ "Response-Key (Deprecated) [RFC3261]*/
{ "Response-Source", NULL }, /* [3GPP TS 24.229 v15.11.0] */
#define POS_RESPONSE_SOURCE 97
{ "Restoration-Info", NULL }, /* [3GPP TS 24.229 v12.14.0] */
#define POS_RESTORATION_INFO 98
{ "Retry-After", NULL }, /* RFC3261 */
#define POS_RETRY_AFTER 99
{ "Route", NULL }, /* RFC3261 */
#define POS_ROUTE 100
{ "RSeq", NULL }, /* RFC3262 */
#define POS_RSEQ 101
{ "Security-Client", NULL }, /* RFC3329 */
#define POS_SECURITY_CLIENT 102
{ "Security-Server", NULL }, /* RFC3329 */
#define POS_SECURITY_SERVER 103
{ "Security-Verify", NULL }, /* RFC3329 */
#define POS_SECURITY_VERIFY 104
{ "Server", NULL }, /* RFC3261 */
#define POS_SERVER 105
{ "Service-Interact-Info", NULL }, /* [3GPP TS 24.229 v13.18.0] */
#define POS_SERVICE_INTERACT_INFO 106
{ "Service-Route", NULL }, /* RFC3608 */
#define POS_SERVICE_ROUTE 107
{ "Session-Expires", "x" }, /* RFC4028 */
#define POS_SESSION_EXPIRES 108
{ "Session-ID", NULL }, /* RFC7329 */
#define POS_SESSION_ID 109
{ "SIP-ETag", NULL }, /* RFC3903 */
#define POS_SIP_ETAG 110
{ "SIP-If-Match", NULL }, /* RFC3903 */
#define POS_SIP_IF_MATCH 111
{ "Subject", "s" }, /* RFC3261 */
#define POS_SUBJECT 112
{ "Subscription-State", NULL }, /* RFC3265 */
#define POS_SUBSCRIPTION_STATE 113
{ "Supported", "k" }, /* RFC3261 */
#define POS_SUPPORTED 114
{ "Suppress-If-Match", NULL }, /* RFC5839 */
#define POS_SUPPRESS_IF_MATCH 115
{ "Target-Dialog", NULL }, /* RFC4538 */
#define POS_TARGET_DIALOG 116
{ "Timestamp", NULL }, /* RFC3261 */
#define POS_TIMESTAMP 117
{ "To", "t" }, /* RFC3261 */
#define POS_TO 118
{ "Trigger-Consent", NULL }, /* RFC5360 */
#define POS_TRIGGER_CONSENT 119
{ "Unsupported", NULL }, /* RFC3261 */
#define POS_UNSUPPORTED 120
{ "User-Agent", NULL }, /* RFC3261 */
#define POS_USER_AGENT 121
{ "Via", "v" }, /* RFC3261 */
#define POS_VIA 122
{ "Warning", NULL }, /* RFC3261 */
#define POS_WARNING 123
{ "WWW-Authenticate", NULL }, /* RFC3261 */
#define POS_WWW_AUTHENTICATE 124
{ "Diversion", NULL }, /* RFC5806 */
#define POS_DIVERSION 125
{ "User-to-User", NULL }, /* RFC7433 */
#define POS_USER_TO_USER 126
};
static gint hf_header_array[] = {
-1, /* 0"Unknown-header" - Pad so that the real headers start at index 1 */
-1, /* 1"Accept" */
-1, /* 2"Accept-Contact" RFC3841 */
-1, /* 3"Accept-Encoding" */
-1, /* 4"Accept-Language" */
-1, /* 5"Accept-Resource-Priority" RFC4412 */
-1, /* 6"Additional-Identity [3GPP TS 24.229 v16.7.0] */
-1, /* 7"Alert-Info", */
-1, /* 8"Allow", */
-1, /* 9"Allow-Events", RFC3265 */
-1, /* 10"Answer-Mode" RFC5373 */
-1, /* 11"Attestation-Info [3GPP TS 24.229 v15.11.0] */
-1, /* 12"Authentication-Info" */
-1, /* 13"Authorization", */
-1, /* 14"Call-ID", */
-1, /* 15"Call-Info" */
-1, /* 16"Cellular-Network-Info [3GPP TS 24.229 v13.9.0] */
-1, /* 17"Contact", */
-1, /* 18"Content-Disposition", */
-1, /* 19"Content-Encoding", */
-1, /* 20"Content-Language", */
-1, /* 21"Content-Length", */
-1, /* 22"Content-Type", */
-1, /* 23"CSeq", */
-1, /* 24"Date", */
-1, /* 25"Error-Info", */
-1, /* 26"Event", */
-1, /* 27"Expires", */
-1, /* 28"Feature-Caps", */
-1, /* 29"Flow-Timer", RFC5626 */
-1, /* 30"From", */
-1, /* 31"Geolocation", */
-1, /* 32"Geolocation-Error", */
-1, /* 33"Geolocation-Routing", */
-1, /* 34"History-Info", RFC4244 */
-1, /* 35"Identity", */
-1, /* 36"Identity-Info", RFC4474 */
-1, /* 37"Info-Package", RFC-ietf-sipcore-info-events-10.txt */
-1, /* 38"In-Reply-To", RFC3261 */
-1, /* 39"Join", RFC3911 */
-1, /* 40"Max-Breadth" RFC5393 */
-1, /* 41"Max-Forwards", */
-1, /* 42"MIME-Version", */
-1, /* 43"Min-Expires", */
-1, /* 44"Min-SE", RFC4028 */
-1, /* 45"Organization", */
-1, /* 46"Origination-Id [3GPP TS 24.229 v15.11.0] */
-1, /* 47"P-Access-Network-Info", RFC3455 */
-1, /* 48"P-Answer-State", RFC4964 */
-1, /* 49"P-Asserted-Identity", RFC3325 */
-1, /* 50"P-Asserted-Service", RFC-drage-sipping-service-identification-05.txt */
-1, /* 51"P-Associated-URI", RFC3455 */
-1, /* 52"P-Charge-Info", RFC8496 */
-1, /* 53"P-Called-Party-ID", RFC3455 */
-1, /* 54"P-Charging-Function-Addresses", RFC3455 */
-1, /* 55"P-Charging-Vector", RFC3455 */
-1, /* 56"P-DCS-Trace-Party-ID", RFC3603 */
-1, /* 57"P-DCS-OSPS", RFC3603 */
-1, /* 58"P-DCS-Billing-Info", RFC3603 */
-1, /* 59"P-DCS-LAES", RFC3603 */
-1, /* 60"P-DCS-Redirect", RFC3603 */
-1, /* 61"P-Early-Media", */
-1, /* 62"P-Media-Authorization", RFC3313 */
-1, /* 63"P-Preferred-Identity", RFC3325 */
-1, /* 64"P-Preferred-Service", RFC-drage-sipping-service-identification-05.txt */
-1, /* 65"P-Profile-Key", */
-1, /* 66"P-Refused-URI-List", RFC5318 */
-1, /* 67"P-Served-User", RFC5502 */
-1, /* 68"P-User-Database RFC4457 */
-1, /* 69"P-Visited-Network-ID", RFC3455 */
-1, /* 70"Path", RFC3327 */
-1, /* 71"Permission-Missing" RFC5360 */
-1, /* 72"Policy-Contact" RFC5360 */
-1, /* 73"Policy-ID" RFC5360 */
-1, /* 74"Priority" */
-1, /* 75"Priority-Share [3GPP TS 24.229 v13.16.0] */
-1, /* 76"Priv-Answer-mode" RFC5373 */
-1, /* 77"Privacy", RFC3323 */
-1, /* 78"Proxy-Authenticate", */
-1, /* 79"Proxy-Authorization", */
-1, /* 80"Proxy-Require", */
-1, /* 81"RAck", RFC3262 */
-1, /* 82"Reason", RFC3326 */
-1, /* 83"Reason-Phrase", RFC3326 */
-1, /* 84"Record-Route", */
-1, /* 85"Recv-Info", RFC6086 */
-1, /* 86"Refer-Sub",", RFC4488 */
-1, /* 87"Refer-To", RFC3515 */
-1, /* 88"Referred-By", */
-1, /* 89"Reject-Contact", RFC3841 */
-1, /* 90"Relayed-Charge [3GPP TS 24.229 v12.14.0] */
-1, /* 91"Replaces", RFC3891 */
-1, /* 92"Reply-To", RFC3261 */
-1, /* 93"Request-Disposition", RFC3841 */
-1, /* 94"Require", RFC3261 */
-1, /* 95"Resource-Priority", RFC4412 */
-1, /* 96"Resource-Share [3GPP TS 24.229 v13.7.0] */
-1, /* 97"Response-Source [3GPP TS 24.229 v15.11.0] */
-1, /* 98"Restoration-Info [3GPP TS 24.229 v12.14.0] */
-1, /* 99"Retry-After", RFC3261 */
-1, /* 100"Route", RFC3261 */
-1, /* 101"RSeq", RFC3262 */
-1, /* 102"Security-Client", RFC3329 */
-1, /* 103"Security-Server", RFC3329 */
-1, /* 104"Security-Verify", RFC3329 */
-1, /* 105"Server", RFC3261 */
-1, /* 106"Service-Interact-Info [3GPP TS 24.229 v13.18.0] */
-1, /* 107"Service-Route", RFC3608 */
-1, /* 108"Session-Expires", RFC4028 */
-1, /* 109"Session-ID", RFC7329 */
-1, /* 110"SIP-ETag", RFC3903 */
-1, /* 111"SIP-If-Match", RFC3903 */
-1, /* 112"Subject", RFC3261 */
-1, /* 113"Subscription-State", RFC3265 */
-1, /* 114"Supported", RFC3261 */
-1, /* 115"Suppress-If-Match", RFC4538 */
-1, /* 116"Target-Dialog", RFC4538 */
-1, /* 117"Timestamp", RFC3261 */
-1, /* 118"To", RFC3261 */
-1, /* 119"Trigger-Consent" RFC5380 */
-1, /* 120"Unsupported", RFC3261 */
-1, /* 121"User-Agent", RFC3261 */
-1, /* 122"Via", RFC3261 */
-1, /* 123"Warning", RFC3261 */
-1, /* 124"WWW-Authenticate", RFC3261 */
-1, /* 125"Diversion", RFC5806 */
-1, /* 126"User-to-User", draft-johnston-sipping-cc-uui-09 */
};
/* Track associations between parameter name and hf item */
typedef struct {
const char *param_name;
const gint *hf_item;
} header_parameter_t;
static header_parameter_t auth_parameters_hf_array[] =
{
{"response", &hf_sip_auth_digest_response},
{"nc", &hf_sip_auth_nc},
{"username", &hf_sip_auth_username},
{"realm", &hf_sip_auth_realm},
{"nonce", &hf_sip_auth_nonce},
{"algorithm", &hf_sip_auth_algorithm},
{"opaque", &hf_sip_auth_opaque},
{"qop", &hf_sip_auth_qop},
{"cnonce", &hf_sip_auth_cnonce},
{"uri", &hf_sip_auth_uri},
{"domain", &hf_sip_auth_domain},
{"stale", &hf_sip_auth_stale},
{"auts", &hf_sip_auth_auts},
{"rspauth", &hf_sip_auth_rspauth},
{"nextnonce", &hf_sip_auth_nextnonce},
{"ik", &hf_sip_auth_ik},
{"ck", &hf_sip_auth_ck}
};
static header_parameter_t via_parameters_hf_array[] =
{
{"branch", &hf_sip_via_branch},
{"maddr", &hf_sip_via_maddr},
{"rport", &hf_sip_via_rport},
{"received", &hf_sip_via_received},
{"ttl", &hf_sip_via_ttl},
{"comp", &hf_sip_via_comp},
{"sigcomp-id", &hf_sip_via_sigcomp_id},
{"oc", &hf_sip_via_oc},
{"oc-validity", &hf_sip_via_oc_validity },
{"oc-seq", &hf_sip_via_oc_seq},
{"oc-algo", &hf_sip_via_oc_algo},
{"be-route", &hf_sip_via_be_route}
};
typedef enum {
MECH_PARA_STRING = 0,
MECH_PARA_UINT = 1,
} mech_parameter_type_t;
/* Track associations between parameter name and hf item for security mechanism*/
typedef struct {
const char *param_name;
const gint para_type;
const gint *hf_item;
} mech_parameter_t;
static mech_parameter_t sec_mechanism_parameters_hf_array[] =
{
{"alg", MECH_PARA_STRING, &hf_sip_sec_mechanism_alg},
{"ealg", MECH_PARA_STRING, &hf_sip_sec_mechanism_ealg},
{"prot", MECH_PARA_STRING, &hf_sip_sec_mechanism_prot},
{"spi-c", MECH_PARA_UINT, &hf_sip_sec_mechanism_spi_c},
{"spi-s", MECH_PARA_UINT, &hf_sip_sec_mechanism_spi_s},
{"port1", MECH_PARA_UINT, &hf_sip_sec_mechanism_port1},
{"port-c", MECH_PARA_UINT, &hf_sip_sec_mechanism_port_c},
{"port2", MECH_PARA_UINT, &hf_sip_sec_mechanism_port2},
{"port-s", MECH_PARA_UINT, &hf_sip_sec_mechanism_port_s},
{NULL, 0, 0}
};
typedef struct {
gint *hf_sip_display;
gint *hf_sip_addr;
gint *hf_sip_user;
gint *hf_sip_host;
gint *hf_sip_port;
gint *hf_sip_param;
gint *ett_uri;
} hf_sip_uri_t;
static hf_sip_uri_t sip_pai_uri = {
&hf_sip_pai_display,
&hf_sip_pai_addr,
&hf_sip_pai_user,
&hf_sip_pai_host,
&hf_sip_pai_port,
&hf_sip_pai_param,
&ett_sip_pai_uri
};
static hf_sip_uri_t sip_ppi_uri = {
&hf_sip_ppi_display,
&hf_sip_ppi_addr,
&hf_sip_ppi_user,
&hf_sip_ppi_host,
&hf_sip_ppi_port,
&hf_sip_ppi_param,
&ett_sip_ppi_uri
};
static hf_sip_uri_t sip_pmiss_uri = {
&hf_sip_pmiss_display,
&hf_sip_pmiss_addr,
&hf_sip_pmiss_user,
&hf_sip_pmiss_host,
&hf_sip_pmiss_port,
&hf_sip_pmiss_param,
&ett_sip_pmiss_uri
};
static hf_sip_uri_t sip_tc_uri = {
&hf_sip_tc_display,
&hf_sip_tc_addr,
&hf_sip_tc_user,
&hf_sip_tc_host,
&hf_sip_tc_port,
&hf_sip_tc_param,
&ett_sip_tc_uri
};
static hf_sip_uri_t sip_to_uri = {
&hf_sip_to_display,
&hf_sip_to_addr,
&hf_sip_to_user,
&hf_sip_to_host,
&hf_sip_to_port,
&hf_sip_to_param,
&ett_sip_to_uri
};
static hf_sip_uri_t sip_from_uri = {
&hf_sip_from_display,
&hf_sip_from_addr,
&hf_sip_from_user,
&hf_sip_from_host,
&hf_sip_from_port,
&hf_sip_from_param,
&ett_sip_from_uri
};
static hf_sip_uri_t sip_req_uri = {
&hf_sip_ruri_display,
&hf_sip_ruri,
&hf_sip_ruri_user,
&hf_sip_ruri_host,
&hf_sip_ruri_port,
&hf_sip_ruri_param,
&ett_sip_ruri
};
static hf_sip_uri_t sip_contact_uri = {
&hf_sip_curi_display,
&hf_sip_curi,
&hf_sip_curi_user,
&hf_sip_curi_host,
&hf_sip_curi_port,
&hf_sip_curi_param,
&ett_sip_curi
};
static hf_sip_uri_t sip_route_uri = {
&hf_sip_route_display,
&hf_sip_route,
&hf_sip_route_user,
&hf_sip_route_host,
&hf_sip_route_port,
&hf_sip_route_param,
&ett_sip_route
};
static hf_sip_uri_t sip_record_route_uri = {
&hf_sip_record_route_display,
&hf_sip_record_route,
&hf_sip_record_route_user,
&hf_sip_record_route_host,
&hf_sip_record_route_port,
&hf_sip_record_route_param,
&ett_sip_record_route
};
static hf_sip_uri_t sip_service_route_uri = {
&hf_sip_service_route_display,
&hf_sip_service_route,
&hf_sip_service_route_user,
&hf_sip_service_route_host,
&hf_sip_service_route_port,
&hf_sip_service_route_param,
&ett_sip_service_route
};
static hf_sip_uri_t sip_path_uri = {
&hf_sip_path_display,
&hf_sip_path,
&hf_sip_path_user,
&hf_sip_path_host,
&hf_sip_path_port,
&hf_sip_path_param,
&ett_sip_path
};
/*
* Type of line. It's either a SIP Request-Line, a SIP Status-Line, or
* another type of line.
*/
typedef enum {
REQUEST_LINE,
STATUS_LINE,
OTHER_LINE
} line_type_t;
/* Preferences */
static guint sip_tls_port = TLS_PORT_SIP;
/* global_sip_raw_text determines whether we are going to display */
/* the raw text of the SIP message, much like the MEGACO dissector does. */
static gboolean global_sip_raw_text = FALSE;
/* global_sip_raw_text_without_crlf determines whether we are going to display */
/* the raw text of the SIP message with or without the '\r\n'. */
static gboolean global_sip_raw_text_without_crlf = FALSE;
/* global_sip_raw_text_body_default_encoding determines what charset we are going to display the body */
static gint global_sip_raw_text_body_default_encoding = IANA_CS_UTF_8;
/* strict_sip_version determines whether the SIP dissector enforces
* the SIP version to be "SIP/2.0". */
static gboolean strict_sip_version = TRUE;
/*
* desegmentation of SIP headers
* (when we are over TCP or another protocol providing the desegmentation API)
*/
static gboolean sip_desegment_headers = TRUE;
/*
* desegmentation of SIP bodies
* (when we are over TCP or another protocol providing the desegmentation API)
*/
static gboolean sip_desegment_body = TRUE;
/*
* same source port for retransmissions
*/
static gboolean sip_retrans_the_same_sport = TRUE;
/* whether we hold off tracking RTP conversations until an SDP answer is received */
static gboolean sip_delay_sdp_changes = FALSE;
/* Hide the generated Call IDs or not */
static gboolean sip_hide_generatd_call_ids = FALSE;
/* Extension header subdissectors */
static dissector_table_t ext_hdr_subdissector_table;
/* Custom SIP headers */
typedef struct _header_field_t {
gchar* header_name;
gchar* header_desc;
} header_field_t;
static header_field_t* sip_custom_header_fields;
static guint sip_custom_num_header_fields;
static GHashTable *sip_custom_header_fields_hash;
static hf_register_info *dynamic_hf;
static guint dynamic_hf_size;
static gboolean
header_fields_update_cb(void *r, char **err)
{
header_field_t *rec = (header_field_t *)r;
char c;
if (rec->header_name == NULL) {
*err = g_strdup("Header name can't be empty");
return FALSE;
}
g_strstrip(rec->header_name);
if (rec->header_name[0] == 0) {
*err = g_strdup("Header name can't be empty");
return FALSE;
}
/* Check for invalid characters (to avoid asserting out when
* registering the field).
*/
c = proto_check_field_name(rec->header_name);
if (c) {
*err = ws_strdup_printf("Header name can't contain '%c'", c);
return FALSE;
}
*err = NULL;
return TRUE;
}
static void *
header_fields_copy_cb(void* n, const void* o, size_t siz _U_)
{
header_field_t* new_rec = (header_field_t*)n;
const header_field_t* old_rec = (const header_field_t*)o;
new_rec->header_name = g_strdup(old_rec->header_name);
new_rec->header_desc = g_strdup(old_rec->header_desc);
return new_rec;
}
static void
header_fields_free_cb(void*r)
{
header_field_t* rec = (header_field_t*)r;
g_free(rec->header_name);
g_free(rec->header_desc);
}
static void
deregister_header_fields(void)
{
if (dynamic_hf) {
/* Deregister all fields */
for (guint i = 0; i < dynamic_hf_size; i++) {
proto_deregister_field(proto_sip, *(dynamic_hf[i].p_id));
g_free(dynamic_hf[i].p_id);
}
proto_add_deregistered_data(dynamic_hf);
dynamic_hf = NULL;
dynamic_hf_size = 0;
}
if (sip_custom_header_fields_hash) {
g_hash_table_destroy(sip_custom_header_fields_hash);
sip_custom_header_fields_hash = NULL;
}
}
static void
header_fields_post_update_cb(void)
{
gint* hf_id;
gchar* header_name;
gchar* header_name_key;
deregister_header_fields();
if (sip_custom_num_header_fields) {
sip_custom_header_fields_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
dynamic_hf = g_new0(hf_register_info, sip_custom_num_header_fields);
dynamic_hf_size = sip_custom_num_header_fields;
for (guint i = 0; i < dynamic_hf_size; i++) {
hf_id = g_new(gint, 1);
*hf_id = -1;
header_name = g_strdup(sip_custom_header_fields[i].header_name);
header_name_key = g_ascii_strdown(header_name, -1);
dynamic_hf[i].p_id = hf_id;
dynamic_hf[i].hfinfo.name = header_name;
dynamic_hf[i].hfinfo.abbrev = ws_strdup_printf("sip.%s", header_name);
dynamic_hf[i].hfinfo.type = FT_STRING;
dynamic_hf[i].hfinfo.display = BASE_NONE;
dynamic_hf[i].hfinfo.strings = NULL;
dynamic_hf[i].hfinfo.bitmask = 0;
dynamic_hf[i].hfinfo.blurb = g_strdup(sip_custom_header_fields[i].header_desc);
HFILL_INIT(dynamic_hf[i]);
g_hash_table_insert(sip_custom_header_fields_hash, header_name_key, hf_id);
}
proto_register_field_array(proto_sip, dynamic_hf, dynamic_hf_size);
}
}
static void
header_fields_reset_cb(void)
{
deregister_header_fields();
}
UAT_CSTRING_CB_DEF(sip_custom_header_fields, header_name, header_field_t)
UAT_CSTRING_CB_DEF(sip_custom_header_fields, header_desc, header_field_t)
/* SIP authorization parameters */
static gboolean global_sip_validate_authorization = FALSE;
typedef struct _authorization_user_t {
gchar* username;
gchar* realm;
gchar* password;
} authorization_user_t;
static authorization_user_t* sip_authorization_users = NULL;
static guint sip_authorization_num_users = 0;
static gboolean
authorization_users_update_cb(void *r, char **err)
{
authorization_user_t *rec = (authorization_user_t *)r;
char c;
if (rec->username == NULL) {
*err = g_strdup("Username can't be empty");
return FALSE;
}
g_strstrip(rec->username);
if (rec->username[0] == 0) {
*err = g_strdup("Username can't be empty");
return FALSE;
}
/* Check for invalid characters (to avoid asserting out when
* registering the field).
*/
c = proto_check_field_name(rec->username);
if (c) {
*err = ws_strdup_printf("Username can't contain '%c'", c);
return FALSE;
}
*err = NULL;
return TRUE;
}
static void *
authorization_users_copy_cb(void* n, const void* o, size_t siz _U_)
{
authorization_user_t* new_rec = (authorization_user_t*)n;
const authorization_user_t* old_rec = (const authorization_user_t*)o;
new_rec->username = g_strdup(old_rec->username);
new_rec->realm = g_strdup(old_rec->realm);
new_rec->password = g_strdup(old_rec->password);
return new_rec;
}
static void
authorization_users_free_cb(void*r)
{
authorization_user_t* rec = (authorization_user_t*)r;
g_free(rec->username);
g_free(rec->realm);
g_free(rec->password);
}
UAT_CSTRING_CB_DEF(sip_authorization_users, username, authorization_user_t)
UAT_CSTRING_CB_DEF(sip_authorization_users, realm, authorization_user_t)
UAT_CSTRING_CB_DEF(sip_authorization_users, password, authorization_user_t)
/* Forward declaration we need below */
void proto_reg_handoff_sip(void);
static gboolean dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info *pinfo,
proto_tree *tree, gboolean is_heur, gboolean use_reassembly);
static line_type_t sip_parse_line(tvbuff_t *tvb, int offset, gint linelen,
guint *token_1_len);
static gboolean sip_is_known_request(tvbuff_t *tvb, int meth_offset,
guint meth_len, guint *meth_idx);
static gint sip_is_known_sip_header(gchar *header_name, guint header_len);
static void dfilter_sip_request_line(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, gint offset,
guint meth_len, gint linelen);
static void dfilter_sip_status_line(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, gint line_end, gint offset);
static void tvb_raw_text_add(tvbuff_t *tvb, int offset, int length, int body_offset, packet_info* pinfo, proto_tree *tree);
static guint sip_is_packet_resend(packet_info *pinfo,
const char *cseq_method,
gchar* call_id,
guchar cseq_number_set, guint32 cseq_number,
line_type_t line_type);
static guint sip_find_request(packet_info *pinfo,
const char *cseq_method,
gchar* call_id,
guchar cseq_number_set, guint32 cseq_number,
guint32 *response_time);
static guint sip_find_invite(packet_info *pinfo,
const char *cseq_method,
gchar* call_id,
guchar cseq_number_set, guint32 cseq_number,
guint32 *response_time);
typedef struct
{
gchar * username;
gchar * realm;
gchar * uri;
gchar * nonce;
gchar * cnonce;
gchar * nonce_count;
gchar * response;
gchar * qop;
gchar * algorithm;
gchar * method;
} sip_authorization_t;
static authorization_user_t * sip_get_authorization(sip_authorization_t *authorization_info);
static gboolean sip_validate_authorization(sip_authorization_t *authorization_info, gchar *password);
static authorization_user_t * sip_get_authorization(sip_authorization_t *authorization_info)
{
guint i;
for (i = 0; i < sip_authorization_num_users; i++) {
if ((!strcmp(sip_authorization_users[i].username, authorization_info->username)) &&
(!strcmp(sip_authorization_users[i].realm, authorization_info->realm))) {
return &sip_authorization_users[i];
}
}
return NULL;
}
/* SIP content type and internet media type used by other dissectors
* are the same. List of media types from IANA at:
* http://www.iana.org/assignments/media-types/index.html */
static dissector_table_t media_type_dissector_table;
static heur_dissector_list_t heur_subdissector_list;
#define SIP2_HDR "SIP/2.0"
#define SIP2_HDR_LEN 7
/* Store the info needed by the SIP tap for one packet */
static sip_info_value_t *stat_info;
/* The buffer size for the cseq_method name */
#define MAX_CSEQ_METHOD_SIZE 16
/****************************************************************************
* Conversation-type definitions
*
* For each call, keep track of the current cseq number and state of
* transaction, in order to be able to detect retransmissions.
*
* Don't use the conversation mechanism, but instead:
* - store with each dissected packet original frame (if any)
* - maintain a global hash table of
* (call_id, source_addr, dest_addr) -> (cseq, transaction_state, frame)
*
* N.B. This is broken for a couple of reasons:
* - it won't cope properly with overlapping transactions within the
* same dialog
* - request response mapping won't work where the response uses a different
* address pair from the request
*
* TODO: proper transaction matching uses RFC fields (use Max-forwards or
* maybe Via count as extra key to limit view to one hop)
****************************************************************************/
static GHashTable *sip_hash = NULL; /* Hash table */
static GHashTable *sip_headers_hash = NULL; /* Hash table */
/* Types for hash table keys and values */
#define MAX_CALL_ID_SIZE 128
#define MAGIC_SOURCE_PORT 0
/* Conversation-type key */
typedef struct
{
char call_id[MAX_CALL_ID_SIZE];
address source_address;
guint32 source_port;
address dest_address;
guint32 dest_port;
} sip_hash_key;
typedef enum
{
nothing_seen,
request_seen,
provisional_response_seen,
final_response_seen
} transaction_state_t;
/* Current conversation-type value */
typedef struct
{
guint32 cseq;
transaction_state_t transaction_state;
const char *method;
nstime_t request_time;
guint32 response_code;
gint frame_number;
} sip_hash_value;
/* Result to be stored in per-packet info */
typedef struct
{
gint original_frame_num;
gint response_request_frame_num;
gint response_time;
} sip_frame_result_value;
/************************/
/* Hash table functions */
/* Equal keys */
static gint sip_equal(gconstpointer v, gconstpointer v2)
{
const sip_hash_key* val1 = (const sip_hash_key*)v;
const sip_hash_key* val2 = (const sip_hash_key*)v2;
/* Call id must match */
if (strcmp(val1->call_id, val2->call_id) != 0)
{
return 0;
}
/* Addresses must match */
return (addresses_equal(&(val1->source_address), &(val2->source_address))) &&
(val1->source_port == val2->source_port) &&
(addresses_equal(&(val1->dest_address), &(val2->dest_address))) &&
(val1->dest_port == val2->dest_port);
}
/* Initializes the hash table each time a new
* file is loaded or re-loaded in wireshark */
static void
sip_init_protocol(void)
{
guint i;
gchar *value_copy;
sip_hash = g_hash_table_new(g_str_hash , sip_equal);
/* Hash table for quick lookup of SIP headers names to hf entry (POS_x) */
sip_headers_hash = g_hash_table_new(g_str_hash , g_str_equal);
for (i = 1; i < array_length(sip_headers); i++){
value_copy = wmem_strdup(wmem_file_scope(), sip_headers[i].name);
ascii_strdown_inplace(value_copy);
g_hash_table_insert(sip_headers_hash, (gpointer)value_copy, GINT_TO_POINTER(i));
}
}
static void
sip_cleanup_protocol(void)
{
g_hash_table_destroy(sip_hash);
g_hash_table_destroy(sip_headers_hash);
}
/* Call the export PDU tap with relevant data */
static void
export_sip_pdu(packet_info *pinfo, tvbuff_t *tvb)
{
exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, "sip", EXP_PDU_TAG_DISSECTOR_NAME);
exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb);
exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
exp_pdu_data->pdu_tvb = tvb;
tap_queue_packet(exported_pdu_tap, pinfo, exp_pdu_data);
}
typedef enum
{
SIP_URI_TYPE_ABSOLUTE_URI,
SIP_URI_TYPE_SIP,
SIP_URI_TYPE_TEL
} sip_uri_type_enum_t;
/* Structure to collect info about a sip uri */
typedef struct _uri_offset_info
{
sip_uri_type_enum_t uri_type;
gint display_name_start;
gint display_name_end;
gint uri_start;
gint uri_end;
gint uri_parameters_start;
gint uri_parameters_end;
gint name_addr_start;
gint name_addr_end;
gint uri_user_start;
gint uri_user_end;
gint uri_host_start;
gint uri_host_end;
gint uri_host_port_start;
gint uri_host_port_end;
} uri_offset_info;
static void
sip_uri_offset_init(uri_offset_info *uri_offsets){
/* Initialize the uri_offsets */
uri_offsets->uri_type = SIP_URI_TYPE_ABSOLUTE_URI;
uri_offsets->display_name_start = -1;
uri_offsets->display_name_end = -1;
uri_offsets->uri_start = -1;
uri_offsets->uri_end = -1;
uri_offsets->uri_parameters_start = -1;
uri_offsets->uri_parameters_end = -1;
uri_offsets->name_addr_start = -1;
uri_offsets->name_addr_end = -1;
uri_offsets->uri_user_start = -1;
uri_offsets->uri_user_end = -1;
uri_offsets->uri_host_start = -1;
uri_offsets->uri_host_end = -1;
uri_offsets->uri_host_port_start = -1;
uri_offsets->uri_host_port_end = -1;
}
/* Code to parse a sip uri.
* Returns Offset end off parsing or -1 for unsuccessful parsing
* - sip_uri_offset_init() must have been called first.
*/
static gint
dissect_sip_uri(tvbuff_t *tvb, packet_info *pinfo _U_, gint start_offset,
gint line_end_offset, uri_offset_info *uri_offsets)
{
guchar c = '\0';
gint current_offset;
gint queried_offset;
gint parameter_end_offset;
gboolean in_ipv6 = FALSE;
/* skip Spaces and Tabs */
current_offset = tvb_skip_wsp(tvb, start_offset, line_end_offset - start_offset);
if(current_offset >= line_end_offset) {
/* Nothing to parse */
return -1;
}
/* Set uri start offset in case this was called directly */
uri_offsets->uri_start = current_offset;
/* Check if it's really a sip uri ( it might be a tel uri, parse that?) */
if (tvb_strneql(tvb, current_offset, "sip", 3) != 0){
if (uri_offsets->uri_end != -1) {
/* We know where the URI ends, set the offsets*/
return uri_offsets->name_addr_end;
}
return -1;
}
uri_offsets->uri_type = SIP_URI_TYPE_SIP;
if(uri_offsets->uri_end == -1)
{
/* name-addr form was NOT used e.g no closing ">" */
/* look for the first ',' or ';' which will mark the end of this URI
* In this case a semicolon indicates a header field parameter, and not an uri parameter.
*/
int end_offset;
end_offset = tvb_ws_mempbrk_pattern_guint8(tvb, current_offset, line_end_offset - current_offset, &pbrk_comma_semi, NULL);
if (end_offset != -1)
{
uri_offsets->uri_end = end_offset - 1;
}
else
{
/* We don't have a semicolon or a comma.
* In that case, we assume that the end of the URI is at the line end
*/
uri_offsets->uri_end = line_end_offset - 3; /* remove '\r\n' */
}
uri_offsets->name_addr_end = uri_offsets->uri_end;
}
/* Look for URI address parts (user, host, host-port) */
/* Look for '@' within URI */
queried_offset = tvb_find_guint8(tvb, uri_offsets->uri_start, uri_offsets->uri_end - uri_offsets->uri_start, '@');
if(queried_offset == -1)
{
/* no '@' = no user part */
uri_offsets->uri_host_start = tvb_find_guint8(tvb, uri_offsets->uri_start, uri_offsets->uri_end - uri_offsets->uri_start, ':')+1;
}
else
{
/* with '@' = with user part */
uri_offsets->uri_user_start = tvb_find_guint8(tvb, uri_offsets->uri_start, uri_offsets->uri_end - uri_offsets->uri_start, ':')+1;
uri_offsets->uri_user_end = tvb_find_guint8(tvb, uri_offsets->uri_user_start, uri_offsets->uri_end - uri_offsets->uri_start, '@')-1;
uri_offsets->uri_host_start = uri_offsets->uri_user_end + 2;
}
/* find URI-Host end*/
parameter_end_offset = uri_offsets->uri_host_start;
in_ipv6 = (tvb_get_guint8(tvb, parameter_end_offset) == '[');
while (parameter_end_offset < line_end_offset)
{
parameter_end_offset++;
parameter_end_offset = tvb_ws_mempbrk_pattern_guint8(tvb, parameter_end_offset, line_end_offset - parameter_end_offset, &pbrk_param_end_colon_brackets, &c);
if (parameter_end_offset == -1)
{
parameter_end_offset = line_end_offset;
break;
}
/* after adding character to this switch() , update also pbrk_param_end_colon_brackets */
switch (c) {
case '>':
case ',':
goto uri_host_end_found;
case ';':
uri_offsets->uri_parameters_start = parameter_end_offset + 1;
goto uri_host_end_found;
case '?':
case ' ':
case '\r':
goto uri_host_end_found;
case ':':
if (!in_ipv6)
goto uri_host_end_found;
break;
case '[':
in_ipv6 = TRUE;
break;
case ']':
in_ipv6 = FALSE;
break;
default :
DISSECTOR_ASSERT_NOT_REACHED();
break;
}
}
uri_host_end_found:
uri_offsets->uri_host_end = parameter_end_offset - 1;
if (c == ':')
{
uri_offsets->uri_host_port_start = parameter_end_offset + 1;
parameter_end_offset = uri_offsets->uri_host_port_start;
while (parameter_end_offset < line_end_offset)
{
parameter_end_offset++;
parameter_end_offset = tvb_ws_mempbrk_pattern_guint8(tvb, parameter_end_offset, line_end_offset - parameter_end_offset, &pbrk_param_end, &c);
if (parameter_end_offset == -1)
{
parameter_end_offset = line_end_offset;
break;
}
/* after adding character to this switch(), update also pbrk_param_end */
switch (c) {
case '>':
case ',':
goto uri_host_port_end_found;
case ';':
uri_offsets->uri_parameters_start = parameter_end_offset + 1;
goto uri_host_port_end_found;
case '?':
case ' ':
case '\r':
goto uri_host_port_end_found;
default :
DISSECTOR_ASSERT_NOT_REACHED();
break;
}
}
uri_host_port_end_found:
uri_offsets->uri_host_port_end = parameter_end_offset -1;
}
return uri_offsets->name_addr_end;
}
void
dfilter_store_sip_from_addr(tvbuff_t *tvb,proto_tree *tree,guint parameter_offset, guint parameter_len)
{
proto_item *pi;
pi = proto_tree_add_item(tree, hf_sip_from_addr, tvb, parameter_offset, parameter_len, ENC_UTF_8);
proto_item_set_generated(pi);
}
static proto_item *
sip_proto_tree_add_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length, gint value_offset, gint value_len)
{
const char *str;
unsigned long val;
/* don't fetch string when field is not referenced */
if (!proto_field_is_referenced(tree, hfindex))
return tree;
str = tvb_get_string_enc(wmem_packet_scope(), tvb, value_offset, value_len, ENC_UTF_8|ENC_NA);
val = strtoul(str, NULL, 10);
return proto_tree_add_uint(tree, hfindex, tvb, start, length, (guint32) val);
}
static proto_item *
sip_proto_tree_add_string(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length, gint value_offset, gint value_len)
{
const char *str;
/* don't fetch string when field is not referenced */
if (!proto_field_is_referenced(tree, hfindex))
return tree;
str = tvb_get_string_enc(wmem_packet_scope(), tvb, value_offset, value_len, ENC_UTF_8|ENC_NA);
return proto_tree_add_string(tree, hfindex, tvb, start, length, str);
}
static void
sip_proto_set_format_text(const proto_tree *tree, proto_item *item, tvbuff_t *tvb, int offset, int length)
{
if (tree != item && item && PTREE_DATA(item)->visible)
proto_item_set_text(item, "%s", tvb_format_text(wmem_packet_scope(), tvb, offset, length));
}
/*
* XXXX If/when more parameters are added consider doing something similar to what's done in
* packet-magaco.c for find_megaco_localParam_names() possibly adding the hf to the array and have a generic
* dissection function here.
*/
static void
dissect_sip_generic_parameters(tvbuff_t *tvb, proto_tree* tree, packet_info *pinfo _U_, gint current_offset, gint line_end_offset)
{
gint semi_colon_offset, par_name_end_offset, equals_offset, length;
/* Loop over the generic parameter(s)*/
while (current_offset < line_end_offset) {
gchar *param_name = NULL;
/* skip Spaces and Tabs */
current_offset = tvb_skip_wsp(tvb, current_offset, line_end_offset - current_offset);
semi_colon_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, ';');
if (semi_colon_offset == -1) {
semi_colon_offset = line_end_offset;
}
length = semi_colon_offset - current_offset;
/* Parse parameter and value */
equals_offset = tvb_find_guint8(tvb, current_offset + 1, length, '=');
if (equals_offset != -1) {
/* Has value part */
par_name_end_offset = equals_offset;
/* Extract the parameter name */
param_name = tvb_get_string_enc(wmem_packet_scope(), tvb, current_offset, par_name_end_offset - current_offset, ENC_UTF_8 | ENC_NA);
/* Access-Info fields */
if ((param_name != NULL) && (g_ascii_strcasecmp(param_name, "service-priority") == 0)) {
proto_tree_add_item(tree, hf_sip_service_priority, tvb,
equals_offset + 1, semi_colon_offset - equals_offset - 1, ENC_UTF_8 | ENC_NA);
}
else {
proto_tree_add_format_text(tree, tvb, current_offset, length);
}
}
else {
proto_tree_add_format_text(tree, tvb, current_offset, length);
}
current_offset = semi_colon_offset + 1;
}
}
/*
* History-Info = "History-Info" HCOLON
* hi-entry *(COMMA hi-entry)
*
* hi-entry = hi-targeted-to-uri *( SEMI hi-param )
* hi-targeted-to-uri= name-addr
*
*
* hi-param = hi-index / hi-extension
*
* hi-index = "index" EQUAL 1*DIGIT *(DOT 1*DIGIT)
*
* hi-extension = generic-param
*/
static gint
dissect_sip_history_info(tvbuff_t *tvb, proto_tree* tree, packet_info *pinfo _U_, gint current_offset,
gint line_end_offset)
{
int comma_offset;
gboolean first_time = TRUE;
/* split the line at the commas */
while (line_end_offset > current_offset){
comma_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, ',');
if(comma_offset == -1){
if(first_time == TRUE){
/* It was only on parameter no need to split it up */
return line_end_offset;
}
/* Last parameter */
comma_offset = line_end_offset;
}
first_time = FALSE;
proto_tree_add_format_text(tree, tvb, current_offset, comma_offset-current_offset);
current_offset = comma_offset+1;
}
return line_end_offset;
}
/*
* The syntax for the P-Charging-Function-Addresses header is described
* as follows:
*
* P-Charging-Addr = "P-Charging-Function-Addresses" HCOLON
* charge-addr-params
* *(SEMI charge-addr-params)
* charge-addr-params = ccf / ecf / generic-param
* ccf = "ccf" EQUAL gen-value
* ecf = "ecf" EQUAL gen-value
* generic-param = token [ EQUAL gen-value ]
* gen-value = token / host / quoted-string
*
*/
static gint
dissect_sip_p_charging_func_addresses(tvbuff_t *tvb, proto_tree* tree, packet_info *pinfo _U_, gint current_offset,
gint line_end_offset)
{
gint semi_offset, start_quote_offset, end_quote_offset;
gboolean first_time = TRUE;
while (line_end_offset > current_offset){
/* Do we have a quoted string ? */
start_quote_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, '"');
if(start_quote_offset>0){
/* Find end of quoted string */
end_quote_offset = tvb_find_guint8(tvb, start_quote_offset+1, line_end_offset - (start_quote_offset+1), '"');
/* Find parameter end */
if (end_quote_offset>0)
semi_offset = tvb_find_guint8(tvb, end_quote_offset+1, line_end_offset - (end_quote_offset+1), ';');
else {
/* XXX expert info about unterminated string */
semi_offset = tvb_find_guint8(tvb, start_quote_offset+1, line_end_offset - (start_quote_offset+1), ';');
}
}else{
/* Find parameter end */
semi_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, ';');
}
if(semi_offset == -1){
if(first_time == TRUE){
/* It was only one parameter no need to split it up */
return line_end_offset;
}
/* Last parameter */
semi_offset = line_end_offset;
}
first_time = FALSE;
proto_tree_add_format_text(tree, tvb, current_offset, semi_offset-current_offset);
current_offset = semi_offset+1;
}
return current_offset;
}
/*
* token = 1*(alphanum / "-" / "." / "!" / "%" / "*"
* / "_" / "+" / "`" / "'" / "~" )
* LWS = [*WSP CRLF] 1*WSP ; linear whitespace
* name-addr = [ display-name ] LAQUOT addr-spec RAQUOT
* addr-spec = SIP-URI / SIPS-URI / absoluteURI
* display-name = *(token LWS)/ quoted-string
* absoluteURI = scheme ":" ( hier-part / opaque-part )
*/
static gint
dissect_sip_name_addr_or_addr_spec(tvbuff_t *tvb, packet_info *pinfo _U_, gint start_offset,
gint line_end_offset, uri_offset_info *uri_offsets)
{
gchar c;
gint i;
gint current_offset;
gint queried_offset;
gint colon_offset;
gboolean uri_without_angle_quotes = FALSE;
/* skip Spaces and Tabs */
current_offset = tvb_skip_wsp(tvb, start_offset, line_end_offset - start_offset);
if(current_offset >= line_end_offset) {
/* Nothing to parse */
return -1;
}
uri_offsets->name_addr_start = current_offset;
/* First look, if we have a display name */
c=tvb_get_guint8(tvb, current_offset);
switch(c)
{
case '"':
/* We have a display name, look for the next unescaped '"' */
uri_offsets->display_name_start = current_offset;
do
{
queried_offset = tvb_find_guint8(tvb, current_offset + 1, line_end_offset - (current_offset + 1), '"');
if(queried_offset == -1)
{
/* malformed URI */
return -1;
}
current_offset = queried_offset;
/* Is it escaped? */
/* count back slashes before '"' */
for(i=1;tvb_get_guint8(tvb, queried_offset - i) == '\\';i++);
i--;
if(i % 2 == 0)
{
/* not escaped */
break;
}
} while (current_offset < line_end_offset);
if(current_offset >= line_end_offset)
{
/* malformed URI */
return -1;
}
uri_offsets->display_name_end = current_offset;
/* find start of the URI */
queried_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, '<');
if(queried_offset == -1)
{
/* malformed Uri */
return -1;
}
current_offset = queried_offset + 1;
break;
case '<':
/* We don't have a display name */
current_offset++;
break;
default:
/* We have either an URI without angles or a display name with a limited character set */
/* Look for the right angle quote or colon */
queried_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, '<');
colon_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, ':');
if(queried_offset != -1 && colon_offset != -1)
{
if(queried_offset < colon_offset)
{
/* we have an URI with angle quotes */
uri_offsets->display_name_start = current_offset;
uri_offsets->display_name_end = queried_offset - 1;
current_offset = queried_offset + 1;
}
else
{
/* we have an URI without angle quotes */
uri_without_angle_quotes = TRUE;
}
}
else
{
if(queried_offset != -1)
{
/* we have an URI with angle quotes */
uri_offsets->display_name_start = current_offset;
uri_offsets->display_name_end = queried_offset - 1;
current_offset = queried_offset + 1;
break;
}
if(colon_offset != -1)
{
/* we have an URI without angle quotes */
uri_without_angle_quotes = TRUE;
break;
}
/* If this point is reached, we can't parse the URI */
return -1;
}
break;
}
/* Start of URI */
uri_offsets->uri_start = current_offset;
if(uri_without_angle_quotes==FALSE){
/* name-addr form was used */
/* look for closing angle quote */
queried_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, '>');
if(queried_offset == -1)
{
/* malformed Uri */
return -1;
}
uri_offsets->name_addr_end = queried_offset;
uri_offsets->uri_end = queried_offset - 1;
}
return dissect_sip_uri(tvb, pinfo, current_offset, line_end_offset, uri_offsets);
}
/*
* Code to add dissected SIP URI Information to proto tree
*/
static proto_tree *
display_sip_uri (tvbuff_t *tvb, proto_tree *sip_element_tree, packet_info *pinfo, uri_offset_info* uri_offsets, hf_sip_uri_t* uri)
{
proto_item *ti;
proto_tree *uri_item_tree = NULL;
tvbuff_t *next_tvb;
if(uri_offsets->display_name_end != uri_offsets->display_name_start) {
proto_tree_add_item(sip_element_tree, *(uri->hf_sip_display), tvb, uri_offsets->display_name_start,
uri_offsets->display_name_end - uri_offsets->display_name_start + 1, ENC_UTF_8|ENC_NA);
ti = proto_tree_add_item(sip_element_tree, hf_sip_display, tvb, uri_offsets->display_name_start,
uri_offsets->display_name_end - uri_offsets->display_name_start + 1, ENC_UTF_8);
proto_item_set_hidden(ti);
}
ti = proto_tree_add_item(sip_element_tree, *(uri->hf_sip_addr),
tvb, uri_offsets->uri_start, uri_offsets->uri_end - uri_offsets->uri_start + 1, ENC_UTF_8|ENC_NA);
uri_item_tree = proto_item_add_subtree(ti, *(uri->ett_uri));
if (uri_offsets->uri_type != SIP_URI_TYPE_SIP) {
return ti;
}
if(uri_offsets->uri_user_end > uri_offsets->uri_user_start) {
proto_tree_add_item(uri_item_tree, *(uri->hf_sip_user), tvb, uri_offsets->uri_user_start,
uri_offsets->uri_user_end - uri_offsets->uri_user_start + 1, ENC_UTF_8|ENC_NA);
if (tvb_get_guint8(tvb, uri_offsets->uri_user_start) == '+') {
dissect_e164_msisdn(tvb, uri_item_tree, uri_offsets->uri_user_start + 1, uri_offsets->uri_user_end - uri_offsets->uri_user_start, E164_ENC_UTF8);
}
/* If we have a SIP diagnostics sub dissector call it */
if (sip_uri_userinfo_handle) {
next_tvb = tvb_new_subset_length_caplen(tvb, uri_offsets->uri_user_start, uri_offsets->uri_user_end - uri_offsets->uri_user_start + 1,
uri_offsets->uri_user_end - uri_offsets->uri_user_start + 1);
call_dissector(sip_uri_userinfo_handle, next_tvb, pinfo, uri_item_tree);
}
}
proto_tree_add_item(uri_item_tree, *(uri->hf_sip_host), tvb, uri_offsets->uri_host_start,
uri_offsets->uri_host_end - uri_offsets->uri_host_start + 1, ENC_UTF_8|ENC_NA);
if(uri_offsets->uri_host_port_end > uri_offsets->uri_host_port_start) {
proto_tree_add_item(uri_item_tree, *(uri->hf_sip_port), tvb, uri_offsets->uri_host_port_start,
uri_offsets->uri_host_port_end - uri_offsets->uri_host_port_start + 1, ENC_UTF_8|ENC_NA);
}
if (uri_offsets->uri_parameters_start != -1) {
/* Move current offset to the start of the first param */
gint current_offset = uri_offsets->uri_parameters_start;
gint uri_params_start_offset = current_offset;
gint queried_offset;
gint uri_param_end_offset = -1;
gchar c;
/* Put the contact parameters in the tree */
while (current_offset < uri_offsets->name_addr_end) {
queried_offset = tvb_ws_mempbrk_pattern_guint8(tvb, current_offset, uri_offsets->name_addr_end - current_offset, &pbrk_comma_semi, &c);
if (queried_offset == -1) {
/* Reached line end */
/* Check if the line ends with a ">", if so decrement end offset. */
c = tvb_get_guint8(tvb, uri_offsets->name_addr_end);
if (c == '>') {
uri_param_end_offset = uri_offsets->name_addr_end - 1;
} else {
uri_param_end_offset = uri_offsets->name_addr_end;
}
current_offset = uri_offsets->name_addr_end;
} else if (c==',') {
uri_param_end_offset = queried_offset;
current_offset = queried_offset+1; /* must move forward */
} else if (c==';') {
/* More parameters */
uri_param_end_offset = queried_offset-1;
current_offset = tvb_skip_wsp(tvb, queried_offset+1, uri_offsets->name_addr_end - queried_offset + 1);
}
proto_tree_add_item(uri_item_tree, *(uri->hf_sip_param), tvb, uri_params_start_offset ,
uri_param_end_offset - uri_params_start_offset +1, ENC_UTF_8|ENC_NA);
/* In case there are more parameters, point to the start of it */
uri_params_start_offset = current_offset;
}
}
return uri_item_tree;
}
/* Code to parse a contact header item
* Returns Offset end off parsing or -1 for unsuccessful parsing
* * contact-param = (name-addr / addr-spec) *(SEMI contact-params)
*/
static gint
dissect_sip_contact_item(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint start_offset, gint line_end_offset,
guchar* contacts_expires_0, guchar* contacts_expires_unknown)
{
gchar c;
gint current_offset;
gint queried_offset;
gint contact_params_start_offset = -1;
/*gint contact_param_end_offset = -1;*/
uri_offset_info uri_offsets;
gboolean end_of_hdr = FALSE;
gboolean has_expires_param = FALSE;
/* skip Spaces and Tabs */
start_offset = tvb_skip_wsp(tvb, start_offset, line_end_offset - start_offset);
if(start_offset >= line_end_offset) {
/* Nothing to parse */
return -1;
}
/* Initialize the uri_offsets */
sip_uri_offset_init(&uri_offsets);
/* contact-param = (name-addr / addr-spec) *(SEMI contact-params) */
current_offset = dissect_sip_name_addr_or_addr_spec(tvb, pinfo, start_offset, line_end_offset, &uri_offsets);
if(current_offset == -1)
{
/* Parsing failed */
return -1;
}
display_sip_uri(tvb, tree, pinfo, &uri_offsets, &sip_contact_uri);
/* check if there's a comma before a ';', in which case we stop parsing this item at the comma */
queried_offset = tvb_find_guint8(tvb, uri_offsets.uri_end, line_end_offset - uri_offsets.uri_end, ',');
/* Check if we have contact parameters, the uri should be followed by a ';' */
contact_params_start_offset = tvb_find_guint8(tvb, uri_offsets.uri_end, line_end_offset - uri_offsets.uri_end, ';');
if (queried_offset != -1 && (queried_offset < contact_params_start_offset || contact_params_start_offset == -1)) {
/* no expires param */
(*contacts_expires_unknown)++;
return queried_offset;
}
/* check if contact-params is present */
if(contact_params_start_offset == -1) {
/* no expires param */
(*contacts_expires_unknown)++;
return line_end_offset;
}
/* Move current offset to the start of the first param */
contact_params_start_offset++;
current_offset = contact_params_start_offset;
/* Put the contact parameters in the tree */
queried_offset = current_offset;
while(current_offset< line_end_offset){
c = '\0';
queried_offset++;
queried_offset = (queried_offset < line_end_offset) ? tvb_ws_mempbrk_pattern_guint8(tvb, queried_offset, line_end_offset - queried_offset, &pbrk_header_end_dquote, &c) : -1;
if (queried_offset != -1)
{
switch (c) {
/* prevent tree from displaying the '\r\n' as part of the param */
case '\r':
case '\n':
end_of_hdr = TRUE;
/* fall through */
case ',':
case ';':
case '"':
break;
default :
DISSECTOR_ASSERT_NOT_REACHED();
break;
}
}
if (queried_offset == -1) {
/* Last parameter, line end */
current_offset = line_end_offset;
}else if(c=='"'){
/* Do we have a quoted string ? */
queried_offset = tvb_find_guint8(tvb, queried_offset+1, line_end_offset - queried_offset, '"');
if(queried_offset==-1){
/* We have an opening quote but no closing quote. */
current_offset = line_end_offset;
} else {
current_offset = tvb_ws_mempbrk_pattern_guint8(tvb, queried_offset+1, line_end_offset - queried_offset, &pbrk_comma_semi, &c);
if(current_offset==-1){
/* Last parameter, line end */
current_offset = line_end_offset;
}
}
}else{
current_offset = queried_offset;
}
proto_tree_add_item(tree, hf_sip_contact_param, tvb, contact_params_start_offset ,
current_offset - contact_params_start_offset, ENC_UTF_8);
/* need to check for an 'expires' parameter
* TODO: this should be done in a common way for all headers,
* but To/From/etc do their own right now so doing the same here
*/
/* also, this is a bad way of checking param names, but it's what To/From
* etc, do. But legally "exPiRes = value" is also legit.
*/
if (tvb_strncaseeql(tvb, contact_params_start_offset, "expires=", 8) == 0) {
gint32 expire;
/* if the expires param value is 0, then it's de-registering
* this assumes the message is a REGISTER request/response, but these
* contacts_expires_0/contacts_expires_unknown variables only get used then,
* so that's ok
*/
if (!ws_strtoi32(tvb_get_string_enc(wmem_packet_scope(), tvb, contact_params_start_offset+8,
current_offset - (contact_params_start_offset+8), ENC_UTF_8|ENC_NA), NULL, &expire))
return contact_params_start_offset+8;
has_expires_param = TRUE;
if (expire == 0) {
(*contacts_expires_0)++;
/* RFC 3261 10.3 "Processing REGISTER requests":
* "The registrar returns a 200 (OK) response. The response
* MUST contain Contact header field values enumerating all
* current bindings."
* This implies it is invalid for the response to contain the
* deregistered, no longer current, Contacts with expires=0.
* However, this warning was removed due to 3GPP usage.
* Cf. 3GPP TS 24.229 "5.4.1.4 User-initiated deregistration":
* "send a 200 (OK) response to a REGISTER request that
* contains a list of Contact header fields enumerating all
* contacts and flows that are currently registered, and all
* contacts that have been deregistered."
* https://gitlab.com/wireshark/wireshark/-/issues/10364
*/
#if 0
if (stat_info && stat_info->response_code > 199 && stat_info->response_code < 300) {
proto_tree_add_expert_format(tree, pinfo, &ei_sip_odd_register_response,
tvb, contact_params_start_offset, current_offset - contact_params_start_offset,
"SIP REGISTER %d response contains Contact with expires=0",
stat_info->response_code);
}
#endif
}
}
/* In case there are more parameters, point to the start of it */
contact_params_start_offset = current_offset+1;
queried_offset = contact_params_start_offset;
if (end_of_hdr) {
/* '\r' or '\n' found, stop parsing and also set current offset to end
* so the return value indicates we reached line end
*/
current_offset = line_end_offset;
}
if (c == ',') {
/* comma separator found, stop parsing of current contact-param here */
break;
}
}
if (!has_expires_param) {
(*contacts_expires_unknown)++;
}
return current_offset;
}
/* Code to parse an authorization header item
* Returns offset at end of parsing, or -1 for unsuccessful parsing
*/
static gint
dissect_sip_authorization_item(tvbuff_t *tvb, proto_tree *tree, gint start_offset, gint line_end_offset, sip_authorization_t *authorization_info)
{
gint current_offset, par_name_end_offset, queried_offset, value_offset, value_search_offset;
gint equals_offset = 0;
gchar *name;
header_parameter_t *auth_parameter;
guint i = 0;
/* skip Spaces and Tabs */
start_offset = tvb_skip_wsp(tvb, start_offset, line_end_offset - start_offset);
if (start_offset >= line_end_offset)
{
/* Nothing to parse */
return -1;
}
current_offset = start_offset;
equals_offset = tvb_find_guint8(tvb, current_offset + 1, line_end_offset - (current_offset + 1), '=');
if(equals_offset == -1){
/* malformed parameter */
return -1;
}
par_name_end_offset = equals_offset - 1;
par_name_end_offset = tvb_skip_wsp_return(tvb,par_name_end_offset);
/* Extract the parameter name */
name = tvb_get_string_enc(wmem_packet_scope(), tvb, start_offset, par_name_end_offset-start_offset, ENC_UTF_8|ENC_NA);
value_offset = tvb_skip_wsp(tvb, equals_offset + 1, line_end_offset - (equals_offset + 1));
if (tvb_get_guint8(tvb, value_offset) == '\"') {
/* quoted value */
value_search_offset = value_offset;
do {
value_search_offset++;
queried_offset = tvb_find_guint8 (tvb, value_search_offset, line_end_offset - value_search_offset, '\"');
} while ((queried_offset != -1) && (tvb_get_guint8(tvb, queried_offset - 1) == '\\'));
if (queried_offset == -1) {
/* Closing quote not found, return line end */
current_offset = line_end_offset;
} else {
/* Include closing quotes */
current_offset = queried_offset + 1;
}
} else {
/* unquoted value */
queried_offset = tvb_find_guint8 (tvb, value_offset, line_end_offset - value_offset, ',');
if (queried_offset == -1) {
/* Last parameter, line end */
current_offset = line_end_offset;
} else {
current_offset = queried_offset;
}
}
/* Try to add parameter as a filterable item */
for (auth_parameter = &auth_parameters_hf_array[i];
i < array_length(auth_parameters_hf_array);
i++, auth_parameter++)
{
if (g_ascii_strcasecmp(name, auth_parameter->param_name) == 0)
{
proto_tree_add_item(tree, *(auth_parameter->hf_item), tvb,
value_offset, current_offset - value_offset,
ENC_UTF_8|ENC_NA);
if (global_sip_validate_authorization) {
gint real_value_offset = value_offset;
gint real_value_length = current_offset - value_offset;
if ((tvb_get_guint8(tvb, value_offset) == '\"') && (tvb_get_guint8(tvb, current_offset - 1) == '\"') && (real_value_length > 1)) {
real_value_offset++;
real_value_length -= 2;
}
if (g_ascii_strcasecmp(name, "response") == 0) {
authorization_info->response = tvb_get_string_enc(wmem_packet_scope(), tvb, real_value_offset, real_value_length, ENC_ASCII);
} else if (g_ascii_strcasecmp(name, "nc") == 0) {
authorization_info->nonce_count = tvb_get_string_enc(wmem_packet_scope(), tvb, real_value_offset, real_value_length, ENC_ASCII);
} else if (g_ascii_strcasecmp(name, "username") == 0) {
authorization_info->username = tvb_get_string_enc(wmem_packet_scope(), tvb, real_value_offset, real_value_length, ENC_ASCII);
} else if (g_ascii_strcasecmp(name, "realm") == 0) {
authorization_info->realm = tvb_get_string_enc(wmem_packet_scope(), tvb, real_value_offset, real_value_length, ENC_ASCII);
} else if (g_ascii_strcasecmp(name, "algorithm") == 0) {
authorization_info->algorithm = tvb_get_string_enc(wmem_packet_scope(), tvb, real_value_offset, real_value_length, ENC_ASCII);
} else if (g_ascii_strcasecmp(name, "nonce") == 0) {
authorization_info->nonce = tvb_get_string_enc(wmem_packet_scope(), tvb, real_value_offset, real_value_length, ENC_ASCII);
} else if (g_ascii_strcasecmp(name, "qop") == 0) {
authorization_info->qop = tvb_get_string_enc(wmem_packet_scope(), tvb, real_value_offset, real_value_length, ENC_ASCII);
} else if (g_ascii_strcasecmp(name, "cnonce") == 0) {
authorization_info->cnonce = tvb_get_string_enc(wmem_packet_scope(), tvb, real_value_offset, real_value_length, ENC_ASCII);
} else if (g_ascii_strcasecmp(name, "uri") == 0) {
authorization_info->uri = tvb_get_string_enc(wmem_packet_scope(), tvb, real_value_offset, real_value_length, ENC_ASCII);
}
}
break;
}
}
/* If not matched, just add as text... */
if (i == array_length(auth_parameters_hf_array))
{
proto_tree_add_format_text(tree, tvb, start_offset, current_offset-start_offset);
}
/* Find comma/end of line */
queried_offset = tvb_find_guint8 (tvb, current_offset, line_end_offset - current_offset, ',');
if (queried_offset == -1) {
current_offset = line_end_offset;
} else {
current_offset = queried_offset;
}
return current_offset;
}
/* Dissect the details of a Reason header
* Reason = "Reason" HCOLON reason-value *(COMMA reason-value)
* reason-value = protocol *(SEMI reason-params)
* protocol = "SIP" / "Q.850" / token
* reason-params = protocol-cause / reason-text / reason-extension
* protocol-cause = "cause" EQUAL cause
* cause = 1*DIGIT
* reason-text = "text" EQUAL quoted-string
* reason-extension = generic-param
*/
static void
dissect_sip_reason_header(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, gint start_offset, gint line_end_offset){
gint current_offset, semi_colon_offset, length, end_quote_offset;
const guint8 *param_name = NULL;
guint cause_value;
sip_reason_code_info_t sip_reason_code_info;
/* skip Spaces and Tabs */
start_offset = tvb_skip_wsp(tvb, start_offset, line_end_offset - start_offset);
if (start_offset >= line_end_offset)
{
/* Nothing to parse */
return;
}
current_offset = start_offset;
semi_colon_offset = tvb_find_guint8(tvb, current_offset, line_end_offset-current_offset, ';');
if(semi_colon_offset == -1)
return;
length = semi_colon_offset - current_offset;
proto_tree_add_item_ret_string(tree, hf_sip_reason_protocols, tvb, start_offset, length, ENC_UTF_8|ENC_NA, wmem_packet_scope(), ¶m_name);
current_offset = tvb_find_guint8(tvb, semi_colon_offset, line_end_offset - semi_colon_offset, '=') + 1;
/* Do we have a text parameter too? */
semi_colon_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, ';');
if (semi_colon_offset == -1){
length = line_end_offset - current_offset;
} else {
/* Text parmeter exist, set length accordingly */
length = semi_colon_offset - current_offset;
}
/* Get cause value */
cause_value = (guint)strtoul(tvb_get_string_enc(wmem_packet_scope(), tvb, current_offset, length, ENC_UTF_8 | ENC_NA), NULL, 10);
if (g_ascii_strcasecmp(param_name, "Q.850") == 0){
proto_tree_add_uint(tree, hf_sip_reason_cause_q850, tvb, current_offset, length, cause_value);
sip_reason_code_info.protocol_type_num = SIP_PROTO_Q850;
}
else if (g_ascii_strcasecmp(param_name, "SIP") == 0) {
proto_tree_add_uint(tree, hf_sip_reason_cause_sip, tvb, current_offset, length, cause_value);
sip_reason_code_info.protocol_type_num = SIP_PROTO_SIP;
}
else {
proto_tree_add_uint(tree, hf_sip_reason_cause_other, tvb, current_offset, length, cause_value);
sip_reason_code_info.protocol_type_num = SIP_PROTO_OTHER;
}
if (semi_colon_offset == -1)
/* Nothing to parse */
return;
/* reason-text = "text" EQUAL quoted-string */
current_offset = tvb_find_guint8(tvb, semi_colon_offset, line_end_offset - semi_colon_offset, '"') + 1;
if (current_offset == -1)
/* Nothing to parse */
return;
end_quote_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, '"');
if (end_quote_offset == -1)
/* Nothing to parse */
return;
length = end_quote_offset - current_offset;
proto_tree_add_item(tree, hf_sip_reason_text, tvb, current_offset, length, ENC_UTF_8 | ENC_NA);
if (sip_reason_code_handle) {
tvbuff_t *next_tvb;
sip_reason_code_info.cause_value = cause_value;
next_tvb = tvb_new_subset_length(tvb, current_offset, length);
call_dissector_with_data(sip_reason_code_handle, next_tvb, pinfo, tree, &sip_reason_code_info);
}
}
/* Dissect the details of a security client header
* sec-mechanism = mechanism-name *(SEMI mech-parameters)
* mech-parameters = ( preference / digest-algorithm /
* digest-qop / digest-verify / extension )
* preference = "q" EQUAL qvalue
* qvalue = ( "0" [ "." 0*3DIGIT ] )
* / ( "1" [ "." 0*3("0") ] )
* digest-algorithm = "d-alg" EQUAL token
* digest-qop = "d-qop" EQUAL token
* digest-verify = "d-ver" EQUAL LDQUOT 32LHEX RDQUOT
* extension = generic-param
*
*
*/
static void
dissect_sip_sec_mechanism(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, gint start_offset, gint line_end_offset){
gint current_offset, semi_colon_offset, length, par_name_end_offset, equals_offset;
/* skip Spaces and Tabs */
start_offset = tvb_skip_wsp(tvb, start_offset, line_end_offset - start_offset);
if (start_offset >= line_end_offset)
{
/* Nothing to parse */
return;
}
current_offset = start_offset;
semi_colon_offset = tvb_find_guint8(tvb, current_offset, line_end_offset-current_offset, ';');
if(semi_colon_offset == -1){
semi_colon_offset = line_end_offset;
}
length = semi_colon_offset-current_offset;
proto_tree_add_item(tree, hf_sip_sec_mechanism, tvb,
start_offset, length,
ENC_UTF_8);
current_offset = current_offset + length + 1;
while(current_offset < line_end_offset){
gchar *param_name = NULL, *value = NULL;
guint8 hf_index = 0;
/* skip Spaces and Tabs */
current_offset = tvb_skip_wsp(tvb, current_offset, line_end_offset - current_offset);
semi_colon_offset = tvb_find_guint8(tvb, current_offset, line_end_offset-current_offset, ';');
if(semi_colon_offset == -1){
semi_colon_offset = line_end_offset;
}
length = semi_colon_offset - current_offset;
/* Parse parameter and value */
equals_offset = tvb_find_guint8(tvb, current_offset + 1, length, '=');
if(equals_offset != -1){
/* Has value part */
par_name_end_offset = equals_offset;
/* Extract the parameter name */
param_name = tvb_get_string_enc(wmem_packet_scope(), tvb, current_offset, par_name_end_offset-current_offset, ENC_UTF_8|ENC_NA);
/* Extract the value */
value = tvb_get_string_enc(wmem_packet_scope(), tvb, equals_offset+1, semi_colon_offset-equals_offset+1, ENC_UTF_8|ENC_NA);
} else {
return;
}
while (sec_mechanism_parameters_hf_array[hf_index].param_name) {
/* Protection algorithm to be used */
if (g_ascii_strcasecmp(param_name, sec_mechanism_parameters_hf_array[hf_index].param_name) == 0) {
switch (sec_mechanism_parameters_hf_array[hf_index].para_type) {
case MECH_PARA_STRING:
proto_tree_add_item(tree, *sec_mechanism_parameters_hf_array[hf_index].hf_item, tvb,
equals_offset+1, semi_colon_offset-equals_offset-1,
ENC_UTF_8);
break;
case MECH_PARA_UINT:
if (!value) {
proto_tree_add_expert(tree, pinfo, &ei_sip_sipsec_malformed,
tvb, current_offset, -1);
} else {
guint32 semi_para;
semi_para = (guint32)strtoul(value, NULL, 10);
proto_tree_add_uint(tree, *sec_mechanism_parameters_hf_array[hf_index].hf_item, tvb,
equals_offset+1, semi_colon_offset-equals_offset-1, semi_para);
}
break;
default:
break;
}
break;
}
hf_index++;
}
if (!sec_mechanism_parameters_hf_array[hf_index].param_name) {
proto_tree_add_format_text(tree, tvb, current_offset, length);
}
current_offset = semi_colon_offset+1;
}
}
/* Dissect the details of a Route (and Record-Route) header */
static void dissect_sip_route_header(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, hf_sip_uri_t *sip_route_uri_p, gint start_offset, gint line_end_offset)
{
gint current_offset;
uri_offset_info uri_offsets;
current_offset = start_offset;
/* skip Spaces and Tabs */
current_offset = tvb_skip_wsp(tvb, current_offset, line_end_offset - current_offset);
if (current_offset >= line_end_offset) {
return;
}
while (current_offset < line_end_offset) {
current_offset = tvb_find_guint8(tvb, current_offset, (line_end_offset - 1) - current_offset, ',');
if (current_offset != -1) { /* found any ',' ? */
sip_uri_offset_init(&uri_offsets);
current_offset = dissect_sip_name_addr_or_addr_spec(tvb, pinfo, start_offset, current_offset, &uri_offsets);
if(current_offset == -1)
return;
display_sip_uri(tvb, tree, pinfo, &uri_offsets, sip_route_uri_p);
current_offset++;
start_offset = current_offset + 1;
} else {
/* current_offset = (line_end_offset - 1); */
sip_uri_offset_init(&uri_offsets);
current_offset = dissect_sip_name_addr_or_addr_spec(tvb, pinfo, start_offset, line_end_offset, &uri_offsets);
if(current_offset == -1)
return;
display_sip_uri(tvb, tree, pinfo, &uri_offsets, sip_route_uri_p);
return;
}
current_offset++;
}
return;
}
/* Dissect the details of a Via header
*
* Via = ( "Via" / "v" ) HCOLON via-parm *(COMMA via-parm)
* via-parm = sent-protocol LWS sent-by *( SEMI via-params )
* via-params = via-ttl / via-maddr
* / via-received / via-branch
* / via-extension
* via-ttl = "ttl" EQUAL ttl
* via-maddr = "maddr" EQUAL host
* via-received = "received" EQUAL (IPv4address / IPv6address)
* via-branch = "branch" EQUAL token
* via-extension = generic-param
* sent-protocol = protocol-name SLASH protocol-version
* SLASH transport
* protocol-name = "SIP" / token
* protocol-version = token
* transport = "UDP" / "TCP" / "TLS" / "SCTP"
* / other-transport
* sent-by = host [ COLON port ]
* ttl = 1*3DIGIT ; 0 to 255
*
*/
static void dissect_sip_via_header(tvbuff_t *tvb, proto_tree *tree, gint start_offset, gint line_end_offset, packet_info *pinfo)
{
gint current_offset;
gint address_start_offset;
gint semicolon_offset;
gboolean colon_seen;
gboolean ipv6_reference;
gboolean ipv6_address;
guchar c;
gchar *param_name = NULL;
current_offset = start_offset;
while (1)
{
/* Reset flags and counters */
semicolon_offset = 0;
ipv6_reference = FALSE;
ipv6_address = FALSE;
colon_seen = FALSE;
/* skip Spaces and Tabs */
current_offset = tvb_skip_wsp(tvb, current_offset, line_end_offset - current_offset);
if (current_offset >= line_end_offset)
{
/* Nothing more to parse */
return;
}
/* Now look for the end of the SIP/2.0/transport parameter.
* There may be spaces between the slashes
* sent-protocol = protocol-name SLASH protocol-version
* SLASH transport
*/
current_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, '/');
if (current_offset != -1)
{
current_offset++;
current_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, '/');
}
if (current_offset != -1)
{
current_offset++;
/* skip Spaces and Tabs */
current_offset = tvb_skip_wsp(tvb, current_offset, line_end_offset - current_offset);
} else
current_offset = line_end_offset;
/* We should now be at the start of the first transport name (or at the end of the line) */
/*
* transport = "UDP" / "TCP" / "TLS" / "SCTP"
* / other-transport
*/
while (current_offset < line_end_offset)
{
int transport_start_offset = current_offset;
current_offset = tvb_ws_mempbrk_pattern_guint8(tvb, current_offset, line_end_offset - current_offset, &pbrk_tab_sp_fslash, &c);
if (current_offset != -1){
proto_tree_add_item(tree, hf_sip_via_transport, tvb, transport_start_offset,
current_offset - transport_start_offset, ENC_UTF_8);
/* Check if we have more transport parameters */
if(c=='/'){
current_offset++;
continue;
}
current_offset = tvb_skip_wsp(tvb, current_offset, line_end_offset - current_offset);
c = tvb_get_guint8(tvb, current_offset);
if(c=='/'){
current_offset++;
continue;
}
break;
}else{
current_offset = line_end_offset;
}
}
/* skip Spaces and Tabs */
current_offset = tvb_skip_wsp(tvb, current_offset, line_end_offset - current_offset);
/* Now read the address part */
address_start_offset = current_offset;
while (current_offset < line_end_offset)
{
current_offset = tvb_ws_mempbrk_pattern_guint8(tvb, current_offset, line_end_offset - current_offset, &pbrk_addr_end, &c);
if (current_offset == -1)
{
current_offset = line_end_offset;
break;
}
if (c == '[') {
ipv6_reference = TRUE;
ipv6_address = TRUE;
}
else if (c == ']')
{
ipv6_reference = FALSE;
}
if (colon_seen || (c == ' ') || (c == '\t') || ((c == ':') && (ipv6_reference == FALSE)) || (c == ';'))
{
break;
}
current_offset++;
}
/* Add address to tree */
if (ipv6_address == TRUE) {
proto_tree_add_item(tree, hf_sip_via_sent_by_address, tvb, address_start_offset + 1,
current_offset - address_start_offset - 2, ENC_UTF_8);
} else {
proto_tree_add_item(tree, hf_sip_via_sent_by_address, tvb, address_start_offset,
current_offset - address_start_offset, ENC_UTF_8);
}
/* Transport port number may follow ([space] : [space])*/
current_offset = tvb_skip_wsp(tvb, current_offset, line_end_offset - current_offset);
c = tvb_get_guint8(tvb, current_offset);
if (c == ':')
{
/* Port number will follow any space after : */
gint port_offset;
current_offset++;
/* Skip optional space after colon */
current_offset = tvb_skip_wsp(tvb, current_offset, line_end_offset - current_offset);
port_offset = current_offset;
/* Find digits of port number */
while (current_offset < line_end_offset)
{
c = tvb_get_guint8(tvb, current_offset);
if (!g_ascii_isdigit(c))
{
if (current_offset > port_offset)
{
/* Add address port number to tree */
guint16 port;
gboolean port_valid;
proto_item* pi;
port_valid = ws_strtou16(tvb_get_string_enc(wmem_packet_scope(), tvb, port_offset,
current_offset - port_offset, ENC_UTF_8|ENC_NA), NULL, &port);
pi = proto_tree_add_uint(tree, hf_sip_via_sent_by_port, tvb, port_offset,
current_offset - port_offset, port);
if (!port_valid)
expert_add_info(pinfo, pi, &ei_sip_via_sent_by_port);
}
else
{
/* Shouldn't see a colon without a port number given */
return;
}
break;
}
current_offset++;
}
}
/* skip Spaces and Tabs */
current_offset = tvb_skip_wsp(tvb, current_offset, line_end_offset - current_offset);
/* Dissect any parameters found */
while (current_offset < line_end_offset)
{
gboolean equals_found = FALSE;
gboolean found_end_of_parameters = FALSE;
gint parameter_name_end = 0;
header_parameter_t *via_parameter;
guint i = 0;
/* Look for the semicolon that signals the start of a parameter */
while (current_offset < line_end_offset)
{
c = tvb_get_guint8(tvb, current_offset);
if (c == ';')
{
semicolon_offset = current_offset;
current_offset++;
break;
}
else
if ((c != ' ') && (c != '\t'))
{
found_end_of_parameters = TRUE;
break;
}
current_offset++;
}
if (found_end_of_parameters)
{
break;
}
if (current_offset == line_end_offset)
{
return;
}
/* Look for end of parameter name */
while (current_offset < line_end_offset)
{
c = tvb_get_guint8(tvb, current_offset);
if (!g_ascii_isalpha(c) && (c != '-'))
{
break;
}
current_offset++;
}
/* Not all params have an = */
if (c == '=')
{
equals_found = TRUE;
}
parameter_name_end = current_offset;
/* Read until end of parameter value */
current_offset = tvb_ws_mempbrk_pattern_guint8(tvb, current_offset, line_end_offset - current_offset, &pbrk_via_param_end, NULL);
if (current_offset == -1)
current_offset = line_end_offset;
/* Note parameter name */
param_name = tvb_get_string_enc(wmem_packet_scope(), tvb, semicolon_offset+1,
parameter_name_end - semicolon_offset - 1, ENC_UTF_8|ENC_NA);
/* Try to add parameter as a filterable item */
for (via_parameter = &via_parameters_hf_array[i];
i < array_length(via_parameters_hf_array);
i++, via_parameter++)
{
if (g_ascii_strcasecmp(param_name, via_parameter->param_name) == 0)
{
if (equals_found)
{
proto_item* via_parameter_item;
via_parameter_item = proto_tree_add_item(tree, *(via_parameter->hf_item), tvb,
parameter_name_end + 1, current_offset - parameter_name_end - 1,
ENC_UTF_8 | ENC_NA);
if (sip_via_branch_handle && g_ascii_strcasecmp(param_name, "branch") == 0)
{
tvbuff_t *next_tvb;
next_tvb = tvb_new_subset_length_caplen(tvb, parameter_name_end + 1, current_offset - parameter_name_end - 1, current_offset - parameter_name_end - 1);
call_dissector(sip_via_branch_handle, next_tvb, pinfo, tree);
}
else if (g_ascii_strcasecmp(param_name, "oc") == 0) {
proto_item *ti;
char *value = tvb_get_string_enc(wmem_packet_scope(), tvb, parameter_name_end + 1,
current_offset - parameter_name_end - 1, ENC_UTF_8 | ENC_NA);
ti = proto_tree_add_uint(tree, hf_sip_via_oc_val, tvb,
parameter_name_end + 1, current_offset - parameter_name_end - 1,
(guint32)strtoul(value, NULL, 10));
proto_item_set_generated(ti);
}
else if (g_ascii_strcasecmp(param_name, "oc-seq") == 0) {
proto_item *ti;
nstime_t ts;
int dec_p_off = tvb_find_guint8(tvb, parameter_name_end + 1, - 1, '.');
char *value;
if(dec_p_off > 0){
value = tvb_get_string_enc(wmem_packet_scope(), tvb,
parameter_name_end + 1, dec_p_off - parameter_name_end, ENC_UTF_8 | ENC_NA);
ts.secs = (time_t)strtoul(value, NULL, 10);
value = tvb_get_string_enc(wmem_packet_scope(), tvb,
dec_p_off + 1, current_offset - parameter_name_end - 1, ENC_UTF_8 | ENC_NA);
ts.nsecs = (guint32)strtoul(value, NULL, 10) * 1000;
ti = proto_tree_add_time(tree, hf_sip_oc_seq_timestamp, tvb,
parameter_name_end + 1, current_offset - parameter_name_end - 1, &ts);
proto_item_set_generated(ti);
}
} else if (g_ascii_strcasecmp(param_name, "be-route") == 0) {
tvbuff_t* next_tvb;
next_tvb = tvb_new_subset_length_caplen(tvb, parameter_name_end + 1, current_offset - parameter_name_end - 1, current_offset - parameter_name_end - 1);
call_dissector(sip_via_be_route_handle, next_tvb, pinfo, proto_item_add_subtree(via_parameter_item, ett_sip_via_be_route));
}
}
else
{
proto_tree_add_item(tree, *(via_parameter->hf_item), tvb,
semicolon_offset+1, current_offset-semicolon_offset-1,
ENC_UTF_8|ENC_NA);
}
break;
}
}
/* If not matched, just add as text... */
if (i == array_length(via_parameters_hf_array))
{
proto_tree_add_format_text(tree, tvb, semicolon_offset+1, current_offset-semicolon_offset-1);
}
/* skip Spaces and Tabs */
current_offset = tvb_skip_wsp(tvb, current_offset, line_end_offset - current_offset);
/* There may be a comma, followed by more Via entries... */
if (current_offset < line_end_offset)
{
c = tvb_get_guint8(tvb, current_offset);
if (c == ',')
{
/* Skip it and get out of parameter loop */
current_offset++;
break;
}
}
}
}
}
/* Dissect the details of a Session-ID header
*
* Session-ID = "Session-ID" HCOLON sess-id
* *( SEMI generic-param )
* sess-id = 32(DIGIT / %x61-66) ; 32 chars of [0-9a-f]
*/
static void dissect_sip_session_id_header(tvbuff_t *tvb, proto_tree *tree, gint start_offset, gint line_end_offset, packet_info *pinfo)
{
gint current_offset, semi_colon_offset, equals_offset, length, logme_end_offset;
GByteArray *bytes;
proto_item *pi;
current_offset = start_offset;
semi_colon_offset = tvb_find_guint8(tvb, current_offset, line_end_offset-current_offset, ';');
if(semi_colon_offset == -1){
semi_colon_offset = line_end_offset;
}
length = semi_colon_offset-current_offset;
bytes = g_byte_array_sized_new(16);
if (length != 0) {
pi = proto_tree_add_bytes_item(tree, hf_sip_session_id_sess_id, tvb,
start_offset, length, ENC_UTF_8|ENC_STR_HEX|ENC_SEP_NONE,
bytes, NULL, NULL);
} else {
pi = proto_tree_add_item(tree, hf_sip_session_id_sess_id, tvb,
start_offset, length, ENC_UTF_8 | ENC_STR_HEX | ENC_SEP_NONE);
expert_add_info(pinfo, pi, &ei_sip_session_id_sess_id);
}
current_offset = current_offset + length + 1;
/* skip Spaces and Tabs */
current_offset = tvb_skip_wsp(tvb, current_offset, line_end_offset - current_offset);
if (current_offset < line_end_offset) {
/* Parse parameter and value */
equals_offset = tvb_find_guint8(tvb, current_offset + 1, length, '=');
if (equals_offset != -1) {
/* Extract the parameter name */
GByteArray *uuid = g_byte_array_sized_new(16);
guint8 *param_name = tvb_get_string_enc(wmem_packet_scope(), tvb, current_offset,
tvb_skip_wsp_return(tvb, equals_offset - 1) - current_offset,
ENC_UTF_8|ENC_NA);
if ((bytes->len == 16) && (g_ascii_strcasecmp(param_name, "remote") == 0) &&
tvb_get_string_bytes(tvb, equals_offset + 1, line_end_offset - equals_offset - 1,
ENC_UTF_8|ENC_STR_HEX|ENC_SEP_NONE, uuid, NULL) &&
(uuid->len == 16)) {
/* Decode header as draft-ietf-insipid-session-id
*
* session-id = "Session-ID" HCOLON session-id-value
* session-id-value = local-uuid *(SEMI sess-id-param)
* local-uuid = sess-uuid / null
* remote-uuid = sess-uuid / null
* sess-uuid = 32(DIGIT / %x61-66) ;32 chars of [0-9a-f]
* sess-id-param = remote-param / generic-param
* remote-param = "remote" EQUAL remote-uuid
* null = 32("0")
*/
e_guid_t guid;
proto_item_set_hidden(pi);
guid.data1 = (bytes->data[0] << 24) | (bytes->data[1] << 16) |
(bytes->data[2] << 8) | bytes->data[3];
guid.data2 = (bytes->data[4] << 8) | bytes->data[5];
guid.data3 = (bytes->data[6] << 8) | bytes->data[7];
memcpy(guid.data4, &bytes->data[8], 8);
proto_tree_add_guid(tree, hf_sip_session_id_local_uuid, tvb,
start_offset, semi_colon_offset - start_offset, &guid);
guid.data1 = (uuid->data[0] << 24) | (uuid->data[1] << 16) |
(uuid->data[2] << 8) | uuid->data[3];
guid.data2 = (uuid->data[4] << 8) | uuid->data[5];
guid.data3 = (uuid->data[6] << 8) | uuid->data[7];
memcpy(guid.data4, &uuid->data[8], 8);
proto_tree_add_guid(tree, hf_sip_session_id_remote_uuid, tvb,
equals_offset + 1, line_end_offset - equals_offset - 1, &guid);
/* Decode logme parameter as per https://tools.ietf.org/html/rfc8497
*
* sess-id-param =/ logme-param
* logme-param = "logme"
*/
semi_colon_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, ';');
while(semi_colon_offset != -1){
current_offset = semi_colon_offset + 1;
if(current_offset != line_end_offset){
logme_end_offset = current_offset + 5;
current_offset = tvb_skip_wsp_return(tvb,semi_colon_offset);
/* Extract logme parameter name */
gchar *name = tvb_get_string_enc(wmem_packet_scope(), tvb, current_offset,logme_end_offset - current_offset, ENC_UTF_8|ENC_NA);
if(g_ascii_strcasecmp(name, "logme") == 0){
proto_tree_add_boolean(tree, hf_sip_session_id_logme, tvb, current_offset, logme_end_offset - current_offset, 1);
} else if(current_offset != line_end_offset){
proto_tree_add_item(tree, hf_sip_session_id_param, tvb, current_offset,line_end_offset - current_offset, ENC_UTF_8);
}
}
semi_colon_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, ';');
}
} else {
/* Display generic parameter */
proto_tree_add_item(tree, hf_sip_session_id_param, tvb, current_offset,
line_end_offset - current_offset, ENC_UTF_8);
}
g_byte_array_free(uuid, TRUE);
} else {
/* Display generic parameter */
proto_tree_add_item(tree, hf_sip_session_id_param, tvb, current_offset,
line_end_offset - current_offset, ENC_UTF_8);
}
}
g_byte_array_free(bytes, TRUE);
}
/* Dissect the headers for P-Access-Network-Info Headers
*
* Spec found in 3GPP 24.229 7.2A.4
* P-Access-Network-Info = "P-Access-Network-Info" HCOLON
* access-net-spec *(COMMA access-net-spec)
* access-net-spec = (access-type / access-class) *(SEMI access-info)
* access-type = "IEEE-802.11" / "IEEE-802.11a" / "IEEE-802.11b" / "IEEE-802.11g" / "IEEE-802.11n" / "3GPP-GERAN" /
* "3GPP-UTRAN-FDD" / "3GPP-UTRAN-TDD" / "3GPP-E-UTRAN-FDD" / "3GPP-E-UTRAN-TDD" / "ADSL" / "ADSL2" /
* "ADSL2+" / "RADSL" / "SDSL" / "HDSL" / "HDSL2" / "G.SHDSL" / "VDSL" / "IDSL" / "3GPP2-1X" /
* "3GPP2-1X-Femto" / "3GPP2-1X-HRPD" / "3GPP2-UMB" / "DOCSIS" / "IEEE-802.3" / "IEEE-802.3a" /
* "IEEE-802.3e" / "IEEE-802.3i" / "IEEE-802.3j" / "IEEE-802.3u" / "IEEE-802.3ab"/ "IEEE-802.3ae" /
* "IEEE-802.3ak" / "IEEE-802.3aq" / "IEEE-802.3an" / "IEEE-802.3y" / "IEEE-802.3z" / "GPON" /
"XGPON1" / "GSTN"/ token
* access-class = "3GPP-GERAN" / "3GPP-UTRAN" / "3GPP-E-UTRAN" / "3GPP-WLAN" / "3GPP-GAN" / "3GPP-HSPA" / token
* np = "network-provided"
* access-info = cgi-3gpp / utran-cell-id-3gpp / dsl-location / i-wlan-node-id / ci-3gpp2 / ci-3gpp2-femto /
eth-location / fiber-location / np / gstn-location / extension-access-info
* extension-access-info = gen-value
* cgi-3gpp = "cgi-3gpp" EQUAL (token / quoted-string)
* utran-cell-id-3gpp = "utran-cell-id-3gpp" EQUAL (token / quoted-string)
* i-wlan-node-id = "i-wlan-node-id" EQUAL (token / quoted-string)
* dsl-location = "dsl-location" EQUAL (token / quoted-string)
* eth-location = "eth-location" EQUAL (token / quoted-string)
* fiber-location = "fiber-location" EQUAL (token / quoted-string)
* ci-3gpp2 = "ci-3gpp2" EQUAL (token / quoted-string)
* ci-3gpp2-femto = "ci-3gpp2-femto" EQUAL (token / quoted-string)
* gstn-location = "gstn-location" EQUAL (token / quoted-string)
*
*/
void dissect_sip_p_access_network_info_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint start_offset, gint line_end_offset)
{
gint current_offset, semi_colon_offset, length, par_name_end_offset, equals_offset;
/* skip Spaces and Tabs */
start_offset = tvb_skip_wsp(tvb, start_offset, line_end_offset - start_offset);
if (start_offset >= line_end_offset)
{
/* Nothing to parse */
return;
}
/* Get the Access Type / Access Class*/
current_offset = start_offset;
semi_colon_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, ';');
if (semi_colon_offset == -1)
return;
length = semi_colon_offset - current_offset;
proto_tree_add_item(tree, hf_sip_p_acc_net_i_acc_type, tvb, start_offset, length, ENC_UTF_8 | ENC_NA);
current_offset = current_offset + length + 1;
while (current_offset < line_end_offset){
gchar *param_name = NULL;
/* skip Spaces and Tabs */
current_offset = tvb_skip_wsp(tvb, current_offset, line_end_offset - current_offset);
semi_colon_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, ';');
if (semi_colon_offset == -1){
semi_colon_offset = line_end_offset;
}
length = semi_colon_offset - current_offset;
/* Parse parameter and value */
equals_offset = tvb_find_guint8(tvb, current_offset + 1, length, '=');
if (equals_offset != -1){
/* Has value part */
par_name_end_offset = equals_offset;
/* Extract the parameter name */
param_name = tvb_get_string_enc(wmem_packet_scope(), tvb, current_offset, par_name_end_offset - current_offset, ENC_UTF_8 | ENC_NA);
/* Access-Info fields */
if ((param_name != NULL)&&(g_ascii_strcasecmp(param_name, "utran-cell-id-3gpp") == 0)) {
proto_tree_add_item(tree, hf_sip_p_acc_net_i_ucid_3gpp, tvb,
equals_offset + 1, semi_colon_offset - equals_offset - 1, ENC_UTF_8 | ENC_NA);
dissect_e212_mcc_mnc_in_utf8_address(tvb, pinfo, tree, equals_offset + 1);
}
else {
proto_tree_add_format_text(tree, tvb, current_offset, length);
}
}
else {
proto_tree_add_format_text(tree, tvb, current_offset, length);
}
current_offset = semi_colon_offset + 1;
}
}
/*
The syntax for the P-Charging-Vector header field is described as
follows:
P-Charging-Vector = "P-Charging-Vector" HCOLON icid-value
*(SEMI charge-params)
charge-params = icid-gen-addr / orig-ioi / term-ioi /
transit-ioi / related-icid /
related-icid-gen-addr / generic-param
icid-value = "icid-value" EQUAL gen-value
icid-gen-addr = "icid-generated-at" EQUAL host
orig-ioi = "orig-ioi" EQUAL gen-value
term-ioi = "term-ioi" EQUAL gen-value
transit-ioi = "transit-ioi" EQUAL transit-ioi-list
transit-ioi-list = DQUOTE transit-ioi-param
*(COMMA transit-ioi-param) DQUOTE
transit-ioi-param = transit-ioi-indexed-value /
transit-ioi-void-value
transit-ioi-indexed-value = transit-ioi-name "."
transit-ioi-index
transit-ioi-name = ALPHA *(ALPHA / DIGIT)
transit-ioi-index = 1*DIGIT
transit-ioi-void-value = "void"
related-icid = "related-icid" EQUAL gen-value
related-icid-gen-addr = "related-icid-generated-at" EQUAL host
*/
static void
dissect_sip_p_charging_vector_header(tvbuff_t *tvb, proto_tree *tree, gint start_offset, gint line_end_offset)
{
gint current_offset, semi_colon_offset, length, equals_offset;
/* skip Spaces and Tabs */
start_offset = tvb_skip_wsp(tvb, start_offset, line_end_offset - start_offset);
if (start_offset >= line_end_offset)
{
/* Nothing to parse */
return;
}
/* icid-value = "icid-value" EQUAL gen-value */
current_offset = start_offset;
semi_colon_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, ';');
if (semi_colon_offset == -1) {
/* No parameters, is that allowed?*/
semi_colon_offset = line_end_offset;
}
length = semi_colon_offset - current_offset;
/* Parse parameter and value */
equals_offset = tvb_find_guint8(tvb, current_offset + 1, length, '=');
if (equals_offset == -1) {
/* Does not conform to ABNF */
return;
}
/* Get the icid-value */
proto_tree_add_item(tree, hf_sip_icid_value, tvb,
equals_offset + 1, semi_colon_offset - equals_offset - 1, ENC_UTF_8 | ENC_NA);
current_offset = semi_colon_offset + 1;
/* Add the rest of the parameters to the tree */
while (current_offset < line_end_offset) {
gchar *param_name = NULL;
gint par_name_end_offset;
/* skip Spaces and Tabs */
current_offset = tvb_skip_wsp(tvb, current_offset, line_end_offset - current_offset);
semi_colon_offset = tvb_find_guint8(tvb, current_offset, line_end_offset - current_offset, ';');
if (semi_colon_offset == -1) {
semi_colon_offset = line_end_offset;
}
length = semi_colon_offset - current_offset;
/* Parse parameter and value */
equals_offset = tvb_find_guint8(tvb, current_offset + 1, length, '=');
if (equals_offset != -1) {
/* Has value part */
par_name_end_offset = equals_offset;
/* Extract the parameter name */
param_name = tvb_get_string_enc(wmem_packet_scope(), tvb, current_offset, par_name_end_offset - current_offset, ENC_UTF_8 | ENC_NA);
/* charge-params */
if ((param_name != NULL) && (g_ascii_strcasecmp(param_name, "icid-gen-addr") == 0)) {
proto_tree_add_item(tree, hf_sip_icid_gen_addr, tvb,
equals_offset + 1, semi_colon_offset - equals_offset - 1, ENC_UTF_8 | ENC_NA);
}
else {
proto_tree_add_format_text(tree, tvb, current_offset, length);
}
}
else {
proto_tree_add_format_text(tree, tvb, current_offset, length);
}
current_offset = semi_colon_offset + 1;
}
}
/*
https://tools.ietf.org/html/rfc6809
The ABNF for the Feature-Caps header fields is:
Feature-Caps = "Feature-Caps" HCOLON fc-value
*(COMMA fc-value)
fc-value = "*" *(SEMI feature-cap)
The ABNF for the feature-capability indicator is:
feature-cap = "+" fcap-name [EQUAL LDQUOT (fcap-value-list
/ fcap-string-value ) RDQUOT]
fcap-name = ftag-name
fcap-value-list = tag-value-list
fcap-string-value = string-value
;; ftag-name, tag-value-list, string-value defined in RFC 3840
NOTE: In comparison with media feature tags, the "+" sign in front of
the feature-capability indicator name is mandatory.
*/
static void
dissect_sip_p_feature_caps(tvbuff_t *tvb, proto_tree *tree, gint start_offset, gint line_end_offset)
{
gint current_offset, next_offset, length;
guint16 semi_plus = 0x3b2b;
/* skip Spaces and Tabs */
next_offset = tvb_skip_wsp(tvb, start_offset, line_end_offset - start_offset);
if (next_offset >= line_end_offset) {
/* Nothing to parse */
return;
}
while (next_offset < line_end_offset) {
/* Find the end of feature cap or start of feature cap parameter, ";+" should indicate the start of a new feature-cap */
current_offset = next_offset;
next_offset = tvb_find_guint16(tvb, current_offset, line_end_offset - current_offset, semi_plus);
if (next_offset == -1) {
length = line_end_offset - current_offset;
next_offset = line_end_offset;
}
else {
length = next_offset - current_offset;
next_offset += 2;
}
proto_tree_add_item(tree, hf_sip_feature_cap, tvb, current_offset, length, ENC_UTF_8 | ENC_NA);
}
}
/* Code to actually dissect the packets */
static int
dissect_sip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
guint8 octet;
int len;
int remaining_length;
octet = tvb_get_guint8(tvb,0);
if ((octet & 0xf8) == 0xf8){
call_dissector(sigcomp_handle, tvb, pinfo, tree);
return tvb_reported_length(tvb);
}
remaining_length = tvb_reported_length(tvb);
len = dissect_sip_common(tvb, 0, remaining_length, pinfo, tree, FALSE, FALSE);
if (len < 0)
return 0; /* not SIP */
else
return len;
}
static int
dissect_sip_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
guint8 octet;
int offset = 0, linelen;
int len;
int remaining_length;
octet = tvb_get_guint8(tvb,0);
if ((octet & 0xf8) == 0xf8){
call_dissector(sigcomp_handle, tvb, pinfo, tree);
return tvb_reported_length(tvb);
}
remaining_length = tvb_reported_length(tvb);
/* If we have exactly one non printable byte of payload, this is
* probably just a keep alive at the beginning of a capture. Better
* to treat it as such than to mark it and everything up to the next
* line end as Continuation Data.
*/
if (remaining_length == 1 && !g_ascii_isprint(octet)) {
return 0;
}
/* Check if we have enough data or if we need another segment, as a safty measure set a length limit*/
if (remaining_length < 1500){
linelen = tvb_find_line_end(tvb, offset, remaining_length, NULL, TRUE);
if (linelen == -1){
pinfo->desegment_offset = offset;
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
return -1;
}
}
len = dissect_sip_common(tvb, offset, remaining_length, pinfo, tree, TRUE, TRUE);
if (len <= 0)
return len;
offset += len;
remaining_length = remaining_length - len;
/*
* This is a bit of a cludge as the TCP dissector does not call the dissectors again if not all
* the data in the segment was dissected and we do not know if we need another segment or not.
* so DESEGMENT_ONE_MORE_SEGMENT can't be used in all cases.
*
*/
while (remaining_length > 0) {
/* Check if we have enough data or if we need another segment, as a safty measure set a length limit*/
if (remaining_length < 1500){
linelen = tvb_find_line_end(tvb, offset, remaining_length, NULL, TRUE);
if (linelen == -1){
pinfo->desegment_offset = offset;
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
return -1;
}
}
len = dissect_sip_common(tvb, offset, remaining_length, pinfo, tree, TRUE, TRUE);
if (len <= 0)
return len;
offset += len;
remaining_length = remaining_length - len;
}
return offset;
}
static gboolean
dissect_sip_tcp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
int offset = 0;
int len;
gboolean first = TRUE;
int remaining_length;
remaining_length = tvb_captured_length(tvb);
while (remaining_length > 0) {
len = dissect_sip_common(tvb, offset, remaining_length, pinfo, tree, !first, TRUE);
if (len == -2) {
if (first) {
/*
* If the first packet doesn't start with
* a valid SIP request or response, don't
* treat this as SIP.
*/
return FALSE;
}
break;
}
if (len == -1)
break; /* need more data */
offset += len;
remaining_length = remaining_length - len;
first = FALSE;
}
return TRUE;
}
static gboolean
dissect_sip_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
int remaining_length = tvb_captured_length(tvb);
return dissect_sip_common(tvb, 0, remaining_length, pinfo, tree, FALSE, FALSE) > 0;
}
static int
dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info *pinfo, proto_tree *tree,
gboolean dissect_other_as_continuation, gboolean use_reassembly)
{
int orig_offset, body_offset;
gint next_offset, linelen;
int content_length, datalen, reported_datalen;
line_type_t line_type;
tvbuff_t *next_tvb;
gboolean is_known_request;
int found_match = 0;
const char *descr;
guint token_1_len = 0;
guint current_method_idx = SIP_METHOD_INVALID;
proto_item *ts, *ti_a = NULL, *th = NULL;
proto_tree *sip_tree, *reqresp_tree = NULL, *hdr_tree = NULL,
*message_body_tree = NULL, *cseq_tree = NULL,
*via_tree = NULL, *reason_tree = NULL, *rack_tree = NULL,
*route_tree = NULL, *security_client_tree = NULL, *session_id_tree = NULL,
*p_access_net_info_tree = NULL;
guchar contacts = 0, contact_is_star = 0, expires_is_0 = 0, contacts_expires_0 = 0, contacts_expires_unknown = 0;
guint32 cseq_number = 0;
guchar cseq_number_set = 0;
const char *cseq_method = "";
char *call_id = NULL;
gchar *media_type_str_lower_case = NULL;
media_content_info_t content_info = { MEDIA_CONTAINER_SIP_DATA, NULL, NULL, NULL };
char *content_encoding_parameter_str = NULL;
guint resend_for_packet = 0;
guint request_for_response = 0;
guint32 response_time = 0;
int strlen_to_copy;
heur_dtbl_entry_t *hdtbl_entry;
/*
* If this should be a request of response, do this quick check to see if
* it begins with a string...
* Otherwise, SIP heuristics are expensive...
*
*/
if (!dissect_other_as_continuation &&
((remaining_length < 1) || !g_ascii_isprint(tvb_get_guint8(tvb, offset))))
{
return -2;
}
/*
* Note that "tvb_find_line_end()" will return a value that
* is not longer than what's in the buffer, so the
* "tvb_get_ptr()" calls below won't throw exceptions.
*
* Note that "tvb_strneql()" doesn't throw exceptions, so
* "sip_parse_line()" won't throw an exception.
*/
orig_offset = offset;
linelen = tvb_find_line_end(tvb, offset, remaining_length, &next_offset, FALSE);
if(linelen==0){
return -2;
}
if (tvb_strnlen(tvb, offset, linelen) > -1)
{
/*
* There's a NULL in the line,
* this may be SIP within another protocol.
* This heuristic still needs to improve.
*/
return -2;
}
line_type = sip_parse_line(tvb, offset, linelen, &token_1_len);
if (line_type == OTHER_LINE) {
/*
* This is neither a SIP request nor response.
*/
if (!dissect_other_as_continuation) {
/*
* We were asked to reject this.
*/
return -2;
}
/*
* Just dissect it as a continuation.
*/
} else if ((use_reassembly)&&( pinfo->ptype == PT_TCP)) {
/*
* Yes, it's a request or response.
* Do header desegmentation if we've been told to,
* and do body desegmentation if we've been told to and
* we find a Content-Length header.
*
* RFC 6594, Section 20.14. requires Content-Length for TCP.
*/
if (!req_resp_hdrs_do_reassembly(tvb, offset, pinfo,
sip_desegment_headers, sip_desegment_body, FALSE, NULL,
NULL, NULL)) {
/*
* More data needed for desegmentation.
*/
return -1;
}
}
/* Initialise stat info for passing to tap
* Note: this isn't _only_ for taps - internal code here uses it too
* also store stat info in proto_data for subdissectors
*/
stat_info = wmem_new0(pinfo->pool, sip_info_value_t);
p_add_proto_data(pinfo->pool, pinfo, proto_sip, pinfo->curr_layer_num, stat_info);
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SIP");
if (!pinfo->flags.in_error_pkt && have_tap_listener(exported_pdu_tap)) {
wmem_list_frame_t *cur;
guint proto_id;
const gchar *proto_name;
void *tmp;
/* For SIP messages with other sip messages embeded in the body, don't export those individually.
* E.g. if we are called from the mime_multipart dissector don't export the message.
*/
cur = wmem_list_frame_prev(wmem_list_tail(pinfo->layers));
tmp = wmem_list_frame_data(cur);
proto_id = GPOINTER_TO_UINT(tmp);
proto_name = proto_get_protocol_filter_name(proto_id);
if (strcmp(proto_name, "mime_multipart") != 0) {
export_sip_pdu(pinfo, tvb);
}
}
DPRINT2(("------------------------------ dissect_sip_common ------------------------------"));
switch (line_type) {
case REQUEST_LINE:
is_known_request = sip_is_known_request(tvb, offset, token_1_len, ¤t_method_idx);
descr = is_known_request ? "Request" : "Unknown request";
col_add_lstr(pinfo->cinfo, COL_INFO,
descr, ": ",
tvb_format_text(pinfo->pool, tvb, offset, linelen - SIP2_HDR_LEN - 1),
COL_ADD_LSTR_TERMINATOR);
DPRINT(("got %s: %s", descr,
tvb_format_text(pinfo->pool, tvb, offset, linelen - SIP2_HDR_LEN - 1)));
break;
case STATUS_LINE:
descr = "Status";
col_add_lstr(pinfo->cinfo, COL_INFO,
"Status: ",
tvb_format_text(pinfo->pool, tvb, offset + SIP2_HDR_LEN + 1, linelen - SIP2_HDR_LEN - 1),
COL_ADD_LSTR_TERMINATOR);
stat_info->reason_phrase = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + SIP2_HDR_LEN + 5,
linelen - (SIP2_HDR_LEN + 5),ENC_UTF_8|ENC_NA);
DPRINT(("got Response: %s",
tvb_format_text(pinfo->pool, tvb, offset + SIP2_HDR_LEN + 1, linelen - SIP2_HDR_LEN - 1)));
break;
case OTHER_LINE:
default: /* Squelch compiler complaints */
descr = "Continuation";
col_set_str(pinfo->cinfo, COL_INFO, "Continuation");
DPRINT(("got continuation"));
break;
}
ts = proto_tree_add_item(tree, proto_sip, tvb, offset, -1, ENC_NA);
sip_tree = proto_item_add_subtree(ts, ett_sip);
switch (line_type) {
case REQUEST_LINE:
if (sip_tree) {
ti_a = proto_tree_add_item(sip_tree, hf_Request_Line, tvb,
offset, linelen, ENC_UTF_8);
reqresp_tree = proto_item_add_subtree(ti_a, ett_sip_reqresp);
}
dfilter_sip_request_line(tvb, reqresp_tree, pinfo, offset, token_1_len, linelen);
break;
case STATUS_LINE:
if (sip_tree) {
ti_a = proto_tree_add_item(sip_tree, hf_sip_Status_Line, tvb,
offset, linelen, ENC_UTF_8);
reqresp_tree = proto_item_add_subtree(ti_a, ett_sip_reqresp);
}
dfilter_sip_status_line(tvb, reqresp_tree, pinfo, linelen, offset);
break;
case OTHER_LINE:
if (sip_tree) {
reqresp_tree = proto_tree_add_subtree_format(sip_tree, tvb, offset, next_offset,
ett_sip_reqresp, NULL, "%s line: %s", descr,
tvb_format_text(pinfo->pool, tvb, offset, linelen));
/* XXX: Is adding to 'reqresp_tree as intended ? Changed from original 'sip_tree' */
proto_tree_add_item(reqresp_tree, hf_sip_continuation, tvb, offset, -1, ENC_NA);
}
return remaining_length;
}
remaining_length = remaining_length - (next_offset - offset);
offset = next_offset;
body_offset = offset;
/*
* Find the blank line separating the headers from the message body.
* Do this now so we can add the msg_hdr FT_STRING item with the correct
* length.
*/
content_length = -1;
while (remaining_length > 0) {
gint line_end_offset;
guchar c;
linelen = tvb_find_line_end(tvb, body_offset, -1, &next_offset, FALSE);
if (linelen == 0) {
/*
* This is a blank line separating the
* message header from the message body.
*/
body_offset = next_offset;
break;
}
line_end_offset = body_offset + linelen;
if(tvb_reported_length_remaining(tvb, next_offset) > 0){
while (tvb_offset_exists(tvb, next_offset) && ((c = tvb_get_guint8(tvb, next_offset)) == ' ' || c == '\t'))
{
/*
* This line end is not a header seperator.
* It just extends the header with another line.
* Look for next line end:
*/
linelen += (next_offset - line_end_offset);
linelen += tvb_find_line_end(tvb, next_offset, -1, &next_offset, FALSE);
line_end_offset = body_offset + linelen;
}
}
remaining_length = remaining_length - (next_offset - body_offset);
body_offset = next_offset;
}/* End while */
remaining_length += (body_offset - offset);
th = proto_tree_add_item(sip_tree, hf_sip_msg_hdr, tvb, offset,
body_offset - offset, ENC_UTF_8);
proto_item_set_text(th, "Message Header");
hdr_tree = proto_item_add_subtree(th, ett_sip_hdr);
if (have_tap_listener(sip_follow_tap))
tap_queue_packet(sip_follow_tap, pinfo, tvb);
/*
* Process the headers - if we're not building a protocol tree,
* we just do this to find the blank line separating the
* headers from the message body.
*/
content_length = -1;
while (remaining_length > 0) {
gint line_end_offset;
gint colon_offset;
gint semi_colon_offset;
gint parameter_offset;
gint parameter_end_offset;
gint parameter_len;
gint content_type_len, content_type_parameter_str_len;
gint header_len;
gchar *header_name;
dissector_handle_t ext_hdr_handle;
gint hf_index;
gint value_offset;
gint sub_value_offset;
gint comma_offset;
guchar c;
gint value_len;
gboolean is_no_header_termination = FALSE;
proto_tree *tc_uri_item_tree = NULL;
uri_offset_info uri_offsets;
linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
if (linelen == 0) {
/*
* This is a blank line separating the
* message header from the message body.
*/
offset = next_offset;
break;
}
line_end_offset = offset + linelen;
if(tvb_reported_length_remaining(tvb, next_offset) <= 0){
is_no_header_termination = TRUE;
}else{
while (tvb_offset_exists(tvb, next_offset) && ((c = tvb_get_guint8(tvb, next_offset)) == ' ' || c == '\t'))
{
/*
* This line end is not a header seperator.
* It just extends the header with another line.
* Look for next line end:
*/
linelen += (next_offset - line_end_offset);
linelen += tvb_find_line_end(tvb, next_offset, -1, &next_offset, FALSE);
line_end_offset = offset + linelen;
}
}
colon_offset = tvb_find_guint8(tvb, offset, linelen, ':');
if (colon_offset == -1) {
/*
* Malformed header - no colon after the name.
*/
expert_add_info(pinfo, th, &ei_sip_header_no_colon);
} else {
header_len = colon_offset - offset;
header_name = (gchar*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, header_len, ENC_UTF_8|ENC_NA);
ascii_strdown_inplace(header_name);
hf_index = sip_is_known_sip_header(header_name, header_len);
/*
* Skip whitespace after the colon.
*/
value_offset = tvb_skip_wsp(tvb, colon_offset + 1, line_end_offset - (colon_offset + 1));
value_len = (gint) (line_end_offset - value_offset);
if (hf_index == -1) {
gint *hf_ptr = NULL;
if (sip_custom_header_fields_hash) {
hf_ptr = (gint*)g_hash_table_lookup(sip_custom_header_fields_hash, header_name);
}
if (hf_ptr) {
sip_proto_tree_add_string(hdr_tree, *hf_ptr, tvb, offset,
next_offset - offset, value_offset, value_len);
} else {
proto_item *ti_c;
proto_tree *ti_tree = proto_tree_add_subtree(hdr_tree, tvb,
offset, next_offset - offset, ett_sip_ext_hdr, &ti_c,
tvb_format_text(pinfo->pool, tvb, offset, linelen));
ext_hdr_handle = dissector_get_string_handle(ext_hdr_subdissector_table, header_name);
if (ext_hdr_handle != NULL) {
tvbuff_t *next_tvb2;
next_tvb2 = tvb_new_subset_length(tvb, value_offset, value_len);
dissector_try_string(ext_hdr_subdissector_table, header_name, next_tvb2, pinfo, ti_tree, NULL);
} else {
expert_add_info_format(pinfo, ti_c, &ei_sip_unrecognized_header,
"Unrecognised SIP header (%s)",
header_name);
}
}
} else {
proto_item *sip_element_item;
proto_tree *sip_element_tree;
/*
* Add it to the protocol tree,
* but display the line as is.
*/
switch ( hf_index ) {
case POS_TO :
/*if(hdr_tree)*/ {
proto_item *item;
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
sip_element_tree = proto_item_add_subtree( sip_element_item,
ett_sip_element);
/* To = ( "To" / "t" ) HCOLON ( name-addr
* / addr-spec ) *( SEMI to-param )
*/
sip_uri_offset_init(&uri_offsets);
if((dissect_sip_name_addr_or_addr_spec(tvb, pinfo, value_offset, line_end_offset+2, &uri_offsets)) != -1){
display_sip_uri(tvb, sip_element_tree, pinfo, &uri_offsets, &sip_to_uri);
if((uri_offsets.name_addr_start != -1) && (uri_offsets.name_addr_end != -1)){
stat_info->tap_to_addr=tvb_get_string_enc(wmem_packet_scope(), tvb, uri_offsets.name_addr_start,
uri_offsets.name_addr_end - uri_offsets.name_addr_start + 1, ENC_UTF_8|ENC_NA);
}
offset = uri_offsets.name_addr_end +1;
}
/* Find parameter tag if present.
* TODO make this generic to find any interesting parameter
* use the same method as for SIP headers ?
*/
parameter_offset = offset;
while (parameter_offset < line_end_offset
&& (tvb_strneql(tvb, parameter_offset, "tag=", 4) != 0))
parameter_offset++;
if ( parameter_offset < line_end_offset ){ /* Tag found */
parameter_offset = parameter_offset + 4;
parameter_end_offset = tvb_find_guint8(tvb, parameter_offset,
(line_end_offset - parameter_offset), ';');
if ( parameter_end_offset == -1)
parameter_end_offset = line_end_offset;
parameter_len = parameter_end_offset - parameter_offset;
proto_tree_add_item(sip_element_tree, hf_sip_to_tag, tvb, parameter_offset,
parameter_len, ENC_UTF_8);
item = proto_tree_add_item(sip_element_tree, hf_sip_tag, tvb, parameter_offset,
parameter_len, ENC_UTF_8);
proto_item_set_hidden(item);
/* Tag indicates in-dialog messages, in case we have a INVITE, SUBSCRIBE or REFER, mark it */
switch (current_method_idx) {
case SIP_METHOD_INVITE:
case SIP_METHOD_SUBSCRIBE:
case SIP_METHOD_REFER:
col_append_str(pinfo->cinfo, COL_INFO, ", in-dialog");
break;
}
}
} /* if hdr_tree */
break;
case POS_FROM :
/*if(hdr_tree)*/ {
proto_item *item;
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
sip_element_tree = proto_item_add_subtree( sip_element_item, ett_sip_element);
/*
* From = ( "From" / "f" ) HCOLON from-spec
* from-spec = ( name-addr / addr-spec )
* *( SEMI from-param )
*/
sip_uri_offset_init(&uri_offsets);
if((dissect_sip_name_addr_or_addr_spec(tvb, pinfo, value_offset, line_end_offset+2, &uri_offsets)) != -1){
display_sip_uri(tvb, sip_element_tree, pinfo, &uri_offsets, &sip_from_uri);
if((uri_offsets.name_addr_start != -1) && (uri_offsets.name_addr_end != -1)){
stat_info->tap_from_addr=tvb_get_string_enc(wmem_packet_scope(), tvb, uri_offsets.name_addr_start,
uri_offsets.name_addr_end - uri_offsets.name_addr_start + 1, ENC_UTF_8|ENC_NA);
}
offset = uri_offsets.name_addr_end +1;
}
/* Find parameter tag if present.
* TODO make this generic to find any interesting parameter
* use the same method as for SIP headers ?
*/
parameter_offset = offset;
while (parameter_offset < line_end_offset
&& (tvb_strneql(tvb, parameter_offset, "tag=", 4) != 0))
parameter_offset++;
if ( parameter_offset < line_end_offset ){ /* Tag found */
parameter_offset = parameter_offset + 4;
parameter_end_offset = tvb_find_guint8(tvb, parameter_offset,
(line_end_offset - parameter_offset), ';');
if ( parameter_end_offset == -1)
parameter_end_offset = line_end_offset;
parameter_len = parameter_end_offset - parameter_offset;
proto_tree_add_item(sip_element_tree, hf_sip_from_tag, tvb, parameter_offset,
parameter_len, ENC_UTF_8);
item = proto_tree_add_item(sip_element_tree, hf_sip_tag, tvb, parameter_offset,
parameter_len, ENC_UTF_8);
proto_item_set_hidden(item);
}
}/* hdr_tree */
break;
case POS_P_ASSERTED_IDENTITY :
if(hdr_tree)
{
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
sip_element_tree = proto_item_add_subtree( sip_element_item,
ett_sip_element);
/*
* PAssertedID = "P-Asserted-Identity" HCOLON PAssertedID-value
* *(COMMA PAssertedID-value)
* PAssertedID-value = name-addr / addr-spec
*
* Initialize the uri_offsets
*/
sip_uri_offset_init(&uri_offsets);
if((dissect_sip_name_addr_or_addr_spec(tvb, pinfo, value_offset, line_end_offset+2, &uri_offsets)) != -1)
display_sip_uri(tvb, sip_element_tree, pinfo, &uri_offsets, &sip_pai_uri);
}
break;
case POS_P_ASSOCIATED_URI:
if (hdr_tree)
{
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
/*
* P-Associated-URI = "P-Associated-URI" HCOLON
* [p-aso-uri-spec]
* *(COMMA p-aso-uri-spec)
* p-aso-uri-spec = name-addr *(SEMI ai-param)
* ai-param = generic-param
*/
/* Skip to the end of the URI directly */
semi_colon_offset = tvb_find_guint8(tvb, value_offset, line_end_offset - value_offset, '>');
if (semi_colon_offset != -1) {
semi_colon_offset = tvb_find_guint8(tvb, semi_colon_offset, line_end_offset - semi_colon_offset, ';');
if (semi_colon_offset != -1) {
sip_element_tree = proto_item_add_subtree(sip_element_item,
ett_sip_element);
/* We have generic parameters */
dissect_sip_generic_parameters(tvb, sip_element_tree, pinfo, semi_colon_offset + 1, line_end_offset);
}
}
}
break;
case POS_HISTORY_INFO:
if(hdr_tree)
{
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
sip_element_tree = proto_item_add_subtree( sip_element_item,
ett_sip_hist);
dissect_sip_history_info(tvb, sip_element_tree, pinfo, value_offset, line_end_offset);
}
break;
case POS_P_CHARGING_FUNC_ADDRESSES:
if(hdr_tree)
{
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
sip_element_tree = proto_item_add_subtree( sip_element_item,
ett_sip_element);
dissect_sip_p_charging_func_addresses(tvb, sip_element_tree, pinfo, value_offset, line_end_offset);
}
break;
case POS_P_PREFERRED_IDENTITY :
if(hdr_tree)
{
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
sip_element_tree = proto_item_add_subtree( sip_element_item,
ett_sip_element);
/*
* PPreferredID = "P-Preferred-Identity" HCOLON PPreferredID-value
* *(COMMA PPreferredID-value)
* PPreferredID-value = name-addr / addr-spec
*
* Initialize the uri_offsets
*/
sip_uri_offset_init(&uri_offsets);
if((dissect_sip_name_addr_or_addr_spec(tvb, pinfo, value_offset, line_end_offset+2, &uri_offsets)) != -1)
display_sip_uri(tvb, sip_element_tree, pinfo, &uri_offsets, &sip_ppi_uri);
}
break;
case POS_PERMISSION_MISSING :
if(hdr_tree)
{
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
sip_element_tree = proto_item_add_subtree( sip_element_item,
ett_sip_element);
/*
* Permission-Missing = "Permission-Missing" HCOLON per-miss-spec
* *( COMMA per-miss-spec )
* per-miss-spec = ( name-addr / addr-spec )
* *( SEMI generic-param )
* Initialize the uri_offsets
*/
sip_uri_offset_init(&uri_offsets);
if((dissect_sip_name_addr_or_addr_spec(tvb, pinfo, value_offset, line_end_offset+2, &uri_offsets)) != -1)
display_sip_uri(tvb, sip_element_tree, pinfo, &uri_offsets, &sip_pmiss_uri);
}
break;
case POS_TRIGGER_CONSENT :
if(hdr_tree)
{
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
sip_element_tree = proto_item_add_subtree( sip_element_item,
ett_sip_element);
/*
* Trigger-Consent = "Trigger-Consent" HCOLON trigger-cons-spec
* *( COMMA trigger-cons-spec )
* trigger-cons-spec = ( SIP-URI / SIPS-URI )
* *( SEMI trigger-param )
* trigger-param = target-uri / generic-param
* target-uri = "target-uri" EQUAL
* LDQUOT *( qdtext / quoted-pair ) RDQUOT
* Initialize the uri_offsets
*/
sip_uri_offset_init(&uri_offsets);
if((dissect_sip_uri(tvb, pinfo, value_offset, line_end_offset+2, &uri_offsets)) != -1) {
tc_uri_item_tree = display_sip_uri(tvb, sip_element_tree, pinfo, &uri_offsets, &sip_tc_uri);
if (line_end_offset > uri_offsets.uri_end) {
gint hparam_offset = uri_offsets.uri_end + 1;
/* Is there a header parameter */
if (tvb_find_guint8(tvb, hparam_offset, 1,';')) {
while ((hparam_offset != -1 && hparam_offset < line_end_offset) ) {
/* Is this a target-uri ? */
hparam_offset = hparam_offset + 1;
if (tvb_strncaseeql(tvb, hparam_offset, "target-uri=\"", 12) == 0) {
gint turi_start_offset = hparam_offset + 12;
gint turi_end_offset = tvb_find_guint8(tvb, turi_start_offset, -1,'\"');
if (turi_end_offset != -1)
proto_tree_add_item(tc_uri_item_tree, hf_sip_tc_turi, tvb, turi_start_offset,(turi_end_offset - turi_start_offset),ENC_UTF_8);
else
break; /* malformed */
}
hparam_offset = tvb_find_guint8(tvb, hparam_offset, -1,';');
}
}
}
}
}/* hdr_tree */
break;
case POS_RETRY_AFTER:
{
/* Store the retry number */
char *value = tvb_get_string_enc(wmem_packet_scope(), tvb, value_offset, value_len, ENC_UTF_8 | ENC_NA);
guint32 retry;
gboolean retry_valid = ws_strtou32(value, NULL, &retry);
sip_element_item = proto_tree_add_uint(hdr_tree, hf_header_array[hf_index],
tvb, offset, next_offset - offset,
retry);
if (!retry_valid) {
expert_add_info(pinfo, sip_element_item, &ei_sip_retry_after_invalid);
}
}
break;
case POS_CSEQ :
{
/* Store the sequence number */
char *value = tvb_get_string_enc(wmem_packet_scope(), tvb, value_offset, value_len, ENC_UTF_8|ENC_NA);
cseq_number = (guint32)strtoul(value, NULL, 10);
cseq_number_set = 1;
stat_info->tap_cseq_number=cseq_number;
/* Add CSeq tree */
if (hdr_tree) {
sip_element_item = proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
cseq_tree = proto_item_add_subtree(sip_element_item, ett_sip_cseq);
}
/* Walk past number and spaces characters to get to start
of method name */
for (sub_value_offset=0; sub_value_offset < value_len; sub_value_offset++)
{
if (!g_ascii_isdigit(value[sub_value_offset]))
{
proto_tree_add_uint(cseq_tree, hf_sip_cseq_seq_no,
tvb, value_offset, sub_value_offset,
cseq_number);
break;
}
}
for (; sub_value_offset < value_len; sub_value_offset++)
{
if (g_ascii_isalpha(value[sub_value_offset]))
{
/* Have reached start of method name */
break;
}
}
if (sub_value_offset == value_len)
{
/* Didn't find method name */
return offset - orig_offset;
}
/* Extract method name from value */
strlen_to_copy = (int)value_len-sub_value_offset;
if (strlen_to_copy > MAX_CSEQ_METHOD_SIZE) {
/* Note the error in the protocol tree */
proto_tree_add_string_format(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value+sub_value_offset, "%s String too big: %d bytes",
sip_headers[POS_CSEQ].name,
strlen_to_copy);
return offset - orig_offset;
}
else {
/* Add CSeq method to the tree */
proto_tree_add_item_ret_string(cseq_tree, hf_sip_cseq_method, tvb,
value_offset + sub_value_offset, strlen_to_copy, ENC_UTF_8,
pinfo->pool, (const guint8 **)&cseq_method);
}
}
break;
case POS_RACK :
{
char *value = tvb_get_string_enc(wmem_packet_scope(), tvb, value_offset, value_len, ENC_UTF_8|ENC_NA);
int cseq_no_offset;
/*int cseq_method_offset;*/
/* Add RAck tree */
if (hdr_tree) {
sip_element_item = proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
rack_tree = proto_item_add_subtree(sip_element_item, ett_sip_rack);
}
/* RSeq number */
for (sub_value_offset=0; sub_value_offset < value_len; sub_value_offset++)
{
if (!g_ascii_isdigit(value[sub_value_offset]))
{
proto_tree_add_uint(rack_tree, hf_sip_rack_rseq_no,
tvb, value_offset, sub_value_offset,
(guint32)strtoul(value, NULL, 10));
break;
}
}
/* Get to start of CSeq number */
for ( ; sub_value_offset < value_len; sub_value_offset++)
{
if (value[sub_value_offset] != ' ' &&
value[sub_value_offset] != '\t')
{
break;
}
}
cseq_no_offset = sub_value_offset;
/* CSeq number */
for ( ; sub_value_offset < value_len; sub_value_offset++)
{
if (!g_ascii_isdigit(value[sub_value_offset]))
{
proto_tree_add_uint(rack_tree, hf_sip_rack_cseq_no,
tvb, value_offset+cseq_no_offset,
sub_value_offset-cseq_no_offset,
(guint32)strtoul(value+cseq_no_offset, NULL, 10));
break;
}
}
/* Get to start of CSeq method name */
for ( ; sub_value_offset < value_len; sub_value_offset++)
{
if (g_ascii_isalpha(value[sub_value_offset]))
{
/* Have reached start of method name */
break;
}
}
/*cseq_method_offset = sub_value_offset;*/
if (sub_value_offset == linelen)
{
/* Didn't find method name */
return offset - orig_offset;
}
/* Add CSeq method to the tree */
if (cseq_tree)
{
proto_tree_add_item(rack_tree, hf_sip_rack_cseq_method, tvb,
value_offset + sub_value_offset,
(int)value_len-sub_value_offset, ENC_UTF_8);
}
break;
}
case POS_CALL_ID :
{
call_id = tvb_get_string_enc(pinfo->pool, tvb, value_offset, value_len, ENC_UTF_8|ENC_NA);
proto_item *gen_item;
/* Store the Call-id */
stat_info->tap_call_id = call_id;
/* Add 'Call-id' string item to tree */
sip_element_item = proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
call_id);
gen_item = proto_tree_add_string(hdr_tree,
hf_sip_call_id_gen, tvb,
offset, next_offset - offset,
call_id);
proto_item_set_generated(gen_item);
if (sip_hide_generatd_call_ids) {
proto_item_set_hidden(gen_item);
}
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
}
break;
case POS_EXPIRES :
if (tvb_strneql(tvb, value_offset, "0", value_len) == 0)
{
expires_is_0 = 1;
}
/* Add 'Expires' string item to tree */
sip_proto_tree_add_uint(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
break;
/*
* Content-Type is the same as Internet
* media type used by other dissectors,
* appropriate dissector found by
* lookup in "media_type" dissector table.
*/
case POS_CONTENT_TYPE :
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
content_type_len = value_len;
semi_colon_offset = tvb_find_guint8(tvb, value_offset, value_len, ';');
/* Content-Type = ( "Content-Type" / "c" ) HCOLON media-type
* media-type = m-type SLASH m-subtype *(SEMI m-parameter)
* SEMI = SWS ";" SWS ; semicolon
* LWS = [*WSP CRLF] 1*WSP ; linear whitespace
* SWS = [LWS] ; sep whitespace
*/
if ( semi_colon_offset != -1) {
gint content_type_end;
/*
* Skip whitespace after the semicolon.
*/
parameter_offset = tvb_skip_wsp(tvb, semi_colon_offset +1, value_offset + value_len - (semi_colon_offset +1));
content_type_end = tvb_skip_wsp_return(tvb, semi_colon_offset-1);
content_type_len = content_type_end - value_offset;
content_type_parameter_str_len = value_offset + value_len - parameter_offset;
content_info.media_str = tvb_get_string_enc(wmem_packet_scope(), tvb, parameter_offset,
content_type_parameter_str_len, ENC_UTF_8|ENC_NA);
}
media_type_str_lower_case = ascii_strdown_inplace(
(gchar *)tvb_get_string_enc(wmem_packet_scope(), tvb, value_offset, content_type_len, ENC_UTF_8|ENC_NA));
/* Debug code
proto_tree_add_debug_text(hdr_tree, tvb, value_offset,content_type_len,
"media_type_str(lower cased)=%s",media_type_str_lower_case);
*/
break;
case POS_CONTENT_LENGTH :
{
char *value = tvb_get_string_enc(wmem_packet_scope(), tvb, value_offset, value_len, ENC_UTF_8|ENC_NA);
gboolean content_length_valid = ws_strtou32(value, NULL, &content_length);
sip_element_item = proto_tree_add_uint(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
content_length);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
if (!content_length_valid)
expert_add_info(pinfo, sip_element_item, &ei_sip_content_length_invalid);
break;
}
case POS_MAX_BREADTH :
case POS_MAX_FORWARDS :
case POS_RSEQ :
sip_proto_tree_add_uint(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
break;
case POS_CONTACT :
/*
* Contact = ("Contact" / "m" ) HCOLON
* ( STAR / (contact-param *(COMMA contact-param)))
* contact-param = (name-addr / addr-spec) *(SEMI contact-params)
*/
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
sip_element_tree = proto_item_add_subtree( sip_element_item,
ett_sip_element);
/* value_offset points to the first non SWS character after ':' */
c = tvb_get_guint8(tvb, value_offset);
if (c =='*'){
contact_is_star = 1;
break;
}
/*if(hdr_tree)*/ {
comma_offset = value_offset;
while((comma_offset = dissect_sip_contact_item(tvb, pinfo, sip_element_tree, comma_offset,
next_offset, &contacts_expires_0, &contacts_expires_unknown)) != -1)
{
contacts++;
if(comma_offset == next_offset)
{
/* Line End reached: Stop Parsing */
break;
}
if(tvb_get_guint8(tvb, comma_offset) != ',')
{
/* Undefined value reached: Stop Parsing */
break;
}
comma_offset++; /* skip comma */
}
}
break;
case POS_AUTHORIZATION:
/* Authorization = "Authorization" HCOLON credentials
* credentials = ("Digest" LWS digest-response)
* / other-response
* digest-response = dig-resp *(COMMA dig-resp)
* other-response = auth-scheme LWS auth-param
* *(COMMA auth-param)
*/
case POS_WWW_AUTHENTICATE:
/* Proxy-Authenticate = "Proxy-Authenticate" HCOLON challenge
* challenge = ("Digest" LWS digest-cln *(COMMA digest-cln))
* / other-challenge
* other-challenge = auth-scheme LWS auth-param
* *(COMMA auth-param)
* auth-scheme = token
*/
case POS_PROXY_AUTHENTICATE:
/* Proxy-Authenticate = "Proxy-Authenticate" HCOLON challenge
*/
case POS_PROXY_AUTHORIZATION:
/* Proxy-Authorization = "Proxy-Authorization" HCOLON credentials
*/
case POS_AUTHENTICATION_INFO:
/* Authentication-Info = "Authentication-Info" HCOLON ainfo
* *(COMMA ainfo)
* ainfo = nextnonce / message-qop
* / response-auth / cnonce
* / nonce-count
*/
/* Add tree using whole text of line */
if (hdr_tree) {
proto_item *ti_c;
sip_authorization_t authorization_info = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
authorization_user_t * authorization_user = NULL;
/* Add whole line as header tree */
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
sip_element_tree = proto_item_add_subtree( sip_element_item,
ett_sip_element);
/* Set sip.auth as a hidden field/filter */
ti_c = proto_tree_add_item(hdr_tree, hf_sip_auth, tvb,
offset, next_offset-offset,
ENC_UTF_8);
proto_item_set_hidden(ti_c);
/* Check if we have any parameters */
if ((line_end_offset - value_offset) != 0) {
/* Authentication-Info does not begin with the scheme name */
if (hf_index != POS_AUTHENTICATION_INFO)
{
/* The first time comma_offset is "start of parameters" */
comma_offset = tvb_ws_mempbrk_pattern_guint8(tvb, value_offset, line_end_offset - value_offset, &pbrk_whitespace, NULL);
proto_tree_add_item(sip_element_tree, hf_sip_auth_scheme,
tvb, value_offset, comma_offset - value_offset,
ENC_UTF_8 | ENC_NA);
} else {
/* The first time comma_offset is "start of parameters" */
comma_offset = value_offset;
}
/* Parse each individual parameter in the line */
while ((comma_offset = dissect_sip_authorization_item(tvb, sip_element_tree, comma_offset, line_end_offset, &authorization_info)) != -1)
{
if (comma_offset == line_end_offset)
{
/* Line End reached: Stop Parsing */
break;
}
if (tvb_get_guint8(tvb, comma_offset) != ',')
{
/* Undefined value reached: Stop Parsing */
break;
}
comma_offset++; /* skip comma */
}
if ((authorization_info.response != NULL) && (global_sip_validate_authorization) &&
(authorization_info.username != NULL) && (authorization_info.realm != NULL)) { /* If there is a response, check for valid credentials */
authorization_user = sip_get_authorization(&authorization_info);
if (authorization_user) {
authorization_info.method = wmem_strdup(wmem_packet_scope(), stat_info->request_method);
if (!sip_validate_authorization(&authorization_info, authorization_user->password)) {
proto_tree_add_expert_format(tree, pinfo, &ei_sip_authorization_invalid, tvb, offset, line_end_offset - offset, "SIP digest does not match known password %s", authorization_user->password);
}
}
}
} /* Check if we have any parameters */
}/*hdr_tree*/
break;
case POS_ROUTE:
/* Add Route subtree */
if (hdr_tree) {
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
route_tree = proto_item_add_subtree(sip_element_item, ett_sip_route);
dissect_sip_route_header(tvb, route_tree, pinfo, &sip_route_uri, value_offset, line_end_offset);
}
break;
case POS_RECORD_ROUTE:
/* Add Record-Route subtree */
if (hdr_tree) {
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
route_tree = proto_item_add_subtree(sip_element_item, ett_sip_route);
dissect_sip_route_header(tvb, route_tree, pinfo, &sip_record_route_uri, value_offset, line_end_offset);
}
break;
case POS_SERVICE_ROUTE:
/* Add Service-Route subtree */
if (hdr_tree) {
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
route_tree = proto_item_add_subtree(sip_element_item, ett_sip_route);
dissect_sip_route_header(tvb, route_tree, pinfo, &sip_service_route_uri, value_offset, line_end_offset);
}
break;
case POS_PATH:
/* Add Path subtree */
if (hdr_tree) {
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
route_tree = proto_item_add_subtree(sip_element_item, ett_sip_route);
dissect_sip_route_header(tvb, route_tree, pinfo, &sip_path_uri, value_offset, line_end_offset);
}
break;
case POS_VIA:
/* Add Via subtree */
if (hdr_tree) {
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
via_tree = proto_item_add_subtree(sip_element_item, ett_sip_via);
dissect_sip_via_header(tvb, via_tree, value_offset, line_end_offset, pinfo);
}
break;
case POS_REASON:
if(hdr_tree) {
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
reason_tree = proto_item_add_subtree(sip_element_item, ett_sip_reason);
dissect_sip_reason_header(tvb, reason_tree, pinfo, value_offset, line_end_offset);
}
break;
case POS_CONTENT_ENCODING:
/* Content-Encoding = ( "Content-Encoding" / "e" ) HCOLON
* content-coding *(COMMA content-coding)
*/
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
content_encoding_parameter_str = ascii_strdown_inplace(tvb_get_string_enc(wmem_packet_scope(), tvb, value_offset,
(line_end_offset-value_offset), ENC_UTF_8|ENC_NA));
break;
case POS_SECURITY_CLIENT:
/* security-client = "Security-Client" HCOLON
* sec-mechanism *(COMMA sec-mechanism)
*/
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
comma_offset = tvb_find_guint8(tvb, value_offset, line_end_offset - value_offset, ',');
while(comma_offset<line_end_offset){
comma_offset = tvb_find_guint8(tvb, value_offset, line_end_offset - value_offset, ',');
if(comma_offset == -1){
comma_offset = line_end_offset;
}
security_client_tree = proto_item_add_subtree(sip_element_item, ett_sip_security_client);
dissect_sip_sec_mechanism(tvb, pinfo, security_client_tree, value_offset, comma_offset);
comma_offset = value_offset = comma_offset+1;
}
break;
case POS_SECURITY_SERVER:
/* security-server = "Security-Server" HCOLON
* sec-mechanism *(COMMA sec-mechanism)
*/
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
comma_offset = tvb_find_guint8(tvb, value_offset, line_end_offset - value_offset, ',');
while(comma_offset<line_end_offset){
comma_offset = tvb_find_guint8(tvb, value_offset, line_end_offset - value_offset, ',');
if(comma_offset == -1){
comma_offset = line_end_offset;
}
security_client_tree = proto_item_add_subtree(sip_element_item, ett_sip_security_server);
dissect_sip_sec_mechanism(tvb, pinfo, security_client_tree, value_offset, comma_offset);
comma_offset = value_offset = comma_offset+1;
}
break;
case POS_SECURITY_VERIFY:
/* security-verify = "Security-Verify" HCOLON
* sec-mechanism *(COMMA sec-mechanism)
*/
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
comma_offset = tvb_find_guint8(tvb, value_offset, line_end_offset - value_offset, ',');
while(comma_offset<line_end_offset){
comma_offset = tvb_find_guint8(tvb, value_offset, line_end_offset - value_offset, ',');
if(comma_offset == -1){
comma_offset = line_end_offset;
}
security_client_tree = proto_item_add_subtree(sip_element_item, ett_sip_security_verify);
dissect_sip_sec_mechanism(tvb, pinfo, security_client_tree, value_offset, comma_offset);
comma_offset = value_offset = comma_offset+1;
}
break;
case POS_SESSION_ID:
if(hdr_tree) {
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
session_id_tree = proto_item_add_subtree(sip_element_item, ett_sip_session_id);
dissect_sip_session_id_header(tvb, session_id_tree, value_offset, line_end_offset, pinfo);
}
break;
case POS_P_ACCESS_NETWORK_INFO:
/* Add P-Access-Network-Info subtree */
if (hdr_tree) {
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
p_access_net_info_tree = proto_item_add_subtree(sip_element_item, ett_sip_p_access_net_info);
dissect_sip_p_access_network_info_header(tvb, pinfo, p_access_net_info_tree, value_offset, line_end_offset);
}
break;
case POS_P_CHARGING_VECTOR:
if (hdr_tree) {
proto_tree *p_charging_vector_tree;
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
p_charging_vector_tree = proto_item_add_subtree(sip_element_item, ett_sip_p_charging_vector);
dissect_sip_p_charging_vector_header(tvb, p_charging_vector_tree, value_offset, line_end_offset);
}
break;
case POS_FEATURE_CAPS:
if (hdr_tree) {
proto_tree *feature_caps_tree;
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
feature_caps_tree = proto_item_add_subtree(sip_element_item, ett_sip_feature_caps);
dissect_sip_p_feature_caps(tvb, feature_caps_tree, value_offset, line_end_offset);
}
break;
default :
/* Default case is to assume it's an FT_STRING field */
sip_element_item = sip_proto_tree_add_string(hdr_tree,
hf_header_array[hf_index], tvb,
offset, next_offset - offset,
value_offset, value_len);
sip_proto_set_format_text(hdr_tree, sip_element_item, tvb, offset, linelen);
break;
}/* end switch */
}/*if HF_index */
}/* if colon_offset */
if (is_no_header_termination == TRUE){
/* Header not terminated by empty line CRLF */
proto_tree_add_expert(hdr_tree, pinfo, &ei_sip_header_not_terminated,
tvb, line_end_offset, -1);
}
remaining_length = remaining_length - (next_offset - offset);
offset = next_offset;
}/* End while */
datalen = tvb_captured_length_remaining(tvb, offset);
reported_datalen = tvb_reported_length_remaining(tvb, offset);
if (content_length != -1) {
if (datalen > content_length)
datalen = content_length;
if (reported_datalen > content_length)
reported_datalen = content_length;
}
if (!call_id) {
call_id = wmem_strdup(pinfo->pool, "");
expert_add_info(pinfo, hdr_tree, &ei_sip_call_id_invalid);
/* XXX: The hash table lookups below (setup time, request/response,
* resend) are less reliable when the mandatory Call-Id header field
* is missing.
*/
}
/* Add to info column interesting things learned from header fields. */
/* for either REGISTER requests or responses, any contacts without expires
* parameter use the Expires header's value
*/
if (expires_is_0) {
/* this may add nothing, but that's ok */
contacts_expires_0 += contacts_expires_unknown;
}
/* Registration requests */
if (current_method_idx == SIP_METHOD_REGISTER)
{
/* TODO: what if there's a *-contact but also non-*-contacts?
* we should create expert info for that someday I guess
*/
if (contact_is_star && expires_is_0)
{
col_append_str(pinfo->cinfo, COL_INFO, " (remove all bindings)");
}
else
if (contacts_expires_0 > 0)
{
col_append_fstr(pinfo->cinfo, COL_INFO, " (remove %d binding%s)",
contacts_expires_0, contacts_expires_0 == 1 ? "":"s");
if (contacts > contacts_expires_0) {
col_append_fstr(pinfo->cinfo, COL_INFO, " (add %d binding%s)",
contacts - contacts_expires_0,
(contacts - contacts_expires_0 == 1) ? "":"s");
}
}
else
if (!contacts)
{
col_append_str(pinfo->cinfo, COL_INFO, " (fetch bindings)");
}
else
{
col_append_fstr(pinfo->cinfo, COL_INFO, " (%d binding%s)",
contacts, contacts == 1 ? "":"s");
}
}
/* Registration responses - this info only makes sense in 2xx responses */
if (line_type == STATUS_LINE && stat_info)
{
if (stat_info->response_code == 200)
{
col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)", cseq_method);
}
if ((strcmp(cseq_method, "REGISTER") == 0) &&
stat_info->response_code > 199 && stat_info->response_code < 300)
{
if (contacts_expires_0 > 0) {
col_append_fstr(pinfo->cinfo, COL_INFO, " (removed %d binding%s)",
contacts_expires_0, contacts_expires_0 == 1 ? "":"s");
if (contacts > contacts_expires_0) {
col_append_fstr(pinfo->cinfo, COL_INFO, " (%d binding%s kept)",
contacts - contacts_expires_0,
(contacts - contacts_expires_0 == 1) ? "":"s");
}
} else {
col_append_fstr(pinfo->cinfo, COL_INFO, " (%d binding%s)",
contacts, contacts == 1 ? "":"s");
}
}
}
/* We've finished writing to the info col for this SIP message
* Set fence in case there is more than one (SIP)message in the frame
*/
/* XXX: this produces ugly output, since usually there's only one SIP
* message in a frame yet this '|' gets added at the end. Need a better
* way to do this.
*/
col_append_str(pinfo->cinfo, COL_INFO, " | ");
col_set_fence(pinfo->cinfo, COL_INFO);
/* Find the total setup time, Must be done before checking for resend
* As that will overwrite the "Request packet no".
*/
if ((line_type == REQUEST_LINE)&&(strcmp(cseq_method, "ACK") == 0))
{
request_for_response = sip_find_invite(pinfo, cseq_method, call_id,
cseq_number_set, cseq_number,
&response_time);
stat_info->setup_time = response_time;
}
/* For responses, try to link back to request frame */
if (line_type == STATUS_LINE)
{
request_for_response = sip_find_request(pinfo, cseq_method, call_id,
cseq_number_set, cseq_number,
&response_time);
}
/* Check if this packet is a resend. */
resend_for_packet = sip_is_packet_resend(pinfo, cseq_method, call_id,
cseq_number_set, cseq_number,
line_type);
/* Mark whether this is a resend for the tap */
stat_info->resend = (resend_for_packet > 0);
/* Report this packet to the tap */
if (!pinfo->flags.in_error_pkt)
{
tap_queue_packet(sip_tap, pinfo, stat_info);
}
if (datalen > 0) {
/*
* There's a message body starting at "offset".
* Set the length of the header item.
*/
sdp_setup_info_t setup_info;
setup_info.hf_id = hf_sip_call_id_gen;
setup_info.add_hidden = sip_hide_generatd_call_ids;
setup_info.hf_type = SDP_TRACE_ID_HF_TYPE_STR;
setup_info.trace_id.str = wmem_strdup(wmem_file_scope(), call_id);
content_info.data = &setup_info;
if(content_encoding_parameter_str != NULL &&
(!strncmp(content_encoding_parameter_str, "gzip", 4) ||
!strncmp(content_encoding_parameter_str,"deflate",7))){
/* The body is gzip:ed */
next_tvb = tvb_child_uncompress(tvb, tvb, offset, datalen);
if (next_tvb) {
add_new_data_source(pinfo, next_tvb, "gunzipped data");
if(sip_tree) {
ti_a = proto_tree_add_item(sip_tree, hf_sip_msg_body, next_tvb, 0, -1,
ENC_NA);
message_body_tree = proto_item_add_subtree(ti_a, ett_sip_message_body);
}
} else {
next_tvb = tvb_new_subset_length_caplen(tvb, offset, datalen, reported_datalen);
if(sip_tree) {
ti_a = proto_tree_add_item(sip_tree, hf_sip_msg_body, next_tvb, 0, -1,
ENC_NA);
message_body_tree = proto_item_add_subtree(ti_a, ett_sip_message_body);
}
}
}else{
next_tvb = tvb_new_subset_length_caplen(tvb, offset, datalen, reported_datalen);
if(sip_tree) {
ti_a = proto_tree_add_item(sip_tree, hf_sip_msg_body, next_tvb, 0, -1,
ENC_NA);
message_body_tree = proto_item_add_subtree(ti_a, ett_sip_message_body);
}
}
/* give the content type parameters to sub dissectors */
if ( media_type_str_lower_case != NULL ) {
/* SDP needs a transport layer to determine request/response */
if (!strcmp(media_type_str_lower_case, "application/sdp")) {
/* Resends don't count */
if (resend_for_packet == 0) {
if (line_type == REQUEST_LINE) {
DPRINT(("calling setup_sdp_transport() SDP_EXCHANGE_OFFER frame=%d",
pinfo->num));
DINDENT();
setup_sdp_transport(next_tvb, pinfo, SDP_EXCHANGE_OFFER, pinfo->num, sip_delay_sdp_changes, &setup_info);
DENDENT();
} else if (line_type == STATUS_LINE) {
if (stat_info->response_code >= 400) {
DPRINT(("calling setup_sdp_transport() SDP_EXCHANGE_ANSWER_REJECT "
"request_frame=%d, this=%d",
request_for_response, pinfo->num));
DINDENT();
/* SIP client request failed, so SDP offer should fail */
setup_sdp_transport(next_tvb, pinfo, SDP_EXCHANGE_ANSWER_REJECT, request_for_response, sip_delay_sdp_changes, &setup_info);
DENDENT();
}
else if ((stat_info->response_code >= 200) && (stat_info->response_code <= 299)) {
DPRINT(("calling setup_sdp_transport() SDP_EXCHANGE_ANSWER_ACCEPT "
"request_frame=%d, this=%d",
request_for_response, pinfo->num));
DINDENT();
/* SIP success request, so SDP offer should be accepted */
setup_sdp_transport(next_tvb, pinfo, SDP_EXCHANGE_ANSWER_ACCEPT, request_for_response, sip_delay_sdp_changes, &setup_info);
DENDENT();
}
}
} else {
DPRINT(("calling setup_sdp_transport() resend_for_packet "
"request_frame=%d, this=%d",
request_for_response, pinfo->num));
DINDENT();
setup_sdp_transport_resend(pinfo->num, resend_for_packet);
DENDENT();
}
}
/* XXX: why is this called even if setup_sdp_transport() was called before? That will
parse the SDP a second time, for 'application/sdp' media MIME bodies */
DPRINT(("calling dissector_try_string()"));
DINDENT();
found_match = dissector_try_string(media_type_dissector_table,
media_type_str_lower_case,
next_tvb, pinfo,
message_body_tree, &content_info);
DENDENT();
DPRINT(("done calling dissector_try_string() with found_match=%u", found_match));
if (!found_match &&
!strncmp(media_type_str_lower_case, "multipart/", sizeof("multipart/")-1)) {
DPRINT(("calling dissector_try_string() for multipart"));
DINDENT();
/* Try to decode the unknown multipart subtype anyway */
found_match = dissector_try_string(media_type_dissector_table,
"multipart/",
next_tvb, pinfo,
message_body_tree, &content_info);
DENDENT();
DPRINT(("done calling dissector_try_string() with found_match=%u", found_match));
}
/* If no match dump as text */
}
if ( found_match == 0 )
{
DPRINT(("calling dissector_try_heuristic() with found_match=0"));
DINDENT();
if (!(dissector_try_heuristic(heur_subdissector_list,
next_tvb, pinfo, message_body_tree, &hdtbl_entry, NULL))) {
int tmp_offset = 0;
while (tvb_offset_exists(next_tvb, tmp_offset)) {
tvb_find_line_end(next_tvb, tmp_offset, -1, &next_offset, FALSE);
linelen = next_offset - tmp_offset;
proto_tree_add_format_text(message_body_tree, next_tvb,
tmp_offset, linelen);
tmp_offset = next_offset;
}/* end while */
}
DENDENT();
}
offset += datalen;
}
/* And add the filterable field to the request/response line */
if (reqresp_tree)
{
proto_item *item;
item = proto_tree_add_boolean(reqresp_tree, hf_sip_resend, tvb, orig_offset, 0,
resend_for_packet > 0);
proto_item_set_generated(item);
if (resend_for_packet > 0)
{
item = proto_tree_add_uint(reqresp_tree, hf_sip_original_frame,
tvb, orig_offset, 0, resend_for_packet);
proto_item_set_generated(item);
}
if (request_for_response > 0)
{
item = proto_tree_add_uint(reqresp_tree, hf_sip_matching_request_frame,
tvb, orig_offset, 0, request_for_response);
proto_item_set_generated(item);
item = proto_tree_add_uint(reqresp_tree, hf_sip_response_time,
tvb, orig_offset, 0, response_time);
proto_item_set_generated(item);
if ((line_type == STATUS_LINE)&&(strcmp(cseq_method, "BYE") == 0)){
item = proto_tree_add_uint(reqresp_tree, hf_sip_release_time,
tvb, orig_offset, 0, response_time);
proto_item_set_generated(item);
}
}
}
if (ts != NULL)
proto_item_set_len(ts, offset - orig_offset);
if (global_sip_raw_text)
tvb_raw_text_add(tvb, orig_offset, offset - orig_offset, body_offset, pinfo, tree);
/* Append a brief summary to the SIP root item */
if (stat_info->request_method) {
proto_item_append_text(ts, " (%s)", stat_info->request_method);
}
else {
proto_item_append_text(ts, " (%u)", stat_info->response_code);
}
return offset - orig_offset;
}
/* Display filter for SIP Request-Line */
static void
dfilter_sip_request_line(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, gint offset, guint meth_len, gint linelen)
{
const guint8 *value;
guint parameter_len = meth_len;
uri_offset_info uri_offsets;
/*
* We know we have the entire method; otherwise, "sip_parse_line()"
* would have returned OTHER_LINE.
* Request-Line = Method SP Request-URI SP SIP-Version CRLF
* SP = single space
* Request-URI = SIP-URI / SIPS-URI / absoluteURI
*/
/* get method string*/
proto_tree_add_item_ret_string(tree, hf_sip_Method, tvb, offset, parameter_len, ENC_ASCII | ENC_NA,
wmem_packet_scope(), &value);
/* Copy request method for telling tap */
stat_info->request_method = value;
if (tree) {
/* build Request-URI tree*/
offset=offset + parameter_len+1;
sip_uri_offset_init(&uri_offsets);
/* calc R-URI len*/
uri_offsets.uri_end = tvb_find_guint8(tvb, offset, linelen, ' ')-1;
dissect_sip_uri(tvb, pinfo, offset, offset + linelen, &uri_offsets);
display_sip_uri(tvb, tree, pinfo, &uri_offsets, &sip_req_uri);
}
}
/* Display filter for SIP Status-Line */
static void
dfilter_sip_status_line(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, gint line_end, gint offset)
{
gint response_code = 0;
gboolean response_code_valid;
proto_item* pi;
int diag_len;
tvbuff_t *next_tvb;
/*
* We know we have the entire status code; otherwise,
* "sip_parse_line()" would have returned OTHER_LINE.
* We also know that we have a version string followed by a
* space at the beginning of the line, for the same reason.
*/
offset = offset + SIP2_HDR_LEN + 1;
response_code_valid = ws_strtoi32(tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 3,
ENC_UTF_8|ENC_NA), NULL, &response_code);
/* Add numerical response code to tree */
pi = proto_tree_add_uint(tree, hf_sip_Status_Code, tvb, offset, 3, response_code);
if (!response_code_valid)
expert_add_info(pinfo, pi, &ei_sip_Status_Code_invalid);
/* Add response code for sending to tap */
stat_info->response_code = response_code;
/* Skip past the response code and possible trailing space */
offset = offset + 3 + 1;
/* Check for diagnostics */
diag_len = line_end - (SIP2_HDR_LEN + 1 + 3 + 1);
if((diag_len) <= 0)
return;
/* If we have a SIP diagnostics sub dissector call it */
if(sip_diag_handle){
next_tvb = tvb_new_subset_length(tvb, offset, diag_len);
call_dissector_only(sip_diag_handle, next_tvb, pinfo, tree, NULL);
}
}
/* From section 4.1 of RFC 2543:
*
* Request-Line = Method SP Request-URI SP SIP-Version CRLF
*
* From section 5.1 of RFC 2543:
*
* Status-Line = SIP-version SP Status-Code SP Reason-Phrase CRLF
*
* From section 7.1 of RFC 3261:
*
* Unlike HTTP, SIP treats the version number as a literal string.
* In practice, this should make no difference.
*/
static line_type_t
sip_parse_line(tvbuff_t *tvb, int offset, gint linelen, guint *token_1_lenp)
{
gint space_offset;
gint token_1_start;
guint token_1_len;
gint token_2_start;
guint token_2_len;
gint token_3_start;
guint token_3_len;
gint colon_pos;
token_1_start = offset;
space_offset = tvb_find_guint8(tvb, token_1_start, -1, ' ');
if ((space_offset == -1) || (space_offset == token_1_start)) {
/*
* Either there's no space in the line (which means
* the line is empty or doesn't have a token followed
* by a space; neither is valid for a request or status), or
* the first character in the line is a space (meaning
* the method is empty, which isn't valid for a request,
* or the SIP version is empty, which isn't valid for a
* status).
*/
return OTHER_LINE;
}
token_1_len = space_offset - token_1_start;
token_2_start = space_offset + 1;
space_offset = tvb_find_guint8(tvb, token_2_start, -1, ' ');
if (space_offset == -1) {
/*
* There's no space after the second token, so we don't
* have a third token.
*/
return OTHER_LINE;
}
token_2_len = space_offset - token_2_start;
token_3_start = space_offset + 1;
token_3_len = token_1_start + linelen - token_3_start;
*token_1_lenp = token_1_len;
/*
* Is the first token a version string?
*/
if ( (strict_sip_version && (
token_1_len == SIP2_HDR_LEN
&& tvb_strneql(tvb, token_1_start, SIP2_HDR, SIP2_HDR_LEN) == 0)
) || (! strict_sip_version && (
tvb_strncaseeql(tvb, token_1_start, "SIP/", 4) == 0)
)) {
/*
* Yes, so this is either a Status-Line or something
* else other than a Request-Line. To be a Status-Line,
* the second token must be a 3-digit number.
*/
if (token_2_len != 3) {
/*
* We don't have 3-character status code.
*/
return OTHER_LINE;
}
if (!g_ascii_isdigit(tvb_get_guint8(tvb, token_2_start)) ||
!g_ascii_isdigit(tvb_get_guint8(tvb, token_2_start + 1)) ||
!g_ascii_isdigit(tvb_get_guint8(tvb, token_2_start + 2))) {
/*
* 3 characters yes, 3 digits no.
*/
return OTHER_LINE;
}
return STATUS_LINE;
} else {
/*
* No, so this is either a Request-Line or something
* other than a Status-Line. To be a Request-Line, the
* second token must be a URI and the third token must
* be a version string.
*/
if (token_2_len < 3) {
/*
* We don't have a URI consisting of at least 3
* characters.
*/
return OTHER_LINE;
}
colon_pos = tvb_find_guint8(tvb, token_2_start + 1, -1, ':');
if (colon_pos == -1) {
/*
* There is no colon after the method, so the URI
* doesn't have a colon in it, so it's not valid.
*/
return OTHER_LINE;
}
if (colon_pos >= token_3_start) {
/*
* The colon is in the version string, not the URI.
*/
return OTHER_LINE;
}
/* XXX - Check for a proper URI prefix? */
if ( (strict_sip_version && (
token_3_len != SIP2_HDR_LEN
|| tvb_strneql(tvb, token_3_start, SIP2_HDR, SIP2_HDR_LEN) == -1)
) || (! strict_sip_version && (
tvb_strncaseeql(tvb, token_3_start, "SIP/", 4) == -1)
)) {
/*
* The version string isn't an SIP version 2.0 version
* string.
*/
return OTHER_LINE;
}
return REQUEST_LINE;
}
}
static gboolean sip_is_known_request(tvbuff_t *tvb, int meth_offset,
guint meth_len, guint *meth_idx)
{
guint i;
gchar *meth_name;
meth_name = tvb_get_string_enc(wmem_packet_scope(), tvb, meth_offset, meth_len, ENC_UTF_8|ENC_NA);
for (i = 1; i < array_length(sip_methods); i++) {
if (meth_len == strlen(sip_methods[i]) &&
strncmp(meth_name, sip_methods[i], meth_len) == 0)
{
*meth_idx = i;
return TRUE;
}
}
return FALSE;
}
/*
* Returns index of method in sip_headers
* Header namne should be in lower case
*/
static gint sip_is_known_sip_header(gchar *header_name, guint header_len)
{
guint pos;
/* Compact name is one character long */
if(header_len>1){
pos = GPOINTER_TO_UINT(g_hash_table_lookup(sip_headers_hash, header_name));
if (pos!=0)
return pos;
}
/* Look for compact name match */
for (pos = 1; pos < array_length(sip_headers); pos++) {
if (sip_headers[pos].compact_name != NULL &&
header_len == strlen(sip_headers[pos].compact_name) &&
g_ascii_strncasecmp(header_name, sip_headers[pos].compact_name, header_len) == 0)
return pos;
}
return -1;
}
/*
* Display the entire message as raw text.
*/
static void
tvb_raw_text_add(tvbuff_t *tvb, int offset, int length, int body_offset, packet_info* pinfo, proto_tree *tree)
{
proto_tree *raw_tree;
proto_item *ti;
int next_offset, linelen, end_offset;
char *str;
tvbuff_t* body_tvb = NULL;
ti = proto_tree_add_item(tree, proto_raw_sip, tvb, offset, length, ENC_NA);
raw_tree = proto_item_add_subtree(ti, ett_raw_text);
end_offset = offset + length;
if (body_offset < end_offset
&& global_sip_raw_text_body_default_encoding != IANA_CS_UTF_8
/* UTF-8 compatible with ASCII */
&& global_sip_raw_text_body_default_encoding != IANA_CS_US_ASCII)
{
/* Create body tvb with new character encoding */
guint32 iana_charset_id = global_sip_raw_text_body_default_encoding;
guint ws_encoding_id = mibenum_charset_to_encoding((guint)iana_charset_id);
if (ws_encoding_id != (ENC_NA | ENC_ASCII) && ws_encoding_id != (ENC_NA | ENC_UTF_8)) {
/* Encoding body with the new encoding */
gchar* encoding_name = val_to_str_ext_wmem(pinfo->pool, iana_charset_id,
&mibenum_vals_character_sets_ext, "UNKNOWN");
const guint8* data_str = tvb_get_string_enc(wmem_packet_scope(), tvb, body_offset,
end_offset - body_offset, ws_encoding_id);
size_t l = strlen(data_str);
body_tvb = tvb_new_child_real_data(tvb, data_str, (guint)l, (gint)l);
add_new_data_source(pinfo, body_tvb, wmem_strdup_printf(pinfo->pool, "Decoded %s text", encoding_name));
}
}
/* Display the headers of SIP message as raw text */
while (offset < body_offset) {
tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
linelen = next_offset - offset;
if (raw_tree) {
if (global_sip_raw_text_without_crlf)
str = tvb_format_text_wsp(wmem_packet_scope(), tvb, offset, linelen);
else
str = tvb_format_text(wmem_packet_scope(), tvb, offset, linelen);
proto_tree_add_string_format(raw_tree, hf_sip_raw_line, tvb, offset, linelen,
str,
"%s",
str);
}
offset = next_offset;
}
DISSECTOR_ASSERT_HINT(offset == body_offset, "The offset must be equal to body_offset before dissect body as raw text.");
if (body_offset < end_offset) {
/* Dissect the body of SIP message as raw text */
if (body_tvb) {
offset = 0;
end_offset = tvb_captured_length_remaining(body_tvb, 0);
} else {
body_tvb = tvb; /* reuse old offset and end_offset */
}
while (offset < end_offset) {
tvb_find_line_end(body_tvb, offset, -1, &next_offset, FALSE);
linelen = next_offset - offset;
if (raw_tree) {
if (global_sip_raw_text_without_crlf)
str = tvb_format_text_wsp(wmem_packet_scope(), body_tvb, offset, linelen);
else
str = tvb_format_text(wmem_packet_scope(), body_tvb, offset, linelen);
proto_tree_add_string_format(raw_tree, hf_sip_raw_line, body_tvb, offset,
linelen, str, "%s", str);
}
offset = next_offset;
}
}
}
/* Check to see if this packet is a resent request. Return value is the frame number
of the original frame this packet seems to be resending (0 = no resend). */
guint sip_is_packet_resend(packet_info *pinfo,
const char *cseq_method,
gchar *call_id,
guchar cseq_number_set,
guint32 cseq_number, line_type_t line_type)
{
guint32 cseq_to_compare = 0;
sip_hash_key key;
sip_hash_key *p_key = 0;
sip_hash_value *p_val = 0;
sip_frame_result_value *sip_frame_result = NULL;
guint result = 0;
/* Only consider retransmission of UDP packets */
if (pinfo->ptype != PT_UDP)
{
return 0;
}
/* Don't consider packets that appear to be resent only because
they are e.g. returned in ICMP unreachable messages. */
if (pinfo->flags.in_error_pkt)
{
return 0;
}
/* A broken packet may have no cseq number set. Don't consider it as
a resend */
if (!cseq_number_set)
{
return 0;
}
/* Return any answer stored from previous dissection */
if (pinfo->fd->visited)
{
sip_frame_result = (sip_frame_result_value*)p_get_proto_data(wmem_file_scope(), pinfo, proto_sip, pinfo->curr_layer_num);
if (sip_frame_result != NULL)
{
return sip_frame_result->original_frame_num;
}
else
{
return 0;
}
}
/* No packet entry found, consult global hash table */
/* Prepare the key */
(void) g_strlcpy(key.call_id, call_id, MAX_CALL_ID_SIZE);
/* We're only using these addresses locally (for the hash lookup) so
* there is no need to make a (g_malloc'd) copy of them.
*/
set_address(&key.dest_address, pinfo->net_dst.type, pinfo->net_dst.len,
pinfo->net_dst.data);
set_address(&key.source_address, pinfo->net_src.type,
pinfo->net_src.len, pinfo->net_src.data);
key.dest_port = pinfo->destport;
if (sip_retrans_the_same_sport) {
key.source_port = pinfo->srcport;
} else {
key.source_port = MAGIC_SOURCE_PORT;
}
/* Do the lookup */
p_val = (sip_hash_value*)g_hash_table_lookup(sip_hash, &key);
if (p_val)
{
/* Table entry found, we'll use its value for comparison */
cseq_to_compare = p_val->cseq;
/* First time through, must update value with current details if
cseq number has changed */
if (cseq_number != p_val->cseq)
{
p_val->cseq = cseq_number;
p_val->method = wmem_strdup(wmem_file_scope(), cseq_method);
p_val->transaction_state = nothing_seen;
p_val->frame_number = 0;
if (line_type == REQUEST_LINE)
{
p_val->request_time = pinfo->abs_ts;
}
}
}
else
{
/* Need to create a new table entry */
/* Allocate a new key and value */
p_key = wmem_new(wmem_file_scope(), sip_hash_key);
p_val = wmem_new0(wmem_file_scope(), sip_hash_value);
/* Fill in key and value details */
snprintf(p_key->call_id, MAX_CALL_ID_SIZE, "%s", call_id);
copy_address_wmem(wmem_file_scope(), &(p_key->dest_address), &pinfo->net_dst);
copy_address_wmem(wmem_file_scope(), &(p_key->source_address), &pinfo->net_src);
p_key->dest_port = pinfo->destport;
if (sip_retrans_the_same_sport) {
p_key->source_port = pinfo->srcport;
} else {
p_key->source_port = MAGIC_SOURCE_PORT;
}
p_val->cseq = cseq_number;
p_val->method = wmem_strdup(wmem_file_scope(), cseq_method);
p_val->transaction_state = nothing_seen;
if (line_type == REQUEST_LINE)
{
p_val->request_time = pinfo->abs_ts;
}
/* Add entry */
g_hash_table_insert(sip_hash, p_key, p_val);
/* Assume have seen no cseq yet */
cseq_to_compare = 0;
}
/******************************************/
/* Is it a resend??? */
/* Does this look like a resent request (discount ACK, CANCEL, or a
different method from the original one) ? */
if ((line_type == REQUEST_LINE) && (cseq_number == cseq_to_compare) &&
(p_val->transaction_state == request_seen) &&
(strcmp(cseq_method, p_val->method) == 0) &&
(strcmp(cseq_method, "ACK") != 0) &&
(strcmp(cseq_method, "CANCEL") != 0))
{
result = p_val->frame_number;
}
/* Does this look like a resent final response ? */
if ((line_type == STATUS_LINE) && (cseq_number == cseq_to_compare) &&
(p_val->transaction_state == final_response_seen) &&
(strcmp(cseq_method, p_val->method) == 0) &&
(stat_info->response_code >= 200) &&
(stat_info->response_code == p_val->response_code))
{
result = p_val->frame_number;
}
/* Update state for this entry */
p_val->cseq = cseq_number;
switch (line_type)
{
case REQUEST_LINE:
p_val->transaction_state = request_seen;
if (!result)
{
/* This frame is the original request */
p_val->frame_number = pinfo->num;
p_val->request_time = pinfo->abs_ts;
}
break;
case STATUS_LINE:
if (stat_info->response_code >= 200)
{
p_val->response_code = stat_info->response_code;
p_val->transaction_state = final_response_seen;
if (!result)
{
/* This frame is the original response */
p_val->frame_number = pinfo->num;
}
}
else
{
p_val->transaction_state = provisional_response_seen;
}
break;
default:
break;
}
sip_frame_result = (sip_frame_result_value *)p_get_proto_data(wmem_file_scope(), pinfo, proto_sip, pinfo->curr_layer_num);
if (sip_frame_result == NULL)
{
sip_frame_result = wmem_new0(wmem_file_scope(), sip_frame_result_value);
p_add_proto_data(wmem_file_scope(), pinfo, proto_sip, pinfo->curr_layer_num, sip_frame_result);
}
/* Store return value with this packet */
sip_frame_result->original_frame_num = result;
return result;
}
/* Check to see if this packet is a resent request. Return value is the frame number
of the original frame this packet seems to be resending (0 = no resend). */
guint sip_find_request(packet_info *pinfo,
const char *cseq_method,
gchar *call_id,
guchar cseq_number_set,
guint32 cseq_number,
guint32 *response_time)
{
guint32 cseq_to_compare = 0;
sip_hash_key key;
sip_hash_value *p_val = 0;
sip_frame_result_value *sip_frame_result = NULL;
guint result = 0;
gint seconds_between_packets;
gint nseconds_between_packets;
/* Only consider UDP */
if (pinfo->ptype != PT_UDP)
{
return 0;
}
/* Ignore error (usually ICMP) frames */
if (pinfo->flags.in_error_pkt)
{
return 0;
}
/* A broken packet may have no cseq number set. Ignore. */
if (!cseq_number_set)
{
return 0;
}
/* Return any answer stored from previous dissection */
if (pinfo->fd->visited)
{
sip_frame_result = (sip_frame_result_value*)p_get_proto_data(wmem_file_scope(), pinfo, proto_sip, pinfo->curr_layer_num);
if (sip_frame_result != NULL)
{
*response_time = sip_frame_result->response_time;
return sip_frame_result->response_request_frame_num;
}
else
{
return 0;
}
}
/* No packet entry found, consult global hash table */
/* Prepare the key */
(void) g_strlcpy(key.call_id, call_id, MAX_CALL_ID_SIZE);
/* Looking for matching request, so reverse addresses for this lookup */
set_address(&key.dest_address, pinfo->net_src.type, pinfo->net_src.len,
pinfo->net_src.data);
set_address(&key.source_address, pinfo->net_dst.type, pinfo->net_dst.len,
pinfo->net_dst.data);
key.dest_port = pinfo->srcport;
key.source_port = pinfo->destport;
/* Do the lookup */
p_val = (sip_hash_value*)g_hash_table_lookup(sip_hash, &key);
if (p_val)
{
/* Table entry found, we'll use its value for comparison */
cseq_to_compare = p_val->cseq;
}
else
{
/* We don't have the request */
return 0;
}
/**************************************************/
/* Is it a response to a request that we've seen? */
if ((cseq_number == cseq_to_compare) &&
(p_val->transaction_state == request_seen) &&
(strcmp(cseq_method, p_val->method) == 0))
{
result = p_val->frame_number;
}
/* Store return value with this packet */
sip_frame_result = (sip_frame_result_value *)p_get_proto_data(wmem_file_scope(), pinfo, proto_sip, pinfo->curr_layer_num);
if (sip_frame_result == NULL)
{
/* Allocate and set all values to zero */
sip_frame_result = wmem_new0(wmem_file_scope(), sip_frame_result_value);
p_add_proto_data(wmem_file_scope(), pinfo, proto_sip, pinfo->curr_layer_num, sip_frame_result);
}
sip_frame_result->response_request_frame_num = result;
/* Work out response time */
seconds_between_packets = (gint)
(pinfo->abs_ts.secs - p_val->request_time.secs);
nseconds_between_packets =
pinfo->abs_ts.nsecs - p_val->request_time.nsecs;
sip_frame_result->response_time = (seconds_between_packets*1000) +
(nseconds_between_packets / 1000000);
*response_time = sip_frame_result->response_time;
return result;
}
/*
* Find the initial INVITE to calculate the total setup time
*/
guint sip_find_invite(packet_info *pinfo,
const char *cseq_method _U_,
gchar *call_id,
guchar cseq_number_set,
guint32 cseq_number _U_,
guint32 *response_time)
{
#if 0
guint32 cseq_to_compare = 0;
#endif
sip_hash_key key;
sip_hash_value *p_val = 0;
sip_frame_result_value *sip_frame_result = NULL;
guint result = 0;
gint seconds_between_packets;
gint nseconds_between_packets;
/* Only consider UDP */
if (pinfo->ptype != PT_UDP)
{
return 0;
}
/* Ignore error (usually ICMP) frames */
if (pinfo->flags.in_error_pkt)
{
return 0;
}
/* A broken packet may have no cseq number set. Ignore. */
if (!cseq_number_set)
{
return 0;
}
/* Return any answer stored from previous dissection */
if (pinfo->fd->visited)
{
sip_frame_result = (sip_frame_result_value*)p_get_proto_data(wmem_file_scope(), pinfo, proto_sip, pinfo->curr_layer_num);
if (sip_frame_result != NULL)
{
*response_time = sip_frame_result->response_time;
return sip_frame_result->response_request_frame_num;
}
else
{
return 0;
}
}
/* No packet entry found, consult global hash table */
/* Prepare the key */
(void) g_strlcpy(key.call_id, call_id, MAX_CALL_ID_SIZE);
/* Looking for matching INVITE */
set_address(&key.dest_address, pinfo->net_dst.type, pinfo->net_dst.len,
pinfo->net_dst.data);
set_address(&key.source_address, pinfo->net_src.type, pinfo->net_src.len,
pinfo->net_src.data);
key.dest_port = pinfo->destport;
key.source_port = pinfo->srcport;
/* Do the lookup */
p_val = (sip_hash_value*)g_hash_table_lookup(sip_hash, &key);
if (p_val)
{
#if 0
/* Table entry found, we'll use its value for comparison */
cseq_to_compare = p_val->cseq;
#endif
}
else
{
/* We don't have the request */
return 0;
}
/**************************************************/
/* Is it a response to a request that we've seen? */
#if 0
if ((cseq_number == cseq_to_compare) &&
(p_val->transaction_state == request_seen) &&
(strcmp(cseq_method, p_val->method) == 0))
{
result = p_val->frame_number;
}
#endif
result = p_val->frame_number;
/* Store return value with this packet */
sip_frame_result = (sip_frame_result_value *)p_get_proto_data(wmem_file_scope(), pinfo, proto_sip, pinfo->curr_layer_num);
if (sip_frame_result == NULL)
{
/* Allocate and set all values to zero */
sip_frame_result = wmem_new0(wmem_file_scope(), sip_frame_result_value);
p_add_proto_data(wmem_file_scope(), pinfo, proto_sip, pinfo->curr_layer_num, sip_frame_result);
}
sip_frame_result->response_request_frame_num = result;
/* Work out response time */
seconds_between_packets = (gint)
(pinfo->abs_ts.secs - p_val->request_time.secs);
nseconds_between_packets =
pinfo->abs_ts.nsecs - p_val->request_time.nsecs;
sip_frame_result->response_time = (seconds_between_packets*1000) +
(nseconds_between_packets / 1000000);
*response_time = sip_frame_result->response_time;
return result;
}
static gboolean sip_validate_authorization(sip_authorization_t *authorization_info, gchar *password) {
gchar ha1[33] = {0};
gchar ha2[33] = {0};
gchar response[33] = {0};
gcry_md_hd_t md5_handle;
if ( (authorization_info->qop == NULL) ||
(authorization_info->username == NULL) ||
(authorization_info->realm == NULL) ||
(authorization_info->method == NULL) ||
(authorization_info->uri == NULL) ||
(authorization_info->nonce == NULL) ) {
return TRUE; /* If no qop, discard */
}
if (strcmp(authorization_info->qop, "auth") ||
(authorization_info->nonce_count == NULL) ||
(authorization_info->cnonce == NULL) ||
(authorization_info->response == NULL) ||
(password == NULL)) {
return TRUE; /* Obsolete or not enough information, discard */
}
if (gcry_md_open(&md5_handle, GCRY_MD_MD5, 0)) {
return FALSE;
}
gcry_md_write(md5_handle, authorization_info->username, strlen(authorization_info->username));
gcry_md_putc(md5_handle, ':');
gcry_md_write(md5_handle, authorization_info->realm, strlen(authorization_info->realm));
gcry_md_putc(md5_handle, ':');
gcry_md_write(md5_handle, password, strlen(password));
/* Array is zeroed out so there is always a \0 at index 32 for string termination */
bytes_to_hexstr(ha1, gcry_md_read(md5_handle, 0), HASH_MD5_LENGTH);
gcry_md_reset(md5_handle);
gcry_md_write(md5_handle, authorization_info->method, strlen(authorization_info->method));
gcry_md_putc(md5_handle, ':');
gcry_md_write(md5_handle, authorization_info->uri, strlen(authorization_info->uri));
/* Array is zeroed out so there is always a \0 at index 32 for string termination */
bytes_to_hexstr(ha2, gcry_md_read(md5_handle, 0), HASH_MD5_LENGTH);
gcry_md_reset(md5_handle);
gcry_md_write(md5_handle, ha1, strlen(ha1));
gcry_md_putc(md5_handle, ':');
gcry_md_write(md5_handle, authorization_info->nonce, strlen(authorization_info->nonce));
gcry_md_putc(md5_handle, ':');
gcry_md_write(md5_handle, authorization_info->nonce_count, strlen(authorization_info->nonce_count));
gcry_md_putc(md5_handle, ':');
gcry_md_write(md5_handle, authorization_info->cnonce, strlen(authorization_info->cnonce));
gcry_md_putc(md5_handle, ':');
gcry_md_write(md5_handle, authorization_info->qop, strlen(authorization_info->qop));
gcry_md_putc(md5_handle, ':');
gcry_md_write(md5_handle, ha2, strlen(ha2));
/* Array is zeroed out so there is always a \0 at index 32 for string termination */
bytes_to_hexstr(response, gcry_md_read(md5_handle, 0), HASH_MD5_LENGTH);
gcry_md_close(md5_handle);
if (!strncmp(response, authorization_info->response, 32)) {
return TRUE;
}
return FALSE;
}
/* TAP STAT INFO */
/*
* Much of this is from ui/gtk/sip_stat.c:
* sip_stat 2004 Martin Mathieson
*/
/* TODO: extra codes to be added from SIP extensions?
* https://www.iana.org/assignments/sip-parameters/sip-parameters.xhtml#sip-parameters-6
*/
const value_string sip_response_code_vals[] = {
{ 999, "Unknown response"}, /* Must be first */
{ 100, "Trying"},
{ 180, "Ringing"},
{ 181, "Call Is Being Forwarded"},
{ 182, "Queued"},
{ 183, "Session Progress"},
{ 199, "Informational - Others" },
{ 200, "OK"},
{ 202, "Accepted"},
{ 204, "No Notification"},
{ 299, "Success - Others"}, /* used to keep track of other Success packets */
{ 300, "Multiple Choices"},
{ 301, "Moved Permanently"},
{ 302, "Moved Temporarily"},
{ 305, "Use Proxy"},
{ 380, "Alternative Service"},
{ 399, "Redirection - Others"},
{ 400, "Bad Request"},
{ 401, "Unauthorized"},
{ 402, "Payment Required"},
{ 403, "Forbidden"},
{ 404, "Not Found"},
{ 405, "Method Not Allowed"},
{ 406, "Not Acceptable"},
{ 407, "Proxy Authentication Required"},
{ 408, "Request Timeout"},
{ 410, "Gone"},
{ 412, "Conditional Request Failed"},
{ 413, "Request Entity Too Large"},
{ 414, "Request-URI Too Long"},
{ 415, "Unsupported Media Type"},
{ 416, "Unsupported URI Scheme"},
{ 420, "Bad Extension"},
{ 421, "Extension Required"},
{ 422, "Session Timer Too Small"},
{ 423, "Interval Too Brief"},
{ 428, "Use Identity Header"},
{ 429, "Provide Referrer Identity"},
{ 430, "Flow Failed"},
{ 433, "Anonymity Disallowed"},
{ 436, "Bad Identity-Info"},
{ 437, "Unsupported Certificate"},
{ 438, "Invalid Identity Header"},
{ 439, "First Hop Lacks Outbound Support"},
{ 440, "Max-Breadth Exceeded"},
{ 470, "Consent Needed"},
{ 480, "Temporarily Unavailable"},
{ 481, "Call/Transaction Does Not Exist"},
{ 482, "Loop Detected"},
{ 483, "Too Many Hops"},
{ 484, "Address Incomplete"},
{ 485, "Ambiguous"},
{ 486, "Busy Here"},
{ 487, "Request Terminated"},
{ 488, "Not Acceptable Here"},
{ 489, "Bad Event"},
{ 491, "Request Pending"},
{ 493, "Undecipherable"},
{ 494, "Security Agreement Required"},
{ 499, "Client Error - Others"},
{ 500, "Server Internal Error"},
{ 501, "Not Implemented"},
{ 502, "Bad Gateway"},
{ 503, "Service Unavailable"},
{ 504, "Server Time-out"},
{ 505, "Version Not Supported"},
{ 513, "Message Too Large"},
{ 599, "Server Error - Others"},
{ 600, "Busy Everywhere"},
{ 603, "Decline"},
{ 604, "Does Not Exist Anywhere"},
{ 606, "Not Acceptable"},
{ 607, "Unwanted"},
{ 608, "Rejected"},
{ 699, "Global Failure - Others"},
{ 0, NULL}
};
#define RESPONSE_CODE_MIN 100
#define RESPONSE_CODE_MAX 699
typedef enum
{
REQ_RESP_METHOD_COLUMN,
COUNT_COLUMN,
RESENT_COLUMN,
MIN_SETUP_COLUMN,
AVG_SETUP_COLUMN,
MAX_SETUP_COLUMN
} sip_stat_columns;
static stat_tap_table_item sip_stat_fields[] = {
{TABLE_ITEM_STRING, TAP_ALIGN_LEFT, "Request Method / Response Code", "%-25s"},
{TABLE_ITEM_UINT, TAP_ALIGN_RIGHT, "Count", "%d"},
{TABLE_ITEM_UINT, TAP_ALIGN_RIGHT, "Resent", "%d"},
{TABLE_ITEM_FLOAT, TAP_ALIGN_RIGHT, "Min Setup (s)", "%8.2f"},
{TABLE_ITEM_FLOAT, TAP_ALIGN_RIGHT, "Avg Setup (s)", "%8.2f"},
{TABLE_ITEM_FLOAT, TAP_ALIGN_RIGHT, "Max Setup (s)", "%8.2f"},
};
static const char *req_table_name = "SIP Requests";
static const char *resp_table_name = "SIP Responses";
static void sip_stat_init(stat_tap_table_ui* new_stat)
{
/* XXX Should we have a single request + response table instead? */
int num_fields = sizeof(sip_stat_fields)/sizeof(stat_tap_table_item);
stat_tap_table *req_table;
stat_tap_table *resp_table;
stat_tap_table_item_type items[sizeof(sip_stat_fields)/sizeof(stat_tap_table_item)];
guint i;
// These values are fixed for all entries.
items[REQ_RESP_METHOD_COLUMN].type = TABLE_ITEM_STRING;
items[COUNT_COLUMN].type = TABLE_ITEM_UINT;
items[COUNT_COLUMN].user_data.uint_value = 0;
items[COUNT_COLUMN].value.uint_value = 0;
items[RESENT_COLUMN].type = TABLE_ITEM_UINT;
items[RESENT_COLUMN].value.uint_value = 0;
items[MIN_SETUP_COLUMN].type = TABLE_ITEM_FLOAT;
items[MIN_SETUP_COLUMN].user_data.uint_value = 0;
items[MIN_SETUP_COLUMN].value.float_value = 0.0f;
items[AVG_SETUP_COLUMN].type = TABLE_ITEM_FLOAT;
items[AVG_SETUP_COLUMN].user_data.float_value = 0.0f;
items[AVG_SETUP_COLUMN].value.float_value = 0.0f;
items[MAX_SETUP_COLUMN].type = TABLE_ITEM_FLOAT;
items[MAX_SETUP_COLUMN].value.float_value = 0.0f;
req_table = stat_tap_find_table(new_stat, req_table_name);
if (req_table) {
if (new_stat->stat_tap_reset_table_cb)
new_stat->stat_tap_reset_table_cb(req_table);
}
else {
req_table = stat_tap_init_table(req_table_name, num_fields, 0, NULL);
stat_tap_add_table(new_stat, req_table);
// For req_table, first column value is method.
for (i = 1; i < array_length(sip_methods); i++) {
items[REQ_RESP_METHOD_COLUMN].value.string_value = g_strdup(sip_methods[i]);
stat_tap_init_table_row(req_table, i-1, num_fields, items);
}
}
resp_table = stat_tap_find_table(new_stat, resp_table_name);
if (resp_table) {
if (new_stat->stat_tap_reset_table_cb)
new_stat->stat_tap_reset_table_cb(resp_table);
}
else {
resp_table = stat_tap_init_table(resp_table_name, num_fields, 0, NULL);
stat_tap_add_table(new_stat, resp_table);
// For responses entries, first column gets code and description.
for (i = 1; sip_response_code_vals[i].strptr; i++) {
unsigned response_code = sip_response_code_vals[i].value;
items[REQ_RESP_METHOD_COLUMN].value.string_value =
ws_strdup_printf("%u %s", response_code, sip_response_code_vals[i].strptr);
items[REQ_RESP_METHOD_COLUMN].user_data.uint_value = response_code;
stat_tap_init_table_row(resp_table, i-1, num_fields, items);
}
}
}
static tap_packet_status
sip_stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *siv_ptr, tap_flags_t flags _U_)
{
stat_data_t* stat_data = (stat_data_t*) tapdata;
const sip_info_value_t *info_value = (const sip_info_value_t *) siv_ptr;
stat_tap_table *cur_table = NULL;
guint cur_row = 0; /* 0 = Unknown for both tables */
if (info_value->request_method && info_value->response_code < 1) {
/* Request table */
stat_tap_table *req_table = stat_tap_find_table(stat_data->stat_tap_data, req_table_name);
stat_tap_table_item_type *item_data;
guint element;
cur_table = req_table;
for (element = 0; element < req_table->num_elements; element++) {
item_data = stat_tap_get_field_data(req_table, element, REQ_RESP_METHOD_COLUMN);
if (g_ascii_strcasecmp(info_value->request_method, item_data->value.string_value) == 0) {
cur_row = element;
break;
}
}
} else if (info_value->response_code > 0) {
/* Response table */
stat_tap_table *resp_table = stat_tap_find_table(stat_data->stat_tap_data, resp_table_name);
guint response_code = info_value->response_code;
stat_tap_table_item_type *item_data;
guint element;
cur_table = resp_table;
if (response_code < RESPONSE_CODE_MIN || response_code > RESPONSE_CODE_MAX) {
response_code = 999;
} else if (!try_val_to_str(response_code, sip_response_code_vals)) {
response_code = ((response_code / 100) * 100) + 99;
}
for (element = 0; element < resp_table->num_elements; element++) {
item_data = stat_tap_get_field_data(resp_table, element, REQ_RESP_METHOD_COLUMN);
if (item_data->user_data.uint_value == response_code) {
cur_row = element;
break;
}
}
} else {
return TAP_PACKET_DONT_REDRAW;
}
if (cur_table) {
stat_tap_table_item_type *item_data;
item_data = stat_tap_get_field_data(cur_table, cur_row, COUNT_COLUMN);
item_data->value.uint_value++;
stat_tap_set_field_data(cur_table, cur_row, COUNT_COLUMN, item_data);
if (info_value->resend) {
item_data = stat_tap_get_field_data(cur_table, cur_row, RESENT_COLUMN);
item_data->value.uint_value++;
stat_tap_set_field_data(cur_table, cur_row, RESENT_COLUMN, item_data);
}
if (info_value->setup_time > 0) {
stat_tap_table_item_type *min_item_data = stat_tap_get_field_data(cur_table, cur_row, MIN_SETUP_COLUMN);
stat_tap_table_item_type *avg_item_data = stat_tap_get_field_data(cur_table, cur_row, AVG_SETUP_COLUMN);
stat_tap_table_item_type *max_item_data = stat_tap_get_field_data(cur_table, cur_row, MAX_SETUP_COLUMN);
double setup_time = (double) info_value->setup_time / 1000;
unsigned count;
min_item_data->user_data.uint_value++; /* We store the setup count in MIN_SETUP_COLUMN */
count = min_item_data->user_data.uint_value;
avg_item_data->user_data.float_value += setup_time; /* We store the total setup time in AVG_SETUP_COLUMN */
if (count <= 1) {
min_item_data->value.float_value = setup_time;
avg_item_data->value.float_value = setup_time;
max_item_data->value.float_value = setup_time;
} else {
if (setup_time < min_item_data->value.float_value) {
min_item_data->value.float_value = setup_time;
}
avg_item_data->value.float_value = avg_item_data->user_data.float_value / count;
if (setup_time > max_item_data->value.float_value) {
max_item_data->value.float_value = setup_time;
}
}
stat_tap_set_field_data(cur_table, cur_row, MIN_SETUP_COLUMN, min_item_data);
stat_tap_set_field_data(cur_table, cur_row, AVG_SETUP_COLUMN, avg_item_data);
stat_tap_set_field_data(cur_table, cur_row, MAX_SETUP_COLUMN, max_item_data);
}
}
return TAP_PACKET_REDRAW;
}
static void
sip_stat_reset(stat_tap_table* table)
{
guint element;
stat_tap_table_item_type* item_data;
for (element = 0; element < table->num_elements; element++)
{
item_data = stat_tap_get_field_data(table, element, COUNT_COLUMN);
item_data->user_data.uint_value = 0;
item_data->value.uint_value = 0;
stat_tap_set_field_data(table, element, COUNT_COLUMN, item_data);
item_data = stat_tap_get_field_data(table, element, RESENT_COLUMN);
item_data->value.uint_value = 0;
stat_tap_set_field_data(table, element, RESENT_COLUMN, item_data);
item_data = stat_tap_get_field_data(table, element, MIN_SETUP_COLUMN);
item_data->user_data.uint_value = 0;
item_data->value.float_value = 0.0f;
stat_tap_set_field_data(table, element, MIN_SETUP_COLUMN, item_data);
item_data = stat_tap_get_field_data(table, element, AVG_SETUP_COLUMN);
item_data->user_data.float_value = 0.0f;
item_data->value.float_value = 0.0f;
stat_tap_set_field_data(table, element, AVG_SETUP_COLUMN, item_data);
item_data = stat_tap_get_field_data(table, element, MAX_SETUP_COLUMN);
item_data->value.float_value = 0.0f;
stat_tap_set_field_data(table, element, MAX_SETUP_COLUMN, item_data);
}
}
static void
sip_stat_free_table_item(stat_tap_table* table _U_, guint row _U_, guint column, stat_tap_table_item_type* field_data)
{
if (column != REQ_RESP_METHOD_COLUMN) return;
g_free((char*)field_data->value.string_value);
field_data->value.string_value = NULL;
}
static gchar *sip_follow_conv_filter(epan_dissect_t *edt, packet_info *pinfo _U_, guint *stream _U_, guint *sub_stream _U_)
{
gchar *filter = NULL;
/* Extract si.Call-ID from decoded tree in edt */
if (edt != NULL) {
int hfid = proto_registrar_get_id_byname("sip.Call-ID");
GPtrArray *gp = proto_find_first_finfo(edt->tree, hfid);
if (gp != NULL && gp->len != 0) {
filter = ws_strdup_printf("sip.Call-ID == \"%s\"", fvalue_get_string(((field_info *)gp->pdata[0])->value));
}
g_ptr_array_free(gp, TRUE);
} else {
filter = ws_strdup_printf("sip.Call-ID");
}
return filter;
}
static gchar *sip_follow_index_filter(guint stream _U_, guint sub_stream _U_)
{
return NULL;
}
static gchar *sip_follow_address_filter(address *src_addr _U_, address *dst_addr _U_, int src_port _U_, int dst_port _U_)
{
return NULL;
}
/* Register the protocol with Wireshark */
void proto_register_sip(void)
{
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_sip_msg_hdr,
{ "Message Header", "sip.msg_hdr",
FT_STRING, BASE_NONE, NULL, 0,
"Message Header in SIP message", HFILL }
},
{ &hf_sip_Method,
{ "Method", "sip.Method",
FT_STRING, BASE_NONE,NULL,0x0,
"SIP Method", HFILL }
},
{ &hf_Request_Line,
{ "Request-Line", "sip.Request-Line",
FT_STRING, BASE_NONE,NULL,0x0,
"SIP Request-Line", HFILL }
},
{ &hf_sip_ruri_display,
{ "Request-URI display info", "sip.r-uri.display.info",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: SIP R-URI Display Info", HFILL }
},
{ &hf_sip_ruri,
{ "Request-URI", "sip.r-uri",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: SIP R-URI", HFILL }
},
{ &hf_sip_ruri_user,
{ "Request-URI User Part", "sip.r-uri.user",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: SIP R-URI User", HFILL }
},
{ &hf_sip_ruri_host,
{ "Request-URI Host Part", "sip.r-uri.host",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: SIP R-URI Host", HFILL }
},
{ &hf_sip_ruri_port,
{ "Request-URI Host Port", "sip.r-uri.port",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: SIP R-URI Port", HFILL }
},
{ &hf_sip_ruri_param,
{ "Request URI parameter", "sip.r-uri.param",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_sip_Status_Code,
{ "Status-Code", "sip.Status-Code",
FT_UINT32, BASE_DEC,NULL,0x0,
"SIP Status Code", HFILL }
},
{ &hf_sip_Status_Line,
{ "Status-Line", "sip.Status-Line",
FT_STRING, BASE_NONE,NULL,0x0,
"SIP Status-Line", HFILL }
},
{ &hf_sip_display,
{ "SIP Display info", "sip.display.info",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Display info", HFILL }
},
{ &hf_sip_to_display,
{ "SIP to display info", "sip.to.display.info",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: To Display info", HFILL }
},
{ &hf_sip_to_addr,
{ "SIP to address", "sip.to.addr",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: To Address", HFILL }
},
{ &hf_sip_to_user,
{ "SIP to address User Part", "sip.to.user",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: To Address User", HFILL }
},
{ &hf_sip_to_host,
{ "SIP to address Host Part", "sip.to.host",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: To Address Host", HFILL }
},
{ &hf_sip_to_port,
{ "SIP to address Host Port", "sip.to.port",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: To Address Port", HFILL }
},
{ &hf_sip_to_param,
{ "SIP To URI parameter", "sip.to.param",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_sip_to_tag,
{ "SIP to tag", "sip.to.tag",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: to tag", HFILL }
},
{ &hf_sip_from_display,
{ "SIP from display info", "sip.from.display.info",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: From Display info", HFILL }
},
{ &hf_sip_from_addr,
{ "SIP from address", "sip.from.addr",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: From Address", HFILL }
},
{ &hf_sip_from_user,
{ "SIP from address User Part", "sip.from.user",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: From Address User", HFILL }
},
{ &hf_sip_from_host,
{ "SIP from address Host Part", "sip.from.host",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: From Address Host", HFILL }
},
{ &hf_sip_from_port,
{ "SIP from address Host Port", "sip.from.port",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: From Address Port", HFILL }
},
{ &hf_sip_from_param,
{ "SIP From URI parameter", "sip.from.param",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_sip_from_tag,
{ "SIP from tag", "sip.from.tag",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: from tag", HFILL }
},
{ &hf_sip_curi_display,
{ "SIP C-URI display info", "sip.contact.display.info",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: SIP C-URI Display info", HFILL }
},
{ &hf_sip_curi,
{ "Contact URI", "sip.contact.uri",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: SIP C-URI", HFILL }
},
{ &hf_sip_curi_user,
{ "Contact URI User Part", "sip.contact.user",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: SIP C-URI User", HFILL }
},
{ &hf_sip_curi_host,
{ "Contact URI Host Part", "sip.contact.host",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: SIP C-URI Host", HFILL }
},
{ &hf_sip_curi_port,
{ "Contact URI Host Port", "sip.contact.port",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: SIP C-URI Port", HFILL }
},
{ &hf_sip_curi_param,
{ "Contact URI parameter", "sip.contact.param",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_sip_route_display,
{ "Route display info", "sip.Route.display.info",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_route,
{ "Route URI", "sip.Route.uri",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_route_user,
{ "Route Userinfo", "sip.Route.user",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_route_host,
{ "Route Host Part", "sip.Route.host",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_route_port,
{ "Route Host Port", "sip.Route.port",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_route_param,
{ "Route URI parameter", "sip.Route.param",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_record_route_display,
{ "Record-Route display info", "sip.Record-Route.display.info",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_record_route,
{ "Record-Route URI", "sip.Record-Route.uri",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_record_route_user,
{ "Record-Route Userinfo", "sip.Record-Route.user",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_record_route_host,
{ "Record-Route Host Part", "sip.Record-Route.host",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_record_route_port,
{ "Record-Route Host Port", "sip.Record-Route.port",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_record_route_param,
{ "Record-Route URI parameter", "sip.Record-Route.param",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_service_route_display,
{ "Service-Route display info", "sip.Service-Route.display.info",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_service_route,
{ "Service-Route URI", "sip.Service-Route.uri",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_service_route_user,
{ "Service-Route Userinfo", "sip.Service-Route.user",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_service_route_host,
{ "Service-Route Host Part", "sip.Service-Route.host",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_service_route_port,
{ "Service-Route Host Port", "sip.Service-Route.port",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_service_route_param,
{ "Service-Route URI parameter", "sip.Service-Route.param",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_path_display,
{ "Path URI", "sip.Path.display.info",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_path,
{ "Path URI", "sip.Path.uri",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_path_user,
{ "Path Userinfo", "sip.Path.user",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_path_host,
{ "Path Host Part", "sip.Path.host",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_path_port,
{ "Path Host Port", "sip.Path.port",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_path_param,
{ "Path URI parameter", "sip.Path.param",
FT_STRING, BASE_NONE,NULL,0x0,NULL,HFILL }
},
{ &hf_sip_contact_param,
{ "Contact parameter", "sip.contact.parameter",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: one contact parameter", HFILL }
},
{ &hf_sip_tag,
{ "SIP tag", "sip.tag",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: tag", HFILL }
},
{ &hf_sip_pai_display,
{ "SIP PAI display info", "sip.pai.display.info",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: P-Asserted-Identity Display info", HFILL }
},
{ &hf_sip_pai_addr,
{ "SIP PAI Address", "sip.pai.addr",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: P-Asserted-Identity Address", HFILL }
},
{ &hf_sip_pai_user,
{ "SIP PAI User Part", "sip.pai.user",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: P-Asserted-Identity User", HFILL }
},
{ &hf_sip_pai_host,
{ "SIP PAI Host Part", "sip.pai.host",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: P-Asserted-Identity Host", HFILL }
},
{ &hf_sip_pai_port,
{ "SIP PAI Host Port", "sip.pai.port",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: P-Asserted-Identity Port", HFILL }
},
{ &hf_sip_pai_param,
{ "SIP PAI URI parameter", "sip.pai.param",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_sip_pmiss_display,
{ "SIP PMISS display info", "sip.pmiss.display.info",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: Permission Missing Display info", HFILL }
},
{ &hf_sip_pmiss_addr,
{ "SIP PMISS Address", "sip.pmiss.addr",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: Permission Missing Address", HFILL }
},
{ &hf_sip_pmiss_user,
{ "SIP PMISS User Part", "sip.pmiss.user",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: Permission Missing User", HFILL }
},
{ &hf_sip_pmiss_host,
{ "SIP PMISS Host Part", "sip.pmiss.host",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: Permission Missing Host", HFILL }
},
{ &hf_sip_pmiss_port,
{ "SIP PMISS Host Port", "sip.pmiss.port",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: Permission Missing Port", HFILL }
},
{ &hf_sip_pmiss_param,
{ "SIP PMISS URI parameter", "sip.pmiss.param",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_sip_ppi_display,
{ "SIP PPI display info", "sip.ppi.display.info",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: P-Preferred-Identity Display info", HFILL }
},
{ &hf_sip_ppi_addr,
{ "SIP PPI Address", "sip.ppi.addr",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: P-Preferred-Identity Address", HFILL }
},
{ &hf_sip_ppi_user,
{ "SIP PPI User Part", "sip.ppi.user",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: P-Preferred-Identity User", HFILL }
},
{ &hf_sip_ppi_host,
{ "SIP PPI Host Part", "sip.ppi.host",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: P-Preferred-Identity Host", HFILL }
},
{ &hf_sip_ppi_port,
{ "SIP PPI Host Port", "sip.ppi.port",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: P-Preferred-Identity Port", HFILL }
},
{ &hf_sip_ppi_param,
{ "SIP PPI URI parameter", "sip.ppi.param",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_sip_tc_display,
{ "SIP TC display info", "sip.tc.display.info",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: Trigger Consent Display info", HFILL }
},
{ &hf_sip_tc_addr,
{ "SIP TC Address", "sip.tc.addr",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: Trigger Consent Address", HFILL }
},
{ &hf_sip_tc_user,
{ "SIP TC User Part", "sip.tc.user",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: Trigger Consent User", HFILL }
},
{ &hf_sip_tc_host,
{ "SIP TC Host Part", "sip.tc.host",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: Trigger Consent Host", HFILL }
},
{ &hf_sip_tc_port,
{ "SIP TC Host Port", "sip.tc.port",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: Trigger Consent Port", HFILL }
},
{ &hf_sip_tc_param,
{ "SIP TC URI parameter", "sip.tc.param",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_sip_tc_turi,
{ "SIP TC Target URI", "sip.tc.target-uri",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: Trigger Consent Target URI", HFILL }
},
{ &hf_header_array[POS_ACCEPT],
{ "Accept", "sip.Accept",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Accept Header", HFILL }
},
{ &hf_header_array[POS_ACCEPT_CONTACT],
{ "Accept-Contact", "sip.Accept-Contact",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3841: Accept-Contact Header", HFILL }
},
{ &hf_header_array[POS_ACCEPT_ENCODING],
{ "Accept-Encoding", "sip.Accept-Encoding",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3841: Accept-Encoding Header", HFILL }
},
{ &hf_header_array[POS_ACCEPT_LANGUAGE],
{ "Accept-Language", "sip.Accept-Language",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Accept-Language Header", HFILL }
},
{ &hf_header_array[POS_ACCEPT_RESOURCE_PRIORITY],
{ "Accept-Resource-Priority", "sip.Accept-Resource-Priority",
FT_STRING, BASE_NONE,NULL,0x0,
"Draft: Accept-Resource-Priority Header", HFILL }
},
{ &hf_header_array[POS_ADDITIONAL_IDENTITY],
{ "Additional-Identity", "sip.Additional-Identity",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_ALERT_INFO],
{ "Alert-Info", "sip.Alert-Info",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Alert-Info Header", HFILL }
},
{ &hf_header_array[POS_ALLOW],
{ "Allow", "sip.Allow",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Allow Header", HFILL }
},
{ &hf_header_array[POS_ALLOW_EVENTS],
{ "Allow-Events", "sip.Allow-Events",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3265: Allow-Events Header", HFILL }
},
{ &hf_header_array[POS_ANSWER_MODE],
{ "Answer-Mode", "sip.Answer-Mode",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 5373: Answer-Mode Header", HFILL }
},
{ &hf_header_array[POS_ATTESTATION_INFO],
{ "Attestation-Info", "sip.Attestation-Info",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_AUTHENTICATION_INFO],
{ "Authentication-Info", "sip.Authentication-Info",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Authentication-Info Header", HFILL }
},
{ &hf_header_array[POS_AUTHORIZATION],
{ "Authorization", "sip.Authorization",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Authorization Header", HFILL }
},
{ &hf_header_array[POS_CALL_ID],
{ "Call-ID", "sip.Call-ID",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Call-ID Header", HFILL }
},
{ &hf_header_array[POS_CALL_INFO],
{ "Call-Info", "sip.Call-Info",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Call-Info Header", HFILL }
},
{ &hf_header_array[POS_CELLULAR_NETWORK_INFO],
{ "Cellular-Network-Info", "sip.Cellular-Network-Info",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_CONTACT],
{ "Contact", "sip.Contact",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Contact Header", HFILL }
},
{ &hf_header_array[POS_CONTENT_DISPOSITION],
{ "Content-Disposition", "sip.Content-Disposition",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Content-Disposition Header", HFILL }
},
{ &hf_header_array[POS_CONTENT_ENCODING],
{ "Content-Encoding", "sip.Content-Encoding",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Content-Encoding Header", HFILL }
},
{ &hf_header_array[POS_CONTENT_LANGUAGE],
{ "Content-Language", "sip.Content-Language",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Content-Language Header", HFILL }
},
{ &hf_header_array[POS_CONTENT_LENGTH],
{ "Content-Length", "sip.Content-Length",
FT_UINT32, BASE_DEC,NULL,0x0,
"RFC 3261: Content-Length Header", HFILL }
},
{ &hf_header_array[POS_CONTENT_TYPE],
{ "Content-Type", "sip.Content-Type",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Content-Type Header", HFILL }
},
{ &hf_header_array[POS_CSEQ],
{ "CSeq", "sip.CSeq",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: CSeq Header", HFILL }
},
{ &hf_header_array[POS_DATE],
{ "Date", "sip.Date",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Date Header", HFILL }
},
{ &hf_header_array[POS_ERROR_INFO],
{ "Error-Info", "sip.Error-Info",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Error-Info Header", HFILL }
},
{ &hf_header_array[POS_EVENT],
{ "Event", "sip.Event",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3265: Event Header", HFILL }
},
{ &hf_header_array[POS_EXPIRES],
{ "Expires", "sip.Expires",
FT_UINT32, BASE_DEC,NULL,0x0,
"RFC 3261: Expires Header", HFILL }
},
{ &hf_header_array[POS_FEATURE_CAPS],
{ "Feature-Caps", "sip.Feature-Caps",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 6809: Feature-Caps", HFILL }
},
{ &hf_header_array[POS_FLOW_TIMER],
{ "Flow-Timer", "sip.Flow-Timer",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 5626: Flow-Timer", HFILL }
},
{ &hf_header_array[POS_FROM],
{ "From", "sip.From",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: From Header", HFILL }
},
{ &hf_header_array[POS_GEOLOCATION],
{ "Geolocation", "sip.Geolocation",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_GEOLOCATION_ERROR],
{ "Geolocation-Error", "sip.Geolocation-Error",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_GEOLOCATION_ROUTING],
{ "Geolocation-Routing", "sip.Geolocation-Routing",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_HISTORY_INFO],
{ "History-Info", "sip.History-Info",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 4244: Request History Information", HFILL }
},
{ &hf_header_array[POS_IDENTITY],
{ "Identity", "sip.Identity",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 4474: Request Identity", HFILL }
},
{ &hf_header_array[POS_IDENTITY_INFO],
{ "Identity-info", "sip.Identity-info",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 4474: Request Identity-info", HFILL }
},
{ &hf_header_array[POS_INFO_PKG],
{ "Info-Package", "sip.Info-Package",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_IN_REPLY_TO],
{ "In-Reply-To", "sip.In-Reply-To",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: In-Reply-To Header", HFILL }
},
{ &hf_header_array[POS_JOIN],
{ "Join", "sip.Join",
FT_STRING, BASE_NONE,NULL,0x0,
"Draft: Join Header", HFILL }
},
{ &hf_header_array[POS_MAX_BREADTH],
{ "Max-Breadth", "sip.Max-Breadth",
FT_UINT32, BASE_DEC,NULL,0x0,
"RFC 5393: Max-Breadth Header", HFILL }
},
{ &hf_header_array[POS_MAX_FORWARDS],
{ "Max-Forwards", "sip.Max-Forwards",
FT_UINT32, BASE_DEC,NULL,0x0,
"RFC 3261: Max-Forwards Header", HFILL }
},
{ &hf_header_array[POS_MIME_VERSION],
{ "MIME-Version", "sip.MIME-Version",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: MIME-Version Header", HFILL }
},
{ &hf_header_array[POS_MIN_EXPIRES],
{ "Min-Expires", "sip.Min-Expires",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Min-Expires Header", HFILL }
},
{ &hf_header_array[POS_MIN_SE],
{ "Min-SE", "sip.Min-SE",
FT_STRING, BASE_NONE,NULL,0x0,
"Draft: Min-SE Header", HFILL }
},
{ &hf_header_array[POS_ORGANIZATION],
{ "Organization", "sip.Organization",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Organization Header", HFILL }
},
{ &hf_header_array[POS_ORIGINATION_ID],
{ "Origination-Id", "sip.Origination-Id",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_P_ACCESS_NETWORK_INFO],
{ "P-Access-Network-Info", "sip.P-Access-Network-Info",
FT_STRING, BASE_NONE,NULL,0x0,
"P-Access-Network-Info Header", HFILL }
},
{ &hf_header_array[POS_P_ANSWER_STATE],
{ "P-Answer-State", "sip.P-Answer-State",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 4964: P-Answer-State Header", HFILL }
},
{ &hf_header_array[POS_P_ASSERTED_IDENTITY],
{ "P-Asserted-Identity", "sip.P-Asserted-Identity",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: P-Asserted-Identity Header", HFILL }
},
{ &hf_header_array[POS_P_ASSERTED_SERV],
{ "P-Asserted-Service", "sip.P-Asserted-Service",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_P_CHARGE_INFO],
{ "P-Charge-Info", "sip.P-Charge-Info",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_P_ASSOCIATED_URI],
{ "P-Associated-URI", "sip.P-Associated-URI",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3455: P-Associated-URI Header", HFILL }
},
{ &hf_header_array[POS_P_CALLED_PARTY_ID],
{ "P-Called-Party-ID", "sip.P-Called-Party-ID",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3455: P-Called-Party-ID Header", HFILL }
},
{ &hf_header_array[POS_P_CHARGING_FUNC_ADDRESSES],
{ "P-Charging-Function-Addresses","sip.P-Charging-Function-Addresses",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_P_CHARGING_VECTOR],
{ "P-Charging-Vector", "sip.P-Charging-Vector",
FT_STRING, BASE_NONE,NULL,0x0,
"P-Charging-Vector Header", HFILL }
},
{ &hf_header_array[POS_P_DCS_TRACE_PARTY_ID],
{ "P-DCS-Trace-Party-ID", "sip.P-DCS-Trace-Party-ID",
FT_STRING, BASE_NONE,NULL,0x0,
"P-DCS-Trace-Party-ID Header", HFILL }
},
{ &hf_header_array[POS_P_DCS_OSPS],
{ "P-DCS-OSPS", "sip.P-DCS-OSPS",
FT_STRING, BASE_NONE,NULL,0x0,
"P-DCS-OSPS Header", HFILL }
},
{ &hf_header_array[POS_P_DCS_BILLING_INFO],
{ "P-DCS-Billing-Info", "sip.P-DCS-Billing-Info",
FT_STRING, BASE_NONE,NULL,0x0,
"P-DCS-Billing-Info Header", HFILL }
},
{ &hf_header_array[POS_P_DCS_LAES],
{ "P-DCS-LAES", "sip.P-DCS-LAES",
FT_STRING, BASE_NONE,NULL,0x0,
"P-DCS-LAES Header", HFILL }
},
{ &hf_header_array[POS_P_DCS_REDIRECT],
{ "P-DCS-Redirect", "sip.P-DCS-Redirect",
FT_STRING, BASE_NONE,NULL,0x0,
"P-DCS-Redirect Header", HFILL }
},
{ &hf_header_array[POS_P_EARLY_MEDIA],
{ "P-Early-Media", "sip.P-Early-Media",
FT_STRING, BASE_NONE,NULL,0x0,
"P-Early-Media Header", HFILL }
},
{ &hf_header_array[POS_P_MEDIA_AUTHORIZATION],
{ "P-Media-Authorization", "sip.P-Media-Authorization",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3313: P-Media-Authorization Header", HFILL }
},
{ &hf_header_array[POS_P_PREFERRED_IDENTITY],
{ "P-Preferred-Identity", "sip.P-Preferred-Identity",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3325: P-Preferred-Identity Header", HFILL }
},
{ &hf_header_array[POS_P_PREFERRED_SERV],
{ "P-Preferred-Service", "sip.P-Preferred-Service",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_P_PROFILE_KEY],
{ "P-Profile-Key", "sip.P-Profile-Key",
FT_STRING, BASE_NONE,NULL,0x0,
"P-Profile-Key Header", HFILL }
},
{ &hf_header_array[POS_P_REFUSED_URI_LST],
{ "P-Refused-URI-List", "sip.P-Refused-URI-List",
FT_STRING, BASE_NONE,NULL,0x0,
"P-Refused-URI-List Header", HFILL }
},
{ &hf_header_array[POS_P_SERVED_USER],
{ "P-Served-User", "sip.P-Served-User",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_P_USER_DATABASE],
{ "P-User-Database", "sip.P-User-Database",
FT_STRING, BASE_NONE,NULL,0x0,
"P-User-Database Header", HFILL }
},
{ &hf_header_array[POS_P_VISITED_NETWORK_ID],
{ "P-Visited-Network-ID", "sip.P-Visited-Network-ID",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3455: P-Visited-Network-ID Header", HFILL }
},
{ &hf_header_array[POS_PATH],
{ "Path", "sip.Path",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3327: Path Header", HFILL }
},
{ &hf_header_array[POS_PERMISSION_MISSING],
{ "Permission-Missing", "sip.Permission-Missing",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 5360: Permission Missing Header", HFILL }
},
{ &hf_header_array[POS_POLICY_CONTACT],
{ "Policy-Contact", "sip.Policy_Contact",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_POLICY_ID],
{ "Policy-ID", "sip.Policy_ID",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_PRIORITY],
{ "Priority", "sip.Priority",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Priority Header", HFILL }
},
{ &hf_header_array[POS_PRIORITY_SHARE],
{ "Priority-Share", "sip.Priority-Share",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_PRIV_ANSWER_MODE],
{ "Priv-Answer-mode", "sip.Priv-Answer-mode",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_PRIVACY],
{ "Privacy", "sip.Privacy",
FT_STRING, BASE_NONE,NULL,0x0,
"Privacy Header", HFILL }
},
{ &hf_header_array[POS_PROXY_AUTHENTICATE],
{ "Proxy-Authenticate", "sip.Proxy-Authenticate",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Proxy-Authenticate Header", HFILL }
},
{ &hf_header_array[POS_PROXY_AUTHORIZATION],
{ "Proxy-Authorization", "sip.Proxy-Authorization",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Proxy-Authorization Header", HFILL }
},
{ &hf_header_array[POS_PROXY_REQUIRE],
{ "Proxy-Require", "sip.Proxy-Require",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Proxy-Require Header", HFILL }
},
{ &hf_header_array[POS_RACK],
{ "RAck", "sip.RAck",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3262: RAck Header", HFILL }
},
{ &hf_header_array[POS_REASON],
{ "Reason", "sip.Reason",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3326 Reason Header", HFILL }
},
{ &hf_header_array[POS_REASON_PHRASE],
{ "Reason-Phrase", "sip.Reason-Phrase",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_RECORD_ROUTE],
{ "Record-Route", "sip.Record-Route",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Record-Route Header", HFILL }
},
{ &hf_header_array[POS_RECV_INFO],
{ "Recv-Info", "sip.Recv-Info",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_REFER_SUB],
{ "Refer-Sub", "sip.Refer-Sub",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 4488: Refer-Sub Header", HFILL }
},
{ &hf_header_array[POS_REFER_TO],
{ "Refer-To", "sip.Refer-To",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3515: Refer-To Header", HFILL }
},
{ &hf_header_array[POS_REFERRED_BY],
{ "Referred By", "sip.Referred-by",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3892: Referred-by Header", HFILL }
},
{ &hf_header_array[POS_REJECT_CONTACT],
{ "Reject-Contact", "sip.Reject-Contact",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3841: Reject-Contact Header", HFILL }
},
{ &hf_header_array[POS_RELAYED_CHARGE],
{ "Relayed-Charge", "sip.Relayed-Charge",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_REPLACES],
{ "Replaces", "sip.Replaces",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3891: Replaces Header", HFILL }
},
{ &hf_header_array[POS_REPLY_TO],
{ "Reply-To", "sip.Reply-To",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Reply-To Header", HFILL }
},
{ &hf_header_array[POS_REQUEST_DISPOSITION],
{ "Request-Disposition", "sip.Request-Disposition",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3841: Request-Disposition Header", HFILL }
},
{ &hf_header_array[POS_REQUIRE],
{ "Require", "sip.Require",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Require Header", HFILL }
},
{ &hf_header_array[POS_RESOURCE_PRIORITY],
{ "Resource-Priority", "sip.Resource-Priority",
FT_STRING, BASE_NONE,NULL,0x0,
"Draft: Resource-Priority Header", HFILL }
},
{ &hf_header_array[POS_RESOURCE_SHARE],
{ "Resource-Share", "sip.Resource-Share",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_RESPONSE_SOURCE],
{ "Response-Source", "sip.Response-Source",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_RESTORATION_INFO],
{ "Restoration-Info", "sip.Restoration-Info",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_RETRY_AFTER],
{ "Retry-After", "sip.Retry-After",
FT_UINT32, BASE_DEC,NULL,0x0,
"RFC 3261: Retry-After Header", HFILL }
},
{ &hf_header_array[POS_ROUTE],
{ "Route", "sip.Route",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Route Header", HFILL }
},
{ &hf_header_array[POS_RSEQ],
{ "RSeq", "sip.RSeq",
FT_UINT32, BASE_DEC,NULL,0x0,
"RFC 3262: RSeq Header", HFILL }
},
{ &hf_header_array[ POS_SECURITY_CLIENT],
{ "Security-Client", "sip.Security-Client",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3329 Security-Client Header", HFILL }
},
{ &hf_header_array[ POS_SECURITY_SERVER],
{ "Security-Server", "sip.Security-Server",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3329 Security-Server Header", HFILL }
},
{ &hf_header_array[ POS_SECURITY_VERIFY],
{ "Security-Verify", "sip.Security-Verify",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3329 Security-Verify Header", HFILL }
},
{ &hf_header_array[POS_SERVER],
{ "Server", "sip.Server",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Server Header", HFILL }
},
{ &hf_header_array[POS_SERVICE_INTERACT_INFO],
{ "Service-Interact-Info", "sip.Service-Interact-Info",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_SERVICE_ROUTE],
{ "Service-Route", "sip.Service-Route",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3608: Service-Route Header", HFILL }
},
{ &hf_header_array[POS_SESSION_EXPIRES],
{ "Session-Expires", "sip.Session-Expires",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 4028: Session-Expires Header", HFILL }
},
{ &hf_header_array[POS_SESSION_ID],
{ "Session-ID", "sip.Session-ID",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_SIP_ETAG],
{ "ETag", "sip.ETag",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3903: SIP-ETag Header", HFILL }
},
{ &hf_header_array[POS_SIP_IF_MATCH],
{ "If_Match", "sip.If_Match",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3903: SIP-If-Match Header", HFILL }
},
{ &hf_header_array[POS_SUBJECT],
{ "Subject", "sip.Subject",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Subject Header", HFILL }
},
{ &hf_header_array[POS_SUBSCRIPTION_STATE],
{ "Subscription-State", "sip.Subscription-State",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3265: Subscription-State Header", HFILL }
},
{ &hf_header_array[POS_SUPPORTED],
{ "Supported", "sip.Supported",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Supported Header", HFILL }
},
{ &hf_header_array[POS_SUPPRESS_IF_MATCH],
{ "Suppress-If-Match", "sip.Suppress_If_Match",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
},
{ &hf_header_array[POS_TARGET_DIALOG],
{ "Target-Dialog", "sip.Target-Dialog",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 4538: Target-Dialog Header", HFILL }
},
{ &hf_header_array[POS_TIMESTAMP],
{ "Timestamp", "sip.Timestamp",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Timestamp Header", HFILL }
},
{ &hf_header_array[POS_TO],
{ "To", "sip.To",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: To Header", HFILL }
},
{ &hf_header_array[POS_TRIGGER_CONSENT],
{ "Trigger-Consent", "sip.Trigger-Consent",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 5380: Trigger Consent", HFILL }
},
{ &hf_header_array[POS_UNSUPPORTED],
{ "Unsupported", "sip.Unsupported",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Unsupported Header", HFILL }
},
{ &hf_header_array[POS_USER_AGENT],
{ "User-Agent", "sip.User-Agent",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: User-Agent Header", HFILL }
},
{ &hf_header_array[POS_VIA],
{ "Via", "sip.Via",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Via Header", HFILL }
},
{ &hf_header_array[POS_WARNING],
{ "Warning", "sip.Warning",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: Warning Header", HFILL }
},
{ &hf_header_array[POS_WWW_AUTHENTICATE],
{ "WWW-Authenticate", "sip.WWW-Authenticate",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 3261: WWW-Authenticate Header", HFILL }
},
{ &hf_header_array[POS_DIVERSION],
{ "Diversion", "sip.Diversion",
FT_STRING, BASE_NONE,NULL,0x0,
"RFC 5806: Diversion Header", HFILL }
},
{ &hf_header_array[POS_USER_TO_USER],
{ "User-to-User", "sip.uui",
FT_STRING, BASE_NONE,NULL,0x0,
"draft-johnston-sipping-cc-uui-09: User-to-User header", HFILL }
},
{ &hf_sip_resend,
{ "Resent Packet", "sip.resend",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_sip_original_frame,
{ "Suspected resend of frame", "sip.resend-original",
FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_RETRANS_PREV), 0x0,
"Original transmission of frame", HFILL}
},
{ &hf_sip_matching_request_frame,
{ "Request Frame", "sip.response-request",
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_response_time,
{ "Response Time (ms)", "sip.response-time",
FT_UINT32, BASE_DEC, NULL, 0x0,
"Response time since original request (in milliseconds)", HFILL}
},
{ &hf_sip_release_time,
{ "Release Time (ms)", "sip.release-time",
FT_UINT32, BASE_DEC, NULL, 0x0,
"release time since original BYE (in milliseconds)", HFILL}
},
{ &hf_sip_auth,
{ "Authentication", "sip.auth",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication", HFILL}
},
{ &hf_sip_auth_scheme,
{ "Authentication Scheme", "sip.auth.scheme",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication Scheme", HFILL}
},
{ &hf_sip_auth_digest_response,
{ "Digest Authentication Response", "sip.auth.digest.response",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Digest Authentication Response Value", HFILL}
},
{ &hf_sip_auth_nc,
{ "Nonce Count", "sip.auth.nc",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication Nonce count", HFILL}
},
{ &hf_sip_auth_username,
{ "Username", "sip.auth.username",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication Username", HFILL}
},
{ &hf_sip_auth_realm,
{ "Realm", "sip.auth.realm",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication Realm", HFILL}
},
{ &hf_sip_auth_nonce,
{ "Nonce Value", "sip.auth.nonce",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication Nonce", HFILL}
},
{ &hf_sip_auth_algorithm,
{ "Algorithm", "sip.auth.algorithm",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication Algorithm", HFILL}
},
{ &hf_sip_auth_opaque,
{ "Opaque Value", "sip.auth.opaque",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication Opaque value", HFILL}
},
{ &hf_sip_auth_qop,
{ "QOP", "sip.auth.qop",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication QOP", HFILL}
},
{ &hf_sip_auth_cnonce,
{ "CNonce Value", "sip.auth.cnonce",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication Client Nonce", HFILL}
},
{ &hf_sip_auth_uri,
{ "Authentication URI", "sip.auth.uri",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication URI", HFILL}
},
{ &hf_sip_auth_domain,
{ "Authentication Domain", "sip.auth.domain",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication Domain", HFILL}
},
{ &hf_sip_auth_stale,
{ "Stale Flag", "sip.auth.stale",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication Stale Flag", HFILL}
},
{ &hf_sip_auth_auts,
{ "Authentication Token", "sip.auth.auts",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication Token", HFILL}
},
{ &hf_sip_auth_rspauth,
{ "Response auth", "sip.auth.rspauth",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication Response auth", HFILL}
},
{ &hf_sip_auth_nextnonce,
{ "Next Nonce", "sip.auth.nextnonce",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication Next Nonce", HFILL}
},
{ &hf_sip_auth_ik,
{ "Integrity Key", "sip.auth.ik",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication Integrity Key", HFILL}
},
{ &hf_sip_auth_ck,
{ "Cyphering Key", "sip.auth.ck",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Authentication Cyphering Key", HFILL}
},
{ &hf_sip_cseq_seq_no,
{ "Sequence Number", "sip.CSeq.seq",
FT_UINT32, BASE_DEC, NULL, 0x0,
"CSeq header sequence number", HFILL}
},
{ &hf_sip_cseq_method,
{ "Method", "sip.CSeq.method",
FT_STRING, BASE_NONE, NULL, 0x0,
"CSeq header method", HFILL}
},
{ &hf_sip_via_transport,
{ "Transport", "sip.Via.transport",
FT_STRING, BASE_NONE, NULL, 0x0,
"Via header Transport", HFILL}
},
{ &hf_sip_via_sent_by_address,
{ "Sent-by Address", "sip.Via.sent-by.address",
FT_STRING, BASE_NONE, NULL, 0x0,
"Via header Sent-by Address", HFILL}
},
{ &hf_sip_via_sent_by_port,
{ "Sent-by port", "sip.Via.sent-by.port",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Via header Sent-by Port", HFILL}
},
{ &hf_sip_via_branch,
{ "Branch", "sip.Via.branch",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Via Branch", HFILL},
},
{ &hf_sip_via_maddr,
{ "Maddr", "sip.Via.maddr",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Via Maddr", HFILL},
},
{ &hf_sip_via_rport,
{ "RPort", "sip.Via.rport",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Via RPort", HFILL},
},
{ &hf_sip_via_received,
{ "Received", "sip.Via.received",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Via Received", HFILL},
},
{ &hf_sip_via_ttl,
{ "TTL", "sip.Via.ttl",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Via TTL", HFILL}
},
{ &hf_sip_via_comp,
{ "Comp", "sip.Via.comp",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Via comp", HFILL}
},
{ &hf_sip_via_sigcomp_id,
{ "Sigcomp identifier", "sip.Via.sigcomp-id",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP Via sigcomp identifier", HFILL}
},
{ &hf_sip_via_oc,
{ "Overload Control", "sip.Via.oc",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_sip_via_oc_val,
{ "Overload Control Value", "sip.Via.oc_val",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_sip_via_oc_validity,
{ "Overload Control Validity", "sip.Via.oc_validity",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_sip_via_oc_seq,
{ "Overload Control Sequence", "sip.Via.oc_seq",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_sip_oc_seq_timestamp,
{ "Overload Control Sequence Time Stamp",
"sip.Via.oc_seq.ts",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_sip_via_oc_algo,
{ "Overload Control Algorithm", "sip.Via.oc_algo",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_sip_via_be_route,
{ "be-route", "sip.Via.be_route",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_sip_p_acc_net_i_acc_type,
{ "access-type", "sip.P-Access-Network-Info.access-type",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP P-Access-Network-Info access-type", HFILL}
},
{ &hf_sip_p_acc_net_i_ucid_3gpp,
{ "utran-cell-id-3gpp", "sip.P-Access-Network-Info.utran-cell-id-3gpp",
FT_STRING, BASE_NONE, NULL, 0x0,
"SIP P-Access-Network-Info utran-cell-id-3gpp", HFILL}
},
{ &hf_sip_rack_rseq_no,
{ "RSeq Sequence Number", "sip.RAck.RSeq.seq",
FT_UINT32, BASE_DEC, NULL, 0x0,
"RAck RSeq header sequence number (from prov response)", HFILL}
},
{ &hf_sip_rack_cseq_no,
{ "CSeq Sequence Number", "sip.RAck.CSeq.seq",
FT_UINT32, BASE_DEC, NULL, 0x0,
"RAck CSeq header sequence number (from prov response)", HFILL}
},
{ &hf_sip_rack_cseq_method,
{ "CSeq Method", "sip.RAck.CSeq.method",
FT_STRING, BASE_NONE, NULL, 0x0,
"RAck CSeq header method (from prov response)", HFILL}
},
{ &hf_sip_reason_protocols,
{ "Reason protocols", "sip.reason_protocols",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_reason_cause_q850,
{ "Cause", "sip.reason_cause_q850",
FT_UINT32, BASE_DEC_HEX|BASE_EXT_STRING, &q850_cause_code_vals_ext, 0x0,
NULL, HFILL}
},
{ &hf_sip_reason_cause_sip,
{ "Cause", "sip.reason_cause_sip",
FT_UINT32, BASE_DEC, VALS(sip_response_code_vals), 0x0,
NULL, HFILL }
},
{ &hf_sip_reason_cause_other,
{ "Cause", "sip.reason_cause_other",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_sip_reason_text,
{ "Text", "sip.reason_text",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_sip_msg_body,
{ "Message Body", "sip.msg_body",
FT_BYTES, BASE_NONE|BASE_NO_DISPLAY_VALUE, NULL, 0x0,
"Message Body in SIP message", HFILL }
},
{ &hf_sip_sec_mechanism,
{ "[Security-mechanism]", "sip.sec_mechanism",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_sec_mechanism_alg,
{ "alg", "sip.sec_mechanism.alg",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_sec_mechanism_ealg,
{ "ealg", "sip.sec_mechanism.ealg",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_sec_mechanism_prot,
{ "prot", "sip.sec_mechanism.prot",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_sec_mechanism_spi_c,
{ "spi-c", "sip.sec_mechanism.spi_c",
FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_sec_mechanism_spi_s,
{ "spi-s", "sip.sec_mechanism.spi_s",
FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_sec_mechanism_port1,
{ "port1", "sip.sec_mechanism.port1",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_sec_mechanism_port_c,
{ "port-c", "sip.sec_mechanism.port_c",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_sec_mechanism_port2,
{ "port2", "sip.sec_mechanism.port2",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_sec_mechanism_port_s,
{ "port-s", "sip.sec_mechanism.port_s",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_session_id_sess_id,
{ "sess-id", "sip.Session-ID.sess_id",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_session_id_param,
{ "param", "sip.Session-ID.param",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_session_id_local_uuid,
{ "local-uuid", "sip.Session-ID.local_uuid",
FT_GUID, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_session_id_remote_uuid,
{ "remote-uuid", "sip.Session-ID.remote_uuid",
FT_GUID, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_session_id_logme,
{ "logme", "sip.Session-ID.logme",
FT_BOOLEAN, BASE_NONE, TFS(&tfs_set_notset), 0x0,
NULL, HFILL}
},
{ &hf_sip_continuation,
{ "Continuation data", "sip.continuation",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_sip_feature_cap,
{ "Feature Cap", "sip.feature_cap",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_sip_service_priority,
{ "Service Priority", "sip.service_priority",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_sip_icid_value,
{ "icid-value", "sip.icid_value",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_sip_icid_gen_addr,
{ "icid-gen-addr", "sip.icid_gen_addr",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_sip_call_id_gen,
{ "Generated Call-ID", "sip.call_id_generated",
FT_STRING, BASE_NONE,NULL,0x0,
"Use to catch call id across protocols", HFILL }
},
};
/* raw_sip header field(s) */
static hf_register_info raw_hf[] = {
{ &hf_sip_raw_line,
{ "Raw SIP Line", "raw_sip.line",
FT_STRING, BASE_NONE,NULL,0x0,
NULL, HFILL }
}};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_sip,
&ett_sip_reqresp,
&ett_sip_hdr,
&ett_sip_ext_hdr,
&ett_sip_element,
&ett_sip_hist,
&ett_sip_uri,
&ett_sip_contact_item,
&ett_sip_message_body,
&ett_sip_cseq,
&ett_sip_via,
&ett_sip_reason,
&ett_sip_security_client,
&ett_sip_security_server,
&ett_sip_security_verify,
&ett_sip_rack,
&ett_sip_record_route,
&ett_sip_service_route,
&ett_sip_route,
&ett_sip_path,
&ett_sip_ruri,
&ett_sip_pai_uri,
&ett_sip_pmiss_uri,
&ett_sip_ppi_uri,
&ett_sip_tc_uri,
&ett_sip_to_uri,
&ett_sip_from_uri,
&ett_sip_curi,
&ett_sip_session_id,
&ett_sip_p_access_net_info,
&ett_sip_p_charging_vector,
&ett_sip_feature_caps,
&ett_sip_via_be_route
};
static gint *ett_raw[] = {
&ett_raw_text,
};
static ei_register_info ei[] = {
{ &ei_sip_unrecognized_header, { "sip.unrecognized_header", PI_UNDECODED, PI_NOTE, "Unrecognised SIP header", EXPFILL }},
{ &ei_sip_header_no_colon, { "sip.header_no_colon", PI_MALFORMED, PI_WARN, "Header has no colon after the name", EXPFILL }},
{ &ei_sip_header_not_terminated, { "sip.header_not_terminated", PI_MALFORMED, PI_WARN, "Header not terminated by empty line (CRLF)", EXPFILL }},
#if 0
{ &ei_sip_odd_register_response, { "sip.response.unusual", PI_RESPONSE_CODE, PI_WARN, "SIP Response is unusual", EXPFILL }},
#endif
{ &ei_sip_call_id_invalid, { "sip.Call-ID.invalid", PI_PROTOCOL, PI_WARN, "Call ID is mandatory", EXPFILL }},
{ &ei_sip_sipsec_malformed, { "sip.sec_mechanism.malformed", PI_MALFORMED, PI_WARN, "SIP Security-mechanism header malformed", EXPFILL }},
{ &ei_sip_via_sent_by_port, { "sip.Via.sent-by.port.invalid", PI_MALFORMED, PI_NOTE, "Invalid SIP Via sent-by-port", EXPFILL }},
{ &ei_sip_content_length_invalid, { "sip.content_length.invalid", PI_MALFORMED, PI_NOTE, "Invalid content_length", EXPFILL }},
{ &ei_sip_retry_after_invalid, { "sip.retry_after.invalid", PI_MALFORMED, PI_NOTE, "Invalid retry_after value", EXPFILL }},
{ &ei_sip_Status_Code_invalid, { "sip.Status-Code.invalid", PI_MALFORMED, PI_NOTE, "Invalid Status-Code", EXPFILL }},
{ &ei_sip_authorization_invalid, { "sip.authorization.invalid", PI_PROTOCOL, PI_WARN, "Invalid authorization response for known credentials", EXPFILL }},
{ &ei_sip_session_id_sess_id,{ "sip.Session-ID.sess_id.invalid", PI_PROTOCOL, PI_WARN, "Session ID cannot be empty", EXPFILL }}
};
module_t *sip_module;
expert_module_t* expert_sip;
uat_t* sip_custom_headers_uat;
uat_t* sip_authorization_users_uat;
static tap_param sip_stat_params[] = {
{ PARAM_FILTER, "filter", "Filter", NULL, TRUE }
};
static stat_tap_table_ui sip_stat_table = {
REGISTER_STAT_GROUP_TELEPHONY,
"SIP Statistics",
"sip",
"sip,stat",
sip_stat_init,
sip_stat_packet,
sip_stat_reset,
sip_stat_free_table_item,
NULL,
sizeof(sip_stat_fields)/sizeof(stat_tap_table_item), sip_stat_fields,
sizeof(sip_stat_params)/sizeof(tap_param), sip_stat_params,
NULL,
0
};
/* UAT for header fields */
static uat_field_t sip_custom_header_uat_fields[] = {
UAT_FLD_CSTRING(sip_custom_header_fields, header_name, "Header name", "SIP header name"),
UAT_FLD_CSTRING(sip_custom_header_fields, header_desc, "Field desc", "Description of the value contained in the header"),
UAT_END_FIELDS
};
static uat_field_t sip_authorization_users_uat_fields[] = {
UAT_FLD_CSTRING(sip_authorization_users, username, "Username", "SIP authorization username"),
UAT_FLD_CSTRING(sip_authorization_users, realm, "Realm", "SIP authorization realm"),
UAT_FLD_CSTRING(sip_authorization_users, password, "Password", "SIP authorization password"),
UAT_END_FIELDS
};
/* Register the protocol name and description */
proto_sip = proto_register_protocol("Session Initiation Protocol", "SIP", "sip");
proto_raw_sip = proto_register_protocol("Session Initiation Protocol (SIP as raw text)",
"Raw_SIP", "raw_sip");
sip_handle = register_dissector("sip", dissect_sip, proto_sip);
sip_tcp_handle = register_dissector("sip.tcp", dissect_sip_tcp, proto_sip);
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_sip, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_sip = expert_register_protocol(proto_sip);
expert_register_field_array(expert_sip, ei, array_length(ei));
proto_register_subtree_array(ett_raw, array_length(ett_raw));
/* Register raw_sip field(s) */
proto_register_field_array(proto_raw_sip, raw_hf, array_length(raw_hf));
sip_module = prefs_register_protocol(proto_sip, proto_reg_handoff_sip);
prefs_register_uint_preference(sip_module, "tls.port",
"SIP TLS Port",
"SIP Server TLS Port",
10, &sip_tls_port);
prefs_register_bool_preference(sip_module, "display_raw_text",
"Display raw text for SIP message",
"Specifies that the raw text of the "
"SIP message should be displayed "
"in addition to the dissection tree",
&global_sip_raw_text);
prefs_register_bool_preference(sip_module, "display_raw_text_without_crlf",
"Don't show '\\r\\n' in raw SIP messages",
"If the raw text of the SIP message "
"is displayed, the trailing carriage "
"return and line feed are not shown",
&global_sip_raw_text_without_crlf);
prefs_register_enum_preference(sip_module, "raw_text_body_default_encoding",
"Default charset of raw SIP messages",
"Display sip body of raw text by using this charset. The default is UTF-8.",
&global_sip_raw_text_body_default_encoding,
ws_supported_mibenum_vals_character_sets_ev_array, FALSE);
prefs_register_bool_preference(sip_module, "strict_sip_version",
"Enforce strict SIP version check (" SIP2_HDR ")",
"If enabled, only " SIP2_HDR " traffic will be dissected as SIP. "
"Disable it to allow SIP traffic with a different version "
"to be dissected as SIP.",
&strict_sip_version);
prefs_register_bool_preference(sip_module, "desegment_headers",
"Reassemble SIP headers spanning multiple TCP segments",
"Whether the SIP dissector should reassemble headers "
"of a request spanning multiple TCP segments. "
"To use this option, you must also enable "
"\"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
&sip_desegment_headers);
prefs_register_bool_preference(sip_module, "desegment_body",
"Reassemble SIP bodies spanning multiple TCP segments",
"Whether the SIP dissector should use the "
"\"Content-length:\" value, if present, to reassemble "
"the body of a request spanning multiple TCP segments, "
"and reassemble chunked data spanning multiple TCP segments. "
"To use this option, you must also enable "
"\"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
&sip_desegment_body);
prefs_register_bool_preference(sip_module, "retrans_the_same_sport",
"Retransmissions always use the same source port",
"Whether retransmissions are detected coming from the same source port only.",
&sip_retrans_the_same_sport);
prefs_register_bool_preference(sip_module, "delay_sdp_changes",
"Delay SDP changes for tracking media",
"Whether SIP should delay tracking the media (e.g., RTP/RTCP) until an SDP offer "
"is answered. If enabled, mid-dialog changes to SDP and media state only take "
"effect if and when an SDP offer is successfully answered; however enabling this "
"prevents tracking media in early-media call scenarios",
&sip_delay_sdp_changes);
prefs_register_bool_preference(sip_module, "hide_generatd_call_id",
"Hide the generated Call Id",
"Whether the generated call id should be hidden(not displayed) in the tree or not.",
&sip_hide_generatd_call_ids);
/* UAT */
sip_custom_headers_uat = uat_new("Custom SIP Header Fields",
sizeof(header_field_t),
"custom_sip_header_fields",
TRUE,
&sip_custom_header_fields,
&sip_custom_num_header_fields,
/* specifies named fields, so affects dissection
and the set of named fields */
UAT_AFFECTS_DISSECTION|UAT_AFFECTS_FIELDS,
NULL,
header_fields_copy_cb,
header_fields_update_cb,
header_fields_free_cb,
header_fields_post_update_cb,
header_fields_reset_cb,
sip_custom_header_uat_fields
);
prefs_register_uat_preference(sip_module, "custom_sip_header_fields", "Custom SIP header fields",
"A table to define custom SIP header for which fields can be setup and used for filtering/data extraction etc.",
sip_custom_headers_uat);
prefs_register_bool_preference(sip_module, "validate_authorization",
"Validate SIP authorization",
"Validate SIP authorizations with known credentials",
&global_sip_validate_authorization);
sip_authorization_users_uat = uat_new("SIP authorization users",
sizeof(authorization_user_t),
"authorization_users_sip",
TRUE,
&sip_authorization_users,
&sip_authorization_num_users,
/* specifies named fields, so affects dissection
and the set of named fields */
UAT_AFFECTS_DISSECTION|UAT_AFFECTS_FIELDS,
NULL,
authorization_users_copy_cb,
authorization_users_update_cb,
authorization_users_free_cb,
NULL,
NULL,
sip_authorization_users_uat_fields
);
prefs_register_uat_preference(sip_module, "authorization_users_sip", "SIP authorization users",
"A table to define user credentials used for validating authorization attempts",
sip_authorization_users_uat);
register_init_routine(&sip_init_protocol);
register_cleanup_routine(&sip_cleanup_protocol);
heur_subdissector_list = register_heur_dissector_list("sip", proto_sip);
/* Register for tapping */
sip_tap = register_tap("sip");
sip_follow_tap = register_tap("sip_follow");
ext_hdr_subdissector_table = register_dissector_table("sip.hdr", "SIP Extension header", proto_sip, FT_STRING, STRING_CASE_SENSITIVE);
register_stat_tap_table_ui(&sip_stat_table);
/* compile patterns */
ws_mempbrk_compile(&pbrk_comma_semi, ",;");
ws_mempbrk_compile(&pbrk_whitespace, " \t\r\n");
ws_mempbrk_compile(&pbrk_param_end, ">,;? \r");
ws_mempbrk_compile(&pbrk_param_end_colon_brackets, ">,;? \r:[]");
ws_mempbrk_compile(&pbrk_header_end_dquote, "\r\n,;\"");
ws_mempbrk_compile(&pbrk_tab_sp_fslash, "\t /");
ws_mempbrk_compile(&pbrk_addr_end, "[] \t:;");
ws_mempbrk_compile(&pbrk_via_param_end, "\t;, ");
register_follow_stream(proto_sip, "sip_follow", sip_follow_conv_filter, sip_follow_index_filter, sip_follow_address_filter,
udp_port_to_display, follow_tvb_tap_listener, NULL, NULL);
}
void
proto_reg_handoff_sip(void)
{
static guint saved_sip_tls_port;
static gboolean sip_prefs_initialized = FALSE;
if (!sip_prefs_initialized) {
sigcomp_handle = find_dissector_add_dependency("sigcomp", proto_sip);
sip_diag_handle = find_dissector("sip.diagnostic");
sip_uri_userinfo_handle = find_dissector("sip.uri_userinfo");
sip_via_branch_handle = find_dissector("sip.via_branch");
sip_via_be_route_handle = find_dissector("sip.via_be_route");
/* Check for a dissector to parse Reason Code texts */
sip_reason_code_handle = find_dissector("sip.reason_code");
/* SIP content type and internet media type used by other dissectors are the same */
media_type_dissector_table = find_dissector_table("media_type");
dissector_add_uint_range_with_preference("udp.port", DEFAULT_SIP_PORT_RANGE, sip_handle);
dissector_add_string("media_type", "message/sip", sip_handle);
dissector_add_string("ws.protocol", "sip", sip_handle); /* RFC 7118 */
dissector_add_uint_range_with_preference("tcp.port", DEFAULT_SIP_PORT_RANGE, sip_tcp_handle);
heur_dissector_add("udp", dissect_sip_heur, "SIP over UDP", "sip_udp", proto_sip, HEURISTIC_ENABLE);
heur_dissector_add("tcp", dissect_sip_tcp_heur, "SIP over TCP", "sip_tcp", proto_sip, HEURISTIC_ENABLE);
heur_dissector_add("sctp", dissect_sip_heur, "SIP over SCTP", "sip_sctp", proto_sip, HEURISTIC_ENABLE);
heur_dissector_add("stun", dissect_sip_heur, "SIP over TURN", "sip_stun", proto_sip, HEURISTIC_ENABLE);
dissector_add_uint("acdr.tls_application_port", 5061, sip_handle);
dissector_add_uint("acdr.tls_application", TLS_APP_SIP, sip_handle);
dissector_add_string("protobuf_field", "adc.sip.ResponsePDU.body", sip_handle);
dissector_add_string("protobuf_field", "adc.sip.RequestPDU.body", sip_handle);
exported_pdu_tap = find_tap_id(EXPORT_PDU_TAP_NAME_LAYER_7);
sip_prefs_initialized = TRUE;
} else {
ssl_dissector_delete(saved_sip_tls_port, sip_tcp_handle);
}
/* Set our port number for future use */
ssl_dissector_add(sip_tls_port, sip_tcp_handle);
saved_sip_tls_port = sip_tls_port;
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-sip.h
|
/* packet-sip.h
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PACKET_SIP_H__
#define __PACKET_SIP_H__
#include <epan/packet.h>
typedef struct _sip_info_value_t
{
const guint8 *request_method;
guint response_code;
gboolean resend;
guint32 setup_time;
/* added for VoIP calls analysis, see ui/voip_calls.c*/
gchar *tap_call_id;
gchar *tap_from_addr;
gchar *tap_to_addr;
guint32 tap_cseq_number;
gchar *reason_phrase;
} sip_info_value_t;
typedef enum {
SIP_PROTO_OTHER = 0,
SIP_PROTO_SIP = 1,
SIP_PROTO_Q850 = 2
} sip_reason_code_proto_t;
typedef struct _sip_reason_code_info_t
{
sip_reason_code_proto_t protocol_type_num;
guint cause_value;
} sip_reason_code_info_t;
WS_DLL_PUBLIC const value_string sip_response_code_vals[];
extern void dfilter_store_sip_from_addr(tvbuff_t *tvb, proto_tree *tree,
guint parameter_offset, guint parameter_len);
extern void dissect_sip_p_access_network_info_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint start_offset, gint line_end_offset);
#endif
|
C
|
wireshark/epan/dissectors/packet-sipfrag.c
|
/* Routines for sipfrag packet disassembly (RFC 3420)
*
* Martin Mathieson
* Based on packet-sdp.c
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
/*
* Doesn't do a detailed dissection of the lines of the message, just treat as text.
*/
void proto_register_sipfrag(void);
/* Initialize the protocol and registered fields. */
static int proto_sipfrag = -1;
static int hf_sipfrag_line = -1;
/* Protocol subtree. */
static int ett_sipfrag = -1;
void proto_reg_handoff_sipfrag(void);
static dissector_handle_t sipfrag_handle;
/* Main dissection function. */
static int dissect_sipfrag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
proto_tree *sipfrag_tree;
proto_item *ti;
gint offset = 0;
gint next_offset;
int linelen;
char *string;
gint lines = 0;
/* Append this protocol name rather than replace. */
col_append_str(pinfo->cinfo, COL_PROTOCOL, "/sipfrag");
/* Add mention of this protocol to info column */
col_append_str(pinfo->cinfo, COL_INFO, ", with Sipfrag");
/* Create sipfrag tree. */
ti = proto_tree_add_item(tree, proto_sipfrag, tvb, offset, -1, ENC_NA);
sipfrag_tree = proto_item_add_subtree(ti, ett_sipfrag);
/* Show the sipfrag message a line at a time. */
while (tvb_offset_exists(tvb, offset))
{
/* Find the end of the line. */
linelen = tvb_find_line_end_unquoted(tvb, offset, -1, &next_offset);
/* For now, add all lines as unparsed strings */
/* Extract & add the string. */
string = (char*)tvb_get_string_enc(pinfo->pool, tvb, offset, linelen, ENC_ASCII);
proto_tree_add_string_format(sipfrag_tree, hf_sipfrag_line,
tvb, offset,
linelen, string,
"%s", string);
lines++;
/* Show first line in info column */
if (lines == 1) {
col_append_fstr(pinfo->cinfo, COL_INFO, "(%s", string);
}
/* Move onto next line. */
offset = next_offset;
}
/* Close off summary of sipfrag in info column */
col_append_str(pinfo->cinfo, COL_INFO, (lines > 1) ? "...)" : ")");
return tvb_captured_length(tvb);
}
void proto_register_sipfrag(void)
{
static hf_register_info hf[] =
{
{ &hf_sipfrag_line,
{ "Line",
"sipfrag.line",FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL
}
},
};
static gint *ett[] =
{
&ett_sipfrag
};
/* Register protocol. */
proto_sipfrag = proto_register_protocol("Sipfrag", "SIPFRAG", "sipfrag");
proto_register_field_array(proto_sipfrag, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
/* Allow other dissectors to find this one by name. */
sipfrag_handle = register_dissector("sipfrag", dissect_sipfrag, proto_sipfrag);
}
void proto_reg_handoff_sipfrag(void)
{
dissector_add_string("media_type", "message/sipfrag", sipfrag_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-sita.c
|
/* packet-sita.c
* Routines for SITA protocol dissection (ALC, UTS, Frame Relay, X.25)
* with a SITA specific link layer information header
*
* Copyright 2007, Fulko Hew, SITA INC Canada, Inc.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* Use indentation = 4 */
#include "config.h"
#include <epan/packet.h>
#include <wiretap/wtap.h>
void proto_register_sita(void);
void proto_reg_handoff_sita(void);
static dissector_table_t sita_dissector_table;
static gint ett_sita = -1;
static gint ett_sita_flags = -1;
static gint ett_sita_signals = -1;
static gint ett_sita_errors1 = -1;
static gint ett_sita_errors2 = -1;
static int proto_sita = -1; /* Initialize the protocol and registered fields */
static int hf_dir = -1;
static int hf_framing = -1;
static int hf_parity = -1;
static int hf_collision = -1;
static int hf_longframe = -1;
static int hf_shortframe = -1;
static int hf_droppedframe = -1;
static int hf_nonaligned = -1;
static int hf_abort = -1;
static int hf_lostcd = -1;
static int hf_lostcts = -1;
static int hf_rxdpll = -1;
static int hf_overrun = -1;
static int hf_length = -1;
static int hf_crc = -1;
static int hf_break = -1;
static int hf_underrun = -1;
static int hf_uarterror = -1;
static int hf_rtxlimit = -1;
static int hf_proto = -1;
static int hf_dsr = -1;
static int hf_dtr = -1;
static int hf_cts = -1;
static int hf_rts = -1;
static int hf_dcd = -1;
static int hf_signals = -1;
static dissector_handle_t sita_handle;
#define MAX_FLAGS_LEN 64 /* max size of a 'flags' decoded string */
#define IOP "Local"
#define REMOTE "Remote"
static const gchar *
format_flags_string(guchar value, const gchar *array[])
{
int i;
guint bpos;
wmem_strbuf_t *buf;
const char *sep = "";
buf = wmem_strbuf_new_sized(wmem_packet_scope(), MAX_FLAGS_LEN);
for (i = 0; i < 8; i++) {
bpos = 1 << i;
if (value & bpos) {
if (array[i][0]) {
/* there is a string to emit... */
wmem_strbuf_append_printf(buf, "%s%s", sep,
array[i]);
sep = ", ";
}
}
}
return wmem_strbuf_get_str(buf);
}
static int
dissect_sita(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
proto_item *ti;
guchar flags, signals, errors1, errors2, proto;
const gchar *errors1_string, *errors2_string, *flags_string;
proto_tree *sita_tree = NULL;
proto_tree *sita_flags_tree = NULL;
proto_tree *sita_errors1_tree = NULL;
proto_tree *sita_errors2_tree = NULL;
static const gchar *rx_errors1_str[] = {"Framing", "Parity", "Collision", "Long-frame", "Short-frame", "", "", "" };
static const gchar *rx_errors2_str[] = {"Non-Aligned", "Abort", "CD-lost", "DPLL", "Overrun", "Length", "CRC", "Break" };
#if 0
static const gchar *tx_errors1_str[] = {"", "", "", "", "", "", "", "" };
#endif
static const gchar *tx_errors2_str[] = {"Underrun", "CTS-lost", "UART", "ReTx-limit", "", "", "", "" };
static const gchar *flags_str[] = {"", "", "", "", "", "", "", "No-buffers" };
static int * const signal_flags[] = {
&hf_dcd,
&hf_rts,
&hf_cts,
&hf_dtr,
&hf_dsr,
NULL
};
col_clear(pinfo->cinfo, COL_PROTOCOL); /* erase the protocol */
col_clear(pinfo->cinfo, COL_INFO); /* and info columns so that the next decoder can fill them in */
flags = pinfo->pseudo_header->sita.sita_flags;
signals = pinfo->pseudo_header->sita.sita_signals;
errors1 = pinfo->pseudo_header->sita.sita_errors1;
errors2 = pinfo->pseudo_header->sita.sita_errors2;
proto = pinfo->pseudo_header->sita.sita_proto;
if ((flags & SITA_FRAME_DIR) == SITA_FRAME_DIR_TXED) {
col_set_str(pinfo->cinfo, COL_DEF_SRC, IOP); /* set the source (direction) column accordingly */
} else {
col_set_str(pinfo->cinfo, COL_DEF_SRC, REMOTE);
}
col_clear(pinfo->cinfo, COL_INFO);
if (tree) {
ti = proto_tree_add_protocol_format(tree, proto_sita, tvb, 0, 0, "Link Layer");
sita_tree = proto_item_add_subtree(ti, ett_sita);
proto_tree_add_uint(sita_tree, hf_proto, tvb, 0, 0, proto);
flags_string = format_flags_string(flags, flags_str);
sita_flags_tree = proto_tree_add_subtree_format(sita_tree, tvb, 0, 0,
ett_sita_flags, NULL, "Flags: 0x%02x (From %s)%s%s",
flags,
((flags & SITA_FRAME_DIR) == SITA_FRAME_DIR_TXED) ? IOP : REMOTE,
strlen(flags_string) ? ", " : "",
flags_string);
proto_tree_add_boolean(sita_flags_tree, hf_droppedframe, tvb, 0, 0, flags);
proto_tree_add_boolean(sita_flags_tree, hf_dir, tvb, 0, 0, flags);
proto_tree_add_bitmask_value_with_flags(sita_tree, tvb, 0, hf_signals, ett_sita_signals,
signal_flags, signals, BMT_NO_FALSE|BMT_NO_TFS);
if ((flags & SITA_FRAME_DIR) == SITA_FRAME_DIR_RXED) {
static int * const errors1_flags[] = {
&hf_shortframe,
&hf_longframe,
&hf_collision,
&hf_parity,
&hf_framing,
NULL
};
static int * const errors2_flags[] = {
&hf_break,
&hf_crc,
&hf_length,
&hf_overrun,
&hf_rxdpll,
&hf_lostcd,
&hf_abort,
&hf_nonaligned,
NULL
};
errors1_string = format_flags_string(errors1, rx_errors1_str);
sita_errors1_tree = proto_tree_add_subtree_format(sita_tree, tvb, 0, 0,
ett_sita_errors1, NULL, "Receive Status: 0x%02x %s", errors1, errors1_string);
proto_tree_add_bitmask_list_value(sita_errors1_tree, tvb, 0, 0, errors1_flags, errors1);
errors2_string = format_flags_string(errors2, rx_errors2_str);
sita_errors2_tree = proto_tree_add_subtree_format(sita_tree, tvb, 0, 0,
ett_sita_errors2, NULL, "Receive Status: 0x%02x %s", errors2, errors2_string);
proto_tree_add_bitmask_list_value(sita_errors2_tree, tvb, 0, 0, errors2_flags, errors2);
} else {
static int * const errors2_flags[] = {
&hf_rtxlimit,
&hf_uarterror,
&hf_lostcts,
&hf_underrun,
NULL
};
errors2_string = format_flags_string(errors2, tx_errors2_str);
sita_errors1_tree = proto_tree_add_subtree_format(sita_tree, tvb, 0, 0,
ett_sita_errors1, NULL, "Transmit Status: 0x%02x %s", errors2, errors2_string);
proto_tree_add_bitmask_list_value(sita_errors1_tree, tvb, 0, 0, errors2_flags, errors2);
}
}
/* try to find and run an applicable dissector */
if (!dissector_try_uint(sita_dissector_table, pinfo->pseudo_header->sita.sita_proto, tvb, pinfo, tree)) {
/* if one can't be found... tell them we don't know how to decode this protocol
and give them the details then */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNKNOWN");
col_add_fstr(pinfo->cinfo, COL_INFO, "IOP protocol number: %u", pinfo->pseudo_header->sita.sita_proto);
call_data_dissector(tvb, pinfo, tree); /* call the generic (hex display) decoder instead */
}
return tvb_captured_length(tvb);
}
static const true_false_string tfs_sita_flags = { "From Remote", "From Local" };
static const true_false_string tfs_sita_error = { "Error", "" };
static const true_false_string tfs_sita_violation = { "Violation", "" };
static const true_false_string tfs_sita_received = { "Received", "" };
static const true_false_string tfs_sita_lost = { "Lost", "" };
static const true_false_string tfs_sita_exceeded = { "Exceeded", "" };
static const value_string tfs_sita_proto[] = {
{ SITA_PROTO_UNUSED, "Unused" },
{ SITA_PROTO_BOP_LAPB, "LAPB" },
{ SITA_PROTO_ETHERNET, "Ethernet" },
{ SITA_PROTO_ASYNC_INTIO, "Async (Interrupt I/O)" },
{ SITA_PROTO_ASYNC_BLKIO, "Async (Block I/O)" },
{ SITA_PROTO_ALC, "IPARS" },
{ SITA_PROTO_UTS, "UTS" },
{ SITA_PROTO_PPP_HDLC, "PPP/HDLC" },
{ SITA_PROTO_SDLC, "SDLC" },
{ SITA_PROTO_TOKENRING, "Token Ring" },
{ SITA_PROTO_I2C, "I2C" },
{ SITA_PROTO_DPM_LINK, "DPM Link" },
{ SITA_PROTO_BOP_FRL, "Frame Relay" },
{ 0, NULL }
};
void
proto_register_sita(void)
{
static hf_register_info hf[] = {
{ &hf_proto,
{ "Protocol", "sita.errors.protocol",
FT_UINT8, BASE_HEX, VALS(tfs_sita_proto), 0,
"Protocol value", HFILL }
},
{ &hf_dir,
{ "Direction", "sita.flags.flags",
FT_BOOLEAN, 8, TFS(&tfs_sita_flags), SITA_FRAME_DIR,
"TRUE 'from Remote', FALSE 'from Local'", HFILL }
},
{ &hf_droppedframe,
{ "No Buffers", "sita.flags.droppedframe",
FT_BOOLEAN, 8, TFS(&tfs_sita_error), SITA_ERROR_NO_BUFFER,
"TRUE if Buffer Failure", HFILL }
},
{ &hf_framing,
{ "Framing", "sita.errors.framing",
FT_BOOLEAN, 8, TFS(&tfs_sita_error), SITA_ERROR_RX_FRAMING,
"TRUE if Framing Error", HFILL }
},
{ &hf_parity,
{ "Parity", "sita.errors.parity",
FT_BOOLEAN, 8, TFS(&tfs_sita_error), SITA_ERROR_RX_PARITY,
"TRUE if Parity Error", HFILL }
},
{ &hf_collision,
{ "Collision", "sita.errors.collision",
FT_BOOLEAN, 8, TFS(&tfs_sita_error), SITA_ERROR_RX_COLLISION,
"TRUE if Collision", HFILL }
},
{ &hf_longframe,
{ "Long Frame", "sita.errors.longframe",
FT_BOOLEAN, 8, TFS(&tfs_sita_error), SITA_ERROR_RX_FRAME_LONG,
"TRUE if Long Frame Received", HFILL }
},
{ &hf_shortframe,
{ "Short Frame", "sita.errors.shortframe",
FT_BOOLEAN, 8, TFS(&tfs_sita_error), SITA_ERROR_RX_FRAME_SHORT,
"TRUE if Short Frame", HFILL }
},
{ &hf_nonaligned,
{ "NonAligned", "sita.errors.nonaligned",
FT_BOOLEAN, 8, TFS(&tfs_sita_error), SITA_ERROR_RX_NONOCTET_ALIGNED,
"TRUE if NonAligned Frame", HFILL }
},
{ &hf_abort,
{ "Abort", "sita.errors.abort",
FT_BOOLEAN, 8, TFS(&tfs_sita_received), SITA_ERROR_RX_ABORT,
"TRUE if Abort Received", HFILL }
},
{ &hf_lostcd,
{ "Carrier", "sita.errors.lostcd",
FT_BOOLEAN, 8, TFS(&tfs_sita_lost), SITA_ERROR_RX_CD_LOST,
"TRUE if Carrier Lost", HFILL }
},
{ &hf_rxdpll,
{ "DPLL", "sita.errors.rxdpll",
FT_BOOLEAN, 8, TFS(&tfs_sita_error), SITA_ERROR_RX_DPLL,
"TRUE if DPLL Error", HFILL }
},
{ &hf_overrun,
{ "Overrun", "sita.errors.overrun",
FT_BOOLEAN, 8, TFS(&tfs_sita_error), SITA_ERROR_RX_OVERRUN,
"TRUE if Overrun Error", HFILL }
},
{ &hf_length,
{ "Length", "sita.errors.length",
FT_BOOLEAN, 8, TFS(&tfs_sita_violation), SITA_ERROR_RX_FRAME_LEN_VIOL,
"TRUE if Length Violation", HFILL }
},
{ &hf_crc,
{ "CRC", "sita.errors.crc",
FT_BOOLEAN, 8, TFS(&tfs_sita_error), SITA_ERROR_RX_CRC,
"TRUE if CRC Error", HFILL }
},
{ &hf_break,
{ "Break", "sita.errors.break",
FT_BOOLEAN, 8, TFS(&tfs_sita_received), SITA_ERROR_RX_BREAK,
"TRUE if Break Received", HFILL }
},
{ &hf_underrun,
{ "Underrun", "sita.errors.underrun",
FT_BOOLEAN, 8, TFS(&tfs_sita_error), SITA_ERROR_TX_UNDERRUN,
"TRUE if Tx Underrun", HFILL }
},
{ &hf_lostcts,
{ "Clear To Send", "sita.errors.lostcts",
FT_BOOLEAN, 8, TFS(&tfs_sita_lost), SITA_ERROR_TX_CTS_LOST,
"TRUE if Clear To Send Lost", HFILL }
},
{ &hf_uarterror,
{ "UART", "sita.errors.uarterror",
FT_BOOLEAN, 8, TFS(&tfs_sita_error), SITA_ERROR_TX_UART_ERROR,
"TRUE if UART Error", HFILL }
},
{ &hf_rtxlimit,
{ "Retx Limit", "sita.errors.rtxlimit",
FT_BOOLEAN, 8, TFS(&tfs_sita_exceeded), SITA_ERROR_TX_RETX_LIMIT,
"TRUE if Retransmit Limit reached", HFILL }
},
{ &hf_dsr,
{ "DSR", "sita.signals.dsr",
FT_BOOLEAN, 8, TFS(&tfs_on_off), SITA_SIG_DSR,
"TRUE if Data Set Ready", HFILL }
},
{ &hf_dtr,
{ "DTR", "sita.signals.dtr",
FT_BOOLEAN, 8, TFS(&tfs_on_off), SITA_SIG_DTR,
"TRUE if Data Terminal Ready", HFILL }
},
{ &hf_cts,
{ "CTS", "sita.signals.cts",
FT_BOOLEAN, 8, TFS(&tfs_on_off), SITA_SIG_CTS,
"TRUE if Clear To Send", HFILL }
},
{ &hf_rts,
{ "RTS", "sita.signals.rts",
FT_BOOLEAN, 8, TFS(&tfs_on_off), SITA_SIG_RTS,
"TRUE if Request To Send", HFILL }
},
{ &hf_dcd,
{ "DCD", "sita.signals.dcd",
FT_BOOLEAN, 8, TFS(&tfs_on_off), SITA_SIG_DCD,
"TRUE if Data Carrier Detect", HFILL }
},
{ &hf_signals,
{ "Signals", "sita.signals",
FT_UINT8, BASE_HEX, NULL, 0,
NULL, HFILL }
},
};
static gint *ett[] = {
&ett_sita,
&ett_sita_flags,
&ett_sita_signals,
&ett_sita_errors1,
&ett_sita_errors2,
};
proto_sita = proto_register_protocol("Societe Internationale de Telecommunications Aeronautiques", "SITA", "sita"); /* name, short name,abbreviation */
sita_dissector_table = register_dissector_table("sita.proto", "SITA protocol number", proto_sita, FT_UINT8, BASE_HEX);
proto_register_field_array(proto_sita, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
sita_handle = register_dissector("sita", dissect_sita, proto_sita);
}
void
proto_reg_handoff_sita(void)
{
dissector_handle_t lapb_handle;
dissector_handle_t frame_relay_handle;
dissector_handle_t uts_handle;
dissector_handle_t ipars_handle;
lapb_handle = find_dissector("lapb");
frame_relay_handle = find_dissector("fr");
uts_handle = find_dissector("uts");
ipars_handle = find_dissector("ipars");
dissector_add_uint("sita.proto", SITA_PROTO_BOP_LAPB, lapb_handle);
dissector_add_uint("sita.proto", SITA_PROTO_BOP_FRL, frame_relay_handle);
dissector_add_uint("sita.proto", SITA_PROTO_UTS, uts_handle);
dissector_add_uint("sita.proto", SITA_PROTO_ALC, ipars_handle);
dissector_add_uint("wtap_encap", WTAP_ENCAP_SITA, sita_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-skinny.c
|
/* Do not modify this file. Changes will be overwritten */
/* Generated Automatically */
/* packet-skinny.c */
/* packet-skinny.c
* Dissector for the Skinny Client Control Protocol
* (The "D-Channel"-Protocol for Cisco Systems' IP-Phones)
*
* Author: Diederik de Groot <[email protected]>, Copyright 2014
* Rewritten to support newer skinny protocolversions (V0-V22)
* Based on previous versions/contributions:
* - Joerg Mayer <[email protected]>, Copyright 2001
* - Paul E. Erkkila ([email protected]) - fleshed out the decode
* skeleton to report values for most message/message fields.
* Much help from Guy Harris on figuring out the wireshark api.
* - packet-aim.c by Ralf Hoelzer <[email protected]>, Copyright 2000
* - Wireshark - Network traffic analyzer,
* By Gerald Combs <[email protected]>, Copyright 1998
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
* Generated automatically Using (from wireshark base directory):
* cog.py -D xmlfile=tools/SkinnyProtocolOptimized.xml -d -c -o epan/dissectors/packet-skinny.c epan/dissectors/packet-skinny.c.in
*/
/* c-basic-offset: 2; tab-width: 8; indent-tabs-mode: nil
* vi: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/conversation.h>
#include <epan/wmem_scopes.h>
#include <epan/to_str.h>
#include <epan/reassemble.h>
#include <epan/tap.h>
#include <epan/ptvcursor.h>
#include "packet-rtp.h"
#include "packet-tcp.h"
#include "packet-tls.h"
#include "packet-skinny.h"
/* un-comment the following as well as this line in conversation.c, to enable debug printing */
/* #define DEBUG_CONVERSATION */
#include "conversation_debug.h"
void proto_register_skinny(void);
void proto_reg_handoff_skinny(void);
#define TCP_PORT_SKINNY 2000 /* Not IANA registered */
#define SSL_PORT_SKINNY 2443 /* IANA assigned to PowerClient Central Storage Facility */
#define BASIC_MSG_TYPE 0x00
#define V10_MSG_TYPE 0x0A
#define V11_MSG_TYPE 0x0B
#define V15_MSG_TYPE 0x0F
#define V16_MSG_TYPE 0x10
#define V17_MSG_TYPE 0x11
#define V18_MSG_TYPE 0x12
#define V19_MSG_TYPE 0x13
#define V20_MSG_TYPE 0x14
#define V21_MSG_TYPE 0x15
#define V22_MSG_TYPE 0x16
static const value_string header_version[] = {
{ BASIC_MSG_TYPE, "Basic" },
{ V10_MSG_TYPE, "V10" },
{ V11_MSG_TYPE, "V11" },
{ V15_MSG_TYPE, "V15" },
{ V16_MSG_TYPE, "V16" },
{ V17_MSG_TYPE, "V17" },
{ V18_MSG_TYPE, "V18" },
{ V19_MSG_TYPE, "V19" },
{ V20_MSG_TYPE, "V20" },
{ V21_MSG_TYPE, "V21" },
{ V22_MSG_TYPE, "V22" },
{ 0 , NULL }
};
/* Declare MessageId */
static const value_string message_id[] = {
{ 0x0000, "KeepAliveReq" },
{ 0x0001, "RegisterReq" },
{ 0x0002, "IpPort" },
{ 0x0003, "KeypadButton" },
{ 0x0004, "EnblocCall" },
{ 0x0005, "Stimulus" },
{ 0x0006, "OffHook" },
{ 0x0007, "OnHook" },
{ 0x0008, "HookFlash" },
{ 0x0009, "ForwardStatReq" },
{ 0x000a, "SpeedDialStatReq" },
{ 0x000b, "LineStatReq" },
{ 0x000c, "ConfigStatReq" },
{ 0x000d, "TimeDateReq" },
{ 0x000e, "ButtonTemplateReq" },
{ 0x000f, "VersionReq" },
{ 0x0010, "CapabilitiesRes" },
{ 0x0012, "ServerReq" },
{ 0x0020, "Alarm" },
{ 0x0021, "MulticastMediaReceptionAck" },
{ 0x0022, "OpenReceiveChannelAck" },
{ 0x0023, "ConnectionStatisticsRes" },
{ 0x0024, "OffHookWithCallingPartyNumber" },
{ 0x0025, "SoftKeySetReq" },
{ 0x0026, "SoftKeyEvent" },
{ 0x0027, "UnregisterReq" },
{ 0x0028, "SoftKeyTemplateReq" },
{ 0x0029, "RegisterTokenReq" },
{ 0x002a, "MediaTransmissionFailure" },
{ 0x002b, "HeadsetStatus" },
{ 0x002c, "MediaResourceNotification" },
{ 0x002d, "RegisterAvailableLines" },
{ 0x002e, "DeviceToUserData" },
{ 0x002f, "DeviceToUserDataResponse" },
{ 0x0030, "UpdateCapabilities" },
{ 0x0031, "OpenMultiMediaReceiveChannelAck" },
{ 0x0032, "ClearConference" },
{ 0x0033, "ServiceURLStatReq" },
{ 0x0034, "FeatureStatReq" },
{ 0x0035, "CreateConferenceRes" },
{ 0x0036, "DeleteConferenceRes" },
{ 0x0037, "ModifyConferenceRes" },
{ 0x0038, "AddParticipantRes" },
{ 0x0039, "AuditConferenceRes" },
{ 0x0040, "AuditParticipantRes" },
{ 0x0041, "DeviceToUserDataVersion1" },
{ 0x0042, "DeviceToUserDataResponseVersion1" },
{ 0x0043, "CapabilitiesV2Res" },
{ 0x0044, "CapabilitiesV3Res" },
{ 0x0045, "PortRes" },
{ 0x0046, "QoSResvNotify" },
{ 0x0047, "QoSErrorNotify" },
{ 0x0048, "SubscriptionStatReq" },
{ 0x0049, "MediaPathEvent" },
{ 0x004a, "MediaPathCapability" },
{ 0x004c, "MwiNotification" },
{ 0x0081, "RegisterAck" },
{ 0x0082, "StartTone" },
{ 0x0083, "StopTone" },
{ 0x0085, "SetRinger" },
{ 0x0086, "SetLamp" },
{ 0x0087, "SetHookFlashDetect" },
{ 0x0088, "SetSpeakerMode" },
{ 0x0089, "SetMicroMode" },
{ 0x008a, "StartMediaTransmission" },
{ 0x008b, "StopMediaTransmission" },
{ 0x008f, "CallInfo" },
{ 0x0090, "ForwardStatRes" },
{ 0x0091, "SpeedDialStatRes" },
{ 0x0092, "LineStatRes" },
{ 0x0093, "ConfigStatRes" },
{ 0x0094, "TimeDateRes" },
{ 0x0095, "StartSessionTransmission" },
{ 0x0096, "StopSessionTransmission" },
{ 0x0097, "ButtonTemplateRes" },
{ 0x0098, "VersionRes" },
{ 0x0099, "DisplayText" },
{ 0x009a, "ClearDisplay" },
{ 0x009b, "CapabilitiesReq" },
{ 0x009d, "RegisterReject" },
{ 0x009e, "ServerRes" },
{ 0x009f, "Reset" },
{ 0x0100, "KeepAliveAck" },
{ 0x0101, "StartMulticastMediaReception" },
{ 0x0102, "StartMulticastMediaTransmission" },
{ 0x0103, "StopMulticastMediaReception" },
{ 0x0104, "StopMulticastMediaTransmission" },
{ 0x0105, "OpenReceiveChannel" },
{ 0x0106, "CloseReceiveChannel" },
{ 0x0107, "ConnectionStatisticsReq" },
{ 0x0108, "SoftKeyTemplateRes" },
{ 0x0109, "SoftKeySetRes" },
{ 0x0110, "SelectSoftKeys" },
{ 0x0111, "CallState" },
{ 0x0112, "DisplayPromptStatus" },
{ 0x0113, "ClearPromptStatus" },
{ 0x0114, "DisplayNotify" },
{ 0x0115, "ClearNotify" },
{ 0x0116, "ActivateCallPlane" },
{ 0x0117, "DeactivateCallPlane" },
{ 0x0118, "UnregisterAck" },
{ 0x0119, "BackSpaceRes" },
{ 0x011a, "RegisterTokenAck" },
{ 0x011b, "RegisterTokenReject" },
{ 0x011c, "StartMediaFailureDetection" },
{ 0x011d, "DialedNumber" },
{ 0x011e, "UserToDeviceData" },
{ 0x011f, "FeatureStatRes" },
{ 0x0120, "DisplayPriNotify" },
{ 0x0121, "ClearPriNotify" },
{ 0x0122, "StartAnnouncement" },
{ 0x0123, "StopAnnouncement" },
{ 0x0124, "AnnouncementFinish" },
{ 0x0127, "NotifyDtmfTone" },
{ 0x0128, "SendDtmfTone" },
{ 0x0129, "SubscribeDtmfPayloadReq" },
{ 0x012a, "SubscribeDtmfPayloadRes" },
{ 0x012b, "SubscribeDtmfPayloadErr" },
{ 0x012c, "UnSubscribeDtmfPayloadReq" },
{ 0x012d, "UnSubscribeDtmfPayloadRes" },
{ 0x012e, "UnSubscribeDtmfPayloadErr" },
{ 0x012f, "ServiceURLStatRes" },
{ 0x0130, "CallSelectStatRes" },
{ 0x0131, "OpenMultiMediaReceiveChannel" },
{ 0x0132, "StartMultiMediaTransmission" },
{ 0x0133, "StopMultiMediaTransmission" },
{ 0x0134, "MiscellaneousCommand" },
{ 0x0135, "FlowControlCommand" },
{ 0x0136, "CloseMultiMediaReceiveChannel" },
{ 0x0137, "CreateConferenceReq" },
{ 0x0138, "DeleteConferenceReq" },
{ 0x0139, "ModifyConferenceReq" },
{ 0x013a, "AddParticipantReq" },
{ 0x013b, "DropParticipantReq" },
{ 0x013c, "AuditConferenceReq" },
{ 0x013d, "AuditParticipantReq" },
{ 0x013e, "ChangeParticipantReq" },
{ 0x013f, "UserToDeviceDataVersion1" },
{ 0x0140, "VideoDisplayCommand" },
{ 0x0141, "FlowControlNotify" },
{ 0x0142, "ConfigStatV2Res" },
{ 0x0143, "DisplayNotifyV2" },
{ 0x0144, "DisplayPriNotifyV2" },
{ 0x0145, "DisplayPromptStatusV2" },
{ 0x0146, "FeatureStatV2Res" },
{ 0x0147, "LineStatV2Res" },
{ 0x0148, "ServiceURLStatV2Res" },
{ 0x0149, "SpeedDialStatV2Res" },
{ 0x014a, "CallInfoV2" },
{ 0x014b, "PortReq" },
{ 0x014c, "PortClose" },
{ 0x014d, "QoSListen" },
{ 0x014e, "QoSPath" },
{ 0x014f, "QoSTeardown" },
{ 0x0150, "UpdateDSCP" },
{ 0x0151, "QoSModify" },
{ 0x0152, "SubscriptionStatRes" },
{ 0x0153, "Notification" },
{ 0x0154, "StartMediaTransmissionAck" },
{ 0x0155, "StartMultiMediaTransmissionAck" },
{ 0x0156, "CallHistoryInfo" },
{ 0x0157, "LocationInfo" },
{ 0x0158, "MwiRes" },
{ 0x0159, "AddOnDeviceCapabilities" },
{ 0x015a, "EnhancedAlarm" },
{ 0x015e, "CallCountReq" },
{ 0x015f, "CallCountResp" },
{ 0x0160, "RecordingStatus" },
{ 0x8000, "SPCPRegisterTokenReq" },
{ 0x8100, "SPCPRegisterTokenAck" },
{ 0x8101, "SPCPRegisterTokenReject" },
{0 , NULL}
};
static value_string_ext message_id_ext = VALUE_STRING_EXT_INIT(message_id);
/* Declare Enums and Defines */
static const value_string DisplayLabels_36[] = {
{ 0x00000, "Empty" },
{ 0x00002, "Acct" },
{ 0x00003, "Flash" },
{ 0x00004, "Login" },
{ 0x00005, "Device In Home Location" },
{ 0x00006, "Device In Roaming Location" },
{ 0x00007, "Enter Authorization Code" },
{ 0x00008, "Enter Client Matter Code" },
{ 0x00009, "Calls Available For Pickup" },
{ 0x0000a, "Cm Fallback Service Operating" },
{ 0x0000b, "Max Phones Exceeded" },
{ 0x0000c, "Waiting To Rehome" },
{ 0x0000d, "Please End Call" },
{ 0x0000e, "Paging" },
{ 0x0000f, "Select Line" },
{ 0x00010, "Transfer Destination Is Busy" },
{ 0x00011, "Select A Service" },
{ 0x00012, "Local Services" },
{ 0x00013, "Enter Search Criteria" },
{ 0x00014, "Night Service" },
{ 0x00015, "Night Service Active" },
{ 0x00016, "Night Service Disabled" },
{ 0x00017, "Login Successful" },
{ 0x00018, "Wrong Pin" },
{ 0x00019, "Please Enter Pin" },
{ 0x0001a, "Of" },
{ 0x0001b, "Records 1 To" },
{ 0x0001c, "No Record Found" },
{ 0x0001d, "Search Results" },
{ 0x0001e, "Calls In Queue" },
{ 0x0001f, "Join To Hunt Group" },
{ 0x00020, "Ready" },
{ 0x00021, "Notready" },
{ 0x00022, "Call On Hold" },
{ 0x00023, "Hold Reversion" },
{ 0x00024, "Setup Failed" },
{ 0x00025, "No Resources" },
{ 0x00026, "Device Not Authorized" },
{ 0x00027, "Monitoring" },
{ 0x00028, "Recording Awaiting Call To Be Active" },
{ 0x00029, "Recording Already In Progress" },
{ 0x0002a, "Inactive Recording Session" },
{ 0x0002b, "Mobility" },
{ 0x0002c, "Whisper" },
{ 0x0002d, "Forward All" },
{ 0x0002e, "Malicious Call Id" },
{ 0x0002f, "Group Pickup" },
{ 0x00030, "Remove Last Participant" },
{ 0x00031, "Other Pickup" },
{ 0x00032, "Video" },
{ 0x00033, "End Call" },
{ 0x00034, "Conference List" },
{ 0x00035, "Quality Reporting Tool" },
{ 0x00036, "Hunt Group" },
{ 0x00037, "Use Line Or Join To Complete" },
{ 0x00038, "Do Not Disturb" },
{ 0x00039, "Do Not Disturb Is Active" },
{ 0x0003a, "Cfwdall Loop Detected" },
{ 0x0003b, "Cfwdall Hops Exceeded" },
{ 0x0003c, "Abbrdial" },
{ 0x0003d, "Pickup Is Unavailable" },
{ 0x0003e, "Conference Is Unavailable" },
{ 0x0003f, "Meetme Is Unavailable" },
{ 0x00040, "Cannot Retrieve Parked Call" },
{ 0x00041, "Cannot Send Call To Mobile" },
{ 0x00043, "Record" },
{ 0x00044, "Cannot Move Conversation" },
{ 0x00045, "Cw Off" },
{ 0x00046, "Coaching" },
{ 0x0004f, "Recording" },
{ 0x00050, "Recording Failed" },
{ 0x00051, "Connecting" },
{ 0x00000, NULL }
};
static value_string_ext DisplayLabels_36_ext = VALUE_STRING_EXT_INIT(DisplayLabels_36);
static const value_string DisplayLabels_200[] = {
{ 0x00001, "Redial" },
{ 0x00002, "Newcall" },
{ 0x00003, "Hold" },
{ 0x00004, "Transfer" },
{ 0x00005, "Cfwdall" },
{ 0x00006, "Cfwdbusy" },
{ 0x00007, "Cfwdnoanswer" },
{ 0x00008, "Backspace" },
{ 0x00009, "Endcall" },
{ 0x0000a, "Resume" },
{ 0x0000b, "Answer" },
{ 0x0000c, "Info" },
{ 0x0000d, "Confrn" },
{ 0x0000e, "Park" },
{ 0x0000f, "Join" },
{ 0x00010, "Meetme" },
{ 0x00011, "Pickup" },
{ 0x00012, "Gpickup" },
{ 0x00013, "Your Current Options" },
{ 0x00014, "Off Hook" },
{ 0x00015, "On Hook" },
{ 0x00016, "Ring Out" },
{ 0x00017, "From " },
{ 0x00018, "Connected" },
{ 0x00019, "Busy" },
{ 0x0001a, "Line In Use" },
{ 0x0001b, "Call Waiting" },
{ 0x0001c, "Call Transfer" },
{ 0x0001d, "Call Park" },
{ 0x0001e, "Call Proceed" },
{ 0x0001f, "In Use Remote" },
{ 0x00020, "Enter Number" },
{ 0x00021, "Call Park At" },
{ 0x00022, "Primary Only" },
{ 0x00023, "Temp Fail" },
{ 0x00024, "You Have Voicemail" },
{ 0x00025, "Forwarded To" },
{ 0x00026, "Can Not Complete Conference" },
{ 0x00027, "No Conference Bridge" },
{ 0x00028, "Can Not Hold Primary Control" },
{ 0x00029, "Invalid Conference Participant" },
{ 0x0002a, "In Conference Already" },
{ 0x0002b, "No Participant Info" },
{ 0x0002c, "Exceed Maximum Parties" },
{ 0x0002d, "Key Is Not Active" },
{ 0x0002e, "Error No License" },
{ 0x0002f, "Error Dbconfig" },
{ 0x00030, "Error Database" },
{ 0x00031, "Error Pass Limit" },
{ 0x00032, "Error Unknown" },
{ 0x00033, "Error Mismatch" },
{ 0x00034, "Conference" },
{ 0x00035, "Park Number" },
{ 0x00036, "Private" },
{ 0x00037, "Not Enough Bandwidth" },
{ 0x00038, "Unknown Number" },
{ 0x00039, "Rmlstc" },
{ 0x0003a, "Voicemail" },
{ 0x0003b, "Immdiv" },
{ 0x0003c, "Intrcpt" },
{ 0x0003d, "Setwtch" },
{ 0x0003e, "Trnsfvm" },
{ 0x0003f, "Dnd" },
{ 0x00040, "Divall" },
{ 0x00041, "Callback" },
{ 0x00042, "Network Congestion Rerouting" },
{ 0x00043, "Barge" },
{ 0x00044, "Failed To Setup Barge" },
{ 0x00045, "Another Barge Exists" },
{ 0x00046, "Incompatible Device Type" },
{ 0x00047, "No Park Number Available" },
{ 0x00048, "Callpark Reversion" },
{ 0x00049, "Service Is Not Active" },
{ 0x0004a, "High Traffic Try Again Later" },
{ 0x0004b, "Qrt" },
{ 0x0004c, "Mcid" },
{ 0x0004d, "Dirtrfr" },
{ 0x0004e, "Select" },
{ 0x0004f, "Conflist" },
{ 0x00050, "Idivert" },
{ 0x00051, "Cbarge" },
{ 0x00052, "Can Not Complete Transfer" },
{ 0x00053, "Can Not Join Calls" },
{ 0x00054, "Mcid Successful" },
{ 0x00055, "Number Not Configured" },
{ 0x00056, "Security Error" },
{ 0x00057, "Video Bandwidth Unavailable" },
{ 0x00058, "Vidmode" },
{ 0x00059, "Max Call Duration Timeout" },
{ 0x0005a, "Max Hold Duration Timeout" },
{ 0x0005b, "Opickup" },
{ 0x0005c, "Hlog" },
{ 0x0005d, "Logged Out Of Hunt Group" },
{ 0x0005e, "Park Slot Unavailable" },
{ 0x0005f, "No Call Available For Pickup" },
{ 0x00061, "External Transfer Restricted" },
{ 0x00062, "No Line Available For Pickup" },
{ 0x00063, "Path Replacement In Progress" },
{ 0x00064, "Unknown 2" },
{ 0x00065, "Mac Address" },
{ 0x00066, "Host Name" },
{ 0x00067, "Domain Name" },
{ 0x00068, "Ip Address" },
{ 0x00069, "Subnet Mask" },
{ 0x0006a, "Tftp Server 1" },
{ 0x0006b, "Default Router 1" },
{ 0x0006c, "Default Router 2" },
{ 0x0006d, "Default Router 3" },
{ 0x0006e, "Default Router 4" },
{ 0x0006f, "Default Router 5" },
{ 0x00070, "Dns Server 1" },
{ 0x00071, "Dns Server 2" },
{ 0x00072, "Dns Server 3" },
{ 0x00073, "Dns Server 4" },
{ 0x00074, "Dns Server 5" },
{ 0x00075, "Operational Vlan Id" },
{ 0x00076, "Admin Vlan Id" },
{ 0x00077, "Call Manager 1" },
{ 0x00078, "Call Manager 2" },
{ 0x00079, "Call Manager 3" },
{ 0x0007a, "Call Manager 4" },
{ 0x0007b, "Call Manager 5" },
{ 0x0007c, "Information Url" },
{ 0x0007d, "Directories Url" },
{ 0x0007e, "Messages Url" },
{ 0x0007f, "Services Url" },
{ 0x00000, NULL }
};
static value_string_ext DisplayLabels_200_ext = VALUE_STRING_EXT_INIT(DisplayLabels_200);
static const value_string DeviceType[] = {
{ 0x00001, "Station30SPplus" },
{ 0x00002, "Station12SPplus" },
{ 0x00003, "Station12SP" },
{ 0x00004, "Station12" },
{ 0x00005, "Station30VIP" },
{ 0x00006, "Cisco 7910" },
{ 0x00007, "StationTelecasterMgr" },
{ 0x00008, "Cisco 7940" },
{ 0x00009, "Cisco 7935" },
{ 0x0000a, "StationVGC" },
{ 0x0000b, "VGCVirtualPhone" },
{ 0x0000c, "StationATA186" },
{ 0x0000d, "StationATA188" },
{ 0x0000f, "EmccBase" },
{ 0x00014, "Virtual30SPplus" },
{ 0x00015, "StationPhoneApplication" },
{ 0x0001e, "AnalogAccess" },
{ 0x00028, "DigitalAccessTitan1" },
{ 0x00029, "Digital Access T1" },
{ 0x0002a, "DigitalAccessTitan2" },
{ 0x0002b, "DigitalAccessLennon" },
{ 0x0002f, "AnalogAccessElvis" },
{ 0x00030, "VGCGateway" },
{ 0x00032, "ConferenceBridge" },
{ 0x00033, "ConferenceBridgeYoko" },
{ 0x00034, "ConferenceBridgeDixieLand" },
{ 0x00035, "ConferenceBridgeSummit" },
{ 0x0003c, "H225" },
{ 0x0003d, "H323Phone" },
{ 0x0003e, "H323Gateway" },
{ 0x00046, "MusicOnHold" },
{ 0x00047, "Pilot" },
{ 0x00048, "TapiPort" },
{ 0x00049, "TapiRoutePoint" },
{ 0x00050, "VoiceInBox" },
{ 0x00051, "VoiceInboxAdmin" },
{ 0x00052, "LineAnnunciator" },
{ 0x00053, "SoftwareMtpDixieLand" },
{ 0x00054, "CiscoMediaServer" },
{ 0x00055, "ConferenceBridgeFlint" },
{ 0x00056, "ConferenceBridgeHetroGen" },
{ 0x00057, "ConferenceBridgeAudVid" },
{ 0x00058, "ConferenceHVideoBridge" },
{ 0x0005a, "RouteList" },
{ 0x00064, "LoadSimulator" },
{ 0x0006e, "MediaTerminationPoint" },
{ 0x0006f, "MediaTerminationPointYoko" },
{ 0x00070, "MediaTerminationPointDixieLand" },
{ 0x00071, "MediaTerminationPointSummit" },
{ 0x00073, "7941G" },
{ 0x00077, "7971" },
{ 0x00078, "MGCPStation" },
{ 0x00079, "MGCPTrunk" },
{ 0x0007a, "RASProxy" },
{ 0x0007c, "Cisco 7914 AddOn" },
{ 0x0007d, "Trunk" },
{ 0x0007e, "Annunciator" },
{ 0x0007f, "MonitorBridge" },
{ 0x00080, "Recorder" },
{ 0x00081, "MonitorBridgeYoko" },
{ 0x00083, "SipTrunk" },
{ 0x00084, "SipGateway" },
{ 0x00085, "WsmTrunk" },
{ 0x00086, "RemoteDestination" },
{ 0x000e3, "Cisco 7915 AddOn" },
{ 0x000e4, "Cisco 7915 AddOn 24" },
{ 0x000e5, "Cisco 7916 AddOn" },
{ 0x000e6, "Cisco 7916 AddOn 24" },
{ 0x000fd, "GenericDevice" },
{ 0x000fe, "UnknownMGCPGateway" },
{ 0x000ff, "NotDefined" },
{ 0x00113, "Nokia E Series" },
{ 0x0012e, "Cisco 7985" },
{ 0x00133, "7911" },
{ 0x00134, "Cisco 7961 GE" },
{ 0x00135, "7961G_GE" },
{ 0x0014f, "MotorolaCN622" },
{ 0x00150, "3rdPartySipBasic" },
{ 0x0015c, "Cisco 7931" },
{ 0x00166, "UnifiedCommunicator" },
{ 0x0016d, "7921" },
{ 0x00171, "7906" },
{ 0x00176, "3rdPartySipAdv" },
{ 0x00177, "Telepresence" },
{ 0x00178, "Nokia ICC client" },
{ 0x00194, "7962" },
{ 0x0019c, "3951" },
{ 0x001af, "7937" },
{ 0x001b2, "7942" },
{ 0x001b3, "7945" },
{ 0x001b4, "7965" },
{ 0x001b5, "7975" },
{ 0x001d4, "UnifiedMobileCommunicator" },
{ 0x001e4, "Cisco 7925" },
{ 0x001ed, "9971_CE" },
{ 0x001ef, "Cisco 6921" },
{ 0x001f0, "Cisco 6941" },
{ 0x001f1, "Cisco 6961" },
{ 0x001f7, "CSF" },
{ 0x00223, "Cisco 6901" },
{ 0x00224, "Cisco 6911" },
{ 0x00234, "Cisco 6945" },
{ 0x00249, "Cisco 8945" },
{ 0x0024a, "Cisco 8941" },
{ 0x00255, "CiscoTelepresenceMcu" },
{ 0x00257, "CiscoTelePresenceExchange" },
{ 0x00258, "CiscoTelePresenceSoftwareConferenceBridge" },
{ 0x00277, "ASSip" },
{ 0x0027b, "CtiRemoteDevice" },
{ 0x04e20, "7905" },
{ 0x07532, "7920" },
{ 0x07536, "7970" },
{ 0x07537, "7912" },
{ 0x07538, "7902" },
{ 0x07540, "Cisco IP Communicator" },
{ 0x07542, "7961G" },
{ 0x07543, "7936" },
{ 0x0754b, "AnalogPhone" },
{ 0x0754c, "ISDNBRIPhone" },
{ 0x07550, "SCCPGwVirtualPhone" },
{ 0x07553, "IP_STE" },
{ 0x08cc9, "CiscoTelePresenceConductor" },
{ 0x08d7b, "InteractiveVoiceResponse" },
{ 0x13880, "Cisco SPA 521S" },
{ 0x13883, "Cisco SPA 502G" },
{ 0x13884, "Cisco SPA 504G" },
{ 0x13885, "Cisco SPA 525G" },
{ 0x13887, "Cisco SPA 509G" },
{ 0x13889, "Cisco SPA 525G2" },
{ 0x1388b, "Cisco SPA 303G" },
{ 0x00000, NULL }
};
static value_string_ext DeviceType_ext = VALUE_STRING_EXT_INIT(DeviceType);
static const value_string KeyPadButton[] = {
{ 0x00000, "Zero" },
{ 0x00001, "One" },
{ 0x00002, "Two" },
{ 0x00003, "Three" },
{ 0x00004, "Four" },
{ 0x00005, "Five" },
{ 0x00006, "Six" },
{ 0x00007, "Seven" },
{ 0x00008, "Eight" },
{ 0x00009, "Nine" },
{ 0x0000a, "A" },
{ 0x0000b, "B" },
{ 0x0000c, "C" },
{ 0x0000d, "D" },
{ 0x0000e, "Star" },
{ 0x0000f, "Pound" },
{ 0x00010, "Plus" },
{ 0x00000, NULL }
};
static value_string_ext KeyPadButton_ext = VALUE_STRING_EXT_INIT(KeyPadButton);
static const value_string KeyPadButton_short[] = {
{ 0x00000, "0" },
{ 0x00001, "1" },
{ 0x00002, "2" },
{ 0x00003, "3" },
{ 0x00004, "4" },
{ 0x00005, "5" },
{ 0x00006, "6" },
{ 0x00007, "7" },
{ 0x00008, "8" },
{ 0x00009, "9" },
{ 0x0000a, "A" },
{ 0x0000b, "B" },
{ 0x0000c, "C" },
{ 0x0000d, "D" },
{ 0x0000e, "*" },
{ 0x0000f, "#" },
{ 0x00010, "+" },
{ 0x00000, NULL }
};
static value_string_ext KeyPadButton_short_ext = VALUE_STRING_EXT_INIT(KeyPadButton_short);
static const value_string DeviceStimulus[] = {
{ 0x00001, "LastNumberRedial" },
{ 0x00002, "SpeedDial" },
{ 0x00003, "Hold" },
{ 0x00004, "Transfer" },
{ 0x00005, "ForwardAll" },
{ 0x00006, "ForwardBusy" },
{ 0x00007, "ForwardNoAnswer" },
{ 0x00008, "Display" },
{ 0x00009, "Line" },
{ 0x0000a, "T120Chat" },
{ 0x0000b, "T120Whiteboard" },
{ 0x0000c, "T120ApplicationSharing" },
{ 0x0000d, "T120FileTransfer" },
{ 0x0000e, "Video" },
{ 0x0000f, "VoiceMail" },
{ 0x00010, "AnswerRelease" },
{ 0x00011, "AutoAnswer" },
{ 0x00012, "Select" },
{ 0x00013, "Privacy" },
{ 0x00014, "ServiceURL" },
{ 0x00015, "BLFSpeedDial" },
{ 0x00016, "DPark" },
{ 0x00017, "Intercom" },
{ 0x0001b, "MaliciousCall" },
{ 0x00021, "GenericAppB1" },
{ 0x00022, "GenericAppB2" },
{ 0x00023, "GenericAppB3" },
{ 0x00024, "GenericAppB4" },
{ 0x00025, "GenericAppB5" },
{ 0x0007b, "MeetMeConference" },
{ 0x0007d, "Conference" },
{ 0x0007e, "CallPark" },
{ 0x0007f, "CallPickUp" },
{ 0x00080, "GroupCallPickUp" },
{ 0x00081, "Mobility" },
{ 0x00082, "DoNotDisturb" },
{ 0x00083, "ConfList" },
{ 0x00084, "RemoveLastParticipant" },
{ 0x00085, "QRT" },
{ 0x00086, "CallBack" },
{ 0x00087, "OtherPickup" },
{ 0x00088, "VideoMode" },
{ 0x00089, "NewCall" },
{ 0x0008a, "EndCall" },
{ 0x0008b, "HLog" },
{ 0x0008f, "Queuing" },
{ 0x000ff, "MaxStimulusValue" },
{ 0x00000, NULL }
};
static value_string_ext DeviceStimulus_ext = VALUE_STRING_EXT_INIT(DeviceStimulus);
#define MEDIA_PAYLOAD_G711ALAW64K 0x00002 /* audio */
#define MEDIA_PAYLOAD_G711ALAW56K 0x00003 /* audio */
#define MEDIA_PAYLOAD_G711ULAW64K 0x00004 /* audio */
#define MEDIA_PAYLOAD_G711ULAW56K 0x00005 /* audio */
#define MEDIA_PAYLOAD_G722_64K 0x00006 /* audio */
#define MEDIA_PAYLOAD_G722_56K 0x00007 /* audio */
#define MEDIA_PAYLOAD_G722_48K 0x00008 /* audio */
#define MEDIA_PAYLOAD_G7231 0x00009 /* audio */
#define MEDIA_PAYLOAD_G728 0x0000a /* audio */
#define MEDIA_PAYLOAD_G729 0x0000b /* audio */
#define MEDIA_PAYLOAD_G729ANNEXA 0x0000c /* audio */
#define MEDIA_PAYLOAD_G729ANNEXB 0x0000f /* audio */
#define MEDIA_PAYLOAD_G729ANNEXAWANNEXB 0x00010 /* audio */
#define MEDIA_PAYLOAD_GSM_FULL_RATE 0x00012 /* audio */
#define MEDIA_PAYLOAD_GSM_HALF_RATE 0x00013 /* audio */
#define MEDIA_PAYLOAD_GSM_ENHANCED_FULL_RATE 0x00014 /* audio */
#define MEDIA_PAYLOAD_WIDE_BAND_256K 0x00019 /* audio */
#define MEDIA_PAYLOAD_DATA64 0x00020 /* audio */
#define MEDIA_PAYLOAD_DATA56 0x00021 /* audio */
#define MEDIA_PAYLOAD_G7221_32K 0x00028 /* audio */
#define MEDIA_PAYLOAD_G7221_24K 0x00029 /* audio */
#define MEDIA_PAYLOAD_AAC 0x0002a /* audio */
#define MEDIA_PAYLOAD_MP4ALATM_128 0x0002b /* audio */
#define MEDIA_PAYLOAD_MP4ALATM_64 0x0002c /* audio */
#define MEDIA_PAYLOAD_MP4ALATM_56 0x0002d /* audio */
#define MEDIA_PAYLOAD_MP4ALATM_48 0x0002e /* audio */
#define MEDIA_PAYLOAD_MP4ALATM_32 0x0002f /* audio */
#define MEDIA_PAYLOAD_MP4ALATM_24 0x00030 /* audio */
#define MEDIA_PAYLOAD_MP4ALATM_NA 0x00031 /* audio */
#define MEDIA_PAYLOAD_GSM 0x00050 /* audio */
#define MEDIA_PAYLOAD_G726_32K 0x00052 /* audio */
#define MEDIA_PAYLOAD_G726_24K 0x00053 /* audio */
#define MEDIA_PAYLOAD_G726_16K 0x00054 /* audio */
#define MEDIA_PAYLOAD_ILBC 0x00056 /* audio */
#define MEDIA_PAYLOAD_ISAC 0x00059 /* audio */
#define MEDIA_PAYLOAD_OPUS 0x0005a /* audio */
#define MEDIA_PAYLOAD_AMR 0x00061 /* audio */
#define MEDIA_PAYLOAD_AMR_WB 0x00062 /* audio */
#define MEDIA_PAYLOAD_H261 0x00064 /* video */
#define MEDIA_PAYLOAD_H263 0x00065 /* video */
#define MEDIA_PAYLOAD_VIEO 0x00066 /* video */
#define MEDIA_PAYLOAD_H264 0x00067 /* video */
#define MEDIA_PAYLOAD_H264_SVC 0x00068 /* video */
#define MEDIA_PAYLOAD_T120 0x00069 /* video */
#define MEDIA_PAYLOAD_H224 0x0006a /* video */
#define MEDIA_PAYLOAD_T38FAX 0x0006b /* video */
#define MEDIA_PAYLOAD_TOTE 0x0006c /* video */
#define MEDIA_PAYLOAD_H265 0x0006d /* video */
#define MEDIA_PAYLOAD_H264_UC 0x0006e /* video */
#define MEDIA_PAYLOAD_XV150_MR_711U 0x0006f /* video */
#define MEDIA_PAYLOAD_NSE_VBD_711U 0x00070 /* video */
#define MEDIA_PAYLOAD_XV150_MR_729A 0x00071 /* video */
#define MEDIA_PAYLOAD_NSE_VBD_729A 0x00072 /* video */
#define MEDIA_PAYLOAD_H264_FEC 0x00073 /* video */
#define MEDIA_PAYLOAD_CLEAR_CHAN 0x00078 /* data */
#define MEDIA_PAYLOAD_UNIVERSAL_XCODER 0x000de /* data */
#define MEDIA_PAYLOAD_RFC2833_DYNPAYLOAD 0x00101 /* data */
#define MEDIA_PAYLOAD_PASSTHROUGH 0x00102 /* data */
#define MEDIA_PAYLOAD_DYNAMIC_PAYLOAD_PASSTHRU 0x00103 /* data */
#define MEDIA_PAYLOAD_DTMF_OOB 0x00104 /* data */
#define MEDIA_PAYLOAD_INBAND_DTMF_RFC2833 0x00105 /* data */
#define MEDIA_PAYLOAD_CFB_TONES 0x00106 /* data */
#define MEDIA_PAYLOAD_NOAUDIO 0x0012b /* data */
#define MEDIA_PAYLOAD_V150_LC_MODEMRELAY 0x0012c /* data */
#define MEDIA_PAYLOAD_V150_LC_SPRT 0x0012d /* data */
#define MEDIA_PAYLOAD_V150_LC_SSE 0x0012e /* data */
#define MEDIA_PAYLOAD_MAX 0x0012f /* data */
static const value_string Media_PayloadType[] = {
{ MEDIA_PAYLOAD_G711ALAW64K, "Media_Payload_G711Alaw64k" },
{ MEDIA_PAYLOAD_G711ALAW56K, "Media_Payload_G711Alaw56k" },
{ MEDIA_PAYLOAD_G711ULAW64K, "Media_Payload_G711Ulaw64k" },
{ MEDIA_PAYLOAD_G711ULAW56K, "Media_Payload_G711Ulaw56k" },
{ MEDIA_PAYLOAD_G722_64K, "Media_Payload_G722_64k" },
{ MEDIA_PAYLOAD_G722_56K, "Media_Payload_G722_56k" },
{ MEDIA_PAYLOAD_G722_48K, "Media_Payload_G722_48k" },
{ MEDIA_PAYLOAD_G7231, "Media_Payload_G7231" },
{ MEDIA_PAYLOAD_G728, "Media_Payload_G728" },
{ MEDIA_PAYLOAD_G729, "Media_Payload_G729" },
{ MEDIA_PAYLOAD_G729ANNEXA, "Media_Payload_G729AnnexA" },
{ MEDIA_PAYLOAD_G729ANNEXB, "Media_Payload_G729AnnexB" },
{ MEDIA_PAYLOAD_G729ANNEXAWANNEXB, "Media_Payload_G729AnnexAwAnnexB" },
{ MEDIA_PAYLOAD_GSM_FULL_RATE, "Media_Payload_GSM_Full_Rate" },
{ MEDIA_PAYLOAD_GSM_HALF_RATE, "Media_Payload_GSM_Half_Rate" },
{ MEDIA_PAYLOAD_GSM_ENHANCED_FULL_RATE, "Media_Payload_GSM_Enhanced_Full_Rate" },
{ MEDIA_PAYLOAD_WIDE_BAND_256K, "Media_Payload_Wide_Band_256k" },
{ MEDIA_PAYLOAD_DATA64, "Media_Payload_Data64" },
{ MEDIA_PAYLOAD_DATA56, "Media_Payload_Data56" },
{ MEDIA_PAYLOAD_G7221_32K, "Media_Payload_G7221_32K" },
{ MEDIA_PAYLOAD_G7221_24K, "Media_Payload_G7221_24K" },
{ MEDIA_PAYLOAD_AAC, "Media_Payload_AAC" },
{ MEDIA_PAYLOAD_MP4ALATM_128, "Media_Payload_MP4ALATM_128" },
{ MEDIA_PAYLOAD_MP4ALATM_64, "Media_Payload_MP4ALATM_64" },
{ MEDIA_PAYLOAD_MP4ALATM_56, "Media_Payload_MP4ALATM_56" },
{ MEDIA_PAYLOAD_MP4ALATM_48, "Media_Payload_MP4ALATM_48" },
{ MEDIA_PAYLOAD_MP4ALATM_32, "Media_Payload_MP4ALATM_32" },
{ MEDIA_PAYLOAD_MP4ALATM_24, "Media_Payload_MP4ALATM_24" },
{ MEDIA_PAYLOAD_MP4ALATM_NA, "Media_Payload_MP4ALATM_NA" },
{ MEDIA_PAYLOAD_GSM, "Media_Payload_GSM" },
{ MEDIA_PAYLOAD_G726_32K, "Media_Payload_G726_32K" },
{ MEDIA_PAYLOAD_G726_24K, "Media_Payload_G726_24K" },
{ MEDIA_PAYLOAD_G726_16K, "Media_Payload_G726_16K" },
{ MEDIA_PAYLOAD_ILBC, "Media_Payload_ILBC" },
{ MEDIA_PAYLOAD_ISAC, "Media_Payload_ISAC" },
{ MEDIA_PAYLOAD_OPUS, "Media_Payload_OPUS" },
{ MEDIA_PAYLOAD_AMR, "Media_Payload_AMR" },
{ MEDIA_PAYLOAD_AMR_WB, "Media_Payload_AMR_WB" },
{ MEDIA_PAYLOAD_H261, "Media_Payload_H261" },
{ MEDIA_PAYLOAD_H263, "Media_Payload_H263" },
{ MEDIA_PAYLOAD_VIEO, "Media_Payload_Vieo" },
{ MEDIA_PAYLOAD_H264, "Media_Payload_H264" },
{ MEDIA_PAYLOAD_H264_SVC, "Media_Payload_H264_SVC" },
{ MEDIA_PAYLOAD_T120, "Media_Payload_T120" },
{ MEDIA_PAYLOAD_H224, "Media_Payload_H224" },
{ MEDIA_PAYLOAD_T38FAX, "Media_Payload_T38Fax" },
{ MEDIA_PAYLOAD_TOTE, "Media_Payload_TOTE" },
{ MEDIA_PAYLOAD_H265, "Media_Payload_H265" },
{ MEDIA_PAYLOAD_H264_UC, "Media_Payload_H264_UC" },
{ MEDIA_PAYLOAD_XV150_MR_711U, "Media_Payload_XV150_MR_711U" },
{ MEDIA_PAYLOAD_NSE_VBD_711U, "Media_Payload_NSE_VBD_711U" },
{ MEDIA_PAYLOAD_XV150_MR_729A, "Media_Payload_XV150_MR_729A" },
{ MEDIA_PAYLOAD_NSE_VBD_729A, "Media_Payload_NSE_VBD_729A" },
{ MEDIA_PAYLOAD_H264_FEC, "Media_Payload_H264_FEC" },
{ MEDIA_PAYLOAD_CLEAR_CHAN, "Media_Payload_Clear_Chan" },
{ MEDIA_PAYLOAD_UNIVERSAL_XCODER, "Media_Payload_Universal_Xcoder" },
{ MEDIA_PAYLOAD_RFC2833_DYNPAYLOAD, "Media_Payload_RFC2833_DynPayload" },
{ MEDIA_PAYLOAD_PASSTHROUGH, "Media_Payload_PassThrough" },
{ MEDIA_PAYLOAD_DYNAMIC_PAYLOAD_PASSTHRU, "Media_Payload_Dynamic_Payload_PassThru" },
{ MEDIA_PAYLOAD_DTMF_OOB, "Media_Payload_DTMF_OOB" },
{ MEDIA_PAYLOAD_INBAND_DTMF_RFC2833, "Media_Payload_Inband_DTMF_RFC2833" },
{ MEDIA_PAYLOAD_CFB_TONES, "Media_Payload_CFB_Tones" },
{ MEDIA_PAYLOAD_NOAUDIO, "Media_Payload_NoAudio" },
{ MEDIA_PAYLOAD_V150_LC_MODEMRELAY, "Media_Payload_v150_LC_ModemRelay" },
{ MEDIA_PAYLOAD_V150_LC_SPRT, "Media_Payload_v150_LC_SPRT" },
{ MEDIA_PAYLOAD_V150_LC_SSE, "Media_Payload_v150_LC_SSE" },
{ MEDIA_PAYLOAD_MAX, "Media_Payload_Max" },
{ 0x00000, NULL }
};
static value_string_ext Media_PayloadType_ext = VALUE_STRING_EXT_INIT(Media_PayloadType);
static const value_string Media_G723BitRate[] = {
{ 0x00001, "Media_G723BRate_5_3" },
{ 0x00002, "Media_G723BRate_6_3" },
{ 0x00000, NULL }
};
static value_string_ext Media_G723BitRate_ext = VALUE_STRING_EXT_INIT(Media_G723BitRate);
static const value_string DeviceAlarmSeverity[] = {
{ 0x00000, "Critical" },
{ 0x00001, "Warning" },
{ 0x00002, "Informational" },
{ 0x00004, "Unknown" },
{ 0x00007, "Major" },
{ 0x00008, "Minor" },
{ 0x0000a, "Marginal" },
{ 0x00014, "TraceInfo" },
{ 0x00000, NULL }
};
static value_string_ext DeviceAlarmSeverity_ext = VALUE_STRING_EXT_INIT(DeviceAlarmSeverity);
static const value_string MulticastMediaReceptionStatus[] = {
{ 0x00000, "Ok" },
{ 0x00001, "Error" },
{ 0x00000, NULL }
};
static value_string_ext MulticastMediaReceptionStatus_ext = VALUE_STRING_EXT_INIT(MulticastMediaReceptionStatus);
static const value_string MediaStatus[] = {
{ 0x00000, "Ok" },
{ 0x00001, "Unknown" },
{ 0x00002, "NotEnoughChannels" },
{ 0x00003, "CodecTooComplex" },
{ 0x00004, "InvalidPartyID" },
{ 0x00005, "InvalidCallRef" },
{ 0x00006, "InvalidCodec" },
{ 0x00007, "InvalidPacketSize" },
{ 0x00008, "OutOfSockets" },
{ 0x00009, "EncoderOrDecoderFailed" },
{ 0x0000a, "InvalidDynamicPayloadType" },
{ 0x0000b, "RequestedIpAddrTypeUnAvailable" },
{ 0x000ff, "DeviceOnHook" },
{ 0x00000, NULL }
};
static value_string_ext MediaStatus_ext = VALUE_STRING_EXT_INIT(MediaStatus);
#define IPADDRTYPE_IPV4 0x00000
#define IPADDRTYPE_IPV6 0x00001
#define IPADDRTYPE_IPV4_V6 0x00002
#define IPADDRTYPE_IP_INVALID 0x00003
static const value_string IpAddrType[] = {
{ IPADDRTYPE_IPV4, "v4" },
{ IPADDRTYPE_IPV6, "v6" },
{ IPADDRTYPE_IPV4_V6, "v4_v6" },
{ IPADDRTYPE_IP_INVALID, "_Invalid" },
{ 0x00000, NULL }
};
static value_string_ext IpAddrType_ext = VALUE_STRING_EXT_INIT(IpAddrType);
static const value_string StatsProcessingType[] = {
{ 0x00000, "clearStats" },
{ 0x00001, "doNotClearStats" },
{ 0x00000, NULL }
};
static value_string_ext StatsProcessingType_ext = VALUE_STRING_EXT_INIT(StatsProcessingType);
static const value_string SoftKeySet[] = {
{ 0x00000, "On Hook" },
{ 0x00001, "Connected" },
{ 0x00002, "On Hold" },
{ 0x00003, "Ring In" },
{ 0x00004, "Off Hook" },
{ 0x00005, "Connected Transferable" },
{ 0x00006, "Digits Following" },
{ 0x00007, "Connected Conference" },
{ 0x00008, "Ring Out" },
{ 0x00009, "OffHook with Features" },
{ 0x0000a, "In Use Hint" },
{ 0x0000b, "On Hook with Stealable Call" },
{ 0x00000, NULL }
};
static value_string_ext SoftKeySet_ext = VALUE_STRING_EXT_INIT(SoftKeySet);
static const value_string SoftKeyEvent[] = {
{ 0x00001, "Redial" },
{ 0x00002, "NewCall" },
{ 0x00003, "Hold" },
{ 0x00004, "Transfer" },
{ 0x00005, "CfwdAll" },
{ 0x00006, "CfwdBusy" },
{ 0x00007, "CfwdNoAnswer" },
{ 0x00008, "BackSpace" },
{ 0x00009, "EndCall" },
{ 0x0000a, "Resume" },
{ 0x0000b, "Answer" },
{ 0x0000c, "Info" },
{ 0x0000d, "Confrn" },
{ 0x0000e, "Park" },
{ 0x0000f, "Join" },
{ 0x00010, "MeetMe" },
{ 0x00011, "PickUp" },
{ 0x00012, "GrpPickup" },
{ 0x00013, "Your current options" },
{ 0x00014, "Off Hook" },
{ 0x00015, "On Hook" },
{ 0x00016, "Ring out" },
{ 0x00017, "From " },
{ 0x00018, "Connected" },
{ 0x00019, "Busy" },
{ 0x0001a, "Line In Use" },
{ 0x0001b, "Call Waiting" },
{ 0x0001c, "Call Transfer" },
{ 0x0001d, "Call Park" },
{ 0x0001e, "Call Proceed" },
{ 0x0001f, "In Use Remote" },
{ 0x00020, "Enter number" },
{ 0x00021, "Call park At" },
{ 0x00022, "Primary Only" },
{ 0x00023, "Temp Fail" },
{ 0x00024, "You Have a VoiceMail" },
{ 0x00025, "Forwarded to" },
{ 0x00026, "Can Not Complete Conference" },
{ 0x00027, "No Conference Bridge" },
{ 0x00028, "Can Not Hold Primary Control" },
{ 0x00029, "Invalid Conference Participant" },
{ 0x0002a, "In Conference Already" },
{ 0x0002b, "No Participant Info" },
{ 0x0002c, "Exceed Maximum Parties" },
{ 0x0002d, "Key Is Not Active" },
{ 0x0002e, "Error No License" },
{ 0x0002f, "Error DBConfig" },
{ 0x00030, "Error Database" },
{ 0x00031, "Error Pass Limit" },
{ 0x00032, "Error Unknown" },
{ 0x00033, "Error Mismatch" },
{ 0x00034, "Conference" },
{ 0x00035, "Park Number" },
{ 0x00036, "Private" },
{ 0x00037, "Not Enough Bandwidth" },
{ 0x00038, "Unknown Number" },
{ 0x00039, "RmLstC" },
{ 0x0003a, "Voicemail" },
{ 0x0003b, "ImmDiv" },
{ 0x0003c, "Intrcpt" },
{ 0x0003d, "SetWtch" },
{ 0x0003e, "TrnsfVM" },
{ 0x0003f, "DND" },
{ 0x00040, "DivAll" },
{ 0x00041, "CallBack" },
{ 0x00042, "Network congestion,rerouting" },
{ 0x00043, "Barge" },
{ 0x00044, "Failed to setup Barge" },
{ 0x00045, "Another Barge exists" },
{ 0x00046, "Incompatible device type" },
{ 0x00047, "No Park Number Available" },
{ 0x00048, "CallPark Reversion" },
{ 0x00049, "Service is not Active" },
{ 0x0004a, "High Traffic Try Again Later" },
{ 0x0004b, "QRT" },
{ 0x0004c, "MCID" },
{ 0x0004d, "DirTrfr" },
{ 0x0004e, "Select" },
{ 0x0004f, "ConfList" },
{ 0x00050, "iDivert" },
{ 0x00051, "cBarge" },
{ 0x00052, "Can Not Complete Transfer" },
{ 0x00053, "Can Not Join Calls" },
{ 0x00054, "Mcid Successful" },
{ 0x00055, "Number Not Configured" },
{ 0x00056, "Security Error" },
{ 0x00057, "Video Bandwidth Unavailable" },
{ 0x00058, "Video Mode" },
{ 0x000c9, "Dial" },
{ 0x000ca, "Record" },
{ 0x00000, NULL }
};
static value_string_ext SoftKeyEvent_ext = VALUE_STRING_EXT_INIT(SoftKeyEvent);
static const value_string UnRegReasonCode[] = {
{ 0x00000, "Unknown" },
{ 0x00001, "PowerSaveMode" },
{ 0x00000, NULL }
};
static value_string_ext UnRegReasonCode_ext = VALUE_STRING_EXT_INIT(UnRegReasonCode);
static const value_string HeadsetMode[] = {
{ 0x00001, "On" },
{ 0x00002, "Off" },
{ 0x00000, NULL }
};
static value_string_ext HeadsetMode_ext = VALUE_STRING_EXT_INIT(HeadsetMode);
static const value_string SequenceFlag[] = {
{ 0x00000, "First" },
{ 0x00001, "More" },
{ 0x00002, "Last" },
{ 0x00000, NULL }
};
static value_string_ext SequenceFlag_ext = VALUE_STRING_EXT_INIT(SequenceFlag);
static const value_string Layout[] = {
{ 0x00000, "NoLayout" },
{ 0x00001, "OneByOne" },
{ 0x00002, "OneByTwo" },
{ 0x00003, "TwoByTwo" },
{ 0x00004, "TwoByTwo3Alt1" },
{ 0x00005, "TwoByTwo3Alt2" },
{ 0x00006, "ThreeByThree" },
{ 0x00007, "ThreeByThree6Alt1" },
{ 0x00008, "ThreeByThree6Alt2" },
{ 0x00009, "ThreeByThree4Alt1" },
{ 0x0000a, "ThreeByThree4Alt2" },
{ 0x00000, NULL }
};
static value_string_ext Layout_ext = VALUE_STRING_EXT_INIT(Layout);
static const value_string TransmitOrReceive[] = {
{ 0x00000, "None" },
{ 0x00001, "ReceiveOnly" },
{ 0x00002, "TransmitOnly" },
{ 0x00003, "Both" },
{ 0x00000, NULL }
};
static value_string_ext TransmitOrReceive_ext = VALUE_STRING_EXT_INIT(TransmitOrReceive);
static const value_string OpenReceiveChanStatus[] = {
{ 0x00000, "Ok" },
{ 0x00001, "Error" },
{ 0x00000, NULL }
};
static value_string_ext OpenReceiveChanStatus_ext = VALUE_STRING_EXT_INIT(OpenReceiveChanStatus);
static const value_string CreateConfResult[] = {
{ 0x00000, "OK" },
{ 0x00001, "ResourceNotAvailable" },
{ 0x00002, "ConferenceAlreadyExist" },
{ 0x00003, "SystemErr" },
{ 0x00000, NULL }
};
static value_string_ext CreateConfResult_ext = VALUE_STRING_EXT_INIT(CreateConfResult);
static const value_string DeleteConfResult[] = {
{ 0x00000, "OK" },
{ 0x00001, "ConferenceNotExist" },
{ 0x00002, "SystemErr" },
{ 0x00000, NULL }
};
static value_string_ext DeleteConfResult_ext = VALUE_STRING_EXT_INIT(DeleteConfResult);
static const value_string ModifyConfResult[] = {
{ 0x00000, "OK" },
{ 0x00001, "ResourceNotAvailable" },
{ 0x00002, "ConferenceNotExist" },
{ 0x00003, "InvalidParameter" },
{ 0x00004, "MoreActiveCallsThanReserved" },
{ 0x00005, "InvalidResourceType" },
{ 0x00006, "SystemErr" },
{ 0x00000, NULL }
};
static value_string_ext ModifyConfResult_ext = VALUE_STRING_EXT_INIT(ModifyConfResult);
static const value_string AddParticipantResult[] = {
{ 0x00000, "OK" },
{ 0x00001, "ResourceNotAvailable" },
{ 0x00002, "ConferenceNotExist" },
{ 0x00003, "DuplicateCallRef" },
{ 0x00004, "SystemErr" },
{ 0x00000, NULL }
};
static value_string_ext AddParticipantResult_ext = VALUE_STRING_EXT_INIT(AddParticipantResult);
static const value_string ResourceType[] = {
{ 0x00000, "Conference" },
{ 0x00001, "IVR" },
{ 0x00000, NULL }
};
static value_string_ext ResourceType_ext = VALUE_STRING_EXT_INIT(ResourceType);
static const value_string AuditParticipantResult[] = {
{ 0x00000, "OK" },
{ 0x00001, "ConferenceNotExist" },
{ 0x00000, NULL }
};
static value_string_ext AuditParticipantResult_ext = VALUE_STRING_EXT_INIT(AuditParticipantResult);
static const value_string Media_Encryption_Capability[] = {
{ 0x00000, "NotEncryptionCapable" },
{ 0x00001, "EncryptionCapable" },
{ 0x00000, NULL }
};
static value_string_ext Media_Encryption_Capability_ext = VALUE_STRING_EXT_INIT(Media_Encryption_Capability);
static const value_string IpAddrMode[] = {
{ 0x00000, "ModeIpv4" },
{ 0x00001, "ModeIpv6" },
{ 0x00002, "ModeIpv4AndIpv6" },
{ 0x00000, NULL }
};
static value_string_ext IpAddrMode_ext = VALUE_STRING_EXT_INIT(IpAddrMode);
static const value_string MediaType[] = {
{ 0x00000, "MediaType_Invalid" },
{ 0x00001, "MediaType_Audio" },
{ 0x00002, "MediaType_Main_Video" },
{ 0x00003, "MediaType_FECC" },
{ 0x00004, "MediaType_Presentation_Video" },
{ 0x00005, "MediaType_DataApp_BFCP" },
{ 0x00006, "MediaType_DataApp_IXChannel" },
{ 0x00007, "MediaType_T38" },
{ 0x00008, "MediaType_Max" },
{ 0x00000, NULL }
};
static value_string_ext MediaType_ext = VALUE_STRING_EXT_INIT(MediaType);
static const value_string RSVPDirection[] = {
{ 0x00001, "SEND" },
{ 0x00002, "RECV" },
{ 0x00003, "SENDRECV" },
{ 0x00000, NULL }
};
static value_string_ext RSVPDirection_ext = VALUE_STRING_EXT_INIT(RSVPDirection);
static const value_string QoSErrorCode[] = {
{ 0x00000, "QOS_CAUSE_RESERVATION_TIMEOUT" },
{ 0x00001, "QOS_CAUSE_PATH_FAIL" },
{ 0x00002, "QOS_CAUSE_RESV_FAIL" },
{ 0x00003, "QOS_CAUSE_LISTEN_FAIL" },
{ 0x00004, "QOS_CAUSE_RESOURCE_UNAVAILABLE" },
{ 0x00005, "QOS_CAUSE_LISTEN_TIMEOUT" },
{ 0x00006, "QOS_CAUSE_RESV_RETRIES_FAIL" },
{ 0x00007, "QOS_CAUSE_PATH_RETRIES_FAIL" },
{ 0x00008, "QOS_CAUSE_RESV_PREEMPTION" },
{ 0x00009, "QOS_CAUSE_PATH_PREEMPTION" },
{ 0x0000a, "QOS_CAUSE_RESV_MODIFY_FAIL" },
{ 0x0000b, "QOS_CAUSE_PATH_MODIFY_FAIL" },
{ 0x0000c, "QOS_CAUSE_RESV_TEAR" },
{ 0x00000, NULL }
};
static value_string_ext QoSErrorCode_ext = VALUE_STRING_EXT_INIT(QoSErrorCode);
static const value_string RSVPErrorCode[] = {
{ 0x00000, "CONFIRM" },
{ 0x00001, "ADMISSION" },
{ 0x00002, "ADMINISTRATIVE" },
{ 0x00003, "NO_PATH_INFORMATION" },
{ 0x00004, "NO_SENDER_INFORMATION" },
{ 0x00005, "CONFLICTING_STYLE" },
{ 0x00006, "UNKNOWN_STYLE" },
{ 0x00007, "CONFLICTING_DST_PORTS" },
{ 0x00008, "CONFLICTING_SRC_PORTS" },
{ 0x0000c, "SERVICE_PREEMPTED" },
{ 0x0000d, "UNKNOWN_OBJECT_CLASS" },
{ 0x0000e, "UNKNOWN_CLASS_TYPE" },
{ 0x00014, "API" },
{ 0x00015, "TRAFFIC" },
{ 0x00016, "TRAFFIC_SYSTEM" },
{ 0x00017, "SYSTEM" },
{ 0x00018, "ROUTING_PROBLEM" },
{ 0x00000, NULL }
};
static value_string_ext RSVPErrorCode_ext = VALUE_STRING_EXT_INIT(RSVPErrorCode);
static const value_string SubscriptionFeatureID[] = {
{ 0x00001, "BLF" },
{ 0x00000, NULL }
};
static value_string_ext SubscriptionFeatureID_ext = VALUE_STRING_EXT_INIT(SubscriptionFeatureID);
static const value_string MediaPathID[] = {
{ 0x00001, "Headset" },
{ 0x00002, "Handset" },
{ 0x00003, "Speaker" },
{ 0x00000, NULL }
};
static value_string_ext MediaPathID_ext = VALUE_STRING_EXT_INIT(MediaPathID);
static const value_string MediaPathEvent[] = {
{ 0x00001, "On" },
{ 0x00002, "Off" },
{ 0x00000, NULL }
};
static value_string_ext MediaPathEvent_ext = VALUE_STRING_EXT_INIT(MediaPathEvent);
static const value_string MediaPathCapabilities[] = {
{ 0x00001, "Enable" },
{ 0x00002, "Disable" },
{ 0x00003, "Monitor" },
{ 0x00000, NULL }
};
static value_string_ext MediaPathCapabilities_ext = VALUE_STRING_EXT_INIT(MediaPathCapabilities);
static const value_string DeviceTone[] = {
{ 0x00000, "Silence" },
{ 0x00001, "Dtmf1" },
{ 0x00002, "Dtmf2" },
{ 0x00003, "Dtmf3" },
{ 0x00004, "Dtmf4" },
{ 0x00005, "Dtmf5" },
{ 0x00006, "Dtmf6" },
{ 0x00007, "Dtmf7" },
{ 0x00008, "Dtmf8" },
{ 0x00009, "Dtmf9" },
{ 0x0000a, "Dtmf0" },
{ 0x0000e, "DtmfStar" },
{ 0x0000f, "DtmfPound" },
{ 0x00010, "DtmfA" },
{ 0x00011, "DtmfB" },
{ 0x00012, "DtmfC" },
{ 0x00013, "DtmfD" },
{ 0x00021, "InsideDialTone" },
{ 0x00022, "OutsideDialTone" },
{ 0x00023, "LineBusyTone" },
{ 0x00024, "AlertingTone" },
{ 0x00025, "ReorderTone" },
{ 0x00026, "RecorderWarningTone" },
{ 0x00027, "RecorderDetectedTone" },
{ 0x00028, "RevertingTone" },
{ 0x00029, "ReceiverOffHookTone" },
{ 0x0002a, "MessageWaitingIndicatorTone" },
{ 0x0002b, "NoSuchNumberTone" },
{ 0x0002c, "BusyVerificationTone" },
{ 0x0002d, "CallWaitingTone" },
{ 0x0002e, "ConfirmationTone" },
{ 0x0002f, "CampOnIndicationTone" },
{ 0x00030, "RecallDialTone" },
{ 0x00031, "ZipZip" },
{ 0x00032, "Zip" },
{ 0x00033, "BeepBonk" },
{ 0x00034, "MusicTone" },
{ 0x00035, "HoldTone" },
{ 0x00036, "TestTone" },
{ 0x00038, "MonitorWarningTone" },
{ 0x00039, "SecureWarningTone" },
{ 0x00040, "AddCallWaiting" },
{ 0x00041, "PriorityCallWait" },
{ 0x00042, "RecallDial" },
{ 0x00043, "BargIn" },
{ 0x00044, "DistinctAlert" },
{ 0x00045, "PriorityAlert" },
{ 0x00046, "ReminderRing" },
{ 0x00047, "PrecedenceRingBack" },
{ 0x00048, "PreemptionTone" },
{ 0x00049, "NonSecureWarningTone" },
{ 0x00050, "MF1" },
{ 0x00051, "MF2" },
{ 0x00052, "MF3" },
{ 0x00053, "MF4" },
{ 0x00054, "MF5" },
{ 0x00055, "MF6" },
{ 0x00056, "MF7" },
{ 0x00057, "MF8" },
{ 0x00058, "MF9" },
{ 0x00059, "MF0" },
{ 0x0005a, "MFKP1" },
{ 0x0005b, "MFST" },
{ 0x0005c, "MFKP2" },
{ 0x0005d, "MFSTP" },
{ 0x0005e, "MFST3P" },
{ 0x0005f, "MILLIWATT" },
{ 0x00060, "MILLIWATTTEST" },
{ 0x00061, "HIGHTONE" },
{ 0x00062, "FLASHOVERRIDE" },
{ 0x00063, "FLASH" },
{ 0x00064, "PRIORITY" },
{ 0x00065, "IMMEDIATE" },
{ 0x00066, "PREAMPWARN" },
{ 0x00067, "2105HZ" },
{ 0x00068, "2600HZ" },
{ 0x00069, "440HZ" },
{ 0x0006a, "300HZ" },
{ 0x0006b, "Mobility_WP" },
{ 0x0006c, "Mobility_UAC" },
{ 0x0006d, "Mobility_WTDN" },
{ 0x0006e, "Mobility_MON" },
{ 0x0006f, "Mobility_MOFF" },
{ 0x00070, "Mobility_UKC" },
{ 0x00071, "Mobility_VMA" },
{ 0x00072, "Mobility_FAC" },
{ 0x00073, "Mobility_CMC" },
{ 0x00077, "MLPP_PALA" },
{ 0x00078, "MLPP_ICA" },
{ 0x00079, "MLPP_VCA" },
{ 0x0007a, "MLPP_BPA" },
{ 0x0007b, "MLPP_BNEA" },
{ 0x0007c, "MLPP_UPA" },
{ 0x0007d, "TUA" },
{ 0x0007e, "GONE" },
{ 0x0007f, "NoTone" },
{ 0x00080, "MeetMe_Greeting" },
{ 0x00081, "MeetMe_NumberInvalid" },
{ 0x00082, "MeetMe_NumberFailed" },
{ 0x00083, "MeetMe_EnterPIN" },
{ 0x00084, "MeetMe_InvalidPIN" },
{ 0x00085, "MeetMe_FailedPIN" },
{ 0x00086, "MeetMe_CFB_Failed" },
{ 0x00087, "MeetMe_EnterAccessCode" },
{ 0x00088, "MeetMe_AccessCodeInvalid" },
{ 0x00089, "MeetMe_AccessCodeFailed" },
{ 0x0008a, "MAX" },
{ 0x00000, NULL }
};
static value_string_ext DeviceTone_ext = VALUE_STRING_EXT_INIT(DeviceTone);
static const value_string ToneOutputDirection[] = {
{ 0x00000, "User" },
{ 0x00001, "Network" },
{ 0x00002, "All" },
{ 0x00000, NULL }
};
static value_string_ext ToneOutputDirection_ext = VALUE_STRING_EXT_INIT(ToneOutputDirection);
static const value_string RingMode[] = {
{ 0x00001, "RingOff" },
{ 0x00002, "InsideRing" },
{ 0x00003, "OutsideRing" },
{ 0x00004, "FeatureRing" },
{ 0x00005, "FlashOnly" },
{ 0x00006, "PrecedenceRing" },
{ 0x00000, NULL }
};
static value_string_ext RingMode_ext = VALUE_STRING_EXT_INIT(RingMode);
static const value_string RingDuration[] = {
{ 0x00001, "NormalRing" },
{ 0x00002, "SingleRing" },
{ 0x00000, NULL }
};
static value_string_ext RingDuration_ext = VALUE_STRING_EXT_INIT(RingDuration);
static const value_string LampMode[] = {
{ 0x00001, "Off" },
{ 0x00002, "On" },
{ 0x00003, "Wink" },
{ 0x00004, "Flash" },
{ 0x00005, "Blink" },
{ 0x00000, NULL }
};
static value_string_ext LampMode_ext = VALUE_STRING_EXT_INIT(LampMode);
static const value_string SpeakerMode[] = {
{ 0x00001, "On" },
{ 0x00002, "Off" },
{ 0x00000, NULL }
};
static value_string_ext SpeakerMode_ext = VALUE_STRING_EXT_INIT(SpeakerMode);
static const value_string MicrophoneMode[] = {
{ 0x00001, "On" },
{ 0x00002, "Off" },
{ 0x00000, NULL }
};
static value_string_ext MicrophoneMode_ext = VALUE_STRING_EXT_INIT(MicrophoneMode);
static const value_string Media_SilenceSuppression[] = {
{ 0x00000, "Media_SilenceSuppression_Off" },
{ 0x00001, "Media_SilenceSuppression_On" },
{ 0x00000, NULL }
};
static value_string_ext Media_SilenceSuppression_ext = VALUE_STRING_EXT_INIT(Media_SilenceSuppression);
static const value_string MediaEncryptionAlgorithmType[] = {
{ 0x00000, "NO_ENCRYPTION" },
{ 0x00001, "CCM_AES_CM_128_HMAC_SHA1_32" },
{ 0x00002, "CCM_AES_CM_128_HMAC_SHA1_80" },
{ 0x00003, "CCM_F8_128_HMAC_SHA1_32" },
{ 0x00004, "CCM_F8_128_HMAC_SHA1_80" },
{ 0x00005, "CCM_AEAD_AES_128_GCM" },
{ 0x00006, "CCM_AEAD_AES_256_GCM" },
{ 0x00000, NULL }
};
static value_string_ext MediaEncryptionAlgorithmType_ext = VALUE_STRING_EXT_INIT(MediaEncryptionAlgorithmType);
static const value_string PortHandling[] = {
{ 0x00000, "CLOSE_PORT" },
{ 0x00001, "KEEP_PORT" },
{ 0x00000, NULL }
};
static value_string_ext PortHandling_ext = VALUE_STRING_EXT_INIT(PortHandling);
static const value_string CallType[] = {
{ 0x00001, "InBoundCall" },
{ 0x00002, "OutBoundCall" },
{ 0x00003, "ForwardCall" },
{ 0x00000, NULL }
};
static value_string_ext CallType_ext = VALUE_STRING_EXT_INIT(CallType);
static const value_string CallSecurityStatusType[] = {
{ 0x00000, "Unknown" },
{ 0x00001, "NotAuthenticated" },
{ 0x00002, "Authenticated" },
{ 0x00003, "Encrypted" },
{ 0x00004, "Max" },
{ 0x00000, NULL }
};
static value_string_ext CallSecurityStatusType_ext = VALUE_STRING_EXT_INIT(CallSecurityStatusType);
static const value_string SessionType[] = {
{ 0x00001, "Chat" },
{ 0x00002, "Whiteboard" },
{ 0x00004, "ApplicationSharing" },
{ 0x00008, "FileTransfer" },
{ 0x00010, "Video" },
{ 0x00000, NULL }
};
static value_string_ext SessionType_ext = VALUE_STRING_EXT_INIT(SessionType);
static const value_string ButtonType[] = {
{ 0x00000, "Unused" },
{ 0x00001, "Last Number Redial" },
{ 0x00002, "SpeedDial" },
{ 0x00003, "Hold" },
{ 0x00004, "Transfer" },
{ 0x00005, "Forward All" },
{ 0x00006, "Forward Busy" },
{ 0x00007, "Forward No Answer" },
{ 0x00008, "Display" },
{ 0x00009, "Line" },
{ 0x0000a, "T120 Chat" },
{ 0x0000b, "T120 Whiteboard" },
{ 0x0000c, "T120 Application Sharing" },
{ 0x0000d, "T120 File Transfer" },
{ 0x0000e, "Video" },
{ 0x0000f, "Voicemail" },
{ 0x00010, "Answer Release" },
{ 0x00011, "Auto Answer" },
{ 0x00012, "Select" },
{ 0x00013, "Feature" },
{ 0x00014, "ServiceURL" },
{ 0x00015, "BusyLampField Speeddial" },
{ 0x0001b, "Malicious Call" },
{ 0x00021, "Generic App B1" },
{ 0x00022, "Generic App B2" },
{ 0x00023, "Generic App B3" },
{ 0x00024, "Generic App B4" },
{ 0x00025, "Generic App B5" },
{ 0x00026, "Monitor/Multiblink" },
{ 0x0007b, "Meet Me Conference" },
{ 0x0007d, "Conference" },
{ 0x0007e, "Call Park" },
{ 0x0007f, "Call Pickup" },
{ 0x00080, "Group Call Pickup" },
{ 0x00081, "Mobility" },
{ 0x00082, "DoNotDisturb" },
{ 0x00083, "ConfList" },
{ 0x00084, "RemoveLastParticipant" },
{ 0x00085, "QRT" },
{ 0x00086, "CallBack" },
{ 0x00087, "OtherPickup" },
{ 0x00088, "VideoMode" },
{ 0x00089, "NewCall" },
{ 0x0008a, "EndCall" },
{ 0x0008b, "HLog" },
{ 0x0008f, "Queuing" },
{ 0x000c0, "Test E" },
{ 0x000c1, "Test F" },
{ 0x000c2, "Messages" },
{ 0x000c3, "Directory" },
{ 0x000c4, "Test I" },
{ 0x000c5, "Application" },
{ 0x000c6, "Headset" },
{ 0x000f0, "Keypad" },
{ 0x000fd, "Aec" },
{ 0x000ff, "Undefined" },
{ 0x00000, NULL }
};
static value_string_ext ButtonType_ext = VALUE_STRING_EXT_INIT(ButtonType);
static const value_string DeviceResetType[] = {
{ 0x00001, "RESET" },
{ 0x00002, "RESTART" },
{ 0x00003, "APPLY_CONFIG" },
{ 0x00000, NULL }
};
static value_string_ext DeviceResetType_ext = VALUE_STRING_EXT_INIT(DeviceResetType);
static const value_string Media_EchoCancellation[] = {
{ 0x00000, "Media_EchoCancellation_Off" },
{ 0x00001, "Media_EchoCancellation_On" },
{ 0x00000, NULL }
};
static value_string_ext Media_EchoCancellation_ext = VALUE_STRING_EXT_INIT(Media_EchoCancellation);
static const value_string SoftKeyTemplateIndex[] = {
{ 0x00001, "Redial" },
{ 0x00002, "NewCall" },
{ 0x00003, "Hold" },
{ 0x00004, "Transfer" },
{ 0x00005, "CfwdAll" },
{ 0x00006, "CfwdBusy" },
{ 0x00007, "CfwdNoAnswer" },
{ 0x00008, "BackSpace" },
{ 0x00009, "EndCall" },
{ 0x0000a, "Resume" },
{ 0x0000b, "Answer" },
{ 0x0000c, "Info" },
{ 0x0000d, "Confrn" },
{ 0x0000e, "Park" },
{ 0x0000f, "Join" },
{ 0x00010, "MeetMe" },
{ 0x00011, "PickUp" },
{ 0x00012, "GrpPickup" },
{ 0x00013, "Monitor" },
{ 0x00014, "CallBack" },
{ 0x00015, "Barge" },
{ 0x00016, "DND" },
{ 0x00017, "ConfList" },
{ 0x00018, "Select" },
{ 0x00019, "Private" },
{ 0x0001a, "Transfer Voicemail" },
{ 0x0001b, "Direct Transfer" },
{ 0x0001c, "Immediate Divert" },
{ 0x0001d, "Video Mode" },
{ 0x0001e, "Intercept" },
{ 0x0001f, "Empty" },
{ 0x00020, "Dial" },
{ 0x00021, "Conference Barge" },
{ 0x00000, NULL }
};
static value_string_ext SoftKeyTemplateIndex_ext = VALUE_STRING_EXT_INIT(SoftKeyTemplateIndex);
static const value_string SoftKeyInfoIndex[] = {
{ 0x0012d, "Redial" },
{ 0x0012e, "NewCall" },
{ 0x0012f, "Hold" },
{ 0x00130, "Transfer" },
{ 0x00131, "CfwdAll" },
{ 0x00132, "CfwdBusy" },
{ 0x00133, "CfwdNoAnswer" },
{ 0x00134, "BackSpace" },
{ 0x00135, "EndCall" },
{ 0x00136, "Resume" },
{ 0x00137, "Answer" },
{ 0x00138, "Info" },
{ 0x00139, "Confrn" },
{ 0x0013a, "Park" },
{ 0x0013b, "Join" },
{ 0x0013c, "MeetMe" },
{ 0x0013d, "PickUp" },
{ 0x0013e, "GrpPickup" },
{ 0x0013f, "Monitor" },
{ 0x00140, "CallBack" },
{ 0x00141, "Barge" },
{ 0x00142, "DND" },
{ 0x00143, "ConfList" },
{ 0x00144, "Select" },
{ 0x00145, "Private" },
{ 0x00146, "Transfer Voicemail" },
{ 0x00147, "Direct Transfer" },
{ 0x00148, "Immediate Divert" },
{ 0x00149, "Video Mode" },
{ 0x0014a, "Intercept" },
{ 0x0014b, "Empty" },
{ 0x0014c, "Dial" },
{ 0x0014d, "Conference Barge" },
{ 0x00000, NULL }
};
static value_string_ext SoftKeyInfoIndex_ext = VALUE_STRING_EXT_INIT(SoftKeyInfoIndex);
static const value_string DCallState[] = {
{ 0x00000, "Idle" },
{ 0x00001, "OffHook" },
{ 0x00002, "OnHook" },
{ 0x00003, "RingOut" },
{ 0x00004, "RingIn" },
{ 0x00005, "Connected" },
{ 0x00006, "Busy" },
{ 0x00007, "Congestion" },
{ 0x00008, "Hold" },
{ 0x00009, "CallWaiting" },
{ 0x0000a, "CallTransfer" },
{ 0x0000b, "CallPark" },
{ 0x0000c, "Proceed" },
{ 0x0000d, "CallRemoteMultiline" },
{ 0x0000e, "InvalidNumber" },
{ 0x0000f, "HoldRevert" },
{ 0x00010, "Whisper" },
{ 0x00011, "RemoteHold" },
{ 0x00012, "MaxState" },
{ 0x00000, NULL }
};
static value_string_ext DCallState_ext = VALUE_STRING_EXT_INIT(DCallState);
static const value_string CallPrivacy[] = {
{ 0x00000, "None" },
{ 0x00001, "Limited" },
{ 0x00002, "Full" },
{ 0x00000, NULL }
};
static value_string_ext CallPrivacy_ext = VALUE_STRING_EXT_INIT(CallPrivacy);
static const value_string DeviceUnregisterStatus[] = {
{ 0x00000, "Ok" },
{ 0x00001, "Error" },
{ 0x00002, "NAK" },
{ 0x00000, NULL }
};
static value_string_ext DeviceUnregisterStatus_ext = VALUE_STRING_EXT_INIT(DeviceUnregisterStatus);
static const value_string EndOfAnnAck[] = {
{ 0x00000, "NoAnnAckRequired" },
{ 0x00001, "AnnAckRequired" },
{ 0x00000, NULL }
};
static value_string_ext EndOfAnnAck_ext = VALUE_STRING_EXT_INIT(EndOfAnnAck);
static const value_string AnnPlayMode[] = {
{ 0x00000, "XmlConfigMode" },
{ 0x00001, "OneShotMode" },
{ 0x00002, "ContinuousMode" },
{ 0x00000, NULL }
};
static value_string_ext AnnPlayMode_ext = VALUE_STRING_EXT_INIT(AnnPlayMode);
static const value_string PlayAnnStatus[] = {
{ 0x00000, "OK" },
{ 0x00001, "Err" },
{ 0x00000, NULL }
};
static value_string_ext PlayAnnStatus_ext = VALUE_STRING_EXT_INIT(PlayAnnStatus);
#define MISCCOMMANDTYPE_VIDEOFREEZEPICTURE 0x00000
#define MISCCOMMANDTYPE_VIDEOFASTUPDATEPICTURE 0x00001
#define MISCCOMMANDTYPE_VIDEOFASTUPDATEGOB 0x00002
#define MISCCOMMANDTYPE_VIDEOFASTUPDATEMB 0x00003
#define MISCCOMMANDTYPE_LOSTPICTURE 0x00004
#define MISCCOMMANDTYPE_LOSTPARTIALPICTURE 0x00005
#define MISCCOMMANDTYPE_RECOVERYREFERENCEPICTURE 0x00006
#define MISCCOMMANDTYPE_TEMPORALSPATIALTRADEOFF 0x00007
static const value_string MiscCommandType[] = {
{ MISCCOMMANDTYPE_VIDEOFREEZEPICTURE, "videoFreezePicture" },
{ MISCCOMMANDTYPE_VIDEOFASTUPDATEPICTURE, "videoFastUpdatePicture" },
{ MISCCOMMANDTYPE_VIDEOFASTUPDATEGOB, "videoFastUpdateGOB" },
{ MISCCOMMANDTYPE_VIDEOFASTUPDATEMB, "videoFastUpdateMB" },
{ MISCCOMMANDTYPE_LOSTPICTURE, "lostPicture" },
{ MISCCOMMANDTYPE_LOSTPARTIALPICTURE, "lostPartialPicture" },
{ MISCCOMMANDTYPE_RECOVERYREFERENCEPICTURE, "recoveryReferencePicture" },
{ MISCCOMMANDTYPE_TEMPORALSPATIALTRADEOFF, "temporalSpatialTradeOff" },
{ 0x00000, NULL }
};
static value_string_ext MiscCommandType_ext = VALUE_STRING_EXT_INIT(MiscCommandType);
static const value_string MediaTransportType[] = {
{ 0x00001, "RTP" },
{ 0x00002, "UDP" },
{ 0x00003, "TCP" },
{ 0x00000, NULL }
};
static value_string_ext MediaTransportType_ext = VALUE_STRING_EXT_INIT(MediaTransportType);
static const value_string ResvStyle[] = {
{ 0x00001, "FF" },
{ 0x00002, "SE" },
{ 0x00003, "WF" },
{ 0x00000, NULL }
};
static value_string_ext ResvStyle_ext = VALUE_STRING_EXT_INIT(ResvStyle);
static const value_string SubscribeCause[] = {
{ 0x00000, "OK" },
{ 0x00001, "RouteFail" },
{ 0x00002, "AuthFail" },
{ 0x00003, "Timeout" },
{ 0x00004, "TrunkTerm" },
{ 0x00005, "TrunkForbidden" },
{ 0x00006, "Throttle" },
{ 0x00000, NULL }
};
static value_string_ext SubscribeCause_ext = VALUE_STRING_EXT_INIT(SubscribeCause);
static const value_string CallHistoryDisposition[] = {
{ 0x00000, "Ignore" },
{ 0x00001, "PlacedCalls" },
{ 0x00002, "ReceivedCalls" },
{ 0x00003, "MissedCalls" },
{ 0x0ffff, "UnknownDisp" },
{ 0x00000, NULL }
};
static value_string_ext CallHistoryDisposition_ext = VALUE_STRING_EXT_INIT(CallHistoryDisposition);
static const value_string MwiNotificationResult[] = {
{ 0x00000, "Ok" },
{ 0x00001, "GeneralError" },
{ 0x00002, "RequestRejected" },
{ 0x00003, "VmCountOutOfBounds" },
{ 0x00004, "FaxCountOutOfBounds" },
{ 0x00005, "InvalidPriorityVmCount" },
{ 0x00006, "InvalidPriorityFaxCount" },
{ 0x00000, NULL }
};
static value_string_ext MwiNotificationResult_ext = VALUE_STRING_EXT_INIT(MwiNotificationResult);
static const value_string RecordingStatus[] = {
{ 0x00000, "_OFF" },
{ 0x00001, "_ON" },
{ 0x00000, NULL }
};
static value_string_ext RecordingStatus_ext = VALUE_STRING_EXT_INIT(RecordingStatus);
/* Staticly Declared Variables */
static int proto_skinny = -1;
static int hf_skinny_messageId = -1;
static int hf_skinny_data_length = -1;
static int hf_skinny_hdr_version = -1;
static int hf_skinny_xmlData = -1;
static int hf_skinny_ipv4or6 = -1;
static int hf_skinny_response_in = -1;
static int hf_skinny_response_to = -1;
static int hf_skinny_response_time = -1;
static int hf_skinny_AlternateCallingParty = -1;
static int hf_skinny_CallingPartyName = -1;
static int hf_skinny_CallingPartyNumber = -1;
static int hf_skinny_DSCPValue = -1;
static int hf_skinny_DeviceName = -1;
static int hf_skinny_FutureUse1 = -1;
static int hf_skinny_FutureUse2 = -1;
static int hf_skinny_FutureUse3 = -1;
static int hf_skinny_Generic_Bitfield_Bit1 = -1;
static int hf_skinny_Generic_Bitfield_Bit10 = -1;
static int hf_skinny_Generic_Bitfield_Bit11 = -1;
static int hf_skinny_Generic_Bitfield_Bit12 = -1;
static int hf_skinny_Generic_Bitfield_Bit13 = -1;
static int hf_skinny_Generic_Bitfield_Bit14 = -1;
static int hf_skinny_Generic_Bitfield_Bit15 = -1;
static int hf_skinny_Generic_Bitfield_Bit16 = -1;
static int hf_skinny_Generic_Bitfield_Bit17 = -1;
static int hf_skinny_Generic_Bitfield_Bit18 = -1;
static int hf_skinny_Generic_Bitfield_Bit19 = -1;
static int hf_skinny_Generic_Bitfield_Bit2 = -1;
static int hf_skinny_Generic_Bitfield_Bit20 = -1;
static int hf_skinny_Generic_Bitfield_Bit21 = -1;
static int hf_skinny_Generic_Bitfield_Bit22 = -1;
static int hf_skinny_Generic_Bitfield_Bit23 = -1;
static int hf_skinny_Generic_Bitfield_Bit24 = -1;
static int hf_skinny_Generic_Bitfield_Bit25 = -1;
static int hf_skinny_Generic_Bitfield_Bit26 = -1;
static int hf_skinny_Generic_Bitfield_Bit27 = -1;
static int hf_skinny_Generic_Bitfield_Bit28 = -1;
static int hf_skinny_Generic_Bitfield_Bit29 = -1;
static int hf_skinny_Generic_Bitfield_Bit3 = -1;
static int hf_skinny_Generic_Bitfield_Bit30 = -1;
static int hf_skinny_Generic_Bitfield_Bit31 = -1;
static int hf_skinny_Generic_Bitfield_Bit32 = -1;
static int hf_skinny_Generic_Bitfield_Bit4 = -1;
static int hf_skinny_Generic_Bitfield_Bit5 = -1;
static int hf_skinny_Generic_Bitfield_Bit6 = -1;
static int hf_skinny_Generic_Bitfield_Bit7 = -1;
static int hf_skinny_Generic_Bitfield_Bit8 = -1;
static int hf_skinny_Generic_Bitfield_Bit9 = -1;
static int hf_skinny_HuntPilotName = -1;
static int hf_skinny_HuntPilotNumber = -1;
static int hf_skinny_MPI = -1;
static int hf_skinny_OrigDialed = -1;
static int hf_skinny_PhoneFeatures_Abbreviated_Dial = -1;
static int hf_skinny_PhoneFeatures_Bit1 = -1;
static int hf_skinny_PhoneFeatures_Bit11 = -1;
static int hf_skinny_PhoneFeatures_Bit12 = -1;
static int hf_skinny_PhoneFeatures_Bit13 = -1;
static int hf_skinny_PhoneFeatures_Bit14 = -1;
static int hf_skinny_PhoneFeatures_Bit15 = -1;
static int hf_skinny_PhoneFeatures_Bit2 = -1;
static int hf_skinny_PhoneFeatures_Bit3 = -1;
static int hf_skinny_PhoneFeatures_Bit4 = -1;
static int hf_skinny_PhoneFeatures_Bit6 = -1;
static int hf_skinny_PhoneFeatures_Bit7 = -1;
static int hf_skinny_PhoneFeatures_Bit9 = -1;
static int hf_skinny_PhoneFeatures_DynamicMessages = -1;
static int hf_skinny_PhoneFeatures_RFC2833 = -1;
static int hf_skinny_PhoneFeatures_UTF8 = -1;
static int hf_skinny_RFC2833PayloadType = -1;
static int hf_skinny_RTCPPortNumber = -1;
static int hf_skinny_RedirDialed = -1;
static int hf_skinny_RestrictInformationType_BitsReserved = -1;
static int hf_skinny_RestrictInformationType_CalledParty = -1;
static int hf_skinny_RestrictInformationType_CalledPartyName = -1;
static int hf_skinny_RestrictInformationType_CalledPartyNumber = -1;
static int hf_skinny_RestrictInformationType_CallingParty = -1;
static int hf_skinny_RestrictInformationType_CallingPartyName = -1;
static int hf_skinny_RestrictInformationType_CallingPartyNumber = -1;
static int hf_skinny_RestrictInformationType_LastRedirectParty = -1;
static int hf_skinny_RestrictInformationType_LastRedirectPartyName = -1;
static int hf_skinny_RestrictInformationType_LastRedirectPartyNumber = -1;
static int hf_skinny_RestrictInformationType_OriginalCalledParty = -1;
static int hf_skinny_RestrictInformationType_OriginalCalledPartyName = -1;
static int hf_skinny_RestrictInformationType_OriginalCalledPartyNumber = -1;
static int hf_skinny_ServerName = -1;
static int hf_skinny_SoftKeyMask_SoftKey1 = -1;
static int hf_skinny_SoftKeyMask_SoftKey10 = -1;
static int hf_skinny_SoftKeyMask_SoftKey11 = -1;
static int hf_skinny_SoftKeyMask_SoftKey12 = -1;
static int hf_skinny_SoftKeyMask_SoftKey13 = -1;
static int hf_skinny_SoftKeyMask_SoftKey14 = -1;
static int hf_skinny_SoftKeyMask_SoftKey15 = -1;
static int hf_skinny_SoftKeyMask_SoftKey16 = -1;
static int hf_skinny_SoftKeyMask_SoftKey2 = -1;
static int hf_skinny_SoftKeyMask_SoftKey3 = -1;
static int hf_skinny_SoftKeyMask_SoftKey4 = -1;
static int hf_skinny_SoftKeyMask_SoftKey5 = -1;
static int hf_skinny_SoftKeyMask_SoftKey6 = -1;
static int hf_skinny_SoftKeyMask_SoftKey7 = -1;
static int hf_skinny_SoftKeyMask_SoftKey8 = -1;
static int hf_skinny_SoftKeyMask_SoftKey9 = -1;
static int hf_skinny_active = -1;
static int hf_skinny_activeConferenceOnRegistration = -1;
static int hf_skinny_activeConferences = -1;
static int hf_skinny_activeForward = -1;
static int hf_skinny_activeStreams = -1;
static int hf_skinny_activeStreamsOnRegistration = -1;
static int hf_skinny_add_participant_result = -1;
static int hf_skinny_alarmInfo = -1;
static int hf_skinny_alarmSeverity = -1;
static int hf_skinny_algorithmID = -1;
static int hf_skinny_alignmentPadding = -1;
static int hf_skinny_annAckReq = -1;
static int hf_skinny_annPlayMode = -1;
static int hf_skinny_annStatus = -1;
static int hf_skinny_annexNandWFutureUse = -1;
static int hf_skinny_appConfID = -1;
static int hf_skinny_appData = -1;
static int hf_skinny_appInstanceID = -1;
static int hf_skinny_appName = -1;
static int hf_skinny_applicationId = -1;
static int hf_skinny_areMessagesWaiting = -1;
static int hf_skinny_associatedStreamId = -1;
static int hf_skinny_audioCapCount = -1;
static int hf_skinny_audioLevelAdjustment = -1;
static int hf_skinny_audit_participant_result = -1;
static int hf_skinny_averageBitRate = -1;
static int hf_skinny_bandwidth = -1;
static int hf_skinny_bitRate = -1;
static int hf_skinny_bridgeParticipantId = -1;
static int hf_skinny_burstSize = -1;
static int hf_skinny_busyTrigger = -1;
static int hf_skinny_buttonCount = -1;
static int hf_skinny_buttonDefinition = -1;
static int hf_skinny_buttonOffset = -1;
static int hf_skinny_callHistoryDisposition = -1;
static int hf_skinny_callInstance = -1;
static int hf_skinny_callReference = -1;
static int hf_skinny_callSecurityStatus = -1;
static int hf_skinny_callSelectStat = -1;
static int hf_skinny_callState = -1;
static int hf_skinny_callType = -1;
static int hf_skinny_calledParty = -1;
static int hf_skinny_calledPartyName = -1;
static int hf_skinny_callingParty = -1;
static int hf_skinny_callingPartyName = -1;
static int hf_skinny_callingPartyNumber = -1;
static int hf_skinny_capAndVer = -1;
static int hf_skinny_capCount = -1;
static int hf_skinny_cause = -1;
static int hf_skinny_cdpnVoiceMailbox = -1;
static int hf_skinny_cgpnVoiceMailbox = -1;
static int hf_skinny_chan0MaxPayload = -1;
static int hf_skinny_chan2MaxPayload = -1;
static int hf_skinny_chan2MaxWindow = -1;
static int hf_skinny_chan3MaxPayload = -1;
static int hf_skinny_clockConversionCode = -1;
static int hf_skinny_clockDivisor = -1;
static int hf_skinny_codecMode = -1;
static int hf_skinny_codecParam1 = -1;
static int hf_skinny_codecParam2 = -1;
static int hf_skinny_command = -1;
static int hf_skinny_compressionType = -1;
static int hf_skinny_confServiceNum = -1;
static int hf_skinny_conferenceId = -1;
static int hf_skinny_conferenceName = -1;
static int hf_skinny_configVersionStamp = -1;
static int hf_skinny_confirmRequired = -1;
static int hf_skinny_country = -1;
static int hf_skinny_customMaxBRandCPB = -1;
static int hf_skinny_customMaxDPB = -1;
static int hf_skinny_customMaxFS = -1;
static int hf_skinny_customMaxMBPS = -1;
static int hf_skinny_customPictureFormatCount = -1;
static int hf_skinny_data = -1;
static int hf_skinny_dataCapCount = -1;
static int hf_skinny_dataCapabilityDirection = -1;
static int hf_skinny_dataLength = -1;
static int hf_skinny_dataSize = -1;
static int hf_skinny_dateTemplate = -1;
static int hf_skinny_defendingPriority = -1;
static int hf_skinny_delete_conf_result = -1;
static int hf_skinny_deviceType = -1;
static int hf_skinny_dialedNumber = -1;
static int hf_skinny_direction = -1;
static int hf_skinny_directoryNum = -1;
static int hf_skinny_displayPriority = -1;
static int hf_skinny_dtmfType = -1;
static int hf_skinny_dynamicPayload = -1;
static int hf_skinny_ecValue = -1;
static int hf_skinny_encryptionCapability = -1;
static int hf_skinny_errorCode = -1;
static int hf_skinny_failureNodeIpAddr = -1;
static int hf_skinny_featureCapabilities = -1;
static int hf_skinny_featureID = -1;
static int hf_skinny_featureIndex = -1;
static int hf_skinny_featureStatus = -1;
static int hf_skinny_featureTextLabel = -1;
static int hf_skinny_features = -1;
static int hf_skinny_firmwareLoadName = -1;
static int hf_skinny_firstGOB = -1;
static int hf_skinny_firstMB = -1;
static int hf_skinny_format = -1;
static int hf_skinny_forwardAllActive = -1;
static int hf_skinny_forwardAllDirnum = -1;
static int hf_skinny_forwardBusyActive = -1;
static int hf_skinny_forwardBusyDirnum = -1;
static int hf_skinny_forwardNoAnswerActive = -1;
static int hf_skinny_forwardNoAnswerlDirnum = -1;
static int hf_skinny_g723BitRate = -1;
static int hf_skinny_headsetStatus = -1;
static int hf_skinny_hearingConfPartyMask = -1;
static int hf_skinny_instance = -1;
static int hf_skinny_instanceNumber = -1;
static int hf_skinny_ipAddr_ipv4 = -1;
static int hf_skinny_ipAddr_ipv6 = -1;
static int hf_skinny_ipAddressType = -1;
static int hf_skinny_ipAddressingMode = -1;
static int hf_skinny_ipV4AddressScope = -1;
static int hf_skinny_ipV6AddressScope = -1;
static int hf_skinny_isConferenceCreator = -1;
static int hf_skinny_isMKIPresent = -1;
static int hf_skinny_jitter = -1;
static int hf_skinny_keepAliveInterval = -1;
static int hf_skinny_key = -1;
static int hf_skinny_keyDerivationRate = -1;
static int hf_skinny_keylen = -1;
static int hf_skinny_kpButton = -1;
static int hf_skinny_lampMode = -1;
static int hf_skinny_last = -1;
static int hf_skinny_lastRedirectingParty = -1;
static int hf_skinny_lastRedirectingPartyName = -1;
static int hf_skinny_lastRedirectingReason = -1;
static int hf_skinny_lastRedirectingVoiceMailbox = -1;
static int hf_skinny_latency = -1;
static int hf_skinny_layoutCount = -1;
static int hf_skinny_layoutID = -1;
static int hf_skinny_layouts = -1;
static int hf_skinny_level = -1;
static int hf_skinny_levelPreferenceCount = -1;
static int hf_skinny_lineDataEntries = -1;
static int hf_skinny_lineDirNumber = -1;
static int hf_skinny_lineDisplayOptions = -1;
static int hf_skinny_lineFullyQualifiedDisplayName = -1;
static int hf_skinny_lineInstance = -1;
static int hf_skinny_lineNumber = -1;
static int hf_skinny_lineTextLabel = -1;
static int hf_skinny_locale = -1;
static int hf_skinny_locationInfo = -1;
static int hf_skinny_longTermPictureIndex = -1;
static int hf_skinny_macAddress = -1;
static int hf_skinny_matrixConfPartyID = -1;
static int hf_skinny_maxBW = -1;
static int hf_skinny_maxBitRate = -1;
static int hf_skinny_maxConferences = -1;
static int hf_skinny_maxFramesPerPacket = -1;
static int hf_skinny_maxNumCalls = -1;
static int hf_skinny_maxNumOfAvailLines = -1;
static int hf_skinny_maxNumberOfLines = -1;
static int hf_skinny_maxProtocolVer = -1;
static int hf_skinny_maxRetryNumber = -1;
static int hf_skinny_maxStreams = -1;
static int hf_skinny_maxStreamsPerConf = -1;
static int hf_skinny_maximumBitRate = -1;
static int hf_skinny_mediaPathCapabilities = -1;
static int hf_skinny_mediaPathEvent = -1;
static int hf_skinny_mediaPathID = -1;
static int hf_skinny_mediaReceptionStatus = -1;
static int hf_skinny_mediaTransmissionStatus = -1;
static int hf_skinny_mediaTransportType = -1;
static int hf_skinny_mediaType = -1;
static int hf_skinny_micMode = -1;
static int hf_skinny_milliSecondPacketSize = -1;
static int hf_skinny_minBitRate = -1;
static int hf_skinny_mixingMode = -1;
static int hf_skinny_modAnd2833 = -1;
static int hf_skinny_modelNumber = -1;
static int hf_skinny_modify_conf_result = -1;
static int hf_skinny_multicastIpAddr_ipv4 = -1;
static int hf_skinny_multicastIpAddr_ipv6 = -1;
static int hf_skinny_multicastPortNumber = -1;
static int hf_skinny_multicastReceptionStatus = -1;
static int hf_skinny_multimediaReceptionStatus = -1;
static int hf_skinny_multimediaTransmissionStatus = -1;
static int hf_skinny_mwiControlNumber = -1;
static int hf_skinny_mwiTargetNumber = -1;
static int hf_skinny_mwi_notification_result = -1;
static int hf_skinny_noaudio = -1;
static int hf_skinny_none = -1;
static int hf_skinny_notificationStatus = -1;
static int hf_skinny_notify = -1;
static int hf_skinny_nse = -1;
static int hf_skinny_numNewMsgs = -1;
static int hf_skinny_numOldMsgs = -1;
static int hf_skinny_numberOctetsReceived = -1;
static int hf_skinny_numberOctetsSent = -1;
static int hf_skinny_numberOfActiveParticipants = -1;
static int hf_skinny_numberOfEntries = -1;
static int hf_skinny_numberOfGOBs = -1;
static int hf_skinny_numberOfInServiceStreams = -1;
static int hf_skinny_numberOfLines = -1;
static int hf_skinny_numberOfMBs = -1;
static int hf_skinny_numberOfOutOfServiceStreams = -1;
static int hf_skinny_numberOfReservedParticipants = -1;
static int hf_skinny_numberOfSpeedDials = -1;
static int hf_skinny_numberPacketsLost = -1;
static int hf_skinny_numberPacketsReceived = -1;
static int hf_skinny_numberPacketsSent = -1;
static int hf_skinny_originalCalledParty = -1;
static int hf_skinny_originalCalledPartyName = -1;
static int hf_skinny_originalCdpnRedirectReason = -1;
static int hf_skinny_originalCdpnVoiceMailbox = -1;
static int hf_skinny_padding = -1;
static int hf_skinny_parm1 = -1;
static int hf_skinny_parm2 = -1;
static int hf_skinny_participantEntry = -1;
static int hf_skinny_participantName = -1;
static int hf_skinny_participantNumber = -1;
static int hf_skinny_partyDirection = -1;
static int hf_skinny_passThroughPartyId = -1;
static int hf_skinny_passThruData = -1;
static int hf_skinny_passthruPartyID = -1;
static int hf_skinny_payloadCapability = -1;
static int hf_skinny_payloadDtmf = -1;
static int hf_skinny_payloadType = -1;
static int hf_skinny_payload_rfc_number = -1;
static int hf_skinny_peakRate = -1;
static int hf_skinny_pictureFormatCount = -1;
static int hf_skinny_pictureHeight = -1;
static int hf_skinny_pictureNumber = -1;
static int hf_skinny_pictureWidth = -1;
static int hf_skinny_pixelAspectRatio = -1;
static int hf_skinny_portHandlingFlag = -1;
static int hf_skinny_portNumber = -1;
static int hf_skinny_precedenceDomain = -1;
static int hf_skinny_precedenceLevel = -1;
static int hf_skinny_precedenceValue = -1;
static int hf_skinny_preemptionPriority = -1;
static int hf_skinny_priority = -1;
static int hf_skinny_privacy = -1;
static int hf_skinny_profile = -1;
static int hf_skinny_promptStatus = -1;
static int hf_skinny_protocolDependentData = -1;
static int hf_skinny_protocolVer = -1;
static int hf_skinny_recording_status = -1;
static int hf_skinny_recoveryReferencePictureCount = -1;
static int hf_skinny_remoteIpAddr_ipv4 = -1;
static int hf_skinny_remoteIpAddr_ipv6 = -1;
static int hf_skinny_remotePortNumber = -1;
static int hf_skinny_requestedIpAddrType = -1;
static int hf_skinny_reserved_for_future_use = -1;
static int hf_skinny_resetType = -1;
static int hf_skinny_resourceType = -1;
static int hf_skinny_result = -1;
static int hf_skinny_resvStyle = -1;
static int hf_skinny_retryTimer = -1;
static int hf_skinny_rfc2833 = -1;
static int hf_skinny_ringDuration = -1;
static int hf_skinny_ringMode = -1;
static int hf_skinny_routingID = -1;
static int hf_skinny_rsvpErrorCode = -1;
static int hf_skinny_rsvpErrorFlag = -1;
static int hf_skinny_rsvpErrorSubCodeVal = -1;
static int hf_skinny_rtpMediaPort = -1;
static int hf_skinny_rtpPayloadFormat = -1;
static int hf_skinny_salt = -1;
static int hf_skinny_saltlen = -1;
static int hf_skinny_secondaryKeepAliveInterval = -1;
static int hf_skinny_sequenceFlag = -1;
static int hf_skinny_serverName = -1;
static int hf_skinny_serverTcpListenPort = -1;
static int hf_skinny_serviceNum = -1;
static int hf_skinny_serviceNumber = -1;
static int hf_skinny_serviceResourceCount = -1;
static int hf_skinny_serviceURL = -1;
static int hf_skinny_serviceURLDisplayName = -1;
static int hf_skinny_serviceURLIndex = -1;
static int hf_skinny_sessionType = -1;
static int hf_skinny_softKeyCount = -1;
static int hf_skinny_softKeyEvent = -1;
static int hf_skinny_softKeyInfoIndex = -1;
static int hf_skinny_softKeyLabel = -1;
static int hf_skinny_softKeyOffset = -1;
static int hf_skinny_softKeySetCount = -1;
static int hf_skinny_softKeySetIndex = -1;
static int hf_skinny_softKeySetOffset = -1;
static int hf_skinny_softKeyTemplateIndex = -1;
static int hf_skinny_sourceIpAddr_ipv4 = -1;
static int hf_skinny_sourceIpAddr_ipv6 = -1;
static int hf_skinny_sourcePortNumber = -1;
static int hf_skinny_speakerMode = -1;
static int hf_skinny_speedDialDirNumber = -1;
static int hf_skinny_speedDialDisplayName = -1;
static int hf_skinny_speedDialNumber = -1;
static int hf_skinny_ssValue = -1;
static int hf_skinny_sse = -1;
static int hf_skinny_standard = -1;
static int hf_skinny_startingLineInstance = -1;
static int hf_skinny_stationIpAddr = -1;
static int hf_skinny_stationIpAddr_ipv4 = -1;
static int hf_skinny_stationIpAddr_ipv6 = -1;
static int hf_skinny_stationIpV6Addr = -1;
static int hf_skinny_stationIpV6Addr_ipv4 = -1;
static int hf_skinny_stationIpV6Addr_ipv6 = -1;
static int hf_skinny_statsProcessingMode = -1;
static int hf_skinny_status = -1;
static int hf_skinny_stillImageTransmission = -1;
static int hf_skinny_stimulus = -1;
static int hf_skinny_stimulusInstance = -1;
static int hf_skinny_stimulusStatus = -1;
static int hf_skinny_streamPassThroughId = -1;
static int hf_skinny_subAppID = -1;
static int hf_skinny_subscriptionFeatureID = -1;
static int hf_skinny_subscriptionID = -1;
static int hf_skinny_systemTime = -1;
static int hf_skinny_temporalSpatialTradeOff = -1;
static int hf_skinny_temporalSpatialTradeOffCapability = -1;
static int hf_skinny_text = -1;
static int hf_skinny_timeOutValue = -1;
static int hf_skinny_timer = -1;
static int hf_skinny_tone = -1;
static int hf_skinny_toneAnnouncement = -1;
static int hf_skinny_tone_output_direction = -1;
static int hf_skinny_totalButtonCount = -1;
static int hf_skinny_totalNumOfConfiguredLines = -1;
static int hf_skinny_totalSoftKeyCount = -1;
static int hf_skinny_totalSoftKeySetCount = -1;
static int hf_skinny_transactionId = -1;
static int hf_skinny_transmitIpAddr_ipv4 = -1;
static int hf_skinny_transmitIpAddr_ipv6 = -1;
static int hf_skinny_transmitPreference = -1;
static int hf_skinny_unRegReasonCode = -1;
static int hf_skinny_unknown = -1;
static int hf_skinny_unknown1_0159 = -1;
static int hf_skinny_unknown2_0159 = -1;
static int hf_skinny_unknown3_0159 = -1;
static int hf_skinny_unknownString_0159 = -1;
static int hf_skinny_userName = -1;
static int hf_skinny_v150sprt = -1;
static int hf_skinny_vendor = -1;
static int hf_skinny_vendorID = -1;
static int hf_skinny_version = -1;
static int hf_skinny_versionStr = -1;
static int hf_skinny_videoCapCount = -1;
static int hf_skinny_videoCapabilityDirection = -1;
static int hf_skinny_wDay = -1;
static int hf_skinny_wDayOfWeek = -1;
static int hf_skinny_wHour = -1;
static int hf_skinny_wMilliseconds = -1;
static int hf_skinny_wMinute = -1;
static int hf_skinny_wMonth = -1;
static int hf_skinny_wSecond = -1;
static int hf_skinny_wYear = -1;
static int hf_skinny_waitTimeBeforeNextReq = -1;
static int hf_skinny_xmldata = -1;
static dissector_handle_t xml_handle;
/* Initialize the subtree pointers */
static int ett_skinny = -1;
static int ett_skinny_tree = -1;
/* preference globals */
static gboolean global_skinny_desegment = true;
/* tap register id */
static int skinny_tap = -1;
/* skinny protocol tap info */
#define MAX_SKINNY_MESSAGES_IN_PACKET 10
static skinny_info_t pi_arr[MAX_SKINNY_MESSAGES_IN_PACKET];
static int pi_current = 0;
static skinny_info_t *si;
dissector_handle_t skinny_handle;
/* Get the length of a single SKINNY PDU */
static unsigned
get_skinny_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
{
uint32_t hdr_data_length;
/* Get the length of the SKINNY packet. */
hdr_data_length = tvb_get_letohl(tvb, offset);
/* That length doesn't include the length of the header itself. */
return hdr_data_length + 8;
}
static void
dissect_skinny_xml(ptvcursor_t *cursor, int hfindex, packet_info *pinfo, uint32_t length, uint32_t maxlength)
{
proto_item *item = NULL;
proto_tree *subtree = NULL;
proto_tree *tree = ptvcursor_tree(cursor);
uint32_t offset = ptvcursor_current_offset(cursor);
tvbuff_t *tvb = ptvcursor_tvbuff(cursor);
tvbuff_t *next_tvb;
if (length == 0) {
length = tvb_strnlen(tvb, offset, -1);
}
if (length >= maxlength) {
length = maxlength;
}
ptvcursor_add_no_advance(cursor, hfindex, length, ENC_ASCII);
item = proto_tree_add_item(tree, hf_skinny_xmlData, tvb, offset, length, ENC_ASCII);
subtree = proto_item_add_subtree(item, 0);
next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, -1);
if (xml_handle != NULL) {
call_dissector(xml_handle, next_tvb, pinfo, subtree);
}
ptvcursor_advance(cursor, maxlength);
}
static void
dissect_skinny_ipv4or6(ptvcursor_t *cursor, int hfindex_ipv4, int hfindex_ipv6)
{
uint32_t ipversion = 0;
uint32_t offset = ptvcursor_current_offset(cursor);
tvbuff_t *tvb = ptvcursor_tvbuff(cursor);
uint32_t hdr_version = tvb_get_letohl(tvb, 4);
/* ProtocolVersion > 18 include and extra field to declare IPv4 (0) / IPv6 (1) */
if (hdr_version >= V17_MSG_TYPE) {
ipversion = tvb_get_letohl(tvb, offset);
ptvcursor_add(cursor, hf_skinny_ipv4or6, 4, ENC_LITTLE_ENDIAN);
}
if (ipversion == IPADDRTYPE_IPV4) {
ptvcursor_add(cursor, hfindex_ipv4, 4, ENC_BIG_ENDIAN);
if (hdr_version >= V17_MSG_TYPE) {
/* skip over the extra room for ipv6 addresses */
ptvcursor_advance(cursor, 12);
}
} else if (ipversion == IPADDRTYPE_IPV6 || ipversion == IPADDRTYPE_IPV4_V6) {
ptvcursor_add(cursor, hfindex_ipv6, 16, ENC_NA);
} else {
/* Invalid : skip over ipv6 space completely */
ptvcursor_advance(cursor, 16);
}
}
/* Reads address to provided variable */
static void
read_skinny_ipv4or6(ptvcursor_t *cursor, address *media_addr)
{
uint32_t ipversion = IPADDRTYPE_IPV4;
uint32_t offset = ptvcursor_current_offset(cursor);
uint32_t offset2 = 0;
tvbuff_t *tvb = ptvcursor_tvbuff(cursor);
uint32_t hdr_version = tvb_get_letohl(tvb, 4);
/* ProtocolVersion > 18 include and extra field to declare IPv4 (0) / IPv6 (1) */
if (hdr_version >= V17_MSG_TYPE) {
ipversion = tvb_get_letohl(tvb, offset);
offset2 = 4;
}
if (ipversion == IPADDRTYPE_IPV4) {
set_address_tvb(media_addr, AT_IPv4, 4, tvb, offset+offset2);
} else if (ipversion == IPADDRTYPE_IPV6 || ipversion == IPADDRTYPE_IPV4_V6) {
set_address_tvb(media_addr, AT_IPv6, 16, tvb, offset+offset2);
} else {
clear_address(media_addr);
}
}
/**
* Parse a displayLabel string and check if it is using any embedded labels, if so lookup the label and add a user readable translation to the item_tree
*/
static void
dissect_skinny_displayLabel(ptvcursor_t *cursor, packet_info *pinfo, int hfindex, int length)
{
proto_item *item = NULL;
proto_tree *tree = ptvcursor_tree(cursor);
uint32_t offset = ptvcursor_current_offset(cursor);
tvbuff_t *tvb = ptvcursor_tvbuff(cursor);
wmem_strbuf_t *wmem_new = NULL;
char *disp_string = NULL;
const char *replacestr = NULL;
bool show_replaced_str = false;
int x = 0;
if (length == 0) {
length = tvb_strnlen(tvb, offset, -1);
if (length == -1) {
/* did not find end of string */
length = tvb_captured_length_remaining(tvb, offset);
}
}
item = proto_tree_add_item(tree, hfindex, tvb, offset, length, ENC_ASCII);
wmem_new = wmem_strbuf_new_sized(pinfo->pool, length + 1);
disp_string = (char*) wmem_alloc(pinfo->pool, length + 1);
disp_string[length] = '\0';
tvb_memcpy(tvb, (void*)disp_string, offset, length);
for (x = 0; x < length && disp_string[x] != '\0'; x++) {
replacestr = NULL;
if (x + 1 < length) {
if (disp_string[x] == '\36') {
replacestr = try_val_to_str_ext(disp_string[x + 1], &DisplayLabels_36_ext);
} else if (disp_string[x] == '\200') {
replacestr = try_val_to_str_ext(disp_string[x + 1], &DisplayLabels_200_ext);
}
}
if (replacestr) {
x++; /* swallow replaced characters */
wmem_strbuf_append(wmem_new, replacestr);
show_replaced_str = true;
} else if (disp_string[x] & 0x80) {
wmem_strbuf_append_unichar_repl(wmem_new);
} else {
wmem_strbuf_append_c(wmem_new, disp_string[x]);
}
}
if (show_replaced_str) {
si->additionalInfo = ws_strdup_printf("\"%s\"", wmem_strbuf_get_str(wmem_new));
proto_item_append_text(item, " => \"%s\"" , wmem_strbuf_get_str(wmem_new));
}
ptvcursor_advance(cursor, length);
}
/*** Request / Response helper functions */
static void skinny_reqrep_add_request(ptvcursor_t *cursor, packet_info * pinfo, skinny_conv_info_t * skinny_conv, const int request_key)
{
proto_tree *tree = ptvcursor_tree(cursor);
tvbuff_t *tvb = ptvcursor_tvbuff(cursor);
skinny_req_resp_t *req_resp = NULL;
if (!PINFO_FD_VISITED(pinfo)) {
req_resp = wmem_new0(wmem_file_scope(), skinny_req_resp_t);
req_resp->request_frame = pinfo->num;
req_resp->response_frame = 0;
req_resp->request_time = pinfo->abs_ts;
wmem_map_insert(skinny_conv->pending_req_resp, GINT_TO_POINTER(request_key), (void *)req_resp);
DPRINT(("SKINNY: setup_request: frame=%d add key=%d to map\n", pinfo->num, request_key));
}
req_resp = (skinny_req_resp_t *) wmem_map_lookup(skinny_conv->requests, GUINT_TO_POINTER(pinfo->num));
if (req_resp && req_resp->response_frame) {
DPRINT(("SKINNY: show request in tree: frame/key=%d\n", pinfo->num));
proto_item *it;
it = proto_tree_add_uint(tree, hf_skinny_response_in, tvb, 0, 0, req_resp->response_frame);
proto_item_set_generated(it);
} else {
DPRINT(("SKINNY: no request found for frame/key=%d\n", pinfo->num));
}
}
static void skinny_reqrep_add_response(ptvcursor_t *cursor, packet_info * pinfo, skinny_conv_info_t * skinny_conv, const int request_key)
{
proto_tree *tree = ptvcursor_tree(cursor);
tvbuff_t *tvb = ptvcursor_tvbuff(cursor);
skinny_req_resp_t *req_resp = NULL;
if (!PINFO_FD_VISITED(pinfo)) {
req_resp = (skinny_req_resp_t *) wmem_map_remove(skinny_conv->pending_req_resp, GINT_TO_POINTER(request_key));
if (req_resp) {
DPRINT(("SKINNY: match request:%d with response:%d for key=%d\n", req_resp->request_frame, pinfo->num, request_key));
req_resp->response_frame = pinfo->num;
wmem_map_insert(skinny_conv->requests, GUINT_TO_POINTER(req_resp->request_frame), (void *)req_resp);
wmem_map_insert(skinny_conv->responses, GUINT_TO_POINTER(pinfo->num), (void *)req_resp);
} else {
DPRINT(("SKINNY: no match found for response frame=%d and key=%d\n", pinfo->num, request_key));
}
}
req_resp = (skinny_req_resp_t *) wmem_map_lookup(skinny_conv->responses, GUINT_TO_POINTER(pinfo->num));
if (req_resp && req_resp->request_frame) {
DPRINT(("SKINNY: show response in tree: frame/key=%d\n", pinfo->num));
proto_item *it;
nstime_t ns;
it = proto_tree_add_uint(tree, hf_skinny_response_to, tvb, 0, 0, req_resp->request_frame);
proto_item_set_generated(it);
nstime_delta(&ns, &pinfo->abs_ts, &req_resp->request_time);
it = proto_tree_add_time(tree, hf_skinny_response_time, tvb, 0, 0, &ns);
proto_item_set_generated(it);
} else {
DPRINT(("SKINNY: no response found for frame/key=%d\n", pinfo->num));
}
}
/*** Messages Handlers ***/
/*
* Message: RegisterReqMessage
* Opcode: 0x0001
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_RegisterReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_data_length = tvb_get_letohl(ptvcursor_tvbuff(cursor), 0);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sid");
ptvcursor_add(cursor, hf_skinny_DeviceName, 16, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_reserved_for_future_use, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_instance, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_add(cursor, hf_skinny_stationIpAddr, 4, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hf_skinny_deviceType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxStreams, 4, ENC_LITTLE_ENDIAN);
if (hdr_data_length > 52) {
ptvcursor_add(cursor, hf_skinny_activeStreams, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_protocolVer, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_unknown, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "phoneFeatures");
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit1, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit2, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit3, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit4, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_UTF8, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit6, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit7, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_DynamicMessages, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit9, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_RFC2833, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit11, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit12, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit13, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit14, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit15, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Abbreviated_Dial, 2, ENC_LITTLE_ENDIAN);
ptvcursor_advance(cursor, 2);
ptvcursor_pop_subtree(cursor); /* end bitfield: phoneFeatures */
ptvcursor_add(cursor, hf_skinny_maxConferences, 4, ENC_LITTLE_ENDIAN);
}
if (hdr_data_length > 100) {
ptvcursor_add(cursor, hf_skinny_activeConferences, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_macAddress, 6, ENC_NA);
ptvcursor_advance(cursor, 12 - 6);
ptvcursor_add(cursor, hf_skinny_ipV4AddressScope, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxNumberOfLines, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_stationIpV6Addr, 16, ENC_NA);
ptvcursor_add(cursor, hf_skinny_ipV6AddressScope, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_firmwareLoadName, 32, ENC_ASCII);
}
if (hdr_data_length > 191) {
ptvcursor_add(cursor, hf_skinny_configVersionStamp, 48, ENC_ASCII);
}
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0001);
}
/*
* Message: IpPortMessage
* Opcode: 0x0002
* Type: CallControl
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_IpPortMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_rtpMediaPort, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: KeypadButtonMessage
* Opcode: 0x0003
* Type: CallControl
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_KeypadButtonMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_data_length = tvb_get_letohl(ptvcursor_tvbuff(cursor), 0);
si->additionalInfo = ws_strdup_printf("\"%s\"",
try_val_to_str_ext(
tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor)),
&KeyPadButton_short_ext
)
);
ptvcursor_add(cursor, hf_skinny_kpButton, 4, ENC_LITTLE_ENDIAN);
if (hdr_data_length > 8) {
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
}
/*
* Message: EnblocCallMessage
* Opcode: 0x0004
* Type: CallControl
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_EnblocCallMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_data_length = tvb_get_letohl(ptvcursor_tvbuff(cursor), 0);
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
uint32_t VariableDirnumSize = (hdr_version >= V18_MSG_TYPE) ? 25 : 24;
si->calledParty = g_strdup(tvb_format_stringzpad(pinfo->pool, ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), VariableDirnumSize));
ptvcursor_add(cursor, hf_skinny_calledParty, VariableDirnumSize, ENC_ASCII);
if (hdr_data_length > 28) {
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
}
}
/*
* Message: StimulusMessage
* Opcode: 0x0005
* Type: CallControl
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_StimulusMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_stimulus, 4, ENC_LITTLE_ENDIAN);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_stimulusStatus, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: OffHookMessage
* Opcode: 0x0006
* Type: CallControl
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_OffHookMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_data_length = tvb_get_letohl(ptvcursor_tvbuff(cursor), 0);
if (hdr_data_length > 4) {
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
}
/*
* Message: OnHookMessage
* Opcode: 0x0007
* Type: CallControl
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_OnHookMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_data_length = tvb_get_letohl(ptvcursor_tvbuff(cursor), 0);
if (hdr_data_length > 4) {
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
}
/*
* Message: HookFlashMessage
* Opcode: 0x0008
* Type: CallControl
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_HookFlashMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: ForwardStatReqMessage
* Opcode: 0x0009
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_ForwardStatReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t lineNumber = 0;
lineNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineNumber, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0009 ^ lineNumber);
}
/*
* Message: SpeedDialStatReqMessage
* Opcode: 0x000a
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_SpeedDialStatReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t speedDialNumber = 0;
speedDialNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_speedDialNumber, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x000a ^ speedDialNumber);
}
/*
* Message: LineStatReqMessage
* Opcode: 0x000b
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_LineStatReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t lineNumber = 0;
lineNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineNumber, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x000b ^ lineNumber);
}
/*
* Message: CapabilitiesResMessage
* Opcode: 0x0010
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_CapabilitiesResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t capCount = 0;
guint32 payloadCapability = 0;
capCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_capCount, 4, ENC_LITTLE_ENDIAN);
if (capCount <= 18) {
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "caps [ref:capCount = %d, max:18]", capCount);
if (capCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (capCount * 16) && capCount <= 18) {
for (counter_1 = 0; counter_1 < 18; counter_1++) {
if (counter_1 < capCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "caps [%d / %d]", counter_1 + 1, capCount);
payloadCapability = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_payloadCapability, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxFramesPerPacket, 4, ENC_LITTLE_ENDIAN);
if (payloadCapability == MEDIA_PAYLOAD_G7231) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_G7231");
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 4);
} else if (payloadCapability == MEDIA_PAYLOAD_V150_LC_MODEMRELAY) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_v150_LC_ModemRelay");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "modemRelay");
ptvcursor_add(cursor, hf_skinny_capAndVer, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_modAnd2833, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (payloadCapability == MEDIA_PAYLOAD_V150_LC_SPRT) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_v150_LC_SPRT");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sprtPayload");
ptvcursor_add(cursor, hf_skinny_chan0MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan2MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan3MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan2MaxWindow, 2, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (payloadCapability == MEDIA_PAYLOAD_V150_LC_SSE) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_v150_LC_SSE");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sse");
ptvcursor_add(cursor, hf_skinny_standard, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_vendor, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "any payloadCapability");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "codecParams");
ptvcursor_add(cursor, hf_skinny_codecMode, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dynamicPayload, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam1, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam2, 1, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 4);
}
} else {
ptvcursor_advance(cursor, 16);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (capCount * 16));
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x009b);
}
/*
* Message: AlarmMessage
* Opcode: 0x0020
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_AlarmMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_alarmSeverity, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_text, 80, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_parm1, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_parm2, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: MulticastMediaReceptionAckMessage
* Opcode: 0x0021
* Type: MediaControl
* Direction: dev2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_MulticastMediaReceptionAckMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t passThroughPartyId = 0;
si->multicastReceptionStatus = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_multicastReceptionStatus, 4, ENC_LITTLE_ENDIAN);
passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0101 ^ passThroughPartyId);
}
/*
* Message: OpenReceiveChannelAckMessage
* Opcode: 0x0022
* Type: MediaControl
* Direction: dev2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_OpenReceiveChannelAckMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_data_length = tvb_get_letohl(ptvcursor_tvbuff(cursor), 0);
address ipAddr;
char *ipAddr_str = NULL;
uint32_t portNumber = 0;
uint32_t passThroughPartyId = 0;
si->mediaReceptionStatus = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_mediaReceptionStatus, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &ipAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_ipAddr_ipv4, hf_skinny_ipAddr_ipv6);
portNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_portNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &ipAddr, portNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
ipAddr_str = address_to_display(NULL, &ipAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", ipAddr_str, portNumber);
wmem_free(NULL, ipAddr_str);
passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
if (hdr_data_length > 20) {
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0105 ^ passThroughPartyId);
}
/*
* Message: ConnectionStatisticsResMessage
* Opcode: 0x0023
* Type: CallControl
* Direction: dev2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_ConnectionStatisticsResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_data_length = tvb_get_letohl(ptvcursor_tvbuff(cursor), 0);
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
uint32_t callReference = 0;
uint32_t dataSize = 0;
if (hdr_version <= V17_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_directoryNum, 24, ENC_ASCII);
callReference = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_statsProcessingMode, 4, ENC_LITTLE_ENDIAN);
}
if (hdr_version >= V18_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_directoryNum, 28, ENC_ASCII);
callReference = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_statsProcessingMode, 1, ENC_LITTLE_ENDIAN);
}
ptvcursor_add(cursor, hf_skinny_numberPacketsSent, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numberOctetsSent, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numberPacketsReceived, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numberOctetsReceived, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numberPacketsLost, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_jitter, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_latency, 4, ENC_LITTLE_ENDIAN);
if (hdr_data_length > 64) {
dataSize = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_dataSize, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_data, dataSize, ENC_ASCII);
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0107 ^ callReference);
}
/*
* Message: OffHookWithCallingPartyNumberMessage
* Opcode: 0x0024
* Type: CallControl
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_OffHookWithCallingPartyNumberMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
uint32_t VariableDirnumSize = (hdr_version >= V18_MSG_TYPE) ? 25 : 24;
ptvcursor_add(cursor, hf_skinny_callingPartyNumber, VariableDirnumSize, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_cgpnVoiceMailbox, VariableDirnumSize, ENC_ASCII);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: SoftKeyEventMessage
* Opcode: 0x0026
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_SoftKeyEventMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_softKeyEvent, 4, ENC_LITTLE_ENDIAN);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: UnregisterReqMessage
* Opcode: 0x0027
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_UnregisterReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_data_length = tvb_get_letohl(ptvcursor_tvbuff(cursor), 0);
if (hdr_data_length > 12) {
ptvcursor_add(cursor, hf_skinny_unRegReasonCode, 4, ENC_LITTLE_ENDIAN);
}
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0027);
}
/*
* Message: RegisterTokenReq
* Opcode: 0x0029
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_RegisterTokenReq(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sid");
ptvcursor_add(cursor, hf_skinny_DeviceName, 16, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_reserved_for_future_use, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_instance, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_add(cursor, hf_skinny_stationIpAddr, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_deviceType, 4, ENC_LITTLE_ENDIAN);
dissect_skinny_ipv4or6(cursor, hf_skinny_stationIpV6Addr_ipv4, hf_skinny_stationIpV6Addr_ipv6);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0029);
}
/*
* Message: MediaTransmissionFailureMessage
* Opcode: 0x002a
* Type: MediaControl
* Direction: dev2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_MediaTransmissionFailureMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t passThroughPartyId = 0;
address remoteIpAddr;
char *remoteIpAddr_str = NULL;
uint32_t remotePortNumber = 0;
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &remoteIpAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_remoteIpAddr_ipv4, hf_skinny_remoteIpAddr_ipv6);
remotePortNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_remotePortNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &remoteIpAddr, remotePortNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
remoteIpAddr_str = address_to_display(NULL, &remoteIpAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", remoteIpAddr_str, remotePortNumber);
wmem_free(NULL, remoteIpAddr_str);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x008a ^ passThroughPartyId);
}
/*
* Message: HeadsetStatusMessage
* Opcode: 0x002b
* Type: CallControl
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_HeadsetStatusMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_headsetStatus, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: MediaResourceNotificationMessage
* Opcode: 0x002c
* Type: MediaControl
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_MediaResourceNotificationMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_deviceType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numberOfInServiceStreams, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxStreamsPerConf, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numberOfOutOfServiceStreams, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: RegisterAvailableLinesMessage
* Opcode: 0x002d
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_RegisterAvailableLinesMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_maxNumOfAvailLines, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: DeviceToUserDataMessage
* Opcode: 0x002e
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_DeviceToUserDataMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t dataLength = 0;
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "deviceToUserData");
ptvcursor_add(cursor, hf_skinny_applicationId, 4, ENC_LITTLE_ENDIAN);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_transactionId, 4, ENC_LITTLE_ENDIAN);
dataLength = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_dataLength, 4, ENC_LITTLE_ENDIAN);
dissect_skinny_xml(cursor, hf_skinny_xmldata, pinfo, dataLength, 2000);
ptvcursor_pop_subtree(cursor);
}
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x002e);
}
/*
* Message: DeviceToUserDataResponseMessage
* Opcode: 0x002f
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_DeviceToUserDataResponseMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t dataLength = 0;
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "deviceToUserData");
ptvcursor_add(cursor, hf_skinny_applicationId, 4, ENC_LITTLE_ENDIAN);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_transactionId, 4, ENC_LITTLE_ENDIAN);
dataLength = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_dataLength, 4, ENC_LITTLE_ENDIAN);
dissect_skinny_xml(cursor, hf_skinny_xmldata, pinfo, dataLength, 2000);
ptvcursor_pop_subtree(cursor);
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x002e);
}
/*
* Message: UpdateCapabilitiesMessage
* Opcode: 0x0030
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_UpdateCapabilitiesMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t audioCapCount = 0;
uint32_t videoCapCount = 0;
uint32_t dataCapCount = 0;
uint32_t customPictureFormatCount = 0;
uint32_t serviceResourceCount = 0;
uint32_t layoutCount = 0;
guint32 payloadCapability = 0;
uint32_t levelPreferenceCount = 0;
audioCapCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_audioCapCount, 4, ENC_LITTLE_ENDIAN);
videoCapCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_videoCapCount, 4, ENC_LITTLE_ENDIAN);
dataCapCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_dataCapCount, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_rtpPayloadFormat, 4, ENC_LITTLE_ENDIAN);
customPictureFormatCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_customPictureFormatCount, 4, ENC_LITTLE_ENDIAN);
if (customPictureFormatCount <= 6) {
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "customPictureFormat [ref:customPictureFormatCount = %d, max:6]", customPictureFormatCount);
if (customPictureFormatCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (customPictureFormatCount * 20) && customPictureFormatCount <= 6) {
for (counter_1 = 0; counter_1 < 6; counter_1++) {
if (counter_1 < customPictureFormatCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "customPictureFormat [%d / %d]", counter_1 + 1, customPictureFormatCount);
ptvcursor_add(cursor, hf_skinny_pictureWidth, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_pictureHeight, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_pixelAspectRatio, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_clockConversionCode, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_clockDivisor, 4, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 20);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (customPictureFormatCount * 20));
}
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "confResources");
ptvcursor_add(cursor, hf_skinny_activeStreamsOnRegistration, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxBW, 4, ENC_LITTLE_ENDIAN);
serviceResourceCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_serviceResourceCount, 4, ENC_LITTLE_ENDIAN);
if (serviceResourceCount <= 4) {
uint32_t counter_2 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "serviceResource [ref:serviceResourceCount = %d, max:4]", serviceResourceCount);
if (serviceResourceCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (serviceResourceCount * 24) && serviceResourceCount <= 4) {
for (counter_2 = 0; counter_2 < 4; counter_2++) {
if (counter_2 < serviceResourceCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "serviceResource [%d / %d]", counter_2 + 1, serviceResourceCount);
layoutCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_layoutCount, 4, ENC_LITTLE_ENDIAN);
if (layoutCount <= 5) { /* tvb enum size guard */
uint32_t counter_7 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "layouts [ref: layoutCount = %d, max:5]", layoutCount);
for (counter_7 = 0; counter_7 < 5; counter_7++) {
if (counter_7 < layoutCount) {
ptvcursor_add(cursor, hf_skinny_layouts, 4, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 4);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (5 * 4)); /* guard kicked in -> skip the rest */;
}
ptvcursor_add(cursor, hf_skinny_serviceNum, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxStreams, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxConferences, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_activeConferenceOnRegistration, 4, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 24);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (serviceResourceCount * 24));
}
ptvcursor_pop_subtree(cursor);
}
if (audioCapCount <= 18) {
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "audiocaps [ref:audioCapCount = %d, max:18]", audioCapCount);
if (audioCapCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (audioCapCount * 16) && audioCapCount <= 18) {
for (counter_1 = 0; counter_1 < 18; counter_1++) {
if (counter_1 < audioCapCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "audiocaps [%d / %d]", counter_1 + 1, audioCapCount);
payloadCapability = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_payloadCapability, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxFramesPerPacket, 4, ENC_LITTLE_ENDIAN);
if (payloadCapability == MEDIA_PAYLOAD_G7231) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_G7231");
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 4);
} else if (payloadCapability == MEDIA_PAYLOAD_V150_LC_MODEMRELAY) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_v150_LC_ModemRelay");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "modemRelay");
ptvcursor_add(cursor, hf_skinny_capAndVer, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_modAnd2833, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (payloadCapability == MEDIA_PAYLOAD_V150_LC_SPRT) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_v150_LC_SPRT");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sprtPayload");
ptvcursor_add(cursor, hf_skinny_chan0MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan2MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan3MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan2MaxWindow, 2, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (payloadCapability == MEDIA_PAYLOAD_V150_LC_SSE) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_v150_LC_SSE");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sse");
ptvcursor_add(cursor, hf_skinny_standard, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_vendor, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "any payloadCapability");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "codecParams");
ptvcursor_add(cursor, hf_skinny_codecMode, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dynamicPayload, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam1, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam2, 1, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 4);
}
} else {
ptvcursor_advance(cursor, 16);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (audioCapCount * 16));
}
if (videoCapCount <= 10) {
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "vidCaps [ref:videoCapCount = %d, max:10]", videoCapCount);
if (videoCapCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (videoCapCount * 44) && videoCapCount <= 10) {
for (counter_1 = 0; counter_1 < 10; counter_1++) {
if (counter_1 < videoCapCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "vidCaps [%d / %d]", counter_1 + 1, videoCapCount);
payloadCapability = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_payloadCapability, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_videoCapabilityDirection, 4, ENC_LITTLE_ENDIAN);
levelPreferenceCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_levelPreferenceCount, 4, ENC_LITTLE_ENDIAN);
if (levelPreferenceCount <= 4) {
uint32_t counter_5 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "levelPreference [ref:levelPreferenceCount = %d, max:4]", levelPreferenceCount);
if (levelPreferenceCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (levelPreferenceCount * 24) && levelPreferenceCount <= 4) {
for (counter_5 = 0; counter_5 < 4; counter_5++) {
if (counter_5 < levelPreferenceCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "levelPreference [%d / %d]", counter_5 + 1, levelPreferenceCount);
ptvcursor_add(cursor, hf_skinny_transmitPreference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_format, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxBitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_minBitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_MPI, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_serviceNumber, 4, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 24);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (levelPreferenceCount * 24));
}
if (payloadCapability == MEDIA_PAYLOAD_H261) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_H261");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h261VideoCapability");
ptvcursor_add(cursor, hf_skinny_temporalSpatialTradeOffCapability, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_stillImageTransmission, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (payloadCapability == MEDIA_PAYLOAD_H263) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_H263");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h263VideoCapability");
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h263_capability_bitfield");
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit1, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit2, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit3, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit4, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit5, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit6, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit7, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit8, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit9, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit10, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit11, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit12, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit13, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit14, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit15, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit16, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit17, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit18, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit19, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit20, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit21, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit22, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit23, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit24, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit25, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit26, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit27, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit28, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit29, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit30, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit31, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit32, 4, ENC_LITTLE_ENDIAN);
ptvcursor_advance(cursor, 4);
ptvcursor_pop_subtree(cursor); /* end bitfield: h263_capability_bitfield */
ptvcursor_add(cursor, hf_skinny_annexNandWFutureUse, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (payloadCapability == MEDIA_PAYLOAD_VIEO) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_Vieo");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "vieoVideoCapability");
ptvcursor_add(cursor, hf_skinny_modelNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_bandwidth, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
}
} else {
ptvcursor_advance(cursor, 44);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (videoCapCount * 44));
}
if (dataCapCount <= 5) {
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "dataCaps [ref:dataCapCount = %d, max:5]", dataCapCount);
if (dataCapCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (dataCapCount * 16) && dataCapCount <= 5) {
for (counter_1 = 0; counter_1 < 5; counter_1++) {
if (counter_1 < dataCapCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "dataCaps [%d / %d]", counter_1 + 1, dataCapCount);
ptvcursor_add(cursor, hf_skinny_payloadCapability, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dataCapabilityDirection, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_protocolDependentData, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxBitRate, 4, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 16);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (dataCapCount * 16));
}
}
/*
* Message: OpenMultiMediaReceiveChannelAckMessage
* Opcode: 0x0031
* Type: MediaControl
* Direction: dev2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_OpenMultiMediaReceiveChannelAckMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
address ipAddr;
char *ipAddr_str = NULL;
uint32_t portNumber = 0;
uint32_t passThroughPartyId = 0;
si->multimediaReceptionStatus = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_multimediaReceptionStatus, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &ipAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_ipAddr_ipv4, hf_skinny_ipAddr_ipv6);
portNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_portNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &ipAddr, portNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
ipAddr_str = address_to_display(NULL, &ipAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", ipAddr_str, portNumber);
wmem_free(NULL, ipAddr_str);
passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0131 ^ passThroughPartyId);
}
/*
* Message: ClearConferenceMessage
* Opcode: 0x0032
* Type: Conference
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_ClearConferenceMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_serviceNum, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: ServiceURLStatReqMessage
* Opcode: 0x0033
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_ServiceURLStatReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t serviceURLIndex = 0;
serviceURLIndex = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_serviceURLIndex, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0033 ^ serviceURLIndex);
}
/*
* Message: FeatureStatReqMessage
* Opcode: 0x0034
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_FeatureStatReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_data_length = tvb_get_letohl(ptvcursor_tvbuff(cursor), 0);
uint32_t featureIndex = 0;
featureIndex = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_featureIndex, 4, ENC_LITTLE_ENDIAN);
if (hdr_data_length > 16) {
ptvcursor_add(cursor, hf_skinny_featureCapabilities, 4, ENC_LITTLE_ENDIAN);
}
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0034 ^ featureIndex);
}
/*
* Message: CreateConferenceResMessage
* Opcode: 0x0035
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_CreateConferenceResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t conferenceId = 0;
uint32_t dataLength = 0;
conferenceId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_result, 4, ENC_LITTLE_ENDIAN);
dataLength = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_dataLength, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_passThruData, dataLength, ENC_ASCII);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0137 ^ conferenceId);
}
/*
* Message: DeleteConferenceResMessage
* Opcode: 0x0036
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_DeleteConferenceResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t conferenceId = 0;
conferenceId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_delete_conf_result, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0138 ^ conferenceId);
}
/*
* Message: ModifyConferenceResMessage
* Opcode: 0x0037
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_ModifyConferenceResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t conferenceId = 0;
uint32_t dataLength = 0;
conferenceId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_modify_conf_result, 4, ENC_LITTLE_ENDIAN);
dataLength = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_dataLength, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_passThruData, dataLength, ENC_ASCII);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0139 ^ conferenceId);
}
/*
* Message: AddParticipantResMessage
* Opcode: 0x0038
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_AddParticipantResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t conferenceId = 0;
conferenceId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_add_participant_result, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_bridgeParticipantId, 257, ENC_ASCII);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x013a ^ conferenceId);
}
/*
* Message: AuditConferenceResMessage
* Opcode: 0x0039
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_AuditConferenceResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t numberOfEntries = 0;
ptvcursor_add(cursor, hf_skinny_last, 4, ENC_LITTLE_ENDIAN);
numberOfEntries = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_numberOfEntries, 4, ENC_LITTLE_ENDIAN);
if (numberOfEntries <= 32) {
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "conferenceEntry [ref:numberOfEntries = %d, max:32]", numberOfEntries);
if (numberOfEntries && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (numberOfEntries * 76) && numberOfEntries <= 32) {
for (counter_1 = 0; counter_1 < 32; counter_1++) {
if (counter_1 < numberOfEntries) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "conferenceEntry [%d / %d]", counter_1 + 1, numberOfEntries);
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_resourceType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numberOfReservedParticipants, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numberOfActiveParticipants, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_applicationId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_appConfID, 32, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_appData, 24, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 76);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (numberOfEntries * 76));
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x013c);
}
/*
* Message: AuditParticipantResMessage
* Opcode: 0x0040
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_AuditParticipantResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t conferenceId = 0;
uint32_t numberOfEntries = 0;
ptvcursor_add(cursor, hf_skinny_audit_participant_result, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_last, 4, ENC_LITTLE_ENDIAN);
conferenceId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
numberOfEntries = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_numberOfEntries, 4, ENC_LITTLE_ENDIAN);
if (numberOfEntries <= 256) {
uint32_t counter_2 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "participantEntry [ref:numberOfEntries = %d, max:256]", numberOfEntries);
for (counter_2 = 0; counter_2 < 256; counter_2++) {
if (counter_2 < numberOfEntries) {
ptvcursor_add(cursor, hf_skinny_participantEntry, 4, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 4);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (256 * 4));
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x013d ^ conferenceId);
}
/*
* Message: DeviceToUserDataMessageVersion1
* Opcode: 0x0041
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_DeviceToUserDataMessageVersion1(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t dataLength = 0;
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "deviceToUserDataVersion1");
ptvcursor_add(cursor, hf_skinny_applicationId, 4, ENC_LITTLE_ENDIAN);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_transactionId, 4, ENC_LITTLE_ENDIAN);
dataLength = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_dataLength, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_sequenceFlag, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_displayPriority, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_appInstanceID, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_routingID, 4, ENC_LITTLE_ENDIAN);
dissect_skinny_xml(cursor, hf_skinny_xmldata, pinfo, dataLength, 2000);
ptvcursor_pop_subtree(cursor);
}
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0041);
}
/*
* Message: DeviceToUserDataResponseMessageVersion1
* Opcode: 0x0042
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_DeviceToUserDataResponseMessageVersion1(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t dataLength = 0;
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "deviceToUserDataVersion1");
ptvcursor_add(cursor, hf_skinny_applicationId, 4, ENC_LITTLE_ENDIAN);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_transactionId, 4, ENC_LITTLE_ENDIAN);
dataLength = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_dataLength, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_sequenceFlag, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_displayPriority, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_appInstanceID, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_routingID, 4, ENC_LITTLE_ENDIAN);
dissect_skinny_xml(cursor, hf_skinny_xmldata, pinfo, dataLength, 2000);
ptvcursor_pop_subtree(cursor);
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0041);
}
/*
* Message: CapabilitiesV2ResMessage
* Opcode: 0x0043
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_CapabilitiesV2ResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t audioCapCount = 0;
uint32_t videoCapCount = 0;
uint32_t dataCapCount = 0;
uint32_t customPictureFormatCount = 0;
uint32_t serviceResourceCount = 0;
uint32_t layoutCount = 0;
guint32 payloadCapability = 0;
uint32_t levelPreferenceCount = 0;
audioCapCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_audioCapCount, 4, ENC_LITTLE_ENDIAN);
videoCapCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_videoCapCount, 4, ENC_LITTLE_ENDIAN);
dataCapCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_dataCapCount, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_rtpPayloadFormat, 4, ENC_LITTLE_ENDIAN);
customPictureFormatCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_customPictureFormatCount, 4, ENC_LITTLE_ENDIAN);
if (customPictureFormatCount <= 6) {
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "customPictureFormat [ref:customPictureFormatCount = %d, max:6]", customPictureFormatCount);
if (customPictureFormatCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (customPictureFormatCount * 20) && customPictureFormatCount <= 6) {
for (counter_1 = 0; counter_1 < 6; counter_1++) {
if (counter_1 < customPictureFormatCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "customPictureFormat [%d / %d]", counter_1 + 1, customPictureFormatCount);
ptvcursor_add(cursor, hf_skinny_pictureWidth, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_pictureHeight, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_pixelAspectRatio, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_clockConversionCode, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_clockDivisor, 4, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 20);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (customPictureFormatCount * 20));
}
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "confResources");
ptvcursor_add(cursor, hf_skinny_activeStreamsOnRegistration, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxBW, 4, ENC_LITTLE_ENDIAN);
serviceResourceCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_serviceResourceCount, 4, ENC_LITTLE_ENDIAN);
if (serviceResourceCount <= 4) {
uint32_t counter_2 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "serviceResource [ref:serviceResourceCount = %d, max:4]", serviceResourceCount);
if (serviceResourceCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (serviceResourceCount * 24) && serviceResourceCount <= 4) {
for (counter_2 = 0; counter_2 < 4; counter_2++) {
if (counter_2 < serviceResourceCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "serviceResource [%d / %d]", counter_2 + 1, serviceResourceCount);
layoutCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_layoutCount, 4, ENC_LITTLE_ENDIAN);
if (layoutCount <= 5) { /* tvb enum size guard */
uint32_t counter_7 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "layouts [ref: layoutCount = %d, max:5]", layoutCount);
for (counter_7 = 0; counter_7 < 5; counter_7++) {
if (counter_7 < layoutCount) {
ptvcursor_add(cursor, hf_skinny_layouts, 4, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 4);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (5 * 4)); /* guard kicked in -> skip the rest */;
}
ptvcursor_add(cursor, hf_skinny_serviceNum, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxStreams, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxConferences, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_activeConferenceOnRegistration, 4, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 24);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (serviceResourceCount * 24));
}
ptvcursor_pop_subtree(cursor);
}
if (audioCapCount <= 18) {
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "audiocaps [ref:audioCapCount = %d, max:18]", audioCapCount);
if (audioCapCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (audioCapCount * 16) && audioCapCount <= 18) {
for (counter_1 = 0; counter_1 < 18; counter_1++) {
if (counter_1 < audioCapCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "audiocaps [%d / %d]", counter_1 + 1, audioCapCount);
payloadCapability = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_payloadCapability, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxFramesPerPacket, 4, ENC_LITTLE_ENDIAN);
if (payloadCapability == MEDIA_PAYLOAD_G7231) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_G7231");
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 4);
} else if (payloadCapability == MEDIA_PAYLOAD_V150_LC_MODEMRELAY) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_v150_LC_ModemRelay");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "modemRelay");
ptvcursor_add(cursor, hf_skinny_capAndVer, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_modAnd2833, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (payloadCapability == MEDIA_PAYLOAD_V150_LC_SPRT) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_v150_LC_SPRT");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sprtPayload");
ptvcursor_add(cursor, hf_skinny_chan0MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan2MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan3MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan2MaxWindow, 2, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (payloadCapability == MEDIA_PAYLOAD_V150_LC_SSE) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_v150_LC_SSE");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sse");
ptvcursor_add(cursor, hf_skinny_standard, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_vendor, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "any payloadCapability");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "codecParams");
ptvcursor_add(cursor, hf_skinny_codecMode, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dynamicPayload, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam1, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam2, 1, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 4);
}
} else {
ptvcursor_advance(cursor, 16);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (audioCapCount * 16));
}
if (videoCapCount <= 10) {
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "vidCaps [ref:videoCapCount = %d, max:10]", videoCapCount);
if (videoCapCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (videoCapCount * 60) && videoCapCount <= 10) {
for (counter_1 = 0; counter_1 < 10; counter_1++) {
if (counter_1 < videoCapCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "vidCaps [%d / %d]", counter_1 + 1, videoCapCount);
payloadCapability = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_payloadCapability, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_videoCapabilityDirection, 4, ENC_LITTLE_ENDIAN);
levelPreferenceCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_levelPreferenceCount, 4, ENC_LITTLE_ENDIAN);
if (levelPreferenceCount <= 4) {
uint32_t counter_5 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "levelPreference [ref:levelPreferenceCount = %d, max:4]", levelPreferenceCount);
if (levelPreferenceCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (levelPreferenceCount * 24) && levelPreferenceCount <= 4) {
for (counter_5 = 0; counter_5 < 4; counter_5++) {
if (counter_5 < levelPreferenceCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "levelPreference [%d / %d]", counter_5 + 1, levelPreferenceCount);
ptvcursor_add(cursor, hf_skinny_transmitPreference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_format, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxBitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_minBitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_MPI, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_serviceNumber, 4, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 24);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (levelPreferenceCount * 24));
}
if (payloadCapability == MEDIA_PAYLOAD_H261) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_H261");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h261VideoCapability");
ptvcursor_add(cursor, hf_skinny_temporalSpatialTradeOffCapability, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_stillImageTransmission, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 16);
} else if (payloadCapability == MEDIA_PAYLOAD_H263) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_H263");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h263VideoCapability");
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h263_capability_bitfield");
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit1, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit2, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit3, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit4, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit5, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit6, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit7, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit8, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit9, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit10, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit11, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit12, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit13, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit14, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit15, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit16, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit17, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit18, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit19, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit20, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit21, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit22, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit23, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit24, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit25, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit26, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit27, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit28, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit29, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit30, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit31, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit32, 4, ENC_LITTLE_ENDIAN);
ptvcursor_advance(cursor, 4);
ptvcursor_pop_subtree(cursor); /* end bitfield: h263_capability_bitfield */
ptvcursor_add(cursor, hf_skinny_annexNandWFutureUse, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 16);
} else if (payloadCapability == MEDIA_PAYLOAD_H264) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_H264");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h264VideoCapability");
ptvcursor_add(cursor, hf_skinny_profile, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_level, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_customMaxMBPS, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_customMaxFS, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_customMaxDPB, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_customMaxBRandCPB, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (payloadCapability == MEDIA_PAYLOAD_VIEO) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_Vieo");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "vieoVideoCapability");
ptvcursor_add(cursor, hf_skinny_modelNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_bandwidth, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 16);
}
} else {
ptvcursor_advance(cursor, 60);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (videoCapCount * 60));
}
if (dataCapCount <= 5) {
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "dataCaps [ref:dataCapCount = %d, max:5]", dataCapCount);
if (dataCapCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (dataCapCount * 16) && dataCapCount <= 5) {
for (counter_1 = 0; counter_1 < 5; counter_1++) {
if (counter_1 < dataCapCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "dataCaps [%d / %d]", counter_1 + 1, dataCapCount);
ptvcursor_add(cursor, hf_skinny_payloadCapability, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dataCapabilityDirection, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_protocolDependentData, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxBitRate, 4, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 16);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (dataCapCount * 16));
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x009b);
}
/*
* Message: CapabilitiesV3ResMessage
* Opcode: 0x0044
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: yes
* MsgType: response
*/
static void
handle_CapabilitiesV3ResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t audioCapCount = 0;
uint32_t videoCapCount = 0;
uint32_t dataCapCount = 0;
uint32_t customPictureFormatCount = 0;
uint32_t serviceResourceCount = 0;
uint32_t layoutCount = 0;
guint32 payloadCapability = 0;
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
uint32_t levelPreferenceCount = 0;
audioCapCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_audioCapCount, 4, ENC_LITTLE_ENDIAN);
videoCapCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_videoCapCount, 4, ENC_LITTLE_ENDIAN);
dataCapCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_dataCapCount, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_rtpPayloadFormat, 4, ENC_LITTLE_ENDIAN);
customPictureFormatCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_customPictureFormatCount, 4, ENC_LITTLE_ENDIAN);
if (customPictureFormatCount <= 6) {
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "customPictureFormat [ref:customPictureFormatCount = %d, max:6]", customPictureFormatCount);
if (customPictureFormatCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (customPictureFormatCount * 20) && customPictureFormatCount <= 6) {
for (counter_1 = 0; counter_1 < 6; counter_1++) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "customPictureFormat [%d / %d]", counter_1 + 1, customPictureFormatCount);
ptvcursor_add(cursor, hf_skinny_pictureWidth, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_pictureHeight, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_pixelAspectRatio, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_clockConversionCode, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_clockDivisor, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (customPictureFormatCount * 20));
}
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "confResources");
ptvcursor_add(cursor, hf_skinny_activeStreamsOnRegistration, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxBW, 4, ENC_LITTLE_ENDIAN);
serviceResourceCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_serviceResourceCount, 4, ENC_LITTLE_ENDIAN);
if (serviceResourceCount <= 4) {
uint32_t counter_2 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "serviceResource [ref:serviceResourceCount = %d, max:4]", serviceResourceCount);
if (serviceResourceCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (serviceResourceCount * 24) && serviceResourceCount <= 4) {
for (counter_2 = 0; counter_2 < 4; counter_2++) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "serviceResource [%d / %d]", counter_2 + 1, serviceResourceCount);
layoutCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_layoutCount, 4, ENC_LITTLE_ENDIAN);
if (layoutCount <= 5) { /* tvb enum size guard */
uint32_t counter_6 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "layouts [ref: layoutCount = %d, max:layoutCount]", layoutCount);
for (counter_6 = 0; counter_6 < layoutCount; counter_6++) {
ptvcursor_add(cursor, hf_skinny_layouts, 4, ENC_LITTLE_ENDIAN);
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (layoutCount * 4)); /* guard kicked in -> skip the rest */;
}
ptvcursor_add(cursor, hf_skinny_serviceNum, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxStreams, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxConferences, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_activeConferenceOnRegistration, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (serviceResourceCount * 24));
}
ptvcursor_pop_subtree(cursor);
}
if (audioCapCount <= 18) {
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "audiocaps [ref:audioCapCount = %d, max:18]", audioCapCount);
if (audioCapCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (audioCapCount * 16) && audioCapCount <= 18) {
for (counter_1 = 0; counter_1 < 18; counter_1++) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "audiocaps [%d / %d]", counter_1 + 1, audioCapCount);
payloadCapability = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_payloadCapability, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxFramesPerPacket, 4, ENC_LITTLE_ENDIAN);
if (payloadCapability == MEDIA_PAYLOAD_G7231) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_G7231");
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 4);
} else if (payloadCapability == MEDIA_PAYLOAD_V150_LC_MODEMRELAY) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_v150_LC_ModemRelay");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "modemRelay");
ptvcursor_add(cursor, hf_skinny_capAndVer, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_modAnd2833, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (payloadCapability == MEDIA_PAYLOAD_V150_LC_SPRT) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_v150_LC_SPRT");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sprtPayload");
ptvcursor_add(cursor, hf_skinny_chan0MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan2MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan3MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan2MaxWindow, 2, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (payloadCapability == MEDIA_PAYLOAD_V150_LC_SSE) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_v150_LC_SSE");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sse");
ptvcursor_add(cursor, hf_skinny_standard, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_vendor, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "any payloadCapability");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "codecParams");
ptvcursor_add(cursor, hf_skinny_codecMode, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dynamicPayload, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam1, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam2, 1, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 4);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (audioCapCount * 16));
}
if (videoCapCount <= 10) {
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "vidCaps [ref:videoCapCount = %d, max:10]", videoCapCount);
if (videoCapCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (videoCapCount * 4) && videoCapCount <= 10) {
for (counter_1 = 0; counter_1 < 10; counter_1++) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "vidCaps [%d / %d]", counter_1 + 1, videoCapCount);
payloadCapability = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_payloadCapability, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_videoCapabilityDirection, 4, ENC_LITTLE_ENDIAN);
levelPreferenceCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_levelPreferenceCount, 4, ENC_LITTLE_ENDIAN);
if (levelPreferenceCount <= 4) {
uint32_t counter_4 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "levelPreference [ref:levelPreferenceCount = %d, max:4]", levelPreferenceCount);
if (levelPreferenceCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (levelPreferenceCount * 24) && levelPreferenceCount <= 4) {
for (counter_4 = 0; counter_4 < 4; counter_4++) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "levelPreference [%d / %d]", counter_4 + 1, levelPreferenceCount);
ptvcursor_add(cursor, hf_skinny_transmitPreference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_format, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxBitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_minBitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_MPI, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_serviceNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (levelPreferenceCount * 24));
}
ptvcursor_add(cursor, hf_skinny_encryptionCapability, 4, ENC_LITTLE_ENDIAN);
if (payloadCapability == MEDIA_PAYLOAD_H261) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_H261");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h261VideoCapability");
ptvcursor_add(cursor, hf_skinny_temporalSpatialTradeOffCapability, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_stillImageTransmission, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 16);
} else if (payloadCapability == MEDIA_PAYLOAD_H263) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_H263");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h263VideoCapability");
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h263_capability_bitfield");
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit1, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit2, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit3, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit4, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit5, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit6, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit7, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit8, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit9, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit10, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit11, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit12, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit13, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit14, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit15, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit16, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit17, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit18, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit19, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit20, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit21, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit22, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit23, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit24, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit25, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit26, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit27, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit28, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit29, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit30, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit31, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit32, 4, ENC_LITTLE_ENDIAN);
ptvcursor_advance(cursor, 4);
ptvcursor_pop_subtree(cursor); /* end bitfield: h263_capability_bitfield */
ptvcursor_add(cursor, hf_skinny_annexNandWFutureUse, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 16);
} else if (payloadCapability == MEDIA_PAYLOAD_H264) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_H264");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h264VideoCapability");
ptvcursor_add(cursor, hf_skinny_profile, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_level, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_customMaxMBPS, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_customMaxFS, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_customMaxDPB, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_customMaxBRandCPB, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (payloadCapability == MEDIA_PAYLOAD_VIEO) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadCapability is Media_Payload_Vieo");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "vieoVideoCapability");
ptvcursor_add(cursor, hf_skinny_modelNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_bandwidth, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 16);
}
ptvcursor_add(cursor, hf_skinny_ipAddressingMode, 4, ENC_LITTLE_ENDIAN);
if (hdr_version >= V16_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_ipAddressingMode, 4, ENC_LITTLE_ENDIAN);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (videoCapCount * 4));
}
if (dataCapCount <= 5) {
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "dataCaps [ref:dataCapCount = %d, max:5]", dataCapCount);
if (dataCapCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (dataCapCount * 20) && dataCapCount <= 5) {
for (counter_1 = 0; counter_1 < 5; counter_1++) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "dataCaps [%d / %d]", counter_1 + 1, dataCapCount);
ptvcursor_add(cursor, hf_skinny_payloadCapability, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dataCapabilityDirection, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_protocolDependentData, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxBitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_encryptionCapability, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (dataCapCount * 20));
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x009b);
}
/*
* Message: PortResMessage
* Opcode: 0x0045
* Type: MediaControl
* Direction: dev2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_PortResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
uint32_t callReference = 0;
address ipAddr;
char *ipAddr_str = NULL;
uint32_t portNumber = 0;
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
callReference = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &ipAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_ipAddr_ipv4, hf_skinny_ipAddr_ipv6);
portNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_portNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &ipAddr, portNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
ipAddr_str = address_to_display(NULL, &ipAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", ipAddr_str, portNumber);
wmem_free(NULL, ipAddr_str);
ptvcursor_add(cursor, hf_skinny_RTCPPortNumber, 4, ENC_LITTLE_ENDIAN);
if (hdr_version >= V19_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_mediaType, 4, ENC_LITTLE_ENDIAN);
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x014b ^ callReference);
}
/*
* Message: QoSResvNotifyMessage
* Opcode: 0x0046
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_QoSResvNotifyMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
address remoteIpAddr;
char *remoteIpAddr_str = NULL;
uint32_t remotePortNumber = 0;
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &remoteIpAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_remoteIpAddr_ipv4, hf_skinny_remoteIpAddr_ipv6);
remotePortNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_remotePortNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &remoteIpAddr, remotePortNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
remoteIpAddr_str = address_to_display(NULL, &remoteIpAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", remoteIpAddr_str, remotePortNumber);
wmem_free(NULL, remoteIpAddr_str);
ptvcursor_add(cursor, hf_skinny_direction, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: QoSErrorNotifyMessage
* Opcode: 0x0047
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_QoSErrorNotifyMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
address remoteIpAddr;
char *remoteIpAddr_str = NULL;
uint32_t remotePortNumber = 0;
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &remoteIpAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_remoteIpAddr_ipv4, hf_skinny_remoteIpAddr_ipv6);
remotePortNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_remotePortNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &remoteIpAddr, remotePortNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
remoteIpAddr_str = address_to_display(NULL, &remoteIpAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", remoteIpAddr_str, remotePortNumber);
wmem_free(NULL, remoteIpAddr_str);
ptvcursor_add(cursor, hf_skinny_direction, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_errorCode, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_failureNodeIpAddr, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_rsvpErrorCode, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_rsvpErrorSubCodeVal, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_rsvpErrorFlag, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: SubscriptionStatReqMessage
* Opcode: 0x0048
* Type: CallControl
* Direction: dev2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_SubscriptionStatReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t transactionId = 0;
transactionId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_transactionId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_subscriptionFeatureID, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_timer, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_subscriptionID, 64, ENC_ASCII);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0048 ^ transactionId);
}
/*
* Message: MediaPathEventMessage
* Opcode: 0x0049
* Type: CallControl
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_MediaPathEventMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_mediaPathID, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_mediaPathEvent, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: MediaPathCapabilityMessage
* Opcode: 0x004a
* Type: CallControl
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_MediaPathCapabilityMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_mediaPathID, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_mediaPathCapabilities, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: MwiNotificationMessage
* Opcode: 0x004c
* Type: RegistrationAndManagement
* Direction: pbx2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_MwiNotificationMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_mwiTargetNumber, 25, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_mwiControlNumber, 25, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_areMessagesWaiting, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "totalVmCounts");
ptvcursor_add(cursor, hf_skinny_numNewMsgs, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numOldMsgs, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "priorityVmCounts");
ptvcursor_add(cursor, hf_skinny_numNewMsgs, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numOldMsgs, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "totalFaxCounts");
ptvcursor_add(cursor, hf_skinny_numNewMsgs, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numOldMsgs, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "priorityFaxCounts");
ptvcursor_add(cursor, hf_skinny_numNewMsgs, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numOldMsgs, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x004c);
}
/*
* Message: RegisterAckMessage
* Opcode: 0x0081
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_RegisterAckMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_keepAliveInterval, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dateTemplate, 6, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_alignmentPadding, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_secondaryKeepAliveInterval, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxProtocolVer, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_unknown, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "phoneFeatures");
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit1, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit2, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit3, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit4, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_UTF8, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit6, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit7, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_DynamicMessages, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit9, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_RFC2833, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit11, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit12, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit13, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit14, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Bit15, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_PhoneFeatures_Abbreviated_Dial, 2, ENC_LITTLE_ENDIAN);
ptvcursor_advance(cursor, 2);
ptvcursor_pop_subtree(cursor); /* end bitfield: phoneFeatures */
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0001);
}
/*
* Message: StartToneMessage
* Opcode: 0x0082
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_StartToneMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
si->additionalInfo = ws_strdup_printf("\"%s\"",
try_val_to_str_ext(
tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor)),
&DeviceTone_ext
)
);
ptvcursor_add(cursor, hf_skinny_tone, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_tone_output_direction, 4, ENC_LITTLE_ENDIAN);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: StopToneMessage
* Opcode: 0x0083
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_StopToneMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
if (hdr_version >= V11_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_tone, 4, ENC_LITTLE_ENDIAN);
}
}
/*
* Message: SetRingerMessage
* Opcode: 0x0085
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_SetRingerMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_ringMode, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_ringDuration, 4, ENC_LITTLE_ENDIAN);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: SetLampMessage
* Opcode: 0x0086
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_SetLampMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_stimulus, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_stimulusInstance, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_lampMode, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: SetSpeakerModeMessage
* Opcode: 0x0088
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_SetSpeakerModeMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_speakerMode, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: SetMicroModeMessage
* Opcode: 0x0089
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_SetMicroModeMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_micMode, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: StartMediaTransmissionMessage
* Opcode: 0x008a
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: request
*/
static void
handle_StartMediaTransmissionMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
uint32_t passThroughPartyId = 0;
address remoteIpAddr;
char *remoteIpAddr_str = NULL;
uint32_t remotePortNumber = 0;
guint32 compressionType = 0;
uint16_t keylen = 0;
uint16_t saltlen = 0;
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &remoteIpAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_remoteIpAddr_ipv4, hf_skinny_remoteIpAddr_ipv6);
remotePortNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_remotePortNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &remoteIpAddr, remotePortNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
remoteIpAddr_str = address_to_display(NULL, &remoteIpAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", remoteIpAddr_str, remotePortNumber);
wmem_free(NULL, remoteIpAddr_str);
ptvcursor_add(cursor, hf_skinny_milliSecondPacketSize, 4, ENC_LITTLE_ENDIAN);
compressionType = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_compressionType, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "qualifierOut");
ptvcursor_add(cursor, hf_skinny_precedenceValue, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_ssValue, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxFramesPerPacket, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_padding, 2, ENC_LITTLE_ENDIAN);
if (hdr_version <= V10_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
}
if (hdr_version >= V11_MSG_TYPE) {
if (compressionType == MEDIA_PAYLOAD_G7231) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "compressionType is Media_Payload_G7231");
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "any compressionType");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "codecParams");
ptvcursor_add(cursor, hf_skinny_codecMode, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dynamicPayload, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam1, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam2, 1, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
}
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "mTxMediaEncryptionKeyInfo");
ptvcursor_add(cursor, hf_skinny_algorithmID, 4, ENC_LITTLE_ENDIAN);
keylen = tvb_get_letohs(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_keylen, 2, ENC_LITTLE_ENDIAN);
saltlen = tvb_get_letohs(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_saltlen, 2, ENC_LITTLE_ENDIAN);
if (keylen <= 16) {
uint32_t counter_3 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "key [ref:keylen = %d, max:16]", keylen);
for (counter_3 = 0; counter_3 < 16; counter_3++) {
if (counter_3 < keylen) {
ptvcursor_add(cursor, hf_skinny_key, 1, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 1);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (16 * 1));
}
if (saltlen <= 16) {
uint32_t counter_3 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "salt [ref:saltlen = %d, max:16]", saltlen);
for (counter_3 = 0; counter_3 < 16; counter_3++) {
if (counter_3 < saltlen) {
ptvcursor_add(cursor, hf_skinny_salt, 1, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 1);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (16 * 1));
}
ptvcursor_add(cursor, hf_skinny_isMKIPresent, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_keyDerivationRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_add(cursor, hf_skinny_streamPassThroughId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_associatedStreamId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_RFC2833PayloadType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dtmfType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_mixingMode, 4, ENC_LITTLE_ENDIAN);
if (hdr_version >= V15_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_partyDirection, 4, ENC_LITTLE_ENDIAN);
}
if (hdr_version >= V21_MSG_TYPE) {
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "latentCapsInfo");
ptvcursor_add(cursor, hf_skinny_active, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "modemRelay");
ptvcursor_add(cursor, hf_skinny_capAndVer, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_modAnd2833, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sprtPayload");
ptvcursor_add(cursor, hf_skinny_chan0MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan2MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan3MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan2MaxWindow, 2, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sse");
ptvcursor_add(cursor, hf_skinny_standard, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_vendor, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadParam");
ptvcursor_add(cursor, hf_skinny_nse, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_rfc2833, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_sse, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_v150sprt, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_noaudio, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_FutureUse1, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_FutureUse2, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_FutureUse3, 1, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
}
}
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x008a ^ passThroughPartyId);
}
/*
* Message: StopMediaTransmissionMessage
* Opcode: 0x008b
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_StopMediaTransmissionMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_portHandlingFlag, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: CallInfoMessage
* Opcode: 0x008f
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_CallInfoMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_callingPartyName, 40, ENC_ASCII);
si->callingParty = g_strdup(tvb_format_stringzpad(pinfo->pool, ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), 24));
ptvcursor_add(cursor, hf_skinny_callingParty, 24, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_calledPartyName, 40, ENC_ASCII);
si->calledParty = g_strdup(tvb_format_stringzpad(pinfo->pool, ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), 24));
ptvcursor_add(cursor, hf_skinny_calledParty, 24, ENC_ASCII);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_callType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_originalCalledPartyName, 40, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_originalCalledParty, 24, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_lastRedirectingPartyName, 40, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_lastRedirectingParty, 24, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_originalCdpnRedirectReason, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_lastRedirectingReason, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_cgpnVoiceMailbox, 24, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_cdpnVoiceMailbox, 24, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_originalCdpnVoiceMailbox, 24, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_lastRedirectingVoiceMailbox, 24, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_callInstance, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_callSecurityStatus, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "partyPIRestrictionBits");
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CallingPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CallingPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CallingParty, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CalledPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CalledPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CalledParty, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_OriginalCalledPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_OriginalCalledPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_OriginalCalledParty, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_LastRedirectPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_LastRedirectPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_LastRedirectParty, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_BitsReserved, 4, ENC_LITTLE_ENDIAN);
ptvcursor_advance(cursor, 4);
ptvcursor_pop_subtree(cursor); /* end bitfield: partyPIRestrictionBits */
if (si->callingParty && si->calledParty) {
si->additionalInfo = ws_strdup_printf("\"%s -> %s\"", si->callingParty, si->calledParty);
}
}
/*
* Message: ForwardStatResMessage
* Opcode: 0x0090
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_ForwardStatResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t lineNumber = 0;
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
uint32_t VariableDirnumSize = (hdr_version >= V18_MSG_TYPE) ? 25 : 24;
ptvcursor_add(cursor, hf_skinny_activeForward, 4, ENC_LITTLE_ENDIAN);
lineNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_forwardAllActive, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_forwardAllDirnum, VariableDirnumSize, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_forwardBusyActive, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_forwardBusyDirnum, VariableDirnumSize, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_forwardNoAnswerActive, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_forwardNoAnswerlDirnum, VariableDirnumSize, ENC_ASCII);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0009 ^ lineNumber);
}
/*
* Message: SpeedDialStatResMessage
* Opcode: 0x0091
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_SpeedDialStatResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t speedDialNumber = 0;
speedDialNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_speedDialNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_speedDialDirNumber, 24, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_speedDialDisplayName, 40, ENC_ASCII);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x000a ^ speedDialNumber);
}
/*
* Message: LineStatResMessage
* Opcode: 0x0092
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_LineStatResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t lineNumber = 0;
lineNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_lineDirNumber, 24, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_lineFullyQualifiedDisplayName, 40, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_lineTextLabel, 40, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_lineDisplayOptions, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x000b ^ lineNumber);
}
/*
* Message: ConfigStatResMessage
* Opcode: 0x0093
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_ConfigStatResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sid");
ptvcursor_add(cursor, hf_skinny_DeviceName, 16, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_reserved_for_future_use, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_instance, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_add(cursor, hf_skinny_userName, 40, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_serverName, 40, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_numberOfLines, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numberOfSpeedDials, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x000c);
}
/*
* Message: TimeDateResMessage
* Opcode: 0x0094
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_TimeDateResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "timeDataInfo");
ptvcursor_add(cursor, hf_skinny_wYear, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_wMonth, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_wDayOfWeek, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_wDay, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_wHour, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_wMinute, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_wSecond, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_wMilliseconds, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_add(cursor, hf_skinny_systemTime, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x000d);
}
/*
* Message: StartSessionTransmissionMessage
* Opcode: 0x0095
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_StartSessionTransmissionMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
dissect_skinny_ipv4or6(cursor, hf_skinny_remoteIpAddr_ipv4, hf_skinny_remoteIpAddr_ipv6);
ptvcursor_add(cursor, hf_skinny_sessionType, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: StopSessionTransmissionMessage
* Opcode: 0x0096
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_StopSessionTransmissionMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
dissect_skinny_ipv4or6(cursor, hf_skinny_remoteIpAddr_ipv4, hf_skinny_remoteIpAddr_ipv6);
ptvcursor_add(cursor, hf_skinny_sessionType, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: ButtonTemplateResMessage
* Opcode: 0x0097
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_ButtonTemplateResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t totalButtonCount = 0;
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "buttonTemplate");
ptvcursor_add(cursor, hf_skinny_buttonOffset, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_buttonCount, 4, ENC_LITTLE_ENDIAN);
totalButtonCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_totalButtonCount, 4, ENC_LITTLE_ENDIAN);
if (totalButtonCount <= 42) {
uint32_t counter_2 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "definition [ref:totalButtonCount = %d, max:42]", totalButtonCount);
if (totalButtonCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (totalButtonCount * 2) && totalButtonCount <= 42) {
for (counter_2 = 0; counter_2 < 42; counter_2++) {
if (counter_2 < totalButtonCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "definition [%d / %d]", counter_2 + 1, totalButtonCount);
ptvcursor_add(cursor, hf_skinny_instanceNumber, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_buttonDefinition, 1, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 2);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (totalButtonCount * 2));
}
ptvcursor_pop_subtree(cursor);
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x000e);
}
/*
* Message: VersionResMessage
* Opcode: 0x0098
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_VersionResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_versionStr, 16, ENC_ASCII);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x000f);
}
/*
* Message: DisplayTextMessage
* Opcode: 0x0099
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_DisplayTextMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_text, 32, ENC_ASCII);
}
/*
* Message: RegisterRejectMessage
* Opcode: 0x009d
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_RegisterRejectMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_text, 32, ENC_ASCII);
}
/*
* Message: ServerResMessage
* Opcode: 0x009e
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_ServerResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_data_length = tvb_get_letohl(ptvcursor_tvbuff(cursor), 0);
{
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "server [max:5]");
for (counter_1 = 0; counter_1 < 5; counter_1++) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "server [%d / %d]", counter_1 + 1, 5);
ptvcursor_add(cursor, hf_skinny_ServerName, 48, ENC_ASCII);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
}
{
uint32_t counter_2 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "serverTcpListenPort [max:5]");
for (counter_2 = 0; counter_2 < 5; counter_2++) {
ptvcursor_add(cursor, hf_skinny_serverTcpListenPort, 4, ENC_LITTLE_ENDIAN);
}
ptvcursor_pop_subtree(cursor);
}
if (hdr_data_length < 293) {
{
uint32_t counter_2 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "serverIpAddr [max:5]");
for (counter_2 = 0; counter_2 < 5; counter_2++) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "serverIpAddr [%d / %d]", counter_2 + 1, 5);
ptvcursor_add(cursor, hf_skinny_stationIpAddr, 4, ENC_BIG_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
}
}
if (hdr_data_length > 292) {
{
uint32_t counter_2 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "serverIpAddr [max:5]");
for (counter_2 = 0; counter_2 < 5; counter_2++) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "serverIpAddr [%d / %d]", counter_2 + 1, 5);
dissect_skinny_ipv4or6(cursor, hf_skinny_stationIpAddr_ipv4, hf_skinny_stationIpAddr_ipv6);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
}
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0012);
}
/*
* Message: Reset
* Opcode: 0x009f
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_Reset(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_resetType, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: StartMulticastMediaReceptionMessage
* Opcode: 0x0101
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: request
*/
static void
handle_StartMulticastMediaReceptionMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t passThroughPartyId = 0;
address multicastIpAddr;
char *multicastIpAddr_str = NULL;
uint32_t multicastPortNumber = 0;
guint32 compressionType = 0;
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &multicastIpAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_multicastIpAddr_ipv4, hf_skinny_multicastIpAddr_ipv6);
multicastPortNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_multicastPortNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &multicastIpAddr, multicastPortNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
multicastIpAddr_str = address_to_display(NULL, &multicastIpAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", multicastIpAddr_str, multicastPortNumber);
wmem_free(NULL, multicastIpAddr_str);
ptvcursor_add(cursor, hf_skinny_milliSecondPacketSize, 4, ENC_LITTLE_ENDIAN);
compressionType = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_compressionType, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "qualifierIn");
ptvcursor_add(cursor, hf_skinny_ecValue, 4, ENC_LITTLE_ENDIAN);
if (hdr_version <= V10_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
}
if (hdr_version >= V11_MSG_TYPE) {
if (compressionType == MEDIA_PAYLOAD_G7231) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "compressionType is Media_Payload_G7231");
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "any compressionType");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "codecParams");
ptvcursor_add(cursor, hf_skinny_codecMode, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dynamicPayload, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam1, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam2, 1, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
}
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0101 ^ passThroughPartyId);
}
/*
* Message: StartMulticastMediaTransmissionMessage
* Opcode: 0x0102
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: request
*/
static void
handle_StartMulticastMediaTransmissionMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t passThroughPartyId = 0;
address multicastIpAddr;
char *multicastIpAddr_str = NULL;
uint32_t multicastPortNumber = 0;
guint32 compressionType = 0;
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &multicastIpAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_multicastIpAddr_ipv4, hf_skinny_multicastIpAddr_ipv6);
multicastPortNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_multicastPortNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &multicastIpAddr, multicastPortNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
multicastIpAddr_str = address_to_display(NULL, &multicastIpAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", multicastIpAddr_str, multicastPortNumber);
wmem_free(NULL, multicastIpAddr_str);
ptvcursor_add(cursor, hf_skinny_milliSecondPacketSize, 4, ENC_LITTLE_ENDIAN);
compressionType = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_compressionType, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "qualifierOut");
ptvcursor_add(cursor, hf_skinny_precedenceValue, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_ssValue, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxFramesPerPacket, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_padding, 2, ENC_LITTLE_ENDIAN);
if (hdr_version <= V10_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
}
if (hdr_version >= V11_MSG_TYPE) {
if (compressionType == MEDIA_PAYLOAD_G7231) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "compressionType is Media_Payload_G7231");
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "any compressionType");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "codecParams");
ptvcursor_add(cursor, hf_skinny_codecMode, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dynamicPayload, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam1, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam2, 1, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
}
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0102 ^ passThroughPartyId);
}
/*
* Message: StopMulticastMediaReceptionMessage
* Opcode: 0x0103
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_StopMulticastMediaReceptionMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: StopMulticastMediaTransmissionMessage
* Opcode: 0x0104
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_StopMulticastMediaTransmissionMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: OpenReceiveChannelMessage
* Opcode: 0x0105
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: request
*/
static void
handle_OpenReceiveChannelMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_data_length = tvb_get_letohl(ptvcursor_tvbuff(cursor), 0);
uint32_t passThroughPartyId = 0;
guint32 compressionType = 0;
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
uint16_t keylen = 0;
uint16_t saltlen = 0;
address sourceIpAddr;
char *sourceIpAddr_str = NULL;
uint32_t sourcePortNumber = 0;
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_milliSecondPacketSize, 4, ENC_LITTLE_ENDIAN);
compressionType = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_compressionType, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "qualifierIn");
ptvcursor_add(cursor, hf_skinny_ecValue, 4, ENC_LITTLE_ENDIAN);
if (hdr_version <= V10_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
}
if (hdr_version >= V11_MSG_TYPE) {
if (compressionType == MEDIA_PAYLOAD_G7231) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "compressionType is Media_Payload_G7231");
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "any compressionType");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "codecParams");
ptvcursor_add(cursor, hf_skinny_codecMode, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dynamicPayload, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam1, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam2, 1, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
}
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "mRxMediaEncryptionKeyInfo");
ptvcursor_add(cursor, hf_skinny_algorithmID, 4, ENC_LITTLE_ENDIAN);
keylen = tvb_get_letohs(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_keylen, 2, ENC_LITTLE_ENDIAN);
saltlen = tvb_get_letohs(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_saltlen, 2, ENC_LITTLE_ENDIAN);
if (keylen <= 16) {
uint32_t counter_3 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "key [ref:keylen = %d, max:16]", keylen);
for (counter_3 = 0; counter_3 < 16; counter_3++) {
if (counter_3 < keylen) {
ptvcursor_add(cursor, hf_skinny_key, 1, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 1);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (16 * 1));
}
if (saltlen <= 16) {
uint32_t counter_3 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "salt [ref:saltlen = %d, max:16]", saltlen);
for (counter_3 = 0; counter_3 < 16; counter_3++) {
if (counter_3 < saltlen) {
ptvcursor_add(cursor, hf_skinny_salt, 1, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 1);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (16 * 1));
}
ptvcursor_add(cursor, hf_skinny_isMKIPresent, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_keyDerivationRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_add(cursor, hf_skinny_streamPassThroughId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_associatedStreamId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_RFC2833PayloadType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dtmfType, 4, ENC_LITTLE_ENDIAN);
if (hdr_version >= V11_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_mixingMode, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_partyDirection, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &sourceIpAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_sourceIpAddr_ipv4, hf_skinny_sourceIpAddr_ipv6);
sourcePortNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_sourcePortNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &sourceIpAddr, sourcePortNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
sourceIpAddr_str = address_to_display(NULL, &sourceIpAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", sourceIpAddr_str, sourcePortNumber);
wmem_free(NULL, sourceIpAddr_str);
}
if (hdr_version >= V16_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_requestedIpAddrType, 4, ENC_LITTLE_ENDIAN);
}
if (hdr_version >= V17_MSG_TYPE) {
if (hdr_data_length > 132) {
ptvcursor_add(cursor, hf_skinny_audioLevelAdjustment, 4, ENC_LITTLE_ENDIAN);
}
}
if (hdr_version >= V21_MSG_TYPE) {
if (hdr_data_length > 132) {
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "latentCapsInfo");
ptvcursor_add(cursor, hf_skinny_active, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "modemRelay");
ptvcursor_add(cursor, hf_skinny_capAndVer, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_modAnd2833, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sprtPayload");
ptvcursor_add(cursor, hf_skinny_chan0MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan2MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan3MaxPayload, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_chan2MaxWindow, 2, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sse");
ptvcursor_add(cursor, hf_skinny_standard, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_vendor, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadParam");
ptvcursor_add(cursor, hf_skinny_nse, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_rfc2833, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_sse, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_v150sprt, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_noaudio, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_FutureUse1, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_FutureUse2, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_FutureUse3, 1, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
}
}
}
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0105 ^ passThroughPartyId);
}
/*
* Message: CloseReceiveChannelMessage
* Opcode: 0x0106
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_CloseReceiveChannelMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_portHandlingFlag, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: ConnectionStatisticsReqMessage
* Opcode: 0x0107
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: request
*/
static void
handle_ConnectionStatisticsReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
uint32_t callReference = 0;
if (hdr_version <= V17_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_directoryNum, 24, ENC_ASCII);
}
if (hdr_version >= V18_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_directoryNum, 28, ENC_ASCII);
}
callReference = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_statsProcessingMode, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0107 ^ callReference);
}
/*
* Message: SoftKeyTemplateResMessage
* Opcode: 0x0108
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_SoftKeyTemplateResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t totalSoftKeyCount = 0;
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "softKeyTemplate");
ptvcursor_add(cursor, hf_skinny_softKeyOffset, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_softKeyCount, 4, ENC_LITTLE_ENDIAN);
totalSoftKeyCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_totalSoftKeyCount, 4, ENC_LITTLE_ENDIAN);
if (totalSoftKeyCount <= 32) {
uint32_t counter_2 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "definition [ref:totalSoftKeyCount = %d, max:32]", totalSoftKeyCount);
if (totalSoftKeyCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (totalSoftKeyCount * 20) && totalSoftKeyCount <= 32) {
for (counter_2 = 0; counter_2 < 32; counter_2++) {
if (counter_2 < totalSoftKeyCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "definition [%d / %d]", counter_2 + 1, totalSoftKeyCount);
dissect_skinny_displayLabel(cursor, pinfo, hf_skinny_softKeyLabel, 16);
ptvcursor_add(cursor, hf_skinny_softKeyEvent, 4, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 20);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (totalSoftKeyCount * 20));
}
ptvcursor_pop_subtree(cursor);
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0028);
}
/*
* Message: SoftKeySetResMessage
* Opcode: 0x0109
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_SoftKeySetResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t totalSoftKeySetCount = 0;
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "softKeySets");
ptvcursor_add(cursor, hf_skinny_softKeySetOffset, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_softKeySetCount, 4, ENC_LITTLE_ENDIAN);
totalSoftKeySetCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_totalSoftKeySetCount, 4, ENC_LITTLE_ENDIAN);
if (totalSoftKeySetCount <= 16) {
uint32_t counter_2 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "definition [ref:totalSoftKeySetCount = %d, max:16]", totalSoftKeySetCount);
if (totalSoftKeySetCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (totalSoftKeySetCount * 3) && totalSoftKeySetCount <= 16) {
for (counter_2 = 0; counter_2 < 16; counter_2++) {
if (counter_2 < totalSoftKeySetCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "definition [%d / %d]", counter_2 + 1, totalSoftKeySetCount);
{
uint32_t counter_7 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "softKeyTemplateIndex [max:16]");
for (counter_7 = 0; counter_7 < 16; counter_7++) {
ptvcursor_add(cursor, hf_skinny_softKeyTemplateIndex, 1, ENC_LITTLE_ENDIAN);
}
ptvcursor_pop_subtree(cursor);
}
{
uint32_t counter_7 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "softKeyInfoIndex [max:16]");
for (counter_7 = 0; counter_7 < 16; counter_7++) {
ptvcursor_add(cursor, hf_skinny_softKeyInfoIndex, 2, ENC_LITTLE_ENDIAN);
}
ptvcursor_pop_subtree(cursor);
}
} else {
ptvcursor_advance(cursor, 3);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (totalSoftKeySetCount * 3));
}
ptvcursor_pop_subtree(cursor);
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0025);
}
/*
* Message: SelectSoftKeysMessage
* Opcode: 0x0110
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_SelectSoftKeysMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_softKeySetIndex, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "validKeyMask");
ptvcursor_add_no_advance(cursor, hf_skinny_SoftKeyMask_SoftKey1, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_SoftKeyMask_SoftKey2, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_SoftKeyMask_SoftKey3, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_SoftKeyMask_SoftKey4, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_SoftKeyMask_SoftKey5, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_SoftKeyMask_SoftKey6, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_SoftKeyMask_SoftKey7, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_SoftKeyMask_SoftKey8, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_SoftKeyMask_SoftKey9, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_SoftKeyMask_SoftKey10, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_SoftKeyMask_SoftKey11, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_SoftKeyMask_SoftKey12, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_SoftKeyMask_SoftKey13, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_SoftKeyMask_SoftKey14, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_SoftKeyMask_SoftKey15, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_SoftKeyMask_SoftKey16, 4, ENC_LITTLE_ENDIAN);
ptvcursor_advance(cursor, 4);
ptvcursor_pop_subtree(cursor); /* end bitfield: validKeyMask */
}
/*
* Message: CallStateMessage
* Opcode: 0x0111
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_CallStateMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
si->additionalInfo = ws_strdup_printf("\"%s\"",
try_val_to_str_ext(
tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor)),
&DCallState_ext
)
);
si->callState = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callState, 4, ENC_LITTLE_ENDIAN);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_privacy, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "precedence");
ptvcursor_add(cursor, hf_skinny_precedenceLevel, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_precedenceDomain, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
}
/*
* Message: DisplayPromptStatusMessage
* Opcode: 0x0112
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_DisplayPromptStatusMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_timeOutValue, 4, ENC_LITTLE_ENDIAN);
dissect_skinny_displayLabel(cursor, pinfo, hf_skinny_promptStatus, 32);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: ClearPromptStatusMessage
* Opcode: 0x0113
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_ClearPromptStatusMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: DisplayNotifyMessage
* Opcode: 0x0114
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_DisplayNotifyMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_timeOutValue, 4, ENC_LITTLE_ENDIAN);
dissect_skinny_displayLabel(cursor, pinfo, hf_skinny_notify, 32);
}
/*
* Message: ActivateCallPlaneMessage
* Opcode: 0x0116
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_ActivateCallPlaneMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: UnregisterAckMessage
* Opcode: 0x0118
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_UnregisterAckMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_status, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0027);
}
/*
* Message: BackSpaceResMessage
* Opcode: 0x0119
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_BackSpaceResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: RegisterTokenReject
* Opcode: 0x011b
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_RegisterTokenReject(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_waitTimeBeforeNextReq, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0029);
}
/*
* Message: StartMediaFailureDetectionMessage
* Opcode: 0x011c
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_StartMediaFailureDetectionMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
guint32 compressionType = 0;
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_milliSecondPacketSize, 4, ENC_LITTLE_ENDIAN);
compressionType = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_compressionType, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "qualifierIn");
ptvcursor_add(cursor, hf_skinny_ecValue, 4, ENC_LITTLE_ENDIAN);
if (hdr_version <= V10_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
}
if (hdr_version >= V11_MSG_TYPE) {
if (compressionType == MEDIA_PAYLOAD_G7231) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "compressionType is Media_Payload_G7231");
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "any compressionType");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "codecParams");
ptvcursor_add(cursor, hf_skinny_codecMode, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dynamicPayload, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam1, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam2, 1, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
}
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: DialedNumberMessage
* Opcode: 0x011d
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_DialedNumberMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
uint32_t VariableDirnumSize = (hdr_version >= V18_MSG_TYPE) ? 25 : 24;
if (hdr_version <= V17_MSG_TYPE) {
uint32_t dialedNumber_len;
dialedNumber_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), 24)+1;
if (dialedNumber_len > 1) {
si->additionalInfo = ws_strdup_printf("\"%s\"", tvb_format_stringzpad(pinfo->pool, ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), dialedNumber_len));
}
ptvcursor_add(cursor, hf_skinny_dialedNumber, 24, ENC_ASCII);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
if (hdr_version >= V18_MSG_TYPE) {
uint32_t dialedNumber_len;
dialedNumber_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), VariableDirnumSize)+1;
if (dialedNumber_len > 1) {
si->additionalInfo = ws_strdup_printf("\"%s\"", tvb_format_stringzpad(pinfo->pool, ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), dialedNumber_len));
}
ptvcursor_add(cursor, hf_skinny_dialedNumber, VariableDirnumSize, ENC_ASCII);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
}
/*
* Message: UserToDeviceDataMessage
* Opcode: 0x011e
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_UserToDeviceDataMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t dataLength = 0;
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "userToDeviceData");
ptvcursor_add(cursor, hf_skinny_applicationId, 4, ENC_LITTLE_ENDIAN);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_transactionId, 4, ENC_LITTLE_ENDIAN);
dataLength = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_dataLength, 4, ENC_LITTLE_ENDIAN);
dissect_skinny_xml(cursor, hf_skinny_xmldata, pinfo, dataLength, 2000);
ptvcursor_pop_subtree(cursor);
}
}
/*
* Message: FeatureStatResMessage
* Opcode: 0x011f
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_FeatureStatResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t featureIndex = 0;
featureIndex = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_featureIndex, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_featureID, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_featureTextLabel, 40, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_featureStatus, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0034 ^ featureIndex);
}
/*
* Message: DisplayPriNotifyMessage
* Opcode: 0x0120
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_DisplayPriNotifyMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_timeOutValue, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_priority, 4, ENC_LITTLE_ENDIAN);
dissect_skinny_displayLabel(cursor, pinfo, hf_skinny_notify, 32);
}
/*
* Message: ClearPriNotifyMessage
* Opcode: 0x0121
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_ClearPriNotifyMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_priority, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: StartAnnouncementMessage
* Opcode: 0x0122
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_StartAnnouncementMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
{
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "AnnList [max:32]");
for (counter_1 = 0; counter_1 < 32; counter_1++) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "AnnList [%d / %d]", counter_1 + 1, 32);
ptvcursor_add(cursor, hf_skinny_locale, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_country, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_toneAnnouncement, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
}
ptvcursor_add(cursor, hf_skinny_annAckReq, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
{
uint32_t counter_2 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "matrixConfPartyID [max:16]");
for (counter_2 = 0; counter_2 < 16; counter_2++) {
ptvcursor_add(cursor, hf_skinny_matrixConfPartyID, 4, ENC_LITTLE_ENDIAN);
}
ptvcursor_pop_subtree(cursor);
}
ptvcursor_add(cursor, hf_skinny_hearingConfPartyMask, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_annPlayMode, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: StopAnnouncementMessage
* Opcode: 0x0123
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_StopAnnouncementMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: AnnouncementFinishMessage
* Opcode: 0x0124
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_AnnouncementFinishMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_annStatus, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: NotifyDtmfToneMessage
* Opcode: 0x0127
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_NotifyDtmfToneMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_tone, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_passthruPartyID, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: SendDtmfToneMessage
* Opcode: 0x0128
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_SendDtmfToneMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_tone, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_passthruPartyID, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: SubscribeDtmfPayloadReqMessage
* Opcode: 0x0129
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: request
*/
static void
handle_SubscribeDtmfPayloadReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_payloadDtmf, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_passthruPartyID, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dtmfType, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0129);
}
/*
* Message: SubscribeDtmfPayloadResMessage
* Opcode: 0x012a
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_SubscribeDtmfPayloadResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t passthruPartyID = 0;
ptvcursor_add(cursor, hf_skinny_payloadDtmf, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
passthruPartyID = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passthruPartyID, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0129 ^ passthruPartyID);
}
/*
* Message: SubscribeDtmfPayloadErrMessage
* Opcode: 0x012b
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_SubscribeDtmfPayloadErrMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t passthruPartyID = 0;
ptvcursor_add(cursor, hf_skinny_payloadDtmf, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
passthruPartyID = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passthruPartyID, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0129 ^ passthruPartyID);
}
/*
* Message: UnSubscribeDtmfPayloadReqMessage
* Opcode: 0x012c
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: request
*/
static void
handle_UnSubscribeDtmfPayloadReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t passthruPartyID = 0;
ptvcursor_add(cursor, hf_skinny_payloadDtmf, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
passthruPartyID = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passthruPartyID, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dtmfType, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x012c ^ passthruPartyID);
}
/*
* Message: UnSubscribeDtmfPayloadResMessage
* Opcode: 0x012d
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_UnSubscribeDtmfPayloadResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t passthruPartyID = 0;
ptvcursor_add(cursor, hf_skinny_payloadDtmf, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
passthruPartyID = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passthruPartyID, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x012d ^ passthruPartyID);
}
/*
* Message: UnSubscribeDtmfPayloadErrMessage
* Opcode: 0x012e
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_UnSubscribeDtmfPayloadErrMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t passthruPartyID = 0;
ptvcursor_add(cursor, hf_skinny_payloadDtmf, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
passthruPartyID = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passthruPartyID, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x012d ^ passthruPartyID);
}
/*
* Message: ServiceURLStatResMessage
* Opcode: 0x012f
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_ServiceURLStatResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t serviceURLIndex = 0;
serviceURLIndex = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_serviceURLIndex, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_serviceURL, 256, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_serviceURLDisplayName, 40, ENC_ASCII);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0033 ^ serviceURLIndex);
}
/*
* Message: CallSelectStatResMessage
* Opcode: 0x0130
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_CallSelectStatResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_callSelectStat, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: OpenMultiMediaReceiveChannelMessage
* Opcode: 0x0131
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: request
*/
static void
handle_OpenMultiMediaReceiveChannelMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
uint32_t passThroughPartyId = 0;
guint32 compressionType = 0;
uint32_t payloadType = 0;
uint32_t pictureFormatCount = 0;
uint16_t keylen = 0;
uint16_t saltlen = 0;
address sourceIpAddr;
char *sourceIpAddr_str = NULL;
uint32_t sourcePortNumber = 0;
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
compressionType = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_compressionType, 4, ENC_LITTLE_ENDIAN);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadType");
ptvcursor_add(cursor, hf_skinny_payload_rfc_number, 4, ENC_LITTLE_ENDIAN);
payloadType = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_payloadType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_add(cursor, hf_skinny_isConferenceCreator, 4, ENC_LITTLE_ENDIAN);
if (payloadType <= MEDIA_PAYLOAD_AMR_WB) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadType <= Media_Payload_AMR_WB");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "audioParameters");
ptvcursor_add(cursor, hf_skinny_milliSecondPacketSize, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "qualifierIn");
ptvcursor_add(cursor, hf_skinny_ecValue, 4, ENC_LITTLE_ENDIAN);
if (hdr_version <= V10_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
}
if (hdr_version >= V11_MSG_TYPE) {
if (compressionType == MEDIA_PAYLOAD_G7231) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "compressionType is Media_Payload_G7231");
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "any compressionType");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "codecParams");
ptvcursor_add(cursor, hf_skinny_codecMode, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dynamicPayload, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam1, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam2, 1, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 36);
} else if (payloadType >= MEDIA_PAYLOAD_H261 && payloadType <= MEDIA_PAYLOAD_H264_FEC) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "Media_Payload_H261 <= payloadType <= Media_Payload_H264_FEC");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "vidParameters");
ptvcursor_add(cursor, hf_skinny_bitRate, 4, ENC_LITTLE_ENDIAN);
pictureFormatCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_pictureFormatCount, 4, ENC_LITTLE_ENDIAN);
if (pictureFormatCount <= 5) {
uint32_t counter_3 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "pictureFormat [ref:pictureFormatCount = %d, max:5]", pictureFormatCount);
if (pictureFormatCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (pictureFormatCount * 8) && pictureFormatCount <= 5) {
for (counter_3 = 0; counter_3 < 5; counter_3++) {
if (counter_3 < pictureFormatCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "pictureFormat [%d / %d]", counter_3 + 1, pictureFormatCount);
ptvcursor_add(cursor, hf_skinny_format, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_MPI, 4, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 8);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (pictureFormatCount * 8));
}
ptvcursor_add(cursor, hf_skinny_confServiceNum, 4, ENC_LITTLE_ENDIAN);
if (payloadType == MEDIA_PAYLOAD_H261) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadType is Media_Payload_H261");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h261VideoCapability");
ptvcursor_add(cursor, hf_skinny_temporalSpatialTradeOffCapability, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_stillImageTransmission, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 16);
} else if (payloadType == MEDIA_PAYLOAD_H263) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadType is Media_Payload_H263");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h263VideoCapability");
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h263_capability_bitfield");
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit1, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit2, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit3, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit4, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit5, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit6, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit7, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit8, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit9, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit10, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit11, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit12, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit13, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit14, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit15, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit16, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit17, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit18, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit19, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit20, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit21, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit22, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit23, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit24, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit25, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit26, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit27, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit28, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit29, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit30, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit31, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit32, 4, ENC_LITTLE_ENDIAN);
ptvcursor_advance(cursor, 4);
ptvcursor_pop_subtree(cursor); /* end bitfield: h263_capability_bitfield */
ptvcursor_add(cursor, hf_skinny_annexNandWFutureUse, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 16);
} else if (payloadType == MEDIA_PAYLOAD_H264) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadType is Media_Payload_H264");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h264VideoCapability");
ptvcursor_add(cursor, hf_skinny_profile, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_level, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_customMaxMBPS, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_customMaxFS, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_customMaxDPB, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_customMaxBRandCPB, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (payloadType == MEDIA_PAYLOAD_VIEO) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadType is Media_Payload_Vieo");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "vieoVideoCapability");
ptvcursor_add(cursor, hf_skinny_modelNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_bandwidth, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 16);
}
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (payloadType >= MEDIA_PAYLOAD_CLEAR_CHAN) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadType >= Media_Payload_Clear_Chan");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "dataParameters");
ptvcursor_add(cursor, hf_skinny_protocolDependentData, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxBitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 36);
}
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "mRxMediaEncryptionKeyInfo");
ptvcursor_add(cursor, hf_skinny_algorithmID, 4, ENC_LITTLE_ENDIAN);
keylen = tvb_get_letohs(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_keylen, 2, ENC_LITTLE_ENDIAN);
saltlen = tvb_get_letohs(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_saltlen, 2, ENC_LITTLE_ENDIAN);
if (keylen <= 16) {
uint32_t counter_3 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "key [ref:keylen = %d, max:16]", keylen);
for (counter_3 = 0; counter_3 < 16; counter_3++) {
if (counter_3 < keylen) {
ptvcursor_add(cursor, hf_skinny_key, 1, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 1);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (16 * 1));
}
if (saltlen <= 16) {
uint32_t counter_3 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "salt [ref:saltlen = %d, max:16]", saltlen);
for (counter_3 = 0; counter_3 < 16; counter_3++) {
if (counter_3 < saltlen) {
ptvcursor_add(cursor, hf_skinny_salt, 1, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 1);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (16 * 1));
}
ptvcursor_add(cursor, hf_skinny_isMKIPresent, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_keyDerivationRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_add(cursor, hf_skinny_streamPassThroughId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_associatedStreamId, 4, ENC_LITTLE_ENDIAN);
if (hdr_version >= V11_MSG_TYPE) {
read_skinny_ipv4or6(cursor, &sourceIpAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_sourceIpAddr_ipv4, hf_skinny_sourceIpAddr_ipv6);
sourcePortNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_sourcePortNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &sourceIpAddr, sourcePortNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
sourceIpAddr_str = address_to_display(NULL, &sourceIpAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", sourceIpAddr_str, sourcePortNumber);
wmem_free(NULL, sourceIpAddr_str);
}
if (hdr_version >= V16_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_requestedIpAddrType, 4, ENC_LITTLE_ENDIAN);
}
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0131 ^ passThroughPartyId);
}
/*
* Message: StartMultiMediaTransmissionMessage
* Opcode: 0x0132
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: request
*/
static void
handle_StartMultiMediaTransmissionMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t passthruPartyID = 0;
guint32 compressionType = 0;
uint32_t payloadType = 0;
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
uint32_t pictureFormatCount = 0;
uint16_t keylen = 0;
uint16_t saltlen = 0;
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
passthruPartyID = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passthruPartyID, 4, ENC_LITTLE_ENDIAN);
compressionType = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_compressionType, 4, ENC_LITTLE_ENDIAN);
dissect_skinny_ipv4or6(cursor, hf_skinny_remoteIpAddr_ipv4, hf_skinny_remoteIpAddr_ipv6);
ptvcursor_add(cursor, hf_skinny_remotePortNumber, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadType");
ptvcursor_add(cursor, hf_skinny_payload_rfc_number, 4, ENC_LITTLE_ENDIAN);
payloadType = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_payloadType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_add(cursor, hf_skinny_DSCPValue, 4, ENC_LITTLE_ENDIAN);
if (payloadType <= MEDIA_PAYLOAD_AMR_WB) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadType <= Media_Payload_AMR_WB");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "audioParameters");
ptvcursor_add(cursor, hf_skinny_milliSecondPacketSize, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "qualifierIn");
ptvcursor_add(cursor, hf_skinny_ecValue, 4, ENC_LITTLE_ENDIAN);
if (hdr_version <= V10_MSG_TYPE) {
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
}
if (hdr_version >= V11_MSG_TYPE) {
if (compressionType == MEDIA_PAYLOAD_G7231) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "compressionType is Media_Payload_G7231");
ptvcursor_add(cursor, hf_skinny_g723BitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "any compressionType");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "codecParams");
ptvcursor_add(cursor, hf_skinny_codecMode, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_dynamicPayload, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam1, 1, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_codecParam2, 1, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 36);
} else if (payloadType >= MEDIA_PAYLOAD_H261 && payloadType <= MEDIA_PAYLOAD_H264_FEC) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "Media_Payload_H261 <= payloadType <= Media_Payload_H264_FEC");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "vidParameters");
ptvcursor_add(cursor, hf_skinny_bitRate, 4, ENC_LITTLE_ENDIAN);
pictureFormatCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_pictureFormatCount, 4, ENC_LITTLE_ENDIAN);
if (pictureFormatCount <= 5) {
uint32_t counter_3 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "pictureFormat [ref:pictureFormatCount = %d, max:5]", pictureFormatCount);
if (pictureFormatCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (pictureFormatCount * 8) && pictureFormatCount <= 5) {
for (counter_3 = 0; counter_3 < 5; counter_3++) {
if (counter_3 < pictureFormatCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "pictureFormat [%d / %d]", counter_3 + 1, pictureFormatCount);
ptvcursor_add(cursor, hf_skinny_format, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_MPI, 4, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 8);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (pictureFormatCount * 8));
}
ptvcursor_add(cursor, hf_skinny_confServiceNum, 4, ENC_LITTLE_ENDIAN);
if (payloadType == MEDIA_PAYLOAD_H261) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadType is Media_Payload_H261");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h261VideoCapability");
ptvcursor_add(cursor, hf_skinny_temporalSpatialTradeOffCapability, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_stillImageTransmission, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 16);
} else if (payloadType == MEDIA_PAYLOAD_H263) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadType is Media_Payload_H263");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h263VideoCapability");
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h263_capability_bitfield");
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit1, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit2, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit3, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit4, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit5, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit6, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit7, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit8, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit9, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit10, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit11, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit12, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit13, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit14, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit15, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit16, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit17, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit18, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit19, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit20, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit21, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit22, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit23, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit24, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit25, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit26, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit27, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit28, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit29, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit30, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit31, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_Generic_Bitfield_Bit32, 4, ENC_LITTLE_ENDIAN);
ptvcursor_advance(cursor, 4);
ptvcursor_pop_subtree(cursor); /* end bitfield: h263_capability_bitfield */
ptvcursor_add(cursor, hf_skinny_annexNandWFutureUse, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 16);
} else if (payloadType == MEDIA_PAYLOAD_H264) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadType is Media_Payload_H264");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "h264VideoCapability");
ptvcursor_add(cursor, hf_skinny_profile, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_level, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_customMaxMBPS, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_customMaxFS, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_customMaxDPB, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_customMaxBRandCPB, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (payloadType == MEDIA_PAYLOAD_VIEO) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadType is Media_Payload_Vieo");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "vieoVideoCapability");
ptvcursor_add(cursor, hf_skinny_modelNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_bandwidth, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 16);
}
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (payloadType >= MEDIA_PAYLOAD_CLEAR_CHAN) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "payloadType >= Media_Payload_Clear_Chan");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "dataParameters");
ptvcursor_add(cursor, hf_skinny_protocolDependentData, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxBitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 36);
}
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "mTxMediaEncryptionKeyInfo");
ptvcursor_add(cursor, hf_skinny_algorithmID, 4, ENC_LITTLE_ENDIAN);
keylen = tvb_get_letohs(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_keylen, 2, ENC_LITTLE_ENDIAN);
saltlen = tvb_get_letohs(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_saltlen, 2, ENC_LITTLE_ENDIAN);
if (keylen <= 16) {
uint32_t counter_3 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "key [ref:keylen = %d, max:16]", keylen);
for (counter_3 = 0; counter_3 < 16; counter_3++) {
if (counter_3 < keylen) {
ptvcursor_add(cursor, hf_skinny_key, 1, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 1);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (16 * 1));
}
if (saltlen <= 16) {
uint32_t counter_3 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "salt [ref:saltlen = %d, max:16]", saltlen);
for (counter_3 = 0; counter_3 < 16; counter_3++) {
if (counter_3 < saltlen) {
ptvcursor_add(cursor, hf_skinny_salt, 1, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 1);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (16 * 1));
}
ptvcursor_add(cursor, hf_skinny_isMKIPresent, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_keyDerivationRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_add(cursor, hf_skinny_streamPassThroughId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_associatedStreamId, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0132 ^ passthruPartyID);
}
/*
* Message: StopMultiMediaTransmissionMessage
* Opcode: 0x0133
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_StopMultiMediaTransmissionMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_portHandlingFlag, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: MiscellaneousCommandMessage
* Opcode: 0x0134
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_MiscellaneousCommandMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
guint32 command = 0;
uint32_t recoveryReferencePictureCount = 0;
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_passthruPartyID, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
command = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_command, 4, ENC_LITTLE_ENDIAN);
if (command == MISCCOMMANDTYPE_VIDEOFASTUPDATEPICTURE) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "command is MiscCommandType_videoFastUpdatePicture");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "videoFastUpdatePicture");
ptvcursor_add(cursor, hf_skinny_firstGOB, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numberOfGOBs, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 8);
} else if (command == MISCCOMMANDTYPE_VIDEOFASTUPDATEGOB) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "command is MiscCommandType_videoFastUpdateGOB");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "videoFastUpdateGOB");
ptvcursor_add(cursor, hf_skinny_firstGOB, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numberOfGOBs, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 8);
} else if (command == MISCCOMMANDTYPE_VIDEOFASTUPDATEMB) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "command is MiscCommandType_videoFastUpdateMB");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "videoFastUpdateMB");
ptvcursor_add(cursor, hf_skinny_firstGOB, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_firstMB, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numberOfMBs, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 4);
} else if (command == MISCCOMMANDTYPE_LOSTPICTURE) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "command is MiscCommandType_lostPicture");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "lostPicture");
ptvcursor_add(cursor, hf_skinny_pictureNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_longTermPictureIndex, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 8);
} else if (command == MISCCOMMANDTYPE_LOSTPARTIALPICTURE) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "command is MiscCommandType_lostPartialPicture");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "lostPartialPicture");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "pictureReference");
ptvcursor_add(cursor, hf_skinny_pictureNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_longTermPictureIndex, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_add(cursor, hf_skinny_firstMB, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numberOfMBs, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
} else if (command == MISCCOMMANDTYPE_RECOVERYREFERENCEPICTURE) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "command is MiscCommandType_recoveryReferencePicture");
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "recoveryReferencePictureValue");
recoveryReferencePictureCount = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_recoveryReferencePictureCount, 4, ENC_LITTLE_ENDIAN);
if (recoveryReferencePictureCount <= 4) {
uint32_t counter_3 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "recoveryReferencePicture [ref:recoveryReferencePictureCount = %d, max:4]", recoveryReferencePictureCount);
if (recoveryReferencePictureCount && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (recoveryReferencePictureCount * 8) && recoveryReferencePictureCount <= 4) {
for (counter_3 = 0; counter_3 < 4; counter_3++) {
if (counter_3 < recoveryReferencePictureCount) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "recoveryReferencePicture [%d / %d]", counter_3 + 1, recoveryReferencePictureCount);
ptvcursor_add(cursor, hf_skinny_pictureNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_longTermPictureIndex, 4, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 8);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (recoveryReferencePictureCount * 8));
}
ptvcursor_pop_subtree(cursor);
}
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 4);
} else if (command == MISCCOMMANDTYPE_TEMPORALSPATIALTRADEOFF) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "command is MiscCommandType_temporalSpatialTradeOff");
ptvcursor_add(cursor, hf_skinny_temporalSpatialTradeOff, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 12);
} else {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "any command");
ptvcursor_add(cursor, hf_skinny_none, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
ptvcursor_advance(cursor, 12);
}
}
/*
* Message: FlowControlCommandMessage
* Opcode: 0x0135
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_FlowControlCommandMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_passthruPartyID, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maximumBitRate, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: CloseMultiMediaReceiveChannelMessage
* Opcode: 0x0136
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_CloseMultiMediaReceiveChannelMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_portHandlingFlag, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: CreateConferenceReqMessage
* Opcode: 0x0137
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_CreateConferenceReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t conferenceId = 0;
uint32_t dataLength = 0;
conferenceId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numberOfReservedParticipants, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_resourceType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_applicationId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_appConfID, 32, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_appData, 24, ENC_ASCII);
dataLength = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_dataLength, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_passThruData, dataLength, ENC_ASCII);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0137 ^ conferenceId);
}
/*
* Message: DeleteConferenceReqMessage
* Opcode: 0x0138
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_DeleteConferenceReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t conferenceId = 0;
conferenceId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0138 ^ conferenceId);
}
/*
* Message: ModifyConferenceReqMessage
* Opcode: 0x0139
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_ModifyConferenceReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t conferenceId = 0;
uint32_t dataLength = 0;
conferenceId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numberOfReservedParticipants, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_applicationId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_appConfID, 32, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_appData, 24, ENC_ASCII);
dataLength = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_dataLength, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_passThruData, dataLength, ENC_ASCII);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x0139 ^ conferenceId);
}
/*
* Message: AddParticipantReqMessage
* Opcode: 0x013a
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_AddParticipantReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t conferenceId = 0;
conferenceId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "partyPIRestrictionBits");
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CallingPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CallingPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CallingParty, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CalledPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CalledPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CalledParty, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_OriginalCalledPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_OriginalCalledPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_OriginalCalledParty, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_LastRedirectPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_LastRedirectPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_LastRedirectParty, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_BitsReserved, 4, ENC_LITTLE_ENDIAN);
ptvcursor_advance(cursor, 4);
ptvcursor_pop_subtree(cursor); /* end bitfield: partyPIRestrictionBits */
ptvcursor_add(cursor, hf_skinny_participantName, 40, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_participantNumber, 24, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_conferenceName, 32, ENC_ASCII);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x013a ^ conferenceId);
}
/*
* Message: DropParticipantReqMessage
* Opcode: 0x013b
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_DropParticipantReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t conferenceId = 0;
conferenceId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x013b ^ conferenceId);
}
/*
* Message: AuditParticipantReqMessage
* Opcode: 0x013d
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_AuditParticipantReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t conferenceId = 0;
conferenceId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x013d ^ conferenceId);
}
/*
* Message: ChangeParticipantReqMessage
* Opcode: 0x013e
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_ChangeParticipantReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t conferenceId = 0;
conferenceId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "partyPIRestrictionBits");
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CallingPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CallingPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CallingParty, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CalledPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CalledPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CalledParty, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_OriginalCalledPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_OriginalCalledPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_OriginalCalledParty, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_LastRedirectPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_LastRedirectPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_LastRedirectParty, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_BitsReserved, 4, ENC_LITTLE_ENDIAN);
ptvcursor_advance(cursor, 4);
ptvcursor_pop_subtree(cursor); /* end bitfield: partyPIRestrictionBits */
ptvcursor_add(cursor, hf_skinny_participantName, 40, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_participantNumber, 24, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_conferenceName, 32, ENC_ASCII);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x013e ^ conferenceId);
}
/*
* Message: UserToDeviceDataMessageVersion1
* Opcode: 0x013f
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_UserToDeviceDataMessageVersion1(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t dataLength = 0;
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "userToDeviceDataVersion1");
ptvcursor_add(cursor, hf_skinny_applicationId, 4, ENC_LITTLE_ENDIAN);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_transactionId, 4, ENC_LITTLE_ENDIAN);
dataLength = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_dataLength, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_sequenceFlag, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_displayPriority, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_appInstanceID, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_routingID, 4, ENC_LITTLE_ENDIAN);
dissect_skinny_xml(cursor, hf_skinny_xmldata, pinfo, dataLength, 2000);
ptvcursor_pop_subtree(cursor);
}
}
/*
* Message: VideoDisplayCommandMessage
* Opcode: 0x0140
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_VideoDisplayCommandMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_layoutID, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: FlowControlNotifyMessage
* Opcode: 0x0141
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_FlowControlNotifyMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_passthruPartyID, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maximumBitRate, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: ConfigStatV2ResMessage
* Opcode: 0x0142
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: yes
* MsgType: response
*/
static void
handle_ConfigStatV2ResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t DeviceName_len = 0;
uint32_t userName_len = 0;
uint32_t serverName_len = 0;
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sid");
DeviceName_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (DeviceName_len > 1) {
ptvcursor_add(cursor, hf_skinny_DeviceName, DeviceName_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
ptvcursor_add(cursor, hf_skinny_reserved_for_future_use, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_instance, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_add(cursor, hf_skinny_numberOfLines, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_numberOfSpeedDials, 4, ENC_LITTLE_ENDIAN);
userName_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (userName_len > 1) {
ptvcursor_add(cursor, hf_skinny_userName, userName_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
serverName_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (serverName_len > 1) {
ptvcursor_add(cursor, hf_skinny_serverName, serverName_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x000c);
}
/*
* Message: DisplayNotifyV2Message
* Opcode: 0x0143
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: yes
* MsgType: event
*/
static void
handle_DisplayNotifyV2Message(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_timeOutValue, 4, ENC_LITTLE_ENDIAN);
dissect_skinny_displayLabel(cursor, pinfo, hf_skinny_notify, 0);
}
/*
* Message: DisplayPriNotifyV2Message
* Opcode: 0x0144
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: yes
* MsgType: event
*/
static void
handle_DisplayPriNotifyV2Message(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_timeOutValue, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_priority, 4, ENC_LITTLE_ENDIAN);
dissect_skinny_displayLabel(cursor, pinfo, hf_skinny_notify, 0);
}
/*
* Message: DisplayPromptStatusV2Message
* Opcode: 0x0145
* Type: CallControl
* Direction: pbx2dev
* VarLength: yes
* MsgType: event
*/
static void
handle_DisplayPromptStatusV2Message(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_timeOutValue, 4, ENC_LITTLE_ENDIAN);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
dissect_skinny_displayLabel(cursor, pinfo, hf_skinny_promptStatus, 0);
}
/*
* Message: FeatureStatV2ResMessage
* Opcode: 0x0146
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: yes
* MsgType: response
*/
static void
handle_FeatureStatV2ResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t featureTextLabel_len = 0;
ptvcursor_add(cursor, hf_skinny_featureIndex, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_featureID, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_featureStatus, 4, ENC_LITTLE_ENDIAN);
featureTextLabel_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (featureTextLabel_len > 1) {
ptvcursor_add(cursor, hf_skinny_featureTextLabel, featureTextLabel_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0034);
}
/*
* Message: LineStatV2ResMessage
* Opcode: 0x0147
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: yes
* MsgType: response
*/
static void
handle_LineStatV2ResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t lineNumber = 0;
uint32_t lineDirNumber_len = 0;
uint32_t lineFullyQualifiedDisplayName_len = 0;
uint32_t lineTextLabel_len = 0;
lineNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "lineType");
ptvcursor_add_no_advance(cursor, hf_skinny_OrigDialed, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RedirDialed, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_CallingPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_CallingPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_advance(cursor, 4);
ptvcursor_pop_subtree(cursor); /* end bitfield: lineType */
lineDirNumber_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (lineDirNumber_len > 1) {
ptvcursor_add(cursor, hf_skinny_lineDirNumber, lineDirNumber_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
lineFullyQualifiedDisplayName_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (lineFullyQualifiedDisplayName_len > 1) {
ptvcursor_add(cursor, hf_skinny_lineFullyQualifiedDisplayName, lineFullyQualifiedDisplayName_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
lineTextLabel_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (lineTextLabel_len > 1) {
ptvcursor_add(cursor, hf_skinny_lineTextLabel, lineTextLabel_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x000b ^ lineNumber);
}
/*
* Message: ServiceURLStatV2ResMessage
* Opcode: 0x0148
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: yes
* MsgType: response
*/
static void
handle_ServiceURLStatV2ResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t serviceURLIndex = 0;
serviceURLIndex = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_serviceURLIndex, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0033 ^ serviceURLIndex);
}
/*
* Message: SpeedDialStatV2ResMessage
* Opcode: 0x0149
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: yes
* MsgType: response
*/
static void
handle_SpeedDialStatV2ResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t speedDialNumber = 0;
uint32_t speedDialDirNumber_len = 0;
uint32_t speedDialDisplayName_len = 0;
speedDialNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_speedDialNumber, 4, ENC_LITTLE_ENDIAN);
speedDialDirNumber_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (speedDialDirNumber_len > 1) {
ptvcursor_add(cursor, hf_skinny_speedDialDirNumber, speedDialDirNumber_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
speedDialDisplayName_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (speedDialDisplayName_len > 1) {
ptvcursor_add(cursor, hf_skinny_speedDialDisplayName, speedDialDisplayName_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x000a ^ speedDialNumber);
}
/*
* Message: CallInfoV2Message
* Opcode: 0x014a
* Type: CallControl
* Direction: pbx2dev
* VarLength: yes
* MsgType: event
*/
static void
handle_CallInfoV2Message(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t hdr_version = tvb_get_letohl(ptvcursor_tvbuff(cursor), 4);
uint32_t callingParty_len = 0;
uint32_t AlternateCallingParty_len = 0;
uint32_t calledParty_len = 0;
uint32_t originalCalledParty_len = 0;
uint32_t lastRedirectingParty_len = 0;
uint32_t cgpnVoiceMailbox_len = 0;
uint32_t cdpnVoiceMailbox_len = 0;
uint32_t originalCdpnVoiceMailbox_len = 0;
uint32_t lastRedirectingVoiceMailbox_len = 0;
uint32_t callingPartyName_len = 0;
uint32_t calledPartyName_len = 0;
uint32_t originalCalledPartyName_len = 0;
uint32_t lastRedirectingPartyName_len = 0;
uint32_t HuntPilotNumber_len = 0;
uint32_t HuntPilotName_len = 0;
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_callType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_originalCdpnRedirectReason, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_lastRedirectingReason, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_callInstance, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_callSecurityStatus, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "partyPIRestrictionBits");
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CallingPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CallingPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CallingParty, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CalledPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CalledPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_CalledParty, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_OriginalCalledPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_OriginalCalledPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_OriginalCalledParty, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_LastRedirectPartyName, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_LastRedirectPartyNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_LastRedirectParty, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add_no_advance(cursor, hf_skinny_RestrictInformationType_BitsReserved, 4, ENC_LITTLE_ENDIAN);
ptvcursor_advance(cursor, 4);
ptvcursor_pop_subtree(cursor); /* end bitfield: partyPIRestrictionBits */
callingParty_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (callingParty_len > 1) {
si->callingParty = g_strdup(tvb_format_stringzpad(pinfo->pool, ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), callingParty_len));
ptvcursor_add(cursor, hf_skinny_callingParty, callingParty_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
AlternateCallingParty_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (AlternateCallingParty_len > 1) {
ptvcursor_add(cursor, hf_skinny_AlternateCallingParty, AlternateCallingParty_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
calledParty_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (calledParty_len > 1) {
si->calledParty = g_strdup(tvb_format_stringzpad(pinfo->pool, ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), calledParty_len));
ptvcursor_add(cursor, hf_skinny_calledParty, calledParty_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
originalCalledParty_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (originalCalledParty_len > 1) {
ptvcursor_add(cursor, hf_skinny_originalCalledParty, originalCalledParty_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
lastRedirectingParty_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (lastRedirectingParty_len > 1) {
ptvcursor_add(cursor, hf_skinny_lastRedirectingParty, lastRedirectingParty_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
cgpnVoiceMailbox_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (cgpnVoiceMailbox_len > 1) {
ptvcursor_add(cursor, hf_skinny_cgpnVoiceMailbox, cgpnVoiceMailbox_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
cdpnVoiceMailbox_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (cdpnVoiceMailbox_len > 1) {
ptvcursor_add(cursor, hf_skinny_cdpnVoiceMailbox, cdpnVoiceMailbox_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
originalCdpnVoiceMailbox_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (originalCdpnVoiceMailbox_len > 1) {
ptvcursor_add(cursor, hf_skinny_originalCdpnVoiceMailbox, originalCdpnVoiceMailbox_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
lastRedirectingVoiceMailbox_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (lastRedirectingVoiceMailbox_len > 1) {
ptvcursor_add(cursor, hf_skinny_lastRedirectingVoiceMailbox, lastRedirectingVoiceMailbox_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
callingPartyName_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (callingPartyName_len > 1) {
ptvcursor_add(cursor, hf_skinny_callingPartyName, callingPartyName_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
calledPartyName_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (calledPartyName_len > 1) {
ptvcursor_add(cursor, hf_skinny_calledPartyName, calledPartyName_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
originalCalledPartyName_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (originalCalledPartyName_len > 1) {
ptvcursor_add(cursor, hf_skinny_originalCalledPartyName, originalCalledPartyName_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
lastRedirectingPartyName_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (lastRedirectingPartyName_len > 1) {
ptvcursor_add(cursor, hf_skinny_lastRedirectingPartyName, lastRedirectingPartyName_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
if (hdr_version >= V17_MSG_TYPE) {
HuntPilotNumber_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (HuntPilotNumber_len > 1) {
ptvcursor_add(cursor, hf_skinny_HuntPilotNumber, HuntPilotNumber_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
HuntPilotName_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (HuntPilotName_len > 1) {
ptvcursor_add(cursor, hf_skinny_HuntPilotName, HuntPilotName_len, ENC_ASCII);
} else {
ptvcursor_advance(cursor, 1);
}
}
if (si->callingParty && si->calledParty) {
si->additionalInfo = ws_strdup_printf("\"%s -> %s\"", si->callingParty, si->calledParty);
}
}
/*
* Message: PortReqMessage
* Opcode: 0x014b
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: request
*/
static void
handle_PortReqMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_mediaTransportType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_ipAddressType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_mediaType, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x014b);
}
/*
* Message: PortCloseMessage
* Opcode: 0x014c
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_PortCloseMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_mediaType, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: QoSListenMessage
* Opcode: 0x014d
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_QoSListenMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
address remoteIpAddr;
char *remoteIpAddr_str = NULL;
uint32_t remotePortNumber = 0;
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &remoteIpAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_remoteIpAddr_ipv4, hf_skinny_remoteIpAddr_ipv6);
remotePortNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_remotePortNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &remoteIpAddr, remotePortNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
remoteIpAddr_str = address_to_display(NULL, &remoteIpAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", remoteIpAddr_str, remotePortNumber);
wmem_free(NULL, remoteIpAddr_str);
ptvcursor_add(cursor, hf_skinny_resvStyle, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxRetryNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_retryTimer, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_confirmRequired, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_preemptionPriority, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_defendingPriority, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_compressionType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_averageBitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_burstSize, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_peakRate, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "applicationID");
ptvcursor_add(cursor, hf_skinny_vendorID, 32, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_version, 16, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_appName, 32, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_subAppID, 32, ENC_ASCII);
ptvcursor_pop_subtree(cursor);
}
}
/*
* Message: QoSPathMessage
* Opcode: 0x014e
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_QoSPathMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
address remoteIpAddr;
char *remoteIpAddr_str = NULL;
uint32_t remotePortNumber = 0;
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &remoteIpAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_remoteIpAddr_ipv4, hf_skinny_remoteIpAddr_ipv6);
remotePortNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_remotePortNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &remoteIpAddr, remotePortNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
remoteIpAddr_str = address_to_display(NULL, &remoteIpAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", remoteIpAddr_str, remotePortNumber);
wmem_free(NULL, remoteIpAddr_str);
ptvcursor_add(cursor, hf_skinny_resvStyle, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxRetryNumber, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_retryTimer, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_preemptionPriority, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_defendingPriority, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_compressionType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_averageBitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_burstSize, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_peakRate, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "applicationID");
ptvcursor_add(cursor, hf_skinny_vendorID, 32, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_version, 16, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_appName, 32, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_subAppID, 32, ENC_ASCII);
ptvcursor_pop_subtree(cursor);
}
}
/*
* Message: QoSTeardownMessage
* Opcode: 0x014f
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_QoSTeardownMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
address remoteIpAddr;
char *remoteIpAddr_str = NULL;
uint32_t remotePortNumber = 0;
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &remoteIpAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_remoteIpAddr_ipv4, hf_skinny_remoteIpAddr_ipv6);
remotePortNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_remotePortNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &remoteIpAddr, remotePortNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
remoteIpAddr_str = address_to_display(NULL, &remoteIpAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", remoteIpAddr_str, remotePortNumber);
wmem_free(NULL, remoteIpAddr_str);
ptvcursor_add(cursor, hf_skinny_direction, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: UpdateDSCPMessage
* Opcode: 0x0150
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_UpdateDSCPMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
address remoteIpAddr;
char *remoteIpAddr_str = NULL;
uint32_t remotePortNumber = 0;
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &remoteIpAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_remoteIpAddr_ipv4, hf_skinny_remoteIpAddr_ipv6);
remotePortNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_remotePortNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &remoteIpAddr, remotePortNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
remoteIpAddr_str = address_to_display(NULL, &remoteIpAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", remoteIpAddr_str, remotePortNumber);
wmem_free(NULL, remoteIpAddr_str);
ptvcursor_add(cursor, hf_skinny_DSCPValue, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: QoSModifyMessage
* Opcode: 0x0151
* Type: IntraCCM
* Direction: pbx2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_QoSModifyMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
address remoteIpAddr;
char *remoteIpAddr_str = NULL;
uint32_t remotePortNumber = 0;
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &remoteIpAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_remoteIpAddr_ipv4, hf_skinny_remoteIpAddr_ipv6);
remotePortNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_remotePortNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &remoteIpAddr, remotePortNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
remoteIpAddr_str = address_to_display(NULL, &remoteIpAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", remoteIpAddr_str, remotePortNumber);
wmem_free(NULL, remoteIpAddr_str);
ptvcursor_add(cursor, hf_skinny_direction, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_compressionType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_averageBitRate, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_burstSize, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_peakRate, 4, ENC_LITTLE_ENDIAN);
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "applicationID");
ptvcursor_add(cursor, hf_skinny_vendorID, 32, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_version, 16, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_appName, 32, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_subAppID, 32, ENC_ASCII);
ptvcursor_pop_subtree(cursor);
}
}
/*
* Message: SubscriptionStatResMessage
* Opcode: 0x0152
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_SubscriptionStatResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t transactionId = 0;
transactionId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_transactionId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_subscriptionFeatureID, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_timer, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_cause, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0048 ^ transactionId);
}
/*
* Message: NotificationMessage
* Opcode: 0x0153
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_NotificationMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_transactionId, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_subscriptionFeatureID, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_notificationStatus, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_text, 97, ENC_ASCII);
}
/*
* Message: StartMediaTransmissionAckMessage
* Opcode: 0x0154
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_StartMediaTransmissionAckMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t passThroughPartyId = 0;
address transmitIpAddr;
char *transmitIpAddr_str = NULL;
uint32_t portNumber = 0;
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &transmitIpAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_transmitIpAddr_ipv4, hf_skinny_transmitIpAddr_ipv6);
portNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_portNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &transmitIpAddr, portNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
transmitIpAddr_str = address_to_display(NULL, &transmitIpAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", transmitIpAddr_str, portNumber);
wmem_free(NULL, transmitIpAddr_str);
si->mediaTransmissionStatus = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_mediaTransmissionStatus, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x008a ^ passThroughPartyId);
}
/*
* Message: StartMultiMediaTransmissionAckMessage
* Opcode: 0x0155
* Type: MediaControl
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_StartMultiMediaTransmissionAckMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t passThroughPartyId = 0;
address transmitIpAddr;
char *transmitIpAddr_str = NULL;
uint32_t portNumber = 0;
ptvcursor_add(cursor, hf_skinny_conferenceId, 4, ENC_LITTLE_ENDIAN);
passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
si->passThroughPartyId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_passThroughPartyId, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
read_skinny_ipv4or6(cursor, &transmitIpAddr);
dissect_skinny_ipv4or6(cursor, hf_skinny_transmitIpAddr_ipv4, hf_skinny_transmitIpAddr_ipv6);
portNumber = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_portNumber, 4, ENC_LITTLE_ENDIAN);
srtp_add_address(pinfo, PT_UDP, &transmitIpAddr, portNumber, 0, "SKINNY", pinfo->num, false, NULL, NULL, NULL);
transmitIpAddr_str = address_to_display(NULL, &transmitIpAddr);
si->additionalInfo = ws_strdup_printf("%s:%d", transmitIpAddr_str, portNumber);
wmem_free(NULL, transmitIpAddr_str);
si->multimediaTransmissionStatus = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_multimediaTransmissionStatus, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x0132 ^ passThroughPartyId);
}
/*
* Message: CallHistoryInfoMessage
* Opcode: 0x0156
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_CallHistoryInfoMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_callHistoryDisposition, 4, ENC_LITTLE_ENDIAN);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: LocationInfoMessage
* Opcode: 0x0157
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: event
* Comment: Sent by wifi devices, contains xml information about connected SSID
*/
static void
handle_LocationInfoMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_locationInfo, 2401, ENC_ASCII);
}
/*
* Message: MwiResMessage
* Opcode: 0x0158
* Type: RegistrationAndManagement
* Direction: pbx2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_MwiResMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_mwiTargetNumber, 25, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_mwi_notification_result, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x004c);
}
/*
* Message: AddOnDeviceCapabilitiesMessage
* Opcode: 0x0159
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: event
*/
static void
handle_AddOnDeviceCapabilitiesMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_unknown1_0159, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_unknown2_0159, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_unknown3_0159, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_unknownString_0159, 152, ENC_ASCII);
}
/*
* Message: EnhancedAlarmMessage
* Opcode: 0x015a
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_EnhancedAlarmMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
dissect_skinny_xml(cursor, hf_skinny_alarmInfo, pinfo, 0, 2048);
}
/*
* Message: CallCountRespMessage
* Opcode: 0x015f
* Type: CallControl
* Direction: pbx2pbx
* VarLength: no
* MsgType: response
*/
static void
handle_CallCountRespMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
uint32_t lineDataEntries = 0;
ptvcursor_add(cursor, hf_skinny_totalNumOfConfiguredLines, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_startingLineInstance, 4, ENC_LITTLE_ENDIAN);
lineDataEntries = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineDataEntries, 4, ENC_LITTLE_ENDIAN);
if (lineDataEntries <= 42) {
uint32_t counter_1 = 0;
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "lineData [ref:lineDataEntries = %d, max:42]", lineDataEntries);
if (lineDataEntries && tvb_get_letohl(ptvcursor_tvbuff(cursor), 0) + 8 >= ptvcursor_current_offset(cursor) + (lineDataEntries * 4) && lineDataEntries <= 42) {
for (counter_1 = 0; counter_1 < 42; counter_1++) {
if (counter_1 < lineDataEntries) {
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "lineData [%d / %d]", counter_1 + 1, lineDataEntries);
ptvcursor_add(cursor, hf_skinny_maxNumCalls, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_busyTrigger, 2, ENC_LITTLE_ENDIAN);
} else {
ptvcursor_advance(cursor, 4);
}
ptvcursor_pop_subtree(cursor);
}
}
ptvcursor_pop_subtree(cursor);
} else {
ptvcursor_advance(cursor, (lineDataEntries * 4));
}
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x015e);
}
/*
* Message: RecordingStatusMessage
* Opcode: 0x0160
* Type: CallControl
* Direction: pbx2dev
* VarLength: no
* MsgType: event
*/
static void
handle_RecordingStatusMessage(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_recording_status, 4, ENC_LITTLE_ENDIAN);
}
/*
* Message: SPCPRegisterTokenReq
* Opcode: 0x8000
* Type: RegistrationAndManagement
* Direction: dev2pbx
* VarLength: no
* MsgType: request
*/
static void
handle_SPCPRegisterTokenReq(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
{
ptvcursor_add_text_with_subtree(cursor, SUBTREE_UNDEFINED_LENGTH, ett_skinny_tree, "sid");
ptvcursor_add(cursor, hf_skinny_DeviceName, 16, ENC_ASCII);
ptvcursor_add(cursor, hf_skinny_reserved_for_future_use, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_instance, 4, ENC_LITTLE_ENDIAN);
ptvcursor_pop_subtree(cursor);
}
ptvcursor_add(cursor, hf_skinny_stationIpAddr, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_deviceType, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxStreams, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_request(cursor, pinfo, skinny_conv, 0x8000);
}
/*
* Message: SPCPRegisterTokenAck
* Opcode: 0x8100
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_SPCPRegisterTokenAck(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_features, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x8000);
}
/*
* Message: SPCPRegisterTokenReject
* Opcode: 0x8101
* Type: RegistrationAndManagement
* Direction: pbx2dev
* VarLength: no
* MsgType: response
*/
static void
handle_SPCPRegisterTokenReject(ptvcursor_t *cursor, packet_info * pinfo _U_, skinny_conv_info_t * skinny_conv _U_)
{
ptvcursor_add(cursor, hf_skinny_waitTimeBeforeNextReq, 4, ENC_LITTLE_ENDIAN);
skinny_reqrep_add_response(cursor, pinfo, skinny_conv, 0x8000);
}
typedef void (*message_handler) (ptvcursor_t * cursor, packet_info *pinfo, skinny_conv_info_t * skinny_conv);
typedef struct _skinny_opcode_map_t {
uint32_t opcode;
message_handler handler;
skinny_message_type_t type;
const char *name;
} skinny_opcode_map_t;
/* Messages Handler Array */
static const skinny_opcode_map_t skinny_opcode_map[] = {
{0x0000, NULL , SKINNY_MSGTYPE_REQUEST , "KeepAliveReqMessage"},
{0x0001, handle_RegisterReqMessage , SKINNY_MSGTYPE_REQUEST , "RegisterReqMessage"},
{0x0002, handle_IpPortMessage , SKINNY_MSGTYPE_EVENT , "IpPortMessage"},
{0x0003, handle_KeypadButtonMessage , SKINNY_MSGTYPE_EVENT , "KeypadButtonMessage"},
{0x0004, handle_EnblocCallMessage , SKINNY_MSGTYPE_EVENT , "EnblocCallMessage"},
{0x0005, handle_StimulusMessage , SKINNY_MSGTYPE_EVENT , "StimulusMessage"},
{0x0006, handle_OffHookMessage , SKINNY_MSGTYPE_EVENT , "OffHookMessage"},
{0x0007, handle_OnHookMessage , SKINNY_MSGTYPE_EVENT , "OnHookMessage"},
{0x0008, handle_HookFlashMessage , SKINNY_MSGTYPE_EVENT , "HookFlashMessage"},
{0x0009, handle_ForwardStatReqMessage , SKINNY_MSGTYPE_REQUEST , "ForwardStatReqMessage"},
{0x000a, handle_SpeedDialStatReqMessage , SKINNY_MSGTYPE_REQUEST , "SpeedDialStatReqMessage"},
{0x000b, handle_LineStatReqMessage , SKINNY_MSGTYPE_REQUEST , "LineStatReqMessage"},
{0x000c, NULL , SKINNY_MSGTYPE_REQUEST , "ConfigStatReqMessage"},
{0x000d, NULL , SKINNY_MSGTYPE_REQUEST , "TimeDateReqMessage"},
{0x000e, NULL , SKINNY_MSGTYPE_REQUEST , "ButtonTemplateReqMessage"},
{0x000f, NULL , SKINNY_MSGTYPE_REQUEST , "VersionReqMessage"},
{0x0010, handle_CapabilitiesResMessage , SKINNY_MSGTYPE_RESPONSE , "CapabilitiesResMessage"},
{0x0012, NULL , SKINNY_MSGTYPE_REQUEST , "ServerReqMessage"},
{0x0020, handle_AlarmMessage , SKINNY_MSGTYPE_EVENT , "AlarmMessage"},
{0x0021, handle_MulticastMediaReceptionAckMessage , SKINNY_MSGTYPE_RESPONSE , "MulticastMediaReceptionAckMessage"},
{0x0022, handle_OpenReceiveChannelAckMessage , SKINNY_MSGTYPE_RESPONSE , "OpenReceiveChannelAckMessage"},
{0x0023, handle_ConnectionStatisticsResMessage , SKINNY_MSGTYPE_RESPONSE , "ConnectionStatisticsResMessage"},
{0x0024, handle_OffHookWithCallingPartyNumberMessage , SKINNY_MSGTYPE_EVENT , "OffHookWithCallingPartyNumberMessage"},
{0x0025, NULL , SKINNY_MSGTYPE_REQUEST , "SoftKeySetReqMessage"},
{0x0026, handle_SoftKeyEventMessage , SKINNY_MSGTYPE_EVENT , "SoftKeyEventMessage"},
{0x0027, handle_UnregisterReqMessage , SKINNY_MSGTYPE_REQUEST , "UnregisterReqMessage"},
{0x0028, NULL , SKINNY_MSGTYPE_REQUEST , "SoftKeyTemplateReqMessage"},
{0x0029, handle_RegisterTokenReq , SKINNY_MSGTYPE_REQUEST , "RegisterTokenReq"},
{0x002a, handle_MediaTransmissionFailureMessage , SKINNY_MSGTYPE_RESPONSE , "MediaTransmissionFailureMessage"},
{0x002b, handle_HeadsetStatusMessage , SKINNY_MSGTYPE_EVENT , "HeadsetStatusMessage"},
{0x002c, handle_MediaResourceNotificationMessage , SKINNY_MSGTYPE_EVENT , "MediaResourceNotificationMessage"},
{0x002d, handle_RegisterAvailableLinesMessage , SKINNY_MSGTYPE_EVENT , "RegisterAvailableLinesMessage"},
{0x002e, handle_DeviceToUserDataMessage , SKINNY_MSGTYPE_REQUEST , "DeviceToUserDataMessage"},
{0x002f, handle_DeviceToUserDataResponseMessage , SKINNY_MSGTYPE_RESPONSE , "DeviceToUserDataResponseMessage"},
{0x0030, handle_UpdateCapabilitiesMessage , SKINNY_MSGTYPE_EVENT , "UpdateCapabilitiesMessage"},
{0x0031, handle_OpenMultiMediaReceiveChannelAckMessage , SKINNY_MSGTYPE_RESPONSE , "OpenMultiMediaReceiveChannelAckMessage"},
{0x0032, handle_ClearConferenceMessage , SKINNY_MSGTYPE_EVENT , "ClearConferenceMessage"},
{0x0033, handle_ServiceURLStatReqMessage , SKINNY_MSGTYPE_REQUEST , "ServiceURLStatReqMessage"},
{0x0034, handle_FeatureStatReqMessage , SKINNY_MSGTYPE_REQUEST , "FeatureStatReqMessage"},
{0x0035, handle_CreateConferenceResMessage , SKINNY_MSGTYPE_RESPONSE , "CreateConferenceResMessage"},
{0x0036, handle_DeleteConferenceResMessage , SKINNY_MSGTYPE_RESPONSE , "DeleteConferenceResMessage"},
{0x0037, handle_ModifyConferenceResMessage , SKINNY_MSGTYPE_RESPONSE , "ModifyConferenceResMessage"},
{0x0038, handle_AddParticipantResMessage , SKINNY_MSGTYPE_RESPONSE , "AddParticipantResMessage"},
{0x0039, handle_AuditConferenceResMessage , SKINNY_MSGTYPE_RESPONSE , "AuditConferenceResMessage"},
{0x0040, handle_AuditParticipantResMessage , SKINNY_MSGTYPE_RESPONSE , "AuditParticipantResMessage"},
{0x0041, handle_DeviceToUserDataMessageVersion1 , SKINNY_MSGTYPE_REQUEST , "DeviceToUserDataMessageVersion1"},
{0x0042, handle_DeviceToUserDataResponseMessageVersion1 , SKINNY_MSGTYPE_RESPONSE , "DeviceToUserDataResponseMessageVersion1"},
{0x0043, handle_CapabilitiesV2ResMessage , SKINNY_MSGTYPE_RESPONSE , "CapabilitiesV2ResMessage"},
{0x0044, handle_CapabilitiesV3ResMessage , SKINNY_MSGTYPE_RESPONSE , "CapabilitiesV3ResMessage"},
{0x0045, handle_PortResMessage , SKINNY_MSGTYPE_RESPONSE , "PortResMessage"},
{0x0046, handle_QoSResvNotifyMessage , SKINNY_MSGTYPE_EVENT , "QoSResvNotifyMessage"},
{0x0047, handle_QoSErrorNotifyMessage , SKINNY_MSGTYPE_EVENT , "QoSErrorNotifyMessage"},
{0x0048, handle_SubscriptionStatReqMessage , SKINNY_MSGTYPE_REQUEST , "SubscriptionStatReqMessage"},
{0x0049, handle_MediaPathEventMessage , SKINNY_MSGTYPE_EVENT , "MediaPathEventMessage"},
{0x004a, handle_MediaPathCapabilityMessage , SKINNY_MSGTYPE_EVENT , "MediaPathCapabilityMessage"},
{0x004c, handle_MwiNotificationMessage , SKINNY_MSGTYPE_REQUEST , "MwiNotificationMessage"},
{0x0081, handle_RegisterAckMessage , SKINNY_MSGTYPE_RESPONSE , "RegisterAckMessage"},
{0x0082, handle_StartToneMessage , SKINNY_MSGTYPE_EVENT , "StartToneMessage"},
{0x0083, handle_StopToneMessage , SKINNY_MSGTYPE_EVENT , "StopToneMessage"},
{0x0085, handle_SetRingerMessage , SKINNY_MSGTYPE_EVENT , "SetRingerMessage"},
{0x0086, handle_SetLampMessage , SKINNY_MSGTYPE_EVENT , "SetLampMessage"},
{0x0087, NULL , SKINNY_MSGTYPE_EVENT , "SetHookFlashDetectMessage"},
{0x0088, handle_SetSpeakerModeMessage , SKINNY_MSGTYPE_EVENT , "SetSpeakerModeMessage"},
{0x0089, handle_SetMicroModeMessage , SKINNY_MSGTYPE_EVENT , "SetMicroModeMessage"},
{0x008a, handle_StartMediaTransmissionMessage , SKINNY_MSGTYPE_REQUEST , "StartMediaTransmissionMessage"},
{0x008b, handle_StopMediaTransmissionMessage , SKINNY_MSGTYPE_EVENT , "StopMediaTransmissionMessage"},
{0x008f, handle_CallInfoMessage , SKINNY_MSGTYPE_EVENT , "CallInfoMessage"},
{0x0090, handle_ForwardStatResMessage , SKINNY_MSGTYPE_RESPONSE , "ForwardStatResMessage"},
{0x0091, handle_SpeedDialStatResMessage , SKINNY_MSGTYPE_RESPONSE , "SpeedDialStatResMessage"},
{0x0092, handle_LineStatResMessage , SKINNY_MSGTYPE_RESPONSE , "LineStatResMessage"},
{0x0093, handle_ConfigStatResMessage , SKINNY_MSGTYPE_RESPONSE , "ConfigStatResMessage"},
{0x0094, handle_TimeDateResMessage , SKINNY_MSGTYPE_RESPONSE , "TimeDateResMessage"},
{0x0095, handle_StartSessionTransmissionMessage , SKINNY_MSGTYPE_EVENT , "StartSessionTransmissionMessage"},
{0x0096, handle_StopSessionTransmissionMessage , SKINNY_MSGTYPE_EVENT , "StopSessionTransmissionMessage"},
{0x0097, handle_ButtonTemplateResMessage , SKINNY_MSGTYPE_RESPONSE , "ButtonTemplateResMessage"},
{0x0098, handle_VersionResMessage , SKINNY_MSGTYPE_RESPONSE , "VersionResMessage"},
{0x0099, handle_DisplayTextMessage , SKINNY_MSGTYPE_EVENT , "DisplayTextMessage"},
{0x009a, NULL , SKINNY_MSGTYPE_EVENT , "ClearDisplay"},
{0x009b, NULL , SKINNY_MSGTYPE_EVENT , "CapabilitiesReq"},
{0x009d, handle_RegisterRejectMessage , SKINNY_MSGTYPE_EVENT , "RegisterRejectMessage"},
{0x009e, handle_ServerResMessage , SKINNY_MSGTYPE_RESPONSE , "ServerResMessage"},
{0x009f, handle_Reset , SKINNY_MSGTYPE_EVENT , "Reset"},
{0x0100, NULL , SKINNY_MSGTYPE_RESPONSE , "KeepAliveAckMessage"},
{0x0101, handle_StartMulticastMediaReceptionMessage , SKINNY_MSGTYPE_REQUEST , "StartMulticastMediaReceptionMessage"},
{0x0102, handle_StartMulticastMediaTransmissionMessage , SKINNY_MSGTYPE_REQUEST , "StartMulticastMediaTransmissionMessage"},
{0x0103, handle_StopMulticastMediaReceptionMessage , SKINNY_MSGTYPE_EVENT , "StopMulticastMediaReceptionMessage"},
{0x0104, handle_StopMulticastMediaTransmissionMessage , SKINNY_MSGTYPE_EVENT , "StopMulticastMediaTransmissionMessage"},
{0x0105, handle_OpenReceiveChannelMessage , SKINNY_MSGTYPE_REQUEST , "OpenReceiveChannelMessage"},
{0x0106, handle_CloseReceiveChannelMessage , SKINNY_MSGTYPE_EVENT , "CloseReceiveChannelMessage"},
{0x0107, handle_ConnectionStatisticsReqMessage , SKINNY_MSGTYPE_REQUEST , "ConnectionStatisticsReqMessage"},
{0x0108, handle_SoftKeyTemplateResMessage , SKINNY_MSGTYPE_RESPONSE , "SoftKeyTemplateResMessage"},
{0x0109, handle_SoftKeySetResMessage , SKINNY_MSGTYPE_RESPONSE , "SoftKeySetResMessage"},
{0x0110, handle_SelectSoftKeysMessage , SKINNY_MSGTYPE_EVENT , "SelectSoftKeysMessage"},
{0x0111, handle_CallStateMessage , SKINNY_MSGTYPE_EVENT , "CallStateMessage"},
{0x0112, handle_DisplayPromptStatusMessage , SKINNY_MSGTYPE_EVENT , "DisplayPromptStatusMessage"},
{0x0113, handle_ClearPromptStatusMessage , SKINNY_MSGTYPE_EVENT , "ClearPromptStatusMessage"},
{0x0114, handle_DisplayNotifyMessage , SKINNY_MSGTYPE_EVENT , "DisplayNotifyMessage"},
{0x0115, NULL , SKINNY_MSGTYPE_EVENT , "ClearNotifyMessage"},
{0x0116, handle_ActivateCallPlaneMessage , SKINNY_MSGTYPE_EVENT , "ActivateCallPlaneMessage"},
{0x0117, NULL , SKINNY_MSGTYPE_EVENT , "DeactivateCallPlaneMessage"},
{0x0118, handle_UnregisterAckMessage , SKINNY_MSGTYPE_RESPONSE , "UnregisterAckMessage"},
{0x0119, handle_BackSpaceResMessage , SKINNY_MSGTYPE_EVENT , "BackSpaceResMessage"},
{0x011a, NULL , SKINNY_MSGTYPE_RESPONSE , "RegisterTokenAck"},
{0x011b, handle_RegisterTokenReject , SKINNY_MSGTYPE_RESPONSE , "RegisterTokenReject"},
{0x011c, handle_StartMediaFailureDetectionMessage , SKINNY_MSGTYPE_EVENT , "StartMediaFailureDetectionMessage"},
{0x011d, handle_DialedNumberMessage , SKINNY_MSGTYPE_EVENT , "DialedNumberMessage"},
{0x011e, handle_UserToDeviceDataMessage , SKINNY_MSGTYPE_EVENT , "UserToDeviceDataMessage"},
{0x011f, handle_FeatureStatResMessage , SKINNY_MSGTYPE_RESPONSE , "FeatureStatResMessage"},
{0x0120, handle_DisplayPriNotifyMessage , SKINNY_MSGTYPE_EVENT , "DisplayPriNotifyMessage"},
{0x0121, handle_ClearPriNotifyMessage , SKINNY_MSGTYPE_EVENT , "ClearPriNotifyMessage"},
{0x0122, handle_StartAnnouncementMessage , SKINNY_MSGTYPE_EVENT , "StartAnnouncementMessage"},
{0x0123, handle_StopAnnouncementMessage , SKINNY_MSGTYPE_EVENT , "StopAnnouncementMessage"},
{0x0124, handle_AnnouncementFinishMessage , SKINNY_MSGTYPE_EVENT , "AnnouncementFinishMessage"},
{0x0127, handle_NotifyDtmfToneMessage , SKINNY_MSGTYPE_EVENT , "NotifyDtmfToneMessage"},
{0x0128, handle_SendDtmfToneMessage , SKINNY_MSGTYPE_EVENT , "SendDtmfToneMessage"},
{0x0129, handle_SubscribeDtmfPayloadReqMessage , SKINNY_MSGTYPE_REQUEST , "SubscribeDtmfPayloadReqMessage"},
{0x012a, handle_SubscribeDtmfPayloadResMessage , SKINNY_MSGTYPE_RESPONSE , "SubscribeDtmfPayloadResMessage"},
{0x012b, handle_SubscribeDtmfPayloadErrMessage , SKINNY_MSGTYPE_RESPONSE , "SubscribeDtmfPayloadErrMessage"},
{0x012c, handle_UnSubscribeDtmfPayloadReqMessage , SKINNY_MSGTYPE_REQUEST , "UnSubscribeDtmfPayloadReqMessage"},
{0x012d, handle_UnSubscribeDtmfPayloadResMessage , SKINNY_MSGTYPE_RESPONSE , "UnSubscribeDtmfPayloadResMessage"},
{0x012e, handle_UnSubscribeDtmfPayloadErrMessage , SKINNY_MSGTYPE_RESPONSE , "UnSubscribeDtmfPayloadErrMessage"},
{0x012f, handle_ServiceURLStatResMessage , SKINNY_MSGTYPE_RESPONSE , "ServiceURLStatResMessage"},
{0x0130, handle_CallSelectStatResMessage , SKINNY_MSGTYPE_EVENT , "CallSelectStatResMessage"},
{0x0131, handle_OpenMultiMediaReceiveChannelMessage , SKINNY_MSGTYPE_REQUEST , "OpenMultiMediaReceiveChannelMessage"},
{0x0132, handle_StartMultiMediaTransmissionMessage , SKINNY_MSGTYPE_REQUEST , "StartMultiMediaTransmissionMessage"},
{0x0133, handle_StopMultiMediaTransmissionMessage , SKINNY_MSGTYPE_EVENT , "StopMultiMediaTransmissionMessage"},
{0x0134, handle_MiscellaneousCommandMessage , SKINNY_MSGTYPE_EVENT , "MiscellaneousCommandMessage"},
{0x0135, handle_FlowControlCommandMessage , SKINNY_MSGTYPE_EVENT , "FlowControlCommandMessage"},
{0x0136, handle_CloseMultiMediaReceiveChannelMessage , SKINNY_MSGTYPE_EVENT , "CloseMultiMediaReceiveChannelMessage"},
{0x0137, handle_CreateConferenceReqMessage , SKINNY_MSGTYPE_REQUEST , "CreateConferenceReqMessage"},
{0x0138, handle_DeleteConferenceReqMessage , SKINNY_MSGTYPE_REQUEST , "DeleteConferenceReqMessage"},
{0x0139, handle_ModifyConferenceReqMessage , SKINNY_MSGTYPE_REQUEST , "ModifyConferenceReqMessage"},
{0x013a, handle_AddParticipantReqMessage , SKINNY_MSGTYPE_REQUEST , "AddParticipantReqMessage"},
{0x013b, handle_DropParticipantReqMessage , SKINNY_MSGTYPE_REQUEST , "DropParticipantReqMessage"},
{0x013c, NULL , SKINNY_MSGTYPE_REQUEST , "AuditConferenceReqMessage"},
{0x013d, handle_AuditParticipantReqMessage , SKINNY_MSGTYPE_REQUEST , "AuditParticipantReqMessage"},
{0x013e, handle_ChangeParticipantReqMessage , SKINNY_MSGTYPE_REQUEST , "ChangeParticipantReqMessage"},
{0x013f, handle_UserToDeviceDataMessageVersion1 , SKINNY_MSGTYPE_EVENT , "UserToDeviceDataMessageVersion1"},
{0x0140, handle_VideoDisplayCommandMessage , SKINNY_MSGTYPE_EVENT , "VideoDisplayCommandMessage"},
{0x0141, handle_FlowControlNotifyMessage , SKINNY_MSGTYPE_EVENT , "FlowControlNotifyMessage"},
{0x0142, handle_ConfigStatV2ResMessage , SKINNY_MSGTYPE_RESPONSE , "ConfigStatV2ResMessage"},
{0x0143, handle_DisplayNotifyV2Message , SKINNY_MSGTYPE_EVENT , "DisplayNotifyV2Message"},
{0x0144, handle_DisplayPriNotifyV2Message , SKINNY_MSGTYPE_EVENT , "DisplayPriNotifyV2Message"},
{0x0145, handle_DisplayPromptStatusV2Message , SKINNY_MSGTYPE_EVENT , "DisplayPromptStatusV2Message"},
{0x0146, handle_FeatureStatV2ResMessage , SKINNY_MSGTYPE_RESPONSE , "FeatureStatV2ResMessage"},
{0x0147, handle_LineStatV2ResMessage , SKINNY_MSGTYPE_RESPONSE , "LineStatV2ResMessage"},
{0x0148, handle_ServiceURLStatV2ResMessage , SKINNY_MSGTYPE_RESPONSE , "ServiceURLStatV2ResMessage"},
{0x0149, handle_SpeedDialStatV2ResMessage , SKINNY_MSGTYPE_RESPONSE , "SpeedDialStatV2ResMessage"},
{0x014a, handle_CallInfoV2Message , SKINNY_MSGTYPE_EVENT , "CallInfoV2Message"},
{0x014b, handle_PortReqMessage , SKINNY_MSGTYPE_REQUEST , "PortReqMessage"},
{0x014c, handle_PortCloseMessage , SKINNY_MSGTYPE_EVENT , "PortCloseMessage"},
{0x014d, handle_QoSListenMessage , SKINNY_MSGTYPE_EVENT , "QoSListenMessage"},
{0x014e, handle_QoSPathMessage , SKINNY_MSGTYPE_EVENT , "QoSPathMessage"},
{0x014f, handle_QoSTeardownMessage , SKINNY_MSGTYPE_EVENT , "QoSTeardownMessage"},
{0x0150, handle_UpdateDSCPMessage , SKINNY_MSGTYPE_EVENT , "UpdateDSCPMessage"},
{0x0151, handle_QoSModifyMessage , SKINNY_MSGTYPE_EVENT , "QoSModifyMessage"},
{0x0152, handle_SubscriptionStatResMessage , SKINNY_MSGTYPE_RESPONSE , "SubscriptionStatResMessage"},
{0x0153, handle_NotificationMessage , SKINNY_MSGTYPE_EVENT , "NotificationMessage"},
{0x0154, handle_StartMediaTransmissionAckMessage , SKINNY_MSGTYPE_RESPONSE , "StartMediaTransmissionAckMessage"},
{0x0155, handle_StartMultiMediaTransmissionAckMessage , SKINNY_MSGTYPE_RESPONSE , "StartMultiMediaTransmissionAckMessage"},
{0x0156, handle_CallHistoryInfoMessage , SKINNY_MSGTYPE_EVENT , "CallHistoryInfoMessage"},
{0x0157, handle_LocationInfoMessage , SKINNY_MSGTYPE_EVENT , "LocationInfoMessage"},
{0x0158, handle_MwiResMessage , SKINNY_MSGTYPE_RESPONSE , "MwiResMessage"},
{0x0159, handle_AddOnDeviceCapabilitiesMessage , SKINNY_MSGTYPE_EVENT , "AddOnDeviceCapabilitiesMessage"},
{0x015a, handle_EnhancedAlarmMessage , SKINNY_MSGTYPE_EVENT , "EnhancedAlarmMessage"},
{0x015e, NULL , SKINNY_MSGTYPE_REQUEST , "CallCountReqMessage"},
{0x015f, handle_CallCountRespMessage , SKINNY_MSGTYPE_RESPONSE , "CallCountRespMessage"},
{0x0160, handle_RecordingStatusMessage , SKINNY_MSGTYPE_EVENT , "RecordingStatusMessage"},
{0x8000, handle_SPCPRegisterTokenReq , SKINNY_MSGTYPE_REQUEST , "SPCPRegisterTokenReq"},
{0x8100, handle_SPCPRegisterTokenAck , SKINNY_MSGTYPE_RESPONSE , "SPCPRegisterTokenAck"},
{0x8101, handle_SPCPRegisterTokenReject , SKINNY_MSGTYPE_RESPONSE , "SPCPRegisterTokenReject"},
};
/* Dissect a single SKINNY PDU */
static int dissect_skinny_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
unsigned offset = 0;
/*bool is_video = false;*/ /* FIX ME: need to indicate video or not */
ptvcursor_t* cursor;
conversation_t *conversation;
skinny_conv_info_t *skinny_conv;
const skinny_opcode_map_t *opcode_entry = NULL;
/* Header fields */
uint32_t hdr_data_length;
uint32_t hdr_version;
uint32_t hdr_opcode;
uint16_t i;
/* Set up structures we will need to add the protocol subtree and manage it */
proto_tree *skinny_tree = NULL;
proto_item *ti = NULL;
/* Initialization */
hdr_data_length = tvb_get_letohl(tvb, 0);
hdr_version = tvb_get_letohl(tvb, 4);
hdr_opcode = tvb_get_letohl(tvb, 8);
for (i = 0; i < sizeof(skinny_opcode_map)/sizeof(skinny_opcode_map_t) ; i++) {
if (skinny_opcode_map[i].opcode == hdr_opcode) {
opcode_entry = &skinny_opcode_map[i];
}
}
conversation = find_or_create_conversation(pinfo);
skinny_conv = (skinny_conv_info_t *)conversation_get_proto_data(conversation, proto_skinny);
if (!skinny_conv) {
skinny_conv = wmem_new0(wmem_file_scope(), skinny_conv_info_t);
//skinny_conv->pending_req_resp = wmem_map_new(wmem_file_scope(), wmem_str_hash, g_str_equal);
skinny_conv->pending_req_resp = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
skinny_conv->requests = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
skinny_conv->responses = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
skinny_conv->lineId = -1;
skinny_conv->mtype = SKINNY_MSGTYPE_EVENT;
conversation_add_proto_data(conversation, proto_skinny, skinny_conv);
}
/* Initialise stat info for passing to tap */
/* WIP: will be (partially) replaced in favor of conversionation, dependents: ui/voip_calls.c */
pi_current++;
if (pi_current == MAX_SKINNY_MESSAGES_IN_PACKET)
{
/* Overwrite info in first struct if run out of space... */
pi_current = 0;
}
si = &pi_arr[pi_current];
si->messId = hdr_opcode;
si->messageName = val_to_str_ext(hdr_opcode, &message_id_ext, "0x%08X (Unknown)");
si->callId = 0;
si->lineId = 0;
si->passThroughPartyId = 0;
si->callState = 0;
g_free(si->callingParty);
si->callingParty = NULL;
g_free(si->calledParty);
si->calledParty = NULL;
si->mediaReceptionStatus = -1;
si->mediaTransmissionStatus = -1;
si->multimediaReceptionStatus = -1;
si->multimediaTransmissionStatus = -1;
si->multicastReceptionStatus = -1;
g_free(si->additionalInfo);
si->additionalInfo = NULL;
col_add_fstr(pinfo->cinfo, COL_INFO,"%s ", si->messageName);
col_set_fence(pinfo->cinfo, COL_INFO);
if (tree) {
ti = proto_tree_add_item(tree, proto_skinny, tvb, offset, hdr_data_length+8, ENC_NA);
skinny_tree = proto_item_add_subtree(ti, ett_skinny);
}
if (opcode_entry && opcode_entry->type != SKINNY_MSGTYPE_EVENT) {
skinny_conv->mtype = opcode_entry->type;
if (opcode_entry->type == SKINNY_MSGTYPE_REQUEST) {
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SKINNY/REQ");
} else {
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SKINNY/RESP");
}
}
if (skinny_tree) {
proto_tree_add_uint(skinny_tree, hf_skinny_data_length, tvb, offset , 4, hdr_data_length);
proto_tree_add_uint(skinny_tree, hf_skinny_hdr_version, tvb, offset+4, 4, hdr_version);
proto_tree_add_uint(skinny_tree, hf_skinny_messageId, tvb, offset+8, 4, hdr_opcode );
}
offset += 12;
cursor = ptvcursor_new(pinfo->pool, skinny_tree, tvb, offset);
if (opcode_entry && opcode_entry->handler) {
opcode_entry->handler(cursor, pinfo, skinny_conv);
}
ptvcursor_free(cursor);
tap_queue_packet(skinny_tap, pinfo, si);
return tvb_captured_length(tvb);
}
/* Code to actually dissect the packets */
static int
dissect_skinny(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
/* The general structure of a packet: {IP-Header|TCP-Header|n*SKINNY}
* SKINNY-Packet: {Header(Size, Reserved)|Data(MessageID, Message-Data)}
*/
/* Header fields */
uint32_t hdr_data_length;
uint32_t hdr_version;
/* check, if this is really an SKINNY packet, they start with a length + 0 */
if (tvb_captured_length(tvb) < 8)
{
return 0;
}
/* get relevant header information */
hdr_data_length = tvb_get_letohl(tvb, 0);
hdr_version = tvb_get_letohl(tvb, 4);
/* data_size = MIN(8+hdr_data_length, tvb_length(tvb)) - 0xC; */
if (
(hdr_data_length < 4) ||
((hdr_version != BASIC_MSG_TYPE) &&
(hdr_version != V10_MSG_TYPE) &&
(hdr_version != V11_MSG_TYPE) &&
(hdr_version != V15_MSG_TYPE) &&
(hdr_version != V16_MSG_TYPE) &&
(hdr_version != V17_MSG_TYPE) &&
(hdr_version != V18_MSG_TYPE) &&
(hdr_version != V19_MSG_TYPE) &&
(hdr_version != V20_MSG_TYPE) &&
(hdr_version != V21_MSG_TYPE) &&
(hdr_version != V22_MSG_TYPE))
)
{
/* Not an SKINNY packet, just happened to use the same port */
return 0;
}
/* Make entries in Protocol column and Info column on summary display */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SKINNY");
col_set_str(pinfo->cinfo, COL_INFO, "Skinny Client Control Protocol");
tcp_dissect_pdus(tvb, pinfo, tree, global_skinny_desegment, 4, get_skinny_pdu_len, dissect_skinny_pdu, data);
return tvb_captured_length(tvb);
}
/* Register the protocol with Wireshark */
void
proto_register_skinny(void)
{
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_skinny_data_length,
{
"Data length", "skinny.data_length", FT_UINT32, BASE_DEC, NULL, 0x0,
"Number of bytes in the data portion.", HFILL }},
{ &hf_skinny_hdr_version,
{
"Header version", "skinny.hdr_version", FT_UINT32, BASE_HEX, VALS(header_version), 0x0,
NULL, HFILL }},
{ &hf_skinny_messageId,
{
"Message ID", "skinny.messageId", FT_UINT32, BASE_DEC|BASE_EXT_STRING, &message_id_ext, 0x0,
NULL, HFILL }},
{ &hf_skinny_xmlData,
{
"XML data", "skinny.xmlData", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_ipv4or6,
{
"IPv4or6", "skinny.ipv4or6", FT_UINT32, BASE_DEC|BASE_EXT_STRING, &IpAddrType_ext, 0x0,
NULL, HFILL }},
{ &hf_skinny_response_in,
{
"Response In", "skinny.response_in", FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE), 0x0,
"The response to this SKINNY request is in this frame", HFILL }},
{ &hf_skinny_response_to,
{
"Request In", "skinny.response_to", FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0x0,
"This is a response to the SKINNY request in this frame", HFILL }},
{ &hf_skinny_response_time,
{
"Response Time", "skinny.response_time", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
"The time between the Call and the Reply", HFILL }},
{ &hf_skinny_CallingPartyName,
{
"CallingName", "skinny.CallingPartyName", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000008,
NULL, HFILL }},
{ &hf_skinny_CallingPartyNumber,
{
"CallingNum", "skinny.CallingPartyNumber", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000004,
NULL, HFILL }},
{ &hf_skinny_DSCPValue,
{
"DSCPValue", "skinny.DSCPValue", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_FutureUse1,
{
"FutureUse1", "skinny.FutureUse1", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_FutureUse2,
{
"FutureUse2", "skinny.FutureUse2", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_FutureUse3,
{
"FutureUse3", "skinny.FutureUse3", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit1,
{
"Bit1", "skinny.Generic.Bitfield.Bit1", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000001,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit10,
{
"Bit10", "skinny.Generic.Bitfield.Bit10", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000200,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit11,
{
"Bit11", "skinny.Generic.Bitfield.Bit11", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000400,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit12,
{
"Bit12", "skinny.Generic.Bitfield.Bit12", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000800,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit13,
{
"Bit13", "skinny.Generic.Bitfield.Bit13", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00001000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit14,
{
"Bit14", "skinny.Generic.Bitfield.Bit14", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00002000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit15,
{
"Bit15", "skinny.Generic.Bitfield.Bit15", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00004000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit16,
{
"Bit16", "skinny.Generic.Bitfield.Bit16", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00008000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit17,
{
"Bit17", "skinny.Generic.Bitfield.Bit17", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00010000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit18,
{
"Bit18", "skinny.Generic.Bitfield.Bit18", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00020000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit19,
{
"Bit19", "skinny.Generic.Bitfield.Bit19", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00040000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit2,
{
"Bit2", "skinny.Generic.Bitfield.Bit2", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000002,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit20,
{
"Bit20", "skinny.Generic.Bitfield.Bit20", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00080000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit21,
{
"Bit21", "skinny.Generic.Bitfield.Bit21", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00100000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit22,
{
"Bit22", "skinny.Generic.Bitfield.Bit22", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00200000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit23,
{
"Bit23", "skinny.Generic.Bitfield.Bit23", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00400000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit24,
{
"Bit24", "skinny.Generic.Bitfield.Bit24", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00800000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit25,
{
"Bit25", "skinny.Generic.Bitfield.Bit25", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x01000000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit26,
{
"Bit26", "skinny.Generic.Bitfield.Bit26", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x02000000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit27,
{
"Bit27", "skinny.Generic.Bitfield.Bit27", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x04000000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit28,
{
"Bit28", "skinny.Generic.Bitfield.Bit28", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x08000000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit29,
{
"Bit29", "skinny.Generic.Bitfield.Bit29", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x10000000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit3,
{
"Bit3", "skinny.Generic.Bitfield.Bit3", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000004,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit30,
{
"Bit30", "skinny.Generic.Bitfield.Bit30", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x20000000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit31,
{
"Bit31", "skinny.Generic.Bitfield.Bit31", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x40000000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit32,
{
"Bit32", "skinny.Generic.Bitfield.Bit32", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x80000000,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit4,
{
"Bit4", "skinny.Generic.Bitfield.Bit4", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000008,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit5,
{
"Bit5", "skinny.Generic.Bitfield.Bit5", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000010,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit6,
{
"Bit6", "skinny.Generic.Bitfield.Bit6", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000020,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit7,
{
"Bit7", "skinny.Generic.Bitfield.Bit7", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000040,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit8,
{
"Bit8", "skinny.Generic.Bitfield.Bit8", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000080,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_Generic_Bitfield_Bit9,
{
"Bit9", "skinny.Generic.Bitfield.Bit9", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000100,
"H263 Capability BitField", HFILL }},
{ &hf_skinny_MPI,
{
"MPI", "skinny.MPI", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_OrigDialed,
{
"Originally Dialed", "skinny.OrigDialed", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000001,
NULL, HFILL }},
{ &hf_skinny_PhoneFeatures_Abbreviated_Dial,
{
"AbbrevDial", "skinny.PhoneFeatures.Abbreviated.Dial", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x8000,
"Features this device supports", HFILL }},
{ &hf_skinny_PhoneFeatures_Bit1,
{
"Bit1", "skinny.PhoneFeatures.Bit1", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x0001,
"Features this device supports", HFILL }},
{ &hf_skinny_PhoneFeatures_Bit11,
{
"Bit11", "skinny.PhoneFeatures.Bit11", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x0400,
"Features this device supports", HFILL }},
{ &hf_skinny_PhoneFeatures_Bit12,
{
"Bit12", "skinny.PhoneFeatures.Bit12", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x0800,
"Features this device supports", HFILL }},
{ &hf_skinny_PhoneFeatures_Bit13,
{
"Bit13", "skinny.PhoneFeatures.Bit13", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x1000,
"Features this device supports", HFILL }},
{ &hf_skinny_PhoneFeatures_Bit14,
{
"Bit14", "skinny.PhoneFeatures.Bit14", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x2000,
"Features this device supports", HFILL }},
{ &hf_skinny_PhoneFeatures_Bit15,
{
"Bit15", "skinny.PhoneFeatures.Bit15", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x4000,
"Features this device supports", HFILL }},
{ &hf_skinny_PhoneFeatures_Bit2,
{
"Bit2", "skinny.PhoneFeatures.Bit2", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x0002,
"Features this device supports", HFILL }},
{ &hf_skinny_PhoneFeatures_Bit3,
{
"Bit3", "skinny.PhoneFeatures.Bit3", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x0004,
"Features this device supports", HFILL }},
{ &hf_skinny_PhoneFeatures_Bit4,
{
"Bit4", "skinny.PhoneFeatures.Bit4", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x0008,
"Features this device supports", HFILL }},
{ &hf_skinny_PhoneFeatures_Bit6,
{
"Bit6", "skinny.PhoneFeatures.Bit6", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x0020,
"Features this device supports", HFILL }},
{ &hf_skinny_PhoneFeatures_Bit7,
{
"Bit7", "skinny.PhoneFeatures.Bit7", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x0040,
"Features this device supports", HFILL }},
{ &hf_skinny_PhoneFeatures_Bit9,
{
"Bit9", "skinny.PhoneFeatures.Bit9", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x0100,
"Features this device supports", HFILL }},
{ &hf_skinny_PhoneFeatures_DynamicMessages,
{
"DynamicMessages", "skinny.PhoneFeatures.DynamicMessages", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x0080,
"Features this device supports", HFILL }},
{ &hf_skinny_PhoneFeatures_RFC2833,
{
"RFC2833", "skinny.PhoneFeatures.RFC2833", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x0200,
"Features this device supports", HFILL }},
{ &hf_skinny_PhoneFeatures_UTF8,
{
"UTF8Bit5", "skinny.PhoneFeatures.UTF8", FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x0010,
"Features this device supports", HFILL }},
{ &hf_skinny_RFC2833PayloadType,
{
"RFC2833PayloadType", "skinny.RFC2833PayloadType", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_RTCPPortNumber,
{
"RTCPPortNumber", "skinny.RTCPPortNumber", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_RedirDialed,
{
"Redirected Dialed", "skinny.RedirDialed", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000002,
NULL, HFILL }},
{ &hf_skinny_RestrictInformationType_BitsReserved,
{
"BitsReserved", "skinny.RestrictInformationType.BitsReserved", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0xffffff00,
NULL, HFILL }},
{ &hf_skinny_RestrictInformationType_CalledParty,
{
"CalledParty", "skinny.RestrictInformationType.CalledParty", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x0000000c,
NULL, HFILL }},
{ &hf_skinny_RestrictInformationType_CalledPartyName,
{
"CalledPartyName", "skinny.RestrictInformationType.CalledPartyName", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000004,
NULL, HFILL }},
{ &hf_skinny_RestrictInformationType_CalledPartyNumber,
{
"CalledPartyNumber", "skinny.RestrictInformationType.CalledPartyNumber", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000008,
NULL, HFILL }},
{ &hf_skinny_RestrictInformationType_CallingParty,
{
"CallingParty", "skinny.RestrictInformationType.CallingParty", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000003,
NULL, HFILL }},
{ &hf_skinny_RestrictInformationType_CallingPartyName,
{
"CallingPartyName", "skinny.RestrictInformationType.CallingPartyName", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000001,
NULL, HFILL }},
{ &hf_skinny_RestrictInformationType_CallingPartyNumber,
{
"CallingPartyNumber", "skinny.RestrictInformationType.CallingPartyNumber", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000002,
NULL, HFILL }},
{ &hf_skinny_RestrictInformationType_LastRedirectParty,
{
"LastRedirectParty", "skinny.RestrictInformationType.LastRedirectParty", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x000000c0,
NULL, HFILL }},
{ &hf_skinny_RestrictInformationType_LastRedirectPartyName,
{
"LastRedirectPartyName", "skinny.RestrictInformationType.LastRedirectPartyName", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000040,
NULL, HFILL }},
{ &hf_skinny_RestrictInformationType_LastRedirectPartyNumber,
{
"LastRedirectPartyNumber", "skinny.RestrictInformationType.LastRedirectPartyNumber", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000080,
NULL, HFILL }},
{ &hf_skinny_RestrictInformationType_OriginalCalledParty,
{
"OriginalCalledParty", "skinny.RestrictInformationType.OriginalCalledParty", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000030,
NULL, HFILL }},
{ &hf_skinny_RestrictInformationType_OriginalCalledPartyName,
{
"OriginalCalledPartyName", "skinny.RestrictInformationType.OriginalCalledPartyName", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000010,
NULL, HFILL }},
{ &hf_skinny_RestrictInformationType_OriginalCalledPartyNumber,
{
"OriginalCalledPartyNumber", "skinny.RestrictInformationType.OriginalCalledPartyNumber", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000020,
NULL, HFILL }},
{ &hf_skinny_SoftKeyMask_SoftKey1,
{
"SoftKey1", "skinny.SoftKeyMask.SoftKey1", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000001,
NULL, HFILL }},
{ &hf_skinny_SoftKeyMask_SoftKey10,
{
"SoftKey10", "skinny.SoftKeyMask.SoftKey10", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000200,
NULL, HFILL }},
{ &hf_skinny_SoftKeyMask_SoftKey11,
{
"SoftKey11", "skinny.SoftKeyMask.SoftKey11", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000400,
NULL, HFILL }},
{ &hf_skinny_SoftKeyMask_SoftKey12,
{
"SoftKey12", "skinny.SoftKeyMask.SoftKey12", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000800,
NULL, HFILL }},
{ &hf_skinny_SoftKeyMask_SoftKey13,
{
"SoftKey13", "skinny.SoftKeyMask.SoftKey13", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00001000,
NULL, HFILL }},
{ &hf_skinny_SoftKeyMask_SoftKey14,
{
"SoftKey14", "skinny.SoftKeyMask.SoftKey14", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00002000,
NULL, HFILL }},
{ &hf_skinny_SoftKeyMask_SoftKey15,
{
"SoftKey15", "skinny.SoftKeyMask.SoftKey15", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00004000,
NULL, HFILL }},
{ &hf_skinny_SoftKeyMask_SoftKey16,
{
"SoftKey16", "skinny.SoftKeyMask.SoftKey16", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00008000,
NULL, HFILL }},
{ &hf_skinny_SoftKeyMask_SoftKey2,
{
"SoftKey2", "skinny.SoftKeyMask.SoftKey2", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000002,
NULL, HFILL }},
{ &hf_skinny_SoftKeyMask_SoftKey3,
{
"SoftKey3", "skinny.SoftKeyMask.SoftKey3", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000004,
NULL, HFILL }},
{ &hf_skinny_SoftKeyMask_SoftKey4,
{
"SoftKey4", "skinny.SoftKeyMask.SoftKey4", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000008,
NULL, HFILL }},
{ &hf_skinny_SoftKeyMask_SoftKey5,
{
"SoftKey5", "skinny.SoftKeyMask.SoftKey5", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000010,
NULL, HFILL }},
{ &hf_skinny_SoftKeyMask_SoftKey6,
{
"SoftKey6", "skinny.SoftKeyMask.SoftKey6", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000020,
NULL, HFILL }},
{ &hf_skinny_SoftKeyMask_SoftKey7,
{
"SoftKey7", "skinny.SoftKeyMask.SoftKey7", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000040,
NULL, HFILL }},
{ &hf_skinny_SoftKeyMask_SoftKey8,
{
"SoftKey8", "skinny.SoftKeyMask.SoftKey8", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000080,
NULL, HFILL }},
{ &hf_skinny_SoftKeyMask_SoftKey9,
{
"SoftKey9", "skinny.SoftKeyMask.SoftKey9", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00000100,
NULL, HFILL }},
{ &hf_skinny_active,
{
"active", "skinny.active", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_activeConferenceOnRegistration,
{
"Active Conference", "skinny.activeConferenceOnRegistration", FT_UINT32, BASE_DEC, NULL, 0x0,
"Active conference at Registration", HFILL }},
{ &hf_skinny_activeConferences,
{
"Active Conferences", "skinny.activeConferences", FT_UINT32, BASE_DEC, NULL, 0x0,
"Active Conferences at Registration", HFILL }},
{ &hf_skinny_activeForward,
{
"activeForward", "skinny.activeForward", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_activeStreams,
{
"Active RTP Streams", "skinny.activeStreams", FT_UINT32, BASE_DEC, NULL, 0x0,
"Active RTP Streams at Registration", HFILL }},
{ &hf_skinny_activeStreamsOnRegistration,
{
"activeStreamsOnRegistration", "skinny.activeStreamsOnRegistration", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_alarmInfo,
{
"alarmInfo", "skinny.alarmInfo", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_alignmentPadding,
{
"alignmentPadding", "skinny.alignmentPadding", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_annexNandWFutureUse,
{
"annexNandWFutureUse", "skinny.annexNandWFutureUse", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_appInstanceID,
{
"appInstanceID", "skinny.appInstanceID", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_applicationId,
{
"applicationId", "skinny.applicationId", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_areMessagesWaiting,
{
"areMessagesWaiting", "skinny.areMessagesWaiting", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_associatedStreamId,
{
"associatedStreamId", "skinny.associatedStreamId", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_audioCapCount,
{
"audioCapCount", "skinny.audioCapCount", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_audioLevelAdjustment,
{
"audioLevelAdjustment", "skinny.audioLevelAdjustment", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_averageBitRate,
{
"averageBitRate", "skinny.averageBitRate", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_bandwidth,
{
"bandwidth", "skinny.bandwidth", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_bitRate,
{
"bitRate", "skinny.bitRate", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_burstSize,
{
"burstSize", "skinny.burstSize", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_busyTrigger,
{
"busyTrigger", "skinny.busyTrigger", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_buttonCount,
{
"buttonCount", "skinny.buttonCount", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_buttonOffset,
{
"buttonOffset", "skinny.buttonOffset", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_callInstance,
{
"callInstance", "skinny.callInstance", FT_UINT32, BASE_DEC, NULL, 0x0,
"CallId", HFILL }},
{ &hf_skinny_callReference,
{
"callReference", "skinny.callReference", FT_UINT32, BASE_DEC, NULL, 0x0,
"CallId", HFILL }},
{ &hf_skinny_callSelectStat,
{
"callSelectStat", "skinny.callSelectStat", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_capAndVer,
{
"capAndVer", "skinny.capAndVer", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_capCount,
{
"capCount", "skinny.capCount", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_chan0MaxPayload,
{
"chan0MaxPayload", "skinny.chan0MaxPayload", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_chan2MaxPayload,
{
"chan2MaxPayload", "skinny.chan2MaxPayload", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_chan2MaxWindow,
{
"chan2MaxWindow", "skinny.chan2MaxWindow", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_chan3MaxPayload,
{
"chan3MaxPayload", "skinny.chan3MaxPayload", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_clockConversionCode,
{
"clockConversionCode", "skinny.clockConversionCode", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_clockDivisor,
{
"clockDivisor", "skinny.clockDivisor", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_codecMode,
{
"codecMode", "skinny.codecMode", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_codecParam1,
{
"codecParam1", "skinny.codecParam1", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_codecParam2,
{
"codecParam2", "skinny.codecParam2", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_confServiceNum,
{
"confServiceNum", "skinny.confServiceNum", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_conferenceId,
{
"conferenceId", "skinny.conferenceId", FT_UINT32, BASE_DEC, NULL, 0x0,
"Conference ID", HFILL }},
{ &hf_skinny_confirmRequired,
{
"confirmRequired", "skinny.confirmRequired", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_country,
{
"country", "skinny.country", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_customMaxBRandCPB,
{
"customMaxBRandCPB", "skinny.customMaxBRandCPB", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_customMaxDPB,
{
"customMaxDPB", "skinny.customMaxDPB", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_customMaxFS,
{
"customMaxFS", "skinny.customMaxFS", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_customMaxMBPS,
{
"customMaxMBPS", "skinny.customMaxMBPS", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_customPictureFormatCount,
{
"customPictureFormatCount", "skinny.customPictureFormatCount", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_dataCapCount,
{
"dataCapCount", "skinny.dataCapCount", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_dataLength,
{
"dataLength", "skinny.dataLength", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_dataSize,
{
"dataSize", "skinny.dataSize", FT_UINT32, BASE_DEC, NULL, 0x0,
"Data Size", HFILL }},
{ &hf_skinny_defendingPriority,
{
"defendingPriority", "skinny.defendingPriority", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_displayPriority,
{
"displayPriority", "skinny.displayPriority", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_dtmfType,
{
"dtmfType", "skinny.dtmfType", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_dynamicPayload,
{
"dynamicPayload", "skinny.dynamicPayload", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_failureNodeIpAddr,
{
"failureNodeIpAddr", "skinny.failureNodeIpAddr", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_featureCapabilities,
{
"featureCapabilities", "skinny.featureCapabilities", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_featureIndex,
{
"featureIndex", "skinny.featureIndex", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_featureStatus,
{
"featureStatus", "skinny.featureStatus", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_features,
{
"features", "skinny.features", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_firstGOB,
{
"firstGOB", "skinny.firstGOB", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_firstMB,
{
"firstMB", "skinny.firstMB", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_format,
{
"format", "skinny.format", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_forwardAllActive,
{
"forwardAllActive", "skinny.forwardAllActive", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_forwardBusyActive,
{
"forwardBusyActive", "skinny.forwardBusyActive", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_forwardNoAnswerActive,
{
"forwardNoAnswerActive", "skinny.forwardNoAnswerActive", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_hearingConfPartyMask,
{
"hearingConfPartyMask", "skinny.hearingConfPartyMask", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_instance,
{
"instance", "skinny.instance", FT_UINT32, BASE_DEC, NULL, 0x0,
"Device Instance", HFILL }},
{ &hf_skinny_instanceNumber,
{
"instanceNumber", "skinny.instanceNumber", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_ipAddr_ipv4,
{
"ipAddr IPv4 Address", "skinny.ipAddr.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_ipAddr_ipv6,
{
"ipAddr IPv6 Address", "skinny.ipAddr.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_ipV4AddressScope,
{
"ipV4AddressScope", "skinny.ipV4AddressScope", FT_UINT32, BASE_DEC, NULL, 0x0,
"IPv4 Address Scope", HFILL }},
{ &hf_skinny_ipV6AddressScope,
{
"ipV6AddressScope", "skinny.ipV6AddressScope", FT_UINT32, BASE_DEC, NULL, 0x0,
"IPv6 Address Scope", HFILL }},
{ &hf_skinny_isConferenceCreator,
{
"isConferenceCreator", "skinny.isConferenceCreator", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_isMKIPresent,
{
"isMKIPresent", "skinny.isMKIPresent", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_jitter,
{
"jitter", "skinny.jitter", FT_UINT32, BASE_DEC, NULL, 0x0,
"Amount of Jitter", HFILL }},
{ &hf_skinny_keepAliveInterval,
{
"keepAliveInterval", "skinny.keepAliveInterval", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_key,
{
"key", "skinny.key", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_keyDerivationRate,
{
"keyDerivationRate", "skinny.keyDerivationRate", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_keylen,
{
"keylen", "skinny.keylen", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_last,
{
"last", "skinny.last", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_lastRedirectingReason,
{
"lastRedirectingReason", "skinny.lastRedirectingReason", FT_UINT32, BASE_DEC, NULL, 0x0,
"Last Redirecting Reason", HFILL }},
{ &hf_skinny_latency,
{
"latency", "skinny.latency", FT_UINT32, BASE_DEC, NULL, 0x0,
"Amount of Latency", HFILL }},
{ &hf_skinny_layoutCount,
{
"layoutCount", "skinny.layoutCount", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_layoutID,
{
"layoutID", "skinny.layoutID", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_level,
{
"level", "skinny.level", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_levelPreferenceCount,
{
"levelPreferenceCount", "skinny.levelPreferenceCount", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_lineDataEntries,
{
"lineDataEntries", "skinny.lineDataEntries", FT_UINT32, BASE_DEC, NULL, 0x0,
"Number of Line Data Entries", HFILL }},
{ &hf_skinny_lineDisplayOptions,
{
"lineDisplayOptions", "skinny.lineDisplayOptions", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_lineInstance,
{
"lineInstance", "skinny.lineInstance", FT_UINT32, BASE_DEC, NULL, 0x0,
"LineId", HFILL }},
{ &hf_skinny_lineNumber,
{
"lineNumber", "skinny.lineNumber", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_locale,
{
"locale", "skinny.locale", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_longTermPictureIndex,
{
"longTermPictureIndex", "skinny.longTermPictureIndex", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_macAddress,
{
"Mac Address", "skinny.macAddress", FT_ETHER, BASE_NONE, NULL, 0x0,
"Ethernet/Mac Address", HFILL }},
{ &hf_skinny_matrixConfPartyID,
{
"matrixConfPartyID", "skinny.matrixConfPartyID", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_maxBW,
{
"maxBW", "skinny.maxBW", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_maxBitRate,
{
"maxBitRate", "skinny.maxBitRate", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_maxConferences,
{
"Maximum Number of Concurrent Conferences", "skinny.maxConferences", FT_UINT32, BASE_DEC, NULL, 0x0,
"Indicates the maximum number of simultaneous Conferences, which this client/appliance can handle", HFILL }},
{ &hf_skinny_maxFramesPerPacket,
{
"maxFramesPerPacket", "skinny.maxFramesPerPacket", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_maxNumCalls,
{
"maxNumCalls", "skinny.maxNumCalls", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_maxNumOfAvailLines,
{
"maxNumOfAvailLines", "skinny.maxNumOfAvailLines", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_maxNumberOfLines,
{
"maxNumberOfLines", "skinny.maxNumberOfLines", FT_UINT32, BASE_DEC, NULL, 0x0,
"Maximum number of lines", HFILL }},
{ &hf_skinny_maxProtocolVer,
{
"maxProtocolVer", "skinny.maxProtocolVer", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_maxRetryNumber,
{
"maxRetryNumber", "skinny.maxRetryNumber", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_maxStreams,
{
"Maximum Number of Concurrent RTP Streams", "skinny.maxStreams", FT_UINT32, BASE_DEC, NULL, 0x0,
"Indicates the maximum number of simultaneous RTP duplex streams, which this client/appliance can handle.", HFILL }},
{ &hf_skinny_maxStreamsPerConf,
{
"maxStreamsPerConf", "skinny.maxStreamsPerConf", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_maximumBitRate,
{
"maximumBitRate", "skinny.maximumBitRate", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_milliSecondPacketSize,
{
"milliSecondPacketSize", "skinny.milliSecondPacketSize", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_minBitRate,
{
"minBitRate", "skinny.minBitRate", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_mixingMode,
{
"mixingMode", "skinny.mixingMode", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_modAnd2833,
{
"modAnd2833", "skinny.modAnd2833", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_modelNumber,
{
"modelNumber", "skinny.modelNumber", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_multicastIpAddr_ipv4,
{
"multicastIpAddr IPv4 Address", "skinny.multicastIpAddr.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0,
"ipaddress in big endian", HFILL }},
{ &hf_skinny_multicastIpAddr_ipv6,
{
"multicastIpAddr IPv6 Address", "skinny.multicastIpAddr.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0,
"ipaddress in big endian", HFILL }},
{ &hf_skinny_multicastPortNumber,
{
"multicastPortNumber", "skinny.multicastPortNumber", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_noaudio,
{
"noaudio", "skinny.noaudio", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_none,
{
"none", "skinny.none", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_notificationStatus,
{
"notificationStatus", "skinny.notificationStatus", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_nse,
{
"nse", "skinny.nse", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_numNewMsgs,
{
"numNewMsgs", "skinny.numNewMsgs", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_numOldMsgs,
{
"numOldMsgs", "skinny.numOldMsgs", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_numberOctetsReceived,
{
"numberOctetsReceived", "skinny.numberOctetsReceived", FT_UINT32, BASE_DEC, NULL, 0x0,
"Number of Octets Received", HFILL }},
{ &hf_skinny_numberOctetsSent,
{
"numberOctetsSent", "skinny.numberOctetsSent", FT_UINT32, BASE_DEC, NULL, 0x0,
"Number of Octets Sent", HFILL }},
{ &hf_skinny_numberOfActiveParticipants,
{
"numberOfActiveParticipants", "skinny.numberOfActiveParticipants", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_numberOfEntries,
{
"numberOfEntries", "skinny.numberOfEntries", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_numberOfGOBs,
{
"numberOfGOBs", "skinny.numberOfGOBs", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_numberOfInServiceStreams,
{
"numberOfInServiceStreams", "skinny.numberOfInServiceStreams", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_numberOfLines,
{
"numberOfLines", "skinny.numberOfLines", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_numberOfMBs,
{
"numberOfMBs", "skinny.numberOfMBs", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_numberOfOutOfServiceStreams,
{
"numberOfOutOfServiceStreams", "skinny.numberOfOutOfServiceStreams", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_numberOfReservedParticipants,
{
"numberOfReservedParticipants", "skinny.numberOfReservedParticipants", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_numberOfSpeedDials,
{
"numberOfSpeedDials", "skinny.numberOfSpeedDials", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_numberPacketsLost,
{
"numberPacketsLost", "skinny.numberPacketsLost", FT_UINT32, BASE_DEC, NULL, 0x0,
"Number of Packets Lost", HFILL }},
{ &hf_skinny_numberPacketsReceived,
{
"numberPacketsReceived", "skinny.numberPacketsReceived", FT_UINT32, BASE_DEC, NULL, 0x0,
"Number of Packets Received", HFILL }},
{ &hf_skinny_numberPacketsSent,
{
"numberPacketsSent", "skinny.numberPacketsSent", FT_UINT32, BASE_DEC, NULL, 0x0,
"Number of Packets Sent", HFILL }},
{ &hf_skinny_originalCdpnRedirectReason,
{
"originalCdpnRedirectReason", "skinny.originalCdpnRedirectReason", FT_UINT32, BASE_DEC, NULL, 0x0,
"Original Called Party Redirect Reason", HFILL }},
{ &hf_skinny_padding,
{
"padding", "skinny.padding", FT_UINT16, BASE_DEC, NULL, 0x0,
"Unused/Padding", HFILL }},
{ &hf_skinny_parm1,
{
"parm1", "skinny.parm1", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_parm2,
{
"parm2", "skinny.parm2", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_participantEntry,
{
"participantEntry", "skinny.participantEntry", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_partyDirection,
{
"partyDirection", "skinny.partyDirection", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_passThroughPartyId,
{
"passThroughPartyId", "skinny.passThroughPartyId", FT_UINT32, BASE_DEC, NULL, 0x0,
"PassThrough PartyId", HFILL }},
{ &hf_skinny_passthruPartyID,
{
"passthruPartyID", "skinny.passthruPartyID", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_payloadDtmf,
{
"payloadDtmf", "skinny.payloadDtmf", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_payloadType,
{
"payloadType", "skinny.payloadType", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_payload_rfc_number,
{
"payload_rfc_number", "skinny.payload.rfc.number", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_peakRate,
{
"peakRate", "skinny.peakRate", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_pictureFormatCount,
{
"pictureFormatCount", "skinny.pictureFormatCount", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_pictureHeight,
{
"pictureHeight", "skinny.pictureHeight", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_pictureNumber,
{
"pictureNumber", "skinny.pictureNumber", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_pictureWidth,
{
"pictureWidth", "skinny.pictureWidth", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_pixelAspectRatio,
{
"pixelAspectRatio", "skinny.pixelAspectRatio", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_portNumber,
{
"portNumber", "skinny.portNumber", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_precedenceDomain,
{
"precedenceDomain", "skinny.precedenceDomain", FT_UINT32, BASE_DEC, NULL, 0x0,
"Precedence Domain", HFILL }},
{ &hf_skinny_precedenceLevel,
{
"precedenceLevel", "skinny.precedenceLevel", FT_UINT32, BASE_DEC, NULL, 0x0,
"Precedence Level, MLPP priorities", HFILL }},
{ &hf_skinny_precedenceValue,
{
"precedenceValue", "skinny.precedenceValue", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_preemptionPriority,
{
"preemptionPriority", "skinny.preemptionPriority", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_priority,
{
"priority", "skinny.priority", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_profile,
{
"profile", "skinny.profile", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_protocolDependentData,
{
"protocolDependentData", "skinny.protocolDependentData", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_protocolVer,
{
"Protocol Version", "skinny.protocolVer", FT_UINT8, BASE_DEC, NULL, 0x0,
"Maximum Supported Protocol Version", HFILL }},
{ &hf_skinny_recoveryReferencePictureCount,
{
"recoveryReferencePictureCount", "skinny.recoveryReferencePictureCount", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_remoteIpAddr_ipv4,
{
"remoteIpAddr IPv4 Address", "skinny.remoteIpAddr.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0,
"ipaddress in big endian", HFILL }},
{ &hf_skinny_remoteIpAddr_ipv6,
{
"remoteIpAddr IPv6 Address", "skinny.remoteIpAddr.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0,
"ipaddress in big endian", HFILL }},
{ &hf_skinny_remotePortNumber,
{
"remotePortNumber", "skinny.remotePortNumber", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_reserved_for_future_use,
{
"reserved_for_future_use", "skinny.reserved.for.future.use", FT_UINT32, BASE_DEC, NULL, 0x0,
"User Id", HFILL }},
{ &hf_skinny_retryTimer,
{
"retryTimer", "skinny.retryTimer", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_rfc2833,
{
"rfc2833", "skinny.rfc2833", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_routingID,
{
"routingID", "skinny.routingID", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_rsvpErrorFlag,
{
"rsvpErrorFlag", "skinny.rsvpErrorFlag", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_rsvpErrorSubCodeVal,
{
"rsvpErrorSubCodeVal", "skinny.rsvpErrorSubCodeVal", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_rtpMediaPort,
{
"rtpMediaPort", "skinny.rtpMediaPort", FT_UINT32, BASE_DEC, NULL, 0x0,
"RTP Media Port", HFILL }},
{ &hf_skinny_rtpPayloadFormat,
{
"rtpPayloadFormat", "skinny.rtpPayloadFormat", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_salt,
{
"salt", "skinny.salt", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_saltlen,
{
"saltlen", "skinny.saltlen", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_secondaryKeepAliveInterval,
{
"secondaryKeepAliveInterval", "skinny.secondaryKeepAliveInterval", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_serverTcpListenPort,
{
"serverTcpListenPort", "skinny.serverTcpListenPort", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_serviceNum,
{
"serviceNum", "skinny.serviceNum", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_serviceNumber,
{
"serviceNumber", "skinny.serviceNumber", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_serviceResourceCount,
{
"serviceResourceCount", "skinny.serviceResourceCount", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_serviceURLIndex,
{
"serviceURLIndex", "skinny.serviceURLIndex", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_softKeyCount,
{
"softKeyCount", "skinny.softKeyCount", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_softKeyOffset,
{
"softKeyOffset", "skinny.softKeyOffset", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_softKeySetCount,
{
"softKeySetCount", "skinny.softKeySetCount", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_softKeySetOffset,
{
"softKeySetOffset", "skinny.softKeySetOffset", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_sourceIpAddr_ipv4,
{
"sourceIpAddr IPv4 Address", "skinny.sourceIpAddr.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_sourceIpAddr_ipv6,
{
"sourceIpAddr IPv6 Address", "skinny.sourceIpAddr.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_sourcePortNumber,
{
"sourcePortNumber", "skinny.sourcePortNumber", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_speedDialNumber,
{
"speedDialNumber", "skinny.speedDialNumber", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_sse,
{
"sse", "skinny.sse", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_standard,
{
"standard", "skinny.standard", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_startingLineInstance,
{
"startingLineInstance", "skinny.startingLineInstance", FT_UINT32, BASE_DEC, NULL, 0x0,
"Starting Line Instance", HFILL }},
{ &hf_skinny_stationIpAddr,
{
"stationIpAddr", "skinny.stationIpAddr", FT_IPv4, BASE_NONE, NULL, 0x0,
"IPv4 Address", HFILL }},
{ &hf_skinny_stationIpAddr_ipv4,
{
"stationIpAddr IPv4 Address", "skinny.stationIpAddr.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0,
"ipaddress in big endian", HFILL }},
{ &hf_skinny_stationIpAddr_ipv6,
{
"stationIpAddr IPv6 Address", "skinny.stationIpAddr.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0,
"ipaddress in big endian", HFILL }},
{ &hf_skinny_stationIpV6Addr,
{
"stationIpV6Addr", "skinny.stationIpV6Addr", FT_IPv6, BASE_NONE, NULL, 0x0,
"IPv6 Address", HFILL }},
{ &hf_skinny_stationIpV6Addr_ipv4,
{
"stationIpV6Addr IPv4 Address", "skinny.stationIpV6Addr.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_stationIpV6Addr_ipv6,
{
"stationIpV6Addr IPv6 Address", "skinny.stationIpV6Addr.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_stillImageTransmission,
{
"stillImageTransmission", "skinny.stillImageTransmission", FT_UINT32, BASE_DEC, NULL, 0x0,
"Still Image Transmission", HFILL }},
{ &hf_skinny_stimulusInstance,
{
"stimulusInstance", "skinny.stimulusInstance", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_stimulusStatus,
{
"stimulusStatus", "skinny.stimulusStatus", FT_UINT32, BASE_DEC, NULL, 0x0,
"Stimulus Status", HFILL }},
{ &hf_skinny_streamPassThroughId,
{
"streamPassThroughId", "skinny.streamPassThroughId", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_systemTime,
{
"systemTime", "skinny.systemTime", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_temporalSpatialTradeOff,
{
"temporalSpatialTradeOff", "skinny.temporalSpatialTradeOff", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_temporalSpatialTradeOffCapability,
{
"temporalSpatialTradeOffCapability", "skinny.temporalSpatialTradeOffCapability", FT_UINT32, BASE_DEC, NULL, 0x0,
"Temporal spatial trade off capability", HFILL }},
{ &hf_skinny_timeOutValue,
{
"timeOutValue", "skinny.timeOutValue", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_timer,
{
"timer", "skinny.timer", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_totalButtonCount,
{
"totalButtonCount", "skinny.totalButtonCount", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_totalNumOfConfiguredLines,
{
"totalNumOfConfiguredLines", "skinny.totalNumOfConfiguredLines", FT_UINT32, BASE_DEC, NULL, 0x0,
"Total Number of Configured Lines", HFILL }},
{ &hf_skinny_totalSoftKeyCount,
{
"totalSoftKeyCount", "skinny.totalSoftKeyCount", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_totalSoftKeySetCount,
{
"totalSoftKeySetCount", "skinny.totalSoftKeySetCount", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_transactionId,
{
"transactionId", "skinny.transactionId", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_transmitIpAddr_ipv4,
{
"transmitIpAddr IPv4 Address", "skinny.transmitIpAddr.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0,
"ipaddress in big endian", HFILL }},
{ &hf_skinny_transmitIpAddr_ipv6,
{
"transmitIpAddr IPv6 Address", "skinny.transmitIpAddr.ipv6", FT_IPv6, BASE_NONE, NULL, 0x0,
"ipaddress in big endian", HFILL }},
{ &hf_skinny_transmitPreference,
{
"transmitPreference", "skinny.transmitPreference", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_unknown,
{
"unknown", "skinny.unknown", FT_UINT8, BASE_DEC, NULL, 0x0,
"unknown (Part of ProtocolVer)", HFILL }},
{ &hf_skinny_unknown1_0159,
{
"unknown1_0159", "skinny.unknown1.0159", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_unknown2_0159,
{
"unknown2_0159", "skinny.unknown2.0159", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_unknown3_0159,
{
"unknown3_0159", "skinny.unknown3.0159", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_v150sprt,
{
"v150sprt", "skinny.v150sprt", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_vendor,
{
"vendor", "skinny.vendor", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_videoCapCount,
{
"videoCapCount", "skinny.videoCapCount", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_wDay,
{
"wDay", "skinny.wDay", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_wDayOfWeek,
{
"wDayOfWeek", "skinny.wDayOfWeek", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_wHour,
{
"wHour", "skinny.wHour", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_wMilliseconds,
{
"wMilliseconds", "skinny.wMilliseconds", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_wMinute,
{
"wMinute", "skinny.wMinute", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_wMonth,
{
"wMonth", "skinny.wMonth", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_wSecond,
{
"wSecond", "skinny.wSecond", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_wYear,
{
"wYear", "skinny.wYear", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_waitTimeBeforeNextReq,
{
"waitTimeBeforeNextReq", "skinny.waitTimeBeforeNextReq", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_xmldata,
{
"xmldata", "skinny.xmldata", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_AlternateCallingParty,
{
"AlternateCallingParty", "skinny.AlternateCallingParty", FT_STRING, BASE_NONE, NULL, 0x0,
"Alternate Calling Party Number", HFILL }},
{&hf_skinny_DeviceName,
{
"DeviceName", "skinny.DeviceName", FT_STRING, BASE_NONE, NULL, 0x0,
"Device Name", HFILL }},
{&hf_skinny_HuntPilotName,
{
"HuntPilotName", "skinny.HuntPilotName", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_HuntPilotNumber,
{
"HuntPilotNumber", "skinny.HuntPilotNumber", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_ServerName,
{
"ServerName", "skinny.ServerName", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_add_participant_result,
{
"add_participant_result", "skinny.add.participant.result", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &AddParticipantResult_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_alarmSeverity,
{
"alarmSeverity", "skinny.alarmSeverity", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &DeviceAlarmSeverity_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_algorithmID,
{
"algorithmID", "skinny.algorithmID", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &MediaEncryptionAlgorithmType_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_annAckReq,
{
"annAckReq", "skinny.annAckReq", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &EndOfAnnAck_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_annPlayMode,
{
"annPlayMode", "skinny.annPlayMode", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &AnnPlayMode_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_annStatus,
{
"annStatus", "skinny.annStatus", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &PlayAnnStatus_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_appConfID,
{
"appConfID", "skinny.appConfID", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_appData,
{
"appData", "skinny.appData", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_appName,
{
"appName", "skinny.appName", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_audit_participant_result,
{
"audit_participant_result", "skinny.audit.participant.result", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &AuditParticipantResult_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_bridgeParticipantId,
{
"bridgeParticipantId", "skinny.bridgeParticipantId", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_buttonDefinition,
{
"buttonDefinition", "skinny.buttonDefinition", FT_UINT8, BASE_HEX | BASE_EXT_STRING, &ButtonType_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_callHistoryDisposition,
{
"callHistoryDisposition", "skinny.callHistoryDisposition", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &CallHistoryDisposition_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_callSecurityStatus,
{
"callSecurityStatus", "skinny.callSecurityStatus", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &CallSecurityStatusType_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_callState,
{
"callState", "skinny.callState", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &DCallState_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_callType,
{
"callType", "skinny.callType", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &CallType_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_calledParty,
{
"calledParty", "skinny.calledParty", FT_STRING, BASE_NONE, NULL, 0x0,
"CalledPartyNumber", HFILL }},
{&hf_skinny_calledPartyName,
{
"calledPartyName", "skinny.calledPartyName", FT_STRING, BASE_NONE, NULL, 0x0,
"Called Party Name", HFILL }},
{&hf_skinny_callingParty,
{
"callingParty", "skinny.callingParty", FT_STRING, BASE_NONE, NULL, 0x0,
"Calling Party Number", HFILL }},
{&hf_skinny_callingPartyName,
{
"callingPartyName", "skinny.callingPartyName", FT_STRING, BASE_NONE, NULL, 0x0,
"Calling Party Name", HFILL }},
{&hf_skinny_callingPartyNumber,
{
"callingPartyNumber", "skinny.callingPartyNumber", FT_STRING, BASE_NONE, NULL, 0x0,
"Calling Party Number", HFILL }},
{&hf_skinny_cause,
{
"cause", "skinny.cause", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &SubscribeCause_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_cdpnVoiceMailbox,
{
"cdpnVoiceMailbox", "skinny.cdpnVoiceMailbox", FT_STRING, BASE_NONE, NULL, 0x0,
"Called Party Voicemail Box Number", HFILL }},
{&hf_skinny_cgpnVoiceMailbox,
{
"cgpnVoiceMailbox", "skinny.cgpnVoiceMailbox", FT_STRING, BASE_NONE, NULL, 0x0,
"Calling Party Voicemail Box Number", HFILL }},
{&hf_skinny_command,
{
"command", "skinny.command", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &MiscCommandType_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_compressionType,
{
"compressionType", "skinny.compressionType", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &Media_PayloadType_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_conferenceName,
{
"conferenceName", "skinny.conferenceName", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_configVersionStamp,
{
"configVersionStamp", "skinny.configVersionStamp", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_data,
{
"Statistics", "skinny.data", FT_STRING, BASE_NONE, NULL, 0x0,
"variable field size (max: 600]", HFILL }},
{&hf_skinny_dataCapabilityDirection,
{
"dataCapabilityDirection", "skinny.dataCapabilityDirection", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &TransmitOrReceive_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_dateTemplate,
{
"dateTemplate", "skinny.dateTemplate", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_delete_conf_result,
{
"delete_conf_result", "skinny.delete.conf.result", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &DeleteConfResult_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_deviceType,
{
"Device Type", "skinny.deviceType", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &DeviceType_ext, 0x0,
"Device Type of this phone / appliance", HFILL }},
{&hf_skinny_dialedNumber,
{
"dialedNumber", "skinny.dialedNumber", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_direction,
{
"direction", "skinny.direction", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &RSVPDirection_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_directoryNum,
{
"directoryNum", "skinny.directoryNum", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_ecValue,
{
"ecValue", "skinny.ecValue", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &Media_EchoCancellation_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_encryptionCapability,
{
"encryptionCapability", "skinny.encryptionCapability", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &Media_Encryption_Capability_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_errorCode,
{
"errorCode", "skinny.errorCode", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &QoSErrorCode_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_featureID,
{
"featureID", "skinny.featureID", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &ButtonType_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_featureTextLabel,
{
"featureTextLabel", "skinny.featureTextLabel", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_firmwareLoadName,
{
"firmwareLoadName", "skinny.firmwareLoadName", FT_STRING, BASE_NONE, NULL, 0x0,
"Firmware Load Name", HFILL }},
{&hf_skinny_forwardAllDirnum,
{
"forwardAllDirnum", "skinny.forwardAllDirnum", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_forwardBusyDirnum,
{
"forwardBusyDirnum", "skinny.forwardBusyDirnum", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_forwardNoAnswerlDirnum,
{
"forwardNoAnswerlDirnum", "skinny.forwardNoAnswerlDirnum", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_g723BitRate,
{
"g723BitRate", "skinny.g723BitRate", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &Media_G723BitRate_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_headsetStatus,
{
"headsetStatus", "skinny.headsetStatus", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &HeadsetMode_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_ipAddressType,
{
"ipAddressType", "skinny.ipAddressType", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &IpAddrType_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_ipAddressingMode,
{
"ipAddressingMode", "skinny.ipAddressingMode", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &IpAddrMode_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_kpButton,
{
"kpButton", "skinny.kpButton", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &KeyPadButton_ext, 0x0,
"KeyPad Button which was Pressed", HFILL }},
{&hf_skinny_lampMode,
{
"lampMode", "skinny.lampMode", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &LampMode_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_lastRedirectingParty,
{
"lastRedirectingParty", "skinny.lastRedirectingParty", FT_STRING, BASE_NONE, NULL, 0x0,
"Last Redirecting Party Number", HFILL }},
{&hf_skinny_lastRedirectingPartyName,
{
"lastRedirectingPartyName", "skinny.lastRedirectingPartyName", FT_STRING, BASE_NONE, NULL, 0x0,
"Last Redirecting Party Name", HFILL }},
{&hf_skinny_lastRedirectingVoiceMailbox,
{
"lastRedirectingVoiceMailbox", "skinny.lastRedirectingVoiceMailbox", FT_STRING, BASE_NONE, NULL, 0x0,
"Last Redirecting Parties Voicemail Box Number", HFILL }},
{&hf_skinny_layouts,
{
"layouts", "skinny.layouts", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &Layout_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_lineDirNumber,
{
"lineDirNumber", "skinny.lineDirNumber", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_lineFullyQualifiedDisplayName,
{
"lineFullyQualifiedDisplayName", "skinny.lineFullyQualifiedDisplayName", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_lineTextLabel,
{
"lineTextLabel", "skinny.lineTextLabel", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_locationInfo,
{
"locationInfo", "skinny.locationInfo", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_mediaPathCapabilities,
{
"mediaPathCapabilities", "skinny.mediaPathCapabilities", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &MediaPathCapabilities_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_mediaPathEvent,
{
"mediaPathEvent", "skinny.mediaPathEvent", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &MediaPathEvent_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_mediaPathID,
{
"mediaPathID", "skinny.mediaPathID", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &MediaPathID_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_mediaReceptionStatus,
{
"mediaReceptionStatus", "skinny.mediaReceptionStatus", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &MediaStatus_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_mediaTransmissionStatus,
{
"mediaTransmissionStatus", "skinny.mediaTransmissionStatus", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &MediaStatus_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_mediaTransportType,
{
"mediaTransportType", "skinny.mediaTransportType", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &MediaTransportType_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_mediaType,
{
"mediaType", "skinny.mediaType", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &MediaType_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_micMode,
{
"micMode", "skinny.micMode", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &MicrophoneMode_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_modify_conf_result,
{
"modify_conf_result", "skinny.modify.conf.result", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &ModifyConfResult_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_multicastReceptionStatus,
{
"multicastReceptionStatus", "skinny.multicastReceptionStatus", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &MulticastMediaReceptionStatus_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_multimediaReceptionStatus,
{
"multimediaReceptionStatus", "skinny.multimediaReceptionStatus", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &OpenReceiveChanStatus_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_multimediaTransmissionStatus,
{
"multimediaTransmissionStatus", "skinny.multimediaTransmissionStatus", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &MediaStatus_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_mwiControlNumber,
{
"mwiControlNumber", "skinny.mwiControlNumber", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_mwiTargetNumber,
{
"mwiTargetNumber", "skinny.mwiTargetNumber", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_mwi_notification_result,
{
"mwi_notification_result", "skinny.mwi.notification.result", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &MwiNotificationResult_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_notify,
{
"notify", "skinny.notify", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_originalCalledParty,
{
"originalCalledParty", "skinny.originalCalledParty", FT_STRING, BASE_NONE, NULL, 0x0,
"Original Called Party Number", HFILL }},
{&hf_skinny_originalCalledPartyName,
{
"originalCalledPartyName", "skinny.originalCalledPartyName", FT_STRING, BASE_NONE, NULL, 0x0,
"Original Called Party Name", HFILL }},
{&hf_skinny_originalCdpnVoiceMailbox,
{
"originalCdpnVoiceMailbox", "skinny.originalCdpnVoiceMailbox", FT_STRING, BASE_NONE, NULL, 0x0,
"Original Called Party Voicemail Box Number", HFILL }},
{&hf_skinny_participantName,
{
"participantName", "skinny.participantName", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_participantNumber,
{
"participantNumber", "skinny.participantNumber", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_passThruData,
{
"passThruData", "skinny.passThruData", FT_STRING, BASE_NONE, NULL, 0x0,
"variable field size (max: 2000]", HFILL }},
{&hf_skinny_payloadCapability,
{
"payloadCapability", "skinny.payloadCapability", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &Media_PayloadType_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_portHandlingFlag,
{
"portHandlingFlag", "skinny.portHandlingFlag", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &PortHandling_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_privacy,
{
"privacy", "skinny.privacy", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &CallPrivacy_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_promptStatus,
{
"promptStatus", "skinny.promptStatus", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_recording_status,
{
"recording_status", "skinny.recording.status", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &RecordingStatus_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_requestedIpAddrType,
{
"requestedIpAddrType", "skinny.requestedIpAddrType", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &IpAddrType_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_resetType,
{
"resetType", "skinny.resetType", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &DeviceResetType_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_resourceType,
{
"resourceType", "skinny.resourceType", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &ResourceType_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_result,
{
"result", "skinny.result", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &CreateConfResult_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_resvStyle,
{
"resvStyle", "skinny.resvStyle", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &ResvStyle_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_ringDuration,
{
"ringDuration", "skinny.ringDuration", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &RingDuration_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_ringMode,
{
"ringMode", "skinny.ringMode", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &RingMode_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_rsvpErrorCode,
{
"rsvpErrorCode", "skinny.rsvpErrorCode", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &RSVPErrorCode_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_sequenceFlag,
{
"sequenceFlag", "skinny.sequenceFlag", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &SequenceFlag_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_serverName,
{
"serverName", "skinny.serverName", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_serviceURL,
{
"serviceURL", "skinny.serviceURL", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_serviceURLDisplayName,
{
"serviceURLDisplayName", "skinny.serviceURLDisplayName", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_sessionType,
{
"sessionType", "skinny.sessionType", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &SessionType_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_softKeyEvent,
{
"softKeyEvent", "skinny.softKeyEvent", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &SoftKeyEvent_ext, 0x0,
"SoftKey Event", HFILL }},
{&hf_skinny_softKeyInfoIndex,
{
"softKeyInfoIndex", "skinny.softKeyInfoIndex", FT_UINT16, BASE_HEX | BASE_EXT_STRING, &SoftKeyInfoIndex_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_softKeyLabel,
{
"softKeyLabel", "skinny.softKeyLabel", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_softKeySetIndex,
{
"softKeySetIndex", "skinny.softKeySetIndex", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &SoftKeySet_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_softKeyTemplateIndex,
{
"softKeyTemplateIndex", "skinny.softKeyTemplateIndex", FT_UINT8, BASE_HEX | BASE_EXT_STRING, &SoftKeyTemplateIndex_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_speakerMode,
{
"speakerMode", "skinny.speakerMode", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &SpeakerMode_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_speedDialDirNumber,
{
"speedDialDirNumber", "skinny.speedDialDirNumber", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_speedDialDisplayName,
{
"speedDialDisplayName", "skinny.speedDialDisplayName", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_ssValue,
{
"ssValue", "skinny.ssValue", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &Media_SilenceSuppression_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_statsProcessingMode,
{
"Stats Processing Mode", "skinny.statsProcessingMode", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &StatsProcessingType_ext, 0x0,
"What to do after you send the stats", HFILL }},
{&hf_skinny_status,
{
"status", "skinny.status", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &DeviceUnregisterStatus_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_stimulus,
{
"stimulus", "skinny.stimulus", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &DeviceStimulus_ext, 0x0,
"Device Stimulus", HFILL }},
{&hf_skinny_subAppID,
{
"subAppID", "skinny.subAppID", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_subscriptionFeatureID,
{
"subscriptionFeatureID", "skinny.subscriptionFeatureID", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &SubscriptionFeatureID_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_subscriptionID,
{
"subscriptionID", "skinny.subscriptionID", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_text,
{
"text", "skinny.text", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_tone,
{
"tone", "skinny.tone", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &DeviceTone_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_toneAnnouncement,
{
"toneAnnouncement", "skinny.toneAnnouncement", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &DeviceTone_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_tone_output_direction,
{
"tone_output_direction", "skinny.tone.output.direction", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &ToneOutputDirection_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_unRegReasonCode,
{
"unRegReasonCode", "skinny.unRegReasonCode", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &UnRegReasonCode_ext, 0x0,
NULL, HFILL }},
{&hf_skinny_unknownString_0159,
{
"unknownString_0159", "skinny.unknownString.0159", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_userName,
{
"userName", "skinny.userName", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_vendorID,
{
"vendorID", "skinny.vendorID", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_version,
{
"version", "skinny.version", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_versionStr,
{
"versionStr", "skinny.versionStr", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_skinny_videoCapabilityDirection,
{
"videoCapabilityDirection", "skinny.videoCapabilityDirection", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &TransmitOrReceive_ext, 0x0,
NULL, HFILL }},
};
/* Setup protocol subtree array */
static int *ett[] = {
&ett_skinny,
&ett_skinny_tree,
};
module_t *skinny_module;
/* Register the protocol name and description */
proto_skinny = proto_register_protocol("Skinny Client Control Protocol",
"SKINNY", "skinny");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_skinny, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
skinny_module = prefs_register_protocol(proto_skinny, NULL);
prefs_register_bool_preference(skinny_module, "desegment",
"Reassemble SKINNY messages spanning multiple TCP segments",
"Whether the SKINNY dissector should reassemble messages spanning multiple TCP segments."
" To use this option, you must also enable"
" \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
&global_skinny_desegment);
skinny_handle = register_dissector("skinny", dissect_skinny, proto_skinny);
skinny_tap = register_tap("skinny");
}
void
proto_reg_handoff_skinny(void)
{
/* Skinny content type and internet media type used by other dissectors are the same */
xml_handle = find_dissector_add_dependency("xml", proto_skinny);
dissector_add_uint_with_preference("tcp.port", TCP_PORT_SKINNY, skinny_handle);
ssl_dissector_add(SSL_PORT_SKINNY, skinny_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|
Inno Setup Script
|
wireshark/epan/dissectors/packet-skinny.c.in
|
/* Do not modify this file. Changes will be overwritten */
/* Generated Automatically */
/* packet-skinny.c */
/* packet-skinny.c
* Dissector for the Skinny Client Control Protocol
* (The "D-Channel"-Protocol for Cisco Systems' IP-Phones)
*
* Author: Diederik de Groot <[email protected]>, Copyright 2014
* Rewritten to support newer skinny protocolversions (V0-V22)
* Based on previous versions/contributions:
* - Joerg Mayer <[email protected]>, Copyright 2001
* - Paul E. Erkkila ([email protected]) - fleshed out the decode
* skeleton to report values for most message/message fields.
* Much help from Guy Harris on figuring out the wireshark api.
* - packet-aim.c by Ralf Hoelzer <[email protected]>, Copyright 2000
* - Wireshark - Network traffic analyzer,
* By Gerald Combs <[email protected]>, Copyright 1998
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* [[[cog
#
# Using Cog.py Inplace Code Generator
#
# Dependencies:
# - python2.x
# - cog.py: (pip install cogapp / http://nedbatchelder.com/code/cog/)
# - python.xml
# - python.xml.sax
#
cog.out('/*\n')
cog.out(' * Generated automatically Using (from wireshark base directory):\n')
cog.out(' * cog.py -D xmlfile=tools/SkinnyProtocolOptimized.xml -d -c -o epan/dissectors/packet-skinny.c epan/dissectors/packet-skinny.c.in\n')
cog.out(' */\n')
/*]]]*/
/*[[[end]]]*/
/* c-basic-offset: 2; tab-width: 8; indent-tabs-mode: nil
* vi: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/conversation.h>
#include <epan/wmem_scopes.h>
#include <epan/to_str.h>
#include <epan/reassemble.h>
#include <epan/tap.h>
#include <epan/ptvcursor.h>
#include "packet-rtp.h"
#include "packet-tcp.h"
#include "packet-tls.h"
#include "packet-skinny.h"
/* un-comment the following as well as this line in conversation.c, to enable debug printing */
/* #define DEBUG_CONVERSATION */
#include "conversation_debug.h"
void proto_register_skinny(void);
void proto_reg_handoff_skinny(void);
#define TCP_PORT_SKINNY 2000 /* Not IANA registered */
#define SSL_PORT_SKINNY 2443 /* IANA assigned to PowerClient Central Storage Facility */
#define BASIC_MSG_TYPE 0x00
#define V10_MSG_TYPE 0x0A
#define V11_MSG_TYPE 0x0B
#define V15_MSG_TYPE 0x0F
#define V16_MSG_TYPE 0x10
#define V17_MSG_TYPE 0x11
#define V18_MSG_TYPE 0x12
#define V19_MSG_TYPE 0x13
#define V20_MSG_TYPE 0x14
#define V21_MSG_TYPE 0x15
#define V22_MSG_TYPE 0x16
static const value_string header_version[] = {
{ BASIC_MSG_TYPE, "Basic" },
{ V10_MSG_TYPE, "V10" },
{ V11_MSG_TYPE, "V11" },
{ V15_MSG_TYPE, "V15" },
{ V16_MSG_TYPE, "V16" },
{ V17_MSG_TYPE, "V17" },
{ V18_MSG_TYPE, "V18" },
{ V19_MSG_TYPE, "V19" },
{ V20_MSG_TYPE, "V20" },
{ V21_MSG_TYPE, "V21" },
{ V22_MSG_TYPE, "V22" },
{ 0 , NULL }
};
/* Declare MessageId */
/* [[[cog
import sys
sys.path.append('tools/')
import parse_xml2skinny_dissector as xml2skinny
global skinny
global message_dissector_functions
message_dissector_functions = ''
skinny = xml2skinny.xml2obj(xmlfile)
cog.out('static const value_string message_id[] = {\n')
for message in skinny.message:
message_dissector_functions += '%s' %message.dissect()
cog.out(' { %s, "%s" },\n' %(message.opcode, message.name.replace('Message','')))
cog.out(' {0 , NULL}\n')
cog.out('};\n')
cog.out('static value_string_ext message_id_ext = VALUE_STRING_EXT_INIT(message_id);\n')
/*]]]*/
/*[[[end]]]*/
/* Declare Enums and Defines */
/* [[[cog
for enum in skinny.enum:
name = enum.name[0].upper() + enum.name[1:]
if enum.define == "yes":
for entries in enum.entries:
for entry in sorted(entries.entry, key=lambda x: int(x['value'],0)):
if entries.type is not None:
cog.out('#define {0:38} 0x{1:05x} /* {2} */\n' .format(entry.name.upper(), int(entry.value,0), entries.type))
else:
cog.out('#define {0:38} 0x{1:05x}\n' .format(entry.name.upper(), int(entry.value,0)))
cog.out('\n')
cog.out('static const value_string %s[] = {\n' %(name))
for entries in enum.entries:
for entry in sorted(entries.entry, key=lambda x: int(x['value'],0)):
if enum.define == "yes":
cog.out(' { %s, "%s" },\n' %(entry.name.upper(), entry.text))
else:
cog.out(' { 0x%05x, "%s" },\n' %(int(entry.value,0), entry.text))
cog.out(' { 0x00000, NULL }\n')
cog.out('};\n')
cog.out('static value_string_ext %s_ext = VALUE_STRING_EXT_INIT(%s);\n\n' %(name, name))
/*]]]*/
/*[[[end]]]*/
/* Staticly Declared Variables */
static int proto_skinny = -1;
static int hf_skinny_messageId = -1;
static int hf_skinny_data_length = -1;
static int hf_skinny_hdr_version = -1;
static int hf_skinny_xmlData = -1;
static int hf_skinny_ipv4or6 = -1;
static int hf_skinny_response_in = -1;
static int hf_skinny_response_to = -1;
static int hf_skinny_response_time = -1;
/* [[[cog
for key in sorted(xml2skinny.fieldsArray.keys()):
cog.out('static int hf_skinny_%s = -1;\n' %key)
]]]*/
/*[[[end]]]*/
static dissector_handle_t xml_handle;
/* Initialize the subtree pointers */
static int ett_skinny = -1;
static int ett_skinny_tree = -1;
/* preference globals */
static gboolean global_skinny_desegment = true;
/* tap register id */
static int skinny_tap = -1;
/* skinny protocol tap info */
#define MAX_SKINNY_MESSAGES_IN_PACKET 10
static skinny_info_t pi_arr[MAX_SKINNY_MESSAGES_IN_PACKET];
static int pi_current = 0;
static skinny_info_t *si;
dissector_handle_t skinny_handle;
/* Get the length of a single SKINNY PDU */
static unsigned
get_skinny_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
{
uint32_t hdr_data_length;
/* Get the length of the SKINNY packet. */
hdr_data_length = tvb_get_letohl(tvb, offset);
/* That length doesn't include the length of the header itself. */
return hdr_data_length + 8;
}
static void
dissect_skinny_xml(ptvcursor_t *cursor, int hfindex, packet_info *pinfo, uint32_t length, uint32_t maxlength)
{
proto_item *item = NULL;
proto_tree *subtree = NULL;
proto_tree *tree = ptvcursor_tree(cursor);
uint32_t offset = ptvcursor_current_offset(cursor);
tvbuff_t *tvb = ptvcursor_tvbuff(cursor);
tvbuff_t *next_tvb;
if (length == 0) {
length = tvb_strnlen(tvb, offset, -1);
}
if (length >= maxlength) {
length = maxlength;
}
ptvcursor_add_no_advance(cursor, hfindex, length, ENC_ASCII);
item = proto_tree_add_item(tree, hf_skinny_xmlData, tvb, offset, length, ENC_ASCII);
subtree = proto_item_add_subtree(item, 0);
next_tvb = tvb_new_subset_length_caplen(tvb, offset, length, -1);
if (xml_handle != NULL) {
call_dissector(xml_handle, next_tvb, pinfo, subtree);
}
ptvcursor_advance(cursor, maxlength);
}
static void
dissect_skinny_ipv4or6(ptvcursor_t *cursor, int hfindex_ipv4, int hfindex_ipv6)
{
uint32_t ipversion = 0;
uint32_t offset = ptvcursor_current_offset(cursor);
tvbuff_t *tvb = ptvcursor_tvbuff(cursor);
uint32_t hdr_version = tvb_get_letohl(tvb, 4);
/* ProtocolVersion > 18 include and extra field to declare IPv4 (0) / IPv6 (1) */
if (hdr_version >= V17_MSG_TYPE) {
ipversion = tvb_get_letohl(tvb, offset);
ptvcursor_add(cursor, hf_skinny_ipv4or6, 4, ENC_LITTLE_ENDIAN);
}
if (ipversion == IPADDRTYPE_IPV4) {
ptvcursor_add(cursor, hfindex_ipv4, 4, ENC_BIG_ENDIAN);
if (hdr_version >= V17_MSG_TYPE) {
/* skip over the extra room for ipv6 addresses */
ptvcursor_advance(cursor, 12);
}
} else if (ipversion == IPADDRTYPE_IPV6 || ipversion == IPADDRTYPE_IPV4_V6) {
ptvcursor_add(cursor, hfindex_ipv6, 16, ENC_NA);
} else {
/* Invalid : skip over ipv6 space completely */
ptvcursor_advance(cursor, 16);
}
}
/* Reads address to provided variable */
static void
read_skinny_ipv4or6(ptvcursor_t *cursor, address *media_addr)
{
uint32_t ipversion = IPADDRTYPE_IPV4;
uint32_t offset = ptvcursor_current_offset(cursor);
uint32_t offset2 = 0;
tvbuff_t *tvb = ptvcursor_tvbuff(cursor);
uint32_t hdr_version = tvb_get_letohl(tvb, 4);
/* ProtocolVersion > 18 include and extra field to declare IPv4 (0) / IPv6 (1) */
if (hdr_version >= V17_MSG_TYPE) {
ipversion = tvb_get_letohl(tvb, offset);
offset2 = 4;
}
if (ipversion == IPADDRTYPE_IPV4) {
set_address_tvb(media_addr, AT_IPv4, 4, tvb, offset+offset2);
} else if (ipversion == IPADDRTYPE_IPV6 || ipversion == IPADDRTYPE_IPV4_V6) {
set_address_tvb(media_addr, AT_IPv6, 16, tvb, offset+offset2);
} else {
clear_address(media_addr);
}
}
/**
* Parse a displayLabel string and check if it is using any embedded labels, if so lookup the label and add a user readable translation to the item_tree
*/
static void
dissect_skinny_displayLabel(ptvcursor_t *cursor, packet_info *pinfo, int hfindex, int length)
{
proto_item *item = NULL;
proto_tree *tree = ptvcursor_tree(cursor);
uint32_t offset = ptvcursor_current_offset(cursor);
tvbuff_t *tvb = ptvcursor_tvbuff(cursor);
wmem_strbuf_t *wmem_new = NULL;
char *disp_string = NULL;
const char *replacestr = NULL;
bool show_replaced_str = false;
int x = 0;
if (length == 0) {
length = tvb_strnlen(tvb, offset, -1);
if (length == -1) {
/* did not find end of string */
length = tvb_captured_length_remaining(tvb, offset);
}
}
item = proto_tree_add_item(tree, hfindex, tvb, offset, length, ENC_ASCII);
wmem_new = wmem_strbuf_new_sized(pinfo->pool, length + 1);
disp_string = (char*) wmem_alloc(pinfo->pool, length + 1);
disp_string[length] = '\0';
tvb_memcpy(tvb, (void*)disp_string, offset, length);
for (x = 0; x < length && disp_string[x] != '\0'; x++) {
replacestr = NULL;
if (x + 1 < length) {
if (disp_string[x] == '\36') {
replacestr = try_val_to_str_ext(disp_string[x + 1], &DisplayLabels_36_ext);
} else if (disp_string[x] == '\200') {
replacestr = try_val_to_str_ext(disp_string[x + 1], &DisplayLabels_200_ext);
}
}
if (replacestr) {
x++; /* swallow replaced characters */
wmem_strbuf_append(wmem_new, replacestr);
show_replaced_str = true;
} else if (disp_string[x] & 0x80) {
wmem_strbuf_append_unichar_repl(wmem_new);
} else {
wmem_strbuf_append_c(wmem_new, disp_string[x]);
}
}
if (show_replaced_str) {
si->additionalInfo = ws_strdup_printf("\"%s\"", wmem_strbuf_get_str(wmem_new));
proto_item_append_text(item, " => \"%s\"" , wmem_strbuf_get_str(wmem_new));
}
ptvcursor_advance(cursor, length);
}
/*** Request / Response helper functions */
static void skinny_reqrep_add_request(ptvcursor_t *cursor, packet_info * pinfo, skinny_conv_info_t * skinny_conv, const int request_key)
{
proto_tree *tree = ptvcursor_tree(cursor);
tvbuff_t *tvb = ptvcursor_tvbuff(cursor);
skinny_req_resp_t *req_resp = NULL;
if (!PINFO_FD_VISITED(pinfo)) {
req_resp = wmem_new0(wmem_file_scope(), skinny_req_resp_t);
req_resp->request_frame = pinfo->num;
req_resp->response_frame = 0;
req_resp->request_time = pinfo->abs_ts;
wmem_map_insert(skinny_conv->pending_req_resp, GINT_TO_POINTER(request_key), (void *)req_resp);
DPRINT(("SKINNY: setup_request: frame=%d add key=%d to map\n", pinfo->num, request_key));
}
req_resp = (skinny_req_resp_t *) wmem_map_lookup(skinny_conv->requests, GUINT_TO_POINTER(pinfo->num));
if (req_resp && req_resp->response_frame) {
DPRINT(("SKINNY: show request in tree: frame/key=%d\n", pinfo->num));
proto_item *it;
it = proto_tree_add_uint(tree, hf_skinny_response_in, tvb, 0, 0, req_resp->response_frame);
proto_item_set_generated(it);
} else {
DPRINT(("SKINNY: no request found for frame/key=%d\n", pinfo->num));
}
}
static void skinny_reqrep_add_response(ptvcursor_t *cursor, packet_info * pinfo, skinny_conv_info_t * skinny_conv, const int request_key)
{
proto_tree *tree = ptvcursor_tree(cursor);
tvbuff_t *tvb = ptvcursor_tvbuff(cursor);
skinny_req_resp_t *req_resp = NULL;
if (!PINFO_FD_VISITED(pinfo)) {
req_resp = (skinny_req_resp_t *) wmem_map_remove(skinny_conv->pending_req_resp, GINT_TO_POINTER(request_key));
if (req_resp) {
DPRINT(("SKINNY: match request:%d with response:%d for key=%d\n", req_resp->request_frame, pinfo->num, request_key));
req_resp->response_frame = pinfo->num;
wmem_map_insert(skinny_conv->requests, GUINT_TO_POINTER(req_resp->request_frame), (void *)req_resp);
wmem_map_insert(skinny_conv->responses, GUINT_TO_POINTER(pinfo->num), (void *)req_resp);
} else {
DPRINT(("SKINNY: no match found for response frame=%d and key=%d\n", pinfo->num, request_key));
}
}
req_resp = (skinny_req_resp_t *) wmem_map_lookup(skinny_conv->responses, GUINT_TO_POINTER(pinfo->num));
if (req_resp && req_resp->request_frame) {
DPRINT(("SKINNY: show response in tree: frame/key=%d\n", pinfo->num));
proto_item *it;
nstime_t ns;
it = proto_tree_add_uint(tree, hf_skinny_response_to, tvb, 0, 0, req_resp->request_frame);
proto_item_set_generated(it);
nstime_delta(&ns, &pinfo->abs_ts, &req_resp->request_time);
it = proto_tree_add_time(tree, hf_skinny_response_time, tvb, 0, 0, &ns);
proto_item_set_generated(it);
} else {
DPRINT(("SKINNY: no response found for frame/key=%d\n", pinfo->num));
}
}
/*** Messages Handlers ***/
/* [[[cog
cog.out(message_dissector_functions)
]]]*/
/*[[[end]]]*/
typedef void (*message_handler) (ptvcursor_t * cursor, packet_info *pinfo, skinny_conv_info_t * skinny_conv);
typedef struct _skinny_opcode_map_t {
uint32_t opcode;
message_handler handler;
skinny_message_type_t type;
const char *name;
} skinny_opcode_map_t;
/* Messages Handler Array */
/* [[[cog
cog.out('static const skinny_opcode_map_t skinny_opcode_map[] = {\n')
for message in skinny.message:
msg_type = "SKINNY_MSGTYPE_EVENT"
if message.msgtype == "request":
msg_type = "SKINNY_MSGTYPE_REQUEST"
if message.msgtype == "response" and message.request is not None:
msg_type = "SKINNY_MSGTYPE_RESPONSE"
cog.out(' {%-6s, %-47s, %-24s, "%s"},\n' %(message.opcode, message.gen_handler(), msg_type, message.name))
cog.out('};\n')
]]]*/
/*[[[end]]]*/
/* Dissect a single SKINNY PDU */
static int dissect_skinny_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
unsigned offset = 0;
/*bool is_video = false;*/ /* FIX ME: need to indicate video or not */
ptvcursor_t* cursor;
conversation_t *conversation;
skinny_conv_info_t *skinny_conv;
const skinny_opcode_map_t *opcode_entry = NULL;
/* Header fields */
uint32_t hdr_data_length;
uint32_t hdr_version;
uint32_t hdr_opcode;
uint16_t i;
/* Set up structures we will need to add the protocol subtree and manage it */
proto_tree *skinny_tree = NULL;
proto_item *ti = NULL;
/* Initialization */
hdr_data_length = tvb_get_letohl(tvb, 0);
hdr_version = tvb_get_letohl(tvb, 4);
hdr_opcode = tvb_get_letohl(tvb, 8);
for (i = 0; i < sizeof(skinny_opcode_map)/sizeof(skinny_opcode_map_t) ; i++) {
if (skinny_opcode_map[i].opcode == hdr_opcode) {
opcode_entry = &skinny_opcode_map[i];
}
}
conversation = find_or_create_conversation(pinfo);
skinny_conv = (skinny_conv_info_t *)conversation_get_proto_data(conversation, proto_skinny);
if (!skinny_conv) {
skinny_conv = wmem_new0(wmem_file_scope(), skinny_conv_info_t);
//skinny_conv->pending_req_resp = wmem_map_new(wmem_file_scope(), wmem_str_hash, g_str_equal);
skinny_conv->pending_req_resp = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
skinny_conv->requests = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
skinny_conv->responses = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
skinny_conv->lineId = -1;
skinny_conv->mtype = SKINNY_MSGTYPE_EVENT;
conversation_add_proto_data(conversation, proto_skinny, skinny_conv);
}
/* Initialise stat info for passing to tap */
/* WIP: will be (partially) replaced in favor of conversionation, dependents: ui/voip_calls.c */
pi_current++;
if (pi_current == MAX_SKINNY_MESSAGES_IN_PACKET)
{
/* Overwrite info in first struct if run out of space... */
pi_current = 0;
}
si = &pi_arr[pi_current];
si->messId = hdr_opcode;
si->messageName = val_to_str_ext(hdr_opcode, &message_id_ext, "0x%08X (Unknown)");
si->callId = 0;
si->lineId = 0;
si->passThroughPartyId = 0;
si->callState = 0;
g_free(si->callingParty);
si->callingParty = NULL;
g_free(si->calledParty);
si->calledParty = NULL;
si->mediaReceptionStatus = -1;
si->mediaTransmissionStatus = -1;
si->multimediaReceptionStatus = -1;
si->multimediaTransmissionStatus = -1;
si->multicastReceptionStatus = -1;
g_free(si->additionalInfo);
si->additionalInfo = NULL;
col_add_fstr(pinfo->cinfo, COL_INFO,"%s ", si->messageName);
col_set_fence(pinfo->cinfo, COL_INFO);
if (tree) {
ti = proto_tree_add_item(tree, proto_skinny, tvb, offset, hdr_data_length+8, ENC_NA);
skinny_tree = proto_item_add_subtree(ti, ett_skinny);
}
if (opcode_entry && opcode_entry->type != SKINNY_MSGTYPE_EVENT) {
skinny_conv->mtype = opcode_entry->type;
if (opcode_entry->type == SKINNY_MSGTYPE_REQUEST) {
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SKINNY/REQ");
} else {
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SKINNY/RESP");
}
}
if (skinny_tree) {
proto_tree_add_uint(skinny_tree, hf_skinny_data_length, tvb, offset , 4, hdr_data_length);
proto_tree_add_uint(skinny_tree, hf_skinny_hdr_version, tvb, offset+4, 4, hdr_version);
proto_tree_add_uint(skinny_tree, hf_skinny_messageId, tvb, offset+8, 4, hdr_opcode );
}
offset += 12;
cursor = ptvcursor_new(pinfo->pool, skinny_tree, tvb, offset);
if (opcode_entry && opcode_entry->handler) {
opcode_entry->handler(cursor, pinfo, skinny_conv);
}
ptvcursor_free(cursor);
tap_queue_packet(skinny_tap, pinfo, si);
return tvb_captured_length(tvb);
}
/* Code to actually dissect the packets */
static int
dissect_skinny(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
/* The general structure of a packet: {IP-Header|TCP-Header|n*SKINNY}
* SKINNY-Packet: {Header(Size, Reserved)|Data(MessageID, Message-Data)}
*/
/* Header fields */
uint32_t hdr_data_length;
uint32_t hdr_version;
/* check, if this is really an SKINNY packet, they start with a length + 0 */
if (tvb_captured_length(tvb) < 8)
{
return 0;
}
/* get relevant header information */
hdr_data_length = tvb_get_letohl(tvb, 0);
hdr_version = tvb_get_letohl(tvb, 4);
/* data_size = MIN(8+hdr_data_length, tvb_length(tvb)) - 0xC; */
if (
(hdr_data_length < 4) ||
((hdr_version != BASIC_MSG_TYPE) &&
(hdr_version != V10_MSG_TYPE) &&
(hdr_version != V11_MSG_TYPE) &&
(hdr_version != V15_MSG_TYPE) &&
(hdr_version != V16_MSG_TYPE) &&
(hdr_version != V17_MSG_TYPE) &&
(hdr_version != V18_MSG_TYPE) &&
(hdr_version != V19_MSG_TYPE) &&
(hdr_version != V20_MSG_TYPE) &&
(hdr_version != V21_MSG_TYPE) &&
(hdr_version != V22_MSG_TYPE))
)
{
/* Not an SKINNY packet, just happened to use the same port */
return 0;
}
/* Make entries in Protocol column and Info column on summary display */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SKINNY");
col_set_str(pinfo->cinfo, COL_INFO, "Skinny Client Control Protocol");
tcp_dissect_pdus(tvb, pinfo, tree, global_skinny_desegment, 4, get_skinny_pdu_len, dissect_skinny_pdu, data);
return tvb_captured_length(tvb);
}
/* Register the protocol with Wireshark */
void
proto_register_skinny(void)
{
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_skinny_data_length,
{
"Data length", "skinny.data_length", FT_UINT32, BASE_DEC, NULL, 0x0,
"Number of bytes in the data portion.", HFILL }},
{ &hf_skinny_hdr_version,
{
"Header version", "skinny.hdr_version", FT_UINT32, BASE_HEX, VALS(header_version), 0x0,
NULL, HFILL }},
{ &hf_skinny_messageId,
{
"Message ID", "skinny.messageId", FT_UINT32, BASE_DEC|BASE_EXT_STRING, &message_id_ext, 0x0,
NULL, HFILL }},
{ &hf_skinny_xmlData,
{
"XML data", "skinny.xmlData", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_skinny_ipv4or6,
{
"IPv4or6", "skinny.ipv4or6", FT_UINT32, BASE_DEC|BASE_EXT_STRING, &IpAddrType_ext, 0x0,
NULL, HFILL }},
{ &hf_skinny_response_in,
{
"Response In", "skinny.response_in", FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE), 0x0,
"The response to this SKINNY request is in this frame", HFILL }},
{ &hf_skinny_response_to,
{
"Request In", "skinny.response_to", FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0x0,
"This is a response to the SKINNY request in this frame", HFILL }},
{ &hf_skinny_response_time,
{
"Response Time", "skinny.response_time", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
"The time between the Call and the Reply", HFILL }},
/* [[[cog
for valuestr in sorted(xml2skinny.fieldsArray.values()):
cog.out('%s' %valuestr)
]]]*/
/*[[[end]]]*/
};
/* Setup protocol subtree array */
static int *ett[] = {
&ett_skinny,
&ett_skinny_tree,
};
module_t *skinny_module;
/* Register the protocol name and description */
proto_skinny = proto_register_protocol("Skinny Client Control Protocol",
"SKINNY", "skinny");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_skinny, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
skinny_module = prefs_register_protocol(proto_skinny, NULL);
prefs_register_bool_preference(skinny_module, "desegment",
"Reassemble SKINNY messages spanning multiple TCP segments",
"Whether the SKINNY dissector should reassemble messages spanning multiple TCP segments."
" To use this option, you must also enable"
" \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
&global_skinny_desegment);
skinny_handle = register_dissector("skinny", dissect_skinny, proto_skinny);
skinny_tap = register_tap("skinny");
}
void
proto_reg_handoff_skinny(void)
{
/* Skinny content type and internet media type used by other dissectors are the same */
xml_handle = find_dissector_add_dependency("xml", proto_skinny);
dissector_add_uint_with_preference("tcp.port", TCP_PORT_SKINNY, skinny_handle);
ssl_dissector_add(SSL_PORT_SKINNY, skinny_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-skinny.h
|
/* Do not modify this file. Changes will be overwritten */
/* Generated Automatically */
/* packet-skinny.h */
/* packet-skinny.h
* Dissector for the Skinny Client Control Protocol
* (The "D-Channel"-Protocol for Cisco Systems' IP-Phones)
*
* Author: Diederik de Groot <[email protected]>, Copyright 2014
* Rewritten to support newer skinny protocolversions (V0-V22)
* Based on previous versions/contributions:
* - Joerg Mayer <[email protected]>, Copyright 2001
* - Paul E. Erkkila ([email protected]) - fleshed out the decode
* skeleton to report values for most message/message fields.
* Much help from Guy Harris on figuring out the wireshark api.
* - packet-aim.c by Ralf Hoelzer <[email protected]>, Copyright 2000
* - Wireshark - Network traffic analyzer,
* By Gerald Combs <[email protected]>, Copyright 1998
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
* Generated Automatically Using (from wireshark base directory):
* cog.py -D xmlfile=tools/SkinnyProtocolOptimized.xml -d -c -o epan/dissectors/packet-skinny.h epan/dissectors/packet-skinny.h.in
*/
#include <epan/wmem_scopes.h>
/* request response tracking */
typedef struct _skinny_req_resp_t {
uint32_t request_frame;
uint32_t response_frame;
nstime_t request_time;
} skinny_req_resp_t;
/* begin conversaton info*/
typedef enum _skinny_message_type_t {
SKINNY_MSGTYPE_EVENT = 0,
SKINNY_MSGTYPE_REQUEST = 1,
SKINNY_MSGTYPE_RESPONSE = 2,
} skinny_message_type_t;
typedef struct _skinny_conv_info_t {
skinny_message_type_t mtype;
wmem_map_t * pending_req_resp;
wmem_map_t * requests;
wmem_map_t * responses;
int32_t lineId;
//uint32_t callId;
//uint32_t passThruId;
//uint32_t transactionId;
//uint32_t callState;
} skinny_conv_info_t;
/* end conversation info */
/* Containers for tapping relevant data */
/* WIP: will be (partially) replaced in favor of conversionation, dependents: ui/voip_calls.c */
typedef struct _skinny_info_t
{
uint32_t messId;
uint32_t maxProtocolVersion;
int32_t lineId;
uint32_t callId;
uint32_t passThroughPartyId;
const char * messageName;
uint32_t callState;
bool hasCallInfo;
char * callingParty;
char * calledParty;
int32_t mediaReceptionStatus;
int32_t mediaTransmissionStatus;
int32_t multimediaReceptionStatus;
int32_t multimediaTransmissionStatus;
int32_t multicastReceptionStatus;
//skinny_conv_info_t * skinny_conv;
char * additionalInfo;
} skinny_info_t;
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|
Inno Setup Script
|
wireshark/epan/dissectors/packet-skinny.h.in
|
/* Do not modify this file. Changes will be overwritten */
/* Generated Automatically */
/* packet-skinny.h */
/* packet-skinny.h
* Dissector for the Skinny Client Control Protocol
* (The "D-Channel"-Protocol for Cisco Systems' IP-Phones)
*
* Author: Diederik de Groot <[email protected]>, Copyright 2014
* Rewritten to support newer skinny protocolversions (V0-V22)
* Based on previous versions/contributions:
* - Joerg Mayer <[email protected]>, Copyright 2001
* - Paul E. Erkkila ([email protected]) - fleshed out the decode
* skeleton to report values for most message/message fields.
* Much help from Guy Harris on figuring out the wireshark api.
* - packet-aim.c by Ralf Hoelzer <[email protected]>, Copyright 2000
* - Wireshark - Network traffic analyzer,
* By Gerald Combs <[email protected]>, Copyright 1998
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* [[[cog
#
# Using Cog.py Inplace Code Generator
#
# Dependencies:
# - python2.x
# - cog.py: (pip install cogapp / http://nedbatchelder.com/code/cog/)
# - python.xml
# - python.xml.sax
#
cog.out('/*\n')
cog.out(' * Generated automatically Using (from wireshark base directory):\n')
cog.out(' * cog.py -D xmlfile=tools/SkinnyProtocolOptimized.xml -d -c -o epan/dissectors/packet-skinny.h epan/dissectors/packet-skinny.h.in\n')
cog.out(' */\n')
/*]]]*/
/*[[[end]]]*/
#include <epan/wmem_scopes.h>
/* request response tracking */
typedef struct _skinny_req_resp_t {
uint32_t request_frame;
uint32_t response_frame;
nstime_t request_time;
} skinny_req_resp_t;
/* begin conversaton info*/
typedef enum _skinny_message_type_t {
SKINNY_MSGTYPE_EVENT = 0,
SKINNY_MSGTYPE_REQUEST = 1,
SKINNY_MSGTYPE_RESPONSE = 2,
} skinny_message_type_t;
typedef struct _skinny_conv_info_t {
skinny_message_type_t mtype;
wmem_map_t * pending_req_resp;
wmem_map_t * requests;
wmem_map_t * responses;
int32_t lineId;
//uint32_t callId;
//uint32_t passThruId;
//uint32_t transactionId;
//uint32_t callState;
} skinny_conv_info_t;
/* end conversation info */
/* Containers for tapping relevant data */
/* WIP: will be (partially) replaced in favor of conversionation, dependents: ui/voip_calls.c */
typedef struct _skinny_info_t
{
uint32_t messId;
uint32_t maxProtocolVersion;
int32_t lineId;
uint32_t callId;
uint32_t passThroughPartyId;
const char * messageName;
uint32_t callState;
bool hasCallInfo;
char * callingParty;
char * calledParty;
int32_t mediaReceptionStatus;
int32_t mediaTransmissionStatus;
int32_t multimediaReceptionStatus;
int32_t multimediaTransmissionStatus;
int32_t multicastReceptionStatus;
//skinny_conv_info_t * skinny_conv;
} skinny_info_t;
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|
C
|
wireshark/epan/dissectors/packet-skype.c
|
/* packet-skype.c
* Routines for the disassembly of Skype
*
* Copyright 2009 Joerg Mayer (see AUTHORS file)
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
* Documentation that formed the basis of the packet decoding:
* https://github.com/matthiasbock/OpenSkype/wiki/Skype's-UDP-Format
* For additional information see:
* https://gitlab.com/wireshark/wireshark/-/wikis/Skype
*
* TODO:
* - Authentication
* - TCP
* - Conversation stuff (to obtain external IPs for decryption)
* - Decryption (with given keys)
* - Test CRC check (requires working decryption)
* - Heuristics to reliably detect Skype traffic - most likely impossible
* to implement in Wireshark (see
* https://gitlab.com/wireshark/wireshark/-/wikis/Skype)
* - Improve tests
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/conversation.h>
void proto_register_skype(void);
void proto_reg_handoff_skype(void);
/* Things we may want to remember for a whole conversation */
typedef struct _skype_udp_conv_info_t {
guint32 global_src_ip;
guint32 global_dst_ip;
} skype_udp_conv_info_t;
/* protocol handles */
static int proto_skype = -1;
/* ett handles */
static int ett_skype = -1;
#define SKYPE_SOM_UNK_MASK 0xF0
#define SKYPE_SOM_TYPE_MASK 0x0F
/* hf elements */
/* Start of Message */
static int hf_skype_som_id = -1;
static int hf_skype_som_unk = -1;
static int hf_skype_som_type = -1;
/* Message body */
/* Unknown_0 */
static int hf_skype_unknown_0_unk1 = -1;
/* Payload */
static int hf_skype_payload_iv = -1;
static int hf_skype_payload_crc = -1;
static int hf_skype_payload_enc_data = -1;
/* Resend */
static int hf_skype_ffr_num = -1;
static int hf_skype_ffr_unk1 = -1;
static int hf_skype_ffr_iv = -1;
static int hf_skype_ffr_crc = -1;
static int hf_skype_ffr_enc_data = -1;
/* Nat info */
static int hf_skype_natinfo_srcip = -1;
static int hf_skype_natinfo_dstip = -1;
/* Nat request */
static int hf_skype_natrequest_srcip = -1;
static int hf_skype_natrequest_dstip = -1;
/* Audio */
static int hf_skype_audio_unk1 = -1;
/* Unknown_f */
static int hf_skype_unknown_f_unk1 = -1;
/* Unknown packet type */
static int hf_skype_unknown_packet = -1;
#define PROTO_SHORT_NAME "SKYPE"
#define PROTO_LONG_NAME "SKYPE"
typedef enum {
SKYPE_TYPE_UNKNOWN_0 = 0,
SKYPE_TYPE_PAYLOAD = 2,
SKYPE_TYPE_FFR = 3,
SKYPE_TYPE_NAT_INFO = 5,
SKYPE_TYPE_NAT_REPEAT = 7,
SKYPE_TYPE_AUDIO = 0xd,
SKYPE_TYPE_UNKNOWN_F = 0xf
} skype_type_t;
static const value_string skype_type_vals[] = {
{ SKYPE_TYPE_UNKNOWN_0, "Unknown_0" },
{ SKYPE_TYPE_PAYLOAD, "Payload" },
{ SKYPE_TYPE_FFR, "Fragment/Forward/Resend" },
{ SKYPE_TYPE_NAT_INFO , "NAT info" },
{ SKYPE_TYPE_NAT_REPEAT,"NAT repeat" },
{ SKYPE_TYPE_AUDIO, "Audio" },
{ SKYPE_TYPE_UNKNOWN_F, "Unknown_F" },
{ 0, NULL }
};
static int
dissect_skype_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *ti;
proto_tree *skype_tree = NULL;
guint32 offset = 0;
guint32 packet_length;
guint8 packet_type;
/* XXX: Just until we know how to decode skype over tcp */
packet_type = 255;
packet_length = tvb_captured_length(tvb);
col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_SHORT_NAME);
col_add_str(pinfo->cinfo, COL_INFO, val_to_str(packet_type,
skype_type_vals, "Type 0x%1x"));
if (tree) {
/* Start of message dissection */
ti = proto_tree_add_item(tree, proto_skype, tvb, offset, -1,
ENC_NA);
skype_tree = proto_item_add_subtree(ti, ett_skype);
/* Body dissection */
switch (packet_type) {
default:
proto_tree_add_item(skype_tree, hf_skype_unknown_packet, tvb, offset, -1,
ENC_NA);
offset = packet_length;
break;
}
}
return offset;
}
static int
dissect_skype_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *ti;
proto_tree *skype_tree = NULL;
guint32 offset = 0;
guint32 packet_length;
guint8 packet_type, packet_unk;
conversation_t *conversation = NULL;
skype_udp_conv_info_t *skype_udp_info;
/* look up the conversation */
conversation = find_or_create_conversation(pinfo);
/* if conversation found get the data pointer that you stored */
skype_udp_info = (skype_udp_conv_info_t *)conversation_get_proto_data(conversation, proto_skype);
if (!skype_udp_info) {
/* new conversation create local data structure */
skype_udp_info = wmem_new(wmem_file_scope(), skype_udp_conv_info_t);
skype_udp_info->global_src_ip = 0;
skype_udp_info->global_dst_ip = 0;
conversation_add_proto_data(conversation, proto_skype,
skype_udp_info);
}
/* at this point the conversation data is ready */
packet_type = tvb_get_guint8(tvb, 2) & SKYPE_SOM_TYPE_MASK;
packet_unk = (tvb_get_guint8(tvb, 2) & SKYPE_SOM_UNK_MASK) >> 4;
packet_length = tvb_captured_length(tvb);
col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_SHORT_NAME);
col_add_str(pinfo->cinfo, COL_INFO, val_to_str(packet_type,
skype_type_vals, "Type 0x%1x"));
if (packet_unk) {
col_append_fstr(pinfo->cinfo, COL_INFO, " Unk: %1x", packet_unk);
}
if (tree) {
/* Start of message dissection */
ti = proto_tree_add_item(tree, proto_skype, tvb, offset, -1,
ENC_NA);
skype_tree = proto_item_add_subtree(ti, ett_skype);
proto_tree_add_item(skype_tree, hf_skype_som_id, tvb, offset, 2,
ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(skype_tree, hf_skype_som_unk, tvb, offset, 1,
ENC_BIG_ENDIAN);
proto_tree_add_item(skype_tree, hf_skype_som_type, tvb, offset, 1,
ENC_BIG_ENDIAN);
offset += 1;
/* Body dissection */
switch (packet_type) {
case SKYPE_TYPE_UNKNOWN_0:
proto_tree_add_item(skype_tree, hf_skype_unknown_0_unk1, tvb, offset, -1,
ENC_NA);
offset = packet_length;
break;
case SKYPE_TYPE_PAYLOAD:
proto_tree_add_item(skype_tree, hf_skype_payload_iv, tvb, offset, 4,
ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(skype_tree, hf_skype_payload_crc, tvb, offset, 4,
ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(skype_tree, hf_skype_payload_enc_data, tvb, offset, -1,
ENC_NA);
offset = packet_length;
break;
case SKYPE_TYPE_FFR:
proto_tree_add_item(skype_tree, hf_skype_ffr_num, tvb, offset, 1,
ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(skype_tree, hf_skype_ffr_unk1, tvb, offset, 4,
ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(skype_tree, hf_skype_ffr_iv, tvb, offset, 4,
ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(skype_tree, hf_skype_ffr_crc, tvb, offset, 4,
ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(skype_tree, hf_skype_ffr_enc_data, tvb, offset, -1,
ENC_NA);
offset = packet_length;
break;
case SKYPE_TYPE_NAT_INFO:
proto_tree_add_item(skype_tree, hf_skype_natinfo_srcip, tvb, offset, 4,
ENC_BIG_ENDIAN);
skype_udp_info->global_src_ip = tvb_get_ipv4(tvb, offset);
offset += 4;
proto_tree_add_item(skype_tree, hf_skype_natinfo_dstip, tvb, offset, 4,
ENC_BIG_ENDIAN);
skype_udp_info->global_dst_ip = tvb_get_ipv4(tvb, offset);
offset += 4;
break;
case SKYPE_TYPE_NAT_REPEAT:
proto_tree_add_item(skype_tree, hf_skype_natrequest_srcip, tvb, offset, 4,
ENC_BIG_ENDIAN);
skype_udp_info->global_src_ip = tvb_get_ipv4(tvb, offset);
offset += 4;
proto_tree_add_item(skype_tree, hf_skype_natrequest_dstip, tvb, offset, 4,
ENC_BIG_ENDIAN);
skype_udp_info->global_dst_ip = tvb_get_ipv4(tvb, offset);
offset += 4;
break;
case SKYPE_TYPE_AUDIO:
proto_tree_add_item(skype_tree, hf_skype_audio_unk1, tvb, offset, -1,
ENC_NA);
offset = packet_length;
break;
case SKYPE_TYPE_UNKNOWN_F:
proto_tree_add_item(skype_tree, hf_skype_unknown_f_unk1, tvb, offset, -1,
ENC_NA);
offset = packet_length;
break;
default:
proto_tree_add_item(skype_tree, hf_skype_unknown_packet, tvb, offset, -1,
ENC_NA);
offset = packet_length;
break;
}
}
return offset;
}
static gboolean
test_skype_udp(tvbuff_t *tvb)
{
/* Minimum of 3 bytes, check for valid message type */
if (tvb_captured_length(tvb) > 3)
{
guint8 type = tvb_get_guint8(tvb, 2) & 0xF;
if ( type == 0 ||
/* FIXME: Extend this by minimum or exact length per message type */
type == 2 ||
type == 3 ||
type == 5 ||
type == 7 ||
type == 0xd ||
type == 0xf
)
{
return TRUE;
}
}
return FALSE;
}
static gboolean
dissect_skype_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
if ( !test_skype_udp(tvb) ) {
return FALSE;
}
dissect_skype_udp(tvb, pinfo, tree);
return TRUE;
}
static int
dissect_skype_static(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
/*
* Don't test for valid packet - we only end here when
* the user did a decode-as.
*/
if (pinfo->ptype == PT_UDP) {
return dissect_skype_udp(tvb, pinfo, tree);
} else if (pinfo->ptype == PT_TCP) {
return dissect_skype_tcp(tvb, pinfo, tree);
}
return 0;
}
void
proto_register_skype(void)
{
static hf_register_info hf[] = {
/* Start of message fields */
{ &hf_skype_som_id,
{ "ID", "skype.som.id", FT_UINT16, BASE_HEX, NULL,
0x0, "Message ID", HFILL }},
{ &hf_skype_som_unk,
{ "Unknown", "skype.som.unk", FT_UINT8, BASE_HEX, NULL,
SKYPE_SOM_UNK_MASK, NULL, HFILL }},
{ &hf_skype_som_type,
{ "Type", "skype.som.type", FT_UINT8, BASE_HEX, VALS(skype_type_vals),
SKYPE_SOM_TYPE_MASK, "Message type", HFILL }},
/* Message body */
/* Unknown_0 */
{ &hf_skype_unknown_0_unk1,
{ "Unknown1", "skype.unknown_0.unk1", FT_BYTES, BASE_NONE, NULL,
0x0, NULL, HFILL }},
/* Payload */
{ &hf_skype_payload_iv,
{ "IV", "skype.payload.iv", FT_UINT32, BASE_HEX, NULL,
0x0, NULL, HFILL }},
{ &hf_skype_payload_crc,
{ "CRC", "skype.payload.crc", FT_UINT32, BASE_HEX, NULL,
0x0, NULL, HFILL }},
{ &hf_skype_payload_enc_data,
{ "Enc Data", "skype.payload.encdata", FT_BYTES, BASE_NONE, NULL,
0x0, NULL, HFILL }},
/* Resend */
{ &hf_skype_ffr_num,
{ "Num", "skype.ffr.num", FT_UINT8, BASE_HEX, NULL,
0x0, NULL, HFILL }},
{ &hf_skype_ffr_unk1,
{ "Unk1", "skype.ffr.unk1", FT_UINT32, BASE_HEX, NULL,
0x0, NULL, HFILL }},
{ &hf_skype_ffr_iv,
{ "IV", "skype.ffr.iv", FT_UINT32, BASE_HEX, NULL,
0x0, NULL, HFILL }},
{ &hf_skype_ffr_crc,
{ "CRC", "skype.ffr.crc", FT_UINT32, BASE_HEX, NULL,
0x0, NULL, HFILL }},
{ &hf_skype_ffr_enc_data,
{ "Enc Data", "skype.ffr.encdata", FT_BYTES, BASE_NONE, NULL,
0x0, NULL, HFILL }},
/* Nat info */
{ &hf_skype_natinfo_srcip,
{ "Src IP", "skype.natinfo.srcip", FT_IPv4, BASE_NONE, NULL,
0x0, "Global source IP", HFILL }},
{ &hf_skype_natinfo_dstip,
{ "Dst IP", "skype.natinfo.dstip", FT_UINT32, BASE_HEX, NULL,
0x0, "Global destination IP", HFILL }},
/* Nat request */
{ &hf_skype_natrequest_srcip,
{ "Src IP", "skype.natrequest.srcip", FT_IPv4, BASE_NONE, NULL,
0x0, "Global source IP", HFILL }},
{ &hf_skype_natrequest_dstip,
{ "Dst IP", "skype.natrequest.dstip", FT_UINT32, BASE_HEX, NULL,
0x0, NULL, HFILL }},
/* Audio */
{ &hf_skype_audio_unk1,
{ "Unknown1", "skype.audio.unk1", FT_BYTES, BASE_NONE, NULL,
0x0, NULL, HFILL }},
/* Unknown_F */
{ &hf_skype_unknown_f_unk1,
{ "Unknown1", "skype.unknown_f.unk1", FT_BYTES, BASE_NONE, NULL,
0x0, NULL, HFILL }},
/* Unknown packet */
{ &hf_skype_unknown_packet,
{ "Unknown Packet", "skype.unknown_packet", FT_BYTES, BASE_NONE, NULL,
0x0, NULL, HFILL }},
};
static gint *ett[] = {
&ett_skype,
};
proto_skype = proto_register_protocol(PROTO_LONG_NAME, PROTO_SHORT_NAME, "skype");
proto_register_field_array(proto_skype, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_skype(void)
{
dissector_handle_t skype_handle;
skype_handle = create_dissector_handle(dissect_skype_static, proto_skype);
dissector_add_for_decode_as_with_preference("tcp.port", skype_handle);
dissector_add_for_decode_as_with_preference("udp.port", skype_handle);
heur_dissector_add("udp", dissect_skype_heur, "Skype over UDP", "skype_udp", proto_skype, HEURISTIC_DISABLE);
}
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-slimp3.c
|
/* packet-slimp3.c
* Routines for SliMP3 protocol dissection
*
* Ashok Narayanan <[email protected]>
*
* Adds support for the data packet protocol for the SliMP3
* See www.slimdevices.com for details.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/to_str.h>
void proto_register_slimp3(void);
void proto_reg_handoff_slimp3(void);
static int proto_slimp3 = -1;
static int hf_slimp3_opcode = -1;
static int hf_slimp3_control = -1;
static int hf_slimp3_uptime = -1;
static int hf_slimp3_code_id = -1;
static int hf_slimp3_code_bits = -1;
static int hf_slimp3_infrared_slimp3 = -1;
static int hf_slimp3_infrared_jvc = -1;
static int hf_slimp3_infrared = -1;
static int hf_slimp3_device_id = -1;
static int hf_slimp3_fw_rev = -1;
static int hf_slimp3_data_offset = -1;
static int hf_slimp3_data_command = -1;
static int hf_slimp3_data_write_pointer = -1;
static int hf_slimp3_data_sequence = -1;
static int hf_slimp3_disc_rsp_server_ip = -1;
static int hf_slimp3_disc_rsp_server_port = -1;
static int hf_slimp3_data_ack_write_pointer = -1;
static int hf_slimp3_data_ack_read_pointer = -1;
static int hf_slimp3_data_ack_sequence = -1;
static int hf_slimp3_data_req_offset = -1;
/* Generated from convert_proto_tree_add_text.pl */
static int hf_slimp3_display_delay = -1;
static int hf_slimp3_display_string = -1;
static int hf_slimp3_display_command = -1;
static int hf_slimp3_display_unknown = -1;
static int hf_slimp3_hello_response_client_server = -1;
static int hf_slimp3_hello_request_server_client = -1;
static int hf_slimp3_i2c_response_client_server = -1;
static int hf_slimp3_i2c_request_server_client = -1;
static int hf_slimp3_data_length = -1;
static int hf_slimp3_data_data = -1;
static gint ett_slimp3 = -1;
#define UDP_PORT_SLIMP3_V1 1069 /* Not IANA registered */
#define UDP_PORT_SLIMP3_V2 3483
#define UDP_PORT_SLIMP3_RANGE "1069,3483"
#define SLIMP3_IR 'i'
#define SLIMP3_CONTROL 's'
#define SLIMP3_HELLO 'h'
#define SLIMP3_DATA 'm'
#define SLIMP3_DATA_REQ 'r'
#define SLIMP3_DISPLAY 'l'
#define SLIMP3_I2C '2'
#define SLIMP3_DISC_REQ 'd'
#define SLIMP3_DISC_RSP 'D'
#define SLIMP3_DATA_ACK 'a'
static const value_string slimp3_opcode_vals[] = {
{ SLIMP3_IR, "Infrared Remote Code" },
{ SLIMP3_CONTROL, "Stream Control" },
{ SLIMP3_DATA, "MPEG Data" },
{ SLIMP3_DATA_REQ, "Data Request" },
{ SLIMP3_HELLO, "Hello" },
{ SLIMP3_DISPLAY, "Display" },
{ SLIMP3_I2C, "I2C" },
{ SLIMP3_DISC_REQ, "Discovery Request" },
{ SLIMP3_DISC_RSP, "Discovery Response" },
{ SLIMP3_DATA_ACK, "Ack" },
{ 0, NULL }
};
/* IR remote control types */
static const value_string slimp3_ir_types[] = {
{ 0x02, "SLIMP3" },
{ 0xff, "JVC DVD Player" },
{ 0, NULL }
};
/* IR codes for the custom SLIMP3 remote control */
static const value_string slimp3_ir_codes_slimp3[] = {
{ 0x768900ff, "voldown" },
{ 0x768904fb, "brightness" },
{ 0x768908f7, "2" },
{ 0x768910ef, "play" },
{ 0x768920df, "pause" },
{ 0x768928d7, "6" },
{ 0x768938c7, "repeat" },
{ 0x768940bf, "power" },
{ 0x768948b7, "4" },
{ 0x768958a7, "search" },
{ 0x7689609f, "add" },
{ 0x76896897, "8" },
{ 0x76897887, "now_playing" },
{ 0x7689807f, "volup" },
{ 0x76898877, "3" },
{ 0x7689906f, "arrow_left" },
{ 0x76899867, "0" },
{ 0x7689a05f, "fwd" },
{ 0x7689a857, "7" },
{ 0x7689b04f, "arrow_down" },
{ 0x7689b847, "sleep" },
{ 0x7689c03f, "rew" },
{ 0x7689c837, "5" },
{ 0x7689d02f, "arrow_right" },
{ 0x7689d827, "shuffle" },
{ 0x7689e01f, "arrow_up" },
{ 0x7689e817, "9" },
{ 0x7689f00f, "1" },
{ 0x7689f807, "size" },
{ 0, NULL }
};
static value_string_ext slimp3_ir_codes_slimp3_ext = VALUE_STRING_EXT_INIT(slimp3_ir_codes_slimp3);
/* IR codes for the JVC remote control */
static const value_string slimp3_ir_codes_jvc[] = {
{ 0xf786, "One" },
{ 0xf746, "Two" },
{ 0xf7c6, "Three" },
{ 0xf726, "Four" },
{ 0xf7a6, "Five" },
{ 0xf766, "Six" },
{ 0xf7e6, "Seven" },
{ 0xf716, "Eight" },
{ 0xf796, "Nine" },
{ 0xf776, "Ten" },
{ 0xf7f6, "Picture-In-Picture" },
/* { 0xf7XX, "Enter" }, */
{ 0xf70e, "Back" },
{ 0xf732, "Play" },
{ 0xf76e, "Forward" },
{ 0xf743, "Record" },
{ 0xf7c2, "Stop" },
{ 0xf7b2, "Pause" },
/* { 0xf7XX, "TV/Video" }, */
{ 0xf703, "Display" },
{ 0xf7b3, "Sleep" },
{ 0xf7b6, "Guide" },
{ 0xf70b, "Up" },
{ 0xf74b, "Left" },
{ 0xf7cb, "Right" },
{ 0xf78b, "Down" },
{ 0xf783, "Menu" },
{ 0xf72b, "OK" },
{ 0xf778, "Volume Up" },
{ 0xf7f8, "Volume Down" },
{ 0xf70d, "Channel Up" },
{ 0xf78d, "Channel Down" },
/* { 0xf7XX, "Mute" }, */
{ 0xf7ab, "Recall" },
{ 0xf702, "Power" },
{ 0, NULL }
};
static const value_string slimp3_display_commands[] = {
{ 0x1, "Clear Display"},
{ 0x2, "Cursor to 1st Line Home"},
{ 0x4, "Mode: Decrement Address, Shift Cursor"},
{ 0x5, "Mode: Decrement Address, Shift Display"},
{ 0x6, "Mode: Increment Address, Shift Cursor"},
{ 0x7, "Mode: Increment Address, Shift Display"},
{ 0x8, "Display Off"},
{ 0xd, "Display On, With Blinking"},
{ 0xe, "Display On, With Cursor"},
{ 0xf, "Display On, With Cursor And Blinking"},
{ 0x10, "Move Cursor Left"},
{ 0x14, "Move Cursor Right"},
{ 0x18, "Shift Display Left"},
{ 0x1b, "Shift Display Right"},
{ 0x30, "Set (8-bit)"},
{ 0x20, "Set (4-bit)"},
{ 0xa0, "Cursor to Top Right"},
{ 0xc0, "Cursor to 2nd Line Home"},
{ 0, NULL},
};
static const value_string slimp3_display_fset8[] = {
{ 0x0, "Brightness 100%"},
{ 0x1, "Brightness 75%"},
{ 0x2, "Brightness 50%"},
{ 0x3, "Brightness 25%"},
{ 0, NULL },
};
static const value_string slimp3_stream_control[] = {
{ 1, "Reset buffer, Start New Stream"},
{ 2, "Pause Playback"},
{ 4, "Resume Playback"},
{ 0, NULL },
};
static const value_string slimp3_mpg_control[] = {
{ 0, "Go"}, /* Run the decoder */
{ 1, "Stop"}, /* Halt decoder but don't reset rptr */
{ 3, "Reset"}, /* Halt decoder and reset rptr */
{ 0, NULL }
};
#define MAX_LCD_STR_LEN 128
static int
dissect_slimp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
const char *opcode_str;
proto_tree *slimp3_tree;
proto_item *ti;
gint i1;
gint offset = 0;
guint16 opcode;
guchar lcd_char;
char lcd_str[MAX_LCD_STR_LEN + 1];
int to_server = FALSE;
int old_protocol = FALSE;
address tmp_addr;
gboolean in_str;
int lcd_strlen;
/*
* If it doesn't begin with a known opcode, reject it, so that
* traffic that happens to be do or from one of our ports
* doesn't get misidentified as SliMP3 traffic.
*/
if (!tvb_bytes_exist(tvb, offset, 1))
return 0; /* not even an opcode */
opcode = tvb_get_guint8(tvb, offset);
opcode_str = try_val_to_str(opcode, slimp3_opcode_vals);
if (opcode_str == NULL)
return 0;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SliMP3");
col_add_str(pinfo->cinfo, COL_INFO, opcode_str);
ti = proto_tree_add_item(tree, proto_slimp3, tvb, offset, -1, ENC_NA);
slimp3_tree = proto_item_add_subtree(ti, ett_slimp3);
proto_tree_add_uint(slimp3_tree, hf_slimp3_opcode, tvb,
offset, 1, opcode);
/* The new protocol (v1.3 and later) uses an IANA-assigned port number.
* It usually uses the same number for both sizes of the conversation, so
* the port numbers can't always be used to determine client and server.
* The new protocol places the clients MAC address in the packet, so that
* is used to identify packets originating at the client.
*/
if ((pinfo->destport == UDP_PORT_SLIMP3_V2) && (pinfo->srcport == UDP_PORT_SLIMP3_V2)) {
set_address_tvb(&tmp_addr, AT_ETHER, 6, tvb, offset+12);
to_server = addresses_equal(&tmp_addr, &pinfo->dl_src);
}
else if (pinfo->destport == UDP_PORT_SLIMP3_V2) {
to_server = TRUE;
}
else if (pinfo->srcport == UDP_PORT_SLIMP3_V2) {
to_server = FALSE;
}
if (pinfo->destport == UDP_PORT_SLIMP3_V1) {
to_server = TRUE;
old_protocol = TRUE;
}
else if (pinfo->srcport == UDP_PORT_SLIMP3_V1) {
to_server = FALSE;
old_protocol = TRUE;
}
switch (opcode) {
case SLIMP3_IR:
/* IR code
*
* [0] 'i' as in "IR"
* [1] 0x00
* [2..5] player's time since startup in ticks @625 KHz
* [6] IR code id, ff=JVC, 02=SLIMP3
* [7] number of meaningful bits - 16 for JVC, 32 for SLIMP3
* [8..11] the 32-bit IR code
* [12..17] reserved
*/
if (tree) {
i1 = tvb_get_ntohl(tvb, offset+2);
proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_uptime, tvb, offset+2, 4, i1,
"%u sec (%u ticks)", i1/625000, i1);
proto_tree_add_item(slimp3_tree, hf_slimp3_code_id, tvb, offset+6, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(slimp3_tree, hf_slimp3_code_bits, tvb, offset+7, 1, ENC_BIG_ENDIAN);
i1 = tvb_get_ntohl(tvb, offset+8);
/* Check the code to figure out which remote is being used. */
if (tvb_get_guint8(tvb, offset+6) == 0x02 &&
tvb_get_guint8(tvb, offset+7) == 32) {
/* This is the custom SLIMP3 remote. */
proto_tree_add_item(slimp3_tree, hf_slimp3_infrared_slimp3, tvb, offset+8, 4, ENC_BIG_ENDIAN);
col_append_fstr(pinfo->cinfo, COL_INFO, ", SLIMP3: %s",
val_to_str_ext(i1, &slimp3_ir_codes_slimp3_ext, "Unknown (0x%0x)"));
}
else if (tvb_get_guint8(tvb, offset+6) == 0xff &&
tvb_get_guint8(tvb, offset+7) == 16) {
/* This is a JVC DVD player remote */
proto_tree_add_item(slimp3_tree, hf_slimp3_infrared_jvc, tvb, offset+8, 4, ENC_BIG_ENDIAN);
col_append_fstr(pinfo->cinfo, COL_INFO, ", JVC: %s",
val_to_str(i1, slimp3_ir_codes_jvc, "Unknown (0x%0x)"));
} else {
/* Unknown code; just write it */
proto_tree_add_item(slimp3_tree, hf_slimp3_infrared, tvb, offset+8, 4, ENC_BIG_ENDIAN);
col_append_fstr(pinfo->cinfo, COL_INFO, ", 0x%0x", i1);
}
}
break;
case SLIMP3_DISPLAY:
if (tree) {
guint8 value;
/* Loop through the commands */
i1 = 18;
in_str = FALSE;
lcd_strlen = 0;
while (i1 < tvb_reported_length_remaining(tvb, offset)) {
switch(tvb_get_guint8(tvb, offset + i1)) {
case 0:
in_str = FALSE;
lcd_strlen = 0;
proto_tree_add_item(slimp3_tree, hf_slimp3_display_delay, tvb, offset + i1, 2, ENC_NA);
i1 += 2;
break;
case 3:
lcd_char = tvb_get_guint8(tvb, offset + i1 + 1);
if (!g_ascii_isprint(lcd_char))
lcd_char = '.';
if (ti && in_str) {
lcd_strlen += 2;
proto_item_append_text(ti, "%c", lcd_char);
proto_item_set_len(ti, lcd_strlen);
} else {
ti = proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_display_string, tvb, offset + i1, 2,
lcd_char, "%c", lcd_char);
in_str = TRUE;
lcd_strlen = 2;
}
i1 += 2;
break;
case 2:
in_str = FALSE;
lcd_strlen = 0;
value = tvb_get_guint8(tvb, offset + i1 + 1);
ti = proto_tree_add_uint(slimp3_tree, hf_slimp3_display_command, tvb, offset + i1, 2, value);
if ((tvb_get_guint8(tvb, offset + i1 + 1) & 0xf0) == 0x30) {
proto_item_append_text(ti, ": %s",
val_to_str(tvb_get_guint8(tvb, offset + i1 + 2),
slimp3_display_fset8,
"Unknown (0x%0x)"));
i1 += 2;
}
i1 += 2;
break;
default:
proto_tree_add_item(slimp3_tree, hf_slimp3_display_unknown, tvb, offset + i1, 2, ENC_NA);
i1 += 2;
break;
}
}
}
i1 = 18;
lcd_strlen = 0;
while (tvb_offset_exists(tvb, offset + i1) &&
lcd_strlen < MAX_LCD_STR_LEN) {
switch (tvb_get_guint8(tvb, offset + i1)) {
case 0:
lcd_str[lcd_strlen++] = '.';
break;
case 2:
lcd_str[lcd_strlen++] = '|';
if (tvb_offset_exists(tvb, offset + i1 + 1) &&
(tvb_get_guint8(tvb, offset + i1 + 1) & 0xf0) == 0x30)
i1 += 2;
break;
case 3:
if (tvb_offset_exists(tvb, offset + i1 + 1)) {
if ((lcd_strlen < 1) ||
(lcd_str[lcd_strlen-1] != ' ') ||
(tvb_get_guint8(tvb, offset + i1 + 1) != ' ')) {
lcd_char = tvb_get_guint8(tvb, offset + i1 + 1);
lcd_str[lcd_strlen++] = g_ascii_isprint(lcd_char) ? lcd_char : '.';
}
}
}
i1 += 2;
}
lcd_str[lcd_strlen] = '\0';
if (lcd_strlen > 0)
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", lcd_str);
break;
case SLIMP3_CONTROL:
proto_tree_add_item(slimp3_tree, hf_slimp3_control, tvb, offset+1, 1, ENC_BIG_ENDIAN);
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
val_to_str(tvb_get_guint8(tvb, offset+1),
slimp3_stream_control, "Unknown (0x%0x)"));
break;
case SLIMP3_HELLO:
if (tree) {
if (to_server) {
guint8 fw_ver;
/* Hello response; client->server */
proto_tree_add_item(slimp3_tree, hf_slimp3_hello_response_client_server, tvb, offset, 1, ENC_NA);
proto_tree_add_item(slimp3_tree, hf_slimp3_device_id, tvb, offset+1, 1, ENC_BIG_ENDIAN);
fw_ver = tvb_get_guint8(tvb, offset+2);
proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_fw_rev, tvb, offset+2, 1, fw_ver,
"%u.%u (0x%0x)", fw_ver>>4, fw_ver & 0xf, fw_ver);
} else {
/* Hello request; server->client */
proto_tree_add_item(slimp3_tree, hf_slimp3_hello_request_server_client, tvb, offset, 1, ENC_NA);
}
}
break;
case SLIMP3_I2C:
if (to_server) {
/* Hello response; client->server */
proto_tree_add_item(slimp3_tree, hf_slimp3_i2c_response_client_server, tvb, offset, -1, ENC_NA);
col_append_str(pinfo->cinfo, COL_INFO, ", Response");
} else {
/* Hello request; server->client */
proto_tree_add_item(slimp3_tree, hf_slimp3_i2c_request_server_client, tvb, offset, -1, ENC_NA);
col_append_str(pinfo->cinfo, COL_INFO, ", Request");
}
break;
case SLIMP3_DATA_REQ:
proto_tree_add_item(slimp3_tree, hf_slimp3_data_req_offset, tvb, offset+2, 2, ENC_BIG_ENDIAN);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Offset: %u bytes",
tvb_get_ntohs(tvb, offset+2)*2);
break;
case SLIMP3_DATA:
/* MPEG data (v1.3 and later)
*
* [0] 'm'
* [1..5] reserved
* [6..7] Write pointer (in words)
* [8..9] reserved
* [10..11] Sequence number
* [12..17] reserved
* [18..] MPEG data
*/
if (old_protocol) {
guint offset_buffer;
proto_tree_add_bytes_format(slimp3_tree, hf_slimp3_data_length, tvb, offset, -1,
NULL, "Length: %d bytes",
tvb_reported_length_remaining(tvb, offset+18));
offset_buffer = tvb_get_ntohs(tvb, offset+2) * 2;
proto_tree_add_uint(slimp3_tree, hf_slimp3_data_offset, tvb, offset+2, 2, offset_buffer);
col_append_fstr(pinfo->cinfo, COL_INFO,
", Length: %d bytes, Offset: %u bytes.",
tvb_reported_length_remaining(tvb, offset+18),
offset_buffer);
}
else {
guint write_pointer;
proto_tree_add_item(slimp3_tree, hf_slimp3_data_command, tvb, offset+1, 1, ENC_BIG_ENDIAN);
proto_tree_add_bytes_format(slimp3_tree, hf_slimp3_data_length, tvb, offset, -1,
NULL, "Length: %d bytes",
tvb_reported_length_remaining(tvb, offset+18));
write_pointer = tvb_get_ntohs(tvb, offset+6) * 2;
proto_tree_add_uint(slimp3_tree, hf_slimp3_data_write_pointer, tvb, offset+6, 2, write_pointer);
proto_tree_add_item(slimp3_tree, hf_slimp3_data_sequence, tvb, offset+10, 2, ENC_BIG_ENDIAN);
col_append_fstr(pinfo->cinfo, COL_INFO,
", %s, %d bytes at %u, Sequence: %u",
val_to_str(tvb_get_guint8(tvb, offset+1),
slimp3_mpg_control, "Unknown (0x%0x)"),
tvb_reported_length_remaining(tvb, offset+18),
write_pointer,
tvb_get_ntohs(tvb, offset+10));
}
break;
case SLIMP3_DISC_REQ:
{
guint8 fw_ver;
proto_tree_add_item(slimp3_tree, hf_slimp3_device_id, tvb, offset+1, 1, ENC_BIG_ENDIAN);
fw_ver = tvb_get_guint8(tvb, offset+2);
proto_tree_add_uint_format_value(slimp3_tree, hf_slimp3_fw_rev, tvb, offset+2, 1, fw_ver,
"%u.%u (0x%0x)", fw_ver>>4, fw_ver & 0xf, fw_ver);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Device ID: %u. Firmware: %u.%u",
tvb_get_guint8(tvb, offset+1), fw_ver>>4, fw_ver & 0xf);
}
break;
case SLIMP3_DISC_RSP:
if (tree) {
proto_tree_add_item(slimp3_tree, hf_slimp3_disc_rsp_server_ip, tvb, offset+2, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(slimp3_tree, hf_slimp3_disc_rsp_server_port, tvb, offset+6, 2, ENC_BIG_ENDIAN);
}
col_append_fstr(pinfo->cinfo, COL_INFO, ", Server Address: %s. Server Port: %u",
tvb_ip_to_str(pinfo->pool, tvb, offset+2),
tvb_get_ntohs(tvb, offset + 6));
break;
case SLIMP3_DATA_ACK:
/* Acknowledge MPEG data
*
* [0] 'a'
* [1..5]
* [6..7] Write pointer (in words)
* [8..9] Read pointer (in words)
* [10..11] Sequence number
* [12..17] client MAC address (v1.3 and later)
*/
if (tree) {
guint pointer;
pointer = tvb_get_ntohs(tvb, offset+6) * 2;
proto_tree_add_uint(slimp3_tree, hf_slimp3_data_ack_write_pointer, tvb, offset+6, 2, pointer);
pointer = tvb_get_ntohs(tvb, offset+8) * 2;
proto_tree_add_uint(slimp3_tree, hf_slimp3_data_ack_read_pointer, tvb, offset+8, 2, pointer);
proto_tree_add_item(slimp3_tree, hf_slimp3_data_ack_sequence, tvb, offset+10, 2, ENC_BIG_ENDIAN);
}
col_append_fstr(pinfo->cinfo, COL_INFO, ", Sequence: %u",
tvb_get_ntohs(tvb, offset+10));
break;
default:
if (tree) {
proto_tree_add_item(slimp3_tree, hf_slimp3_data_data, tvb, offset, -1, ENC_NA);
}
break;
}
return tvb_reported_length(tvb);
}
void
proto_register_slimp3(void)
{
static hf_register_info hf[] = {
{ &hf_slimp3_opcode,
{ "Opcode", "slimp3.opcode",
FT_UINT8, BASE_DEC, VALS(slimp3_opcode_vals), 0x0,
"SLIMP3 message type", HFILL }},
{ &hf_slimp3_control,
{ "Control Packet", "slimp3.control",
FT_UINT8, BASE_DEC, VALS(slimp3_stream_control), 0x0,
"SLIMP3 control", HFILL }},
{ &hf_slimp3_uptime,
{ "Uptime", "slimp3.uptime",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_slimp3_code_id,
{ "Code identifier", "slimp3.code_id",
FT_UINT8, BASE_DEC, VALS(slimp3_ir_types), 0x0,
NULL, HFILL }},
{ &hf_slimp3_code_bits,
{ "Code bits", "slimp3.code_bits",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_slimp3_infrared_slimp3,
{ "Infrared Code", "slimp3.infrared",
FT_UINT32, BASE_HEX | BASE_EXT_STRING, &slimp3_ir_codes_slimp3_ext, 0x0,
NULL, HFILL }},
{ &hf_slimp3_infrared_jvc,
{ "Infrared Code", "slimp3.infrared",
FT_UINT32, BASE_HEX, VALS(slimp3_ir_codes_jvc), 0x0,
NULL, HFILL }},
{ &hf_slimp3_infrared,
{ "Infrared Code", "slimp3.infrared",
FT_UINT32, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_slimp3_device_id,
{ "Device ID", "slimp3.device_id",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_slimp3_fw_rev,
{ "Firmware Revision", "slimp3.fw_rev",
FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_slimp3_data_offset,
{ "Buffer offset", "slimp3.data.offset",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_slimp3_data_command,
{ "Command", "slimp3.data.command",
FT_UINT8, BASE_HEX, VALS(slimp3_mpg_control), 0x0,
NULL, HFILL }},
{ &hf_slimp3_data_write_pointer,
{ "Write Pointer", "slimp3.data.write_pointer",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_slimp3_data_sequence,
{ "Sequence", "slimp3.data.sequence",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_slimp3_disc_rsp_server_ip,
{ "Server Address", "slimp3.disc_rsp.server_ip",
FT_IPv4, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_slimp3_disc_rsp_server_port,
{ "Server Port", "slimp3.disc_rsp.server_port",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_slimp3_data_ack_write_pointer,
{ "Write Pointer", "slimp3.data_ack.write_pointer",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_slimp3_data_ack_read_pointer,
{ "Read Pointer", "slimp3.data_ack.read_pointer",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_slimp3_data_ack_sequence,
{ "Sequence", "slimp3.data_ack.sequence",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_slimp3_data_req_offset,
{ "Requested offset", "slimp3.data_req.offset",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
/* Generated from convert_proto_tree_add_text.pl */
{ &hf_slimp3_display_delay, { "Delay", "slimp3.display_delay", FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0, NULL, HFILL }},
{ &hf_slimp3_display_string, { "String", "slimp3.display_string", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_slimp3_display_command, { "Command", "slimp3.display_command", FT_UINT8, BASE_DEC, VALS(slimp3_display_commands), 0x0, NULL, HFILL }},
{ &hf_slimp3_display_unknown, { "Unknown", "slimp3.display_unknown", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_slimp3_hello_response_client_server, { "Hello Response (Client --> Server)", "slimp3.hello_response_client_server", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_slimp3_hello_request_server_client, { "Hello Request (Server --> Client)", "slimp3.hello_request_server_client", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_slimp3_i2c_response_client_server, { "I2C Response (Client --> Server)", "slimp3.i2c_response_client_server", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_slimp3_i2c_request_server_client, { "I2C Request (Server --> Client)", "slimp3.i2c_request_server_client", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_slimp3_data_length, { "Length", "slimp3.data.length", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_slimp3_data_data, { "Data", "slimp3.data.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
};
static gint *ett[] = {
&ett_slimp3,
};
proto_slimp3 = proto_register_protocol("SliMP3 Communication Protocol", "SliMP3", "slimp3");
proto_register_field_array(proto_slimp3, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_slimp3(void)
{
dissector_handle_t slimp3_handle;
slimp3_handle = create_dissector_handle(dissect_slimp3, proto_slimp3);
dissector_add_uint_range_with_preference("udp.port", UDP_PORT_SLIMP3_RANGE, slimp3_handle);
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
|
C
|
wireshark/epan/dissectors/packet-sll.c
|
/* packet-sll.c
* Routines for disassembly of packets from Linux "cooked mode" captures
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/capture_dissectors.h>
#include <epan/conversation_table.h>
#include <epan/arptypes.h>
#include <wsutil/pint.h>
#include "packet-sll.h"
#include "packet-ipx.h"
#include "packet-llc.h"
#include "packet-eth.h"
#include "packet-ppp.h"
#include "packet-gre.h"
#include "packet-arp.h"
#include <epan/addr_resolv.h>
#include <epan/etypes.h>
#include <epan/arptypes.h>
#include <epan/decode_as.h>
#include <epan/proto_data.h>
void proto_register_sll(void);
void proto_reg_handoff_sll(void);
typedef struct sll_tap_data {
address src_address;
} sll_tap_data;
/*
* A LINKTYPE_LINUX_SLL fake link-layer header.
*/
#define SLL_HEADER_SIZE 16 /* total header length */
/*
* A LINKTYPE_LINUX_SLL fake link-layer header.
*/
#define SLL2_HEADER_SIZE 20 /* total header length */
#define SLL_ADDRLEN 8 /* length of address field */
/*
* The LINUX_SLL_ values for "sll_pkttype".
*/
#define LINUX_SLL_HOST 0
#define LINUX_SLL_BROADCAST 1
#define LINUX_SLL_MULTICAST 2
#define LINUX_SLL_OTHERHOST 3
#define LINUX_SLL_OUTGOING 4
static const value_string packet_type_vals[] = {
{ LINUX_SLL_HOST, "Unicast to us" },
{ LINUX_SLL_BROADCAST, "Broadcast" },
{ LINUX_SLL_MULTICAST, "Multicast" },
{ LINUX_SLL_OTHERHOST, "Unicast to another host" },
{ LINUX_SLL_OUTGOING, "Sent by us" },
{ 0, NULL }
};
static const value_string ltype_vals[] = {
{ LINUX_SLL_P_802_3, "Raw 802.3" },
{ LINUX_SLL_P_ETHERNET, "Ethernet" },
{ LINUX_SLL_P_802_2, "802.2 LLC" },
{ LINUX_SLL_P_PPPHDLC, "PPP (HDLC)" },
{ LINUX_SLL_P_CAN, "CAN" },
{ LINUX_SLL_P_CANFD, "CAN FD" },
{ LINUX_SLL_P_IRDA_LAP, "IrDA LAP" },
{ LINUX_SLL_P_ISI, "ISI" },
{ LINUX_SLL_P_IEEE802154, "IEEE 802.15.4" },
{ LINUX_SLL_P_MCTP, "MCTP" },
{ 0, NULL }
};
static dissector_handle_t sll_handle;
static dissector_handle_t sll2_handle;
static dissector_handle_t ethertype_handle;
static dissector_handle_t netlink_handle;
static int proto_sll;
static int sll_tap = -1;
static int hf_sll_etype = -1;
static int hf_sll_gretype = -1;
static int hf_sll_halen = -1;
static int hf_sll_hatype = -1;
static int hf_sll_ifindex = -1;
static int hf_sll_ltype = -1;
static int hf_sll_pkttype = -1;
static int hf_sll_src_eth = -1;
static int hf_sll_src_ipv4 = -1;
static int hf_sll_src_other = -1;
static int hf_sll_trailer = -1;
static int hf_sll_unused = -1;
static gint ett_sll = -1;
static dissector_table_t sll_hatype_dissector_table;
static dissector_table_t sll_ltype_dissector_table;
static dissector_table_t gre_dissector_table;
static void sll_prompt(packet_info *pinfo, gchar* result)
{
snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "SLL protocol type 0x%04x as",
GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_sll, 0)));
}
static gpointer sll_value(packet_info *pinfo)
{
return p_get_proto_data(pinfo->pool, pinfo, proto_sll, 0);
}
static const char* sll_conv_get_filter_type(conv_item_t* conv, conv_filter_type_e filter)
{
if ((filter == CONV_FT_SRC_ADDRESS) && (conv->src_address.type == AT_ETHER))
return "sll.src.eth";
if ((filter == CONV_FT_ANY_ADDRESS) && (conv->src_address.type == AT_ETHER))
return "sll.src.eth";
if ((filter == CONV_FT_SRC_ADDRESS) && (conv->src_address.type == AT_IPv4))
return "sll.src.ipv4";
if ((filter == CONV_FT_ANY_ADDRESS) && (conv->src_address.type == AT_IPv4))
return "sll.src.ipv4";
return CONV_FILTER_INVALID;
}
static ct_dissector_info_t sll_ct_dissector_info = {&sll_conv_get_filter_type};
static address no_dst = {AT_NONE, 0, NULL, NULL};
static tap_packet_status
sll_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip, tap_flags_t flags)
{
conv_hash_t *hash = (conv_hash_t*) pct;
hash->flags = flags;
const sll_tap_data *tap_data = (const sll_tap_data*)vip;
add_conversation_table_data(hash, &tap_data->src_address, &no_dst, 0, 0, 1, pinfo->fd->pkt_len, &pinfo->rel_ts, &pinfo->abs_ts, &sll_ct_dissector_info, CONVERSATION_NONE);
return TAP_PACKET_REDRAW;
}
static const char* sll_endpoint_get_filter_type(endpoint_item_t* endpoint, conv_filter_type_e filter)
{
if ((filter == CONV_FT_SRC_ADDRESS) && (endpoint->myaddress.type == AT_ETHER))
return "sll.src.eth";
if ((filter == CONV_FT_ANY_ADDRESS) && (endpoint->myaddress.type == AT_ETHER))
return "sll.src.eth";
if ((filter == CONV_FT_SRC_ADDRESS) && (endpoint->myaddress.type == AT_IPv4))
return "sll.src.ipv4";
if ((filter == CONV_FT_ANY_ADDRESS) && (endpoint->myaddress.type == AT_IPv4))
return "sll.src.ipv4";
return CONV_FILTER_INVALID;
}
static et_dissector_info_t sll_endpoint_dissector_info = {&sll_endpoint_get_filter_type};
static tap_packet_status
sll_endpoint_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip, tap_flags_t flags)
{
conv_hash_t *hash = (conv_hash_t*) pit;
hash->flags = flags;
const sll_tap_data *tap_data = (const sll_tap_data*)vip;
add_endpoint_table_data(hash, &tap_data->src_address, 0, TRUE, 1, pinfo->fd->pkt_len, &sll_endpoint_dissector_info, ENDPOINT_NONE);
return TAP_PACKET_REDRAW;
}
static gboolean
capture_sll(const guchar *pd, int offset _U_, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header _U_)
{
guint16 hatype;
guint16 protocol;
if (!BYTES_ARE_IN_FRAME(0, len, SLL_HEADER_SIZE))
return FALSE;
protocol = pntoh16(&pd[14]);
if (protocol <= 1536) { /* yes, 1536 - that's how Linux does it */
/*
* "proto" is *not* a length field, it's a Linux internal
* protocol type.
*/
hatype = pntoh16(&pd[2]);
if (try_capture_dissector("sll.hatype", hatype, pd,
SLL_HEADER_SIZE, len, cpinfo, pseudo_header))
return TRUE;
return try_capture_dissector("sll.ltype", protocol, pd, SLL_HEADER_SIZE, len, cpinfo, pseudo_header);
} else {
return try_capture_dissector("ethertype", protocol, pd, SLL_HEADER_SIZE, len, cpinfo, pseudo_header);
}
return FALSE;
}
static gboolean
capture_sll2(const guchar *pd, int offset _U_, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header _U_)
{
guint16 hatype;
guint16 protocol;
if (!BYTES_ARE_IN_FRAME(0, len, SLL2_HEADER_SIZE))
return FALSE;
protocol = pntoh16(&pd[0]);
if (protocol <= 1536) { /* yes, 1536 - that's how Linux does it */
/*
* "proto" is *not* a length field, it's a Linux internal
* protocol type.
*/
hatype = pntoh16(&pd[8]);
if (try_capture_dissector("sll.hatype", hatype, pd,
SLL2_HEADER_SIZE, len, cpinfo, pseudo_header))
return TRUE;
return try_capture_dissector("sll.ltype", protocol, pd, SLL2_HEADER_SIZE, len, cpinfo, pseudo_header);
} else {
return try_capture_dissector("ethertype", protocol, pd, SLL2_HEADER_SIZE, len, cpinfo, pseudo_header);
}
return FALSE;
}
static void
add_ll_address(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb,
int halen_offset, int halen_len, sll_tap_data *tap_data)
{
guint32 ha_len;
int ha_offset = halen_offset + halen_len;
/*
* XXX - check the link-layer address type value?
* For now, we just assume ha_len 4 is IPv4 and ha_len 6
* is Ethernet.
*/
proto_tree_add_item_ret_uint(tree, hf_sll_halen, tvb, halen_offset, halen_len, ENC_BIG_ENDIAN, &ha_len);
switch (ha_len) {
case 4:
set_address_tvb(&pinfo->dl_src, AT_IPv4, 4, tvb, ha_offset);
copy_address_shallow(&pinfo->src, &pinfo->dl_src);
copy_address_wmem(wmem_file_scope(), &tap_data->src_address, &pinfo->src);
proto_tree_add_item(tree, hf_sll_src_ipv4, tvb, ha_offset, 4, ENC_BIG_ENDIAN);
break;
case 6:
set_address_tvb(&pinfo->dl_src, AT_ETHER, 6, tvb, ha_offset);
copy_address_shallow(&pinfo->src, &pinfo->dl_src);
copy_address_wmem(wmem_file_scope(), &tap_data->src_address, &pinfo->src);
proto_tree_add_item(tree, hf_sll_src_eth, tvb, ha_offset, 6, ENC_NA);
break;
case 0:
break;
default:
proto_tree_add_item(tree, hf_sll_src_other, tvb,
ha_offset, ha_len > 8 ? 8 : ha_len, ENC_NA);
break;
}
/* Not all bytes of SLL_ADDRLEN have been used. Add remaining as unused */
if (ha_len < SLL_ADDRLEN)
proto_tree_add_item(tree, hf_sll_unused, tvb, ha_offset + ha_len,
SLL_ADDRLEN - ha_len, ENC_NA);
}
static guint16
add_protocol_type(proto_tree *fh_tree, tvbuff_t *tvb, int protocol_offset,
int hatype)
{
guint16 protocol;
protocol = tvb_get_ntohs(tvb, protocol_offset);
if (protocol <= 1536) { /* yes, 1536 - that's how Linux does it */
/*
* "proto" is *not* a length field, it's a Linux internal
* protocol type.
* We therefore cannot say how much of the packet will
* be trailer data.
* XXX - do the same thing we do for packets with Ethertypes?
*/
proto_tree_add_uint(fh_tree, hf_sll_ltype, tvb,
protocol_offset, 2, protocol);
} else {
switch (hatype) {
case ARPHRD_IPGRE:
/*
* XXX - the link-layer header appears to consist
* of an IPv4 header followed by a bunch of stuff
* that includes the GRE flags and version, but
* cooked captures strip the link-layer header,
* so we can't provide the flags and version to
* the dissector.
*/
proto_tree_add_uint(fh_tree, hf_sll_gretype, tvb,
protocol_offset, 2, protocol);
break;
default:
proto_tree_add_uint(fh_tree, hf_sll_etype, tvb,
protocol_offset, 2, protocol);
break;
}
}
return protocol;
}
static void
dissect_payload(proto_tree *tree, packet_info *pinfo, proto_tree *fh_tree,
tvbuff_t *tvb, int header_size, int hatype, guint16 protocol)
{
tvbuff_t *next_tvb;
ethertype_data_t ethertype_data;
next_tvb = tvb_new_subset_remaining(tvb, header_size);
if (protocol <= 1536) { /* yes, 1536 - that's how Linux does it */
/*
* "proto" is *not* a length field, it's a Linux internal
* protocol type.
* We therefore cannot say how much of the packet will
* be trailer data.
* XXX - do the same thing we do for packets with Ethertypes?
*/
if (!dissector_try_uint(sll_hatype_dissector_table, hatype,
next_tvb, pinfo, tree)) {
p_add_proto_data(pinfo->pool, pinfo, proto_sll, 0, GUINT_TO_POINTER((guint)protocol));
if (!dissector_try_uint(sll_ltype_dissector_table,
protocol, next_tvb, pinfo, tree)) {
call_data_dissector(next_tvb, pinfo, tree);
}
}
} else {
switch (hatype) {
case ARPHRD_IPGRE:
/*
* XXX - the link-layer header appears to consist
* of an IPv4 header followed by a bunch of stuff
* that includes the GRE flags and version, but
* cooked captures strip the link-layer header,
* so we can't provide the flags and version to
* the dissector.
*/
dissector_try_uint(gre_dissector_table, protocol,
next_tvb, pinfo, tree);
break;
default:
ethertype_data.etype = protocol;
ethertype_data.payload_offset = header_size;
ethertype_data.fh_tree = fh_tree;
ethertype_data.trailer_id = hf_sll_trailer;
ethertype_data.fcs_len = 0;
call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, ðertype_data);
break;
}
}
}
static int
dissect_sll_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int encap)
{
guint16 pkttype;
guint16 protocol;
guint16 hatype;
int header_size;
int version;
proto_item *ti;
proto_tree *fh_tree;
sll_tap_data* tap_data;
switch (encap) {
case WTAP_ENCAP_SLL:
pkttype = tvb_get_ntohs(tvb, 0);
header_size = SLL_HEADER_SIZE;
version = 1;
break;
case WTAP_ENCAP_SLL2:
pkttype = tvb_get_ntohs(tvb, 10);
header_size = SLL2_HEADER_SIZE;
version = 2;
break;
default:
DISSECTOR_ASSERT_NOT_REACHED();
}
/*
* Set "pinfo->p2p_dir" if the packet wasn't received
* promiscuously.
*/
switch (pkttype) {
case LINUX_SLL_HOST:
case LINUX_SLL_BROADCAST:
case LINUX_SLL_MULTICAST:
pinfo->p2p_dir = P2P_DIR_RECV;
break;
case LINUX_SLL_OUTGOING:
pinfo->p2p_dir = P2P_DIR_SENT;
break;
}
switch (encap) {
case WTAP_ENCAP_SLL:
hatype = tvb_get_ntohs(tvb, 2);
break;
case WTAP_ENCAP_SLL2:
hatype = tvb_get_ntohs(tvb, 8);
break;
default:
DISSECTOR_ASSERT_NOT_REACHED();
}
/*
* XXX - special purpose hack. Netlink packets have a hardware
* address type of ARPHRD_NETLINK, but the protocol type value
* indicates the Netlink message type; we just hand the netlink
* dissector our *entire* packet.
*
* That's different from link-layer types such as 802.11+radiotap,
* where the payload follows the complete SLL header, and the
* protocol field in the SLL header is irrelevant; for those,
* we have the sll.hatype dissector table.
*/
if (hatype == ARPHRD_NETLINK) {
return call_dissector(netlink_handle, tvb, pinfo, tree);
}
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SLL");
col_clear(pinfo->cinfo, COL_INFO);
col_add_str(pinfo->cinfo, COL_INFO,
val_to_str(pkttype, packet_type_vals, "Unknown (%u)"));
ti = proto_tree_add_protocol_format(tree, proto_sll, tvb, 0,
header_size, "Linux cooked capture v%d", version);
fh_tree = proto_item_add_subtree(ti, ett_sll);
tap_data = wmem_new0(wmem_file_scope(), sll_tap_data);
switch (encap) {
case WTAP_ENCAP_SLL:
proto_tree_add_item(fh_tree, hf_sll_pkttype, tvb, 0, 2, ENC_BIG_ENDIAN);
proto_tree_add_uint(fh_tree, hf_sll_hatype, tvb, 2, 2, hatype);
add_ll_address(fh_tree, pinfo, tvb, 4, 2, tap_data);
protocol = add_protocol_type(fh_tree, tvb, 14, hatype);
dissect_payload(tree, pinfo, fh_tree, tvb, SLL_HEADER_SIZE, hatype, protocol);
break;
case WTAP_ENCAP_SLL2:
protocol = add_protocol_type(fh_tree, tvb, 0, hatype);
proto_tree_add_item(fh_tree, hf_sll_ifindex, tvb, 4, 4, ENC_BIG_ENDIAN);
proto_tree_add_uint(fh_tree, hf_sll_hatype, tvb, 8, 2, hatype);
proto_tree_add_item(fh_tree, hf_sll_pkttype, tvb, 10, 1, ENC_BIG_ENDIAN);
add_ll_address(fh_tree, pinfo, tvb, 11, 1, tap_data);
dissect_payload(tree, pinfo, fh_tree, tvb, SLL2_HEADER_SIZE, hatype, protocol);
break;
default:
DISSECTOR_ASSERT_NOT_REACHED();
}
tap_queue_packet(sll_tap, pinfo, tap_data);
return tvb_captured_length(tvb);
}
static int
dissect_sll_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
return dissect_sll_common(tvb, pinfo, tree, WTAP_ENCAP_SLL);
}
static int
dissect_sll_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
return dissect_sll_common(tvb, pinfo, tree, WTAP_ENCAP_SLL2);
}
void
proto_register_sll(void)
{
static hf_register_info hf[] = {
{ &hf_sll_pkttype,
{ "Packet type", "sll.pkttype",
FT_UINT16, BASE_DEC, VALS(packet_type_vals), 0x0,
NULL, HFILL }
},
{ &hf_sll_hatype,
{ "Link-layer address type", "sll.hatype",
FT_UINT16, BASE_DEC, VALS(arp_hrd_vals), 0x0,
NULL, HFILL }
},
{ &hf_sll_halen,
{ "Link-layer address length", "sll.halen",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_sll_src_eth,
{ "Source", "sll.src.eth",
FT_ETHER, BASE_NONE, NULL, 0x0,
"Source link-layer address", HFILL }
},
{ &hf_sll_src_ipv4,
{ "Source", "sll.src.ipv4",
FT_IPv4, BASE_NONE, NULL, 0x0,
"Source link-layer address", HFILL }
},
{ &hf_sll_src_other,
{ "Source", "sll.src.other",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Source link-layer address", HFILL }
},
{ &hf_sll_unused,
{ "Unused", "sll.unused",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Unused bytes", HFILL }
},
{ &hf_sll_ltype,
{ "Protocol", "sll.ltype",
FT_UINT16, BASE_HEX, VALS(ltype_vals), 0x0,
"Linux protocol type", HFILL }
},
{ &hf_sll_gretype,
{ "Protocol", "sll.gretype",
FT_UINT16, BASE_HEX, VALS(gre_typevals), 0x0,
"GRE protocol type", HFILL }
},
{ &hf_sll_etype,
{ "Protocol", "sll.etype",
FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0,
"Ethernet protocol type", HFILL }
},
{ &hf_sll_trailer,
{ "Trailer", "sll.trailer",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_sll_ifindex,
{ "Interface index", "sll.ifindex",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
};
static gint *ett[] = {
&ett_sll
};
/* Decode As handling */
static build_valid_func sll_da_build_value[1] = {sll_value};
static decode_as_value_t sll_da_values = {sll_prompt, 1, sll_da_build_value};
static decode_as_t sll_da = {"sll.ltype", "sll.ltype", 1, 0, &sll_da_values, NULL, NULL,
decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL};
proto_sll = proto_register_protocol("Linux cooked-mode capture", "SLL", "sll" );
proto_register_field_array(proto_sll, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
sll_handle = register_dissector("sll_v1", dissect_sll_v1, proto_sll);
sll2_handle = register_dissector("sll_v2", dissect_sll_v2, proto_sll);
sll_tap = register_tap("sll");
/*
* Sigh.
*
* For some packets, the link-layer header *isn't* been stripped
* off in a cooked capture; the hardware address type is the
* device ARPTYPE, so, for those packets, we should call the
* dissector for that value.
*
* We define a "sll.hatype" dissector table; we try dissecting
* with that first, and then try the protocol type if nothing
* is found in sll.hatype.
*/
sll_hatype_dissector_table = register_dissector_table (
"sll.hatype",
"Linux SLL ARPHRD_ type",
proto_sll, FT_UINT16,
BASE_DEC
);
register_capture_dissector_table("sll.hatype", "Linux SLL ARPHRD_ type");
sll_ltype_dissector_table = register_dissector_table (
"sll.ltype",
"Linux SLL protocol type",
proto_sll, FT_UINT16,
BASE_HEX
);
register_capture_dissector_table("sll.ltype", "Linux SLL protocol");
register_conversation_table(proto_sll, TRUE, sll_conversation_packet, sll_endpoint_packet);
register_decode_as(&sll_da);
}
void
proto_reg_handoff_sll(void)
{
capture_dissector_handle_t sll_cap_handle;
capture_dissector_handle_t sll2_cap_handle;
/*
* Get handles for the IPX and LLC dissectors.
*/
gre_dissector_table = find_dissector_table("gre.proto");
ethertype_handle = find_dissector_add_dependency("ethertype", proto_sll);
netlink_handle = find_dissector_add_dependency("netlink", proto_sll);
dissector_add_uint("wtap_encap", WTAP_ENCAP_SLL, sll_handle);
dissector_add_uint("wtap_encap", WTAP_ENCAP_SLL2, sll2_handle);
sll_cap_handle = create_capture_dissector_handle(capture_sll, proto_sll);
capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_SLL, sll_cap_handle);
sll2_cap_handle = create_capture_dissector_handle(capture_sll2, proto_sll);
capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_SLL2, sll2_cap_handle);
}
/*
* Editor modelines - https://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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-sll.h
|
/* packet-sll.h
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 2001 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PACKET_SLL_H__
#define __PACKET_SLL_H__
#include "ws_symbol_export.h"
/*
* The LINUX_SLL_ values for "sll_protocol".
* https://github.com/torvalds/linux/blob/master/include/uapi/linux/if_ether.h
*/
#define LINUX_SLL_P_802_3 0x0001 /* Novell 802.3 frames without 802.2 LLC header */
#define LINUX_SLL_P_ETHERNET 0x0003 /* Ethernet */
#define LINUX_SLL_P_802_2 0x0004 /* 802.2 frames (not D/I/X Ethernet) */
#define LINUX_SLL_P_PPPHDLC 0x0007 /* PPP HDLC frames */
#define LINUX_SLL_P_CAN 0x000C /* Controller Area Network */
#define LINUX_SLL_P_CANFD 0x000D /* Controller Area Network flexible data rate */
#define LINUX_SLL_P_IRDA_LAP 0x0017 /* IrDA Link Access Protocol */
#define LINUX_SLL_P_ISI 0x00F5 /* Intelligent Service Interface */
#define LINUX_SLL_P_IEEE802154 0x00f6 /* 802.15.4 on monitor inteface */
#define LINUX_SLL_P_MCTP 0x00fa /* Management Component Transport Protocol */
#endif
|
C
|
wireshark/epan/dissectors/packet-slowprotocols.c
|
/* packet-slowprotocols.c
* Routines for EtherType (0x8809) Slow Protocols disassembly.
* IEEE Std 802.3, Annex 57A
*
* Copyright 2002 Steve Housley <[email protected]>
* Copyright 2005 Dominique Bastien <[email protected]>
* Copyright 2009 Artem Tamazov <[email protected]>
* Copyright 2010 Roberto Morro <roberto.morro[AT]tilab.com>
* Copyright 2014 Philip Rosenberg-Watt <p.rosenberg-watt[at]cablelabs.com.>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/etypes.h>
#include <epan/slow_protocol_subtypes.h>
/* General declarations */
void proto_register_slow_protocols(void);
void proto_reg_handoff_slow_protocols(void);
static dissector_table_t slow_protocols_dissector_table;
static const value_string subtype_vals[] = {
{ LACP_SUBTYPE , "LACP" },
{ MARKER_SUBTYPE , "Marker Protocol" },
{ OAM_SUBTYPE , "OAM" },
{ OSSP_SUBTYPE , "Organization Specific Slow Protocol" },
{ 0, NULL }
};
/* Initialise the protocol and registered fields */
static int proto_slow = -1;
static int hf_slow_subtype = -1;
/* Initialise the subtree pointers */
static gint ett_slow = -1;
/*
* Name: dissect_slow_protocols
*
* Description:
* This function is used to dissect the slow protocols defined in IEEE802.3
* CSMA/CD. The current slow protocols subtypes are define in Annex 57A of
* the 802.3 document. In case of an unsupported slow protocol, we only
* fill the protocol and info columns.
*
* Input Arguments:
* tvb: buffer associated with the rcv packet (see tvbuff.h).
* pinfo: structure associated with the rcv packet (see packet_info.h).
* tree: the protocol tree associated with the rcv packet (see proto.h).
*
* Return Values:
* None
*/
static int
dissect_slow_protocols(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
guint8 subtype;
proto_tree *pdu_tree;
proto_item *pdu_item;
tvbuff_t *next_tvb;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Slow Protocols");
subtype = tvb_get_guint8(tvb, 0);
col_add_fstr(pinfo->cinfo, COL_INFO, "Subtype = %u", subtype);
if (tree)
{
pdu_item = proto_tree_add_item(tree, proto_slow, tvb, 0, 1, ENC_NA);
pdu_tree = proto_item_add_subtree(pdu_item, ett_slow);
/* Subtype */
proto_tree_add_item(pdu_tree, hf_slow_subtype, tvb, 0, 1, ENC_BIG_ENDIAN);
}
next_tvb = tvb_new_subset_remaining(tvb, 1);
if (!dissector_try_uint_new(slow_protocols_dissector_table, subtype,
next_tvb, pinfo, tree, TRUE, NULL))
call_data_dissector(next_tvb, pinfo, tree);
set_actual_length(tvb, tvb_captured_length(next_tvb) + 1);
return tvb_captured_length(tvb);
}
/* Register the protocol with Wireshark */
void
proto_register_slow_protocols(void)
{
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_slow_subtype,
{ "Slow Protocols subtype", "slow.subtype",
FT_UINT8, BASE_HEX, VALS(subtype_vals), 0x0,
NULL, HFILL }},
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_slow,
};
/* Register the protocol name and description */
proto_slow = proto_register_protocol("Slow Protocols", "802.3 Slow protocols", "slow");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_slow, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
/* subdissector code */
slow_protocols_dissector_table = register_dissector_table("slow.subtype",
"Slow protocol subtype",
proto_slow, FT_UINT8, BASE_DEC);
}
void
proto_reg_handoff_slow_protocols(void)
{
dissector_handle_t slow_protocols_handle;
slow_protocols_handle = create_dissector_handle(dissect_slow_protocols, proto_slow);
dissector_add_uint("ethertype", ETHERTYPE_SLOW_PROTOCOLS, slow_protocols_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-slsk.c
|
/* packet-slsk.c
* Routines for SoulSeek Protocol dissection
* Copyright 2003, Christian Wagner <[email protected]>
* Institute of Telematics - University of Karlsruhe
* part of this work supported by
* Deutsche Forschungsgemeinschaft (DFG) Grant Number FU448/1
*
* SoulSeek Protocol dissector based on protocol descriptions from SoleSeek Project:
* http://cvs.sourceforge.net/viewcvs.py/soleseek/SoleSeek/doc/protocol.html?rev=HEAD
* Updated for SoulSeek client version 151
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/strutil.h>
#include <epan/expert.h>
#include "packet-tcp.h"
void proto_register_slsk(void);
void proto_reg_handoff_slsk(void);
/* Initialize the protocol and registered fields */
static int proto_slsk = -1;
static int hf_slsk_integer = -1;
static int hf_slsk_string = -1;
static int hf_slsk_byte = -1;
static int hf_slsk_message_length = -1;
static int hf_slsk_message_code = -1;
static int hf_slsk_embedded_message_type = -1;
static int hf_slsk_client_ip = -1;
/* static int hf_slsk_server_ip = -1; */
static int hf_slsk_directory_name = -1;
static int hf_slsk_username = -1;
static int hf_slsk_password = -1;
static int hf_slsk_version = -1;
static int hf_slsk_login_successful = -1;
static int hf_slsk_login_message = -1;
static int hf_slsk_port = -1;
static int hf_slsk_ip = -1;
static int hf_slsk_user_exists = -1;
static int hf_slsk_status_code = -1;
static int hf_slsk_room = -1;
static int hf_slsk_chat_message = -1;
static int hf_slsk_users_in_room = -1;
static int hf_slsk_token = -1;
static int hf_slsk_connection_type = -1;
static int hf_slsk_chat_message_id = -1;
static int hf_slsk_timestamp = -1;
static int hf_slsk_search_text = -1;
static int hf_slsk_folder_count = -1;
static int hf_slsk_file_count = -1;
static int hf_slsk_average_speed = -1;
static int hf_slsk_download_number = -1;
static int hf_slsk_files = -1;
static int hf_slsk_directories = -1;
static int hf_slsk_slotsfull = -1;
static int hf_slsk_place_in_queue = -1;
static int hf_slsk_number_of_rooms = -1;
static int hf_slsk_filename = -1;
static int hf_slsk_filename_ext = -1;
static int hf_slsk_directory = -1;
static int hf_slsk_size = -1;
/* static int hf_slsk_checksum = -1; */
static int hf_slsk_code = -1;
static int hf_slsk_number_of_users = -1;
static int hf_slsk_number_of_days = -1;
static int hf_slsk_transfer_direction = -1;
static int hf_slsk_user_description = -1;
static int hf_slsk_picture_exists = -1;
static int hf_slsk_picture = -1;
/* static int hf_slsk_user_uploads = -1; */
static int hf_slsk_total_uploads = -1;
static int hf_slsk_queued_uploads = -1;
static int hf_slsk_slots_available = -1;
static int hf_slsk_allowed = -1;
static int hf_slsk_compr_packet = -1;
static int hf_slsk_parent_min_speed = -1;
static int hf_slsk_parent_speed_connection_ratio = -1;
static int hf_slsk_seconds_parent_inactivity_before_disconnect = -1;
static int hf_slsk_seconds_server_inactivity_before_disconnect = -1;
static int hf_slsk_nodes_in_cache_before_disconnect = -1;
static int hf_slsk_seconds_before_ping_children = -1;
static int hf_slsk_recommendation = -1;
static int hf_slsk_user = -1;
static int hf_slsk_ranking = -1;
static int hf_slsk_compressed_packet_length = -1;
static int hf_slsk_uncompressed_packet_length = -1;
static int hf_slsk_num_directories = -1;
static int hf_slsk_upload_speed = -1;
static int hf_slsk_in_queue = -1;
static int hf_slsk_num_slotsfull_records = -1;
static int hf_slsk_num_recommendations = -1;
static int hf_slsk_num_files = -1;
static int hf_slsk_num_strings = -1;
static int hf_slsk_file_code = -1;
static int hf_slsk_file_size1 = -1;
static int hf_slsk_file_size2 = -1;
static int hf_slsk_file_num_attributes = -1;
static int hf_slsk_file_attribute_type = -1;
static int hf_slsk_file_attribute_value = -1;
static int hf_slsk_free_upload_slots = -1;
static int hf_slsk_bytes = -1;
static int hf_slsk_same_recommendation = -1;
static int hf_slsk_number_of_priv_users = -1;
static int hf_slsk_num_parent_address = -1;
/* Initialize the subtree pointers */
static gint ett_slsk = -1;
static gint ett_slsk_compr_packet = -1;
static gint ett_slsk_directory = -1;
static gint ett_slsk_file = -1;
static gint ett_slsk_file_attribute = -1;
static gint ett_slsk_user = -1;
static gint ett_slsk_recommendation = -1;
static gint ett_slsk_room = -1;
static gint ett_slsk_string = -1;
static expert_field ei_slsk_unknown_data = EI_INIT;
static expert_field ei_slsk_zlib_decompression_failed = EI_INIT;
static expert_field ei_slsk_decompression_failed = EI_INIT;
#define SLSK_TCP_PORT_RANGE "2234,2240,5534"
/* desegmentation of SoulSeek Message over TCP */
static gboolean slsk_desegment = TRUE;
#ifdef HAVE_ZLIB
static gboolean slsk_decompress = TRUE;
#else
static gboolean slsk_decompress = FALSE;
#endif
static const value_string slsk_tcp_msgs[] = {
{ 1, "Login"},
{ 2, "Set Wait Port"},
{ 3, "Get Peer Address"},
{ 4, "Get Shared File List"},
{ 5, "User Exists / Shared File List"},
{ 7, "Get User Status"},
{ 9, "File Search Result"},
{ 13, "Say ChatRoom"},
{ 14, "Join Room"},
{ 15, "Leave Room / User Info Request"},
{ 16, "User Joined Room / User Info Reply"},
{ 17, "User Left Room"},
{ 18, "Connect To Peer"},
{ 22, "Message User"},
{ 23, "Message User Ack"},
{ 26, "File Search"},
{ 28, "Set Status"},
{ 32, "Ping"},
{ 34, "Update Upload Speed"},
{ 35, "Shared Files & Folders"},
{ 36, "Get User Stats / Folder Contents Request"},
{ 37, "Folder Contents Response"},
{ 40, "Queued Downloads / Transfer Request"},
{ 41, "Transfer Response"},
{ 42, "Placehold Upload"},
{ 43, "Queue Upload"},
{ 44, "Place In Queue"},
{ 46, "Upload Failed"},
{ 50, "Queue Failed / Own Recommendation"},
{ 51, "Add Things I like / Place In Queue Request"},
{ 52, "Remove Things I like"},
{ 54, "Get Recommendations"},
{ 55, "Type 55"},
{ 56, "Get Global Rankings"},
{ 57, "Get User Recommendations"},
{ 58, "Admin Command"},
{ 60, "Place In Line Response"},
{ 62, "Room Added"},
{ 63, "Room Removed"},
{ 64, "Room List"},
{ 65, "Exact File Search"},
{ 66, "Admin Message"},
{ 67, "Global User List"},
{ 68, "Tunneled Message"},
{ 69, "Privileged User List"},
{ 71, "Get Parent List"},
{ 73, "Type 73"},
{ 83, "Parent Min Speed"},
{ 84, "Parent Speed Connection Ratio"},
{ 86, "Parent Inactivity Before Disconnect"},
{ 87, "Server Inactivity Before Disconnect"},
{ 88, "Nodes In Cache Before Disconnect"},
{ 90, "Seconds Before Ping Children"},
{ 91, "Add To Privileged"},
{ 92, "Check Privileges"},
{ 93, "Embedded Message"},
{ 100, "Become Parent"},
{ 102, "Random Parent Addresses"},
{ 103, "Send Wishlist Entry"},
{ 104, "Type 104"},
{ 110, "Get Similar Users"},
{ 111, "Get Recommendations for Item"},
{ 112, "Get Similar Users for Item"},
{ 1001, "Can't Connect To Peer"},
{ 0, NULL }
};
static const value_string slsk_status_codes[] = {
{ -1, "Unknown"},
{ 0, "Offline"},
{ 1, "Away"},
{ 2, "Online"},
{ 0, NULL }
};
static const value_string slsk_transfer_direction[] = {
{ 0, "Download"},
{ 1, "Upload"},
{ 0, NULL }
};
static const value_string slsk_yes_no[] = {
{ 0, "No"},
{ 1, "Yes"},
{ 0, NULL }
};
static const value_string slsk_attr_type[] = {
{ 0, "Bitrate"},
{ 1, "Length"},
{ 2, "VBR"},
{ 0, NULL }
};
static const char* connection_type(char con_type[]) {
if (strlen(con_type) != 1) return "Unknown";
if (con_type[0] == 'D') return "Distributed Search";
if (con_type[0] == 'P') return "Peer Connection"; /* "File Search Result / User Info Request / Get Shared File List" */
if (con_type[0] == 'F') return "File Transfer";
return "Unknown";
}
static gboolean check_slsk_format(tvbuff_t *tvb, int offset, const char format[]){
/*
* Returns TRUE if tvbuff beginning at offset matches a certain format
* The format is given by an array of characters standing for a special field type
* i - integer (4 bytes)
* b - byte (1 byte)
* s - string (string_length + 4 bytes)
*
* * - can be used at the end of a format to ignore any following bytes
*/
switch ( format[0] ) {
case 'i':
if (tvb_captured_length_remaining(tvb, offset) < 4) return FALSE;
offset += 4;
break;
case 'b':
if (tvb_captured_length_remaining(tvb, offset) < 1) return FALSE;
offset += 1;
break;
case 's':
if (tvb_captured_length_remaining(tvb, offset) < 4) return FALSE;
if (tvb_captured_length_remaining(tvb, offset) < (int)tvb_get_letohl(tvb, offset)+4) return FALSE;
offset += tvb_get_letohl(tvb, offset)+4;
break;
case '*':
return TRUE;
default:
return FALSE;
}
if (format[1] == '\0' ) {
if (tvb_captured_length_remaining(tvb, offset) > 0) /* Checks for additional bytes at the end */
return FALSE;
return TRUE;
}
return check_slsk_format(tvb, offset, &format[1]);
}
static const char* get_message_type(tvbuff_t *tvb) {
/*
* Checks if the Message Code is known.
* If unknown checks if the Message Code is stored in a byte.
* Returns the Message Type.
*/
int msg_code = tvb_get_letohl(tvb, 4);
const gchar *message_type = try_val_to_str(msg_code, slsk_tcp_msgs);
if (message_type == NULL) {
if (check_slsk_format(tvb, 4, "bisis"))
message_type = "Distributed Search";
else if (check_slsk_format(tvb, 4, "bssi"))
message_type = "Peer Init";
else if (check_slsk_format(tvb, 4, "bi"))
message_type = "Pierce Fw";
else
message_type = "Unknown";
}
return message_type;
}
static guint get_slsk_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb,
int offset, void *data _U_)
{
guint32 msg_len;
msg_len = tvb_get_letohl(tvb, offset);
/* That length doesn't include the length field itself; add that in. */
msg_len += 4;
return msg_len;
}
/* Code to actually dissect the packets */
static int dissect_slsk_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
/* Set up structures needed to add the protocol subtree and manage it */
proto_item *ti, *ti_len, *ti_subtree, *ti_subtree2;
proto_tree *slsk_tree, *subtree, *subtree2, *subtree3;
int offset = 0, i, j;
guint32 msg_len, msg_code;
guint8 *str;
int str_len, start_offset, start_offset2;
int comprlen = 0, uncomprlen = 0, uncompr_tvb_offset = 0;
int i2 = 0, j2 = 0;
int i3 = 0, j3 = 0;
/* Make entries in Protocol column and Info column on summary display */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "slsk");
/* This field shows up as the "Info" column in the display */
col_set_str(pinfo->cinfo, COL_INFO, "SoulSeek Message");
col_append_fstr(pinfo->cinfo, COL_INFO, ": %s", get_message_type(tvb));
/* create display subtree for the protocol */
ti = proto_tree_add_item(tree, proto_slsk, tvb, 0, -1, ENC_NA);
slsk_tree = proto_item_add_subtree(ti, ett_slsk);
/* Continue adding tree items to process the packet here */
ti_len = proto_tree_add_item_ret_uint(slsk_tree, hf_slsk_message_length, tvb, offset, 4, ENC_LITTLE_ENDIAN, &msg_len);
offset += 4;
msg_code = tvb_get_letohl(tvb, offset);
switch (msg_code) {
case 1:
if (check_slsk_format(tvb, offset, "issi")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Login (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_password, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
else if (check_slsk_format(tvb, offset, "ibs") || check_slsk_format(tvb, offset, "ibsi")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Login Reply (Code: %02d)", msg_code);
offset += 4;
i=tvb_get_guint8(tvb, offset);
proto_tree_add_item(slsk_tree, hf_slsk_login_successful, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_login_message, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
if (i == 1){
proto_tree_add_item(slsk_tree, hf_slsk_client_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
}
break;
case 2:
if (check_slsk_format(tvb, offset, "ii")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Set Wait Port (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_port, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 3:
if (check_slsk_format(tvb, offset, "isii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Peer Address Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_port, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
else if (check_slsk_format(tvb, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Peer Address (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 4:
if (check_slsk_format(tvb, offset, "i")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Shared File List (Code: %02d)", msg_code);
offset += 4;
}
break;
case 5:
if (check_slsk_format(tvb, offset, "isb")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"User Exists Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_user_exists, tvb, offset, 1, ENC_NA);
offset += 1;
}
else if (check_slsk_format(tvb, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"User Exists Request (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, offset, "i*")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Shared File List (Code: %02d)", msg_code);
offset += 4;
/* [zlib compressed] */
comprlen = tvb_captured_length_remaining(tvb, offset);
if (slsk_decompress == TRUE){
tvbuff_t *uncompr_tvb = tvb_child_uncompress(tvb, tvb, offset, comprlen);
if (uncompr_tvb == NULL) {
proto_tree_add_expert(slsk_tree, pinfo, &ei_slsk_zlib_decompression_failed, tvb, offset, -1);
offset += tvb_captured_length_remaining(tvb, offset);
} else {
proto_item *ti2 = proto_tree_add_item(slsk_tree, hf_slsk_compr_packet, tvb, offset, -1, ENC_NA);
proto_tree *slsk_compr_packet_tree = proto_item_add_subtree(ti2, ett_slsk_compr_packet);
proto_item_set_generated(ti2);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_compressed_packet_length, tvb, offset, 0, comprlen);
proto_item_set_generated(ti);
uncomprlen = tvb_reported_length_remaining(uncompr_tvb, 0);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_uncompressed_packet_length, tvb, offset, 0, uncomprlen);
proto_item_set_generated(ti);
add_new_data_source(pinfo, uncompr_tvb, "Uncompressed SoulSeek data");
uncompr_tvb_offset = 0;
if (check_slsk_format(uncompr_tvb, uncompr_tvb_offset, "i*")) {
proto_tree_add_item_ret_int(slsk_compr_packet_tree, hf_slsk_num_directories, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j);
uncompr_tvb_offset += 4;
for (i = 0; i < j; i++) {
if (check_slsk_format(uncompr_tvb, uncompr_tvb_offset, "si*")) {
start_offset = uncompr_tvb_offset;
subtree = proto_tree_add_subtree_format(slsk_compr_packet_tree, uncompr_tvb, uncompr_tvb_offset, 1, ett_slsk_directory, &ti_subtree, "Directory #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_directory_name, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item_ret_int(subtree, hf_slsk_num_files, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j2);
uncompr_tvb_offset += 4;
for (i2 = 0; i2 < j2; i2++) {
if (check_slsk_format(uncompr_tvb, uncompr_tvb_offset, "bsiisi*")) {
start_offset2 = uncompr_tvb_offset;
subtree2 = proto_tree_add_subtree_format(subtree, uncompr_tvb, uncompr_tvb_offset, 1, ett_slsk_file, &ti_subtree2, "File #%d", i2+1);
proto_tree_add_item(subtree2, hf_slsk_file_code, uncompr_tvb, uncompr_tvb_offset, 1, ENC_NA);
uncompr_tvb_offset += 1;
proto_tree_add_item_ret_length(subtree2, hf_slsk_filename, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item(subtree2, hf_slsk_file_size1, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item(subtree2, hf_slsk_file_size2, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item_ret_length(subtree2, hf_slsk_filename_ext, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item_ret_int(subtree2, hf_slsk_file_num_attributes, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j3);
uncompr_tvb_offset += 4;
for (i3 = 0; i3 < j3; i3++) {
if (check_slsk_format(uncompr_tvb, uncompr_tvb_offset, "ii*")) {
subtree3 = proto_tree_add_subtree_format(subtree2, uncompr_tvb, uncompr_tvb_offset, 8, ett_slsk_file_attribute, NULL, "Attribute #%d", i3+1);
proto_tree_add_item(subtree3, hf_slsk_file_attribute_type, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item(subtree3, hf_slsk_file_attribute_value, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
} else {
break; /* invalid format */
}
}
proto_item_set_len(ti_subtree2, uncompr_tvb_offset-start_offset2);
} else {
break; /* invalid format */
}
}
proto_item_set_len(ti_subtree, uncompr_tvb_offset-start_offset);
} else {
break; /* invalid format */
}
}
}
}
}else {
ti = proto_tree_add_item(slsk_tree, hf_slsk_compr_packet, tvb, offset, -1, ENC_NA);
proto_item_set_generated(ti);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_compressed_packet_length, tvb, offset, 0, comprlen);
proto_item_set_generated(ti);
offset += tvb_captured_length_remaining(tvb, offset);
}
}
break;
case 7:
if (check_slsk_format(tvb, offset, "isi")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get User Status Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_status_code, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
else if (check_slsk_format(tvb, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get User Status (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 9:
if (check_slsk_format(tvb, offset, "i*")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"File Search Result (Code: %02d)", msg_code);
offset += 4;
/* [zlib compressed] */
comprlen = tvb_captured_length_remaining(tvb, offset);
if (slsk_decompress == TRUE){
tvbuff_t *uncompr_tvb = tvb_child_uncompress(tvb, tvb, offset, comprlen);
if (uncompr_tvb == NULL) {
ti = proto_tree_add_item(slsk_tree, hf_slsk_compr_packet, tvb, offset, tvb_captured_length_remaining(tvb, offset), ENC_NA);
proto_item_set_generated(ti);
offset += tvb_captured_length_remaining(tvb, offset);
expert_add_info(pinfo, ti, &ei_slsk_decompression_failed);
} else {
proto_item *ti2 = proto_tree_add_item(slsk_tree, hf_slsk_compr_packet, tvb, offset, -1, ENC_NA);
proto_tree *slsk_compr_packet_tree = proto_item_add_subtree(ti2, ett_slsk_compr_packet);
proto_item_set_generated(ti2);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_compressed_packet_length, tvb, offset, 0, comprlen);
proto_item_set_generated(ti);
uncomprlen = tvb_captured_length_remaining(uncompr_tvb, 0);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_uncompressed_packet_length, tvb, offset, 0, uncomprlen);
proto_item_set_generated(ti);
add_new_data_source(pinfo, uncompr_tvb, "Uncompressed SoulSeek data");
uncompr_tvb_offset = 0;
if (check_slsk_format(uncompr_tvb, uncompr_tvb_offset, "sii*")) {
proto_tree_add_item_ret_length(slsk_compr_packet_tree, hf_slsk_username, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_NA, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item(slsk_compr_packet_tree, hf_slsk_token, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item_ret_int(slsk_compr_packet_tree, hf_slsk_num_files, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j);
uncompr_tvb_offset += 4;
for (i = 0; i < j; i++) {
if (check_slsk_format(uncompr_tvb, uncompr_tvb_offset, "bsiisi*")) {
start_offset2 = uncompr_tvb_offset;
subtree2 = proto_tree_add_subtree_format(slsk_compr_packet_tree, uncompr_tvb, uncompr_tvb_offset, 1, ett_slsk_file, &ti_subtree2, "File #%d", i+1);
proto_tree_add_item(subtree2, hf_slsk_file_code, uncompr_tvb, uncompr_tvb_offset, 1, ENC_NA);
uncompr_tvb_offset += 1;
proto_tree_add_item_ret_length(subtree2, hf_slsk_filename, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item(subtree2, hf_slsk_file_size1, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item(subtree2, hf_slsk_file_size2, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item_ret_length(subtree2, hf_slsk_filename_ext, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item_ret_int(subtree2, hf_slsk_file_num_attributes, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j2);
uncompr_tvb_offset += 4;
for (i2 = 0; i2 < j2; i2++) {
if (check_slsk_format(uncompr_tvb, uncompr_tvb_offset, "ii*")) {
subtree3 = proto_tree_add_subtree_format(subtree2, uncompr_tvb, uncompr_tvb_offset, 8, ett_slsk_file_attribute, NULL, "Attribute #%d", i2+1);
proto_tree_add_item(subtree3, hf_slsk_file_attribute_type, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item(subtree3, hf_slsk_file_attribute_value, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
} else {
break; /* invalid format */
}
}
proto_item_set_len(ti_subtree2, uncompr_tvb_offset-start_offset2);
} else {
break; /* invalid format */
}
}
proto_tree_add_item(slsk_compr_packet_tree, hf_slsk_free_upload_slots, uncompr_tvb, uncompr_tvb_offset, 1, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 1;
proto_tree_add_item(slsk_compr_packet_tree, hf_slsk_upload_speed, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item(slsk_compr_packet_tree, hf_slsk_in_queue, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
}
}
}else {
ti = proto_tree_add_item(slsk_tree, hf_slsk_compr_packet, tvb, offset, -1, ENC_NA);
proto_item_set_generated(ti);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_compressed_packet_length, tvb, offset, 0, comprlen);
proto_item_set_generated(ti);
offset += tvb_captured_length_remaining(tvb, offset);
}
}
break;
case 13:
if (check_slsk_format(tvb, offset, "isss")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Say ChatRoom (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_chat_message, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, offset, "iss")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Say ChatRoom (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_chat_message, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 14:
if (check_slsk_format(tvb, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Join/Add Room (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, offset, "isi*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Join Room User List (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_users_in_room, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "s*")) {
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_user, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
} else {
break; /* invalid format */
}
}
if (check_slsk_format(tvb, offset, "i*")) {
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_users_in_room, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "i*")) {
proto_tree_add_item(slsk_tree, hf_slsk_status_code, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
break; /* invalid format */
}
}
}
if (check_slsk_format(tvb, offset, "i*")) {
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_users_in_room, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "iiiii*")) {
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 20, ett_slsk_user, NULL, "User #%d", i+1);
proto_tree_add_item(subtree, hf_slsk_average_speed, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_slsk_download_number, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_slsk_files, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_slsk_directories, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
break; /* invalid format */
}
}
}
if (check_slsk_format(tvb, offset, "i*")) {
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_slotsfull_records, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "i*")) {
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 4, ett_slsk_user, NULL, "User #%d", i+1);
proto_tree_add_item(subtree, hf_slsk_slotsfull, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
break; /* invalid format */
}
}
}
}
break;
case 15:
if (check_slsk_format(tvb, offset, "is")) {
/* Client-to-Server & Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Leave Room (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, offset, "i")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"User Info Request (Code: %02d)", msg_code);
offset += 4;
}
break;
case 16:
if (check_slsk_format(tvb, offset, "issiiiiiii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"User Joined Room (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_total_uploads, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_average_speed, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_download_number, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_files, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_directories, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_slotsfull, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
else if (check_slsk_format(tvb, offset, "isbiib") || check_slsk_format(tvb, offset, "isbsiib")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"User Info Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_user_description, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_picture_exists, tvb, offset, 1, ENC_NA);
offset += 1;
if ( tvb_get_guint8(tvb, offset -1 ) == 1 ) {
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_picture, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
proto_tree_add_item(slsk_tree, hf_slsk_total_uploads, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_queued_uploads, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_slots_available, tvb, offset, 1, ENC_NA);
offset += 1;
}
break;
case 17:
if (check_slsk_format(tvb, offset, "iss")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"User Left Room (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 18:
if (check_slsk_format(tvb, offset, "iiss")) {
/* Client-to-Server */
guint32 len;
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Connect To Peer (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
len = tvb_get_letohl(tvb, offset);
str = tvb_get_string_enc(pinfo->pool, tvb, offset+4, len, ENC_ASCII);
proto_tree_add_string_format_value(slsk_tree, hf_slsk_connection_type, tvb, offset, 4+len, str,
"%s (Char: %s)", connection_type(str),
format_text(pinfo->pool, str, len));
offset += 4+len;
}
else if (check_slsk_format(tvb, offset, "issiii")) {
/* Server-to-Client */
guint32 len;
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Connect To Peer (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
len = tvb_get_letohl(tvb, offset);
str = tvb_get_string_enc(pinfo->pool, tvb, offset+4, len, ENC_ASCII);
proto_tree_add_string_format_value(slsk_tree, hf_slsk_connection_type, tvb, offset, 4+len, str,
"%s (Char: %s)", connection_type(str),
format_text(pinfo->pool, str, len));
offset += 4+len;
proto_tree_add_item(slsk_tree, hf_slsk_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_port, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 22:
if (check_slsk_format(tvb, offset, "iss")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Message User Send (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_chat_message, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, offset, "iiiss")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Message User Receive (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_chat_message_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_timestamp, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_chat_message, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 23:
if (check_slsk_format(tvb, offset, "ii")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Message User Receive Ack (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_chat_message_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 26:
if (check_slsk_format(tvb, offset, "iis")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"File Search (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_search_text, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 28:
if (check_slsk_format(tvb, offset, "ii")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Set Status (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_status_code, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 32:
if (check_slsk_format(tvb, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Ping (Code: %02d)", msg_code);
offset += 4;
}
break;
case 34:
if (check_slsk_format(tvb, offset, "isi")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Update Upload Speed (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_average_speed, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 35:
if (check_slsk_format(tvb, offset, "iii")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Shared Files & Folders (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_folder_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_file_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 36:
if (check_slsk_format(tvb, offset, "isiiiii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get User Stats Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_average_speed, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_download_number, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_files, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_directories, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
else if (check_slsk_format(tvb, offset, "is")) {
/* Client-to-Client */
/* Client-to-Server: send after login successful */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get User Stats (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, offset, "iis")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Folder Contents Request (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_directory, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 37:
if (check_slsk_format(tvb, offset, "i*")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Folder Contents Response (Code: %02d)", msg_code);
offset += 4;
/* [zlib compressed] */
comprlen = tvb_captured_length_remaining(tvb, offset);
if (slsk_decompress == TRUE){
tvbuff_t *uncompr_tvb = tvb_child_uncompress(tvb, tvb, offset, comprlen);
if (uncompr_tvb == NULL) {
proto_tree_add_expert(slsk_tree, pinfo, &ei_slsk_zlib_decompression_failed, tvb, offset, -1);
offset += tvb_captured_length_remaining(tvb, offset);
} else {
proto_item *ti2 = proto_tree_add_item(slsk_tree, hf_slsk_compr_packet, tvb, offset, -1, ENC_NA);
proto_tree *slsk_compr_packet_tree = proto_item_add_subtree(ti2, ett_slsk_compr_packet);
proto_item_set_generated(ti2);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_compressed_packet_length, tvb, offset, 0, comprlen);
proto_item_set_generated(ti);
uncomprlen = tvb_captured_length_remaining(uncompr_tvb, 0);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_uncompressed_packet_length, tvb, offset, 0, uncomprlen);
proto_item_set_generated(ti);
add_new_data_source(pinfo, uncompr_tvb, "Uncompressed SoulSeek data");
uncompr_tvb_offset = 0;
if (check_slsk_format(uncompr_tvb, uncompr_tvb_offset, "isi*")) {
guint32 len;
proto_tree_add_item(slsk_compr_packet_tree, hf_slsk_token, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item_ret_length(slsk_compr_packet_tree, hf_slsk_directory_name, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &len);
uncompr_tvb_offset += len;
proto_tree_add_item_ret_int(slsk_compr_packet_tree, hf_slsk_num_directories, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j);
uncompr_tvb_offset += 4;
for (i = 0; i < j; i++) {
if (check_slsk_format(uncompr_tvb, uncompr_tvb_offset, "si*")) {
start_offset = uncompr_tvb_offset;
subtree = proto_tree_add_subtree_format(slsk_compr_packet_tree, uncompr_tvb, uncompr_tvb_offset, 1, ett_slsk_directory, &ti_subtree, "Directory #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_directory_name, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item_ret_int(subtree, hf_slsk_num_files, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j2);
uncompr_tvb_offset += 4;
for (i2 = 0; i2 < j2; i2++) {
if (check_slsk_format(uncompr_tvb, uncompr_tvb_offset, "bsiisi*")) {
start_offset2 = uncompr_tvb_offset;
subtree2 = proto_tree_add_subtree_format(subtree, uncompr_tvb, uncompr_tvb_offset, 1, ett_slsk_file, &ti_subtree2, "File #%d", i2+1);
proto_tree_add_item(subtree2, hf_slsk_file_code, uncompr_tvb, uncompr_tvb_offset, 1, ENC_NA);
uncompr_tvb_offset += 1;
proto_tree_add_item_ret_length(subtree2, hf_slsk_filename, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item(subtree2, hf_slsk_file_size1, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item(subtree2, hf_slsk_file_size2, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item_ret_length(subtree2, hf_slsk_filename_ext, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
uncompr_tvb_offset += str_len;
proto_tree_add_item_ret_int(subtree2, hf_slsk_file_num_attributes, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j3);
uncompr_tvb_offset += 4;
for (i3 = 0; i3 < j3; i3++) {
if (check_slsk_format(uncompr_tvb, uncompr_tvb_offset, "ii*")) {
subtree3 = proto_tree_add_subtree_format(subtree2, uncompr_tvb, uncompr_tvb_offset, 8, ett_slsk_file_attribute, NULL, "Attribute #%d", i3+1);
proto_tree_add_item(subtree3, hf_slsk_file_attribute_type, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item(subtree3, hf_slsk_file_attribute_value, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
} else {
break; /* invalid format */
}
}
proto_item_set_len(ti_subtree2, uncompr_tvb_offset-start_offset2);
} else {
break; /* invalid format */
}
}
proto_item_set_len(ti_subtree, uncompr_tvb_offset-start_offset);
} else {
break; /* invalid format */
}
}
}
}
}else {
ti = proto_tree_add_item(slsk_tree, hf_slsk_compr_packet, tvb, offset, -1, ENC_NA);
proto_item_set_generated(ti);
ti = proto_tree_add_uint(slsk_tree, hf_slsk_compressed_packet_length, tvb, offset, 0, comprlen);
proto_item_set_generated(ti);
offset += tvb_captured_length_remaining(tvb, offset);
}
}
break;
case 40:
if (check_slsk_format(tvb, offset, "isi")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Queued Downloads (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_slotsfull, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
else if (check_slsk_format(tvb, offset, "iiis") || check_slsk_format(tvb, offset, "iiisii")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Transfer Request (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_transfer_direction, tvb, offset, 4, ENC_LITTLE_ENDIAN, &i);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
if (i == 1){
proto_tree_add_item(slsk_tree, hf_slsk_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
}
break;
case 41:
if (check_slsk_format(tvb, offset, "iibs") || check_slsk_format(tvb, offset, "iibii") || check_slsk_format(tvb, offset, "iib")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Transfer Response (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
i = tvb_get_guint8(tvb, offset);
proto_tree_add_item(slsk_tree, hf_slsk_allowed, tvb, offset, 1, ENC_NA);
offset += 1;
if ( i == 1 ) {
if ( tvb_reported_length_remaining(tvb, offset) == 8 ) {
proto_tree_add_item(slsk_tree, hf_slsk_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
} else {
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_string, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
}
break;
case 42:
if (check_slsk_format(tvb, offset, "is")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Placehold Upload (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 43:
if (check_slsk_format(tvb, offset, "is")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Queue Upload (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 44:
if (check_slsk_format(tvb, offset, "isi")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Place In Queue (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_place_in_queue, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 46:
if (check_slsk_format(tvb, offset, "is")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Upload Failed (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 50:
if (check_slsk_format(tvb, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Make Own Recommendation (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, offset, "isi")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Remove Own Recommendation (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_ranking, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
else if (check_slsk_format(tvb, offset, "iss")) {
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Queue Failed (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_string, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 51:
if (check_slsk_format(tvb, offset, "is")) {
/* Client-to-Server: "Add Things I like" */
/* Client-to-Client: "Place In Queue Request" */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Add Things I like / Place In Queue Request (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 52:
if (check_slsk_format(tvb, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Remove Things I like (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 54:
if (check_slsk_format(tvb, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Recommendations (Code: %02d)", msg_code);
offset += 4;
}
else if (check_slsk_format(tvb, offset, "ii*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Recommendations Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_recommendations, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "si*")) {
start_offset = offset;
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 1, ett_slsk_recommendation, &ti_subtree, "Recommendation #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(subtree, hf_slsk_ranking, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_item_set_len(ti_subtree, offset-start_offset);
} else {
break; /* invalid format */
}
}
}
break;
case 55:
if (check_slsk_format(tvb, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Type 55 (Code: %02d)", msg_code);
offset += 4;
}
break;
case 56:
if (check_slsk_format(tvb, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Global Rankings (Code: %02d)", msg_code);
offset += 4;
}
else if (check_slsk_format(tvb, offset, "ii*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Global Rankings Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_recommendations, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "si*")) {
start_offset = offset;
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 1, ett_slsk_recommendation, &ti_subtree, "Recommendation #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(subtree, hf_slsk_ranking, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_item_set_len(ti_subtree, offset-start_offset);
} else {
break; /* invalid format */
}
}
}
break;
case 57:
if (check_slsk_format(tvb, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get User Recommendations (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, offset, "isi*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get User Recommendations Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_recommendations, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "s*")) {
start_offset = offset;
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 1, ett_slsk_recommendation, &ti_subtree, "Recommendation #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_item_set_len(ti_subtree, offset-start_offset);
} else {
break; /* invalid format */
}
}
}
break;
case 58:
if (check_slsk_format(tvb, offset, "isi*")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Admin Command (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_string, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_strings, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "s*")) {
start_offset = offset;
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 1, ett_slsk_string, &ti_subtree, "String #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_string, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_item_set_len(ti_subtree, offset-start_offset);
} else {
break; /* invalid format */
}
}
}
break;
case 60:
if (check_slsk_format(tvb, offset, "isii")) {
/* Client-to-Server & Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Place In Line Response (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_place_in_queue, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 62:
if (check_slsk_format(tvb, offset, "is")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Room Added (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 63:
if (check_slsk_format(tvb, offset, "is")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Room Removed (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 64:
if (check_slsk_format(tvb, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Room List Request (Code: %02d)", msg_code);
offset += 4;
}
else if (check_slsk_format(tvb, offset, "ii*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Room List (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_number_of_rooms, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "s*")) {
start_offset = offset;
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 1, ett_slsk_room, &ti_subtree, "Room #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_item_set_len(ti_subtree, offset-start_offset);
} else {
break; /* invalid format */
}
}
if (check_slsk_format(tvb, offset, "i*")) {
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_users_in_room, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "i*")) {
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 4, ett_slsk_room, &ti_subtree, "Room #%d", i+1);
proto_tree_add_item(subtree, hf_slsk_users_in_room, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
break; /* invalid format */
}
}
}
}
break;
case 65:
if (check_slsk_format(tvb, offset, "isissiii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Exact File Search (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_directory, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_bytes, tvb, offset, 16, ENC_NA);
offset += 12;
}
else if (check_slsk_format(tvb, offset, "iissiiib")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Exact File Search (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_filename, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_directory, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_bytes, tvb, offset, 13, ENC_NA);
offset += 13;
}
break;
case 66:
if (check_slsk_format(tvb, offset, "is")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Admin Message (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_chat_message, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 67:
if (check_slsk_format(tvb, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Global User List Request (Code: %02d)", msg_code);
offset += 4;
}
else if (check_slsk_format(tvb, offset, "isi*")) { /* same as case 14 */
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Global User List (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_room, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_users_in_room, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "s*")) {
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_user, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
} else {
break; /* invalid format */
}
}
if (check_slsk_format(tvb, offset, "i*")) {
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_users_in_room, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "i*")) {
proto_tree_add_item(slsk_tree, hf_slsk_status_code, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
break; /* invalid format */
}
}
}
if (check_slsk_format(tvb, offset, "i*")) {
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_users_in_room, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "iiiii*")) {
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 20, ett_slsk_user, NULL, "User #%d", i+1);
proto_tree_add_item(subtree, hf_slsk_average_speed, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_slsk_download_number, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_slsk_files, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_slsk_directories, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
break; /* invalid format */
}
}
}
if (check_slsk_format(tvb, offset, "i*")) {
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_slotsfull_records, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "i*")) {
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 4, ett_slsk_user, NULL, "User #%d", i+1);
proto_tree_add_item(subtree, hf_slsk_slotsfull, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
break; /* invalid format */
}
}
}
}
break;
case 68:
if (check_slsk_format(tvb, offset, "isiiiis")) {
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Tunneled Message (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_code, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_port, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_chat_message, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 69:
if (check_slsk_format(tvb, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Privileged User List Request (Code: %02d)", msg_code);
offset += 4;
}
else if (check_slsk_format(tvb, offset, "ii*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Privileged User List (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_number_of_priv_users, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "s*")) {
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_user, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
} else {
break; /* invalid format */
}
}
}
break;
case 71:
if (check_slsk_format(tvb, offset, "ib")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Parent List (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_byte, tvb, offset, 1, ENC_NA);
offset += 1;
}
break;
case 73:
if (check_slsk_format(tvb, offset, "ii")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Type 73 (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 83:
if (check_slsk_format(tvb, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Parent Min Speed (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_parent_min_speed, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 84:
if (check_slsk_format(tvb, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Parent Speed Connection Ratio (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_parent_speed_connection_ratio, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 86:
if (check_slsk_format(tvb, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Parent Inactivity Before Disconnect (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_seconds_parent_inactivity_before_disconnect, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 87:
if (check_slsk_format(tvb, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Server Inactivity Before Disconnect (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_seconds_server_inactivity_before_disconnect, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 88:
if (check_slsk_format(tvb, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Nodes In Cache Before Disconnect (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_nodes_in_cache_before_disconnect, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 90:
if (check_slsk_format(tvb, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Seconds Before Ping Children (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_seconds_before_ping_children, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 91:
if (check_slsk_format(tvb, offset, "is")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Add To Privileged (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 92:
if (check_slsk_format(tvb, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Check Privileges (Code: %02d)", msg_code);
offset += 4;
}
else if (check_slsk_format(tvb, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Check Privileges Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_number_of_days, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 93:
if (check_slsk_format(tvb, offset, "ibisis")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Embedded Message (Code: %02d)", msg_code);
offset += 4;
if ( tvb_get_guint8(tvb, offset) == 3 ){
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_embedded_message_type, tvb, offset, 1, msg_code,
"Distributed Search (Byte: %d)", 3);
offset += 1;
proto_tree_add_item(slsk_tree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_search_text, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
}
break;
case 100:
if (check_slsk_format(tvb, offset, "ib")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Become Parent (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_byte, tvb, offset, 1, ENC_NA);
offset += 1;
}
break;
case 102:
if (check_slsk_format(tvb, offset, "ii*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Random Parent Addresses (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_parent_address, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "sii*")) {
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_user, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_port, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
break; /* invalid format */
}
}
}
break;
case 103:
if (check_slsk_format(tvb, offset, "iis")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Send Wishlist Entry (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_search_text, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
break;
case 104:
if (check_slsk_format(tvb, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Type 104 (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case 110:
if (check_slsk_format(tvb, offset, "i")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Similar Users (Code: %02d)", msg_code);
offset += 4;
}
else if (check_slsk_format(tvb, offset, "ii*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Similar Users Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_number_of_users, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "si*")) {
start_offset = offset;
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 4, ett_slsk_user, &ti_subtree, "User #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_user, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(subtree, hf_slsk_same_recommendation, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_item_set_len(ti_subtree, offset-start_offset);
} else {
break; /* invalid format */
}
}
}
break;
case 111:
if (check_slsk_format(tvb, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Recommendations for Item (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, offset, "isi*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Recommendations for Item Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_recommendations, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "si*")) {
start_offset = offset;
subtree = proto_tree_add_subtree_format(slsk_tree, tvb, offset, 1, ett_slsk_recommendation, &ti_subtree, "Recommendation #%d", i+1);
proto_tree_add_item_ret_length(subtree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(subtree, hf_slsk_ranking, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_item_set_len(ti_subtree, offset-start_offset);
} else {
break; /* invalid format */
}
}
}
break;
case 112:
if (check_slsk_format(tvb, offset, "is")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Similar Users for Item (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, offset, "isi*")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Get Similar Users for Item Reply (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_recommendation, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item_ret_int(slsk_tree, hf_slsk_num_recommendations, tvb, offset, 4, ENC_LITTLE_ENDIAN, &j);
offset += 4;
if (j > tvb_reported_length_remaining(tvb, offset))
break;
for (i = 0; i < j; i++) {
if (check_slsk_format(tvb, offset, "s*")) {
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
} else {
break; /* invalid format */
}
}
}
break;
case 1001:
if (check_slsk_format(tvb, offset, "iis")) {
/* Client-to-Server */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Can't Connect To Peer (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
else if (check_slsk_format(tvb, offset, "ii")) {
/* Server-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Can't Connect To Peer (Code: %02d)", msg_code);
offset += 4;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
default:
if (check_slsk_format(tvb, offset, "bisis")) {
if ( tvb_get_guint8(tvb, offset) == 3 ){
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 1, msg_code,
"Distributed Search (Byte: %d)", 3);
offset += 1;
proto_tree_add_item(slsk_tree, hf_slsk_integer, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_search_text, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
}
}
else if (check_slsk_format(tvb, offset, "bssi")) {
if ( tvb_get_guint8(tvb, offset) == 1 ){
/* Client-to-Client */
guint32 len;
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 1, msg_code,
"Peer Init (Byte: %d)", 1);
offset += 1;
proto_tree_add_item_ret_length(slsk_tree, hf_slsk_username, tvb, offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &str_len);
offset += str_len;
len = tvb_get_letohl(tvb, offset);
str = tvb_get_string_enc(pinfo->pool, tvb, offset+4, len, ENC_ASCII);
proto_tree_add_string_format_value(slsk_tree, hf_slsk_connection_type, tvb, offset, 4+len, str,
"%s (Char: %s)", connection_type(str),
format_text(pinfo->pool, str, len));
offset += 4+len;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
}
else if (check_slsk_format(tvb, offset, "bi")) {
if ( tvb_get_guint8(tvb, offset) == 0 ){
/* Client-to-Client */
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 1, msg_code,
"Pierce Fw (Byte: %d)", 0);
offset += 1;
proto_tree_add_item(slsk_tree, hf_slsk_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
}
else {
proto_tree_add_uint_format_value(slsk_tree, hf_slsk_message_code, tvb, offset, 4, msg_code,
"Unknown (Code: %02d)", msg_code);
offset += 4;
}
break;
}
if(offset < (int)msg_len){
expert_add_info(pinfo, ti_len, &ei_slsk_unknown_data);
}
return tvb_captured_length(tvb);
}
static int dissect_slsk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
tcp_dissect_pdus(tvb, pinfo, tree, slsk_desegment, 4, get_slsk_pdu_len, dissect_slsk_pdu, data);
return tvb_captured_length(tvb);
}
/* Register the protocol with Wireshark */
void
proto_register_slsk(void)
{
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_slsk_integer,
{ "Integer", "slsk.integer",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_string,
{ "String", "slsk.string",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_byte,
{ "Byte", "slsk.byte",
FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_message_length,
{ "Message Length", "slsk.message.length",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_message_code,
{ "Message Type", "slsk.message.code",
FT_UINT32, BASE_DEC, NULL, 0, "Message Code with type string", HFILL } },
{ &hf_slsk_embedded_message_type,
{ "Embedded Message Type", "slsk.embedded_message.code",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_client_ip,
{ "Client IP", "slsk.client.ip",
FT_IPv4, BASE_NONE, NULL, 0, "Client IP Address", HFILL } },
#if 0
{ &hf_slsk_server_ip,
{ "SoulSeek Server IP", "slsk.server.ip",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
#endif
{ &hf_slsk_directory_name,
{ "Directory name", "slsk.directory_name",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_username,
{ "Username", "slsk.username",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_password,
{ "Password", "slsk.password",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_version,
{ "Version", "slsk.version",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_login_successful,
{ "Login successful", "slsk.login.successful",
FT_UINT8, BASE_DEC, VALS(slsk_yes_no), 0, NULL, HFILL } },
{ &hf_slsk_login_message,
{ "Login Message", "slsk.login.message",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_port,
{ "Port Number", "slsk.port.number",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_ip,
{ "IP Address", "slsk.ip.address",
FT_IPv4, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_user_exists,
{ "User exists", "slsk.user.exists",
FT_UINT8, BASE_DEC, VALS(slsk_yes_no), 0, NULL, HFILL } },
{ &hf_slsk_status_code,
{ "Status Code", "slsk.status.code",
FT_UINT32, BASE_DEC, VALS(slsk_status_codes), 0, NULL, HFILL } },
{ &hf_slsk_room,
{ "Room", "slsk.room",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_chat_message,
{ "Chat Message", "slsk.chat.message",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_users_in_room,
{ "Users in Room", "slsk.room.users",
FT_INT32, BASE_DEC, NULL, 0, "Number of Users in Room", HFILL } },
{ &hf_slsk_token,
{ "Token", "slsk.token",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_connection_type,
{ "Connection Type", "slsk.connection.type",
FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_chat_message_id,
{ "Chat Message ID", "slsk.chat.message.id",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_timestamp,
{ "Timestamp", "slsk.timestamp",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_search_text,
{ "Search Text", "slsk.search.text",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_folder_count,
{ "Folder Count", "slsk.folder.count",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_file_count,
{ "File Count", "slsk.file.count",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_average_speed,
{ "Average Speed", "slsk.average.speed",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_download_number,
{ "Download Number", "slsk.download.number",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_files,
{ "Files", "slsk.files",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_directories,
{ "Directories", "slsk.directories",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_slotsfull,
{ "Slots full", "slsk.slots.full",
FT_UINT32, BASE_DEC, NULL, 0, "Upload Slots Full", HFILL } },
{ &hf_slsk_place_in_queue,
{ "Place in Queue", "slsk.queue.place",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_number_of_rooms,
{ "Number of Rooms", "slsk.room.count",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_filename,
{ "Filename", "slsk.filename",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_filename_ext,
{ "Filename ext", "slsk.filename_ext",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_directory,
{ "Directory", "slsk.directory",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_size,
{ "Size", "slsk.size",
FT_UINT32, BASE_DEC, NULL, 0, "File Size", HFILL } },
#if 0
{ &hf_slsk_checksum,
{ "Checksum", "slsk.checksum",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
#endif
{ &hf_slsk_code,
{ "Code", "slsk.code",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_number_of_users,
{ "Number of Users", "slsk.user.count",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_number_of_days,
{ "Number of Days", "slsk.day.count",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_transfer_direction,
{ "Transfer Direction", "slsk.transfer.direction",
FT_INT32, BASE_DEC, VALS(slsk_transfer_direction), 0, NULL, HFILL } },
{ &hf_slsk_user_description,
{ "User Description", "slsk.user.description",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_picture_exists,
{ "Picture exists", "slsk.user.picture.exists",
FT_UINT8, BASE_DEC, VALS(slsk_yes_no), 0, "User has a picture", HFILL } },
{ &hf_slsk_picture,
{ "User Picture", "slsk.user.picture",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
#if 0
{ &hf_slsk_user_uploads,
{ "User uploads", "slsk.uploads.user",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
#endif
{ &hf_slsk_total_uploads,
{ "Total uploads allowed", "slsk.uploads.total",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_queued_uploads,
{ "Queued uploads", "slsk.uploads.queued",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_slots_available,
{ "Upload Slots available", "slsk.uploads.available",
FT_UINT8, BASE_DEC, VALS(slsk_yes_no), 0, NULL, HFILL } },
{ &hf_slsk_allowed,
{ "Download allowed", "slsk.user.allowed",
FT_UINT8, BASE_DEC, VALS(slsk_yes_no), 0, NULL, HFILL } },
{ &hf_slsk_compr_packet,
{ "zlib compressed packet", "slsk.compr.packet",
FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_parent_min_speed,
{ "Parent Min Speed", "slsk.parent.min.speed",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_parent_speed_connection_ratio,
{ "Parent Speed Connection Ratio", "slsk.parent.speed.connection.ratio",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_seconds_parent_inactivity_before_disconnect,
{ "Seconds Parent Inactivity Before Disconnect", "slsk.seconds.parent.inactivity.before.disconnect",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_seconds_server_inactivity_before_disconnect,
{ "Seconds Server Inactivity Before Disconnect", "slsk.seconds.server.inactivity.before.disconnect",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_nodes_in_cache_before_disconnect,
{ "Nodes In Cache Before Disconnect", "slsk.nodes.in.cache.before.disconnect",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_seconds_before_ping_children,
{ "Seconds Before Ping Children", "slsk.seconds.before.ping.children",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_recommendation,
{ "Recommendation", "slsk.recommendation",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_user,
{ "User", "slsk.user",
FT_UINT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_ranking,
{ "Ranking", "slsk.ranking",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_compressed_packet_length,
{ "Compressed packet length", "slsk.compressed_packet_length",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_uncompressed_packet_length,
{ "Uncompressed packet length", "slsk.uncompressed_packet_length",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_num_directories,
{ "Number of directories", "slsk.num_directories",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_upload_speed,
{ "Upload speed", "slsk.upload_speed",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_in_queue,
{ "In Queue", "slsk.in_queue",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_num_slotsfull_records,
{ "Number of Slotsfull Records", "slsk.num_slotsfull_records",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_num_recommendations,
{ "Number of Recommendations", "slsk.num_recommendations",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_num_files,
{ "Number of Files", "slsk.num_files",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_num_strings,
{ "Number of strings", "slsk.num_strings",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_file_code,
{ "Code", "slsk.file_code",
FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_file_size1,
{ "Size1", "slsk.file_size1",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_file_size2,
{ "Size2", "slsk.file_size2",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_file_num_attributes,
{ "Number of attributes", "slsk.file_num_attributes",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_file_attribute_type,
{ "File attribute type", "slsk.file_attribute_type",
FT_UINT32, BASE_DEC, VALS(slsk_attr_type), 0, NULL, HFILL } },
{ &hf_slsk_file_attribute_value,
{ "File attribute value", "slsk.file_attribute_value",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_free_upload_slots,
{ "Free upload slots", "slsk.free_upload_slots",
FT_UINT32, BASE_DEC, VALS(slsk_yes_no), 0, NULL, HFILL } },
{ &hf_slsk_bytes,
{ "Bytes", "slsk.bytes",
FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_slsk_same_recommendation,
{ "Same Recommendation", "slsk.same_recommendation",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_number_of_priv_users,
{ "Number of Privileged Users", "slsk.priv_user.count",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_slsk_num_parent_address,
{ "Number of Parent Addresses", "slsk.parent_addr.count",
FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_slsk,
&ett_slsk_compr_packet,
&ett_slsk_directory,
&ett_slsk_file,
&ett_slsk_file_attribute,
&ett_slsk_user,
&ett_slsk_recommendation,
&ett_slsk_room,
&ett_slsk_string,
};
static ei_register_info ei[] = {
{ &ei_slsk_unknown_data, { "slsk.unknown_data", PI_UNDECODED, PI_WARN, "Unknown Data (not interpreted)", EXPFILL }},
{ &ei_slsk_zlib_decompression_failed, { "slsk.zlib_decompression_failed", PI_PROTOCOL, PI_WARN, "zlib compressed packet failed to decompress", EXPFILL }},
{ &ei_slsk_decompression_failed, { "slsk.decompression_failed", PI_PROTOCOL, PI_WARN, "decompression failed", EXPFILL }},
};
module_t *slsk_module;
expert_module_t* expert_slsk;
/* Registers the protocol name and description */
proto_slsk = proto_register_protocol("SoulSeek Protocol", "SoulSeek", "slsk");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_slsk, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_slsk = expert_register_protocol(proto_slsk);
expert_register_field_array(expert_slsk, ei, array_length(ei));
slsk_module = prefs_register_protocol(proto_slsk, NULL);
/* Registers the options in the menu preferences */
prefs_register_bool_preference(slsk_module, "desegment",
"Reassemble SoulSeek messages spanning multiple TCP segments",
"Whether the SoulSeek dissector should reassemble messages spanning multiple TCP segments."
" To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
&slsk_desegment);
#ifdef HAVE_ZLIB
prefs_register_bool_preference(slsk_module, "decompress",
"Decompress zlib compressed packets inside SoulSeek messages",
"Whether the SoulSeek dissector should decompress all zlib compressed packets inside messages",
&slsk_decompress);
#endif
}
void
proto_reg_handoff_slsk(void)
{
dissector_handle_t slsk_handle;
slsk_handle = create_dissector_handle(dissect_slsk, proto_slsk);
dissector_add_uint_range_with_preference("tcp.port", SLSK_TCP_PORT_RANGE, slsk_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|
C
|
wireshark/epan/dissectors/packet-smb-browse.c
|
/* packet-smb-browse.c
* Routines for SMB Browser packet dissection
* Copyright 1999, Richard Sharpe <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Copied from packet-pop.c
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/to_str.h>
#include "packet-smb-browse.h"
#include "packet-dcerpc.h"
void proto_register_smb_browse(void);
static int proto_smb_browse = -1;
static int hf_command = -1;
static int hf_update_count = -1;
static int hf_periodicity = -1;
static int hf_server_name = -1;
static int hf_mb_server_name = -1;
static int hf_mb_reset_command = -1;
static int hf_mb_reset_demote = -1;
static int hf_mb_reset_flush = -1;
static int hf_mb_reset_stop = -1;
static int hf_os_major = -1;
static int hf_os_minor = -1;
static int hf_server_type = -1;
static int hf_server_type_workstation = -1;
static int hf_server_type_server = -1;
static int hf_server_type_sql = -1;
static int hf_server_type_domain = -1;
static int hf_server_type_backup = -1;
static int hf_server_type_time = -1;
static int hf_server_type_apple = -1;
static int hf_server_type_novell = -1;
static int hf_server_type_member = -1;
static int hf_server_type_print = -1;
static int hf_server_type_dialin = -1;
static int hf_server_type_xenix = -1;
static int hf_server_type_ntw = -1;
static int hf_server_type_wfw = -1;
static int hf_server_type_nts = -1;
static int hf_server_type_potentialb = -1;
static int hf_server_type_backupb = -1;
static int hf_server_type_masterb = -1;
static int hf_server_type_domainmasterb = -1;
static int hf_server_type_osf = -1;
static int hf_server_type_vms = -1;
static int hf_server_type_w95 = -1;
static int hf_server_type_dfs = -1;
static int hf_server_type_local = -1;
static int hf_server_type_domainenum = -1;
static int hf_election_version = -1;
static int hf_proto_major = -1;
static int hf_proto_minor = -1;
static int hf_sig_const = -1;
static int hf_server_comment = -1;
static int hf_unused_flags = -1;
static int hf_response_computer_name = -1;
static int hf_election_criteria = -1;
static int hf_election_desire = -1;
static int hf_election_desire_flags_backup = -1;
static int hf_election_desire_flags_standby = -1;
static int hf_election_desire_flags_master = -1;
static int hf_election_desire_flags_domain_master = -1;
static int hf_election_desire_flags_wins = -1;
static int hf_election_desire_flags_nt = -1;
/* static int hf_election_revision = -1; */
static int hf_election_os = -1;
static int hf_election_os_wfw = -1;
static int hf_election_os_ntw = -1;
static int hf_election_os_nts = -1;
static int hf_server_uptime = -1;
static int hf_backup_count = -1;
static int hf_backup_token = -1;
static int hf_backup_server = -1;
static int hf_browser_to_promote = -1;
static int hf_windows_version = -1;
static int hf_mysterious_field = -1;
static gint ett_browse = -1;
static gint ett_browse_flags = -1;
static gint ett_browse_election_criteria = -1;
static gint ett_browse_election_os = -1;
static gint ett_browse_election_desire = -1;
static gint ett_browse_reset_cmd_flags = -1;
#define SERVER_WORKSTATION 0
#define SERVER_SERVER 1
#define SERVER_SQL_SERVER 2
#define SERVER_DOMAIN_CONTROLLER 3
#define SERVER_BACKUP_CONTROLLER 4
#define SERVER_TIME_SOURCE 5
#define SERVER_APPLE_SERVER 6
#define SERVER_NOVELL_SERVER 7
#define SERVER_DOMAIN_MEMBER_SERVER 8
#define SERVER_PRINT_QUEUE_SERVER 9
#define SERVER_DIALIN_SERVER 10
#define SERVER_XENIX_SERVER 11
#define SERVER_NT_WORKSTATION 12
#define SERVER_WINDOWS_FOR_WORKGROUPS 13
#define SERVER_NT_SERVER 15
#define SERVER_POTENTIAL_BROWSER 16
#define SERVER_BACKUP_BROWSER 17
#define SERVER_MASTER_BROWSER 18
#define SERVER_DOMAIN_MASTER_BROWSER 19
#define SERVER_OSF 20
#define SERVER_VMS 21
#define SERVER_WINDOWS_95 22
#define SERVER_DFS_SERVER 23
#define SERVER_LOCAL_LIST_ONLY 30
#define SERVER_DOMAIN_ENUM 31
static const value_string server_types[] = {
{SERVER_WORKSTATION, "Workstation"},
{SERVER_SERVER, "Server"},
{SERVER_SQL_SERVER, "SQL Server"},
{SERVER_DOMAIN_CONTROLLER, "Domain Controller"},
{SERVER_BACKUP_CONTROLLER, "Backup Controller"},
{SERVER_TIME_SOURCE, "Time Source"},
{SERVER_APPLE_SERVER, "Apple Server"},
{SERVER_NOVELL_SERVER, "Novell Server"},
{SERVER_DOMAIN_MEMBER_SERVER, "Domain Member Server"},
{SERVER_PRINT_QUEUE_SERVER, "Print Queue Server"},
{SERVER_DIALIN_SERVER, "Dialin Server"},
{SERVER_XENIX_SERVER, "Xenix Server"},
{SERVER_NT_WORKSTATION, "NT Workstation"},
{SERVER_WINDOWS_FOR_WORKGROUPS, "Windows for Workgroups"},
{SERVER_NT_SERVER, "NT Server"},
{SERVER_POTENTIAL_BROWSER, "Potential Browser"},
{SERVER_BACKUP_BROWSER, "Backup Browser"},
{SERVER_MASTER_BROWSER, "Master Browser"},
{SERVER_DOMAIN_MASTER_BROWSER, "Domain Master Browser"},
{SERVER_OSF, "OSF"},
{SERVER_VMS, "VMS"},
{SERVER_WINDOWS_95, "Windows 95 or above"},
{SERVER_DFS_SERVER, "DFS server"},
{SERVER_LOCAL_LIST_ONLY, "Local List Only"},
{SERVER_DOMAIN_ENUM, "Domain Enum"},
{0, NULL}
};
#define SET_WINDOWS_VERSION_STRING(os_major_ver, os_minor_ver, windows_version) \
if(os_major_ver == 6 && os_minor_ver == 1) \
windows_version = "Windows 7 or Windows Server 2008 R2"; \
\
else if(os_major_ver == 6 && os_minor_ver == 0) \
windows_version = "Windows Vista or Windows Server 2008"; \
\
else if(os_major_ver == 5 && os_minor_ver == 2) \
windows_version = "Windows Server 2003 R2 or Windows Server 2003"; \
\
else if(os_major_ver == 5 && os_minor_ver == 1) \
windows_version = "Windows XP"; \
\
else if(os_major_ver == 5 && os_minor_ver == 0) \
windows_version = "Windows 2000"; \
\
else \
windows_version = "";
static const value_string resetbrowserstate_command_names[] = {
{ 0x01, "Stop being a master browser and become a backup browser"},
{ 0x02, "Discard browse lists, stop being a master browser, and try again"},
{ 0x04, "Stop being a master browser for ever"},
{ 0, NULL}
};
static true_false_string tfs_demote_to_backup = {
"Demote an LMB to a Backup Browser",
"Do not demote an LMB to a Backup Browser"
};
static true_false_string tfs_flush_browse_list = {
"Flush the Browse List",
"Do not Flush the Browse List"
};
static true_false_string tfs_stop_being_lmb = {
"Stop Being a Local Master Browser",
"Do not Stop Being a Local Master Browser"
};
static const true_false_string tfs_workstation = {
"This is a Workstation",
"This is NOT a Workstation"
};
static const true_false_string tfs_server = {
"This is a Server",
"This is NOT a Server"
};
static const true_false_string tfs_sql = {
"This is an SQL server",
"This is NOT an SQL server"
};
static const true_false_string tfs_domain = {
"This is a Domain Controller",
"This is NOT a Domain Controller"
};
static const true_false_string tfs_backup = {
"This is a Backup Controller",
"This is NOT a Backup Controller"
};
static const true_false_string tfs_time = {
"This is a Time Source",
"This is NOT a Time Source"
};
static const true_false_string tfs_apple = {
"This is an Apple host",
"This is NOT an Apple host"
};
static const true_false_string tfs_novell = {
"This is a Novell server",
"This is NOT a Novell server"
};
static const true_false_string tfs_member = {
"This is a Domain Member server",
"This is NOT a Domain Member server"
};
static const true_false_string tfs_print = {
"This is a Print Queue server",
"This is NOT a Print Queue server"
};
static const true_false_string tfs_dialin = {
"This is a Dialin server",
"This is NOT a Dialin server"
};
static const true_false_string tfs_xenix = {
"This is a Xenix server",
"This is NOT a Xenix server"
};
static const true_false_string tfs_ntw = {
"This is an NT Workstation",
"This is NOT an NT Workstation"
};
static const true_false_string tfs_wfw = {
"This is a WfW host",
"This is NOT a WfW host"
};
static const true_false_string tfs_nts = {
"This is an NT Server",
"This is NOT an NT Server"
};
static const true_false_string tfs_potentialb = {
"This is a Potential Browser",
"This is NOT a Potential Browser"
};
static const true_false_string tfs_backupb = {
"This is a Backup Browser",
"This is NOT a Backup Browser"
};
static const true_false_string tfs_masterb = {
"This is a Master Browser",
"This is NOT a Master Browser"
};
static const true_false_string tfs_domainmasterb = {
"This is a Domain Master Browser",
"This is NOT a Domain Master Browser"
};
static const true_false_string tfs_osf = {
"This is an OSF host",
"This is NOT an OSF host"
};
static const true_false_string tfs_vms = {
"This is a VMS host",
"This is NOT a VMS host"
};
static const true_false_string tfs_w95 = {
"This is a Windows 95 or above host",
"This is NOT a Windows 95 or above host"
};
static const true_false_string tfs_dfs = {
"This is a DFS server",
"THis is NOT a DFS server"
};
static const true_false_string tfs_local = {
"This is a local list only request",
"This is NOT a local list only request"
};
static const true_false_string tfs_domainenum = {
"This is a Domain Enum request",
"This is NOT a Domain Enum request"
};
#define DESIRE_BACKUP 0
#define DESIRE_STANDBY 1
#define DESIRE_MASTER 2
#define DESIRE_DOMAIN_MASTER 3
#define DESIRE_WINS 5
#define DESIRE_NT 7
static const true_false_string tfs_desire_backup = {
"Backup Browse Server",
"NOT Backup Browse Server"
};
static const true_false_string tfs_desire_standby = {
"Standby Browse Server",
"NOT Standby Browse Server"
};
static const true_false_string tfs_desire_master = {
"Master Browser",
"NOT Master Browser"
};
static const true_false_string tfs_desire_domain_master = {
"Domain Master Browse Server",
"NOT Domain Master Browse Server"
};
static const true_false_string tfs_desire_wins = {
"WINS Client",
"NOT WINS Client"
};
static const true_false_string tfs_desire_nt = {
"Windows NT Advanced Server",
"NOT Windows NT Advanced Server"
};
#define BROWSE_HOST_ANNOUNCE 1
#define BROWSE_REQUEST_ANNOUNCE 2
#define BROWSE_ELECTION_REQUEST 8
#define BROWSE_BACKUP_LIST_REQUEST 9
#define BROWSE_BACKUP_LIST_RESPONSE 10
#define BROWSE_BECOME_BACKUP 11
#define BROWSE_DOMAIN_ANNOUNCEMENT 12
#define BROWSE_MASTER_ANNOUNCEMENT 13
#define BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT 14
#define BROWSE_LOCAL_MASTER_ANNOUNCEMENT 15
static const value_string commands[] = {
{BROWSE_HOST_ANNOUNCE, "Host Announcement"},
{BROWSE_REQUEST_ANNOUNCE, "Request Announcement"},
{BROWSE_ELECTION_REQUEST, "Browser Election Request"},
{BROWSE_BACKUP_LIST_REQUEST, "Get Backup List Request"},
{BROWSE_BACKUP_LIST_RESPONSE, "Get Backup List Response"},
{BROWSE_BECOME_BACKUP, "Become Backup Browser"},
{BROWSE_DOMAIN_ANNOUNCEMENT, "Domain/Workgroup Announcement"},
{BROWSE_MASTER_ANNOUNCEMENT, "Master Announcement"},
{BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT, "Reset Browser State Announcement"},
{BROWSE_LOCAL_MASTER_ANNOUNCEMENT, "Local Master Announcement"},
{0, NULL}
};
#define OS_WFW 0
#define OS_NTW 4
#define OS_NTS 5
static const true_false_string tfs_os_wfw = {
"Windows for Workgroups",
"Not Windows for Workgroups"
};
static const true_false_string tfs_os_ntw = {
"Windows NT Workstation",
"Not Windows NT Workstation"
};
static const true_false_string tfs_os_nts = {
"Windows NT Server",
"Not Windows NT Server"
};
static void
dissect_election_criterion_os(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_election_os_wfw,
&hf_election_os_ntw,
&hf_election_os_nts,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_election_os, ett_browse_election_os, flags, ENC_NA);
}
static void
dissect_election_criterion_desire(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_election_desire_flags_backup,
&hf_election_desire_flags_standby,
&hf_election_desire_flags_master,
&hf_election_desire_flags_domain_master,
&hf_election_desire_flags_wins,
&hf_election_desire_flags_nt,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_election_desire, ett_browse_election_desire, flags, ENC_NA);
}
static void
dissect_election_criterion(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
proto_tree *tree = NULL;
proto_item *item = NULL;
guint32 criterion;
criterion = tvb_get_letohl(tvb, offset);
if (parent_tree) {
item = proto_tree_add_uint(parent_tree, hf_election_criteria, tvb, offset, 4, criterion);
tree = proto_item_add_subtree(item, ett_browse_election_criteria);
}
/* election desire */
dissect_election_criterion_desire(tvb, tree, offset);
offset += 1;
/* browser protocol major version */
proto_tree_add_item(tree, hf_proto_major, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* browser protocol minor version */
proto_tree_add_item(tree, hf_proto_minor, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* election os */
dissect_election_criterion_os(tvb, tree, offset);
}
/*
* XXX - this causes non-browser packets to have browser fields.
*/
int
dissect_smb_server_type_flags(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *parent_tree, guint8 *drep,
gboolean infoflag)
{
guint32 flags;
int i;
static int * const type_flags[] = {
&hf_server_type_workstation,
&hf_server_type_server,
&hf_server_type_sql,
&hf_server_type_domain,
&hf_server_type_backup,
&hf_server_type_time,
&hf_server_type_apple,
&hf_server_type_novell,
&hf_server_type_member,
&hf_server_type_print,
&hf_server_type_dialin,
&hf_server_type_xenix,
&hf_server_type_ntw,
&hf_server_type_wfw,
&hf_server_type_nts,
&hf_server_type_potentialb,
&hf_server_type_backupb,
&hf_server_type_masterb,
&hf_server_type_domainmasterb,
&hf_server_type_osf,
&hf_server_type_vms,
&hf_server_type_w95,
&hf_server_type_dfs,
&hf_server_type_local,
&hf_server_type_domainenum,
NULL
};
if (drep != NULL) {
/*
* Called from a DCE RPC protocol dissector, for a
* protocol where a 32-bit NDR integer contains
* an server type mask; extract the server type mask
* with an NDR call (but don't put it into the
* protocol tree, as we can't get a pointer to the
* item it puts in, and thus can't put a tree below
* it with the values of the individual bits).
*/
offset = dissect_ndr_uint32(
tvb, offset, pinfo, NULL, NULL, drep, hf_server_type, &flags);
} else {
/*
* Called from SMB browser or RAP, where the server type
* mask is just a 4-byte little-endian quantity with no
* special NDR alignment requirement; extract it with
* "tvb_get_letohl()".
*/
flags = tvb_get_letohl(tvb, offset);
offset += 4;
}
if (infoflag) {
/* Append the type(s) of the system to the COL_INFO line ... */
for (i = 0; i < 32; i++) {
if (flags & (1U<<i)) {
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
val_to_str(i, server_types,
"Unknown server type:%d"));
}
}
}
proto_tree_add_bitmask_value(parent_tree, tvb, offset-4,
hf_server_type, ett_browse_flags, type_flags, flags);
return offset;
}
#define HOST_NAME_LEN 16
static int
dissect_mailslot_browse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_)
{
int offset = 0;
guint8 cmd;
proto_tree *tree = NULL;
proto_item *item = NULL;
guint32 periodicity;
guint8 *host_name;
gint namelen;
guint8 server_count;
guint8 os_major_ver, os_minor_ver;
const gchar *windows_version;
int i;
guint32 uptime;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "BROWSER");
col_clear(pinfo->cinfo, COL_INFO);
cmd = tvb_get_guint8(tvb, offset);
/* Put in something, and replace it later */
col_add_str(pinfo->cinfo, COL_INFO, val_to_str(cmd, commands, "Unknown command:0x%02x"));
item = proto_tree_add_item(parent_tree, proto_smb_browse, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_browse);
/* command */
proto_tree_add_uint(tree, hf_command, tvb, offset, 1, cmd);
offset += 1;
switch (cmd) {
case BROWSE_DOMAIN_ANNOUNCEMENT:
case BROWSE_LOCAL_MASTER_ANNOUNCEMENT:
case BROWSE_HOST_ANNOUNCE: {
/* update count */
proto_tree_add_item(tree, hf_update_count, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* periodicity (in milliseconds) */
periodicity = tvb_get_letohl(tvb, offset);
proto_tree_add_uint_format_value(tree, hf_periodicity, tvb, offset, 4,
periodicity,
"%s",
signed_time_msecs_to_str(pinfo->pool, periodicity));
offset += 4;
/* server name */
host_name = tvb_get_stringzpad(pinfo->pool, tvb, offset, HOST_NAME_LEN, ENC_CP437|ENC_NA);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", host_name);
proto_tree_add_string_format(tree, hf_server_name,
tvb, offset, HOST_NAME_LEN,
host_name,
(cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
"Domain/Workgroup: %s":
"Host Name: %s",
host_name);
offset += HOST_NAME_LEN;
/* Windows version (See "OSVERSIONINFO Structure" on MSDN) */
os_major_ver = tvb_get_guint8(tvb, offset);
os_minor_ver = tvb_get_guint8(tvb, offset+1);
SET_WINDOWS_VERSION_STRING(os_major_ver, os_minor_ver, windows_version);
proto_tree_add_string(tree, hf_windows_version, tvb, offset, 2, windows_version);
/* OS major version */
proto_tree_add_item(tree, hf_os_major, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* OS minor version */
proto_tree_add_item(tree, hf_os_minor, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* server type flags */
offset = dissect_smb_server_type_flags(
tvb, offset, pinfo, tree, NULL, TRUE);
if (cmd == BROWSE_DOMAIN_ANNOUNCEMENT && tvb_get_letohs (tvb, offset + 2) != 0xAA55) {
/*
* Network Monitor claims this is a "Comment
* Pointer". I don't believe it.
*
* It's not a browser protocol major/minor
* version number, and signature constant,
* however.
*/
proto_tree_add_item(tree, hf_mysterious_field, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
/* browser protocol major version */
proto_tree_add_item(tree, hf_proto_major, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* browser protocol minor version */
proto_tree_add_item(tree, hf_proto_minor, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* signature constant */
proto_tree_add_item(tree, hf_sig_const, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
}
/* master browser server name or server comment */
namelen = tvb_strsize(tvb, offset);
proto_tree_add_item(tree,
(cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
hf_mb_server_name : hf_server_comment,
tvb, offset, namelen, ENC_ASCII|ENC_NA);
break;
}
case BROWSE_REQUEST_ANNOUNCE: {
guint8 *computer_name;
/* unused/unknown flags */
proto_tree_add_item(tree, hf_unused_flags,
tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* name of computer to which to send reply */
computer_name = tvb_get_stringz_enc(pinfo->pool, tvb, offset, &namelen, ENC_ASCII);
proto_tree_add_string(tree, hf_response_computer_name,
tvb, offset, namelen, computer_name);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", computer_name);
break;
}
case BROWSE_ELECTION_REQUEST:
/* election version */
proto_tree_add_item(tree, hf_election_version, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* criterion */
dissect_election_criterion(tvb, tree, offset);
offset += 4;
/* server uptime */
uptime = tvb_get_letohl(tvb, offset);
proto_tree_add_uint_format_value(tree, hf_server_uptime,
tvb, offset, 4, uptime,
"%s",
signed_time_msecs_to_str(pinfo->pool, uptime));
offset += 4;
/* next 4 bytes must be zero */
offset += 4;
/* server name */
namelen = tvb_strsize(tvb, offset);
proto_tree_add_item(tree, hf_server_name,
tvb, offset, namelen, ENC_ASCII);
break;
case BROWSE_BACKUP_LIST_REQUEST:
/* backup list requested count */
proto_tree_add_item(tree, hf_backup_count, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* backup requested token */
proto_tree_add_item(tree, hf_backup_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
break;
case BROWSE_BACKUP_LIST_RESPONSE:
/* backup list requested count */
server_count = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_backup_count, tvb, offset, 1,
server_count);
offset += 1;
/* backup requested token */
proto_tree_add_item(tree, hf_backup_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* backup server names */
for (i = 0; i < server_count; i++) {
namelen = tvb_strsize(tvb, offset);
proto_tree_add_item(tree, hf_backup_server,
tvb, offset, namelen, ENC_ASCII);
offset += namelen;
}
break;
case BROWSE_MASTER_ANNOUNCEMENT:
/* master browser server name */
namelen = tvb_strsize(tvb, offset);
proto_tree_add_item(tree, hf_mb_server_name,
tvb, offset, namelen, ENC_ASCII);
break;
case BROWSE_RESETBROWSERSTATE_ANNOUNCEMENT: {
static int * const flags[] = {
&hf_mb_reset_demote,
&hf_mb_reset_flush,
&hf_mb_reset_stop,
NULL
};
proto_tree_add_bitmask(tree, tvb, offset, hf_mb_reset_command, ett_browse_reset_cmd_flags, flags, ENC_NA);
break;
}
case BROWSE_BECOME_BACKUP:
/* name of browser to promote */
namelen = tvb_strsize(tvb, offset);
proto_tree_add_item(tree, hf_browser_to_promote,
tvb, offset, namelen, ENC_ASCII);
break;
}
return tvb_captured_length(tvb);
}
/*
* It appears that browser announcements sent to \MAILSLOT\LANMAN aren't
* the same as browser announcements sent to \MAILSLOT\BROWSE.
* Was that an older version of the protocol?
*
* The document at
*
* http://www.samba.org/samba/ftp/specs/brow_rev.txt
*
* gives both formats of host announcement packets, saying that
* "[The first] format seems wrong", that one being what appears to
* show up in \MAILSLOT\LANMAN packets, and that "[The second one]
* may be better", that one being what appears to show up in
* \MAILSLOT\BROWSE packets.
*
* XXX - what other browser packets go out to that mailslot?
*/
static int
dissect_mailslot_lanman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_)
{
int offset = 0;
guint8 cmd;
proto_tree *tree;
proto_item *item;
guint32 periodicity;
const guint8 *host_name;
guint8 os_major_ver, os_minor_ver;
const gchar *windows_version;
guint namelen;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "BROWSER");
col_clear(pinfo->cinfo, COL_INFO);
cmd = tvb_get_guint8(tvb, offset);
/* Put in something, and replace it later */
col_add_str(pinfo->cinfo, COL_INFO, val_to_str(cmd, commands, "Unknown command:0x%02x"));
item = proto_tree_add_item(parent_tree, proto_smb_browse, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_browse);
/* command */
proto_tree_add_uint(tree, hf_command, tvb, offset, 1, cmd);
offset += 1;
switch (cmd) {
case BROWSE_DOMAIN_ANNOUNCEMENT:
case BROWSE_LOCAL_MASTER_ANNOUNCEMENT:
case BROWSE_HOST_ANNOUNCE:
/* update count */
proto_tree_add_item(tree, hf_update_count, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* server type flags */
offset = dissect_smb_server_type_flags(
tvb, offset, pinfo, tree, NULL, TRUE);
/* OS version string (See "OSVERSIONINFO Structure" on MSDN) */
os_major_ver = tvb_get_guint8(tvb, offset);
os_minor_ver = tvb_get_guint8(tvb, offset+1);
SET_WINDOWS_VERSION_STRING(os_major_ver, os_minor_ver, windows_version);
proto_tree_add_string(tree, hf_windows_version, tvb, offset, 2, windows_version);
/* OS major version */
proto_tree_add_item(tree, hf_os_major, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* OS minor version */
proto_tree_add_item(tree, hf_os_minor, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* periodicity (in seconds; convert to milliseconds) */
periodicity = tvb_get_letohs(tvb, offset)*1000;
proto_tree_add_uint_format_value(tree, hf_periodicity, tvb, offset, 2,
periodicity,
"%s",
signed_time_msecs_to_str(pinfo->pool, periodicity));
offset += 2;
/* server name */
host_name = tvb_get_stringz_enc(pinfo->pool, tvb, offset, &namelen, ENC_CP437|ENC_NA);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", host_name);
proto_tree_add_item(tree, hf_server_name,
tvb, offset, namelen, ENC_ASCII);
offset += namelen;
/* master browser server name or server comment */
namelen = tvb_strsize(tvb, offset);
proto_tree_add_item(tree,
(cmd==BROWSE_DOMAIN_ANNOUNCEMENT)?
hf_mb_server_name : hf_server_comment,
tvb, offset, namelen, ENC_CP437|ENC_NA);
break;
}
return tvb_captured_length(tvb);
}
void
proto_register_smb_browse(void)
{
static hf_register_info hf[] = {
{ &hf_command,
{ "Command", "browser.command", FT_UINT8, BASE_HEX,
VALS(commands), 0, "Browse command opcode", HFILL }},
{ &hf_update_count,
{ "Update Count", "browser.update_count", FT_UINT8, BASE_DEC,
NULL, 0, "Browse Update Count", HFILL }},
{ &hf_periodicity,
{ "Update Periodicity", "browser.period", FT_UINT32, BASE_DEC,
NULL, 0, "Update Periodicity in ms", HFILL }},
{ &hf_server_name,
{ "Server Name", "browser.server", FT_STRING, BASE_NONE,
NULL, 0, "BROWSE Server Name", HFILL }},
{ &hf_mb_server_name,
{ "Master Browser Server Name", "browser.mb_server", FT_STRING, BASE_NONE,
NULL, 0, "BROWSE Master Browser Server Name", HFILL }},
{ &hf_mb_reset_command,
{ "ResetBrowserState Command", "browser.reset_cmd", FT_UINT8,
BASE_HEX, VALS(resetbrowserstate_command_names), 0,
NULL, HFILL }},
{ &hf_mb_reset_demote,
{ "Demote LMB", "browser.reset_cmd.demote", FT_BOOLEAN,
8, TFS(&tfs_demote_to_backup), 0x01, NULL, HFILL}},
{ &hf_mb_reset_flush,
{ "Flush Browse List", "browser.reset_cmd.flush", FT_BOOLEAN,
8, TFS(&tfs_flush_browse_list), 0x02, NULL, HFILL}},
{ &hf_mb_reset_stop,
{ "Stop Being LMB", "browser.reset_cmd.stop_lmb", FT_BOOLEAN,
8, TFS(&tfs_stop_being_lmb), 0x04, NULL, HFILL}},
{ &hf_os_major,
{ "OS Major Version", "browser.os_major", FT_UINT8, BASE_DEC,
NULL, 0, "Operating System Major Version", HFILL }},
{ &hf_os_minor,
{ "OS Minor Version", "browser.os_minor", FT_UINT8, BASE_DEC,
NULL, 0, "Operating System Minor Version", HFILL }},
{ &hf_server_type,
{ "Server Type", "browser.server_type", FT_UINT32, BASE_HEX,
NULL, 0, "Server Type Flags", HFILL }},
{ &hf_server_type_workstation,
{ "Workstation", "browser.server_type.workstation", FT_BOOLEAN, 32,
TFS(&tfs_workstation), 1U<<SERVER_WORKSTATION, "Is This A Workstation?", HFILL }},
{ &hf_server_type_server,
{ "Server", "browser.server_type.server", FT_BOOLEAN, 32,
TFS(&tfs_server), 1U<<SERVER_SERVER, "Is This A Server?", HFILL }},
{ &hf_server_type_sql,
{ "SQL", "browser.server_type.sql", FT_BOOLEAN, 32,
TFS(&tfs_sql), 1U<<SERVER_SQL_SERVER, "Is This A SQL Server?", HFILL }},
{ &hf_server_type_domain,
{ "Domain Controller", "browser.server_type.domain_controller", FT_BOOLEAN, 32,
TFS(&tfs_domain), 1U<<SERVER_DOMAIN_CONTROLLER, "Is This A Domain Controller?", HFILL }},
{ &hf_server_type_backup,
{ "Backup Controller", "browser.server_type.backup_controller", FT_BOOLEAN, 32,
TFS(&tfs_backup), 1U<<SERVER_BACKUP_CONTROLLER, "Is This A Backup Domain Controller?", HFILL }},
{ &hf_server_type_time,
{ "Time Source", "browser.server_type.time", FT_BOOLEAN, 32,
TFS(&tfs_time), 1U<<SERVER_TIME_SOURCE, "Is This A Time Source?", HFILL }},
{ &hf_server_type_apple,
{ "Apple", "browser.server_type.apple", FT_BOOLEAN, 32,
TFS(&tfs_apple), 1U<<SERVER_APPLE_SERVER, "Is This An Apple Server ?", HFILL }},
{ &hf_server_type_novell,
{ "Novell", "browser.server_type.novell", FT_BOOLEAN, 32,
TFS(&tfs_novell), 1U<<SERVER_NOVELL_SERVER, "Is This A Novell Server?", HFILL }},
{ &hf_server_type_member,
{ "Member", "browser.server_type.member", FT_BOOLEAN, 32,
TFS(&tfs_member), 1U<<SERVER_DOMAIN_MEMBER_SERVER, "Is This A Domain Member Server?", HFILL }},
{ &hf_server_type_print,
{ "Print", "browser.server_type.print", FT_BOOLEAN, 32,
TFS(&tfs_print), 1U<<SERVER_PRINT_QUEUE_SERVER, "Is This A Print Server?", HFILL }},
{ &hf_server_type_dialin,
{ "Dialin", "browser.server_type.dialin", FT_BOOLEAN, 32,
TFS(&tfs_dialin), 1U<<SERVER_DIALIN_SERVER, "Is This A Dialin Server?", HFILL }},
{ &hf_server_type_xenix,
{ "Xenix", "browser.server_type.xenix", FT_BOOLEAN, 32,
TFS(&tfs_xenix), 1U<<SERVER_XENIX_SERVER, "Is This A Xenix Server?", HFILL }},
{ &hf_server_type_ntw,
{ "NT Workstation", "browser.server_type.ntw", FT_BOOLEAN, 32,
TFS(&tfs_ntw), 1U<<SERVER_NT_WORKSTATION, "Is This A NT Workstation?", HFILL }},
{ &hf_server_type_wfw,
{ "WfW", "browser.server_type.wfw", FT_BOOLEAN, 32,
TFS(&tfs_wfw), 1U<<SERVER_WINDOWS_FOR_WORKGROUPS, "Is This A Windows For Workgroups Server?", HFILL }},
{ &hf_server_type_nts,
{ "NT Server", "browser.server_type.nts", FT_BOOLEAN, 32,
TFS(&tfs_nts), 1U<<SERVER_NT_SERVER, "Is This A NT Server?", HFILL }},
{ &hf_server_type_potentialb,
{ "Potential Browser", "browser.server_type.browser.potential", FT_BOOLEAN, 32,
TFS(&tfs_potentialb), 1U<<SERVER_POTENTIAL_BROWSER, "Is This A Potential Browser?", HFILL }},
{ &hf_server_type_backupb,
{ "Backup Browser", "browser.server_type.browser.backup", FT_BOOLEAN, 32,
TFS(&tfs_backupb), 1U<<SERVER_BACKUP_BROWSER, "Is This A Backup Browser?", HFILL }},
{ &hf_server_type_masterb,
{ "Master Browser", "browser.server_type.browser.master", FT_BOOLEAN, 32,
TFS(&tfs_masterb), 1U<<SERVER_MASTER_BROWSER, "Is This A Master Browser?", HFILL }},
{ &hf_server_type_domainmasterb,
{ "Domain Master Browser", "browser.server_type.browser.domain_master", FT_BOOLEAN, 32,
TFS(&tfs_domainmasterb), 1U<<SERVER_DOMAIN_MASTER_BROWSER, "Is This A Domain Master Browser?", HFILL }},
{ &hf_server_type_osf,
{ "OSF", "browser.server_type.osf", FT_BOOLEAN, 32,
TFS(&tfs_osf), 1U<<SERVER_OSF, "Is This An OSF server ?", HFILL }},
{ &hf_server_type_vms,
{ "VMS", "browser.server_type.vms", FT_BOOLEAN, 32,
TFS(&tfs_vms), 1U<<SERVER_VMS, "Is This A VMS Server?", HFILL }},
{ &hf_server_type_w95,
{ "Windows 95+", "browser.server_type.w95", FT_BOOLEAN, 32,
TFS(&tfs_w95), 1U<<SERVER_WINDOWS_95, "Is This A Windows 95 or above server?", HFILL }},
{ &hf_server_type_dfs,
{ "DFS", "browser.server_type.dfs", FT_BOOLEAN, 32,
TFS(&tfs_dfs), 1U<<SERVER_DFS_SERVER, "Is This A DFS server?", HFILL }},
{ &hf_server_type_local,
{ "Local", "browser.server_type.local", FT_BOOLEAN, 32,
TFS(&tfs_local), 1U<<SERVER_LOCAL_LIST_ONLY, "Is This A Local List Only request?", HFILL }},
{ &hf_server_type_domainenum,
{ "Domain Enum", "browser.server_type.domainenum", FT_BOOLEAN, 32,
TFS(&tfs_domainenum), 1U<<SERVER_DOMAIN_ENUM, "Is This A Domain Enum request?", HFILL }},
{ &hf_election_version,
{ "Election Version", "browser.election.version", FT_UINT8, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_proto_major,
{ "Browser Protocol Major Version", "browser.proto_major", FT_UINT8, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_proto_minor,
{ "Browser Protocol Minor Version", "browser.proto_minor", FT_UINT8, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_sig_const,
{ "Signature", "browser.sig", FT_UINT16, BASE_HEX,
NULL, 0, "Signature Constant", HFILL }},
{ &hf_server_comment,
{ "Host Comment", "browser.comment", FT_STRINGZ, BASE_NONE,
NULL, 0, "Server Comment", HFILL }},
{ &hf_unused_flags,
{ "Unused flags", "browser.unused", FT_UINT8, BASE_HEX,
NULL, 0, "Unused/unknown flags", HFILL }},
{ &hf_response_computer_name,
{ "Response Computer Name", "browser.response_computer_name", FT_STRINGZ, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_election_criteria,
{ "Election Criteria", "browser.election.criteria", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_election_desire,
{ "Election Desire", "browser.election.desire", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_election_desire_flags_backup,
{ "Backup", "browser.election.desire.backup", FT_BOOLEAN, 8,
TFS(&tfs_desire_backup), 1U<<DESIRE_BACKUP, "Is this a backup server", HFILL }},
{ &hf_election_desire_flags_standby,
{ "Standby", "browser.election.desire.standby", FT_BOOLEAN, 8,
TFS(&tfs_desire_standby), 1U<<DESIRE_STANDBY, "Is this a standby server?", HFILL }},
{ &hf_election_desire_flags_master,
{ "Master", "browser.election.desire.master", FT_BOOLEAN, 8,
TFS(&tfs_desire_master), 1U<<DESIRE_MASTER, "Is this a master server", HFILL }},
{ &hf_election_desire_flags_domain_master,
{ "Domain Master", "browser.election.desire.domain_master", FT_BOOLEAN, 8,
TFS(&tfs_desire_domain_master), 1U<<DESIRE_DOMAIN_MASTER, "Is this a domain master", HFILL }},
{ &hf_election_desire_flags_wins,
{ "WINS", "browser.election.desire.wins", FT_BOOLEAN, 8,
TFS(&tfs_desire_wins), 1U<<DESIRE_WINS, "Is this a WINS server", HFILL }},
{ &hf_election_desire_flags_nt,
{ "NT", "browser.election.desire.nt", FT_BOOLEAN, 8,
TFS(&tfs_desire_nt), 1U<<DESIRE_NT, "Is this a NT server", HFILL }},
#if 0
{ &hf_election_revision,
{ "Election Revision", "browser.election.revision", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
#endif
{ &hf_election_os,
{ "Election OS", "browser.election.os", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_election_os_wfw,
{ "WfW", "browser.election.os.wfw", FT_BOOLEAN, 8,
TFS(&tfs_os_wfw), 1U<<OS_WFW, "Is this a WfW host?", HFILL }},
{ &hf_election_os_ntw,
{ "NT Workstation", "browser.election.os.ntw", FT_BOOLEAN, 8,
TFS(&tfs_os_ntw), 1U<<OS_NTW, "Is this a NT Workstation?", HFILL }},
{ &hf_election_os_nts,
{ "NT Server", "browser.election.os.nts", FT_BOOLEAN, 8,
TFS(&tfs_os_nts), 1U<<OS_NTS, "Is this a NT Server?", HFILL }},
{ &hf_server_uptime,
{ "Uptime", "browser.uptime", FT_UINT32, BASE_DEC,
NULL, 0, "Server uptime in ms", HFILL }},
{ &hf_backup_count,
{ "Backup List Requested Count", "browser.backup.count", FT_UINT8, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_backup_token,
{ "Backup Request Token", "browser.backup.token", FT_UINT32, BASE_DEC,
NULL, 0, "Backup requested/response token", HFILL }},
{ &hf_backup_server,
{ "Backup Server", "browser.backup.server", FT_STRING, BASE_NONE,
NULL, 0, "Backup Server Name", HFILL }},
{ &hf_browser_to_promote,
{ "Browser to Promote", "browser.browser_to_promote", FT_STRINGZ, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_windows_version,
{ "Windows version", "browser.windows_version", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_mysterious_field,
{ "Mysterious Field", "browser.mysterious_field", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }},
};
static gint *ett[] = {
&ett_browse,
&ett_browse_flags,
&ett_browse_election_criteria,
&ett_browse_election_os,
&ett_browse_election_desire,
&ett_browse_reset_cmd_flags,
};
proto_smb_browse = proto_register_protocol("Microsoft Windows Browser Protocol",
"BROWSER", "browser");
proto_register_field_array(proto_smb_browse, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_dissector("mailslot_browse", dissect_mailslot_browse,
proto_smb_browse);
register_dissector("mailslot_lanman", dissect_mailslot_lanman,
proto_smb_browse);
}
/*
* Editor modelines - https://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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-smb-browse.h
|
/* packet-smb-browse.h
* Declaration of routines for SMB Browser packet dissection
* Copyright 1999, Richard Sharpe <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef _PACKET_SMB_BROWSE_H_
#define _PACKET_SMB_BROWSE_H_
int
dissect_smb_server_type_flags(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *parent_tree, guint8 *drep,
gboolean infoflag);
#endif
|
C
|
wireshark/epan/dissectors/packet-smb-common.c
|
/* packet-smb-common.c
* Common routines for smb packet dissection
* Copyright 2000, Jeffrey C. Foster <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Copied from packet-pop.c
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/strutil.h>
#include "packet-smb-common.h"
#include "packet-dns.h"
/*
* Share type values - used in LANMAN and in SRVSVC.
*
* XXX - should we dissect share type values, at least in SRVSVC, as
* a subtree with bitfields, as the 0x80000000 bit appears to be a
* hidden bit, with some number of bits at the bottom being the share
* type?
*
* Does LANMAN use that bit?
*/
const value_string share_type_vals[] = {
{0, "Directory tree"},
{1, "Printer queue"},
{2, "Communications device"},
{3, "IPC"},
{0x80000000, "Hidden Directory tree"},
{0x80000001, "Hidden Printer queue"},
{0x80000002, "Hidden Communications device"},
{0x80000003, "Hidden IPC"},
{0, NULL}
};
int display_ms_string(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int hf_index, char **data)
{
char *str;
gint len;
/* display a string from the tree and return the new offset */
str = tvb_get_stringz_enc(pinfo->pool, tvb, offset, &len, ENC_ASCII);
proto_tree_add_string(tree, hf_index, tvb, offset, len, str);
/* Return a copy of the string if requested */
if (data)
*data = str;
return offset+len;
}
int display_unicode_string(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int hf_index, char **data)
{
char *str;
int len;
/* display a unicode string from the tree and return new offset */
str = tvb_get_stringz_enc(pinfo->pool, tvb, offset, &len, ENC_UTF_16|ENC_LITTLE_ENDIAN);
proto_tree_add_string(tree, hf_index, tvb, offset, len, str);
/* Return a copy of the string if requested */
if (data)
*data = str;
return offset+len;
}
/* Max string length for displaying Unicode strings. */
#define MAX_UNICODE_STR_LEN 256
int dissect_ms_compressed_string(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int hf_index,
const char **data)
{
int compr_len;
gint str_len;
const gchar *str = NULL;
/* The name data MUST start at offset 0 of the tvb */
compr_len = get_dns_name(tvb, offset, MAX_UNICODE_STR_LEN+3+1, 0, &str, &str_len);
proto_tree_add_string(tree, hf_index, tvb, offset, compr_len, format_text(pinfo->pool, str, str_len));
if (data)
*data = str;
return offset + compr_len;
}
/*
* Editor modelines - https://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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-smb-common.h
|
/* packet-smb-common.h
* Routines for SMB packet dissection
* Copyright 1999, Richard Sharpe <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Copied from packet-pop.c
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PACKET_SMB_COMMON_H__
#define __PACKET_SMB_COMMON_H__
/* **data is allocated with ephemeral scope and will be automatically freed
* when packet dissection completes.
* You do NOT need to g_free() that string.
*/
int display_unicode_string(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int hf_index, char **data);
int display_ms_string(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int hf_index, char **data);
int dissect_ms_compressed_string(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int hf_index,
const char **data);
extern const value_string share_type_vals[];
#endif
|
C
|
wireshark/epan/dissectors/packet-smb-direct.c
|
/*
* packet-smb-direct.c
*
* Routines for [MS-SMBD] the RDMA transport layer for SMB2/3
*
* Copyright 2012-2014 Stefan Metzmacher <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/reassemble.h>
#include <epan/prefs.h>
#include <epan/proto_data.h>
#include "packet-windows-common.h"
#include "packet-iwarp-ddp-rdmap.h"
#include "packet-infiniband.h"
void proto_register_smb_direct(void);
void proto_reg_handoff_smb_direct(void);
static int proto_smb_direct = -1;
static gint ett_smb_direct = -1;
static gint ett_smb_direct_hdr = -1;
static gint ett_smb_direct_flags = -1;
static gint ett_smb_direct_fragment = -1;
static gint ett_smb_direct_fragments = -1;
static int hf_smb_direct_negotiate_request = -1;
static int hf_smb_direct_negotiate_response = -1;
static int hf_smb_direct_data_message = -1;
static int hf_smb_direct_min_version = -1;
static int hf_smb_direct_max_version = -1;
static int hf_smb_direct_negotiated_version = -1;
static int hf_smb_direct_credits_requested = -1;
static int hf_smb_direct_credits_granted = -1;
static int hf_smb_direct_status = -1;
static int hf_smb_direct_max_read_write_size = -1;
static int hf_smb_direct_preferred_send_size = -1;
static int hf_smb_direct_max_receive_size = -1;
static int hf_smb_direct_max_fragmented_size = -1;
static int hf_smb_direct_flags = -1;
static int hf_smb_direct_flags_response_requested = -1;
static int hf_smb_direct_remaining_length = -1;
static int hf_smb_direct_data_offset = -1;
static int hf_smb_direct_data_length = -1;
static int hf_smb_direct_fragments = -1;
static int hf_smb_direct_fragment = -1;
static int hf_smb_direct_fragment_overlap = -1;
static int hf_smb_direct_fragment_overlap_conflict = -1;
static int hf_smb_direct_fragment_multiple_tails = -1;
static int hf_smb_direct_fragment_too_long_fragment = -1;
static int hf_smb_direct_fragment_error = -1;
static int hf_smb_direct_fragment_count = -1;
static int hf_smb_direct_reassembled_in = -1;
static int hf_smb_direct_reassembled_length = -1;
static int hf_smb_direct_reassembled_data = -1;
static const fragment_items smb_direct_frag_items = {
&ett_smb_direct_fragment,
&ett_smb_direct_fragments,
&hf_smb_direct_fragments,
&hf_smb_direct_fragment,
&hf_smb_direct_fragment_overlap,
&hf_smb_direct_fragment_overlap_conflict,
&hf_smb_direct_fragment_multiple_tails,
&hf_smb_direct_fragment_too_long_fragment,
&hf_smb_direct_fragment_error,
&hf_smb_direct_fragment_count,
&hf_smb_direct_reassembled_in,
&hf_smb_direct_reassembled_length,
&hf_smb_direct_reassembled_data,
"SMB Direct fragments"
};
enum SMB_DIRECT_HDR_TYPE {
SMB_DIRECT_HDR_UNKNOWN = -1,
SMB_DIRECT_HDR_NEG_REQ = 1,
SMB_DIRECT_HDR_NEG_REP = 2,
SMB_DIRECT_HDR_DATA = 3
};
#define SMB_DIRECT_RESPONSE_REQUESTED 0x0001
static heur_dissector_list_t smb_direct_heur_subdissector_list;
static gboolean smb_direct_reassemble = TRUE;
static reassembly_table smb_direct_reassembly_table;
static void
dissect_smb_direct_payload(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, guint32 remaining_length)
{
gboolean save_fragmented = pinfo->fragmented;
int save_visited = pinfo->fd->visited;
conversation_t *conversation = NULL;
fragment_head *fd_head = NULL;
tvbuff_t *payload_tvb = NULL;
gboolean more_frags = FALSE;
gboolean fd_head_not_cached = FALSE;
heur_dtbl_entry_t *hdtbl_entry;
if (!smb_direct_reassemble) {
payload_tvb = tvb;
goto dissect_payload;
}
conversation = find_or_create_conversation(pinfo);
if (remaining_length > 0) {
more_frags = TRUE;
}
fd_head = (fragment_head *)p_get_proto_data(wmem_file_scope(), pinfo, proto_smb_direct, 0);
if (fd_head == NULL) {
fd_head_not_cached = TRUE;
pinfo->fd->visited = 0;
fd_head = fragment_add_seq_next(&smb_direct_reassembly_table,
tvb, 0, pinfo,
conversation->conv_index,
NULL, tvb_captured_length(tvb),
more_frags);
}
if (fd_head == NULL) {
/*
* We really want the fd_head and pass it to
* process_reassembled_data()
*
* So that individual fragments gets the
* reassembled in field.
*/
fd_head = fragment_get_reassembled_id(&smb_direct_reassembly_table,
pinfo,
conversation->conv_index);
}
if (fd_head == NULL) {
/*
* we need more data...
*/
goto done;
}
if (fd_head_not_cached) {
p_add_proto_data(wmem_file_scope(), pinfo,
proto_smb_direct, 0, fd_head);
}
payload_tvb = process_reassembled_data(tvb, 0, pinfo,
"Reassembled SMB Direct",
fd_head,
&smb_direct_frag_items,
NULL, /* update_col_info*/
tree);
if (payload_tvb == NULL) {
/*
* we need more data...
*/
goto done;
}
dissect_payload:
pinfo->fragmented = FALSE;
if (!dissector_try_heuristic(smb_direct_heur_subdissector_list,
payload_tvb, pinfo, tree, &hdtbl_entry, NULL)) {
call_data_dissector(payload_tvb, pinfo, tree);
}
done:
pinfo->fragmented = save_fragmented;
pinfo->fd->visited = save_visited;
return;
}
static void
dissect_smb_direct(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
enum SMB_DIRECT_HDR_TYPE hdr_type)
{
proto_tree *tree = NULL;
proto_item *item = NULL;
proto_tree *neg_req_tree = NULL;
proto_tree *neg_rep_tree = NULL;
proto_tree *data_tree = NULL;
int offset = 0;
guint32 status = 0;
guint32 remaining_length = 0;
guint32 data_offset = 0;
guint32 data_length = 0;
guint rlen = tvb_reported_length(tvb);
gint len = 0;
tvbuff_t *next_tvb = NULL;
static int * const flags[] = {
&hf_smb_direct_flags_response_requested,
NULL
};
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMBDirect");
col_clear(pinfo->cinfo, COL_INFO);
if (parent_tree != NULL) {
item = proto_tree_add_item(parent_tree, proto_smb_direct, tvb, 0, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb_direct);
}
switch (hdr_type) {
case SMB_DIRECT_HDR_UNKNOWN:
break;
case SMB_DIRECT_HDR_NEG_REQ:
col_append_str(pinfo->cinfo, COL_INFO, "NegotiateRequest");
if (tree == NULL) {
break;
}
item = proto_tree_add_item(tree, hf_smb_direct_negotiate_request, tvb, 0, -1, ENC_NA);
neg_req_tree = proto_item_add_subtree(item, ett_smb_direct_hdr);
proto_tree_add_item(neg_req_tree, hf_smb_direct_min_version,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(neg_req_tree, hf_smb_direct_max_version,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* 2 bytes reserved */
offset += 2;
proto_tree_add_item(neg_req_tree, hf_smb_direct_credits_requested,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(neg_req_tree, hf_smb_direct_preferred_send_size,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(neg_req_tree, hf_smb_direct_max_receive_size,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(neg_req_tree, hf_smb_direct_max_fragmented_size,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
/* offset += 4; */
break;
case SMB_DIRECT_HDR_NEG_REP:
col_append_str(pinfo->cinfo, COL_INFO, "NegotiateResponse");
status = tvb_get_letohl(tvb, 12);
if (status != 0) {
col_append_fstr(
pinfo->cinfo, COL_INFO, ", Error: %s",
val_to_str(status, NT_errors, "Unknown (0x%08X)"));
}
if (tree == NULL) {
break;
}
item = proto_tree_add_item(tree, hf_smb_direct_negotiate_response, tvb, 0, -1, ENC_NA);
neg_rep_tree = proto_item_add_subtree(item, ett_smb_direct_hdr);
proto_tree_add_item(neg_rep_tree, hf_smb_direct_min_version,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(neg_rep_tree, hf_smb_direct_max_version,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(neg_rep_tree, hf_smb_direct_negotiated_version,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* 2 bytes reserved */
offset += 2;
proto_tree_add_item(neg_rep_tree, hf_smb_direct_credits_requested,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(neg_rep_tree, hf_smb_direct_credits_granted,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(neg_rep_tree, hf_smb_direct_status,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(neg_rep_tree, hf_smb_direct_max_read_write_size,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(neg_rep_tree, hf_smb_direct_preferred_send_size,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(neg_rep_tree, hf_smb_direct_max_receive_size,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(neg_rep_tree, hf_smb_direct_max_fragmented_size,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
/* offset += 4; */
break;
case SMB_DIRECT_HDR_DATA:
col_append_str(pinfo->cinfo, COL_INFO, "DataMessage");
rlen = MIN(rlen, 24);
item = proto_tree_add_item(tree, hf_smb_direct_data_message, tvb, 0, rlen, ENC_NA);
data_tree = proto_item_add_subtree(item, ett_smb_direct_hdr);
proto_tree_add_item(data_tree, hf_smb_direct_credits_requested,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(data_tree, hf_smb_direct_credits_granted,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_bitmask(data_tree, tvb, offset, hf_smb_direct_flags,
ett_smb_direct_flags, flags, ENC_LITTLE_ENDIAN);
offset += 2;
/* 2 bytes reserved */
offset += 2;
remaining_length = tvb_get_letohl(tvb, offset);
proto_tree_add_item(data_tree, hf_smb_direct_remaining_length,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
data_offset = tvb_get_letohl(tvb, offset);
proto_tree_add_item(data_tree, hf_smb_direct_data_offset,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
data_length = tvb_get_letohl(tvb, offset);
proto_tree_add_item(data_tree, hf_smb_direct_data_length,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
if (data_length > 0 && data_offset > (guint32)offset) {
len = tvb_reported_length_remaining(tvb, data_offset);
}
if (data_length <= (guint32)len) {
next_tvb = tvb_new_subset_length(tvb, data_offset,
data_length);
}
if (next_tvb != NULL) {
dissect_smb_direct_payload(next_tvb, pinfo,
parent_tree, remaining_length);
}
/* offset = data_offset + data_length; */
break;
}
return;
}
static enum SMB_DIRECT_HDR_TYPE
is_smb_direct(tvbuff_t *tvb, packet_info *pinfo _U_)
{
gboolean maybe_neg_req = FALSE;
gboolean maybe_data = FALSE;
guint len = tvb_reported_length(tvb);
if (len < 20) {
return SMB_DIRECT_HDR_UNKNOWN;
}
if (len == 32 &&
tvb_get_letohs(tvb, 0) == 0x0100 && /* min version */
tvb_get_letohs(tvb, 2) == 0x0100 && /* max version */
tvb_get_letohs(tvb, 4) == 0x0100 && /* negotiated version */
tvb_get_letohs(tvb, 6) == 0x0000) /* reserved */
{
/* Negotiate Response */
return SMB_DIRECT_HDR_NEG_REP;
}
if (tvb_get_letohs(tvb, 0) == 0x0100 && /* min version */
tvb_get_letohs(tvb, 2) == 0x0100 && /* max version */
tvb_get_letohs(tvb, 4) == 0x0000) /* reserved */
{
maybe_neg_req = TRUE;
}
if (tvb_get_letohs(tvb, 0) <= 255 && /* credits up to 255 */
tvb_get_letohs(tvb, 2) <= 255 && /* credits up to 255 */
tvb_get_letohs(tvb, 4) <= 1 && /* flags 0 or 1 */
tvb_get_letohs(tvb, 6) == 0) /* reserved */
{
maybe_data = TRUE;
}
if (len == 20) {
if (tvb_get_letohl(tvb, 8) != 0) { /* remaining */
maybe_data = FALSE;
}
if (tvb_get_letohl(tvb, 12) != 0) { /* data offset */
maybe_data = FALSE;
}
if (tvb_get_letohl(tvb, 16) != 0) { /* data length */
maybe_data = FALSE;
}
if (maybe_neg_req && !maybe_data) {
/* Negotiate Request */
return SMB_DIRECT_HDR_NEG_REQ;
}
/* maybe_neg_req = FALSE; */
if (maybe_data) {
/* Data Message */
return SMB_DIRECT_HDR_DATA;
}
}
if (len <= 24) {
return SMB_DIRECT_HDR_UNKNOWN;
}
if (tvb_get_letohl(tvb, 12) != 24) { /* data offset */
return SMB_DIRECT_HDR_UNKNOWN;
}
if (tvb_get_letohl(tvb, 16) == 0) { /* data length */
return SMB_DIRECT_HDR_UNKNOWN;
}
if (tvb_get_letohl(tvb, 20) != 0) { /* padding */
return SMB_DIRECT_HDR_UNKNOWN;
}
if (maybe_data) {
/* Data Message */
return SMB_DIRECT_HDR_DATA;
}
return SMB_DIRECT_HDR_UNKNOWN;
}
static gboolean
dissect_smb_direct_iwarp_heur(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *parent_tree, void *data)
{
struct rdmapinfo *info = (struct rdmapinfo *)data;
enum SMB_DIRECT_HDR_TYPE hdr_type;
if (info == NULL) {
return FALSE;
}
switch (info->opcode) {
case RDMA_SEND:
case RDMA_SEND_INVALIDATE:
case RDMA_SEND_SE:
case RDMA_SEND_SE_INVALIDATE:
break;
default:
return FALSE;
}
hdr_type = is_smb_direct(tvb, pinfo);
if (hdr_type == SMB_DIRECT_HDR_UNKNOWN) {
return FALSE;
}
dissect_smb_direct(tvb, pinfo, parent_tree, hdr_type);
return TRUE;
}
static int
dissect_smb_direct_infiniband(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *parent_tree, void *data)
{
struct infinibandinfo *info = (struct infinibandinfo *)data;
enum SMB_DIRECT_HDR_TYPE hdr_type;
if (info == NULL) {
return 0;
}
switch (info->opCode) {
case RC_SEND_FIRST:
case RC_SEND_MIDDLE:
case RC_SEND_LAST:
case RC_SEND_LAST_IMM:
case RC_SEND_ONLY:
case RC_SEND_ONLY_IMM:
case RC_SEND_LAST_INVAL:
case RC_SEND_ONLY_INVAL:
break;
default:
return 0;
}
hdr_type = is_smb_direct(tvb, pinfo);
if (hdr_type == SMB_DIRECT_HDR_UNKNOWN) {
return 0;
}
dissect_smb_direct(tvb, pinfo, parent_tree, hdr_type);
return tvb_captured_length(tvb);
}
static gboolean
dissect_smb_direct_infiniband_heur(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *parent_tree, void *data)
{
return (dissect_smb_direct_infiniband(tvb, pinfo, parent_tree, data) > 0);
}
void proto_register_smb_direct(void)
{
static gint *ett[] = {
&ett_smb_direct,
&ett_smb_direct_hdr,
&ett_smb_direct_flags,
&ett_smb_direct_fragment,
&ett_smb_direct_fragments,
};
static hf_register_info hf[] = {
{ &hf_smb_direct_negotiate_request,
{ "NegotiateRequest", "smb_direct.negotiate_request",
FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_smb_direct_negotiate_response,
{ "NegotiateResponse", "smb_direct.negotiate_response",
FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_smb_direct_data_message,
{ "DataMessage", "smb_direct.data_message",
FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_smb_direct_min_version,
{ "MinVersion", "smb_direct.version.min",
FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_max_version,
{ "MaxVersion", "smb_direct.version.max",
FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_negotiated_version,
{ "NegotiatedVersion", "smb_direct.version.negotiated",
FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_credits_requested,
{ "CreditsRequested", "smb_direct.credits.requested",
FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_credits_granted,
{ "CreditsGranted", "smb_direct.credits.granted",
FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_status,
{ "Status", "smb_direct.status",
FT_UINT32, BASE_HEX, VALS(NT_errors), 0,
"NT Status code", HFILL }},
{ &hf_smb_direct_max_read_write_size,
{ "MaxReadWriteSize", "smb_direct.max_read_write_size",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_preferred_send_size,
{ "PreferredSendSize", "smb_direct.preferred_send_size",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_max_receive_size,
{ "MaxReceiveSize", "smb_direct.max_receive_size",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_max_fragmented_size,
{ "MaxFragmentedSize", "smb_direct.max_fragmented_size",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_flags,
{ "Flags", "smb_direct.flags",
FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_flags_response_requested,
{ "ResponseRequested", "smb_direct.flags.response_requested",
FT_BOOLEAN, 16, NULL, SMB_DIRECT_RESPONSE_REQUESTED,
NULL, HFILL }},
{ &hf_smb_direct_remaining_length,
{ "RemainingLength", "smb_direct.remaining_length",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_data_offset,
{ "DataOffset", "smb_direct.data_offset",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_data_length,
{ "DataLength", "smb_direct.data_length",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_fragments,
{ "Reassembled SMB Direct Fragments", "smb_direct.fragments",
FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_fragment,
{ "SMB Direct Fragment", "smb_direct.fragment",
FT_FRAMENUM, BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_fragment_overlap,
{ "Fragment overlap", "smb_direct.fragment.overlap",
FT_BOOLEAN, BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_fragment_overlap_conflict,
{ "Conflicting data in fragment overlap", "smb_direct.fragment.overlap.conflict",
FT_BOOLEAN, BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_fragment_multiple_tails,
{ "Multiple tail fragments found", "smb_direct.fragment.multipletails",
FT_BOOLEAN, BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_fragment_too_long_fragment,
{ "Fragment too long", "smb_direct.fragment.toolongfragment",
FT_BOOLEAN, BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_fragment_error,
{ "Defragmentation error", "smb_direct.fragment.error",
FT_FRAMENUM, BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_fragment_count,
{ "Fragment count", "smb_direct.fragment.count",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_smb_direct_reassembled_in,
{ "Reassembled PDU in frame", "smb_direct.reassembled_in",
FT_FRAMENUM, BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_reassembled_length,
{ "Reassembled SMB Direct length", "smb_direct.reassembled.length",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }},
{ &hf_smb_direct_reassembled_data,
{ "Reassembled SMB Direct data", "smb_direct.reassembled.data",
FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
};
module_t *smb_direct_module;
proto_smb_direct = proto_register_protocol("SMB-Direct (SMB RDMA Transport)",
"SMBDirect", "smb_direct");
proto_register_subtree_array(ett, array_length(ett));
proto_register_field_array(proto_smb_direct, hf, array_length(hf));
smb_direct_heur_subdissector_list = register_heur_dissector_list("smb_direct", proto_smb_direct);
smb_direct_module = prefs_register_protocol(proto_smb_direct, NULL);
prefs_register_bool_preference(smb_direct_module,
"reassemble_smb_direct",
"Reassemble SMB Direct fragments",
"Whether the SMB Direct dissector should reassemble fragmented payloads",
&smb_direct_reassemble);
reassembly_table_register(&smb_direct_reassembly_table,
&addresses_ports_reassembly_table_functions);
}
void
proto_reg_handoff_smb_direct(void)
{
heur_dissector_add("iwarp_ddp_rdmap",
dissect_smb_direct_iwarp_heur,
"SMB Direct over iWARP", "smb_direct_iwarp",
proto_smb_direct, HEURISTIC_ENABLE);
heur_dissector_add("infiniband.payload",
dissect_smb_direct_infiniband_heur,
"SMB Direct Infiniband", "smb_direct_infiniband",
proto_smb_direct, HEURISTIC_ENABLE);
dissector_add_for_decode_as("infiniband", create_dissector_handle( dissect_smb_direct_infiniband, proto_smb_direct ) );
}
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-smb-logon.c
|
/* packet-smb-logon.c
* Routines for SMB net logon packet dissection
* Copyright 2000, Jeffrey C. Foster <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Copied from packet-pop.c
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include "packet-windows-common.h"
#include "packet-smb-common.h"
void proto_register_smb_logon(void);
static int proto_smb_logon = -1;
static int hf_command = -1;
static int hf_computer_name = -1;
static int hf_unicode_computer_name = -1;
static int hf_server_name = -1;
static int hf_user_name = -1;
static int hf_domain_name = -1;
static int hf_server_dns_name = -1;
static int hf_forest_dns_name = -1;
static int hf_domain_dns_name = -1;
static int hf_mailslot_name = -1;
static int hf_pdc_name = -1;
static int hf_unicode_pdc_name = -1;
static int hf_script_name = -1;
static int hf_nt_version = -1;
static int hf_lmnt_token = -1;
static int hf_lm_token = -1;
static int hf_major_version = -1;
static int hf_minor_version = -1;
static int hf_os_version = -1;
static int hf_signature = -1;
static int hf_date_time = -1;
static int hf_update_type = -1;
static int hf_request_count = -1;
static int hf_account_control = -1;
static int hf_flags_autolock = -1;
static int hf_flags_expire = -1;
static int hf_flags_server_trust = -1;
static int hf_flags_workstation_trust = -1;
static int hf_flags_interdomain_trust = -1;
static int hf_flags_mns_user = -1;
static int hf_flags_normal_user = -1;
static int hf_flags_temp_dup_user = -1;
static int hf_flags_password_required = -1;
static int hf_flags_homedir_required = -1;
static int hf_flags_enabled = -1;
static int hf_domain_sid_size = -1;
static int hf_low_serial = -1;
static int hf_pulse = -1;
static int hf_random = -1;
static int hf_db_count = -1;
static int hf_db_index = -1;
static int hf_large_serial = -1;
static int hf_nt_date_time = -1;
static int hf_unknown8 = -1;
static int hf_unknown32 = -1;
static int hf_domain_guid = -1;
static int hf_server_ip = -1;
static int hf_server_site_name = -1;
static int hf_client_site_name = -1;
static int hf_data = -1;
static int ett_smb_logon = -1;
static int ett_smb_account_flags = -1;
static int ett_smb_db_info = -1;
#define ACC_FLAG_AUTO_LOCKED 0x00000400
#define ACC_FLAG_EXPIRE 0x00000200
#define ACC_FLAG_SERVER_TRUST 0x00000100
#define ACC_FLAG_WORKSTATION_TRUST 0x00000080
#define ACC_FLAG_INTERDOMAIN_TRUST 0x00000040
#define ACC_FLAG_MNS_USER 0x00000020
#define ACC_FLAG_NORMAL_USER 0x00000010
#define ACC_FLAG_TEMP_DUP_USER 0x00000008
#define ACC_FLAG_PASSWORD_REQUIRED 0x00000004
#define ACC_FLAG_HOMEDIR_REQUIRED 0x00000002
#define ACC_FLAG_ENABLED 0x00000001
static const true_false_string tfs_flags_autolock = {
"User account auto-locked",
"User account NOT auto-locked"
};
static const true_false_string tfs_flags_expire = {
"User password will NOT expire",
"User password will expire"
};
static const true_false_string tfs_flags_server_trust = {
"Server Trust user account",
"NOT a Server Trust user account"
};
static const true_false_string tfs_flags_workstation_trust = {
"Workstation Trust user account",
"NOT a Workstation Trust user account"
};
static const true_false_string tfs_flags_interdomain_trust = {
"Inter-domain Trust user account",
"NOT a Inter-domain Trust user account"
};
static const true_false_string tfs_flags_mns_user = {
"MNS Logon user account",
"NOT a MNS Logon user account"
};
static const true_false_string tfs_flags_normal_user = {
"Normal user account",
"NOT a normal user account"
};
static const true_false_string tfs_flags_temp_dup_user = {
"Temp duplicate user account",
"NOT a temp duplicate user account"
};
static const true_false_string tfs_flags_password_required = {
"NO password required",
"Password required"
};
static const true_false_string tfs_flags_homedir_required = {
"NO homedir required",
"Homedir required"
};
static const true_false_string tfs_flags_enabled = {
"User account enabled",
"User account disabled"
};
static int
dissect_account_control(tvbuff_t *tvb, proto_tree *tree, int offset)
{
/* display the Allowable Account control bits */
static int * const flags[] = {
&hf_flags_autolock,
&hf_flags_expire,
&hf_flags_server_trust,
&hf_flags_workstation_trust,
&hf_flags_interdomain_trust,
&hf_flags_mns_user,
&hf_flags_normal_user,
&hf_flags_temp_dup_user,
&hf_flags_password_required,
&hf_flags_homedir_required,
&hf_flags_enabled,
NULL
};
proto_tree_add_bitmask(tree, tvb, offset, hf_account_control, ett_smb_account_flags, flags, ENC_LITTLE_ENDIAN);
offset += 4;
return offset;
}
static int
display_LM_token(tvbuff_t *tvb, int offset, proto_tree *tree)
{
guint16 Token;
Token = tvb_get_letohs(tvb, offset);
if (Token & 0x01) {
proto_tree_add_uint_format(tree, hf_lm_token, tvb, offset, 2,
Token,
"LM20 Token: 0x%04x (LanMan 2.0 or higher)", Token);
} else {
/*
* XXX - are all values with the lower bit set LM 2.0,
* and all values with it not set LM 1.0?
* What do the other bits mean, if anything?
*/
proto_tree_add_uint_format(tree, hf_lm_token, tvb, offset, 2,
Token,
"LM10 Token: 0x%04x (WFW Networking)", Token);
}
offset += 2;
return offset;
}
static int
display_LMNT_token(tvbuff_t *tvb, int offset, proto_tree *tree)
{
guint16 Token;
Token = tvb_get_letohs(tvb, offset);
if (Token == 0xffff) {
proto_tree_add_uint_format_value(tree, hf_lmnt_token, tvb, offset, 2,
Token,
"0x%04x (Windows NT Networking)", Token);
} else {
/*
* XXX - what is it if it's not 0xffff?
*/
proto_tree_add_uint_format(tree, hf_lm_token, tvb, offset, 2,
Token,
"LMNT Token: 0x%04x (Unknown)", Token);
}
offset += 2;
return offset;
}
static int
dissect_smb_logon_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
/*** 0x00 (LM1.0/LM2.0 LOGON Request) ***/
/* computer name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_computer_name, NULL);
/* user name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_user_name, NULL);
/* mailslot name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_mailslot_name, NULL);
/*$$$$$ here add the Mailslot to the response list (if needed) */
/* Request count */
proto_tree_add_item(tree, hf_request_count, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* NT version */
proto_tree_add_item(tree, hf_nt_version, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* LM token */
offset = display_LM_token(tvb, offset, tree);
return offset;
}
static int
dissect_smb_logon_LM10_resp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
/*** 0x01 LanMan 1.0 Logon response ***/
/* user name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_user_name, NULL);
/* script name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_script_name, NULL);
return offset;
}
static int
dissect_smb_logon_2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
/*** 0x02 LM1.0 Query - Centralized Initialization ***/
/*** 0x03 LM1.0 Query - Distributed Initialization ***/
/*** 0x04 LM1.0 Query - Centralized Query Response ***/
/*** 0x04 LM1.0 Query - Distributed Query Response ***/
/* computer name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_computer_name, NULL);
/* mailslot name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_mailslot_name, NULL);
/* NT version */
proto_tree_add_item(tree, hf_nt_version, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* LM token */
offset = display_LM_token(tvb, offset, tree);
return offset;
}
static int
dissect_smb_logon_LM20_resp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
/*** 0x06 (LM2.0 LOGON Response) ***/
/* server name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_server_name, NULL);
/* LM token */
offset = display_LM_token(tvb, offset, tree);
return offset;
}
static int
dissect_smb_pdc_query(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
char *name;
/*** 0x07 Query for Primary PDC ***/
/* computer name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_computer_name, &name);
col_append_fstr(pinfo->cinfo, COL_INFO, " from %s", name);
/* mailslot name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_mailslot_name, NULL);
if (tvb_reported_length_remaining(tvb, offset) > 2) {
/*
* NT-style Query for PDC?
* If only 2 bytes remain, it's probably a Windows 95-style
* query, which has only an LM token after the mailslot
* name.
*
* XXX - base this on flags in the SMB header, e.g.
* the ASCII/Unicode strings flag?
*/
if (offset % 2) offset++; /* word align ... */
/* Unicode computer name */
offset = display_unicode_string(tvb, pinfo, tree, offset, hf_unicode_computer_name, NULL);
/* NT version */
proto_tree_add_item(tree, hf_nt_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* LMNT token */
offset = display_LMNT_token(tvb, offset, tree);
}
/* LM token */
offset = display_LM_token(tvb, offset, tree);
return offset;
}
static int
dissect_smb_pdc_startup(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
/*** 0x08 Announce startup of PDC ***/
/* pdc name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_pdc_name, NULL);
/* A short Announce will not have the rest */
if (tvb_reported_length_remaining(tvb, offset) != 0) {
char *name = NULL;
if (offset % 2) offset++; /* word align ... */
/* pdc name */
offset = display_unicode_string(tvb, pinfo, tree, offset, hf_unicode_pdc_name, &name);
if (name) {
col_append_fstr(pinfo->cinfo, COL_INFO, ": host %s", name);
name = NULL;
}
if (offset % 2) offset++;
/* domain name */
offset = display_unicode_string(tvb, pinfo, tree, offset, hf_domain_name, &name);
if (name) {
col_append_fstr(pinfo->cinfo, COL_INFO, ", domain %s", name);
name = NULL;
}
/* NT version */
proto_tree_add_item(tree, hf_nt_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* LMNT token */
offset = display_LMNT_token(tvb, offset, tree);
/* LM token */
offset = display_LM_token(tvb, offset, tree);
}
return offset;
}
static int
dissect_smb_pdc_failure(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
/*** 0x09 Announce failure of the PDC ***/
/*** 0x0F LM2.0 Resp. during LOGON pause ***/
/*** 0x10 (LM 2.0 Unknown user response) ***/
/* NT version */
proto_tree_add_item(tree, hf_nt_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* LM token */
offset = display_LM_token(tvb, offset, tree);
return offset;
}
static int
dissect_announce_change(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
/*** 0x0A ( Announce change to UAS or SAM ) ***/
guint32 info_count;
proto_tree *info_tree;
guint32 db_index;
guint32 domain_sid_size;
/* low serial number */
proto_tree_add_item(tree, hf_low_serial, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* date/time */
/* XXX - what format is this? Neither SMB_Date/SMB_Time nor
"time_t but in the local time zone" appear to be correct. */
proto_tree_add_item(tree, hf_date_time, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* pulse */
proto_tree_add_item(tree, hf_pulse, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* random */
proto_tree_add_item(tree, hf_random, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* pdc name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_pdc_name, NULL);
/* domain name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_domain_name, NULL);
if (offset % 2) offset++; /* word align ... */
if (tvb_reported_length_remaining(tvb, offset) > 2) {
/*
* XXX - older protocol versions don't have this stuff?
*/
/* pdc name */
offset = display_unicode_string(tvb, pinfo, tree, offset, hf_unicode_pdc_name, NULL);
/* domain name */
offset = display_unicode_string(tvb, pinfo, tree, offset, hf_domain_name, NULL);
/* DB count */
info_count = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_db_count, tvb, offset, 4, info_count);
offset += 4;
while (info_count != 0) {
db_index = tvb_get_letohl(tvb, offset);
info_tree = proto_tree_add_subtree_format(tree, tvb, offset, 20,
ett_smb_db_info, NULL, "DBChange Info Structure: index %u", db_index);
proto_tree_add_uint(info_tree, hf_db_index, tvb, offset, 4,
db_index);
offset += 4;
proto_tree_add_item(info_tree, hf_large_serial, tvb, offset, 8,
ENC_LITTLE_ENDIAN);
offset += 8;
offset = dissect_nt_64bit_time(tvb, info_tree, offset,
hf_nt_date_time);
info_count--;
}
/* Domain SID Size */
domain_sid_size = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_domain_sid_size, tvb, offset, 4,
domain_sid_size);
offset += 4;
if (domain_sid_size != 0) {
/* Align to four-byte boundary */
offset = ((offset + 3)/4)*4;
/* Domain SID */
offset = dissect_nt_sid(
tvb, offset, tree, "Domain", NULL, -1);
}
/* NT version */
proto_tree_add_item(tree, hf_nt_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* LMNT token */
offset = display_LMNT_token(tvb, offset, tree);
}
/* LM token */
offset = display_LM_token(tvb, offset, tree);
return offset;
}
static int
dissect_smb_sam_logon_req(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
/* Netlogon command 0x12 - decode the SAM logon request from client */
guint32 domain_sid_size;
/* Request count */
proto_tree_add_item(tree, hf_request_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* computer name */
offset = display_unicode_string(tvb, pinfo, tree, offset, hf_unicode_computer_name, NULL);
/* user name */
offset = display_unicode_string(tvb, pinfo, tree, offset, hf_user_name, NULL);
/* mailslot name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_mailslot_name, NULL);
/* account control */
offset = dissect_account_control(tvb, tree, offset);
/* Domain SID Size */
domain_sid_size = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_domain_sid_size, tvb, offset, 4,
domain_sid_size);
offset += 4;
if (domain_sid_size != 0) {
/* Align to four-byte boundary */
offset = ((offset + 3)/4)*4;
/* Domain SID */
offset = dissect_nt_sid(tvb, offset, tree, "Domain", NULL, -1);
}
/* NT version */
proto_tree_add_item(tree, hf_nt_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* LMNT token */
offset = display_LMNT_token(tvb, offset, tree);
/* LM token */
offset = display_LM_token(tvb, offset, tree);
return offset;
}
static int
dissect_smb_no_user(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
/* 0x0B (Announce no user on machine) */
/* computer name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_computer_name, NULL);
return offset;
}
static int
dissect_smb_relogon_resp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
/*** 0x0d LanMan Response to relogon request ***/
/* Major version */
proto_tree_add_item(tree, hf_major_version, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* Minor version */
proto_tree_add_item(tree, hf_minor_version, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* OS version */
proto_tree_add_item(tree, hf_os_version, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* NT version */
proto_tree_add_item(tree, hf_nt_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* LM token */
offset = display_LM_token(tvb, offset, tree);
return offset;
}
static int
dissect_smb_acc_update(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
/*** 0x11 LM2.1 Announce Acc updates ***/
/* signature */
proto_tree_add_item(tree, hf_signature, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* date/time */
/* XXX - what format is this? Neither SMB_Date/SMB_Time nor
"time_t but in the local time zone" appear to be correct. */
proto_tree_add_item(tree, hf_date_time, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* computer name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_computer_name, NULL);
/* user name */
offset = display_ms_string(tvb, pinfo, tree, offset, hf_user_name, NULL);
/* update type */
proto_tree_add_item(tree, hf_update_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* NT version */
proto_tree_add_item(tree, hf_nt_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* LM token */
offset = display_LM_token(tvb, offset, tree);
return offset;
}
static int
dissect_smb_inter_resp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
/* 0x0e LanMan Response to interrogate request */
/* Major version */
proto_tree_add_item(tree, hf_major_version, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* Minor version */
proto_tree_add_item(tree, hf_minor_version, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* OS version */
proto_tree_add_item(tree, hf_os_version, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* NT version */
proto_tree_add_item(tree, hf_nt_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* LMNT token */
offset = display_LMNT_token(tvb, offset, tree);
/* XXX - no LM token? Every other packet has one after the LMNT
token. */
return offset;
}
static int
dissect_smb_sam_logon_resp(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, int offset)
{
/* Netlogon command 0x13 - decode the SAM logon response from server */
/* Netlogon command 0x15 - decode the SAM logon response from server unknown user */
/* server name */
offset = display_unicode_string(tvb, pinfo, tree, offset, hf_server_name, NULL);
/* user name */
offset = display_unicode_string(tvb, pinfo, tree, offset, hf_user_name, NULL);
/* domain name */
offset = display_unicode_string(tvb, pinfo, tree, offset, hf_domain_name, NULL);
/* NT version */
proto_tree_add_item(tree, hf_nt_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* LMNT token */
offset = display_LMNT_token(tvb, offset, tree);
/* LM token */
offset = display_LM_token(tvb, offset, tree);
return offset;
}
static int
dissect_smb_pdc_response_ads(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, int offset)
{
/* Netlogon command 0x17 - decode the response from PDC ADS */
/* Netlogon command 0x19 - decode the response from PDC ADS USER ?*/
/* Align to four-byte boundary */
offset = ((offset + 3)/4)*4;
/* unknown uint32 type */
proto_tree_add_item(tree, hf_unknown32, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* Domain GUID */
proto_tree_add_item(tree, hf_domain_guid, tvb, offset, 16, ENC_NA);
offset += 16;
/* forest dns name */
offset=dissect_ms_compressed_string(tvb, pinfo, tree, offset, hf_forest_dns_name, NULL);
/* domain dns name */
offset=dissect_ms_compressed_string(tvb, pinfo, tree, offset, hf_domain_dns_name, NULL);
/* server dns name */
offset=dissect_ms_compressed_string(tvb, pinfo, tree, offset, hf_server_dns_name, NULL);
/* domain name */
offset=dissect_ms_compressed_string(tvb, pinfo, tree, offset, hf_domain_name, NULL);
/* server name */
offset=dissect_ms_compressed_string(tvb, pinfo, tree, offset, hf_server_name, NULL);
/* user name */
offset=dissect_ms_compressed_string(tvb, pinfo, tree, offset, hf_user_name, NULL);
/* server_site name */
offset=dissect_ms_compressed_string(tvb, pinfo, tree, offset, hf_server_site_name, NULL);
/* client_site name */
offset=dissect_ms_compressed_string(tvb, pinfo, tree, offset, hf_client_site_name, NULL);
/* unknown uint8 type */
proto_tree_add_item(tree, hf_unknown8, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* unknown uint32 type */
proto_tree_add_item(tree, hf_unknown32, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* server ip */
proto_tree_add_item(tree, hf_server_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
/* unknown uint32 type */
proto_tree_add_item(tree, hf_unknown32, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* unknown uint32 type */
proto_tree_add_item(tree, hf_unknown32, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* NT version */
proto_tree_add_item(tree, hf_nt_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* LMNT token */
offset = display_LMNT_token(tvb, offset, tree);
/* LM token */
offset = display_LM_token(tvb, offset, tree);
return offset;
}
static int
dissect_smb_unknown(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
/* display data as unknown */
proto_tree_add_item(tree, hf_data, tvb, offset, -1, ENC_NA);
return offset+tvb_reported_length_remaining(tvb, offset);
}
#define LOGON_LM10_LOGON_REQUEST 0x00
#define LOGON_LM10_LOGON_RESPONSE 0x01
#define LOGON_LM10_QUERY_CI 0x02
#define LOGON_LM10_QUERY_DI 0x03
#define LOGON_LM10_RESPONSE_CI 0x04
#define LOGON_LM10_RESPONSE_DI 0x05
#define LOGON_LM20_LOGON_RESPONSE 0x06
#define LOGON_PDC_QUERY 0x07
#define LOGON_PDC_STARTUP 0x08
#define LOGON_PDC_FAILED 0x09
#define LOGON_UAS_SAM 0x0a
#define LOGON_NO_USER 0x0b
#define LOGON_PDC_RESPONSE 0x0c
#define LOGON_RELOGON_RESPONSE 0x0d
#define LOGON_INTERROGATE_RESPONSE 0x0e
#define LOGON_LM20_RESPONSE_DURING_LOGON 0x0f
#define LOGON_LM20_USER_UNKNOWN 0x10
#define LOGON_LM20_ACCOUNT_UPDATE 0x11
#define LOGON_SAM_LOGON_REQUEST 0x12
#define LOGON_SAM_LOGON_RESPONSE 0x13
#define LOGON_SAM_RESPONSE_DURING_LOGON 0x14
#define LOGON_SAM_USER_UNKNOWN 0x15
#define LOGON_SAM_INTERROGATE_RESPONSE 0x16
#define LOGON_SAM_AD_USER_UNKNOWN 0x17
#define LOGON_SAM_UNKNOWN_18 0x18
#define LOGON_SAM_AD_LOGON_RESPONSE 0x19
#define LOGON_LAST_CMD 0x19
static const value_string commands[] = {
{LOGON_LM10_LOGON_REQUEST, "LM1.0/LM2.0 LOGON Request"},
{LOGON_LM10_LOGON_RESPONSE, "LM1.0 LOGON Response"},
{LOGON_LM10_QUERY_CI, "LM1.0 Query - Centralized Initialization"},
{LOGON_LM10_QUERY_DI, "LM1.0 Query - Distributed Initialization"},
{LOGON_LM10_RESPONSE_CI, "LM1.0 Response - Centralized Query"},
{LOGON_LM10_RESPONSE_DI, "LM1.0 Response - Distributed Initialization"},
{LOGON_LM20_LOGON_RESPONSE, "LM2.0 Response to LOGON Request"},
{LOGON_PDC_QUERY, "Query for PDC"},
{LOGON_PDC_STARTUP, "Announce Startup of PDC"},
{LOGON_PDC_FAILED, "Announce Failed PDC"},
{LOGON_UAS_SAM, "Announce Change to UAS or SAM"},
{LOGON_NO_USER, "Announce no user on machine"},
{LOGON_PDC_RESPONSE, "Response from PDC"},
{LOGON_RELOGON_RESPONSE, "LM1.0/LM2.0 Response to re-LOGON Request"},
{LOGON_INTERROGATE_RESPONSE, "LM1.0/LM2.0 Response to Interrogate Request"},
{LOGON_LM20_RESPONSE_DURING_LOGON, "LM2.0 Response during LOGON pause"},
{LOGON_LM20_USER_UNKNOWN, "LM2.0 Response - user unknown"},
{LOGON_LM20_ACCOUNT_UPDATE, "LM2.0 Announce account updates"},
{LOGON_SAM_LOGON_REQUEST, "SAM LOGON request from client"},
{LOGON_SAM_LOGON_RESPONSE, "Response to SAM LOGON request"},
{LOGON_SAM_RESPONSE_DURING_LOGON, "SAM Response during LOGON pause"},
{LOGON_SAM_USER_UNKNOWN, "SAM Response - user unknown"},
{LOGON_SAM_INTERROGATE_RESPONSE, "SAM Response to Interrogate Request"},
{LOGON_SAM_AD_USER_UNKNOWN, "SAM Active Directory Response - user unknown"},
{LOGON_SAM_UNKNOWN_18, "SAM unknown command 0x18"},
{LOGON_SAM_AD_LOGON_RESPONSE, "Active Directory Response to SAM LOGON request"},
{0, NULL}
};
static int (*dissect_smb_logon_cmds[])(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset) = {
dissect_smb_logon_request, /* 0x00 (LM1.0/LM2.0 LOGON Request) */
dissect_smb_logon_LM10_resp, /* 0x01 (LM1.0 LOGON Response) */
dissect_smb_logon_2, /* 0x02 (LM1.0 Query Centralized Init.)*/
dissect_smb_logon_2, /* 0x03 (LM1.0 Query Distributed Init.)*/
dissect_smb_logon_2, /* 0x04 (LM1.0 Centralized Query Resp.)*/
dissect_smb_logon_2, /* 0x05 (LM1.0 Distributed Query Resp.) */
dissect_smb_logon_LM20_resp, /* 0x06 (LM2.0 LOGON Response) */
dissect_smb_pdc_query, /* 0x07 (Query for PDC) */
dissect_smb_pdc_startup, /* 0x08 (Announce PDC startup) */
dissect_smb_pdc_failure, /* 0x09 (Announce Failed PDC) */
dissect_announce_change, /* 0x0A (Announce Change to UAS or SAM)*/
dissect_smb_no_user, /* 0x0B (Announce no user on machine)*/
dissect_smb_pdc_startup, /* 0x0C (Response from PDC) */
dissect_smb_relogon_resp, /* 0x0D (Relogon response) */
dissect_smb_inter_resp, /* 0x0E (Interrogate response) */
dissect_smb_pdc_failure, /* 0x0F (LM2.0 Resp. during LOGON pause*/
dissect_smb_pdc_failure, /* 0x10 (LM 2.0 Unknown user response)*/
dissect_smb_acc_update, /* 0x11 (LM2.1 Announce Acc updates)*/
dissect_smb_sam_logon_req, /* 0x12 (SAM LOGON request ) */
dissect_smb_sam_logon_resp, /* 0x13 (SAM LOGON response) */
dissect_smb_unknown, /* 0x14 (SAM Response during LOGON Pause) */
dissect_smb_sam_logon_resp, /* 0x15 (SAM Response User Unknown) */
dissect_smb_unknown, /* 0x16 (SAM Response to Interrogate)*/
dissect_smb_pdc_response_ads, /* 0x17 (SAM AD response User Unknown*/
dissect_smb_unknown, /* 0x18 (Unknown command) */
dissect_smb_pdc_response_ads /* 0x19 (SAM LOGON AD response) */
};
static int
dissect_smb_logon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
int offset = 0;
guint8 cmd;
proto_tree *smb_logon_tree = NULL;
proto_item *item = NULL;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMB_NETLOGON");
col_clear(pinfo->cinfo, COL_INFO);
/* get the Command field */
cmd = tvb_get_guint8(tvb, offset);
col_add_str(pinfo->cinfo, COL_INFO, val_to_str(cmd, commands, "Unknown Command:%02x") );
if (tree) {
item = proto_tree_add_item(tree, proto_smb_logon, tvb,
offset, -1, ENC_NA);
smb_logon_tree = proto_item_add_subtree(item, ett_smb_logon);
}
/* command */
proto_tree_add_uint(smb_logon_tree, hf_command, tvb, offset, 1, cmd);
offset += 1;
/* skip next byte */
offset += 1;
if (cmd<LOGON_LAST_CMD) {
(dissect_smb_logon_cmds[cmd])(tvb, pinfo,
smb_logon_tree, offset);
} else {
/* unknown command */
dissect_smb_unknown(tvb, pinfo, smb_logon_tree,
offset);
}
return tvb_captured_length(tvb);
}
void
proto_register_smb_logon( void)
{
static hf_register_info hf[] = {
{ &hf_command,
{ "Command", "smb_netlogon.command", FT_UINT8, BASE_HEX,
VALS(commands), 0, "SMB NETLOGON Command", HFILL }},
{ &hf_computer_name,
{ "Computer Name", "smb_netlogon.computer_name", FT_STRING, BASE_NONE,
NULL, 0, "SMB NETLOGON Computer Name", HFILL }},
{ &hf_unicode_computer_name,
{ "Unicode Computer Name", "smb_netlogon.unicode_computer_name", FT_STRING, BASE_NONE,
NULL, 0, "SMB NETLOGON Unicode Computer Name", HFILL }},
{ &hf_server_name,
{ "Server Name", "smb_netlogon.server_name", FT_STRING, BASE_NONE,
NULL, 0, "SMB NETLOGON Server Name", HFILL }},
{ &hf_server_dns_name,
{ "Server DNS Name", "smb_netlogon.server_dns_name", FT_STRING, BASE_NONE,
NULL, 0, "SMB NETLOGON Server DNS Name", HFILL }},
{ &hf_user_name,
{ "User Name", "smb_netlogon.user_name", FT_STRING, BASE_NONE,
NULL, 0, "SMB NETLOGON User Name", HFILL }},
{ &hf_domain_name,
{ "Domain Name", "smb_netlogon.domain_name", FT_STRING, BASE_NONE,
NULL, 0, "SMB NETLOGON Domain Name", HFILL }},
{ &hf_domain_dns_name,
{ "Domain DNS Name", "smb_netlogon.domain_dns_name", FT_STRING, BASE_NONE,
NULL, 0, "SMB NETLOGON Domain DNS Name", HFILL }},
{ &hf_forest_dns_name,
{ "Forest DNS Name", "smb_netlogon.forest_dns_name", FT_STRING, BASE_NONE,
NULL, 0, "SMB NETLOGON Forest DNS Name", HFILL }},
{ &hf_mailslot_name,
{ "Mailslot Name", "smb_netlogon.mailslot_name", FT_STRING, BASE_NONE,
NULL, 0, "SMB NETLOGON Mailslot Name", HFILL }},
{ &hf_pdc_name,
{ "PDC Name", "smb_netlogon.pdc_name", FT_STRING, BASE_NONE,
NULL, 0, "SMB NETLOGON PDC Name", HFILL }},
{ &hf_unicode_pdc_name,
{ "Unicode PDC Name", "smb_netlogon.unicode_pdc_name", FT_STRING, BASE_NONE,
NULL, 0, "SMB NETLOGON Unicode PDC Name", HFILL }},
{ &hf_script_name,
{ "Script Name", "smb_netlogon.script_name", FT_STRING, BASE_NONE,
NULL, 0, "SMB NETLOGON Script Name", HFILL }},
{ &hf_nt_version,
{ "NT Version", "smb_netlogon.nt_version", FT_UINT32, BASE_DEC,
NULL, 0, "SMB NETLOGON NT Version", HFILL }},
/* An LMNT Token, if 0xffff, is "WindowsNT Networking";
what is it otherwise? */
{ &hf_lmnt_token,
{ "LMNT Token", "smb_netlogon.lmnt_token", FT_UINT16, BASE_HEX,
NULL, 0, "SMB NETLOGON LMNT Token", HFILL }},
{ &hf_lm_token,
{ "LM Token", "smb_netlogon.lm_token", FT_UINT16, BASE_HEX,
NULL, 0, "SMB NETLOGON LM Token", HFILL }},
{ &hf_major_version,
{ "Workstation Major Version", "smb_netlogon.major_version", FT_UINT8, BASE_DEC,
NULL, 0, "SMB NETLOGON Workstation Major Version", HFILL }},
{ &hf_minor_version,
{ "Workstation Minor Version", "smb_netlogon.minor_version", FT_UINT8, BASE_DEC,
NULL, 0, "SMB NETLOGON Workstation Minor Version", HFILL }},
{ &hf_os_version,
{ "Workstation OS Version", "smb_netlogon.os_version", FT_UINT8, BASE_DEC,
NULL, 0, "SMB NETLOGON Workstation OS Version", HFILL }},
{ &hf_signature,
{ "Signature", "smb_netlogon.signature", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_date_time,
{ "Date/Time", "smb_netlogon.date_time", FT_UINT32, BASE_DEC,
NULL, 0, "SMB NETLOGON Date/Time", HFILL }},
{ &hf_update_type,
{ "Update Type", "smb_netlogon.update", FT_UINT16, BASE_DEC,
NULL, 0, "SMB NETLOGON Update Type", HFILL }},
{ &hf_request_count,
{ "Request Count", "smb_netlogon.request_count", FT_UINT16, BASE_DEC,
NULL, 0, "SMB NETLOGON Request Count", HFILL }},
{ &hf_account_control,
{ "Account control", "smb_netlogon.flags", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_flags_autolock,
{ "Autolock", "smb_netlogon.flags.autolock", FT_BOOLEAN, 32,
TFS(&tfs_flags_autolock), ACC_FLAG_AUTO_LOCKED, "SMB NETLOGON Account Autolock", HFILL}},
{ &hf_flags_expire,
{ "Expire", "smb_netlogon.flags.expire", FT_BOOLEAN, 32,
TFS(&tfs_flags_expire), ACC_FLAG_EXPIRE, "SMB NETLOGON Will Account Expire", HFILL}},
{ &hf_flags_server_trust,
{ "Server Trust", "smb_netlogon.flags.server", FT_BOOLEAN, 32,
TFS(&tfs_flags_server_trust), ACC_FLAG_SERVER_TRUST, "SMB NETLOGON Server Trust Account", HFILL}},
{ &hf_flags_workstation_trust,
{ "Workstation Trust", "smb_netlogon.flags.workstation", FT_BOOLEAN, 32,
TFS(&tfs_flags_workstation_trust), ACC_FLAG_WORKSTATION_TRUST, "SMB NETLOGON Workstation Trust Account", HFILL}},
{ &hf_flags_interdomain_trust,
{ "Interdomain Trust", "smb_netlogon.flags.interdomain", FT_BOOLEAN, 32,
TFS(&tfs_flags_interdomain_trust), ACC_FLAG_INTERDOMAIN_TRUST, "SMB NETLOGON Inter-domain Trust Account", HFILL}},
{ &hf_flags_mns_user,
{ "MNS User", "smb_netlogon.flags.mns", FT_BOOLEAN, 32,
TFS(&tfs_flags_mns_user), ACC_FLAG_MNS_USER, "SMB NETLOGON MNS User Account", HFILL}},
{ &hf_flags_normal_user,
{ "Normal User", "smb_netlogon.flags.normal", FT_BOOLEAN, 32,
TFS(&tfs_flags_normal_user), ACC_FLAG_NORMAL_USER, "SMB NETLOGON Normal User Account", HFILL}},
{ &hf_flags_temp_dup_user,
{ "Temp Duplicate User", "smb_netlogon.flags.temp_dup", FT_BOOLEAN, 32,
TFS(&tfs_flags_temp_dup_user), ACC_FLAG_TEMP_DUP_USER, "SMB NETLOGON Temp Duplicate User Account", HFILL}},
{ &hf_flags_password_required,
{ "Password", "smb_netlogon.flags.password", FT_BOOLEAN, 32,
TFS(&tfs_flags_password_required), ACC_FLAG_PASSWORD_REQUIRED, "SMB NETLOGON Password Required", HFILL}},
{ &hf_flags_homedir_required,
{ "Homedir", "smb_netlogon.flags.homedir", FT_BOOLEAN, 32,
TFS(&tfs_flags_homedir_required), ACC_FLAG_HOMEDIR_REQUIRED, "SMB NETLOGON Homedir Required", HFILL}},
{ &hf_flags_enabled,
{ "Enabled", "smb_netlogon.flags.enabled", FT_BOOLEAN, 32,
TFS(&tfs_flags_enabled), ACC_FLAG_ENABLED, "SMB NETLOGON Is This Account Enabled", HFILL}},
{ &hf_domain_sid_size,
{ "Domain SID Size", "smb_netlogon.domain_sid_size", FT_UINT32, BASE_DEC,
NULL, 0, "SMB NETLOGON Domain SID Size", HFILL }},
{ &hf_low_serial,
{ "Low Serial Number", "smb_netlogon.low_serial", FT_UINT32, BASE_DEC,
NULL, 0, "SMB NETLOGON Low Serial Number", HFILL }},
{ &hf_pulse,
{ "Pulse", "smb_netlogon.pulse", FT_UINT32, BASE_DEC,
NULL, 0, "SMB NETLOGON Pulse", HFILL }},
{ &hf_random,
{ "Random", "smb_netlogon.random", FT_UINT32, BASE_DEC,
NULL, 0, "SMB NETLOGON Random", HFILL }},
{ &hf_db_count,
{ "DB Count", "smb_netlogon.db_count", FT_UINT32, BASE_DEC,
NULL, 0, "SMB NETLOGON DB Count", HFILL }},
{ &hf_db_index,
{ "Database Index", "smb_netlogon.db_index", FT_UINT32, BASE_DEC,
NULL, 0, "SMB NETLOGON Database Index", HFILL }},
{ &hf_large_serial,
{ "Large Serial Number", "smb_netlogon.large_serial", FT_UINT64, BASE_DEC,
NULL, 0, "SMB NETLOGON Large Serial Number", HFILL }},
{ &hf_nt_date_time,
{ "NT Date/Time", "smb_netlogon.nt_date_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "SMB NETLOGON NT Date/Time", HFILL }},
{ &hf_unknown8,
{ "Unknown", "smb_netlogon.unknown", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_unknown32,
{ "Unknown", "smb_netlogon.unknown", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_domain_guid,
{ "Domain GUID", "smb_netlogon.domain.guid", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_server_ip, {
"Server IP", "smb_netlogon.server_ip", FT_IPv4, BASE_NONE,
NULL, 0x0, "Server IP Address", HFILL }},
{ &hf_server_site_name,
{ "Server Site Name", "smb_netlogon.server_site_name", FT_STRING, BASE_NONE,
NULL, 0, "SMB NETLOGON Server Site Name", HFILL }},
{ &hf_client_site_name,
{ "Client Site Name", "smb_netlogon.client_site_name", FT_STRING, BASE_NONE,
NULL, 0, "SMB NETLOGON Client Site Name", HFILL }},
{ &hf_data,
{ "Data", "smb_netlogon.data", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
};
static gint *ett[] = {
&ett_smb_logon,
&ett_smb_account_flags,
&ett_smb_db_info
};
proto_smb_logon = proto_register_protocol(
"Microsoft Windows Logon Protocol (Old)", "SMB_NETLOGON", "smb_netlogon");
proto_register_field_array(proto_smb_logon, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_dissector("smb_netlogon", dissect_smb_logon, proto_smb_logon);
}
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-smb-mailslot.c
|
/* packet-smb-mailslot.c
* Routines for SMB mailslot packet dissection
* Copyright 2000, Jeffrey C. Foster <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Copied from packet-pop.c
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include "packet-smb.h"
#include "packet-smb-mailslot.h"
void proto_register_smb_mailslot(void);
void proto_reg_handoff_smb_mailslot(void);
static int proto_smb_msp = -1;
static int hf_opcode = -1;
static int hf_priority = -1;
static int hf_class = -1;
static int hf_size = -1;
static int hf_name = -1;
static int ett_smb_msp = -1;
static dissector_handle_t mailslot_browse_handle;
static dissector_handle_t mailslot_lanman_handle;
static dissector_handle_t netlogon_handle;
#define MAILSLOT_UNKNOWN 0
#define MAILSLOT_BROWSE 1
#define MAILSLOT_LANMAN 2
#define MAILSLOT_NET 3
#define MAILSLOT_TEMP_NETLOGON 4
#define MAILSLOT_MSSP 5
static const value_string opcode_vals[] = {
{1, "Write Mail Slot"},
{0, NULL}
};
static const value_string class_vals[] = {
{1, "Reliable"},
{2, "Unreliable & Broadcast"},
{0, NULL}
};
/* decode the SMB mail slot protocol
for requests
mailslot is the name of the mailslot, e.g. BROWSE
si->trans_subcmd is set to the symbolic constant matching the mailslot name.
for responses
mailslot is NULL
si->trans_subcmd gives us which mailslot this response refers to.
*/
gboolean
dissect_mailslot_smb(tvbuff_t *mshdr_tvb, tvbuff_t *setup_tvb,
tvbuff_t *tvb, const char *mailslot, packet_info *pinfo,
proto_tree *parent_tree, smb_info_t* smb_info)
{
smb_transact_info_t *tri;
int trans_subcmd;
proto_tree *tree = NULL;
proto_item *item = NULL;
guint16 opcode;
int offset = 0;
int len;
if (!proto_is_protocol_enabled(find_protocol_by_id(proto_smb_msp))) {
return FALSE;
}
pinfo->current_proto = "SMB Mailslot";
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMB Mailslot");
if ((tvb==NULL) || (tvb_reported_length(tvb)==0)) {
/* Interim reply */
col_set_str(pinfo->cinfo, COL_INFO, "Interim reply");
return TRUE;
}
col_clear(pinfo->cinfo, COL_INFO);
if (smb_info->sip != NULL && smb_info->sip->extra_info_type == SMB_EI_TRI)
tri = (smb_transact_info_t *)smb_info->sip->extra_info;
else
tri = NULL;
/* check which mailslot this is about */
trans_subcmd=MAILSLOT_UNKNOWN;
if(smb_info->request){
if(strncmp(mailslot,"BROWSE",6) == 0){
trans_subcmd=MAILSLOT_BROWSE;
} else if(strncmp(mailslot,"LANMAN",6) == 0){
trans_subcmd=MAILSLOT_LANMAN;
} else if(strncmp(mailslot,"NET",3) == 0){
trans_subcmd=MAILSLOT_NET;
} else if(strncmp(mailslot,"TEMP\\NETLOGON",13) == 0){
trans_subcmd=MAILSLOT_TEMP_NETLOGON;
} else if(strncmp(mailslot,"MSSP",4) == 0){
trans_subcmd=MAILSLOT_MSSP;
}
if (!pinfo->fd->visited) {
if (tri != NULL)
tri->trans_subcmd = trans_subcmd;
}
} else {
if(!tri){
return FALSE;
} else {
trans_subcmd = tri->trans_subcmd;
}
}
/* Only do these ones if we have them. For fragmented SMB Transactions
we may only have the setup area for the first fragment
*/
if(mshdr_tvb && setup_tvb){
if (parent_tree) {
item = proto_tree_add_item(parent_tree, proto_smb_msp,
mshdr_tvb, 0, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb_msp);
}
/* do the opcode field */
opcode = tvb_get_letohs(setup_tvb, offset);
col_add_str(pinfo->cinfo, COL_INFO,
val_to_str(opcode, opcode_vals, "Unknown opcode: 0x%04x"));
/* These are in the setup words; use "setup_tvb". */
/* opcode */
proto_tree_add_uint(tree, hf_opcode, setup_tvb, offset, 2,
opcode);
offset += 2;
/* priority */
proto_tree_add_item(tree, hf_priority, setup_tvb, offset, 2,
ENC_LITTLE_ENDIAN);
offset += 2;
/* class */
proto_tree_add_item(tree, hf_class, setup_tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* These are in the rest of the data; use "mshdr_tvb", which
starts at the same place "setup_tvb" does. */
/* size */
/* this is actually bytecount in the SMB Transaction command */
proto_tree_add_item(tree, hf_size, mshdr_tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* mailslot name */
len = tvb_strsize(mshdr_tvb, offset);
proto_tree_add_item(tree, hf_name, mshdr_tvb, offset, len, ENC_ASCII);
offset += len;
proto_item_set_len(item, offset);
}
switch(trans_subcmd){
case MAILSLOT_BROWSE:
call_dissector(mailslot_browse_handle, tvb, pinfo,
parent_tree);
break;
case MAILSLOT_LANMAN:
call_dissector(mailslot_lanman_handle, tvb, pinfo,
parent_tree);
break;
case MAILSLOT_NET:
case MAILSLOT_TEMP_NETLOGON:
case MAILSLOT_MSSP:
call_dissector(netlogon_handle, tvb, pinfo,
parent_tree);
break;
default:
/*
* We dissected the mailslot header, but we don't know
* how to dissect the message; dissect the latter as data,
* but indicate that we successfully dissected the mailslot
* stuff.
*/
call_data_dissector(tvb, pinfo, parent_tree);
break;
}
return TRUE;
}
void
proto_register_smb_mailslot(void)
{
static hf_register_info hf[] = {
{ &hf_opcode,
{ "Opcode", "mailslot.opcode", FT_UINT16, BASE_DEC,
VALS(opcode_vals), 0, "MAILSLOT OpCode", HFILL }},
{ &hf_priority,
{ "Priority", "mailslot.priority", FT_UINT16, BASE_DEC,
NULL, 0, "MAILSLOT Priority of transaction", HFILL }},
{ &hf_class,
{ "Class", "mailslot.class", FT_UINT16, BASE_DEC,
VALS(class_vals), 0, "MAILSLOT Class of transaction", HFILL }},
{ &hf_size,
{ "Size", "mailslot.size", FT_UINT16, BASE_DEC,
NULL, 0, "MAILSLOT Total size of mail data", HFILL }},
{ &hf_name,
{ "Mailslot Name", "mailslot.name", FT_STRING, BASE_NONE,
NULL, 0, "MAILSLOT Name of mailslot", HFILL }},
};
static gint *ett[] = {
&ett_smb_msp
};
proto_smb_msp = proto_register_protocol(
"SMB MailSlot Protocol", "SMB Mailslot", "mailslot");
proto_register_field_array(proto_smb_msp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_smb_mailslot(void)
{
mailslot_browse_handle = find_dissector_add_dependency("mailslot_browse", proto_smb_msp);
mailslot_lanman_handle = find_dissector_add_dependency("mailslot_lanman", proto_smb_msp);
netlogon_handle = find_dissector_add_dependency("smb_netlogon", proto_smb_msp);
}
/*
* Editor modelines - https://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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-smb-mailslot.h
|
/* packet-smb-mailslot.h
* Declaration of routines for SMB mailslot packet dissection
* Copyright 2000, Jeffrey C. Foster <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef _PACKET_SMB_MAILSLOT_H_
#define _PACKET_SMB_MAILSLOT_H_
gboolean
dissect_mailslot_smb(tvbuff_t *total_tvb, tvbuff_t *setup_tvb,
tvbuff_t *tvb, const char *mailslot,
packet_info *pinfo, proto_tree *tree, smb_info_t* smb_info);
#endif
|
C
|
wireshark/epan/dissectors/packet-smb-pipe.c
|
/*
XXX Fixme : shouldn't show [malformed frame] for long packets
*/
/* packet-smb-pipe.c
* Routines for SMB named pipe packet dissection
* Copyright 1999, Richard Sharpe <[email protected]>
* significant rewrite to tvbuffify the dissector, Ronnie Sahlberg and
* Guy Harris 2001
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Copied from packet-pop.c
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/to_str.h>
#include <epan/strutil.h>
#include <epan/expert.h>
#include <epan/reassemble.h>
#include "packet-smb.h"
#include "packet-smb-pipe.h"
#include "packet-smb-browse.h"
#include "packet-smb-common.h"
#include "packet-windows-common.h"
void proto_register_pipe_lanman(void);
void proto_register_smb_pipe(void);
static int proto_smb_pipe = -1;
static int hf_smb_pipe_function = -1;
static int hf_smb_pipe_priority = -1;
static int hf_smb_pipe_peek_available = -1;
static int hf_smb_pipe_peek_remaining = -1;
static int hf_smb_pipe_peek_status = -1;
static int hf_smb_pipe_getinfo_info_level = -1;
static int hf_smb_pipe_getinfo_output_buffer_size = -1;
static int hf_smb_pipe_getinfo_input_buffer_size = -1;
static int hf_smb_pipe_getinfo_maximum_instances = -1;
static int hf_smb_pipe_getinfo_current_instances = -1;
static int hf_smb_pipe_getinfo_pipe_name_length = -1;
static int hf_smb_pipe_getinfo_pipe_name = -1;
static int hf_smb_pipe_write_raw_bytes_written = -1;
static int hf_smb_pipe_fragments = -1;
static int hf_smb_pipe_fragment = -1;
static int hf_smb_pipe_fragment_overlap = -1;
static int hf_smb_pipe_fragment_overlap_conflict = -1;
static int hf_smb_pipe_fragment_multiple_tails = -1;
static int hf_smb_pipe_fragment_too_long_fragment = -1;
static int hf_smb_pipe_fragment_error = -1;
static int hf_smb_pipe_fragment_count = -1;
static int hf_smb_pipe_reassembled_in = -1;
static int hf_smb_pipe_reassembled_length = -1;
static gint ett_smb_pipe = -1;
static gint ett_smb_pipe_fragment = -1;
static gint ett_smb_pipe_fragments = -1;
static const fragment_items smb_pipe_frag_items = {
&ett_smb_pipe_fragment,
&ett_smb_pipe_fragments,
&hf_smb_pipe_fragments,
&hf_smb_pipe_fragment,
&hf_smb_pipe_fragment_overlap,
&hf_smb_pipe_fragment_overlap_conflict,
&hf_smb_pipe_fragment_multiple_tails,
&hf_smb_pipe_fragment_too_long_fragment,
&hf_smb_pipe_fragment_error,
&hf_smb_pipe_fragment_count,
NULL,
&hf_smb_pipe_reassembled_length,
/* Reassembled data field */
NULL,
"fragments"
};
static int proto_smb_lanman = -1;
static int hf_function_code = -1;
static int hf_param_desc = -1;
static int hf_return_desc = -1;
static int hf_aux_data_desc = -1;
static int hf_detail_level = -1;
static int hf_padding = -1;
static int hf_recv_buf_len = -1;
static int hf_send_buf_len = -1;
/* static int hf_continuation_from = -1; */
static int hf_status = -1;
static int hf_convert = -1;
static int hf_param_no_descriptor = -1;
static int hf_data_no_descriptor = -1;
static int hf_data_no_recv_buffer = -1;
static int hf_ecount = -1;
static int hf_acount = -1;
static int hf_share = -1;
static int hf_share_name = -1;
static int hf_share_type = -1;
static int hf_share_comment = -1;
static int hf_share_permissions = -1;
static int hf_share_max_uses = -1;
static int hf_share_current_uses = -1;
static int hf_share_path = -1;
static int hf_share_password = -1;
static int hf_server = -1;
static int hf_server_name = -1;
static int hf_server_major = -1;
static int hf_server_minor = -1;
static int hf_server_comment = -1;
static int hf_abytes = -1;
static int hf_current_time = -1;
static int hf_msecs = -1;
static int hf_hour = -1;
static int hf_minute = -1;
static int hf_second = -1;
static int hf_hundredths = -1;
static int hf_tzoffset = -1;
static int hf_timeinterval = -1;
static int hf_day = -1;
static int hf_month = -1;
static int hf_year = -1;
static int hf_weekday = -1;
static int hf_enumeration_domain = -1;
static int hf_last_entry = -1;
static int hf_computer_name = -1;
static int hf_user_name = -1;
static int hf_group_name = -1;
static int hf_workstation_domain = -1;
static int hf_workstation_major = -1;
static int hf_workstation_minor = -1;
static int hf_logon_domain = -1;
static int hf_other_domains = -1;
static int hf_password = -1;
static int hf_workstation_name = -1;
static int hf_ustruct_size = -1;
static int hf_logon_code = -1;
static int hf_privilege_level = -1;
static int hf_operator_privileges = -1;
static int hf_num_logons = -1;
static int hf_bad_pw_count = -1;
static int hf_last_logon = -1;
static int hf_last_logoff = -1;
static int hf_logoff_time = -1;
static int hf_kickoff_time = -1;
static int hf_password_age = -1;
static int hf_password_can_change = -1;
static int hf_password_must_change = -1;
static int hf_script_path = -1;
static int hf_logoff_code = -1;
static int hf_duration = -1;
static int hf_comment = -1;
static int hf_user_comment = -1;
static int hf_full_name = -1;
static int hf_homedir = -1;
static int hf_parameters = -1;
static int hf_logon_server = -1;
static int hf_country_code = -1;
static int hf_workstations = -1;
static int hf_max_storage = -1;
static int hf_units_per_week = -1;
static int hf_logon_hours = -1;
static int hf_code_page = -1;
static int hf_new_password = -1;
static int hf_old_password = -1;
static int hf_reserved = -1;
static int hf_aux_data_struct_count = -1;
/* Generated from convert_proto_tree_add_text.pl */
static int hf_smb_pipe_stringz_param = -1;
static int hf_smb_pipe_string_param = -1;
static int hf_smb_pipe_bytes_param = -1;
static int hf_smb_pipe_byte_param = -1;
static int hf_smb_pipe_doubleword_param = -1;
static int hf_smb_pipe_word_param = -1;
static gint ett_lanman = -1;
static gint ett_lanman_unknown_entries = -1;
static gint ett_lanman_unknown_entry = -1;
static gint ett_lanman_shares = -1;
static gint ett_lanman_share = -1;
static gint ett_lanman_groups = -1;
static gint ett_lanman_servers = -1;
static gint ett_lanman_server = -1;
static expert_field ei_smb_pipe_bogus_netwkstauserlogon = EI_INIT;
static expert_field ei_smb_pipe_bad_type = EI_INIT;
/*
* See
*
* ftp://ftp.microsoft.com/developr/drg/CIFS/cifsrap2.txt
*
* among other documents.
*/
static const value_string status_vals[] = {
{ 0, "Success"},
{ 5, "User has insufficient privilege"},
{ 65, "Network access is denied"},
{ 86, "The specified password is invalid"},
{SMBE_DOS_moredata, "Additional data is available"},
{2114, "Service is not running on the remote computer"},
{2123, "Supplied buffer is too small"},
{2141, "Server is not configured for transactions (IPC$ not shared)"},
{2212, "An error occurred while loading or running the logon script"},
{2214, "The logon was not validated by any server"},
{2217, "The logon server is running an older software version"},
{2221, "The user name was not found"},
{2226, "Operation not permitted on Backup Domain Controller"},
{2240, "The user is not allowed to logon from this computer"},
{2241, "The user is not allowed to logon at this time"},
{2242, "The user password has expired"},
{2243, "The password cannot be changed"},
{2246, "The password is too short"},
{0, NULL}
};
static const value_string privilege_vals[] = {
{0, "Guest"},
{1, "User"},
{2, "Administrator"},
{0, NULL}
};
static const value_string op_privilege_vals[] = {
{0, "Print operator"},
{1, "Communications operator"},
{2, "Server operator"},
{3, "Accounts operator"},
{0, NULL}
};
static const value_string weekday_vals[] = {
{0, "Sunday"},
{1, "Monday"},
{2, "Tuesday"},
{3, "Wednesday"},
{4, "Thursday"},
{5, "Friday"},
{6, "Saturday"},
{0, NULL}
};
static int
add_word_param(tvbuff_t *tvb, int offset, int count _U_,
packet_info *pinfo _U_, proto_tree *tree, int convert _U_, int hf_index, smb_info_t *smb_info _U_)
{
proto_tree_add_item(tree, hf_index, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
static int
add_dword_param(tvbuff_t *tvb, int offset, int count _U_,
packet_info *pinfo _U_, proto_tree *tree, int convert _U_, int hf_index, smb_info_t *smb_info _U_)
{
proto_tree_add_item(tree, hf_index, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
return offset;
}
static int
add_bytes_param(tvbuff_t *tvb, int offset, int count, packet_info *pinfo _U_,
proto_tree *tree, int convert _U_, int hf_index, smb_info_t *smb_info _U_)
{
header_field_info *hfinfo;
if (hf_index != -1) {
hfinfo = proto_registrar_get_nth(hf_index);
if ((hfinfo == NULL) ||
((hfinfo->type == FT_INT8 || hfinfo->type == FT_UINT8)
&& (count != 1))) {
THROW(ReportedBoundsError);
}
switch (hfinfo->type) {
case FT_INT8:
case FT_UINT8:
proto_tree_add_item(tree, hf_index, tvb, offset, count,
ENC_LITTLE_ENDIAN);
break;
case FT_STRING:
proto_tree_add_item(tree, hf_index, tvb, offset, count,
ENC_ASCII|ENC_NA); /* XXX - code page? */
break;
default:
proto_tree_add_item(tree, hf_index, tvb, offset, count,
ENC_NA);
break;
}
} else {
if (count == 1) {
proto_tree_add_item(tree, hf_smb_pipe_byte_param, tvb, offset, count, ENC_LITTLE_ENDIAN);
} else {
proto_tree_add_item(tree, hf_smb_pipe_bytes_param, tvb, offset, count, ENC_NA);
}
}
offset += count;
return offset;
}
static int
add_string_param_update_parent(tvbuff_t *tvb, int offset, int count, packet_info *pinfo _U_,
proto_tree *tree, int convert _U_, int hf_index, smb_info_t *smb_info _U_)
{
proto_item *ti, *parent_ti;
const guint8 *str;
DISSECTOR_ASSERT(hf_index != -1);
ti = proto_tree_add_item_ret_string(tree, hf_index, tvb, offset,
count, ENC_ASCII|ENC_NA, pinfo->pool, &str);
/* XXX - code page? */
parent_ti = proto_item_get_parent(ti);
proto_item_append_text(parent_ti, ": %s",
format_text(pinfo->pool, str, strlen(str)));
offset += count;
return offset;
}
static int
add_pad_param(tvbuff_t *tvb _U_, int offset, int count, packet_info *pinfo _U_,
proto_tree *tree _U_, int convert _U_, int hf_index _U_, smb_info_t *smb_info _U_)
{
/*
* This is for parameters that have descriptor entries but that
* are, in practice, just padding.
*/
offset += count;
return offset;
}
static void
add_null_pointer_param(tvbuff_t *tvb, int offset, int count _U_,
packet_info *pinfo _U_, proto_tree *tree, int convert _U_, int hf_index, smb_info_t *smb_info _U_)
{
if (hf_index != -1) {
proto_tree_add_string_format_value(tree, hf_index, tvb, offset, 0, "", "(Null pointer)");
} else {
proto_tree_add_string_format_value(tree, hf_smb_pipe_string_param, tvb, offset, 0, "", "(Null pointer)");
}
}
static int
add_string_param(tvbuff_t *tvb, int offset, int count _U_,
packet_info *pinfo _U_, proto_tree *tree, int convert _U_, int hf_index, smb_info_t *smb_info _U_)
{
guint string_len;
string_len = tvb_strsize(tvb, offset);
if (hf_index != -1) {
proto_tree_add_item(tree, hf_index, tvb, offset, string_len,
ENC_ASCII|ENC_NA); /* XXX - code page? */
} else {
proto_tree_add_item(tree, hf_smb_pipe_string_param, tvb, offset, string_len, ENC_NA|ENC_ASCII);
}
offset += string_len;
return offset;
}
static const char *
get_stringz_pointer_value(tvbuff_t *tvb, int offset, int convert, int *cptrp,
int *lenp)
{
int cptr;
gint string_len;
/* pointer to string */
cptr = (tvb_get_letohl(tvb, offset)&0xffff)-convert;
*cptrp = cptr;
/* string */
if (tvb_offset_exists(tvb, cptr) &&
(string_len = tvb_strnlen(tvb, cptr, -1)) != -1) {
string_len++; /* include the terminating '\0' */
*lenp = string_len;
return tvb_format_text(wmem_packet_scope(), tvb, cptr, string_len - 1);
} else
return NULL;
}
static int
add_stringz_pointer_param(tvbuff_t *tvb, int offset, int count _U_,
packet_info *pinfo _U_, proto_tree *tree, int convert, int hf_index, smb_info_t *smb_info _U_)
{
int cptr;
const char *string;
gint string_len;
string = get_stringz_pointer_value(tvb, offset, convert, &cptr,
&string_len);
offset += 4;
/* string */
if (string != NULL) {
if (hf_index != -1) {
proto_tree_add_item(tree, hf_index, tvb, cptr,
string_len, ENC_ASCII|ENC_NA); /* XXX - code page? */
} else {
proto_tree_add_item(tree, hf_smb_pipe_stringz_param, tvb, cptr, string_len, ENC_NA|ENC_ASCII);
}
} else {
if (hf_index != -1) {
proto_tree_add_string(tree, hf_index, tvb, 0, 0,
"<String goes past end of frame>");
} else {
proto_tree_add_string(tree, hf_smb_pipe_stringz_param, tvb, 0, 0,
"<String goes past end of frame>");
}
}
return offset;
}
static int
add_bytes_pointer_param(tvbuff_t *tvb, int offset, int count,
packet_info *pinfo _U_, proto_tree *tree, int convert, int hf_index, smb_info_t *smb_info _U_)
{
int cptr;
/* pointer to byte array */
cptr = (tvb_get_letohl(tvb, offset)&0xffff)-convert;
offset += 4;
/* bytes */
if (tvb_bytes_exist(tvb, cptr, count)) {
if (hf_index != -1) {
proto_tree_add_item(tree, hf_index, tvb, cptr,
count, ENC_NA);
} else {
proto_tree_add_item(tree, hf_smb_pipe_bytes_param, tvb, cptr, count, ENC_NA);
}
} else {
if (hf_index != -1) {
proto_tree_add_bytes_format_value(tree, hf_index, tvb, 0, 0,
NULL, "<Bytes go past end of frame>");
} else {
proto_tree_add_bytes_format_value(tree, hf_smb_pipe_bytes_param, tvb, 0, 0,
NULL, "<Bytes go past end of frame>");
}
}
return offset;
}
static int
add_detail_level(tvbuff_t *tvb, int offset, int count _U_, packet_info *pinfo,
proto_tree *tree, int convert _U_, int hf_index, smb_info_t *smb_info)
{
smb_transact_info_t *trp = NULL;
guint16 level;
if (smb_info->sip->extra_info_type == SMB_EI_TRI)
trp = (smb_transact_info_t *)smb_info->sip->extra_info;
level = tvb_get_letohs(tvb, offset);
if (!pinfo->fd->visited)
if (trp)
trp->info_level = level; /* remember this for the response */
proto_tree_add_uint(tree, hf_index, tvb, offset, 2, level);
offset += 2;
return offset;
}
static int
add_max_uses(tvbuff_t *tvb, int offset, int count _U_, packet_info *pinfo _U_,
proto_tree *tree, int convert _U_, int hf_index, smb_info_t *smb_info _U_)
{
guint16 WParam;
WParam = tvb_get_letohs(tvb, offset);
if (WParam == 0xffff) { /* -1 */
proto_tree_add_uint_format_value(tree, hf_index, tvb,
offset, 2, WParam,
"No limit");
} else {
proto_tree_add_uint(tree, hf_index, tvb,
offset, 2, WParam);
}
offset += 2;
return offset;
}
static int
add_server_type(tvbuff_t *tvb, int offset, int count _U_,
packet_info *pinfo, proto_tree *tree, int convert _U_, int hf_index _U_, smb_info_t *smb_info _U_)
{
offset = dissect_smb_server_type_flags(
tvb, offset, pinfo, tree, NULL, FALSE);
return offset;
}
static int
add_server_type_info(tvbuff_t *tvb, int offset, int count _U_,
packet_info *pinfo, proto_tree *tree, int convert _U_, int hf_index _U_, smb_info_t *smb_info _U_)
{
offset = dissect_smb_server_type_flags(
tvb, offset, pinfo, tree, NULL, TRUE);
return offset;
}
static int
add_reltime(tvbuff_t *tvb, int offset, int count _U_, packet_info *pinfo _U_,
proto_tree *tree, int convert _U_, int hf_index, smb_info_t *smb_info _U_)
{
nstime_t nstime;
nstime.secs = tvb_get_letohl(tvb, offset);
nstime.nsecs = 0;
proto_tree_add_time_format_value(tree, hf_index, tvb, offset, 4,
&nstime, "%s",
signed_time_secs_to_str(pinfo->pool, (gint32) nstime.secs));
offset += 4;
return offset;
}
/*
* Sigh. These are for handling Microsoft's annoying almost-UNIX-time-but-
* it's-local-time-not-UTC time.
*/
static int
add_abstime_common(tvbuff_t *tvb, int offset, proto_tree *tree, int hf_index,
const char *absent_name)
{
nstime_t nstime;
struct tm *tmp;
nstime.secs = tvb_get_letohl(tvb, offset);
nstime.nsecs = 0;
/*
* Sigh. Sometimes it appears that -1 means "unknown", and
* sometimes it appears that 0 means "unknown", for the last
* logoff date/time.
*/
if (nstime.secs == -1 || nstime.secs == 0) {
proto_tree_add_time_format_value(tree, hf_index, tvb, offset, 4,
&nstime, "%s",
absent_name);
} else {
/*
* Run it through "gmtime()" to break it down, and then
* run it through "mktime()" to put it back together
* as UTC.
*/
tmp = gmtime(&nstime.secs);
if (tmp == NULL) {
/*
* Can't be represented.
*/
proto_tree_add_time_format_value(tree, hf_index, tvb,
offset, 4, &nstime, "Not representable");
} else {
tmp->tm_isdst = -1; /* we don't know if it's DST or not */
nstime.secs = mktime(tmp);
proto_tree_add_time(tree, hf_index, tvb, offset, 4,
&nstime);
}
}
offset += 4;
return offset;
}
static int
add_abstime_absent_never(tvbuff_t *tvb, int offset, int count _U_,
packet_info *pinfo _U_, proto_tree *tree, int convert _U_, int hf_index, smb_info_t *smb_info _U_)
{
return add_abstime_common(tvb, offset, tree, hf_index, "Never");
}
static int
add_abstime_absent_unknown(tvbuff_t *tvb, int offset, int count _U_,
packet_info *pinfo _U_, proto_tree *tree, int convert _U_, int hf_index, smb_info_t *smb_info _U_)
{
return add_abstime_common(tvb, offset, tree, hf_index, "Unknown");
}
static int
add_nlogons(tvbuff_t *tvb, int offset, int count _U_, packet_info *pinfo _U_,
proto_tree *tree, int convert _U_, int hf_index, smb_info_t *smb_info _U_)
{
guint16 nlogons;
nlogons = tvb_get_letohs(tvb, offset);
if (nlogons == 0xffff) /* -1 */
proto_tree_add_uint_format_value(tree, hf_index, tvb, offset, 2,
nlogons, "Unknown");
else
proto_tree_add_uint(tree, hf_index, tvb, offset, 2, nlogons);
offset += 2;
return offset;
}
static int
add_max_storage(tvbuff_t *tvb, int offset, int count _U_,
packet_info *pinfo _U_, proto_tree *tree, int convert _U_, int hf_index, smb_info_t *smb_info _U_)
{
guint32 max_storage;
max_storage = tvb_get_letohl(tvb, offset);
if (max_storage == 0xffffffff)
proto_tree_add_uint_format(tree, hf_index, tvb, offset, 4,
max_storage, "No limit");
else
proto_tree_add_uint(tree, hf_index, tvb, offset, 4, max_storage);
offset += 4;
return offset;
}
static int
add_logon_hours(tvbuff_t *tvb, int offset, int count, packet_info *pinfo _U_,
proto_tree *tree, int convert, int hf_index, smb_info_t *smb_info _U_)
{
int cptr;
/* pointer to byte array */
cptr = (tvb_get_letohl(tvb, offset)&0xffff)-convert;
offset += 4;
/* bytes */
if (tvb_bytes_exist(tvb, cptr, count)) {
if (count == 21) {
/*
* The logon hours should be exactly 21 bytes long.
*
* XXX - should actually carve up the bits;
* we need the units per week to do that, though.
*/
proto_tree_add_item(tree, hf_index, tvb, cptr, count,
ENC_NA);
} else {
proto_tree_add_bytes_format_value(tree, hf_index, tvb,
cptr, count, NULL,
"%s (wrong length, should be 21, is %d",
tvb_bytes_to_str(pinfo->pool, tvb, cptr, count), count);
}
} else {
proto_tree_add_bytes_format_value(tree, hf_index, tvb, 0, 0,
NULL, "<Bytes go past end of frame>");
}
return offset;
}
static int
add_tzoffset(tvbuff_t *tvb, int offset, int count _U_, packet_info *pinfo _U_,
proto_tree *tree, int convert _U_, int hf_index _U_, smb_info_t *smb_info _U_)
{
gint16 tzoffset;
tzoffset = tvb_get_letohs(tvb, offset);
if (tzoffset < 0) {
proto_tree_add_int_format_value(tree, hf_tzoffset, tvb, offset, 2,
tzoffset, "%s east of UTC",
signed_time_secs_to_str(pinfo->pool, -tzoffset*60));
} else if (tzoffset > 0) {
proto_tree_add_int_format_value(tree, hf_tzoffset, tvb, offset, 2,
tzoffset, "%s west of UTC",
signed_time_secs_to_str(pinfo->pool, tzoffset*60));
} else {
proto_tree_add_int_format_value(tree, hf_tzoffset, tvb, offset, 2,
tzoffset, "at UTC");
}
offset += 2;
return offset;
}
static int
add_timeinterval(tvbuff_t *tvb, int offset, int count _U_,
packet_info *pinfo _U_, proto_tree *tree, int convert _U_, int hf_index _U_, smb_info_t *smb_info _U_)
{
guint16 timeinterval;
timeinterval = tvb_get_letohs(tvb, offset);
proto_tree_add_uint_format_value(tree, hf_timeinterval, tvb, offset, 2,
timeinterval, "%f seconds", timeinterval*.0001);
offset += 2;
return offset;
}
static int
add_logon_args(tvbuff_t *tvb, int offset, int count, packet_info *pinfo _U_,
proto_tree *tree, int convert _U_, int hf_index _U_, smb_info_t *smb_info _U_)
{
if (count != 54) {
proto_tree_add_expert_format(tree, pinfo, &ei_smb_pipe_bogus_netwkstauserlogon, tvb, offset, count, "Bogus NetWkstaUserLogon parameters: length is %d, should be 54", count);
offset += count;
return offset;
}
/* user name */
proto_tree_add_item(tree, hf_user_name, tvb, offset, 21, ENC_ASCII);
offset += 21;
/* pad1 */
offset += 1;
/* password */
proto_tree_add_item(tree, hf_password, tvb, offset, 15, ENC_ASCII);
offset += 15;
/* pad2 */
offset += 1;
/* workstation name */
proto_tree_add_item(tree, hf_workstation_name, tvb, offset, 16, ENC_ASCII);
offset += 16;
return offset;
}
/*
* The following data structure describes the Remote API requests we
* understand.
*
* Simply fill in the number and parameter information.
* Try to keep them in order.
*
* We will extend this data structure as we try to decode more.
*/
/*
* This is a pointer to a function to process an item.
*/
typedef int (*item_func)(tvbuff_t *, int, int, packet_info *, proto_tree *,
int, int, smb_info_t*);
/*
* Type of an item; determines what parameter strings are valid for
* the item.
*/
typedef enum {
PARAM_NONE, /* for the end-of-list stopper */
PARAM_WORD, /* 'W' or 'h' - 16-bit word */
PARAM_DWORD, /* 'D' or 'i' - 32-bit word */
PARAM_BYTES, /* 'B' or 'b' or 'g' or 'O' - one or more bytes */
PARAM_STRINGZ /* 'z' or 'O' - null-terminated string */
} param_type_t;
/*
* This structure describes an item; "hf_index" points to the index
* for the field corresponding to that item, "func" points to the
* function to use to add that item to the tree, and "type" is the
* type that the item is supposed to have.
*/
typedef struct {
int *hf_index;
item_func func;
param_type_t type;
} item_t;
/*
* This structure describes a list of items; each list of items
* has a corresponding detail level.
*/
typedef struct {
int level;
const item_t *item_list;
} item_list_t;
struct lanman_desc {
int lanman_num;
const item_t *req;
proto_item *(*req_data_item)(tvbuff_t *, packet_info *,
proto_tree *, int);
gint *ett_req_data;
const item_t *req_data;
const item_t *req_aux_data;
const item_t *resp;
const gchar *resp_data_entry_list_label;
gint *ett_data_entry_list;
proto_item *(*resp_data_element_item)(tvbuff_t *, proto_tree *,
int);
gint *ett_resp_data_element_item;
const item_list_t *resp_data_list;
const item_t *resp_aux_data;
};
static int no_hf = -1; /* for padding crap */
static const item_t lm_params_req_netshareenum[] = {
{ &hf_detail_level, add_detail_level, PARAM_WORD },
{ &hf_recv_buf_len, add_word_param, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_params_resp_netshareenum[] = {
{ &hf_acount, add_word_param, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
/*
* Create a subtree for a share.
*/
static proto_item *
netshareenum_share_entry(tvbuff_t *tvb, proto_tree *tree, int offset)
{
return proto_tree_add_item(tree, hf_share, tvb, offset, -1, ENC_NA);
}
static const item_t lm_null[] = {
{ NULL, NULL, PARAM_NONE }
};
static const item_list_t lm_null_list[] = {
{ -1, lm_null }
};
static const item_t lm_data_resp_netshareenum_1[] = {
{ &hf_share_name, add_string_param_update_parent, PARAM_BYTES },
{ &no_hf, add_pad_param, PARAM_BYTES },
{ &hf_share_type, add_word_param, PARAM_WORD },
{ &hf_share_comment, add_stringz_pointer_param, PARAM_STRINGZ },
{ NULL, NULL, PARAM_NONE }
};
static const item_list_t lm_data_resp_netshareenum[] = {
{ 1, lm_data_resp_netshareenum_1 },
{ -1, lm_null }
};
static const item_t lm_params_req_netsharegetinfo[] = {
{ &hf_share_name, add_string_param, PARAM_STRINGZ },
{ &hf_detail_level, add_detail_level, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_params_resp_netsharegetinfo[] = {
{ &hf_abytes, add_word_param, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_data_resp_netsharegetinfo_0[] = {
{ &hf_share_name, add_bytes_param, PARAM_BYTES },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_data_resp_netsharegetinfo_1[] = {
{ &hf_share_name, add_bytes_param, PARAM_BYTES },
{ &no_hf, add_pad_param, PARAM_BYTES },
{ &hf_share_type, add_word_param, PARAM_WORD },
{ &hf_share_comment, add_stringz_pointer_param, PARAM_STRINGZ },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_data_resp_netsharegetinfo_2[] = {
{ &hf_share_name, add_bytes_param, PARAM_BYTES },
{ &no_hf, add_pad_param, PARAM_BYTES },
{ &hf_share_type, add_word_param, PARAM_WORD },
{ &hf_share_comment, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_share_permissions, add_word_param, PARAM_WORD }, /* XXX - do as bit fields */
{ &hf_share_max_uses, add_max_uses, PARAM_WORD },
{ &hf_share_current_uses, add_word_param, PARAM_WORD },
{ &hf_share_path, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_share_password, add_bytes_param, PARAM_BYTES },
{ NULL, NULL, PARAM_NONE }
};
static const item_list_t lm_data_resp_netsharegetinfo[] = {
{ 0, lm_data_resp_netsharegetinfo_0 },
{ 1, lm_data_resp_netsharegetinfo_1 },
{ 2, lm_data_resp_netsharegetinfo_2 },
{ -1, lm_null }
};
static const item_t lm_params_req_netservergetinfo[] = {
{ &hf_detail_level, add_detail_level, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_params_resp_netservergetinfo[] = {
{ &hf_abytes, add_word_param, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_data_serverinfo_0[] = {
{ &hf_server_name, add_string_param_update_parent, PARAM_BYTES },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_data_serverinfo_1[] = {
{ &hf_server_name, add_string_param_update_parent, PARAM_BYTES },
{ &hf_server_major, add_bytes_param, PARAM_BYTES },
{ &hf_server_minor, add_bytes_param, PARAM_BYTES },
{ &no_hf, add_server_type, PARAM_DWORD },
{ &hf_server_comment, add_stringz_pointer_param, PARAM_STRINGZ },
{ NULL, NULL, PARAM_NONE }
};
static const item_list_t lm_data_serverinfo[] = {
{ 0, lm_data_serverinfo_0 },
{ 1, lm_data_serverinfo_1 },
{ -1, lm_null }
};
static const item_t lm_params_req_netusergetinfo[] = {
{ &hf_user_name, add_string_param, PARAM_STRINGZ },
{ &hf_detail_level, add_detail_level, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_params_resp_netusergetinfo[] = {
{ &hf_abytes, add_word_param, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_data_resp_netusergetinfo_11[] = {
{ &hf_user_name, add_bytes_param, PARAM_BYTES },
{ &no_hf, add_pad_param, PARAM_BYTES },
{ &hf_comment, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_user_comment, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_full_name, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_privilege_level, add_word_param, PARAM_WORD },
{ &hf_operator_privileges, add_dword_param, PARAM_DWORD },
{ &hf_password_age, add_reltime, PARAM_DWORD },
{ &hf_homedir, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_parameters, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_last_logon, add_abstime_absent_unknown, PARAM_DWORD },
{ &hf_last_logoff, add_abstime_absent_unknown, PARAM_DWORD },
{ &hf_bad_pw_count, add_word_param, PARAM_WORD },
{ &hf_num_logons, add_nlogons, PARAM_WORD },
{ &hf_logon_server, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_country_code, add_word_param, PARAM_WORD },
{ &hf_workstations, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_max_storage, add_max_storage, PARAM_DWORD },
{ &hf_units_per_week, add_word_param, PARAM_WORD },
{ &hf_logon_hours, add_logon_hours, PARAM_BYTES },
{ &hf_code_page, add_word_param, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_list_t lm_data_resp_netusergetinfo[] = {
{ 11, lm_data_resp_netusergetinfo_11 },
{ -1, lm_null }
};
static const item_t lm_params_req_netusergetgroups[] = {
{ &hf_user_name, add_string_param, PARAM_STRINGZ },
{ &hf_detail_level, add_detail_level, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_params_resp_netusergetgroups[] = {
{ &hf_abytes, add_word_param, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_data_resp_netusergetgroups_0[] = {
{ &hf_group_name, add_bytes_param, PARAM_BYTES },
{ NULL, NULL, PARAM_NONE }
};
static const item_list_t lm_data_resp_netusergetgroups[] = {
{ 0, lm_data_resp_netusergetgroups_0 },
{ -1, lm_null }
};
/*
* Has no detail level; make it the default.
*/
static const item_t lm_data_resp_netremotetod_nolevel[] = {
{ &hf_current_time, add_abstime_absent_unknown, PARAM_DWORD },
{ &hf_msecs, add_dword_param, PARAM_DWORD },
{ &hf_hour, add_bytes_param, PARAM_BYTES },
{ &hf_minute, add_bytes_param, PARAM_BYTES },
{ &hf_second, add_bytes_param, PARAM_BYTES },
{ &hf_hundredths, add_bytes_param, PARAM_BYTES },
{ &hf_tzoffset, add_tzoffset, PARAM_WORD },
{ &hf_timeinterval, add_timeinterval, PARAM_WORD },
{ &hf_day, add_bytes_param, PARAM_BYTES },
{ &hf_month, add_bytes_param, PARAM_BYTES },
{ &hf_year, add_word_param, PARAM_WORD },
{ &hf_weekday, add_bytes_param, PARAM_BYTES },
{ NULL, NULL, PARAM_NONE }
};
static const item_list_t lm_data_resp_netremotetod[] = {
{ -1, lm_data_resp_netremotetod_nolevel },
};
static const item_t lm_params_req_netserverenum2[] = {
{ &hf_detail_level, add_detail_level, PARAM_WORD },
{ &no_hf, add_server_type_info, PARAM_DWORD },
{ &hf_enumeration_domain, add_string_param, PARAM_STRINGZ },
{ NULL, NULL, PARAM_NONE }
};
/*
* Create a subtree for a server.
*/
static proto_item *
netserverenum2_server_entry(tvbuff_t *tvb, proto_tree *tree, int offset)
{
return proto_tree_add_item(tree, hf_server, tvb, offset, -1, ENC_NA);
}
static const item_t lm_params_resp_netserverenum2[] = {
{ &hf_acount, add_word_param, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_params_req_netserverenum3[] = {
{ &hf_detail_level, add_detail_level, PARAM_WORD },
{ &no_hf, add_server_type_info, PARAM_DWORD },
{ &hf_enumeration_domain, add_string_param, PARAM_STRINGZ },
{ &hf_last_entry, add_string_param, PARAM_STRINGZ },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_params_req_netwkstagetinfo[] = {
{ &hf_detail_level, add_detail_level, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_params_resp_netwkstagetinfo[] = {
{ &hf_abytes, add_word_param, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_data_resp_netwkstagetinfo_10[] = {
{ &hf_computer_name, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_user_name, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_workstation_domain, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_workstation_major, add_bytes_param, PARAM_BYTES },
{ &hf_workstation_minor, add_bytes_param, PARAM_BYTES },
{ &hf_logon_domain, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_other_domains, add_stringz_pointer_param, PARAM_STRINGZ },
{ NULL, NULL, PARAM_NONE }
};
static const item_list_t lm_data_resp_netwkstagetinfo[] = {
{ 10, lm_data_resp_netwkstagetinfo_10 },
{ -1, lm_null }
};
static const item_t lm_params_req_netwkstauserlogon[] = {
{ &no_hf, add_stringz_pointer_param, PARAM_STRINGZ },
{ &no_hf, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_detail_level, add_detail_level, PARAM_WORD },
{ &no_hf, add_logon_args, PARAM_BYTES },
{ &hf_ustruct_size, add_word_param, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_params_resp_netwkstauserlogon[] = {
{ &hf_abytes, add_word_param, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_data_resp_netwkstauserlogon_1[] = {
{ &hf_logon_code, add_word_param, PARAM_WORD },
{ &hf_user_name, add_bytes_param, PARAM_BYTES },
{ &no_hf, add_pad_param, PARAM_BYTES },
{ &hf_privilege_level, add_word_param, PARAM_WORD },
{ &hf_operator_privileges, add_dword_param, PARAM_DWORD },
{ &hf_num_logons, add_nlogons, PARAM_WORD },
{ &hf_bad_pw_count, add_word_param, PARAM_WORD },
{ &hf_last_logon, add_abstime_absent_unknown, PARAM_DWORD },
{ &hf_last_logoff, add_abstime_absent_unknown, PARAM_DWORD },
{ &hf_logoff_time, add_abstime_absent_never, PARAM_DWORD },
{ &hf_kickoff_time, add_abstime_absent_never, PARAM_DWORD },
{ &hf_password_age, add_reltime, PARAM_DWORD },
{ &hf_password_can_change, add_abstime_absent_never, PARAM_DWORD },
{ &hf_password_must_change, add_abstime_absent_never, PARAM_DWORD },
{ &hf_server_name, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_logon_domain, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_script_path, add_stringz_pointer_param, PARAM_STRINGZ },
{ &hf_reserved, add_dword_param, PARAM_DWORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_list_t lm_data_resp_netwkstauserlogon[] = {
{ 1, lm_data_resp_netwkstauserlogon_1 },
{ -1, lm_null }
};
static const item_t lm_params_req_netwkstauserlogoff[] = {
{ &hf_user_name, add_bytes_param, PARAM_BYTES },
{ &no_hf, add_pad_param, PARAM_BYTES },
{ &hf_workstation_name, add_bytes_param, PARAM_BYTES },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_params_resp_netwkstauserlogoff[] = {
{ &hf_abytes, add_word_param, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_data_resp_netwkstauserlogoff_1[] = {
{ &hf_logoff_code, add_word_param, PARAM_WORD },
{ &hf_duration, add_reltime, PARAM_DWORD },
{ &hf_num_logons, add_nlogons, PARAM_WORD },
{ NULL, NULL, PARAM_NONE }
};
static const item_list_t lm_data_resp_netwkstauserlogoff[] = {
{ 1, lm_data_resp_netwkstauserlogoff_1 },
{ -1, lm_null }
};
static const item_t lm_params_req_samoemchangepassword[] = {
{ &hf_user_name, add_string_param, PARAM_STRINGZ },
{ NULL, NULL, PARAM_NONE }
};
static const item_t lm_data_req_samoemchangepassword[] = {
{ &hf_new_password, add_bytes_param, PARAM_BYTES },
{ &hf_old_password, add_bytes_param, PARAM_BYTES },
{ NULL, NULL, PARAM_NONE }
};
#define API_NetShareEnum 0
#define API_NetShareGetInfo 1
#define API_NetShareSetInfo 2
#define API_NetShareAdd 3
#define API_NetShareDel 4
#define API_NetShareCheck 5
#define API_NetSessionEnum 6
#define API_NetSessionGetInfo 7
#define API_NetSessionDel 8
#define API_WconnectionEnum 9
#define API_NetFileEnum 10
#define API_NetFileGetInfo 11
#define API_NetFileClose 12
#define API_NetServerGetInfo 13
#define API_NetServerSetInfo 14
#define API_NetServerDiskEnum 15
#define API_NetServerAdminCommand 16
#define API_NetAuditOpen 17
#define API_NetAuditClear 18
#define API_NetErrorLogOpen 19
#define API_NetErrorLogClear 20
#define API_NetCharDevEnum 21
#define API_NetCharDevGetInfo 22
#define API_NetCharDevControl 23
#define API_NetCharDevQEnum 24
#define API_NetCharDevQGetInfo 25
#define API_NetCharDevQSetInfo 26
#define API_NetCharDevQPurge 27
#define API_NetCharDevQPurgeSelf 28
#define API_NetMessageNameEnum 29
#define API_NetMessageNameGetInfo 30
#define API_NetMessageNameAdd 31
#define API_NetMessageNameDel 32
#define API_NetMessageNameFwd 33
#define API_NetMessageNameUnFwd 34
#define API_NetMessageBufferSend 35
#define API_NetMessageFileSend 36
#define API_NetMessageLogFileSet 37
#define API_NetMessageLogFileGet 38
#define API_NetServiceEnum 39
#define API_NetServiceInstall 40
#define API_NetServiceControl 41
#define API_NetAccessEnum 42
#define API_NetAccessGetInfo 43
#define API_NetAccessSetInfo 44
#define API_NetAccessAdd 45
#define API_NetAccessDel 46
#define API_NetGroupEnum 47
#define API_NetGroupAdd 48
#define API_NetGroupDel 49
#define API_NetGroupAddUser 50
#define API_NetGroupDelUser 51
#define API_NetGroupGetUsers 52
#define API_NetUserEnum 53
#define API_NetUserAdd 54
#define API_NetUserDel 55
#define API_NetUserGetInfo 56
#define API_NetUserSetInfo 57
#define API_NetUserPasswordSet 58
#define API_NetUserGetGroups 59
/*This line and number replaced a Dead Entry for 60 */
/*This line and number replaced a Dead Entry for 61 */
#define API_NetWkstaSetUID 62
#define API_NetWkstaGetInfo 63
#define API_NetWkstaSetInfo 64
#define API_NetUseEnum 65
#define API_NetUseAdd 66
#define API_NetUseDel 67
#define API_NetUseGetInfo 68
#define API_WPrintQEnum 69
#define API_WPrintQGetInfo 70
#define API_WPrintQSetInfo 71
#define API_WPrintQAdd 72
#define API_WPrintQDel 73
#define API_WPrintQPause 74
#define API_WPrintQContinue 75
#define API_WPrintJobEnum 76
#define API_WPrintJobGetInfo 77
#define API_WPrintJobSetInfo_OLD 78
/* This line and number replaced a Dead Entry for 79 */
/* This line and number replaced a Dead Entry for 80 */
#define API_WPrintJobDel 81
#define API_WPrintJobPause 82
#define API_WPrintJobContinue 83
#define API_WPrintDestEnum 84
#define API_WPrintDestGetInfo 85
#define API_WPrintDestControl 86
#define API_NetProfileSave 87
#define API_NetProfileLoad 88
#define API_NetStatisticsGet 89
#define API_NetStatisticsClear 90
#define API_NetRemoteTOD 91
#define API_WNetBiosEnum 92
#define API_WNetBiosGetInfo 93
#define API_NetServerEnum 94
#define API_I_NetServerEnum 95
#define API_NetServiceGetInfo 96
/* This line and number replaced a Dead Entry for 97 */
/* This line and number replaced a Dead Entry for 98 */
/* This line and number replaced a Dead Entry for 99 */
/* This line and number replaced a Dead Entry for 100 */
/* This line and number replaced a Dead Entry for 101 */
/* This line and number replaced a Dead Entry for 102 */
#define API_WPrintQPurge 103
#define API_NetServerEnum2 104
#define API_NetAccessGetUserPerms 105
#define API_NetGroupGetInfo 106
#define API_NetGroupSetInfo 107
#define API_NetGroupSetUsers 108
#define API_NetUserSetGroups 109
#define API_NetUserModalsGet 110
#define API_NetUserModalsSet 111
#define API_NetFileEnum2 112
#define API_NetUserAdd2 113
#define API_NetUserSetInfo2 114
#define API_NetUserPasswordSet2 115
#define API_I_NetServerEnum2 116
#define API_NetConfigGet2 117
#define API_NetConfigGetAll2 118
#define API_NetGetDCName 119
#define API_NetHandleGetInfo 120
#define API_NetHandleSetInfo 121
#define API_NetStatisticsGet2 122
#define API_WBuildGetInfo 123
#define API_NetFileGetInfo2 124
#define API_NetFileClose2 125
#define API_NetServerReqChallenge 126
#define API_NetServerAuthenticate 127
#define API_NetServerPasswordSet 128
#define API_WNetAccountDeltas 129
#define API_WNetAccountSync 130
#define API_NetUserEnum2 131
#define API_NetWkstaUserLogon 132
#define API_NetWkstaUserLogoff 133
#define API_NetLogonEnum 134
#define API_NetErrorLogRead 135
#define API_I_NetPathType 136
#define API_I_NetPathCanonicalize 137
#define API_I_NetPathCompare 138
#define API_I_NetNameValidate 139
#define API_I_NetNameCanonicalize 140
#define API_I_NetNameCompare 141
#define API_NetAuditRead 142
#define API_WPrintDestAdd 143
#define API_WPrintDestSetInfo 144
#define API_WPrintDestDel 145
#define API_NetUserValidate2 146
#define API_WPrintJobSetInfo 147
#define API_TI_NetServerDiskEnum 148
#define API_TI_NetServerDiskGetInfo 149
#define API_TI_FTVerifyMirror 150
#define API_TI_FTAbortVerify 151
#define API_TI_FTGetInfo 152
#define API_TI_FTSetInfo 153
#define API_TI_FTLockDisk 154
#define API_TI_FTFixError 155
#define API_TI_FTAbortFix 156
#define API_TI_FTDiagnoseError 157
#define API_TI_FTGetDriveStats 158
/* This line and number replaced a Dead Entry for 159 */
#define API_TI_FTErrorGetInfo 160
/* This line and number replaced a Dead Entry for 161 */
/* This line and number replaced a Dead Entry for 162 */
#define API_NetAccessCheck 163
#define API_NetAlertRaise 164
#define API_NetAlertStart 165
#define API_NetAlertStop 166
#define API_NetAuditWrite 167
#define API_NetIRemoteAPI 168
#define API_NetServiceStatus 169
#define API_I_NetServerRegister 170
#define API_I_NetServerDeregister 171
#define API_I_NetSessionEntryMake 172
#define API_I_NetSessionEntryClear 173
#define API_I_NetSessionEntryGetInfo 174
#define API_I_NetSessionEntrySetInfo 175
#define API_I_NetConnectionEntryMake 176
#define API_I_NetConnectionEntryClear 177
#define API_I_NetConnectionEntrySetInfo 178
#define API_I_NetConnectionEntryGetInfo 179
#define API_I_NetFileEntryMake 180
#define API_I_NetFileEntryClear 181
#define API_I_NetFileEntrySetInfo 182
#define API_I_NetFileEntryGetInfo 183
#define API_AltSrvMessageBufferSend 184
#define API_AltSrvMessageFileSend 185
#define API_wI_NetRplWkstaEnum 186
#define API_wI_NetRplWkstaGetInfo 187
#define API_wI_NetRplWkstaSetInfo 188
#define API_wI_NetRplWkstaAdd 189
#define API_wI_NetRplWkstaDel 190
#define API_wI_NetRplProfileEnum 191
#define API_wI_NetRplProfileGetInfo 192
#define API_wI_NetRplProfileSetInfo 193
#define API_wI_NetRplProfileAdd 194
#define API_wI_NetRplProfileDel 195
#define API_wI_NetRplProfileClone 196
#define API_wI_NetRplBaseProfileEnum 197
/* This line and number replaced a Dead Entry for 198 */
/* This line and number replaced a Dead Entry for 199 */
/* This line and number replaced a Dead Entry for 200 */
#define API_WIServerSetInfo 201
/* This line and number replaced a Dead Entry for 202 */
/* This line and number replaced a Dead Entry for 203 */
/* This line and number replaced a Dead Entry for 204 */
#define API_WPrintDriverEnum 205
#define API_WPrintQProcessorEnum 206
#define API_WPrintPortEnum 207
#define API_WNetWriteUpdateLog 208
#define API_WNetAccountUpdate 209
#define API_WNetAccountConfirmUpdate 210
#define API_NetConfigSet 211
#define API_WAccountsReplicate 212
/* 213 is used by WfW */
#define API_SamOEMChgPasswordUser2_P 214
#define API_NetServerEnum3 215
/* XXX - what about 216 through 249? */
#define API_WPrintDriverGetInfo 250
#define API_WPrintDriverSetInfo 251
#define API_NetAliasAdd 252
#define API_NetAliasDel 253
#define API_NetAliasGetInfo 254
#define API_NetAliasSetInfo 255
#define API_NetAliasEnum 256
#define API_NetUserGetLogonAsn 257
#define API_NetUserSetLogonAsn 258
#define API_NetUserGetAppSel 259
#define API_NetUserSetAppSel 260
#define API_NetAppAdd 261
#define API_NetAppDel 262
#define API_NetAppGetInfo 263
#define API_NetAppSetInfo 264
#define API_NetAppEnum 265
#define API_NetUserDCDBInit 266
#define API_NetDASDAdd 267
#define API_NetDASDDel 268
#define API_NetDASDGetInfo 269
#define API_NetDASDSetInfo 270
#define API_NetDASDEnum 271
#define API_NetDASDCheck 272
#define API_NetDASDCtl 273
#define API_NetUserRemoteLogonCheck 274
#define API_NetUserPasswordSet3 275
#define API_NetCreateRIPLMachine 276
#define API_NetDeleteRIPLMachine 277
#define API_NetGetRIPLMachineInfo 278
#define API_NetSetRIPLMachineInfo 279
#define API_NetEnumRIPLMachine 280
#define API_I_ShareAdd 281
#define API_I_AliasEnum 282
#define API_NetAccessApply 283
#define API_WPrt16Query 284
#define API_WPrt16Set 285
#define API_NetUserDel100 286
#define API_NetUserRemoteLogonCheck2 287
#define API_WRemoteTODSet 294
#define API_WPrintJobMoveAll 295
#define API_W16AppParmAdd 296
#define API_W16AppParmDel 297
#define API_W16AppParmGet 298
#define API_W16AppParmSet 299
#define API_W16RIPLMachineCreate 300
#define API_W16RIPLMachineGetInfo 301
#define API_W16RIPLMachineSetInfo 302
#define API_W16RIPLMachineEnum 303
#define API_W16RIPLMachineListParmEnum 304
#define API_W16RIPLMachClassGetInfo 305
#define API_W16RIPLMachClassEnum 306
#define API_W16RIPLMachClassCreate 307
#define API_W16RIPLMachClassSetInfo 308
#define API_W16RIPLMachClassDelete 309
#define API_W16RIPLMachClassLPEnum 310
#define API_W16RIPLMachineDelete 311
#define API_W16WSLevelGetInfo 312
#define API_NetServerNameAdd 313
#define API_NetServerNameDel 314
#define API_NetServerNameEnum 315
#define API_I_WDASDEnum 316
#define API_I_WDASDEnumTerminate 317
#define API_I_WDASDSetInfo2 318
static const struct lanman_desc lmd[] = {
{ API_NetShareEnum,
lm_params_req_netshareenum,
NULL,
NULL,
lm_null,
lm_null,
lm_params_resp_netshareenum,
"Available Shares",
&ett_lanman_shares,
netshareenum_share_entry,
&ett_lanman_share,
lm_data_resp_netshareenum,
lm_null },
{ API_NetShareGetInfo,
lm_params_req_netsharegetinfo,
NULL,
NULL,
lm_null,
lm_null,
lm_params_resp_netsharegetinfo,
NULL,
NULL,
NULL,
NULL,
lm_data_resp_netsharegetinfo,
lm_null },
{ API_NetServerGetInfo,
lm_params_req_netservergetinfo,
NULL,
NULL,
lm_null,
lm_null,
lm_params_resp_netservergetinfo,
NULL,
NULL,
NULL,
NULL,
lm_data_serverinfo,
lm_null },
{ API_NetUserGetInfo,
lm_params_req_netusergetinfo,
NULL,
NULL,
lm_null,
lm_null,
lm_params_resp_netusergetinfo,
NULL,
NULL,
NULL,
NULL,
lm_data_resp_netusergetinfo,
lm_null },
{ API_NetUserGetGroups,
lm_params_req_netusergetgroups,
NULL,
NULL,
lm_null,
lm_null,
lm_params_resp_netusergetgroups,
"Groups",
&ett_lanman_groups,
NULL,
NULL,
lm_data_resp_netusergetgroups,
lm_null },
{ API_NetRemoteTOD,
lm_null,
NULL,
NULL,
lm_null,
lm_null,
lm_null,
NULL,
NULL,
NULL,
NULL,
lm_data_resp_netremotetod,
lm_null },
{ API_NetServerEnum2,
lm_params_req_netserverenum2,
NULL,
NULL,
lm_null,
lm_null,
lm_params_resp_netserverenum2,
"Servers",
&ett_lanman_servers,
netserverenum2_server_entry,
&ett_lanman_server,
lm_data_serverinfo,
lm_null },
{ API_NetWkstaGetInfo,
lm_params_req_netwkstagetinfo,
NULL,
NULL,
lm_null,
lm_null,
lm_params_resp_netwkstagetinfo,
NULL,
NULL,
NULL,
NULL,
lm_data_resp_netwkstagetinfo,
lm_null },
{ API_NetWkstaUserLogon,
lm_params_req_netwkstauserlogon,
NULL,
NULL,
lm_null,
lm_null,
lm_params_resp_netwkstauserlogon,
NULL,
NULL,
NULL,
NULL,
lm_data_resp_netwkstauserlogon,
lm_null },
{ API_NetWkstaUserLogoff,
lm_params_req_netwkstauserlogoff,
NULL,
NULL,
lm_null,
lm_null,
lm_params_resp_netwkstauserlogoff,
NULL,
NULL,
NULL,
NULL,
lm_data_resp_netwkstauserlogoff,
lm_null },
{ API_SamOEMChgPasswordUser2_P,
lm_params_req_samoemchangepassword,
NULL,
NULL,
lm_data_req_samoemchangepassword,
lm_null,
lm_null,
NULL,
NULL,
NULL,
NULL,
lm_null_list,
lm_null },
{ API_NetServerEnum3,
lm_params_req_netserverenum3,
NULL,
NULL,
lm_null,
lm_null,
lm_params_resp_netserverenum2,
"Servers",
&ett_lanman_servers,
netserverenum2_server_entry,
&ett_lanman_server,
lm_data_serverinfo,
lm_null },
{ -1,
lm_null,
NULL,
NULL,
lm_null,
lm_null,
lm_null,
NULL,
NULL,
NULL,
&ett_lanman_unknown_entry,
lm_null_list,
lm_null }
};
static const struct lanman_desc *
find_lanman(int lanman_num)
{
int i;
for (i = 0; lmd[i].lanman_num != -1; i++) {
if (lmd[i].lanman_num == lanman_num)
break;
}
return &lmd[i];
}
static const guchar *
get_count(const guchar *desc, int *countp)
{
int count = 0;
guchar c;
if (!g_ascii_isdigit(*desc)) {
*countp = 1; /* no count was supplied */
return desc;
}
while ((c = *desc) != '\0' && g_ascii_isdigit(c)) {
count = (count * 10) + c - '0';
desc++;
}
*countp = count; /* XXX - what if it's 0? */
return desc;
}
static int
dissect_request_parameters(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *tree, const guchar *desc, const item_t *items,
gboolean *has_data_p, smb_info_t *smb_info)
{
guint c;
guint16 WParam;
guint32 LParam;
guint string_len;
int count;
*has_data_p = FALSE;
while ((c = *desc++) != '\0') {
switch (c) {
case 'W':
/*
* A 16-bit word value in the request.
*/
if (items->func == NULL) {
/*
* We've run out of items in the table;
* fall back on the default.
*/
offset = add_word_param(tvb, offset, 0, pinfo,
tree, 0, hf_smb_pipe_word_param, smb_info);
} else if (items->type != PARAM_WORD) {
/*
* Descriptor character is 'W', but this
* isn't a word parameter.
*/
WParam = tvb_get_letohs(tvb, offset);
proto_tree_add_expert_format(tree, pinfo, &ei_smb_pipe_bad_type, tvb, offset, 2,
"%s: Value is %u (0x%04X), type is wrong (W)",
proto_registrar_get_name((*items->hf_index == -1) ?
hf_smb_pipe_word_param : *items->hf_index),
WParam, WParam);
offset += 2;
items++;
} else {
offset = (*items->func)(tvb, offset, 0, pinfo,
tree, 0, *items->hf_index, smb_info);
items++;
}
break;
case 'D':
/*
* A 32-bit doubleword value in the request.
*/
if (items->func == NULL) {
/*
* We've run out of items in the table;
* fall back on the default.
*/
offset = add_dword_param(tvb, offset, 0, pinfo,
tree, 0, hf_smb_pipe_doubleword_param, smb_info);
} else if (items->type != PARAM_DWORD) {
/*
* Descriptor character is 'D', but this
* isn't a doubleword parameter.
*/
LParam = tvb_get_letohl(tvb, offset);
proto_tree_add_expert_format(tree, pinfo, &ei_smb_pipe_bad_type, tvb, offset, 2,
"%s: Value is %u (0x%08X), type is wrong (D)",
proto_registrar_get_name((*items->hf_index == -1) ?
hf_smb_pipe_doubleword_param : *items->hf_index),
LParam, LParam);
offset += 4;
items++;
} else {
offset = (*items->func)(tvb, offset, 0, pinfo,
tree, 0, *items->hf_index, smb_info);
items++;
}
break;
case 'b':
/*
* A byte or multi-byte value in the request.
*/
desc = get_count(desc, &count);
if (items->func == NULL) {
/*
* We've run out of items in the table;
* fall back on the default.
*/
offset = add_bytes_param(tvb, offset, count,
pinfo, tree, 0, -1, smb_info);
} else if (items->type != PARAM_BYTES) {
/*
* Descriptor character is 'b', but this
* isn't a byte/bytes parameter.
*/
proto_tree_add_expert_format(tree, pinfo, &ei_smb_pipe_bad_type, tvb, offset, count,
"%s: Value is %s, type is wrong (b)",
proto_registrar_get_name((*items->hf_index == -1) ?
hf_smb_pipe_bytes_param : *items->hf_index),
tvb_bytes_to_str(pinfo->pool, tvb, offset, count));
offset += count;
items++;
} else {
offset = (*items->func)(tvb, offset, count,
pinfo, tree, 0, *items->hf_index, smb_info);
items++;
}
break;
case 'O':
/*
* A null pointer.
*/
if (items->func == NULL) {
/*
* We've run out of items in the table;
* fall back on the default.
*/
add_null_pointer_param(tvb, offset, 0,
pinfo, tree, 0, -1, smb_info);
} else {
/*
* If "*items->hf_index" is -1, this is
* a reserved must-be-null field; don't
* clutter the protocol tree by putting
* it in.
*/
if (*items->hf_index != -1) {
add_null_pointer_param(tvb,
offset, 0, pinfo, tree, 0,
*items->hf_index, smb_info);
}
items++;
}
break;
case 'z':
/*
* A null-terminated ASCII string.
*/
if (items->func == NULL) {
/*
* We've run out of items in the table;
* fall back on the default.
*/
offset = add_string_param(tvb, offset, 0,
pinfo, tree, 0, -1, smb_info);
} else if (items->type != PARAM_STRINGZ) {
/*
* Descriptor character is 'z', but this
* isn't a string parameter.
*/
string_len = tvb_strsize(tvb, offset);
proto_tree_add_expert_format(tree, pinfo, &ei_smb_pipe_bad_type, tvb, offset, string_len,
"%s: Value is %s, type is wrong (z)",
proto_registrar_get_name((*items->hf_index == -1) ?
hf_smb_pipe_string_param : *items->hf_index),
tvb_format_text(pinfo->pool, tvb, offset, string_len));
offset += string_len;
items++;
} else {
offset = (*items->func)(tvb, offset, 0,
pinfo, tree, 0, *items->hf_index, smb_info);
items++;
}
break;
case 'F':
/*
* One or more pad bytes.
*/
desc = get_count(desc, &count);
proto_tree_add_item(tree, hf_padding, tvb, offset, count, ENC_NA);
offset += count;
break;
case 'L':
/*
* 16-bit receive buffer length.
*/
proto_tree_add_item(tree, hf_recv_buf_len, tvb,
offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
break;
case 's':
/*
* 32-bit send buffer offset.
* This appears not to be sent over the wire.
*/
*has_data_p = TRUE;
break;
case 'T':
/*
* 16-bit send buffer length.
*/
proto_tree_add_item(tree, hf_send_buf_len, tvb,
offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
break;
default:
break;
}
}
return offset;
}
static int
dissect_response_parameters(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *tree, const guchar *desc, const item_t *items,
gboolean *has_data_p, gboolean *has_ent_count_p, guint16 *ent_count_p, smb_info_t *smb_info)
{
guint c;
guint16 WParam;
guint32 LParam;
int count;
*has_data_p = FALSE;
*has_ent_count_p = FALSE;
while ((c = *desc++) != '\0') {
switch (c) {
case 'r':
/*
* 32-bit receive buffer offset.
*/
*has_data_p = TRUE;
break;
case 'g':
/*
* A byte or series of bytes is returned.
*/
desc = get_count(desc, &count);
if (items->func == NULL) {
/*
* We've run out of items in the table;
* fall back on the default.
*/
offset = add_bytes_param(tvb, offset, count,
pinfo, tree, 0, -1, smb_info);
} else if (items->type != PARAM_BYTES) {
/*
* Descriptor character is 'b', but this
* isn't a byte/bytes parameter.
*/
proto_tree_add_expert_format(tree, pinfo, &ei_smb_pipe_bad_type, tvb, offset, count,
"%s: Value is %s, type is wrong (g)",
proto_registrar_get_name((*items->hf_index == -1) ?
hf_smb_pipe_bytes_param : *items->hf_index),
tvb_bytes_to_str(pinfo->pool, tvb, offset, count));
offset += count;
items++;
} else {
offset = (*items->func)(tvb, offset, count,
pinfo, tree, 0, *items->hf_index, smb_info);
items++;
}
break;
case 'h':
/*
* A 16-bit word is received.
*/
if (items->func == NULL) {
/*
* We've run out of items in the table;
* fall back on the default.
*/
offset = add_word_param(tvb, offset, 0, pinfo,
tree, 0, hf_smb_pipe_word_param, smb_info);
} else if (items->type != PARAM_WORD) {
/*
* Descriptor character is 'h', but this
* isn't a word parameter.
*/
WParam = tvb_get_letohs(tvb, offset);
proto_tree_add_expert_format(tree, pinfo, &ei_smb_pipe_bad_type, tvb, offset, 2,
"%s: Value is %u (0x%04X), type is wrong (W)",
proto_registrar_get_name((*items->hf_index == -1) ?
hf_smb_pipe_word_param : *items->hf_index),
WParam, WParam);
offset += 2;
items++;
} else {
offset = (*items->func)(tvb, offset, 0, pinfo,
tree, 0, *items->hf_index, smb_info);
items++;
}
break;
case 'i':
/*
* A 32-bit doubleword is received.
*/
if (items->func == NULL) {
/*
* We've run out of items in the table;
* fall back on the default.
*/
offset = add_dword_param(tvb, offset, 0, pinfo,
tree, 0, hf_smb_pipe_doubleword_param, smb_info);
} else if (items->type != PARAM_DWORD) {
/*
* Descriptor character is 'i', but this
* isn't a doubleword parameter.
*/
LParam = tvb_get_letohl(tvb, offset);
proto_tree_add_expert_format(tree, pinfo, &ei_smb_pipe_bad_type, tvb, offset, 2,
"%s: Value is %u (0x%08X), type is wrong (i)",
proto_registrar_get_name((*items->hf_index == -1) ?
hf_smb_pipe_doubleword_param : *items->hf_index),
LParam, LParam);
offset += 4;
items++;
} else {
offset = (*items->func)(tvb, offset, 0, pinfo,
tree, 0, *items->hf_index, smb_info);
items++;
}
break;
case 'e':
/*
* A 16-bit entry count is returned.
*/
WParam = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_ecount, tvb, offset, 2,
WParam);
offset += 2;
*has_ent_count_p = TRUE;
*ent_count_p = WParam; /* Save this for later retrieval */
break;
default:
break;
}
}
return offset;
}
static int
dissect_transact_data(tvbuff_t *tvb, int offset, int convert,
packet_info *pinfo, proto_tree *tree, const guchar *desc,
const item_t *items, guint16 *aux_count_p, smb_info_t *smb_info)
{
guint c;
guint16 WParam;
guint32 LParam;
int count;
int cptr;
const char *string;
gint string_len = 0;
if (aux_count_p != NULL)
*aux_count_p = 0;
while ((c = *desc++) != '\0') {
switch (c) {
case 'W':
/*
* A 16-bit word value.
* XXX - handle the count?
*/
desc = get_count(desc, &count);
if (items->func == NULL) {
/*
* We've run out of items in the table;
* fall back on the default.
*/
offset = add_word_param(tvb, offset, 0, pinfo,
tree, convert, hf_smb_pipe_word_param, smb_info);
} else if (items->type != PARAM_WORD) {
/*
* Descriptor character is 'W', but this
* isn't a word parameter.
*/
WParam = tvb_get_letohs(tvb, offset);
proto_tree_add_expert_format(tree, pinfo, &ei_smb_pipe_bad_type, tvb, offset, 2,
"%s: Value is %u (0x%04X), type is wrong (W)",
proto_registrar_get_name((*items->hf_index == -1) ?
hf_smb_pipe_word_param : *items->hf_index),
WParam, WParam);
offset += 2;
items++;
} else {
offset = (*items->func)(tvb, offset, 0, pinfo,
tree, convert, *items->hf_index, smb_info);
items++;
}
break;
case 'D':
/*
* A 32-bit doubleword value.
* XXX - handle the count?
*/
desc = get_count(desc, &count);
if (items->func == NULL) {
/*
* We've run out of items in the table;
* fall back on the default.
*/
offset = add_dword_param(tvb, offset, 0, pinfo,
tree, convert, hf_smb_pipe_doubleword_param, smb_info);
} else if (items->type != PARAM_DWORD) {
/*
* Descriptor character is 'D', but this
* isn't a doubleword parameter.
*/
LParam = tvb_get_letohl(tvb, offset);
proto_tree_add_expert_format(tree, pinfo, &ei_smb_pipe_bad_type, tvb, offset, 2,
"%s: Value is %u (0x%08X), type is wrong (D)",
proto_registrar_get_name((*items->hf_index == -1) ?
hf_smb_pipe_doubleword_param : *items->hf_index),
LParam, LParam);
offset += 4;
items++;
} else {
offset = (*items->func)(tvb, offset, 0, pinfo,
tree, convert, *items->hf_index, smb_info);
items++;
}
break;
case 'B':
/*
* A byte or multi-byte value.
*/
desc = get_count(desc, &count);
if (items->func == NULL) {
/*
* We've run out of items in the table;
* fall back on the default.
*/
offset = add_bytes_param(tvb, offset, count,
pinfo, tree, convert, -1, smb_info);
} else if (items->type != PARAM_BYTES) {
/*
* Descriptor character is 'B', but this
* isn't a byte/bytes parameter.
*/
proto_tree_add_expert_format(tree, pinfo, &ei_smb_pipe_bad_type, tvb, offset, count,
"%s: Value is %s, type is wrong (B)",
proto_registrar_get_name((*items->hf_index == -1) ?
hf_smb_pipe_bytes_param : *items->hf_index),
tvb_bytes_to_str(pinfo->pool, tvb, offset, count));
offset += count;
items++;
} else {
offset = (*items->func)(tvb, offset, count,
pinfo, tree, convert, *items->hf_index, smb_info);
items++;
}
break;
case 'O':
/*
* A null pointer.
*/
if (items->func == NULL) {
/*
* We've run out of items in the table;
* fall back on the default.
*/
add_null_pointer_param(tvb, offset, 0,
pinfo, tree, convert, -1, smb_info);
} else {
/*
* If "*items->hf_index" is -1, this is
* a reserved must-be-null field; don't
* clutter the protocol tree by putting
* it in.
*/
if (*items->hf_index != -1) {
add_null_pointer_param(tvb,
offset, 0, pinfo, tree, convert,
*items->hf_index, smb_info);
}
items++;
}
break;
case 'z':
/*
* A pointer to a null-terminated ASCII string.
*/
if (items->func == NULL) {
/*
* We've run out of items in the table;
* fall back on the default.
*/
offset = add_stringz_pointer_param(tvb, offset,
0, pinfo, tree, convert, -1, smb_info);
} else if (items->type != PARAM_STRINGZ) {
/*
* Descriptor character is 'z', but this
* isn't a string parameter.
*/
string = get_stringz_pointer_value(tvb, offset,
convert, &cptr, &string_len);
offset += 4;
proto_tree_add_expert_format(tree, pinfo, &ei_smb_pipe_bad_type, tvb, cptr, string_len,
"%s: Value is %s, type is wrong (z)",
proto_registrar_get_name((*items->hf_index == -1) ?
hf_smb_pipe_string_param : *items->hf_index),
string ? string : "(null)");
items++;
} else {
offset = (*items->func)(tvb, offset, 0,
pinfo, tree, convert, *items->hf_index, smb_info);
items++;
}
break;
case 'b':
/*
* A pointer to a byte or multi-byte value.
*/
desc = get_count(desc, &count);
if (items->func == NULL) {
/*
* We've run out of items in the table;
* fall back on the default.
*/
offset = add_bytes_pointer_param(tvb, offset,
count, pinfo, tree, convert, -1, smb_info);
} else if (items->type != PARAM_BYTES) {
/*
* Descriptor character is 'b', but this
* isn't a byte/bytes parameter.
*/
cptr = (tvb_get_letohl(tvb, offset)&0xffff)-convert;
offset += 4;
proto_tree_add_expert_format(tree, pinfo, &ei_smb_pipe_bad_type, tvb, offset, count,
"%s: Value is %s, type is wrong (b)",
proto_registrar_get_name((*items->hf_index == -1) ?
hf_smb_pipe_bytes_param : *items->hf_index),
tvb_bytes_to_str(pinfo->pool, tvb, cptr, count));
items++;
} else {
offset = (*items->func)(tvb, offset, count,
pinfo, tree, convert, *items->hf_index, smb_info);
items++;
}
break;
case 'N':
/*
* 16-bit auxiliary data structure count.
* XXX - hf_acount?
*/
WParam = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_aux_data_struct_count, tvb, offset, 2, WParam);
offset += 2;
if (aux_count_p != NULL)
*aux_count_p = WParam; /* Save this for later retrieval */
break;
default:
break;
}
}
return offset;
}
static const value_string commands[] = {
{API_NetShareEnum, "NetShareEnum"},
{API_NetShareGetInfo, "NetShareGetInfo"},
{API_NetShareSetInfo, "NetShareSetInfo"},
{API_NetShareAdd, "NetShareAdd"},
{API_NetShareDel, "NetShareDel"},
{API_NetShareCheck, "NetShareCheck"},
{API_NetSessionEnum, "NetSessionEnum"},
{API_NetSessionGetInfo, "NetSessionGetInfo"},
{API_NetSessionDel, "NetSessionDel"},
{API_WconnectionEnum, "NetConnectionEnum"},
{API_NetFileEnum, "NetFileEnum"},
{API_NetFileGetInfo, "NetFileGetInfo"},
{API_NetFileClose, "NetFileClose"},
{API_NetServerGetInfo, "NetServerGetInfo"},
{API_NetServerSetInfo, "NetServerSetInfo"},
{API_NetServerDiskEnum, "NetServerDiskEnum"},
{API_NetServerAdminCommand, "NetServerAdminCommand"},
{API_NetAuditOpen, "NetAuditOpen"},
{API_NetAuditClear, "NetAuditClear"},
{API_NetErrorLogOpen, "NetErrorLogOpen"},
{API_NetErrorLogClear, "NetErrorLogClear"},
{API_NetCharDevEnum, "NetCharDevEnum"},
{API_NetCharDevGetInfo, "NetCharDevGetInfo"},
{API_NetCharDevControl, "NetCharDevControl"},
{API_NetCharDevQEnum, "NetCharDevQEnum"},
{API_NetCharDevQGetInfo, "NetCharDevQGetInfo"},
{API_NetCharDevQSetInfo, "NetCharDevQSetInfo"},
{API_NetCharDevQPurge, "NetCharDevQPurge"},
{API_NetCharDevQPurgeSelf, "NetCharDevQPurgeSelf"},
{API_NetMessageNameEnum, "NetMessageNameEnum"},
{API_NetMessageNameGetInfo, "NetMessageNameGetInfo"},
{API_NetMessageNameAdd, "NetMessageNameAdd"},
{API_NetMessageNameDel, "NetMessageNameDel"},
{API_NetMessageNameFwd, "NetMessageNameFwd"},
{API_NetMessageNameUnFwd, "NetMessageNameUnFwd"},
{API_NetMessageBufferSend, "NetMessageBufferSend"},
{API_NetMessageFileSend, "NetMessageFileSend"},
{API_NetMessageLogFileSet, "NetMessageLogFileSet"},
{API_NetMessageLogFileGet, "NetMessageLogFileGet"},
{API_NetServiceEnum, "NetServiceEnum"},
{API_NetServiceInstall, "NetServiceInstall"},
{API_NetServiceControl, "NetServiceControl"},
{API_NetAccessEnum, "NetAccessEnum"},
{API_NetAccessGetInfo, "NetAccessGetInfo"},
{API_NetAccessSetInfo, "NetAccessSetInfo"},
{API_NetAccessAdd, "NetAccessAdd"},
{API_NetAccessDel, "NetAccessDel"},
{API_NetGroupEnum, "NetGroupEnum"},
{API_NetGroupAdd, "NetGroupAdd"},
{API_NetGroupDel, "NetGroupDel"},
{API_NetGroupAddUser, "NetGroupAddUser"},
{API_NetGroupDelUser, "NetGroupDelUser"},
{API_NetGroupGetUsers, "NetGroupGetUsers"},
{API_NetUserEnum, "NetUserEnum"},
{API_NetUserAdd, "NetUserAdd"},
{API_NetUserDel, "NetUserDel"},
{API_NetUserGetInfo, "NetUserGetInfo"},
{API_NetUserSetInfo, "NetUserSetInfo"},
{API_NetUserPasswordSet, "NetUserPasswordSet"},
{API_NetUserGetGroups, "NetUserGetGroups"},
{API_NetWkstaSetUID, "NetWkstaSetUID"},
{API_NetWkstaGetInfo, "NetWkstaGetInfo"},
{API_NetWkstaSetInfo, "NetWkstaSetInfo"},
{API_NetUseEnum, "NetUseEnum"},
{API_NetUseAdd, "NetUseAdd"},
{API_NetUseDel, "NetUseDel"},
{API_NetUseGetInfo, "NetUseGetInfo"},
{API_WPrintQEnum, "WPrintQEnum"},
{API_WPrintQGetInfo, "WPrintQGetInfo"},
{API_WPrintQSetInfo, "WPrintQSetInfo"},
{API_WPrintQAdd, "WPrintQAdd"},
{API_WPrintQDel, "WPrintQDel"},
{API_WPrintQPause, "WPrintQPause"},
{API_WPrintQContinue, "WPrintQContinue"},
{API_WPrintJobEnum, "WPrintJobEnum"},
{API_WPrintJobGetInfo, "WPrintJobGetInfo"},
{API_WPrintJobSetInfo_OLD, "WPrintJobSetInfo_OLD"},
{API_WPrintJobDel, "WPrintJobDel"},
{API_WPrintJobPause, "WPrintJobPause"},
{API_WPrintJobContinue, "WPrintJobContinue"},
{API_WPrintDestEnum, "WPrintDestEnum"},
{API_WPrintDestGetInfo, "WPrintDestGetInfo"},
{API_WPrintDestControl, "WPrintDestControl"},
{API_NetProfileSave, "NetProfileSave"},
{API_NetProfileLoad, "NetProfileLoad"},
{API_NetStatisticsGet, "NetStatisticsGet"},
{API_NetStatisticsClear, "NetStatisticsClear"},
{API_NetRemoteTOD, "NetRemoteTOD"},
{API_WNetBiosEnum, "WNetBiosEnum"},
{API_WNetBiosGetInfo, "WNetBiosGetInfo"},
{API_NetServerEnum, "NetServerEnum"},
{API_I_NetServerEnum, "I_NetServerEnum"},
{API_NetServiceGetInfo, "NetServiceGetInfo"},
{API_WPrintQPurge, "WPrintQPurge"},
{API_NetServerEnum2, "NetServerEnum2"},
{API_NetAccessGetUserPerms, "NetAccessGetUserPerms"},
{API_NetGroupGetInfo, "NetGroupGetInfo"},
{API_NetGroupSetInfo, "NetGroupSetInfo"},
{API_NetGroupSetUsers, "NetGroupSetUsers"},
{API_NetUserSetGroups, "NetUserSetGroups"},
{API_NetUserModalsGet, "NetUserModalsGet"},
{API_NetUserModalsSet, "NetUserModalsSet"},
{API_NetFileEnum2, "NetFileEnum2"},
{API_NetUserAdd2, "NetUserAdd2"},
{API_NetUserSetInfo2, "NetUserSetInfo2"},
{API_NetUserPasswordSet2, "SetUserPassword"},
{API_I_NetServerEnum2, "I_NetServerEnum2"},
{API_NetConfigGet2, "NetConfigGet2"},
{API_NetConfigGetAll2, "NetConfigGetAll2"},
{API_NetGetDCName, "NetGetDCName"},
{API_NetHandleGetInfo, "NetHandleGetInfo"},
{API_NetHandleSetInfo, "NetHandleSetInfo"},
{API_NetStatisticsGet2, "NetStatisticsGet2"},
{API_WBuildGetInfo, "WBuildGetInfo"},
{API_NetFileGetInfo2, "NetFileGetInfo2"},
{API_NetFileClose2, "NetFileClose2"},
{API_NetServerReqChallenge, "NetServerReqChallenge"},
{API_NetServerAuthenticate, "NetServerAuthenticate"},
{API_NetServerPasswordSet, "NetServerPasswordSet"},
{API_WNetAccountDeltas, "WNetAccountDeltas"},
{API_WNetAccountSync, "WNetAccountSync"},
{API_NetUserEnum2, "NetUserEnum2"},
{API_NetWkstaUserLogon, "NetWkstaUserLogon"},
{API_NetWkstaUserLogoff, "NetWkstaUserLogoff"},
{API_NetLogonEnum, "NetLogonEnum"},
{API_NetErrorLogRead, "NetErrorLogRead"},
{API_I_NetPathType, "I_NetPathType"},
{API_I_NetPathCanonicalize, "I_NetPathCanonicalize"},
{API_I_NetPathCompare, "I_NetPathCompare"},
{API_I_NetNameValidate, "I_NetNameValidate"},
{API_I_NetNameCanonicalize, "I_NetNameCanonicalize"},
{API_I_NetNameCompare, "I_NetNameCompare"},
{API_NetAuditRead, "NetAuditRead"},
{API_WPrintDestAdd, "WPrintDestAdd"},
{API_WPrintDestSetInfo, "WPrintDestSetInfo"},
{API_WPrintDestDel, "WPrintDestDel"},
{API_NetUserValidate2, "NetUserValidate2"},
{API_WPrintJobSetInfo, "WPrintJobSetInfo"},
{API_TI_NetServerDiskEnum, "TI_NetServerDiskEnum"},
{API_TI_NetServerDiskGetInfo, "TI_NetServerDiskGetInfo"},
{API_TI_FTVerifyMirror, "TI_FTVerifyMirror"},
{API_TI_FTAbortVerify, "TI_FTAbortVerify"},
{API_TI_FTGetInfo, "TI_FTGetInfo"},
{API_TI_FTSetInfo, "TI_FTSetInfo"},
{API_TI_FTLockDisk, "TI_FTLockDisk"},
{API_TI_FTFixError, "TI_FTFixError"},
{API_TI_FTAbortFix, "TI_FTAbortFix"},
{API_TI_FTDiagnoseError, "TI_FTDiagnoseError"},
{API_TI_FTGetDriveStats, "TI_FTGetDriveStats"},
{API_TI_FTErrorGetInfo, "TI_FTErrorGetInfo"},
{API_NetAccessCheck, "NetAccessCheck"},
{API_NetAlertRaise, "NetAlertRaise"},
{API_NetAlertStart, "NetAlertStart"},
{API_NetAlertStop, "NetAlertStop"},
{API_NetAuditWrite, "NetAuditWrite"},
{API_NetIRemoteAPI, "NetIRemoteAPI"},
{API_NetServiceStatus, "NetServiceStatus"},
{API_I_NetServerRegister, "I_NetServerRegister"},
{API_I_NetServerDeregister, "I_NetServerDeregister"},
{API_I_NetSessionEntryMake, "I_NetSessionEntryMake"},
{API_I_NetSessionEntryClear, "I_NetSessionEntryClear"},
{API_I_NetSessionEntryGetInfo, "I_NetSessionEntryGetInfo"},
{API_I_NetSessionEntrySetInfo, "I_NetSessionEntrySetInfo"},
{API_I_NetConnectionEntryMake, "I_NetConnectionEntryMake"},
{API_I_NetConnectionEntryClear, "I_NetConnectionEntryClear"},
{API_I_NetConnectionEntrySetInfo, "I_NetConnectionEntrySetInfo"},
{API_I_NetConnectionEntryGetInfo, "I_NetConnectionEntryGetInfo"},
{API_I_NetFileEntryMake, "I_NetFileEntryMake"},
{API_I_NetFileEntryClear, "I_NetFileEntryClear"},
{API_I_NetFileEntrySetInfo, "I_NetFileEntrySetInfo"},
{API_I_NetFileEntryGetInfo, "I_NetFileEntryGetInfo"},
{API_AltSrvMessageBufferSend, "AltSrvMessageBufferSend"},
{API_AltSrvMessageFileSend, "AltSrvMessageFileSend"},
{API_wI_NetRplWkstaEnum, "wI_NetRplWkstaEnum"},
{API_wI_NetRplWkstaGetInfo, "wI_NetRplWkstaGetInfo"},
{API_wI_NetRplWkstaSetInfo, "wI_NetRplWkstaSetInfo"},
{API_wI_NetRplWkstaAdd, "wI_NetRplWkstaAdd"},
{API_wI_NetRplWkstaDel, "wI_NetRplWkstaDel"},
{API_wI_NetRplProfileEnum, "wI_NetRplProfileEnum"},
{API_wI_NetRplProfileGetInfo, "wI_NetRplProfileGetInfo"},
{API_wI_NetRplProfileSetInfo, "wI_NetRplProfileSetInfo"},
{API_wI_NetRplProfileAdd, "wI_NetRplProfileAdd"},
{API_wI_NetRplProfileDel, "wI_NetRplProfileDel"},
{API_wI_NetRplProfileClone, "wI_NetRplProfileClone"},
{API_wI_NetRplBaseProfileEnum, "wI_NetRplBaseProfileEnum"},
{API_WIServerSetInfo, "WIServerSetInfo"},
{API_WPrintDriverEnum, "WPrintDriverEnum"},
{API_WPrintQProcessorEnum, "WPrintQProcessorEnum"},
{API_WPrintPortEnum, "WPrintPortEnum"},
{API_WNetWriteUpdateLog, "WNetWriteUpdateLog"},
{API_WNetAccountUpdate, "WNetAccountUpdate"},
{API_WNetAccountConfirmUpdate, "WNetAccountConfirmUpdate"},
{API_NetConfigSet, "NetConfigSet"},
{API_WAccountsReplicate, "WAccountsReplicate"},
{API_SamOEMChgPasswordUser2_P, "SamOEMChangePassword"},
{API_NetServerEnum3, "NetServerEnum3"},
{API_WPrintDriverGetInfo, "WPrintDriverGetInfo"},
{API_WPrintDriverSetInfo, "WPrintDriverSetInfo"},
{API_NetAliasAdd, "NetAliasAdd"},
{API_NetAliasDel, "NetAliasDel"},
{API_NetAliasGetInfo, "NetAliasGetInfo"},
{API_NetAliasSetInfo, "NetAliasSetInfo"},
{API_NetAliasEnum, "NetAliasEnum"},
{API_NetUserGetLogonAsn, "NetUserGetLogonAsn"},
{API_NetUserSetLogonAsn, "NetUserSetLogonAsn"},
{API_NetUserGetAppSel, "NetUserGetAppSel"},
{API_NetUserSetAppSel, "NetUserSetAppSel"},
{API_NetAppAdd, "NetAppAdd"},
{API_NetAppDel, "NetAppDel"},
{API_NetAppGetInfo, "NetAppGetInfo"},
{API_NetAppSetInfo, "NetAppSetInfo"},
{API_NetAppEnum, "NetAppEnum"},
{API_NetUserDCDBInit, "NetUserDCDBInit"},
{API_NetDASDAdd, "NetDASDAdd"},
{API_NetDASDDel, "NetDASDDel"},
{API_NetDASDGetInfo, "NetDASDGetInfo"},
{API_NetDASDSetInfo, "NetDASDSetInfo"},
{API_NetDASDEnum, "NetDASDEnum"},
{API_NetDASDCheck, "NetDASDCheck"},
{API_NetDASDCtl, "NetDASDCtl"},
{API_NetUserRemoteLogonCheck, "NetUserRemoteLogonCheck"},
{API_NetUserPasswordSet3, "NetUserPasswordSet3"},
{API_NetCreateRIPLMachine, "NetCreateRIPLMachine"},
{API_NetDeleteRIPLMachine, "NetDeleteRIPLMachine"},
{API_NetGetRIPLMachineInfo, "NetGetRIPLMachineInfo"},
{API_NetSetRIPLMachineInfo, "NetSetRIPLMachineInfo"},
{API_NetEnumRIPLMachine, "NetEnumRIPLMachine"},
{API_I_ShareAdd, "I_ShareAdd"},
{API_I_AliasEnum, "I_AliasEnum"},
{API_NetAccessApply, "NetAccessApply"},
{API_WPrt16Query, "WPrt16Query"},
{API_WPrt16Set, "WPrt16Set"},
{API_NetUserDel100, "NetUserDel100"},
{API_NetUserRemoteLogonCheck2, "NetUserRemoteLogonCheck2"},
{API_WRemoteTODSet, "WRemoteTODSet"},
{API_WPrintJobMoveAll, "WPrintJobMoveAll"},
{API_W16AppParmAdd, "W16AppParmAdd"},
{API_W16AppParmDel, "W16AppParmDel"},
{API_W16AppParmGet, "W16AppParmGet"},
{API_W16AppParmSet, "W16AppParmSet"},
{API_W16RIPLMachineCreate, "W16RIPLMachineCreate"},
{API_W16RIPLMachineGetInfo, "W16RIPLMachineGetInfo"},
{API_W16RIPLMachineSetInfo, "W16RIPLMachineSetInfo"},
{API_W16RIPLMachineEnum, "W16RIPLMachineEnum"},
{API_W16RIPLMachineListParmEnum, "W16RIPLMachineListParmEnum"},
{API_W16RIPLMachClassGetInfo, "W16RIPLMachClassGetInfo"},
{API_W16RIPLMachClassEnum, "W16RIPLMachClassEnum"},
{API_W16RIPLMachClassCreate, "W16RIPLMachClassCreate"},
{API_W16RIPLMachClassSetInfo, "W16RIPLMachClassSetInfo"},
{API_W16RIPLMachClassDelete, "W16RIPLMachClassDelete"},
{API_W16RIPLMachClassLPEnum, "W16RIPLMachClassLPEnum"},
{API_W16RIPLMachineDelete, "W16RIPLMachineDelete"},
{API_W16WSLevelGetInfo, "W16WSLevelGetInfo"},
{API_NetServerNameAdd, "NetServerNameAdd"},
{API_NetServerNameDel, "NetServerNameDel"},
{API_NetServerNameEnum, "NetServerNameEnum"},
{API_I_WDASDEnum, "I_WDASDEnum"},
{API_I_WDASDEnumTerminate, "I_WDASDEnumTerminate"},
{API_I_WDASDSetInfo2, "I_WDASDSetInfo2"},
{0, NULL}
};
static value_string_ext commands_ext = VALUE_STRING_EXT_INIT(commands);
static void
dissect_response_data(tvbuff_t *tvb, packet_info *pinfo, int convert,
proto_tree *tree, smb_info_t *smb_info,
const struct lanman_desc *lanman, gboolean has_ent_count,
guint16 ent_count)
{
smb_transact_info_t *trp;
const item_list_t *resp_data_list;
int offset, start_offset;
const char *label;
gint ett;
const item_t *resp_data;
proto_item *data_item = NULL;
proto_tree *data_tree = NULL;
proto_item *entry_item;
proto_tree *entry_tree;
guint i, j;
guint16 aux_count;
trp = (smb_transact_info_t *)smb_info->sip->extra_info;
/*
* Find the item table for the matching request's detail level.
*/
for (resp_data_list = lanman->resp_data_list;
resp_data_list->level != -1; resp_data_list++) {
if (resp_data_list->level == trp->info_level)
break;
}
resp_data = resp_data_list->item_list;
offset = 0;
if (has_ent_count) {
/*
* The data is a list of entries; create a protocol tree item
* for it.
*/
if (tree) {
label = lanman->resp_data_entry_list_label;
if (label == NULL)
label = "Entries";
if (lanman->ett_data_entry_list != NULL)
ett = *lanman->ett_data_entry_list;
else
ett = ett_lanman_unknown_entries;
data_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett, &data_item, label);
}
}
if (trp->data_descrip == NULL) {
/*
* This could happen if we only dissected
* part of the request to which this is a
* reply, e.g. if the request was split
* across TCP segments and we weren't doing
* TCP desegmentation, or if we had a snapshot
* length that was too short.
*
* We can't dissect the data; just show it as raw data or,
* if we've already created a top-level item, note that
* no descriptor is available.
*/
if (has_ent_count) {
if (data_item != NULL) {
proto_item_append_text(data_item,
" (No descriptor available)");
}
} else {
proto_tree_add_item(data_tree, hf_data_no_descriptor, tvb, offset, -1, ENC_NA);
}
offset += tvb_captured_length_remaining(tvb, offset);
} else {
/*
* If we have an entry count, show all the entries,
* with each one having a protocol tree item.
*
* Otherwise, we just show one returned item, with
* no protocol tree item.
*/
if (!has_ent_count)
ent_count = 1;
for (i = 0; i < ent_count; i++) {
start_offset = offset;
if (has_ent_count &&
lanman->resp_data_element_item != NULL) {
/*
* Create a protocol tree item for the
* entry.
*/
entry_item =
(*lanman->resp_data_element_item)
(tvb, data_tree, offset);
entry_tree = proto_item_add_subtree(
entry_item,
*lanman->ett_resp_data_element_item);
} else {
/*
* Just leave it at the current
* level.
*/
entry_item = NULL;
entry_tree = data_tree;
}
offset = dissect_transact_data(tvb, offset,
convert, pinfo, entry_tree,
trp->data_descrip, resp_data, &aux_count, smb_info);
/* auxiliary data */
if (trp->aux_data_descrip != NULL) {
for (j = 0; j < aux_count; j++) {
offset = dissect_transact_data(
tvb, offset, convert,
pinfo, entry_tree,
trp->data_descrip,
lanman->resp_aux_data, NULL, smb_info);
}
}
if (entry_item != NULL) {
/*
* Set the length of the protocol tree
* item for the entry.
*/
proto_item_set_len(entry_item,
offset - start_offset);
}
}
}
if (data_item != NULL) {
/*
* Set the length of the protocol tree item
* for the data.
*/
proto_item_set_len(data_item, offset);
}
}
static gboolean
dissect_pipe_lanman(tvbuff_t *pd_tvb, tvbuff_t *p_tvb, tvbuff_t *d_tvb,
packet_info *pinfo, proto_tree *parent_tree, smb_info_t *smb_info)
{
smb_transact_info_t *trp = NULL;
int offset = 0/*, start_offset*/;
guint16 cmd;
guint16 status;
int convert;
const struct lanman_desc *lanman;
proto_item *item = NULL;
proto_tree *tree = NULL;
guint descriptor_len;
const gchar *param_descrip, *data_descrip, *aux_data_descrip = NULL;
gboolean has_data;
gboolean has_ent_count;
guint16 ent_count = 0, aux_count;
guint i;
proto_item *data_item;
proto_tree *data_tree;
if (smb_info->sip->extra_info_type == SMB_EI_TRI)
trp = (smb_transact_info_t *)smb_info->sip->extra_info;
if (!proto_is_protocol_enabled(find_protocol_by_id(proto_smb_lanman)))
return FALSE;
if (p_tvb == NULL) {
/*
* Requests must have parameters.
*/
return FALSE;
}
pinfo->current_proto = "LANMAN";
col_set_str(pinfo->cinfo, COL_PROTOCOL, "LANMAN");
if (parent_tree) {
item = proto_tree_add_item(parent_tree, proto_smb_lanman,
pd_tvb, 0, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_lanman);
}
if (smb_info->request) { /* this is a request */
/* function code */
cmd = tvb_get_letohs(p_tvb, offset);
col_add_fstr(pinfo->cinfo, COL_INFO, "%s Request", val_to_str_ext(cmd, &commands_ext, "Unknown Command (%u)"));
proto_tree_add_uint(tree, hf_function_code, p_tvb, offset, 2,
cmd);
offset += 2;
if(!trp){
return FALSE; /* can't dissect this request */
}
/*
* If we haven't already done so, save the function code in
* the structure we were handed, so that it's available to
* the code parsing the reply, and initialize the detail
* level to -1, meaning "unknown".
*/
if (!pinfo->fd->visited) {
trp->lanman_cmd = cmd;
trp->info_level = -1;
trp->param_descrip=NULL;
trp->data_descrip=NULL;
trp->aux_data_descrip=NULL;
}
/* parameter descriptor */
param_descrip = tvb_get_stringz_enc(pinfo->pool, p_tvb, offset, &descriptor_len, ENC_ASCII);
proto_tree_add_string(tree, hf_param_desc, p_tvb, offset, descriptor_len, param_descrip);
if (!pinfo->fd->visited) {
/*
* Save the parameter descriptor for future use.
*/
DISSECTOR_ASSERT(trp->param_descrip == NULL);
trp->param_descrip = wmem_strdup(wmem_file_scope(), param_descrip);
}
offset += descriptor_len;
/* return descriptor */
data_descrip = tvb_get_stringz_enc(pinfo->pool, p_tvb, offset, &descriptor_len, ENC_ASCII);
proto_tree_add_string(tree, hf_return_desc, p_tvb, offset, descriptor_len, data_descrip);
if (!pinfo->fd->visited) {
/*
* Save the return descriptor for future use.
*/
DISSECTOR_ASSERT(trp->data_descrip == NULL);
trp->data_descrip = wmem_strdup(wmem_file_scope(), data_descrip);
}
offset += descriptor_len;
lanman = find_lanman(cmd);
/* request parameters */
/*start_offset = offset;*/
offset = dissect_request_parameters(p_tvb, offset, pinfo, tree,
param_descrip, lanman->req, &has_data, smb_info);
/* auxiliary data descriptor */
if (tvb_reported_length_remaining(p_tvb, offset) > 0){
/*
* There are more parameters left, so the next
* item is the auxiliary data descriptor.
*/
aux_data_descrip = tvb_get_stringz_enc(pinfo->pool, p_tvb, offset, &descriptor_len, ENC_ASCII);
proto_tree_add_string(tree, hf_aux_data_desc, p_tvb, offset, descriptor_len, aux_data_descrip);
if (!pinfo->fd->visited) {
/*
* Save the auxiliary data descriptor for
* future use.
*/
DISSECTOR_ASSERT(trp->aux_data_descrip == NULL);
trp->aux_data_descrip =
wmem_strdup(wmem_file_scope(), aux_data_descrip);
}
}
/* reset offset, we now start dissecting the data area */
offset = 0;
if (has_data && d_tvb && tvb_reported_length(d_tvb) != 0) {
/*
* There's a send buffer item in the descriptor
* string, and the data count in the transaction
* is non-zero, so there's data to dissect.
*/
if (lanman->req_data_item != NULL) {
/*
* Create a protocol tree item for the data.
*/
data_item = (*lanman->req_data_item)(d_tvb,
pinfo, tree, offset);
data_tree = proto_item_add_subtree(data_item,
*lanman->ett_req_data);
} else {
/*
* Just leave it at the top level.
*/
data_item = NULL;
data_tree = tree;
}
/* data */
offset = dissect_transact_data(d_tvb, offset, -1,
pinfo, data_tree, data_descrip, lanman->req_data,
&aux_count, smb_info); /* XXX - what about strings? */
/* auxiliary data */
if (aux_data_descrip != NULL) {
for (i = 0; i < aux_count; i++) {
offset = dissect_transact_data(d_tvb,
offset, -1, pinfo, data_tree,
aux_data_descrip,
lanman->req_aux_data, NULL, smb_info);
}
}
if (data_item != NULL) {
/*
* Set the length of the protocol tree item
* for the data.
*/
proto_item_set_len(data_item, offset);
}
}
} else {
/*
* This is a response.
* Have we seen the request to which it's a response?
*/
if (trp == NULL)
return FALSE; /* no - can't dissect it */
/* ok we have seen this one before */
/* if it looks like an interim response, update COL_INFO and return */
if( ( tvb_reported_length(p_tvb)==0 )
&& ( tvb_reported_length(d_tvb)==0 ) ){
/* command */
col_add_fstr(pinfo->cinfo, COL_INFO, "%s Interim Response",
val_to_str_ext(trp->lanman_cmd, &commands_ext, "Unknown Command (%u)"));
proto_tree_add_uint(tree, hf_function_code, p_tvb, 0, 0, trp->lanman_cmd);
return TRUE;
}
/* command */
col_add_fstr(pinfo->cinfo, COL_INFO, "%s Response",
val_to_str_ext(trp->lanman_cmd, &commands_ext, "Unknown Command (%u)"));
proto_tree_add_uint(tree, hf_function_code, p_tvb, 0, 0,
trp->lanman_cmd);
lanman = find_lanman(trp->lanman_cmd);
/* response parameters */
/* status */
status = tvb_get_letohs(p_tvb, offset);
proto_tree_add_uint(tree, hf_status, p_tvb, offset, 2, status);
offset += 2;
/* convert */
convert = tvb_get_letohs(p_tvb, offset);
proto_tree_add_uint(tree, hf_convert, p_tvb, offset, 2, convert);
offset += 2;
if (trp->param_descrip == NULL) {
/*
* This could happen if we only dissected
* part of the request to which this is a
* reply, e.g. if the request was split
* across TCP segments and we weren't doing
* TCP desegmentation, or if we had a snapshot
* length that was too short.
*
* We can't dissect the parameters; just show them
* as raw data.
*/
proto_tree_add_item(tree, hf_param_no_descriptor, p_tvb, offset, -1, ENC_NA);
/*
* We don't know whether we have a receive buffer,
* as we don't have the descriptor; just show what
* bytes purport to be data.
*/
if (d_tvb && tvb_reported_length(d_tvb) > 0) {
proto_tree_add_item(tree, hf_data_no_descriptor, d_tvb, 0, -1, ENC_NA);
}
} else {
/* rest of the parameters */
dissect_response_parameters(p_tvb, offset,
pinfo, tree, trp->param_descrip, lanman->resp,
&has_data, &has_ent_count, &ent_count, smb_info);
/* data */
if (d_tvb && tvb_reported_length(d_tvb) > 0) {
/*
* Well, there are bytes that purport to
* be data, at least.
*/
if (has_data) {
/*
* There's a receive buffer item
* in the descriptor string, so
* dissect it as response data.
*/
dissect_response_data(d_tvb, pinfo,
convert, tree, smb_info, lanman,
has_ent_count, ent_count);
} else {
/*
* There's no receive buffer item,
* but we do have data, so just
* show what bytes are data.
*/
proto_tree_add_item(tree, hf_data_no_recv_buffer, d_tvb, 0, -1, ENC_NA);
}
}
}
}
return TRUE;
}
void
proto_register_pipe_lanman(void)
{
static hf_register_info hf[] = {
{ &hf_function_code,
{ "Function Code", "lanman.function_code", FT_UINT16, BASE_DEC|BASE_EXT_STRING,
&commands_ext, 0, "LANMAN Function Code/Command", HFILL }},
{ &hf_param_desc,
{ "Parameter Descriptor", "lanman.param_desc", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Parameter Descriptor", HFILL }},
{ &hf_return_desc,
{ "Return Descriptor", "lanman.ret_desc", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Return Descriptor", HFILL }},
{ &hf_aux_data_desc,
{ "Auxiliary Data Descriptor", "lanman.aux_data_desc", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Auxiliary Data Descriptor", HFILL }},
{ &hf_detail_level,
{ "Detail Level", "lanman.level", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Detail Level", HFILL }},
{ &hf_padding,
{ "Padding", "lanman.padding", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_recv_buf_len,
{ "Receive Buffer Length", "lanman.recv_buf_len", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Receive Buffer Length", HFILL }},
{ &hf_send_buf_len,
{ "Send Buffer Length", "lanman.send_buf_len", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Send Buffer Length", HFILL }},
#if 0
{ &hf_continuation_from,
{ "Continuation from message in frame", "lanman.continuation_from", FT_UINT32, BASE_DEC,
NULL, 0, "This is a LANMAN continuation from the message in the frame in question", HFILL }},
#endif
{ &hf_status,
{ "Status", "lanman.status", FT_UINT16, BASE_DEC,
VALS(status_vals), 0, "LANMAN Return status", HFILL }},
{ &hf_convert,
{ "Convert", "lanman.convert", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Convert", HFILL }},
{ &hf_param_no_descriptor,
{ "Parameters (no descriptor available)", "lanman.param_no_descriptor", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_data_no_descriptor,
{ "Data (no descriptor available)", "lanman.data_no_descriptor", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_data_no_recv_buffer,
{ "Data (no receive buffer)", "lanman.data_no_recv_buffer", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_ecount,
{ "Entry Count", "lanman.entry_count", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Number of Entries", HFILL }},
{ &hf_acount,
{ "Available Entries", "lanman.available_count", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Number of Available Entries", HFILL }},
{ &hf_share,
{ "Share", "lanman.share", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_share_name,
{ "Share Name", "lanman.share.name", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Name of Share", HFILL }},
{ &hf_share_type,
{ "Share Type", "lanman.share.type", FT_UINT16, BASE_DEC,
VALS(share_type_vals), 0, "LANMAN Type of Share", HFILL }},
{ &hf_share_comment,
{ "Share Comment", "lanman.share.comment", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Share Comment", HFILL }},
{ &hf_share_permissions,
{ "Share Permissions", "lanman.share.permissions", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Permissions on share", HFILL }},
{ &hf_share_max_uses,
{ "Share Max Uses", "lanman.share.max_uses", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Max connections allowed to share", HFILL }},
{ &hf_share_current_uses,
{ "Share Current Uses", "lanman.share.current_uses", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Current connections to share", HFILL }},
{ &hf_share_path,
{ "Share Path", "lanman.share.path", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Share Path", HFILL }},
{ &hf_share_password,
{ "Share Password", "lanman.share.password", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Share Password", HFILL }},
{ &hf_server,
{ "Server", "lanman.server", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_server_name,
{ "Server Name", "lanman.server.name", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Name of Server", HFILL }},
{ &hf_server_major,
{ "Major Version", "lanman.server.major", FT_UINT8, BASE_DEC,
NULL, 0, "LANMAN Server Major Version", HFILL }},
{ &hf_server_minor,
{ "Minor Version", "lanman.server.minor", FT_UINT8, BASE_DEC,
NULL, 0, "LANMAN Server Minor Version", HFILL }},
{ &hf_server_comment,
{ "Server Comment", "lanman.server.comment", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Server Comment", HFILL }},
{ &hf_abytes,
{ "Available Bytes", "lanman.available_bytes", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Number of Available Bytes", HFILL }},
{ &hf_current_time,
{ "Current Date/Time", "lanman.current_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "LANMAN Current date and time, in seconds since 00:00:00, January 1, 1970", HFILL }},
{ &hf_msecs,
{ "Milliseconds", "lanman.msecs", FT_UINT32, BASE_DEC,
NULL, 0, "LANMAN Milliseconds since arbitrary time in the past (typically boot time)", HFILL }},
{ &hf_hour,
{ "Hour", "lanman.hour", FT_UINT8, BASE_DEC,
NULL, 0, "LANMAN Current hour", HFILL }},
{ &hf_minute,
{ "Minute", "lanman.minute", FT_UINT8, BASE_DEC,
NULL, 0, "LANMAN Current minute", HFILL }},
{ &hf_second,
{ "Second", "lanman.second", FT_UINT8, BASE_DEC,
NULL, 0, "LANMAN Current second", HFILL }},
{ &hf_hundredths,
{ "Hundredths of a second", "lanman.hundredths", FT_UINT8, BASE_DEC,
NULL, 0, "LANMAN Current hundredths of a second", HFILL }},
{ &hf_tzoffset,
{ "Time Zone Offset", "lanman.tzoffset", FT_INT16, BASE_DEC,
NULL, 0, "LANMAN Offset of time zone from GMT, in minutes", HFILL }},
{ &hf_timeinterval,
{ "Time Interval", "lanman.timeinterval", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN .0001 second units per clock tick", HFILL }},
{ &hf_day,
{ "Day", "lanman.day", FT_UINT8, BASE_DEC,
NULL, 0, "LANMAN Current day", HFILL }},
{ &hf_month,
{ "Month", "lanman.month", FT_UINT8, BASE_DEC,
NULL, 0, "LANMAN Current month", HFILL }},
{ &hf_year,
{ "Year", "lanman.year", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Current year", HFILL }},
{ &hf_weekday,
{ "Weekday", "lanman.weekday", FT_UINT8, BASE_DEC,
VALS(weekday_vals), 0, "LANMAN Current day of the week", HFILL }},
{ &hf_enumeration_domain,
{ "Enumeration Domain", "lanman.enumeration_domain", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Domain in which to enumerate servers", HFILL }},
{ &hf_last_entry,
{ "Last Entry", "lanman.last_entry", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN last reported entry of the enumerated servers", HFILL }},
{ &hf_computer_name,
{ "Computer Name", "lanman.computer_name", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Computer Name", HFILL }},
{ &hf_user_name,
{ "User Name", "lanman.user_name", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN User Name", HFILL }},
{ &hf_group_name,
{ "Group Name", "lanman.group_name", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Group Name", HFILL }},
{ &hf_workstation_domain,
{ "Workstation Domain", "lanman.workstation_domain", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Workstation Domain", HFILL }},
{ &hf_workstation_major,
{ "Workstation Major Version", "lanman.workstation_major", FT_UINT8, BASE_DEC,
NULL, 0, "LANMAN Workstation Major Version", HFILL }},
{ &hf_workstation_minor,
{ "Workstation Minor Version", "lanman.workstation_minor", FT_UINT8, BASE_DEC,
NULL, 0, "LANMAN Workstation Minor Version", HFILL }},
{ &hf_logon_domain,
{ "Logon Domain", "lanman.logon_domain", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Logon Domain", HFILL }},
{ &hf_other_domains,
{ "Other Domains", "lanman.other_domains", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Other Domains", HFILL }},
{ &hf_password,
{ "Password", "lanman.password", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Password", HFILL }},
{ &hf_workstation_name,
{ "Workstation Name", "lanman.workstation_name", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Workstation Name", HFILL }},
{ &hf_ustruct_size,
{ "Length of UStruct", "lanman.ustruct_size", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN UStruct Length", HFILL }},
{ &hf_logon_code,
{ "Logon Code", "lanman.logon_code", FT_UINT16, BASE_DEC,
VALS(status_vals), 0, "LANMAN Logon Code", HFILL }},
{ &hf_privilege_level,
{ "Privilege Level", "lanman.privilege_level", FT_UINT16, BASE_DEC,
VALS(privilege_vals), 0, "LANMAN Privilege Level", HFILL }},
{ &hf_operator_privileges,
{ "Operator Privileges", "lanman.operator_privileges", FT_UINT32, BASE_DEC,
VALS(op_privilege_vals), 0, "LANMAN Operator Privileges", HFILL }},
{ &hf_num_logons,
{ "Number of Logons", "lanman.num_logons", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Number of Logons", HFILL }},
{ &hf_bad_pw_count,
{ "Bad Password Count", "lanman.bad_pw_count", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Number of incorrect passwords entered since last successful login", HFILL }},
{ &hf_last_logon,
{ "Last Logon Date/Time", "lanman.last_logon", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "LANMAN Date and time of last logon", HFILL }},
{ &hf_last_logoff,
{ "Last Logoff Date/Time", "lanman.last_logoff", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "LANMAN Date and time of last logoff", HFILL }},
{ &hf_logoff_time,
{ "Logoff Date/Time", "lanman.logoff_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "LANMAN Date and time when user should log off", HFILL }},
{ &hf_kickoff_time,
{ "Kickoff Date/Time", "lanman.kickoff_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "LANMAN Date and time when user will be logged off", HFILL }},
{ &hf_password_age,
{ "Password Age", "lanman.password_age", FT_RELATIVE_TIME, BASE_NONE,
NULL, 0, "LANMAN Time since user last changed his/her password", HFILL }},
{ &hf_password_can_change,
{ "Password Can Change", "lanman.password_can_change", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "LANMAN Date and time when user can change their password", HFILL }},
{ &hf_password_must_change,
{ "Password Must Change", "lanman.password_must_change", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "LANMAN Date and time when user must change their password", HFILL }},
{ &hf_script_path,
{ "Script Path", "lanman.script_path", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Pathname of user's logon script", HFILL }},
{ &hf_logoff_code,
{ "Logoff Code", "lanman.logoff_code", FT_UINT16, BASE_DEC,
VALS(status_vals), 0, "LANMAN Logoff Code", HFILL }},
{ &hf_duration,
{ "Duration of Session", "lanman.duration", FT_RELATIVE_TIME, BASE_NONE,
NULL, 0, "LANMAN Number of seconds the user was logged on", HFILL }},
{ &hf_comment,
{ "Comment", "lanman.comment", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Comment", HFILL }},
{ &hf_user_comment,
{ "User Comment", "lanman.user_comment", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN User Comment", HFILL }},
{ &hf_full_name,
{ "Full Name", "lanman.full_name", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Full Name", HFILL }},
{ &hf_homedir,
{ "Home Directory", "lanman.homedir", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Home Directory", HFILL }},
{ &hf_parameters,
{ "Parameters", "lanman.parameters", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Parameters", HFILL }},
{ &hf_logon_server,
{ "Logon Server", "lanman.logon_server", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Logon Server", HFILL }},
{ &hf_country_code,
{ "Country Code", "lanman.country_code", FT_UINT16, BASE_DEC | BASE_EXT_STRING,
&ms_country_codes_ext, 0, "LANMAN Country Code", HFILL }},
{ &hf_workstations,
{ "Workstations", "lanman.workstations", FT_STRING, BASE_NONE,
NULL, 0, "LANMAN Workstations", HFILL }},
{ &hf_max_storage,
{ "Max Storage", "lanman.max_storage", FT_UINT32, BASE_DEC,
NULL, 0, "LANMAN Max Storage", HFILL }},
{ &hf_units_per_week,
{ "Units Per Week", "lanman.units_per_week", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Units Per Week", HFILL }},
{ &hf_logon_hours,
{ "Logon Hours", "lanman.logon_hours", FT_BYTES, BASE_NONE,
NULL, 0, "LANMAN Logon Hours", HFILL }},
/* XXX - we should have a value_string table for this */
{ &hf_code_page,
{ "Code Page", "lanman.code_page", FT_UINT16, BASE_DEC,
NULL, 0, "LANMAN Code Page", HFILL }},
{ &hf_new_password,
{ "New Password", "lanman.new_password", FT_BYTES, BASE_NONE,
NULL, 0, "LANMAN New Password (encrypted)", HFILL }},
{ &hf_old_password,
{ "Old Password", "lanman.old_password", FT_BYTES, BASE_NONE,
NULL, 0, "LANMAN Old Password (encrypted)", HFILL }},
{ &hf_reserved,
{ "Reserved", "lanman.reserved", FT_UINT32, BASE_HEX,
NULL, 0, "LANMAN Reserved", HFILL }},
{ &hf_aux_data_struct_count,
{ "Auxiliary data structure count", "lanman.aux_data_struct_count", FT_UINT16, BASE_DEC_HEX,
NULL, 0, NULL, HFILL }},
};
static gint *ett[] = {
&ett_lanman,
&ett_lanman_unknown_entries,
&ett_lanman_unknown_entry,
&ett_lanman_servers,
&ett_lanman_server,
&ett_lanman_groups,
&ett_lanman_shares,
&ett_lanman_share,
};
proto_smb_lanman = proto_register_protocol(
"Microsoft Windows Lanman Remote API Protocol", "LANMAN", "lanman");
proto_register_field_array(proto_smb_lanman, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
static heur_dissector_list_t smb_transact_heur_subdissector_list;
static reassembly_table dcerpc_reassembly_table;
gboolean
dissect_pipe_dcerpc(tvbuff_t *d_tvb, packet_info *pinfo, proto_tree *parent_tree,
proto_tree *tree, guint32 fid, void *data)
{
gboolean result=0;
gboolean save_fragmented;
guint reported_len;
fragment_head *fd_head;
fragment_item *fd_i;
tvbuff_t *new_tvb;
proto_item *frag_tree_item;
heur_dtbl_entry_t *hdtbl_entry;
dcerpc_set_transport_salt(fid, pinfo);
/*
* Offer desegmentation service to DCERPC if we have all the
* data. Otherwise, reassembly is (probably) impossible.
*/
pinfo->can_desegment=0;
pinfo->desegment_offset = 0;
pinfo->desegment_len = 0;
reported_len = tvb_reported_length(d_tvb);
if(smb_dcerpc_reassembly && tvb_captured_length(d_tvb) >= reported_len){
pinfo->can_desegment=2;
}
save_fragmented = pinfo->fragmented;
/* if we are not offering desegmentation, just try the heuristics
and bail out
*/
if(!pinfo->can_desegment){
result = dissector_try_heuristic(smb_transact_heur_subdissector_list, d_tvb, pinfo, parent_tree, &hdtbl_entry, data);
goto clean_up_and_exit;
}
/* below this line, we know we are doing reassembly */
/* this is a new packet, see if we are already reassembling this
pdu and if not, check if the dissector wants us
to reassemble it
*/
if(!pinfo->fd->visited){
/*
* This is the first pass.
*
* Check if we are already reassembling this PDU or not;
* we check for an in-progress reassembly for this FID
* in this direction, by searching for its reassembly
* structure.
*/
fd_head=fragment_get(&dcerpc_reassembly_table, pinfo, fid, NULL);
if(!fd_head){
/* No reassembly, so this is a new pdu. check if the
dissector wants us to reassemble it or if we
already got the full pdu in this tvb.
*/
/*
* Try the heuristic dissectors and see if we
* find someone that recognizes this payload.
*/
result = dissector_try_heuristic(smb_transact_heur_subdissector_list, d_tvb, pinfo, parent_tree, &hdtbl_entry, data);
/* no this didn't look like something we know */
if(!result){
goto clean_up_and_exit;
}
/* did the subdissector want us to reassemble any
more data ?
*/
if(pinfo->desegment_len){
fragment_add_check(&dcerpc_reassembly_table,
d_tvb, 0, pinfo, fid, NULL,
0, reported_len, TRUE);
fragment_set_tot_len(&dcerpc_reassembly_table,
pinfo, fid, NULL,
pinfo->desegment_len+reported_len);
}
goto clean_up_and_exit;
}
/* OK, we're already doing a reassembly for this FID.
skip to last segment in the existing reassembly structure
and add this fragment there
XXX we might add code here to use any offset values
we might pick up from the Read/Write calls instead of
assuming we always get them in the correct order
*/
for (fd_i = fd_head->next; fd_i->next; fd_i = fd_i->next) {}
fd_head=fragment_add_check(&dcerpc_reassembly_table,
d_tvb, 0, pinfo, fid, NULL,
fd_i->offset+fd_i->len,
reported_len, TRUE);
/* if we completed reassembly */
if(fd_head){
new_tvb = tvb_new_chain(d_tvb, fd_head->tvb_data);
add_new_data_source(pinfo, new_tvb,
"DCERPC over SMB");
pinfo->fragmented=FALSE;
d_tvb=new_tvb;
/* list what segments we have */
show_fragment_tree(fd_head, &smb_pipe_frag_items,
tree, pinfo, d_tvb, &frag_tree_item);
/* dissect the full PDU */
result = dissector_try_heuristic(smb_transact_heur_subdissector_list, d_tvb, pinfo, parent_tree, &hdtbl_entry, data);
}
goto clean_up_and_exit;
}
/*
* This is not the first pass; see if it's in the table of
* reassembled packets.
*
* XXX - we know that several of the arguments aren't going to
* be used, so we pass bogus variables. Can we clean this
* up so that we don't have to distinguish between the first
* pass and subsequent passes?
*/
fd_head=fragment_add_check(&dcerpc_reassembly_table,
d_tvb, 0, pinfo, fid, NULL, 0, 0, TRUE);
if(!fd_head){
/* we didn't find it, try any of the heuristic dissectors
and bail out
*/
result = dissector_try_heuristic(smb_transact_heur_subdissector_list, d_tvb, pinfo, parent_tree, &hdtbl_entry, data);
goto clean_up_and_exit;
}
if(!(fd_head->flags&FD_DEFRAGMENTED)){
/* we don't have a fully reassembled frame */
result = dissector_try_heuristic(smb_transact_heur_subdissector_list, d_tvb, pinfo, parent_tree, &hdtbl_entry, data);
goto clean_up_and_exit;
}
/* it is reassembled but it was reassembled in a different frame */
if(pinfo->num!=fd_head->reassembled_in){
proto_tree_add_uint(parent_tree, hf_smb_pipe_reassembled_in, d_tvb, 0, 0, fd_head->reassembled_in);
goto clean_up_and_exit;
}
/* display the reassembled pdu */
new_tvb = tvb_new_chain(d_tvb, fd_head->tvb_data);
add_new_data_source(pinfo, new_tvb,
"DCERPC over SMB");
pinfo->fragmented=FALSE;
d_tvb=new_tvb;
/* list what segments we have */
show_fragment_tree(fd_head, &smb_pipe_frag_items,
tree, pinfo, d_tvb, &frag_tree_item);
/* dissect the full PDU */
result = dissector_try_heuristic(smb_transact_heur_subdissector_list, d_tvb, pinfo, parent_tree, &hdtbl_entry, data);
clean_up_and_exit:
/* clear out the variables */
pinfo->can_desegment=0;
pinfo->desegment_offset = 0;
pinfo->desegment_len = 0;
if (!result)
call_data_dissector(d_tvb, pinfo, parent_tree);
pinfo->fragmented = save_fragmented;
return TRUE;
}
#define CALL_NAMED_PIPE 0x54
#define WAIT_NAMED_PIPE 0x53
#define PEEK_NAMED_PIPE 0x23
#define Q_NM_P_HAND_STATE 0x21
#define SET_NM_P_HAND_STATE 0x01
#define Q_NM_PIPE_INFO 0x22
#define TRANSACT_NM_PIPE 0x26
#define RAW_READ_NM_PIPE 0x11
#define RAW_WRITE_NM_PIPE 0x31
static const value_string functions[] = {
{CALL_NAMED_PIPE, "CallNamedPipe"},
{WAIT_NAMED_PIPE, "WaitNamedPipe"},
{PEEK_NAMED_PIPE, "PeekNamedPipe"},
{Q_NM_P_HAND_STATE, "QNmPHandState"},
{SET_NM_P_HAND_STATE, "SetNmPHandState"},
{Q_NM_PIPE_INFO, "QNmPipeInfo"},
{TRANSACT_NM_PIPE, "TransactNmPipe"},
{RAW_READ_NM_PIPE, "RawReadNmPipe"},
{RAW_WRITE_NM_PIPE, "RawWriteNmPipe"},
{0, NULL}
};
static const value_string pipe_status[] = {
{1, "Disconnected by server"},
{2, "Listening"},
{3, "Connection to server is OK"},
{4, "Server end of pipe is closed"},
{0, NULL}
};
#define PIPE_LANMAN 1
#define PIPE_DCERPC 2
/* decode the SMB pipe protocol
for requests
pipe is the name of the pipe, e.g. LANMAN
smb_info->trans_subcmd is set to the symbolic constant matching the mailslot name
for responses
pipe is NULL
smb_info->trans_subcmd gives us which pipe this response is for
*/
gboolean
dissect_pipe_smb(tvbuff_t *sp_tvb, tvbuff_t *s_tvb, tvbuff_t *pd_tvb,
tvbuff_t *p_tvb, tvbuff_t *d_tvb, const char *pipe,
packet_info *pinfo, proto_tree *tree, smb_info_t *smb_info)
{
smb_transact_info_t *tri;
guint sp_len;
proto_item *pipe_item = NULL;
proto_tree *pipe_tree = NULL;
int offset;
int trans_subcmd=0;
int function;
int fid = -1;
guint16 info_level;
if (!proto_is_protocol_enabled(find_protocol_by_id(proto_smb_pipe)))
return FALSE;
pinfo->current_proto = "SMB Pipe";
/*
* Set the columns.
*/
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMB Pipe");
col_set_str(pinfo->cinfo, COL_INFO,
smb_info->request ? "Request" : "Response");
if (smb_info->sip != NULL && smb_info->sip->extra_info_type == SMB_EI_TRI)
tri = (smb_transact_info_t *)smb_info->sip->extra_info;
else
tri = NULL;
/*
* Set up a subtree for the pipe protocol. (It might not contain
* anything.)
*/
if (sp_tvb != NULL)
sp_len = tvb_captured_length(sp_tvb);
else
sp_len = 0;
if (tree) {
pipe_item = proto_tree_add_item(tree, proto_smb_pipe,
sp_tvb, 0, sp_len, ENC_NA);
pipe_tree = proto_item_add_subtree(pipe_item, ett_smb_pipe);
}
offset = 0;
/*
* Do we have any setup words at all?
*/
if (s_tvb != NULL && tvb_reported_length(s_tvb) != 0) {
/*
* Yes. The first of them is the function.
*/
function = tvb_get_letohs(s_tvb, offset);
proto_tree_add_uint(pipe_tree, hf_smb_pipe_function, s_tvb,
offset, 2, function);
offset += 2;
col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
val_to_str(function, functions, "Unknown function (0x%04x)"),
smb_info->request ? "Request" : "Response");
if (tri != NULL)
tri->function = function;
/*
* The second of them depends on the function.
*/
switch (function) {
case CALL_NAMED_PIPE:
case WAIT_NAMED_PIPE:
/*
* It's a priority.
*/
proto_tree_add_item(pipe_tree, hf_smb_pipe_priority, s_tvb,
offset, 2, ENC_LITTLE_ENDIAN);
break;
case PEEK_NAMED_PIPE:
case Q_NM_P_HAND_STATE:
case SET_NM_P_HAND_STATE:
case Q_NM_PIPE_INFO:
case TRANSACT_NM_PIPE:
case RAW_READ_NM_PIPE:
case RAW_WRITE_NM_PIPE:
/*
* It's a FID.
*/
fid = tvb_get_letohs(s_tvb, 2);
dissect_smb_fid(s_tvb, pinfo, pipe_tree, offset, 2, (guint16) fid, FALSE, FALSE, FALSE, smb_info);
if (tri != NULL)
tri->fid = fid;
break;
default:
/*
* It's something unknown.
* XXX - put it into the tree?
*/
break;
}
} else {
/*
* This is either a response or a pipe transaction with
* no setup information.
*
* In the former case, we can get that information from
* the matching request, if we saw it.
*
* In the latter case, there is no function or FID.
*/
if (tri != NULL && tri->function != -1) {
function = tri->function;
proto_tree_add_uint(pipe_tree, hf_smb_pipe_function, NULL,
0, 0, function);
col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
val_to_str(function, functions, "Unknown function (0x%04x)"),
smb_info->request ? "Request" : "Response");
fid = tri->fid;
if (fid != -1)
dissect_smb_fid(d_tvb, pinfo, pipe_tree, 0, 0, (guint16) fid, FALSE, FALSE, TRUE, smb_info);
} else {
function = -1;
fid = -1;
}
}
/*
* XXX - put the byte count and the pipe name into the tree as well;
* that requires us to fetch a possibly-Unicode string.
*/
if(smb_info->request){
if(strncmp(pipe,"LANMAN",6) == 0){
trans_subcmd=PIPE_LANMAN;
} else {
/* assume it is DCERPC */
trans_subcmd=PIPE_DCERPC;
}
if (!pinfo->fd->visited) {
if (tri == NULL)
return FALSE;
tri->trans_subcmd = trans_subcmd;
}
} else {
if(tri == NULL)
return FALSE;
trans_subcmd = tri->trans_subcmd;
}
if (tri == NULL) {
/*
* We don't know what type of pipe transaction this
* was, so indicate that we didn't dissect it.
*/
return FALSE;
}
switch (function) {
case CALL_NAMED_PIPE:
case TRANSACT_NM_PIPE:
switch(trans_subcmd){
case PIPE_LANMAN:
return dissect_pipe_lanman(pd_tvb, p_tvb, d_tvb, pinfo, tree, smb_info);
case PIPE_DCERPC:
/*
* Only dissect this if we know the FID.
*/
if (fid != -1) {
if (d_tvb == NULL)
return FALSE;
return dissect_pipe_dcerpc(d_tvb, pinfo, tree, pipe_tree, fid, smb_info);
}
break;
}
break;
case -1:
/*
* We don't know the function; we dissect only LANMAN
* pipe messages, not RPC pipe messages, in that case.
*/
switch(trans_subcmd){
case PIPE_LANMAN:
return dissect_pipe_lanman(pd_tvb, p_tvb, d_tvb, pinfo, tree, smb_info);
}
break;
case WAIT_NAMED_PIPE:
break;
case PEEK_NAMED_PIPE:
/*
* Request contains no parameters or data.
*/
if (!smb_info->request) {
if (p_tvb == NULL)
return FALSE;
offset = 0;
proto_tree_add_item(pipe_tree, hf_smb_pipe_peek_available,
p_tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(pipe_tree, hf_smb_pipe_peek_remaining,
p_tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(pipe_tree, hf_smb_pipe_peek_status,
p_tvb, offset, 2, ENC_LITTLE_ENDIAN);
}
break;
case Q_NM_P_HAND_STATE:
/*
* Request contains no parameters or data.
*/
if (!smb_info->request) {
if (p_tvb == NULL)
return FALSE;
dissect_ipc_state(p_tvb, pipe_tree, 0, FALSE);
}
break;
case SET_NM_P_HAND_STATE:
/*
* Response contains no parameters or data.
*/
if (smb_info->request) {
if (p_tvb == NULL)
return FALSE;
dissect_ipc_state(p_tvb, pipe_tree, 0, TRUE);
}
break;
case Q_NM_PIPE_INFO:
offset = 0;
if (smb_info->request) {
if (p_tvb == NULL)
return FALSE;
/*
* Request contains an information level.
*/
info_level = tvb_get_letohs(p_tvb, offset);
proto_tree_add_uint(pipe_tree, hf_smb_pipe_getinfo_info_level,
p_tvb, offset, 2, info_level);
if (!pinfo->fd->visited)
tri->info_level = info_level;
} else {
guint8 pipe_namelen;
if (d_tvb == NULL)
return FALSE;
switch (tri->info_level) {
case 1:
proto_tree_add_item(pipe_tree,
hf_smb_pipe_getinfo_output_buffer_size,
d_tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(pipe_tree,
hf_smb_pipe_getinfo_input_buffer_size,
d_tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(pipe_tree,
hf_smb_pipe_getinfo_maximum_instances,
d_tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(pipe_tree,
hf_smb_pipe_getinfo_current_instances,
d_tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
pipe_namelen = tvb_get_guint8(d_tvb, offset);
proto_tree_add_uint(pipe_tree,
hf_smb_pipe_getinfo_pipe_name_length,
d_tvb, offset, 1, pipe_namelen);
offset += 1;
/* XXX - can this be Unicode? */
proto_tree_add_item(pipe_tree,
hf_smb_pipe_getinfo_pipe_name,
d_tvb, offset, pipe_namelen, ENC_ASCII);
break;
}
}
break;
case RAW_READ_NM_PIPE:
/*
* Request contains no parameters or data.
*/
if (!smb_info->request) {
if (d_tvb == NULL)
return FALSE;
dissect_file_data(d_tvb, pipe_tree, 0,
(guint16) tvb_reported_length(d_tvb),
-1,
(guint16) tvb_reported_length(d_tvb));
}
break;
case RAW_WRITE_NM_PIPE:
offset = 0;
if (smb_info->request) {
if (d_tvb == NULL)
return FALSE;
dissect_file_data(d_tvb, pipe_tree,
offset, (guint16) tvb_reported_length(d_tvb),
-1,
(guint16) tvb_reported_length(d_tvb));
} else {
if (p_tvb == NULL)
return FALSE;
proto_tree_add_item(pipe_tree,
hf_smb_pipe_write_raw_bytes_written,
p_tvb, offset, 2, ENC_LITTLE_ENDIAN);
}
break;
}
return TRUE;
}
void
proto_register_smb_pipe(void)
{
static hf_register_info hf[] = {
{ &hf_smb_pipe_function,
{ "Function", "smb_pipe.function", FT_UINT16, BASE_HEX,
VALS(functions), 0, "SMB Pipe Function Code", HFILL }},
{ &hf_smb_pipe_priority,
{ "Priority", "smb_pipe.priority", FT_UINT16, BASE_DEC,
NULL, 0, "SMB Pipe Priority", HFILL }},
{ &hf_smb_pipe_peek_available,
{ "Available Bytes", "smb_pipe.peek.available_bytes", FT_UINT16, BASE_DEC,
NULL, 0, "Total number of bytes available to be read from the pipe", HFILL }},
{ &hf_smb_pipe_peek_remaining,
{ "Bytes Remaining", "smb_pipe.peek.remaining_bytes", FT_UINT16, BASE_DEC,
NULL, 0, "Total number of bytes remaining in the message at the head of the pipe", HFILL }},
{ &hf_smb_pipe_peek_status,
{ "Pipe Status", "smb_pipe.peek.status", FT_UINT16, BASE_DEC,
VALS(pipe_status), 0, NULL, HFILL }},
{ &hf_smb_pipe_getinfo_info_level,
{ "Information Level", "smb_pipe.getinfo.info_level", FT_UINT16, BASE_DEC,
NULL, 0, "Information level of information to return", HFILL }},
{ &hf_smb_pipe_getinfo_output_buffer_size,
{ "Output Buffer Size", "smb_pipe.getinfo.output_buffer_size", FT_UINT16, BASE_DEC,
NULL, 0, "Actual size of buffer for outgoing (server) I/O", HFILL }},
{ &hf_smb_pipe_getinfo_input_buffer_size,
{ "Input Buffer Size", "smb_pipe.getinfo.input_buffer_size", FT_UINT16, BASE_DEC,
NULL, 0, "Actual size of buffer for incoming (client) I/O", HFILL }},
{ &hf_smb_pipe_getinfo_maximum_instances,
{ "Maximum Instances", "smb_pipe.getinfo.maximum_instances", FT_UINT8, BASE_DEC,
NULL, 0, "Maximum allowed number of instances", HFILL }},
{ &hf_smb_pipe_getinfo_current_instances,
{ "Current Instances", "smb_pipe.getinfo.current_instances", FT_UINT8, BASE_DEC,
NULL, 0, "Current number of instances", HFILL }},
{ &hf_smb_pipe_getinfo_pipe_name_length,
{ "Pipe Name Length", "smb_pipe.getinfo.pipe_name_length", FT_UINT8, BASE_DEC,
NULL, 0, "Length of pipe name", HFILL }},
{ &hf_smb_pipe_getinfo_pipe_name,
{ "Pipe Name", "smb_pipe.getinfo.pipe_name", FT_STRING, BASE_NONE,
NULL, 0, "Name of pipe", HFILL }},
{ &hf_smb_pipe_write_raw_bytes_written,
{ "Bytes Written", "smb_pipe.write_raw.bytes_written", FT_UINT16, BASE_DEC,
NULL, 0, "Number of bytes written to the pipe", HFILL }},
{ &hf_smb_pipe_fragment_overlap,
{ "Fragment overlap", "smb_pipe.fragment.overlap", FT_BOOLEAN, BASE_NONE,
NULL, 0x0, "Fragment overlaps with other fragments", HFILL }},
{ &hf_smb_pipe_fragment_overlap_conflict,
{ "Conflicting data in fragment overlap", "smb_pipe.fragment.overlap.conflict", FT_BOOLEAN,
BASE_NONE, NULL, 0x0, "Overlapping fragments contained conflicting data", HFILL }},
{ &hf_smb_pipe_fragment_multiple_tails,
{ "Multiple tail fragments found", "smb_pipe.fragment.multipletails", FT_BOOLEAN,
BASE_NONE, NULL, 0x0, "Several tails were found when defragmenting the packet", HFILL }},
{ &hf_smb_pipe_fragment_too_long_fragment,
{ "Fragment too long", "smb_pipe.fragment.toolongfragment", FT_BOOLEAN,
BASE_NONE, NULL, 0x0, "Fragment contained data past end of packet", HFILL }},
{ &hf_smb_pipe_fragment_error,
{ "Defragmentation error", "smb_pipe.fragment.error", FT_FRAMENUM,
BASE_NONE, NULL, 0x0, "Defragmentation error due to illegal fragments", HFILL }},
{ &hf_smb_pipe_fragment_count,
{ "Fragment count", "smb_pipe.fragment.count", FT_UINT32,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_smb_pipe_fragment,
{ "Fragment", "smb_pipe.fragment", FT_FRAMENUM,
BASE_NONE, NULL, 0x0, "Pipe Fragment", HFILL }},
{ &hf_smb_pipe_fragments,
{ "Fragments", "smb_pipe.fragments", FT_NONE,
BASE_NONE, NULL, 0x0, "Pipe Fragments", HFILL }},
{ &hf_smb_pipe_reassembled_in,
{ "This PDU is reassembled in", "smb_pipe.reassembled_in", FT_FRAMENUM,
BASE_NONE, NULL, 0x0, "The DCE/RPC PDU is completely reassembled in this frame", HFILL }},
{ &hf_smb_pipe_reassembled_length,
{ "Reassembled SMB Pipe length", "smb_pipe.reassembled.length", FT_UINT32,
BASE_DEC, NULL, 0x0, "The total length of the reassembled payload", HFILL }},
/* Generated from convert_proto_tree_add_text.pl */
{ &hf_smb_pipe_word_param,
{ "Word Param", "smb_pipe.word_param", FT_UINT16,
BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_smb_pipe_doubleword_param,
{ "Doubleword Param", "smb_pipe.doubleword_param", FT_UINT32,
BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_smb_pipe_byte_param,
{ "Byte Param", "smb_pipe.byte_param", FT_UINT8,
BASE_DEC_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_smb_pipe_bytes_param,
{ "Bytes Param", "smb_pipe.bytes_param", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_smb_pipe_string_param,
{ "String Param", "smb_pipe.string_param", FT_STRING,
BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_smb_pipe_stringz_param,
{ "String Param", "smb_pipe.string_param", FT_STRINGZ,
BASE_NONE, NULL, 0x0, NULL, HFILL }},
};
static gint *ett[] = {
&ett_smb_pipe,
&ett_smb_pipe_fragment,
&ett_smb_pipe_fragments,
};
static ei_register_info ei[] = {
{ &ei_smb_pipe_bogus_netwkstauserlogon, { "smb_pipe.bogus_netwkstauserlogon_parameters", PI_PROTOCOL, PI_WARN, "Bogus NetWkstaUserLogon parameters", EXPFILL }},
{ &ei_smb_pipe_bad_type, { "smb_pipe.bad_type", PI_PROTOCOL, PI_ERROR, "Bad type field", EXPFILL }},
};
expert_module_t* expert_smb_pipe;
proto_smb_pipe = proto_register_protocol("SMB Pipe Protocol", "SMB Pipe", "smb_pipe");
proto_register_field_array(proto_smb_pipe, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_smb_pipe = expert_register_protocol(proto_smb_pipe);
expert_register_field_array(expert_smb_pipe, ei, array_length(ei));
smb_transact_heur_subdissector_list = register_heur_dissector_list("smb_transact", proto_smb_pipe);
/*
* XXX - addresses_ports_reassembly_table_functions?
* Probably correct for SMB-over-NBT and SMB-over-TCP,
* as stuff from two different connections should
* probably not be combined, but what about other
* transports for SMB, e.g. NBF or Netware?
*/
reassembly_table_register(&dcerpc_reassembly_table,
&addresses_reassembly_table_functions);
}
/*
* Editor modelines - https://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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-smb-pipe.h
|
/* packet-smb-pipe.h
* Declarations of routines for SMB named pipe packet dissection
* Copyright 1999, Richard Sharpe <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef _PACKET_SMB_PIPE_H_
#define _PACKET_SMB_PIPE_H_
extern gboolean
dissect_pipe_smb(tvbuff_t *sp_tvb, tvbuff_t *s_tvb, tvbuff_t *pd_tvb,
tvbuff_t *p_tvb, tvbuff_t *d_tvb, const char *pipe,
packet_info *pinfo, proto_tree *tree, smb_info_t *smb_info);
gboolean
dissect_pipe_dcerpc(tvbuff_t *d_tvb, packet_info *pinfo, proto_tree *parent_tree,
proto_tree *tree, guint32 fid, void *data);
#endif
|
C
|
wireshark/epan/dissectors/packet-smb-sidsnooping.c
|
/* packet-smb-sidsnooping.c
* Routines for snooping SID to name mappings
* Copyright 2003, Ronnie Sahlberg
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/epan_dissect.h>
#include <epan/tap.h>
#include <wsutil/report_message.h>
#include "packet-dcerpc.h"
#include "packet-dcerpc-nt.h"
#include "packet-smb.h"
#include "packet-smb-sidsnooping.h"
void proto_register_smb_sidsnooping(void);
#if 0
static int hf_lsa = -1;
static int hf_lsa_opnum = -1;
#endif
static int hf_lsa_info_level = -1;
static int hf_lsa_domain = -1;
static int hf_nt_domain_sid = -1;
static int hf_samr_hnd = -1;
static int hf_samr_rid = -1;
static int hf_samr_acct_name = -1;
static int hf_samr_level = -1;
GHashTable *sid_name_table = NULL;
static GHashTable *ctx_handle_table = NULL;
static gboolean lsa_policy_information_tap_installed = FALSE;
static gboolean samr_query_dispinfo_tap_installed = FALSE;
const char *
find_sid_name(const char *sid)
{
return (const char *)g_hash_table_lookup(sid_name_table, sid);
}
static void
add_sid_name_mapping(const char *sid, const char *name)
{
if (find_sid_name(sid)) {
return;
}
g_hash_table_insert(sid_name_table, g_strdup(sid), g_strdup(name));
}
/*
* QueryDispInfo :
* level 1 : user displayinfo 1
*/
static tap_packet_status
samr_query_dispinfo(void *dummy _U_, packet_info *pinfo, epan_dissect_t *edt, const void *pri, tap_flags_t flags _U_)
{
const dcerpc_info *ri=(const dcerpc_info *)pri;
void *old_ctx=NULL;
char *pol_name;
char *sid;
int sid_len;
int num_rids;
int num_names;
GPtrArray *gp;
GPtrArray *gp_rids;
GPtrArray *gp_names;
field_info *fi;
field_info *fi_rid;
field_info *fi_name;
char sid_name_str[256];
int info_level;
gp=proto_get_finfo_ptr_array(edt->tree, hf_samr_level);
if(!gp || gp->len!=1){
return TAP_PACKET_DONT_REDRAW;
}
fi=(field_info *)gp->pdata[0];
info_level = fvalue_get_sinteger(fi->value);
if(info_level!=1){
return TAP_PACKET_DONT_REDRAW;
}
if(!ri){
return TAP_PACKET_DONT_REDRAW;
}
if(!ri->call_data){
return TAP_PACKET_DONT_REDRAW;
}
if(ri->ptype == PDU_REQ){
gp=proto_get_finfo_ptr_array(edt->tree, hf_samr_hnd);
if(!gp || gp->len!=1){
return TAP_PACKET_DONT_REDRAW;
}
fi=(field_info *)gp->pdata[0];
old_ctx=g_hash_table_lookup(ctx_handle_table, GINT_TO_POINTER(pinfo->num));
if(old_ctx){
g_hash_table_remove(ctx_handle_table, GINT_TO_POINTER(pinfo->num));
}
if(!old_ctx){
old_ctx=wmem_memdup(wmem_file_scope(), fvalue_get_bytes_data(fi->value), 20);
}
g_hash_table_insert(ctx_handle_table, GINT_TO_POINTER(pinfo->num), old_ctx);
return TAP_PACKET_DONT_REDRAW;
}
if(!ri->call_data->req_frame){
return TAP_PACKET_DONT_REDRAW;
}
old_ctx=g_hash_table_lookup(ctx_handle_table, GINT_TO_POINTER(ri->call_data->req_frame));
if(!old_ctx){
return TAP_PACKET_DONT_REDRAW;
}
if (!dcerpc_fetch_polhnd_data((e_ctx_hnd *)old_ctx, &pol_name, NULL, NULL, NULL, ri->call_data->req_frame)) {
return TAP_PACKET_DONT_REDRAW;
}
if (!pol_name)
return TAP_PACKET_DONT_REDRAW;
sid=strstr(pol_name,"S-1-5");
if(!sid){
return TAP_PACKET_DONT_REDRAW;
}
for(sid_len=4;1;sid_len++){
if((sid[sid_len]>='0') && (sid[sid_len]<='9')){
continue;
}
if(sid[sid_len]=='-'){
continue;
}
break;
}
gp_rids=proto_get_finfo_ptr_array(edt->tree, hf_samr_rid);
if(!gp_rids || gp_rids->len<1){
return TAP_PACKET_DONT_REDRAW;
}
num_rids=gp_rids->len;
gp_names=proto_get_finfo_ptr_array(edt->tree, hf_samr_acct_name);
if(!gp_names || gp_names->len<1){
return TAP_PACKET_DONT_REDRAW;
}
num_names=gp_names->len;
if(num_rids>num_names){
num_rids=num_names;
}
for(;num_rids;num_rids--){
int len=sid_len;
if (len > 247)
len = 247;
fi_rid=(field_info *)gp_rids->pdata[num_rids-1];
fi_name=(field_info *)gp_names->pdata[num_rids-1];
(void) g_strlcpy(sid_name_str, sid, 256);
sid_name_str[len++]='-';
snprintf(sid_name_str+len, 256-len, "%d", fvalue_get_sinteger(fi_rid->value));
add_sid_name_mapping(sid_name_str, fvalue_get_string(fi_name->value));
}
return TAP_PACKET_REDRAW;
}
/*
* PolicyInformation :
* level 3 : PRIMARY_DOMAIN_INFO lsa.domain_sid -> lsa.domain
* level 5 : ACCOUNT_DOMAIN_INFO lsa.domain_sid -> lsa.domain
* level 12 : DNS_DOMAIN_INFO lsa.domain_sid -> lsa.domain
*/
static tap_packet_status
lsa_policy_information(void *dummy _U_, packet_info *pinfo _U_, epan_dissect_t *edt, const void *pri _U_, tap_flags_t flags _U_)
{
GPtrArray *gp;
field_info *fi;
const char *domain;
const char *sid;
int info_level;
gp=proto_get_finfo_ptr_array(edt->tree, hf_lsa_info_level);
if(!gp || gp->len!=1){
return TAP_PACKET_DONT_REDRAW;
}
fi=(field_info *)gp->pdata[0];
info_level = fvalue_get_sinteger(fi->value);
switch(info_level){
case 3:
case 5:
case 12:
gp=proto_get_finfo_ptr_array(edt->tree, hf_lsa_domain);
if(!gp || gp->len!=1){
return TAP_PACKET_DONT_REDRAW;
}
fi=(field_info *)gp->pdata[0];
domain=fvalue_get_string(fi->value);
gp=proto_get_finfo_ptr_array(edt->tree, hf_nt_domain_sid);
if(!gp || gp->len!=1){
return TAP_PACKET_DONT_REDRAW;
}
fi=(field_info *)gp->pdata[0];
sid=fvalue_get_string(fi->value);
add_sid_name_mapping(sid, domain);
break;
}
return TAP_PACKET_DONT_REDRAW;
}
static gint
ctx_handle_equal(gconstpointer k1, gconstpointer k2)
{
int sn1 = GPOINTER_TO_INT(k1);
int sn2 = GPOINTER_TO_INT(k2);
return sn1==sn2;
}
static guint
ctx_handle_hash(gconstpointer k)
{
int sn = GPOINTER_TO_INT(k);
return sn;
}
static void
sid_snooping_init(void)
{
GString *error_string;
if(lsa_policy_information_tap_installed){
remove_tap_listener(&lsa_policy_information_tap_installed);
lsa_policy_information_tap_installed=FALSE;
}
if(samr_query_dispinfo_tap_installed){
remove_tap_listener(&samr_query_dispinfo_tap_installed);
samr_query_dispinfo_tap_installed=FALSE;
}
sid_name_table = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, g_free);
ctx_handle_table = g_hash_table_new(ctx_handle_hash, ctx_handle_equal);
/* TODO this code needs to be rewritten from scratch
disabling it now so that it won't cause wireshark to abort due to
unknown hf fields
*/
sid_name_snooping=FALSE;
if(!sid_name_snooping){
return;
}
#if 0
hf_lsa = proto_get_id_by_filter_name("lsa");
hf_lsa_opnum = proto_registrar_get_id_byname("lsa.opnum");
#endif
hf_nt_domain_sid = proto_registrar_get_id_byname("nt.domain_sid");
hf_lsa_domain = proto_registrar_get_id_byname("lsa.domain");
hf_lsa_info_level = proto_registrar_get_id_byname("lsa.info.level");
hf_samr_hnd = proto_registrar_get_id_byname("samr.handle");
hf_samr_rid = proto_registrar_get_id_byname("samr.rid");
hf_samr_acct_name = proto_registrar_get_id_byname("samr.acct_name");
hf_samr_level = proto_registrar_get_id_byname("samr.level");
error_string=register_tap_listener("dcerpc",
&lsa_policy_information_tap_installed,
"lsa.policy_information and ( lsa.info.level or lsa.domain or nt.domain_sid )",
TL_REQUIRES_PROTO_TREE, NULL, lsa_policy_information, NULL, NULL);
if(error_string){
/* error, we failed to attach to the tap. clean up */
report_failure( "Couldn't register proto_reg_handoff_smb_sidsnooping()/lsa_policy_information tap: %s\n",
error_string->str);
g_string_free(error_string, TRUE);
return;
}
lsa_policy_information_tap_installed=TRUE;
error_string=register_tap_listener("dcerpc",
&samr_query_dispinfo_tap_installed,
"samr and samr.opnum==40 and ( samr.handle or samr.rid or samr.acct_name or samr.level )",
TL_REQUIRES_PROTO_TREE, NULL, samr_query_dispinfo, NULL, NULL);
if(error_string){
/* error, we failed to attach to the tap. clean up */
report_failure( "Couldn't register proto_reg_handoff_smb_sidsnooping()/samr_query_dispinfo tap: %s\n",
error_string->str);
g_string_free(error_string, TRUE);
return;
}
samr_query_dispinfo_tap_installed=TRUE;
}
static void
sid_snooping_cleanup(void)
{
g_hash_table_destroy(sid_name_table);
g_hash_table_destroy(ctx_handle_table);
}
void
proto_register_smb_sidsnooping(void)
{
register_init_routine(sid_snooping_init);
register_cleanup_routine(sid_snooping_cleanup);
}
/*
* Editor modelines - https://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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-smb-sidsnooping.h
|
/* packet-smb-sidsnooping.h
* Routines for snooping SID to name mappings
* Copyright 2003, Ronnie Sahlberg
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef _PACKET_SMB_SID_SNOOPING_H_
#define _PACKET_SMB_SID_SNOOPING_H_
#include "ws_symbol_export.h"
/* With MSVC and a libwireshark.dll, we need a
* special declaration for sid_name_table.
*/
WS_DLL_PUBLIC GHashTable *sid_name_table;
WS_DLL_PUBLIC
const char *find_sid_name(const char *sid);
#endif
|
C
|
wireshark/epan/dissectors/packet-smb.c
|
/* packet-smb.c
* Routines for smb packet dissection
* Copyright 1999, Richard Sharpe <[email protected]>
* 2001 Rewrite by Ronnie Sahlberg and Guy Harris
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Copied from packet-pop.c
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/strutil.h>
#include <epan/prefs.h>
#include <epan/reassemble.h>
#include <epan/tap.h>
#include <epan/srt_table.h>
#include <epan/expert.h>
#include <epan/to_str.h>
#include <epan/export_object.h>
#include "packet-windows-common.h"
#include "packet-smb.h"
#include "packet-ipx.h"
#include "packet-idp.h"
#include "packet-smb-common.h"
#include "packet-smb-mailslot.h"
#include "packet-smb-pipe.h"
#include "packet-ntlmssp.h"
#include "packet-smb2.h"
void proto_register_smb(void);
void proto_reg_handoff_smb(void);
/*
* Various specifications and documents about SMB can be found in
*
* ftp://ftp.microsoft.com/developr/drg/CIFS/
*
* and a CIFS specification from the Storage Networking Industry Association
* can be found on a link from the page at
*
* http://www.snia.org/tech_activities/CIFS
*
* (it supercedes the document at
*
* ftp://ftp.microsoft.com/developr/drg/CIFS/draft-leach-cifs-v1-spec-01.txt
*
* ).
*
* There are also some Open Group publications documenting CIFS available
* for download; catalog entries for them are at:
*
* http://www.opengroup.org/products/publications/catalog/c209.htm
*
* http://www.opengroup.org/products/publications/catalog/c195.htm
*
* The document "NT LAN Manager SMB File Sharing Protocol Extensions"
* can be found at
*
* http://www.samba.org/samba/ftp/specs/smb-nt01.doc
*
* (or, presumably a similar path under the Samba mirrors). As the
* ".doc" indicates, it's a Word document. Some of the specs from the
* Microsoft FTP site can be found in the
*
* http://www.samba.org/samba/ftp/specs/
*
* directory as well.
*
* Beware - these specs may have errors.
*
* Microsoft's public protocol specifications, including MS-CIFS and
* other SMB-related specifications, can be found at
*
* http://msdn.microsoft.com/en-us/library/cc216513.aspx
*
* See also
*
* https://wiki.samba.org/index.php/UNIX_Extensions
*/
/* DFS referral entry flags */
#define REFENT_FLAGS_NAME_LIST_REFERRAL 0x0002
#define REFENT_FLAGS_TARGET_SET_BOUNDARY 0x0004
static int proto_smb = -1;
static int hf_smb_cmd = -1;
static int hf_smb_andxcmd = -1;
static int hf_smb_mapped_in = -1;
static int hf_smb_unmapped_in = -1;
static int hf_smb_opened_in = -1;
static int hf_smb_closed_in = -1;
static int hf_smb_key = -1;
static int hf_smb_session_id = -1;
static int hf_smb_sequence_num = -1;
static int hf_smb_group_id = -1;
static int hf_smb_pid = -1;
static int hf_smb_tid = -1;
static int hf_smb_uid = -1;
static int hf_smb_mid = -1;
static int hf_smb_pid_high = -1;
static int hf_smb_sig = -1;
static int hf_smb_response_to = -1;
static int hf_smb_time = -1;
static int hf_smb_response_in = -1;
static int hf_smb_continuation_to = -1;
static int hf_smb_nt_status = -1;
static int hf_smb_error_class = -1;
static int hf_smb_error_code = -1;
static int hf_smb_reserved = -1;
static int hf_smb_create_flags = -1;
static int hf_smb_create_options = -1;
static int hf_smb_share_access = -1;
static int hf_smb_access_mask = -1;
static int hf_smb_flags = -1;
static int hf_smb_flags_lock = -1;
static int hf_smb_flags_receive_buffer = -1;
static int hf_smb_flags_caseless = -1;
static int hf_smb_flags_canon = -1;
static int hf_smb_flags_oplock = -1;
static int hf_smb_flags_notify = -1;
static int hf_smb_flags_response = -1;
static int hf_smb_flags2 = -1;
static int hf_smb_flags2_long_names_allowed = -1;
static int hf_smb_flags2_ea = -1;
static int hf_smb_flags2_sec_sig = -1;
static int hf_smb_flags2_compressed = -1;
static int hf_smb_flags2_sec_sig_required = -1;
static int hf_smb_flags2_long_names_used = -1;
static int hf_smb_flags2_reparse_path = -1;
static int hf_smb_flags2_esn = -1;
static int hf_smb_flags2_dfs = -1;
static int hf_smb_flags2_roe = -1;
static int hf_smb_flags2_nt_error = -1;
static int hf_smb_flags2_string = -1;
static int hf_smb_word_count = -1;
static int hf_smb_byte_count = -1;
static int hf_smb_buffer_format = -1;
static int hf_smb_dialect = -1;
static int hf_smb_dialect_name = -1;
static int hf_smb_dialect_index = -1;
static int hf_smb_max_trans_buf_size = -1;
static int hf_smb_max_mpx_count = -1;
static int hf_smb_max_vcs_num = -1;
static int hf_smb_session_key = -1;
static int hf_smb_server_timezone = -1;
static int hf_smb_challenge_length = -1;
static int hf_smb_challenge = -1;
static int hf_smb_primary_domain = -1;
static int hf_smb_server = -1;
static int hf_smb_max_raw_buf_size = -1;
static int hf_smb_server_guid = -1;
static int hf_smb_volume_guid = -1;
static int hf_smb_security_blob_len = -1;
static int hf_smb_security_blob = -1;
static int hf_smb_sm16 = -1;
static int hf_smb_sm_mode16 = -1;
static int hf_smb_sm_password16 = -1;
static int hf_smb_sm = -1;
static int hf_smb_sm_mode = -1;
static int hf_smb_sm_password = -1;
static int hf_smb_sm_signatures = -1;
static int hf_smb_sm_sig_required = -1;
static int hf_smb_rm = -1;
static int hf_smb_rm_read = -1;
static int hf_smb_rm_write = -1;
static int hf_smb_server_date_time = -1;
static int hf_smb_server_smb_date = -1;
static int hf_smb_server_smb_time = -1;
static int hf_smb_server_cap = -1;
static int hf_smb_server_cap_raw_mode = -1;
static int hf_smb_server_cap_mpx_mode = -1;
static int hf_smb_server_cap_unicode = -1;
static int hf_smb_server_cap_large_files = -1;
static int hf_smb_server_cap_nt_smbs = -1;
static int hf_smb_server_cap_rpc_remote_apis = -1;
static int hf_smb_server_cap_nt_status = -1;
static int hf_smb_server_cap_level_ii_oplocks = -1;
static int hf_smb_server_cap_lock_and_read = -1;
static int hf_smb_server_cap_nt_find = -1;
static int hf_smb_server_cap_dfs = -1;
static int hf_smb_server_cap_infolevel_passthru = -1;
static int hf_smb_server_cap_large_readx = -1;
static int hf_smb_server_cap_large_writex = -1;
static int hf_smb_server_cap_lwio = -1;
static int hf_smb_server_cap_unix = -1;
static int hf_smb_server_cap_compressed_data = -1;
static int hf_smb_server_cap_dynamic_reauth = -1;
static int hf_smb_server_cap_extended_security = -1;
static int hf_smb_system_time = -1;
static int hf_smb_unknown = -1;
static int hf_smb_dir_name = -1;
static int hf_smb_echo_count = -1;
static int hf_smb_echo_data = -1;
static int hf_smb_echo_seq_num = -1;
static int hf_smb_max_buf_size = -1;
static int hf_smb_password = -1;
static int hf_smb_password_len = -1;
static int hf_smb_ansi_password = -1;
static int hf_smb_ansi_password_len = -1;
static int hf_smb_unicode_password = -1;
static int hf_smb_unicode_password_len = -1;
static int hf_smb_path = -1;
static int hf_smb_service = -1;
static int hf_smb_move_flags = -1;
static int hf_smb_move_flags_file = -1;
static int hf_smb_move_flags_dir = -1;
static int hf_smb_move_flags_verify = -1;
static int hf_smb_files_moved = -1;
static int hf_smb_file_access_mask_read_data = -1;
static int hf_smb_file_access_mask_write_data = -1;
static int hf_smb_file_access_mask_append_data = -1;
static int hf_smb_file_access_mask_read_ea = -1;
static int hf_smb_file_access_mask_write_ea = -1;
static int hf_smb_file_access_mask_execute = -1;
static int hf_smb_file_access_mask_read_attribute = -1;
static int hf_smb_file_access_mask_write_attribute = -1;
static int hf_smb_dir_access_mask_list = -1;
static int hf_smb_dir_access_mask_add_file = -1;
static int hf_smb_dir_access_mask_add_subdir = -1;
static int hf_smb_dir_access_mask_read_ea = -1;
static int hf_smb_dir_access_mask_write_ea = -1;
static int hf_smb_dir_access_mask_traverse = -1;
static int hf_smb_dir_access_mask_delete_child = -1;
static int hf_smb_dir_access_mask_read_attribute = -1;
static int hf_smb_dir_access_mask_write_attribute = -1;
static int hf_smb_copy_flags = -1;
static int hf_smb_copy_flags_file = -1;
static int hf_smb_copy_flags_dir = -1;
static int hf_smb_copy_flags_dest_mode = -1;
static int hf_smb_copy_flags_source_mode = -1;
static int hf_smb_copy_flags_verify = -1;
static int hf_smb_copy_flags_tree_copy = -1;
static int hf_smb_copy_flags_ea_action = -1;
static int hf_smb_count = -1;
static int hf_smb_count_low = -1;
static int hf_smb_count_high = -1;
static int hf_smb_file_name = -1;
static int hf_smb_open_function = -1;
static int hf_smb_open_function_open = -1;
static int hf_smb_open_function_create = -1;
static int hf_smb_fid = -1;
static int hf_smb_file_attr_16bit = -1;
static int hf_smb_file_attr_8bit = -1;
static int hf_smb_file_attr_read_only_16bit = -1;
static int hf_smb_file_attr_read_only_8bit = -1;
static int hf_smb_file_attr_hidden_16bit = -1;
static int hf_smb_file_attr_hidden_8bit = -1;
static int hf_smb_file_attr_system_16bit = -1;
static int hf_smb_file_attr_system_8bit = -1;
static int hf_smb_file_attr_volume_16bit = -1;
static int hf_smb_file_attr_volume_8bit = -1;
static int hf_smb_file_attr_directory_16bit = -1;
static int hf_smb_file_attr_directory_8bit = -1;
static int hf_smb_file_attr_archive_16bit = -1;
static int hf_smb_file_attr_archive_8bit = -1;
#if 0
static int hf_smb_file_attr_device = -1;
static int hf_smb_file_attr_normal = -1;
static int hf_smb_file_attr_temporary = -1;
static int hf_smb_file_attr_sparse = -1;
static int hf_smb_file_attr_reparse = -1;
static int hf_smb_file_attr_compressed = -1;
static int hf_smb_file_attr_offline = -1;
static int hf_smb_file_attr_not_content_indexed = -1;
static int hf_smb_file_attr_encrypted = -1;
#endif
static int hf_smb_file_size = -1;
static int hf_smb_search_attribute = -1;
static int hf_smb_search_attribute_read_only = -1;
static int hf_smb_search_attribute_hidden = -1;
static int hf_smb_search_attribute_system = -1;
static int hf_smb_search_attribute_volume = -1;
static int hf_smb_search_attribute_directory = -1;
static int hf_smb_search_attribute_archive = -1;
static int hf_smb_access_mode = -1;
static int hf_smb_access_sharing = -1;
static int hf_smb_access_locality = -1;
static int hf_smb_access_caching = -1;
static int hf_smb_access_writetru = -1;
static int hf_smb_desired_access = -1;
static int hf_smb_granted_access = -1;
static int hf_smb_create_time = -1;
static int hf_smb_modify_time = -1;
static int hf_smb_backup_time = -1;
static int hf_smb_mac_alloc_block_count = -1;
static int hf_smb_mac_alloc_block_size = -1;
static int hf_smb_mac_free_block_count = -1;
static int hf_smb_mac_fndrinfo = -1;
static int hf_smb_mac_root_file_count = -1;
static int hf_smb_mac_root_dir_count = -1;
static int hf_smb_mac_file_count = -1;
static int hf_smb_mac_dir_count = -1;
static int hf_smb_mac_sup = -1;
static int hf_smb_mac_sup_access_ctrl = -1;
static int hf_smb_mac_sup_getset_comments = -1;
static int hf_smb_mac_sup_desktopdb_calls = -1;
static int hf_smb_mac_sup_unique_ids = -1;
static int hf_smb_mac_sup_streams = -1;
static int hf_smb_create_dos_date = -1;
static int hf_smb_create_dos_time = -1;
static int hf_smb_last_write_time = -1;
static int hf_smb_last_write_dos_date = -1;
static int hf_smb_last_write_dos_time = -1;
static int hf_smb_access_time = -1;
static int hf_smb_access_dos_date = -1;
static int hf_smb_access_dos_time = -1;
static int hf_smb_old_file_name = -1;
static int hf_smb_offset = -1;
static int hf_smb_remaining = -1;
static int hf_smb_padding = -1;
static int hf_smb_file_data = -1;
/* static int hf_smb_raw_ea_data = -1; */
static int hf_smb_total_data_len = -1;
static int hf_smb_data_len = -1;
static int hf_smb_data_len_low = -1;
static int hf_smb_data_len_high = -1;
static int hf_smb_seek_mode = -1;
static int hf_smb_data_size = -1;
static int hf_smb_alloc_size = -1;
static int hf_smb_alloc_size64 = -1;
static int hf_smb_max_count = -1;
static int hf_smb_max_count_low = -1;
static int hf_smb_max_count_high = -1;
static int hf_smb_min_count = -1;
static int hf_smb_timeout = -1;
static int hf_smb_high_offset = -1;
static int hf_smb_units = -1;
static int hf_smb_bpu = -1;
static int hf_smb_blocksize = -1;
static int hf_smb_freeunits = -1;
static int hf_smb_data_offset = -1;
static int hf_smb_dcm = -1;
static int hf_smb_request_mask = -1;
static int hf_smb_response_mask = -1;
static int hf_smb_search_id = -1;
static int hf_smb_write_mode = -1;
static int hf_smb_write_mode_write_through = -1;
static int hf_smb_write_mode_return_remaining = -1;
static int hf_smb_write_mode_raw = -1;
static int hf_smb_write_mode_message_start = -1;
static int hf_smb_write_mode_connectionless = -1;
static int hf_smb_resume_key_len = -1;
static int hf_smb_resume_find_id = -1;
static int hf_smb_resume_server_cookie = -1;
static int hf_smb_resume_client_cookie = -1;
static int hf_smb_andxoffset = -1;
static int hf_smb_lock_type = -1;
static int hf_smb_lock_type_large = -1;
static int hf_smb_lock_type_cancel = -1;
static int hf_smb_lock_type_change = -1;
static int hf_smb_lock_type_oplock = -1;
static int hf_smb_lock_type_shared = -1;
static int hf_smb_locking_ol = -1;
static int hf_smb_number_of_locks = -1;
static int hf_smb_number_of_unlocks = -1;
static int hf_smb_lock_long_offset = -1;
static int hf_smb_lock_long_length = -1;
static int hf_smb_file_type = -1;
static int hf_smb_ipc_state = -1;
static int hf_smb_ipc_state_nonblocking = -1;
static int hf_smb_ipc_state_endpoint = -1;
static int hf_smb_ipc_state_pipe_type = -1;
static int hf_smb_ipc_state_read_mode = -1;
static int hf_smb_ipc_state_icount = -1;
static int hf_smb_server_fid = -1;
static int hf_smb_open_flags = -1;
static int hf_smb_open_flags_add_info = -1;
static int hf_smb_open_flags_ex_oplock = -1;
static int hf_smb_open_flags_batch_oplock = -1;
static int hf_smb_open_flags_ealen = -1;
static int hf_smb_open_action = -1;
static int hf_smb_open_action_open = -1;
static int hf_smb_open_action_lock = -1;
static int hf_smb_vc_num = -1;
static int hf_smb_account = -1;
static int hf_smb_os = -1;
static int hf_smb_lanman = -1;
static int hf_smb_setup_action = -1;
static int hf_smb_setup_action_guest = -1;
static int hf_smb_fs = -1;
static int hf_smb_connect_flags = -1;
static int hf_smb_connect_flags_dtid = -1;
static int hf_smb_connect_flags_ext_sig = -1;
static int hf_smb_connect_flags_ext_resp = -1;
static int hf_smb_connect_support = -1;
static int hf_smb_connect_support_search = -1;
static int hf_smb_connect_support_in_dfs = -1;
static int hf_smb_connect_support_csc_mask_vals = -1;
static int hf_smb_connect_support_uniquefilename = -1;
static int hf_smb_connect_support_extended_signature = -1;
static int hf_smb_max_setup_count = -1;
static int hf_smb_total_param_count = -1;
static int hf_smb_total_data_count = -1;
static int hf_smb_max_param_count = -1;
static int hf_smb_max_data_count = -1;
static int hf_smb_param_disp16 = -1;
static int hf_smb_param_count16 = -1;
static int hf_smb_param_offset16 = -1;
static int hf_smb_param_disp32 = -1;
static int hf_smb_param_count32 = -1;
static int hf_smb_param_offset32 = -1;
static int hf_smb_data_disp16 = -1;
static int hf_smb_data_count16 = -1;
static int hf_smb_data_offset16 = -1;
static int hf_smb_data_disp32 = -1;
static int hf_smb_data_count32 = -1;
static int hf_smb_data_offset32 = -1;
static int hf_smb_setup_count = -1;
static int hf_smb_nt_trans_subcmd = -1;
static int hf_smb_nt_ioctl_isfsctl = -1;
static int hf_smb_nt_ioctl_flags_completion_filter = -1;
static int hf_smb_nt_ioctl_flags_root_handle = -1;
static int hf_smb_nt_notify_action = -1;
static int hf_smb_nt_notify_watch_tree = -1;
static int hf_smb_nt_notify_completion_filter = -1;
static int hf_smb_nt_notify_stream_write = -1;
static int hf_smb_nt_notify_stream_size = -1;
static int hf_smb_nt_notify_stream_name = -1;
static int hf_smb_nt_notify_security = -1;
static int hf_smb_nt_notify_ea = -1;
static int hf_smb_nt_notify_creation = -1;
static int hf_smb_nt_notify_last_access = -1;
static int hf_smb_nt_notify_last_write = -1;
static int hf_smb_nt_notify_size = -1;
static int hf_smb_nt_notify_attributes = -1;
static int hf_smb_nt_notify_dir_name = -1;
static int hf_smb_nt_notify_file_name = -1;
static int hf_smb_root_dir_fid = -1;
static int hf_smb_nt_create_disposition = -1;
static int hf_smb_sd_length = -1;
static int hf_smb_ea_list_length = -1;
static int hf_smb_ea_flags = -1;
static int hf_smb_ea_name_length = -1;
static int hf_smb_ea_data_length = -1;
static int hf_smb_ea_name = -1;
static int hf_smb_ea_data = -1;
static int hf_smb_file_name_len = -1;
static int hf_smb_nt_impersonation_level = -1;
static int hf_smb_nt_security_flags = -1;
static int hf_smb_nt_security_flags_context_tracking = -1;
static int hf_smb_nt_security_flags_effective_only = -1;
static int hf_smb_nt_access_mask_generic_read = -1;
static int hf_smb_nt_access_mask_generic_write = -1;
static int hf_smb_nt_access_mask_generic_execute = -1;
static int hf_smb_nt_access_mask_generic_all = -1;
static int hf_smb_nt_access_mask_maximum_allowed = -1;
static int hf_smb_nt_access_mask_system_security = -1;
static int hf_smb_nt_access_mask_synchronize = -1;
static int hf_smb_nt_access_mask_write_owner = -1;
static int hf_smb_nt_access_mask_write_dac = -1;
static int hf_smb_nt_access_mask_read_control = -1;
static int hf_smb_nt_access_mask_delete = -1;
static int hf_smb_nt_access_mask_write_attributes = -1;
static int hf_smb_nt_access_mask_read_attributes = -1;
static int hf_smb_nt_access_mask_delete_child = -1;
static int hf_smb_nt_access_mask_execute = -1;
static int hf_smb_nt_access_mask_write_ea = -1;
static int hf_smb_nt_access_mask_read_ea = -1;
static int hf_smb_nt_access_mask_append = -1;
static int hf_smb_nt_access_mask_write = -1;
static int hf_smb_nt_access_mask_read = -1;
static int hf_smb_nt_create_bits_oplock = -1;
static int hf_smb_nt_create_bits_boplock = -1;
static int hf_smb_nt_create_bits_dir = -1;
static int hf_smb_nt_create_bits_ext_resp = -1;
static int hf_smb_nt_create_options_directory_file = -1;
static int hf_smb_nt_create_options_write_through = -1;
static int hf_smb_nt_create_options_sequential_only = -1;
static int hf_smb_nt_create_options_no_intermediate_buffering = -1;
static int hf_smb_nt_create_options_sync_io_alert = -1;
static int hf_smb_nt_create_options_sync_io_nonalert = -1;
static int hf_smb_nt_create_options_non_directory_file = -1;
static int hf_smb_nt_create_options_create_tree_connection = -1;
static int hf_smb_nt_create_options_complete_if_oplocked = -1;
static int hf_smb_nt_create_options_no_ea_knowledge = -1;
static int hf_smb_nt_create_options_eight_dot_three_only = -1;
static int hf_smb_nt_create_options_random_access = -1;
static int hf_smb_nt_create_options_delete_on_close = -1;
static int hf_smb_nt_create_options_open_by_fileid = -1;
static int hf_smb_nt_create_options_backup_intent = -1;
static int hf_smb_nt_create_options_no_compression = -1;
static int hf_smb_nt_create_options_reserve_opfilter = -1;
static int hf_smb_nt_create_options_open_reparse_point = -1;
static int hf_smb_nt_create_options_open_no_recall = -1;
static int hf_smb_nt_create_options_open_for_free_space_query = -1;
static int hf_smb_nt_share_access_read = -1;
static int hf_smb_nt_share_access_write = -1;
static int hf_smb_nt_share_access_delete = -1;
static int hf_smb_file_eattr = -1;
static int hf_smb_file_eattr_read_only = -1;
static int hf_smb_file_eattr_hidden = -1;
static int hf_smb_file_eattr_system = -1;
static int hf_smb_file_eattr_volume = -1;
static int hf_smb_file_eattr_directory = -1;
static int hf_smb_file_eattr_archive = -1;
static int hf_smb_file_eattr_device = -1;
static int hf_smb_file_eattr_normal = -1;
static int hf_smb_file_eattr_temporary = -1;
static int hf_smb_file_eattr_sparse = -1;
static int hf_smb_file_eattr_reparse = -1;
static int hf_smb_file_eattr_compressed = -1;
static int hf_smb_file_eattr_offline = -1;
static int hf_smb_file_eattr_not_content_indexed = -1;
static int hf_smb_file_eattr_encrypted = -1;
static int hf_smb_size_returned_quota_data = -1;
static int hf_smb_sec_desc_len = -1;
static int hf_smb_nt_qsd = -1;
static int hf_smb_nt_qsd_owner = -1;
static int hf_smb_nt_qsd_group = -1;
static int hf_smb_nt_qsd_dacl = -1;
static int hf_smb_nt_qsd_sacl = -1;
static int hf_smb_extended_attributes = -1;
static int hf_smb_oplock_level = -1;
static int hf_smb_response_type = -1;
static int hf_smb_create_action = -1;
static int hf_smb_file_id = -1;
static int hf_smb_file_id_64bit = -1;
static int hf_smb_ea_error_offset = -1;
static int hf_smb_end_of_file = -1;
static int hf_smb_replace = -1;
static int hf_smb_root_dir_handle = -1;
static int hf_smb_target_name_len = -1;
static int hf_smb_target_name = -1;
static int hf_smb_device_type = -1;
static int hf_smb_is_directory = -1;
static int hf_smb_next_entry_offset = -1;
static int hf_smb_change_time = -1;
static int hf_smb_setup_len = -1;
static int hf_smb_print_mode = -1;
static int hf_smb_print_identifier = -1;
static int hf_smb_restart_index = -1;
static int hf_smb_print_queue_date = -1;
static int hf_smb_print_queue_dos_date = -1;
static int hf_smb_print_queue_dos_time = -1;
static int hf_smb_print_status = -1;
static int hf_smb_print_spool_file_number = -1;
static int hf_smb_print_spool_file_size = -1;
static int hf_smb_print_spool_file_name = -1;
static int hf_smb_start_index = -1;
static int hf_smb_originator_name = -1;
static int hf_smb_destination_name = -1;
static int hf_smb_message_len = -1;
static int hf_smb_message = -1;
static int hf_smb_mgid = -1;
static int hf_smb_forwarded_name = -1;
static int hf_smb_machine_name = -1;
static int hf_smb_cancel_to = -1;
static int hf_smb_trans2_subcmd = -1;
static int hf_smb_trans_name = -1;
static int hf_smb_transaction_flags = -1;
static int hf_smb_transaction_flags_dtid = -1;
static int hf_smb_transaction_flags_owt = -1;
static int hf_smb_search_count = -1;
static int hf_smb_search_pattern = -1;
static int hf_smb_ff2 = -1;
static int hf_smb_ff2_backup = -1;
static int hf_smb_ff2_continue = -1;
static int hf_smb_ff2_resume = -1;
static int hf_smb_ff2_close_eos = -1;
static int hf_smb_ff2_close = -1;
static int hf_smb_ff2_information_level = -1;
static int hf_smb_qpi_loi = -1;
static int hf_smb_spi_loi = -1;
#if 0
static int hf_smb_sfi = -1;
static int hf_smb_sfi_writetru = -1;
static int hf_smb_sfi_caching = -1;
#endif
static int hf_smb_storage_type = -1;
static int hf_smb_resume = -1;
static int hf_smb_max_referral_level = -1;
static int hf_smb_qfsi_information_level = -1;
static int hf_smb_sfsi_information_level = -1;
static int hf_smb_number_of_links = -1;
static int hf_smb_delete_pending = -1;
static int hf_smb_index_number = -1;
static int hf_smb_position = -1;
/* static int hf_smb_current_offset = -1; */
static int hf_smb_t2_alignment = -1;
static int hf_smb_t2_stream_name_length = -1;
static int hf_smb_t2_stream_size = -1;
static int hf_smb_t2_stream_name = -1;
static int hf_smb_t2_compressed_file_size = -1;
static int hf_smb_t2_compressed_format = -1;
static int hf_smb_t2_compressed_unit_shift = -1;
static int hf_smb_t2_compressed_chunk_shift = -1;
static int hf_smb_t2_compressed_cluster_shift = -1;
static int hf_smb_t2_marked_for_deletion = -1;
static int hf_smb_dfs_path_consumed = -1;
static int hf_smb_dfs_num_referrals = -1;
static int hf_smb_get_dfs_flags = -1;
static int hf_smb_get_dfs_server_hold_storage = -1;
static int hf_smb_get_dfs_fielding = -1;
static int hf_smb_dfs_referral_version = -1;
static int hf_smb_dfs_referral_size = -1;
static int hf_smb_dfs_referral_server_type = -1;
static int hf_smb_dfs_referral_flags = -1;
static int hf_smb_dfs_referral_flags_name_list_referral = -1;
static int hf_smb_dfs_referral_flags_target_set_boundary = -1;
static int hf_smb_dfs_referral_node_offset = -1;
static int hf_smb_dfs_referral_node = -1;
static int hf_smb_dfs_referral_proximity = -1;
static int hf_smb_dfs_referral_ttl = -1;
static int hf_smb_dfs_referral_path_offset = -1;
static int hf_smb_dfs_referral_path = -1;
static int hf_smb_dfs_referral_alt_path_offset = -1;
static int hf_smb_dfs_referral_alt_path = -1;
static int hf_smb_dfs_referral_domain_offset = -1;
static int hf_smb_dfs_referral_number_of_expnames = -1;
static int hf_smb_dfs_referral_expnames_offset = -1;
static int hf_smb_dfs_referral_domain_name = -1;
static int hf_smb_dfs_referral_expname = -1;
static int hf_smb_dfs_referral_server_guid = -1;
static int hf_smb_end_of_search = -1;
static int hf_smb_last_name_offset = -1;
static int hf_smb_fn_information_level = -1;
static int hf_smb_monitor_handle = -1;
static int hf_smb_change_count = -1;
static int hf_smb_file_index = -1;
static int hf_smb_short_file_name = -1;
static int hf_smb_short_file_name_len = -1;
static int hf_smb_fs_id = -1;
static int hf_smb_sector_unit = -1;
static int hf_smb_fs_units = -1;
static int hf_smb_fs_sector = -1;
static int hf_smb_avail_units = -1;
static int hf_smb_volume_serial_num = -1;
static int hf_smb_volume_label_len = -1;
static int hf_smb_volume_label = -1;
static int hf_smb_free_alloc_units64 = -1;
static int hf_smb_caller_free_alloc_units64 = -1;
static int hf_smb_actual_free_alloc_units64 = -1;
static int hf_smb_max_name_len = -1;
static int hf_smb_fs_name_len = -1;
static int hf_smb_fs_name = -1;
static int hf_smb_device_char = -1;
static int hf_smb_device_char_removable = -1;
static int hf_smb_device_char_read_only = -1;
static int hf_smb_device_char_floppy = -1;
static int hf_smb_device_char_write_once = -1;
static int hf_smb_device_char_remote = -1;
static int hf_smb_device_char_mounted = -1;
static int hf_smb_device_char_virtual = -1;
static int hf_smb_device_char_secure_open = -1;
static int hf_smb_device_char_ts = -1;
static int hf_smb_device_char_webdav = -1;
static int hf_smb_device_char_aat = -1;
static int hf_smb_device_char_portable = -1;
static int hf_smb_fs_attr = -1;
static int hf_smb_fs_attr_css = -1;
static int hf_smb_fs_attr_cpn = -1;
static int hf_smb_fs_attr_uod = -1;
static int hf_smb_fs_attr_pacls = -1;
static int hf_smb_fs_attr_fc = -1;
static int hf_smb_fs_attr_vq = -1;
static int hf_smb_fs_attr_ssf = -1;
static int hf_smb_fs_attr_srp = -1;
static int hf_smb_fs_attr_srs = -1;
static int hf_smb_fs_attr_sla = -1;
static int hf_smb_fs_attr_vic = -1;
static int hf_smb_fs_attr_soids = -1;
static int hf_smb_fs_attr_se = -1;
static int hf_smb_fs_attr_ns = -1;
static int hf_smb_fs_attr_rov = -1;
static int hf_smb_fs_attr_swo = -1;
static int hf_smb_fs_attr_st = -1;
static int hf_smb_fs_attr_shl = -1;
static int hf_smb_fs_attr_sis = -1;
static int hf_smb_fs_attr_sbr = -1;
static int hf_smb_fs_attr_ssv = -1;
static int hf_smb_quota_flags = -1;
static int hf_smb_quota_flags_enabled = -1;
static int hf_smb_quota_flags_deny_disk = -1;
static int hf_smb_quota_flags_log_limit = -1;
static int hf_smb_quota_flags_log_warning = -1;
static int hf_smb_soft_quota_limit = -1;
static int hf_smb_hard_quota_limit = -1;
static int hf_smb_user_quota_used = -1;
static int hf_smb_user_quota_change_time = -1;
static int hf_smb_length_of_sid = -1;
static int hf_smb_user_quota_offset = -1;
static int hf_smb_nt_rename_level = -1;
static int hf_smb_cluster_count = -1;
static int hf_smb_segments = -1;
static int hf_smb_segment = -1;
static int hf_smb_segment_overlap = -1;
static int hf_smb_segment_overlap_conflict = -1;
static int hf_smb_segment_multiple_tails = -1;
static int hf_smb_segment_too_long_fragment = -1;
static int hf_smb_segment_error = -1;
static int hf_smb_segment_count = -1;
static int hf_smb_reassembled_length = -1;
static int hf_smb_pipe_write_len = -1;
static int hf_smb_unix_major_version = -1;
static int hf_smb_unix_minor_version = -1;
static int hf_smb_unix_capability = -1;
static int hf_smb_unix_capability_fcntl = -1;
static int hf_smb_unix_capability_posix_acl = -1;
static int hf_smb_unix_capability_xattr = -1;
static int hf_smb_unix_capability_attr = -1;
static int hf_smb_unix_capability_posix_paths = -1;
static int hf_smb_unix_capability_posix_path_ops = -1;
static int hf_smb_unix_capability_large_read = -1;
static int hf_smb_unix_capability_large_write = -1;
static int hf_smb_unix_capability_encryption = -1;
static int hf_smb_unix_capability_mandatory_crypto = -1;
static int hf_smb_unix_capability_proxy = -1;
static int hf_smb_unix_file_link_dest = -1;
static int hf_smb_unix_file_size = -1;
static int hf_smb_unix_file_num_bytes = -1;
static int hf_smb_unix_file_last_status = -1;
static int hf_smb_unix_file_last_access = -1;
static int hf_smb_unix_file_last_change = -1;
static int hf_smb_unix_file_creation_time = -1;
static int hf_smb_unix_file_uid = -1;
static int hf_smb_unix_file_gid = -1;
static int hf_smb_unix_file_type = -1;
static int hf_smb_unix_file_dev_major = -1;
static int hf_smb_unix_file_dev_minor = -1;
static int hf_smb_unix_file_unique_id = -1;
static int hf_smb_unix_file_permissions = -1;
static int hf_smb_unix_file_nlinks = -1;
static int hf_smb_unix_info2_file_flags = -1;
static int hf_smb_unix_info2_file_flags_mask = -1;
static int hf_smb_unix_info2_file_flags_secure_delete = -1;
static int hf_smb_unix_info2_file_flags_enable_undelete = -1;
static int hf_smb_unix_info2_file_flags_synchronous = -1;
static int hf_smb_unix_info2_file_flags_immutable = -1;
static int hf_smb_unix_info2_file_flags_append_only = -1;
static int hf_smb_unix_info2_file_flags_do_not_backup = -1;
static int hf_smb_unix_info2_file_flags_no_update_atime = -1;
static int hf_smb_unix_info2_file_flags_hidden = -1;
static int hf_smb_unix_file_name_length = -1;
static int hf_smb_unix_file_name = -1;
static int hf_smb_unix_find_file_nextoffset = -1;
static int hf_smb_unix_find_file_resumekey = -1;
static int hf_smb_unix_whoami_mapflags = -1;
static int hf_smb_unix_whoami_mapflags_mask = -1;
static int hf_smb_unix_whoami_num_supl_gids = -1;
static int hf_smb_unix_whoami_num_supl_sids = -1;
static int hf_smb_unix_whoami_sids_buflen = -1;
static int hf_smb_disposition_delete_on_close = -1;
static int hf_smb_pipe_info_flag = -1;
static int hf_smb_mode = -1;
static int hf_smb_attribute = -1;
static int hf_smb_reparse_tag = -1;
static int hf_smb_logged_in = -1;
static int hf_smb_logged_out = -1;
static int hf_smb_file_rw_offset = -1;
static int hf_smb_file_rw_length = -1;
static int hf_smb_posix_acl_version = -1;
static int hf_smb_posix_num_file_aces = -1;
static int hf_smb_posix_num_def_aces = -1;
static int hf_smb_posix_ace_type = -1;
static int hf_smb_posix_ace_flags = -1;
static int hf_smb_posix_ace_perm_read = -1;
static int hf_smb_posix_ace_perm_write = -1;
static int hf_smb_posix_ace_perm_execute = -1;
static int hf_smb_posix_ace_perm_owner_uid = -1;
static int hf_smb_posix_ace_perm_owner_gid = -1;
static int hf_smb_posix_ace_perm_uid = -1;
static int hf_smb_posix_ace_perm_gid = -1;
static int hf_smb_trans_data_setup_word = -1;
static int hf_smb_trans_data_parameters = -1;
static int hf_smb_trans_data = -1;
static int hf_smb_extra_byte_parameters = -1;
static int hf_smb_file_access_mask_full_control = -1;
static int hf_smb_dir_access_mask_full_control = -1;
static int hf_smb_word_unk_response_format = -1;
static int hf_smb_nt_transaction_setup = -1;
static int hf_smb_server_component = -1;
static int hf_smb_byte_parameters = -1;
static int hf_smb_word_parameters = -1;
static gint ett_smb = -1;
static gint ett_smb_fid = -1;
static gint ett_smb_tid = -1;
static gint ett_smb_uid = -1;
static gint ett_smb_hdr = -1;
static gint ett_smb_command = -1;
static gint ett_smb_fileattributes = -1;
static gint ett_smb_capabilities = -1;
static gint ett_smb_aflags = -1;
static gint ett_smb_dialect = -1;
static gint ett_smb_dialects = -1;
static gint ett_smb_mode = -1;
static gint ett_smb_rawmode = -1;
static gint ett_smb_flags = -1;
static gint ett_smb_flags2 = -1;
static gint ett_smb_desiredaccess = -1;
static gint ett_smb_search = -1;
static gint ett_smb_file = -1;
static gint ett_smb_openfunction = -1;
static gint ett_smb_filetype = -1;
static gint ett_smb_openaction = -1;
static gint ett_smb_writemode = -1;
static gint ett_smb_lock_type = -1;
static gint ett_smb_ssetupandxaction = -1;
static gint ett_smb_optionsup = -1;
static gint ett_smb_time_date = -1;
static gint ett_smb_move_copy_flags = -1;
static gint ett_smb_file_attributes = -1;
static gint ett_smb_search_resume_key = -1;
static gint ett_smb_search_dir_info = -1;
static gint ett_smb_unlocks = -1;
static gint ett_smb_unlock = -1;
static gint ett_smb_locks = -1;
static gint ett_smb_lock = -1;
static gint ett_smb_open_flags = -1;
static gint ett_smb_ipc_state = -1;
static gint ett_smb_open_action = -1;
static gint ett_smb_setup_action = -1;
static gint ett_smb_connect_flags = -1;
static gint ett_smb_connect_support_bits = -1;
static gint ett_smb_nt_access_mask = -1;
static gint ett_smb_nt_create_bits = -1;
static gint ett_smb_nt_create_options = -1;
static gint ett_smb_nt_share_access = -1;
static gint ett_smb_nt_security_flags = -1;
static gint ett_smb_nt_trans_setup = -1;
static gint ett_smb_nt_trans_data = -1;
static gint ett_smb_nt_trans_param = -1;
static gint ett_smb_nt_notify_completion_filter = -1;
static gint ett_smb_nt_ioctl_flags = -1;
static gint ett_smb_security_information_mask = -1;
static gint ett_smb_print_queue_entry = -1;
static gint ett_smb_transaction_flags = -1;
static gint ett_smb_transaction_params = -1;
static gint ett_smb_find_first2_flags = -1;
static gint ett_smb_mac_support_flags = -1;
#if 0
static gint ett_smb_ioflag = -1;
#endif
static gint ett_smb_transaction_data = -1;
static gint ett_smb_stream_info = -1;
static gint ett_smb_dfs_referrals = -1;
static gint ett_smb_dfs_referral = -1;
static gint ett_smb_dfs_referral_flags = -1;
static gint ett_smb_dfs_referral_expnames = -1;
static gint ett_smb_get_dfs_flags = -1;
static gint ett_smb_ff2_data = -1;
static gint ett_smb_device_characteristics = -1;
static gint ett_smb_fs_attributes = -1;
static gint ett_smb_segments = -1;
static gint ett_smb_segment = -1;
static gint ett_smb_quotaflags = -1;
static gint ett_smb_secblob = -1;
static gint ett_smb_unicode_password = -1;
static gint ett_smb_ea = -1;
static gint ett_smb_unix_capabilities = -1;
static gint ett_smb_unix_whoami_gids = -1;
static gint ett_smb_unix_whoami_sids = -1;
static gint ett_smb_posix_ace = -1;
static gint ett_smb_posix_ace_perms = -1;
static gint ett_smb_info2_file_flags = -1;
static expert_field ei_smb_missing_word_parameters = EI_INIT;
static expert_field ei_smb_mal_information_level = EI_INIT;
static expert_field ei_smb_not_implemented = EI_INIT;
static expert_field ei_smb_nt_transaction_setup = EI_INIT;
static expert_field ei_smb_posix_ace_type = EI_INIT;
static expert_field ei_smb_info_level_unknown = EI_INIT;
static expert_field ei_smb_info_level_not_understood = EI_INIT;
static int smb_tap = -1;
static int smb_eo_tap = -1;
static dissector_handle_t smb_handle;
static dissector_handle_t gssapi_handle;
static dissector_handle_t ntlmssp_handle;
static const fragment_items smb_frag_items = {
&ett_smb_segment,
&ett_smb_segments,
&hf_smb_segments,
&hf_smb_segment,
&hf_smb_segment_overlap,
&hf_smb_segment_overlap_conflict,
&hf_smb_segment_multiple_tails,
&hf_smb_segment_too_long_fragment,
&hf_smb_segment_error,
&hf_smb_segment_count,
NULL,
&hf_smb_reassembled_length,
/* Reassembled data field */
NULL,
"segments"
};
static proto_tree *top_tree_global = NULL; /* ugly */
static int dissect_smb_command(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *smb_tree, guint8 cmd, gboolean first_pdu, smb_info_t *si);
#define SMB_NUM_PROCEDURES 256
#define SMB_SRT_TABLE_INDEX 0
#define TRANS2_SRT_TABLE_INDEX 1
#define NT_SRT_TABLE_INDEX 2
static void
smbstat_init(struct register_srt* srt _U_, GArray* srt_array)
{
srt_stat_table *smb_srt_table;
srt_stat_table *trans2_srt_table;
srt_stat_table *nt_srt_table;
guint32 i;
smb_srt_table = init_srt_table("SMB Commands", NULL, srt_array, SMB_NUM_PROCEDURES, "Commands", "smb.cmd", NULL);
trans2_srt_table = init_srt_table("Transaction2 Sub-Commands", NULL, srt_array, SMB_NUM_PROCEDURES, "Transaction2 Commands", "smb.trans2.cmd", NULL);
nt_srt_table = init_srt_table("NT Transaction Sub-Commands", NULL, srt_array, SMB_NUM_PROCEDURES, "NT Transaction Sub-Commands", "smb.nt.function", NULL);
for (i = 0; i < SMB_NUM_PROCEDURES; i++)
{
init_srt_table_row(smb_srt_table, i, val_to_str_ext_const(i, &smb_cmd_vals_ext, "<unknown>"));
init_srt_table_row(trans2_srt_table, i, val_to_str_ext_const(i, &trans2_cmd_vals_ext, "<unknown>"));
init_srt_table_row(nt_srt_table, i, val_to_str_ext_const(i, &nt_cmd_vals_ext, "<unknown>"));
}
}
static tap_packet_status
smbstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv, tap_flags_t flags _U_)
{
guint i = 0;
srt_stat_table *smb_srt_table;
srt_data_t *data = (srt_data_t *)pss;
const smb_info_t *si = (const smb_info_t *)prv;
/* we are only interested in reply packets */
if (si->request) {
return TAP_PACKET_DONT_REDRAW;
}
/* if we havnt seen the request, just ignore it */
if (!si->sip) {
return TAP_PACKET_DONT_REDRAW;
}
if (si->cmd == 0xA0 && si->sip->extra_info_type == SMB_EI_NTI) {
smb_nt_transact_info_t *sti = (smb_nt_transact_info_t *)si->sip->extra_info;
/*nt transaction*/
if (sti) {
i = NT_SRT_TABLE_INDEX;
smb_srt_table = g_array_index(data->srt_array, srt_stat_table*, i);
add_srt_table_data(smb_srt_table, sti->subcmd, &si->sip->req_time, pinfo);
}
} else if (si->cmd == 0x32 && si->sip->extra_info_type == SMB_EI_T2I) {
smb_transact2_info_t *st2i = (smb_transact2_info_t *)si->sip->extra_info;
/*transaction2*/
if (st2i) {
i = TRANS2_SRT_TABLE_INDEX;
smb_srt_table = g_array_index(data->srt_array, srt_stat_table*, i);
add_srt_table_data(smb_srt_table, st2i->subcmd, &si->sip->req_time, pinfo);
}
} else {
i = SMB_SRT_TABLE_INDEX;
smb_srt_table = g_array_index(data->srt_array, srt_stat_table*, i);
add_srt_table_data(smb_srt_table, si->cmd, &si->sip->req_time, pinfo);
}
return TAP_PACKET_REDRAW;
}
/*
* Export object functionality
*/
/* These flags show what kind of data the object contains
(designed to be or'ed) */
#define SMB_EO_CONTAINS_NOTHING 0x00
#define SMB_EO_CONTAINS_READS 0x01
#define SMB_EO_CONTAINS_WRITES 0x02
#define SMB_EO_CONTAINS_READSANDWRITES 0x03
static const value_string smb_eo_contains_string[] = {
{SMB_EO_CONTAINS_NOTHING, "" },
{SMB_EO_CONTAINS_READS, "R" },
{SMB_EO_CONTAINS_WRITES, "W" },
{SMB_EO_CONTAINS_READSANDWRITES, "R&W"},
{0, NULL}
};
/* Strings that describes the SMB object type */
static const value_string smb_fid_types[] = {
{SMB_FID_TYPE_UNKNOWN,"UNKNOWN"},
{SMB_FID_TYPE_FILE,"FILE"},
{SMB_FID_TYPE_DIR,"DIRECTORY (Not Implemented)"},
{SMB_FID_TYPE_PIPE,"PIPE (Not Implemented)"},
{0, NULL}
};
static const value_string smb2_fid_types[] = {
{SMB2_FID_TYPE_UNKNOWN,"UNKNOWN"},
{SMB2_FID_TYPE_FILE,"FILE"},
{SMB2_FID_TYPE_DIR,"DIRECTORY (Not Implemented)"},
{SMB2_FID_TYPE_PIPE,"PIPE (Not Implemented)"},
{SMB2_FID_TYPE_OTHER,"OTHER (Not Implemented)"},
{0, NULL}
};
/* This struct contains the relationship between
the row# in the export_object window and the file being captured;
the row# in this GSList will match the row# in the entry list */
typedef struct _active_file {
guint16 tid, uid;
guint32 fid; /* 16-bit fid (smb) or 32-bit compressed fid (smb2) */
guint64 file_length; /* The last free reported offset. We treat it as the file length */
guint64 data_gathered; /* The actual total of data gathered */
guint8 flag_contains; /* What kind of data it contains */
GSList *free_chunk_list; /* A list of virtual "holes" in the file stream stored in memory */
gboolean is_out_of_memory; /* TRUE if we cannot allocate memory for this file */
} active_file ;
/* This is the GSList that will contain all the files that we are tracking */
static GSList *GSL_active_files = NULL;
/* We define a free chunk in a file as an start offset and end offset
Consider a free chunk as a "hole" in a file that we are capturing */
typedef struct _free_chunk {
guint64 start_offset;
guint64 end_offset;
} free_chunk;
/* insert_chunk function will recalculate the free_chunk_list, the data_size,
the end_of_file, and the data_gathered as appropriate.
It will also insert the data chunk that is coming in the right
place of the file in memory.
HINTS:
file->data_gathered contains the real data gathered independently from the file length
file->file_length contains the length of the file in memory, i.e.,
the last offset captured. In most cases, the real
file length would be different.
*/
static void
insert_chunk(active_file *file, export_object_entry_t *entry, const smb_eo_t *eo_info)
{
gint nfreechunks = g_slist_length(file->free_chunk_list);
gint i;
free_chunk *current_free_chunk;
free_chunk *new_free_chunk;
guint64 chunk_offset = eo_info->smb_file_offset;
guint64 chunk_length = eo_info->payload_len;
guint64 chunk_end_offset = chunk_offset + chunk_length-1;
/* Size of file in memory */
guint64 calculated_size = chunk_offset + chunk_length;
gpointer dest_memory_addr;
/* Let's recalculate the file length and data gathered */
if ((file->data_gathered == 0) && (nfreechunks == 0)) {
/* If this is the first entry for this file, we first create an initial free chunk */
new_free_chunk = g_new(free_chunk, 1);
new_free_chunk->start_offset = 0;
new_free_chunk->end_offset = MAX(file->file_length, chunk_end_offset+1) - 1;
file->free_chunk_list = NULL;
file->free_chunk_list = g_slist_append(file->free_chunk_list, new_free_chunk);
nfreechunks += 1;
} else {
if (chunk_end_offset > file->file_length-1) {
new_free_chunk = g_new(free_chunk, 1);
new_free_chunk->start_offset = file->file_length;
new_free_chunk->end_offset = chunk_end_offset;
file->free_chunk_list = g_slist_append(file->free_chunk_list, new_free_chunk);
nfreechunks += 1;
}
}
file->file_length = MAX(file->file_length, chunk_end_offset+1);
/* Recalculate each free chunk according with the incoming data chunk */
for (i=0; i<nfreechunks; i++) {
current_free_chunk = (free_chunk *)g_slist_nth_data(file->free_chunk_list, i);
/* 1. data chunk before the free chunk? */
/* -> free chunk is not altered and no new data gathered */
if (chunk_end_offset<current_free_chunk->start_offset) {
continue;
}
/* 2. data chunk overlaps the first part of free_chunk */
/* -> free chunk shrinks from the beginning */
if (chunk_offset<=current_free_chunk->start_offset && chunk_end_offset>=current_free_chunk->start_offset && chunk_end_offset<current_free_chunk->end_offset) {
file->data_gathered += chunk_end_offset-current_free_chunk->start_offset+1;
current_free_chunk->start_offset=chunk_end_offset+1;
continue;
}
/* 3. data chunk overlaps completely the free chunk */
/* -> free chunk is removed */
if (chunk_offset<=current_free_chunk->start_offset && chunk_end_offset>=current_free_chunk->end_offset) {
file->data_gathered += current_free_chunk->end_offset-current_free_chunk->start_offset+1;
file->free_chunk_list = g_slist_remove(file->free_chunk_list, current_free_chunk);
g_free(current_free_chunk);
nfreechunks -= 1;
if (nfreechunks == 0) { /* The free chunk list is empty */
g_slist_free(file->free_chunk_list);
file->free_chunk_list = NULL;
break;
}
i--;
continue;
}
/* 4. data chunk is inside the free chunk */
/* -> free chunk is split into two */
if (chunk_offset>current_free_chunk->start_offset && chunk_end_offset<current_free_chunk->end_offset) {
new_free_chunk = g_new(free_chunk, 1);
new_free_chunk->start_offset = chunk_end_offset + 1;
new_free_chunk->end_offset = current_free_chunk->end_offset;
current_free_chunk->end_offset = chunk_offset-1;
file->free_chunk_list = g_slist_insert(file->free_chunk_list, new_free_chunk, i + 1);
file->data_gathered += chunk_length;
continue;
}
/* 5.- data chunk overlaps the end part of free chunk */
/* -> free chunk shrinks from the end */
if (chunk_offset>current_free_chunk->start_offset && chunk_offset<=current_free_chunk->end_offset && chunk_end_offset>=current_free_chunk->end_offset) {
file->data_gathered += current_free_chunk->end_offset-chunk_offset+1;
current_free_chunk->end_offset = chunk_offset-1;
continue;
}
/* 6.- data chunk is after the free chunk */
/* -> free chunk is not altered and no new data gathered */
if (chunk_offset>current_free_chunk->end_offset) {
continue;
}
}
/* Now, let's insert the data chunk into memory
...first, we shall be able to allocate the memory */
if (!entry->payload_data) {
/* This is a New file */
if (calculated_size > G_MAXUINT32) {
/*
* The argument to g_try_malloc() is
* a gsize, however the maximum size of a file
* is 32-bit. If the calculated size is
* bigger than that, we just say the attempt
* to allocate memory failed.
*/
entry->payload_data = NULL;
} else {
entry->payload_data = (guint8 *)g_try_malloc((gsize)calculated_size);
entry->payload_len = (size_t)calculated_size;
}
if (!entry->payload_data) {
/* Memory error */
file->is_out_of_memory = TRUE;
}
} else {
/* This is an existing file in memory */
if (calculated_size > (guint64) entry->payload_len &&
!file->is_out_of_memory) {
/* We need more memory */
if (calculated_size > G_MAXUINT32) {
/*
* As for g_try_malloc(), so for
* g_try_realloc().
*/
dest_memory_addr = NULL;
} else {
dest_memory_addr = g_try_realloc(
entry->payload_data,
(gsize)calculated_size);
}
if (!dest_memory_addr) {
/* Memory error */
file->is_out_of_memory = TRUE;
/* We don't have memory for this file.
Free the current file content from memory */
g_free(entry->payload_data);
entry->payload_data = NULL;
entry->payload_len = 0;
} else {
entry->payload_data = (guint8 *)dest_memory_addr;
entry->payload_len = (size_t)calculated_size;
}
}
}
/* ...then, put the chunk of the file in the right place */
if (!file->is_out_of_memory) {
dest_memory_addr = entry->payload_data + chunk_offset;
memmove(dest_memory_addr, eo_info->payload_data, eo_info->payload_len);
}
}
/* We use this function to obtain the index in the GSL of a given file */
static int
find_incoming_file(GSList *GSL_active_files_p, active_file *incoming_file)
{
int i, row, last;
active_file *in_list_file;
row = -1;
last = g_slist_length(GSL_active_files_p) - 1;
/* We lookup in reverse order because it is more likely that the file
is one of the latest */
for (i=last; i>=0; i--) {
in_list_file = (active_file *)g_slist_nth_data(GSL_active_files_p, i);
/* The best-working criteria of two identical files is that the file
that is the same of the file that we are analyzing is the last one
in the list that has the same tid and the same fid */
/* note that we have excluded in_list_file->uid == incoming_file->uid
from the comparison, because a file can be opened by different
SMB users and it is still the same file */
if (in_list_file->tid == incoming_file->tid &&
in_list_file->fid == incoming_file->fid) {
row = i;
break;
}
}
return row;
}
static tap_packet_status
smb_eo_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const void *data, tap_flags_t flags _U_)
{
export_object_list_t *object_list = (export_object_list_t *)tapdata;
const smb_eo_t *eo_info = (const smb_eo_t *)data;
export_object_entry_t *entry;
export_object_entry_t *current_entry;
active_file incoming_file;
gint active_row;
active_file *new_file;
active_file *current_file;
guint8 contains;
gboolean is_supported_filetype;
gfloat percent;
const gchar *aux_smb_fid_type_string;
if (eo_info->smbversion==1) {
/* Is this an eo_smb supported file_type? (right now we only support FILE) */
is_supported_filetype = (eo_info->fid_type == SMB_FID_TYPE_FILE);
aux_smb_fid_type_string = val_to_str_const(eo_info->fid_type, smb_fid_types, "?");
/* What kind of data this packet contains? */
switch(eo_info->cmd) {
case SMB_COM_READ_ANDX:
case SMB_COM_READ:
contains = SMB_EO_CONTAINS_READS;
break;
case SMB_COM_WRITE_ANDX:
case SMB_COM_WRITE:
contains = SMB_EO_CONTAINS_WRITES;
break;
default:
contains = SMB_EO_CONTAINS_NOTHING;
break;
}
} else {
/* Is this an eo_smb supported file_type? (right now we only support FILE) */
is_supported_filetype = (eo_info->fid_type == SMB2_FID_TYPE_FILE );
aux_smb_fid_type_string = val_to_str_const(eo_info->fid_type, smb2_fid_types, "?");
/* What kind of data this packet contains? */
switch(eo_info->cmd) {
case SMB2_COM_READ:
contains = SMB_EO_CONTAINS_READS;
break;
case SMB2_COM_WRITE:
contains = SMB_EO_CONTAINS_WRITES;
break;
default:
contains = SMB_EO_CONTAINS_NOTHING;
break;
}
}
/* Is this data from an already tracked file or not? */
incoming_file.tid = eo_info->tid;
incoming_file.uid = eo_info->uid;
incoming_file.fid = eo_info->fid;
active_row = find_incoming_file(GSL_active_files, &incoming_file);
if (active_row == -1) { /* This is a new-tracked file */
/* Construct the entry in the list of active files */
entry = g_new(export_object_entry_t, 1);
entry->payload_data = NULL;
entry->payload_len = 0;
new_file = g_new(active_file, 1);
new_file->tid = incoming_file.tid;
new_file->uid = incoming_file.uid;
new_file->fid = incoming_file.fid;
new_file->file_length = eo_info->end_of_file;
new_file->flag_contains = contains;
new_file->free_chunk_list = NULL;
new_file->data_gathered = 0;
new_file->is_out_of_memory = FALSE;
entry->pkt_num = pinfo->num;
entry->hostname=g_filename_display_name(eo_info->hostname);
entry->filename=g_filename_display_name(eo_info->filename);
/* Insert the first chunk in the chunk list of this file */
if (is_supported_filetype) {
insert_chunk(new_file, entry, eo_info);
}
if (new_file->is_out_of_memory) {
entry->content_type =
ws_strdup_printf("%s (%"PRIu64"?/%"PRIu64") %s [mem!!]",
aux_smb_fid_type_string,
new_file->data_gathered,
new_file->file_length,
try_val_to_str(contains, smb_eo_contains_string));
} else {
if (new_file->file_length > 0) {
percent = (gfloat) (100*new_file->data_gathered/new_file->file_length);
} else {
percent = 0.0f;
}
entry->content_type =
ws_strdup_printf("%s (%"PRIu64"/%"PRIu64") %s [%5.2f%%]",
aux_smb_fid_type_string,
new_file->data_gathered,
new_file->file_length,
try_val_to_str(contains, smb_eo_contains_string),
percent);
}
object_list->add_entry(object_list->gui_data, entry);
GSL_active_files = g_slist_append(GSL_active_files, new_file);
}
else if (is_supported_filetype) {
current_file = (active_file *)g_slist_nth_data(GSL_active_files, active_row);
/* Recalculate the current file flags */
current_file->flag_contains = current_file->flag_contains|contains;
current_entry = object_list->get_entry(object_list->gui_data, active_row);
insert_chunk(current_file, current_entry, eo_info);
/* Modify the current_entry object_type string */
if (current_file->is_out_of_memory) {
current_entry->content_type =
ws_strdup_printf("%s (%"PRIu64"?/%"PRIu64") %s [mem!!]",
aux_smb_fid_type_string,
current_file->data_gathered,
current_file->file_length,
try_val_to_str(current_file->flag_contains, smb_eo_contains_string));
} else {
percent = (gfloat) (100*current_file->data_gathered/current_file->file_length);
current_entry->content_type =
ws_strdup_printf("%s (%"PRIu64"/%"PRIu64") %s [%5.2f%%]",
aux_smb_fid_type_string,
current_file->data_gathered,
current_file->file_length,
try_val_to_str(current_file->flag_contains, smb_eo_contains_string),
percent);
}
}
return TAP_PACKET_REDRAW; /* State changed - window should be redrawn */
}
/* This is the eo_reset_cb function that is used in the export_object module
to cleanup any previous private data of the export object functionality before perform
the eo_reset function or when the window closes */
static void
smb_eo_cleanup(void)
{
int i, last;
active_file *in_list_file;
/* Free any previous data structures used in previous invocation to the
export_object_smb function */
last = g_slist_length(GSL_active_files);
if (GSL_active_files) {
for (i=last-1; i>=0; i--) {
in_list_file = (active_file *)g_slist_nth_data(GSL_active_files, i);
if (in_list_file->free_chunk_list) {
g_slist_free(in_list_file->free_chunk_list);
in_list_file->free_chunk_list = NULL;
}
g_free(in_list_file);
}
g_slist_free(GSL_active_files);
GSL_active_files = NULL;
}
}
/*
* Macros for use in the main dissector routines for an SMB.
*/
#define WORD_COUNT \
/* Word Count */ \
wc = tvb_get_guint8(tvb, offset); \
proto_tree_add_uint(tree, hf_smb_word_count, \
tvb, offset, 1, wc); \
offset += 1; \
if (wc == 0) goto bytecount;
#define BYTE_COUNT \
bytecount: \
bc = tvb_get_letohs(tvb, offset); \
proto_tree_add_uint(tree, hf_smb_byte_count, \
tvb, offset, 2, bc); \
offset += 2; \
if (bc == 0) goto endofcommand;
#define CHECK_BYTE_COUNT(len) \
if (bc < len) goto endofcommand;
#define COUNT_BYTES(len) {\
int tmp; \
tmp = len; \
offset += tmp; \
bc -= tmp; \
}
#define END_OF_SMB \
if (bc != 0) { \
gint bc_remaining; \
bc_remaining = tvb_reported_length_remaining(tvb, offset); \
if ( ((gint)bc) > bc_remaining) { \
bc = bc_remaining; \
} \
if (bc) { \
proto_tree_add_item(tree, hf_smb_extra_byte_parameters, tvb, offset, bc, ENC_NA); \
} \
offset += bc; \
} \
endofcommand:
/*
* Macros for use in routines called by them.
*/
#define CHECK_BYTE_COUNT_SUBR(len) \
if (*bcp < len) { \
*trunc = TRUE; \
return offset; \
}
#define CHECK_STRING_SUBR(fn) \
if (fn == NULL) { \
*trunc = TRUE; \
return offset; \
}
#define COUNT_BYTES_SUBR(len) \
offset += len; \
*bcp -= len;
/*
* Macros for use when dissecting transaction parameters and data
*/
#define CHECK_BYTE_COUNT_TRANS(len) \
if (bc < len) return offset;
#define CHECK_STRING_TRANS(fn) \
if (fn == NULL) return offset;
#define COUNT_BYTES_TRANS(len) \
offset += len; \
bc -= len;
/*
* Macros for use in subrroutines dissecting transaction parameters or data
*/
#define CHECK_BYTE_COUNT_TRANS_SUBR(len) \
if (*bcp < len) return offset;
#define CHECK_STRING_TRANS_SUBR(fn) \
if (fn == NULL) return offset;
#define COUNT_BYTES_TRANS_SUBR(len) \
offset += len; \
*bcp -= len;
gboolean sid_display_hex = FALSE;
gboolean sid_name_snooping = FALSE;
/* ExportObject preferences variable */
gboolean eosmb_take_name_as_fid = FALSE ;
/* Utility to get an str reprensenting ipv4 or ipv6 address */
const gchar *tree_ip_str(packet_info *pinfo, guint16 cmd) {
const gchar *buf;
if ( cmd == SMB_COM_READ_ANDX ||
cmd == SMB_COM_READ ||
cmd == SMB2_COM_READ) {
buf = address_to_str(wmem_packet_scope(), &pinfo->src);
} else {
buf = address_to_str(wmem_packet_scope(), &pinfo->dst);
}
return buf;
}
/* ExportObject feed function*/
static void
feed_eo_smb(guint16 cmd, guint16 fid, tvbuff_t * tvb, packet_info *pinfo, guint16 dataoffset, guint32 datalen, guint32 chunk_len,
guint64 file_offset, smb_info_t *si) {
smb_eo_t *eo_info; /* eo_info variable to pass info. to
export object and aux */
smb_tid_info_t *tid_info = NULL;
smb_fid_info_t *fid_info = NULL;
smb_fid_info_t *suspect_fid_info = NULL;
tvbuff_t *data_tvb;
GSList *GSL_iterator;
/* Create a new tvb to point to the payload data */
data_tvb = tvb_new_subset_length(tvb, dataoffset, datalen);
/* Create the eo_info to pass to the listener */
eo_info = wmem_new(wmem_packet_scope(), smb_eo_t);
/* Try to get fid_info and tid_info */
if (fid_info == NULL) {
GSL_iterator = si->ct->GSL_fid_info;
while (GSL_iterator) {
suspect_fid_info = (smb_fid_info_t *)GSL_iterator->data;
if (suspect_fid_info->opened_in > pinfo->num) break;
if ((suspect_fid_info->tid == si->tid) && (suspect_fid_info->fid == fid))
fid_info = suspect_fid_info;
GSL_iterator = g_slist_next(GSL_iterator);
}
}
tid_info = (smb_tid_info_t *)wmem_tree_lookup32(si->ct->tid_tree, si->tid);
/* Construct the eo_info structure */
eo_info->smbversion = 1;
if (tid_info) {
if (tid_info->filename) {
eo_info->hostname = tid_info->filename;
} else {
eo_info->hostname = wmem_strdup_printf(wmem_packet_scope(), "\\\\%s\\TREEID_UNKNOWN", tree_ip_str(pinfo, cmd));
}
}
else eo_info->hostname = wmem_strdup_printf(wmem_packet_scope(), "\\\\%s\\TREEID_%i", tree_ip_str(pinfo, cmd), si->tid);
if (fid_info) {
eo_info->filename = NULL;
if (fid_info->fsi)
if (fid_info->fsi->filename)
eo_info->filename = (gchar *) fid_info->fsi->filename;
if (!eo_info->filename) eo_info->filename = wmem_strdup_printf(wmem_packet_scope(), "\\FILEID_%i", fid);
eo_info->fid_type = fid_info->type;
eo_info->end_of_file = fid_info->end_of_file;
} else {
eo_info->fid_type = SMB_FID_TYPE_UNKNOWN;
eo_info->filename = wmem_strdup_printf(wmem_packet_scope(), "\\FILEID_%i", fid);
eo_info->end_of_file = 0;
}
if (eosmb_take_name_as_fid) {
eo_info->fid = g_str_hash(eo_info->filename);
} else {
eo_info->fid = fid;
}
eo_info->tid = si->tid;
eo_info->uid = si->uid;
eo_info->payload_len = datalen;
eo_info->payload_data = tvb_get_ptr(data_tvb, 0, datalen);
eo_info->smb_file_offset = file_offset;
eo_info->smb_chunk_len = chunk_len;
eo_info->cmd = cmd;
/* Queue data to the listener */
tap_queue_packet(smb_eo_tap, pinfo, eo_info);
} /* feed_eo_smb */
/* Compare function to maintain the GSL_fid_info ordered
Order criteria: packet where the fid was opened */
static gint
fid_cmp(smb_fid_info_t *fida, smb_fid_info_t *fidb)
{
return (fida->opened_in - fidb->opened_in);
}
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
These are needed by the reassembly of SMB Transaction payload and DCERPC over SMB
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
static gboolean smb_trans_reassembly = TRUE;
gboolean smb_dcerpc_reassembly = TRUE;
static reassembly_table smb_trans_reassembly_table;
static fragment_head *
smb_trans_defragment(proto_tree *tree _U_, packet_info *pinfo, tvbuff_t *tvb,
int offset, guint count, guint pos, guint totlen, smb_info_t *si)
{
fragment_head *fd_head = NULL;
int more_frags;
/* Don't pass the reassembly code data that doesn't exist */
/* Fail if some or all of the fragment is located beyond the total length */
if ( !tvb_bytes_exist(tvb, offset, count) || (pos > totlen) || (count > totlen) || ((pos + count) > totlen)) {
THROW(ReportedBoundsError);
}
more_frags = totlen > (pos + count);
DISSECTOR_ASSERT(si);
if (si->sip == NULL) {
/*
* We don't have the frame number of the request.
*/
return NULL;
}
if (!pinfo->fd->visited) {
fd_head = fragment_add(&smb_trans_reassembly_table, tvb, offset,
pinfo, si->sip->frame_req, NULL,
pos, count, more_frags);
} else {
fd_head = fragment_get(&smb_trans_reassembly_table,
pinfo, si->sip->frame_req, NULL);
}
if (!fd_head || !(fd_head->flags & FD_DEFRAGMENTED)) {
/* This is continued - mark it as such, so we recognize
continuation responses.
*/
si->sip->flags |= SMB_SIF_IS_CONTINUED;
} else {
/* We've finished reassembling, so there are no more
continuation responses.
*/
si->sip->flags &= ~SMB_SIF_IS_CONTINUED;
}
/* we only show the defragmented packet for the first fragment,
or else we might end up with dissecting one HUGE transaction PDU
a LOT of times. (first fragment is the only one containing the setup
bytes)
I have seen ONE Transaction PDU that is ~60kb, spanning many Transaction
SMBs. Takes a LOT of time dissecting and is not fun.
*/
if ( (pos == 0) && fd_head && (fd_head->flags & FD_DEFRAGMENTED)) {
return fd_head;
} else {
return NULL;
}
}
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
These variables and functions are used to match
responses with calls
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
/*
* The information we need to save about a request in order to show the
* frame number of the request in the dissection of the reply.
*/
typedef struct {
guint32 frame;
guint32 pid_mid;
} smb_saved_info_key_t;
/* unmatched smb_saved_info structures.
For unmatched smb_saved_info structures we store the smb_saved_info
structure using the MID and the PID as the key.
Oh, yes, the key is really a pointer, but we use it as if it was an integer.
Ugly, yes. Not portable to DEC-20 Yes. But it saves a few bytes.
The key is the PID in the upper 16 bits and the MID in the lower 16 bits.
*/
static gint
smb_saved_info_equal_unmatched(gconstpointer k1, gconstpointer k2)
{
register guint32 key1 = GPOINTER_TO_UINT(k1);
register guint32 key2 = GPOINTER_TO_UINT(k2);
return key1 == key2;
}
static guint
smb_saved_info_hash_unmatched(gconstpointer k)
{
register guint32 key = GPOINTER_TO_UINT(k);
return key;
}
/* matched smb_saved_info structures.
For matched smb_saved_info structures we store the smb_saved_info
structure twice in the table using the frame number, and a combination
of the MID and the PID, as the key.
The frame number is guaranteed to be unique but if ever someone makes
some change that will renumber the frames in a capture we are in BIG trouble.
This is not likely though since that would break (among other things) all the
reassembly routines as well.
We also need the MID as there may be more than one SMB request or reply
in a single frame, and we also need the PID as there may be more than
one outstanding request with the same MID and different PIDs.
*/
static gint
smb_saved_info_equal_matched(gconstpointer k1, gconstpointer k2)
{
const smb_saved_info_key_t *key1 = (const smb_saved_info_key_t *)k1;
const smb_saved_info_key_t *key2 = (const smb_saved_info_key_t *)k2;
return (key1->frame == key2->frame) && (key1->pid_mid == key2->pid_mid);
}
static guint
smb_saved_info_hash_matched(gconstpointer k)
{
const smb_saved_info_key_t *key = (const smb_saved_info_key_t *)k;
return key->frame + key->pid_mid;
}
static GSList *conv_tables = NULL;
static gint
smb_find_unicode_null_offset(tvbuff_t *tvb, gint offset, const gint maxlength, const guint16 needle, const guint encoding)
{
guint captured_length = tvb_captured_length(tvb);
if (G_LIKELY((guint) offset > captured_length)) {
return -1;
}
guint limit = captured_length - offset;
/* Only search to end of tvbuff, w/o throwing exception. */
if (maxlength >= 0 && limit > (guint) maxlength) {
/* Maximum length doesn't go past end of tvbuff; search
to that value. */
limit = (guint) maxlength;
}
limit = limit & ~1;
while(limit){
if (needle == tvb_get_guint16(tvb, offset, encoding)){
return offset;
}
offset += 2;
limit -= 2;
}
return -1;
}
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
End of request/response matching functions
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
/* Turn a little-endian Unicode '\0'-terminated string into a string we
can display.
If exactlen==TRUE then us_lenp contains the exact len of the string in
bytes. It might not be null terminated !
bc specifies the number of bytes in the byte parameters; Windows 2000,
at least, appears, in some cases, to put only 1 byte of 0 at the end
of a Unicode string if the byte count
*/
static gchar *
unicode_to_str(tvbuff_t *tvb, int offset, int *us_lenp, gboolean exactlen,
guint16 bc)
{
int len;
if (exactlen) {
return tvb_get_string_enc(wmem_packet_scope(), tvb, offset, *us_lenp, ENC_UTF_16|ENC_LITTLE_ENDIAN);
} else {
/* Handle the odd cases where Windows 2000 has a Unicode
* string followed by a single NUL byte when the string
* takes up the entire byte count.
*/
len = smb_find_unicode_null_offset(tvb, offset, bc, 0, ENC_LITTLE_ENDIAN);
if (len == -1) {
if (bc % 2 == 1 && tvb_get_guint8(tvb, offset + bc - 1) == 0) {
*us_lenp = bc;
return tvb_get_string_enc(wmem_packet_scope(), tvb, offset, bc - 1, ENC_UTF_16|ENC_LITTLE_ENDIAN);
}
}
return tvb_get_stringz_enc(wmem_packet_scope(), tvb, offset, us_lenp, ENC_UTF_16|ENC_LITTLE_ENDIAN);
}
}
/* nopad == TRUE : Do not add any padding before this string
* exactlen == TRUE : len contains the exact len of the string in bytes.
* bc: pointer to variable with amount of data left in the byte parameters
* region
*/
static const gchar *
get_unicode_or_ascii_string(tvbuff_t *tvb, int *offsetp,
gboolean useunicode, int *len, gboolean nopad, gboolean exactlen,
guint16 *bcp)
{
const gchar *string;
int string_len = 0;
int copylen;
if (*bcp == 0) {
/* Not enough data in buffer */
return NULL;
}
if (useunicode) {
if ((!nopad) && (*offsetp % 2)) {
(*offsetp)++; /* Looks like a pad byte there sometimes */
(*bcp)--;
if (*bcp == 0) {
/* Not enough data in buffer */
return NULL;
}
}
if(exactlen){
string_len = *len;
if (string_len < 0) {
/* This probably means it's a very large unsigned number; just set
it to the largest signed number, so that we throw the appropriate
exception. */
string_len = INT_MAX;
} else if (string_len > *bcp){
string_len = *bcp;
}
}
string = unicode_to_str(tvb, *offsetp, &string_len, exactlen, *bcp);
} else {
/* XXX: Use the local OEM (extended ASCII DOS) code page.
* On US English machines that means ENC_CP437, but it
* could be CP850 (which contains the characters of
* ISO-8859-1, arranged differently), CP866, etc.
* Using ENC_ASCII is safest.
*
* There could be a preference for local code page.
* (The same should apply in packet-smb-browser.c too)
*/
if(exactlen){
copylen = *len;
if (copylen < 0) {
/* This probably means it's a very large unsigned number; just set
it to the largest signed number, so that we throw the appropriate
exception. */
copylen = INT_MAX;
}
return tvb_get_string_enc(wmem_packet_scope(), tvb, *offsetp, copylen, ENC_ASCII);
} else {
return tvb_get_stringz_enc(wmem_packet_scope(), tvb, *offsetp, len, ENC_ASCII);
}
}
*len = string_len;
return string;
}
typedef struct _smb_uid_t {
char *domain;
char *account;
int logged_in;
int logged_out;
} smb_uid_t;
static void
smb_file_specific_rights(tvbuff_t *tvb, gint offset, proto_tree *tree, guint32 mask)
{
static int * const mask_flags[] = {
&hf_smb_file_access_mask_write_attribute,
&hf_smb_file_access_mask_read_attribute,
&hf_smb_file_access_mask_execute,
&hf_smb_file_access_mask_write_ea,
&hf_smb_file_access_mask_read_ea,
&hf_smb_file_access_mask_append_data,
&hf_smb_file_access_mask_write_data,
&hf_smb_file_access_mask_read_data,
NULL
};
mask &= 0x0000ffff;
if (mask == 0x000001ff) {
proto_tree_add_uint(tree, hf_smb_file_access_mask_full_control, tvb, offset, 4, mask);
}
proto_tree_add_bitmask_list_value(tree, tvb, offset, 4, mask_flags, mask);
}
static struct access_mask_info smb_file_access_mask_info = {
"FILE", /* Name of specific rights */
smb_file_specific_rights, /* Dissection function */
NULL, /* Generic mapping table */
NULL /* Standard mapping table */
};
static void
smb_dir_specific_rights(tvbuff_t *tvb, gint offset, proto_tree *tree, guint32 mask)
{
static int * const mask_flags[] = {
&hf_smb_dir_access_mask_write_attribute,
&hf_smb_dir_access_mask_read_attribute,
&hf_smb_dir_access_mask_delete_child,
&hf_smb_dir_access_mask_traverse,
&hf_smb_dir_access_mask_write_ea,
&hf_smb_dir_access_mask_read_ea,
&hf_smb_dir_access_mask_add_subdir,
&hf_smb_dir_access_mask_add_file,
&hf_smb_dir_access_mask_list,
NULL
};
mask &= 0x0000ffff;
if (mask == 0x000001ff) {
proto_tree_add_uint(tree, hf_smb_dir_access_mask_full_control, tvb, offset, 4, mask);
}
proto_tree_add_bitmask_list_value(tree, tvb, offset, 4, mask_flags, mask);
}
static struct access_mask_info smb_dir_access_mask_info = {
"DIR", /* Name of specific rights */
smb_dir_specific_rights, /* Dissection function */
NULL, /* Generic mapping table */
NULL /* Standard mapping table */
};
static const value_string buffer_format_vals[] = {
{1, "Data Block"},
{2, "Dialect"},
{3, "Pathname"},
{4, "ASCII"},
{5, "Variable Block"},
{0, NULL}
};
#define POSIX_ACE_TYPE_USER_OBJ 0x01
#define POSIX_ACE_TYPE_USER 0x02
#define POSIX_ACE_TYPE_GROUP_OBJ 0x04
#define POSIX_ACE_TYPE_GROUP 0x08
#define POSIX_ACE_TYPE_MASK 0x10
#define POSIX_ACE_TYPE_OTHER 0x20
static const value_string ace_type_vals[] = {
{POSIX_ACE_TYPE_USER_OBJ, "User Obj"},
{POSIX_ACE_TYPE_USER, "User"},
{POSIX_ACE_TYPE_GROUP_OBJ, "Group Obj"},
{POSIX_ACE_TYPE_GROUP, "Group"},
{POSIX_ACE_TYPE_MASK, "Mask"},
{POSIX_ACE_TYPE_OTHER, "Other"},
{0, NULL}
};
/*
* UTIME - this is *almost* like a UNIX time stamp, except that it's
* in seconds since January 1, 1970, 00:00:00 *local* time, not since
* January 1, 1970, 00:00:00 GMT.
*
* This means we have to do some extra work to convert it. This code is
* based on the Samba code:
*
* Unix SMB/Netbios implementation.
* Version 1.9.
* time handling functions
* Copyright (C) Andrew Tridgell 1992-1998
*/
/*
* Yield the difference between *A and *B, in seconds, ignoring leap
* seconds.
*/
#define TM_YEAR_BASE 1900
static int
tm_diff(struct tm *a, struct tm *b)
{
int ay = a->tm_year + (TM_YEAR_BASE - 1);
int by = b->tm_year + (TM_YEAR_BASE - 1);
int intervening_leap_days =
(ay/4 - by/4) - (ay/100 - by/100) + (ay/400 - by/400);
int years = ay - by;
int days =
365*years + intervening_leap_days + (a->tm_yday - b->tm_yday);
int hours = 24*days + (a->tm_hour - b->tm_hour);
int minutes = 60*hours + (a->tm_min - b->tm_min);
int seconds = 60*minutes + (a->tm_sec - b->tm_sec);
return seconds;
}
/*
* Return the UTC offset in seconds west of UTC, or 0 if it cannot be
* determined.
*/
static int
TimeZone(time_t t)
{
struct tm *tm = gmtime(&t);
struct tm tm_utc;
if (tm == NULL)
return 0;
tm_utc = *tm;
tm = localtime(&t);
if (tm == NULL)
return 0;
return tm_diff(&tm_utc, tm);
}
/*
* Return the same value as TimeZone, but it should be more efficient.
*
* We keep a table of DST offsets to prevent calling localtime() on each
* call of this function. This saves a LOT of time on many unixes.
*
* Updated by Paul Eggert <[email protected]>
*/
#ifndef CHAR_BIT
#define CHAR_BIT 8
#endif
#ifndef TIME_T_MIN
#define TIME_T_MIN ((time_t) ((time_t)0 < (time_t) -1 ? (time_t) 0 \
: ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1)))
#endif
#ifndef TIME_T_MAX
#define TIME_T_MAX ((time_t) (~ (time_t) 0 - TIME_T_MIN))
#endif
static int
TimeZoneFaster(time_t t)
{
static struct dst_table {time_t start, end; int zone;} *tdt;
static struct dst_table *dst_table = NULL;
static int table_size = 0;
int i;
int zone = 0;
if (t == 0)
t = time(NULL);
/* Tunis has a 8 day DST region, we need to be careful ... */
#define MAX_DST_WIDTH (365*24*60*60)
#define MAX_DST_SKIP (7*24*60*60)
for (i = 0; i < table_size; i++) {
if ((t >= dst_table[i].start) && (t <= dst_table[i].end))
break;
}
if (i < table_size) {
zone = dst_table[i].zone;
} else {
time_t low, high;
zone = TimeZone(t);
if (dst_table == NULL)
tdt = (struct dst_table *)g_malloc(sizeof(dst_table[0])*(i+1));
else
tdt = (struct dst_table *)g_realloc(dst_table, sizeof(dst_table[0])*(i+1));
if (tdt == NULL) {
g_free(dst_table);
table_size = 0;
} else {
dst_table = tdt;
table_size++;
dst_table[i].zone = zone;
dst_table[i].start = dst_table[i].end = t;
/* no entry will cover more than 6 months */
low = t - MAX_DST_WIDTH/2;
/* XXX - what if t < MAX_DST_WIDTH/2? */
high = t + MAX_DST_WIDTH/2;
/* XXX - what if this overflows? */
/*
* Widen the new entry using two bisection searches.
*/
while (low+60*60 < dst_table[i].start) {
if (dst_table[i].start - low > MAX_DST_SKIP*2)
t = dst_table[i].start - MAX_DST_SKIP;
else
t = low + (dst_table[i].start-low)/2;
if (TimeZone(t) == zone)
dst_table[i].start = t;
else
low = t;
}
while (high-60*60 > dst_table[i].end) {
if (high - dst_table[i].end > MAX_DST_SKIP*2)
t = dst_table[i].end + MAX_DST_SKIP;
else
t = high - (high-dst_table[i].end)/2;
if (TimeZone(t) == zone)
dst_table[i].end = t;
else
high = t;
}
}
}
return zone;
}
/*
* Return the UTC offset in seconds west of UTC, adjusted for extra time
* offset, for a local time value. If ut = lt + LocTimeDiff(lt), then
* lt = ut - TimeDiff(ut), but the converse does not necessarily hold near
* daylight savings transitions because some local times are ambiguous.
* LocTimeDiff(t) equals TimeDiff(t) except near daylight savings transitions.
*/
static int
LocTimeDiff(time_t lt)
{
int d = TimeZoneFaster(lt);
time_t t = lt + d;
/* if overflow occurred, ignore all the adjustments so far */
if (((t < lt) ^ (d < 0)))
t = lt;
/*
* Now t should be close enough to the true UTC to yield the
* right answer.
*/
return TimeZoneFaster(t);
}
static int
dissect_smb_UTIME(tvbuff_t *tvb, proto_tree *tree, int offset, int hf_date)
{
guint32 timeval;
nstime_t ts;
ts.secs = timeval = tvb_get_letohl(tvb, offset);
ts.nsecs = 0;
if (timeval == 0xffffffff) {
proto_tree_add_time_format_value(tree, hf_date, tvb, offset, 4, &ts,
"No time specified (0xffffffff)");
offset += 4;
return offset;
}
/*
* We add the local time offset.
*/
ts.secs = timeval + LocTimeDiff(timeval);
proto_tree_add_time(tree, hf_date, tvb, offset, 4, &ts);
offset += 4;
return offset;
}
static int
dissect_smb_datetime(tvbuff_t *tvb, proto_tree *parent_tree, int offset,
int hf_date, int hf_dos_date, int hf_dos_time, gboolean time_first)
{
guint16 dos_time, dos_date;
proto_item *item = NULL;
proto_tree *tree = NULL;
struct tm tm;
time_t t;
nstime_t tv;
static const int mday_noleap[12] = {
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
static const int mday_leap[12] = {
31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
#define ISLEAP(y) ((((y) % 4) == 0) && ((((y) % 100) != 0) || (((y) % 400) == 0)))
if (time_first) {
dos_time = tvb_get_letohs(tvb, offset);
dos_date = tvb_get_letohs(tvb, offset+2);
} else {
dos_date = tvb_get_letohs(tvb, offset);
dos_time = tvb_get_letohs(tvb, offset+2);
}
if (((dos_date == 0xffff) && (dos_time == 0xffff)) ||
((dos_date == 0) && (dos_time == 0))) {
/*
* No date/time specified.
*/
if (parent_tree) {
tv.secs = 0;
tv.nsecs = 0;
proto_tree_add_time_format_value(parent_tree, hf_date, tvb, offset, 4,
&tv, "No time specified (0x%08x)",
((dos_date << 16) | dos_time));
}
offset += 4;
return offset;
}
tm.tm_sec = (dos_time & 0x1f) * 2;
tm.tm_min = (dos_time>>5) & 0x3f;
tm.tm_hour = (dos_time>>11) & 0x1f;
tm.tm_mday = dos_date & 0x1f;
tm.tm_mon = ((dos_date>>5) & 0x0f) - 1;
tm.tm_year = ((dos_date>>9) & 0x7f) + 1980 - 1900;
tm.tm_isdst = -1;
/*
* Do some sanity checks before calling "mktime()";
* "mktime()" doesn't do them, it "normalizes" out-of-range
* values.
*/
if ((tm.tm_sec > 59) || (tm.tm_min > 59) || (tm.tm_hour > 23) ||
(tm.tm_mon < 0) || (tm.tm_mon > 11) ||
(ISLEAP(tm.tm_year + 1900) ?
(tm.tm_mday > mday_leap[tm.tm_mon]) :
(tm.tm_mday > mday_noleap[tm.tm_mon])) ||
((t = mktime(&tm)) == -1)) {
/*
* Invalid date/time.
*/
if (parent_tree) {
tv.secs = 0;
tv.nsecs = 0;
item = proto_tree_add_time_format_value(parent_tree, hf_date, tvb, offset, 4,
&tv, "Invalid time (0x%08x)", ((dos_date << 16) | dos_time));
tree = proto_item_add_subtree(item, ett_smb_time_date);
if (time_first) {
proto_tree_add_uint_format(tree, hf_dos_time, tvb, offset, 2, dos_time, "DOS Time: %02d:%02d:%02d (0x%04x)", tm.tm_hour, tm.tm_min, tm.tm_sec, dos_time);
proto_tree_add_uint_format(tree, hf_dos_date, tvb, offset+2, 2, dos_date, "DOS Date: %04d-%02d-%02d (0x%04x)", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, dos_date);
} else {
proto_tree_add_uint_format(tree, hf_dos_date, tvb, offset, 2, dos_date, "DOS Date: %04d-%02d-%02d (0x%04x)", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, dos_date);
proto_tree_add_uint_format(tree, hf_dos_time, tvb, offset+2, 2, dos_time, "DOS Time: %02d:%02d:%02d (0x%04x)", tm.tm_hour, tm.tm_min, tm.tm_sec, dos_time);
}
}
offset += 4;
return offset;
}
tv.secs = t;
tv.nsecs = 0;
if (parent_tree) {
item = proto_tree_add_time(parent_tree, hf_date, tvb, offset, 4, &tv);
tree = proto_item_add_subtree(item, ett_smb_time_date);
if (time_first) {
proto_tree_add_uint_format(tree, hf_dos_time, tvb, offset, 2, dos_time, "DOS Time: %02d:%02d:%02d (0x%04x)", tm.tm_hour, tm.tm_min, tm.tm_sec, dos_time);
proto_tree_add_uint_format(tree, hf_dos_date, tvb, offset+2, 2, dos_date, "DOS Date: %04d-%02d-%02d (0x%04x)", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, dos_date);
} else {
proto_tree_add_uint_format(tree, hf_dos_date, tvb, offset, 2, dos_date, "DOS Date: %04d-%02d-%02d (0x%04x)", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, dos_date);
proto_tree_add_uint_format(tree, hf_dos_time, tvb, offset+2, 2, dos_time, "DOS Time: %02d:%02d:%02d (0x%04x)", tm.tm_hour, tm.tm_min, tm.tm_sec, dos_time);
}
}
offset += 4;
return offset;
}
static const true_false_string tfs_disposition_delete_on_close = {
"DELETE this file when closed",
"Normal access, do not delete on close"
};
static const true_false_string tfs_pipe_info_flag = {
"SET NAMED PIPE mode",
"Clear NAMED PIPE mode"
};
static const value_string da_access_vals[] = {
{ 0, "Open for reading"},
{ 1, "Open for writing"},
{ 2, "Open for reading and writing"},
{ 3, "Open for execute"},
{0, NULL}
};
static const value_string da_sharing_vals[] = {
{ 0, "Compatibility mode"},
{ 1, "Deny read/write/execute (exclusive)"},
{ 2, "Deny write"},
{ 3, "Deny read/execute"},
{ 4, "Deny none"},
{0, NULL}
};
static const value_string da_locality_vals[] = {
{ 0, "Locality of reference unknown"},
{ 1, "Mainly sequential access"},
{ 2, "Mainly random access"},
{ 3, "Random access with some locality"},
{0, NULL}
};
static const true_false_string tfs_da_caching = {
"Do not cache this file",
"Caching permitted on this file"
};
static const true_false_string tfs_da_writetru = {
"Write through enabled",
"Write through disabled"
};
static int
dissect_access(tvbuff_t *tvb, proto_tree *parent_tree, int offset, int hf_access)
{
static int * const flags[] = {
&hf_smb_access_writetru,
&hf_smb_access_caching,
&hf_smb_access_locality,
&hf_smb_access_sharing,
&hf_smb_access_mode,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_access, ett_smb_desiredaccess, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
#define SMB_FILE_ATTRIBUTE_READ_ONLY 0x00000001
#define SMB_FILE_ATTRIBUTE_HIDDEN 0x00000002
#define SMB_FILE_ATTRIBUTE_SYSTEM 0x00000004
#define SMB_FILE_ATTRIBUTE_VOLUME 0x00000008
#define SMB_FILE_ATTRIBUTE_DIRECTORY 0x00000010
#define SMB_FILE_ATTRIBUTE_ARCHIVE 0x00000020
#define SMB_FILE_ATTRIBUTE_DEVICE 0x00000040
#define SMB_FILE_ATTRIBUTE_NORMAL 0x00000080
#define SMB_FILE_ATTRIBUTE_TEMPORARY 0x00000100
#define SMB_FILE_ATTRIBUTE_SPARSE 0x00000200
#define SMB_FILE_ATTRIBUTE_REPARSE 0x00000400
#define SMB_FILE_ATTRIBUTE_COMPRESSED 0x00000800
#define SMB_FILE_ATTRIBUTE_OFFLINE 0x00001000
#define SMB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
#define SMB_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
static const true_false_string tfs_file_attribute_read_only = {
"READ ONLY",
"NOT read only",
};
static const true_false_string tfs_file_attribute_hidden = {
"HIDDEN",
"NOT hidden"
};
static const true_false_string tfs_file_attribute_system = {
"SYSTEM file/dir",
"NOT a system file/dir"
};
static const true_false_string tfs_file_attribute_volume = {
"VOLUME ID",
"NOT a volume ID"
};
static const true_false_string tfs_file_attribute_directory = {
"DIRECTORY",
"NOT a directory"
};
static const true_false_string tfs_file_attribute_archive = {
"Modified since last ARCHIVE",
"Has NOT been modified since last archive"
};
static const true_false_string tfs_file_attribute_device = {
"A DEVICE",
"NOT a device"
};
static const true_false_string tfs_file_attribute_normal = {
"An ordinary file/dir",
"Has some attribute set"
};
static const true_false_string tfs_file_attribute_temporary = {
"A TEMPORARY file",
"NOT a temporary file"
};
static const true_false_string tfs_file_attribute_sparse = {
"A SPARSE file",
"NOT a sparse file"
};
static const true_false_string tfs_file_attribute_reparse = {
"Has an associated REPARSE POINT",
"Does NOT have an associated reparse point"
};
static const true_false_string tfs_file_attribute_compressed = {
"COMPRESSED",
"Uncompressed"
};
static const true_false_string tfs_file_attribute_offline = {
"OFFLINE",
"Online"
};
static const true_false_string tfs_file_attribute_not_content_indexed = {
"CONTENT INDEXED",
"NOT content indexed"
};
static const true_false_string tfs_file_attribute_encrypted = {
"This is an ENCRYPTED file",
"This is NOT an encrypted file"
};
/*
* Dissects an SMB_FILE_ATTRIBUTES, to use the term given to it by
* section 2.2.1.2.4 of [MS-CIFS], in cases where it's just file attributes,
* not search attributes.
*/
static int
dissect_file_attributes(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_file_attr_archive_16bit,
&hf_smb_file_attr_directory_16bit,
&hf_smb_file_attr_volume_16bit,
&hf_smb_file_attr_system_16bit,
&hf_smb_file_attr_hidden_16bit,
&hf_smb_file_attr_read_only_16bit,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_file_attr_16bit, ett_smb_file_attributes, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
/*
* 3.11 in the SNIA CIFS spec
* SMB_EXT_FILE_ATTR, section 2.2.1.2.3 in the [MS-CIFS] spec
*/
static int
dissect_file_ext_attr_bits(tvbuff_t *tvb, proto_tree *parent_tree, int offset,
int len, guint32 mask)
{
proto_item *item;
/*
* XXX - Network Monitor disagrees on some of the
* bits, e.g. the bits above temporary are "atomic write"
* and "transaction write", and it says nothing about the
* bits above that.
*
* Does the Win32 API documentation, or the NT Native API book,
* suggest anything?
*/
static int * const mask_fields[] = {
&hf_smb_file_eattr_read_only,
&hf_smb_file_eattr_hidden,
&hf_smb_file_eattr_system,
&hf_smb_file_eattr_volume,
&hf_smb_file_eattr_directory,
&hf_smb_file_eattr_archive,
&hf_smb_file_eattr_device,
&hf_smb_file_eattr_normal,
&hf_smb_file_eattr_temporary,
&hf_smb_file_eattr_sparse,
&hf_smb_file_eattr_reparse,
&hf_smb_file_eattr_compressed,
&hf_smb_file_eattr_offline,
&hf_smb_file_eattr_not_content_indexed,
&hf_smb_file_eattr_encrypted,
NULL
};
item = proto_tree_add_bitmask_value_with_flags(parent_tree, tvb, offset,
hf_smb_file_eattr, ett_smb_file_attributes, mask_fields, mask, BMT_NO_APPEND);
if (len == 0)
proto_item_set_generated(item);
offset += len;
return offset;
}
/* 3.11 */
static int
dissect_file_ext_attr(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
guint32 mask;
mask = tvb_get_letohl(tvb, offset);
offset = dissect_file_ext_attr_bits(tvb, parent_tree, offset, 4, mask);
return offset;
}
static int
dissect_dir_info_file_attributes(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_file_attr_read_only_8bit,
&hf_smb_file_attr_hidden_8bit,
&hf_smb_file_attr_system_8bit,
&hf_smb_file_attr_volume_8bit,
&hf_smb_file_attr_directory_8bit,
&hf_smb_file_attr_archive_8bit,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_file_attr_8bit, ett_smb_file_attributes, flags, ENC_NA);
offset += 1;
return offset;
}
static const true_false_string tfs_search_attribute_read_only = {
"Include READ ONLY files in search results",
"Do NOT include read only files in search results",
};
static const true_false_string tfs_search_attribute_hidden = {
"Include HIDDEN files in search results",
"Do NOT include hidden files in search results"
};
static const true_false_string tfs_search_attribute_system = {
"Include SYSTEM files in search results",
"Do NOT include system files in search results"
};
static const true_false_string tfs_search_attribute_volume = {
"Include VOLUME IDs in search results",
"Do NOT include volume IDs in search results"
};
static const true_false_string tfs_search_attribute_directory = {
"Include DIRECTORIES in search results",
"Do NOT include directories in search results"
};
static const true_false_string tfs_search_attribute_archive = {
"Include ARCHIVE files in search results",
"Do NOT include archive files in search results"
};
/*
* Dissects an SMB_FILE_ATTRIBUTES, to use the term given to it by
* section 2.2.1.2.4 of [MS-CIFS], in cases where it's search attributes.
*/
static int
dissect_search_attributes(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_search_attribute_read_only,
&hf_smb_search_attribute_hidden,
&hf_smb_search_attribute_system,
&hf_smb_search_attribute_volume,
&hf_smb_search_attribute_directory,
&hf_smb_search_attribute_archive,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_search_attribute, ett_smb_search, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
#if 0
/*
* XXX - this isn't used.
* Is this used for anything? NT Create AndX doesn't use it.
* Is there some 16-bit attribute field with more bits than Read Only,
* Hidden, System, Volume ID, Directory, and Archive?
*/
static int
dissect_extended_file_attributes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_file_attr_read_only_16bit,
&hf_smb_file_attr_hidden_16bit,
&hf_smb_file_attr_system_16bit,
&hf_smb_file_attr_volume_16bit,
&hf_smb_file_attr_directory_16bit,
&hf_smb_file_attr_archive_16bit,
&hf_smb_file_attr_device,
&hf_smb_file_attr_normal,
&hf_smb_file_attr_temporary,
&hf_smb_file_attr_sparse,
&hf_smb_file_attr_reparse,
&hf_smb_file_attr_compressed,
&hf_smb_file_attr_offline,
&hf_smb_file_attr_not_content_indexed,
&hf_smb_file_attr_encrypted,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_file_eattr, ett_smb_file_attributes, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
#endif
#define SERVER_CAP_RAW_MODE 0x00000001
#define SERVER_CAP_MPX_MODE 0x00000002
#define SERVER_CAP_UNICODE 0x00000004
#define SERVER_CAP_LARGE_FILES 0x00000008
#define SERVER_CAP_NT_SMBS 0x00000010
#define SERVER_CAP_RPC_REMOTE_APIS 0x00000020
#define SERVER_CAP_STATUS32 0x00000040
#define SERVER_CAP_LEVEL_II_OPLOCKS 0x00000080
#define SERVER_CAP_LOCK_AND_READ 0x00000100
#define SERVER_CAP_NT_FIND 0x00000200
#define SERVER_CAP_DFS 0x00001000
#define SERVER_CAP_INFOLEVEL_PASSTHRU 0x00002000
#define SERVER_CAP_LARGE_READX 0x00004000
#define SERVER_CAP_LARGE_WRITEX 0x00008000
#define SERVER_CAP_LWIO 0x00010000
#define SERVER_CAP_UNIX 0x00800000
#define SERVER_CAP_COMPRESSED_DATA 0x02000000
#define SERVER_CAP_DYNAMIC_REAUTH 0x20000000
#define SERVER_CAP_EXTENDED_SECURITY 0x80000000
static const true_false_string tfs_server_cap_raw_mode = {
"Read Raw and Write Raw are supported",
"Read Raw and Write Raw are not supported"
};
static const true_false_string tfs_server_cap_mpx_mode = {
"Read Mpx and Write Mpx are supported",
"Read Mpx and Write Mpx are not supported"
};
static const true_false_string tfs_server_cap_unicode = {
"Unicode strings are supported",
"Unicode strings are not supported"
};
static const true_false_string tfs_server_cap_large_files = {
"Large files are supported",
"Large files are not supported",
};
static const true_false_string tfs_server_cap_nt_smbs = {
"NT SMBs are supported",
"NT SMBs are not supported"
};
static const true_false_string tfs_server_cap_rpc_remote_apis = {
"RPC remote APIs are supported",
"RPC remote APIs are not supported"
};
static const true_false_string tfs_server_cap_nt_status = {
"NT status codes are supported",
"NT status codes are not supported"
};
static const true_false_string tfs_server_cap_level_ii_oplocks = {
"Level 2 oplocks are supported",
"Level 2 oplocks are not supported"
};
static const true_false_string tfs_server_cap_lock_and_read = {
"Lock and Read is supported",
"Lock and Read is not supported"
};
static const true_false_string tfs_server_cap_nt_find = {
"NT Find is supported",
"NT Find is not supported"
};
static const true_false_string tfs_server_cap_dfs = {
"Dfs is supported",
"Dfs is not supported"
};
static const true_false_string tfs_server_cap_infolevel_passthru = {
"NT information level request passthrough is supported",
"NT information level request passthrough is not supported"
};
static const true_false_string tfs_server_cap_large_readx = {
"Large Read andX is supported",
"Large Read andX is not supported"
};
static const true_false_string tfs_server_cap_large_writex = {
"Large Write andX is supported",
"Large Write andX is not supported"
};
static const true_false_string tfs_server_cap_lwio = {
"LWIO ioctl/fsctl is supported",
"LWIO ioctl/fsctl is not supported"
};
static const true_false_string tfs_server_cap_unix = {
"UNIX extensions are supported",
"UNIX extensions are not supported"
};
static const true_false_string tfs_server_cap_compressed_data = {
"Compressed data transfer is supported",
"Compressed data transfer is not supported"
};
static const true_false_string tfs_server_cap_dynamic_reauth = {
"Dynamic Reauth is supported",
"Dynamic Reauth is not supported"
};
static const true_false_string tfs_server_cap_extended_security = {
"Extended security exchanges are supported",
"Extended security exchanges are not supported"
};
static int
dissect_negprot_capabilities(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
guint32 mask;
static int * const flags[] = {
&hf_smb_server_cap_raw_mode,
&hf_smb_server_cap_mpx_mode,
&hf_smb_server_cap_unicode,
&hf_smb_server_cap_large_files,
&hf_smb_server_cap_nt_smbs,
&hf_smb_server_cap_rpc_remote_apis,
&hf_smb_server_cap_nt_status,
&hf_smb_server_cap_level_ii_oplocks,
&hf_smb_server_cap_lock_and_read,
&hf_smb_server_cap_nt_find,
&hf_smb_server_cap_dfs,
&hf_smb_server_cap_infolevel_passthru,
&hf_smb_server_cap_large_readx,
&hf_smb_server_cap_large_writex,
&hf_smb_server_cap_lwio,
&hf_smb_server_cap_unix,
&hf_smb_server_cap_compressed_data,
&hf_smb_server_cap_dynamic_reauth,
&hf_smb_server_cap_extended_security,
NULL
};
mask = tvb_get_letohl(tvb, offset);
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_server_cap, ett_smb_capabilities, flags, ENC_LITTLE_ENDIAN);
return mask;
}
#define RAWMODE_READ 0x0001
#define RAWMODE_WRITE 0x0002
static const true_false_string tfs_rm_read = {
"Read Raw is supported",
"Read Raw is not supported"
};
static const true_false_string tfs_rm_write = {
"Write Raw is supported",
"Write Raw is not supported"
};
static int
dissect_negprot_rawmode(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_rm_read,
&hf_smb_rm_write,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_rm, ett_smb_rawmode, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
#define SECURITY_MODE_MODE 0x01
#define SECURITY_MODE_PASSWORD 0x02
#define SECURITY_MODE_SIGNATURES 0x04
#define SECURITY_MODE_SIG_REQUIRED 0x08
static const true_false_string tfs_sm_mode = {
"USER security mode",
"SHARE security mode"
};
static const true_false_string tfs_sm_password = {
"ENCRYPTED password. Use challenge/response",
"PLAINTEXT password"
};
static const true_false_string tfs_sm_signatures = {
"Security signatures ENABLED",
"Security signatures NOT enabled"
};
static const true_false_string tfs_sm_sig_required = {
"Security signatures REQUIRED",
"Security signatures NOT required"
};
static int
dissect_negprot_security_mode(tvbuff_t *tvb, proto_tree *parent_tree, int offset, int wc)
{
static int * const flags13[] = {
&hf_smb_sm_mode16,
&hf_smb_sm_password16,
NULL
};
static int * const flags17[] = {
&hf_smb_sm_mode,
&hf_smb_sm_password,
&hf_smb_sm_signatures,
&hf_smb_sm_sig_required,
NULL
};
switch(wc) {
case 13:
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_sm16, ett_smb_mode, flags13, ENC_LITTLE_ENDIAN);
offset += 2;
break;
case 17:
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_sm, ett_smb_mode, flags17, ENC_LITTLE_ENDIAN);
offset += 1;
break;
}
return offset;
}
#define MAX_DIALECTS 20
struct negprot_dialects {
int num;
char *name[MAX_DIALECTS+1];
};
static int
dissect_negprot_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
proto_tree *tr = NULL;
proto_item *ti;
guint16 bc;
guint8 wc;
struct negprot_dialects *dialects = NULL;
DISSECTOR_ASSERT(si);
WORD_COUNT;
BYTE_COUNT;
tr = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb_dialects, &ti, "Requested Dialects");
if (!pinfo->fd->visited && si->sip) {
dialects = wmem_new(wmem_file_scope(), struct negprot_dialects);
dialects->num = 0;
si->sip->extra_info_type = SMB_EI_DIALECTS;
si->sip->extra_info = dialects;
}
while (bc) {
int len;
const guint8 *str;
proto_item *dit = NULL;
proto_tree *dtr = NULL;
/* XXX - what if this runs past bc? */
tvb_ensure_bytes_exist(tvb, offset+1, 1);
/* XXX: This is an OEM String according to MS-CIFS and
* should use the local OEM (extended ASCII DOS) code page,
* It doesn't appear than any known dialect strings use
* anything outside ASCII, though.
*
* There could be a dissector preference for local code page.
*/
str = tvb_get_stringz_enc(pinfo->pool, tvb, offset+1, &len, ENC_ASCII);
if (tr) {
dit = proto_tree_add_string(tr, hf_smb_dialect, tvb, offset, len+1, str);
dtr = proto_item_add_subtree(dit, ett_smb_dialect);
}
/* Buffer Format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(dtr, hf_smb_buffer_format, tvb, offset, 1,
ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/*Dialect Name */
CHECK_BYTE_COUNT(len);
proto_tree_add_item(dtr, hf_smb_dialect_name, tvb,
offset, len, ENC_ASCII);
COUNT_BYTES(len);
if (!pinfo->fd->visited && dialects && (dialects->num < MAX_DIALECTS)) {
dialects->name[dialects->num++] = wmem_strdup(wmem_file_scope(), str);
}
}
proto_item_set_len(ti, bc);
END_OF_SMB
return offset;
}
static int
dissect_negprot_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 dialect;
const char *dn;
int dn_len;
guint16 bc;
guint16 chl = 0;
guint32 caps = 0;
gint16 tz;
const char *dialect_name = NULL;
struct negprot_dialects *dialects = NULL;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* Dialect Index */
dialect = tvb_get_letohs(tvb, offset);
if (si->sip && (si->sip->extra_info_type == SMB_EI_DIALECTS)) {
dialects = (struct negprot_dialects *)si->sip->extra_info;
if (dialect < dialects->num) {
dialect_name = dialects->name[dialect];
}
}
if (!dialect_name) {
dialect_name = "unknown";
}
switch(wc) {
case 1:
if (dialect == 0xffff) {
/*
* Server doesn't support any of the dialects the
* client listed.
*/
proto_tree_add_uint_format_value(tree, hf_smb_dialect_index,
tvb, offset, 2, dialect,
"-1, server does not support any of the listed dialects");
} else {
/*
* A dialect was selected; this should be
* Core Protocol.
*/
proto_tree_add_uint(tree, hf_smb_dialect_index,
tvb, offset, 2, dialect);
}
break;
case 13:
/*
* Server selected a dialect from LAN Manager 1.0 through
* LAN Manager 2.1.
*/
proto_tree_add_uint_format_value(tree, hf_smb_dialect_index,
tvb, offset, 2, dialect,
"%u, Greater than CORE PROTOCOL and up to LANMAN2.1", dialect);
break;
case 17:
/*
* Server selected NT LAN Manager.
*/
proto_tree_add_uint_format_value(tree, hf_smb_dialect_index,
tvb, offset, 2, dialect,
"%u: %s", dialect, dialect_name);
break;
default:
proto_tree_add_item(tree, hf_smb_word_unk_response_format, tvb, offset, wc*2, ENC_NA);
offset += wc*2;
goto bytecount;
}
offset += 2;
switch(wc) {
case 13:
/*
* Server selected a dialect from LAN Manager 1.0 through
* LAN Manager 2.1.
*/
/* Security Mode */
offset = dissect_negprot_security_mode(tvb, tree, offset, wc);
/* Maximum Transmit Buffer Size */
proto_tree_add_item(tree, hf_smb_max_trans_buf_size,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* Maximum Multiplex Count */
proto_tree_add_item(tree, hf_smb_max_mpx_count,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* Maximum Vcs Number */
proto_tree_add_item(tree, hf_smb_max_vcs_num,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* raw mode */
offset = dissect_negprot_rawmode(tvb, tree, offset);
/* session key */
proto_tree_add_item(tree, hf_smb_session_key,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* current time and date at server */
offset = dissect_smb_datetime(tvb, tree, offset, hf_smb_server_date_time, hf_smb_server_smb_date, hf_smb_server_smb_time,
TRUE);
/* time zone */
tz = tvb_get_letohs(tvb, offset);
proto_tree_add_int_format_value(tree, hf_smb_server_timezone, tvb, offset, 2, tz, "%d min from UTC", tz);
offset += 2;
/*
* The LAN Manager 1 and 2.0 specs say these are the
* first 2 of 4 reserved bytes; the LAN Manager 2.1
* spec says it's a 2-byte encryption key (challenge)
* length.
*/
chl = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_challenge_length, tvb, offset, 2, chl);
offset += 2;
/* 2 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
break;
case 17:
/*
* Server selected NT LAN Manager.
*/
/* Security Mode */
offset = dissect_negprot_security_mode(tvb, tree, offset, wc);
/* Maximum Multiplex Count */
proto_tree_add_item(tree, hf_smb_max_mpx_count,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* Maximum Vcs Number */
proto_tree_add_item(tree, hf_smb_max_vcs_num,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* Maximum Transmit Buffer Size */
proto_tree_add_item(tree, hf_smb_max_trans_buf_size,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* maximum raw buffer size */
proto_tree_add_item(tree, hf_smb_max_raw_buf_size,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* session key */
proto_tree_add_item(tree, hf_smb_session_key,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* server capabilities */
caps = dissect_negprot_capabilities(tvb, tree, offset);
offset += 4;
/* system time */
offset = dissect_nt_64bit_time(tvb, tree, offset,
hf_smb_system_time);
/* time zone */
tz = tvb_get_letohs(tvb, offset);
proto_tree_add_int_format_value(tree, hf_smb_server_timezone,
tvb, offset, 2, tz,
"%d min from UTC", tz);
offset += 2;
/* challenge length */
chl = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_smb_challenge_length,
tvb, offset, 1, chl);
offset += 1;
break;
}
BYTE_COUNT;
switch(wc) {
case 13:
/*
* Server selected a dialect from LAN Manager 1.0 through
* LAN Manager 2.1.
*/
/* encrypted challenge/response data */
if (chl) {
CHECK_BYTE_COUNT(chl);
proto_tree_add_item(tree, hf_smb_challenge, tvb, offset, chl, ENC_NA);
COUNT_BYTES(chl);
}
/*
* Primary domain.
*
* XXX - not present if negotiated dialect isn't
* "DOS LANMAN 2.1" or "LANMAN2.1", but we'd either
* have to see the request, or assume what dialect strings
* were sent, to determine that.
*
* Is this something other than a primary domain if the
* negotiated dialect is Windows for Workgroups 3.1a?
* It appears to be 8 bytes of binary data in at least
* one capture - is that an encryption key or something
* such as that?
*/
dn = get_unicode_or_ascii_string(tvb, &offset,
si->unicode, &dn_len, FALSE, FALSE, &bc);
if (dn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_primary_domain, tvb,
offset, dn_len, dn);
COUNT_BYTES(dn_len);
break;
case 17:
/*
* Server selected NT LAN Manager.
*/
if (!(caps & SERVER_CAP_EXTENDED_SECURITY)) {
/* encrypted challenge/response data */
/* XXX - is this aligned on an even boundary? */
if (chl) {
CHECK_BYTE_COUNT(chl);
proto_tree_add_item(tree, hf_smb_challenge,
tvb, offset, chl, ENC_NA);
COUNT_BYTES(chl);
}
/* domain */
/*
* This string is special; at least in some captures,
* it's in Unicode, even if "Unicode strings" isn't
* set in the flags2 field. If the "Unicode support"
* flag is set in the server capabilities field,
* that seems to indicate that it's in Unicode for
* those captures.
*
* So fetch it in Unicode either if it's set in the
* flags2 field *or* in the capabilities field.
*
* XXX - I've seen captures where "Unicode strings"
* isn't set, "Unicode support" is set in the server
* capabilities field, and the primary domain string
* is in the local code page; that may just have
* a buggy server, though.
*
* Clients tend, at least according to the
* footnote in MS-CIFS for the DomainName field
* in the Negotiate response, to ignore that
* field, so maybe servers put extra bytes in
* there without clients noticing.
*/
si->unicode = (caps & SERVER_CAP_UNICODE) || si->unicode;
/*
* If we're fetching Unicode strings:
*
* This string is NOT padded to be 16-bit
* aligned; it's unaligned in some captures.
*
* However, it sometimes has an extra byte
* before it. If the byte count is not a
* multiple of 2, there must be an extra byte
* somewhere; it appears to be the byte just
* before this string, so check for an odd
* byte count, and skip that byte.
*
* If we're fetching local code page strings:
*
* In some cases there appears to be an extra
* byte before it. It's not clear what
* indicates its presence, if anything.
*
* However, at least one of those cases
* was one of the "the server set the
* Unicode support flag in capabilities,
* but sent the domain name in the local
* code page" captures mentioned above,
* so maybe it was just a buggy server.
*
* Again, as noted above, clients may just
* ignore that field, leaving servers "free"
* to mess it up.
*/
if (si->unicode && (bc % 2) != 0) {
/* Skip the padding */
CHECK_BYTE_COUNT(1);
COUNT_BYTES(1);
}
dn = get_unicode_or_ascii_string(tvb,
&offset, si->unicode, &dn_len, TRUE, FALSE,
&bc);
if (dn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_primary_domain,
tvb, offset, dn_len, dn);
COUNT_BYTES(dn_len);
/* server name, seen in w2k pro capture */
dn = get_unicode_or_ascii_string(tvb,
&offset, si->unicode, &dn_len, TRUE, FALSE,
&bc);
if (dn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_server,
tvb, offset, dn_len, dn);
COUNT_BYTES(dn_len);
} else {
proto_item *blob_item;
guint16 sbloblen;
/* guid */
/* XXX - show it in the standard Microsoft format
for GUIDs? */
CHECK_BYTE_COUNT(16);
proto_tree_add_item(tree, hf_smb_server_guid,
tvb, offset, 16, ENC_NA);
COUNT_BYTES(16);
/* security blob */
/* If it runs past the end of the captured data, don't
* try to put all of it into the protocol tree as the
* raw security blob; we might get an exception on
* short frames and then we will not see anything at all
* of the security blob.
*/
sbloblen = bc;
if (sbloblen > tvb_reported_length_remaining(tvb, offset)) {
sbloblen = tvb_reported_length_remaining(tvb, offset);
}
blob_item = proto_tree_add_item(
tree, hf_smb_security_blob,
tvb, offset, sbloblen, ENC_NA);
/*
* If Extended security and BCC == 16, then raw
* NTLMSSP is in use. We need to save this info
*/
if (bc) {
tvbuff_t *gssapi_tvb;
proto_tree *gssapi_tree;
gssapi_tree = proto_item_add_subtree(
blob_item, ett_smb_secblob);
/*
* Set the reported length of this to
* the reported length of the blob,
* rather than the amount of data
* available from the blob, so that
* we'll throw the right exception if
* it's too short.
*/
gssapi_tvb = tvb_new_subset_length_caplen(
tvb, offset, sbloblen, bc);
call_dissector(
gssapi_handle, gssapi_tvb, pinfo,
gssapi_tree);
if (si->ct)
si->ct->raw_ntlmssp = 0;
COUNT_BYTES(bc);
}
else {
/*
* There is no blob. We just have to make sure
* that subsequent routines know to call the
* right things ...
*/
if (si->ct)
si->ct->raw_ntlmssp = 1;
}
}
break;
}
END_OF_SMB
return offset;
}
static int
dissect_old_dir_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
int dn_len;
const char *dn;
guint8 wc;
guint16 bc;
DISSECTOR_ASSERT(si);
WORD_COUNT;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* dir name */
dn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &dn_len,
FALSE, FALSE, &bc);
if ((!pinfo->fd->visited) && si->sip) {
si->sip->extra_info_type = SMB_EI_FILENAME;
si->sip->extra_info = wmem_strdup(wmem_file_scope(), dn);
}
if (dn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_dir_name, tvb, offset, dn_len,
dn);
COUNT_BYTES(dn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Directory: %s",
format_text(wmem_packet_scope(), (const guchar *)dn, strlen(dn)));
END_OF_SMB
return offset;
}
static int
dissect_empty(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc;
proto_item *item = NULL;
DISSECTOR_ASSERT(si);
if (si->sip && (si->sip->extra_info_type == SMB_EI_FILENAME)) {
item = proto_tree_add_string(tree, hf_smb_file_name, tvb, 0, 0, (const char *)si->sip->extra_info);
proto_item_set_generated(item);
}
WORD_COUNT;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_rename_file_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc;
proto_item *item = NULL;
DISSECTOR_ASSERT(si);
if (si->sip && (si->sip->extra_info_type == SMB_EI_RENAMEDATA)) {
smb_rename_saved_info_t *rni = (smb_rename_saved_info_t *)si->sip->extra_info;
item = proto_tree_add_string(tree, hf_smb_old_file_name, tvb, 0, 0, rni->old_name);
proto_item_set_generated(item);
item = proto_tree_add_string(tree, hf_smb_file_name, tvb, 0, 0, rni->new_name);
proto_item_set_generated(item);
}
WORD_COUNT;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_echo_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint16 ec, bc;
guint8 wc;
WORD_COUNT;
/* echo count */
ec = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_echo_count, tvb, offset, 2, ec);
offset += 2;
BYTE_COUNT;
if (bc != 0) {
/* echo data */
proto_tree_add_item(tree, hf_smb_echo_data, tvb, offset, bc, ENC_NA);
COUNT_BYTES(bc);
}
END_OF_SMB
return offset;
}
static int
dissect_echo_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint16 bc;
guint8 wc;
WORD_COUNT;
/* echo sequence number */
proto_tree_add_item(tree, hf_smb_echo_seq_num, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
BYTE_COUNT;
if (bc != 0) {
/* echo data */
proto_tree_add_item(tree, hf_smb_echo_data, tvb, offset, bc, ENC_NA);
COUNT_BYTES(bc);
}
END_OF_SMB
return offset;
}
static int
dissect_tree_connect_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
int an_len, pwlen;
const char *an;
guint8 wc;
guint16 bc;
DISSECTOR_ASSERT(si);
WORD_COUNT;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* Path */
an = get_unicode_or_ascii_string(tvb, &offset,
si->unicode, &an_len, FALSE, FALSE, &bc);
if (an == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_path, tvb,
offset, an_len, an);
COUNT_BYTES(an_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Path: %s",
format_text(wmem_packet_scope(), (const guchar*)an, strlen(an)));
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* password, ANSI */
/* XXX - what if this runs past bc? */
pwlen = tvb_strsize(tvb, offset);
CHECK_BYTE_COUNT(pwlen);
proto_tree_add_item(tree, hf_smb_password,
tvb, offset, pwlen, ENC_NA);
COUNT_BYTES(pwlen);
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* Service */
/*
* XXX - the SNIA CIFS spec "Strings that are never passed in
* Unicode are: ... The service name string in the
* Tree_Connect_AndX SMB". Is that claim false?
*/
an = get_unicode_or_ascii_string(tvb, &offset,
si->unicode, &an_len, FALSE, FALSE, &bc);
if (an == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_service, tvb,
offset, an_len, an);
COUNT_BYTES(an_len);
END_OF_SMB
return offset;
}
static int
dissect_smb_uid(tvbuff_t *tvb, proto_tree *parent_tree, int offset, smb_info_t *si)
{
proto_item *item, *subitem;
proto_tree *tree;
smb_uid_t *smb_uid = NULL;
item = proto_tree_add_uint(parent_tree, hf_smb_uid, tvb, offset, 2, si->uid);
tree = proto_item_add_subtree(item, ett_smb_uid);
smb_uid = (smb_uid_t *)wmem_tree_lookup32(si->ct->uid_tree, si->uid);
if (smb_uid) {
if (smb_uid->domain && smb_uid->account)
proto_item_append_text(item, " (");
if (smb_uid->domain) {
proto_item_append_text(item, "%s", smb_uid->domain);
subitem = proto_tree_add_string(tree, hf_smb_primary_domain, tvb, 0, 0, smb_uid->domain);
proto_item_set_generated(subitem);
}
if (smb_uid->account) {
proto_item_append_text(item, "\\%s", smb_uid->account);
subitem = proto_tree_add_string(tree, hf_smb_account, tvb, 0, 0, smb_uid->account);
proto_item_set_generated(subitem);
}
if (smb_uid->domain && smb_uid->account)
proto_item_append_text(item, ")");
if (smb_uid->logged_in > 0) {
subitem = proto_tree_add_uint(tree, hf_smb_logged_in, tvb, 0, 0, smb_uid->logged_in);
proto_item_set_generated(subitem);
}
if (smb_uid->logged_out > 0) {
subitem = proto_tree_add_uint(tree, hf_smb_logged_out, tvb, 0, 0, smb_uid->logged_out);
proto_item_set_generated(subitem);
}
}
offset += 2;
return offset;
}
static int
dissect_smb_tid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint16 tid, gboolean is_created, gboolean is_closed, smb_info_t *si)
{
proto_item *it;
proto_tree *tr;
smb_tid_info_t *tid_info = NULL;
DISSECTOR_ASSERT(si);
/* tid */
it = proto_tree_add_uint(tree, hf_smb_tid, tvb, offset, 2, tid);
tr = proto_item_add_subtree(it, ett_smb_tid);
offset += 2;
if ((!pinfo->fd->visited) && is_created) {
tid_info = wmem_new(wmem_file_scope(), smb_tid_info_t);
tid_info->opened_in = pinfo->num;
tid_info->closed_in = 0;
tid_info->type = SMB_FID_TYPE_UNKNOWN;
if (si->sip && (si->sip->extra_info_type == SMB_EI_TIDNAME)) {
tid_info->filename = (char *)si->sip->extra_info;
} else {
tid_info->filename = NULL;
}
wmem_tree_insert32(si->ct->tid_tree, tid, tid_info);
}
if (!tid_info) {
tid_info = (smb_tid_info_t *)wmem_tree_lookup32_le(si->ct->tid_tree, tid);
}
if (!tid_info) {
return offset;
}
if ((!pinfo->fd->visited) && is_closed) {
tid_info->closed_in = pinfo->num;
}
if (tid_info->opened_in) {
if (tid_info->filename) {
proto_item_append_text(it, " (%s)", tid_info->filename);
it = proto_tree_add_string(tr, hf_smb_path, tvb, 0, 0, tid_info->filename);
proto_item_set_generated(it);
}
it = proto_tree_add_uint(tr, hf_smb_mapped_in, tvb, 0, 0, tid_info->opened_in);
proto_item_set_generated(it);
}
if (tid_info->closed_in) {
it = proto_tree_add_uint(tr, hf_smb_unmapped_in, tvb, 0, 0, tid_info->closed_in);
proto_item_set_generated(it);
}
return offset;
}
static int
dissect_tree_connect_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc;
WORD_COUNT;
/* Maximum Buffer Size */
proto_tree_add_item(tree, hf_smb_max_buf_size, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* tid */
offset = dissect_smb_tid(tvb, pinfo, tree, offset, tvb_get_letohs(tvb, offset), TRUE, FALSE, si);
BYTE_COUNT;
END_OF_SMB
return offset;
}
static const true_false_string tfs_of_create = {
"Create file if it does not exist",
"Fail if file does not exist"
};
static const value_string of_open[] = {
{ 0, "Fail if file exists"},
{ 1, "Open file if it exists"},
{ 2, "Truncate file if it exists"},
{0, NULL}
};
static int
dissect_open_function(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_open_function_create,
&hf_smb_open_function_open,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_open_function, ett_smb_openfunction, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
static const true_false_string tfs_mf_file = {
"Target must be a file",
"Target needn't be a file"
};
static const true_false_string tfs_mf_dir = {
"Target must be a directory",
"Target needn't be a directory"
};
static const true_false_string tfs_mf_verify = {
"MUST verify all writes",
"Don't have to verify writes"
};
static int
dissect_move_flags(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_move_flags_verify,
&hf_smb_move_flags_dir,
&hf_smb_move_flags_file,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_move_flags, ett_smb_move_copy_flags, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
static const true_false_string tfs_cf_mode = {
"ASCII",
"Binary"
};
static const true_false_string tfs_cf_tree_copy = {
"Copy is a tree copy",
"Copy is a file copy"
};
static const true_false_string tfs_cf_ea_action = {
"Fail copy",
"Discard EAs"
};
static int
dissect_copy_flags(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_copy_flags_ea_action,
&hf_smb_copy_flags_tree_copy,
&hf_smb_copy_flags_verify,
&hf_smb_copy_flags_source_mode,
&hf_smb_copy_flags_dest_mode,
&hf_smb_copy_flags_dir,
&hf_smb_copy_flags_file,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_copy_flags, ett_smb_move_copy_flags, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
static int
dissect_move_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
int fn_len;
guint16 tid;
guint16 bc;
guint8 wc;
const char *fn;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* tid */
tid = tvb_get_letohs(tvb, offset);
offset = dissect_smb_tid(tvb, pinfo, tree, offset, tid, FALSE, FALSE, si);
/* open function */
offset = dissect_open_function(tvb, tree, offset);
/* move flags */
offset = dissect_move_flags(tvb, tree, offset);
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string_format(tree, hf_smb_file_name, tvb, offset,
fn_len, fn, "Old File Name: %s", format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
COUNT_BYTES(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Old Name: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string_format(tree, hf_smb_file_name, tvb, offset,
fn_len, fn, "New File Name: %s", format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
COUNT_BYTES(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", New Name: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
END_OF_SMB
return offset;
}
static int
dissect_copy_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
int fn_len;
guint16 tid;
guint16 bc;
guint8 wc;
const char *fn;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* tid */
tid = tvb_get_letohs(tvb, offset);
offset = dissect_smb_tid(tvb, pinfo, tree, offset, tid, FALSE, FALSE, si);
/* open function */
offset = dissect_open_function(tvb, tree, offset);
/* copy flags */
offset = dissect_copy_flags(tvb, tree, offset);
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string_format(tree, hf_smb_file_name, tvb, offset,
fn_len, fn, "Source File Name: %s", format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
COUNT_BYTES(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Source Name: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string_format(tree, hf_smb_file_name, tvb, offset,
fn_len, fn, "Destination File Name: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
COUNT_BYTES(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Destination Name: %s", format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
END_OF_SMB
return offset;
}
static int
dissect_move_copy_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
int fn_len;
const char *fn;
guint8 wc;
guint16 bc;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* # of files moved */
proto_tree_add_item(tree, hf_smb_files_moved, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
END_OF_SMB
return offset;
}
static int
dissect_open_file_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
int fn_len;
const char *fn;
guint8 wc;
guint16 bc;
smb_fid_saved_info_t *fsi; /* eo_smb needs to track this info */
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* desired access */
offset = dissect_access(tvb, tree, offset, hf_smb_desired_access);
/* Search Attributes */
offset = dissect_search_attributes(tvb, tree, offset);
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
/* store it for the fid->name/openframe/closeframe matching in
* dissect_smb_fid() called from the response.
*/
if ((!pinfo->fd->visited) && si->sip && fn) {
fsi = wmem_new0(wmem_file_scope(), smb_fid_saved_info_t);
fsi->filename = wmem_strdup(wmem_file_scope(), fn);
si->sip->extra_info_type = SMB_EI_FILEDATA;
si->sip->extra_info = fsi;
}
col_append_fstr(pinfo->cinfo, COL_INFO, ", Path: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
END_OF_SMB
return offset;
}
static int
dissect_nt_create_bits(tvbuff_t *tvb, proto_tree *parent_tree, int offset,
int len, guint32 mask)
{
proto_item *item = NULL;
/*
* XXX - it's 0x00000016 in at least one capture, but
* Network Monitor doesn't say what the 0x00000010 bit is.
* Does the Win32 API documentation, or NT Native API book,
* suggest anything?
*
* That is the extended response desired bit ... RJS, from Samba
* Well, maybe. Samba thinks it is, and uses it to encode
* OpLock granted as the high order bit of the Action field
* in the response. However, Windows does not do that. Or at least
* Win2K doesn't.
*/
static int * const fields[] = {
&hf_smb_nt_create_bits_oplock,
&hf_smb_nt_create_bits_boplock,
&hf_smb_nt_create_bits_dir,
&hf_smb_nt_create_bits_ext_resp,
NULL
};
item = proto_tree_add_bitmask_value_with_flags(parent_tree, tvb, offset, hf_smb_create_flags, ett_smb_nt_create_bits,
fields, mask, BMT_NO_APPEND);
if (len == 0)
proto_item_set_generated(item);
offset += len;
return offset;
}
/* FIXME: need to call dissect_nt_access_mask() instead */
static int
dissect_smb_access_mask_bits(tvbuff_t *tvb, proto_tree *parent_tree,
int offset, int len, guint32 mask)
{
proto_item *item;
/*
* Some of these bits come from
*
* http://www.samba.org/samba/ftp/specs/smb-nt01.doc
*
* and others come from the section on ZwOpenFile in "Windows(R)
* NT(R)/2000 Native API Reference".
*/
static int * const fields[] = {
&hf_smb_nt_access_mask_read,
&hf_smb_nt_access_mask_write,
&hf_smb_nt_access_mask_append,
&hf_smb_nt_access_mask_read_ea,
&hf_smb_nt_access_mask_write_ea,
&hf_smb_nt_access_mask_execute,
&hf_smb_nt_access_mask_delete_child,
&hf_smb_nt_access_mask_read_attributes,
&hf_smb_nt_access_mask_write_attributes,
&hf_smb_nt_access_mask_delete,
&hf_smb_nt_access_mask_read_control,
&hf_smb_nt_access_mask_write_dac,
&hf_smb_nt_access_mask_write_owner,
&hf_smb_nt_access_mask_synchronize,
&hf_smb_nt_access_mask_system_security,
&hf_smb_nt_access_mask_maximum_allowed,
&hf_smb_nt_access_mask_generic_all,
&hf_smb_nt_access_mask_generic_execute,
&hf_smb_nt_access_mask_generic_write,
&hf_smb_nt_access_mask_generic_read,
NULL
};
item = proto_tree_add_bitmask_value_with_flags(parent_tree, tvb, offset, hf_smb_access_mask, ett_smb_nt_access_mask,
fields, mask, BMT_NO_APPEND);
if (len == 0)
proto_item_set_generated(item);
offset += len;
return offset;
}
int
dissect_smb_access_mask(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
guint32 mask;
mask = tvb_get_letohl(tvb, offset);
offset = dissect_smb_access_mask_bits(tvb, parent_tree, offset, 4, mask);
return offset;
}
#define SHARE_ACCESS_READ 0x00000001
#define SHARE_ACCESS_WRITE 0x00000002
#define SHARE_ACCESS_DELETE 0x00000004
static int
dissect_nt_share_access_bits(tvbuff_t *tvb, proto_tree *parent_tree,
int offset, int len, guint32 mask)
{
proto_item *item;
static int * const fields[] = {
&hf_smb_nt_share_access_read,
&hf_smb_nt_share_access_write,
&hf_smb_nt_share_access_delete,
NULL
};
item = proto_tree_add_bitmask_value(parent_tree, tvb, offset, hf_smb_share_access, ett_smb_nt_share_access, fields, mask);
if (len == 0)
proto_item_set_generated(item);
offset += len;
return offset;
}
int
dissect_nt_share_access(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
guint32 mask;
mask = tvb_get_letohl(tvb, offset);
offset = dissect_nt_share_access_bits(tvb, parent_tree, offset, 4, mask);
return offset;
}
static int
dissect_nt_create_options_bits(tvbuff_t *tvb, proto_tree *parent_tree,
int offset, int len, guint32 mask)
{
proto_item *item;
/*
* From
*
* http://www.samba.org/samba/ftp/specs/smb-nt01.doc
*/
static int * const fields[] = {
&hf_smb_nt_create_options_directory_file,
&hf_smb_nt_create_options_write_through,
&hf_smb_nt_create_options_sequential_only,
&hf_smb_nt_create_options_no_intermediate_buffering,
&hf_smb_nt_create_options_sync_io_alert,
&hf_smb_nt_create_options_sync_io_nonalert,
&hf_smb_nt_create_options_non_directory_file,
&hf_smb_nt_create_options_create_tree_connection,
&hf_smb_nt_create_options_complete_if_oplocked,
&hf_smb_nt_create_options_no_ea_knowledge,
&hf_smb_nt_create_options_eight_dot_three_only,
&hf_smb_nt_create_options_random_access,
&hf_smb_nt_create_options_delete_on_close,
&hf_smb_nt_create_options_open_by_fileid,
&hf_smb_nt_create_options_backup_intent,
&hf_smb_nt_create_options_no_compression,
&hf_smb_nt_create_options_reserve_opfilter,
&hf_smb_nt_create_options_open_reparse_point,
&hf_smb_nt_create_options_open_no_recall,
&hf_smb_nt_create_options_open_for_free_space_query,
NULL
};
item = proto_tree_add_bitmask_value_with_flags(parent_tree, tvb, offset, hf_smb_create_options, ett_smb_nt_create_options, fields, mask, BMT_NO_APPEND);
if (len == 0)
proto_item_set_generated(item);
offset += len;
return offset;
}
int
dissect_nt_create_options(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
guint32 mask;
mask = tvb_get_letohl(tvb, offset);
offset = dissect_nt_create_options_bits(tvb, parent_tree, offset, 4, mask);
return offset;
}
/* fids are scoped by tcp session */
smb_fid_info_t *
dissect_smb_fid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
int len, guint16 fid, gboolean is_created, gboolean is_closed, gboolean is_generated, smb_info_t* si)
{
smb_saved_info_t *sip;
proto_item *it;
proto_tree *tr;
smb_fid_info_t *fid_info = NULL;
smb_fid_info_t *suspect_fid_info = NULL;
/* We need this to use an array-accessed tree */
GSList *GSL_iterator;
DISSECTOR_ASSERT(si);
sip = si->sip;
it = proto_tree_add_uint(tree, hf_smb_fid, tvb, offset, len, fid);
if (is_generated) {
proto_item_set_generated(it);
}
tr = proto_item_add_subtree(it, ett_smb_fid);
col_append_fstr(pinfo->cinfo, COL_INFO, ", FID: 0x%04x", fid);
if ((!pinfo->fd->visited) && is_created) {
fid_info = wmem_new(wmem_file_scope(), smb_fid_info_t);
fid_info->opened_in = pinfo->num;
fid_info->closed_in = 0;
fid_info->type = SMB_FID_TYPE_UNKNOWN;
fid_info->fid = fid;
fid_info->tid = si->tid;
if (si->sip && (si->sip->extra_info_type == SMB_EI_FILEDATA)) {
fid_info->fsi = (smb_fid_saved_info_t *)si->sip->extra_info;
} else {
fid_info->fsi = NULL;
}
/* We don't use the fid_tree anymore to access and
maintain the fid information of analyzed files.
(was wmem_tree_insert32(si->ct->fid_tree, fid, fid_info);)
We'll use a single list instead to keep track of the
files (fid) opened.
Note that the insert_sorted function allows to insert duplicates
but being inside this if section should prevent it */
si->ct->GSL_fid_info = g_slist_insert_sorted(
si->ct->GSL_fid_info,
fid_info,
(GCompareFunc)fid_cmp);
}
if (!fid_info) {
/* we use the single linked list to access this fid_info
(was fid_info = wmem_tree_lookup32(si->ct->fid_tree, fid);) */
GSL_iterator = si->ct->GSL_fid_info;
while (GSL_iterator) {
suspect_fid_info = (smb_fid_info_t *)GSL_iterator->data;
if (suspect_fid_info->opened_in > pinfo->num) break;
if ((suspect_fid_info->tid == si->tid) && (suspect_fid_info->fid == fid))
fid_info = (smb_fid_info_t *)suspect_fid_info;
GSL_iterator = g_slist_next(GSL_iterator);
}
}
if (!fid_info) {
return NULL;
}
/* Store the fid in the transaction structure and remember if
it was in the request or in the reply we saw it
*/
if (sip && (!is_generated) && (!pinfo->fd->visited)) {
sip->fid = fid;
if (si->request) {
sip->fid_seen_in_request = TRUE;
} else {
sip->fid_seen_in_request = FALSE;
}
}
if ((!pinfo->fd->visited) && is_closed) {
fid_info->closed_in = pinfo->num;
}
if (fid_info->opened_in) {
it = proto_tree_add_uint(tr, hf_smb_opened_in, tvb, 0, 0, fid_info->opened_in);
proto_item_set_generated(it);
}
if (fid_info->closed_in) {
it = proto_tree_add_uint(tr, hf_smb_closed_in, tvb, 0, 0, fid_info->closed_in);
proto_item_set_generated(it);
}
if (fid_info->opened_in) {
if (fid_info->fsi && fid_info->fsi->filename) {
it = proto_tree_add_string(tr, hf_smb_file_name, tvb, 0, 0, fid_info->fsi->filename);
proto_item_set_generated(it);
proto_item_append_text(tr, " (%s)", fid_info->fsi->filename);
dissect_nt_create_bits(tvb, tr, 0, 0, fid_info->fsi->create_flags);
dissect_smb_access_mask_bits(tvb, tr, 0, 0, fid_info->fsi->access_mask);
dissect_file_ext_attr_bits(tvb, tr, 0, 0, fid_info->fsi->file_attributes);
dissect_nt_share_access_bits(tvb, tr, 0, 0, fid_info->fsi->share_access);
dissect_nt_create_options_bits(tvb, tr, 0, 0, fid_info->fsi->create_options);
it = proto_tree_add_uint(tr, hf_smb_nt_create_disposition, tvb, 0, 0, fid_info->fsi->create_disposition);
proto_item_set_generated(it);
}
}
return fid_info;
}
static int
dissect_open_file_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc;
guint16 fid;
smb_fid_info_t *fid_info = NULL; /* eo_smb needs to track this info */
guint16 fattr;
gboolean isdir = FALSE;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
fid_info = dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, TRUE, FALSE, FALSE, si);
if (fid_info) {
/* This command is used to create and open a new file or open
and truncate an existing file to zero length */
fid_info->end_of_file = 0;
if (fid_info->fsi) {
/* File Type */
fattr = fid_info->fsi->file_attributes;
/* XXX Volumes considered as directories */
isdir = (fattr & SMB_FILE_ATTRIBUTE_DIRECTORY) || (fattr & SMB_FILE_ATTRIBUTE_VOLUME);
if (isdir == 0) {
fid_info->type = SMB_FID_TYPE_FILE;
} else {
fid_info->type = SMB_FID_TYPE_DIR;
}
}
}
offset += 2;
/* File Attributes */
offset = dissect_file_attributes(tvb, tree, offset);
/* last write time */
offset = dissect_smb_UTIME(tvb, tree, offset, hf_smb_last_write_time);
/* File Size */
proto_tree_add_item(tree, hf_smb_file_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* granted access */
offset = dissect_access(tvb, tree, offset, hf_smb_granted_access);
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_query_information2_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc;
guint16 fid;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_close_print_file_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc;
guint16 fid;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, TRUE, FALSE, si);
offset += 2;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_open_print_file_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc;
guint16 fid;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_create_new_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc;
guint16 fid;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, TRUE, FALSE, FALSE, si);
offset += 2;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_flush_file_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc;
guint16 fid;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_create_file_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc;
guint16 fid;
smb_fid_info_t *fid_info = NULL; /* eo_smb needs to track this info */
guint16 fattr;
gboolean isdir = FALSE;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
fid_info = dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, TRUE, FALSE, FALSE, si);
if (fid_info) {
/* This command is used to create and open a new file or open
and truncate an existing file to zero length */
fid_info->end_of_file = 0;
if (fid_info->fsi) {
/* File Type */
fattr = fid_info->fsi->file_attributes;
/* XXX Volumes considered as directories */
isdir = (fattr & SMB_FILE_ATTRIBUTE_DIRECTORY) || (fattr & SMB_FILE_ATTRIBUTE_VOLUME);
if (isdir == 0) {
fid_info->type = SMB_FID_TYPE_FILE;
} else {
fid_info->type = SMB_FID_TYPE_DIR;
}
}
}
offset += 2;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_create_file_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
int fn_len;
const char *fn;
guint8 wc;
guint16 bc;
smb_fid_saved_info_t *fsi; /* eo_smb needs to track this info */
guint32 file_attributes = 0;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* file attributes */
/* We read the two lower bytes into the four-bytes file-attributes, because they are compatible */
file_attributes = tvb_get_letohs(tvb, offset);
offset = dissect_file_attributes(tvb, tree, offset);
/* creation time */
offset = dissect_smb_UTIME(tvb, tree, offset, hf_smb_create_time);
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* File Name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
/* store it for the fid->name/openframe/closeframe matching in
* dissect_smb_fid() called from the response.
*/
if ((!pinfo->fd->visited) && si->sip && fn) {
fsi = wmem_new0(wmem_file_scope(), smb_fid_saved_info_t);
fsi->filename = wmem_strdup(wmem_file_scope(), fn);
fsi->file_attributes = file_attributes;
si->sip->extra_info_type = SMB_EI_FILEDATA;
si->sip->extra_info = fsi;
}
col_append_fstr(pinfo->cinfo, COL_INFO, ", Path: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
END_OF_SMB
return offset;
}
static int
dissect_close_file_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc, fid;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, TRUE, FALSE, si);
offset += 2;
/* last write time */
offset = dissect_smb_UTIME(tvb, tree, offset, hf_smb_last_write_time);
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_delete_file_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
int fn_len;
const char *fn;
guint8 wc;
guint16 bc;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* search attributes */
offset = dissect_search_attributes(tvb, tree, offset);
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
if ((!pinfo->fd->visited) && si->sip) {
si->sip->extra_info_type = SMB_EI_FILENAME;
si->sip->extra_info = wmem_strdup(wmem_file_scope(), fn);
}
if (fn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Path: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
END_OF_SMB
return offset;
}
static int
dissect_rename_file_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
int fn_len;
const char *fn, *old_name = NULL, *new_name = NULL;
guint8 wc;
guint16 bc;
smb_rename_saved_info_t *rni = NULL;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* search attributes */
offset = dissect_search_attributes(tvb, tree, offset);
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* old file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
old_name = fn;
proto_tree_add_string(tree, hf_smb_old_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Old Name: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
new_name = fn;
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", New Name: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
END_OF_SMB
/* save the offset/len for this transaction */
if (si->sip && !pinfo->fd->visited) {
rni = wmem_new(wmem_file_scope(), smb_rename_saved_info_t);
rni->old_name = wmem_strdup(wmem_file_scope(), old_name);
rni->new_name = wmem_strdup(wmem_file_scope(), new_name);
si->sip->extra_info_type = SMB_EI_RENAMEDATA;
si->sip->extra_info = rni;
}
return offset;
}
static int
dissect_nt_rename_file_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
int fn_len;
const char *fn;
guint8 wc;
guint16 bc;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* search attributes */
offset = dissect_search_attributes(tvb, tree, offset);
proto_tree_add_item(tree, hf_smb_nt_rename_level, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_smb_cluster_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* old file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_old_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Old Name: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", New Name: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
END_OF_SMB
return offset;
}
static int
dissect_query_information_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint16 bc;
guint8 wc;
const char *fn;
int fn_len;
DISSECTOR_ASSERT(si);
WORD_COUNT;
BYTE_COUNT;
/* Buffer Format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* File Name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Path: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
END_OF_SMB
return offset;
}
static int
dissect_query_information_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint16 bc;
guint8 wc;
WORD_COUNT;
/* File Attributes */
offset = dissect_file_attributes(tvb, tree, offset);
/* Last Write Time */
offset = dissect_smb_UTIME(tvb, tree, offset, hf_smb_last_write_time);
/* File Size */
proto_tree_add_item(tree, hf_smb_file_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* 10 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 10, ENC_NA);
offset += 10;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_set_information_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
int fn_len;
const char *fn;
guint8 wc;
guint16 bc;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* file attributes */
offset = dissect_file_attributes(tvb, tree, offset);
/* last write time */
offset = dissect_smb_UTIME(tvb, tree, offset, hf_smb_last_write_time);
/* 10 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 10, ENC_NA);
offset += 10;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Path: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
END_OF_SMB
return offset;
}
typedef struct _rw_info_t {
guint64 offset;
guint32 len;
guint16 fid;
} rw_info_t;
static int
dissect_read_file_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 cnt = 0, bc;
guint32 ofs = 0;
unsigned int fid;
rw_info_t *rwi = NULL;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, (guint16) fid, FALSE, FALSE, FALSE, si);
offset += 2;
/* read count */
cnt = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* offset */
ofs = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
col_append_fstr(pinfo->cinfo, COL_INFO,
", %u byte%s at offset %u", cnt,
(cnt == 1) ? "" : "s", ofs);
/* remaining */
proto_tree_add_item(tree, hf_smb_remaining, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* save the offset/len for this transaction */
if (si->sip && !pinfo->fd->visited) {
rwi = wmem_new(wmem_file_scope(), rw_info_t);
rwi->offset = ofs;
rwi->len = cnt;
rwi->fid = fid;
si->sip->extra_info_type = SMB_EI_RWINFO;
si->sip->extra_info = rwi;
}
BYTE_COUNT;
END_OF_SMB
return offset;
}
int
dissect_file_data(tvbuff_t *tvb, proto_tree *tree, int offset, guint16 bc, int dataoffset, guint16 datalen)
{
int tvblen;
if (bc > datalen) {
/* We have some initial padding bytes. */
/* XXX - use the data offset here instead? */
proto_tree_add_item(tree, hf_smb_padding, tvb, offset, bc-datalen,
ENC_NA);
offset += bc-datalen;
bc = datalen;
}
tvblen = tvb_reported_length_remaining(tvb, dataoffset > 0 ? dataoffset : offset );
if (bc > tvblen) {
proto_tree_add_bytes_format_value(tree, hf_smb_file_data, tvb, dataoffset > 0 ? dataoffset : offset, tvblen, NULL, "Incomplete. Only %d of %u bytes", tvblen, bc);
if (dataoffset == -1 || dataoffset == offset)
offset += tvblen;
} else {
proto_tree_add_item(tree, hf_smb_file_data, tvb, dataoffset > 0 ? dataoffset : offset, bc, ENC_NA);
if (dataoffset == -1 || dataoffset == offset)
offset += bc;
}
return offset;
}
static int
dissect_file_data_dcerpc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
proto_tree *top_tree, int offset, guint16 bc, guint16 datalen, guint16 fid,
void *data)
{
int tvblen;
tvbuff_t *dcerpc_tvb;
if (bc > datalen) {
/* We have some initial padding bytes. */
/* XXX - use the data offset here instead? */
proto_tree_add_item(tree, hf_smb_padding, tvb, offset, bc-datalen,
ENC_NA);
offset += bc-datalen;
bc = datalen;
}
tvblen = tvb_reported_length_remaining(tvb, offset);
dcerpc_tvb = tvb_new_subset_length_caplen(tvb, offset, tvblen, bc);
dissect_pipe_dcerpc(dcerpc_tvb, pinfo, top_tree, tree, fid, data);
if (bc > tvblen)
offset += tvblen;
else
offset += bc;
return offset;
}
/*
* transporting DCERPC over SMB seems to be implemented in various
* ways. We might just assume it can be done by an almost random
* mix of Trans/Read/Write calls
*
* if we suspect dcerpc, just send them all down to packet-smb-pipe.c
* and let him sort them out
*/
static int
dissect_file_data_maybe_dcerpc(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, proto_tree *top_tree, int offset, guint16 bc,
int dataoffset, guint16 datalen, guint32 ofs, guint16 fid, smb_info_t *si)
{
DISSECTOR_ASSERT(si);
if ( (si->sip && (si->sip->flags & SMB_SIF_TID_IS_IPC)) && (ofs == 0) ) {
/* dcerpc call */
/* XXX - use the data offset to determine where the data starts? */
return dissect_file_data_dcerpc(tvb, pinfo, tree,
top_tree, offset, bc, datalen, fid, si);
} else {
/* ordinary file data */
return dissect_file_data(tvb, tree, offset, bc, dataoffset, datalen);
}
}
static int
dissect_read_file_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint16 cnt = 0, bc;
guint8 wc;
int fid = 0;
guint32 datalen = 0, dataoffset = 0;
guint32 tvblen;
rw_info_t *rwi = NULL;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* read count */
cnt = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_count, tvb, offset, 2, cnt);
offset += 2;
/* 8 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 8, ENC_NA);
offset += 8;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* data len */
CHECK_BYTE_COUNT(2);
proto_tree_add_item(tree, hf_smb_data_len, tvb, offset, 2, ENC_LITTLE_ENDIAN);
datalen = tvb_get_letohs(tvb, offset);
COUNT_BYTES(2);
dataoffset = offset;
/* file data, might be DCERPC on a pipe */
if (bc) {
offset = dissect_file_data_maybe_dcerpc(tvb, pinfo, tree,
top_tree_global, offset, bc, -1, bc, 0, (guint16) fid, si);
bc = 0;
}
/* If we have seen the request, then print which FID this refers to */
if ((si->sip != NULL) && (si->sip->frame_req > 0) && (si->sip->extra_info_type == SMB_EI_FID)) {
fid = GPOINTER_TO_INT(si->sip->extra_info);
}
if (si->sip && (si->sip->extra_info_type == SMB_EI_RWINFO)) {
rwi = (rw_info_t *)si->sip->extra_info;
}
if (rwi) {
proto_item *it;
it = proto_tree_add_uint64(tree, hf_smb_file_rw_offset, tvb, 0, 0, rwi->offset);
proto_item_set_generated(it);
it = proto_tree_add_uint(tree, hf_smb_file_rw_length, tvb, 0, 0, rwi->len);
proto_item_set_generated(it);
/* we need the fid for the call to dcerpc below */
fid = rwi->fid;
}
/* feed the export object tap listener */
tvblen = tvb_reported_length_remaining(tvb, dataoffset);
if (have_tap_listener(smb_eo_tap) && (datalen == tvblen) && rwi) {
feed_eo_smb(SMB_COM_READ, fid, tvb, pinfo, dataoffset, datalen, rwi->len, rwi->offset, si);
}
END_OF_SMB
return offset;
}
static int
dissect_lock_and_read_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint16 cnt, bc;
guint8 wc;
WORD_COUNT;
/* read count */
cnt = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_count, tvb, offset, 2, cnt);
offset += 2;
/* 8 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 8, ENC_NA);
offset += 8;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* data len */
CHECK_BYTE_COUNT(2);
proto_tree_add_item(tree, hf_smb_data_len, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES(2);
END_OF_SMB
return offset;
}
static int
dissect_write_file_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint32 ofs = 0;
guint16 cnt = 0, bc, fid = 0;
guint8 wc;
rw_info_t *rwi = NULL;
guint32 datalen = 0, dataoffset = 0;
guint32 tvblen;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
/* write count */
cnt = tvb_get_letohs(tvb, offset);
datalen = cnt;
proto_tree_add_uint(tree, hf_smb_count, tvb, offset, 2, cnt);
offset += 2;
/* offset */
ofs = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
col_append_fstr(pinfo->cinfo, COL_INFO,
", %u byte%s at offset %u", cnt,
(cnt == 1) ? "" : "s", ofs);
/* save the offset/len for this transaction */
if (si->sip && !pinfo->fd->visited) {
rwi = wmem_new(wmem_file_scope(), rw_info_t);
rwi->offset = ofs;
rwi->len = cnt;
rwi->fid = fid;
si->sip->extra_info_type = SMB_EI_RWINFO;
si->sip->extra_info = rwi;
}
if (si->sip && (si->sip->extra_info_type == SMB_EI_RWINFO)) {
rwi = (rw_info_t *)si->sip->extra_info;
}
if (rwi) {
proto_item *it;
it = proto_tree_add_uint64(tree, hf_smb_file_rw_offset, tvb, 0, 0, rwi->offset);
proto_item_set_generated(it);
it = proto_tree_add_uint(tree, hf_smb_file_rw_length, tvb, 0, 0, rwi->len);
proto_item_set_generated(it);
}
/* remaining */
proto_tree_add_item(tree, hf_smb_remaining, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* data len */
CHECK_BYTE_COUNT(2);
proto_tree_add_item(tree, hf_smb_data_len, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES(2);
dataoffset = offset;
/* file data, might be DCERPC on a pipe */
if (bc != 0) {
offset = dissect_file_data_maybe_dcerpc(tvb, pinfo, tree,
top_tree_global, offset, bc, -1, bc, ofs, fid, si);
bc = 0;
}
/* feed the export object tap listener */
tvblen = tvb_reported_length_remaining(tvb, dataoffset);
if (have_tap_listener(smb_eo_tap) && (datalen == tvblen) && rwi) {
feed_eo_smb(SMB_COM_WRITE, fid, tvb, pinfo, dataoffset, datalen, rwi->len, rwi->offset, si);
}
END_OF_SMB
return offset;
}
static int
dissect_write_file_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc, cnt;
rw_info_t *rwi = NULL;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* write count */
cnt = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
col_append_fstr(pinfo->cinfo, COL_INFO,
", %u byte%s", cnt, (cnt == 1) ? "" : "s");
if (si->sip && (si->sip->extra_info_type == SMB_EI_RWINFO)) {
rwi = (rw_info_t *)si->sip->extra_info;
}
if (rwi) {
proto_item *it;
it = proto_tree_add_uint64(tree, hf_smb_file_rw_offset, tvb, 0, 0, rwi->offset);
proto_item_set_generated(it);
it = proto_tree_add_uint(tree, hf_smb_file_rw_length, tvb, 0, 0, rwi->len);
proto_item_set_generated(it);
}
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_lock_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc, fid;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
/* lock count */
proto_tree_add_item(tree, hf_smb_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* offset */
proto_tree_add_item(tree, hf_smb_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_create_temporary_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
int fn_len;
const char *fn;
guint8 wc;
guint16 bc;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* 2 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* Creation time */
offset = dissect_smb_UTIME(tvb, tree, offset, hf_smb_create_time);
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/*
* Directory name.
*
* MS-CIFS says this is a "null-terminated string", without saying
* it's always ASCII, so we honor the "Unicode strings" flag.
*/
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_dir_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Path: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
END_OF_SMB
return offset;
}
static int
dissect_create_temporary_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
int fn_len;
const char *fn;
guint8 wc;
guint16 bc, fid;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, TRUE, FALSE, FALSE, si);
offset += 2;
BYTE_COUNT;
/*
* File name.
*
* MS-CIFS says "The string SHOULD be a null-terminated array of
* ASCII characters.", so we ignore the "Unicode strings" flag.
*/
fn = get_unicode_or_ascii_string(tvb, &offset, FALSE, &fn_len,
TRUE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
END_OF_SMB
return offset;
}
static const value_string seek_mode_vals[] = {
{0, "From Start Of File"},
{1, "From Current Position"},
{2, "From End Of File"},
{0, NULL}
};
static int
dissect_seek_file_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc, fid;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
/* Seek Mode */
proto_tree_add_item(tree, hf_smb_seek_mode, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* offset */
proto_tree_add_item(tree, hf_smb_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_seek_file_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint8 wc;
guint16 bc;
WORD_COUNT;
/* offset */
proto_tree_add_item(tree, hf_smb_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_set_information2_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc, fid;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
/* create time */
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_create_time,
hf_smb_create_dos_date, hf_smb_create_dos_time, FALSE);
/* access time */
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_access_time,
hf_smb_access_dos_date, hf_smb_access_dos_time, FALSE);
/* last write time */
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_last_write_time,
hf_smb_last_write_dos_date, hf_smb_last_write_dos_time, FALSE);
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_query_information2_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint8 wc;
guint16 bc;
WORD_COUNT;
/* create time */
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_create_time,
hf_smb_create_dos_date, hf_smb_create_dos_time, FALSE);
/* access time */
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_access_time,
hf_smb_access_dos_date, hf_smb_access_dos_time, FALSE);
/* last write time */
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_last_write_time,
hf_smb_last_write_dos_date, hf_smb_last_write_dos_time, FALSE);
/* data size */
proto_tree_add_item(tree, hf_smb_data_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* allocation size */
proto_tree_add_item(tree, hf_smb_alloc_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* File Attributes */
offset = dissect_file_attributes(tvb, tree, offset);
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_write_and_close_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 cnt = 0;
guint16 bc, fid;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, TRUE, FALSE, si);
offset += 2;
/* write count */
cnt = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_count, tvb, offset, 2, cnt);
offset += 2;
/* offset */
proto_tree_add_item(tree, hf_smb_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* last write time */
offset = dissect_smb_UTIME(tvb, tree, offset, hf_smb_last_write_time);
if (wc == 12) {
/* 12 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 12, ENC_NA);
offset += 12;
}
BYTE_COUNT;
/* 1 pad byte */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_padding, tvb, offset, 1, ENC_NA);
COUNT_BYTES(1);
offset = dissect_file_data(tvb, tree, offset, cnt, -1, cnt);
bc = 0; /* XXX */
END_OF_SMB
return offset;
}
static int
dissect_write_and_close_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint8 wc;
guint16 bc;
WORD_COUNT;
/* write count */
proto_tree_add_item(tree, hf_smb_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
BYTE_COUNT;
END_OF_SMB
return offset;
}
/* Timeout is defined on page 117 of SMB Protocol Extensions version 2.0
available at http://us1.samba.org/samba/ftp/SMB-info/DOSEXTP.TXT
*/
static gchar *
smbext20_timeout_msecs_to_str(gint32 timeout)
{
gchar *buf;
#define SMBEXT20_TIMEOUT_MSECS_TO_STR_MAXLEN 60
if (timeout <= 0) {
buf = (gchar *)wmem_alloc(wmem_packet_scope(), SMBEXT20_TIMEOUT_MSECS_TO_STR_MAXLEN+1);
if (timeout == 0) {
snprintf(buf, SMBEXT20_TIMEOUT_MSECS_TO_STR_MAXLEN+1, "Return immediately (0)");
} else if (timeout == -1) {
snprintf(buf, SMBEXT20_TIMEOUT_MSECS_TO_STR_MAXLEN+1, "Wait indefinitely (-1)");
} else if (timeout == -2) {
snprintf(buf, SMBEXT20_TIMEOUT_MSECS_TO_STR_MAXLEN+1, "Use default timeout (-2)");
} else {
snprintf(buf, SMBEXT20_TIMEOUT_MSECS_TO_STR_MAXLEN+1, "Unknown reserved value (%d)", timeout);
}
return buf;
}
return signed_time_msecs_to_str(wmem_packet_scope(), timeout);
}
static int
dissect_read_raw_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc, fid;
guint32 to;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
/* offset */
proto_tree_add_item(tree, hf_smb_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* max count */
proto_tree_add_item(tree, hf_smb_max_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* min count */
proto_tree_add_item(tree, hf_smb_min_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* timeout */
to = tvb_get_letohl(tvb, offset);
proto_tree_add_uint_format_value(tree, hf_smb_timeout, tvb, offset, 4, to, "%s", smbext20_timeout_msecs_to_str(to));
offset += 4;
/* 2 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
if (wc == 10) {
/* high offset */
proto_tree_add_item(tree, hf_smb_high_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_query_information_disk_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint8 wc;
guint16 bc;
WORD_COUNT;
/* units */
proto_tree_add_item(tree, hf_smb_units, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* bpu */
proto_tree_add_item(tree, hf_smb_bpu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* block size */
proto_tree_add_item(tree, hf_smb_blocksize, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* free units */
proto_tree_add_item(tree, hf_smb_freeunits, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* 2 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_read_mpx_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc;
guint16 bc, fid;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
/* offset */
proto_tree_add_item(tree, hf_smb_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* max count */
proto_tree_add_item(tree, hf_smb_max_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* min count */
proto_tree_add_item(tree, hf_smb_min_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* 6 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 6, ENC_NA);
offset += 6;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_read_mpx_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint16 datalen = 0, bc;
guint8 wc;
WORD_COUNT;
/* offset */
proto_tree_add_item(tree, hf_smb_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* count */
proto_tree_add_item(tree, hf_smb_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* 2 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* data compaction mode */
proto_tree_add_item(tree, hf_smb_dcm, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* 2 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* data len */
datalen = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_len, tvb, offset, 2, datalen);
offset += 2;
/* data offset */
proto_tree_add_item(tree, hf_smb_data_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
BYTE_COUNT;
/* file data */
/* XXX - use the data offset to determine where the data starts? */
offset = dissect_file_data(tvb, tree, offset, bc, -1, datalen);
bc = 0;
END_OF_SMB
return offset;
}
static const true_false_string tfs_write_mode_write_through = {
"WRITE THROUGH requested",
"Write through not requested"
};
static const true_false_string tfs_write_mode_return_remaining = {
"RETURN REMAINING (pipe/dev) requested",
"DON'T return remaining (pipe/dev)"
};
static const true_false_string tfs_write_mode_raw = {
"Use WriteRawNamedPipe (pipe)",
"DON'T use WriteRawNamedPipe (pipe)"
};
static const true_false_string tfs_write_mode_message_start = {
"This is the START of a MESSAGE (pipe)",
"This is NOT the start of a message (pipe)"
};
static const true_false_string tfs_write_mode_connectionless = {
"CONNECTIONLESS mode requested",
"Connectionless mode NOT requested"
};
#define WRITE_MODE_CONNECTIONLESS 0x0080
#define WRITE_MODE_MESSAGE_START 0x0008
#define WRITE_MODE_RAW 0x0004
#define WRITE_MODE_RETURN_REMAINING 0x0002
#define WRITE_MODE_WRITE_THROUGH 0x0001
static int
dissect_write_mode(tvbuff_t *tvb, proto_tree *parent_tree, int offset, int bm)
{
guint16 mask;
proto_item *item;
proto_tree *tree;
mask = tvb_get_letohs(tvb, offset);
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb_write_mode, tvb, offset, 2, ENC_LITTLE_ENDIAN);
tree = proto_item_add_subtree(item, ett_smb_rawmode);
if (bm&WRITE_MODE_CONNECTIONLESS) {
proto_tree_add_boolean(tree, hf_smb_write_mode_connectionless,
tvb, offset, 2, mask);
}
if (bm&WRITE_MODE_MESSAGE_START) {
proto_tree_add_boolean(tree, hf_smb_write_mode_message_start,
tvb, offset, 2, mask);
}
if (bm&WRITE_MODE_RAW) {
proto_tree_add_boolean(tree, hf_smb_write_mode_raw,
tvb, offset, 2, mask);
}
if (bm&WRITE_MODE_RETURN_REMAINING) {
proto_tree_add_boolean(tree, hf_smb_write_mode_return_remaining,
tvb, offset, 2, mask);
}
if (bm&WRITE_MODE_WRITE_THROUGH) {
proto_tree_add_boolean(tree, hf_smb_write_mode_write_through,
tvb, offset, 2, mask);
}
}
offset += 2;
return offset;
}
static int
dissect_write_raw_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint32 to;
guint16 datalen = 0, bc, fid;
guint8 wc;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
/* total data length */
proto_tree_add_item(tree, hf_smb_total_data_len, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* 2 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* offset */
proto_tree_add_item(tree, hf_smb_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* timeout */
to = tvb_get_letohl(tvb, offset);
proto_tree_add_uint_format_value(tree, hf_smb_timeout, tvb, offset, 4, to, "%s", smbext20_timeout_msecs_to_str(to));
offset += 4;
/* mode */
offset = dissect_write_mode(tvb, tree, offset, 0x0003);
/* 4 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
/* data len */
datalen = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_len, tvb, offset, 2, datalen);
offset += 2;
/* data offset */
proto_tree_add_item(tree, hf_smb_data_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
BYTE_COUNT;
/* file data */
/* XXX - use the data offset to determine where the data starts? */
offset = dissect_file_data(tvb, tree, offset, bc, -1, datalen);
bc = 0;
END_OF_SMB
return offset;
}
static int
dissect_write_raw_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint8 wc;
guint16 bc;
WORD_COUNT;
/* remaining */
proto_tree_add_item(tree, hf_smb_remaining, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_write_mpx_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint32 to;
guint16 datalen = 0, bc, fid;
guint8 wc;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
/* total data length */
proto_tree_add_item(tree, hf_smb_total_data_len, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* 2 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* offset */
proto_tree_add_item(tree, hf_smb_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* timeout */
to = tvb_get_letohl(tvb, offset);
proto_tree_add_uint_format_value(tree, hf_smb_timeout, tvb, offset, 4, to, "%s", smbext20_timeout_msecs_to_str(to));
offset += 4;
/* mode */
offset = dissect_write_mode(tvb, tree, offset, 0x0083);
/* request mask */
proto_tree_add_item(tree, hf_smb_request_mask, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* data len */
datalen = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_len, tvb, offset, 2, datalen);
offset += 2;
/* data offset */
proto_tree_add_item(tree, hf_smb_data_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
BYTE_COUNT;
/* file data */
/* XXX - use the data offset to determine where the data starts? */
offset = dissect_file_data(tvb, tree, offset, bc, -1,datalen);
bc = 0;
END_OF_SMB
return offset;
}
static int
dissect_write_mpx_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint8 wc;
guint16 bc;
WORD_COUNT;
/* response mask */
proto_tree_add_item(tree, hf_smb_response_mask, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_sid(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint8 wc;
guint16 bc;
WORD_COUNT;
/* sid */
proto_tree_add_item(tree, hf_smb_search_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_search_resume_key(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree *parent_tree, int offset, guint16 *bcp, gboolean *trunc,
gboolean has_find_id, smb_info_t *si)
{
proto_tree *tree;
int fn_len;
const char *fn;
DISSECTOR_ASSERT(si);
tree = proto_tree_add_subtree(parent_tree, tvb, offset, 21,
ett_smb_search_resume_key, NULL, "Resume Key");
/* reserved byte */
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
COUNT_BYTES_SUBR(1);
/* file name */
fn_len = 11;
fn = get_unicode_or_ascii_string(tvb, &offset, FALSE/*never Unicode*/, &fn_len,
TRUE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, 11, fn);
COUNT_BYTES_SUBR(fn_len);
if (has_find_id) {
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(tree, hf_smb_resume_find_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(1);
/* server cookie */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_resume_server_cookie, tvb, offset, 4, ENC_NA);
COUNT_BYTES_SUBR(4);
} else {
/* server cookie */
CHECK_BYTE_COUNT_SUBR(5);
proto_tree_add_item(tree, hf_smb_resume_server_cookie, tvb, offset, 5, ENC_NA);
COUNT_BYTES_SUBR(5);
}
/* client cookie */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_resume_client_cookie, tvb, offset, 4, ENC_NA);
COUNT_BYTES_SUBR(4);
*trunc = FALSE;
return offset;
}
static int
dissect_search_dir_info(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *parent_tree, int offset, guint16 *bcp, gboolean *trunc,
gboolean has_find_id, smb_info_t *si)
{
proto_tree *tree;
int fn_len;
const char *fn;
DISSECTOR_ASSERT(si);
tree = proto_tree_add_subtree(parent_tree, tvb, offset, 43,
ett_smb_search_dir_info, NULL, "Directory Information");
/* resume key */
offset = dissect_search_resume_key(tvb, pinfo, tree, offset, bcp,
trunc, has_find_id, si);
if (*trunc)
return offset;
/* File Attributes */
CHECK_BYTE_COUNT_SUBR(1);
offset = dissect_dir_info_file_attributes(tvb, tree, offset);
*bcp -= 1;
/* last write time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_last_write_time,
hf_smb_last_write_dos_date, hf_smb_last_write_dos_time,
TRUE);
*bcp -= 4;
/* File Size */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_file_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* file name */
/* [MS-CIFS] says this is 13 *bytes*, and also says "Unicode is
not supported; names are returned in the extended ASCII
(OEM) character set only." */
fn_len = 13;
fn = get_unicode_or_ascii_string(tvb, &offset, FALSE/*Never Unicode*/, &fn_len,
TRUE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len, fn);
COUNT_BYTES_SUBR(fn_len);
*trunc = FALSE;
return offset;
}
static int
dissect_search_find_request(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si,
gboolean has_find_id)
{
int fn_len;
const char *fn;
guint16 rkl;
guint8 wc;
guint16 bc;
gboolean trunc;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* max count */
proto_tree_add_item(tree, hf_smb_max_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* Search Attributes */
offset = dissect_search_attributes(tvb, tree, offset);
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
TRUE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", File: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* resume key length */
CHECK_BYTE_COUNT(2);
rkl = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_resume_key_len, tvb, offset, 2, rkl);
COUNT_BYTES(2);
/* resume key */
if (rkl) {
offset = dissect_search_resume_key(tvb, pinfo, tree, offset,
&bc, &trunc, has_find_id, si);
if (trunc)
goto endofcommand;
}
END_OF_SMB
return offset;
}
static int
dissect_search_dir_request(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
return dissect_search_find_request(tvb, pinfo, tree, offset,
smb_tree, si, FALSE);
}
static int
dissect_find_request(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
return dissect_search_find_request(tvb, pinfo, tree, offset,
smb_tree, si, TRUE);
}
static int
dissect_find_close_request(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
return dissect_search_find_request(tvb, pinfo, tree, offset,
smb_tree, si, TRUE);
}
static int
dissect_search_find_response(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, int offset, proto_tree *smb_tree _U_,
gboolean has_find_id, smb_info_t *si)
{
guint16 count = 0;
guint8 wc;
guint16 bc;
gboolean trunc;
WORD_COUNT;
/* count */
count = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_count, tvb, offset, 2, count);
offset += 2;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* data len */
CHECK_BYTE_COUNT(2);
proto_tree_add_item(tree, hf_smb_data_len, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES(2);
while (count--) {
offset = dissect_search_dir_info(tvb, pinfo, tree, offset,
&bc, &trunc, has_find_id, si);
if (trunc)
goto endofcommand;
}
END_OF_SMB
return offset;
}
static int
dissect_search_dir_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
return dissect_search_find_response(tvb, pinfo, tree, offset, smb_tree,
FALSE, si);
}
static int
dissect_find_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
return dissect_search_find_response(tvb, pinfo, tree, offset, smb_tree,
TRUE, si);
}
static int
dissect_find_close_response(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint8 wc;
guint16 bc;
guint16 data_len;
WORD_COUNT;
/* reserved */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* data len */
CHECK_BYTE_COUNT(2);
data_len = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_len, tvb, offset, 2, data_len);
COUNT_BYTES(2);
if (data_len != 0) {
CHECK_BYTE_COUNT(data_len);
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset,
data_len, ENC_NA);
COUNT_BYTES(data_len);
}
END_OF_SMB
return offset;
}
static const value_string locking_ol_vals[] = {
{0, "Client is not holding oplock on this file"},
{1, "Level 2 oplock currently held by client"},
{0, NULL}
};
static const true_false_string tfs_lock_type_large = {
"Large file locking format requested",
"Large file locking format not requested"
};
static const true_false_string tfs_lock_type_cancel = {
"Cancel outstanding lock request",
"Don't cancel outstanding lock request"
};
static const true_false_string tfs_lock_type_change = {
"Change lock type",
"Don't change lock type"
};
static const true_false_string tfs_lock_type_oplock = {
"This is an oplock break notification/response",
"This is not an oplock break notification/response"
};
static const true_false_string tfs_lock_type_shared = {
"This is a shared lock",
"This is an exclusive lock"
};
static int
dissect_locking_andx_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
guint8 wc, cmd = 0xff, lt = 0, ol = 0;
guint16 andxoffset = 0, un = 0, ln = 0, bc, fid, num_lock = 0, num_unlock = 0;
guint32 to;
proto_item *it = NULL;
proto_tree *tr = NULL;
int old_offset = offset;
smb_locking_saved_info_t *ld = NULL;
static int * const locks[] = {
&hf_smb_lock_type_large,
&hf_smb_lock_type_cancel,
&hf_smb_lock_type_change,
&hf_smb_lock_type_oplock,
&hf_smb_lock_type_shared,
NULL
};
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* next smb command */
cmd = tvb_get_guint8(tvb, offset);
if (cmd != 0xff) {
proto_tree_add_uint(tree, hf_smb_andxcmd, tvb, offset, 1, cmd);
} else {
proto_tree_add_uint_format_value(tree, hf_smb_andxcmd, tvb, offset, 1, cmd, "No further commands (0xff)");
}
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* andxoffset */
andxoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_andxoffset, tvb, offset, 2, andxoffset);
offset += 2;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
/* lock type */
lt = tvb_get_guint8(tvb, offset);
proto_tree_add_bitmask(tree, tvb, offset, hf_smb_lock_type, ett_smb_lock_type, locks, ENC_NA);
offset += 1;
/* oplock level */
ol = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_smb_locking_ol, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* timeout */
to = tvb_get_letohl(tvb, offset);
proto_tree_add_uint_format_value(tree, hf_smb_timeout, tvb, offset, 4, to, "%s", smbext20_timeout_msecs_to_str(to));
offset += 4;
/* number of unlocks */
un = tvb_get_letohs(tvb, offset);
num_unlock = un;
proto_tree_add_uint(tree, hf_smb_number_of_unlocks, tvb, offset, 2, un);
offset += 2;
/* number of locks */
ln = tvb_get_letohs(tvb, offset);
num_lock = ln;
proto_tree_add_uint(tree, hf_smb_number_of_locks, tvb, offset, 2, ln);
offset += 2;
BYTE_COUNT;
/* store the locking data for the response */
if ((!pinfo->fd->visited) && si->sip) {
ld = wmem_new(wmem_file_scope(), smb_locking_saved_info_t);
ld->type = lt;
ld->oplock_level = ol;
ld->num_lock = num_lock;
ld->num_unlock = num_unlock;
ld->locks = NULL;
ld->unlocks = NULL;
si->sip->extra_info_type = SMB_EI_LOCKDATA;
si->sip->extra_info = ld;
}
/* unlocks */
if (un) {
old_offset = offset;
tr = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb_unlocks, &it, "Unlocks");
while (un--) {
proto_tree *ltree_2;
if (lt&0x10) {
guint64 val;
guint16 lock_pid;
guint64 lock_offset;
guint64 lock_length;
/* large lock format */
ltree_2 = proto_tree_add_subtree(tr, tvb, offset, 20, ett_smb_unlock, NULL, "Unlock");
/* PID */
CHECK_BYTE_COUNT(2);
lock_pid = tvb_get_letohs(tvb, offset);
proto_tree_add_item(ltree_2, hf_smb_pid, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES(2);
/* 2 reserved bytes */
CHECK_BYTE_COUNT(2);
proto_tree_add_item(ltree_2, hf_smb_reserved, tvb, offset, 2, ENC_NA);
COUNT_BYTES(2);
/* offset */
CHECK_BYTE_COUNT(8);
val = ((guint64)tvb_get_letohl(tvb, offset)) << 32
| tvb_get_letohl(tvb, offset+4);
lock_offset = val;
proto_tree_add_uint64(ltree_2, hf_smb_lock_long_offset, tvb, offset, 8, val);
COUNT_BYTES(8);
/* length */
CHECK_BYTE_COUNT(8);
val = ((guint64)tvb_get_letohl(tvb, offset)) << 32
| tvb_get_letohl(tvb, offset+4);
lock_length = val;
proto_tree_add_uint64(ltree_2, hf_smb_lock_long_length, tvb, offset, 8, val);
COUNT_BYTES(8);
/* remember the unlock for the reply */
if (ld) {
smb_lock_info_t *li;
li = wmem_new(wmem_file_scope(), smb_lock_info_t);
li->next = ld->unlocks;
ld->unlocks = li;
li->pid = lock_pid;
li->offset = lock_offset;
li->length = lock_length;
}
} else {
/* normal lock format */
ltree_2 = proto_tree_add_subtree(tr, tvb, offset, 10, ett_smb_unlock, NULL, "Unlock");
/* PID */
CHECK_BYTE_COUNT(2);
proto_tree_add_item(ltree_2, hf_smb_pid, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES(2);
/* offset */
CHECK_BYTE_COUNT(4);
proto_tree_add_item(ltree_2, hf_smb_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES(4);
/* lock count */
CHECK_BYTE_COUNT(4);
proto_tree_add_item(ltree_2, hf_smb_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES(4);
}
}
proto_item_set_len(it, offset-old_offset);
it = NULL;
}
/* locks */
if (ln) {
old_offset = offset;
tr = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb_locks, &it, "Locks");
while (ln--) {
proto_tree *ltree_2;
if (lt&0x10) {
guint64 val;
guint16 lock_pid;
guint64 lock_offset;
guint64 lock_length;
/* large lock format */
ltree_2 = proto_tree_add_subtree(tr, tvb, offset, 20, ett_smb_lock, NULL, "Lock");
/* PID */
CHECK_BYTE_COUNT(2);
lock_pid = tvb_get_letohs(tvb, offset);
proto_tree_add_item(ltree_2, hf_smb_pid, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES(2);
/* 2 reserved bytes */
CHECK_BYTE_COUNT(2);
proto_tree_add_item(ltree_2, hf_smb_reserved, tvb, offset, 2, ENC_NA);
COUNT_BYTES(2);
/* offset */
CHECK_BYTE_COUNT(8);
val = ((guint64)tvb_get_letohl(tvb, offset)) << 32
| tvb_get_letohl(tvb, offset+4);
lock_offset = val;
proto_tree_add_uint64(ltree_2, hf_smb_lock_long_offset, tvb, offset, 8, val);
COUNT_BYTES(8);
/* length */
CHECK_BYTE_COUNT(8);
val = ((guint64)tvb_get_letohl(tvb, offset)) << 32
| tvb_get_letohl(tvb, offset+4);
lock_length = val;
proto_tree_add_uint64(ltree_2, hf_smb_lock_long_length, tvb, offset, 8, val);
COUNT_BYTES(8);
/* remember the lock for the reply */
if (ld) {
smb_lock_info_t *li;
li = wmem_new(wmem_file_scope(), smb_lock_info_t);
li->next = ld->locks;
ld->locks = li;
li->pid = lock_pid;
li->offset = lock_offset;
li->length = lock_length;
}
} else {
/* normal lock format */
ltree_2 = proto_tree_add_subtree(tr, tvb, offset, 10, ett_smb_lock, NULL, "Lock");
/* PID */
CHECK_BYTE_COUNT(2);
proto_tree_add_item(ltree_2, hf_smb_pid, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES(2);
/* offset */
CHECK_BYTE_COUNT(4);
proto_tree_add_item(ltree_2, hf_smb_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES(4);
/* lock count */
CHECK_BYTE_COUNT(4);
proto_tree_add_item(ltree_2, hf_smb_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES(4);
}
}
proto_item_set_len(it, offset-old_offset);
it = NULL;
}
END_OF_SMB
if (it != NULL) {
/*
* We ran out of byte count in the middle of dissecting
* the locks or the unlocks; set the site of the item
* we were dissecting.
*/
proto_item_set_len(it, offset-old_offset);
}
if (cmd != 0xff) { /* there is an andX command */
if (andxoffset < offset) {
THROW(ReportedBoundsError);
}
dissect_smb_command(tvb, pinfo, andxoffset, smb_tree, cmd, FALSE, si);
}
return offset;
}
static int
dissect_locking_andx_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
guint8 wc, cmd = 0xff;
guint16 andxoffset = 0;
guint16 bc;
DISSECTOR_ASSERT(si);
/* print the lock info from the request */
if ((si->sip != NULL) && (si->sip->extra_info_type == SMB_EI_LOCKDATA)) {
smb_locking_saved_info_t *ld;
proto_item *litem = NULL;
proto_tree *ltree = NULL;
ld = (smb_locking_saved_info_t *)si->sip->extra_info;
if (ld != NULL) {
proto_tree *ltr;
smb_lock_info_t *li;
if (tree) {
litem = proto_tree_add_uint(tree, hf_smb_lock_type, tvb, 0, 0, ld->type);
proto_item_set_generated(litem);
ltree = proto_item_add_subtree(litem, ett_smb_lock_type);
proto_tree_add_boolean(ltree, hf_smb_lock_type_large, tvb, 0, 0, ld->type);
proto_tree_add_boolean(ltree, hf_smb_lock_type_cancel, tvb, 0, 0, ld->type);
proto_tree_add_boolean(ltree, hf_smb_lock_type_change, tvb, 0, 0, ld->type);
proto_tree_add_boolean(ltree, hf_smb_lock_type_oplock, tvb, 0, 0, ld->type);
proto_tree_add_boolean(ltree, hf_smb_lock_type_shared, tvb, 0, 0, ld->type);
proto_tree_add_uint(ltree, hf_smb_locking_ol, tvb, 0, 0, ld->oplock_level);
proto_tree_add_uint(ltree, hf_smb_number_of_unlocks, tvb, 0, 0, ld->num_unlock);
proto_tree_add_uint(ltree, hf_smb_number_of_locks, tvb, 0, 0, ld->num_lock);
ltr = proto_tree_add_subtree(ltree, tvb, 0, 0, ett_smb_lock, NULL, "Locks");
li = ld->locks;
while (li) {
proto_tree_add_uint(ltr, hf_smb_pid, tvb, 0, 0, li->pid);
proto_tree_add_uint64(ltr, hf_smb_lock_long_offset, tvb, 0, 0, li->offset);
proto_tree_add_uint64(ltr, hf_smb_lock_long_length, tvb, 0, 0, li->length);
li = li->next;
}
ltr = proto_tree_add_subtree(ltree, tvb, 0, 0, ett_smb_unlock, NULL, "Unlocks");
li = ld->unlocks;
while (li) {
proto_tree_add_uint(ltr, hf_smb_pid, tvb, 0, 0, li->pid);
proto_tree_add_uint64(ltr, hf_smb_lock_long_offset, tvb, 0, 0, li->offset);
proto_tree_add_uint64(ltr, hf_smb_lock_long_length, tvb, 0, 0, li->length);
li = li->next;
}
}
}
}
WORD_COUNT;
/* next smb command */
cmd = tvb_get_guint8(tvb, offset);
if (cmd != 0xff) {
proto_tree_add_uint(tree, hf_smb_andxcmd, tvb, offset, 1, cmd);
} else {
proto_tree_add_uint_format_value(tree, hf_smb_andxcmd, tvb, offset, 1, cmd, "No further commands (0xff)");
}
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* andxoffset */
andxoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_andxoffset, tvb, offset, 2, andxoffset);
offset += 2;
BYTE_COUNT;
END_OF_SMB
if (cmd != 0xff) { /* there is an andX command */
if (andxoffset < offset) {
THROW(ReportedBoundsError);
}
dissect_smb_command(tvb, pinfo, andxoffset, smb_tree, cmd, FALSE, si);
}
return offset;
}
const value_string oa_open_vals[] = {
{ 0, "No action taken?"},
{ 1, "The file existed and was opened"},
{ 2, "The file did not exist but was created"},
{ 3, "The file existed and was truncated"},
{ 0x8001, "The file existed and was opened, and an OpLock was granted"},
{ 0x8002, "The file did not exist but was created, and an OpLock was granted"},
{ 0x8003, "The file existed and was truncated, and an OpLock was granted"},
{0, NULL}
};
static const true_false_string tfs_oa_lock = {
"File is currently opened only by this user",
"File is opened by another user (or mode not supported by server)"
};
static int
dissect_open_action(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_open_action_lock,
&hf_smb_open_action_open,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_open_action, ett_smb_open_action, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
static const true_false_string tfs_open_flags_add_info = {
"Additional information requested",
"Additional information not requested"
};
static const true_false_string tfs_open_flags_ex_oplock = {
"Exclusive oplock requested",
"Exclusive oplock not requested"
};
static const true_false_string tfs_open_flags_batch_oplock = {
"Batch oplock requested",
"Batch oplock not requested"
};
static const true_false_string tfs_open_flags_ealen = {
"Total length of EAs requested",
"Total length of EAs not requested"
};
static int
dissect_open_flags(tvbuff_t *tvb, proto_tree *parent_tree, int offset, int bm)
{
guint16 mask;
proto_item *item;
proto_tree *tree;
mask = tvb_get_letohs(tvb, offset);
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb_open_flags, tvb, offset, 2, ENC_LITTLE_ENDIAN);
tree = proto_item_add_subtree(item, ett_smb_open_flags);
if (bm&0x0001) {
proto_tree_add_boolean(tree, hf_smb_open_flags_add_info,
tvb, offset, 2, mask);
}
if (bm&0x0002) {
proto_tree_add_boolean(tree, hf_smb_open_flags_ex_oplock,
tvb, offset, 2, mask);
}
if (bm&0x0004) {
proto_tree_add_boolean(tree, hf_smb_open_flags_batch_oplock,
tvb, offset, 2, mask);
}
if (bm&0x0008) {
proto_tree_add_boolean(tree, hf_smb_open_flags_ealen,
tvb, offset, 2, mask);
}
}
offset += 2;
return offset;
}
/* [MS-CIFS].pdf 2.2.4.64.2 provides the last two file types, however
[MS-SMB].PDF 2.2.4.9.2 elides value 4, Character mode device. */
static const value_string filetype_vals[] = {
{ 0, "Disk file or directory"},
{ 1, "Named pipe in byte mode"},
{ 2, "Named pipe in message mode"},
{ 3, "Spooled printer"},
{ 4, "Character mode device"},
{ 0xFFFF, "Unknown file type"},
{0, NULL}
};
static int
dissect_open_andx_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
guint8 wc, cmd = 0xff;
guint16 andxoffset = 0, bc;
guint32 to;
int fn_len;
const char *fn;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* next smb command */
cmd = tvb_get_guint8(tvb, offset);
if (cmd != 0xff) {
proto_tree_add_uint(tree, hf_smb_andxcmd, tvb, offset, 1, cmd);
} else {
proto_tree_add_uint_format_value(tree, hf_smb_andxcmd, tvb, offset, 1, cmd, "No further commands (0xff)");
}
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* andxoffset */
andxoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_andxoffset, tvb, offset, 2, andxoffset);
offset += 2;
/* open flags */
offset = dissect_open_flags(tvb, tree, offset, 0x0007);
/* desired access */
offset = dissect_access(tvb, tree, offset, hf_smb_desired_access);
/* Search Attributes */
offset = dissect_search_attributes(tvb, tree, offset);
/* File Attributes */
offset = dissect_file_attributes(tvb, tree, offset);
/* creation time */
offset = dissect_smb_UTIME(tvb, tree, offset, hf_smb_create_time);
/* open function */
offset = dissect_open_function(tvb, tree, offset);
/* allocation size */
proto_tree_add_item(tree, hf_smb_alloc_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* timeout, described at http://us1.samba.org/samba/ftp/SMB-info/DOSEXTP.TXT */
to = tvb_get_letohl(tvb, offset);
proto_tree_add_uint_format_value(tree, hf_smb_timeout, tvb, offset, 4, to, "%s", smbext20_timeout_msecs_to_str(to));
offset += 4;
/* 4 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
BYTE_COUNT;
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
/* Copied this portion of code from create_andx_request
to guarantee that fsi and si->sip are always correctly filled out */
if ((!pinfo->fd->visited) && si->sip && fn) {
smb_fid_saved_info_t *fsi;
fsi = wmem_new0(wmem_file_scope(), smb_fid_saved_info_t);
fsi->filename = wmem_strdup(wmem_file_scope(), fn);
si->sip->extra_info_type = SMB_EI_FILEDATA;
si->sip->extra_info = fsi;
}
col_append_fstr(pinfo->cinfo, COL_INFO, ", Path: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
END_OF_SMB
if (cmd != 0xff) { /* there is an andX command */
if (andxoffset < offset) {
THROW(ReportedBoundsError);
}
dissect_smb_command(tvb, pinfo, andxoffset, smb_tree, cmd, FALSE, si);
}
return offset;
}
static const true_false_string tfs_ipc_state_nonblocking = {
"Reads/writes return immediately if no data available",
"Reads/writes block if no data available"
};
static const value_string ipc_state_endpoint_vals[] = {
{ 0, "Consumer end of pipe"},
{ 1, "Server end of pipe"},
{0, NULL}
};
static const value_string ipc_state_pipe_type_vals[] = {
{ 0, "Byte stream pipe"},
{ 1, "Message pipe"},
{0, NULL}
};
static const value_string ipc_state_read_mode_vals[] = {
{ 0, "Read pipe as a byte stream"},
{ 1, "Read messages from pipe"},
{0, NULL}
};
int
dissect_ipc_state(tvbuff_t *tvb, proto_tree *parent_tree, int offset, gboolean setstate_flag)
{
static int * const setstate_flags[] = {
&hf_smb_ipc_state_nonblocking,
&hf_smb_ipc_state_read_mode,
NULL
};
static int * const not_setstate_flags[] = {
&hf_smb_ipc_state_nonblocking,
&hf_smb_ipc_state_endpoint,
&hf_smb_ipc_state_pipe_type,
&hf_smb_ipc_state_read_mode,
&hf_smb_ipc_state_icount,
NULL
};
if (!setstate_flag) {
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_ipc_state, ett_smb_ipc_state, not_setstate_flags, ENC_LITTLE_ENDIAN);
} else {
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_ipc_state, ett_smb_ipc_state, setstate_flags, ENC_LITTLE_ENDIAN);
}
offset += 2;
return offset;
}
static int
dissect_open_andx_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
guint8 wc, cmd = 0xff;
guint16 andxoffset = 0, bc;
guint16 fid;
guint16 ftype;
guint16 fattr;
smb_fid_info_t *fid_info = NULL;
gboolean isdir = FALSE;
WORD_COUNT;
/* next smb command */
cmd = tvb_get_guint8(tvb, offset);
if (cmd != 0xff) {
proto_tree_add_uint(tree, hf_smb_andxcmd, tvb, offset, 1, cmd);
} else {
proto_tree_add_uint_format_value(tree, hf_smb_andxcmd, tvb, offset, 1, cmd, "No further commands (0xff)");
}
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* andxoffset */
andxoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_andxoffset, tvb, offset, 2, andxoffset);
offset += 2;
/* fid */
fid = tvb_get_letohs(tvb, offset);
/* we add fid_info= to this call so that we save the result */
fid_info = dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, TRUE, FALSE, FALSE, si);
offset += 2;
/* File Attributes */
fattr = tvb_get_letohs(tvb, offset);
isdir = fattr & SMB_FILE_ATTRIBUTE_DIRECTORY;
offset = dissect_file_attributes(tvb, tree, offset);
/* last write time */
offset = dissect_smb_UTIME(tvb, tree, offset, hf_smb_last_write_time);
/* File Size */
/* We store the file_size in the fid_info */
if (fid_info) {
fid_info->end_of_file = (guint64) tvb_get_letohl(tvb, offset);
}
proto_tree_add_item(tree, hf_smb_file_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* granted access */
offset = dissect_access(tvb, tree, offset, hf_smb_granted_access);
/* File Type */
ftype = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb_file_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* Copied from dissect_nt_create_andx_response
Try to remember the type of this fid so that we can dissect
any future security descriptor (access mask) properly
*/
if (fid_info) {
fid_info->type = SMB_FID_TYPE_UNKNOWN;
}
if (ftype == 0) {
if (isdir == 0) {
if (fid_info) {
fid_info->type = SMB_FID_TYPE_FILE;
}
} else {
if (fid_info) {
fid_info->type = SMB_FID_TYPE_DIR;
}
}
}
if ((ftype == 2) || (ftype == 1)) {
if (fid_info) {
fid_info->type = SMB_FID_TYPE_PIPE;
}
}
/* IPC State */
offset = dissect_ipc_state(tvb, tree, offset, FALSE);
/* open_action */
offset = dissect_open_action(tvb, tree, offset);
/* server fid */
proto_tree_add_item(tree, hf_smb_server_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* 2 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* [MS-SMB] 2.2.4.1.2 Server Response Extensions */
if (wc == 19) {
proto_tree *tr = NULL;
tr = proto_tree_add_subtree(tree, tvb, offset, 4,
ett_smb_nt_access_mask, NULL, "Maximal Access Rights");
offset = dissect_smb_access_mask(tvb, tr, offset);
tr = proto_tree_add_subtree(tree, tvb, offset, 4,
ett_smb_nt_access_mask, NULL, "Guest Maximal Access Rights");
offset = dissect_smb_access_mask(tvb, tr, offset);
}
BYTE_COUNT;
END_OF_SMB
if (cmd != 0xff) { /* there is an andX command */
if (andxoffset < offset) {
THROW(ReportedBoundsError);
}
dissect_smb_command(tvb, pinfo, andxoffset, smb_tree, cmd, FALSE, si);
}
return offset;
}
static int
dissect_read_andx_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
guint8 wc, cmd = 0xff;
guint16 andxoffset = 0, bc, maxcnt_low;
guint32 maxcnt_high;
guint32 maxcnt = 0;
guint32 offsetlow, offsethigh = 0;
guint64 ofs;
unsigned int fid;
rw_info_t *rwi = NULL;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* next smb command */
cmd = tvb_get_guint8(tvb, offset);
if (cmd != 0xff) {
proto_tree_add_uint(tree, hf_smb_andxcmd, tvb, offset, 1, cmd);
} else {
proto_tree_add_uint_format_value(tree, hf_smb_andxcmd, tvb, offset, 1, cmd, "No further commands (0xff)");
}
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* andxoffset */
andxoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_andxoffset, tvb, offset, 2, andxoffset);
offset += 2;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, (guint16) fid, FALSE, FALSE, FALSE, si);
offset += 2;
/* offset */
offsetlow = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* max count low */
maxcnt_low = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_max_count_low, tvb, offset, 2, maxcnt_low);
offset += 2;
/* min count */
proto_tree_add_item(tree, hf_smb_min_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/*
* max count high
*
* XXX - we should really only do this in case we have seen
* LARGE FILE being negotiated. Unfortunately, we might not
* have seen the negotiation phase in the capture....
*
* XXX - this is shown as a ULONG in the SNIA SMB spec, i.e.
* it's 32 bits, but the description says "High 16 bits of
* MaxCount if CAP_LARGE_READX".
*
* The SMB File Sharing Protocol Extensions Version 2.0,
* Document Version 3.3 spec doesn't speak of an extra 16
* bits in max count, but it does show a 32-bit timeout
* after the min count field.
*
* The Microsoft [MS-SMB] spec shows it as a ULONG named
* Timeout_or_MaxCountHigh, which is
*
* ...extended to be treated as a union of a 32-bit
* Timeout field and a 16-bit MaxCountHigh field.
* When reading from a regular file, the field
* MUST be interpreted as MaxCountHigh and the
* two unused bytes MUST be zero. When reading from
* a name[sic] pipe or I/O device, the field MUST
* be interpreted as Timeout.
*
* Timeout is a timeout in milliseconds, with 0xffffffff
* and 0xfffffffe having special meaning.
*
* MaxCountHigh is 16 bits of the MaxCountHigh value
* followed by 16 bits of Reserved.
*
* We fetch and display it as 32 bits for now.
*
* XXX if maxcount high is 0xFFFFFFFF we assume it is just padding
* bytes and we just ignore it.
*/
maxcnt_high = tvb_get_letohl(tvb, offset);
if (maxcnt_high == 0xffffffff) {
maxcnt_high = 0;
} else {
proto_tree_add_uint(tree, hf_smb_max_count_high, tvb, offset, 4, maxcnt_high);
}
offset += 4;
maxcnt = maxcnt_high;
maxcnt = (maxcnt<<16) | maxcnt_low;
/* remaining */
proto_tree_add_item(tree, hf_smb_remaining, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
if (wc == 12) {
/* high offset */
offsethigh = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb_high_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
ofs = offsethigh;
ofs = (ofs<<32) | offsetlow;
col_append_fstr(pinfo->cinfo, COL_INFO,
", %u byte%s at offset %" PRIu64,
maxcnt, (maxcnt == 1) ? "" : "s", ofs);
/* save the offset/len for this transaction */
if (si->sip && !pinfo->fd->visited) {
rwi = wmem_new(wmem_file_scope(), rw_info_t);
rwi->offset = ofs;
rwi->len = maxcnt;
rwi->fid = fid;
si->sip->extra_info_type = SMB_EI_RWINFO;
si->sip->extra_info = rwi;
}
if (si->sip && (si->sip->extra_info_type == SMB_EI_RWINFO)) {
rwi = (rw_info_t *)si->sip->extra_info;
}
if (rwi) {
proto_item *it;
it = proto_tree_add_uint64(tree, hf_smb_file_rw_offset, tvb, 0, 0, rwi->offset);
proto_item_set_generated(it);
it = proto_tree_add_uint(tree, hf_smb_file_rw_length, tvb, 0, 0, rwi->len);
proto_item_set_generated(it);
}
BYTE_COUNT;
END_OF_SMB
if (cmd != 0xff) { /* there is an andX command */
if (andxoffset < offset) {
THROW(ReportedBoundsError);
}
dissect_smb_command(tvb, pinfo, andxoffset, smb_tree, cmd, FALSE, si);
}
return offset;
}
static int
dissect_read_andx_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
guint8 wc, cmd = 0xff;
guint16 andxoffset = 0, bc, datalen_low, dataoffset = 0;
guint32 datalen = 0, datalen_high;
rw_info_t *rwi = NULL;
guint16 fid = 0; /* was int fid = 0; */
guint32 tvblen;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* next smb command */
cmd = tvb_get_guint8(tvb, offset);
if (cmd != 0xff) {
proto_tree_add_uint(tree, hf_smb_andxcmd, tvb, offset, 1, cmd);
} else {
proto_tree_add_uint_format_value(tree, hf_smb_andxcmd, tvb, offset, 1, cmd, "No further commands (0xff)");
}
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* andxoffset */
andxoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_andxoffset, tvb, offset, 2, andxoffset);
offset += 2;
/* If we have seen the request, then print which FID this refers to */
/* first check if we have seen the request */
if ((si->sip != NULL) && (si->sip->frame_req > 0) && (si->sip->extra_info_type == SMB_EI_FID)) {
fid = GPOINTER_TO_INT(si->sip->extra_info);
dissect_smb_fid(tvb, pinfo, tree, 0, 0, (guint16) fid, FALSE, FALSE, FALSE, si);
}
if (si->sip && (si->sip->extra_info_type == SMB_EI_RWINFO)) {
rwi = (rw_info_t *)si->sip->extra_info;
}
if (rwi) {
proto_item *it;
it = proto_tree_add_uint64(tree, hf_smb_file_rw_offset, tvb, 0, 0, rwi->offset);
proto_item_set_generated(it);
it = proto_tree_add_uint(tree, hf_smb_file_rw_length, tvb, 0, 0, rwi->len);
proto_item_set_generated(it);
/* we need the fid for the call to dcerpc below */
fid = rwi->fid;
}
/* remaining */
proto_tree_add_item(tree, hf_smb_remaining, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* data compaction mode */
proto_tree_add_item(tree, hf_smb_dcm, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* 2 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* data len low */
datalen_low = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_len_low, tvb, offset, 2, datalen_low);
offset += 2;
/* data offset */
dataoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_offset, tvb, offset, 2, dataoffset);
offset += 2;
/*
* XXX - the SNIA SMB spec says this is a USHORT, not a
* ULONG.
*
* XXX - we should really only do this in case we have seen
* LARGE FILE being negotiated. Unfortunately, we might not
* have seen the negotiation phase in the capture....
*/
/* data length high */
datalen_high = tvb_get_letohl(tvb, offset);
if (datalen_high == 0xffffffff) {
datalen_high = 0;
} else {
proto_tree_add_uint(tree, hf_smb_data_len_high, tvb, offset, 4, datalen_high);
}
offset += 4;
datalen = datalen_high;
datalen = (datalen<<16) | datalen_low;
col_append_fstr(pinfo->cinfo, COL_INFO,
", %u byte%s", datalen,
(datalen == 1) ? "" : "s");
/* 6 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 6, ENC_NA);
offset += 6;
BYTE_COUNT;
/* file data, might be DCERPC on a pipe */
if (bc) {
offset = dissect_file_data_maybe_dcerpc(tvb, pinfo, tree,
top_tree_global, offset, bc, -1, (guint16) datalen, 0, (guint16) fid, si);
bc = 0;
}
/* feed the export object tap listener */
tvblen = tvb_reported_length_remaining(tvb, dataoffset);
if (have_tap_listener(smb_eo_tap) && (datalen == tvblen) && rwi) {
feed_eo_smb(SMB_COM_READ_ANDX, fid, tvb, pinfo, dataoffset, datalen, rwi->len, rwi->offset, si);
}
END_OF_SMB
if (cmd != 0xff) { /* there is an andX command */
if (andxoffset < offset) {
THROW(ReportedBoundsError);
}
dissect_smb_command(tvb, pinfo, andxoffset, smb_tree, cmd, FALSE, si);
}
return offset;
}
/* SMB_COM_WRITE_ANDX(0x2F)
https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/a66126d2-a1db-446b-8736-b9f5559c49bd
*/
static int
dissect_write_andx_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
guint8 wc, cmd = 0xff;
guint16 andxoffset = 0, bc, dataoffset = 0, datalen_low, datalen_high;
guint32 offsetlow, offsethigh = 0;
guint64 ofs;
guint32 datalen = 0;
guint16 fid = 0; /* was unsigned int fid = 0; */
guint16 mode = 0;
rw_info_t *rwi = NULL;
guint32 tvblen;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* next smb command */
cmd = tvb_get_guint8(tvb, offset);
if (cmd != 0xff) {
proto_tree_add_uint(tree, hf_smb_andxcmd, tvb, offset, 1, cmd);
} else {
proto_tree_add_uint_format_value(tree, hf_smb_andxcmd, tvb, offset, 1, cmd, "No further commands (0xff)");
}
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* andxoffset */
andxoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_andxoffset, tvb, offset, 2, andxoffset);
offset += 2;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, (guint16) fid, FALSE, FALSE, FALSE, si);
offset += 2;
/* offset */
offsetlow = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* reserved */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
/* mode */
mode = tvb_get_letohs(tvb, offset);
offset = dissect_write_mode(tvb, tree, offset, 0x000f);
/* remaining */
proto_tree_add_item(tree, hf_smb_remaining, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/*
* XXX - we should really only do this in case we have seen
* LARGE FILE being negotiated. Unfortunately, we might not
* have seen the negotiation phase in the capture....
*/
/* data length high */
datalen_high = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_len_high, tvb, offset, 2, datalen_high);
offset += 2;
/* data len low */
datalen_low = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_len_low, tvb, offset, 2, datalen_low);
offset += 2;
datalen = datalen_high;
datalen = (datalen<<16) | datalen_low;
/* data offset */
dataoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_offset, tvb, offset, 2, dataoffset);
offset += 2;
if (wc == 14) {
/* high offset */
offsethigh = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb_high_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
ofs = offsethigh;
ofs = (ofs<<32) | offsetlow;
col_append_fstr(pinfo->cinfo, COL_INFO,
", %u byte%s at offset %" PRIu64,
datalen, (datalen == 1) ? "" : "s", ofs);
/* save the offset/len for this transaction */
if (si->sip && !pinfo->fd->visited) {
rwi = wmem_new(wmem_file_scope(), rw_info_t);
rwi->offset = ofs;
rwi->len = datalen;
rwi->fid = fid;
si->sip->extra_info_type = SMB_EI_RWINFO;
si->sip->extra_info = rwi;
}
if (si->sip && (si->sip->extra_info_type == SMB_EI_RWINFO)) {
rwi = (rw_info_t *)si->sip->extra_info;
}
if (rwi) {
proto_item *it;
it = proto_tree_add_uint64(tree, hf_smb_file_rw_offset, tvb, 0, 0, rwi->offset);
proto_item_set_generated(it);
it = proto_tree_add_uint(tree, hf_smb_file_rw_length, tvb, 0, 0, rwi->len);
proto_item_set_generated(it);
}
BYTE_COUNT;
/* if both the MessageStart and the WriteRawNamedPipe flags are set
the first two bytes of the payload is the length of the data.
Assume that all WriteAndX PDUs that have MESSAGE_START set to
be over the IPC$ share and thus they all transport DCERPC.
(if we didn't already know that from the TreeConnect call)
*/
if (mode&WRITE_MODE_MESSAGE_START) {
if (mode&WRITE_MODE_RAW) {
proto_tree_add_item(tree, hf_smb_pipe_write_len, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
dataoffset += 2;
bc -= 2;
datalen -= 2;
}
if (!pinfo->fd->visited) {
/* In case we did not see the TreeConnect call,
store this TID here as well as a IPC TID
so we know that future Read/Writes to this
TID is (probably) DCERPC.
*/
if (g_hash_table_lookup(si->ct->tid_service, GUINT_TO_POINTER(si->tid))) {
g_hash_table_remove(si->ct->tid_service, GUINT_TO_POINTER(si->tid));
}
g_hash_table_insert(si->ct->tid_service, GUINT_TO_POINTER(si->tid), (void *)TID_IPC);
}
if (si->sip) {
si->sip->flags |= SMB_SIF_TID_IS_IPC;
}
}
/* file data, might be DCERPC on a pipe */
if (bc != 0) {
/* https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/a66126d2-a1db-446b-8736-b9f5559c49bd
The DataOffset field can be used to relocate the SMB_Data.Bytes.Data
block to the end of the message,even if the message is a multi-part AndX
chain. If the SMB_Data.Bytes.Data block is relocated, the contents of
SMB_Data.Bytes will not be contiguous.
*/
offset = dissect_file_data_maybe_dcerpc(tvb, pinfo, tree,
top_tree_global, offset, bc, dataoffset, (guint16) datalen, 0, (guint16) fid, si);
bc = 0;
}
/* feed the export object tap listener */
tvblen = tvb_reported_length_remaining(tvb, dataoffset);
if (have_tap_listener(smb_eo_tap) && (datalen == tvblen) && rwi) {
feed_eo_smb(SMB_COM_WRITE_ANDX, fid, tvb, pinfo, dataoffset, datalen, rwi->len, rwi->offset, si);
}
END_OF_SMB
if (cmd != 0xff) { /* there is an andX command */
if (andxoffset < offset) {
THROW(ReportedBoundsError);
}
dissect_smb_command(tvb, pinfo, andxoffset, smb_tree, cmd, FALSE, si);
}
return offset;
}
static int
dissect_write_andx_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
guint8 wc, cmd = 0xff;
guint16 andxoffset = 0, bc, count_low, count_high;
guint32 count = 0;
rw_info_t *rwi = NULL;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* next smb command */
cmd = tvb_get_guint8(tvb, offset);
if (cmd != 0xff) {
proto_tree_add_uint(tree, hf_smb_andxcmd, tvb, offset, 1, cmd);
} else {
proto_tree_add_uint_format_value(tree, hf_smb_andxcmd, tvb, offset, 1, cmd, "No further commands (0xff)");
}
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* andxoffset */
andxoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_andxoffset, tvb, offset, 2, andxoffset);
offset += 2;
if (si->sip && (si->sip->extra_info_type == SMB_EI_RWINFO)) {
rwi = (rw_info_t *)si->sip->extra_info;
}
if (rwi) {
proto_item *it;
it = proto_tree_add_uint64(tree, hf_smb_file_rw_offset, tvb, 0, 0, rwi->offset);
proto_item_set_generated(it);
it = proto_tree_add_uint(tree, hf_smb_file_rw_length, tvb, 0, 0, rwi->len);
proto_item_set_generated(it);
}
/* write count low */
count_low = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_count_low, tvb, offset, 2, count_low);
offset += 2;
/* remaining */
proto_tree_add_item(tree, hf_smb_remaining, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* XXX we should really only do this in case we have seen LARGE FILE being negotiated */
/* write count high */
count_high = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_count_high, tvb, offset, 2, count_high);
offset += 2;
count = count_high;
count = (count<<16) | count_low;
col_append_fstr(pinfo->cinfo, COL_INFO,
", %u byte%s", count,
(count == 1) ? "" : "s");
/* 2 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
BYTE_COUNT;
END_OF_SMB
if (cmd != 0xff) { /* there is an andX command */
if (andxoffset < offset) {
THROW(ReportedBoundsError);
}
dissect_smb_command(tvb, pinfo, andxoffset, smb_tree, cmd, FALSE, si);
}
return offset;
}
static const true_false_string tfs_setup_action_guest = {
"Logged in as GUEST",
"Not logged in as GUEST"
};
static int
dissect_setup_action(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_setup_action_guest,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_setup_action, ett_smb_setup_action, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
static int
dissect_session_setup_andx_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
guint8 wc, cmd = 0xff;
guint16 bc;
guint16 andxoffset = 0;
int an_len;
const char *an;
int dn_len;
const char *dn;
guint16 pwlen = 0;
guint16 sbloblen = 0, sbloblen_short;
guint16 apwlen = 0, upwlen = 0;
gboolean unicodeflag;
static int ntlmssp_tap_id = 0;
const ntlmssp_header_t *ntlmssph;
if (!ntlmssp_tap_id) {
GString *error_string;
/* We don't specify any callbacks at all.
* Instead we manually fetch the tapped data after the
* security blob has been fully dissected and before
* we exit from this dissector.
*/
error_string = register_tap_listener("ntlmssp", NULL, NULL,
TL_IS_DISSECTOR_HELPER, NULL, NULL, NULL, NULL);
if (!error_string) {
ntlmssp_tap_id = find_tap_id("ntlmssp");
} else {
g_string_free(error_string, TRUE);
}
}
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* next smb command */
cmd = tvb_get_guint8(tvb, offset);
if (cmd != 0xff) {
proto_tree_add_uint(tree, hf_smb_andxcmd, tvb, offset, 1, cmd);
} else {
proto_tree_add_uint_format_value(tree, hf_smb_andxcmd, tvb, offset, 1, cmd, "No further commands (0xff)");
}
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* andxoffset */
andxoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_andxoffset, tvb, offset, 2, andxoffset);
offset += 2;
/* Maximum Buffer Size */
proto_tree_add_item(tree, hf_smb_max_buf_size, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* Maximum Multiplex Count */
proto_tree_add_item(tree, hf_smb_max_mpx_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* VC Number */
proto_tree_add_item(tree, hf_smb_vc_num, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* session key */
proto_tree_add_item(tree, hf_smb_session_key, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
switch (wc) {
case 10:
/* password length, ASCII*/
pwlen = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_password_len,
tvb, offset, 2, pwlen);
offset += 2;
/* 4 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
break;
case 12:
/* security blob length */
sbloblen = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_security_blob_len, tvb, offset, 2, sbloblen);
offset += 2;
/* 4 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
/* capabilities */
dissect_negprot_capabilities(tvb, tree, offset);
offset += 4;
break;
case 13:
/* password length, ANSI*/
apwlen = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_ansi_password_len,
tvb, offset, 2, apwlen);
offset += 2;
/* password length, Unicode*/
upwlen = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_unicode_password_len,
tvb, offset, 2, upwlen);
offset += 2;
/* 4 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
/* capabilities */
dissect_negprot_capabilities(tvb, tree, offset);
offset += 4;
break;
}
BYTE_COUNT;
if (wc == 12) {
proto_item *blob_item;
/* security blob */
/* If it runs past the end of the captured data, don't
* try to put all of it into the protocol tree as the
* raw security blob; we might get an exception on
* short frames and then we will not see anything at all
* of the security blob.
*/
sbloblen_short = sbloblen;
if (sbloblen_short > tvb_reported_length_remaining(tvb, offset)) {
sbloblen_short = tvb_reported_length_remaining(tvb, offset);
}
blob_item = proto_tree_add_item(tree, hf_smb_security_blob,
tvb, offset, sbloblen_short,
ENC_NA);
/* As an optimization, because Windows is perverse,
we check to see if NTLMSSP is the first part of the
blob, and if so, call the NTLMSSP dissector,
otherwise we call the GSS-API dissector. This is because
Windows can request RAW NTLMSSP, but will happily handle
a client that wraps NTLMSSP in SPNEGO
*/
if (sbloblen) {
tvbuff_t *blob_tvb;
proto_tree *blob_tree;
blob_tree = proto_item_add_subtree(blob_item,
ett_smb_secblob);
CHECK_BYTE_COUNT(sbloblen);
/*
* Set the reported length of this to the reported
* length of the blob, rather than the amount of
* data available from the blob, so that we'll
* throw the right exception if it's too short.
*/
blob_tvb = tvb_new_subset_length_caplen(tvb, offset, sbloblen_short,
sbloblen);
if (si && si->ct && si->ct->raw_ntlmssp &&
(tvb_strneql(tvb, offset, "NTLMSSP", 7) == 0)) {
call_dissector(ntlmssp_handle, blob_tvb, pinfo,
blob_tree);
}
else {
call_dissector(gssapi_handle, blob_tvb,
pinfo, blob_tree);
}
/* If we have found a uid->acct_name mapping, store it */
if (!pinfo->fd->visited && si->sip) {
int idx = 0;
if ((ntlmssph = (const ntlmssp_header_t *)fetch_tapped_data(ntlmssp_tap_id, idx + 1 )) != NULL) {
if (ntlmssph && (ntlmssph->type == 3)) {
smb_uid_t *smb_uid;
smb_uid = wmem_new(wmem_file_scope(), smb_uid_t);
smb_uid->logged_in = -1;
smb_uid->logged_out = -1;
smb_uid->domain = wmem_strdup(wmem_file_scope(), ntlmssph->domain_name);
smb_uid->account = wmem_strdup(wmem_file_scope(), ntlmssph->acct_name);
si->sip->extra_info = smb_uid;
si->sip->extra_info_type = SMB_EI_UID;
}
}
}
COUNT_BYTES(sbloblen);
}
/* OS
* Eventhough this field should honour the unicode flag
* some ms clients gets this wrong.
* At least XP SP1 sends this in ASCII
* even when the unicode flag is on.
* Test if the first three bytes are "Win"
* and if so just override the flag.
*/
unicodeflag = si->unicode;
if ( tvb_strneql(tvb, offset, "Win", 3) == 0 ) {
unicodeflag = FALSE;
}
an = get_unicode_or_ascii_string(tvb, &offset,
unicodeflag, &an_len, FALSE, FALSE, &bc);
if (an == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_os, tvb,
offset, an_len, an);
COUNT_BYTES(an_len);
/* LANMAN */
/* XXX - pre-W2K NT systems appear to stick an extra 2 bytes of
* padding/null string/whatever in front of this. W2K doesn't
* appear to. I suspect that's a bug that got fixed; I also
* suspect that, in practice, nobody ever looks at that field
* because the bug didn't appear to get fixed until NT 5.0....
*
* Eventhough this field should honour the unicode flag
* some ms clients gets this wrong.
* At least XP SP1 sends this in ASCII
* even when the unicode flag is on.
* Test if the first three bytes are "Win"
* and if so just override the flag.
*/
unicodeflag = si->unicode;
if ( tvb_strneql(tvb, offset, "Win", 3) == 0 ) {
unicodeflag = FALSE;
}
an = get_unicode_or_ascii_string(tvb, &offset,
unicodeflag, &an_len, FALSE, FALSE, &bc);
if (an == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_lanman, tvb,
offset, an_len, an);
COUNT_BYTES(an_len);
/* Primary domain */
/* XXX - pre-W2K NT systems sometimes appear to stick an extra
* byte in front of this, at least if all the strings are
* ASCII and the account name is empty. Another bug?
*/
dn = get_unicode_or_ascii_string(tvb, &offset,
si->unicode, &dn_len, FALSE, FALSE, &bc);
if (dn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_primary_domain, tvb,
offset, dn_len, dn);
COUNT_BYTES(dn_len);
} else {
switch (wc) {
case 10:
if (pwlen) {
/* password, ASCII */
CHECK_BYTE_COUNT(pwlen);
proto_tree_add_item(tree, hf_smb_password,
tvb, offset, pwlen, ENC_NA);
COUNT_BYTES(pwlen);
}
break;
case 13:
if (apwlen) {
/* password, ANSI */
CHECK_BYTE_COUNT(apwlen);
proto_tree_add_item(tree, hf_smb_ansi_password,
tvb, offset, apwlen, ENC_NA);
COUNT_BYTES(apwlen);
}
if (upwlen) {
proto_item *item;
/* password, Unicode */
CHECK_BYTE_COUNT(upwlen);
item = proto_tree_add_item(tree, hf_smb_unicode_password,
tvb, offset, upwlen, ENC_NA);
if (upwlen > 24) {
proto_tree *subtree;
subtree = proto_item_add_subtree(item, ett_smb_unicode_password);
dissect_ntlmv2_response(tvb, pinfo, subtree, offset, upwlen);
}
COUNT_BYTES(upwlen);
}
break;
}
/* Account Name */
an = get_unicode_or_ascii_string(tvb, &offset,
si->unicode, &an_len, FALSE, FALSE, &bc);
if (an == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_account, tvb, offset, an_len,
an);
COUNT_BYTES(an_len);
/* Primary domain */
/* XXX - pre-W2K NT systems sometimes appear to stick an extra
* byte in front of this, at least if all the strings are
* ASCII and the account name is empty. Another bug?
*/
dn = get_unicode_or_ascii_string(tvb, &offset,
si->unicode, &dn_len, FALSE, FALSE, &bc);
if (dn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_primary_domain, tvb,
offset, dn_len, dn);
COUNT_BYTES(dn_len);
col_append_str(pinfo->cinfo, COL_INFO, ", User: ");
if (!dn[0] && !an[0])
col_append_str(pinfo->cinfo, COL_INFO, "anonymous");
else
col_append_fstr(pinfo->cinfo, COL_INFO,
"%s\\%s",
format_text(wmem_packet_scope(), (const guchar*)dn, strlen(dn)),
format_text(wmem_packet_scope(), (const guchar*)an, strlen(an)));
/* OS */
an = get_unicode_or_ascii_string(tvb, &offset,
si->unicode, &an_len, FALSE, FALSE, &bc);
if (an == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_os, tvb,
offset, an_len, an);
COUNT_BYTES(an_len);
/* LANMAN */
/* XXX - pre-W2K NT systems appear to stick an extra 2 bytes of
* padding/null string/whatever in front of this. W2K doesn't
* appear to. I suspect that's a bug that got fixed; I also
* suspect that, in practice, nobody ever looks at that field
* because the bug didn't appear to get fixed until NT 5.0....
*/
an = get_unicode_or_ascii_string(tvb, &offset,
si->unicode, &an_len, FALSE, FALSE, &bc);
if (an == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_lanman, tvb,
offset, an_len, an);
COUNT_BYTES(an_len);
}
END_OF_SMB
if (cmd != 0xff) { /* there is an andX command */
if (andxoffset < offset) {
THROW(ReportedBoundsError);
}
dissect_smb_command(tvb, pinfo, andxoffset, smb_tree, cmd, FALSE, si);
}
return offset;
}
static int
dissect_session_setup_andx_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
guint8 wc, cmd = 0xff;
guint16 andxoffset = 0, bc;
guint16 sbloblen = 0;
int an_len;
const char *an;
DISSECTOR_ASSERT(si);
WORD_COUNT;
if (!pinfo->fd->visited && si->sip && si->sip->extra_info &&
(si->sip->extra_info_type == SMB_EI_UID)) {
smb_uid_t *smb_uid;
smb_uid = (smb_uid_t *)si->sip->extra_info;
smb_uid->logged_in = pinfo->num;
wmem_tree_insert32(si->ct->uid_tree, si->uid, smb_uid);
}
/* next smb command */
cmd = tvb_get_guint8(tvb, offset);
if (cmd != 0xff) {
proto_tree_add_uint(tree, hf_smb_andxcmd, tvb, offset, 1, cmd);
} else {
proto_tree_add_uint_format_value(tree, hf_smb_andxcmd, tvb, offset, 1, cmd, "No further commands (0xff)");
}
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* andxoffset */
andxoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_andxoffset, tvb, offset, 2, andxoffset);
offset += 2;
/* flags */
offset = dissect_setup_action(tvb, tree, offset);
if (wc == 4) {
/* security blob length */
sbloblen = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_security_blob_len, tvb, offset, 2, sbloblen);
offset += 2;
}
BYTE_COUNT;
if (wc == 4) {
proto_item *blob_item;
/* security blob */
/* don't try to eat too much of we might get an exception on
* short frames and then we will not see anything at all
* of the security blob.
*/
if (sbloblen > tvb_reported_length_remaining(tvb, offset)) {
sbloblen = tvb_reported_length_remaining(tvb, offset);
}
blob_item = proto_tree_add_item(tree, hf_smb_security_blob,
tvb, offset, sbloblen, ENC_NA);
if (sbloblen) {
tvbuff_t *blob_tvb;
proto_tree *blob_tree;
blob_tree = proto_item_add_subtree(blob_item,
ett_smb_secblob);
CHECK_BYTE_COUNT(sbloblen);
blob_tvb = tvb_new_subset_length(tvb, offset, sbloblen);
if (si && si->ct && si->ct->raw_ntlmssp &&
(tvb_strneql(tvb, offset, "NTLMSSP", 7) == 0)) {
call_dissector(ntlmssp_handle, blob_tvb, pinfo,
blob_tree);
}
else {
call_dissector(gssapi_handle, blob_tvb, pinfo,
blob_tree);
}
COUNT_BYTES(sbloblen);
}
}
/* OS */
an = get_unicode_or_ascii_string(tvb, &offset,
si->unicode, &an_len, FALSE, FALSE, &bc);
if (an == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_os, tvb,
offset, an_len, an);
COUNT_BYTES(an_len);
/* LANMAN */
an = get_unicode_or_ascii_string(tvb, &offset,
si->unicode, &an_len, FALSE, FALSE, &bc);
if (an == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_lanman, tvb,
offset, an_len, an);
COUNT_BYTES(an_len);
if ((wc == 3) || (wc == 4)) {
/* Primary domain */
an = get_unicode_or_ascii_string(tvb, &offset,
si->unicode, &an_len, FALSE, FALSE, &bc);
if (an == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_primary_domain, tvb,
offset, an_len, an);
COUNT_BYTES(an_len);
}
END_OF_SMB
if (cmd != 0xff) { /* there is an andX command */
if (andxoffset < offset) {
THROW(ReportedBoundsError);
}
dissect_smb_command(tvb, pinfo, andxoffset, smb_tree, cmd, FALSE, si);
}
return offset;
}
static int
dissect_empty_andx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si _U_)
{
guint8 wc, cmd = 0xff;
guint16 andxoffset = 0;
guint16 bc;
WORD_COUNT;
/* next smb command */
cmd = tvb_get_guint8(tvb, offset);
if (cmd != 0xff) {
proto_tree_add_uint(tree, hf_smb_andxcmd, tvb, offset, 1, cmd);
} else {
proto_tree_add_uint_format_value(tree, hf_smb_andxcmd, tvb, offset, 1, cmd, "No further commands (0xff)");
}
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* andxoffset */
andxoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_andxoffset, tvb, offset, 2, andxoffset);
offset += 2;
BYTE_COUNT;
END_OF_SMB
if (cmd != 0xff) { /* there is an andX command */
if (andxoffset < offset) {
THROW(ReportedBoundsError);
}
dissect_smb_command(tvb, pinfo, andxoffset, smb_tree, cmd, FALSE, si);
}
return offset;
}
/*
* From [MS-SMB] - v20100711 Server Message Block (SMB) Protocol Specification
* http://download.microsoft.com/download/a/e/6/ae6e4142-aa58-45c6-8dcf-a657e5900cd3/%5BMS-SMB%5D.pdf
* 2.2.4.7 SMB_COM_TREE_CONNECT_ANDX (0x75)
*/
static const true_false_string tfs_connect_support_search = {
"Exclusive search bits supported",
"Exclusive search bits not supported"
};
static const true_false_string tfs_connect_support_in_dfs = {
"Share is in Dfs",
"Share isn't in Dfs"
};
static const value_string connect_support_csc_mask_vals[] = {
{ 0, "Automatic file-to-file reintegration NOT permitted"},
{ 1, "Automatic file-to-file reintegration permitted"},
{ 2, "Offline caching allow for the share"},
{ 3, "Offline caching NOT allow for the share"},
{0, NULL}
};
static const true_false_string tfs_connect_support_uniquefilename = {
"Client allowed to cache share namespaces",
"Client NOT allowed to cache share namespaces"
};
static const true_false_string tfs_connect_support_extended_signature = {
"Extended signature",
"NOT extended signature"
};
static int
dissect_connect_support_bits(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_connect_support_search,
&hf_smb_connect_support_in_dfs,
&hf_smb_connect_support_csc_mask_vals,
&hf_smb_connect_support_uniquefilename,
&hf_smb_connect_support_extended_signature,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_connect_support, ett_smb_connect_support_bits, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
static const true_false_string tfs_disconnect_tid = {
"DISCONNECT TID",
"Do NOT disconnect TID"
};
static const true_false_string tfs_extended_signature = {
"Extended Signature",
"NOT Extended Signature"
};
static const true_false_string tfs_extended_response = {
"Extended Response",
"NOT Extended Response"
};
static int
dissect_connect_flags(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_connect_flags_dtid,
&hf_smb_connect_flags_ext_sig,
&hf_smb_connect_flags_ext_resp,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_connect_flags, ett_smb_connect_flags, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
static int
dissect_tree_connect_andx_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
guint8 wc, cmd = 0xff;
guint16 bc;
guint16 andxoffset = 0, pwlen = 0;
int an_len;
const guint8 *an;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* next smb command */
cmd = tvb_get_guint8(tvb, offset);
if (cmd != 0xff) {
proto_tree_add_uint(tree, hf_smb_andxcmd, tvb, offset, 1, cmd);
} else {
proto_tree_add_uint_format_value(tree, hf_smb_andxcmd, tvb, offset, 1, cmd, "No further commands (0xff)");
}
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* andxoffset */
andxoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_andxoffset, tvb, offset, 2, andxoffset);
offset += 2;
/* flags */
offset = dissect_connect_flags(tvb, tree, offset);
/* password length*/
pwlen = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_password_len, tvb, offset, 2, pwlen);
offset += 2;
BYTE_COUNT;
/* password */
CHECK_BYTE_COUNT(pwlen);
proto_tree_add_item(tree, hf_smb_password,
tvb, offset, pwlen, ENC_NA);
COUNT_BYTES(pwlen);
/* Path */
an = get_unicode_or_ascii_string(tvb, &offset,
si->unicode, &an_len, FALSE, FALSE, &bc);
if (an == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_path, tvb,
offset, an_len, an);
COUNT_BYTES(an_len);
/* store it for the tid->name/openframe/closeframe matching in
* dissect_smb_tid() called from the response.
*/
if ((!pinfo->fd->visited) && si->sip && an) {
si->sip->extra_info_type = SMB_EI_TIDNAME;
si->sip->extra_info = wmem_strdup(wmem_file_scope(), an);
}
col_append_fstr(pinfo->cinfo, COL_INFO, ", Path: %s",
format_text(wmem_packet_scope(), (const guchar*)an, strlen(an)));
/*
* NOTE: the Service string is always ASCII, even if the
* "strings are Unicode" bit is set in the flags2 field
* of the SMB.
*/
/* Service */
/* XXX - what if this runs past bc? */
an_len = tvb_strsize(tvb, offset);
CHECK_BYTE_COUNT(an_len);
proto_tree_add_item_ret_string(tree, hf_smb_service, tvb,
offset, an_len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &an);
COUNT_BYTES(an_len);
END_OF_SMB
if (cmd != 0xff) { /* there is an andX command */
if (andxoffset < offset) {
THROW(ReportedBoundsError);
}
dissect_smb_command(tvb, pinfo, andxoffset, smb_tree, cmd, FALSE, si);
}
return offset;
}
static int
dissect_tree_connect_andx_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
guint8 wc, cmd = 0xff;
guint16 andxoffset = 0;
guint16 bc;
int an_len;
const guint8 *an;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* next smb command */
cmd = tvb_get_guint8(tvb, offset);
if (cmd != 0xff) {
proto_tree_add_uint(tree, hf_smb_andxcmd, tvb, offset, 1, cmd);
} else {
proto_tree_add_uint_format_value(tree, hf_smb_andxcmd, tvb, offset, 1, cmd, "No further commands (0xff)");
}
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* andxoffset */
andxoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_andxoffset, tvb, offset, 2, andxoffset);
offset += 2;
/* There are three valid formats of tree connect response.
All have the first two words: andx_cmd, andx_off,
and then have additional words as follows:
wc=2: (ancient LanMan -- no more words)
wc=3: (NT, non-ext) opt_support
wc=7: (NT, extended) opt_support,
tree_access(2w), guest_access(2w)
byte_count follows those words as usual */
if (wc >= 3) {
/* flags */
offset = dissect_connect_support_bits(tvb, tree, offset);
}
if (wc == 7) {
/*
* Refer to [MS-SMB] - v20100711
* When a server returns extended information, the response
* takes the following format, with WordCount = 7.
* MaximalShareAccessRights, and GuestMaximalShareAccessRights fields
* has added.
*/
proto_tree *tr;
tr = proto_tree_add_subtree(tree, tvb, offset, 4,
ett_smb_nt_access_mask, NULL, "Maximal Share Access Rights");
offset = dissect_smb_access_mask(tvb, tr, offset);
tr = proto_tree_add_subtree(tree, tvb, offset, 4,
ett_smb_nt_access_mask, NULL, "Guest Maximal Share Access Rights");
offset = dissect_smb_access_mask(tvb, tr, offset);
}
BYTE_COUNT;
/*
* NOTE: even though the SNIA CIFS spec doesn't say there's
* a "Service" string if there's a word count of 2, the
* document at
*
* ftp://ftp.microsoft.com/developr/drg/CIFS/dosextp.txt
*
* (it's in an ugly format - text intended to be sent to a
* printer, with backspaces and overstrikes used for boldfacing
* and underlining; UNIX "col -b" can be used to strip the
* overstrikes out) says there's a "Service" string there, and
* some network traffic has it.
*/
/*
* NOTE: the Service string is always ASCII, even if the
* "strings are Unicode" bit is set in the flags2 field
* of the SMB.
*/
/* Service */
/* XXX - what if this runs past bc? */
an_len = tvb_strsize(tvb, offset);
CHECK_BYTE_COUNT(an_len);
proto_tree_add_item_ret_string(tree, hf_smb_service, tvb,
offset, an_len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &an);
COUNT_BYTES(an_len);
/* Now when we know the service type, store it so that we know it for later commands down
this tree */
if (!pinfo->fd->visited) {
/* Remove any previous entry for this TID */
if (g_hash_table_lookup(si->ct->tid_service, GUINT_TO_POINTER(si->tid))) {
g_hash_table_remove(si->ct->tid_service, GUINT_TO_POINTER(si->tid));
}
if (strcmp(an, "IPC") == 0) {
g_hash_table_insert(si->ct->tid_service, GUINT_TO_POINTER(si->tid), (void *)TID_IPC);
} else {
g_hash_table_insert(si->ct->tid_service, GUINT_TO_POINTER(si->tid), (void *)TID_NORMAL);
}
}
if (bc != 0) {
/*
* Sometimes this isn't present.
*/
/* Native FS */
an = get_unicode_or_ascii_string(tvb, &offset,
si->unicode, &an_len, /*TRUE*/FALSE, FALSE,
&bc);
if (an == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_fs, tvb,
offset, an_len, an);
COUNT_BYTES(an_len);
}
END_OF_SMB
if (cmd != 0xff) { /* there is an andX command */
if (andxoffset < offset) {
THROW(ReportedBoundsError);
}
dissect_smb_command(tvb, pinfo, andxoffset, smb_tree, cmd, FALSE, si);
}
return offset;
}
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
NT Transaction command begins here
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
#define NT_TRANS_CREATE 1
#define NT_TRANS_IOCTL 2
#define NT_TRANS_SSD 3
#define NT_TRANS_NOTIFY 4
#define NT_TRANS_RENAME 5
#define NT_TRANS_QSD 6
#define NT_TRANS_GET_USER_QUOTA 7
#define NT_TRANS_SET_USER_QUOTA 8
static const value_string nt_cmd_vals[] = {
{NT_TRANS_CREATE, "NT CREATE"},
{NT_TRANS_IOCTL, "NT IOCTL"},
{NT_TRANS_SSD, "NT SET SECURITY DESC"},
{NT_TRANS_NOTIFY, "NT NOTIFY"},
{NT_TRANS_RENAME, "NT RENAME"},
{NT_TRANS_QSD, "NT QUERY SECURITY DESC"},
{NT_TRANS_GET_USER_QUOTA, "NT GET USER QUOTA"},
{NT_TRANS_SET_USER_QUOTA, "NT SET USER QUOTA"},
{0, NULL}
};
value_string_ext nt_cmd_vals_ext = VALUE_STRING_EXT_INIT(nt_cmd_vals);
static const value_string nt_ioctl_isfsctl_vals[] = {
{0, "Device IOCTL"},
{1, "FS control : FSCTL"},
{0, NULL}
};
#define NT_IOCTL_FLAGS_ROOT_HANDLE 0x01
static const true_false_string tfs_nt_ioctl_flags_root_handle = {
"Apply the command to share root handle (MUST BE Dfs)",
"Apply to this share",
};
static const value_string nt_notify_action_vals[] = {
{1, "ADDED (object was added"},
{2, "REMOVED (object was removed)"},
{3, "MODIFIED (object was modified)"},
{4, "RENAMED_OLD_NAME (this is the old name of object)"},
{5, "RENAMED_NEW_NAME (this is the new name of object)"},
{6, "ADDED_STREAM (a stream was added)"},
{7, "REMOVED_STREAM (a stream was removed)"},
{8, "MODIFIED_STREAM (a stream was modified)"},
{0, NULL}
};
static const value_string watch_tree_vals[] = {
{0, "Current directory only"},
{1, "Subdirectories also"},
{0, NULL}
};
#define NT_NOTIFY_STREAM_WRITE 0x00000800
#define NT_NOTIFY_STREAM_SIZE 0x00000400
#define NT_NOTIFY_STREAM_NAME 0x00000200
#define NT_NOTIFY_SECURITY 0x00000100
#define NT_NOTIFY_EA 0x00000080
#define NT_NOTIFY_CREATION 0x00000040
#define NT_NOTIFY_LAST_ACCESS 0x00000020
#define NT_NOTIFY_LAST_WRITE 0x00000010
#define NT_NOTIFY_SIZE 0x00000008
#define NT_NOTIFY_ATTRIBUTES 0x00000004
#define NT_NOTIFY_DIR_NAME 0x00000002
#define NT_NOTIFY_FILE_NAME 0x00000001
static const true_false_string tfs_nt_notify_stream_write = {
"Notify on changes to STREAM WRITE",
"Do NOT notify on changes to stream write",
};
static const true_false_string tfs_nt_notify_stream_size = {
"Notify on changes to STREAM SIZE",
"Do NOT notify on changes to stream size",
};
static const true_false_string tfs_nt_notify_stream_name = {
"Notify on changes to STREAM NAME",
"Do NOT notify on changes to stream name",
};
static const true_false_string tfs_nt_notify_security = {
"Notify on changes to SECURITY",
"Do NOT notify on changes to security",
};
static const true_false_string tfs_nt_notify_ea = {
"Notify on changes to EA",
"Do NOT notify on changes to EA",
};
static const true_false_string tfs_nt_notify_creation = {
"Notify on changes to CREATION TIME",
"Do NOT notify on changes to creation time",
};
static const true_false_string tfs_nt_notify_last_access = {
"Notify on changes to LAST ACCESS TIME",
"Do NOT notify on changes to last access time",
};
static const true_false_string tfs_nt_notify_last_write = {
"Notify on changes to LAST WRITE TIME",
"Do NOT notify on changes to last write time",
};
static const true_false_string tfs_nt_notify_size = {
"Notify on changes to SIZE",
"Do NOT notify on changes to size",
};
static const true_false_string tfs_nt_notify_attributes = {
"Notify on changes to ATTRIBUTES",
"Do NOT notify on changes to attributes",
};
static const true_false_string tfs_nt_notify_dir_name = {
"Notify on changes to DIR NAME",
"Do NOT notify on changes to dir name",
};
static const true_false_string tfs_nt_notify_file_name = {
"Notify on changes to FILE NAME",
"Do NOT notify on changes to file name",
};
const value_string create_disposition_vals[] = {
{0, "Supersede (supersede existing file (if it exists))"},
{1, "Open (if file exists open it, else fail)"},
{2, "Create (if file exists fail, else create it)"},
{3, "Open If (if file exists open it, else create it)"},
{4, "Overwrite (if file exists overwrite, else fail)"},
{5, "Overwrite If (if file exists overwrite, else create it)"},
{0, NULL}
};
const value_string impersonation_level_vals[] = {
{0, "Anonymous"},
{1, "Identification"},
{2, "Impersonation"},
{3, "Delegation"},
{0, NULL}
};
static const true_false_string tfs_nt_security_flags_context_tracking = {
"Security tracking mode is DYNAMIC",
"Security tracking mode is STATIC",
};
static const true_false_string tfs_nt_security_flags_effective_only = {
"ONLY ENABLED aspects of the client's security context are available",
"ALL aspects of the client's security context are available",
};
static const true_false_string tfs_nt_create_bits_oplock = {
"Requesting OPLOCK",
"Does NOT request oplock"
};
static const true_false_string tfs_nt_create_bits_boplock = {
"Requesting BATCH OPLOCK",
"Does NOT request batch oplock"
};
/*
* XXX - must be a directory, and can be a file, or can be a directory,
* and must be a file?
*/
static const true_false_string tfs_nt_create_bits_dir = {
"Target of open MUST be a DIRECTORY",
"Target of open can be a file"
};
static const true_false_string tfs_nt_create_bits_ext_resp = {
"Extended responses required",
"Extended responses NOT required"
};
static const true_false_string tfs_nt_access_mask_generic_read = {
"GENERIC READ is set",
"Generic read is NOT set"
};
static const true_false_string tfs_nt_access_mask_generic_write = {
"GENERIC WRITE is set",
"Generic write is NOT set"
};
static const true_false_string tfs_nt_access_mask_generic_execute = {
"GENERIC EXECUTE is set",
"Generic execute is NOT set"
};
static const true_false_string tfs_nt_access_mask_generic_all = {
"GENERIC ALL is set",
"Generic all is NOT set"
};
static const true_false_string tfs_nt_access_mask_maximum_allowed = {
"MAXIMUM ALLOWED is set",
"Maximum allowed is NOT set"
};
static const true_false_string tfs_nt_access_mask_system_security = {
"SYSTEM SECURITY is set",
"System security is NOT set"
};
static const true_false_string tfs_nt_access_mask_synchronize = {
"Can wait on handle to SYNCHRONIZE on completion of I/O",
"Can NOT wait on handle to synchronize on completion of I/O"
};
static const true_false_string tfs_nt_access_mask_write_owner = {
"Can WRITE OWNER (take ownership)",
"Can NOT write owner (take ownership)"
};
static const true_false_string tfs_nt_access_mask_write_dac = {
"OWNER may WRITE the DAC",
"Owner may NOT write to the DAC"
};
static const true_false_string tfs_nt_access_mask_read_control = {
"READ ACCESS to owner, group and ACL of the SID",
"Read access is NOT granted to owner, group and ACL of the SID"
};
static const true_false_string tfs_nt_access_mask_delete = {
"DELETE access",
"NO delete access"
};
static const true_false_string tfs_nt_access_mask_write_attributes = {
"WRITE ATTRIBUTES access",
"NO write attributes access"
};
static const true_false_string tfs_nt_access_mask_read_attributes = {
"READ ATTRIBUTES access",
"NO read attributes access"
};
static const true_false_string tfs_nt_access_mask_delete_child = {
"DELETE CHILD access",
"NO delete child access"
};
static const true_false_string tfs_nt_access_mask_execute = {
"EXECUTE access",
"NO execute access"
};
static const true_false_string tfs_nt_access_mask_write_ea = {
"WRITE EXTENDED ATTRIBUTES access",
"NO write extended attributes access"
};
static const true_false_string tfs_nt_access_mask_read_ea = {
"READ EXTENDED ATTRIBUTES access",
"NO read extended attributes access"
};
static const true_false_string tfs_nt_access_mask_append = {
"APPEND access",
"NO append access"
};
static const true_false_string tfs_nt_access_mask_write = {
"WRITE access",
"NO write access"
};
static const true_false_string tfs_nt_access_mask_read = {
"READ access",
"NO read access"
};
static const true_false_string tfs_nt_share_access_delete = {
"Object can be shared for DELETE",
"Object can NOT be shared for delete"
};
static const true_false_string tfs_nt_share_access_write = {
"Object can be shared for WRITE",
"Object can NOT be shared for write"
};
static const true_false_string tfs_nt_share_access_read = {
"Object can be shared for READ",
"Object can NOT be shared for read"
};
static const value_string oplock_level_vals[] = {
{0, "No oplock granted"},
{1, "Exclusive oplock granted"},
{2, "Batch oplock granted"},
{3, "Level II oplock granted"},
{0, NULL}
};
static const value_string response_type_vals[] = {
{0x00, "Non-extended response"},
{0x01, "Extended response"},
{0, NULL}
};
static const value_string device_type_vals[] = {
{0x00000001, "Beep"},
{0x00000002, "CDROM"},
{0x00000003, "CDROM Filesystem"},
{0x00000004, "Controller"},
{0x00000005, "Datalink"},
{0x00000006, "Dfs"},
{0x00000007, "Disk"},
{0x00000008, "Disk Filesystem"},
{0x00000009, "Filesystem"},
{0x0000000a, "Inport Port"},
{0x0000000b, "Keyboard"},
{0x0000000c, "Mailslot"},
{0x0000000d, "MIDI-In"},
{0x0000000e, "MIDI-Out"},
{0x0000000f, "Mouse"},
{0x00000010, "Multi UNC Provider"},
{0x00000011, "Named Pipe"},
{0x00000012, "Network"},
{0x00000013, "Network Browser"},
{0x00000014, "Network Filesystem"},
{0x00000015, "NULL"},
{0x00000016, "Parallel Port"},
{0x00000017, "Physical card"},
{0x00000018, "Printer"},
{0x00000019, "Scanner"},
{0x0000001a, "Serial Mouse port"},
{0x0000001b, "Serial port"},
{0x0000001c, "Screen"},
{0x0000001d, "Sound"},
{0x0000001e, "Streams"},
{0x0000001f, "Tape"},
{0x00000020, "Tape Filesystem"},
{0x00000021, "Transport"},
{0x00000022, "Unknown"},
{0x00000023, "Video"},
{0x00000024, "Virtual Disk"},
{0x00000025, "WAVE-In"},
{0x00000026, "WAVE-Out"},
{0x00000027, "8042 Port"},
{0x00000028, "Network Redirector"},
{0x00000029, "Battery"},
{0x0000002a, "Bus Extender"},
{0x0000002b, "Modem"},
{0x0000002c, "VDM"},
{0, NULL}
};
static value_string_ext device_type_vals_ext = VALUE_STRING_EXT_INIT(device_type_vals);
static const value_string is_directory_vals[] = {
{0, "This is NOT a directory"},
{1, "This is a DIRECTORY"},
{0, NULL}
};
static int
dissect_nt_security_flags(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_nt_security_flags_context_tracking,
&hf_smb_nt_security_flags_effective_only,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_nt_security_flags, ett_smb_nt_security_flags, flags, ENC_NA);
offset += 1;
return offset;
}
/*
* XXX - there are some more flags in the description of "ZwOpenFile()"
* in "Windows(R) NT(R)/2000 Native API Reference"; do those go over
* the wire as well? (The spec at
*
* http://www.samba.org/samba/ftp/specs/smb-nt01.doc
*
* says that "the FILE_NO_INTERMEDIATE_BUFFERING option is not exported
* via the SMB protocol. The NT redirector should convert this option
* to FILE_WRITE_THROUGH."
*
* The "Sync I/O Alert" and "Sync I/O Nonalert" are given the bit
* values one would infer from their position in the list of flags for
* "ZwOpenFile()". Most of the others probably have those values
* as well, although "8.3 only" would collide with FILE_OPEN_FOR_RECOVERY,
* which might go over the wire (for the benefit of backup/restore software).
*/
static const true_false_string tfs_nt_create_options_directory = {
"File being created/opened must be a directory",
"File being created/opened must not be a directory"
};
static const true_false_string tfs_nt_create_options_write_through = {
"Writes should flush buffered data before completing",
"Writes need not flush buffered data before completing"
};
static const true_false_string tfs_nt_create_options_sequential_only = {
"The file will only be accessed sequentially",
"The file might not only be accessed sequentially"
};
static const true_false_string tfs_nt_create_options_no_intermediate_buffering = {
"NO intermediate buffering is allowed",
"Intermediate buffering is allowed"
};
static const true_false_string tfs_nt_create_options_sync_io_alert = {
"All operations SYNCHRONOUS, waits subject to termination from alert",
"Operations NOT necessarily synchronous"
};
static const true_false_string tfs_nt_create_options_sync_io_nonalert = {
"All operations SYNCHRONOUS, waits not subject to alert",
"Operations NOT necessarily synchronous"
};
static const true_false_string tfs_nt_create_options_non_directory = {
"File being created/opened must not be a directory",
"File being created/opened must be a directory"
};
static const true_false_string tfs_nt_create_options_create_tree_connection = {
"Create Tree Connections is SET",
"Create Tree Connections is NOT set"
};
static const true_false_string tfs_nt_create_options_complete_if_oplocked = {
"Complete if oplocked is SET",
"Complete if oplocked is NOT set"
};
static const true_false_string tfs_nt_create_options_no_ea_knowledge = {
"The client does not understand extended attributes",
"The client understands extended attributes"
};
static const true_false_string tfs_nt_create_options_eight_dot_three_only = {
"The client understands only 8.3 file names",
"The client understands long file names"
};
static const true_false_string tfs_nt_create_options_random_access = {
"The file will be accessed randomly",
"The file will not be accessed randomly"
};
static const true_false_string tfs_nt_create_options_delete_on_close = {
"The file should be deleted when it is closed",
"The file should not be deleted when it is closed"
};
static const true_false_string tfs_nt_create_options_open_by_fileid = {
"OpenByFileID bit is SET",
"OpenByFileID is NOT set"
};
static const true_false_string tfs_nt_create_options_backup_intent = {
"This is a create with BACKUP INTENT",
"This is a normal create"
};
static const true_false_string tfs_nt_create_options_no_compression = {
"Open/Create with NO Compression",
"Compression is allowed for Open/Create"
};
static const true_false_string tfs_nt_create_options_reserve_opfilter = {
"Reserve Opfilter is SET",
"Reserve Opfilter is NOT set"
};
static const true_false_string tfs_nt_create_options_open_reparse_point = {
"Open a Reparse Point",
"Normal open"
};
static const true_false_string tfs_nt_create_options_open_no_recall = {
"Open No Recall is SET",
"Open no recall is NOT set"
};
static const true_false_string tfs_nt_create_options_open_for_free_space_query = {
"This is an OPEN FOR FREE SPACE QUERY",
"This is NOT an open for free space query"
};
int
dissect_nt_notify_completion_filter(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_nt_notify_file_name,
&hf_smb_nt_notify_dir_name,
&hf_smb_nt_notify_attributes,
&hf_smb_nt_notify_size,
&hf_smb_nt_notify_last_write,
&hf_smb_nt_notify_last_access,
&hf_smb_nt_notify_creation,
&hf_smb_nt_notify_ea,
&hf_smb_nt_notify_security,
&hf_smb_nt_notify_stream_name,
&hf_smb_nt_notify_stream_size,
&hf_smb_nt_notify_stream_write,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_nt_notify_completion_filter, ett_smb_nt_notify_completion_filter, flags, ENC_LITTLE_ENDIAN);
offset += 4;
return offset;
}
static int
dissect_nt_ioctl_flags(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_nt_ioctl_flags_root_handle,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_nt_ioctl_flags_completion_filter, ett_smb_nt_ioctl_flags, flags, ENC_NA);
offset += 1;
return offset;
}
/*
* From the section on ZwQuerySecurityObject in "Windows(R) NT(R)/2000
* Native API Reference".
*/
static const true_false_string tfs_nt_qsd_owner = {
"Requesting OWNER security information",
"NOT requesting owner security information",
};
static const true_false_string tfs_nt_qsd_group = {
"Requesting GROUP security information",
"NOT requesting group security information",
};
static const true_false_string tfs_nt_qsd_dacl = {
"Requesting DACL security information",
"NOT requesting DACL security information",
};
static const true_false_string tfs_nt_qsd_sacl = {
"Requesting SACL security information",
"NOT requesting SACL security information",
};
#define NT_QSD_OWNER 0x00000001
#define NT_QSD_GROUP 0x00000002
#define NT_QSD_DACL 0x00000004
#define NT_QSD_SACL 0x00000008
int
dissect_security_information_mask(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_nt_qsd_owner,
&hf_smb_nt_qsd_group,
&hf_smb_nt_qsd_dacl,
&hf_smb_nt_qsd_sacl,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_nt_qsd, ett_smb_security_information_mask, flags, ENC_LITTLE_ENDIAN);
offset += 4;
return offset;
}
int
dissect_nt_user_quota(tvbuff_t *tvb, proto_tree *tree, int offset, guint16 *bcp)
{
int old_offset, old_sid_offset;
guint32 qsize;
do {
old_offset = offset;
CHECK_BYTE_COUNT_TRANS_SUBR(4);
qsize = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_user_quota_offset, tvb, offset, 4, qsize);
COUNT_BYTES_TRANS_SUBR(4);
CHECK_BYTE_COUNT_TRANS_SUBR(4);
/* length of SID */
proto_tree_add_item(tree, hf_smb_length_of_sid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* change time */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
offset = dissect_nt_64bit_time(tvb, tree, offset,
hf_smb_user_quota_change_time);
/* number of bytes for used quota */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
proto_tree_add_item(tree, hf_smb_user_quota_used, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(8);
/* number of bytes for quota warning */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
proto_tree_add_item(tree, hf_smb_soft_quota_limit, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(8);
/* number of bytes for quota limit */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
proto_tree_add_item(tree, hf_smb_hard_quota_limit, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(8);
/* SID of the user */
old_sid_offset = offset;
offset = dissect_nt_sid(tvb, offset, tree, "Quota", NULL, -1);
*bcp -= (offset-old_sid_offset);
if (qsize) {
offset = old_offset+qsize;
}
}while (qsize);
return offset;
}
int
dissect_nt_get_user_quota(tvbuff_t *tvb, proto_tree *tree, int offset, guint32 *bcp)
{
int old_offset, old_sid_offset;
guint32 qsize;
do {
old_offset = offset;
CHECK_BYTE_COUNT_TRANS_SUBR(4);
qsize = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_user_quota_offset, tvb, offset, 4, qsize);
COUNT_BYTES_TRANS_SUBR(4);
CHECK_BYTE_COUNT_TRANS_SUBR(4);
/* length of SID */
proto_tree_add_item(tree, hf_smb_length_of_sid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* SID of the user */
old_sid_offset = offset;
offset = dissect_nt_sid(tvb, offset, tree, "SID", NULL, -1);
*bcp -= (offset-old_sid_offset);
if (qsize) {
offset = old_offset+qsize;
}
}while (qsize);
return offset;
}
static int
dissect_nt_trans_data_request(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *parent_tree, int bc, smb_nt_transact_info_t *nti, smb_info_t *si, int subcmd, guint32 sd_len, guint32 ea_len)
{
proto_tree *tree;
int old_offset = offset;
guint16 bcp = bc; /* XXX fixme */
struct access_mask_info *ami = NULL;
tvbuff_t *ioctl_tvb;
DISSECTOR_ASSERT(si);
tree = proto_tree_add_subtree_format(parent_tree, tvb, offset, -1,
ett_smb_nt_trans_data, NULL, "%s Data",
val_to_str_ext(subcmd, &nt_cmd_vals_ext, "Unknown NT transaction (%u)"));
switch(subcmd) {
case NT_TRANS_CREATE:
/* security descriptor */
if (sd_len) {
offset = dissect_nt_sec_desc(
tvb, offset, pinfo, tree, NULL, TRUE,
sd_len, NULL);
}
/* extended attributes */
if (ea_len) {
proto_tree_add_item(tree, hf_smb_extended_attributes, tvb, offset, ea_len, ENC_NA);
offset += ea_len;
}
break;
case NT_TRANS_IOCTL:
/* ioctl data */
ioctl_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN((int)bc, tvb_reported_length_remaining(tvb, offset)), bc);
if (nti) {
dissect_smb2_ioctl_data(ioctl_tvb, pinfo, tree, top_tree_global, nti->ioctl_function, TRUE, NULL);
}
offset += bc;
break;
case NT_TRANS_SSD:
if (nti) {
switch(nti->fid_type) {
case SMB_FID_TYPE_FILE:
ami = &smb_file_access_mask_info;
break;
case SMB_FID_TYPE_DIR:
ami = &smb_dir_access_mask_info;
break;
}
}
offset = dissect_nt_sec_desc(
tvb, offset, pinfo, tree, NULL, TRUE, bc, ami);
if (offset < (old_offset + bc)) {
offset = old_offset + bc;
}
break;
case NT_TRANS_NOTIFY:
break;
case NT_TRANS_RENAME:
/* XXX not documented */
break;
case NT_TRANS_QSD:
break;
case NT_TRANS_GET_USER_QUOTA:
/* unknown 4 bytes */
proto_tree_add_item(tree, hf_smb_unknown, tvb,
offset, 4, ENC_NA);
offset += 4;
/* length of SID */
proto_tree_add_item(tree, hf_smb_length_of_sid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset +=4;
offset = dissect_nt_sid(tvb, offset, tree, "Quota", NULL, -1);
break;
case NT_TRANS_SET_USER_QUOTA:
offset = dissect_nt_user_quota(tvb, tree, offset, &bcp);
break;
}
/* ooops there were data we didn't know how to process */
if ((offset-old_offset) < bc) {
proto_tree_add_item(tree, hf_smb_unknown, tvb, offset,
bc - (offset-old_offset), ENC_NA);
offset += bc - (offset-old_offset);
}
return offset;
}
static int
dissect_nt_trans_param_request(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *parent_tree, int len, guint16 bc, smb_nt_transact_info_t *nti, smb_info_t *si, int subcmd, guint32 *sd_len, guint32 *ea_len)
{
proto_tree *tree;
guint32 fn_len, create_flags, access_mask, share_access, create_options;
const char *fn;
DISSECTOR_ASSERT(si);
tree = proto_tree_add_subtree_format(parent_tree, tvb, offset, len,
ett_smb_nt_trans_param, NULL, "%s Parameters",
val_to_str_ext(subcmd, &nt_cmd_vals_ext, "Unknown NT transaction (%u)"));
switch(subcmd) {
case NT_TRANS_CREATE:
/* Create flags */
create_flags = tvb_get_letohl(tvb, offset);
offset = dissect_nt_create_bits(tvb, tree, offset, 4, create_flags);
bc -= 4;
/* root directory fid */
proto_tree_add_item(tree, hf_smb_root_dir_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES(4);
/* nt access mask */
access_mask = tvb_get_letohl(tvb, offset);
offset = dissect_smb_access_mask_bits(tvb, tree, offset, 4, access_mask);
bc -= 4;
/* allocation size */
proto_tree_add_item(tree, hf_smb_alloc_size64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES(8);
/* Extended File Attributes */
offset = dissect_file_ext_attr(tvb, tree, offset);
bc -= 4;
/* share access */
share_access = tvb_get_letohl(tvb, offset);
offset = dissect_nt_share_access_bits(tvb, tree, offset, 4, share_access);
bc -= 4;
/* create disposition */
proto_tree_add_item(tree, hf_smb_nt_create_disposition, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES(4);
/* create options */
create_options = tvb_get_letohl(tvb, offset);
offset = dissect_nt_create_options_bits(tvb, tree, offset, 4, create_options);
bc -= 4;
/* sd length */
proto_tree_add_item_ret_uint(tree, hf_smb_sd_length, tvb, offset, 4, ENC_LITTLE_ENDIAN, sd_len);
COUNT_BYTES(4);
/* ea length */
proto_tree_add_item_ret_uint(tree, hf_smb_ea_list_length, tvb, offset, 4, ENC_LITTLE_ENDIAN, ea_len);
COUNT_BYTES(4);
/* file name len */
fn_len = (guint32)tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_file_name_len, tvb, offset, 4, fn_len);
COUNT_BYTES(4);
/* impersonation level */
proto_tree_add_item(tree, hf_smb_nt_impersonation_level, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES(4);
/* security flags */
offset = dissect_nt_security_flags(tvb, tree, offset);
bc -= 1;
/* May need to skip alignment padding. */
if (offset&1) {
/* pad byte */
proto_tree_add_item(tree, hf_smb_padding, tvb, offset, 1, ENC_NA);
offset += 1;
}
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, TRUE, TRUE, &bc);
if (fn != NULL) {
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
}
break;
case NT_TRANS_IOCTL:
break;
case NT_TRANS_SSD: {
guint16 fid;
smb_fid_info_t *fid_info;
/* fid */
fid = tvb_get_letohs(tvb, offset);
fid_info = dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
if (nti) {
if (fid_info) {
nti->fid_type = fid_info->type;
} else {
nti->fid_type = SMB_FID_TYPE_UNKNOWN;
}
}
/* 2 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* security information */
offset = dissect_security_information_mask(tvb, tree, offset);
break;
}
case NT_TRANS_NOTIFY:
break;
case NT_TRANS_RENAME:
/* XXX not documented */
break;
case NT_TRANS_QSD: {
guint16 fid;
smb_fid_info_t *fid_info;
/* fid */
fid = tvb_get_letohs(tvb, offset);
fid_info = dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
if (nti) {
if (fid_info) {
nti->fid_type = fid_info->type;
} else {
nti->fid_type = SMB_FID_TYPE_UNKNOWN;
}
}
/* 2 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* security information */
offset = dissect_security_information_mask(tvb, tree, offset);
break;
}
case NT_TRANS_GET_USER_QUOTA:
/* not decoded yet */
break;
case NT_TRANS_SET_USER_QUOTA:
/* not decoded yet */
break;
}
return offset;
}
static int
dissect_nt_trans_setup_request(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *parent_tree, int len, smb_info_t *si, int subcmd)
{
proto_tree *tree;
smb_nt_transact_info_t *nti = NULL;
smb_saved_info_t *sip;
DISSECTOR_ASSERT(si);
sip = si->sip;
if (sip && (sip->extra_info_type == SMB_EI_NTI)) {
nti = (smb_nt_transact_info_t *)sip->extra_info;
}
tree = proto_tree_add_subtree_format(parent_tree, tvb, offset, len,
ett_smb_nt_trans_setup, NULL, "%s Setup",
val_to_str_ext(subcmd, &nt_cmd_vals_ext, "Unknown NT transaction (%u)"));
switch(subcmd) {
case NT_TRANS_CREATE:
offset += len;
break;
case NT_TRANS_IOCTL: {
guint16 fid;
/* function code */
offset = dissect_smb2_ioctl_function(tvb, pinfo, tree, offset, nti ? &nti->ioctl_function : NULL);
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
/* isfsctl */
proto_tree_add_item(tree, hf_smb_nt_ioctl_isfsctl, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* isflags */
offset = dissect_nt_ioctl_flags(tvb, tree, offset);
break;
}
case NT_TRANS_SSD:
offset += len;
break;
case NT_TRANS_NOTIFY: {
guint16 fid;
/* completion filter */
offset = dissect_nt_notify_completion_filter(tvb, tree, offset);
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
/* watch tree */
proto_tree_add_item(tree, hf_smb_nt_notify_watch_tree, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
break;
}
case NT_TRANS_RENAME:
/* XXX not documented */
offset += len;
break;
case NT_TRANS_QSD:
break;
case NT_TRANS_GET_USER_QUOTA:
/* not decoded yet */
offset += len;
break;
case NT_TRANS_SET_USER_QUOTA:
/* not decoded yet */
offset += len;
break;
}
return offset;
}
static int
dissect_nt_transaction_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc, sc;
guint32 pc = 0, pd = 0, po = 0, dc = 0, od = 0, dd = 0;
guint32 td = 0, tp = 0;
smb_saved_info_t *sip;
int subcmd;
guint32 sd_len, ea_len;
guint16 bc;
guint32 padcnt;
smb_nt_transact_info_t *nti = NULL;
fragment_head *r_fd = NULL;
tvbuff_t *pd_tvb = NULL;
gboolean save_fragmented;
save_fragmented = pinfo->fragmented;
subcmd = 0;
sd_len = 0;
ea_len = 0;
DISSECTOR_ASSERT(si);
sip = si->sip;
WORD_COUNT;
if (wc >= 19) {
/* primary request */
/* max setup count */
proto_tree_add_item(tree, hf_smb_max_setup_count, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* 2 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
} else {
/* secondary request */
/* 3 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 3, ENC_NA);
offset += 3;
}
/* total param count */
tp = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_total_param_count, tvb, offset, 4, tp);
offset += 4;
/* total data count */
td = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_total_data_count, tvb, offset, 4, td);
offset += 4;
if (wc >= 19) {
/* primary request */
/* max param count */
proto_tree_add_item(tree, hf_smb_max_param_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* max data count */
proto_tree_add_item(tree, hf_smb_max_data_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
/* param count */
pc = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_param_count32, tvb, offset, 4, pc);
offset += 4;
/* param offset */
po = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_param_offset32, tvb, offset, 4, po);
offset += 4;
/* param displacement */
if (wc >= 19) {
/* primary request*/
} else {
/* secondary request */
proto_tree_add_item(tree, hf_smb_param_disp32, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
/* data count */
dc = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_count32, tvb, offset, 4, dc);
offset += 4;
/* data offset */
od = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_offset32, tvb, offset, 4, od);
offset += 4;
/* data displacement */
if (wc >= 19) {
/* primary request */
} else {
/* secondary request */
dd = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_disp32, tvb, offset, 4, dd);
offset += 4;
}
/* setup count */
if (wc >= 19) {
/* primary request */
sc = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_smb_setup_count, tvb, offset, 1, sc);
offset += 1;
} else {
/* secondary request */
sc = 0;
}
/* function */
if (wc >= 19) {
/* primary request */
subcmd = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_nt_trans_subcmd, tvb, offset, 2, subcmd);
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
val_to_str_ext_const(subcmd, &nt_cmd_vals_ext, "<unknown>"));
if (!si->unidir && sip) {
if (!pinfo->fd->visited) {
/*
* Allocate a new smb_nt_transact_info_t
* structure.
*/
nti = wmem_new(wmem_file_scope(), smb_nt_transact_info_t);
nti->subcmd = subcmd;
nti->fid_type = SMB_FID_TYPE_UNKNOWN;
nti->ioctl_function = 0;
sip->extra_info = nti;
sip->extra_info_type = SMB_EI_NTI;
} else {
if (sip->extra_info_type == SMB_EI_NTI) {
nti = (smb_nt_transact_info_t *)sip->extra_info;
}
}
}
} else {
/* secondary request */
col_append_str(pinfo->cinfo, COL_INFO, " (secondary request)");
}
offset += 2;
#if 0 /* XXX this is a padding byte? I don't think so. -gwr */
if (offset&1) {
/* pad byte */
proto_tree_add_item(tree, hf_smb_padding, tvb, offset, 1, ENC_NA);
offset += 1;
}
#endif
/* if there were any setup bytes, decode them */
if (sc) {
dissect_nt_trans_setup_request(tvb, pinfo, offset, tree, sc*2, si, subcmd);
offset += sc*2;
}
/*
* Do we really need to even look at the byte count here?
* Servers normally use byte_count only when assembling the
* setup, parameters, and data segments. Once we know
* how long each of those are, we should dissect them
* using the lengths determined during assembly.
*/
BYTE_COUNT;
/* reassembly of SMB NT Transaction data payload.
In this section we do reassembly of both the data and parameters
blocks of the SMB transaction command.
*/
/* do we need reassembly? */
if ( (td && (td != dc)) || (tp && (tp != pc)) ) {
/* oh yeah, either data or parameter section needs
reassembly...
*/
pinfo->fragmented = TRUE;
if (smb_trans_reassembly) {
/* ...and we were told to do reassembly */
if (pc) {
r_fd = smb_trans_defragment(tree, pinfo, tvb,
po, pc, pd, td+tp, si);
}
if ((r_fd == NULL) && dc) {
r_fd = smb_trans_defragment(tree, pinfo, tvb,
od, dc, dd+tp, td+tp, si);
}
}
}
/* if we got a reassembled fd structure from the reassembly routine we
must create pd_tvb from it
*/
if (r_fd) {
proto_item *frag_tree_item;
pd_tvb = tvb_new_chain(tvb, r_fd->tvb_data);
add_new_data_source(pinfo, pd_tvb, "Reassembled SMB");
show_fragment_tree(r_fd, &smb_frag_items, tree, pinfo, pd_tvb, &frag_tree_item);
}
if (pd_tvb) {
/* we have reassembled data, grab param and data from there */
dissect_nt_trans_param_request(pd_tvb, pinfo, 0, tree, tp,
(guint16) tvb_reported_length(pd_tvb),
nti, si, subcmd, &sd_len, &ea_len);
dissect_nt_trans_data_request(pd_tvb, pinfo, tp, tree, td, nti, si,
subcmd, sd_len, ea_len);
COUNT_BYTES(bc); /* We are done */
} else {
/* we do not have reassembled data, just use what we have in the
packet as well as we can */
/* parameters */
if (po > (guint32)offset) {
/* We have some initial padding bytes.
*/
padcnt = po-offset;
if (padcnt > bc)
padcnt = bc;
CHECK_BYTE_COUNT(padcnt);
proto_tree_add_item(tree, hf_smb_padding, tvb, offset, padcnt, ENC_NA);
COUNT_BYTES(padcnt);
}
if (pc) {
CHECK_BYTE_COUNT(pc);
dissect_nt_trans_param_request(tvb, pinfo, offset, tree, pc, bc,
nti, si, subcmd, &sd_len, &ea_len);
COUNT_BYTES(pc);
}
/* data */
if (od > (guint32)offset) {
/* We have some initial padding bytes.
*/
padcnt = od-offset;
if (padcnt > bc)
padcnt = bc;
proto_tree_add_item(tree, hf_smb_padding, tvb, offset, padcnt, ENC_NA);
COUNT_BYTES(padcnt);
}
if (dc) {
CHECK_BYTE_COUNT(dc);
dissect_nt_trans_data_request(tvb, pinfo, offset, tree, dc,
nti, si, subcmd, sd_len, ea_len);
COUNT_BYTES(dc);
}
}
END_OF_SMB
pinfo->fragmented = save_fragmented;
return offset;
}
static int
dissect_nt_trans_data_response(tvbuff_t *tvb, packet_info *pinfo,
int offset, proto_tree *parent_tree, int len,
smb_nt_transact_info_t *nti, smb_info_t *si)
{
proto_tree *tree = NULL;
guint16 bcp;
struct access_mask_info *ami = NULL;
tvbuff_t *ioctl_tvb;
DISSECTOR_ASSERT(si);
if (parent_tree) {
if (nti != NULL) {
tree = proto_tree_add_subtree_format(parent_tree, tvb, offset, len,
ett_smb_nt_trans_data, NULL, "%s Data",
val_to_str_ext(nti->subcmd, &nt_cmd_vals_ext, "Unknown NT Transaction (%u)"));
} else {
/*
* We never saw the request to which this is a
* response.
*/
tree = proto_tree_add_subtree(parent_tree, tvb, offset, len,
ett_smb_nt_trans_data, NULL, "Unknown NT Transaction Data (matching request not seen)");
}
}
if (nti == NULL) {
offset += len;
return offset;
}
switch(nti->subcmd) {
case NT_TRANS_CREATE:
break;
case NT_TRANS_IOCTL:
/* ioctl data */
ioctl_tvb = tvb_new_subset_length_caplen(tvb, offset, MIN((int)len, tvb_reported_length_remaining(tvb, offset)), len);
dissect_smb2_ioctl_data(ioctl_tvb, pinfo, tree, top_tree_global, nti->ioctl_function, FALSE, NULL);
offset += len;
break;
case NT_TRANS_SSD:
break;
case NT_TRANS_NOTIFY:
break;
case NT_TRANS_RENAME:
/* XXX not documented */
break;
case NT_TRANS_QSD:
if (nti) {
switch(nti->fid_type) {
case SMB_FID_TYPE_FILE:
ami = &smb_file_access_mask_info;
break;
case SMB_FID_TYPE_DIR:
ami = &smb_dir_access_mask_info;
break;
}
}
offset = dissect_nt_sec_desc(
tvb, offset, pinfo, tree, NULL, TRUE, len, ami);
break;
case NT_TRANS_GET_USER_QUOTA:
bcp = len;
offset = dissect_nt_user_quota(tvb, tree, offset, &bcp);
break;
case NT_TRANS_SET_USER_QUOTA:
/* not decoded yet */
break;
}
return offset;
}
static int
dissect_nt_trans_param_response(tvbuff_t *tvb, packet_info *pinfo,
int offset, proto_tree *parent_tree,
int len, guint16 bc, smb_info_t *si)
{
proto_tree *tree = NULL;
guint32 fn_len;
const char *fn;
smb_nt_transact_info_t *nti;
guint16 fid;
int old_offset;
guint32 neo;
int padcnt;
smb_fid_info_t *fid_info = NULL;
guint16 ftype;
guint8 isdir;
guint8 ext_resp = 0;
DISSECTOR_ASSERT(si);
if ((si->sip != NULL) && (si->sip->extra_info_type == SMB_EI_NTI))
nti = (smb_nt_transact_info_t *)si->sip->extra_info;
else
nti = NULL;
if (parent_tree) {
if (nti != NULL) {
tree = proto_tree_add_subtree_format(parent_tree, tvb, offset, len,
ett_smb_nt_trans_param, NULL, "%s Parameters",
val_to_str_ext(nti->subcmd, &nt_cmd_vals_ext, "Unknown NT Transaction (%u)"));
} else {
/*
* We never saw the request to which this is a
* response.
*/
tree = proto_tree_add_subtree(parent_tree, tvb, offset, len,
ett_smb_nt_trans_param, NULL, "Unknown NT Transaction Parameters (matching request not seen)");
}
}
if (nti == NULL) {
offset += len;
return offset;
}
switch(nti->subcmd) {
case NT_TRANS_CREATE:
/* oplock level */
proto_tree_add_item(tree, hf_smb_oplock_level, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* response type, as per MS-SMB 2.2.7.1.2 */
ext_resp = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_smb_response_type, tvb, offset, 1, ENC_NA);
offset += 1;
/* fid */
fid = tvb_get_letohs(tvb, offset);
fid_info = dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, TRUE, FALSE, FALSE, si);
offset += 2;
/* create action */
proto_tree_add_item(tree, hf_smb_create_action, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* ea error offset */
proto_tree_add_item(tree, hf_smb_ea_error_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* create time */
offset = dissect_nt_64bit_time(tvb, tree, offset,
hf_smb_create_time);
/* access time */
offset = dissect_nt_64bit_time(tvb, tree, offset,
hf_smb_access_time);
/* last write time */
offset = dissect_nt_64bit_time(tvb, tree, offset,
hf_smb_last_write_time);
/* last change time */
offset = dissect_nt_64bit_time(tvb, tree, offset,
hf_smb_change_time);
/* Extended File Attributes */
offset = dissect_file_ext_attr(tvb, tree, offset);
/* allocation size */
proto_tree_add_item(tree, hf_smb_alloc_size64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* end of file */
proto_tree_add_item(tree, hf_smb_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* File Type */
ftype = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb_file_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* device state */
offset = dissect_ipc_state(tvb, tree, offset, FALSE);
/* is directory */
isdir = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_smb_is_directory, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* decode extended response per [MS-SMB] 2.2.7.1.2
(volume_guid, file_id, max_acc, guest_acc)
Just like dissect_nt_create_andx_response */
if (ext_resp != 0) {
proto_tree *tr = NULL;
/* The first field is a Volume GUID ... */
proto_tree_add_item(tree, hf_smb_volume_guid,
tvb, offset, 16, ENC_NA);
offset += 16;
/* The file ID comes next */
proto_tree_add_item(tree, hf_smb_file_id_64bit,
tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
tr = proto_tree_add_subtree(tree, tvb, offset, 4,
ett_smb_nt_access_mask, NULL, "Maximal Access Rights");
offset = dissect_smb_access_mask(tvb, tr, offset);
tr = proto_tree_add_subtree(tree, tvb, offset, 4,
ett_smb_nt_access_mask, NULL, "Guest Maximal Access Rights");
offset = dissect_smb_access_mask(tvb, tr, offset);
}
/* Try to remember the type of this fid so that we can dissect
* any future security descriptor (access mask) properly
*/
if (ftype == 0) {
if (isdir == 0) {
if (fid_info) {
fid_info->type = SMB_FID_TYPE_FILE;
}
} else {
if (fid_info) {
fid_info->type = SMB_FID_TYPE_DIR;
}
}
}
if (ftype == 2) {
if (fid_info) {
fid_info->type = SMB_FID_TYPE_PIPE;
}
}
break;
case NT_TRANS_IOCTL:
break;
case NT_TRANS_SSD:
break;
case NT_TRANS_NOTIFY:
while (len) {
old_offset = offset;
/* next entry offset */
neo = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_next_entry_offset, tvb, offset, 4, neo);
COUNT_BYTES(4);
len -= 4;
/* broken implementations */
if (len < 0) break;
/* action */
proto_tree_add_item(tree, hf_smb_nt_notify_action, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES(4);
len -= 4;
/* broken implementations */
if (len < 0) break;
/* file name len */
fn_len = (guint32)tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_file_name_len, tvb, offset, 4, fn_len);
COUNT_BYTES(4);
len -= 4;
/* broken implementations */
if (len < 0) break;
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, TRUE, TRUE, &bc);
if (fn == NULL)
break;
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
len -= fn_len;
/* broken implementations */
if (len < 0) break;
if (neo == 0)
break; /* no more structures */
/* skip to next structure */
padcnt = (old_offset + neo) - offset;
if (padcnt < 0) {
/*
* XXX - this is bogus; flag it?
*/
padcnt = 0;
}
if (padcnt != 0) {
COUNT_BYTES(padcnt);
len -= padcnt;
/* broken implementations */
if (len < 0) break;
}
}
break;
case NT_TRANS_RENAME:
/* XXX not documented */
break;
case NT_TRANS_QSD:
/*
* This appears to be the size of the security
* descriptor; the calling sequence of
* "ZwQuerySecurityObject()" suggests that it would
* be. The actual security descriptor wouldn't
* follow if the max data count in the request
* was smaller; this lets the client know how
* big a buffer it needs to provide.
*/
proto_tree_add_item(tree, hf_smb_sec_desc_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case NT_TRANS_GET_USER_QUOTA:
proto_tree_add_item(tree, hf_smb_size_returned_quota_data, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case NT_TRANS_SET_USER_QUOTA:
/* not decoded yet */
break;
}
return offset;
}
static int
dissect_nt_trans_setup_response(tvbuff_t *tvb, packet_info *pinfo,
int offset, proto_tree *parent_tree,
int len, smb_info_t *si)
{
smb_nt_transact_info_t *nti;
DISSECTOR_ASSERT(si);
if ((si->sip != NULL) && (si->sip->extra_info_type == SMB_EI_NTI))
nti = (smb_nt_transact_info_t *)si->sip->extra_info;
else
nti = NULL;
if (parent_tree) {
if (nti != NULL) {
proto_tree_add_bytes_format(parent_tree, hf_smb_nt_transaction_setup, tvb, offset, len,
NULL, "%s Setup",
val_to_str_ext(nti->subcmd, &nt_cmd_vals_ext, "Unknown NT Transaction (%u)"));
} else {
/*
* We never saw the request to which this is a
* response.
*/
proto_tree_add_expert(parent_tree, pinfo, &ei_smb_nt_transaction_setup, tvb, offset, len);
}
}
if (nti == NULL) {
offset += len;
return offset;
}
switch(nti->subcmd) {
case NT_TRANS_CREATE:
break;
case NT_TRANS_IOCTL:
break;
case NT_TRANS_SSD:
break;
case NT_TRANS_NOTIFY:
break;
case NT_TRANS_RENAME:
/* XXX not documented */
break;
case NT_TRANS_QSD:
break;
case NT_TRANS_GET_USER_QUOTA:
/* not decoded yet */
break;
case NT_TRANS_SET_USER_QUOTA:
/* not decoded yet */
break;
}
return offset;
}
static int
dissect_nt_transaction_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc, sc;
guint32 pc = 0, po = 0, pd = 0, dc = 0, od = 0, dd = 0;
guint32 td = 0, tp = 0;
smb_nt_transact_info_t *nti = NULL;
guint16 bc;
gint32 padcnt;
fragment_head *r_fd = NULL;
tvbuff_t *pd_tvb = NULL;
gboolean save_fragmented;
DISSECTOR_ASSERT(si);
if ((si->sip != NULL) && (si->sip->extra_info_type == SMB_EI_NTI))
nti = (smb_nt_transact_info_t *)si->sip->extra_info;
else
nti = NULL;
/* primary request */
if (nti != NULL) {
proto_tree_add_uint(tree, hf_smb_nt_trans_subcmd, tvb, 0, 0, nti->subcmd);
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
val_to_str_ext(nti->subcmd, &nt_cmd_vals_ext, "<unknown (%u)>"));
} else {
proto_tree_add_uint_format_value(tree, hf_smb_nt_trans_subcmd, tvb, offset, 0, -1,
"<unknown function - could not find matching request>");
col_append_str(pinfo->cinfo, COL_INFO, ", <unknown>");
}
WORD_COUNT;
/* 3 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 3, ENC_NA);
offset += 3;
/* total param count */
tp = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_total_param_count, tvb, offset, 4, tp);
offset += 4;
/* total data count */
td = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_total_data_count, tvb, offset, 4, td);
offset += 4;
/* param count */
pc = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_param_count32, tvb, offset, 4, pc);
offset += 4;
/* param offset */
po = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_param_offset32, tvb, offset, 4, po);
offset += 4;
/* param displacement */
pd = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_param_disp32, tvb, offset, 4, pd);
offset += 4;
/* data count */
dc = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_count32, tvb, offset, 4, dc);
offset += 4;
/* data offset */
od = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_offset32, tvb, offset, 4, od);
offset += 4;
/* data displacement */
dd = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_disp32, tvb, offset, 4, dd);
offset += 4;
/* setup count */
sc = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_smb_setup_count, tvb, offset, 1, sc);
offset += 1;
/* setup data */
if (sc) {
dissect_nt_trans_setup_response(tvb, pinfo, offset, tree, sc*2, si);
offset += sc*2;
}
BYTE_COUNT;
/* reassembly of SMB NT Transaction data payload.
In this section we do reassembly of both the data and parameters
blocks of the SMB transaction command.
*/
save_fragmented = pinfo->fragmented;
/* do we need reassembly? */
if ( (td && (td != dc)) || (tp && (tp != pc)) ) {
/* oh yeah, either data or parameter section needs
reassembly...
*/
pinfo->fragmented = TRUE;
if (smb_trans_reassembly) {
/* ...and we were told to do reassembly */
if (pc) {
r_fd = smb_trans_defragment(tree, pinfo, tvb,
po, pc, pd, td+tp, si);
}
if ((r_fd == NULL) && dc) {
r_fd = smb_trans_defragment(tree, pinfo, tvb,
od, dc, dd+tp, td+tp, si);
}
}
}
/* if we got a reassembled fd structure from the reassembly routine we
must create pd_tvb from it
*/
if (r_fd) {
proto_item *frag_tree_item;
pd_tvb = tvb_new_chain(tvb, r_fd->tvb_data);
add_new_data_source(pinfo, pd_tvb, "Reassembled SMB");
show_fragment_tree(r_fd, &smb_frag_items, tree, pinfo, pd_tvb, &frag_tree_item);
}
if (pd_tvb) {
/* we have reassembled data, grab param and data from there */
dissect_nt_trans_param_response(pd_tvb, pinfo, 0, tree, tp,
(guint16) tvb_reported_length(pd_tvb), si);
dissect_nt_trans_data_response(pd_tvb, pinfo, tp, tree, td, nti, si);
COUNT_BYTES(bc); /* We are done */
} else {
/* we do not have reassembled data, just use what we have in the
packet as well as we can */
/* parameters */
if (po > (guint32)offset) {
/* We have some initial padding bytes.
*/
padcnt = po-offset;
if (padcnt > bc)
padcnt = bc;
CHECK_BYTE_COUNT(padcnt);
proto_tree_add_item(tree, hf_smb_padding, tvb, offset, padcnt, ENC_NA);
COUNT_BYTES(padcnt);
}
if (pc) {
CHECK_BYTE_COUNT(pc);
dissect_nt_trans_param_response(tvb, pinfo, offset, tree, pc, bc, si);
COUNT_BYTES(pc);
}
/* data */
if (od > (guint32)offset) {
/* We have some initial padding bytes.
*/
padcnt = od-offset;
if (padcnt > bc)
padcnt = bc;
proto_tree_add_item(tree, hf_smb_padding, tvb, offset, padcnt, ENC_NA);
COUNT_BYTES(padcnt);
}
if (dc) {
CHECK_BYTE_COUNT(dc);
dissect_nt_trans_data_response(tvb, pinfo, offset, tree, dc, nti, si);
COUNT_BYTES(dc);
}
}
pinfo->fragmented = save_fragmented;
END_OF_SMB
return offset;
}
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
NT Transaction command ends here
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
static const value_string print_mode_vals[] = {
{0, "Text Mode"},
{1, "Graphics Mode"},
{0, NULL}
};
static int
dissect_open_print_file_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
int fn_len;
const char *fn;
guint8 wc;
guint16 bc;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* setup len */
proto_tree_add_item(tree, hf_smb_setup_len, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* print mode */
proto_tree_add_item(tree, hf_smb_print_mode, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* print identifier */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, TRUE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_print_identifier, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
END_OF_SMB
return offset;
}
static int
dissect_write_print_file_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
int cnt;
guint8 wc;
guint16 bc, fid;
WORD_COUNT;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* data len */
CHECK_BYTE_COUNT(2);
cnt = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_len, tvb, offset, 2, cnt);
COUNT_BYTES(2);
/* file data */
offset = dissect_file_data(tvb, tree, offset, (guint16) cnt, -1, (guint16) cnt);
END_OF_SMB
return offset;
}
static const value_string print_status_vals[] = {
{1, "Held or Stopped"},
{2, "Printing"},
{3, "Awaiting print"},
{4, "In intercept"},
{5, "File had error"},
{6, "Printer error"},
{0, NULL}
};
static int
dissect_get_print_queue_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint8 wc;
guint16 bc;
WORD_COUNT;
/* max count */
proto_tree_add_item(tree, hf_smb_max_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* start index */
proto_tree_add_item(tree, hf_smb_start_index, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_print_queue_element(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree *parent_tree, int offset, guint16 *bcp, gboolean *trunc, smb_info_t *si)
{
proto_tree *tree;
int fn_len;
const char *fn;
DISSECTOR_ASSERT(si);
tree = proto_tree_add_subtree(parent_tree, tvb, offset, 28,
ett_smb_print_queue_entry, NULL, "Queue entry");
/* queued time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_print_queue_date,
hf_smb_print_queue_dos_date, hf_smb_print_queue_dos_time, FALSE);
*bcp -= 4;
/* status */
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(tree, hf_smb_print_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(1);
/* spool file number */
CHECK_BYTE_COUNT_SUBR(2);
proto_tree_add_item(tree, hf_smb_print_spool_file_number, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(2);
/* spool file size */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_print_spool_file_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* reserved byte */
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
COUNT_BYTES_SUBR(1);
/* file name */
fn_len = 16;
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, TRUE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(tree, hf_smb_print_spool_file_name, tvb, offset, 16,
fn);
COUNT_BYTES_SUBR(fn_len);
*trunc = FALSE;
return offset;
}
static int
dissect_get_print_queue_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint16 cnt = 0, len;
guint8 wc;
guint16 bc;
gboolean trunc;
WORD_COUNT;
/* count */
cnt = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_count, tvb, offset, 2, cnt);
offset += 2;
/* restart index */
proto_tree_add_item(tree, hf_smb_restart_index, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* data len */
CHECK_BYTE_COUNT(2);
len = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_len, tvb, offset, 2, len);
COUNT_BYTES(2);
/* queue elements */
while (cnt--) {
offset = dissect_print_queue_element(tvb, pinfo, tree, offset,
&bc, &trunc, si);
if (trunc)
goto endofcommand;
}
END_OF_SMB
return offset;
}
static int
dissect_send_single_block_message_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
int name_len;
guint16 bc;
guint8 wc;
guint16 message_len;
WORD_COUNT;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* originator name */
/* XXX - what if this runs past bc? */
name_len = tvb_strsize(tvb, offset);
CHECK_BYTE_COUNT(name_len);
proto_tree_add_item(tree, hf_smb_originator_name, tvb, offset,
name_len, ENC_ASCII);
COUNT_BYTES(name_len);
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* destination name */
/* XXX - what if this runs past bc? */
name_len = tvb_strsize(tvb, offset);
CHECK_BYTE_COUNT(name_len);
proto_tree_add_item(tree, hf_smb_destination_name, tvb, offset,
name_len, ENC_ASCII);
COUNT_BYTES(name_len);
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* message len */
CHECK_BYTE_COUNT(2);
message_len = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_message_len, tvb, offset, 2,
message_len);
COUNT_BYTES(2);
/* message */
CHECK_BYTE_COUNT(message_len);
proto_tree_add_item(tree, hf_smb_message, tvb, offset, message_len,
ENC_ASCII);
COUNT_BYTES(message_len);
END_OF_SMB
return offset;
}
static int
dissect_send_multi_block_message_start_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
int name_len;
guint16 bc;
guint8 wc;
WORD_COUNT;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* originator name */
/* XXX - what if this runs past bc? */
name_len = tvb_strsize(tvb, offset);
CHECK_BYTE_COUNT(name_len);
proto_tree_add_item(tree, hf_smb_originator_name, tvb, offset,
name_len, ENC_ASCII);
COUNT_BYTES(name_len);
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* destination name */
/* XXX - what if this runs past bc? */
name_len = tvb_strsize(tvb, offset);
CHECK_BYTE_COUNT(name_len);
proto_tree_add_item(tree, hf_smb_destination_name, tvb, offset,
name_len, ENC_ASCII);
COUNT_BYTES(name_len);
END_OF_SMB
return offset;
}
static int
dissect_message_group_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint16 bc;
guint8 wc;
WORD_COUNT;
/* message group ID */
proto_tree_add_item(tree, hf_smb_mgid, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
BYTE_COUNT;
END_OF_SMB
return offset;
}
static int
dissect_send_multi_block_message_text_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint16 bc;
guint8 wc;
guint16 message_len;
WORD_COUNT;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* message len */
CHECK_BYTE_COUNT(2);
message_len = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_message_len, tvb, offset, 2,
message_len);
COUNT_BYTES(2);
/* message */
CHECK_BYTE_COUNT(message_len);
proto_tree_add_item(tree, hf_smb_message, tvb, offset, message_len,
ENC_ASCII);
COUNT_BYTES(message_len);
END_OF_SMB
return offset;
}
static int
dissect_forwarded_name(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
int name_len;
guint16 bc;
guint8 wc;
WORD_COUNT;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* forwarded name */
/* XXX - what if this runs past bc? */
name_len = tvb_strsize(tvb, offset);
CHECK_BYTE_COUNT(name_len);
proto_tree_add_item(tree, hf_smb_forwarded_name, tvb, offset,
name_len, ENC_ASCII);
COUNT_BYTES(name_len);
END_OF_SMB
return offset;
}
static int
dissect_get_machine_name_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
int name_len;
guint16 bc;
guint8 wc;
WORD_COUNT;
BYTE_COUNT;
/* buffer format */
CHECK_BYTE_COUNT(1);
proto_tree_add_item(tree, hf_smb_buffer_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES(1);
/* machine name */
/* XXX - what if this runs past bc? */
name_len = tvb_strsize(tvb, offset);
CHECK_BYTE_COUNT(name_len);
proto_tree_add_item(tree, hf_smb_machine_name, tvb, offset,
name_len, ENC_ASCII);
COUNT_BYTES(name_len);
END_OF_SMB
return offset;
}
static int
dissect_nt_create_andx_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si _U_)
{
guint8 wc, cmd = 0xff;
guint16 andxoffset = 0;
guint16 bc;
int fn_len = -1;
const char *fn;
guint32 create_flags = 0, access_mask = 0, file_attributes = 0;
guint32 share_access = 0, create_options = 0, create_disposition = 0;
DISSECTOR_ASSERT(si);
WORD_COUNT;
/* next smb command */
cmd = tvb_get_guint8(tvb, offset);
if (cmd != 0xff) {
proto_tree_add_uint(tree, hf_smb_andxcmd, tvb, offset, 1, cmd);
} else {
proto_tree_add_uint_format_value(tree, hf_smb_andxcmd, tvb, offset, 1, cmd, "No further commands (0xff)");
}
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* andxoffset */
andxoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_andxoffset, tvb, offset, 2, andxoffset);
offset += 2;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* file name len */
fn_len = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_file_name_len, tvb, offset, 2, fn_len);
offset += 2;
/* Create flags */
create_flags = tvb_get_letohl(tvb, offset);
offset = dissect_nt_create_bits(tvb, tree, offset, 4, create_flags);
/* root directory fid */
proto_tree_add_item(tree, hf_smb_root_dir_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* nt access mask */
access_mask = tvb_get_letohl(tvb, offset);
offset = dissect_smb_access_mask_bits(tvb, tree, offset, 4, access_mask);
/* allocation size */
proto_tree_add_item(tree, hf_smb_alloc_size64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* Extended File Attributes */
file_attributes = tvb_get_letohl(tvb, offset);
offset = dissect_file_ext_attr_bits(tvb, tree, offset, 4, file_attributes);
/* share access */
share_access = tvb_get_letohl(tvb, offset);
offset = dissect_nt_share_access_bits(tvb, tree, offset, 4, share_access);
/* create disposition */
create_disposition = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb_nt_create_disposition, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* create options */
create_options = tvb_get_letohl(tvb, offset);
offset = dissect_nt_create_options_bits(tvb, tree, offset, 4, create_options);
/* impersonation level */
proto_tree_add_item(tree, hf_smb_nt_impersonation_level, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* security flags */
offset = dissect_nt_security_flags(tvb, tree, offset);
BYTE_COUNT;
/* file name */
if (fn_len == -1) {
/*
* We never set the file name length, perhaps because
* the word count was zero. This is not a valid
* packet.
*/
proto_tree_add_expert(tree, pinfo, &ei_smb_missing_word_parameters,
tvb, 0, 0);
goto endofcommand;
}
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, FALSE, &bc);
if (fn == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES(fn_len);
/* store it for the fid->name/openframe/closeframe matching in
* dissect_smb_fid() called from the response.
*/
if ((!pinfo->fd->visited) && si->sip && fn) {
smb_fid_saved_info_t *fsi;
fsi = wmem_new(wmem_file_scope(), smb_fid_saved_info_t);
fsi->filename = wmem_strdup(wmem_file_scope(), fn);
fsi->create_flags = create_flags;
fsi->access_mask = access_mask;
fsi->file_attributes = file_attributes;
fsi->share_access = share_access;
fsi->create_options = create_options;
fsi->create_disposition = create_disposition;
si->sip->extra_info_type = SMB_EI_FILEDATA;
si->sip->extra_info = fsi;
}
col_append_fstr(pinfo->cinfo, COL_INFO, ", Path: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
END_OF_SMB
if (cmd != 0xff) { /* there is an andX command */
if (andxoffset < offset)
THROW(ReportedBoundsError);
dissect_smb_command(tvb, pinfo, andxoffset, smb_tree, cmd, FALSE, si);
}
return offset;
}
static int
dissect_nt_create_andx_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si)
{
guint8 wc, cmd = 0xff;
guint16 andxoffset = 0;
guint16 bc;
guint16 fid = 0;
guint16 ftype;
guint8 isdir;
smb_fid_info_t *fid_info = NULL;
WORD_COUNT;
/* next smb command */
cmd = tvb_get_guint8(tvb, offset);
if (cmd != 0xff) {
proto_tree_add_uint(tree, hf_smb_andxcmd, tvb, offset, 1, cmd);
} else {
proto_tree_add_uint_format_value(tree, hf_smb_andxcmd, tvb, offset, 1, cmd, "No further commands (0xff)");
}
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* andxoffset */
andxoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_andxoffset, tvb, offset, 2, andxoffset);
offset += 2;
/* oplock level */
proto_tree_add_item(tree, hf_smb_oplock_level, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* fid */
fid = tvb_get_letohs(tvb, offset);
fid_info = dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, TRUE, FALSE, FALSE, si);
offset += 2;
/* create action */
/*XXX is this really the same as create disposition in the request? it looks so*/
/* No, it is not. It is the same as the create action from an Open&X request ... RJS */
proto_tree_add_item(tree, hf_smb_create_action, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* create time */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb_create_time);
/* access time */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb_access_time);
/* last write time */
offset = dissect_nt_64bit_time(tvb, tree, offset,
hf_smb_last_write_time);
/* last change time */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb_change_time);
/* Extended File Attributes */
offset = dissect_file_ext_attr(tvb, tree, offset);
/* allocation size */
proto_tree_add_item(tree, hf_smb_alloc_size64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* end of file */
/* We store the end of file */
if (fid_info) {
fid_info->end_of_file = tvb_get_letoh64(tvb, offset);
}
proto_tree_add_item(tree, hf_smb_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* File Type */
ftype = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb_file_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* IPC State */
offset = dissect_ipc_state(tvb, tree, offset, FALSE);
/* is directory */
isdir = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_smb_is_directory, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* Always use the word count to decide if this is an "extended" response.
When the server doesn't support the 0x10 flag, it will send a normal
34 word response, so the word count is the only way to tell which of
the response formats we have. MS-SMB 2.2.4.9.2
Also note that the extended format is actually 50 words, but in a
"windows behavior note" they say Windows sets word count to 42.
Handle anything 42 or larger as "extended" format. */
if (wc >= 42) {
proto_tree *tr = NULL;
/* The first field is a Volume GUID ... */
proto_tree_add_item(tree, hf_smb_volume_guid,
tvb, offset, 16, ENC_NA);
offset += 16;
/* The file ID comes next */
proto_tree_add_item(tree, hf_smb_file_id_64bit,
tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
tr = proto_tree_add_subtree(tree, tvb, offset, 4,
ett_smb_nt_access_mask, NULL, "Maximal Access Rights");
offset = dissect_smb_access_mask(tvb, tr, offset);
tr = proto_tree_add_subtree(tree, tvb, offset, 4,
ett_smb_nt_access_mask, NULL, "Guest Maximal Access Rights");
offset = dissect_smb_access_mask(tvb, tr, offset);
}
/* Try to remember the type of this fid so that we can dissect
* any future security descriptor (access mask) properly
*/
if (ftype == 0) {
if (isdir == 0) {
if (fid_info) {
fid_info->type = SMB_FID_TYPE_FILE;
}
} else {
if (fid_info) {
fid_info->type = SMB_FID_TYPE_DIR;
}
}
}
if (ftype == 2) {
if (fid_info) {
fid_info->type = SMB_FID_TYPE_PIPE;
}
}
BYTE_COUNT;
END_OF_SMB
if (cmd != 0xff) { /* there is an andX command */
if (andxoffset < offset)
THROW(ReportedBoundsError);
dissect_smb_command(tvb, pinfo, andxoffset, smb_tree, cmd, FALSE, si);
}
/* if there was an error, add a generated filename to the tree */
if (si->nt_status) {
dissect_smb_fid(tvb, pinfo, tree, 0, 0, fid, TRUE, TRUE, TRUE, si);
}
return offset;
}
static int
dissect_nt_cancel_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint8 wc;
guint16 bc;
WORD_COUNT;
BYTE_COUNT;
END_OF_SMB
return offset;
}
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
BEGIN Transaction/Transaction2 Primary and secondary requests
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
static const value_string trans2_cmd_vals[] = {
{ 0x00, "OPEN2" },
{ 0x01, "FIND_FIRST2" },
{ 0x02, "FIND_NEXT2" },
{ 0x03, "QUERY_FS_INFO" },
{ 0x04, "SET_FS_INFO" },
{ 0x05, "QUERY_PATH_INFO" },
{ 0x06, "SET_PATH_INFO" },
{ 0x07, "QUERY_FILE_INFO" },
{ 0x08, "SET_FILE_INFO" },
{ 0x09, "FSCTL" },
{ 0x0A, "IOCTL2" },
{ 0x0B, "FIND_NOTIFY_FIRST" },
{ 0x0C, "FIND_NOTIFY_NEXT" },
{ 0x0D, "CREATE_DIRECTORY" },
{ 0x0E, "SESSION_SETUP" },
{ 0x0F, "Unknown (0x0f)" }, /* dummy so val_to_str_ext can do indexed lookup */
{ 0x10, "GET_DFS_REFERRAL" },
{ 0x11, "REPORT_DFS_INCONSISTENCY" },
{ 0, NULL }
};
value_string_ext trans2_cmd_vals_ext = VALUE_STRING_EXT_INIT(trans2_cmd_vals);
static const true_false_string tfs_tf_dtid = {
"Also DISCONNECT TID",
"Do NOT disconnect TID"
};
static const true_false_string tfs_tf_owt = {
"One Way Transaction (NO RESPONSE)",
"Two way transaction"
};
static const true_false_string tfs_ff2_backup = {
"Find WITH backup intent",
"No backup intent"
};
static const true_false_string tfs_ff2_continue = {
"CONTINUE search from previous position",
"New search, do NOT continue from previous position"
};
static const true_false_string tfs_ff2_resume = {
"Return RESUME keys",
"Do NOT return resume keys"
};
static const true_false_string tfs_ff2_close_eos = {
"CLOSE search if END OF SEARCH is reached",
"Do NOT close search if end of search reached"
};
static const true_false_string tfs_ff2_close = {
"CLOSE search after this request",
"Do NOT close search after this request"
};
/* used by
TRANS2_FIND_FIRST2
*/
static const value_string ff2_il_vals[] = {
{ 1, "Info Standard"},
{ 2, "Info Query EA Size"},
{ 3, "Info Query EAs From List"},
{ 0x0101, "Find File Directory Info"},
{ 0x0102, "Find File Full Directory Info"},
{ 0x0103, "Find File Names Info"},
{ 0x0104, "Find File Both Directory Info"},
{ 0x0105, "Find File Full Directory Info"},
{ 0x0106, "Find File Id Both Directory Info"},
{ 0x0202, "Find File Unix"},
{ 0x020B, "Find File Unix Info2"},
{0, NULL}
};
/* values used by :
TRANS2_QUERY_PATH_INFORMATION
TRANS2_QUERY_FILE_INFORMATION
*/
static const value_string qpi_loi_vals[] = {
{ 1, "Info Standard"},
{ 2, "Info Query EA Size"},
{ 3, "Info Query EAs From List"},
{ 4, "Info Query All EAs"},
{ 6, "Info Is Name Valid"},
{ 0x0101, "Query File Basic Info"},
{ 0x0102, "Query File Standard Info"},
{ 0x0103, "Query File EA Info"},
{ 0x0104, "Query File Name Info"},
{ 0x0107, "Query File All Info"},
{ 0x0108, "Query File Alt Name Info"},
{ 0x0109, "Query File Stream Info"},
{ 0x010b, "Query File Compression Info"},
{ 0x0200, "Query File Unix Basic"},
{ 0x0201, "Query File Unix Link"},
{ 0x0202, "Query File Unix Hardlink"},
{ 0x0204, "Query File Posix ACL"},
{ 0x0205, "Query File Posix XATTR"},
{ 0x0206, "Query File Posix Attr Flags"},
{ 0x0207, "Query File Posix Permissions"},
{ 0x0208, "Query File Posix Lock"},
{ 0x020b, "Query File Unix Info2"},
{ 1004, "Query File Basic Info"},
{ 1005, "Query File Standard Info"},
{ 1006, "Query File Internal Info"},
{ 1007, "Query File EA Info"},
{ 1009, "Query File Name Info"},
{ 1010, "Query File Rename Info"},
{ 1011, "Query File Link Info"},
{ 1012, "Query File Names Info"},
{ 1013, "Query File Disposition Info"},
{ 1014, "Query File Position Info"},
{ 1015, "Query File Full EA Info"},
{ 1016, "Query File Mode Info"},
{ 1017, "Query File Alignment Info"},
{ 1018, "Query File All Info"},
{ 1019, "Query File Allocation Info"},
{ 1020, "Query File End of File Info"},
{ 1021, "Query File Alt Name Info"},
{ 1022, "Query File Stream Info"},
{ 1023, "Query File Pipe Info"},
{ 1024, "Query File Pipe Local Info"},
{ 1025, "Query File Pipe Remote Info"},
{ 1026, "Query File Mailslot Query Info"},
{ 1027, "Query File Mailslot Set Info"},
{ 1028, "Query File Compression Info"},
{ 1029, "Query File ObjectID Info"},
{ 1030, "Query File Completion Info"},
{ 1031, "Query File Move Cluster Info"},
{ 1032, "Query File Quota Info"},
{ 1033, "Query File Reparsepoint Info"},
{ 1034, "Query File Network Open Info"},
{ 1035, "Query File Attribute Tag Info"},
{ 1036, "Query File Tracking Info"},
{ 1037, "Query File Maximum Info"},
{0, NULL}
};
static value_string_ext qpi_loi_vals_ext = VALUE_STRING_EXT_INIT(qpi_loi_vals);
/* values used by :
TRANS2_SET_PATH_INFORMATION
TRANS2_SET_FILE_INFORMATION
(the SNIA CIFS spec lists some only for TRANS2_SET_FILE_INFORMATION,
but I'm assuming they apply to TRANS2_SET_PATH_INFORMATION as
well; note that they're different from the QUERY_PATH_INFORMATION
and QUERY_FILE_INFORMATION values!)
*/
static const value_string spi_loi_vals[] = {
{ 1, "Info Standard"},
{ 2, "Info Set EAs"},
{ 4, "Info Query All EAs"},
{ 0x0101, "Set File Basic Info"},
{ 0x0102, "Set File Disposition Info"},
{ 0x0103, "Set File Allocation Info"},
{ 0x0104, "Set File End Of File Info"},
{ 0x0200, "Set File Unix Basic"},
{ 0x0201, "Set File Unix Link"},
{ 0x0202, "Set File Unix HardLink"},
{ 0x0204, "Set File Unix ACL"},
{ 0x0205, "Set File Unix XATTR"},
{ 0x0206, "Set File Unix Attr Flags"},
{ 0x0208, "Set File Posix Lock"},
{ 0x0209, "Set File Posix Open"},
{ 0x020a, "Set File Posix Unlink"},
{ 0x020b, "Set File Unix Info2"},
{ 1004, "Set File Basic Info"},
{ 1010, "Set Rename Information"},
{ 1013, "Set Disposition Information"},
{ 1014, "Set Position Information"},
{ 1016, "Set Mode Information"},
{ 1019, "Set Allocation Information"},
{ 1020, "Set EOF Information"},
{ 1023, "Set File Pipe Information"},
{ 1025, "Set File Pipe Remote Information"},
{ 1029, "Set Copy On Write Information"},
{ 1032, "Set OLE Class ID Information"},
{ 1039, "Set Inherit Context Index Information"},
{ 1040, "Set OLE Information (?)"},
{0, NULL}
};
static value_string_ext spi_loi_vals_ext = VALUE_STRING_EXT_INIT(spi_loi_vals);
static const value_string qfsi_vals[] = {
{ 1, "Info Allocation"},
{ 2, "Info Volume"},
{ 0x0101, "Query FS Label Info"},
{ 0x0102, "Query FS Volume Info"},
{ 0x0103, "Query FS Size Info"},
{ 0x0104, "Query FS Device Info"},
{ 0x0105, "Query FS Attribute Info"},
{ 0x0200, "Unix Query FS Info"},
{ 0x0202, "Unix Query POSIX whoami"},
{ 0x0301, "Mac Query FS Info"},
{ 1001, "Query FS Label Info"},
{ 1002, "Query FS Volume Info"},
{ 1003, "Query FS Size Info"},
{ 1004, "Query FS Device Info"},
{ 1005, "Query FS Attribute Info"},
{ 1006, "Query FS Quota Info"},
{ 1007, "Query Full FS Size Info"},
{ 1008, "Object ID Information"},
{0, NULL}
};
static value_string_ext qfsi_vals_ext = VALUE_STRING_EXT_INIT(qfsi_vals);
static const value_string sfsi_vals[] = {
{ 0x203, "Request Transport Encryption"},
{ 1006, "Set FS Quota Info"},
{0, NULL}
};
static const value_string nt_rename_vals[] = {
{ 0x0103, "Create Hard Link"},
{0, NULL}
};
static const value_string delete_pending_vals[] = {
{0, "Normal, no pending delete"},
{1, "This object has DELETE PENDING"},
{0, NULL}
};
static const value_string alignment_vals[] = {
{0, "Byte alignment"},
{1, "Word (16bit) alignment"},
{3, "Long (32bit) alignment"},
{7, "8 byte boundary alignment"},
{0x0f, "16 byte boundary alignment"},
{0x1f, "32 byte boundary alignment"},
{0x3f, "64 byte boundary alignment"},
{0x7f, "128 byte boundary alignment"},
{0xff, "256 byte boundary alignment"},
{0x1ff, "512 byte boundary alignment"},
{0, NULL}
};
static const true_false_string tfs_marked_for_deletion = {
"File is MARKED FOR DELETION",
"File is NOT marked for deletion"
};
static const true_false_string tfs_get_dfs_server_hold_storage = {
"Referral SERVER HOLDS STORAGE for the file",
"Referral server does NOT hold storage for the file"
};
static const true_false_string tfs_get_dfs_fielding = {
"The server in referral is FIELDING CAPABLE",
"The server in referrals is NOT fielding capable"
};
static const true_false_string tfs_dfs_referral_flags_name_list_referral = {
"A domain/DC referral response",
"NOT a domain/DC referral response"
};
static const true_false_string tfs_dfs_referral_flags_target_set_boundary = {
"The first target in the target set",
"NOT the first target in the target set"
};
static const value_string dfs_referral_server_type_vals[] = {
{0, "Non-root targets returned"},
{1, "Root targets returns"},
{0, NULL}
};
static const true_false_string tfs_device_char_removable = {
"This is a REMOVABLE device",
"This is NOT a removable device"
};
static const true_false_string tfs_device_char_read_only = {
"This is a READ-ONLY device",
"This is NOT a read-only device"
};
static const true_false_string tfs_device_char_floppy = {
"This is a FLOPPY DISK device",
"This is NOT a floppy disk device"
};
static const true_false_string tfs_device_char_write_once = {
"This is a WRITE-ONCE device",
"This is NOT a write-once device"
};
static const true_false_string tfs_device_char_remote = {
"This is a REMOTE device",
"This is NOT a remote device"
};
static const true_false_string tfs_device_char_mounted = {
"This device is MOUNTED",
"This device is NOT mounted"
};
static const true_false_string tfs_device_char_virtual = {
"This is a VIRTUAL device",
"This is NOT a virtual device"
};
static const true_false_string tfs_device_char_secure_open = {
"This device supports SECURE OPEN",
"This device does NOT support secure open"
};
static const true_false_string tfs_device_char_ts = {
"This is a TERMINAL SERVICES device",
"This is NOT a terminal services device"
};
static const true_false_string tfs_device_char_webdav = {
"This is a WEBDAV device",
"This is NOT a webdav device"
};
static const true_false_string tfs_device_char_portable = {
"This is a PORTABLE device",
"This is NOT a portable device"
};
static const true_false_string tfs_device_char_aat = {
"This device ALLOWS APPCONTAINER TRAVERSAL",
"This device does NOT allow appcontainer traversal"
};
static const true_false_string tfs_fs_attr_css = {
"This FS supports CASE SENSITIVE SEARCHes",
"This FS does NOT support case sensitive searches"
};
static const true_false_string tfs_fs_attr_cpn = {
"This FS supports CASE PRESERVED NAMES",
"This FS does NOT support case preserved names"
};
static const true_false_string tfs_fs_attr_uod = {
"This FS supports UNICODE NAMES",
"This FS does NOT support unicode names"
};
static const true_false_string tfs_fs_attr_pacls = {
"This FS supports PERSISTENT ACLs",
"This FS does NOT support persistent acls"
};
static const true_false_string tfs_fs_attr_fc = {
"This FS supports COMPRESSED FILES",
"This FS does NOT support compressed files"
};
static const true_false_string tfs_fs_attr_vq = {
"This FS supports VOLUME QUOTAS",
"This FS does NOT support volume quotas"
};
static const true_false_string tfs_fs_attr_srp = {
"This FS supports REPARSE POINTS",
"This FS does NOT support reparse points"
};
static const true_false_string tfs_fs_attr_srs = {
"This FS supports REMOTE STORAGE",
"This FS does NOT support remote storage"
};
static const true_false_string tfs_fs_attr_ssf = {
"This FS supports SPARSE FILES",
"This FS does NOT support sparse files"
};
static const true_false_string tfs_fs_attr_sla = {
"This FS supports LFN APIs",
"This FS does NOT support lfn apis"
};
static const true_false_string tfs_fs_attr_vic = {
"This FS VOLUME IS COMPRESSED",
"This FS volume is NOT compressed"
};
static const true_false_string tfs_fs_attr_soids = {
"This FS supports OIDs",
"This FS does NOT support OIDs"
};
static const true_false_string tfs_fs_attr_se = {
"This FS supports ENCRYPTION",
"This FS does NOT support encryption"
};
static const true_false_string tfs_fs_attr_ns = {
"This FS supports NAMED STREAMS",
"This FS does NOT support named streams"
};
static const true_false_string tfs_fs_attr_rov = {
"This is a READ ONLY VOLUME",
"This is a read/write volume"
};
static const true_false_string tfs_fs_attr_swo = {
"This is a SEQUENTIAL WRITE ONCE VOLUME",
"This is NOT a sequential write once volume"
};
static const true_false_string tfs_fs_attr_st = {
"This filesystem supports TRANSACTIONS",
"This filesystem does NOT support transactions"
};
static const true_false_string tfs_fs_attr_shl = {
"This filesystem supports HARD LINKS",
"This filesystem does NOT support hard links"
};
static const true_false_string tfs_fs_attr_sis = {
"This filesystem supports INTEGRITY STREAMS",
"This filesystem does NOT support integrity streams"
};
static const true_false_string tfs_fs_attr_sbr = {
"This filesystem supports BLOCK REFCOUNTING",
"This filesystem does NOT support block refcounting"
};
static const true_false_string tfs_fs_attr_ssv = {
"This filesystem supports SPARSE VDL",
"This filesystem does NOT support sparse vdl"
};
#define FF2_RESUME 0x0004
static int
dissect_ff2_flags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, smb_info_t *si)
{
guint16 mask;
smb_transact2_info_t *t2i;
static int * const flags[] = {
&hf_smb_ff2_backup,
&hf_smb_ff2_continue,
&hf_smb_ff2_resume,
&hf_smb_ff2_close_eos,
&hf_smb_ff2_close,
NULL
};
mask = tvb_get_letohs(tvb, offset);
DISSECTOR_ASSERT(si);
if ((si->sip != NULL) && (si->sip->extra_info_type == SMB_EI_T2I)) {
t2i = (smb_transact2_info_t *)si->sip->extra_info;
if (t2i != NULL) {
if (!pinfo->fd->visited)
t2i->resume_keys = (mask & FF2_RESUME);
}
}
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_ff2, ett_smb_find_first2_flags, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
#if 0
static int
dissect_sfi_ioflag(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_sfi_writetru,
&hf_smb_sfi_caching,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_sfi, ett_smb_ioflag, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
#endif
int
dissect_get_dfs_request_data(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, int offset, guint16 *bcp, gboolean unicode)
{
int fn_len;
const char *fn;
guint16 bc = *bcp;
/* referral level */
CHECK_BYTE_COUNT_TRANS(2);
proto_tree_add_item(tree, hf_smb_max_referral_level, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS(2);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, unicode, &fn_len, FALSE, FALSE, &bc);
CHECK_STRING_TRANS(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_TRANS(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", File: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
*bcp = bc;
return offset;
}
static int
dissect_transaction2_request_parameters(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *parent_tree, int offset, int subcmd, guint16 bc, smb_info_t *si)
{
proto_tree *tree;
smb_transact2_info_t *t2i;
int fn_len;
const char *fn;
DISSECTOR_ASSERT(si);
if ((si->sip != NULL) && (si->sip->extra_info_type == SMB_EI_T2I))
t2i = (smb_transact2_info_t *)si->sip->extra_info;
else
t2i = NULL;
tree = proto_tree_add_subtree_format(parent_tree, tvb, offset, bc,
ett_smb_transaction_params, NULL, "%s Parameters",
val_to_str_ext(subcmd, &trans2_cmd_vals_ext,
"Unknown (0x%02x)"));
switch(subcmd) {
case 0x0000: /*TRANS2_OPEN2*/
/* open flags */
CHECK_BYTE_COUNT_TRANS(2);
offset = dissect_open_flags(tvb, tree, offset, 0x000f);
bc -= 2;
/* desired access */
CHECK_BYTE_COUNT_TRANS(2);
offset = dissect_access(tvb, tree, offset, hf_smb_desired_access);
bc -= 2;
/* Search Attributes */
CHECK_BYTE_COUNT_TRANS(2);
offset = dissect_search_attributes(tvb, tree, offset);
bc -= 2;
/* File Attributes */
CHECK_BYTE_COUNT_TRANS(2);
offset = dissect_file_attributes(tvb, tree, offset);
bc -= 2;
/* create time */
CHECK_BYTE_COUNT_TRANS(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_create_time,
hf_smb_create_dos_date, hf_smb_create_dos_time,
TRUE);
bc -= 4;
/* open function */
CHECK_BYTE_COUNT_TRANS(2);
offset = dissect_open_function(tvb, tree, offset);
bc -= 2;
/* allocation size */
CHECK_BYTE_COUNT_TRANS(4);
proto_tree_add_item(tree, hf_smb_alloc_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS(4);
/* 10 reserved bytes */
CHECK_BYTE_COUNT_TRANS(10);
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 10, ENC_NA);
COUNT_BYTES_TRANS(10);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, FALSE, &bc);
CHECK_STRING_TRANS(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_TRANS(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Path: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
break;
case 0x0001: /*TRANS2_FIND_FIRST2*/
/* Search Attributes */
CHECK_BYTE_COUNT_TRANS(2);
offset = dissect_search_attributes(tvb, tree, offset);
bc -= 2;
/* search count */
CHECK_BYTE_COUNT_TRANS(2);
proto_tree_add_item(tree, hf_smb_search_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS(2);
/* Find First2 flags */
CHECK_BYTE_COUNT_TRANS(2);
offset = dissect_ff2_flags(tvb, pinfo, tree, offset, si);
bc -= 2;
/* Find First2 information level */
CHECK_BYTE_COUNT_TRANS(2);
si->info_level = tvb_get_letohs(tvb, offset);
if ((t2i != NULL) && !pinfo->fd->visited)
t2i->info_level = si->info_level;
proto_tree_add_uint(tree, hf_smb_ff2_information_level, tvb, offset, 2, si->info_level);
COUNT_BYTES_TRANS(2);
/* storage type */
CHECK_BYTE_COUNT_TRANS(4);
proto_tree_add_item(tree, hf_smb_storage_type, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS(4);
/* search pattern */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, FALSE, &bc);
CHECK_STRING_TRANS(fn);
if (t2i && !t2i->name) {
t2i->name = wmem_strdup(wmem_file_scope(), fn);
}
proto_tree_add_string(tree, hf_smb_search_pattern, tvb, offset, fn_len,
fn);
COUNT_BYTES_TRANS(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Pattern: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
break;
case 0x0002: /*TRANS2_FIND_NEXT2*/
/* sid */
CHECK_BYTE_COUNT_TRANS(2);
proto_tree_add_item(tree, hf_smb_search_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS(2);
/* search count */
CHECK_BYTE_COUNT_TRANS(2);
proto_tree_add_item(tree, hf_smb_search_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS(2);
/* Find First2 information level */
CHECK_BYTE_COUNT_TRANS(2);
si->info_level = tvb_get_letohs(tvb, offset);
if ((t2i != NULL) && !pinfo->fd->visited)
t2i->info_level = si->info_level;
proto_tree_add_uint(tree, hf_smb_ff2_information_level, tvb, offset, 2, si->info_level);
COUNT_BYTES_TRANS(2);
/* resume key */
CHECK_BYTE_COUNT_TRANS(4);
proto_tree_add_item(tree, hf_smb_resume, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS(4);
/* Find First2 flags */
CHECK_BYTE_COUNT_TRANS(2);
offset = dissect_ff2_flags(tvb, pinfo, tree, offset, si);
bc -= 2;
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, FALSE, &bc);
CHECK_STRING_TRANS(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_TRANS(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Continue: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
break;
case 0x0003: /*TRANS2_QUERY_FS_INFORMATION*/
/* level of interest */
CHECK_BYTE_COUNT_TRANS(2);
si->info_level = tvb_get_letohs(tvb, offset);
if ((t2i != NULL) && !pinfo->fd->visited)
t2i->info_level = si->info_level;
proto_tree_add_uint(tree, hf_smb_qfsi_information_level, tvb, offset, 2, si->info_level);
COUNT_BYTES_TRANS(2);
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
val_to_str_ext(si->info_level, &qfsi_vals_ext,
"Unknown (0x%02x)"));
break;
case 0x0004: /*TRANS2_SET_FS_INFORMATION*/
/* level of interest */
CHECK_BYTE_COUNT_TRANS(4);
si->info_level = tvb_get_letohs(tvb, offset+2);
if ((t2i != NULL) && !pinfo->fd->visited)
t2i->info_level = si->info_level;
proto_tree_add_uint(tree, hf_smb_sfsi_information_level, tvb, offset+2, 2, si->info_level);
COUNT_BYTES_TRANS(4);
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
val_to_str(si->info_level, sfsi_vals,
"Unknown (0x%02x)"));
break;
case 0x0005: /*TRANS2_QUERY_PATH_INFORMATION*/
/* level of interest */
CHECK_BYTE_COUNT_TRANS(2);
si->info_level = tvb_get_letohs(tvb, offset);
if ((t2i != NULL) && !pinfo->fd->visited)
t2i->info_level = si->info_level;
proto_tree_add_uint(tree, hf_smb_qpi_loi, tvb, offset, 2, si->info_level);
COUNT_BYTES_TRANS(2);
col_append_fstr(
pinfo->cinfo, COL_INFO, ", %s",
val_to_str_ext(si->info_level, &qpi_loi_vals_ext,
"Unknown (%u)"));
/* 4 reserved bytes */
CHECK_BYTE_COUNT_TRANS(4);
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 4, ENC_NA);
COUNT_BYTES_TRANS(4);
/* file name */
fn = tvb_get_stringz_enc(wmem_packet_scope(), tvb, offset, &fn_len, (si->unicode ? ENC_UTF_16|ENC_LITTLE_ENDIAN : ENC_ASCII|ENC_NA));
CHECK_STRING_TRANS(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_TRANS(fn_len);
if (t2i && !t2i->name) {
t2i->name = wmem_strdup(wmem_file_scope(), fn);
}
col_append_fstr(pinfo->cinfo, COL_INFO, ", Path: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
break;
case 0x0006: /*TRANS2_SET_PATH_INFORMATION*/
/* level of interest */
CHECK_BYTE_COUNT_TRANS(2);
si->info_level = tvb_get_letohs(tvb, offset);
if ((t2i != NULL) && !pinfo->fd->visited)
t2i->info_level = si->info_level;
proto_tree_add_uint(tree, hf_smb_spi_loi, tvb, offset, 2, si->info_level);
COUNT_BYTES_TRANS(2);
/* 4 reserved bytes */
CHECK_BYTE_COUNT_TRANS(4);
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 4, ENC_NA);
COUNT_BYTES_TRANS(4);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, FALSE, &bc);
CHECK_STRING_TRANS(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_TRANS(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Path: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
break;
case 0x0007: { /*TRANS2_QUERY_FILE_INFORMATION*/
guint16 fid;
/* fid */
CHECK_BYTE_COUNT_TRANS(2);
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
COUNT_BYTES_TRANS(2);
/* level of interest */
CHECK_BYTE_COUNT_TRANS(2);
si->info_level = tvb_get_letohs(tvb, offset);
if ((t2i != NULL) && !pinfo->fd->visited)
t2i->info_level = si->info_level;
proto_tree_add_uint(tree, hf_smb_qpi_loi, tvb, offset, 2, si->info_level);
COUNT_BYTES_TRANS(2);
col_append_fstr(
pinfo->cinfo, COL_INFO, ", %s",
val_to_str_ext(si->info_level, &qpi_loi_vals_ext,
"Unknown (%u)"));
break;
}
case 0x0008: { /*TRANS2_SET_FILE_INFORMATION*/
guint16 fid;
/* fid */
CHECK_BYTE_COUNT_TRANS(2);
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
COUNT_BYTES_TRANS(2);
/* level of interest */
CHECK_BYTE_COUNT_TRANS(2);
si->info_level = tvb_get_letohs(tvb, offset);
if ((t2i != NULL) && !pinfo->fd->visited)
t2i->info_level = si->info_level;
proto_tree_add_uint(tree, hf_smb_spi_loi, tvb, offset, 2, si->info_level);
COUNT_BYTES_TRANS(2);
#if 0
/*
* XXX - "Microsoft Networks SMB File Sharing Protocol
* Extensions Version 3.0, Document Version 1.11,
* July 19, 1990" says this is I/O flags, but it's
* reserved in the SNIA spec, and some clients appear
* to leave junk in it.
*
* Is this some field used only if a particular
* dialect was negotiated, so that clients can feel
* safe not setting it if they haven't negotiated that
* dialect? Or do the (non-OS/2) clients simply not care
* about that particular OS/2-oriented dialect?
*/
/* IO Flag */
CHECK_BYTE_COUNT_TRANS(2);
offset = dissect_sfi_ioflag(tvb, tree, offset);
bc -= 2;
#else
/* 2 reserved bytes */
CHECK_BYTE_COUNT_TRANS(2);
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
COUNT_BYTES_TRANS(2);
#endif
break;
}
case 0x0009: /*TRANS2_FSCTL*/
/* this call has no parameter block in the request */
/*
* XXX - "Microsoft Networks SMB File Sharing Protocol
* Extensions Version 3.0, Document Version 1.11,
* July 19, 1990" says this contains a
* "File system specific parameter block". (That means
* we may not be able to dissect it in any case.)
*/
break;
case 0x000a: /*TRANS2_IOCTL2*/
/* this call has no parameter block in the request */
/*
* XXX - "Microsoft Networks SMB File Sharing Protocol
* Extensions Version 3.0, Document Version 1.11,
* July 19, 1990" says this contains a
* "Device/function specific parameter block". (That
* means we may not be able to dissect it in any case.)
*/
break;
case 0x000b: /*TRANS2_FIND_NOTIFY_FIRST*/
/* Search Attributes */
CHECK_BYTE_COUNT_TRANS(2);
offset = dissect_search_attributes(tvb, tree, offset);
bc -= 2;
/* Number of changes to wait for */
CHECK_BYTE_COUNT_TRANS(2);
proto_tree_add_item(tree, hf_smb_change_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS(2);
/* Find Notify information level */
CHECK_BYTE_COUNT_TRANS(2);
si->info_level = tvb_get_letohs(tvb, offset);
if ((t2i != NULL) && !pinfo->fd->visited)
t2i->info_level = si->info_level;
proto_tree_add_uint(tree, hf_smb_fn_information_level, tvb, offset, 2, si->info_level);
COUNT_BYTES_TRANS(2);
/* 4 reserved bytes */
CHECK_BYTE_COUNT_TRANS(4);
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 4, ENC_NA);
COUNT_BYTES_TRANS(4);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, FALSE, &bc);
CHECK_STRING_TRANS(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_TRANS(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Path: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
break;
case 0x000c: /*TRANS2_FIND_NOTIFY_NEXT*/
/* Monitor handle */
CHECK_BYTE_COUNT_TRANS(2);
proto_tree_add_item(tree, hf_smb_monitor_handle, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS(2);
/* Number of changes to wait for */
CHECK_BYTE_COUNT_TRANS(2);
proto_tree_add_item(tree, hf_smb_change_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS(2);
break;
case 0x000d: /*TRANS2_CREATE_DIRECTORY*/
/* 4 reserved bytes */
CHECK_BYTE_COUNT_TRANS(4);
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 4, ENC_NA);
COUNT_BYTES_TRANS(4);
/* dir name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len,
FALSE, FALSE, &bc);
CHECK_STRING_TRANS(fn);
proto_tree_add_string(tree, hf_smb_dir_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_TRANS(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Dir: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
break;
case 0x000e: /*TRANS2_SESSION_SETUP*/
/* XXX unknown structure*/
break;
case 0x0010: /*TRANS2_GET_DFS_REFERRAL*/
offset = dissect_get_dfs_request_data(tvb, pinfo, tree, offset, &bc, si->unicode);
break;
case 0x0011: /*TRANS2_REPORT_DFS_INCONSISTENCY*/
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, FALSE, &bc);
CHECK_STRING_TRANS(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_TRANS(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, ", File: %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
break;
}
/* ooops there were data we didn't know how to process */
if (bc != 0) {
proto_tree_add_item(tree, hf_smb_unknown, tvb, offset, bc, ENC_NA);
offset += bc;
}
return offset;
}
/*
* XXX - just use "dissect_connect_flags()" here?
*/
static guint16
dissect_transaction_flags(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
guint16 mask;
static int * const flags[] = {
&hf_smb_transaction_flags_owt,
&hf_smb_transaction_flags_dtid,
NULL
};
mask = tvb_get_letohs(tvb, offset);
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_transaction_flags, ett_smb_transaction_flags, flags, ENC_LITTLE_ENDIAN);
return mask;
}
static int
dissect_get_dfs_flags(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_get_dfs_server_hold_storage,
&hf_smb_get_dfs_fielding,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_get_dfs_flags, ett_smb_get_dfs_flags, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
static int
dissect_dfs_referral_flags(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_dfs_referral_flags_name_list_referral,
&hf_smb_dfs_referral_flags_target_set_boundary,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_dfs_referral_flags, ett_smb_dfs_referral_flags, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
/* dfs inconsistency data (4.4.2)
*/
static int
dissect_dfs_inconsistency_data(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree *tree, int offset, guint16 *bcp, smb_info_t *si)
{
int fn_len;
const char *fn;
DISSECTOR_ASSERT(si);
/*XXX shouldn this data hold version and size? unclear from doc*/
/* referral version */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
proto_tree_add_item(tree, hf_smb_dfs_referral_version, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(2);
/* referral size */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
proto_tree_add_item(tree, hf_smb_dfs_referral_size, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(2);
/* referral server type */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
proto_tree_add_item(tree, hf_smb_dfs_referral_server_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(2);
/* referral flags */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
offset = dissect_dfs_referral_flags(tvb, tree, offset);
*bcp -= 2;
/* node name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, FALSE, bcp);
CHECK_STRING_TRANS_SUBR(fn);
proto_tree_add_string(tree, hf_smb_dfs_referral_node, tvb, offset, fn_len,
fn);
COUNT_BYTES_TRANS_SUBR(fn_len);
return offset;
}
static int
dissect_dfs_referral_strings(tvbuff_t *tvb, proto_tree *tree, int hfindex,
int nstring, int stroffset, int oldoffset, int offset,
guint16 bc, gboolean unicode, int *end)
{
int istring;
const char *str;
int str_len; /* string length including the terminating NULL. */
if (stroffset <= oldoffset)
return oldoffset;
bc -= (stroffset - offset);
for (istring = 0; istring < nstring; istring++) {
if ((gint16)bc > 0) {
str = get_unicode_or_ascii_string(tvb, &stroffset, unicode, &str_len, FALSE, FALSE, &bc);
CHECK_STRING_TRANS_SUBR(str);
proto_tree_add_string(tree, hfindex, tvb, stroffset, str_len, str);
stroffset += str_len;
bc -= str_len;
if (end && (*end < stroffset))
*end = stroffset;
}
}
return offset;
}
static int
dissect_dfs_referral_string(tvbuff_t *tvb, proto_tree *tree, int hfindex,
int stroffset, int oldoffset, int offset,
guint16 bc, gboolean unicode, int *end)
{
return dissect_dfs_referral_strings(tvb, tree, hfindex,
1, stroffset, oldoffset, offset,
bc, unicode, end);
}
static int
dissect_dfs_referral_entry_v2(tvbuff_t *tvb, proto_tree *tree, int oldoffset, int offset,
guint16 refflags _U_, guint16 *bcp, gboolean unicode, int *ucstring_end)
{
guint16 pathoffset;
guint16 altpathoffset;
guint16 nodeoffset;
/* proximity */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_dfs_referral_proximity, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* ttl */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_dfs_referral_ttl, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* path offset */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
pathoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_dfs_referral_path_offset, tvb, offset, 2, pathoffset);
COUNT_BYTES_TRANS_SUBR(2);
/* alt path offset */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
altpathoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_dfs_referral_alt_path_offset, tvb, offset, 2, altpathoffset);
COUNT_BYTES_TRANS_SUBR(2);
/* node offset */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
nodeoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_dfs_referral_node_offset, tvb, offset, 2, nodeoffset);
COUNT_BYTES_TRANS_SUBR(2);
/* path */
if (pathoffset) {
dissect_dfs_referral_string(tvb, tree, hf_smb_dfs_referral_path,
pathoffset+oldoffset, oldoffset, offset,
*bcp, unicode, ucstring_end);
}
/* alt path */
if (altpathoffset) {
dissect_dfs_referral_string(tvb, tree, hf_smb_dfs_referral_alt_path,
altpathoffset+oldoffset, oldoffset, offset,
*bcp, unicode, ucstring_end);
}
/* node */
if (nodeoffset) {
dissect_dfs_referral_string(tvb, tree, hf_smb_dfs_referral_node,
nodeoffset+oldoffset, oldoffset, offset,
*bcp, unicode, ucstring_end);
}
return offset;
}
static int
dissect_dfs_referral_entry_v3(tvbuff_t *tvb, proto_tree *tree, int oldoffset, int offset,
guint16 refflags, guint16 *bcp, gboolean unicode, int *ucstring_end)
{
guint16 domoffset;
guint16 nexpnames;
guint16 expoffset;
guint16 pathoffset;
guint16 altpathoffset;
guint16 nodeoffset;
/* ttl */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_dfs_referral_ttl, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
if (refflags & REFENT_FLAGS_NAME_LIST_REFERRAL) {
/* domain name offset */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
domoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_dfs_referral_domain_offset, tvb, offset, 2, domoffset);
COUNT_BYTES_TRANS_SUBR(2);
/* number of expanded names*/
CHECK_BYTE_COUNT_TRANS_SUBR(2);
nexpnames = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_dfs_referral_number_of_expnames, tvb, offset, 2, nexpnames);
COUNT_BYTES_TRANS_SUBR(2);
/* expanded names offset */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
expoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_dfs_referral_expnames_offset, tvb, offset, 2, expoffset);
COUNT_BYTES_TRANS_SUBR(2);
/* padding: zero or 16 bytes, which should be ignored by clients.
* we ignore them too.
*/
/* domain name */
if (domoffset) {
dissect_dfs_referral_string(tvb, tree, hf_smb_dfs_referral_domain_name,
domoffset+oldoffset, oldoffset, offset,
*bcp, unicode, ucstring_end);
}
/* expanded names */
if (expoffset) {
proto_tree *exptree;
exptree = proto_tree_add_subtree(tree, tvb, offset, *bcp, ett_smb_dfs_referral_expnames, NULL, "Expanded Names");
dissect_dfs_referral_strings(tvb, exptree, hf_smb_dfs_referral_expname,
nexpnames, expoffset+oldoffset, oldoffset, offset,
*bcp, unicode, ucstring_end);
}
} else {
/* path offset */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
pathoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_dfs_referral_path_offset, tvb, offset, 2, pathoffset);
COUNT_BYTES_TRANS_SUBR(2);
/* alt path offset */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
altpathoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_dfs_referral_alt_path_offset, tvb, offset, 2, altpathoffset);
COUNT_BYTES_TRANS_SUBR(2);
/* node offset */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
nodeoffset = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_dfs_referral_node_offset, tvb, offset, 2, nodeoffset);
COUNT_BYTES_TRANS_SUBR(2);
/* service site guid */
CHECK_BYTE_COUNT_TRANS_SUBR(16);
proto_tree_add_item(tree, hf_smb_dfs_referral_server_guid, tvb, offset, 16, ENC_NA);
COUNT_BYTES_TRANS_SUBR(16);
/* path */
if (pathoffset) {
dissect_dfs_referral_string(tvb, tree, hf_smb_dfs_referral_path,
pathoffset+oldoffset, oldoffset, offset,
*bcp, unicode, ucstring_end);
}
/* alt path */
if (altpathoffset) {
dissect_dfs_referral_string(tvb, tree, hf_smb_dfs_referral_alt_path,
altpathoffset+oldoffset, oldoffset, offset,
*bcp, unicode, ucstring_end);
}
/* node */
if (nodeoffset) {
dissect_dfs_referral_string(tvb, tree, hf_smb_dfs_referral_node,
nodeoffset+oldoffset, oldoffset, offset,
*bcp, unicode, ucstring_end);
}
}
return offset;
}
/* get dfs referral data (4.4.1)
*/
int
dissect_get_dfs_referral_data(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree *tree, int offset, guint16 *bcp, gboolean unicode)
{
guint16 numref;
guint16 refsize;
guint16 refflags;
int fn_len;
const char *fn;
int unklen;
int ucstring_end;
int ucstring_len;
/* path consumed */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
proto_tree_add_item(tree, hf_smb_dfs_path_consumed, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(2);
/* num referrals */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
numref = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_dfs_num_referrals, tvb, offset, 2, numref);
COUNT_BYTES_TRANS_SUBR(2);
/* get dfs flags */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
offset = dissect_get_dfs_flags(tvb, tree, offset);
*bcp -= 2;
/* XXX - in at least one capture there appears to be 2 bytes
of stuff after the Dfs flags, perhaps so that the header
in front of the referral list is a multiple of 4 bytes long. */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
proto_tree_add_item(tree, hf_smb_padding, tvb, offset, 2, ENC_NA);
COUNT_BYTES_TRANS_SUBR(2);
/* if there are any referrals */
if (numref) {
proto_item *ref_item;
proto_tree *ref_tree;
int old_offset = offset;
ref_tree = proto_tree_add_subtree(tree,
tvb, offset, *bcp, ett_smb_dfs_referrals, &ref_item, "Referrals");
ucstring_end = -1;
while (numref--) {
proto_item *ri;
proto_tree *rt;
int old_offset_2 = offset;
guint16 version;
rt = proto_tree_add_subtree(ref_tree,
tvb, offset, *bcp, ett_smb_dfs_referral, &ri, "Referral");
/* referral version */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
version = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(rt, hf_smb_dfs_referral_version,
tvb, offset, 2, version);
COUNT_BYTES_TRANS_SUBR(2);
/* referral size */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
refsize = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(rt, hf_smb_dfs_referral_size, tvb, offset, 2, refsize);
COUNT_BYTES_TRANS_SUBR(2);
/* referral server type */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
proto_tree_add_item(rt, hf_smb_dfs_referral_server_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(2);
/* referral flags */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
refflags = tvb_get_letohs(tvb, offset);
offset = dissect_dfs_referral_flags(tvb, rt, offset);
*bcp -= 2;
switch(version) {
case 1:
/* node name */
fn = get_unicode_or_ascii_string(tvb, &offset, unicode, &fn_len, FALSE, FALSE, bcp);
CHECK_STRING_TRANS_SUBR(fn);
proto_tree_add_string(rt, hf_smb_dfs_referral_node, tvb, offset, fn_len,
fn);
COUNT_BYTES_TRANS_SUBR(fn_len);
break;
case 2:
offset = dissect_dfs_referral_entry_v2(tvb, rt, old_offset_2, offset,
refflags, bcp, unicode, &ucstring_end);
break;
case 3:
offset = dissect_dfs_referral_entry_v3(tvb, rt, old_offset_2, offset,
refflags, bcp, unicode, &ucstring_end);
break;
case 4:
/* V4 is extactly same as V3, except the version number and
* one more ReferralEntryFlags */
offset = dissect_dfs_referral_entry_v3(tvb, rt, old_offset_2, offset,
refflags, bcp, unicode, &ucstring_end);
break;
}
/*
* Show anything beyond the length of the referral
* as unknown data.
*/
unklen = (old_offset_2 + refsize) - offset;
if (unklen < 0) {
/*
* XXX - the length is bogus.
*/
unklen = 0;
}
if (unklen != 0) {
CHECK_BYTE_COUNT_TRANS_SUBR(unklen);
proto_tree_add_item(rt, hf_smb_unknown, tvb,
offset, unklen, ENC_NA);
COUNT_BYTES_TRANS_SUBR(unklen);
}
proto_item_set_len(ri, offset-old_offset_2);
}
/*
* Treat the offset past the end of the last Unicode
* string after the referrals (if any) as the last
* offset.
*/
if (ucstring_end > offset) {
ucstring_len = ucstring_end - offset;
if (*bcp < ucstring_len)
ucstring_len = *bcp;
offset += ucstring_len;
*bcp -= ucstring_len;
}
proto_item_set_len(ref_item, offset-old_offset);
}
return offset;
}
/* This dissects the standard four 8-byte Windows timestamps ...
*/
static int
dissect_smb_standard_8byte_timestamps(tvbuff_t *tvb,
packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* create time */
CHECK_BYTE_COUNT_SUBR(8);
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb_create_time);
*bcp -= 8;
/* access time */
CHECK_BYTE_COUNT_SUBR(8);
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb_access_time);
*bcp -= 8;
/* last write time */
CHECK_BYTE_COUNT_SUBR(8);
offset = dissect_nt_64bit_time(tvb, tree, offset,
hf_smb_last_write_time);
*bcp -= 8;
/* last change time */
CHECK_BYTE_COUNT_SUBR(8);
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb_change_time);
*bcp -= 8;
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_INFO_STANDARD
as described in 4.2.16.1 of the CIFS 1.0 specification
or as described in 2.2.8.3.1 of the MS-CIFS specification for query
section 2.2.8.4.1 of the MS-CIFS specification describes it for set;
it says that everything past the last write time is "reserved",
presumably meaning that you can fetch it but not set it
for now we just use it for both query and set
*/
static int
dissect_qsfi_SMB_INFO_STANDARD(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* create time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_create_time, hf_smb_create_dos_date, hf_smb_create_dos_time,
FALSE);
*bcp -= 4;
/* access time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_access_time, hf_smb_access_dos_date, hf_smb_access_dos_time,
FALSE);
*bcp -= 4;
/* last write time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_last_write_time, hf_smb_last_write_dos_date, hf_smb_last_write_dos_time,
FALSE);
*bcp -= 4;
/* data size */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_data_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* allocation size */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_alloc_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* File Attributes */
CHECK_BYTE_COUNT_SUBR(2);
offset = dissect_file_attributes(tvb, tree, offset);
*bcp -= 2;
/*
* The MS-CIFS spec says this doesn't have an EA length field;
* the SNIA CIFS spec says it does, as does the 1996
* "Microsoft Networks SMB FILE SHARING PROTOCOL Document
* Version 6.0p" document.
*
* Some older SMB documents point to the documentation
* for the OS/2 DosQFileInfo() API; the page at
*
* http://cyberkinetica.homeunix.net/os2tk45/prcp/111_L2_DosQFileInfo.html
*
* says that, for level 1 (SMB_INFO_STANDARD), there is no EA
* length - that's just for level 2 (SMB_INFO_QUERY_EA_SIZE).
*
* I've seen captures with it and without it; given the mixed
* messages sent by different documents, this is not surprising.
*
* We display it if it's there; we don't set *trunc if it's
* not.
*
* Note: in FIND_FIRST2/FIND_NEXT2, the EA length is *not*
* present.
*/
if (*bcp != 0) {
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_ea_list_length, tvb, offset,
4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
}
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_INFO_QUERY_EA_SIZE
as described in 4.2.16.1 of the CIFS 1.0 specification
and as described in 2.2.8.3.2 of the MS-CIFS specification
*/
static int
dissect_qfi_SMB_INFO_QUERY_EA_SIZE(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* create time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_create_time, hf_smb_create_dos_date, hf_smb_create_dos_time,
FALSE);
*bcp -= 4;
/* access time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_access_time, hf_smb_access_dos_date, hf_smb_access_dos_time,
FALSE);
*bcp -= 4;
/* last write time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_last_write_time, hf_smb_last_write_dos_date, hf_smb_last_write_dos_time,
FALSE);
*bcp -= 4;
/* data size */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_data_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* allocation size */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_alloc_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* File Attributes */
CHECK_BYTE_COUNT_SUBR(2);
offset = dissect_file_attributes(tvb, tree, offset);
*bcp -= 2;
/* ea length */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_ea_list_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_INFO_QUERY_EAS_FROM_LIST and SMB_INFO_QUERY_ALL_EAS
as described in 4.2.16.2
*/
static int
dissect_4_2_16_2(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
guint8 name_len;
guint16 data_len;
/* EA size */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_ea_list_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
while (*bcp > 0) {
proto_item *item;
proto_tree *subtree;
char *display_string;
int start_offset = offset;
subtree = proto_tree_add_subtree(
tree, tvb, offset, 0, ett_smb_ea, &item, "Extended Attribute");
/* EA flags */
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(
subtree, hf_smb_ea_flags, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(1);
/* EA name length */
name_len = tvb_get_guint8(tvb, offset);
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(
subtree, hf_smb_ea_name_length, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(1);
/* EA data length */
data_len = tvb_get_letohs(tvb, offset);
CHECK_BYTE_COUNT_SUBR(2);
proto_tree_add_item(
subtree, hf_smb_ea_data_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(2);
/* EA name */
CHECK_BYTE_COUNT_SUBR(name_len + 1);
proto_tree_add_item_ret_display_string(
subtree, hf_smb_ea_name, tvb, offset, name_len + 1,
ENC_ASCII|ENC_NA,
wmem_packet_scope(), &display_string);
proto_item_append_text(item, ": %s", display_string);
COUNT_BYTES_SUBR(name_len + 1);
/* EA data */
CHECK_BYTE_COUNT_SUBR(data_len);
proto_tree_add_item(
subtree, hf_smb_ea_data, tvb, offset, data_len, ENC_NA);
COUNT_BYTES_SUBR(data_len);
proto_item_set_len(item, offset - start_offset);
}
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_INFO_IS_NAME_VALID
as described in 4.2.16.3
*/
static int
dissect_4_2_16_3(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc, smb_info_t *si)
{
int fn_len;
const char *fn;
DISSECTOR_ASSERT(si);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, FALSE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_SUBR(fn_len);
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_QUERY_FILE_BASIC_INFO
as described in 4.2.16.4
*/
static int
dissect_4_2_16_4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
offset = dissect_smb_standard_8byte_timestamps(tvb, pinfo, tree, offset, bcp, trunc);
if (*trunc) {
return offset;
}
/* File Attributes */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_file_ext_attr(tvb, tree, offset);
*bcp -= 4;
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_QUERY_FILE_STANDARD_INFO
as described in 4.2.16.5 of the SNIA CIFS spec
and section 2.2.8.3.7 of the MS-CIFS spec
*/
int
dissect_qfi_SMB_FILE_STANDARD_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* allocation size */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_alloc_size64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* end of file */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* number of links */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_number_of_links, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* delete pending */
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(tree, hf_smb_delete_pending, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(1);
/* is directory */
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(tree, hf_smb_is_directory, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(1);
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_QUERY_FILE_INTERNAL_INFO
*/
int
dissect_qfi_SMB_FILE_INTERNAL_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* file id */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_index_number, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_QUERY_FILE_POSITION_INFO
*/
int
dissect_qsfi_SMB_FILE_POSITION_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* file position */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_position, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_QUERY_FILE_MODE_INFO
*/
int
dissect_qsfi_SMB_FILE_MODE_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* mode */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_mode, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_QUERY_FILE_ALIGNMENT_INFO
*/
int
dissect_qfi_SMB_FILE_ALIGNMENT_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* alignment */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_t2_alignment, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_QUERY_FILE_EA_INFO
as described in 4.2.16.6 of the SNIA CIFS spec
and 2.2.8.3.8 of the MS-CIFS spec
*/
int
dissect_qfi_SMB_FILE_EA_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* ea length */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_ea_list_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_FILE_ALLOCATION_INFO
as described in 4.2.19.3 in the SNIA CIFS spec
and the SMB_SET_FILE_ALLOCATION_INFO
as described in 2.2.8.4.5 in the MS-CIFS spec for set (MS-CIFS doesn't
say it can be queried)
*/
int
dissect_qsfi_SMB_FILE_ALLOCATION_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* allocation size */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_alloc_size64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_FILE_ENDOFFILE_INFO
as described in 4.2.19.4 in the SNIA CIFS spec
and the SMB_SET_FILE_END_OF_FILE_INFO
as described in 2.2.8.4.6 in the MS-CIFS spec for set (MS-CIFS doesn't
say it can be queried)
*/
int
dissect_qsfi_SMB_FILE_ENDOFFILE_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* offset of end of file */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_QUERY_FILE_NAME_INFO
as described in 4.2.16.7 of the SNIA CIFS spec
and in 2.2.8.3.9 of the MS-CIFS spec
this is the same as SMB_QUERY_FILE_ALT_NAME_INFO
as described in 4.2.16.9 of the SNIA CIFS spec
and 2.2.8.3.11 of the MS-CIFS spec
although the latter two are used to fetch the 8.3 name
rather than the long name
https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/4718fc40-e539-4014-8e33-b675af74e3e1
FileNormalizedNameInformation:
https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/20bcadba-808c-4880-b757-4af93e41edf6
*/
int
dissect_qfi_SMB_FILE_NAME_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc, gboolean unicode)
{
int fn_len;
const char *fn;
/* file name len */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item_ret_uint(tree, hf_smb_file_name_len, tvb, offset, 4, ENC_LITTLE_ENDIAN, &fn_len);
COUNT_BYTES_SUBR(4);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, unicode, &fn_len, TRUE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_SUBR(fn_len);
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_QUERY_FILE_ALL_INFO
as described in 2.2.8.3.8 of the MS-CIFS spec
but not as described in 4.2.16.8 since SNIA spec is wrong
*/
static int
dissect_qfi_SMB_FILE_ALL_INFO(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc, smb_info_t *si)
{
guint32 fn_len;
const char *fn;
DISSECTOR_ASSERT(si);
offset = dissect_smb_standard_8byte_timestamps(tvb, pinfo, tree, offset, bcp, trunc);
if (*trunc) {
return offset;
}
/* File Attributes */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_file_ext_attr(tvb, tree, offset);
*bcp -= 4;
/* 4 pad bytes */
offset += 4;
*bcp -= 4;
/* allocation size */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_alloc_size64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* end of file */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* number of links */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_number_of_links, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* delete pending */
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(tree, hf_smb_delete_pending, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(1);
/* is directory */
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(tree, hf_smb_is_directory, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(1);
/* 2 pad bytes */
offset += 2;
*bcp -= 2;
/* ea length */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_ea_list_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* file name len */
CHECK_BYTE_COUNT_SUBR(4);
fn_len = (guint32)tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_file_name_len, tvb, offset, 4, fn_len);
COUNT_BYTES_SUBR(4);
/* file name */
CHECK_BYTE_COUNT_SUBR(fn_len);
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, TRUE, TRUE, bcp);
if (fn != NULL) {
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_SUBR(fn_len);
}
if (*trunc)
return offset;
return offset;
}
/* this dissects the SMB_QUERY_FILE_STREAM_INFO
as described in 4.2.16.10 of the SNIA CIFS spec
and 2.2.8.3.12 of the MS-CIFS spec
*/
int
dissect_qfi_SMB_FILE_STREAM_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree,
int offset, guint16 *bcp, gboolean *trunc, int unicode)
{
proto_item *item;
proto_tree *tree;
int old_offset;
guint32 neo;
int fn_len;
const char *fn;
int padcnt;
for (;;) {
old_offset = offset;
/* next entry offset */
CHECK_BYTE_COUNT_SUBR(4);
tree = proto_tree_add_subtree(parent_tree, tvb, offset, *bcp, ett_smb_ff2_data, &item, "Stream Info");
neo = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_next_entry_offset, tvb, offset, 4, neo);
COUNT_BYTES_SUBR(4);
/* stream name len */
CHECK_BYTE_COUNT_SUBR(4);
fn_len = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_t2_stream_name_length, tvb, offset, 4, fn_len);
COUNT_BYTES_SUBR(4);
/* stream size */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_t2_stream_size, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* allocation size */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_alloc_size64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* stream name */
fn = get_unicode_or_ascii_string(tvb, &offset, unicode, &fn_len, FALSE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(tree, hf_smb_t2_stream_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_SUBR(fn_len);
proto_item_append_text(item, ": %s", format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
proto_item_set_len(item, offset-old_offset);
if (neo == 0)
break; /* no more structures */
/* skip to next structure */
padcnt = (old_offset + neo) - offset;
if (padcnt < 0) {
/*
* XXX - this is bogus; flag it?
*/
padcnt = 0;
}
if (padcnt != 0) {
CHECK_BYTE_COUNT_SUBR(padcnt);
COUNT_BYTES_SUBR(padcnt);
}
}
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_QUERY_FILE_COMPRESSION_INFO
as described in 4.2.16.11 of the SNIA CIFS spec
and 2.2.8.3.13 of the MS-CIFS spec
*/
int
dissect_qfi_SMB_FILE_COMPRESSION_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* compressed file size */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_t2_compressed_file_size, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* compression format */
CHECK_BYTE_COUNT_SUBR(2);
proto_tree_add_item(tree, hf_smb_t2_compressed_format, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(2);
/* compression unit shift */
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(tree, hf_smb_t2_compressed_unit_shift, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(1);
/* compression chunk shift */
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(tree, hf_smb_t2_compressed_chunk_shift, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(1);
/* compression cluster shift */
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(tree, hf_smb_t2_compressed_cluster_shift, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(1);
/* 3 reserved bytes */
CHECK_BYTE_COUNT_SUBR(3);
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 3, ENC_NA);
COUNT_BYTES_SUBR(3);
*trunc = FALSE;
return offset;
}
/* 4.2.16.12 - SMB_QUERY_FILE_UNIX_BASIC */
static const value_string unix_file_type_vals[] = {
{ 0, "File" },
{ 1, "Directory" },
{ 2, "Symbolic link" },
{ 3, "Character device" },
{ 4, "Block device" },
{ 5, "FIFO" },
{ 6, "Socket" },
{ 0, NULL }
};
static int
dissect_4_2_16_12(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* End of file (file size) */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_size, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Number of bytes */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_num_bytes, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Last status change */
CHECK_BYTE_COUNT_SUBR(8);
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb_unix_file_last_status);
*bcp -= 8; /* dissect_nt_64bit_time() increments offset */
/* Last access time */
CHECK_BYTE_COUNT_SUBR(8);
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb_unix_file_last_access);
*bcp -= 8;
/* Last modification time */
CHECK_BYTE_COUNT_SUBR(8);
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb_unix_file_last_change);
*bcp -= 8;
/* File owner uid */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_uid, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* File group gid */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_gid, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* File type */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_unix_file_type, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* Major device number */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_dev_major, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Minor device number */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_dev_minor, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Unique id */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_unique_id, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Permissions */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_permissions, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Nlinks */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_nlinks, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Sometimes there is one extra byte in the data field which I
guess could be padding, but we are only using 4 or 8 byte
data types so this is a bit confusing. -tpot */
*trunc = FALSE;
return offset;
}
/* 4.2.16.13 - SMB_QUERY_FILE_UNIX_LINK */
static int
dissect_4_2_16_13(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc, smb_info_t *si)
{
const char *fn;
int fn_len = 0;
DISSECTOR_ASSERT(si);
/* Link destination */
fn = get_unicode_or_ascii_string(
tvb, &offset, si->unicode, &fn_len, FALSE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(
tree, hf_smb_unix_file_link_dest, tvb, offset, fn_len, fn);
COUNT_BYTES_SUBR(fn_len);
*trunc = FALSE;
return offset;
}
/* unix ACL
*/
static int
dissect_qspi_unix_acl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
guint16 num_file_aces;
static int * const perm_fields[] = {
&hf_smb_posix_ace_perm_read,
&hf_smb_posix_ace_perm_write,
&hf_smb_posix_ace_perm_execute,
NULL
};
/* version */
CHECK_BYTE_COUNT_SUBR(2);
proto_tree_add_item(tree, hf_smb_posix_acl_version, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(2);
/* num file acls */
CHECK_BYTE_COUNT_SUBR(2);
num_file_aces = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb_posix_num_file_aces, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(2);
/* num default acls */
CHECK_BYTE_COUNT_SUBR(2);
proto_tree_add_item(tree, hf_smb_posix_num_def_aces, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(2);
while (num_file_aces--) {
proto_item *it, *type_item;
proto_tree *tr;
int old_offset = offset;
guint8 ace_type;
tr = proto_tree_add_subtree(tree, tvb, offset, 0, ett_smb_posix_ace, &it, "ACE");
/* ace type */
CHECK_BYTE_COUNT_SUBR(1);
ace_type = tvb_get_guint8(tvb, offset);
type_item = proto_tree_add_item(tr, hf_smb_posix_ace_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(1);
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_bitmask(tr, tvb, offset, hf_smb_posix_ace_flags, ett_smb_posix_ace_perms, perm_fields, ENC_BIG_ENDIAN);
COUNT_BYTES_SUBR(1);
switch(ace_type) {
case POSIX_ACE_TYPE_USER_OBJ:
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tr, hf_smb_posix_ace_perm_owner_uid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
CHECK_BYTE_COUNT_SUBR(4);
/* 4 reserved bytes */
COUNT_BYTES_SUBR(4);
break;
case POSIX_ACE_TYPE_GROUP_OBJ:
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tr, hf_smb_posix_ace_perm_owner_gid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
CHECK_BYTE_COUNT_SUBR(4);
/* 4 reserved bytes */
COUNT_BYTES_SUBR(4);
break;
case POSIX_ACE_TYPE_MASK:
case POSIX_ACE_TYPE_OTHER:
CHECK_BYTE_COUNT_SUBR(8);
/* 8 reserved bytes */
COUNT_BYTES_SUBR(8);
break;
case POSIX_ACE_TYPE_USER:
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tr, hf_smb_posix_ace_perm_uid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
CHECK_BYTE_COUNT_SUBR(4);
/* 4 reserved bytes */
COUNT_BYTES_SUBR(4);
break;
case POSIX_ACE_TYPE_GROUP:
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tr, hf_smb_posix_ace_perm_gid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
CHECK_BYTE_COUNT_SUBR(4);
/* 4 reserved bytes */
COUNT_BYTES_SUBR(4);
break;
default:
expert_add_info(pinfo, type_item, &ei_smb_posix_ace_type);
CHECK_BYTE_COUNT_SUBR(8);
/* skip 8 bytes */
COUNT_BYTES_SUBR(8);
}
proto_item_set_len(it, offset-old_offset);
}
*trunc = FALSE;
return offset;
}
static int
dissect_qspi_unix_xattr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
int offset, guint16 *bcp _U_, gboolean *trunc)
{
proto_tree_add_expert(tree, pinfo, &ei_smb_not_implemented, tvb, offset, 0);
*trunc = FALSE;
return offset;
}
static int
dissect_qspi_unix_attr_flags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
int offset, guint16 *bcp _U_, gboolean *trunc)
{
proto_tree_add_expert(tree, pinfo, &ei_smb_not_implemented, tvb, offset, 0);
*trunc = FALSE;
return offset;
}
static int
dissect_qpi_unix_permissions(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
int offset, guint16 *bcp _U_, gboolean *trunc)
{
proto_tree_add_expert(tree, pinfo, &ei_smb_not_implemented, tvb, offset, 0);
*trunc = FALSE;
return offset;
}
static int
dissect_qspi_unix_lock(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
int offset, guint16 *bcp _U_, gboolean *trunc)
{
proto_tree_add_expert(tree, pinfo, &ei_smb_not_implemented, tvb, offset, 0);
*trunc = FALSE;
return offset;
}
static int
dissect_qspi_unix_open(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
int offset, guint16 *bcp _U_, gboolean *trunc)
{
proto_tree_add_expert(tree, pinfo, &ei_smb_not_implemented, tvb, offset, 0);
*trunc = FALSE;
return offset;
}
static int
dissect_qspi_unix_unlink(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
int offset, guint16 *bcp _U_, gboolean *trunc)
{
proto_tree_add_expert(tree, pinfo, &ei_smb_not_implemented, tvb, offset, 0);
*trunc = FALSE;
return offset;
}
/* SMB_FIND_FILE_UNIX_INFO2 */
#if 0
static const true_false_string tfs_i2f_secure_delete = {
"File should be erased such that the data is not recoverable",
"File need not be erased such that the data is not recoverable"
};
static const true_false_string tfs_i2f_enable_undelete = {
"File should opt-in to a server-specific deletion recovery scheme",
"File should not opt-in to a server-specific deletion recovery scheme"
};
static const true_false_string tfs_i2f_synchronous = {
"I/O to this file should be performed synchronously",
"I/O to this file need not be performed synchronously"
};
static const true_false_string tfs_i2f_immutable = {
"NO changes can be made to this file",
"Changes can be made to this file if permissions allow it"
};
static const true_false_string tfs_i2f_append_only = {
"Only appends can be made to this file",
"Writes can be made atop existing data in this file"
};
static const true_false_string tfs_i2f_do_not_backup = {
"Backup programs should ignore this file",
"Backup programs should not ignore this file"
};
static const true_false_string tfs_i2f_no_update_atime = {
"The server is not required to update the last access time on this file",
"The server is required to update the last access time on this file"
};
static const true_false_string tfs_i2f_hidden = {
"User interface programs may ignore this file",
"User interface programs should not ignore this file based solely on this flag"
};
#endif
static int
dissect_unix_info2_file_flags(tvbuff_t *tvb, proto_tree *parent_tree, int offset, int hf)
{
static int * const flags[] = {
&hf_smb_unix_info2_file_flags_secure_delete,
&hf_smb_unix_info2_file_flags_enable_undelete,
&hf_smb_unix_info2_file_flags_synchronous,
&hf_smb_unix_info2_file_flags_immutable,
&hf_smb_unix_info2_file_flags_append_only,
&hf_smb_unix_info2_file_flags_do_not_backup,
&hf_smb_unix_info2_file_flags_no_update_atime,
&hf_smb_unix_info2_file_flags_hidden,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf, ett_smb_info2_file_flags, flags, ENC_LITTLE_ENDIAN);
offset += 4;
return offset;
}
static int
dissect_qspi_unix_info2(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* End of file (file size) */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_size, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Number of bytes (or blocks? The SNIA spec for UNIX basic
info says "bytes", the Samba page for this says "blocks") */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_num_bytes, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Last status change */
CHECK_BYTE_COUNT_SUBR(8);
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb_unix_file_last_status);
*bcp -= 8;
/* Last access time */
CHECK_BYTE_COUNT_SUBR(8);
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb_unix_file_last_access);
*bcp -= 8;
/* Last modification time */
CHECK_BYTE_COUNT_SUBR(8);
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb_unix_file_last_change);
*bcp -= 8;
/* File owner uid */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_uid, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* File group gid */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_gid, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* File type */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_unix_file_type, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* Major device number */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_dev_major, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Minor device number */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_dev_minor, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Unique id */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_unique_id, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Permissions */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_permissions, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Nlinks */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_nlinks, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Creation time */
CHECK_BYTE_COUNT_SUBR(8);
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb_unix_file_creation_time);
*bcp -= 8;
/* File flags */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_unix_info2_file_flags(tvb, tree, offset, hf_smb_unix_info2_file_flags);
*bcp -= 4;
/* File flags mask */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_unix_info2_file_flags(tvb, tree, offset, hf_smb_unix_info2_file_flags_mask);
*bcp -= 4;
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_QUERY_FILE_NETWORK_OPEN_INFO
*/
int
dissect_qfi_SMB_FILE_NETWORK_OPEN_INFO(tvbuff_t *tvb,
packet_info *pinfo, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
offset = dissect_smb_standard_8byte_timestamps(tvb, pinfo, tree, offset, bcp, trunc);
if (*trunc) {
return offset;
}
/* allocation size */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_alloc_size64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* end of file */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* File Attributes */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_file_ext_attr(tvb, tree, offset);
*bcp -= 4;
/* 4 reserved bytes */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 4, ENC_NA);
COUNT_BYTES_SUBR(4);
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_FILE_ATTRIBUTE_TAG_INFO
*/
int
dissect_qfi_SMB_FILE_ATTRIBUTE_TAG_INFO(tvbuff_t *tvb,
packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* attribute */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_attribute, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* reparse tag */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_reparse_tag, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
*trunc = FALSE;
return offset;
}
/* this dissects the SMB_SET_FILE_DISPOSITION_INFO
as described in 4.2.19.2
*/
static int
dissect_4_2_19_2(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* marked for deletion? */
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(tree, hf_smb_t2_marked_for_deletion, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(1);
*trunc = FALSE;
return offset;
}
/* Set File Rename Info */
static const true_false_string tfs_smb_replace = {
"Remove target file if it exists",
"Do NOT remove target file if it exists",
};
static int
dissect_rename_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc, smb_info_t *si)
{
const char *fn;
guint32 target_name_len;
int fn_len;
DISSECTOR_ASSERT(si);
/* Replace flag */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_replace, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* Root directory handle */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_root_dir_handle, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* Target name length */
CHECK_BYTE_COUNT_SUBR(4);
target_name_len = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_target_name_len, tvb, offset, 4, target_name_len);
COUNT_BYTES_SUBR(4);
/* Target name */
fn_len = target_name_len;
fn = get_unicode_or_ascii_string(
tvb, &offset, si->unicode, &fn_len, FALSE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(
tree, hf_smb_target_name, tvb, offset, fn_len, fn);
COUNT_BYTES_SUBR(fn_len);
*trunc = FALSE;
return offset;
}
static int
dissect_disposition_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc, smb_info_t *si)
{
#if 0
const char *fn;
guint32 target_name_len;*/
int fn_len;
#endif
DISSECTOR_ASSERT(si);
/* Disposition flags */
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(tree, hf_smb_disposition_delete_on_close, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(1);
*trunc = FALSE;
return offset;
}
int
dissect_sfi_SMB_FILE_PIPE_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
int offset, guint16 *bcp, gboolean *trunc)
{
/* pipe info flag */
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(tree, hf_smb_pipe_info_flag, tvb, offset, 1, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(1);
*trunc = FALSE;
return offset;
}
/*dissect the data block for TRANS2_QUERY_PATH_INFORMATION and
TRANS2_QUERY_FILE_INFORMATION*/
static int
dissect_qpi_loi_vals(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
proto_item *item, int offset, guint16 *bcp, smb_info_t *si)
{
gboolean trunc = FALSE;
if (!*bcp) {
return offset;
}
DISSECTOR_ASSERT(si);
switch(si->info_level) {
case 1: /*Info Standard*/
offset = dissect_qsfi_SMB_INFO_STANDARD(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 2: /*Info Query EA Size*/
offset = dissect_qfi_SMB_INFO_QUERY_EA_SIZE(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 3: /*Info Query EAs From List*/
case 4: /*Info Query All EAs*/
offset = dissect_4_2_16_2(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 6: /*Info Is Name Valid*/
offset = dissect_4_2_16_3(tvb, pinfo, tree, offset, bcp,
&trunc, si);
break;
case 0x0101: /*Query File Basic Info*/
case 1004: /* SMB_FILE_BASIC_INFORMATION */
offset = dissect_4_2_16_4(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0102: /*Query File Standard Info*/
case 1005: /* SMB_FILE_STANDARD_INFORMATION */
offset = dissect_qfi_SMB_FILE_STANDARD_INFO(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 1006: /* SMB_FILE_INTERNAL_INFORMATION */
offset = dissect_qfi_SMB_FILE_INTERNAL_INFO(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0103: /*Query File EA Info*/
case 1007: /* SMB_FILE_EA_INFORMATION */
offset = dissect_qfi_SMB_FILE_EA_INFO(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0104: /*Query File Name Info*/
case 1009: /* SMB_FILE_NAME_INFORMATION */
offset = dissect_qfi_SMB_FILE_NAME_INFO(tvb, pinfo, tree, offset, bcp,
&trunc, si->unicode);
break;
case 1014: /* SMB_FILE_POSITION_INFORMATION */
offset = dissect_qsfi_SMB_FILE_POSITION_INFO(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 1016: /* SMB_FILE_MODE_INFORMATION */
offset = dissect_qsfi_SMB_FILE_MODE_INFO(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 1017: /* SMB_FILE_ALIGNMENT_INFORMATION */
offset = dissect_qfi_SMB_FILE_ALIGNMENT_INFO(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0107: /*Query File All Info*/
case 1018: /* SMB_FILE_ALL_INFORMATION */
offset = dissect_qfi_SMB_FILE_ALL_INFO(tvb, pinfo, tree, offset, bcp,
&trunc, si);
break;
case 1019: /* SMB_FILE_ALLOCATION_INFORMATION */
offset = dissect_qsfi_SMB_FILE_ALLOCATION_INFO(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 1020: /* SMB_FILE_ENDOFFILE_INFORMATION */
offset = dissect_qsfi_SMB_FILE_ENDOFFILE_INFO(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0108: /*Query File Alt File Info*/
case 1021: /* SMB_FILE_ALTERNATE_NAME_INFORMATION */
offset = dissect_qfi_SMB_FILE_NAME_INFO(tvb, pinfo, tree, offset, bcp,
&trunc, si->unicode);
break;
case 1022: /* SMB_FILE_STREAM_INFORMATION */
si->unicode = TRUE;
/* FALLTHRU */
case 0x0109: /*Query File Stream Info*/
offset = dissect_qfi_SMB_FILE_STREAM_INFO(tvb, pinfo, tree, offset, bcp,
&trunc, si->unicode);
break;
case 0x010b: /*Query File Compression Info*/
case 1028: /* SMB_FILE_COMPRESSION_INFORMATION */
offset = dissect_qfi_SMB_FILE_COMPRESSION_INFO(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 1034: /* SMB_FILE_NETWORK_OPEN_INFO */
offset = dissect_qfi_SMB_FILE_NETWORK_OPEN_INFO(tvb, pinfo, tree, offset, bcp, &trunc);
break;
case 1035: /* SMB_FILE_ATTRIBUTE_TAG_INFO */
offset = dissect_qfi_SMB_FILE_ATTRIBUTE_TAG_INFO(tvb, pinfo, tree, offset, bcp, &trunc);
break;
case 0x0200: /* Query File Unix Basic*/
offset = dissect_4_2_16_12(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0201: /* Query File Unix Link*/
offset = dissect_4_2_16_13(tvb, pinfo, tree, offset, bcp,
&trunc, si);
break;
case 0x0202: /* Query File Unix HardLink*/
/* XXX add this from the SNIA doc */
break;
case 0x0204: /* Query File Unix ACL*/
offset = dissect_qspi_unix_acl(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0205: /* Query File Unix XATTR*/
offset = dissect_qspi_unix_xattr(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0206: /* Query File Unix Attr Flags*/
offset = dissect_qspi_unix_attr_flags(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0207: /* Query File Unix Permissions*/
offset = dissect_qpi_unix_permissions(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0208: /* Query File Unix Lock*/
offset = dissect_qspi_unix_lock(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x020b: /* Query File Unix Info2*/
offset = dissect_qspi_unix_info2(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
default:
proto_tree_add_expert(tree, pinfo, &ei_smb_info_level_unknown, tvb, offset, *bcp);
offset += *bcp;
*bcp = 0;
trunc = FALSE;
break;
}
if (trunc) {
expert_add_info(pinfo, item, &ei_smb_mal_information_level);
}
return offset;
}
/*dissect the data block for TRANS2_SET_PATH_INFORMATION and
TRANS2_SET_FILE_INFORMATION*/
static int
dissect_spi_loi_vals(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
proto_item *item, int offset, guint16 *bcp, smb_info_t *si)
{
gboolean trunc;
if (!*bcp) {
return offset;
}
DISSECTOR_ASSERT(si);
switch(si->info_level) {
case 1: /*Info Standard*/
offset = dissect_qsfi_SMB_INFO_STANDARD(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 2: /*Info Set EAs*/
offset = dissect_4_2_16_2(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 4: /*Info Query All EAs - not in [MS-CIFS]*/
offset = dissect_4_2_16_2(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0101: /*Set File Basic Info*/
case 1004: /* SMB_FILE_BASIC_INFORMATION */
offset = dissect_4_2_16_4(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0102: /*Set File Disposition Info*/
offset = dissect_4_2_19_2(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0103: /*Set File Allocation Info*/
case 1019: /* Set File Allocation Information */
offset = dissect_qsfi_SMB_FILE_ALLOCATION_INFO(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0104: /*Set End Of File Info*/
case 1020: /* SMB_FILE_ENDOFFILE_INFORMATION */
offset = dissect_qsfi_SMB_FILE_ENDOFFILE_INFO(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0200: /*Set File Unix Basic. Same as query. */
offset = dissect_4_2_16_12(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0201: /*Set File Unix Link. Same as query. */
offset = dissect_4_2_16_13(tvb, pinfo, tree, offset, bcp,
&trunc, si);
break;
case 0x0202: /*Set File Unix HardLink. Same as link query. */
offset = dissect_4_2_16_13(tvb, pinfo, tree, offset, bcp,
&trunc, si);
break;
case 0x0204: /* Set File Unix ACL*/
offset = dissect_qspi_unix_acl(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0205: /* Set File Unix XATTR*/
offset = dissect_qspi_unix_xattr(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0206: /* Set File Unix Attr Flags*/
offset = dissect_qspi_unix_attr_flags(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0208: /* Set File Unix Lock*/
offset = dissect_qspi_unix_lock(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x0209: /* Set File Unix Open*/
offset = dissect_qspi_unix_open(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x020a: /* Set File Unix Unlink*/
offset = dissect_qspi_unix_unlink(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 0x020b: /* Set File Unix Info2*/
offset = dissect_qspi_unix_info2(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 1010: /* Set File Rename */
offset = dissect_rename_info(tvb, pinfo, tree, offset, bcp,
&trunc, si);
break;
case 1013: /* Set Disposition Information */
offset = dissect_disposition_info(tvb, pinfo, tree, offset, bcp,
&trunc, si);
break;
case 1014: /* SMB_FILE_POSITION_INFORMATION */
offset = dissect_qsfi_SMB_FILE_POSITION_INFO(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 1016: /* SMB_FILE_MODE_INFORMATION */
offset = dissect_qsfi_SMB_FILE_MODE_INFO(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 1023: /* Set Pipe Info */
offset = dissect_sfi_SMB_FILE_PIPE_INFO(tvb, pinfo, tree, offset, bcp,
&trunc);
break;
case 1025:
case 1029:
case 1032:
case 1039:
case 1040:
/* XXX: TODO, extra levels discovered by tridge */
proto_tree_add_expert(tree, pinfo, &ei_smb_info_level_not_understood, tvb, offset, *bcp);
offset += *bcp;
*bcp = 0;
trunc = FALSE;
break;
default:
proto_tree_add_expert(tree, pinfo, &ei_smb_info_level_unknown, tvb, offset, *bcp);
offset += *bcp;
*bcp = 0;
trunc = FALSE;
break;
}
if (trunc) {
expert_add_info(pinfo, item, &ei_smb_mal_information_level);
}
return offset;
}
static const true_false_string tfs_quota_flags_deny_disk = {
"DENY DISK SPACE for users exceeding quota limit",
"Do NOT deny disk space for users exceeding quota limit"
};
static const true_false_string tfs_quota_flags_log_limit = {
"LOG EVENT when a user exceeds their QUOTA LIMIT",
"Do NOT log event when a user exceeds their quota limit"
};
static const true_false_string tfs_quota_flags_log_warning = {
"LOG EVENT when a user exceeds their WARNING LEVEL",
"Do NOT log event when a user exceeds their warning level"
};
static const true_false_string tfs_quota_flags_enabled = {
"Quotas are ENABLED of this fs",
"Quotas are NOT enabled on this fs"
};
static void
dissect_quota_flags(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const mask[] = {
&hf_smb_quota_flags_deny_disk,
&hf_smb_quota_flags_log_warning,
&hf_smb_quota_flags_log_limit,
&hf_smb_quota_flags_enabled,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_quota_flags,
ett_smb_quotaflags, mask, ENC_NA);
}
int
dissect_nt_quota(tvbuff_t *tvb, proto_tree *tree, int offset, guint16 *bcp)
{
/* first 24 bytes are unknown */
CHECK_BYTE_COUNT_TRANS_SUBR(24);
proto_tree_add_item(tree, hf_smb_unknown, tvb,
offset, 24, ENC_NA);
COUNT_BYTES_TRANS_SUBR(24);
/* number of bytes for quota warning */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
proto_tree_add_item(tree, hf_smb_soft_quota_limit, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(8);
/* number of bytes for quota limit */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
proto_tree_add_item(tree, hf_smb_hard_quota_limit, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(8);
/* one byte of quota flags */
CHECK_BYTE_COUNT_TRANS_SUBR(1);
dissect_quota_flags(tvb, tree, offset);
COUNT_BYTES_TRANS_SUBR(1);
/* these 7 bytes are unknown */
CHECK_BYTE_COUNT_TRANS_SUBR(7);
proto_tree_add_item(tree, hf_smb_unknown, tvb,
offset, 7, ENC_NA);
COUNT_BYTES_TRANS_SUBR(7);
return offset;
}
static int
dissect_sfsi_request(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
int offset, guint16 *bcp, smb_info_t *si)
{
if (!*bcp) {
return offset;
}
DISSECTOR_ASSERT(si);
switch(si->info_level) {
case 0x203: /* REQUEST_TRANSPORT_ENCRYPTION */ {
proto_item *blob_item;
tvbuff_t *blob_tvb;
proto_tree *blob_tree;
/* security blob */
blob_item = proto_tree_add_item(tree, hf_smb_security_blob,
tvb, offset,
tvb_reported_length_remaining(tvb, offset),
ENC_NA);
/* As an optimization, because Windows is perverse,
we check to see if NTLMSSP is the first part of the
blob, and if so, call the NTLMSSP dissector,
otherwise we call the GSS-API dissector. This is because
Windows can request RAW NTLMSSP, but will happily handle
a client that wraps NTLMSSP in SPNEGO
*/
blob_tree = proto_item_add_subtree(blob_item,
ett_smb_secblob);
blob_tvb = tvb_new_subset_remaining(tvb, offset);
if (tvb_strneql(blob_tvb, 0, "NTLMSSP", 7) == 0) {
call_dissector(ntlmssp_handle, blob_tvb, pinfo, blob_tree);
} else {
call_dissector(gssapi_handle, blob_tvb, pinfo, blob_tree);
}
offset += tvb_reported_length_remaining(tvb, offset);
*bcp = 0;
break;
}
case 1006: /* QUERY_FS_QUOTA_INFO */
offset = dissect_nt_quota(tvb, tree, offset, bcp);
break;
}
return offset;
}
static int
dissect_sfsi_response(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
int offset, guint16 *bcp, smb_info_t *si)
{
if (!*bcp) {
return offset;
}
DISSECTOR_ASSERT(si);
switch(si->info_level) {
case 0x203: /* REQUEST_TRANSPORT_ENCRYPTION */ {
proto_item *blob_item;
tvbuff_t *blob_tvb;
proto_tree *blob_tree;
/* security blob */
blob_item = proto_tree_add_item(tree, hf_smb_security_blob,
tvb, offset,
tvb_reported_length_remaining(tvb, offset),
ENC_NA);
/* As an optimization, because Windows is perverse,
we check to see if NTLMSSP is the first part of the
blob, and if so, call the NTLMSSP dissector,
otherwise we call the GSS-API dissector. This is because
Windows can request RAW NTLMSSP, but will happily handle
a client that wraps NTLMSSP in SPNEGO
*/
blob_tree = proto_item_add_subtree(blob_item,
ett_smb_secblob);
blob_tvb = tvb_new_subset_remaining(tvb, offset);
if (tvb_strneql(blob_tvb, 0, "NTLMSSP", 7) == 0) {
call_dissector(ntlmssp_handle, blob_tvb, pinfo, blob_tree);
} else {
call_dissector(gssapi_handle, blob_tvb, pinfo, blob_tree);
}
offset += tvb_reported_length_remaining(tvb, offset);
*bcp = 0;
break;
}
case 1006: /* QUERY_FS_QUOTA_INFO */
/* nothing */
break;
}
return offset;
}
static int
dissect_transaction2_request_data(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *parent_tree, int offset, int subcmd, guint16 dc, smb_info_t *si)
{
proto_item *item;
proto_tree *tree;
DISSECTOR_ASSERT(si);
tree = proto_tree_add_subtree_format(parent_tree, tvb, offset, dc,
ett_smb_transaction_data, &item, "%s Data",
val_to_str_ext(subcmd, &trans2_cmd_vals_ext,
"Unknown (0x%02x)"));
switch(subcmd) {
case 0x0000: /*TRANS2_OPEN2*/
/* XXX don't know how to decode FEAList */
break;
case 0x0001: /*TRANS2_FIND_FIRST2*/
/* XXX don't know how to decode FEAList */
break;
case 0x0002: /*TRANS2_FIND_NEXT2*/
/* XXX don't know how to decode FEAList */
break;
case 0x0003: /*TRANS2_QUERY_FS_INFORMATION*/
/* no data field in this request */
break;
case 0x0004: /* TRANS2_SET_FS_INFORMATION */
offset = dissect_sfsi_request(tvb, pinfo, tree, offset, &dc, si);
break;
case 0x0005: /*TRANS2_QUERY_PATH_INFORMATION*/
/* no data field in this request */
/*
* XXX - "Microsoft Networks SMB File Sharing Protocol
* Extensions Version 3.0, Document Version 1.11,
* July 19, 1990" says there may be "Additional
* FileInfoLevel dependent information" here.
*
* Was that just a cut-and-pasteo?
* TRANS2_SET_PATH_INFORMATION *does* have that information
* here.
*/
break;
case 0x0006: /*TRANS2_SET_PATH_INFORMATION*/
offset = dissect_spi_loi_vals(tvb, pinfo, tree, item, offset, &dc, si);
break;
case 0x0007: /*TRANS2_QUERY_FILE_INFORMATION*/
/* no data field in this request */
/*
* XXX - "Microsoft Networks SMB File Sharing Protocol
* Extensions Version 3.0, Document Version 1.11,
* July 19, 1990" says there may be "Additional
* FileInfoLevel dependent information" here.
*
* Was that just a cut-and-pasteo?
* TRANS2_SET_FILE_INFORMATION *does* have that information
* here.
*/
break;
case 0x0008: /*TRANS2_SET_FILE_INFORMATION*/
offset = dissect_spi_loi_vals(tvb, pinfo, tree, item, offset, &dc, si);
break;
case 0x0009: /*TRANS2_FSCTL*/
/*XXX don't know how to decode this yet */
/*
* XXX - "Microsoft Networks SMB File Sharing Protocol
* Extensions Version 3.0, Document Version 1.11,
* July 19, 1990" says this contains a
* "File system specific data block". (That means we
* may not be able to dissect it in any case.)
*/
break;
case 0x000a: /*TRANS2_IOCTL2*/
/*XXX don't know how to decode this yet */
/*
* XXX - "Microsoft Networks SMB File Sharing Protocol
* Extensions Version 3.0, Document Version 1.11,
* July 19, 1990" says this contains a
* "Device/function specific data block". (That
* means we may not be able to dissect it in any case.)
*/
break;
case 0x000b: /*TRANS2_FIND_NOTIFY_FIRST*/
/*XXX don't know how to decode this yet */
/*
* XXX - "Microsoft Networks SMB File Sharing Protocol
* Extensions Version 3.0, Document Version 1.11,
* July 19, 1990" says this contains "additional
* level dependent match data".
*/
break;
case 0x000c: /*TRANS2_FIND_NOTIFY_NEXT*/
/*XXX don't know how to decode this yet */
/*
* XXX - "Microsoft Networks SMB File Sharing Protocol
* Extensions Version 3.0, Document Version 1.11,
* July 19, 1990" says this contains "additional
* level dependent monitor information".
*/
break;
case 0x000d: /*TRANS2_CREATE_DIRECTORY*/
/* XXX optional FEAList, unknown what FEAList looks like*/
break;
case 0x000e: /*TRANS2_SESSION_SETUP*/
/*XXX don't know how to decode this yet */
break;
case 0x0010: /*TRANS2_GET_DFS_REFERRAL*/
/* no data field in this request */
break;
case 0x0011: /*TRANS2_REPORT_DFS_INCONSISTENCY*/
offset = dissect_dfs_inconsistency_data(tvb, pinfo, tree, offset, &dc, si);
break;
}
/* ooops there were data we didn't know how to process */
if (dc != 0) {
proto_tree_add_item(tree, hf_smb_unknown, tvb, offset, dc, ENC_NA);
offset += dc;
}
return offset;
}
static void
dissect_trans_data(tvbuff_t *s_tvb, tvbuff_t *p_tvb, tvbuff_t *d_tvb,
proto_tree *tree)
{
int i;
int offset;
guint length;
/*
* Show the setup words.
*/
if (s_tvb != NULL) {
length = tvb_reported_length(s_tvb);
for (i = 0, offset = 0; length >= 2;
i++, offset += 2, length -= 2) {
/*
* XXX - add a setup word filterable field?
*/
proto_tree_add_uint_format(tree, hf_smb_trans_data_setup_word, s_tvb, offset, 2,
tvb_get_letohs(s_tvb, offset), "Setup Word %d: 0x%04x", i, tvb_get_letohs(s_tvb, offset));
}
}
/*
* Show the parameters, if any.
*/
if (p_tvb != NULL) {
length = tvb_reported_length(p_tvb);
if (length != 0) {
proto_tree_add_item(tree, hf_smb_trans_data_parameters, p_tvb, 0, length, ENC_NA);
}
}
/*
* Show the data, if any.
*/
if (d_tvb != NULL) {
length = tvb_reported_length(d_tvb);
if (length != 0) {
proto_tree_add_item(tree, hf_smb_trans_data, d_tvb, 0, length, ENC_NA);
}
}
}
/* This routine handles the following 4 calls
Transaction 0x25
Transaction Secondary 0x26
Transaction2 0x32
Transaction2 Secondary 0x33
*/
static int
dissect_transaction_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 wc, sc = 0;
int so = offset;
int sl = 0;
int spo = offset;
int spc = 0;
guint16 od = 0, po = 0, pc = 0, dc = 0, pd, dd = 0;
int subcmd = -1;
guint32 to;
int an_len;
const char *an = NULL;
smb_transact2_info_t *t2i;
smb_transact_info_t *tri;
guint16 bc;
int padcnt;
gboolean dissected_trans;
DISSECTOR_ASSERT(si);
WORD_COUNT;
if (wc == 8 || (wc == 9 && si->cmd == SMB_COM_TRANSACTION2_SECONDARY)) {
/*secondary client request*/
/* total param count, only a 16bit integer here*/
proto_tree_add_item(tree, hf_smb_total_param_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* total data count , only 16bit integer here*/
proto_tree_add_item(tree, hf_smb_total_data_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* param count */
pc = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_param_count16, tvb, offset, 2, pc);
offset += 2;
/* param offset */
po = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_param_offset16, tvb, offset, 2, po);
offset += 2;
/* param disp */
pd = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_param_disp16, tvb, offset, 2, pd);
offset += 2;
/* data count */
dc = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_count16, tvb, offset, 2, dc);
offset += 2;
/* data offset */
od = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_offset16, tvb, offset, 2, od);
offset += 2;
/* data disp */
dd = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_disp16, tvb, offset, 2, dd);
offset += 2;
if (si->cmd == SMB_COM_TRANSACTION2 || si->cmd == SMB_COM_TRANSACTION2_SECONDARY) {
guint16 fid;
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, FALSE, FALSE, FALSE, si);
offset += 2;
}
/* There are no setup words. */
so = offset;
sl = 0;
} else {
/* it is not a secondary request */
/* total param count , only a 16 bit integer here*/
proto_tree_add_item(tree, hf_smb_total_param_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* total data count , only 16bit integer here*/
proto_tree_add_item(tree, hf_smb_total_data_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* max param count , only 16bit integer here*/
proto_tree_add_item(tree, hf_smb_max_param_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* max data count, only 16bit integer here*/
proto_tree_add_item(tree, hf_smb_max_data_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* max setup count, only 16bit integer here*/
proto_tree_add_item(tree, hf_smb_max_setup_count, tvb, offset, 1, ENC_NA);
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* transaction flags */
dissect_transaction_flags(tvb, tree, offset);
offset += 2;
/* timeout */
to = tvb_get_letohl(tvb, offset);
proto_tree_add_uint_format_value(tree, hf_smb_timeout, tvb, offset, 4, to, "%s", smbext20_timeout_msecs_to_str(to));
offset += 4;
/* 2 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* param count */
pc = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_param_count16, tvb, offset, 2, pc);
offset += 2;
/* param offset */
po = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_param_offset16, tvb, offset, 2, po);
offset += 2;
/* data count */
dc = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_count16, tvb, offset, 2, dc);
offset += 2;
/* data offset */
od = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_offset16, tvb, offset, 2, od);
offset += 2;
/* data displacement is zero here */
dd = 0;
/* setup count */
sc = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_smb_setup_count, tvb, offset, 1, sc);
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* this is where the setup bytes, if any start */
so = offset;
sl = sc*2;
/* if there were any setup bytes, decode them */
if (sc) {
switch(si->cmd) {
case SMB_COM_TRANSACTION2:
/* TRANSACTION2 only has one setup word and
that is the subcommand code.
XXX - except for TRANS2_FSCTL
and TRANS2_IOCTL. */
subcmd = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_trans2_subcmd,
tvb, offset, 2, subcmd);
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
val_to_str_ext(subcmd, &trans2_cmd_vals_ext,
"Unknown (0x%02x)"));
if (!si->unidir) {
if (!pinfo->fd->visited && si->sip) {
/*
* Allocate a new
* smb_transact2_info_t
* structure.
*/
t2i = wmem_new(wmem_file_scope(), smb_transact2_info_t);
t2i->subcmd = subcmd;
t2i->info_level = -1;
t2i->resume_keys = FALSE;
t2i->name = NULL;
si->sip->extra_info = t2i;
si->sip->extra_info_type = SMB_EI_T2I;
}
}
/*
* XXX - process TRANS2_FSCTL and
* TRANS2_IOCTL setup words here.
*/
break;
case SMB_COM_TRANSACTION:
/* TRANSACTION setup words processed below */
break;
}
offset += sl;
}
}
BYTE_COUNT;
if (wc != 8) {
/* primary request */
/* name is NULL if transaction2 */
if (si->cmd == SMB_COM_TRANSACTION) {
/* Transaction Name */
an = get_unicode_or_ascii_string(tvb, &offset,
si->unicode, &an_len, FALSE, FALSE, &bc);
if (an == NULL)
goto endofcommand;
proto_tree_add_string(tree, hf_smb_trans_name, tvb,
offset, an_len, an);
COUNT_BYTES(an_len);
}
}
/*
* The pipe or mailslot arguments for Transaction start with
* the first setup word (or where the first setup word would
* be if there were any setup words), and run to the current
* offset (which could mean that there aren't any).
*/
spo = so;
spc = offset - spo;
/* parameters */
if (po > offset) {
/* We have some initial padding bytes.
*/
padcnt = po-offset;
if (padcnt > bc)
padcnt = bc;
proto_tree_add_item(tree, hf_smb_padding, tvb, offset, padcnt, ENC_NA);
COUNT_BYTES(padcnt);
}
if (pc) {
CHECK_BYTE_COUNT(pc);
switch(si->cmd) {
case SMB_COM_TRANSACTION2:
/* TRANSACTION2 parameters*/
offset = dissect_transaction2_request_parameters(tvb,
pinfo, tree, offset, subcmd, pc, si);
bc -= pc;
break;
case SMB_COM_TRANSACTION:
/* TRANSACTION parameters processed below */
COUNT_BYTES(pc);
break;
}
}
/* data */
if (od > offset) {
/* We have some initial padding bytes.
*/
padcnt = od-offset;
if (padcnt > bc)
padcnt = bc;
proto_tree_add_item(tree, hf_smb_padding, tvb, offset, padcnt, ENC_NA);
COUNT_BYTES(padcnt);
}
if (dc) {
CHECK_BYTE_COUNT(dc);
switch(si->cmd) {
case SMB_COM_TRANSACTION2:
/* TRANSACTION2 data*/
offset = dissect_transaction2_request_data(tvb, pinfo,
tree, offset, subcmd, dc, si);
bc -= dc;
break;
case SMB_COM_TRANSACTION:
/* TRANSACTION data processed below */
COUNT_BYTES(dc);
break;
}
}
/*TRANSACTION request parameters */
if (si->cmd == SMB_COM_TRANSACTION) {
/*XXX replace this block with a function and use that one
for both requests/responses*/
if (dd == 0) {
tvbuff_t *p_tvb, *d_tvb, *s_tvb;
tvbuff_t *sp_tvb, *pd_tvb;
if (pc > 0) {
if (pc>tvb_reported_length_remaining(tvb, po)) {
p_tvb = tvb_new_subset_length_caplen(tvb, po, tvb_reported_length_remaining(tvb, po), pc);
} else {
p_tvb = tvb_new_subset_length(tvb, po, pc);
}
} else {
p_tvb = NULL;
}
if (dc > 0) {
if (dc>tvb_reported_length_remaining(tvb, od)) {
d_tvb = tvb_new_subset_length_caplen(tvb, od, tvb_reported_length_remaining(tvb, od), dc);
} else {
d_tvb = tvb_new_subset_length(tvb, od, dc);
}
} else {
d_tvb = NULL;
}
if (sl) {
if (sl>tvb_reported_length_remaining(tvb, so)) {
s_tvb = tvb_new_subset_length_caplen(tvb, so, tvb_reported_length_remaining(tvb, so), sl);
} else {
s_tvb = tvb_new_subset_length(tvb, so, sl);
}
} else {
s_tvb = NULL;
}
if (!si->unidir) {
if (!pinfo->fd->visited && si->sip) {
/*
* Allocate a new smb_transact_info_t
* structure.
*/
tri = wmem_new(wmem_file_scope(), smb_transact_info_t);
tri->subcmd = -1;
tri->trans_subcmd = -1;
tri->function = -1;
tri->fid = -1;
tri->lanman_cmd = 0;
tri->param_descrip = NULL;
tri->data_descrip = NULL;
tri->aux_data_descrip = NULL;
tri->info_level = -1;
si->sip->extra_info = tri;
si->sip->extra_info_type = SMB_EI_TRI;
} else {
/*
* We already filled the structure
* in; don't bother doing so again.
*/
tri = NULL;
}
} else {
/*
* This is a unidirectional message, for
* which there will be no reply; don't
* bother allocating an "smb_transact_info_t"
* structure for it.
*/
tri = NULL;
}
dissected_trans = FALSE;
if (an == NULL)
goto endofcommand;
if (strncmp("\\PIPE\\", an, 6) == 0) {
if (tri != NULL)
tri->subcmd = TRANSACTION_PIPE;
/*
* A tvbuff containing the setup words and
* the pipe path.
*/
sp_tvb = tvb_new_subset_length(tvb, spo, spc);
/*
* A tvbuff containing the parameters and the
* data.
*/
pd_tvb = tvb_new_subset_remaining(tvb, po);
dissected_trans = dissect_pipe_smb(sp_tvb,
s_tvb, pd_tvb, p_tvb, d_tvb, an+6, pinfo,
top_tree_global, si);
/* In case we did not see the TreeConnect call,
store this TID here as well as a IPC TID
so we know that future Read/Writes to this
TID is (probably) DCERPC.
*/
if (g_hash_table_lookup(si->ct->tid_service, GUINT_TO_POINTER(si->tid))) {
g_hash_table_remove(si->ct->tid_service, GUINT_TO_POINTER(si->tid));
}
g_hash_table_insert(si->ct->tid_service, GUINT_TO_POINTER(si->tid), (void *)TID_IPC);
} else if (strncmp("\\MAILSLOT\\", an, 10) == 0) {
if (tri != NULL)
tri->subcmd = TRANSACTION_MAILSLOT;
/*
* A tvbuff containing the setup words and
* the mailslot path.
*/
sp_tvb = tvb_new_subset_length(tvb, spo, spc);
dissected_trans = dissect_mailslot_smb(sp_tvb,
s_tvb, d_tvb, an+10, pinfo, top_tree_global, si);
}
if (!dissected_trans)
dissect_trans_data(s_tvb, p_tvb, d_tvb, tree);
} else {
col_append_str(pinfo->cinfo, COL_INFO,
"[transact continuation]");
}
}
END_OF_SMB
return offset;
}
static int
dissect_4_3_4_1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
int offset, guint16 *bcp, gboolean *trunc, smb_info_t *si)
{
int fn_len;
const char *fn;
int old_offset = offset;
proto_item *item;
proto_tree *tree;
smb_transact2_info_t *t2i;
gboolean resume_keys = FALSE;
guint32 bytes_needed = 0;
DISSECTOR_ASSERT(si);
if ((si->sip != NULL) && (si->sip->extra_info_type == SMB_EI_T2I)) {
t2i = (smb_transact2_info_t *)si->sip->extra_info;
if (t2i != NULL)
resume_keys = t2i->resume_keys;
}
tree = proto_tree_add_subtree(parent_tree, tvb, offset, *bcp, ett_smb_ff2_data, &item,
val_to_str(si->info_level, ff2_il_vals, "Unknown (0x%02x)"));
/*
* Figure out of there are enough bytes to display the whole entry.
* This consistes of 22 bytes or 26 bytes if resume_keys, followed
* by a length byte and that many chars.
*/
bytes_needed = 23 + (resume_keys ? 4 : 0);
tvb_ensure_bytes_exist(tvb, offset, bytes_needed);
/* Now, get the length */
fn_len = tvb_get_guint8(tvb, offset + bytes_needed - 1);
tvb_ensure_bytes_exist(tvb, offset, bytes_needed + fn_len);
if (resume_keys) {
/* resume key */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_resume, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
}
/* create time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_create_time,
hf_smb_create_dos_date, hf_smb_create_dos_time, FALSE);
*bcp -= 4;
/* access time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_access_time,
hf_smb_access_dos_date, hf_smb_access_dos_time, FALSE);
*bcp -= 4;
/* last write time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_last_write_time,
hf_smb_last_write_dos_date, hf_smb_last_write_dos_time, FALSE);
*bcp -= 4;
/* data size */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_data_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* allocation size */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_alloc_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* File Attributes */
CHECK_BYTE_COUNT_SUBR(2);
offset = dissect_file_attributes(tvb, tree, offset);
*bcp -= 2;
/* file name len */
CHECK_BYTE_COUNT_SUBR(1);
fn_len = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_smb_file_name_len, tvb, offset, 1, fn_len);
COUNT_BYTES_SUBR(1);
if (si->unicode)
fn_len += 2; /* include terminating '\0' */
else
fn_len++; /* include terminating '\0' */
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_SUBR(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
format_text(wmem_packet_scope(), fn, strlen(fn)));
proto_item_append_text(item, " File: %s", format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
proto_item_set_len(item, offset-old_offset);
*trunc = FALSE;
return offset;
}
static int
dissect_4_3_4_2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
int offset, guint16 *bcp, gboolean *trunc, smb_info_t *si)
{
int fn_len;
const char *fn;
int old_offset = offset;
proto_item *item;
proto_tree *tree;
smb_transact2_info_t *t2i;
gboolean resume_keys = FALSE;
guint32 bytes_needed = 0;
DISSECTOR_ASSERT(si);
if ((si->sip != NULL) && (si->sip->extra_info_type == SMB_EI_T2I)) {
t2i = (smb_transact2_info_t *)si->sip->extra_info;
if (t2i != NULL)
resume_keys = t2i->resume_keys;
}
tree = proto_tree_add_subtree(parent_tree, tvb, offset, *bcp, ett_smb_ff2_data, &item,
val_to_str(si->info_level, ff2_il_vals, "Unknown (0x%02x)"));
/*
* Figure out of there are enough bytes to display the whole entry.
* This consistes of 26 bytes or 30 bytes if resume_keys, followed
* by a length byte and that many chars.
*/
bytes_needed = 27 + (resume_keys ? 4 : 0);
tvb_ensure_bytes_exist(tvb, offset, bytes_needed);
/* Now, get the length */
fn_len = tvb_get_guint8(tvb, offset + bytes_needed - 1);
tvb_ensure_bytes_exist(tvb, offset, bytes_needed + fn_len);
if (resume_keys) {
/* resume key */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_resume, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
}
/* create time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_create_time,
hf_smb_create_dos_date, hf_smb_create_dos_time, FALSE);
*bcp -= 4;
/* access time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_access_time,
hf_smb_access_dos_date, hf_smb_access_dos_time, FALSE);
*bcp -= 4;
/* last write time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_last_write_time,
hf_smb_last_write_dos_date, hf_smb_last_write_dos_time, FALSE);
*bcp -= 4;
/* data size */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_data_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* allocation size */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_alloc_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* File Attributes */
CHECK_BYTE_COUNT_SUBR(2);
offset = dissect_file_attributes(tvb, tree, offset);
*bcp -= 2;
/* ea length */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_ea_list_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* file name len */
CHECK_BYTE_COUNT_SUBR(1);
fn_len = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_smb_file_name_len, tvb, offset, 1, fn_len);
COUNT_BYTES_SUBR(1);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, TRUE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_SUBR(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
proto_item_append_text(item, " File: %s", format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
/*
* To quote the footnote for FileName in Section 2.2.8.1.2:
*
* Windows NT servers always append a single NULL padding byte
* to the FileName field. The length of this additional byte
* is not included in the value of the FileNameLength field.
*
* That's "single byte", not "UTF-16 null character".
*
* XXX - what about other servers? Do we need to somehow
* determine whether the server is a "Windows NT server" or
* not?
*/
CHECK_BYTE_COUNT_SUBR(1);
COUNT_BYTES_SUBR(1);
proto_item_set_len(item, offset-old_offset);
*trunc = FALSE;
return offset;
}
/*
* According to MS-CIFS 2.2.8.1.3 this is like the function above with the
* addition of the list of EA name value pairs before the file name.
*
* The EAs are formatted as an SMB_FEA as in 2.2.1.2.2. We will deal with
* this soon.
*/
static int
dissect_4_3_4_3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
int offset, guint16 *bcp, gboolean *trunc, smb_info_t *si)
{
int fn_len;
const char *fn;
int old_offset = offset;
int ea_size = 0;
proto_item *item;
proto_tree *tree;
smb_transact2_info_t *t2i;
gboolean resume_keys = FALSE;
DISSECTOR_ASSERT(si);
if ((si->sip != NULL) && (si->sip->extra_info_type == SMB_EI_T2I)) {
t2i = (smb_transact2_info_t *)si->sip->extra_info;
if (t2i != NULL)
resume_keys = t2i->resume_keys;
}
tree = proto_tree_add_subtree(parent_tree, tvb, offset, *bcp, ett_smb_ff2_data, &item,
val_to_str(si->info_level, ff2_il_vals, "Unknown (0x%02x)"));
if (resume_keys) {
/* resume key */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_resume, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
}
/* create time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_create_time,
hf_smb_create_dos_date, hf_smb_create_dos_time, FALSE);
*bcp -= 4;
/* access time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_access_time,
hf_smb_access_dos_date, hf_smb_access_dos_time, FALSE);
*bcp -= 4;
/* last write time */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_last_write_time,
hf_smb_last_write_dos_date, hf_smb_last_write_dos_time, FALSE);
*bcp -= 4;
/* data size */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_data_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* allocation size */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_alloc_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* File Attributes */
CHECK_BYTE_COUNT_SUBR(2);
offset = dissect_file_attributes(tvb, tree, offset);
*bcp -= 2;
/* ea length */
CHECK_BYTE_COUNT_SUBR(4);
ea_size = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb_ea_list_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* The EAs ... they are formatted as in MS-CIFS 2.2.1.2.2 */
proto_tree_add_bytes_format(tree, hf_smb_file_data, tvb, offset, ea_size, NULL, "EAs");
COUNT_BYTES_SUBR(ea_size);
*bcp -= ea_size;
/* file name len */
CHECK_BYTE_COUNT_SUBR(1);
fn_len = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_smb_file_name_len, tvb, offset, 1, fn_len);
COUNT_BYTES_SUBR(1);
if (si->unicode)
fn_len += 2; /* include terminating '\0' */
else
fn_len++; /* include terminating '\0' */
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_SUBR(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
proto_item_append_text(item, " File: %s", format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
proto_item_set_len(item, offset-old_offset);
return offset;
}
static int
dissect_4_3_4_4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
int offset, guint16 *bcp, gboolean *trunc, smb_info_t *si)
{
int fn_len;
const char *fn;
int old_offset = offset;
proto_item *item;
proto_tree *tree;
guint32 neo;
int padcnt;
DISSECTOR_ASSERT(si);
/*
* We check this first before adding the sub-tree so things do not
* get ugly.
*/
/* next entry offset */
CHECK_BYTE_COUNT_SUBR(4);
neo = tvb_get_letohl(tvb, offset);
/* Ensure we have the bytes we need, which is up to neo */
tvb_ensure_bytes_exist(tvb, offset, neo ? neo : *bcp);
tree = proto_tree_add_subtree(parent_tree, tvb, offset, *bcp, ett_smb_ff2_data, &item,
val_to_str(si->info_level, ff2_il_vals, "Unknown (0x%02x)"));
/*
* We assume that the presence of a next entry offset implies the
* absence of a resume key, as appears to be the case for 4.3.4.6.
*/
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_uint(tree, hf_smb_next_entry_offset, tvb, offset, 4, neo);
COUNT_BYTES_SUBR(4);
/* file index */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_file_index, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
offset = dissect_smb_standard_8byte_timestamps(tvb, pinfo, tree, offset, bcp, trunc);
if (*trunc) {
return offset;
}
/* end of file */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* allocation size */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_alloc_size64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Extended File Attributes */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_file_ext_attr(tvb, tree, offset);
*bcp -= 4;
/* file name len */
CHECK_BYTE_COUNT_SUBR(4);
fn_len = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_file_name_len, tvb, offset, 4, fn_len);
COUNT_BYTES_SUBR(4);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_SUBR(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
/* skip to next structure */
if (neo) {
padcnt = (old_offset + neo) - offset;
if (padcnt < 0) {
/*
* XXX - this is bogus; flag it?
*/
padcnt = 0;
}
if (padcnt != 0) {
CHECK_BYTE_COUNT_SUBR(padcnt);
COUNT_BYTES_SUBR(padcnt);
}
}
proto_item_append_text(item, " File: %s", format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
proto_item_set_len(item, offset-old_offset);
*trunc = FALSE;
return offset;
}
static int
dissect_4_3_4_5(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
int offset, guint16 *bcp, gboolean *trunc, smb_info_t *si)
{
int fn_len;
const char *fn;
int old_offset = offset;
proto_item *item;
proto_tree *tree;
guint32 neo;
int padcnt;
DISSECTOR_ASSERT(si);
/*
* We check this first before adding the sub-tree so things do not
* get ugly.
*/
/* next entry offset */
CHECK_BYTE_COUNT_SUBR(4);
neo = tvb_get_letohl(tvb, offset);
/* Ensure we have the bytes we need, which is up to neo */
tvb_ensure_bytes_exist(tvb, offset, neo ? neo : *bcp);
tree = proto_tree_add_subtree(parent_tree, tvb, offset, *bcp, ett_smb_ff2_data, &item,
val_to_str(si->info_level, ff2_il_vals, "Unknown (0x%02x)"));
/*
* We assume that the presence of a next entry offset implies the
* absence of a resume key, as appears to be the case for 4.3.4.6.
*/
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_uint(tree, hf_smb_next_entry_offset, tvb, offset, 4, neo);
COUNT_BYTES_SUBR(4);
/* file index */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_file_index, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* standard 8-byte timestamps */
offset = dissect_smb_standard_8byte_timestamps(tvb, pinfo, tree, offset, bcp, trunc);
if (*trunc) {
return offset;
}
/* end of file */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* allocation size */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_alloc_size64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Extended File Attributes */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_file_ext_attr(tvb, tree, offset);
*bcp -= 4;
/* file name len */
CHECK_BYTE_COUNT_SUBR(4);
fn_len = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_file_name_len, tvb, offset, 4, fn_len);
COUNT_BYTES_SUBR(4);
/* ea length */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_ea_list_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_SUBR(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
/* skip to next structure */
if (neo) {
padcnt = (old_offset + neo) - offset;
if (padcnt < 0) {
/*
* XXX - this is bogus; flag it?
*/
padcnt = 0;
}
if (padcnt != 0) {
CHECK_BYTE_COUNT_SUBR(padcnt);
COUNT_BYTES_SUBR(padcnt);
}
}
proto_item_append_text(item, " File: %s", format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
proto_item_set_len(item, offset-old_offset);
*trunc = FALSE;
return offset;
}
static int
dissect_4_3_4_6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
int offset, guint16 *bcp, gboolean *trunc, smb_info_t *si)
{
int fn_len, sfn_len;
const char *fn, *sfn;
int old_offset = offset;
proto_item *item;
proto_tree *tree;
guint32 neo;
int padcnt;
DISSECTOR_ASSERT(si);
/*
* We check this first before adding the sub-tree so things do not
* get ugly.
*/
/* next entry offset */
CHECK_BYTE_COUNT_SUBR(4);
neo = tvb_get_letohl(tvb, offset);
/* Ensure we have the bytes we need, which is up to neo */
tvb_ensure_bytes_exist(tvb, offset, neo ? neo : *bcp);
tree = proto_tree_add_subtree(parent_tree, tvb, offset, *bcp, ett_smb_ff2_data, &item,
val_to_str(si->info_level, ff2_il_vals, "Unknown (0x%02x)"));
/*
* XXX - I have not seen any of these that contain a resume
* key, even though some of the requests had the "return resume
* key" flag set.
*/
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_uint(tree, hf_smb_next_entry_offset, tvb, offset, 4, neo);
COUNT_BYTES_SUBR(4);
/* file index */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_file_index, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* dissect standard 8-byte timestamps */
offset = dissect_smb_standard_8byte_timestamps(tvb, pinfo, tree, offset, bcp, trunc);
if (*trunc) {
return offset;
}
/* end of file */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* allocation size */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_alloc_size64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Extended File Attributes */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_file_ext_attr(tvb, tree, offset);
*bcp -= 4;
/* file name len */
CHECK_BYTE_COUNT_SUBR(4);
fn_len = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_file_name_len, tvb, offset, 4, fn_len);
COUNT_BYTES_SUBR(4);
/*
* EA length.
*
* XXX - in one captures, this has the topmost bit set, and the
* rest of the bits have the value 7. Is the topmost bit being
* set some indication that the value *isn't* the length of
* the EAs?
*/
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_ea_list_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* short file name len */
CHECK_BYTE_COUNT_SUBR(1);
sfn_len = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_smb_short_file_name_len, tvb, offset, 1, sfn_len);
COUNT_BYTES_SUBR(1);
/* reserved byte */
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
COUNT_BYTES_SUBR(1);
/* short file name - it's not always in Unicode */
sfn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &sfn_len, FALSE, TRUE, bcp);
CHECK_STRING_SUBR(sfn);
proto_tree_add_string(tree, hf_smb_short_file_name, tvb, offset, 24,
sfn);
COUNT_BYTES_SUBR(24);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_SUBR(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
/* skip to next structure */
if (neo) {
padcnt = (old_offset + neo) - offset;
if (padcnt < 0) {
/*
* XXX - this is bogus; flag it?
*/
padcnt = 0;
}
if (padcnt != 0) {
CHECK_BYTE_COUNT_SUBR(padcnt);
COUNT_BYTES_SUBR(padcnt);
}
}
proto_item_append_text(item, " File: %s", format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
proto_item_set_len(item, offset-old_offset);
*trunc = FALSE;
return offset;
}
static int
dissect_4_3_4_6full(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
int offset, guint16 *bcp, gboolean *trunc, smb_info_t *si)
{
int fn_len;
const char *fn;
int old_offset = offset;
proto_item *item;
proto_tree *tree;
guint32 neo;
int padcnt;
DISSECTOR_ASSERT(si);
/*
* We check this first before adding the sub-tree so things do not
* get ugly.
*/
/* next entry offset */
CHECK_BYTE_COUNT_SUBR(4);
neo = tvb_get_letohl(tvb, offset);
/* Ensure we have the bytes we need, which is up to neo */
tvb_ensure_bytes_exist(tvb, offset, neo ? neo : *bcp);
tree = proto_tree_add_subtree(parent_tree, tvb, offset, *bcp, ett_smb_ff2_data, &item,
val_to_str(si->info_level, ff2_il_vals, "Unknown (0x%02x)"));
/*
* XXX - I have not seen any of these that contain a resume
* key, even though some of the requests had the "return resume
* key" flag set.
*/
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_uint(tree, hf_smb_next_entry_offset, tvb, offset, 4, neo);
COUNT_BYTES_SUBR(4);
/* file index */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_file_index, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* dissect standard 8-byte timestamps */
offset = dissect_smb_standard_8byte_timestamps(tvb, pinfo, tree, offset, bcp, trunc);
if (*trunc) {
return offset;
}
/* end of file */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* allocation size */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_alloc_size64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Extended File Attributes */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_file_ext_attr(tvb, tree, offset);
*bcp -= 4;
/* file name len */
CHECK_BYTE_COUNT_SUBR(4);
fn_len = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_file_name_len, tvb, offset, 4, fn_len);
COUNT_BYTES_SUBR(4);
/*
* EA length.
*
* XXX - in one captures, this has the topmost bit set, and the
* rest of the bits have the value 7. Is the topmost bit being
* set some indication that the value *isn't* the length of
* the EAs?
*/
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_ea_list_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* skip 4 bytes */
COUNT_BYTES_SUBR(4);
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_index_number, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_SUBR(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
/* skip to next structure */
if (neo) {
padcnt = (old_offset + neo) - offset;
if (padcnt < 0) {
/*
* XXX - this is bogus; flag it?
*/
padcnt = 0;
}
if (padcnt != 0) {
CHECK_BYTE_COUNT_SUBR(padcnt);
COUNT_BYTES_SUBR(padcnt);
}
}
proto_item_append_text(item, " File: %s", format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
proto_item_set_len(item, offset-old_offset);
*trunc = FALSE;
return offset;
}
static int
dissect_4_3_4_6_id_both(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
int offset, guint16 *bcp, gboolean *trunc, smb_info_t *si)
{
int fn_len, sfn_len;
const char *fn, *sfn;
int old_offset = offset;
proto_item *item;
proto_tree *tree;
guint32 neo;
int padcnt;
DISSECTOR_ASSERT(si);
/*
* We check this first before adding the sub-tree so things do not
* get ugly.
*/
/* next entry offset */
CHECK_BYTE_COUNT_SUBR(4);
neo = tvb_get_letohl(tvb, offset);
/* Ensure we have the bytes we need, which is up to neo */
tvb_ensure_bytes_exist(tvb, offset, neo ? neo : *bcp);
tree = proto_tree_add_subtree(parent_tree, tvb, offset, *bcp, ett_smb_ff2_data, &item,
val_to_str(si->info_level, ff2_il_vals, "Unknown (0x%02x)"));
/*
* XXX - I have not seen any of these that contain a resume
* key, even though some of the requests had the "return resume
* key" flag set.
*/
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_uint(tree, hf_smb_next_entry_offset, tvb, offset, 4, neo);
COUNT_BYTES_SUBR(4);
/* file index */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_file_index, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* dissect standard 8-byte timestamps */
offset = dissect_smb_standard_8byte_timestamps(tvb, pinfo, tree, offset, bcp, trunc);
if (*trunc) {
return offset;
}
/* end of file */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* allocation size */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_alloc_size64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* Extended File Attributes */
CHECK_BYTE_COUNT_SUBR(4);
offset = dissect_file_ext_attr(tvb, tree, offset);
*bcp -= 4;
/* file name len */
CHECK_BYTE_COUNT_SUBR(4);
fn_len = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_file_name_len, tvb, offset, 4, fn_len);
COUNT_BYTES_SUBR(4);
/*
* EA length.
*
* XXX - in one captures, this has the topmost bit set, and the
* rest of the bits have the value 7. Is the topmost bit being
* set some indication that the value *isn't* the length of
* the EAs?
*/
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_ea_list_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* short file name len */
CHECK_BYTE_COUNT_SUBR(1);
sfn_len = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_smb_short_file_name_len, tvb, offset, 1, sfn_len);
COUNT_BYTES_SUBR(1);
/* reserved byte */
CHECK_BYTE_COUNT_SUBR(1);
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
COUNT_BYTES_SUBR(1);
/* short file name - it's not always in Unicode */
sfn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &sfn_len, FALSE, TRUE, bcp);
CHECK_STRING_SUBR(sfn);
proto_tree_add_string(tree, hf_smb_short_file_name, tvb, offset, 24,
sfn);
COUNT_BYTES_SUBR(24);
/* reserved bytes */
CHECK_BYTE_COUNT_SUBR(2);
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
COUNT_BYTES_SUBR(2);
/* file id */
CHECK_BYTE_COUNT_SUBR(8);
proto_tree_add_item(tree, hf_smb_index_number, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(8);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_SUBR(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
/* skip to next structure */
if (neo) {
padcnt = (old_offset + neo) - offset;
if (padcnt < 0) {
/*
* XXX - this is bogus; flag it?
*/
padcnt = 0;
}
if (padcnt != 0) {
CHECK_BYTE_COUNT_SUBR(padcnt);
COUNT_BYTES_SUBR(padcnt);
}
}
proto_item_append_text(item, " File: %s", format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
proto_item_set_len(item, offset-old_offset);
*trunc = FALSE;
return offset;
}
static int
dissect_4_3_4_7(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
int offset, guint16 *bcp, gboolean *trunc, smb_info_t *si)
{
int fn_len;
const char *fn;
int old_offset = offset;
proto_item *item;
proto_tree *tree;
guint32 neo;
int padcnt;
DISSECTOR_ASSERT(si);
/*
* We check this first before adding the sub-tree so things do not
* get ugly.
*/
/* next entry offset */
CHECK_BYTE_COUNT_SUBR(4);
neo = tvb_get_letohl(tvb, offset);
/* Ensure we have the bytes we need, which is up to neo */
tvb_ensure_bytes_exist(tvb, offset, neo ? neo : *bcp);
tree = proto_tree_add_subtree(parent_tree, tvb, offset, *bcp, ett_smb_ff2_data, &item,
val_to_str(si->info_level, ff2_il_vals, "Unknown (0x%02x)"));
/*
* We assume that the presence of a next entry offset implies the
* absence of a resume key, as appears to be the case for 4.3.4.6.
*/
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_uint(tree, hf_smb_next_entry_offset, tvb, offset, 4, neo);
COUNT_BYTES_SUBR(4);
/* file index */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_file_index, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* file name len */
CHECK_BYTE_COUNT_SUBR(4);
fn_len = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_file_name_len, tvb, offset, 4, fn_len);
COUNT_BYTES_SUBR(4);
/* file name */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(tree, hf_smb_file_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_SUBR(fn_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
/* skip to next structure */
if (neo) {
padcnt = (old_offset + neo) - offset;
if (padcnt < 0) {
/*
* XXX - this is bogus; flag it?
*/
padcnt = 0;
}
if (padcnt != 0) {
CHECK_BYTE_COUNT_SUBR(padcnt);
COUNT_BYTES_SUBR(padcnt);
}
}
proto_item_append_text(item, " File: %s", format_text(wmem_packet_scope(), (const guchar*)fn, strlen(fn)));
proto_item_set_len(item, offset-old_offset);
*trunc = FALSE;
return offset;
}
/* 4.3.4.8 - SMB_FIND_FILE_UNIX */
static int
dissect_4_3_4_8(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, int offset, guint16 *bcp,
gboolean *trunc, smb_info_t *si)
{
const char *fn;
int fn_len;
int pad;
DISSECTOR_ASSERT(si);
/* NextEntryOffset */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_unix_find_file_nextoffset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* ResumeKey */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_unix_find_file_resumekey, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* Unix basic info */
offset = dissect_4_2_16_12(tvb, pinfo, tree, offset, bcp, trunc);
if (*trunc)
return offset;
/* Name */
fn = get_unicode_or_ascii_string(
tvb, &offset, si->unicode, &fn_len, FALSE, FALSE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(
tree, hf_smb_unix_file_name, tvb, offset, fn_len, fn);
COUNT_BYTES_SUBR(fn_len);
/* Pad to 4 bytes */
if (offset % 4) {
pad = 4 - (offset % 4);
COUNT_BYTES_SUBR(pad);
}
*trunc = FALSE;
return offset;
}
static int
dissect_find_file_unix_info2(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, int offset, guint16 *bcp,
gboolean *trunc, smb_info_t *si)
{
const char *fn;
guint32 namelen;
int fn_len;
int pad;
DISSECTOR_ASSERT(si);
/* NextEntryOffset */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_unix_find_file_nextoffset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* ResumeKey */
CHECK_BYTE_COUNT_SUBR(4);
proto_tree_add_item(tree, hf_smb_unix_find_file_resumekey, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_SUBR(4);
/* Unix Info2 */
offset = dissect_qspi_unix_info2(tvb, pinfo, tree, offset, bcp, trunc);
if (*trunc)
return offset;
/* Name length */
CHECK_BYTE_COUNT_SUBR(4);
namelen = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_unix_file_name_length, tvb, offset, 4, namelen);
COUNT_BYTES_SUBR(4);
/* Name */
/*
* namelen could be > 2^31-1; this will catch that.
* The length argument to get_unicode_or_ascii_string() is an
* int, not an unsigned int, so we have to worry about that.
*/
tvb_ensure_bytes_exist(tvb, offset, namelen);
fn_len = namelen;
fn = get_unicode_or_ascii_string(
tvb, &offset, si->unicode, &fn_len, TRUE, TRUE, bcp);
CHECK_STRING_SUBR(fn);
proto_tree_add_string(
tree, hf_smb_unix_file_name, tvb, offset, fn_len, fn);
COUNT_BYTES_SUBR(fn_len);
/* Pad to 4 bytes */
if (offset % 4) {
pad = 4 - (offset % 4);
CHECK_BYTE_COUNT_SUBR(pad);
COUNT_BYTES_SUBR(pad);
}
*trunc = FALSE;
return offset;
}
/*dissect the data block for TRANS2_FIND_FIRST2*/
static int
dissect_ff2_response_data(tvbuff_t * tvb, packet_info * pinfo,
proto_tree * tree, int offset, guint16 *bcp, gboolean *trunc, smb_info_t *si)
{
if (!*bcp) {
*trunc = FALSE;
return offset;
}
DISSECTOR_ASSERT(si);
switch(si->info_level) {
case 1: /*Info Standard*/
offset = dissect_4_3_4_1(tvb, pinfo, tree, offset, bcp,
trunc, si);
break;
case 2: /*Info Query EA Size*/
offset = dissect_4_3_4_2(tvb, pinfo, tree, offset, bcp,
trunc, si);
break;
case 3: /* Info Query EAs From List same as
* InfoQueryEASize.
* Not according to MS-CIFS 2.2.8.1.3. RJS
*/
offset = dissect_4_3_4_3(tvb, pinfo, tree, offset, bcp,
trunc, si);
break;
case 0x0101: /*Find File Directory Info*/
offset = dissect_4_3_4_4(tvb, pinfo, tree, offset, bcp,
trunc, si);
break;
case 0x0102: /*Find File Full Directory Info*/
offset = dissect_4_3_4_5(tvb, pinfo, tree, offset, bcp,
trunc, si);
break;
case 0x0103: /*Find File Names Info*/
offset = dissect_4_3_4_7(tvb, pinfo, tree, offset, bcp,
trunc, si);
break;
case 0x0104: /*Find File Both Directory Info*/
offset = dissect_4_3_4_6(tvb, pinfo, tree, offset, bcp,
trunc, si);
break;
case 0x0105: /*Find File Full Directory Info*/
offset = dissect_4_3_4_6full(tvb, pinfo, tree, offset, bcp,
trunc, si);
break;
case 0x0106: /*Find File Id Both Directory Info*/
offset = dissect_4_3_4_6_id_both(tvb, pinfo, tree, offset, bcp,
trunc, si);
break;
case 0x0202: /*Find File Unix*/
offset = dissect_4_3_4_8(tvb, pinfo, tree, offset, bcp,
trunc, si);
break;
case 0x020B: /*Find File Unix Info2*/
offset = dissect_find_file_unix_info2(tvb, pinfo, tree, offset, bcp,
trunc, si);
break;
default: /* unknown info level */
*trunc = FALSE;
break;
}
return offset;
}
/* is this one just wrong and should be dissect_fs0105_attributes above ? */
static int
dissect_fs_attributes(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
/* case sensitive search */
&hf_smb_fs_attr_css,
/* case preserved names */
&hf_smb_fs_attr_cpn,
/* unicode on disk */
&hf_smb_fs_attr_uod,
/* persistent acls */
&hf_smb_fs_attr_pacls,
/* file compression */
&hf_smb_fs_attr_fc,
/* volume quotas */
&hf_smb_fs_attr_vq,
/* sparse files */
&hf_smb_fs_attr_ssf,
/* reparse points */
&hf_smb_fs_attr_srp,
/* remote storage */
&hf_smb_fs_attr_srs,
/* lfn apis */
&hf_smb_fs_attr_sla,
/* volume is compressed */
&hf_smb_fs_attr_vic,
/* support oids */
&hf_smb_fs_attr_soids,
/* encryption */
&hf_smb_fs_attr_se,
/* named streams */
&hf_smb_fs_attr_ns,
/* read only volume */
&hf_smb_fs_attr_rov,
/* sequential write once */
&hf_smb_fs_attr_swo,
/* supports transactions */
&hf_smb_fs_attr_st,
/* supports hard links */
&hf_smb_fs_attr_shl,
/* supports integrity streams */
&hf_smb_fs_attr_sis,
/* supports block refcounting */
&hf_smb_fs_attr_sbr,
/* supports sparse vdl */
&hf_smb_fs_attr_ssv,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_fs_attr, ett_smb_fs_attributes, flags, ENC_LITTLE_ENDIAN);
offset += 4;
return offset;
}
static int
dissect_device_characteristics(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const mask[] = {
&hf_smb_device_char_removable,
&hf_smb_device_char_read_only,
&hf_smb_device_char_floppy,
&hf_smb_device_char_write_once,
&hf_smb_device_char_remote,
&hf_smb_device_char_mounted,
&hf_smb_device_char_virtual,
&hf_smb_device_char_secure_open,
&hf_smb_device_char_ts,
&hf_smb_device_char_webdav,
&hf_smb_device_char_portable,
&hf_smb_device_char_aat,
NULL
};
proto_tree_add_bitmask_with_flags(parent_tree, tvb, offset, hf_smb_device_char,
ett_smb_device_characteristics, mask, ENC_LITTLE_ENDIAN, BMT_NO_APPEND);
offset += 4;
return offset;
}
/*dissect the data block for TRANS2_QUERY_FS_INFORMATION*/
static const true_false_string tfs_smb_mac_access_ctrl = {
"Macintosh Access Control Supported",
"Macintosh Access Control Not Supported"
};
static const true_false_string tfs_smb_mac_getset_comments = {
"Macintosh Get & Set Comments Supported",
"Macintosh Get & Set Comments Not Supported"
};
static const true_false_string tfs_smb_mac_desktopdb_calls = {
"Macintosh Get & Set Desktop Database Info Supported",
"Macintosh Get & Set Desktop Database Info Not Supported"
};
static const true_false_string tfs_smb_mac_unique_ids = {
"Macintosh Unique IDs Supported",
"Macintosh Unique IDs Not Supported"
};
static const true_false_string tfs_smb_mac_streams = {
"Macintosh and Streams Extensions Not Supported",
"Macintosh and Streams Extensions Supported"
};
int
dissect_qfsi_FS_VOLUME_INFO(tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree, int offset, guint16 *bcp, int unicode)
{
int fn_len, vll;
const char *fn;
/* create time */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
offset = dissect_nt_64bit_time(tvb, tree, offset,
hf_smb_create_time);
*bcp -= 8;
/* volume serial number */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_volume_serial_num, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* volume label length */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
vll = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_volume_label_len, tvb, offset, 4, vll);
COUNT_BYTES_TRANS_SUBR(4);
/* 2 reserved bytes */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
COUNT_BYTES_TRANS_SUBR(2);
/* label */
fn_len = vll;
fn = get_unicode_or_ascii_string(tvb, &offset, unicode, &fn_len, FALSE, TRUE, bcp);
CHECK_STRING_TRANS_SUBR(fn);
proto_tree_add_string(tree, hf_smb_volume_label, tvb, offset, fn_len,
fn);
COUNT_BYTES_TRANS_SUBR(fn_len);
return offset;
}
int
dissect_qfsi_FS_SIZE_INFO(tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree, int offset, guint16 *bcp)
{
/* allocation size */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
proto_tree_add_item(tree, hf_smb_alloc_size64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(8);
/* free allocation units */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
proto_tree_add_item(tree, hf_smb_free_alloc_units64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(8);
/* sectors per unit */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_sector_unit, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* bytes per sector */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_fs_sector, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
return offset;
}
int
dissect_qfsi_FS_DEVICE_INFO(tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree, int offset, guint16 *bcp)
{
/* device type */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_device_type, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* device characteristics */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
offset = dissect_device_characteristics(tvb, tree, offset);
*bcp -= 4;
return offset;
}
int
dissect_qfsi_FS_ATTRIBUTE_INFO(tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree, int offset, guint16 *bcp)
{
int fn_len, fnl;
const char *fn;
/* FS attributes */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
offset = dissect_fs_attributes(tvb, tree, offset);
*bcp -= 4;
/* max name len */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_max_name_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* fs name length */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
fnl = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_fs_name_len, tvb, offset, 4, fnl);
COUNT_BYTES_TRANS_SUBR(4);
/* label */
fn_len = fnl;
fn = get_unicode_or_ascii_string(tvb, &offset, TRUE, &fn_len, FALSE, TRUE, bcp);
CHECK_STRING_TRANS_SUBR(fn);
proto_tree_add_string(tree, hf_smb_fs_name, tvb, offset, fn_len,
fn);
COUNT_BYTES_TRANS_SUBR(fn_len);
return offset;
}
int
dissect_qfsi_FS_OBJECTID_INFO(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, int offset, guint16 *bcp)
{
CHECK_BYTE_COUNT_TRANS_SUBR(64);
dissect_smb2_FILE_OBJECTID_BUFFER(tvb, pinfo, tree, offset);
COUNT_BYTES_TRANS_SUBR(64);
return offset;
}
int
dissect_qfsi_FS_FULL_SIZE_INFO(tvbuff_t * tvb, packet_info * pinfo _U_, proto_tree * tree, int offset, guint16 *bcp)
{
/* allocation size */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
proto_tree_add_item(tree, hf_smb_alloc_size64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(8);
/* caller free allocation units */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
proto_tree_add_item(tree, hf_smb_caller_free_alloc_units64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(8);
/* actual free allocation units */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
proto_tree_add_item(tree, hf_smb_actual_free_alloc_units64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(8);
/* sectors per unit */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_sector_unit, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* bytes per sector */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_fs_sector, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
return offset;
}
static int
dissect_qfsi_vals(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
int offset, guint16 *bcp, smb_info_t *si)
{
int fn_len, vll;
const char *fn;
if (!*bcp) {
return offset;
}
DISSECTOR_ASSERT(si);
switch(si->info_level) {
case 1: /* SMB_INFO_ALLOCATION */
/* filesystem id */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_fs_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* sectors per unit */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_sector_unit, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* units */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_fs_units, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* avail units */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_avail_units, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* bytes per sector, only 16bit integer here */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
proto_tree_add_item(tree, hf_smb_fs_sector, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(2);
break;
case 2: /* SMB_INFO_VOLUME */
/* volume serial number */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_volume_serial_num, tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* volume label length, only one byte here */
CHECK_BYTE_COUNT_TRANS_SUBR(1);
proto_tree_add_item(tree, hf_smb_volume_label_len, tvb, offset, 1, ENC_NA);
COUNT_BYTES_TRANS_SUBR(1);
/* label - not aligned! */
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, TRUE, FALSE, bcp);
CHECK_STRING_TRANS_SUBR(fn);
proto_tree_add_string(tree, hf_smb_volume_label, tvb, offset, fn_len,
fn);
COUNT_BYTES_TRANS_SUBR(fn_len);
break;
case 0x0101: /* SMB_QUERY_FS_LABEL_INFO */
case 1002: /* SMB_FS_LABEL_INFORMATION */
/* volume label length */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
vll = tvb_get_letohl(tvb, offset);
proto_tree_add_uint(tree, hf_smb_volume_label_len, tvb, offset, 4, vll);
COUNT_BYTES_TRANS_SUBR(4);
/* label */
fn_len = vll;
fn = get_unicode_or_ascii_string(tvb, &offset, si->unicode, &fn_len, FALSE, TRUE, bcp);
CHECK_STRING_TRANS_SUBR(fn);
proto_tree_add_string(tree, hf_smb_volume_label, tvb, offset, fn_len,
fn);
COUNT_BYTES_TRANS_SUBR(fn_len);
break;
case 0x0102: /* SMB_QUERY_FS_VOLUME_INFO */
case 1001: /* SMB_FS_VOLUME_INFORMATION */
offset = dissect_qfsi_FS_VOLUME_INFO(tvb, pinfo, tree, offset, bcp, si->unicode);
break;
case 0x0103: /* SMB_QUERY_FS_SIZE_INFO */
case 1003: /* SMB_FS_SIZE_INFORMATION */
offset = dissect_qfsi_FS_SIZE_INFO(tvb, pinfo, tree, offset, bcp);
break;
case 0x0104: /* SMB_QUERY_FS_DEVICE_INFO */
case 1004: /* SMB_FS_DEVICE_INFORMATION */
offset = dissect_qfsi_FS_DEVICE_INFO(tvb, pinfo, tree, offset, bcp);
break;
case 0x0105: /* SMB_QUERY_FS_ATTRIBUTE_INFO */
case 1005: /* SMB_FS_ATTRIBUTE_INFORMATION */
offset = dissect_qfsi_FS_ATTRIBUTE_INFO(tvb, pinfo, tree, offset, bcp);
break;
case 0x200: { /* SMB_QUERY_CIFS_UNIX_INFO */
proto_item *item_2 = NULL;
proto_tree *subtree = NULL;
/* MajorVersionNumber */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
proto_tree_add_item(tree, hf_smb_unix_major_version, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(2);
/* MinorVersionNumber */
CHECK_BYTE_COUNT_TRANS_SUBR(2);
proto_tree_add_item(tree, hf_smb_unix_minor_version, tvb, offset, 2, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(2);
/* Capability */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
if (tree) {
item_2 = proto_tree_add_item(tree, hf_smb_unix_capability, tvb, offset, 8, ENC_LITTLE_ENDIAN);
subtree = proto_item_add_subtree(
item_2, ett_smb_unix_capabilities);
}
proto_tree_add_item(
subtree, hf_smb_unix_capability_fcntl, tvb, offset, 4,
ENC_LITTLE_ENDIAN);
proto_tree_add_item(
subtree, hf_smb_unix_capability_posix_acl, tvb, offset, 4,
ENC_LITTLE_ENDIAN);
proto_tree_add_item(
subtree, hf_smb_unix_capability_xattr, tvb, offset, 4,
ENC_LITTLE_ENDIAN);
proto_tree_add_item(
subtree, hf_smb_unix_capability_attr, tvb, offset, 4,
ENC_LITTLE_ENDIAN);
proto_tree_add_item(
subtree, hf_smb_unix_capability_posix_paths, tvb, offset, 4,
ENC_LITTLE_ENDIAN);
proto_tree_add_item(
subtree, hf_smb_unix_capability_posix_path_ops, tvb, offset, 4,
ENC_LITTLE_ENDIAN);
proto_tree_add_item(
subtree, hf_smb_unix_capability_large_read, tvb, offset, 4,
ENC_LITTLE_ENDIAN);
proto_tree_add_item(
subtree, hf_smb_unix_capability_large_write, tvb, offset, 4,
ENC_LITTLE_ENDIAN);
proto_tree_add_item(
subtree, hf_smb_unix_capability_encryption, tvb, offset, 4,
ENC_LITTLE_ENDIAN);
proto_tree_add_item(
subtree, hf_smb_unix_capability_mandatory_crypto, tvb, offset, 4,
ENC_LITTLE_ENDIAN);
proto_tree_add_item(
subtree, hf_smb_unix_capability_proxy, tvb, offset, 4,
ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(8);
break;
}
case 0x202: { /* SMB_QUERY_POSIX_WHOAMI */
proto_tree *st_gids;
guint32 num_gids;
guint i;
proto_tree *st_sids;
int old_sid_offset;
guint32 num_sids;
guint32 sids_buflen;
/* Mapping flags */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_unix_whoami_mapflags,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* Mapping flags mask */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_unix_whoami_mapflags_mask,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* primary UID */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_uid,
tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(8);
/* primary GID */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
proto_tree_add_item(tree, hf_smb_unix_file_gid,
tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(8);
/* number of supplementary GIDs */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
num_gids = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb_unix_whoami_num_supl_gids,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* number of supplementary SIDs */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
num_sids = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb_unix_whoami_num_supl_sids,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* supplementary SIDs buffer length */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
sids_buflen = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb_unix_whoami_sids_buflen,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* pad / reserved (must be zero) */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 4, ENC_NA);
COUNT_BYTES_TRANS_SUBR(4);
/* GIDs */
st_gids = proto_tree_add_subtree(tree, tvb, offset, num_gids * 8,
ett_smb_unix_whoami_gids, NULL, "Supplementary UNIX GIDs");
for (i = 0; i < num_gids; i++) {
CHECK_BYTE_COUNT_TRANS_SUBR(8);
proto_tree_add_item(st_gids, hf_smb_unix_file_gid,
tvb, offset, 8, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(8);
}
/* SIDs */
st_sids = proto_tree_add_subtree(tree, tvb, offset, sids_buflen,
ett_smb_unix_whoami_sids, NULL, "List of SIDs");
for (i = 0; i < num_sids; i++) {
old_sid_offset = offset;
offset = dissect_nt_sid(tvb, offset, st_sids, "SID", NULL, -1);
CHECK_BYTE_COUNT_TRANS_SUBR(offset-old_sid_offset);
*bcp -= (offset - old_sid_offset);
}
break;
}
case 0x301: { /* MAC_QUERY_FS_INFO */
static int * const support_flags[] = {
&hf_smb_mac_sup_access_ctrl,
&hf_smb_mac_sup_getset_comments,
&hf_smb_mac_sup_desktopdb_calls,
&hf_smb_mac_sup_unique_ids,
&hf_smb_mac_sup_streams,
NULL
};
/* Create time */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb_create_time);
*bcp -= 8;
/* Modify Time */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb_modify_time);
*bcp -= 8;
/* Backup Time */
CHECK_BYTE_COUNT_TRANS_SUBR(8);
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb_backup_time);
*bcp -= 8;
/* Allocation blocks */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_mac_alloc_block_count, tvb,
offset,
4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* Allocation Block Size */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_mac_alloc_block_size, tvb,
offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* Free Block Count */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_mac_free_block_count, tvb,
offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* Finder Info ... */
CHECK_BYTE_COUNT_TRANS_SUBR(32);
proto_tree_add_bytes_format_value(tree, hf_smb_mac_fndrinfo, tvb,
offset, 32, NULL,
"%s",
tvb_format_text(pinfo->pool, tvb, offset, 32));
COUNT_BYTES_TRANS_SUBR(32);
/* Number Files */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_mac_root_file_count, tvb,
offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* Number of Root Directories */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_mac_root_dir_count, tvb,
offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* Number of files */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_mac_file_count, tvb,
offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* Dir Count */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_item(tree, hf_smb_mac_dir_count, tvb,
offset, 4, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
/* Mac Support Flags */
CHECK_BYTE_COUNT_TRANS_SUBR(4);
proto_tree_add_bitmask(tree, tvb, offset, hf_smb_mac_sup, ett_smb_mac_support_flags, support_flags, ENC_LITTLE_ENDIAN);
COUNT_BYTES_TRANS_SUBR(4);
break;
}
case 1006: /* QUERY_FS_QUOTA_INFO */
offset = dissect_nt_quota(tvb, tree, offset, bcp);
break;
case 1007: /* SMB_FS_FULL_SIZE_INFORMATION */
offset = dissect_qfsi_FS_FULL_SIZE_INFO(tvb, pinfo, tree, offset, bcp);
break;
case 1008: /* Query Object ID */ {
offset = dissect_qfsi_FS_OBJECTID_INFO(tvb, pinfo, tree, offset, bcp);
break;
}
}
return offset;
}
static int
dissect_transaction2_response_data(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *parent_tree, smb_info_t *si)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
smb_transact2_info_t *t2i;
int count;
gboolean trunc = FALSE;
int offset = 0;
guint16 dc;
dc = tvb_reported_length(tvb);
DISSECTOR_ASSERT(si);
if ((si->sip != NULL) && (si->sip->extra_info_type == SMB_EI_T2I))
t2i = (smb_transact2_info_t *)si->sip->extra_info;
else
t2i = NULL;
if (parent_tree) {
if ((t2i != NULL) && (t2i->subcmd != -1)) {
tree = proto_tree_add_subtree_format(parent_tree, tvb, offset, dc,
ett_smb_transaction_data, &item, "%s Data",
val_to_str_ext(t2i->subcmd, &trans2_cmd_vals_ext,
"Unknown (0x%02x)"));
} else {
tree = proto_tree_add_subtree(parent_tree, tvb, offset, dc,
ett_smb_transaction_data, &item, "Unknown Transaction2 Data");
}
}
if (t2i == NULL) {
offset += dc;
return offset;
}
switch(t2i->subcmd) {
case 0x0000: /*TRANS2_OPEN2*/
/* XXX not implemented yet. See SNIA doc */
break;
case 0x0001: /*TRANS2_FIND_FIRST2*/
/* returned data */
count = si->info_count;
if (count == -1) {
break;
}
if (count) {
col_append_str(pinfo->cinfo, COL_INFO,
", Files:");
}
while (count--) {
offset = dissect_ff2_response_data(tvb, pinfo, tree,
offset, &dc, &trunc, si);
if (trunc)
break;
}
break;
case 0x0002: /*TRANS2_FIND_NEXT2*/
/* returned data */
count = si->info_count;
if (count == -1) {
break;
}
if (count) {
col_append_str(pinfo->cinfo, COL_INFO,
", Files:");
}
while (count--) {
offset = dissect_ff2_response_data(tvb, pinfo, tree,
offset, &dc, &trunc, si);
if (trunc)
break;
}
break;
case 0x0003: /*TRANS2_QUERY_FS_INFORMATION*/
offset = dissect_qfsi_vals(tvb, pinfo, tree, offset, &dc, si);
break;
case 0x0004: /*TRANS2_SET_FS_INFORMATION*/
offset = dissect_sfsi_response(tvb, pinfo, tree, offset, &dc, si);
break;
case 0x0005: /*TRANS2_QUERY_PATH_INFORMATION*/
offset = dissect_qpi_loi_vals(tvb, pinfo, tree, item, offset, &dc, si);
break;
case 0x0006: /*TRANS2_SET_PATH_INFORMATION*/
/* no data in this response */
break;
case 0x0007: /*TRANS2_QUERY_FILE_INFORMATION*/
/* identical to QUERY_PATH_INFO */
offset = dissect_qpi_loi_vals(tvb, pinfo, tree, item, offset, &dc, si);
break;
case 0x0008: /*TRANS2_SET_FILE_INFORMATION*/
/* no data in this response */
break;
case 0x0009: /*TRANS2_FSCTL*/
/* XXX don't know how to dissect this one (yet)*/
/*
* XXX - "Microsoft Networks SMB File Sharing Protocol
* Extensions Version 3.0, Document Version 1.11,
* July 19, 1990" says this contains a
* "File system specific return data block".
* (That means we may not be able to dissect it in any
* case.)
*/
break;
case 0x000a: /*TRANS2_IOCTL2*/
/* XXX don't know how to dissect this one (yet)*/
/*
* XXX - "Microsoft Networks SMB File Sharing Protocol
* Extensions Version 3.0, Document Version 1.11,
* July 19, 1990" says this contains a
* "Device/function specific return data block".
* (That means we may not be able to dissect it in any
* case.)
*/
break;
case 0x000b: /*TRANS2_FIND_NOTIFY_FIRST*/
/* XXX don't know how to dissect this one (yet)*/
/*
* XXX - "Microsoft Networks SMB File Sharing Protocol
* Extensions Version 3.0, Document Version 1.11,
* July 19, 1990" says this contains "the level
* dependent information about the changes which
* occurred".
*/
break;
case 0x000c: /*TRANS2_FIND_NOTIFY_NEXT*/
/* XXX don't know how to dissect this one (yet)*/
/*
* XXX - "Microsoft Networks SMB File Sharing Protocol
* Extensions Version 3.0, Document Version 1.11,
* July 19, 1990" says this contains "the level
* dependent information about the changes which
* occurred".
*/
break;
case 0x000d: /*TRANS2_CREATE_DIRECTORY*/
/* no data in this response */
break;
case 0x000e: /*TRANS2_SESSION_SETUP*/
/* XXX don't know how to dissect this one (yet)*/
break;
case 0x0010: /*TRANS2_GET_DFS_REFERRAL*/
offset = dissect_get_dfs_referral_data(tvb, pinfo, tree, offset, &dc, si->unicode);
break;
case 0x0011: /*TRANS2_REPORT_DFS_INCONSISTENCY*/
/* the SNIA spec appears to say the response has no data */
break;
case -1:
/*
* We don't know what the matching request was; don't
* bother putting anything else into the tree for the data.
*/
offset += dc;
dc = 0;
break;
}
/* ooops there were data we didn't know how to process */
if (dc != 0) {
proto_tree_add_item(tree, hf_smb_unknown, tvb, offset, dc, ENC_NA);
offset += dc;
}
return offset;
}
static int
dissect_transaction2_response_parameters(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, smb_info_t *si)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
smb_transact2_info_t *t2i;
guint16 fid;
int lno;
int offset = 0;
int pc;
pc = tvb_reported_length(tvb);
DISSECTOR_ASSERT(si);
if ((si->sip != NULL) && (si->sip->extra_info_type == SMB_EI_T2I))
t2i = (smb_transact2_info_t *)si->sip->extra_info;
else
t2i = NULL;
if (parent_tree) {
if ((t2i != NULL) && (t2i->subcmd != -1)) {
tree = proto_tree_add_subtree_format(parent_tree, tvb, offset, pc,
ett_smb_transaction_params, &item, "%s Parameters",
val_to_str_ext(t2i->subcmd, &trans2_cmd_vals_ext,
"Unknown (0x%02x)"));
} else {
tree = proto_tree_add_subtree(parent_tree, tvb, offset, pc,
ett_smb_transaction_params, &item, "Unknown Transaction2 Parameters");
}
}
if (t2i == NULL) {
offset += pc;
return offset;
}
switch(t2i->subcmd) {
case 0x00: /*TRANS2_OPEN2*/
/* fid */
fid = tvb_get_letohs(tvb, offset);
dissect_smb_fid(tvb, pinfo, tree, offset, 2, fid, TRUE, FALSE, FALSE, si);
offset += 2;
/*
* XXX - Microsoft Networks SMB File Sharing Protocol
* Extensions Version 3.0, Document Version 1.11,
* July 19, 1990 says that the file attributes, create
* time (which it says is the last modification time),
* data size, granted access, file type, and IPC state
* are returned only if bit 0 is set in the open flags,
* and that the EA length is returned only if bit 3
* is set in the open flags. Does that mean that,
* at least in that SMB dialect, those fields are not
* present in the reply parameters if the bits in
* question aren't set?
*/
/* File Attributes */
offset = dissect_file_attributes(tvb, tree, offset);
/* create time */
offset = dissect_smb_datetime(tvb, tree, offset,
hf_smb_create_time,
hf_smb_create_dos_date, hf_smb_create_dos_time, TRUE);
/* data size */
proto_tree_add_item(tree, hf_smb_data_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* granted access */
offset = dissect_access(tvb, tree, offset, hf_smb_granted_access);
/* File Type */
proto_tree_add_item(tree, hf_smb_file_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* IPC State */
offset = dissect_ipc_state(tvb, tree, offset, FALSE);
/* open_action */
offset = dissect_open_action(tvb, tree, offset);
/* server unique file ID */
proto_tree_add_item(tree, hf_smb_file_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* ea error offset, only a 16 bit integer here */
proto_tree_add_item(tree, hf_smb_ea_error_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* ea length */
proto_tree_add_item(tree, hf_smb_ea_list_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case 0x01: /*TRANS2_FIND_FIRST2*/
/* Find First2 information level */
proto_tree_add_uint(tree, hf_smb_ff2_information_level, tvb, 0, 0, si->info_level);
/* sid */
proto_tree_add_item(tree, hf_smb_search_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* search count */
si->info_count = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_search_count, tvb, offset, 2, si->info_count);
offset += 2;
/* end of search */
proto_tree_add_item(tree, hf_smb_end_of_search, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* ea error offset, only a 16 bit integer here */
proto_tree_add_item(tree, hf_smb_ea_error_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* last name offset */
lno = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_last_name_offset, tvb, offset, 2, lno);
offset += 2;
break;
case 0x02: /*TRANS2_FIND_NEXT2*/
/* search count */
si->info_count = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_search_count, tvb, offset, 2, si->info_count);
offset += 2;
/* end of search */
proto_tree_add_item(tree, hf_smb_end_of_search, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* ea_error_offset, only a 16 bit integer here*/
proto_tree_add_item(tree, hf_smb_ea_error_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* last name offset */
lno = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_last_name_offset, tvb, offset, 2, lno);
offset += 2;
break;
case 0x03: /*TRANS2_QUERY_FS_INFORMATION*/
/* no parameter block here */
break;
case 0x05: /*TRANS2_QUERY_PATH_INFORMATION*/
/* ea_error_offset, only a 16 bit integer here*/
proto_tree_add_item(tree, hf_smb_ea_error_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
break;
case 0x06: /*TRANS2_SET_PATH_INFORMATION*/
/* ea_error_offset, only a 16 bit integer here*/
proto_tree_add_item(tree, hf_smb_ea_error_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
break;
case 0x07: /*TRANS2_QUERY_FILE_INFORMATION*/
/* ea_error_offset, only a 16 bit integer here*/
proto_tree_add_item(tree, hf_smb_ea_error_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
break;
case 0x08: /*TRANS2_SET_FILE_INFORMATION*/
/* ea_error_offset, only a 16 bit integer here*/
proto_tree_add_item(tree, hf_smb_ea_error_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
break;
case 0x09: /*TRANS2_FSCTL*/
/* XXX don't know how to dissect this one (yet)*/
/*
* XXX - "Microsoft Networks SMB File Sharing Protocol
* Extensions Version 3.0, Document Version 1.11,
* July 19, 1990" says this contains a
* "File system specific return parameter block".
* (That means we may not be able to dissect it in any
* case.)
*/
break;
case 0x0a: /*TRANS2_IOCTL2*/
/* XXX don't know how to dissect this one (yet)*/
/*
* XXX - "Microsoft Networks SMB File Sharing Protocol
* Extensions Version 3.0, Document Version 1.11,
* July 19, 1990" says this contains a
* "Device/function specific return parameter block".
* (That means we may not be able to dissect it in any
* case.)
*/
break;
case 0x0b: /*TRANS2_FIND_NOTIFY_FIRST*/
/* Find Notify information level */
proto_tree_add_uint(tree, hf_smb_fn_information_level, tvb, 0, 0, si->info_level);
/* Monitor handle */
proto_tree_add_item(tree, hf_smb_monitor_handle, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* Change count */
si->info_count = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_change_count, tvb, offset, 2, si->info_count);
offset += 2;
/* ea_error_offset, only a 16 bit integer here*/
proto_tree_add_item(tree, hf_smb_ea_error_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
break;
case 0x0c: /*TRANS2_FIND_NOTIFY_NEXT*/
/* Find Notify information level */
proto_tree_add_uint(tree, hf_smb_fn_information_level, tvb, 0, 0, si->info_level);
/* Change count */
si->info_count = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_change_count, tvb, offset, 2, si->info_count);
offset += 2;
/* ea_error_offset, only a 16 bit integer here*/
proto_tree_add_item(tree, hf_smb_ea_error_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
break;
case 0x0d: /*TRANS2_CREATE_DIRECTORY*/
/* ea error offset, only a 16 bit integer here */
proto_tree_add_item(tree, hf_smb_ea_error_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
break;
case 0x0e: /*TRANS2_SESSION_SETUP*/
/* XXX don't know how to dissect this one (yet)*/
break;
case 0x10: /*TRANS2_GET_DFS_REFERRAL*/
/* XXX don't know how to dissect this one (yet) see SNIA doc*/
break;
case 0x11: /*TRANS2_REPORT_DFS_INCONSISTENCY*/
/* XXX don't know how to dissect this one (yet) see SNIA doc*/
break;
case -1:
/*
* We don't know what the matching request was; don't
* bother putting anything else into the tree for the data.
*/
offset += pc;
break;
}
/* ooops there were data we didn't know how to process */
if (offset < pc) {
proto_tree_add_item(tree, hf_smb_unknown, tvb, offset, pc-offset, ENC_NA);
offset += pc-offset;
}
return offset;
}
static int
dissect_transaction_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si)
{
guint8 sc, wc;
guint16 od = 0, po = 0, pc = 0, pd = 0, dc = 0, dd = 0, td = 0, tp = 0;
smb_transact2_info_t *t2i = NULL;
guint16 bc;
int padcnt;
gboolean dissected_trans;
fragment_head *r_fd = NULL;
tvbuff_t *pd_tvb = NULL, *d_tvb = NULL, *p_tvb = NULL;
tvbuff_t *s_tvb = NULL, *sp_tvb = NULL;
gboolean save_fragmented;
proto_item *item;
DISSECTOR_ASSERT(si);
switch(si->cmd) {
case SMB_COM_TRANSACTION2:
/* transaction2 */
if ((si->sip != NULL) && (si->sip->extra_info_type == SMB_EI_T2I)) {
t2i = (smb_transact2_info_t *)si->sip->extra_info;
} else
t2i = NULL;
if (t2i == NULL) {
/*
* We didn't see the matching request, so we don't
* know what type of transaction this is.
*/
proto_tree_add_uint_format_value(tree, hf_smb_trans2_subcmd, tvb, 0, 0, -1,
"<UNKNOWN> since request packet wasn't seen");
col_append_str(pinfo->cinfo, COL_INFO, "<unknown>");
} else {
si->info_level = t2i->info_level;
if (t2i->subcmd == -1) {
/*
* We didn't manage to extract the subcommand
* from the matching request (perhaps because
* the frame was short), so we don't know what
* type of transaction this is.
*/
proto_tree_add_uint_format_value(tree, hf_smb_trans2_subcmd, tvb, 0, 0, t2i->subcmd,
"<UNKNOWN> since transaction code wasn't found in request packet");
col_append_str(pinfo->cinfo, COL_INFO, "<unknown>");
} else {
proto_tree_add_uint(tree, hf_smb_trans2_subcmd, tvb, 0, 0, t2i->subcmd);
switch (t2i->subcmd) {
case 0x0001: /* FIND_FIRST2 */
if (t2i->info_level == -1)
item = proto_tree_add_uint_format_value(tree, hf_smb_ff2_information_level, tvb, 0, 0, t2i->info_level,
"<UNKNOWN> since information level wasn't found in request packet");
else
item = proto_tree_add_uint(tree, hf_smb_ff2_information_level, tvb, 0, 0, t2i->info_level);
proto_item_set_generated(item);
if (t2i->name) {
item = proto_tree_add_string(tree, hf_smb_search_pattern, tvb, 0, 0, t2i->name);
proto_item_set_generated(item);
}
break;
case 0x0005: /* QUERY_PATH_INFORMATION */
if (t2i->info_level == -1)
item = proto_tree_add_uint_format_value(tree, hf_smb_qpi_loi, tvb, 0, 0, t2i->info_level,
"<UNKNOWN> since information level wasn't found in request packet");
else
item = proto_tree_add_uint(tree, hf_smb_qpi_loi, tvb, 0, 0, t2i->info_level);
proto_item_set_generated(item);
if (t2i->name) {
item = proto_tree_add_string(tree, hf_smb_file_name, tvb, 0, 0, t2i->name);
proto_item_set_generated(item);
}
break;
case 0x0007: /* QUERY_FILE_INFORMATION */
if (t2i->info_level == -1)
item = proto_tree_add_uint_format_value(tree, hf_smb_qpi_loi, tvb, 0, 0, t2i->info_level,
"<UNKNOWN> since information level wasn't found in request packet");
else
item = proto_tree_add_uint(tree, hf_smb_qpi_loi, tvb, 0, 0, t2i->info_level);
proto_item_set_generated(item);
break;
case 0x0003: /* QUERY_FS_INFORMATION */
if (t2i->info_level == -1)
item = proto_tree_add_uint_format_value(tree, hf_smb_qfsi_information_level, tvb, 0, 0, si->info_level,
"<UNKNOWN> since information level wasn't found in request packet");
else
item = proto_tree_add_uint(tree, hf_smb_qfsi_information_level, tvb, 0, 0, si->info_level);
proto_item_set_generated(item);
break;
case 0x0004: /* SET_FS_INFORMATION */
if (t2i->info_level == -1)
item = proto_tree_add_uint_format_value(tree, hf_smb_sfsi_information_level, tvb, 0, 0, si->info_level,
"<UNKNOWN> since information level wasn't found in request packet");
else
item = proto_tree_add_uint(tree, hf_smb_sfsi_information_level, tvb, 0, 0, si->info_level);
proto_item_set_generated(item);
break;
}
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
val_to_str_ext(t2i->subcmd,
&trans2_cmd_vals_ext,
"<unknown (0x%02x)>"));
}
}
break;
}
WORD_COUNT;
/* total param count, only a 16bit integer here */
tp = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_total_param_count, tvb, offset, 2, tp);
offset += 2;
/* total data count, only a 16 bit integer here */
td = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_total_data_count, tvb, offset, 2, td);
offset += 2;
/* 2 reserved bytes */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* param count */
pc = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_param_count16, tvb, offset, 2, pc);
offset += 2;
/* param offset */
po = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_param_offset16, tvb, offset, 2, po);
offset += 2;
/* param disp */
pd = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_param_disp16, tvb, offset, 2, pd);
offset += 2;
/* data count */
dc = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_count16, tvb, offset, 2, dc);
offset += 2;
/* data offset */
od = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_offset16, tvb, offset, 2, od);
offset += 2;
/* data disp */
dd = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_smb_data_disp16, tvb, offset, 2, dd);
offset += 2;
/* setup count */
sc = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_smb_setup_count, tvb, offset, 1, sc);
offset += 1;
/* reserved byte */
proto_tree_add_item(tree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* if there were any setup bytes, put them in a tvb for later */
if (sc) {
if ((2*sc) > tvb_reported_length_remaining(tvb, offset)) {
s_tvb = tvb_new_subset_length_caplen(tvb, offset, tvb_reported_length_remaining(tvb, offset), 2*sc);
} else {
s_tvb = tvb_new_subset_length(tvb, offset, 2*sc);
}
sp_tvb = tvb_new_subset_remaining(tvb, offset);
} else {
s_tvb = NULL;
sp_tvb = NULL;
}
offset += 2*sc;
BYTE_COUNT;
/* reassembly of SMB Transaction data payload.
In this section we do reassembly of both the data and parameters
blocks of the SMB transaction command.
*/
save_fragmented = pinfo->fragmented;
/* do we need reassembly? */
if ( (td != dc) || (tp != pc) ) {
/* oh yeah, either data or parameter section needs
reassembly
*/
pinfo->fragmented = TRUE;
if (smb_trans_reassembly) {
/* ...and we were told to do reassembly */
if (pc) {
r_fd = smb_trans_defragment(tree, pinfo, tvb,
po, pc, pd, td+tp, si);
}
if ((r_fd == NULL) && dc) {
r_fd = smb_trans_defragment(tree, pinfo, tvb,
od, dc, dd+tp, td+tp, si);
}
}
}
/* if we got a reassembled fd structure from the reassembly routine we must
create pd_tvb from it
*/
if (r_fd) {
proto_item *frag_tree_item;
pd_tvb = tvb_new_chain(tvb, r_fd->tvb_data);
add_new_data_source(pinfo, pd_tvb, "Reassembled SMB");
show_fragment_tree(r_fd, &smb_frag_items, tree, pinfo, pd_tvb, &frag_tree_item);
}
if (pd_tvb) {
/* OK we have reassembled data, extract d_tvb and p_tvb from it */
if (tp) {
p_tvb = tvb_new_subset_length(pd_tvb, 0, tp);
}
if (td) {
d_tvb = tvb_new_subset_length(pd_tvb, tp, td);
}
} else {
/* It was not reassembled. Do as best as we can.
* in this case we always try to dissect the stuff if
* data and param displacement is 0. i.e. for the first
* (and maybe only) packet.
*/
if ( (pd == 0) && (dd == 0) ) {
int min;
int reported_min;
min = MIN(pc, tvb_reported_length_remaining(tvb, po));
reported_min = MIN(pc, tvb_reported_length_remaining(tvb, po));
if (min && reported_min) {
p_tvb = tvb_new_subset_length_caplen(tvb, po, min, reported_min);
}
min = MIN(dc, tvb_reported_length_remaining(tvb, od));
reported_min = MIN(dc, tvb_reported_length_remaining(tvb, od));
if (min && reported_min) {
d_tvb = tvb_new_subset_length_caplen(tvb, od, min, reported_min);
}
/*
* A tvbuff containing the parameters
* and the data.
* XXX - check pc and dc as well?
*/
if (tvb_reported_length_remaining(tvb, po)) {
pd_tvb = tvb_new_subset_remaining(tvb, po);
}
}
}
/* parameters */
if (po > offset) {
/* We have some padding bytes.
*/
padcnt = po-offset;
if (padcnt > bc)
padcnt = bc;
proto_tree_add_item(tree, hf_smb_padding, tvb, offset, padcnt, ENC_NA);
COUNT_BYTES(padcnt);
}
if ((si->cmd == SMB_COM_TRANSACTION2) && p_tvb) {
/* TRANSACTION2 parameters*/
dissect_transaction2_response_parameters(p_tvb, pinfo, tree, si);
}
COUNT_BYTES(pc);
/* data */
if (od > offset) {
/* We have some initial padding bytes.
*/
padcnt = od-offset;
if (padcnt > bc)
padcnt = bc;
proto_tree_add_item(tree, hf_smb_padding, tvb, offset, padcnt, ENC_NA);
COUNT_BYTES(padcnt);
}
/*
* If the data count is bigger than the count of bytes
* remaining, clamp it so that the count of bytes remaining
* doesn't go negative.
*/
if (dc > bc)
dc = bc;
COUNT_BYTES(dc);
/* from now on, everything is in separate tvbuffs so we don't count
the bytes with COUNT_BYTES any more.
neither do we reference offset any more (which by now points to the
first byte AFTER this PDU */
if ((si->cmd == SMB_COM_TRANSACTION2) && d_tvb) {
/* TRANSACTION2 parameters*/
dissect_transaction2_response_data(d_tvb, pinfo, tree, si);
}
if (si->cmd == SMB_COM_TRANSACTION) {
smb_transact_info_t *tri;
dissected_trans = FALSE;
if ((si->sip != NULL) && (si->sip->extra_info_type == SMB_EI_TRI))
tri = (smb_transact_info_t *)si->sip->extra_info;
else
tri = NULL;
if (tri != NULL) {
switch(tri->subcmd) {
case TRANSACTION_PIPE:
/* This function is safe to call for
s_tvb == sp_tvb == NULL, i.e. if we don't
know them at this point.
It's also safe to call if "p_tvb"
or "d_tvb" are null.
*/
if ( pd_tvb) {
dissected_trans = dissect_pipe_smb(
sp_tvb, s_tvb, pd_tvb, p_tvb,
d_tvb, NULL, pinfo, top_tree_global, si);
}
break;
case TRANSACTION_MAILSLOT:
/* This one should be safe to call
even if s_tvb and sp_tvb is NULL
*/
if (d_tvb) {
dissected_trans = dissect_mailslot_smb(
sp_tvb, s_tvb, d_tvb, NULL, pinfo,
top_tree_global, si);
}
break;
}
}
if (!dissected_trans) {
/* This one is safe to call for s_tvb == p_tvb == d_tvb == NULL */
dissect_trans_data(s_tvb, p_tvb, d_tvb, tree);
}
}
if ( (p_tvb == 0) && (d_tvb == 0) ) {
col_append_str(pinfo->cinfo, COL_INFO,
"[transact continuation]");
}
pinfo->fragmented = save_fragmented;
END_OF_SMB
return offset;
}
static int
dissect_find_notify_close(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint8 wc;
guint16 bc;
WORD_COUNT;
/* Monitor handle */
proto_tree_add_item(tree, hf_smb_monitor_handle, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
BYTE_COUNT;
END_OF_SMB
return offset;
}
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
END Transaction/Transaction2 Primary and secondary requests
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
static int
dissect_unknown(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_, smb_info_t *si _U_)
{
guint8 wc;
guint16 bc;
WORD_COUNT;
if (wc != 0) {
proto_tree_add_item(tree, hf_smb_word_parameters, tvb, offset, wc*2, ENC_NA);
offset += wc*2;
}
BYTE_COUNT;
if (bc != 0) {
proto_tree_add_item(tree, hf_smb_byte_parameters, tvb, offset, bc, ENC_NA);
offset += bc;
bc = 0;
}
END_OF_SMB
return offset;
}
typedef struct _smb_function {
int (*request)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si);
int (*response)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si);
} smb_function;
static smb_function smb_dissector[256] = {
/* 0x00 Create Dir*/ {dissect_old_dir_request , dissect_empty},
/* 0x01 Delete Dir*/ {dissect_old_dir_request , dissect_empty},
/* 0x02 Open File*/ {dissect_open_file_request , dissect_open_file_response},
/* 0x03 Create File*/ {dissect_create_file_request , dissect_create_file_response},
/* 0x04 Close File*/ {dissect_close_file_request , dissect_empty},
/* 0x05 Flush File*/ {dissect_flush_file_request , dissect_empty},
/* 0x06 Delete File*/ {dissect_delete_file_request , dissect_empty},
/* 0x07 Rename File*/ {dissect_rename_file_request , dissect_rename_file_response},
/* 0x08 Query Info*/ {dissect_query_information_request , dissect_query_information_response},
/* 0x09 Set Info*/ {dissect_set_information_request , dissect_empty},
/* 0x0a Read File*/ {dissect_read_file_request , dissect_read_file_response},
/* 0x0b Write File*/ {dissect_write_file_request , dissect_write_file_response},
/* 0x0c Lock Byte Range*/ {dissect_lock_request , dissect_empty},
/* 0x0d Unlock Byte Range*/ {dissect_lock_request , dissect_empty},
/* 0x0e Create Temp*/ {dissect_create_temporary_request , dissect_create_temporary_response},
/* 0x0f Create New*/ {dissect_create_file_request , dissect_create_new_response},
/* 0x10 Check Dir*/ {dissect_old_dir_request , dissect_empty},
/* 0x11 Process Exit*/ {dissect_empty , dissect_empty},
/* 0x12 Seek File*/ {dissect_seek_file_request , dissect_seek_file_response},
/* 0x13 Lock And Read*/ {dissect_read_file_request , dissect_lock_and_read_response},
/* 0x14 Write And Unlock*/ {dissect_write_file_request , dissect_write_file_response},
/* 0x15 */ {dissect_unknown , dissect_unknown},
/* 0x16 */ {dissect_unknown , dissect_unknown},
/* 0x17 */ {dissect_unknown , dissect_unknown},
/* 0x18 */ {dissect_unknown , dissect_unknown},
/* 0x19 */ {dissect_unknown , dissect_unknown},
/* 0x1a Read Raw*/ {dissect_read_raw_request , dissect_unknown},
/* 0x1b Read MPX*/ {dissect_read_mpx_request , dissect_read_mpx_response},
/* 0x1c Read MPX Secondary*/ {dissect_unknown , dissect_unknown},
/* 0x1d Write Raw*/ {dissect_write_raw_request , dissect_write_raw_response},
/* 0x1e Write MPX*/ {dissect_write_mpx_request , dissect_write_mpx_response},
/* 0x1f Write MPX Secondary*/ {dissect_unknown , dissect_unknown},
/* 0x20 Write Complete*/ {dissect_unknown , dissect_write_and_close_response},
/* 0x21 */ {dissect_unknown , dissect_unknown},
/* 0x22 Set Info2*/ {dissect_set_information2_request , dissect_empty},
/* 0x23 Query Info2*/ {dissect_query_information2_request , dissect_query_information2_response},
/* 0x24 Locking And X*/ {dissect_locking_andx_request , dissect_locking_andx_response},
/* 0x25 Transaction*/ {dissect_transaction_request , dissect_transaction_response},
/* 0x26 Transaction Secondary*/ {dissect_transaction_request , dissect_unknown}, /*This SMB has no response */
/* 0x27 IOCTL*/ {dissect_unknown , dissect_unknown},
/* 0x28 IOCTL Secondary*/ {dissect_unknown , dissect_unknown},
/* 0x29 Copy File*/ {dissect_copy_request , dissect_move_copy_response},
/* 0x2a Move File*/ {dissect_move_request , dissect_move_copy_response},
/* 0x2b Echo*/ {dissect_echo_request , dissect_echo_response},
/* 0x2c Write And Close*/ {dissect_write_and_close_request , dissect_write_and_close_response},
/* 0x2d Open And X*/ {dissect_open_andx_request , dissect_open_andx_response},
/* 0x2e Read And X*/ {dissect_read_andx_request , dissect_read_andx_response},
/* 0x2f Write And X*/ {dissect_write_andx_request , dissect_write_andx_response},
/* 0x30 */ {dissect_unknown , dissect_unknown},
/* 0x31 Close And Tree Disconnect */ {dissect_close_file_request , dissect_empty},
/* 0x32 Transaction2*/ {dissect_transaction_request , dissect_transaction_response},
/* 0x33 Transaction2 Secondary*/ {dissect_transaction_request , dissect_unknown}, /*This SMB has no response */
/* 0x34 Find Close2*/ {dissect_sid , dissect_empty},
/* 0x35 Find Notify Close*/ {dissect_find_notify_close , dissect_empty},
/* 0x36 */ {dissect_unknown, dissect_unknown},
/* 0x37 */ {dissect_unknown, dissect_unknown},
/* 0x38 */ {dissect_unknown, dissect_unknown},
/* 0x39 */ {dissect_unknown, dissect_unknown},
/* 0x3a */ {dissect_unknown, dissect_unknown},
/* 0x3b */ {dissect_unknown, dissect_unknown},
/* 0x3c */ {dissect_unknown, dissect_unknown},
/* 0x3d */ {dissect_unknown, dissect_unknown},
/* 0x3e */ {dissect_unknown, dissect_unknown},
/* 0x3f */ {dissect_unknown, dissect_unknown},
/* 0x40 */ {dissect_unknown, dissect_unknown},
/* 0x41 */ {dissect_unknown, dissect_unknown},
/* 0x42 */ {dissect_unknown, dissect_unknown},
/* 0x43 */ {dissect_unknown, dissect_unknown},
/* 0x44 */ {dissect_unknown, dissect_unknown},
/* 0x45 */ {dissect_unknown, dissect_unknown},
/* 0x46 */ {dissect_unknown, dissect_unknown},
/* 0x47 */ {dissect_unknown, dissect_unknown},
/* 0x48 */ {dissect_unknown, dissect_unknown},
/* 0x49 */ {dissect_unknown, dissect_unknown},
/* 0x4a */ {dissect_unknown, dissect_unknown},
/* 0x4b */ {dissect_unknown, dissect_unknown},
/* 0x4c */ {dissect_unknown, dissect_unknown},
/* 0x4d */ {dissect_unknown, dissect_unknown},
/* 0x4e */ {dissect_unknown, dissect_unknown},
/* 0x4f */ {dissect_unknown, dissect_unknown},
/* 0x50 */ {dissect_unknown, dissect_unknown},
/* 0x51 */ {dissect_unknown, dissect_unknown},
/* 0x52 */ {dissect_unknown, dissect_unknown},
/* 0x53 */ {dissect_unknown, dissect_unknown},
/* 0x54 */ {dissect_unknown, dissect_unknown},
/* 0x55 */ {dissect_unknown, dissect_unknown},
/* 0x56 */ {dissect_unknown, dissect_unknown},
/* 0x57 */ {dissect_unknown, dissect_unknown},
/* 0x58 */ {dissect_unknown, dissect_unknown},
/* 0x59 */ {dissect_unknown, dissect_unknown},
/* 0x5a */ {dissect_unknown, dissect_unknown},
/* 0x5b */ {dissect_unknown, dissect_unknown},
/* 0x5c */ {dissect_unknown, dissect_unknown},
/* 0x5d */ {dissect_unknown, dissect_unknown},
/* 0x5e */ {dissect_unknown, dissect_unknown},
/* 0x5f */ {dissect_unknown, dissect_unknown},
/* 0x60 */ {dissect_unknown, dissect_unknown},
/* 0x61 */ {dissect_unknown, dissect_unknown},
/* 0x62 */ {dissect_unknown, dissect_unknown},
/* 0x63 */ {dissect_unknown, dissect_unknown},
/* 0x64 */ {dissect_unknown, dissect_unknown},
/* 0x65 */ {dissect_unknown, dissect_unknown},
/* 0x66 */ {dissect_unknown, dissect_unknown},
/* 0x67 */ {dissect_unknown, dissect_unknown},
/* 0x68 */ {dissect_unknown, dissect_unknown},
/* 0x69 */ {dissect_unknown, dissect_unknown},
/* 0x6a */ {dissect_unknown, dissect_unknown},
/* 0x6b */ {dissect_unknown, dissect_unknown},
/* 0x6c */ {dissect_unknown, dissect_unknown},
/* 0x6d */ {dissect_unknown, dissect_unknown},
/* 0x6e */ {dissect_unknown, dissect_unknown},
/* 0x6f */ {dissect_unknown, dissect_unknown},
/* 0x70 Tree Connect*/ {dissect_tree_connect_request , dissect_tree_connect_response},
/* 0x71 Tree Disconnect*/ {dissect_empty , dissect_empty},
/* 0x72 Negotiate Protocol*/ {dissect_negprot_request , dissect_negprot_response},
/* 0x73 Session Setup And X*/ {dissect_session_setup_andx_request , dissect_session_setup_andx_response},
/* 0x74 Logoff And X*/ {dissect_empty_andx , dissect_empty_andx},
/* 0x75 Tree Connect And X*/ {dissect_tree_connect_andx_request , dissect_tree_connect_andx_response},
/* 0x76 */ {dissect_unknown, dissect_unknown},
/* 0x77 */ {dissect_unknown, dissect_unknown},
/* 0x78 */ {dissect_unknown, dissect_unknown},
/* 0x79 */ {dissect_unknown, dissect_unknown},
/* 0x7a */ {dissect_unknown, dissect_unknown},
/* 0x7b */ {dissect_unknown, dissect_unknown},
/* 0x7c */ {dissect_unknown, dissect_unknown},
/* 0x7d */ {dissect_unknown, dissect_unknown},
/* 0x7e */ {dissect_unknown, dissect_unknown},
/* 0x7f */ {dissect_unknown, dissect_unknown},
/* 0x80 Query Info Disk*/ {dissect_empty , dissect_query_information_disk_response},
/* 0x81 Search Dir*/ {dissect_search_dir_request , dissect_search_dir_response},
/* 0x82 Find*/ {dissect_find_request , dissect_find_response},
/* 0x83 Find Unique*/ {dissect_find_request , dissect_find_response},
/* 0x84 Find Close*/ {dissect_find_close_request , dissect_find_close_response},
/* 0x85 */ {dissect_unknown, dissect_unknown},
/* 0x86 */ {dissect_unknown, dissect_unknown},
/* 0x87 */ {dissect_unknown, dissect_unknown},
/* 0x88 */ {dissect_unknown, dissect_unknown},
/* 0x89 */ {dissect_unknown, dissect_unknown},
/* 0x8a */ {dissect_unknown, dissect_unknown},
/* 0x8b */ {dissect_unknown, dissect_unknown},
/* 0x8c */ {dissect_unknown, dissect_unknown},
/* 0x8d */ {dissect_unknown, dissect_unknown},
/* 0x8e */ {dissect_unknown, dissect_unknown},
/* 0x8f */ {dissect_unknown, dissect_unknown},
/* 0x90 */ {dissect_unknown, dissect_unknown},
/* 0x91 */ {dissect_unknown, dissect_unknown},
/* 0x92 */ {dissect_unknown, dissect_unknown},
/* 0x93 */ {dissect_unknown, dissect_unknown},
/* 0x94 */ {dissect_unknown, dissect_unknown},
/* 0x95 */ {dissect_unknown, dissect_unknown},
/* 0x96 */ {dissect_unknown, dissect_unknown},
/* 0x97 */ {dissect_unknown, dissect_unknown},
/* 0x98 */ {dissect_unknown, dissect_unknown},
/* 0x99 */ {dissect_unknown, dissect_unknown},
/* 0x9a */ {dissect_unknown, dissect_unknown},
/* 0x9b */ {dissect_unknown, dissect_unknown},
/* 0x9c */ {dissect_unknown, dissect_unknown},
/* 0x9d */ {dissect_unknown, dissect_unknown},
/* 0x9e */ {dissect_unknown, dissect_unknown},
/* 0x9f */ {dissect_unknown, dissect_unknown},
/* 0xa0 NT Transaction*/ {dissect_nt_transaction_request , dissect_nt_transaction_response},
/* 0xa1 NT Trans secondary*/ {dissect_nt_transaction_request , dissect_nt_transaction_response},
/* 0xa2 NT CreateAndX*/ {dissect_nt_create_andx_request , dissect_nt_create_andx_response},
/* 0xa3 */ {dissect_unknown, dissect_unknown},
/* 0xa4 NT Cancel*/ {dissect_nt_cancel_request , dissect_unknown}, /*no response to this one*/
/* 0xa5 NT Rename*/ {dissect_nt_rename_file_request , dissect_empty},
/* 0xa6 */ {dissect_unknown, dissect_unknown},
/* 0xa7 */ {dissect_unknown, dissect_unknown},
/* 0xa8 */ {dissect_unknown, dissect_unknown},
/* 0xa9 */ {dissect_unknown, dissect_unknown},
/* 0xaa */ {dissect_unknown, dissect_unknown},
/* 0xab */ {dissect_unknown, dissect_unknown},
/* 0xac */ {dissect_unknown, dissect_unknown},
/* 0xad */ {dissect_unknown, dissect_unknown},
/* 0xae */ {dissect_unknown, dissect_unknown},
/* 0xaf */ {dissect_unknown, dissect_unknown},
/* 0xb0 */ {dissect_unknown, dissect_unknown},
/* 0xb1 */ {dissect_unknown, dissect_unknown},
/* 0xb2 */ {dissect_unknown, dissect_unknown},
/* 0xb3 */ {dissect_unknown, dissect_unknown},
/* 0xb4 */ {dissect_unknown, dissect_unknown},
/* 0xb5 */ {dissect_unknown, dissect_unknown},
/* 0xb6 */ {dissect_unknown, dissect_unknown},
/* 0xb7 */ {dissect_unknown, dissect_unknown},
/* 0xb8 */ {dissect_unknown, dissect_unknown},
/* 0xb9 */ {dissect_unknown, dissect_unknown},
/* 0xba */ {dissect_unknown, dissect_unknown},
/* 0xbb */ {dissect_unknown, dissect_unknown},
/* 0xbc */ {dissect_unknown, dissect_unknown},
/* 0xbd */ {dissect_unknown, dissect_unknown},
/* 0xbe */ {dissect_unknown, dissect_unknown},
/* 0xbf */ {dissect_unknown, dissect_unknown},
/* 0xc0 Open Print File*/ {dissect_open_print_file_request , dissect_open_print_file_response},
/* 0xc1 Write Print File*/ {dissect_write_print_file_request , dissect_empty},
/* 0xc2 Close Print File*/ {dissect_close_print_file_request , dissect_empty},
/* 0xc3 Get Print Queue*/ {dissect_get_print_queue_request , dissect_get_print_queue_response},
/* 0xc4 */ {dissect_unknown, dissect_unknown},
/* 0xc5 */ {dissect_unknown, dissect_unknown},
/* 0xc6 */ {dissect_unknown, dissect_unknown},
/* 0xc7 */ {dissect_unknown, dissect_unknown},
/* 0xc8 */ {dissect_unknown, dissect_unknown},
/* 0xc9 */ {dissect_unknown, dissect_unknown},
/* 0xca */ {dissect_unknown, dissect_unknown},
/* 0xcb */ {dissect_unknown, dissect_unknown},
/* 0xcc */ {dissect_unknown, dissect_unknown},
/* 0xcd */ {dissect_unknown, dissect_unknown},
/* 0xce */ {dissect_unknown, dissect_unknown},
/* 0xcf */ {dissect_unknown, dissect_unknown},
/* 0xd0 Send Single Block Message*/ {dissect_send_single_block_message_request , dissect_empty},
/* 0xd1 Send Broadcast Message*/ {dissect_send_single_block_message_request , dissect_empty},
/* 0xd2 Forward User Name*/ {dissect_forwarded_name , dissect_empty},
/* 0xd3 Cancel Forward*/ {dissect_forwarded_name , dissect_empty},
/* 0xd4 Get Machine Name*/ {dissect_empty , dissect_get_machine_name_response},
/* 0xd5 Send Start of Multi-block Message*/ {dissect_send_multi_block_message_start_request , dissect_message_group_id},
/* 0xd6 Send End of Multi-block Message*/ {dissect_message_group_id , dissect_empty},
/* 0xd7 Send Text of Multi-block Message*/ {dissect_send_multi_block_message_text_request , dissect_empty},
/* 0xd8 SMBreadbulk*/ {dissect_unknown , dissect_unknown},
/* 0xd9 SMBwritebulk*/ {dissect_unknown , dissect_unknown},
/* 0xda SMBwritebulkdata*/ {dissect_unknown , dissect_unknown},
/* 0xdb */ {dissect_unknown, dissect_unknown},
/* 0xdc */ {dissect_unknown, dissect_unknown},
/* 0xdd */ {dissect_unknown, dissect_unknown},
/* 0xde */ {dissect_unknown, dissect_unknown},
/* 0xdf */ {dissect_unknown, dissect_unknown},
/* 0xe0 */ {dissect_unknown, dissect_unknown},
/* 0xe1 */ {dissect_unknown, dissect_unknown},
/* 0xe2 */ {dissect_unknown, dissect_unknown},
/* 0xe3 */ {dissect_unknown, dissect_unknown},
/* 0xe4 */ {dissect_unknown, dissect_unknown},
/* 0xe5 */ {dissect_unknown, dissect_unknown},
/* 0xe6 */ {dissect_unknown, dissect_unknown},
/* 0xe7 */ {dissect_unknown, dissect_unknown},
/* 0xe8 */ {dissect_unknown, dissect_unknown},
/* 0xe9 */ {dissect_unknown, dissect_unknown},
/* 0xea */ {dissect_unknown, dissect_unknown},
/* 0xeb */ {dissect_unknown, dissect_unknown},
/* 0xec */ {dissect_unknown, dissect_unknown},
/* 0xed */ {dissect_unknown, dissect_unknown},
/* 0xee */ {dissect_unknown, dissect_unknown},
/* 0xef */ {dissect_unknown, dissect_unknown},
/* 0xf0 */ {dissect_unknown, dissect_unknown},
/* 0xf1 */ {dissect_unknown, dissect_unknown},
/* 0xf2 */ {dissect_unknown, dissect_unknown},
/* 0xf3 */ {dissect_unknown, dissect_unknown},
/* 0xf4 */ {dissect_unknown, dissect_unknown},
/* 0xf5 */ {dissect_unknown, dissect_unknown},
/* 0xf6 */ {dissect_unknown, dissect_unknown},
/* 0xf7 */ {dissect_unknown, dissect_unknown},
/* 0xf8 */ {dissect_unknown, dissect_unknown},
/* 0xf9 */ {dissect_unknown, dissect_unknown},
/* 0xfa */ {dissect_unknown, dissect_unknown},
/* 0xfb */ {dissect_unknown, dissect_unknown},
/* 0xfc */ {dissect_unknown, dissect_unknown},
/* 0xfd */ {dissect_unknown, dissect_unknown},
/* 0xfe */ {dissect_unknown, dissect_unknown},
/* 0xff */ {dissect_unknown, dissect_unknown},
};
static int
dissect_smb_command(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *smb_tree, guint8 cmd, gboolean first_pdu, smb_info_t *si)
{
smb_saved_info_t *sip;
DISSECTOR_ASSERT(si);
if (cmd != 0xff) {
proto_item *cmd_item;
proto_tree *cmd_tree;
int (*dissector)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si);
if (first_pdu) {
col_append_fstr(pinfo->cinfo, COL_INFO,
"%s %s",
val_to_str_ext(cmd, &smb_cmd_vals_ext, "Unknown (0x%02x)"),
(si->request)? "Request" : "Response");
} else {
col_append_fstr(pinfo->cinfo, COL_INFO,
"; %s",
val_to_str_ext(cmd, &smb_cmd_vals_ext, "Unknown (0x%02x)"));
}
cmd_tree = proto_tree_add_subtree_format(smb_tree, tvb, offset, -1,
ett_smb_command, &cmd_item, "%s %s (0x%02x)",
val_to_str_ext_const(cmd, &smb_cmd_vals_ext, "Unknown"),
(si->request)?"Request":"Response",
cmd);
/* we track FIDs on a per transaction basis.
if this was a request and the fid was seen in a reply
we add a "generated" fid tree for this pdu and v.v.
*/
sip = si->sip;
if (sip && sip->fid) {
if ( (si->request && (!sip->fid_seen_in_request))
|| ((!si->request) && sip->fid_seen_in_request) ) {
dissect_smb_fid(tvb, pinfo, cmd_tree, offset, 0, sip->fid, FALSE, FALSE, TRUE, si);
}
}
dissector = (si->request) ?
smb_dissector[cmd].request : smb_dissector[cmd].response;
offset = (*dissector)(tvb, pinfo, cmd_tree, offset, smb_tree, si);
if (!tvb_offset_exists(tvb, offset-1)) {
THROW(ReportedBoundsError);
}
proto_item_set_end(cmd_item, tvb, offset);
}
return offset;
}
static const value_string smb_cmd_vals[] = {
{ 0x00, "Create Directory" },
{ 0x01, "Delete Directory" },
{ 0x02, "Open" },
{ 0x03, "Create" },
{ 0x04, "Close" },
{ 0x05, "Flush" },
{ 0x06, "Delete" },
{ 0x07, "Rename" },
{ 0x08, "Query Information" },
{ 0x09, "Set Information" },
{ 0x0A, "Read" },
{ 0x0B, "Write" },
{ 0x0C, "Lock Byte Range" },
{ 0x0D, "Unlock Byte Range" },
{ 0x0E, "Create Temp" },
{ 0x0F, "Create New" },
{ 0x10, "Check Directory" },
{ 0x11, "Process Exit" },
{ 0x12, "Seek" },
{ 0x13, "Lock And Read" },
{ 0x14, "Write And Unlock" },
{ 0x15, "unknown-0x15" },
{ 0x16, "unknown-0x16" },
{ 0x17, "unknown-0x17" },
{ 0x18, "unknown-0x18" },
{ 0x19, "unknown-0x19" },
{ 0x1A, "Read Raw" },
{ 0x1B, "Read MPX" },
{ 0x1C, "Read MPX Secondary" },
{ 0x1D, "Write Raw" },
{ 0x1E, "Write MPX" },
{ 0x1F, "Write MPX Secondary" },
{ 0x20, "Write Complete" },
/*
* To quote
*
* http://msdn.microsoft.com/en-us/library/ee442098.aspx
*
* "This command was introduced in the NT LAN Manager dialect, and
* was reserved but not implemented.
*
* Clients SHOULD NOT send requests using this command code, and
* servers receiving requests with this command code SHOULD return
* STATUS_NOT_IMPLEMENTED (ERRDOS/ERRbadfunc)."
*/
{ 0x21, "Query Server (reserved)" },
{ 0x22, "Set Information2" },
{ 0x23, "Query Information2" },
{ 0x24, "Locking AndX" },
{ 0x25, "Trans" },
{ 0x26, "Trans Secondary" },
{ 0x27, "IOCTL" },
{ 0x28, "IOCTL Secondary" },
{ 0x29, "Copy" },
{ 0x2A, "Move" },
{ 0x2B, "Echo" },
{ 0x2C, "Write And Close" },
{ 0x2D, "Open AndX" },
{ 0x2E, "Read AndX" },
{ 0x2F, "Write AndX" },
/*
* To quote
*
* http://msdn.microsoft.com/en-us/library/ee442127.aspx
*
* "This command was reserved but not implemented. It was also never
* defined. It is listed in [SNIA], but it is not defined in that
* document and does not appear in any other references.
*
* Clients SHOULD NOT send requests using this command code, and
* servers receiving requests with this command code SHOULD return
* STATUS_NOT_IMPLEMENTED (ERRDOC/ERRbadfunc)."
*/
{ 0x30, "New File Size (reserved)" },
{ 0x31, "Close And Tree Disconnect" },
{ 0x32, "Trans2" },
{ 0x33, "Trans2 Secondary" },
{ 0x34, "Find Close2" },
{ 0x35, "Find Notify Close" },
{ 0x70, "Tree Connect" },
{ 0x71, "Tree Disconnect" },
{ 0x72, "Negotiate Protocol" },
{ 0x73, "Session Setup AndX" },
{ 0x74, "Logoff AndX" },
{ 0x75, "Tree Connect AndX" },
{ 0x80, "Query Information Disk" },
{ 0x81, "Search" },
{ 0x82, "Find" },
{ 0x83, "Find Unique" },
{ 0x84, "Find Close" },
{ 0xA0, "NT Trans" },
{ 0xA1, "NT Trans Secondary" },
{ 0xA2, "NT Create AndX" },
{ 0xA3, "unknown-0xA3" },
{ 0xA4, "NT Cancel" },
{ 0xA5, "NT Rename" },
{ 0xC0, "Open Print File" },
{ 0xC1, "Write Print File" },
{ 0xC2, "Close Print File" },
{ 0xC3, "Get Print Queue" },
{ 0xD0, "Send Single Block Message" },
{ 0xD1, "Send Broadcast Message" },
{ 0xD2, "Forward User Name" },
{ 0xD3, "Cancel Forward" },
{ 0xD4, "Get Machine Name" },
{ 0xD5, "Send Start of Multi-block Message" },
{ 0xD6, "Send End of Multi-block Message" },
{ 0xD7, "Send Text of Multi-block Message" },
{ 0xD8, "SMBreadbulk" },
{ 0xD9, "SMBwritebulk" },
{ 0xDA, "SMBwritebulkdata" },
{ 0xFE, "SMBinvalid" },
{ 0x00, NULL },
};
value_string_ext smb_cmd_vals_ext = VALUE_STRING_EXT_INIT(smb_cmd_vals);
static void
free_hash_tables(gpointer ctarg, gpointer user_data _U_)
{
conv_tables_t *ct = (conv_tables_t *)ctarg;
if (ct->unmatched)
g_hash_table_destroy(ct->unmatched);
if (ct->matched)
g_hash_table_destroy(ct->matched);
if (ct->primaries)
g_hash_table_destroy(ct->primaries);
if (ct->tid_service)
g_hash_table_destroy(ct->tid_service);
g_slist_free(ct->GSL_fid_info);
g_free(ct);
}
static void
smb_cleanup(void)
{
if (conv_tables) {
g_slist_foreach(conv_tables, free_hash_tables, NULL);
g_slist_free(conv_tables);
conv_tables = NULL;
}
}
static const value_string errcls_types[] = {
{ SMB_SUCCESS, "Success"},
{ SMB_ERRDOS, "DOS Error"},
{ SMB_ERRSRV, "Server Error"},
{ SMB_ERRHRD, "Hardware Error"},
{ SMB_ERRCMD, "Command Error - Not an SMB format command"},
{ 0, NULL }
};
/* Error codes for the ERRSRV class */
#define SRV_errors_VALUE_STRING_LIST(XXX) \
XXX( SMBE_SRV_error, 1, "Non specific error code") \
XXX( SMBE_SRV_badpw, 2, "Bad password") \
XXX( SMBE_SRV_badtype, 3, "Reserved") \
XXX( SMBE_SRV_access, 4, "No permissions to perform the requested operation") \
XXX( SMBE_SRV_invnid, 5, "TID invalid") \
XXX( SMBE_SRV_invnetname, 6, "Invalid network name. Service not found") \
XXX( SMBE_SRV_invdevice, 7, "Invalid device") \
XXX( SMBE_SRV_unknownsmb, 22, "Unknown SMB, from NT 3.5 response") \
XXX( SMBE_SRV_qfull, 49, "Print queue full") \
XXX( SMBE_SRV_qtoobig, 50, "Queued item too big") \
XXX( SMBE_SRV_qeof, 51, "EOF in print queue dump") \
XXX( SMBE_SRV_invpfid, 52, "Invalid print file in smb_fid") \
XXX( SMBE_SRV_smbcmd, 64, "Unrecognised command") \
XXX( SMBE_SRV_srverror, 65, "SMB server internal error") \
XXX( SMBE_SRV_filespecs, 67, "Fid and pathname invalid combination") \
XXX( SMBE_SRV_badlink, 68, "Bad link in request ???") \
XXX( SMBE_SRV_badpermits, 69, "Access specified for a file is not valid") \
XXX( SMBE_SRV_badpid, 70, "Bad process id in request") \
XXX( SMBE_SRV_setattrmode, 71, "Attribute mode invalid") \
XXX( SMBE_SRV_paused, 81, "Message server paused") \
XXX( SMBE_SRV_msgoff, 82, "Not receiving messages") \
XXX( SMBE_SRV_noroom, 83, "No room for message") \
XXX( SMBE_SRV_rmuns, 87, "Too many remote usernames") \
XXX( SMBE_SRV_timeout, 88, "Operation timed out") \
XXX( SMBE_SRV_noresource, 89, "No resources currently available for request.") \
XXX( SMBE_SRV_toomanyuids, 90, "Too many userids") \
XXX( SMBE_SRV_baduid, 91, "Bad userid") \
XXX( SMBE_SRV_useMPX, 250, "Temporarily unable to use raw mode, use MPX mode") \
XXX( SMBE_SRV_useSTD, 251, "Temporarily unable to use raw mode, use standard mode") \
XXX( SMBE_SRV_contMPX, 252, "Resume MPX mode") \
XXX( SMBE_SRV_badPW, 253, "Bad Password???") \
XXX( SMBE_SRV_nosupport, 0xFFFF, "Operation not supported")
#if 0 /* Values not needed */
VALUE_STRING_ENUM(SRV_errors);
#endif
VALUE_STRING_ARRAY(SRV_errors);
static value_string_ext SRV_errors_ext = VALUE_STRING_EXT_INIT(SRV_errors);
/* Error codes for the ERRHRD class */
#define HRD_errors_VALUE_STRING_LIST(XXX) \
XXX( SMBE_HRD_nowrite, 19, "Read only media") \
XXX( SMBE_HRD_badunit, 20, "Unknown device") \
XXX( SMBE_HRD_notready, 21, "Drive not ready") \
XXX( SMBE_HRD_badcmd, 22, "Unknown command") \
XXX( SMBE_HRD_data, 23, "Data (CRC) error") \
XXX( SMBE_HRD_badreq, 24, "Bad request structure length") \
XXX( SMBE_HRD_seek, 25, "Seek error") \
XXX( SMBE_HRD_badmedia, 26, "Unknown media type") \
XXX( SMBE_HRD_badsector, 27, "Sector not found") \
XXX( SMBE_HRD_nopaper, 28, "Printer out of paper") \
XXX( SMBE_HRD_write, 29, "Write fault") \
XXX( SMBE_HRD_read, 30, "Read fault") \
XXX( SMBE_HRD_general, 31, "General failure") \
/* -- (really part of ERRDOS class ??) -- */ \
XXX( SMBE_HRD_badshare, 32, "An open conflicts with an existing open") \
XXX( SMBE_HRD_lock, 33, "Lock conflict/invalid mode, or unlock of another process's lock") \
/* -- --*/ \
XXX( SMBE_HRD_wrongdisk, 34, "The wrong disk was found in a drive") \
XXX( SMBE_HRD_FCBunavail, 35, "No FCBs are available to process request") \
XXX( SMBE_HRD_sharebufexc, 36, "A sharing buffer has been exceeded") \
XXX( SMBE_HRD_diskfull, 39, "Disk full???")
#if 0 /* Values not needed */
VALUE_STRING_ENUM(HRD_errors);
#endif
VALUE_STRING_ARRAY(HRD_errors);
static value_string_ext HRD_errors_ext = VALUE_STRING_EXT_INIT(HRD_errors);
static const char *decode_smb_error(guint8 errcls, guint16 errcode)
{
switch (errcls) {
case SMB_SUCCESS:
return("No Error"); /* No error ??? */
case SMB_ERRDOS:
return(val_to_str_ext(errcode, &DOS_errors_ext, "Unknown DOS error (%x)"));
case SMB_ERRSRV:
return(val_to_str_ext(errcode, &SRV_errors_ext, "Unknown SRV error (%x)"));
case SMB_ERRHRD:
return(val_to_str_ext(errcode, &HRD_errors_ext, "Unknown HRD error (%x)"));
default:
return("Unknown error class!");
}
}
static const true_false_string tfs_smb_flags_lock = {
"Lock&Read, Write&Unlock are supported",
"Lock&Read, Write&Unlock are not supported"
};
static const true_false_string tfs_smb_flags_receive_buffer = {
"Receive buffer has been posted",
"Receive buffer has not been posted"
};
static const true_false_string tfs_smb_flags_caseless = {
"Path names are caseless",
"Path names are case sensitive"
};
static const true_false_string tfs_smb_flags_canon = {
"Pathnames are canonicalized",
"Pathnames are not canonicalized"
};
static const true_false_string tfs_smb_flags_oplock = {
"OpLock requested/granted",
"OpLock not requested/granted"
};
static const true_false_string tfs_smb_flags_notify = {
"Notify client on all modifications",
"Notify client only on open"
};
static const true_false_string tfs_smb_flags_response = {
"Message is a response to the client/redirector",
"Message is a request to the server"
};
static int
dissect_smb_flags(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_flags_response,
&hf_smb_flags_notify,
&hf_smb_flags_oplock,
&hf_smb_flags_canon,
&hf_smb_flags_caseless,
&hf_smb_flags_receive_buffer,
&hf_smb_flags_lock,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_flags, ett_smb_flags, flags, ENC_NA);
offset += 1;
return offset;
}
static const true_false_string tfs_smb_flags2_long_names_allowed = {
"Long file names are allowed in the response",
"Long file names are not allowed in the response"
};
static const true_false_string tfs_smb_flags2_ea = {
"Extended attributes are supported",
"Extended attributes are not supported"
};
static const true_false_string tfs_smb_flags2_sec_sig = {
"Security signatures are supported",
"Security signatures are not supported"
};
static const true_false_string tfs_smb_flags2_compressed = {
"Compression is requested",
"Compression is not requested"
};
static const true_false_string tfs_smb_flags2_sec_sig_required = {
"Security signatures are required",
"Security signatures are not required"
};
static const true_false_string tfs_smb_flags2_long_names_used = {
"Path names in request are long file names",
"Path names in request are not long file names"
};
static const true_false_string tfs_smb_flags2_reparse_path = {
"The request uses a @GMT reparse path",
"The request does not use a @GMT reparse path"
};
static const true_false_string tfs_smb_flags2_esn = {
"Extended security negotiation is supported",
"Extended security negotiation is not supported"
};
static const true_false_string tfs_smb_flags2_dfs = {
"Resolve pathnames with Dfs",
"Don't resolve pathnames with Dfs"
};
static const true_false_string tfs_smb_flags2_roe = {
"Permit reads if execute-only",
"Don't permit reads if execute-only"
};
static const true_false_string tfs_smb_flags2_nt_error = {
"Error codes are NT error codes",
"Error codes are DOS error codes"
};
static const true_false_string tfs_smb_flags2_string = {
"Strings are Unicode",
"Strings are ASCII"
};
static int
dissect_smb_flags2(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
static int * const flags[] = {
&hf_smb_flags2_string,
&hf_smb_flags2_nt_error,
&hf_smb_flags2_roe,
&hf_smb_flags2_dfs,
&hf_smb_flags2_esn,
&hf_smb_flags2_reparse_path,
&hf_smb_flags2_long_names_used,
&hf_smb_flags2_sec_sig_required,
&hf_smb_flags2_compressed,
&hf_smb_flags2_sec_sig,
&hf_smb_flags2_ea,
&hf_smb_flags2_long_names_allowed,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb_flags2, ett_smb_flags2, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
#define SMB_FLAGS_DIRN 0x80
static int
dissect_smb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_)
{
int offset = 0;
proto_item *item;
proto_tree *tree, *htree;
proto_item *tmp_item = NULL;
guint8 flags;
guint16 flags2;
smb_info_t *si;
smb_saved_info_t *sip = NULL;
smb_saved_info_key_t key;
smb_saved_info_key_t *new_key;
guint8 errclass = 0;
guint16 errcode = 0;
guint32 pid_mid;
conversation_t *conversation;
nstime_t t, deltat;
si = wmem_new0(wmem_packet_scope(), smb_info_t);
top_tree_global = parent_tree;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMB");
col_clear(pinfo->cinfo, COL_INFO);
/* start off using the local variable, we will allocate a new one if we
need to*/
si->cmd = tvb_get_guint8(tvb, offset+4);
flags = tvb_get_guint8(tvb, offset+9);
/*
* XXX - in some SMB-over-OSI-transport and SMB-over-Vines traffic,
* the direction flag appears never to be set, even for what appear
* to be replies. Do some SMB servers fail to set that flag,
* under the assumption that the client knows it's a reply because
* it received it?
*/
si->request = !(flags&SMB_FLAGS_DIRN);
flags2 = tvb_get_letohs(tvb, offset+10);
if (flags2 & 0x8000) {
si->unicode = TRUE; /* Mark them as Unicode */
} else {
si->unicode = FALSE;
}
si->tid = tvb_get_letohs(tvb, offset+24);
si->pid = tvb_get_letohs(tvb, offset+26);
si->uid = tvb_get_letohs(tvb, offset+28);
si->mid = tvb_get_letohs(tvb, offset+30);
pid_mid = (si->pid << 16) | si->mid;
si->info_level = -1;
si->info_count = -1;
item = proto_tree_add_item(parent_tree, proto_smb, tvb, offset,
-1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb);
htree = proto_tree_add_subtree(tree, tvb, offset, 32,
ett_smb_hdr, NULL, "SMB Header");
proto_tree_add_uint_format_value(htree, hf_smb_server_component, tvb, offset, 4, tvb_get_letohl(tvb, offset), "SMB");
offset += 4; /* Skip the marker */
/* find which conversation we are part of and get the tables for that
conversation*/
conversation = find_or_create_conversation(pinfo);
/* see if we already have the smb data for this conversation */
si->ct = (conv_tables_t *)conversation_get_proto_data(conversation, proto_smb);
if (!si->ct) {
/* No, not yet. create it and attach it to the conversation */
si->ct = g_new(conv_tables_t, 1);
conv_tables = g_slist_prepend(conv_tables, si->ct);
si->ct->matched = g_hash_table_new(smb_saved_info_hash_matched,
smb_saved_info_equal_matched);
si->ct->unmatched = g_hash_table_new(smb_saved_info_hash_unmatched,
smb_saved_info_equal_unmatched);
/* We used the same key format as the unmatched entries */
si->ct->primaries = g_hash_table_new(
smb_saved_info_hash_unmatched,
smb_saved_info_equal_unmatched);
si->ct->tid_service = g_hash_table_new(
smb_saved_info_hash_unmatched,
smb_saved_info_equal_unmatched);
si->ct->raw_ntlmssp = 0;
si->ct->fid_tree = wmem_tree_new(wmem_file_scope());
si->ct->tid_tree = wmem_tree_new(wmem_file_scope());
si->ct->uid_tree = wmem_tree_new(wmem_file_scope());
/* Initialize the GSL_fid_info for this ct */
si->ct->GSL_fid_info = NULL;
conversation_add_proto_data(conversation, proto_smb, si->ct);
}
if ( (si->request)
&& (si->mid == 0)
&& (si->uid == 0)
&& (si->pid == 0)
&& (si->tid == 0) ) {
/* this is a broadcast SMB packet, there will not be a reply.
We don't need to do anything
*/
si->unidir = TRUE;
} else if ( (si->cmd == SMB_COM_NT_CANCEL) /* NT Cancel */
|| (si->cmd == SMB_COM_TRANSACTION_SECONDARY) /* Transaction Secondary */
|| (si->cmd == SMB_COM_TRANSACTION2_SECONDARY) /* Transaction2 Secondary */
|| (si->cmd == SMB_COM_NT_TRANSACT_SECONDARY)) { /* NT Transaction Secondary */
/* Ok, we got a special request type. This request is either
an NT Cancel or a continuation relative to a real request
in an earlier packet. In either case, we don't expect any
responses to this packet. For continuations, any later
responses we see really just belong to the original request.
Anyway, we want to remember this packet somehow and
remember which original request it is associated with so
we can say nice things such as "This is a Cancellation to
the request in frame x", but we don't want the
request/response matching to get messed up.
The only thing we do in this case is trying to find which original
request we match with and insert an entry for this "special"
request for later reference. We continue to reference the original
requests smb_saved_info_t but we don't touch it or change anything
in it.
*/
si->unidir = TRUE; /*we don't expect an answer to this one*/
if (!pinfo->fd->visited) {
/* try to find which original call we match and if we
find it add us to the matched table. Don't touch
anything else since we don't want this one to mess
up the request/response matching. We still consider
the initial call the real request and this is only
some sort of continuation.
*/
/* we only check the unmatched table and assume that the
last seen MID matching ours is the right one.
This can fail but is better than nothing
*/
sip = (smb_saved_info_t *)g_hash_table_lookup(si->ct->unmatched, GUINT_TO_POINTER(pid_mid));
if (sip != NULL) {
new_key = wmem_new(wmem_file_scope(), smb_saved_info_key_t);
new_key->frame = pinfo->num;
new_key->pid_mid = pid_mid;
g_hash_table_insert(si->ct->matched, new_key,
sip);
} else {
if ((si->cmd == SMB_COM_TRANSACTION_SECONDARY) ||
(si->cmd == SMB_COM_TRANSACTION2_SECONDARY) ||
(si->cmd == SMB_COM_NT_TRANSACT_SECONDARY)) {
sip = (smb_saved_info_t *)g_hash_table_lookup(si->ct->primaries, GUINT_TO_POINTER(pid_mid));
}
}
} else {
/* we have seen this packet before; check the
matching table
*/
key.frame = pinfo->num;
key.pid_mid = pid_mid;
sip = (smb_saved_info_t *)g_hash_table_lookup(si->ct->matched, &key);
if (sip == NULL) {
/*
We didn't find it.
Too bad, unfortunately there is not really much we can
do now since this means that we never saw the initial
request.
*/
}
}
if (sip && sip->frame_req) {
switch(si->cmd) {
case SMB_COM_NT_CANCEL:
tmp_item = proto_tree_add_uint(htree, hf_smb_cancel_to,
tvb, 0, 0, sip->frame_req);
proto_item_set_generated(tmp_item);
break;
case SMB_COM_TRANSACTION_SECONDARY:
case SMB_COM_TRANSACTION2_SECONDARY:
case SMB_COM_NT_TRANSACT_SECONDARY:
tmp_item = proto_tree_add_uint(htree, hf_smb_continuation_to,
tvb, 0, 0, sip->frame_req);
proto_item_set_generated(tmp_item);
break;
}
} else {
switch(si->cmd) {
case SMB_COM_NT_CANCEL:
proto_tree_add_uint_format_value(htree, hf_smb_cancel_to, tvb, 0, 0, 0, "<unknown frame>");
break;
case SMB_COM_TRANSACTION_SECONDARY:
case SMB_COM_TRANSACTION2_SECONDARY:
case SMB_COM_NT_TRANSACT_SECONDARY:
proto_tree_add_uint_format_value(htree, hf_smb_continuation_to, tvb, 0, 0, 0, "<unknown frame>");
break;
}
}
} else { /* normal bidirectional request or response */
si->unidir = FALSE;
if (!pinfo->fd->visited) {
/* first see if we find an unmatched smb "equal" to
the current one
*/
sip = (smb_saved_info_t *)g_hash_table_lookup(si->ct->unmatched, GUINT_TO_POINTER(pid_mid));
if (sip != NULL) {
gboolean cmd_match = FALSE;
/*
* Make sure the SMB we found was the
* same command, or a different command
* that's another valid type of reply
* to that command.
*/
if (si->cmd == sip->cmd) {
cmd_match = TRUE;
}
else if (si->cmd == SMB_COM_NT_CANCEL) {
cmd_match = TRUE;
}
else if ((si->cmd == SMB_COM_TRANSACTION_SECONDARY)
&& (sip->cmd == SMB_COM_TRANSACTION)) {
cmd_match = TRUE;
}
else if ((si->cmd == SMB_COM_TRANSACTION2_SECONDARY)
&& (sip->cmd == SMB_COM_TRANSACTION2)) {
cmd_match = TRUE;
}
else if ((si->cmd == SMB_COM_NT_TRANSACT_SECONDARY)
&& (sip->cmd == SMB_COM_NT_TRANSACT)) {
cmd_match = TRUE;
}
if ( (si->request) || (!cmd_match) ) {
/* We are processing an SMB request but there was already
another "identical" smb request we had not matched yet.
This must mean that either we have a retransmission or that the
response to the previous one was lost and the client has reused
the MID for this conversation. In either case it's not much more
we can do than forget the old request and concentrate on the
present one instead.
We also do this cleanup if we see that the cmd in the original
request in sip->cmd is not compatible with the current cmd.
This is to prevent matching errors such as if there were two
SMBs of different cmds but with identical MID and PID values and
if wireshark lost the first reply and the second request.
*/
g_hash_table_remove(si->ct->unmatched, GUINT_TO_POINTER(pid_mid));
sip = NULL; /* XXX should free it as well */
} else {
/* we have found a response to some
request we have seen earlier.
What we do now depends on whether
this is the first response to that
request we see (id frame_res == 0) or
if it's a response to a request
for which we've seen an earlier
response that's continued.
*/
if ((sip->frame_res == 0) ||
(sip->flags & SMB_SIF_IS_CONTINUED)) {
/* OK, it is the first response
we have seen to this packet,
or it's a continuation of
a response we've seen. */
sip->frame_res = pinfo->num;
new_key = wmem_new(wmem_file_scope(), smb_saved_info_key_t);
new_key->frame = sip->frame_res;
new_key->pid_mid = pid_mid;
g_hash_table_insert(si->ct->matched, new_key, sip);
/* We remove the entry for unmatched since we have found a match.
* We have to do this since the MID value wraps so quickly (effective only 10 bits)
* and if there is packetloss in the trace (maybe due to large holes
* created by a sniffer device not being able to keep up
* with the line rate.
* There is a real possibility that the following would occur which is painful :
* 1, -> Request MID:5
* 2, <- Response MID:5
* 3, -> Request MID:5 (missing from capture)
* 4, <- Response MID:5
* We DON'T want #4 to be presented as a response to #1
*/
g_hash_table_remove(si->ct->unmatched, GUINT_TO_POINTER(pid_mid));
} else {
/* We have already seen another response to this MID.
Since the MID in reality is only something like 10 bits
this probably means that we just have a MID that is being
reused due to the small MID space and that this is a new
command we did not see the original request for.
*/
sip = NULL;
}
}
} else {
if ((si->cmd == SMB_COM_TRANSACTION) ||
(si->cmd == SMB_COM_TRANSACTION2) ||
(si->cmd == SMB_COM_NT_TRANSACT)) {
sip = (smb_saved_info_t *)g_hash_table_lookup(si->ct->primaries, GUINT_TO_POINTER(pid_mid));
}
}
if (si->request) {
sip = wmem_new(wmem_file_scope(), smb_saved_info_t);
sip->frame_req = pinfo->num;
sip->frame_res = 0;
sip->req_time = pinfo->abs_ts;
sip->flags = 0;
if (g_hash_table_lookup(si->ct->tid_service, GUINT_TO_POINTER(si->tid))
== (void *)TID_IPC) {
sip->flags |= SMB_SIF_TID_IS_IPC;
}
sip->cmd = si->cmd;
sip->extra_info = NULL;
sip->extra_info_type = SMB_EI_NONE;
sip->fid = 0;
sip->fid_seen_in_request = 0;
g_hash_table_insert(si->ct->unmatched, GUINT_TO_POINTER(pid_mid), sip);
new_key = wmem_new(wmem_file_scope(), smb_saved_info_key_t);
new_key->frame = sip->frame_req;
new_key->pid_mid = pid_mid;
g_hash_table_insert(si->ct->matched, new_key, sip);
/* If it is a TRANSACT cmd, insert in hash */
if ((si->cmd == SMB_COM_TRANSACTION) ||
(si->cmd == SMB_COM_TRANSACTION2) ||
(si->cmd == SMB_COM_NT_TRANSACT)) {
g_hash_table_insert(si->ct->primaries, GUINT_TO_POINTER(pid_mid), sip);
}
}
} else {
/* we have seen this packet before; check the
matching table.
If we haven't yet seen the reply, we won't
find the info for it; we don't need it, as
we only use it to save information, and, as
we've seen this packet before, we've already
saved the information.
*/
key.frame = pinfo->num;
key.pid_mid = pid_mid;
sip = (smb_saved_info_t *)g_hash_table_lookup(si->ct->matched, &key);
}
}
/*
* Pass the "sip" on to subdissectors through "si".
*/
si->sip = sip;
if (sip != NULL) {
/*
* Put in fields for the frame number of the frame to which
* this is a response or the frame with the response to this
* frame - if we know the frame number (i.e., it's not 0).
*/
if (si->request) {
if (sip->frame_res != 0) {
tmp_item = proto_tree_add_uint(htree, hf_smb_response_in, tvb, 0, 0, sip->frame_res);
proto_item_set_generated(tmp_item);
}
} else {
if (sip->frame_req != 0) {
tmp_item = proto_tree_add_uint(htree, hf_smb_response_to, tvb, 0, 0, sip->frame_req);
proto_item_set_generated(tmp_item);
t = pinfo->abs_ts;
nstime_delta(&deltat, &t, &sip->req_time);
tmp_item = proto_tree_add_time(htree, hf_smb_time, tvb,
0, 0, &deltat);
proto_item_set_generated(tmp_item);
}
}
}
/* smb command */
proto_tree_add_uint(htree, hf_smb_cmd, tvb, offset, 1, si->cmd);
offset += 1;
if (flags2 & 0x4000) {
/* handle NT 32 bit error code */
si->nt_status = tvb_get_letohl(tvb, offset);
proto_tree_add_item(htree, hf_smb_nt_status, tvb, offset, 4,
ENC_LITTLE_ENDIAN);
offset += 4;
} else {
/* handle DOS error code & class */
errclass = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(htree, hf_smb_error_class, tvb, offset, 1,
errclass);
offset += 1;
/* reserved byte */
proto_tree_add_item(htree, hf_smb_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* error code */
/* XXX - the type of this field depends on the value of
* "errcls", so there is isn't a single value_string array
* fo it, so there can't be a single field for it.
*/
errcode = tvb_get_letohs(tvb, offset);
proto_tree_add_uint_format_value(htree, hf_smb_error_code, tvb,
offset, 2, errcode, "%s",
decode_smb_error(errclass, errcode));
offset += 2;
}
/* flags */
offset = dissect_smb_flags(tvb, htree, offset);
/* flags2 */
offset = dissect_smb_flags2(tvb, htree, offset);
/*
* The document at
*
* http://www.samba.org/samba/ftp/specs/smbpub.txt
*
* (a text version of "Microsoft Networks SMB FILE SHARING
* PROTOCOL, Document Version 6.0p") says that:
*
* the first 2 bytes of these 12 bytes are, for NT Create and X,
* the "High Part of PID";
*
* the next four bytes are reserved;
*
* the next four bytes are, for SMB-over-IPX (with no
* NetBIOS involved) two bytes of Session ID and two bytes
* of SequenceNumber.
*
* Network Monitor 2.x dissects the four bytes before the Session ID
* as a "Key", and the two bytes after the SequenceNumber as
* a "Group ID".
*
* The "High Part of PID" has been seen in calls other than NT
* Create and X, although most of them appear to be I/O on DCE RPC
* pipes opened with the NT Create and X in question.
*/
proto_tree_add_item(htree, hf_smb_pid_high, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
if ((pinfo->ptype == PT_IPX) &&
((pinfo->match_uint == IPX_SOCKET_NWLINK_SMB_SERVER) ||
(pinfo->match_uint == IPX_SOCKET_NWLINK_SMB_REDIR) ||
(pinfo->match_uint == IPX_SOCKET_NWLINK_SMB_MESSENGER))) {
/*
* This is SMB-over-IPX.
* XXX - do we have to worry about "sequenced commands",
* as per the Samba document? They say that for
* "unsequenced commands" (with a sequence number of 0),
* the Mid must be unique, but perhaps the Mid doesn't
* have to be unique for sequenced commands. In at least
* one capture with SMB-over-IPX, however, the Mids
* are unique even for sequenced commands.
*/
/* Key */
proto_tree_add_item(htree, hf_smb_key, tvb, offset, 4,
ENC_LITTLE_ENDIAN);
offset += 4;
/* Session ID */
proto_tree_add_item(htree, hf_smb_session_id, tvb, offset, 2,
ENC_LITTLE_ENDIAN);
offset += 2;
/* Sequence number */
proto_tree_add_item(htree, hf_smb_sequence_num, tvb, offset, 2,
ENC_LITTLE_ENDIAN);
offset += 2;
/* Group ID */
proto_tree_add_item(htree, hf_smb_group_id, tvb, offset, 2,
ENC_LITTLE_ENDIAN);
offset += 2;
} else {
/*
* According to http://ubiqx.org/cifs/SMB.html#SMB.4.2.1
* and http://ubiqx.org/cifs/SMB.html#SMB.5.5.1 the 8
* bytes after the "High part of PID" are an 8-byte
* signature ...
*/
proto_tree_add_item(htree, hf_smb_sig, tvb, offset, 8, ENC_NA);
offset += 8;
proto_tree_add_item(htree, hf_smb_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
}
/* TID
* TreeConnectAndX(0x75) is special, here it is the mere fact of
* having a response that means that the share was mapped and we
* need to track it
*/
if (!pinfo->fd->visited && (si->cmd == 0x75) && !si->request) {
offset = dissect_smb_tid(tvb, pinfo, htree, offset, (guint16)si->tid, TRUE, FALSE, si);
} else {
offset = dissect_smb_tid(tvb, pinfo, htree, offset, (guint16)si->tid, FALSE, FALSE, si);
}
/* PID */
proto_tree_add_uint(htree, hf_smb_pid, tvb, offset, 2, si->pid);
offset += 2;
/* UID */
offset = dissect_smb_uid(tvb, htree, offset, si);
/* MID */
proto_tree_add_uint(htree, hf_smb_mid, tvb, offset, 2, si->mid);
offset += 2;
/* tap the packet before the dissectors are called so we still get
the tap listener called even if there is an exception.
*/
tap_queue_packet(smb_tap, pinfo, si);
dissect_smb_command(tvb, pinfo, offset, tree, si->cmd, TRUE, si);
/* Append error info from this packet to info string. */
if (!si->request) {
if (flags2 & 0x4000) {
/*
* The status is an NT status code; was there
* an error?
*/
if ((si->nt_status & 0xC0000000) == 0xC0000000) {
/*
* Yes.
*/
col_append_fstr(
pinfo->cinfo, COL_INFO, ", Error: %s",
val_to_str_ext(si->nt_status, &NT_errors_ext,
"Unknown (0x%08X)"));
}
} else {
/*
* The status is a DOS error class and code; was
* there an error?
*/
if (errclass != SMB_SUCCESS) {
/*
* Yes.
*/
col_append_fstr(
pinfo->cinfo, COL_INFO, ", Error: %s",
decode_smb_error(errclass, errcode));
}
}
}
return tvb_captured_length(tvb);
}
static gboolean
dissect_smb_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
{
/* must check that this really is a smb packet */
if (tvb_reported_length(tvb) < 4)
return FALSE;
if ( (tvb_get_guint8(tvb, 0) != 0xff)
|| (tvb_get_guint8(tvb, 1) != 'S')
|| (tvb_get_guint8(tvb, 2) != 'M')
|| (tvb_get_guint8(tvb, 3) != 'B') ) {
return FALSE;
}
dissect_smb(tvb, pinfo, parent_tree, data);
return TRUE;
}
void
proto_register_smb(void)
{
static hf_register_info hf[] = {
{ &hf_smb_cmd,
{ "SMB Command", "smb.cmd", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
&smb_cmd_vals_ext, 0x0, NULL, HFILL }},
{ &hf_smb_andxcmd,
{ "AndXCommand", "smb.cmd", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
&smb_cmd_vals_ext, 0x0, NULL, HFILL }},
{ &hf_smb_trans2_subcmd,
{ "Subcommand", "smb.trans2.cmd", FT_UINT16, BASE_HEX|BASE_EXT_STRING,
&trans2_cmd_vals_ext, 0, "Subcommand for TRANSACTION2", HFILL }},
{ &hf_smb_nt_trans_subcmd,
{ "Function", "smb.nt.function", FT_UINT16, BASE_DEC|BASE_EXT_STRING,
&nt_cmd_vals_ext, 0, "Function for NT Transaction", HFILL }},
{ &hf_smb_word_count,
{ "Word Count (WCT)", "smb.wct", FT_UINT8, BASE_DEC,
NULL, 0x0, "Word Count, count of parameter words", HFILL }},
{ &hf_smb_byte_count,
{ "Byte Count (BCC)", "smb.bcc", FT_UINT16, BASE_DEC,
NULL, 0x0, "Byte Count, count of data bytes", HFILL }},
{ &hf_smb_response_to,
{ "Response to", "smb.response_to", FT_FRAMENUM, BASE_NONE,
NULL, 0, "This packet is a response to the packet in this frame", HFILL }},
{ &hf_smb_time,
{ "Time from request", "smb.time", FT_RELATIVE_TIME, BASE_NONE,
NULL, 0, "Time between Request and Response for SMB cmds", HFILL }},
{ &hf_smb_response_in,
{ "Response in", "smb.response_in", FT_FRAMENUM, BASE_NONE,
NULL, 0, "The response to this packet is in this packet", HFILL }},
{ &hf_smb_continuation_to,
{ "Continuation to", "smb.continuation_to", FT_FRAMENUM, BASE_NONE,
NULL, 0, "This packet is a continuation to the packet in this frame", HFILL }},
{ &hf_smb_nt_status,
{ "NT Status", "smb.nt_status", FT_UINT32, BASE_HEX | BASE_EXT_STRING,
&NT_errors_ext, 0, "NT Status code", HFILL }},
{ &hf_smb_error_class,
{ "Error Class", "smb.error_class", FT_UINT8, BASE_HEX,
VALS(errcls_types), 0, "DOS Error Class", HFILL }},
{ &hf_smb_error_code,
{ "Error Code", "smb.error_code", FT_UINT16, BASE_HEX,
NULL, 0, "DOS Error Code", HFILL }},
{ &hf_smb_reserved,
{ "Reserved", "smb.reserved", FT_BYTES, BASE_NONE,
NULL, 0, "Reserved bytes, must be zero", HFILL }},
{ &hf_smb_sig,
{ "Signature", "smb.signature", FT_BYTES, BASE_NONE,
NULL, 0, "Signature bytes", HFILL }},
{ &hf_smb_key,
{ "Key", "smb.key", FT_UINT32, BASE_HEX,
NULL, 0, "SMB-over-IPX Key", HFILL }},
{ &hf_smb_session_id,
{ "Session ID", "smb.sessid", FT_UINT16, BASE_DEC,
NULL, 0, "SMB-over-IPX Session ID", HFILL }},
{ &hf_smb_sequence_num,
{ "Sequence Number", "smb.sequence_num", FT_UINT16, BASE_DEC,
NULL, 0, "SMB-over-IPX Sequence Number", HFILL }},
{ &hf_smb_group_id,
{ "Group ID", "smb.group_id", FT_UINT16, BASE_DEC,
NULL, 0, "SMB-over-IPX Group ID", HFILL }},
{ &hf_smb_pid,
{ "Process ID", "smb.pid", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_pid_high,
{ "Process ID High", "smb.pid.high", FT_UINT16, BASE_DEC,
NULL, 0, "Process ID High Bytes", HFILL }},
{ &hf_smb_tid,
{ "Tree ID", "smb.tid", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_uid,
{ "User ID", "smb.uid", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_mid,
{ "Multiplex ID", "smb.mid", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_flags,
{ "Flags", "smb.flags", FT_UINT8, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_flags_lock,
{ "Lock and Read", "smb.flags.lock", FT_BOOLEAN, 8,
TFS(&tfs_smb_flags_lock), 0x01, "Are Lock&Read and Write&Unlock operations supported?", HFILL }},
{ &hf_smb_flags_receive_buffer,
{ "Receive Buffer Posted", "smb.flags.receive_buffer", FT_BOOLEAN, 8,
TFS(&tfs_smb_flags_receive_buffer), 0x02, "Have receive buffers been reported?", HFILL }},
{ &hf_smb_flags_caseless,
{ "Case Sensitivity", "smb.flags.caseless", FT_BOOLEAN, 8,
TFS(&tfs_smb_flags_caseless), 0x08, "Are pathnames caseless or casesensitive?", HFILL }},
{ &hf_smb_flags_canon,
{ "Canonicalized Pathnames", "smb.flags.canon", FT_BOOLEAN, 8,
TFS(&tfs_smb_flags_canon), 0x10, "Are pathnames canonicalized?", HFILL }},
{ &hf_smb_flags_oplock,
{ "Oplocks", "smb.flags.oplock", FT_BOOLEAN, 8,
TFS(&tfs_smb_flags_oplock), 0x20, "Is an oplock requested/granted?", HFILL }},
{ &hf_smb_flags_notify,
{ "Notify", "smb.flags.notify", FT_BOOLEAN, 8,
TFS(&tfs_smb_flags_notify), 0x40, "Notify on open or all?", HFILL }},
{ &hf_smb_flags_response,
{ "Request/Response", "smb.flags.response", FT_BOOLEAN, 8,
TFS(&tfs_smb_flags_response), 0x80, "Is this a request or a response?", HFILL }},
{ &hf_smb_flags2,
{ "Flags2", "smb.flags2", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_flags2_long_names_allowed,
{ "Long Names Allowed", "smb.flags2.long_names_allowed", FT_BOOLEAN, 16,
TFS(&tfs_smb_flags2_long_names_allowed), 0x0001, "Are long file names allowed in the response?", HFILL }},
{ &hf_smb_flags2_ea,
{ "Extended Attributes", "smb.flags2.ea", FT_BOOLEAN, 16,
TFS(&tfs_smb_flags2_ea), 0x0002, "Are extended attributes supported?", HFILL }},
{ &hf_smb_flags2_sec_sig,
{ "Security Signatures", "smb.flags2.sec_sig", FT_BOOLEAN, 16,
TFS(&tfs_smb_flags2_sec_sig), 0x0004, "Are security signatures supported?", HFILL }},
{ &hf_smb_flags2_compressed,
{ "Compressed", "smb.flags2.compressed", FT_BOOLEAN, 16,
TFS(&tfs_smb_flags2_compressed), 0x0008, "Is compression requested?", HFILL }},
{ &hf_smb_flags2_sec_sig_required,
{ "Security Signatures Required", "smb.flags2.sec_sig_required", FT_BOOLEAN, 16,
TFS(&tfs_smb_flags2_sec_sig_required), 0x0010, "Are security signatures required?", HFILL }},
{ &hf_smb_flags2_long_names_used,
{ "Long Names Used", "smb.flags2.long_names_used", FT_BOOLEAN, 16,
TFS(&tfs_smb_flags2_long_names_used), 0x0040, "Are pathnames in this request long file names?", HFILL }},
{ &hf_smb_flags2_reparse_path,
{ "Reparse Path", "smb.flags2.reparse_path", FT_BOOLEAN, 16,
TFS(&tfs_smb_flags2_reparse_path), 0x0400, "The request uses a @GMT reparse path", HFILL }},
{ &hf_smb_flags2_esn,
{ "Extended Security Negotiation", "smb.flags2.esn", FT_BOOLEAN, 16,
TFS(&tfs_smb_flags2_esn), 0x0800, "Is extended security negotiation supported?", HFILL }},
{ &hf_smb_flags2_dfs,
{ "Dfs", "smb.flags2.dfs", FT_BOOLEAN, 16,
TFS(&tfs_smb_flags2_dfs), 0x1000, "Can pathnames be resolved using Dfs?", HFILL }},
{ &hf_smb_flags2_roe,
{ "Execute-only Reads", "smb.flags2.roe", FT_BOOLEAN, 16,
TFS(&tfs_smb_flags2_roe), 0x2000, "Will reads be allowed for execute-only files?", HFILL }},
{ &hf_smb_flags2_nt_error,
{ "Error Code Type", "smb.flags2.nt_error", FT_BOOLEAN, 16,
TFS(&tfs_smb_flags2_nt_error), 0x4000, "Are error codes NT or DOS format?", HFILL }},
{ &hf_smb_flags2_string,
{ "Unicode Strings", "smb.flags2.string", FT_BOOLEAN, 16,
TFS(&tfs_smb_flags2_string), 0x8000, "Are strings ASCII or Unicode?", HFILL }},
{ &hf_smb_buffer_format,
{ "Buffer Format", "smb.buffer_format", FT_UINT8, BASE_DEC,
VALS(buffer_format_vals), 0x0, "Buffer Format, type of buffer", HFILL }},
{ &hf_smb_dialect,
{ "Dialect", "smb.dialect", FT_STRING, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_dialect_name,
{ "Name", "smb.dialect.name", FT_STRING, BASE_NONE,
NULL, 0, "Name of dialect", HFILL }},
{ &hf_smb_dialect_index,
{ "Selected Index", "smb.dialect.index", FT_UINT16, BASE_DEC,
NULL, 0, "Index of selected dialect", HFILL }},
{ &hf_smb_max_trans_buf_size,
{ "Max Buffer Size", "smb.max_bufsize", FT_UINT32, BASE_DEC,
NULL, 0, "Maximum transmit buffer size", HFILL }},
{ &hf_smb_max_mpx_count,
{ "Max Mpx Count", "smb.max_mpx_count", FT_UINT16, BASE_DEC,
NULL, 0, "Maximum pending multiplexed requests", HFILL }},
{ &hf_smb_max_vcs_num,
{ "Max VCs", "smb.max_vcs", FT_UINT16, BASE_DEC,
NULL, 0, "Maximum VCs between client and server", HFILL }},
{ &hf_smb_session_key,
{ "Session Key", "smb.session_key", FT_UINT32, BASE_HEX,
NULL, 0, "Unique token identifying this session", HFILL }},
{ &hf_smb_server_timezone,
{ "Server Time Zone", "smb.server_timezone", FT_INT16, BASE_DEC,
NULL, 0, "Current timezone at server.", HFILL }},
{ &hf_smb_challenge_length,
{ "Challenge Length", "smb.challenge_length", FT_UINT16, BASE_DEC,
NULL, 0, "Challenge_length (must be 0 if not LM2.1 dialect)", HFILL }},
{ &hf_smb_challenge,
{ "Challenge", "smb.challenge", FT_BYTES, BASE_NONE,
NULL, 0, "Challenge Data (for LM2.1 dialect)", HFILL }},
{ &hf_smb_primary_domain,
{ "Primary Domain", "smb.primary_domain", FT_STRING, BASE_NONE,
NULL, 0, "The server's primary domain", HFILL }},
{ &hf_smb_server,
{ "Server", "smb.server", FT_STRING, BASE_NONE,
NULL, 0, "The name of the DC/server", HFILL }},
{ &hf_smb_max_raw_buf_size,
{ "Max Raw Buffer", "smb.max_raw", FT_UINT32, BASE_DEC,
NULL, 0, "Maximum raw buffer size", HFILL }},
{ &hf_smb_server_guid,
{ "Server GUID", "smb.server_guid", FT_GUID, BASE_NONE,
NULL, 0, "Globally unique identifier for this server", HFILL }},
{ &hf_smb_volume_guid,
{ "Volume GUID", "smb.volume_guid", FT_GUID, BASE_NONE,
NULL, 0, "Globally unique identifier for this volume", HFILL }},
{ &hf_smb_security_blob_len,
{ "Security Blob Length", "smb.security_blob_len", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_security_blob,
{ "Security Blob", "smb.security_blob", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_smb_sm16,
{ "Security Mode", "smb.sm", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_sm_mode16,
{ "Mode", "smb.sm.mode", FT_BOOLEAN, 16,
TFS(&tfs_sm_mode), SECURITY_MODE_MODE, "User or Share security mode?", HFILL }},
{ &hf_smb_sm_password16,
{ "Password", "smb.sm.password", FT_BOOLEAN, 16,
TFS(&tfs_sm_password), SECURITY_MODE_PASSWORD, "Encrypted or plaintext passwords?", HFILL }},
{ &hf_smb_sm,
{ "Security Mode", "smb.sm", FT_UINT8, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_sm_mode,
{ "Mode", "smb.sm.mode", FT_BOOLEAN, 8,
TFS(&tfs_sm_mode), SECURITY_MODE_MODE, "User or Share security mode?", HFILL }},
{ &hf_smb_sm_password,
{ "Password", "smb.sm.password", FT_BOOLEAN, 8,
TFS(&tfs_sm_password), SECURITY_MODE_PASSWORD, "Encrypted or plaintext passwords?", HFILL }},
{ &hf_smb_sm_signatures,
{ "Signatures", "smb.sm.signatures", FT_BOOLEAN, 8,
TFS(&tfs_sm_signatures), SECURITY_MODE_SIGNATURES, "Are security signatures enabled?", HFILL }},
{ &hf_smb_sm_sig_required,
{ "Sig Req", "smb.sm.sig_required", FT_BOOLEAN, 8,
TFS(&tfs_sm_sig_required), SECURITY_MODE_SIG_REQUIRED, "Are security signatures required?", HFILL }},
{ &hf_smb_rm,
{ "Raw Mode", "smb.rm", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_rm_read,
{ "Read Raw", "smb.rm.read", FT_BOOLEAN, 16,
TFS(&tfs_rm_read), RAWMODE_READ, "Is Read Raw supported?", HFILL }},
{ &hf_smb_rm_write,
{ "Write Raw", "smb.rm.write", FT_BOOLEAN, 16,
TFS(&tfs_rm_write), RAWMODE_WRITE, "Is Write Raw supported?", HFILL }},
{ &hf_smb_server_date_time,
{ "Server Date and Time", "smb.server_date_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "Current date and time at server", HFILL }},
{ &hf_smb_server_smb_date,
{ "Server Date", "smb.server_date_time.smb_date", FT_UINT16, BASE_HEX,
NULL, 0, "Current date at server, SMB_DATE format", HFILL }},
{ &hf_smb_server_smb_time,
{ "Server Time", "smb.server_date_time.smb_time", FT_UINT16, BASE_HEX,
NULL, 0, "Current time at server, SMB_TIME format", HFILL }},
{ &hf_smb_server_cap,
{ "Capabilities", "smb.server_cap", FT_UINT32, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_server_cap_raw_mode,
{ "Raw Mode", "smb.server_cap.raw_mode", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_raw_mode), SERVER_CAP_RAW_MODE, "Are Raw Read and Raw Write supported?", HFILL }},
{ &hf_smb_server_cap_mpx_mode,
{ "MPX Mode", "smb.server_cap.mpx_mode", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_mpx_mode), SERVER_CAP_MPX_MODE, "Are Read Mpx and Write Mpx supported?", HFILL }},
{ &hf_smb_server_cap_unicode,
{ "Unicode", "smb.server_cap.unicode", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_unicode), SERVER_CAP_UNICODE, "Are Unicode strings supported?", HFILL }},
{ &hf_smb_server_cap_large_files,
{ "Large Files", "smb.server_cap.large_files", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_large_files), SERVER_CAP_LARGE_FILES, "Are large files (>4GB) supported?", HFILL }},
{ &hf_smb_server_cap_nt_smbs,
{ "NT SMBs", "smb.server_cap.nt_smbs", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_nt_smbs), SERVER_CAP_NT_SMBS, "Are NT SMBs supported?", HFILL }},
{ &hf_smb_server_cap_rpc_remote_apis,
{ "RPC Remote APIs", "smb.server_cap.rpc_remote_apis", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_rpc_remote_apis), SERVER_CAP_RPC_REMOTE_APIS, "Are RPC Remote APIs supported?", HFILL }},
{ &hf_smb_server_cap_nt_status,
{ "NT Status Codes", "smb.server_cap.nt_status", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_nt_status), SERVER_CAP_STATUS32, "Are NT Status Codes supported?", HFILL }},
{ &hf_smb_server_cap_level_ii_oplocks,
{ "Level 2 Oplocks", "smb.server_cap.level_2_oplocks", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_level_ii_oplocks), SERVER_CAP_LEVEL_II_OPLOCKS, "Are Level 2 oplocks supported?", HFILL }},
{ &hf_smb_server_cap_lock_and_read,
{ "Lock and Read", "smb.server_cap.lock_and_read", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_lock_and_read), SERVER_CAP_LOCK_AND_READ, "Is Lock and Read supported?", HFILL }},
{ &hf_smb_server_cap_nt_find,
{ "NT Find", "smb.server_cap.nt_find", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_nt_find), SERVER_CAP_NT_FIND, "Is NT Find supported?", HFILL }},
{ &hf_smb_server_cap_dfs,
{ "Dfs", "smb.server_cap.dfs", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_dfs), SERVER_CAP_DFS, "Is Dfs supported?", HFILL }},
{ &hf_smb_server_cap_infolevel_passthru,
{ "Infolevel Passthru", "smb.server_cap.infolevel_passthru", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_infolevel_passthru), SERVER_CAP_INFOLEVEL_PASSTHRU, "Is NT information level request passthrough supported?", HFILL }},
{ &hf_smb_server_cap_large_readx,
{ "Large ReadX", "smb.server_cap.large_readx", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_large_readx), SERVER_CAP_LARGE_READX, "Is Large Read andX supported?", HFILL }},
{ &hf_smb_server_cap_large_writex,
{ "Large WriteX", "smb.server_cap.large_writex", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_large_writex), SERVER_CAP_LARGE_WRITEX, "Is Large Write andX supported?", HFILL }},
{ &hf_smb_server_cap_lwio,
{ "LWIO", "smb.server_cap.lwio", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_lwio), SERVER_CAP_LWIO,
"Is IOCTL/FSCTL supported", HFILL }},
{ &hf_smb_server_cap_unix,
{ "UNIX", "smb.server_cap.unix", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_unix), SERVER_CAP_UNIX , "Are UNIX extensions supported?", HFILL }},
{ &hf_smb_server_cap_compressed_data,
{ "Compressed Data", "smb.server_cap.compressed_data", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_compressed_data), SERVER_CAP_COMPRESSED_DATA, "Is compressed data transfer supported?", HFILL }},
{ &hf_smb_server_cap_dynamic_reauth,
{ "Dynamic Reauth", "smb.server_cap.dynamic_reauth", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_dynamic_reauth), SERVER_CAP_DYNAMIC_REAUTH,
"Is dynamic reauth supported?", HFILL }},
{ &hf_smb_server_cap_extended_security,
{ "Extended Security", "smb.server_cap.extended_security", FT_BOOLEAN, 32,
TFS(&tfs_server_cap_extended_security), SERVER_CAP_EXTENDED_SECURITY, "Are Extended security exchanges supported?", HFILL }},
{ &hf_smb_system_time,
{ "System Time", "smb.system.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unknown,
{ "Unknown Data", "smb.unknown_data", FT_BYTES, BASE_NONE,
NULL, 0, "Unknown Data. Should be implemented by someone", HFILL }},
{ &hf_smb_dir_name,
{ "Directory", "smb.dir_name", FT_STRING, BASE_NONE,
NULL, 0, "SMB Directory Name", HFILL }},
{ &hf_smb_echo_count,
{ "Echo Count", "smb.echo.count", FT_UINT16, BASE_DEC,
NULL, 0, "Number of times to echo data back", HFILL }},
{ &hf_smb_echo_data,
{ "Echo Data", "smb.echo.data", FT_BYTES, BASE_NONE,
NULL, 0, "Data for SMB Echo Request/Response", HFILL }},
{ &hf_smb_echo_seq_num,
{ "Echo Seq Num", "smb.echo.seq_num", FT_UINT16, BASE_DEC,
NULL, 0, "Sequence number for this echo response", HFILL }},
{ &hf_smb_max_buf_size,
{ "Max Buffer", "smb.max_buf", FT_UINT16, BASE_DEC,
NULL, 0, "Max client buffer size", HFILL }},
{ &hf_smb_path,
{ "Path", "smb.path", FT_STRING, BASE_NONE,
NULL, 0, "Path. Server name and share name", HFILL }},
{ &hf_smb_service,
{ "Service", "smb.service", FT_STRING, BASE_NONE,
NULL, 0, "Service name", HFILL }},
{ &hf_smb_password,
{ "Password", "smb.password", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_smb_ansi_password,
{ "ANSI Password", "smb.ansi_password", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unicode_password,
{ "Unicode Password", "smb.unicode_password", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_smb_move_flags,
{ "Flags", "smb.move.flags", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_move_flags_file,
{ "Must be file", "smb.move.flags.file", FT_BOOLEAN, 16,
TFS(&tfs_mf_file), 0x0001, "Must target be a file?", HFILL }},
{ &hf_smb_move_flags_dir,
{ "Must be directory", "smb.move.flags.dir", FT_BOOLEAN, 16,
TFS(&tfs_mf_dir), 0x0002, "Must target be a directory?", HFILL }},
{ &hf_smb_move_flags_verify,
{ "Verify writes", "smb.move.flags.verify", FT_BOOLEAN, 16,
TFS(&tfs_mf_verify), 0x0010, "Verify all writes?", HFILL }},
{ &hf_smb_files_moved,
{ "Files Moved", "smb.files_moved", FT_UINT16, BASE_DEC,
NULL, 0, "Number of files moved", HFILL }},
{ &hf_smb_copy_flags,
{ "Flags", "smb.copy.flags", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_copy_flags_file,
{ "Must be file", "smb.copy.flags.file", FT_BOOLEAN, 16,
TFS(&tfs_mf_file), 0x0001, "Must target be a file?", HFILL }},
{ &hf_smb_copy_flags_dir,
{ "Must be directory", "smb.copy.flags.dir", FT_BOOLEAN, 16,
TFS(&tfs_mf_dir), 0x0002, "Must target be a directory?", HFILL }},
{ &hf_smb_copy_flags_dest_mode,
{ "Destination mode", "smb.copy.flags.dest_mode", FT_BOOLEAN, 16,
TFS(&tfs_cf_mode), 0x0004, "Is destination in ASCII?", HFILL }},
{ &hf_smb_copy_flags_source_mode,
{ "Source mode", "smb.copy.flags.source_mode", FT_BOOLEAN, 16,
TFS(&tfs_cf_mode), 0x0008, "Is source in ASCII?", HFILL }},
{ &hf_smb_copy_flags_verify,
{ "Verify writes", "smb.copy.flags.verify", FT_BOOLEAN, 16,
TFS(&tfs_mf_verify), 0x0010, "Verify all writes?", HFILL }},
{ &hf_smb_copy_flags_tree_copy,
{ "Tree copy", "smb.copy.flags.tree_copy", FT_BOOLEAN, 16,
TFS(&tfs_cf_tree_copy), 0x0020, "Is copy a tree copy?", HFILL }},
{ &hf_smb_copy_flags_ea_action,
{ "EA action if EAs not supported on dest", "smb.copy.flags.ea_action", FT_BOOLEAN, 16,
TFS(&tfs_cf_ea_action), 0x0040, "Fail copy if source file has EAs and dest doesn't support EAs?", HFILL }},
{ &hf_smb_count,
{ "Count", "smb.count", FT_UINT32, BASE_DEC,
NULL, 0, "Count number of items/bytes", HFILL }},
{ &hf_smb_count_low,
{ "Count Low", "smb.count_low", FT_UINT16, BASE_DEC,
NULL, 0, "Count number of items/bytes, Low 16 bits", HFILL }},
{ &hf_smb_count_high,
{ "Count High (multiply with 64K)", "smb.count_high", FT_UINT16, BASE_DEC,
NULL, 0, "Count number of items/bytes, High 16 bits", HFILL }},
{ &hf_smb_file_name,
{ "File Name", "smb.file", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_smb_open_function,
{ "Open Function", "smb.open.function", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_open_function_create,
{ "Create", "smb.open.function.create", FT_BOOLEAN, 16,
TFS(&tfs_of_create), 0x0010, "Create file if it doesn't exist?", HFILL }},
{ &hf_smb_open_function_open,
{ "Open", "smb.open.function.open", FT_UINT16, BASE_DEC,
VALS(of_open), 0x0003, "Action to be taken on open if file exists", HFILL }},
{ &hf_smb_fid,
{ "FID", "smb.fid", FT_UINT16, BASE_HEX,
NULL, 0, "FID: File ID", HFILL }},
{ &hf_smb_file_attr_16bit,
{ "File Attributes", "smb.file_attribute", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_file_attr_8bit,
{ "File Attributes", "smb.file_attribute", FT_UINT8, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_file_attr_read_only_16bit,
{ "Read Only", "smb.file_attribute.read_only", FT_BOOLEAN, 16,
TFS(&tfs_file_attribute_read_only), SMB_FILE_ATTRIBUTE_READ_ONLY, "READ ONLY file attribute", HFILL }},
{ &hf_smb_file_attr_read_only_8bit,
{ "Read Only", "smb.file_attribute.read_only", FT_BOOLEAN, 8,
TFS(&tfs_file_attribute_read_only), SMB_FILE_ATTRIBUTE_READ_ONLY, "READ ONLY file attribute", HFILL }},
{ &hf_smb_file_attr_hidden_16bit,
{ "Hidden", "smb.file_attribute.hidden", FT_BOOLEAN, 16,
TFS(&tfs_file_attribute_hidden), SMB_FILE_ATTRIBUTE_HIDDEN, "HIDDEN file attribute", HFILL }},
{ &hf_smb_file_attr_hidden_8bit,
{ "Hidden", "smb.file_attribute.hidden", FT_BOOLEAN, 8,
TFS(&tfs_file_attribute_hidden), SMB_FILE_ATTRIBUTE_HIDDEN, "HIDDEN file attribute", HFILL }},
{ &hf_smb_file_attr_system_16bit,
{ "System", "smb.file_attribute.system", FT_BOOLEAN, 16,
TFS(&tfs_file_attribute_system), SMB_FILE_ATTRIBUTE_SYSTEM, "SYSTEM file attribute", HFILL }},
{ &hf_smb_file_attr_system_8bit,
{ "System", "smb.file_attribute.system", FT_BOOLEAN, 8,
TFS(&tfs_file_attribute_system), SMB_FILE_ATTRIBUTE_SYSTEM, "SYSTEM file attribute", HFILL }},
{ &hf_smb_file_attr_volume_16bit,
{ "Volume ID", "smb.file_attribute.volume", FT_BOOLEAN, 16,
TFS(&tfs_file_attribute_volume), SMB_FILE_ATTRIBUTE_VOLUME, "VOLUME file attribute", HFILL }},
{ &hf_smb_file_attr_volume_8bit,
{ "Volume ID", "smb.file_attribute.volume", FT_BOOLEAN, 8,
TFS(&tfs_file_attribute_volume), SMB_FILE_ATTRIBUTE_VOLUME, "VOLUME ID file attribute", HFILL }},
{ &hf_smb_file_attr_directory_16bit,
{ "Directory", "smb.file_attribute.directory", FT_BOOLEAN, 16,
TFS(&tfs_file_attribute_directory), SMB_FILE_ATTRIBUTE_DIRECTORY, "DIRECTORY file attribute", HFILL }},
{ &hf_smb_file_attr_directory_8bit,
{ "Directory", "smb.file_attribute.directory", FT_BOOLEAN, 8,
TFS(&tfs_file_attribute_directory), SMB_FILE_ATTRIBUTE_DIRECTORY, "DIRECTORY file attribute", HFILL }},
{ &hf_smb_file_attr_archive_16bit,
{ "Archive", "smb.file_attribute.archive", FT_BOOLEAN, 16,
TFS(&tfs_file_attribute_archive), SMB_FILE_ATTRIBUTE_ARCHIVE, "ARCHIVE file attribute", HFILL }},
{ &hf_smb_file_attr_archive_8bit,
{ "Archive", "smb.file_attribute.archive", FT_BOOLEAN, 8,
TFS(&tfs_file_attribute_archive), SMB_FILE_ATTRIBUTE_ARCHIVE, "ARCHIVE file attribute", HFILL }},
#if 0
{ &hf_smb_file_attr_device,
{ "Device", "smb.file_attribute.device", FT_BOOLEAN, 16,
TFS(&tfs_file_attribute_device), SMB_FILE_ATTRIBUTE_DEVICE, "Is this file a device?", HFILL }},
{ &hf_smb_file_attr_normal,
{ "Normal", "smb.file_attribute.normal", FT_BOOLEAN, 16,
TFS(&tfs_file_attribute_normal), SMB_FILE_ATTRIBUTE_NORMAL, "Is this a normal file?", HFILL }},
{ &hf_smb_file_attr_temporary,
{ "Temporary", "smb.file_attribute.temporary", FT_BOOLEAN, 16,
TFS(&tfs_file_attribute_temporary), SMB_FILE_ATTRIBUTE_TEMPORARY, "Is this a temporary file?", HFILL }},
{ &hf_smb_file_attr_sparse,
{ "Sparse", "smb.file_attribute.sparse", FT_BOOLEAN, 16,
TFS(&tfs_file_attribute_sparse), SMB_FILE_ATTRIBUTE_SPARSE, "Is this a sparse file?", HFILL }},
{ &hf_smb_file_attr_reparse,
{ "Reparse Point", "smb.file_attribute.reparse", FT_BOOLEAN, 16,
TFS(&tfs_file_attribute_reparse), SMB_FILE_ATTRIBUTE_REPARSE, "Does this file have an associated reparse point?", HFILL }},
{ &hf_smb_file_attr_compressed,
{ "Compressed", "smb.file_attribute.compressed", FT_BOOLEAN, 16,
TFS(&tfs_file_attribute_compressed), SMB_FILE_ATTRIBUTE_COMPRESSED, "Is this file compressed?", HFILL }},
{ &hf_smb_file_attr_offline,
{ "Offline", "smb.file_attribute.offline", FT_BOOLEAN, 16,
TFS(&tfs_file_attribute_offline), SMB_FILE_ATTRIBUTE_OFFLINE, "Is this file offline?", HFILL }},
{ &hf_smb_file_attr_not_content_indexed,
{ "Content Indexed", "smb.file_attribute.not_content_indexed", FT_BOOLEAN, 16,
TFS(&tfs_file_attribute_not_content_indexed), SMB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, "May this file be indexed by the content indexing service", HFILL }},
{ &hf_smb_file_attr_encrypted,
{ "Encrypted", "smb.file_attribute.encrypted", FT_BOOLEAN, 16,
TFS(&tfs_file_attribute_encrypted), SMB_FILE_ATTRIBUTE_ENCRYPTED, "Is this file encrypted?", HFILL }},
#endif
{ &hf_smb_file_size,
{ "File Size", "smb.file_size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_search_attribute,
{ "Search Attributes", "smb.search.attribute", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_search_attribute_read_only,
{ "Read Only", "smb.search.attribute.read_only", FT_BOOLEAN, 16,
TFS(&tfs_search_attribute_read_only), SMB_FILE_ATTRIBUTE_READ_ONLY, "READ ONLY search attribute", HFILL }},
{ &hf_smb_search_attribute_hidden,
{ "Hidden", "smb.search.attribute.hidden", FT_BOOLEAN, 16,
TFS(&tfs_search_attribute_hidden), SMB_FILE_ATTRIBUTE_HIDDEN, "HIDDEN search attribute", HFILL }},
{ &hf_smb_search_attribute_system,
{ "System", "smb.search.attribute.system", FT_BOOLEAN, 16,
TFS(&tfs_search_attribute_system), SMB_FILE_ATTRIBUTE_SYSTEM, "SYSTEM search attribute", HFILL }},
{ &hf_smb_search_attribute_volume,
{ "Volume ID", "smb.search.attribute.volume", FT_BOOLEAN, 16,
TFS(&tfs_search_attribute_volume), SMB_FILE_ATTRIBUTE_VOLUME, "VOLUME ID search attribute", HFILL }},
{ &hf_smb_search_attribute_directory,
{ "Directory", "smb.search.attribute.directory", FT_BOOLEAN, 16,
TFS(&tfs_search_attribute_directory), SMB_FILE_ATTRIBUTE_DIRECTORY, "DIRECTORY search attribute", HFILL }},
{ &hf_smb_search_attribute_archive,
{ "Archive", "smb.search.attribute.archive", FT_BOOLEAN, 16,
TFS(&tfs_search_attribute_archive), SMB_FILE_ATTRIBUTE_ARCHIVE, "ARCHIVE search attribute", HFILL }},
{ &hf_smb_access_mode,
{ "Access Mode", "smb.access.mode", FT_UINT16, BASE_DEC,
VALS(da_access_vals), 0x0007, NULL, HFILL }},
{ &hf_smb_access_sharing,
{ "Sharing Mode", "smb.access.sharing", FT_UINT16, BASE_DEC,
VALS(da_sharing_vals), 0x0070, NULL, HFILL }},
{ &hf_smb_access_locality,
{ "Locality", "smb.access.locality", FT_UINT16, BASE_DEC,
VALS(da_locality_vals), 0x0700, "Locality of reference", HFILL }},
{ &hf_smb_access_caching,
{ "Caching", "smb.access.caching", FT_BOOLEAN, 16,
TFS(&tfs_da_caching), 0x1000, "Caching mode?", HFILL }},
{ &hf_smb_desired_access,
{ "Desired Access", "smb.access.desired", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_granted_access,
{ "Granted Access", "smb.access.granted", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_access_writetru,
{ "Writethrough", "smb.access.writethrough", FT_BOOLEAN, 16,
TFS(&tfs_da_writetru), 0x4000, "Writethrough mode?", HFILL }},
{ &hf_smb_create_time,
{ "Created", "smb.create.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "Creation Time", HFILL }},
{ &hf_smb_modify_time,
{ "Modified", "smb.modify.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "Modification Time", HFILL }},
{ &hf_smb_backup_time,
{ "Backed-up", "smb.backup.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "Backup time", HFILL}},
{ &hf_smb_mac_alloc_block_count,
{ "Allocation Block Count", "smb.alloc.count", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL}},
{ &hf_smb_mac_alloc_block_size,
{ "Allocation Block Count", "smb.alloc.size", FT_UINT32, BASE_DEC,
NULL, 0, "Allocation Block Size", HFILL}},
{ &hf_smb_mac_free_block_count,
{ "Free Block Count", "smb.free_block.count", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL}},
{ &hf_smb_mac_root_file_count,
{ "Root File Count", "smb.root.file.count", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL}},
{ &hf_smb_mac_root_dir_count,
{ "Root Directory Count", "smb.root.dir.count", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL}},
{ &hf_smb_mac_file_count,
{ "Root File Count", "smb.file.count", FT_UINT32, BASE_DEC,
NULL, 0, "File Count", HFILL}},
{ &hf_smb_mac_dir_count,
{ "Root Directory Count", "smb.dir.count", FT_UINT32, BASE_DEC,
NULL, 0, "Directory Count", HFILL}},
{ &hf_smb_mac_sup,
{ "Mac Support Flags", "smb.mac", FT_UINT32, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_mac_sup_access_ctrl,
{ "Mac Access Control", "smb.mac.access_control", FT_BOOLEAN, 32,
TFS(&tfs_smb_mac_access_ctrl), 0x00000010, "Are Mac Access Control Supported", HFILL }},
{ &hf_smb_mac_sup_getset_comments,
{ "Get Set Comments", "smb.mac.get_set_comments", FT_BOOLEAN, 32,
TFS(&tfs_smb_mac_getset_comments), 0x00000020, "Are Mac Get Set Comments supported?", HFILL }},
{ &hf_smb_mac_sup_desktopdb_calls,
{ "Desktop DB Calls", "smb.mac.desktop_db_calls", FT_BOOLEAN, 32,
TFS(&tfs_smb_mac_desktopdb_calls), 0x00000040, "Are Macintosh Desktop DB Calls Supported?", HFILL }},
{ &hf_smb_mac_sup_unique_ids,
{ "Macintosh Unique IDs", "smb.mac.uids", FT_BOOLEAN, 32,
TFS(&tfs_smb_mac_unique_ids), 0x00000080, "Are Unique IDs supported", HFILL }},
{ &hf_smb_mac_sup_streams,
{ "Mac Streams", "smb.mac.streams_support", FT_BOOLEAN, 32,
TFS(&tfs_smb_mac_streams), 0x00000100, "Are Mac Extensions and streams supported?", HFILL }},
{ &hf_smb_create_dos_date,
{ "Create Date", "smb.create.smb.date", FT_UINT16, BASE_HEX,
NULL, 0, "Create Date, SMB_DATE format", HFILL }},
{ &hf_smb_create_dos_time,
{ "Create Time", "smb.create.smb.time", FT_UINT16, BASE_HEX,
NULL, 0, "Create Time, SMB_TIME format", HFILL }},
{ &hf_smb_last_write_time,
{ "Last Write", "smb.last_write.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "Time this file was last written to", HFILL }},
{ &hf_smb_last_write_dos_date,
{ "Last Write Date", "smb.last_write.smb.date", FT_UINT16, BASE_HEX,
NULL, 0, "Last Write Date, SMB_DATE format", HFILL }},
{ &hf_smb_last_write_dos_time,
{ "Last Write Time", "smb.last_write.smb.time", FT_UINT16, BASE_HEX,
NULL, 0, "Last Write Time, SMB_TIME format", HFILL }},
{ &hf_smb_old_file_name,
{ "Old File Name", "smb.old_file", FT_STRING, BASE_NONE,
NULL, 0, "Old File Name (When renaming a file)", HFILL }},
{ &hf_smb_offset,
{ "Offset", "smb.offset", FT_UINT32, BASE_DEC,
NULL, 0, "Offset in file", HFILL }},
{ &hf_smb_remaining,
{ "Remaining", "smb.remaining", FT_UINT32, BASE_DEC,
NULL, 0, "Remaining number of bytes", HFILL }},
{ &hf_smb_padding,
{ "Padding", "smb.padding", FT_BYTES, BASE_NONE,
NULL, 0, "Padding or unknown data", HFILL }},
{ &hf_smb_file_data,
{ "File Data", "smb.file_data", FT_BYTES, BASE_NONE,
NULL, 0, "Data read/written to the file", HFILL }},
#if 0
{ &hf_smb_raw_ea_data,
{ "EA Data", "smb.ea_data", FT_BYTES, BASE_NONE,
NULL, 0, "Data in EA list", HFILL }},
#endif
{ &hf_smb_mac_fndrinfo,
{ "Finder Info", "smb.mac.finderinfo", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL}},
{ &hf_smb_total_data_len,
{ "Total Data Length", "smb.total_data_len", FT_UINT16, BASE_DEC,
NULL, 0, "Total length of data", HFILL }},
{ &hf_smb_data_len,
{ "Data Length", "smb.data_len", FT_UINT16, BASE_DEC,
NULL, 0, "Length of data", HFILL }},
{ &hf_smb_data_len_low,
{ "Data Length Low", "smb.data_len_low", FT_UINT16, BASE_DEC,
NULL, 0, "Length of data, Low 16 bits", HFILL }},
{ &hf_smb_data_len_high,
{ "Data Length High (multiply with 64K)", "smb.data_len_high", FT_UINT16, BASE_DEC,
NULL, 0, "Length of data, High 16 bits", HFILL }},
{ &hf_smb_seek_mode,
{ "Seek Mode", "smb.seek_mode", FT_UINT16, BASE_DEC,
VALS(seek_mode_vals), 0, "Seek Mode, what type of seek", HFILL }},
{ &hf_smb_access_time,
{ "Last Access", "smb.access.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "Last Access Time", HFILL }},
{ &hf_smb_access_dos_date,
{ "Last Access Date", "smb.access.smb.date", FT_UINT16, BASE_HEX,
NULL, 0, "Last Access Date, SMB_DATE format", HFILL }},
{ &hf_smb_access_dos_time,
{ "Last Access Time", "smb.access.smb.time", FT_UINT16, BASE_HEX,
NULL, 0, "Last Access Time, SMB_TIME format", HFILL }},
{ &hf_smb_data_size,
{ "Data Size", "smb.data_size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_alloc_size,
{ "Allocation Size", "smb.alloc_size", FT_UINT32, BASE_DEC,
NULL, 0, "Number of bytes to reserve on create or truncate", HFILL }},
{ &hf_smb_max_count,
{ "Max Count", "smb.maxcount", FT_UINT16, BASE_DEC,
NULL, 0, "Maximum Count", HFILL }},
{ &hf_smb_max_count_low,
{ "Max Count Low", "smb.maxcount_low", FT_UINT16, BASE_DEC,
NULL, 0, "Maximum Count, Low 16 bits", HFILL }},
{ &hf_smb_max_count_high,
{ "Max Count High (multiply with 64K)", "smb.maxcount_high", FT_UINT16, BASE_DEC,
NULL, 0, "Maximum Count, High 16 bits", HFILL }},
{ &hf_smb_min_count,
{ "Min Count", "smb.mincount", FT_UINT16, BASE_DEC,
NULL, 0, "Minimum Count", HFILL }},
{ &hf_smb_timeout,
{ "Timeout", "smb.timeout", FT_UINT32, BASE_DEC,
NULL, 0, "Timeout in milliseconds", HFILL }},
{ &hf_smb_high_offset,
{ "High Offset", "smb.offset_high", FT_UINT32, BASE_DEC,
NULL, 0, "High 32 Bits Of File Offset", HFILL }},
{ &hf_smb_units,
{ "Total Units", "smb.units", FT_UINT16, BASE_DEC,
NULL, 0, "Total number of units at server", HFILL }},
{ &hf_smb_bpu,
{ "Blocks Per Unit", "smb.bpu", FT_UINT16, BASE_DEC,
NULL, 0, "Blocks per unit at server", HFILL }},
{ &hf_smb_blocksize,
{ "Block Size", "smb.blocksize", FT_UINT16, BASE_DEC,
NULL, 0, "Block size (in bytes) at server", HFILL }},
{ &hf_smb_freeunits,
{ "Free Units", "smb.free_units", FT_UINT16, BASE_DEC,
NULL, 0, "Number of free units at server", HFILL }},
{ &hf_smb_data_offset,
{ "Data Offset", "smb.data_offset", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_dcm,
{ "Data Compaction Mode", "smb.dcm", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_request_mask,
{ "Request Mask", "smb.request.mask", FT_UINT32, BASE_HEX,
NULL, 0, "Connectionless mode mask", HFILL }},
{ &hf_smb_response_mask,
{ "Response Mask", "smb.response.mask", FT_UINT32, BASE_HEX,
NULL, 0, "Connectionless mode mask", HFILL }},
{ &hf_smb_search_id,
{ "Search ID", "smb.search_id", FT_UINT16, BASE_HEX,
NULL, 0, "Search ID, handle for find operations", HFILL }},
{ &hf_smb_write_mode,
{ "Write Mode", "smb.write.mode", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_write_mode_write_through,
{ "Write Through", "smb.write.mode.write_through", FT_BOOLEAN, 16,
TFS(&tfs_write_mode_write_through), WRITE_MODE_WRITE_THROUGH, "Write through mode requested?", HFILL }},
{ &hf_smb_write_mode_return_remaining,
{ "Return Remaining", "smb.write.mode.return_remaining", FT_BOOLEAN, 16,
TFS(&tfs_write_mode_return_remaining), WRITE_MODE_RETURN_REMAINING, "Return remaining data responses?", HFILL }},
{ &hf_smb_write_mode_raw,
{ "Write Raw", "smb.write.mode.raw", FT_BOOLEAN, 16,
TFS(&tfs_write_mode_raw), WRITE_MODE_RAW, "Use WriteRawNamedPipe?", HFILL }},
{ &hf_smb_write_mode_message_start,
{ "Message Start", "smb.write.mode.message_start", FT_BOOLEAN, 16,
TFS(&tfs_write_mode_message_start), WRITE_MODE_MESSAGE_START, "Is this the start of a message?", HFILL }},
{ &hf_smb_write_mode_connectionless,
{ "Connectionless", "smb.write.mode.connectionless", FT_BOOLEAN, 16,
TFS(&tfs_write_mode_connectionless), WRITE_MODE_CONNECTIONLESS, "Connectionless mode requested?", HFILL }},
{ &hf_smb_resume_key_len,
{ "Resume Key Length", "smb.resume.key_len", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_resume_find_id,
{ "Find ID", "smb.resume.find_id", FT_UINT8, BASE_HEX,
NULL, 0, "Handle for Find operation", HFILL }},
{ &hf_smb_resume_server_cookie,
{ "Server Cookie", "smb.resume.server.cookie", FT_BYTES, BASE_NONE,
NULL, 0, "Cookie, must not be modified by the client", HFILL }},
{ &hf_smb_resume_client_cookie,
{ "Client Cookie", "smb.resume.client.cookie", FT_BYTES, BASE_NONE,
NULL, 0, "Cookie, must not be modified by the server", HFILL }},
{ &hf_smb_andxoffset,
{ "AndXOffset", "smb.andxoffset", FT_UINT16, BASE_DEC,
NULL, 0, "Offset to next command in this SMB packet", HFILL }},
{ &hf_smb_lock_type,
{ "Lock Type", "smb.lock.type", FT_UINT8, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_lock_type_large,
{ "Large Files", "smb.lock.type.large", FT_BOOLEAN, 8,
TFS(&tfs_lock_type_large), 0x10, "Large file locking requested?", HFILL }},
{ &hf_smb_lock_type_cancel,
{ "Cancel", "smb.lock.type.cancel", FT_BOOLEAN, 8,
TFS(&tfs_lock_type_cancel), 0x08, "Cancel outstanding lock requests?", HFILL }},
{ &hf_smb_lock_type_change,
{ "Change", "smb.lock.type.change", FT_BOOLEAN, 8,
TFS(&tfs_lock_type_change), 0x04, "Change type of lock?", HFILL }},
{ &hf_smb_lock_type_oplock,
{ "Oplock Break", "smb.lock.type.oplock_release", FT_BOOLEAN, 8,
TFS(&tfs_lock_type_oplock), 0x02, "Is this a notification of, or a response to, an oplock break?", HFILL }},
{ &hf_smb_lock_type_shared,
{ "Shared", "smb.lock.type.shared", FT_BOOLEAN, 8,
TFS(&tfs_lock_type_shared), 0x01, "Shared or exclusive lock requested?", HFILL }},
{ &hf_smb_locking_ol,
{ "Oplock Level", "smb.locking.oplock.level", FT_UINT8, BASE_DEC,
VALS(locking_ol_vals), 0, "Level of existing oplock at client (if any)", HFILL }},
{ &hf_smb_number_of_locks,
{ "Number of Locks", "smb.locking.num_locks", FT_UINT16, BASE_DEC,
NULL, 0, "Number of lock requests in this request", HFILL }},
{ &hf_smb_number_of_unlocks,
{ "Number of Unlocks", "smb.locking.num_unlocks", FT_UINT16, BASE_DEC,
NULL, 0, "Number of unlock requests in this request", HFILL }},
{ &hf_smb_lock_long_length,
{ "Length", "smb.lock.length", FT_UINT64, BASE_DEC,
NULL, 0, "Length of lock/unlock region", HFILL }},
{ &hf_smb_lock_long_offset,
{ "Offset", "smb.lock.offset", FT_UINT64, BASE_DEC,
NULL, 0, "Offset in the file of lock/unlock region", HFILL }},
{ &hf_smb_file_type,
{ "File Type", "smb.file_type", FT_UINT16, BASE_DEC,
VALS(filetype_vals), 0, "Type of file", HFILL }},
{ &hf_smb_ipc_state,
{ "IPC State", "smb.ipc_state", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_ipc_state_nonblocking,
{ "Nonblocking", "smb.ipc_state.nonblocking", FT_BOOLEAN, 16,
TFS(&tfs_ipc_state_nonblocking), 0x8000, "Is I/O to this pipe nonblocking?", HFILL }},
{ &hf_smb_ipc_state_endpoint,
{ "Endpoint", "smb.ipc_state.endpoint", FT_UINT16, BASE_DEC,
VALS(ipc_state_endpoint_vals), 0x4000, "Which end of the pipe this is", HFILL }},
{ &hf_smb_ipc_state_pipe_type,
{ "Pipe Type", "smb.ipc_state.pipe_type", FT_UINT16, BASE_DEC,
VALS(ipc_state_pipe_type_vals), 0x0c00, "What type of pipe this is", HFILL }},
{ &hf_smb_ipc_state_read_mode,
{ "Read Mode", "smb.ipc_state.read_mode", FT_UINT16, BASE_DEC,
VALS(ipc_state_read_mode_vals), 0x0300, "How this pipe should be read", HFILL }},
{ &hf_smb_ipc_state_icount,
{ "Icount", "smb.ipc_state.icount", FT_UINT16, BASE_DEC,
NULL, 0x00FF, "Count to control pipe instancing", HFILL }},
{ &hf_smb_server_fid,
{ "Server FID", "smb.server_fid", FT_UINT32, BASE_HEX,
NULL, 0, "Server unique File ID", HFILL }},
{ &hf_smb_open_flags,
{ "Flags", "smb.open.flags", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_open_flags_add_info,
{ "Additional Info", "smb.open.flags.add_info", FT_BOOLEAN, 16,
TFS(&tfs_open_flags_add_info), 0x0001, "Additional Information Requested?", HFILL }},
{ &hf_smb_open_flags_ex_oplock,
{ "Exclusive Oplock", "smb.open.flags.ex_oplock", FT_BOOLEAN, 16,
TFS(&tfs_open_flags_ex_oplock), 0x0002, "Exclusive Oplock Requested?", HFILL }},
{ &hf_smb_open_flags_batch_oplock,
{ "Batch Oplock", "smb.open.flags.batch_oplock", FT_BOOLEAN, 16,
TFS(&tfs_open_flags_batch_oplock), 0x0004, "Batch Oplock Requested?", HFILL }},
{ &hf_smb_open_flags_ealen,
{ "Total EA Len", "smb.open.flags.ealen", FT_BOOLEAN, 16,
TFS(&tfs_open_flags_ealen), 0x0008, "Total EA Len Requested?", HFILL }},
{ &hf_smb_open_action,
{ "Action", "smb.open.action", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_open_action_open,
{ "Open Action", "smb.open.action.open", FT_UINT16, BASE_DEC,
VALS(oa_open_vals), 0x0003, "Open Action, how the file was opened", HFILL }},
{ &hf_smb_open_action_lock,
{ "Exclusive Open", "smb.open.action.lock", FT_BOOLEAN, 16,
TFS(&tfs_oa_lock), 0x8000, "Is this file opened by another user?", HFILL }},
{ &hf_smb_vc_num,
{ "VC Number", "smb.vc", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_password_len,
{ "Password Length", "smb.pwlen", FT_UINT16, BASE_DEC,
NULL, 0, "Length of password", HFILL }},
{ &hf_smb_ansi_password_len,
{ "ANSI Password Length", "smb.ansi_pwlen", FT_UINT16, BASE_DEC,
NULL, 0, "Length of ANSI password", HFILL }},
{ &hf_smb_unicode_password_len,
{ "Unicode Password Length", "smb.unicode_pwlen", FT_UINT16, BASE_DEC,
NULL, 0, "Length of Unicode password", HFILL }},
{ &hf_smb_account,
{ "Account", "smb.account", FT_STRING, BASE_NONE,
NULL, 0, "Account, username", HFILL }},
{ &hf_smb_os,
{ "Native OS", "smb.native_os", FT_STRING, BASE_NONE,
NULL, 0, "Which OS we are running", HFILL }},
{ &hf_smb_lanman,
{ "Native LAN Manager", "smb.native_lanman", FT_STRING, BASE_NONE,
NULL, 0, "Which LANMAN protocol we are running", HFILL }},
{ &hf_smb_setup_action,
{ "Action", "smb.setup.action", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_setup_action_guest,
{ "Guest", "smb.setup.action.guest", FT_BOOLEAN, 16,
TFS(&tfs_setup_action_guest), 0x0001, "Client logged in as GUEST?", HFILL }},
{ &hf_smb_fs,
{ "Native File System", "smb.native_fs", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_smb_connect_flags,
{ "Flags", "smb.connect.flags", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_connect_flags_dtid,
{ "Disconnect TID", "smb.connect.flags.dtid", FT_BOOLEAN, 16,
TFS(&tfs_disconnect_tid), 0x0001, "Disconnect TID?", HFILL }},
{ &hf_smb_connect_flags_ext_sig,
{ "Extended Signature", "smb.connect.flags.extendedsig", FT_BOOLEAN, 16,
TFS(&tfs_extended_signature), 0x0004, "Extended signature?", HFILL }},
{ &hf_smb_connect_flags_ext_resp,
{ "Extended Response", "smb.connect.flags.extendedresp", FT_BOOLEAN, 16,
TFS(&tfs_extended_response), 0x0008, "Extended response?", HFILL }},
{ &hf_smb_connect_support,
{ "Optional Support", "smb.connect.support", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_connect_support_search,
{ "Search Bits", "smb.connect.support.search", FT_BOOLEAN, 16,
TFS(&tfs_connect_support_search), 0x0001, "Exclusive Search Bits supported?", HFILL }},
{ &hf_smb_connect_support_in_dfs,
{ "In Dfs", "smb.connect.support.dfs", FT_BOOLEAN, 16,
TFS(&tfs_connect_support_in_dfs), 0x0002, "Is this in a Dfs tree?", HFILL }},
{ &hf_smb_connect_support_csc_mask_vals,
{ "CSC Mask", "smb.connect.support.cscmask", FT_UINT16, BASE_DEC,
VALS(connect_support_csc_mask_vals), 0x000c, "CSC mask?", HFILL }},
{ &hf_smb_connect_support_uniquefilename,
{ "Unique File Name", "smb.connect.support.uniqfilename", FT_BOOLEAN, 16,
TFS(&tfs_connect_support_uniquefilename), 0x0010, "Unique file name supported?", HFILL }},
{ &hf_smb_connect_support_extended_signature,
{ "Extended Signatures", "smb.connect.support.extendedsig", FT_BOOLEAN, 16,
TFS(&tfs_connect_support_extended_signature), 0x0020, "Extended signatures?", HFILL }},
{ &hf_smb_max_setup_count,
{ "Max Setup Count", "smb.msc", FT_UINT8, BASE_DEC,
NULL, 0, "Maximum number of setup words to return", HFILL }},
{ &hf_smb_total_param_count,
{ "Total Parameter Count", "smb.tpc", FT_UINT32, BASE_DEC,
NULL, 0, "Total number of parameter bytes", HFILL }},
{ &hf_smb_total_data_count,
{ "Total Data Count", "smb.tdc", FT_UINT32, BASE_DEC,
NULL, 0, "Total number of data bytes", HFILL }},
{ &hf_smb_max_param_count,
{ "Max Parameter Count", "smb.mpc", FT_UINT32, BASE_DEC,
NULL, 0, "Maximum number of parameter bytes to return", HFILL }},
{ &hf_smb_max_data_count,
{ "Max Data Count", "smb.mdc", FT_UINT32, BASE_DEC,
NULL, 0, "Maximum number of data bytes to return", HFILL }},
{ &hf_smb_param_disp16,
{ "Parameter Displacement", "smb.pd", FT_UINT16, BASE_DEC,
NULL, 0, "Displacement of these parameter bytes", HFILL }},
{ &hf_smb_param_count16,
{ "Parameter Count", "smb.pc", FT_UINT16, BASE_DEC,
NULL, 0, "Number of parameter bytes in this buffer", HFILL }},
{ &hf_smb_param_offset16,
{ "Parameter Offset", "smb.po", FT_UINT16, BASE_DEC,
NULL, 0, "Offset (from header start) to parameters", HFILL }},
{ &hf_smb_param_disp32,
{ "Parameter Displacement", "smb.pd", FT_UINT32, BASE_DEC,
NULL, 0, "Displacement of these parameter bytes", HFILL }},
{ &hf_smb_param_count32,
{ "Parameter Count", "smb.pc", FT_UINT32, BASE_DEC,
NULL, 0, "Number of parameter bytes in this buffer", HFILL }},
{ &hf_smb_param_offset32,
{ "Parameter Offset", "smb.po", FT_UINT32, BASE_DEC,
NULL, 0, "Offset (from header start) to parameters", HFILL }},
{ &hf_smb_data_count16,
{ "Data Count", "smb.dc", FT_UINT16, BASE_DEC,
NULL, 0, "Number of data bytes in this buffer", HFILL }},
{ &hf_smb_data_disp16,
{ "Data Displacement", "smb.data_disp", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_data_offset16,
{ "Data Offset", "smb.data_offset", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_data_count32,
{ "Data Count", "smb.dc", FT_UINT32, BASE_DEC,
NULL, 0, "Number of data bytes in this buffer", HFILL }},
{ &hf_smb_data_disp32,
{ "Data Displacement", "smb.data_disp", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_data_offset32,
{ "Data Offset", "smb.data_offset", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_setup_count,
{ "Setup Count", "smb.sc", FT_UINT8, BASE_DEC,
NULL, 0, "Number of setup words in this buffer", HFILL }},
{ &hf_smb_nt_ioctl_isfsctl,
{ "IsFSctl", "smb.nt.ioctl.isfsctl", FT_UINT8, BASE_DEC,
VALS(nt_ioctl_isfsctl_vals), 0, "Is this a device IOCTL (FALSE) or FS Control (TRUE)", HFILL }},
{ &hf_smb_nt_ioctl_flags_completion_filter,
{ "Completion Filter", "smb.nt.ioctl.completion_filter", FT_UINT8, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_nt_ioctl_flags_root_handle,
{ "Root Handle", "smb.nt.ioctl.flags.root_handle", FT_BOOLEAN, 8,
TFS(&tfs_nt_ioctl_flags_root_handle), NT_IOCTL_FLAGS_ROOT_HANDLE, "Apply to this share or root Dfs share", HFILL }},
{ &hf_smb_nt_notify_action,
{ "Action", "smb.nt.notify.action", FT_UINT32, BASE_DEC,
VALS(nt_notify_action_vals), 0, "Which action caused this notify response", HFILL }},
{ &hf_smb_nt_notify_watch_tree,
{ "Watch Tree", "smb.nt.notify.watch_tree", FT_UINT8, BASE_DEC,
VALS(watch_tree_vals), 0, "Should Notify watch subdirectories also?", HFILL }},
{ &hf_smb_nt_notify_completion_filter,
{ "Completion Filter", "smb.nt.notify.completion_filter", FT_UINT32, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_nt_notify_file_name,
{ "File Name Change", "smb.nt.notify.file_name", FT_BOOLEAN, 32,
TFS(&tfs_nt_notify_file_name), NT_NOTIFY_FILE_NAME, "Notify on changes to file name", HFILL }},
{ &hf_smb_nt_notify_dir_name,
{ "Directory Name Change", "smb.nt.notify.dir_name", FT_BOOLEAN, 32,
TFS(&tfs_nt_notify_dir_name), NT_NOTIFY_DIR_NAME, "Notify on changes to directory name", HFILL }},
{ &hf_smb_nt_notify_attributes,
{ "Attribute Change", "smb.nt.notify.attributes", FT_BOOLEAN, 32,
TFS(&tfs_nt_notify_attributes), NT_NOTIFY_ATTRIBUTES, "Notify on changes to attributes", HFILL }},
{ &hf_smb_nt_notify_size,
{ "Size Change", "smb.nt.notify.size", FT_BOOLEAN, 32,
TFS(&tfs_nt_notify_size), NT_NOTIFY_SIZE, "Notify on changes to size", HFILL }},
{ &hf_smb_nt_notify_last_write,
{ "Last Write Change", "smb.nt.notify.last_write", FT_BOOLEAN, 32,
TFS(&tfs_nt_notify_last_write), NT_NOTIFY_LAST_WRITE, "Notify on changes to last write", HFILL }},
{ &hf_smb_nt_notify_last_access,
{ "Last Access Change", "smb.nt.notify.last_access", FT_BOOLEAN, 32,
TFS(&tfs_nt_notify_last_access), NT_NOTIFY_LAST_ACCESS, "Notify on changes to last access", HFILL }},
{ &hf_smb_nt_notify_creation,
{ "Created Change", "smb.nt.notify.creation", FT_BOOLEAN, 32,
TFS(&tfs_nt_notify_creation), NT_NOTIFY_CREATION, "Notify on changes to creation time", HFILL }},
{ &hf_smb_nt_notify_ea,
{ "EA Change", "smb.nt.notify.ea", FT_BOOLEAN, 32,
TFS(&tfs_nt_notify_ea), NT_NOTIFY_EA, "Notify on changes to Extended Attributes", HFILL }},
{ &hf_smb_nt_notify_security,
{ "Security Change", "smb.nt.notify.security", FT_BOOLEAN, 32,
TFS(&tfs_nt_notify_security), NT_NOTIFY_SECURITY, "Notify on changes to security settings", HFILL }},
{ &hf_smb_nt_notify_stream_name,
{ "Stream Name Change", "smb.nt.notify.stream_name", FT_BOOLEAN, 32,
TFS(&tfs_nt_notify_stream_name), NT_NOTIFY_STREAM_NAME, "Notify on changes to stream name?", HFILL }},
{ &hf_smb_nt_notify_stream_size,
{ "Stream Size Change", "smb.nt.notify.stream_size", FT_BOOLEAN, 32,
TFS(&tfs_nt_notify_stream_size), NT_NOTIFY_STREAM_SIZE, "Notify on changes of stream size", HFILL }},
{ &hf_smb_nt_notify_stream_write,
{ "Stream Write", "smb.nt.notify.stream_write", FT_BOOLEAN, 32,
TFS(&tfs_nt_notify_stream_write), NT_NOTIFY_STREAM_WRITE, "Notify on stream write?", HFILL }},
{ &hf_smb_root_dir_fid,
{ "Root FID", "smb.rfid", FT_UINT32, BASE_HEX,
NULL, 0, "Open is relative to this FID (if nonzero)", HFILL }},
{ &hf_smb_alloc_size64,
{ "Allocation Size", "smb.alloc_size64", FT_UINT64, BASE_DEC,
NULL, 0, "Number of bytes to reserve on create or truncate", HFILL }},
{ &hf_smb_nt_create_disposition,
{ "Disposition", "smb.create.disposition", FT_UINT32, BASE_DEC,
VALS(create_disposition_vals), 0, "Create disposition, what to do if the file does/does not exist", HFILL }},
{ &hf_smb_sd_length,
{ "SD Length", "smb.sd.length", FT_UINT32, BASE_DEC,
NULL, 0, "Total length of security descriptor", HFILL }},
{ &hf_smb_ea_list_length,
{ "EA List Length", "smb.ea.list_length", FT_UINT32, BASE_DEC,
NULL, 0, "Total length of extended attributes", HFILL }},
{ &hf_smb_ea_flags,
{ "EA Flags", "smb.ea.flags", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_ea_name_length,
{ "EA Name Length", "smb.ea.name_length", FT_UINT8, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_ea_data_length,
{ "EA Data Length", "smb.ea.data_length", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_ea_name,
{ "EA Name", "smb.ea.name", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_smb_ea_data,
{ "EA Data", "smb.ea.data", FT_BYTES, BASE_NONE|BASE_SHOW_ASCII_PRINTABLE,
NULL, 0, NULL, HFILL }},
{ &hf_smb_file_name_len,
{ "File Name Len", "smb.file_name_len", FT_UINT32, BASE_DEC,
NULL, 0, "Length of File Name", HFILL }},
{ &hf_smb_nt_impersonation_level,
{ "Impersonation", "smb.impersonation.level", FT_UINT32, BASE_DEC,
VALS(impersonation_level_vals), 0, "Impersonation level", HFILL }},
{ &hf_smb_nt_security_flags,
{ "Security Flags", "smb.security.flags", FT_UINT8, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_nt_security_flags_context_tracking,
{ "Context Tracking", "smb.security.flags.context_tracking", FT_BOOLEAN, 8,
TFS(&tfs_nt_security_flags_context_tracking), 0x01, "Is security tracking static or dynamic?", HFILL }},
{ &hf_smb_nt_security_flags_effective_only,
{ "Effective Only", "smb.security.flags.effective_only", FT_BOOLEAN, 8,
TFS(&tfs_nt_security_flags_effective_only), 0x02, "Are only enabled or all aspects uf the users SID available?", HFILL }},
{ &hf_smb_nt_access_mask_generic_read,
{ "Generic Read", "smb.access.generic_read", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_generic_read), 0x80000000, "Is generic read allowed for this object?", HFILL }},
{ &hf_smb_nt_access_mask_generic_write,
{ "Generic Write", "smb.access.generic_write", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_generic_write), 0x40000000, "Is generic write allowed for this object?", HFILL }},
{ &hf_smb_nt_access_mask_generic_execute,
{ "Generic Execute", "smb.access.generic_execute", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_generic_execute), 0x20000000, "Is generic execute allowed for this object?", HFILL }},
{ &hf_smb_nt_access_mask_generic_all,
{ "Generic All", "smb.access.generic_all", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_generic_all), 0x10000000, "Is generic all allowed for this attribute", HFILL }},
{ &hf_smb_nt_access_mask_maximum_allowed,
{ "Maximum Allowed", "smb.access.maximum_allowed", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_maximum_allowed), 0x02000000, "?", HFILL }},
{ &hf_smb_nt_access_mask_system_security,
{ "System Security", "smb.access.system_security", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_system_security), 0x01000000, "Access to a system ACL?", HFILL }},
{ &hf_smb_nt_access_mask_synchronize,
{ "Synchronize", "smb.access.synchronize", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_synchronize), 0x00100000, "Windows NT: synchronize access", HFILL }},
{ &hf_smb_nt_access_mask_write_owner,
{ "Write Owner", "smb.access.write_owner", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_write_owner), 0x00080000, "Can owner write to the object?", HFILL }},
{ &hf_smb_nt_access_mask_write_dac,
{ "Write DAC", "smb.access.write_dac", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_write_dac), 0x00040000, "Is write allowed to the owner group or ACLs?", HFILL }},
{ &hf_smb_nt_access_mask_read_control,
{ "Read Control", "smb.access.read_control", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_read_control), 0x00020000, "Are reads allowed of owner, group and ACL data of the SID?", HFILL }},
{ &hf_smb_nt_access_mask_delete,
{ "Delete", "smb.access.delete", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_delete), 0x00010000, "Can object be deleted", HFILL }},
{ &hf_smb_nt_access_mask_write_attributes,
{ "Write Attributes", "smb.access.write_attributes", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_write_attributes), 0x00000100, "Can object's attributes be written", HFILL }},
{ &hf_smb_nt_access_mask_read_attributes,
{ "Read Attributes", "smb.access.read_attributes", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_read_attributes), 0x00000080, "Can object's attributes be read", HFILL }},
{ &hf_smb_nt_access_mask_delete_child,
{ "Delete Child", "smb.access.delete_child", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_delete_child), 0x00000040, "Can object's subdirectories be deleted", HFILL }},
/*
* "Execute" for files, "traverse" for directories.
*/
{ &hf_smb_nt_access_mask_execute,
{ "Execute", "smb.access.execute", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_execute), 0x00000020, "Can object be executed (if file) or traversed (if directory)", HFILL }},
{ &hf_smb_nt_access_mask_write_ea,
{ "Write EA", "smb.access.write_ea", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_write_ea), 0x00000010, "Can object's extended attributes be written", HFILL }},
{ &hf_smb_nt_access_mask_read_ea,
{ "Read EA", "smb.access.read_ea", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_read_ea), 0x00000008, "Can object's extended attributes be read", HFILL }},
/*
* "Append data" for files, "add subdirectory" for directories,
* "create pipe instance" for named pipes.
*/
{ &hf_smb_nt_access_mask_append,
{ "Append", "smb.access.append", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_append), 0x00000004, "Can object's contents be appended to", HFILL }},
/*
* "Write data" for files and pipes, "add file" for directory.
*/
{ &hf_smb_nt_access_mask_write,
{ "Write", "smb.access.write", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_write), 0x00000002, "Can object's contents be written", HFILL }},
/*
* "Read data" for files and pipes, "list directory" for directory.
*/
{ &hf_smb_nt_access_mask_read,
{ "Read", "smb.access.read", FT_BOOLEAN, 32,
TFS(&tfs_nt_access_mask_read), 0x00000001, "Can object's contents be read", HFILL }},
{ &hf_smb_nt_create_bits_oplock,
{ "Exclusive Oplock", "smb.nt.create.oplock", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_bits_oplock), 0x00000002, "Is an oplock requested", HFILL }},
{ &hf_smb_nt_create_bits_boplock,
{ "Batch Oplock", "smb.nt.create.batch_oplock", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_bits_boplock), 0x00000004, "Is a batch oplock requested?", HFILL }},
{ &hf_smb_nt_create_bits_dir,
{ "Create Directory", "smb.nt.create.dir", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_bits_dir), 0x00000008, "Must target of open be a directory?", HFILL }},
{ &hf_smb_nt_create_bits_ext_resp,
{ "Extended Response", "smb.nt.create.ext", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_bits_ext_resp), 0x00000010, "Extended response required?", HFILL }},
{ &hf_smb_nt_create_options_directory_file,
{ "Directory", "smb.nt.create_options.directory", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_directory), 0x00000001, "Should file being opened/created be a directory?", HFILL }},
{ &hf_smb_nt_create_options_write_through,
{ "Write Through", "smb.nt.create_options.write_through", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_write_through), 0x00000002, "Should writes to the file write buffered data out before completing?", HFILL }},
{ &hf_smb_nt_create_options_sequential_only,
{ "Sequential Only", "smb.nt.create_options.sequential_only", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_sequential_only), 0x00000004, "Will access to this file only be sequential?", HFILL }},
{ &hf_smb_nt_create_options_no_intermediate_buffering,
{ "Intermediate Buffering", "smb.nt.create_options.intermediate_buffering", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_no_intermediate_buffering), 0x00000008, "Is intermediate buffering allowed?", HFILL }},
{ &hf_smb_nt_create_options_sync_io_alert,
{ "Sync I/O Alert", "smb.nt.create_options.sync_io_alert", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_sync_io_alert), 0x00000010, "All operations are performed synchronous", HFILL}},
{ &hf_smb_nt_create_options_sync_io_nonalert,
{ "Sync I/O Nonalert", "smb.nt.create_options.sync_io_nonalert", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_sync_io_nonalert), 0x00000020, "All operations are synchronous and may block", HFILL}},
{ &hf_smb_nt_create_options_non_directory_file,
{ "Non-Directory", "smb.nt.create_options.non_directory", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_non_directory), 0x00000040, "Should file being opened/created be a non-directory?", HFILL }},
{ &hf_smb_nt_create_options_create_tree_connection,
{ "Create Tree Connection", "smb.nt.create_options.create_tree_connection", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_create_tree_connection), 0x00000080, "Create Tree Connection flag", HFILL }},
{ &hf_smb_nt_create_options_complete_if_oplocked,
{ "Complete If Oplocked", "smb.nt.create_options.complete_if_oplocked", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_complete_if_oplocked), 0x00000100, "Complete if oplocked flag", HFILL }},
{ &hf_smb_nt_create_options_no_ea_knowledge,
{ "No EA Knowledge", "smb.nt.create_options.no_ea_knowledge", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_no_ea_knowledge), 0x00000200, "Does the client not understand extended attributes?", HFILL }},
{ &hf_smb_nt_create_options_eight_dot_three_only,
{ "8.3 Only", "smb.nt.create_options.eight_dot_three_only", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_eight_dot_three_only), 0x00000400, "Does the client understand only 8.3 filenames?", HFILL }},
{ &hf_smb_nt_create_options_random_access,
{ "Random Access", "smb.nt.create_options.random_access", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_random_access), 0x00000800, "Will the client be accessing the file randomly?", HFILL }},
{ &hf_smb_nt_create_options_delete_on_close,
{ "Delete On Close", "smb.nt.create_options.delete_on_close", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_delete_on_close), 0x00001000, "Should the file be deleted when closed?", HFILL }},
{ &hf_smb_nt_create_options_open_by_fileid,
{ "Open By FileID", "smb.nt.create_options.open_by_fileid", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_open_by_fileid), 0x00002000, "Open file by inode", HFILL }},
{ &hf_smb_nt_create_options_backup_intent,
{ "Backup Intent", "smb.nt.create_options.backup_intent", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_backup_intent), 0x00004000, "Is this opened by BACKUP ADMIN for backup intent?", HFILL }},
{ &hf_smb_nt_create_options_no_compression,
{ "No Compression", "smb.nt.create_options.no_compression", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_no_compression), 0x00008000, "Is compression allowed?", HFILL }},
{ &hf_smb_nt_create_options_reserve_opfilter,
{ "Reserve Opfilter", "smb.nt.create_options.reserve_opfilter", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_reserve_opfilter), 0x00100000, "Reserve Opfilter flag", HFILL }},
{ &hf_smb_nt_create_options_open_reparse_point,
{ "Open Reparse Point", "smb.nt.create_options.open_reparse_point", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_open_reparse_point), 0x00200000, "Is this an open of a reparse point or of the normal file?", HFILL }},
{ &hf_smb_nt_create_options_open_no_recall,
{ "Open No Recall", "smb.nt.create_options.open_no_recall", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_open_no_recall), 0x00400000, "Open no recall flag", HFILL }},
{ &hf_smb_nt_create_options_open_for_free_space_query,
{ "Open For Free Space query", "smb.nt.create_options.open_for_free_space_query", FT_BOOLEAN, 32,
TFS(&tfs_nt_create_options_open_for_free_space_query), 0x00800000, "Open For Free Space Query flag", HFILL }},
{ &hf_smb_nt_share_access_read,
{ "Read", "smb.share.access.read", FT_BOOLEAN, 32,
TFS(&tfs_nt_share_access_read), SHARE_ACCESS_READ, "Can the object be shared for reading?", HFILL }},
{ &hf_smb_nt_share_access_write,
{ "Write", "smb.share.access.write", FT_BOOLEAN, 32,
TFS(&tfs_nt_share_access_write), SHARE_ACCESS_WRITE, "Can the object be shared for write?", HFILL }},
{ &hf_smb_nt_share_access_delete,
{ "Delete", "smb.share.access.delete", FT_BOOLEAN, 32,
TFS(&tfs_nt_share_access_delete), SHARE_ACCESS_DELETE, NULL, HFILL }},
{ &hf_smb_file_eattr,
{ "File Attributes", "smb.file_attribute", FT_UINT32, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_file_eattr_read_only,
{ "Read Only", "smb.file_attribute.read_only", FT_BOOLEAN, 32,
TFS(&tfs_file_attribute_read_only), SMB_FILE_ATTRIBUTE_READ_ONLY, "READ ONLY file attribute", HFILL }},
{ &hf_smb_file_eattr_hidden,
{ "Hidden", "smb.file_attribute.hidden", FT_BOOLEAN, 32,
TFS(&tfs_file_attribute_hidden), SMB_FILE_ATTRIBUTE_HIDDEN, "HIDDEN file attribute", HFILL }},
{ &hf_smb_file_eattr_system,
{ "System", "smb.file_attribute.system", FT_BOOLEAN, 32,
TFS(&tfs_file_attribute_system), SMB_FILE_ATTRIBUTE_SYSTEM, "SYSTEM file attribute", HFILL }},
{ &hf_smb_file_eattr_volume,
{ "Volume ID", "smb.file_attribute.volume", FT_BOOLEAN, 32,
TFS(&tfs_file_attribute_volume), SMB_FILE_ATTRIBUTE_VOLUME, "VOLUME file attribute", HFILL }},
{ &hf_smb_file_eattr_directory,
{ "Directory", "smb.file_attribute.directory", FT_BOOLEAN, 32,
TFS(&tfs_file_attribute_directory), SMB_FILE_ATTRIBUTE_DIRECTORY, "DIRECTORY file attribute", HFILL }},
{ &hf_smb_file_eattr_archive,
{ "Archive", "smb.file_attribute.archive", FT_BOOLEAN, 32,
TFS(&tfs_file_attribute_archive), SMB_FILE_ATTRIBUTE_ARCHIVE, "ARCHIVE file attribute", HFILL }},
{ &hf_smb_file_eattr_device,
{ "Device", "smb.file_attribute.device", FT_BOOLEAN, 32,
TFS(&tfs_file_attribute_device), SMB_FILE_ATTRIBUTE_DEVICE, "Is this file a device?", HFILL }},
{ &hf_smb_file_eattr_normal,
{ "Normal", "smb.file_attribute.normal", FT_BOOLEAN, 32,
TFS(&tfs_file_attribute_normal), SMB_FILE_ATTRIBUTE_NORMAL, "Is this a normal file?", HFILL }},
{ &hf_smb_file_eattr_temporary,
{ "Temporary", "smb.file_attribute.temporary", FT_BOOLEAN, 32,
TFS(&tfs_file_attribute_temporary), SMB_FILE_ATTRIBUTE_TEMPORARY, "Is this a temporary file?", HFILL }},
{ &hf_smb_file_eattr_sparse,
{ "Sparse", "smb.file_attribute.sparse", FT_BOOLEAN, 32,
TFS(&tfs_file_attribute_sparse), SMB_FILE_ATTRIBUTE_SPARSE, "Is this a sparse file?", HFILL }},
{ &hf_smb_file_eattr_reparse,
{ "Reparse Point", "smb.file_attribute.reparse", FT_BOOLEAN, 32,
TFS(&tfs_file_attribute_reparse), SMB_FILE_ATTRIBUTE_REPARSE, "Does this file have an associated reparse point?", HFILL }},
{ &hf_smb_file_eattr_compressed,
{ "Compressed", "smb.file_attribute.compressed", FT_BOOLEAN, 32,
TFS(&tfs_file_attribute_compressed), SMB_FILE_ATTRIBUTE_COMPRESSED, "Is this file compressed?", HFILL }},
{ &hf_smb_file_eattr_offline,
{ "Offline", "smb.file_attribute.offline", FT_BOOLEAN, 32,
TFS(&tfs_file_attribute_offline), SMB_FILE_ATTRIBUTE_OFFLINE, "Is this file offline?", HFILL }},
{ &hf_smb_file_eattr_not_content_indexed,
{ "Content Indexed", "smb.file_attribute.not_content_indexed", FT_BOOLEAN, 32,
TFS(&tfs_file_attribute_not_content_indexed), SMB_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, "May this file be indexed by the content indexing service", HFILL }},
{ &hf_smb_file_eattr_encrypted,
{ "Encrypted", "smb.file_attribute.encrypted", FT_BOOLEAN, 32,
TFS(&tfs_file_attribute_encrypted), SMB_FILE_ATTRIBUTE_ENCRYPTED, "Is this file encrypted?", HFILL }},
{ &hf_smb_size_returned_quota_data,
{ "Size of returned Quota data", "smb.size_returned_quota_data", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_sec_desc_len,
{ "NT Security Descriptor Length", "smb.sec_desc_len", FT_UINT32, BASE_DEC,
NULL, 0, "Security Descriptor Length", HFILL }},
{ &hf_smb_nt_qsd,
{ "Security Information", "smb.nt_qsd", FT_UINT32, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_nt_qsd_owner,
{ "Owner", "smb.nt_qsd.owner", FT_BOOLEAN, 32,
TFS(&tfs_nt_qsd_owner), NT_QSD_OWNER, "Is owner security information being queried?", HFILL }},
{ &hf_smb_nt_qsd_group,
{ "Group", "smb.nt_qsd.group", FT_BOOLEAN, 32,
TFS(&tfs_nt_qsd_group), NT_QSD_GROUP, "Is group security information being queried?", HFILL }},
{ &hf_smb_nt_qsd_dacl,
{ "DACL", "smb.nt_qsd.dacl", FT_BOOLEAN, 32,
TFS(&tfs_nt_qsd_dacl), NT_QSD_DACL, "Is DACL security information being queried?", HFILL }},
{ &hf_smb_nt_qsd_sacl,
{ "SACL", "smb.nt_qsd.sacl", FT_BOOLEAN, 32,
TFS(&tfs_nt_qsd_sacl), NT_QSD_SACL, "Is SACL security information being queried?", HFILL }},
{ &hf_smb_extended_attributes,
{ "Extended Attributes", "smb.ext_attr", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_smb_oplock_level,
{ "Oplock level", "smb.oplock.level", FT_UINT8, BASE_DEC,
VALS(oplock_level_vals), 0, "Level of oplock granted", HFILL }},
{ &hf_smb_response_type,
{ "Response type", "smb.response_type", FT_UINT8, BASE_HEX,
VALS(response_type_vals), 0, "NT Transaction Create response type", HFILL }},
{ &hf_smb_create_action,
{ "Create action", "smb.create.action", FT_UINT32, BASE_DEC,
VALS(oa_open_vals), 0, "Type of action taken", HFILL }},
{ &hf_smb_file_id,
{ "Server unique file ID", "smb.create.file_id", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_file_id_64bit,
{ "Server unique 64-bit file ID", "smb.create.file_id_64b", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_ea_error_offset,
{ "EA Error offset", "smb.ea.error_offset", FT_UINT32, BASE_DEC,
NULL, 0, "Offset into EA list if EA error", HFILL }},
{ &hf_smb_end_of_file,
{ "End Of File", "smb.end_of_file", FT_UINT64, BASE_DEC,
NULL, 0, "Offset to the first free byte in the file", HFILL }},
{ &hf_smb_replace,
{ "Replace", "smb.replace", FT_BOOLEAN, BASE_NONE,
TFS(&tfs_smb_replace), 0x0, "Remove target if it exists?", HFILL }},
{ &hf_smb_root_dir_handle,
{ "Root Directory Handle", "smb.root_dir_handle", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_target_name_len,
{ "Target name length", "smb.target_name_len", FT_UINT32, BASE_DEC,
NULL, 0, "Length of target file name", HFILL }},
{ &hf_smb_target_name,
{ "Target name", "smb.target_name", FT_STRING, BASE_NONE,
NULL, 0, "Target file name", HFILL }},
{ &hf_smb_device_type,
{ "Device Type", "smb.device.type", FT_UINT32, BASE_HEX | BASE_EXT_STRING,
&device_type_vals_ext, 0, "Type of device", HFILL }},
{ &hf_smb_is_directory,
{ "Is Directory", "smb.is_directory", FT_UINT8, BASE_DEC,
VALS(is_directory_vals), 0, "Is this object a directory?", HFILL }},
{ &hf_smb_next_entry_offset,
{ "Next Entry Offset", "smb.next_entry_offset", FT_UINT32, BASE_DEC,
NULL, 0, "Offset to next entry", HFILL }},
{ &hf_smb_change_time,
{ "Change", "smb.change.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "Last Change Time", HFILL }},
{ &hf_smb_setup_len,
{ "Setup Len", "smb.print.setup.len", FT_UINT16, BASE_DEC,
NULL, 0, "Length of printer setup data", HFILL }},
{ &hf_smb_print_mode,
{ "Mode", "smb.print.mode", FT_UINT16, BASE_DEC,
VALS(print_mode_vals), 0, "Text or Graphics mode", HFILL }},
{ &hf_smb_print_identifier,
{ "Identifier", "smb.print.identifier", FT_STRING, BASE_NONE,
NULL, 0, "Identifier string for this print job", HFILL }},
{ &hf_smb_restart_index,
{ "Restart Index", "smb.print.restart_index", FT_UINT16, BASE_DEC,
NULL, 0, "Index of entry after last returned", HFILL }},
{ &hf_smb_print_queue_date,
{ "Queued", "smb.print.queued.date", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "Date when this entry was queued", HFILL }},
{ &hf_smb_print_queue_dos_date,
{ "Queued Date", "smb.print.queued.smb.date", FT_UINT16, BASE_HEX,
NULL, 0, "Date when this print job was queued, SMB_DATE format", HFILL }},
{ &hf_smb_print_queue_dos_time,
{ "Queued Time", "smb.print.queued.smb.time", FT_UINT16, BASE_HEX,
NULL, 0, "Time when this print job was queued, SMB_TIME format", HFILL }},
{ &hf_smb_print_status,
{ "Status", "smb.print.status", FT_UINT8, BASE_HEX,
VALS(print_status_vals), 0, "Status of this entry", HFILL }},
{ &hf_smb_print_spool_file_number,
{ "Spool File Number", "smb.print.spool.file_number", FT_UINT16, BASE_DEC,
NULL, 0, "Spool File Number, assigned by the spooler", HFILL }},
{ &hf_smb_print_spool_file_size,
{ "Spool File Size", "smb.print.spool.file_size", FT_UINT32, BASE_DEC,
NULL, 0, "Number of bytes in spool file", HFILL }},
{ &hf_smb_print_spool_file_name,
{ "Name", "smb.print.spool.name", FT_STRINGZ, BASE_NONE,
NULL, 0, "Name of client that submitted this job", HFILL }},
{ &hf_smb_start_index,
{ "Start Index", "smb.print.start_index", FT_UINT16, BASE_DEC,
NULL, 0, "First queue entry to return", HFILL }},
{ &hf_smb_originator_name,
{ "Originator Name", "smb.originator_name", FT_STRINGZ, BASE_NONE,
NULL, 0, "Name of sender of message", HFILL }},
{ &hf_smb_destination_name,
{ "Destination Name", "smb.destination_name", FT_STRINGZ, BASE_NONE,
NULL, 0, "Name of recipient of message", HFILL }},
{ &hf_smb_message_len,
{ "Message Len", "smb.message.len", FT_UINT16, BASE_DEC,
NULL, 0, "Length of message", HFILL }},
{ &hf_smb_message,
{ "Message", "smb.message", FT_STRING, BASE_NONE,
NULL, 0, "Message text", HFILL }},
{ &hf_smb_mgid,
{ "Message Group ID", "smb.mgid", FT_UINT16, BASE_DEC,
NULL, 0, "Message group ID for multi-block messages", HFILL }},
{ &hf_smb_forwarded_name,
{ "Forwarded Name", "smb.forwarded_name", FT_STRINGZ, BASE_NONE,
NULL, 0, "Recipient name being forwarded", HFILL }},
{ &hf_smb_machine_name,
{ "Machine Name", "smb.machine_name", FT_STRINGZ, BASE_NONE,
NULL, 0, "Name of target machine", HFILL }},
{ &hf_smb_cancel_to,
{ "Cancel to", "smb.cancel_to", FT_FRAMENUM, BASE_NONE,
NULL, 0, "This packet is a cancellation of the packet in this frame", HFILL }},
{ &hf_smb_trans_name,
{ "Transaction Name", "smb.trans_name", FT_STRING, BASE_NONE,
NULL, 0, "Name of transaction", HFILL }},
{ &hf_smb_transaction_flags,
{ "Flags", "smb.transaction.flags", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_transaction_flags_dtid,
{ "Disconnect TID", "smb.transaction.flags.dtid", FT_BOOLEAN, 16,
TFS(&tfs_tf_dtid), 0x0001, "Disconnect TID?", HFILL }},
{ &hf_smb_transaction_flags_owt,
{ "One Way Transaction", "smb.transaction.flags.owt", FT_BOOLEAN, 16,
TFS(&tfs_tf_owt), 0x0002, "One Way Transaction (no response)?", HFILL }},
{ &hf_smb_search_count,
{ "Search Count", "smb.search_count", FT_UINT16, BASE_DEC,
NULL, 0, "Maximum number of search entries to return", HFILL }},
{ &hf_smb_search_pattern,
{ "Search Pattern", "smb.search_pattern", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_smb_ff2,
{ "Flags", "smb.find_first2.flags", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_ff2_backup,
{ "Backup Intent", "smb.find_first2.flags.backup", FT_BOOLEAN, 16,
TFS(&tfs_ff2_backup), 0x0010, "Find with backup intent", HFILL }},
{ &hf_smb_ff2_continue,
{ "Continue", "smb.find_first2.flags.continue", FT_BOOLEAN, 16,
TFS(&tfs_ff2_continue), 0x0008, "Continue search from previous ending place", HFILL }},
{ &hf_smb_ff2_resume,
{ "Resume", "smb.find_first2.flags.resume", FT_BOOLEAN, 16,
TFS(&tfs_ff2_resume), FF2_RESUME, "Return resume keys for each entry found", HFILL }},
{ &hf_smb_ff2_close_eos,
{ "Close on EOS", "smb.find_first2.flags.eos", FT_BOOLEAN, 16,
TFS(&tfs_ff2_close_eos), 0x0002, "Close search if end of search reached", HFILL }},
{ &hf_smb_ff2_close,
{ "Close", "smb.find_first2.flags.close", FT_BOOLEAN, 16,
TFS(&tfs_ff2_close), 0x0001, "Close search after this request", HFILL }},
{ &hf_smb_ff2_information_level,
{ "Level of Interest", "smb.ff2_loi", FT_UINT16, BASE_DEC,
VALS(ff2_il_vals), 0, "Level of interest for FIND_FIRST2 command", HFILL }},
{ &hf_smb_qpi_loi,
{ "Level of Interest", "smb.qpi_loi", FT_UINT16, BASE_DEC,
VALS(qpi_loi_vals), 0, "Level of interest for TRANSACTION[2] QUERY_{FILE,PATH}_INFO commands", HFILL }},
{ &hf_smb_spi_loi,
{ "Level of Interest", "smb.spi_loi", FT_UINT16, BASE_DEC | BASE_EXT_STRING,
&spi_loi_vals_ext, 0, "Level of interest for TRANSACTION[2] SET_{FILE,PATH}_INFO commands", HFILL }},
#if 0
{ &hf_smb_sfi,
{ "IO Flag", "smb.sfi_flags", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_sfi_writetru,
{ "Writethrough", "smb.sfi_writethrough", FT_BOOLEAN, 16,
TFS(&tfs_da_writetru), 0x0010, "Writethrough mode?", HFILL }},
{ &hf_smb_sfi_caching,
{ "Caching", "smb.sfi_caching", FT_BOOLEAN, 16,
TFS(&tfs_da_caching), 0x0020, "Caching mode?", HFILL }},
#endif
{ &hf_smb_storage_type,
{ "Storage Type", "smb.storage_type", FT_UINT32, BASE_DEC,
NULL, 0, "Type of storage", HFILL }},
{ &hf_smb_resume,
{ "Resume Key", "smb.resume", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_max_referral_level,
{ "Max Referral Level", "smb.max_referral_level", FT_UINT16, BASE_DEC,
NULL, 0, "Latest referral version number understood", HFILL }},
{ &hf_smb_qfsi_information_level,
{ "Level of Interest", "smb.qfsi_loi", FT_UINT16, BASE_HEX | BASE_EXT_STRING,
&qfsi_vals_ext, 0, "Level of interest for QUERY_FS_INFORMATION2 command", HFILL }},
{ &hf_smb_sfsi_information_level,
{ "Level of Interest", "smb.sfsi_loi", FT_UINT16, BASE_HEX,
VALS(sfsi_vals), 0, "Level of interest for SET_FS_INFORMATION2 command", HFILL }},
{ &hf_smb_nt_rename_level,
{ "Level of Interest", "smb.ntr_loi", FT_UINT16, BASE_DEC,
VALS(nt_rename_vals), 0, "NT Rename level", HFILL }},
{ &hf_smb_cluster_count,
{ "Cluster count", "smb.ntr_clu", FT_UINT32, BASE_DEC,
NULL, 0, "Number of clusters", HFILL }},
{ &hf_smb_number_of_links,
{ "Link Count", "smb.link_count", FT_UINT32, BASE_DEC,
NULL, 0, "Number of hard links to the file", HFILL }},
{ &hf_smb_delete_pending,
{ "Delete Pending", "smb.delete_pending", FT_UINT16, BASE_DEC,
VALS(delete_pending_vals), 0, "Is this object about to be deleted?", HFILL }},
{ &hf_smb_index_number,
{ "Index Number", "smb.index_number", FT_UINT64, BASE_HEX,
NULL, 0, "File system unique identifier", HFILL }},
{ &hf_smb_position,
{ "Position", "smb.position", FT_UINT64, BASE_DEC,
NULL, 0, "File position", HFILL }},
#if 0
{ &hf_smb_current_offset,
{ "Current Offset", "smb.offset", FT_UINT64, BASE_DEC,
NULL, 0, "Current offset in the file", HFILL }},
#endif
{ &hf_smb_t2_alignment,
{ "Alignment", "smb.alignment", FT_UINT32, BASE_DEC,
VALS(alignment_vals), 0, "What alignment do we require for buffers", HFILL }},
{ &hf_smb_t2_stream_name_length,
{ "Stream Name Length", "smb.stream_name_len", FT_UINT32, BASE_DEC,
NULL, 0, "Length of stream name", HFILL }},
{ &hf_smb_t2_stream_size,
{ "Stream Size", "smb.stream_size", FT_UINT64, BASE_DEC,
NULL, 0, "Size of the stream in number of bytes", HFILL }},
{ &hf_smb_t2_stream_name,
{ "Stream Name", "smb.stream_name", FT_STRING, BASE_NONE,
NULL, 0, "Name of the stream", HFILL }},
{ &hf_smb_t2_compressed_file_size,
{ "Compressed Size", "smb.compressed.file_size", FT_UINT64, BASE_DEC,
NULL, 0, "Size of the compressed file", HFILL }},
{ &hf_smb_t2_compressed_format,
{ "Compression Format", "smb.compressed.format", FT_UINT16, BASE_DEC,
NULL, 0, "Compression algorithm used", HFILL }},
{ &hf_smb_t2_compressed_unit_shift,
{ "Unit Shift", "smb.compressed.unit_shift", FT_UINT8, BASE_DEC,
NULL, 0, "Size of the stream in number of bytes", HFILL }},
{ &hf_smb_t2_compressed_chunk_shift,
{ "Chunk Shift", "smb.compressed.chunk_shift", FT_UINT8, BASE_DEC,
NULL, 0, "Allocated size of the stream in number of bytes", HFILL }},
{ &hf_smb_t2_compressed_cluster_shift,
{ "Cluster Shift", "smb.compressed.cluster_shift", FT_UINT8, BASE_DEC,
NULL, 0, "Allocated size of the stream in number of bytes", HFILL }},
{ &hf_smb_t2_marked_for_deletion,
{ "Marked for Deletion", "smb.marked_for_deletion", FT_BOOLEAN, BASE_NONE,
TFS(&tfs_marked_for_deletion), 0x0, "Marked for deletion?", HFILL }},
{ &hf_smb_dfs_path_consumed,
{ "Path Consumed", "smb.dfs.path_consumed", FT_UINT16, BASE_DEC,
NULL, 0, "Number of RequestFilename bytes client", HFILL }},
{ &hf_smb_dfs_num_referrals,
{ "Num Referrals", "smb.dfs.num_referrals", FT_UINT16, BASE_DEC,
NULL, 0, "Number of referrals in this pdu", HFILL }},
{ &hf_smb_get_dfs_flags,
{ "Flags", "smb.dfs.flags", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_get_dfs_server_hold_storage,
{ "Hold Storage", "smb.dfs.flags.server_hold_storage", FT_BOOLEAN, 16,
TFS(&tfs_get_dfs_server_hold_storage), 0x0002, "The servers in referrals should hold storage for the file", HFILL }},
{ &hf_smb_get_dfs_fielding,
{ "Fielding", "smb.dfs.flags.fielding", FT_BOOLEAN, 16,
TFS(&tfs_get_dfs_fielding), 0x0001, "The servers in referrals are capable of fielding", HFILL }},
{ &hf_smb_dfs_referral_version,
{ "Version", "smb.dfs.referral.version", FT_UINT16, BASE_DEC,
NULL, 0, "Version of referral element", HFILL }},
{ &hf_smb_dfs_referral_size,
{ "Size", "smb.dfs.referral.size", FT_UINT16, BASE_DEC,
NULL, 0, "Size of referral element", HFILL }},
{ &hf_smb_dfs_referral_server_type,
{ "Server Type", "smb.dfs.referral.server.type", FT_UINT16, BASE_DEC,
VALS(dfs_referral_server_type_vals), 0, "Type of referral server", HFILL }},
{ &hf_smb_dfs_referral_flags,
{ "Flags", "smb.dfs.referral.flags", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_dfs_referral_flags_name_list_referral,
{ "NameListReferral", "smb.dfs.referral.flags.name_list_referral", FT_BOOLEAN, 16,
TFS(&tfs_dfs_referral_flags_name_list_referral), REFENT_FLAGS_NAME_LIST_REFERRAL, "Is a domain/DC referral response?", HFILL }},
{ &hf_smb_dfs_referral_flags_target_set_boundary,
{ "TargetSetBoundary", "smb.dfs.referral.flags.target_set_boundary", FT_BOOLEAN, 16,
TFS(&tfs_dfs_referral_flags_target_set_boundary), REFENT_FLAGS_TARGET_SET_BOUNDARY, "Is this a first target in the target set?", HFILL }},
{ &hf_smb_dfs_referral_node_offset,
{ "Node Offset", "smb.dfs.referral.node_offset", FT_UINT16, BASE_DEC,
NULL, 0, "Offset of name of entity to visit next", HFILL }},
{ &hf_smb_dfs_referral_node,
{ "Node", "smb.dfs.referral.node", FT_STRING, BASE_NONE,
NULL, 0, "Name of entity to visit next", HFILL }},
{ &hf_smb_dfs_referral_proximity,
{ "Proximity", "smb.dfs.referral.proximity", FT_UINT32, BASE_DEC,
NULL, 0, "Hint describing proximity of this server to the client", HFILL }},
{ &hf_smb_dfs_referral_ttl,
{ "TTL", "smb.dfs.referral.ttl", FT_UINT32, BASE_DEC,
NULL, 0, "Number of seconds the client can cache this referral", HFILL }},
{ &hf_smb_dfs_referral_path_offset,
{ "Path Offset", "smb.dfs.referral.path_offset", FT_UINT16, BASE_DEC,
NULL, 0, "Offset of Dfs Path that matched pathconsumed", HFILL }},
{ &hf_smb_dfs_referral_path,
{ "Path", "smb.dfs.referral.path", FT_STRING, BASE_NONE,
NULL, 0, "Dfs Path that matched pathconsumed", HFILL }},
{ &hf_smb_dfs_referral_alt_path_offset,
{ "Alt Path Offset", "smb.dfs.referral.alt_path_offset", FT_UINT16, BASE_DEC,
NULL, 0, "Offset of alternative(8.3) Path that matched pathconsumed", HFILL }},
{ &hf_smb_dfs_referral_alt_path,
{ "Alt Path", "smb.dfs.referral.alt_path", FT_STRING, BASE_NONE,
NULL, 0, "Alternative(8.3) Path that matched pathconsumed", HFILL }},
{ &hf_smb_dfs_referral_domain_offset,
{ "Domain Offset", "smb.dfs.referral.domain_offset", FT_UINT16, BASE_DEC,
NULL, 0, "Offset of Dfs Path that matched pathconsumed", HFILL }},
{ &hf_smb_dfs_referral_number_of_expnames,
{ "Number of Expanded Names", "smb.dfs.referral.number_of_expnames", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_dfs_referral_expnames_offset,
{ "Expanded Names Offset", "smb.dfs.referral.expnames_offset", FT_UINT16, BASE_DEC,
NULL, 0, "Offset of Dfs Path that matched pathconsumed", HFILL }},
{ &hf_smb_dfs_referral_domain_name,
{ "Domain Name", "smb.dfs.referral.domain_name", FT_STRING, BASE_NONE,
NULL, 0, "Dfs referral domain name", HFILL }},
{ &hf_smb_dfs_referral_expname,
{ "Expanded Name", "smb.dfs.referral.expname", FT_STRING, BASE_NONE,
NULL, 0, "Dfs expanded name", HFILL }},
{ &hf_smb_dfs_referral_server_guid,
{ "Server GUID", "smb.dfs.referral.server_guid", FT_GUID, BASE_NONE,
NULL, 0, "Globally unique identifier for this server", HFILL }},
{ &hf_smb_end_of_search,
{ "End Of Search", "smb.end_of_search", FT_UINT16, BASE_DEC,
NULL, 0, "Was last entry returned?", HFILL }},
{ &hf_smb_last_name_offset,
{ "Last Name Offset", "smb.last_name_offset", FT_UINT16, BASE_DEC,
NULL, 0, "If non-0 this is the offset into the datablock for the file name of the last entry", HFILL }},
{ &hf_smb_fn_information_level,
{ "Level of Interest", "smb.fn_loi", FT_UINT16, BASE_DEC,
NULL, 0, "Level of interest for FIND_NOTIFY command", HFILL }},
{ &hf_smb_monitor_handle,
{ "Monitor Handle", "smb.monitor_handle", FT_UINT16, BASE_HEX,
NULL, 0, "Handle for Find Notify operations", HFILL }},
{ &hf_smb_change_count,
{ "Change Count", "smb.change_count", FT_UINT16, BASE_DEC,
NULL, 0, "Number of changes to wait for", HFILL }},
{ &hf_smb_file_index,
{ "File Index", "smb.file_index", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_short_file_name,
{ "Short File Name", "smb.short_file", FT_STRING, BASE_NONE,
NULL, 0, "Short (8.3) File Name", HFILL }},
{ &hf_smb_short_file_name_len,
{ "Short File Name Len", "smb.short_file_name_len", FT_UINT32, BASE_DEC,
NULL, 0, "Length of Short (8.3) File Name", HFILL }},
{ &hf_smb_fs_id,
{ "FS Id", "smb.fs_id", FT_UINT32, BASE_DEC,
NULL, 0, "File System ID (NT Server always returns 0)", HFILL }},
{ &hf_smb_sector_unit,
{ "Sectors/Unit", "smb.fs_sector_per_unit", FT_UINT32, BASE_DEC,
NULL, 0, "Sectors per allocation unit", HFILL }},
{ &hf_smb_fs_units,
{ "Total Units", "smb.fs_units", FT_UINT32, BASE_DEC,
NULL, 0, "Total number of units on this filesystem", HFILL }},
{ &hf_smb_fs_sector,
{ "Bytes per Sector", "smb.fs_bytes_per_sector", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_avail_units,
{ "Available Units", "smb.avail.units", FT_UINT32, BASE_DEC,
NULL, 0, "Total number of available units on this filesystem", HFILL }},
{ &hf_smb_volume_serial_num,
{ "Volume Serial Number", "smb.volume.serial", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_volume_label_len,
{ "Label Length", "smb.volume.label.len", FT_UINT32, BASE_DEC,
NULL, 0, "Length of volume label", HFILL }},
{ &hf_smb_volume_label,
{ "Label", "smb.volume.label", FT_STRING, BASE_NONE,
NULL, 0, "Volume label", HFILL }},
{ &hf_smb_free_alloc_units64,
{ "Free Units", "smb.free_alloc_units", FT_UINT64, BASE_DEC,
NULL, 0, "Number of free allocation units", HFILL }},
{ &hf_smb_caller_free_alloc_units64,
{ "Caller Free Units", "smb.caller_free_alloc_units", FT_UINT64, BASE_DEC,
NULL, 0, "Number of caller free allocation units", HFILL }},
{ &hf_smb_actual_free_alloc_units64,
{ "Actual Free Units", "smb.actual_free_alloc_units", FT_UINT64, BASE_DEC,
NULL, 0, "Number of actual free allocation units", HFILL }},
{ &hf_smb_soft_quota_limit,
{ "(Soft) Quota Threshold", "smb.quota.soft.default", FT_UINT64, BASE_DEC,
NULL, 0, "Soft Quota threshold", HFILL }},
{ &hf_smb_hard_quota_limit,
{ "(Hard) Quota Limit", "smb.quota.hard.default", FT_UINT64, BASE_DEC,
NULL, 0, "Hard Quota limit", HFILL }},
{ &hf_smb_user_quota_used,
{ "Quota Used", "smb.quota.used", FT_UINT64, BASE_DEC,
NULL, 0, "How much Quota is used by this user", HFILL }},
{ &hf_smb_max_name_len,
{ "Max name length", "smb.fs_max_name_len", FT_UINT32, BASE_DEC,
NULL, 0, "Maximum length of each file name component in number of bytes", HFILL }},
{ &hf_smb_fs_name_len,
{ "Label Length", "smb.fs_name.len", FT_UINT32, BASE_DEC,
NULL, 0, "Length of filesystem name in bytes", HFILL }},
{ &hf_smb_fs_name,
{ "FS Name", "smb.fs_name", FT_STRING, BASE_NONE,
NULL, 0, "Name of filesystem", HFILL }},
{ &hf_smb_device_char,
{ "Device Characteristics", "smb.device", FT_UINT32, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_device_char_removable,
{ "Removable", "smb.device.removable", FT_BOOLEAN, 32,
TFS(&tfs_device_char_removable), 0x00000001, "Is this a removable device", HFILL }},
{ &hf_smb_device_char_read_only,
{ "Read Only", "smb.device.read_only", FT_BOOLEAN, 32,
TFS(&tfs_device_char_read_only), 0x00000002, "Is this a read-only device", HFILL }},
{ &hf_smb_device_char_floppy,
{ "Floppy", "smb.device.floppy", FT_BOOLEAN, 32,
TFS(&tfs_device_char_floppy), 0x00000004, "Is this a floppy disk", HFILL }},
{ &hf_smb_device_char_write_once,
{ "Write Once", "smb.device.write_once", FT_BOOLEAN, 32,
TFS(&tfs_device_char_write_once), 0x00000008, "Is this a write-once device", HFILL }},
{ &hf_smb_device_char_remote,
{ "Remote", "smb.device.remote", FT_BOOLEAN, 32,
TFS(&tfs_device_char_remote), 0x00000010, "Is this a remote device", HFILL }},
{ &hf_smb_device_char_mounted,
{ "Mounted", "smb.device.mounted", FT_BOOLEAN, 32,
TFS(&tfs_device_char_mounted), 0x00000020, "Is this a mounted device", HFILL }},
{ &hf_smb_device_char_virtual,
{ "Virtual", "smb.device.virtual", FT_BOOLEAN, 32,
TFS(&tfs_device_char_virtual), 0x00000040, "Is this a virtual device", HFILL }},
{ &hf_smb_device_char_secure_open,
{ "Secure Open", "smb.device.secure_open", FT_BOOLEAN, 32,
TFS(&tfs_device_char_secure_open), 0x00000100, "Is this a secure open device", HFILL }},
{ &hf_smb_device_char_ts,
{ "Terminal Services", "smb.device.ts", FT_BOOLEAN, 32,
TFS(&tfs_device_char_ts), 0x00001000, "Is this a terminal services device", HFILL }},
{ &hf_smb_device_char_webdav,
{ "Webdav", "smb.device.webdav", FT_BOOLEAN, 32,
TFS(&tfs_device_char_webdav), 0x00002000, "Is this a WEBDAV device", HFILL }},
{ &hf_smb_device_char_aat,
{ "Allow Appcontainer Traversal", "smb.device.aat", FT_BOOLEAN, 32,
TFS(&tfs_device_char_aat), 0x00020000, "Does this device allow appcontainer traversal", HFILL }},
{ &hf_smb_device_char_portable,
{ "Portable", "smb.device.portable", FT_BOOLEAN, 32,
TFS(&tfs_device_char_portable), 0x00004000, "Is this a portable device", HFILL }},
{ &hf_smb_fs_attr,
{ "FS Attributes", "smb.fs_attr", FT_UINT32, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_fs_attr_css,
{ "Case Sensitive Search", "smb.fs_attr.css", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_css), 0x00000001, "Does this FS support Case Sensitive Search?", HFILL }},
{ &hf_smb_fs_attr_cpn,
{ "Case Preserving", "smb.fs_attr.cpn", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_cpn), 0x00000002, "Will this FS Preserve Name Case?", HFILL }},
{ &hf_smb_fs_attr_uod,
{ "Unicode On Disk", "smb.fs_attr.uod", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_uod), 0x00000004, "Does this FS support Unicode On Disk?", HFILL }},
{ &hf_smb_fs_attr_pacls,
{ "Persistent ACLs", "smb.fs_attr.pacls", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_pacls), 0x00000008, "Does this FS support Persistent ACLs?", HFILL }},
{ &hf_smb_fs_attr_fc,
{ "Compression", "smb.fs_attr.fc", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_fc), 0x00000010, "Does this FS support File Compression?", HFILL }},
{ &hf_smb_fs_attr_vq,
{ "Volume Quotas", "smb.fs_attr.vq", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_vq), 0x00000020, "Does this FS support Volume Quotas?", HFILL }},
{ &hf_smb_fs_attr_ssf,
{ "Sparse Files", "smb.fs_attr.ssf", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_ssf), 0x00000040, "Does this FS support SPARSE FILES?", HFILL }},
{ &hf_smb_fs_attr_srp,
{ "Reparse Points", "smb.fs_attr.srp", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_srp), 0x00000080, "Does this FS support REPARSE POINTS?", HFILL }},
{ &hf_smb_fs_attr_srs,
{ "Remote Storage", "smb.fs_attr.srs", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_srs), 0x00000100, "Does this FS support REMOTE STORAGE?", HFILL }},
{ &hf_smb_fs_attr_sla,
{ "LFN APIs", "smb.fs_attr.sla", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_sla), 0x00004000, "Does this FS support LFN APIs?", HFILL }},
{ &hf_smb_fs_attr_vic,
{ "Volume Is Compressed", "smb.fs_attr.vis", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_vic), 0x00008000, "Is this FS on a compressed volume?", HFILL }},
{ &hf_smb_fs_attr_soids,
{ "Supports OIDs", "smb.fs_attr.soids", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_soids), 0x00010000, "Does this FS support OIDs?", HFILL }},
{ &hf_smb_fs_attr_se,
{ "Supports Encryption", "smb.fs_attr.se", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_se), 0x00020000, "Does this FS support encryption?", HFILL }},
{ &hf_smb_fs_attr_ns,
{ "Named Streams", "smb.fs_attr.ns", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_ns), 0x00040000, "Does this FS support named streams?", HFILL }},
{ &hf_smb_fs_attr_rov,
{ "Read Only Volume", "smb.fs_attr.rov", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_rov), 0x00080000, "Is this FS on a read only volume?", HFILL }},
{ &hf_smb_fs_attr_swo,
{ "Sequential Write Once", "smb.fs_attr.swo", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_swo), 0x00100000, "Is this FS on a sequential write once volume?", HFILL }},
{ &hf_smb_fs_attr_st,
{ "Transactions", "smb.fs_attr.st", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_st), 0x00200000, "Does this FS support transactions?", HFILL }},
{ &hf_smb_fs_attr_shl,
{ "Hard Links", "smb.fs_attr.shl", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_shl), 0x00400000, "Does this FS support hard links?", HFILL }},
{ &hf_smb_fs_attr_sis,
{ "Integrity Streams", "smb.fs_attr.sis", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_sis), 0x04000000, "Does this FS support integrity streams?", HFILL }},
{ &hf_smb_fs_attr_sbr,
{ "Block Refcounting", "smb.fs_attr.sbr", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_sbr), 0x08000000, "Does this FS support block refcounting?", HFILL }},
{ &hf_smb_fs_attr_ssv,
{ "Sparse VDL", "smb.fs_attr.ssv", FT_BOOLEAN, 32,
TFS(&tfs_fs_attr_ssv), 0x10000000, "Does this FS support sparse VDL?", HFILL }},
{ &hf_smb_user_quota_change_time,
{ "Change Time", "smb.quota.user.change_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0x0, "The last time the quota was changed", HFILL }},
{ &hf_smb_length_of_sid,
{ "Length of SID", "smb.length_of_sid", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_user_quota_offset,
{ "Next Offset", "smb.quota.user.offset", FT_UINT32, BASE_DEC,
NULL, 0, "Relative offset to next user quota structure", HFILL }},
{ &hf_smb_pipe_write_len,
{ "Pipe Write Len", "smb.pipe.write_len", FT_UINT16, BASE_DEC,
NULL, 0, "Number of bytes written to pipe", HFILL }},
{ &hf_smb_quota_flags_deny_disk,
{ "Deny Disk", "smb.quota.flags.deny_disk", FT_BOOLEAN, 8,
TFS(&tfs_quota_flags_deny_disk), 0x02, "Is the default quota limit enforced?", HFILL }},
{ &hf_smb_quota_flags_log_limit,
{ "Log Limit", "smb.quota.flags.log_limit", FT_BOOLEAN, 8,
TFS(&tfs_quota_flags_log_limit), 0x20, "Should the server log an event when the limit is exceeded?", HFILL }},
{ &hf_smb_quota_flags_log_warning,
{ "Log Warning", "smb.quota.flags.log_warning", FT_BOOLEAN, 8,
TFS(&tfs_quota_flags_log_warning), 0x10, "Should the server log an event when the warning level is exceeded?", HFILL }},
{ &hf_smb_quota_flags,
{ "Quota Flags", "smb.quota.flags", FT_UINT8, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_quota_flags_enabled,
{ "Enabled", "smb.quota.flags.enabled", FT_BOOLEAN, 8,
TFS(&tfs_quota_flags_enabled), 0x01, "Is quotas enabled of this FS?", HFILL }},
{ &hf_smb_segment_overlap,
{ "Fragment overlap", "smb.segment.overlap", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"Fragment overlaps with other fragments", HFILL }},
{ &hf_smb_segment_overlap_conflict,
{ "Conflicting data in fragment overlap", "smb.segment.overlap.conflict", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"Overlapping fragments contained conflicting data", HFILL }},
{ &hf_smb_segment_multiple_tails,
{ "Multiple tail fragments found", "smb.segment.multipletails", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"Several tails were found when defragmenting the packet", HFILL }},
{ &hf_smb_segment_too_long_fragment,
{ "Fragment too long", "smb.segment.toolongfragment", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"Fragment contained data past end of packet", HFILL }},
{ &hf_smb_segment_error,
{ "Defragmentation error", "smb.segment.error", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
"Defragmentation error due to illegal fragments", HFILL }},
{ &hf_smb_segment_count,
{ "Fragment count", "smb.fragment.count", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_smb_reassembled_length,
{ "Reassembled SMB length", "smb.reassembled.length", FT_UINT32, BASE_DEC, NULL, 0x0,
"The total length of the reassembled payload", HFILL }},
{ &hf_smb_opened_in,
{ "Opened in", "smb.fid.opened_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
"The frame this fid was opened", HFILL }},
{ &hf_smb_closed_in,
{ "Closed in", "smb.fid.closed_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
"The frame this fid was closed", HFILL }},
{ &hf_smb_mapped_in,
{ "Mapped in", "smb.fid.mapped_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
"The frame this share was mapped", HFILL }},
{ &hf_smb_unmapped_in,
{ "Unmapped in", "smb.fid.unmapped_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
"The frame this share was unmapped", HFILL }},
{ &hf_smb_segment,
{ "SMB Segment", "smb.segment", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_smb_segments,
{ "SMB Segments", "smb.segment.segments", FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_smb_unix_major_version,
{ "Major Version", "smb.unix.major_version", FT_UINT16, BASE_DEC,
NULL, 0, "UNIX Major Version", HFILL }},
{ &hf_smb_unix_minor_version,
{ "Minor Version", "smb.unix.minor_version", FT_UINT16, BASE_DEC,
NULL, 0, "UNIX Minor Version", HFILL }},
{ &hf_smb_unix_capability,
{ "Capabilities", "smb.unix.capability", FT_UINT64, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_unix_capability_fcntl,
{ "FCNTL Capability", "smb.unix.capability.fcntl", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000001, NULL, HFILL }},
{ &hf_smb_unix_capability_posix_acl,
{ "POSIX ACL Capability", "smb.unix.capability.posix_acl", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000002, NULL, HFILL }},
{ &hf_smb_unix_capability_xattr,
{ "EA Capability", "smb.unix.capability.ea", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000004, NULL, HFILL }},
{ &hf_smb_unix_capability_attr,
{ "Additional Attributes Capability", "smb.unix.capability.attr", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000008, NULL, HFILL }},
{ &hf_smb_unix_capability_posix_paths,
{ "POSIX Pathnames Capability", "smb.unix.capability.posix_paths", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000010, NULL, HFILL }},
{ &hf_smb_unix_capability_posix_path_ops,
{ "POSIX Path Operations Capability", "smb.unix.capability.posix_path_ops", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000020, NULL, HFILL }},
{ &hf_smb_unix_capability_large_read,
{ "Large Read Capability", "smb.unix.capability.large_read", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000040, NULL, HFILL }},
{ &hf_smb_unix_capability_large_write,
{ "Large Write Capability", "smb.unix.capability.large_write", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000080, NULL, HFILL }},
{ &hf_smb_unix_capability_encryption,
{ "Encryption Capability", "smb.unix.capability.encryption", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000100, NULL, HFILL }},
{ &hf_smb_unix_capability_mandatory_crypto,
{ "Mandatory Encryption Capability", "smb.unix.capability.mandatory_crypto", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000200, NULL, HFILL }},
{ &hf_smb_unix_capability_proxy,
{ "Proxy Capability", "smb.unix.capability.proxy", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000400, NULL, HFILL }},
{ &hf_smb_file_access_mask_read_data,
{ "Read Data", "smb.file.accessmask.read_data", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000001, NULL, HFILL }},
{ &hf_smb_file_access_mask_write_data,
{ "Write Data", "smb.file.accessmask.write_data", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000002, NULL, HFILL }},
{ &hf_smb_file_access_mask_append_data,
{ "Append Data", "smb.file.accessmask.append_data", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000004, NULL, HFILL }},
{ &hf_smb_file_access_mask_read_ea,
{ "Read EA", "smb.file.accessmask.read_ea", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000008, NULL, HFILL }},
{ &hf_smb_file_access_mask_write_ea,
{ "Write EA", "smb.file.accessmask.write_ea", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000010, NULL, HFILL }},
{ &hf_smb_file_access_mask_execute,
{ "Execute", "smb.file.accessmask.execute", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000020, NULL, HFILL }},
{ &hf_smb_file_access_mask_read_attribute,
{ "Read Attribute", "smb.file.accessmask.read_attribute", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000080, NULL, HFILL }},
{ &hf_smb_file_access_mask_write_attribute,
{ "Write Attribute", "smb.file.accessmask.write_attribute", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000100, NULL, HFILL }},
{ &hf_smb_dir_access_mask_list,
{ "List", "smb.dir.accessmask.list", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000001, NULL, HFILL }},
{ &hf_smb_dir_access_mask_add_file,
{ "Add File", "smb.dir.accessmask.add_file", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000002, NULL, HFILL }},
{ &hf_smb_dir_access_mask_add_subdir,
{ "Add Subdir", "smb.dir.accessmask.add_subdir", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000004, NULL, HFILL }},
{ &hf_smb_dir_access_mask_read_ea,
{ "Read EA", "smb.dir.accessmask.read_ea", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000008, NULL, HFILL }},
{ &hf_smb_dir_access_mask_write_ea,
{ "Write EA", "smb.dir.accessmask.write_ea", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000010, NULL, HFILL }},
{ &hf_smb_dir_access_mask_traverse,
{ "Traverse", "smb.dir.accessmask.traverse", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000020, NULL, HFILL }},
{ &hf_smb_dir_access_mask_delete_child,
{ "Delete Child", "smb.dir.accessmask.delete_child", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000040, NULL, HFILL }},
{ &hf_smb_dir_access_mask_read_attribute,
{ "Read Attribute", "smb.dir.accessmask.read_attribute", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000080, NULL, HFILL }},
{ &hf_smb_dir_access_mask_write_attribute,
{ "Write Attribute", "smb.dir.accessmask.write_attribute", FT_BOOLEAN, 32,
TFS(&tfs_set_notset), 0x00000100, NULL, HFILL }},
{ &hf_smb_unix_file_link_dest,
{ "Link destination", "smb.unix.file.link_dest", FT_STRING,
BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_file_size,
{ "File size", "smb.unix.file.size", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_file_num_bytes,
{ "Number of bytes", "smb.unix.file.num_bytes", FT_UINT64, BASE_DEC,
NULL, 0, "Number of bytes used to store the file", HFILL }},
{ &hf_smb_unix_file_last_status,
{ "Last status change", "smb.unix.file.stime", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_file_last_access,
{ "Last access", "smb.unix.file.atime", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_file_last_change,
{ "Last modification", "smb.unix.file.mtime", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_file_creation_time,
{ "Creation time", "smb.unix.file.crtime", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_file_uid,
{ "UID", "smb.unix.file.uid", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_file_gid,
{ "GID", "smb.unix.file.gid", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_file_type,
{ "File type", "smb.unix.file.file_type", FT_UINT32, BASE_DEC,
VALS(unix_file_type_vals), 0, NULL, HFILL }},
{ &hf_smb_unix_file_dev_major,
{ "Major device", "smb.unix.file.dev_major", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_file_dev_minor,
{ "Minor device", "smb.unix.file.dev_minor", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_file_unique_id,
{ "Unique ID", "smb.unix.file.unique_id", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_file_permissions,
{ "File permissions", "smb.unix.file.perms", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_file_nlinks,
{ "Num links", "smb.unix.file.num_links", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_info2_file_flags,
{ "Flags", "smb.unix_info2.file.flags", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_info2_file_flags_mask,
{ "Flags mask", "smb.unix_info2.file.flags_mask", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_info2_file_flags_secure_delete,
{ "Secure delete", "smb.unix_info2.file.flags.secure_delete", FT_BOOLEAN, 32,
NULL, 0x00000001, NULL, HFILL }},
{ &hf_smb_unix_info2_file_flags_enable_undelete,
{ "Enable undelete", "smb.unix_info2.file.flags.enable_undelete", FT_BOOLEAN, 32,
NULL, 0x00000002, NULL, HFILL }},
{ &hf_smb_unix_info2_file_flags_synchronous,
{ "Synchronous", "smb.unix_info2.file.flags.synchronous", FT_BOOLEAN, 32,
NULL, 0x00000004, NULL, HFILL }},
{ &hf_smb_unix_info2_file_flags_immutable,
{ "Immutable", "smb.unix_info2.file.flags.immutable", FT_BOOLEAN, 32,
NULL, 0x00000008, NULL, HFILL }},
{ &hf_smb_unix_info2_file_flags_append_only,
{ "Append-only", "smb.unix_info2.file.flags.append_only", FT_BOOLEAN, 32,
NULL, 0x00000010, NULL, HFILL }},
{ &hf_smb_unix_info2_file_flags_do_not_backup,
{ "Do not backup", "smb.unix_info2.file.flags.do_not_backup", FT_BOOLEAN, 32,
NULL, 0x00000020, NULL, HFILL }},
{ &hf_smb_unix_info2_file_flags_no_update_atime,
{ "Don't update atime", "smb.unix_info2.file.flags.no_update_atime", FT_BOOLEAN, 32,
NULL, 0x00000040, NULL, HFILL }},
{ &hf_smb_unix_info2_file_flags_hidden,
{ "Hidden", "smb.unix_info2.file.flags.hidden", FT_BOOLEAN, 32,
NULL, 0x00000080, NULL, HFILL }},
{ &hf_smb_unix_file_name_length,
{ "File name length", "smb.unix.file.name_length", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_file_name,
{ "File name", "smb.unix.file.name", FT_STRING,
BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_find_file_nextoffset,
{ "Next entry offset", "smb.unix.find_file.next_offset", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_find_file_resumekey,
{ "Resume key", "smb.unix.find_file.resume_key", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_whoami_mapflags,
{ "UNIX whoami mapping flags", "smb.unix.whoami.mapflags", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_whoami_mapflags_mask,
{ "UNIX whoami mapping flags mask", "smb.unix.whoami.mapflags_mask", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_whoami_num_supl_gids,
{ "Number of supplementary UNIX GIDs", "smb.unix.whoami.num_gids", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_whoami_num_supl_sids,
{ "Number of supplementary SIDs", "smb.unix.whoami.num_sids", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_unix_whoami_sids_buflen,
{ "Supplementary SIDs buffer length", "smb.unix.whoami.sids_buflen", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_create_flags,
{ "Create Flags", "smb.create_flags", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_create_options,
{ "Create Options", "smb.create_options", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_share_access,
{ "Share Access", "smb.share_access", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_access_mask,
{ "Access Mask", "smb.access_mask", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_mode,
{ "Mode", "smb.mode", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_attribute,
{ "Attribute", "smb.attribute", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_reparse_tag,
{ "Reparse Tag", "smb.reparse_tag", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_disposition_delete_on_close,
{ "Delete on close", "smb.disposition.delete_on_close", FT_BOOLEAN, 8,
TFS(&tfs_disposition_delete_on_close), 0x01, NULL, HFILL }},
{ &hf_smb_pipe_info_flag,
{ "Pipe Info", "smb.pipe_info_flag", FT_BOOLEAN, 8,
TFS(&tfs_pipe_info_flag), 0x01, NULL, HFILL }},
{ &hf_smb_logged_in,
{ "Logged In", "smb.logged_in", FT_FRAMENUM, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_smb_logged_out,
{ "Logged Out", "smb.logged_out", FT_FRAMENUM, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_smb_file_rw_offset,
{ "File Offset", "smb.file.rw.offset", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_file_rw_length,
{ "File RW Length", "smb.file.rw.length", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_posix_acl_version,
{ "Posix ACL version", "smb.posix_acl.version", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_posix_num_file_aces,
{ "Number of file ACEs", "smb.posix_acl.num_file_aces", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_posix_num_def_aces,
{ "Number of default ACEs", "smb.posix_acl.num_def_aces", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_posix_ace_type,
{ "ACE Type", "smb.posix_acl.ace_type", FT_UINT8, BASE_DEC,
VALS(ace_type_vals), 0, NULL, HFILL }},
{ &hf_smb_posix_ace_flags,
{ "Permissions", "smb.posix_acl.ace_perms", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_smb_posix_ace_perm_read,
{"READ", "smb.posix_acl.ace_perms.read", FT_BOOLEAN, 8,
NULL, 0x04, NULL, HFILL}},
{ &hf_smb_posix_ace_perm_write,
{"WRITE", "smb.posix_acl.ace_perms.write", FT_BOOLEAN, 8,
NULL, 0x02, NULL, HFILL}},
{ &hf_smb_posix_ace_perm_execute,
{"EXECUTE", "smb.posix_acl.ace_perms.execute", FT_BOOLEAN, 8,
NULL, 0x01, NULL, HFILL}},
{ &hf_smb_posix_ace_perm_owner_uid,
{ "Owner UID", "smb.posix_acl.ace_perms.owner_uid", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_posix_ace_perm_owner_gid,
{ "Owner GID", "smb.posix_acl.ace_perms.owner_gid", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_posix_ace_perm_uid,
{ "UID", "smb.posix_acl.ace_perms.uid", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_posix_ace_perm_gid,
{ "GID", "smb.posix_acl.ace_perms.gid", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb_trans_data_setup_word,
{ "Setup Word", "smb.trans_data.setup_word", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_trans_data_parameters,
{ "Parameters", "smb.trans_data.parameters", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_trans_data,
{ "Data", "smb.trans_data", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_extra_byte_parameters,
{ "Extra byte parameters", "smb.extra_byte_parameters", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_file_access_mask_full_control,
{ "FULL CONTROL", "smb.file.accessmask.full_control", FT_UINT32, BASE_HEX,
NULL, 0x000001ff, NULL, HFILL }},
{ &hf_smb_dir_access_mask_full_control,
{ "FULL CONTROL", "smb.dir.accessmask.full_control", FT_UINT32, BASE_HEX,
NULL, 0x000001ff, NULL, HFILL }},
{ &hf_smb_word_unk_response_format,
{ "Words for unknown response format", "smb.word_unk_response_format", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_nt_transaction_setup,
{ "NT Transaction Setup", "smb.nt_transaction_setup", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_server_component,
{ "Server Component", "smb.server_component", FT_UINT32, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_byte_parameters,
{ "Byte parameters", "smb.byte_parameters", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_smb_word_parameters,
{ "Word parameters", "smb.word_parameters", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
};
static gint *ett[] = {
&ett_smb,
&ett_smb_fid,
&ett_smb_tid,
&ett_smb_uid,
&ett_smb_hdr,
&ett_smb_command,
&ett_smb_fileattributes,
&ett_smb_capabilities,
&ett_smb_aflags,
&ett_smb_dialect,
&ett_smb_dialects,
&ett_smb_mode,
&ett_smb_rawmode,
&ett_smb_flags,
&ett_smb_flags2,
&ett_smb_desiredaccess,
&ett_smb_search,
&ett_smb_file,
&ett_smb_openfunction,
&ett_smb_filetype,
&ett_smb_openaction,
&ett_smb_writemode,
&ett_smb_lock_type,
&ett_smb_ssetupandxaction,
&ett_smb_optionsup,
&ett_smb_time_date,
&ett_smb_move_copy_flags,
&ett_smb_file_attributes,
&ett_smb_search_resume_key,
&ett_smb_search_dir_info,
&ett_smb_unlocks,
&ett_smb_unlock,
&ett_smb_locks,
&ett_smb_lock,
&ett_smb_open_flags,
&ett_smb_ipc_state,
&ett_smb_open_action,
&ett_smb_setup_action,
&ett_smb_connect_flags,
&ett_smb_connect_support_bits,
&ett_smb_nt_access_mask,
&ett_smb_nt_create_bits,
&ett_smb_nt_create_options,
&ett_smb_nt_share_access,
&ett_smb_nt_security_flags,
&ett_smb_nt_trans_setup,
&ett_smb_nt_trans_data,
&ett_smb_nt_trans_param,
&ett_smb_nt_notify_completion_filter,
&ett_smb_nt_ioctl_flags,
&ett_smb_security_information_mask,
&ett_smb_print_queue_entry,
&ett_smb_transaction_flags,
&ett_smb_transaction_params,
&ett_smb_find_first2_flags,
#if 0
&ett_smb_ioflag,
#endif
&ett_smb_transaction_data,
&ett_smb_stream_info,
&ett_smb_dfs_referrals,
&ett_smb_dfs_referral,
&ett_smb_dfs_referral_flags,
&ett_smb_dfs_referral_expnames,
&ett_smb_get_dfs_flags,
&ett_smb_ff2_data,
&ett_smb_device_characteristics,
&ett_smb_fs_attributes,
&ett_smb_segments,
&ett_smb_segment,
&ett_smb_quotaflags,
&ett_smb_secblob,
&ett_smb_mac_support_flags,
&ett_smb_unicode_password,
&ett_smb_ea,
&ett_smb_unix_capabilities,
&ett_smb_unix_whoami_gids,
&ett_smb_unix_whoami_sids,
&ett_smb_posix_ace,
&ett_smb_posix_ace_perms,
&ett_smb_info2_file_flags
};
static ei_register_info ei[] = {
{ &ei_smb_missing_word_parameters, {"smb.missing_word_parameters", PI_MALFORMED, PI_ERROR, "The word parameters are missing, so the byte parameters cannot be dissected.", EXPFILL }},
{ &ei_smb_mal_information_level, { "smb.information_level.malformed", PI_MALFORMED, PI_ERROR, "Information level structure goes past the end of the transaction data.", EXPFILL }},
{ &ei_smb_not_implemented, { "smb.not_implemented", PI_UNDECODED, PI_WARN, "Not Implemented yet", EXPFILL }},
{ &ei_smb_nt_transaction_setup, { "smb.nt_transaction_setup.unknown", PI_PROTOCOL, PI_NOTE, "Unknown NT Transaction Setup (matching request not seen)", EXPFILL }},
{ &ei_smb_posix_ace_type, { "smb.posix_acl.ace_type.unknown", PI_PROTOCOL, PI_WARN, "Unknown posix ace type", EXPFILL }},
{ &ei_smb_info_level_unknown, { "smb.info_level_unknown", PI_PROTOCOL, PI_WARN, "Information level unknown", EXPFILL }},
{ &ei_smb_info_level_not_understood, { "smb.info_level_not_understood", PI_PROTOCOL, PI_WARN, "Information level not understood", EXPFILL }},
};
module_t *smb_module;
expert_module_t* expert_smb;
proto_smb = proto_register_protocol("SMB (Server Message Block Protocol)",
"SMB", "smb");
proto_register_subtree_array(ett, array_length(ett));
proto_register_field_array(proto_smb, hf, array_length(hf));
expert_smb = expert_register_protocol(proto_smb);
expert_register_field_array(expert_smb, ei, array_length(ei));
proto_do_register_windows_common(proto_smb);
register_cleanup_routine(&smb_cleanup);
smb_module = prefs_register_protocol(proto_smb, NULL);
prefs_register_bool_preference(smb_module, "trans_reassembly",
"Reassemble SMB Transaction payload",
"Whether the dissector should reassemble the payload of SMB Transaction commands spanning multiple SMB PDUs",
&smb_trans_reassembly);
prefs_register_bool_preference(smb_module, "dcerpc_reassembly",
"Reassemble DCERPC over SMB",
"Whether the dissector should reassemble DCERPC over SMB commands",
&smb_dcerpc_reassembly);
prefs_register_bool_preference(smb_module, "sid_name_snooping",
"Snoop SID to Name mappings",
"Whether the dissector should snoop SMB and related CIFS protocols to discover and display Names associated with SIDs",
&sid_name_snooping);
/* For display of SIDs and RIDs in Hex option */
prefs_register_bool_preference(smb_module, "sid_display_hex",
"Display SIDs in Hex",
"Whether the dissector should display SIDs and RIDs in hexadecimal rather than decimal",
&sid_display_hex);
/* Will Export Object take name as fid ? */
prefs_register_bool_preference(smb_module, "eosmb_take_name_as_fid",
"Use the full file name as File ID when exporting an SMB object",
"Whether the export object functionality will take the full path file name as file identifier",
&eosmb_take_name_as_fid);
/*
* XXX - addresses_ports_reassembly_table_functions?
* Probably correct for SMB-over-NBT and SMB-over-TCP,
* as stuff from two different connections should
* probably not be combined, but what about other
* transports for SMB, e.g. NBF or Netware?
*/
reassembly_table_register(&smb_trans_reassembly_table,
&addresses_reassembly_table_functions);
smb_tap = register_tap("smb");
smb_handle = register_dissector("smb", dissect_smb, proto_smb);
register_srt_table(proto_smb, NULL, 3, smbstat_packet, smbstat_init, NULL);
/* Register the tap for the "Export Object" function */
smb_eo_tap = register_export_object(proto_smb, smb_eo_packet, smb_eo_cleanup);
}
void
proto_reg_handoff_smb(void)
{
gssapi_handle = find_dissector_add_dependency("gssapi", proto_smb);
ntlmssp_handle = find_dissector_add_dependency("ntlmssp", proto_smb);
heur_dissector_add("netbios", dissect_smb_heur, "SMB over Netbios", "smb_netbios", proto_smb, HEURISTIC_ENABLE);
heur_dissector_add("smb_direct", dissect_smb_heur, "SMB over SMB Direct", "smb_smb_direct", proto_smb, HEURISTIC_ENABLE);
heur_dissector_add("cotp", dissect_smb_heur, "SMB over COTP", "smb_cotp", proto_smb, HEURISTIC_ENABLE);
heur_dissector_add("vines_spp", dissect_smb_heur, "SMB over Vines", "smb_vines", proto_smb, HEURISTIC_ENABLE);
dissector_add_uint("ipx.socket", IPX_SOCKET_NWLINK_SMB_SERVER, smb_handle);
dissector_add_uint("ipx.socket", IPX_SOCKET_NWLINK_SMB_REDIR, smb_handle);
dissector_add_uint("ipx.socket", IPX_SOCKET_NWLINK_SMB_MESSENGER, smb_handle);
dissector_add_uint("spp.socket", IDP_SOCKET_SMB, smb_handle);
}
/*
* Editor modelines - https://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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-smb.h
|
/* packet-smb.h
* Defines for SMB packet dissection
* Copyright 1999, Richard Sharpe <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998, 1999 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PACKET_SMB_H__
#define __PACKET_SMB_H__
#include "ws_symbol_export.h"
#include <epan/proto.h>
#include <epan/wmem_scopes.h>
WS_DLL_PUBLIC gboolean sid_name_snooping;
/* SMB command codes, from the SNIA CIFS spec. With MSVC and a
* libwireshark.dll, we need a special declaration.
*/
WS_DLL_PUBLIC value_string_ext smb_cmd_vals_ext;
WS_DLL_PUBLIC value_string_ext trans2_cmd_vals_ext;
WS_DLL_PUBLIC value_string_ext nt_cmd_vals_ext;
#define SMB_COM_CREATE_DIRECTORY 0x00
#define SMB_COM_DELETE_DIRECTORY 0x01
#define SMB_COM_OPEN 0x02
#define SMB_COM_CREATE 0x03
#define SMB_COM_CLOSE 0x04
#define SMB_COM_FLUSH 0x05
#define SMB_COM_DELETE 0x06
#define SMB_COM_RENAME 0x07
#define SMB_COM_QUERY_INFORMATION 0x08
#define SMB_COM_SET_INFORMATION 0x09
#define SMB_COM_READ 0x0A
#define SMB_COM_WRITE 0x0B
#define SMB_COM_LOCK_BYTE_RANGE 0x0C
#define SMB_COM_UNLOCK_BYTE_RANGE 0x0D
#define SMB_COM_CREATE_TEMPORARY 0x0E
#define SMB_COM_CREATE_NEW 0x0F
#define SMB_COM_CHECK_DIRECTORY 0x10
#define SMB_COM_PROCESS_EXIT 0x11
#define SMB_COM_SEEK 0x12
#define SMB_COM_LOCK_AND_READ 0x13
#define SMB_COM_WRITE_AND_UNLOCK 0x14
#define SMB_COM_READ_RAW 0x1A
#define SMB_COM_READ_MPX 0x1B
#define SMB_COM_READ_MPX_SECONDARY 0x1C
#define SMB_COM_WRITE_RAW 0x1D
#define SMB_COM_WRITE_MPX 0x1E
#define SMB_COM_WRITE_MPX_SECONDARY 0x1F
#define SMB_COM_WRITE_COMPLETE 0x20
#define SMB_COM_QUERY_SERVER 0x21
#define SMB_COM_SET_INFORMATION2 0x22
#define SMB_COM_QUERY_INFORMATION2 0x23
#define SMB_COM_LOCKING_ANDX 0x24
#define SMB_COM_TRANSACTION 0x25
#define SMB_COM_TRANSACTION_SECONDARY 0x26
#define SMB_COM_IOCTL 0x27
#define SMB_COM_IOCTL_SECONDARY 0x28
#define SMB_COM_COPY 0x29
#define SMB_COM_MOVE 0x2A
#define SMB_COM_ECHO 0x2B
#define SMB_COM_WRITE_AND_CLOSE 0x2C
#define SMB_COM_OPEN_ANDX 0x2D
#define SMB_COM_READ_ANDX 0x2E
#define SMB_COM_WRITE_ANDX 0x2F
#define SMB_COM_NEW_FILE_SIZE 0x30
#define SMB_COM_CLOSE_AND_TREE_DISC 0x31
#define SMB_COM_TRANSACTION2 0x32
#define SMB_COM_TRANSACTION2_SECONDARY 0x33
#define SMB_COM_FIND_CLOSE2 0x34
#define SMB_COM_FIND_NOTIFY_CLOSE 0x35
/* Used by Xenix/Unix 0x60-0x6E */
#define SMB_COM_TREE_CONNECT 0x70
#define SMB_COM_TREE_DISCONNECT 0x71
#define SMB_COM_NEGOTIATE 0x72
#define SMB_COM_SESSION_SETUP_ANDX 0x73
#define SMB_COM_LOGOFF_ANDX 0x74
#define SMB_COM_TREE_CONNECT_ANDX 0x75
#define SMB_COM_QUERY_INFORMATION_DISK 0x80
#define SMB_COM_SEARCH 0x81
#define SMB_COM_FIND 0x82
#define SMB_COM_FIND_UNIQUE 0x83
#define SMB_COM_FIND_CLOSE 0x84
#define SMB_COM_NT_TRANSACT 0xA0
#define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
#define SMB_COM_NT_CREATE_ANDX 0xA2
#define SMB_COM_NT_CANCEL 0xA4
#define SMB_COM_NT_RENAME 0xA5
#define SMB_COM_OPEN_PRINT_FILE 0xC0
#define SMB_COM_WRITE_PRINT_FILE 0xC1
#define SMB_COM_CLOSE_PRINT_FILE 0xC2
#define SMB_COM_GET_PRINT_QUEUE 0xC3
#define SMB_COM_READ_BULK 0xD8
#define SMB_COM_WRITE_BULK 0xD9
#define SMB_COM_WRITE_BULK_DATA 0xDA
/* Error codes */
#define SMB_SUCCESS 0x00 /* All OK */
#define SMB_ERRDOS 0x01 /* DOS based error */
#define SMB_ERRSRV 0x02 /* server error, network file manager */
#define SMB_ERRHRD 0x03 /* Hardware style error */
#define SMB_ERRCMD 0x04 /* Not an SMB format command */
/* used for SMB export object functionality */
typedef struct _smb_eo_t {
guint smbversion;
guint16 cmd;
int tid,uid;
guint fid;
guint32 pkt_num;
gchar *hostname;
gchar *filename;
int fid_type;
gint64 end_of_file;
gchar *content_type;
guint32 payload_len;
const guint8 *payload_data;
guint64 smb_file_offset;
guint32 smb_chunk_len;
} smb_eo_t;
/* the information we need to keep around for NT transaction commands */
typedef struct {
int subcmd;
int fid_type;
guint32 ioctl_function;
} smb_nt_transact_info_t;
/* the information we need to keep around for transaction2 commands */
typedef struct {
int subcmd;
int info_level;
gboolean resume_keys; /* if "return resume" keys set in T2 FIND_FIRST request */
const char *name;
} smb_transact2_info_t;
/*
* The information we need to save about a request in order to show the
* frame number of the request in the dissection of the reply.
*/
#define SMB_SIF_TID_IS_IPC 0x0001
#define SMB_SIF_IS_CONTINUED 0x0002
typedef enum {
SMB_EI_NONE, /* Unassigned / NULL */
SMB_EI_FID, /* FID */
SMB_EI_NTI, /* smb_nt_transact_info_t * */
SMB_EI_TRI, /* smb_transact_info_t * */
SMB_EI_T2I, /* smb_transact2_info_t * */
SMB_EI_TIDNAME, /* tid tracking char * */
SMB_EI_FILEDATA, /* fid tracking */
SMB_EI_FILENAME, /* filename tracking */
SMB_EI_UID, /* smb_uid_t */
SMB_EI_RWINFO, /* read/write offset/count info */
SMB_EI_LOCKDATA, /* locking and x data */
SMB_EI_RENAMEDATA, /* rename data */
SMB_EI_DIALECTS /* negprot dialects */
} smb_extra_info_t;
typedef struct _smb_fid_into_t smb_fid_info_t;
typedef struct {
guint32 frame_req, frame_res;
nstime_t req_time;
guint16 flags;
guint8 cmd;
void *extra_info;
smb_extra_info_t extra_info_type;
/* we save the fid in each transaction so that we can get fid filters
to match both request and response */
gboolean fid_seen_in_request;
guint16 fid;
} smb_saved_info_t;
/*
* The information we need to save about a Transaction request in order
* to dissect the reply; this includes information for use by the
* Remote API and Mailslot dissectors.
* XXX - have an additional data structure hung off of this by the
* subdissectors?
*/
typedef struct {
int subcmd;
int trans_subcmd;
int function;
/* Unification of fid variable type (was int) */
guint16 fid;
guint16 lanman_cmd;
guchar *param_descrip; /* Keep these descriptors around */
guchar *data_descrip;
guchar *aux_data_descrip;
int info_level;
} smb_transact_info_t;
/*
* Subcommand type.
*/
#define TRANSACTION_PIPE 0
#define TRANSACTION_MAILSLOT 1
/* these are defines used to represent different types of TIDs.
don't use the value 0 for any of these */
#define TID_NORMAL 1
#define TID_IPC 2
/* this is the structure which is associated with each conversation */
typedef struct conv_tables {
/* these two tables are used to match requests with responses */
GHashTable *unmatched;
GHashTable *matched;
/* This table keeps primary transact requests so secondaries can find
them */
GHashTable *primaries;
/* This table is used to track TID->services for a conversation */
GHashTable *tid_service;
gboolean raw_ntlmssp; /* Do extended security exc use raw ntlmssp */
/* track fid to fidstruct (filename/openframe/closeframe */
wmem_tree_t *fid_tree;
/* We'll use a GSL list instead */
GSList *GSL_fid_info;
/* track tid to fidstruct (sharename/shareframe/unshareframe */
wmem_tree_t *tid_tree;
/* track uid to username mappings */
wmem_tree_t *uid_tree;
} conv_tables_t;
typedef struct smb_info {
guint8 cmd;
int tid, pid, uid, mid;
guint32 nt_status;
gboolean unicode; /* Are strings in this SMB Unicode? */
gboolean request; /* Is this a request? */
gboolean unidir;
int info_level;
int info_count;
smb_saved_info_t *sip; /* smb_saved_info_t, if any, for this */
conv_tables_t *ct;
} smb_info_t;
/*
* Show file data for a read or write.
*/
extern int dissect_file_data(tvbuff_t *tvb, proto_tree *tree, int offset,
guint16 bc, int dataoffset, guint16 datalen);
#define SMB_FID_TYPE_UNKNOWN 0
#define SMB_FID_TYPE_FILE 1
#define SMB_FID_TYPE_DIR 2
#define SMB_FID_TYPE_PIPE 3
/* used for tracking filenames from rename request to response */
typedef struct _smb_rename_saved_info_t {
char *old_name;
char *new_name;
} smb_rename_saved_info_t;
/* used for tracking lock data between lock request/response */
typedef struct _smb_lock_info_t {
struct _smb_lock_info_t *next;
guint16 pid;
guint64 offset;
guint64 length;
} smb_lock_info_t;
typedef struct _smb_locking_saved_info_t {
guint8 type;
guint8 oplock_level;
guint16 num_lock;
guint16 num_unlock;
smb_lock_info_t *locks;
smb_lock_info_t *unlocks;
} smb_locking_saved_info_t;
/* used for tracking fid/tid to filename/sharename openedframe closedframe */
typedef struct _smb_fid_saved_info_t {
char *filename;
guint32 create_flags;
guint32 access_mask;
guint32 file_attributes;
guint32 share_access;
guint32 create_options;
guint32 create_disposition;
} smb_fid_saved_info_t;
struct _smb_fid_into_t {
guint16 tid,fid;
/* The end_of_file will store the last registered offset or
the reported end_of_file from the SMB protocol */
gint64 end_of_file;
/* These two were int */
guint opened_in;
guint closed_in;
int type;
smb_fid_saved_info_t *fsi;
};
/* used for tracking tid to sharename openedframe closedframe */
typedef struct _smb_tid_into_t {
int opened_in;
int closed_in;
char *filename;
int type;
} smb_tid_info_t;
/*
* Dissect an smb FID
*/
extern smb_fid_info_t *dissect_smb_fid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
int offset, int len, guint16 fid, gboolean is_created, gboolean is_closed, gboolean is_generated, smb_info_t* si);
/*
* Dissect named pipe state information.
*/
extern int dissect_ipc_state(tvbuff_t *tvb, proto_tree *parent_tree,
int offset, gboolean setstate);
extern gboolean smb_dcerpc_reassembly;
extern const value_string create_disposition_vals[];
extern int dissect_nt_create_options(tvbuff_t *tvb, proto_tree *parent_tree, int offset);
extern int dissect_nt_share_access(tvbuff_t *tvb, proto_tree *parent_tree, int offset);
extern int dissect_smb_access_mask(tvbuff_t *tvb, proto_tree *parent_tree, int offset);
extern const value_string oa_open_vals[];
extern const value_string impersonation_level_vals[];
extern gboolean sid_display_hex;
extern int dissect_security_information_mask(tvbuff_t *tvb, proto_tree *parent_tree, int offset);
extern int dissect_qfsi_FS_VOLUME_INFO(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, int offset, guint16 *bcp, int unicode);
extern int dissect_qfsi_FS_SIZE_INFO(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, int offset, guint16 *bcp);
extern int dissect_qfsi_FS_DEVICE_INFO(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, int offset, guint16 *bcp);
extern int dissect_qfsi_FS_ATTRIBUTE_INFO(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, int offset, guint16 *bcp);
extern int dissect_nt_quota(tvbuff_t *tvb, proto_tree *tree, int offset, guint16 *bcp);
extern int dissect_nt_user_quota(tvbuff_t *tvb, proto_tree *tree, int offset, guint16 *bcp);
extern int dissect_nt_get_user_quota(tvbuff_t *tvb, proto_tree *tree, int offset, guint32 *bcp);
extern int dissect_qfsi_FS_OBJECTID_INFO(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, int offset, guint16 *bcp);
extern int dissect_qfsi_FS_FULL_SIZE_INFO(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, int offset, guint16 *bcp);
extern int dissect_qfi_SMB_FILE_EA_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, guint16 *bcp, gboolean *trunc);
extern int dissect_qfi_SMB_FILE_STREAM_INFO(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, guint16 *bcp, gboolean *trunc, int unicode);
extern int dissect_qfi_SMB_FILE_NAME_INFO(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint16 *bcp, gboolean *trunc, gboolean unicode);
extern int dissect_qfi_SMB_FILE_STANDARD_INFO(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint16 *bcp, gboolean *trunc);
extern int dissect_qfi_SMB_FILE_INTERNAL_INFO(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint16 *bcp, gboolean *trunc);
extern int dissect_qsfi_SMB_FILE_POSITION_INFO(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint16 *bcp, gboolean *trunc);
extern int dissect_qsfi_SMB_FILE_MODE_INFO(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint16 *bcp, gboolean *trunc);
extern int dissect_qfi_SMB_FILE_ALIGNMENT_INFO(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint16 *bcp, gboolean *trunc);
extern int dissect_qfi_SMB_FILE_COMPRESSION_INFO(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint16 *bcp, gboolean *trunc);
extern int dissect_qfi_SMB_FILE_NETWORK_OPEN_INFO(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint16 *bcp, gboolean *trunc);
extern int dissect_qfi_SMB_FILE_ATTRIBUTE_TAG_INFO(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint16 *bcp, gboolean *trunc);
extern int dissect_qsfi_SMB_FILE_ALLOCATION_INFO(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint16 *bcp, gboolean *trunc);
extern int dissect_qsfi_SMB_FILE_ENDOFFILE_INFO(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint16 *bcp, gboolean *trunc);
extern int dissect_nt_notify_completion_filter(tvbuff_t *tvb, proto_tree *parent_tree, int offset);
extern int dissect_sfi_SMB_FILE_PIPE_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, guint16 *bcp, gboolean *trunc);
extern int dissect_get_dfs_request_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint16 *bcp, gboolean unicode);
extern int dissect_get_dfs_referral_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint16 *bcp, gboolean unicode);
/* Returns an IP (v4 or v6) of the server in a SMB/SMB2 conversation */
extern const gchar *tree_ip_str(packet_info *pinfo, guint16 cmd);
#endif
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-smb2.c
|
/* packet-smb2.c
* Routines for smb2 packet dissection
* Ronnie Sahlberg 2005
*
* For documentation of this protocol, see:
*
* https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/
* https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/
* https://gitlab.com/wireshark/wireshark/-/wikis/SMB2
*
* If you edit this file, keep the wiki updated as well.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/prefs.h>
#include <epan/expert.h>
#include <epan/tap.h>
#include <epan/srt_table.h>
#include <epan/aftypes.h>
#include <epan/to_str.h>
#include <epan/strutil.h>
#include <epan/asn1.h>
#include <epan/reassemble.h>
#include <epan/uat.h>
#include "packet-smb2.h"
#include "packet-ntlmssp.h"
#include "packet-kerberos.h"
#include "packet-windows-common.h"
#include "packet-dcerpc-nt.h"
#include "read_keytab_file.h"
#include <wsutil/wsgcrypt.h>
#include <wsutil/ws_roundup.h>
#ifdef _WIN32
#include <windows.h>
#else
/* Defined in winnt.h */
#define OWNER_SECURITY_INFORMATION 0x00000001
#define GROUP_SECURITY_INFORMATION 0x00000002
#define DACL_SECURITY_INFORMATION 0x00000004
#define SACL_SECURITY_INFORMATION 0x00000008
#define LABEL_SECURITY_INFORMATION 0x00000010
#define ATTRIBUTE_SECURITY_INFORMATION 0x00000020
#define SCOPE_SECURITY_INFORMATION 0x00000040
#define BACKUP_SECURITY_INFORMATION 0x00010000
#endif
//#define DEBUG_SMB2
#ifdef DEBUG_SMB2
#define DEBUG(...) g_ ## warning(__VA_ARGS__)
#define HEXDUMP(p, sz) do_hexdump((const guint8 *)(p), sz)
static void
do_hexdump (const guint8 *data, gsize len)
{
guint n, m;
for (n = 0; n < len; n += 16) {
g_printerr ("%04x: ", n);
for (m = n; m < n + 16; m++) {
if (m > n && (m%4) == 0)
g_printerr (" ");
if (m < len)
g_printerr ("%02x ", data[m]);
else
g_printerr (" ");
}
g_printerr (" ");
for (m = n; m < len && m < n + 16; m++)
g_printerr ("%c", g_ascii_isprint (data[m]) ? data[m] : '.');
g_printerr ("\n");
}
}
#else
#define DEBUG(...)
#define HEXDUMP(...)
#endif
#define NT_STATUS_PENDING 0x00000103
#define NT_STATUS_BUFFER_TOO_SMALL 0xC0000023
#define NT_STATUS_STOPPED_ON_SYMLINK 0x8000002D
#define NT_STATUS_BAD_NETWORK_NAME 0xC00000CC
void proto_register_smb2(void);
void proto_reg_handoff_smb2(void);
#define SMB2_NORM_HEADER 0xFE
#define SMB2_ENCR_HEADER 0xFD
#define SMB2_COMP_HEADER 0xFC
static wmem_map_t *smb2_sessions = NULL;
static const char smb_header_label[] = "SMB2 Header";
static const char smb_transform_header_label[] = "SMB2 Transform Header";
static const char smb_comp_transform_header_label[] = "SMB2 Compression Transform Header";
static const char smb_bad_header_label[] = "Bad SMB2 Header";
static int proto_smb2 = -1;
static int hf_smb2_cmd = -1;
static int hf_smb2_nt_status = -1;
static int hf_smb2_response_to = -1;
static int hf_smb2_response_in = -1;
static int hf_smb2_time = -1;
static int hf_smb2_preauth_hash = -1;
static int hf_smb2_header_len = -1;
static int hf_smb2_msg_id = -1;
static int hf_smb2_pid = -1;
static int hf_smb2_tid = -1;
static int hf_smb2_aid = -1;
static int hf_smb2_sesid = -1;
static int hf_smb2_previous_sesid = -1;
static int hf_smb2_flags_response = -1;
static int hf_smb2_flags_async_cmd = -1;
static int hf_smb2_flags_dfs_op = -1;
static int hf_smb2_flags_chained = -1;
static int hf_smb2_flags_signature = -1;
static int hf_smb2_flags_replay_operation = -1;
static int hf_smb2_flags_priority_mask = -1;
static int hf_smb2_chain_offset = -1;
static int hf_smb2_security_blob = -1;
static int hf_smb2_ioctl_in_data = -1;
static int hf_smb2_ioctl_out_data = -1;
static int hf_smb2_unknown = -1;
static int hf_smb2_root_directory_mbz = -1;
static int hf_smb2_twrp_timestamp = -1;
static int hf_smb2_mxac_timestamp = -1;
static int hf_smb2_mxac_status = -1;
static int hf_smb2_qfid_fid = -1;
static int hf_smb2_create_timestamp = -1;
static int hf_smb2_oplock = -1;
static int hf_smb2_close_flags = -1;
static int hf_smb2_notify_flags = -1;
static int hf_smb2_last_access_timestamp = -1;
static int hf_smb2_last_write_timestamp = -1;
static int hf_smb2_last_change_timestamp = -1;
static int hf_smb2_current_time = -1;
static int hf_smb2_boot_time = -1;
static int hf_smb2_filename = -1;
static int hf_smb2_filename_len = -1;
static int hf_smb2_replace_if = -1;
static int hf_smb2_nlinks = -1;
static int hf_smb2_delete_pending = -1;
static int hf_smb2_is_directory = -1;
static int hf_smb2_file_id = -1;
static int hf_smb2_allocation_size = -1;
static int hf_smb2_end_of_file = -1;
static int hf_smb2_tree = -1;
static int hf_smb2_find_pattern = -1;
static int hf_smb2_find_info_level = -1;
static int hf_smb2_find_info_blob = -1;
static int hf_smb2_client_guid = -1;
static int hf_smb2_server_guid = -1;
static int hf_smb2_object_id = -1;
static int hf_smb2_birth_volume_id = -1;
static int hf_smb2_birth_object_id = -1;
static int hf_smb2_domain_id = -1;
static int hf_smb2_class = -1;
static int hf_smb2_infolevel = -1;
static int hf_smb2_infolevel_file_info = -1;
static int hf_smb2_infolevel_fs_info = -1;
static int hf_smb2_infolevel_sec_info = -1;
static int hf_smb2_max_response_size = -1;
static int hf_smb2_max_ioctl_in_size = -1;
static int hf_smb2_max_ioctl_out_size = -1;
static int hf_smb2_flags = -1;
static int hf_smb2_required_buffer_size = -1;
static int hf_smb2_getinfo_input_size = -1;
static int hf_smb2_getinfo_input_offset = -1;
static int hf_smb2_getsetinfo_additional = -1;
static int hf_smb2_getsetinfo_additionals = -1;
static int hf_smb2_getsetinfo_additional_owner = -1;
static int hf_smb2_getsetinfo_additional_group = -1;
static int hf_smb2_getsetinfo_additional_dacl = -1;
static int hf_smb2_getsetinfo_additional_sacl = -1;
static int hf_smb2_getsetinfo_additional_label = -1;
static int hf_smb2_getsetinfo_additional_attribute = -1;
static int hf_smb2_getsetinfo_additional_scope = -1;
static int hf_smb2_getsetinfo_additional_backup = -1;
static int hf_smb2_getinfo_flags = -1;
static int hf_smb2_setinfo_size = -1;
static int hf_smb2_setinfo_offset = -1;
static int hf_smb2_setinfo_reserved = -1;
static int hf_smb2_file_basic_info = -1;
static int hf_smb2_file_standard_info = -1;
static int hf_smb2_file_internal_info = -1;
static int hf_smb2_file_ea_info = -1;
static int hf_smb2_file_access_info = -1;
static int hf_smb2_file_rename_info = -1;
static int hf_smb2_file_disposition_info = -1;
static int hf_smb2_file_position_info = -1;
static int hf_smb2_file_full_ea_info = -1;
static int hf_smb2_file_mode_info = -1;
static int hf_smb2_file_alignment_info = -1;
static int hf_smb2_file_all_info = -1;
static int hf_smb2_file_allocation_info = -1;
static int hf_smb2_file_endoffile_info = -1;
static int hf_smb2_file_alternate_name_info = -1;
static int hf_smb2_file_stream_info = -1;
static int hf_smb2_file_pipe_info = -1;
static int hf_smb2_file_compression_info = -1;
static int hf_smb2_file_network_open_info = -1;
static int hf_smb2_file_attribute_tag_info = -1;
static int hf_smb2_file_normalized_name_info = -1;
static int hf_smb2_fs_info_01 = -1;
static int hf_smb2_fs_info_03 = -1;
static int hf_smb2_fs_info_04 = -1;
static int hf_smb2_fs_info_05 = -1;
static int hf_smb2_fs_info_06 = -1;
static int hf_smb2_fs_info_07 = -1;
static int hf_smb2_fs_objectid_info = -1;
static int hf_smb2_sec_info_00 = -1;
static int hf_smb2_quota_info = -1;
static int hf_smb2_query_quota_info = -1;
static int hf_smb2_qq_single = -1;
static int hf_smb2_qq_restart = -1;
static int hf_smb2_qq_sidlist_len = -1;
static int hf_smb2_qq_start_sid_len = -1;
static int hf_smb2_qq_start_sid_offset = -1;
static int hf_smb2_fid = -1;
static int hf_smb2_write_length = -1;
static int hf_smb2_write_data = -1;
static int hf_smb2_write_flags = -1;
static int hf_smb2_write_flags_write_through = -1;
static int hf_smb2_write_flags_write_unbuffered = -1;
static int hf_smb2_write_count = -1;
static int hf_smb2_write_remaining = -1;
static int hf_smb2_read_blob = -1;
static int hf_smb2_read_length = -1;
static int hf_smb2_read_remaining = -1;
static int hf_smb2_read_padding = -1;
static int hf_smb2_read_flags = -1;
static int hf_smb2_read_flags_unbuffered = -1;
static int hf_smb2_read_flags_compressed = -1;
static int hf_smb2_file_offset = -1;
static int hf_smb2_qfr_length = -1;
static int hf_smb2_qfr_usage = -1;
static int hf_smb2_qfr_flags = -1;
static int hf_smb2_qfr_total_region_entry_count = -1;
static int hf_smb2_qfr_region_entry_count = -1;
static int hf_smb2_read_data = -1;
static int hf_smb2_disposition_delete_on_close = -1;
static int hf_smb2_create_disposition = -1;
static int hf_smb2_create_chain_offset = -1;
static int hf_smb2_create_chain_data = -1;
static int hf_smb2_data_offset = -1;
static int hf_smb2_extrainfo = -1;
static int hf_smb2_create_action = -1;
static int hf_smb2_create_rep_flags = -1;
static int hf_smb2_create_rep_flags_reparse_point = -1;
static int hf_smb2_next_offset = -1;
static int hf_smb2_negotiate_context_type = -1;
static int hf_smb2_negotiate_context_data_length = -1;
static int hf_smb2_negotiate_context_offset = -1;
static int hf_smb2_negotiate_context_count = -1;
static int hf_smb2_hash_alg_count = -1;
static int hf_smb2_hash_algorithm = -1;
static int hf_smb2_salt_length = -1;
static int hf_smb2_salt = -1;
static int hf_smb2_cipher_count = -1;
static int hf_smb2_cipher_id = -1;
static int hf_smb2_signing_alg_count = -1;
static int hf_smb2_signing_alg_id = -1;
static int hf_smb2_comp_alg_count = -1;
static int hf_smb2_comp_alg_id = -1;
static int hf_smb2_comp_alg_flags = -1;
static int hf_smb2_comp_alg_flags_chained = -1;
static int hf_smb2_comp_alg_flags_reserved = -1;
static int hf_smb2_netname_neg_id = -1;
static int hf_smb2_transport_ctx_flags = -1;
static int hf_smb2_rdma_transform_count = -1;
static int hf_smb2_rdma_transform_reserved1 = -1;
static int hf_smb2_rdma_transform_reserved2 = -1;
static int hf_smb2_rdma_transform_id = -1;
static int hf_smb2_posix_reserved = -1;
static int hf_smb2_inode = -1;
static int hf_smb2_ea_size = -1;
static int hf_smb2_ea_flags = -1;
static int hf_smb2_ea_name_len = -1;
static int hf_smb2_ea_data_len = -1;
static int hf_smb2_ea_name = -1;
static int hf_smb2_ea_data = -1;
static int hf_smb2_position_information = -1;
static int hf_smb2_mode_information = -1;
static int hf_smb2_mode_file_write_through = -1;
static int hf_smb2_mode_file_sequential_only = -1;
static int hf_smb2_mode_file_no_intermediate_buffering = -1;
static int hf_smb2_mode_file_synchronous_io_alert = -1;
static int hf_smb2_mode_file_synchronous_io_nonalert = -1;
static int hf_smb2_mode_file_delete_on_close = -1;
static int hf_smb2_alignment_information = -1;
static int hf_smb2_buffer_code = -1;
static int hf_smb2_buffer_code_len = -1;
static int hf_smb2_buffer_code_flags_dyn = -1;
static int hf_smb2_olb_offset = -1;
static int hf_smb2_olb_length = -1;
static int hf_smb2_tag = -1;
static int hf_smb2_impersonation_level = -1;
static int hf_smb2_ioctl_function = -1;
static int hf_smb2_ioctl_function_device = -1;
static int hf_smb2_ioctl_function_access = -1;
static int hf_smb2_ioctl_function_function = -1;
static int hf_smb2_fsctl_pipe_wait_timeout = -1;
static int hf_smb2_fsctl_pipe_wait_name = -1;
static int hf_smb2_fsctl_odx_token_type = -1;
static int hf_smb2_fsctl_odx_token_idlen = -1;
static int hf_smb2_fsctl_odx_token_idraw = -1;
static int hf_smb2_fsctl_odx_token_ttl = -1;
static int hf_smb2_fsctl_odx_size = -1;
static int hf_smb2_fsctl_odx_flags = -1;
static int hf_smb2_fsctl_odx_file_offset = -1;
static int hf_smb2_fsctl_odx_copy_length = -1;
static int hf_smb2_fsctl_odx_xfer_length = -1;
static int hf_smb2_fsctl_odx_token_offset = -1;
static int hf_smb2_fsctl_sparse_flag = -1;
static int hf_smb2_fsctl_range_offset = -1;
static int hf_smb2_fsctl_range_length = -1;
static int hf_smb2_ioctl_function_method = -1;
static int hf_smb2_ioctl_resiliency_timeout = -1;
static int hf_smb2_ioctl_resiliency_reserved = -1;
static int hf_smb2_ioctl_shared_virtual_disk_support = -1;
static int hf_smb2_ioctl_shared_virtual_disk_handle_state = -1;
static int hf_smb2_ioctl_sqos_protocol_version = -1;
static int hf_smb2_ioctl_sqos_reserved = -1;
static int hf_smb2_ioctl_sqos_options = -1;
static int hf_smb2_ioctl_sqos_op_set_logical_flow_id = -1;
static int hf_smb2_ioctl_sqos_op_set_policy = -1;
static int hf_smb2_ioctl_sqos_op_probe_policy = -1;
static int hf_smb2_ioctl_sqos_op_get_status = -1;
static int hf_smb2_ioctl_sqos_op_update_counters = -1;
static int hf_smb2_ioctl_sqos_logical_flow_id = -1;
static int hf_smb2_ioctl_sqos_policy_id = -1;
static int hf_smb2_ioctl_sqos_initiator_id = -1;
static int hf_smb2_ioctl_sqos_limit = -1;
static int hf_smb2_ioctl_sqos_reservation = -1;
static int hf_smb2_ioctl_sqos_initiator_name = -1;
static int hf_smb2_ioctl_sqos_initiator_node_name = -1;
static int hf_smb2_ioctl_sqos_io_count_increment = -1;
static int hf_smb2_ioctl_sqos_normalized_io_count_increment = -1;
static int hf_smb2_ioctl_sqos_latency_increment = -1;
static int hf_smb2_ioctl_sqos_lower_latency_increment = -1;
static int hf_smb2_ioctl_sqos_bandwidth_limit = -1;
static int hf_smb2_ioctl_sqos_kilobyte_count_increment = -1;
static int hf_smb2_ioctl_sqos_time_to_live = -1;
static int hf_smb2_ioctl_sqos_status = -1;
static int hf_smb2_ioctl_sqos_maximum_io_rate = -1;
static int hf_smb2_ioctl_sqos_minimum_io_rate = -1;
static int hf_smb2_ioctl_sqos_base_io_size = -1;
static int hf_smb2_ioctl_sqos_reserved2 = -1;
static int hf_smb2_ioctl_sqos_maximum_bandwidth = -1;
static int hf_windows_sockaddr_family = -1;
static int hf_windows_sockaddr_port = -1;
static int hf_windows_sockaddr_in_addr = -1;
static int hf_windows_sockaddr_in6_flowinfo = -1;
static int hf_windows_sockaddr_in6_addr = -1;
static int hf_windows_sockaddr_in6_scope_id = -1;
static int hf_smb2_ioctl_network_interface_next_offset = -1;
static int hf_smb2_ioctl_network_interface_index = -1;
static int hf_smb2_ioctl_network_interface_rss_queue_count = -1;
static int hf_smb2_ioctl_network_interface_capabilities = -1;
static int hf_smb2_ioctl_network_interface_capability_rss = -1;
static int hf_smb2_ioctl_network_interface_capability_rdma = -1;
static int hf_smb2_ioctl_network_interface_link_speed = -1;
static int hf_smb2_ioctl_enumerate_snapshots_num_snapshots = -1;
static int hf_smb2_ioctl_enumerate_snapshots_num_snapshots_returned = -1;
static int hf_smb2_ioctl_enumerate_snapshots_snapshot_array_size = -1;
static int hf_smb2_ioctl_enumerate_snapshots_snapshot = -1;
static int hf_smb2_compression_format = -1;
static int hf_smb2_checksum_algorithm = -1;
static int hf_smb2_integrity_reserved = -1;
static int hf_smb2_integrity_flags = -1;
static int hf_smb2_integrity_flags_enforcement_off = -1;
static int hf_smb2_FILE_OBJECTID_BUFFER = -1;
static int hf_smb2_lease_key = -1;
static int hf_smb2_lease_state = -1;
static int hf_smb2_lease_state_read_caching = -1;
static int hf_smb2_lease_state_handle_caching = -1;
static int hf_smb2_lease_state_write_caching = -1;
static int hf_smb2_lease_flags = -1;
static int hf_smb2_lease_flags_break_ack_required = -1;
static int hf_smb2_lease_flags_parent_lease_key_set = -1;
static int hf_smb2_lease_flags_break_in_progress = -1;
static int hf_smb2_lease_duration = -1;
static int hf_smb2_parent_lease_key = -1;
static int hf_smb2_lease_epoch = -1;
static int hf_smb2_lease_reserved = -1;
static int hf_smb2_lease_break_reason = -1;
static int hf_smb2_lease_access_mask_hint = -1;
static int hf_smb2_lease_share_mask_hint = -1;
static int hf_smb2_acct_name = -1;
static int hf_smb2_domain_name = -1;
static int hf_smb2_host_name = -1;
static int hf_smb2_auth_frame = -1;
static int hf_smb2_tcon_frame = -1;
static int hf_smb2_share_type = -1;
static int hf_smb2_signature = -1;
static int hf_smb2_credit_charge = -1;
static int hf_smb2_credits_requested = -1;
static int hf_smb2_credits_granted = -1;
static int hf_smb2_channel_sequence = -1;
static int hf_smb2_dialect_count = -1;
static int hf_smb2_security_mode = -1;
static int hf_smb2_secmode_flags_sign_required = -1;
static int hf_smb2_secmode_flags_sign_enabled = -1;
static int hf_smb2_ses_req_flags = -1;
static int hf_smb2_ses_req_flags_session_binding = -1;
static int hf_smb2_capabilities = -1;
static int hf_smb2_cap_dfs = -1;
static int hf_smb2_cap_leasing = -1;
static int hf_smb2_cap_large_mtu = -1;
static int hf_smb2_cap_multi_channel = -1;
static int hf_smb2_cap_persistent_handles = -1;
static int hf_smb2_cap_directory_leasing = -1;
static int hf_smb2_cap_encryption = -1;
static int hf_smb2_dialect = -1;
static int hf_smb2_max_trans_size = -1;
static int hf_smb2_max_read_size = -1;
static int hf_smb2_max_write_size = -1;
static int hf_smb2_channel = -1;
static int hf_smb2_rdma_v1_offset = -1;
static int hf_smb2_rdma_v1_token = -1;
static int hf_smb2_rdma_v1_length = -1;
static int hf_smb2_session_flags = -1;
static int hf_smb2_ses_flags_guest = -1;
static int hf_smb2_ses_flags_null = -1;
static int hf_smb2_ses_flags_encrypt = -1;
static int hf_smb2_share_flags = -1;
static int hf_smb2_share_flags_dfs = -1;
static int hf_smb2_share_flags_dfs_root = -1;
static int hf_smb2_share_flags_restrict_exclusive_opens = -1;
static int hf_smb2_share_flags_force_shared_delete = -1;
static int hf_smb2_share_flags_allow_namespace_caching = -1;
static int hf_smb2_share_flags_access_based_dir_enum = -1;
static int hf_smb2_share_flags_force_levelii_oplock = -1;
static int hf_smb2_share_flags_enable_hash_v1 = -1;
static int hf_smb2_share_flags_enable_hash_v2 = -1;
static int hf_smb2_share_flags_encrypt_data = -1;
static int hf_smb2_share_flags_identity_remoting = -1;
static int hf_smb2_share_flags_compress_data = -1;
static int hf_smb2_share_flags_isolated_transport = -1;
static int hf_smb2_share_caching = -1;
static int hf_smb2_share_caps = -1;
static int hf_smb2_share_caps_dfs = -1;
static int hf_smb2_share_caps_continuous_availability = -1;
static int hf_smb2_share_caps_scaleout = -1;
static int hf_smb2_share_caps_cluster = -1;
static int hf_smb2_share_caps_assymetric = -1;
static int hf_smb2_share_caps_redirect_to_owner = -1;
static int hf_smb2_create_flags = -1;
static int hf_smb2_lock_count = -1;
static int hf_smb2_lock_sequence_number = -1;
static int hf_smb2_lock_sequence_index = -1;
static int hf_smb2_min_count = -1;
static int hf_smb2_remaining_bytes = -1;
static int hf_smb2_channel_info_offset = -1;
static int hf_smb2_channel_info_length = -1;
static int hf_smb2_channel_info_blob = -1;
static int hf_smb2_ioctl_flags = -1;
static int hf_smb2_ioctl_is_fsctl = -1;
static int hf_smb2_close_pq_attrib = -1;
static int hf_smb2_notify_watch_tree = -1;
static int hf_smb2_output_buffer_len = -1;
static int hf_smb2_notify_out_data = -1;
static int hf_smb2_notify_info = -1;
static int hf_smb2_notify_next_offset = -1;
static int hf_smb2_notify_action = -1;
static int hf_smb2_find_flags = -1;
static int hf_smb2_find_flags_restart_scans = -1;
static int hf_smb2_find_flags_single_entry = -1;
static int hf_smb2_find_flags_index_specified = -1;
static int hf_smb2_find_flags_reopen = -1;
static int hf_smb2_file_index = -1;
static int hf_smb2_file_directory_info = -1;
static int hf_smb2_both_directory_info = -1;
static int hf_smb2_posix_info = -1;
static int hf_smb2_short_name_len = -1;
static int hf_smb2_short_name = -1;
static int hf_smb2_id_both_directory_info = -1;
static int hf_smb2_full_directory_info = -1;
static int hf_smb2_lock_info = -1;
static int hf_smb2_lock_length = -1;
static int hf_smb2_lock_flags = -1;
static int hf_smb2_lock_flags_shared = -1;
static int hf_smb2_lock_flags_exclusive = -1;
static int hf_smb2_lock_flags_unlock = -1;
static int hf_smb2_lock_flags_fail_immediately = -1;
static int hf_smb2_dhnq_buffer_reserved = -1;
static int hf_smb2_dh2x_buffer_timeout = -1;
static int hf_smb2_dh2x_buffer_flags = -1;
static int hf_smb2_dh2x_buffer_flags_persistent_handle = -1;
static int hf_smb2_dh2x_buffer_reserved = -1;
static int hf_smb2_dh2x_buffer_create_guid = -1;
static int hf_smb2_APP_INSTANCE_buffer_struct_size = -1;
static int hf_smb2_APP_INSTANCE_buffer_reserved = -1;
static int hf_smb2_APP_INSTANCE_buffer_app_guid = -1;
static int hf_smb2_svhdx_open_device_context_version = -1;
static int hf_smb2_svhdx_open_device_context_has_initiator_id = -1;
static int hf_smb2_svhdx_open_device_context_reserved = -1;
static int hf_smb2_svhdx_open_device_context_initiator_id = -1;
static int hf_smb2_svhdx_open_device_context_flags = -1;
static int hf_smb2_svhdx_open_device_context_originator_flags = -1;
static int hf_smb2_svhdx_open_device_context_open_request_id = -1;
static int hf_smb2_svhdx_open_device_context_initiator_host_name_len = -1;
static int hf_smb2_svhdx_open_device_context_initiator_host_name = -1;
static int hf_smb2_svhdx_open_device_context_virtual_disk_properties_initialized = -1;
static int hf_smb2_svhdx_open_device_context_server_service_version = -1;
static int hf_smb2_svhdx_open_device_context_virtual_sector_size = -1;
static int hf_smb2_svhdx_open_device_context_physical_sector_size = -1;
static int hf_smb2_svhdx_open_device_context_virtual_size = -1;
static int hf_smb2_app_instance_version_struct_size = -1;
static int hf_smb2_app_instance_version_reserved = -1;
static int hf_smb2_app_instance_version_padding = -1;
static int hf_smb2_app_instance_version_high = -1;
static int hf_smb2_app_instance_version_low = -1;
static int hf_smb2_posix_perms = -1;
static int hf_smb2_aapl_command_code = -1;
static int hf_smb2_aapl_reserved = -1;
static int hf_smb2_aapl_server_query_bitmask = -1;
static int hf_smb2_aapl_server_query_bitmask_server_caps = -1;
static int hf_smb2_aapl_server_query_bitmask_volume_caps = -1;
static int hf_smb2_aapl_server_query_bitmask_model_info = -1;
static int hf_smb2_aapl_server_query_caps = -1;
static int hf_smb2_aapl_server_query_caps_supports_read_dir_attr = -1;
static int hf_smb2_aapl_server_query_caps_supports_osx_copyfile = -1;
static int hf_smb2_aapl_server_query_caps_unix_based = -1;
static int hf_smb2_aapl_server_query_caps_supports_nfs_ace = -1;
static int hf_smb2_aapl_server_query_volume_caps = -1;
static int hf_smb2_aapl_server_query_volume_caps_support_resolve_id = -1;
static int hf_smb2_aapl_server_query_volume_caps_case_sensitive = -1;
static int hf_smb2_aapl_server_query_volume_caps_supports_full_sync = -1;
static int hf_smb2_aapl_server_query_model_string = -1;
static int hf_smb2_aapl_server_query_server_path = -1;
static int hf_smb2_error_context_count = -1;
static int hf_smb2_error_reserved = -1;
static int hf_smb2_error_byte_count = -1;
static int hf_smb2_error_data = -1;
static int hf_smb2_error_context = -1;
static int hf_smb2_error_context_length = -1;
static int hf_smb2_error_context_id = -1;
static int hf_smb2_error_min_buf_length = -1;
static int hf_smb2_error_redir_context = -1;
static int hf_smb2_error_redir_struct_size = -1;
static int hf_smb2_error_redir_notif_type = -1;
static int hf_smb2_error_redir_flags = -1;
static int hf_smb2_error_redir_target_type = -1;
static int hf_smb2_error_redir_ip_count = -1;
static int hf_smb2_error_redir_ip_list = -1;
static int hf_smb2_error_redir_res_name = -1;
static int hf_smb2_reserved = -1;
static int hf_smb2_reserved_random = -1;
static int hf_smb2_transform_signature = -1;
static int hf_smb2_transform_nonce = -1;
static int hf_smb2_transform_msg_size = -1;
static int hf_smb2_transform_reserved = -1;
static int hf_smb2_transform_flags = -1;
static int hf_smb2_transform_flags_encrypted = -1;
static int hf_smb2_transform_encrypted_data = -1;
static int hf_smb2_protocol_id = -1;
static int hf_smb2_comp_transform_orig_size = -1;
static int hf_smb2_comp_transform_comp_alg = -1;
static int hf_smb2_comp_transform_flags = -1;
static int hf_smb2_comp_transform_offset = -1;
static int hf_smb2_comp_transform_length = -1;
static int hf_smb2_comp_transform_data = -1;
static int hf_smb2_comp_transform_orig_payload_size = -1;
static int hf_smb2_comp_pattern_v1_pattern = -1;
static int hf_smb2_comp_pattern_v1_reserved1 = -1;
static int hf_smb2_comp_pattern_v1_reserved2 = -1;
static int hf_smb2_comp_pattern_v1_repetitions = -1;
static int hf_smb2_truncated = -1;
static int hf_smb2_pipe_fragments = -1;
static int hf_smb2_pipe_fragment = -1;
static int hf_smb2_pipe_fragment_overlap = -1;
static int hf_smb2_pipe_fragment_overlap_conflict = -1;
static int hf_smb2_pipe_fragment_multiple_tails = -1;
static int hf_smb2_pipe_fragment_too_long_fragment = -1;
static int hf_smb2_pipe_fragment_error = -1;
static int hf_smb2_pipe_fragment_count = -1;
static int hf_smb2_pipe_reassembled_in = -1;
static int hf_smb2_pipe_reassembled_length = -1;
static int hf_smb2_pipe_reassembled_data = -1;
static int hf_smb2_cchunk_resume_key = -1;
static int hf_smb2_cchunk_count = -1;
static int hf_smb2_cchunk_src_offset = -1;
static int hf_smb2_cchunk_dst_offset = -1;
static int hf_smb2_cchunk_xfer_len = -1;
static int hf_smb2_cchunk_chunks_written = -1;
static int hf_smb2_cchunk_bytes_written = -1;
static int hf_smb2_cchunk_total_written = -1;
static int hf_smb2_reparse_data_buffer = -1;
static int hf_smb2_reparse_tag = -1;
static int hf_smb2_reparse_guid = -1;
static int hf_smb2_reparse_data_length = -1;
static int hf_smb2_nfs_type = -1;
static int hf_smb2_nfs_symlink_target = -1;
static int hf_smb2_nfs_chr_major = -1;
static int hf_smb2_nfs_chr_minor = -1;
static int hf_smb2_nfs_blk_major = -1;
static int hf_smb2_nfs_blk_minor = -1;
static int hf_smb2_symlink_error_response = -1;
static int hf_smb2_symlink_length = -1;
static int hf_smb2_symlink_error_tag = -1;
static int hf_smb2_unparsed_path_length = -1;
static int hf_smb2_symlink_substitute_name = -1;
static int hf_smb2_symlink_print_name = -1;
static int hf_smb2_symlink_flags = -1;
static int hf_smb2_bad_signature = -1;
static int hf_smb2_good_signature = -1;
static int hf_smb2_fscc_file_attr = -1;
static int hf_smb2_fscc_file_attr_archive = -1;
static int hf_smb2_fscc_file_attr_compressed = -1;
static int hf_smb2_fscc_file_attr_directory = -1;
static int hf_smb2_fscc_file_attr_encrypted = -1;
static int hf_smb2_fscc_file_attr_hidden = -1;
static int hf_smb2_fscc_file_attr_normal = -1;
static int hf_smb2_fscc_file_attr_not_content_indexed = -1;
static int hf_smb2_fscc_file_attr_offline = -1;
static int hf_smb2_fscc_file_attr_read_only = -1;
static int hf_smb2_fscc_file_attr_reparse_point = -1;
static int hf_smb2_fscc_file_attr_sparse_file = -1;
static int hf_smb2_fscc_file_attr_system = -1;
static int hf_smb2_fscc_file_attr_temporary = -1;
static int hf_smb2_fscc_file_attr_integrity_stream = -1;
static int hf_smb2_fscc_file_attr_no_scrub_data = -1;
static int hf_smb2_tree_connect_flags = -1;
static int hf_smb2_tc_cluster_reconnect = -1;
static int hf_smb2_tc_redirect_to_owner = -1;
static int hf_smb2_tc_extension_present = -1;
static int hf_smb2_tc_reserved = -1;
static gint ett_smb2 = -1;
static gint ett_smb2_olb = -1;
static gint ett_smb2_ea = -1;
static gint ett_smb2_header = -1;
static gint ett_smb2_encrypted = -1;
static gint ett_smb2_compressed = -1;
static gint ett_smb2_decompressed = -1;
static gint ett_smb2_command = -1;
static gint ett_smb2_secblob = -1;
static gint ett_smb2_negotiate_context_element = -1;
static gint ett_smb2_file_basic_info = -1;
static gint ett_smb2_file_standard_info = -1;
static gint ett_smb2_file_internal_info = -1;
static gint ett_smb2_file_ea_info = -1;
static gint ett_smb2_file_access_info = -1;
static gint ett_smb2_file_position_info = -1;
static gint ett_smb2_file_mode_info = -1;
static gint ett_smb2_file_alignment_info = -1;
static gint ett_smb2_file_all_info = -1;
static gint ett_smb2_file_allocation_info = -1;
static gint ett_smb2_file_endoffile_info = -1;
static gint ett_smb2_file_alternate_name_info = -1;
static gint ett_smb2_file_stream_info = -1;
static gint ett_smb2_file_pipe_info = -1;
static gint ett_smb2_file_compression_info = -1;
static gint ett_smb2_file_network_open_info = -1;
static gint ett_smb2_file_attribute_tag_info = -1;
static gint ett_smb2_file_rename_info = -1;
static gint ett_smb2_file_disposition_info = -1;
static gint ett_smb2_file_full_ea_info = -1;
static gint ett_smb2_file_normalized_name_info = -1;
static gint ett_smb2_fs_info_01 = -1;
static gint ett_smb2_fs_info_03 = -1;
static gint ett_smb2_fs_info_04 = -1;
static gint ett_smb2_fs_info_05 = -1;
static gint ett_smb2_fs_info_06 = -1;
static gint ett_smb2_fs_info_07 = -1;
static gint ett_smb2_fs_objectid_info = -1;
static gint ett_smb2_sec_info_00 = -1;
static gint ett_smb2_additional_information_sec_mask = -1;
static gint ett_smb2_quota_info = -1;
static gint ett_smb2_query_quota_info = -1;
static gint ett_smb2_tid_tree = -1;
static gint ett_smb2_sesid_tree = -1;
static gint ett_smb2_create_chain_element = -1;
static gint ett_smb2_MxAc_buffer = -1;
static gint ett_smb2_QFid_buffer = -1;
static gint ett_smb2_RqLs_buffer = -1;
static gint ett_smb2_ioctl_function = -1;
static gint ett_smb2_FILE_OBJECTID_BUFFER = -1;
static gint ett_smb2_flags = -1;
static gint ett_smb2_sec_mode = -1;
static gint ett_smb2_capabilities = -1;
static gint ett_smb2_ses_req_flags = -1;
static gint ett_smb2_ses_flags = -1;
static gint ett_smb2_lease_state = -1;
static gint ett_smb2_lease_flags = -1;
static gint ett_smb2_share_flags = -1;
static gint ett_smb2_create_rep_flags = -1;
static gint ett_smb2_share_caps = -1;
static gint ett_smb2_comp_alg_flags = -1;
static gint ett_smb2_ioctl_flags = -1;
static gint ett_smb2_ioctl_network_interface = -1;
static gint ett_smb2_ioctl_sqos_opeations = -1;
static gint ett_smb2_fsctl_range_data = -1;
static gint ett_windows_sockaddr = -1;
static gint ett_smb2_close_flags = -1;
static gint ett_smb2_notify_info = -1;
static gint ett_smb2_notify_flags = -1;
static gint ett_smb2_write_flags = -1;
static gint ett_smb2_rdma_v1 = -1;
static gint ett_smb2_DH2Q_buffer = -1;
static gint ett_smb2_DH2C_buffer = -1;
static gint ett_smb2_dh2x_flags = -1;
static gint ett_smb2_APP_INSTANCE_buffer = -1;
static gint ett_smb2_svhdx_open_device_context = -1;
static gint ett_smb2_app_instance_version_buffer = -1;
static gint ett_smb2_app_instance_version_buffer_version = -1;
static gint ett_smb2_aapl_create_context_request = -1;
static gint ett_smb2_aapl_server_query_bitmask = -1;
static gint ett_smb2_aapl_server_query_caps = -1;
static gint ett_smb2_aapl_create_context_response = -1;
static gint ett_smb2_aapl_server_query_volume_caps = -1;
static gint ett_smb2_integrity_flags = -1;
static gint ett_smb2_find_flags = -1;
static gint ett_smb2_file_directory_info = -1;
static gint ett_smb2_both_directory_info = -1;
static gint ett_smb2_id_both_directory_info = -1;
static gint ett_smb2_full_directory_info = -1;
static gint ett_smb2_posix_info = -1;
static gint ett_smb2_file_name_info = -1;
static gint ett_smb2_lock_info = -1;
static gint ett_smb2_lock_flags = -1;
static gint ett_smb2_buffercode = -1;
static gint ett_smb2_ioctl_network_interface_capabilities = -1;
static gint ett_smb2_tree_connect_flags = -1;
static gint ett_qfr_entry = -1;
static gint ett_smb2_pipe_fragment = -1;
static gint ett_smb2_pipe_fragments = -1;
static gint ett_smb2_cchunk_entry = -1;
static gint ett_smb2_fsctl_odx_token = -1;
static gint ett_smb2_symlink_error_response = -1;
static gint ett_smb2_reparse_data_buffer = -1;
static gint ett_smb2_error_data = -1;
static gint ett_smb2_error_context = -1;
static gint ett_smb2_error_redir_context = -1;
static gint ett_smb2_error_redir_ip_list = -1;
static gint ett_smb2_read_flags = -1;
static gint ett_smb2_signature = -1;
static gint ett_smb2_transform_flags = -1;
static gint ett_smb2_fscc_file_attributes = -1;
static gint ett_smb2_comp_payload = -1;
static gint ett_smb2_comp_pattern_v1 = -1;
static expert_field ei_smb2_invalid_length = EI_INIT;
static expert_field ei_smb2_bad_response = EI_INIT;
static expert_field ei_smb2_invalid_getinfo_offset = EI_INIT;
static expert_field ei_smb2_invalid_getinfo_size = EI_INIT;
static expert_field ei_smb2_empty_getinfo_buffer = EI_INIT;
static expert_field ei_smb2_invalid_signature = EI_INIT;
static int smb2_tap = -1;
static int smb2_eo_tap = -1;
static dissector_handle_t gssapi_handle = NULL;
static dissector_handle_t ntlmssp_handle = NULL;
static dissector_handle_t rsvd_handle = NULL;
static heur_dissector_list_t smb2_pipe_subdissector_list;
static const fragment_items smb2_pipe_frag_items = {
&ett_smb2_pipe_fragment,
&ett_smb2_pipe_fragments,
&hf_smb2_pipe_fragments,
&hf_smb2_pipe_fragment,
&hf_smb2_pipe_fragment_overlap,
&hf_smb2_pipe_fragment_overlap_conflict,
&hf_smb2_pipe_fragment_multiple_tails,
&hf_smb2_pipe_fragment_too_long_fragment,
&hf_smb2_pipe_fragment_error,
&hf_smb2_pipe_fragment_count,
&hf_smb2_pipe_reassembled_in,
&hf_smb2_pipe_reassembled_length,
&hf_smb2_pipe_reassembled_data,
"Fragments"
};
#define FILE_BYTE_ALIGNMENT 0x00
#define FILE_WORD_ALIGNMENT 0x01
#define FILE_LONG_ALIGNMENT 0x03
#define FILE_QUAD_ALIGNMENT 0x07
#define FILE_OCTA_ALIGNMENT 0x0f
#define FILE_32_BYTE_ALIGNMENT 0x1f
#define FILE_64_BYTE_ALIGNMENT 0x3f
#define FILE_128_BYTE_ALIGNMENT 0x7f
#define FILE_256_BYTE_ALIGNMENT 0xff
#define FILE_512_BYTE_ALIGNMENT 0x1ff
static const value_string smb2_alignment_vals[] = {
{ FILE_BYTE_ALIGNMENT, "FILE_BYTE_ALIGNMENT" },
{ FILE_WORD_ALIGNMENT, "FILE_WORD_ALIGNMENT" },
{ FILE_LONG_ALIGNMENT, "FILE_LONG_ALIGNMENT" },
{ FILE_OCTA_ALIGNMENT, "FILE_OCTA_ALIGNMENT" },
{ FILE_32_BYTE_ALIGNMENT, "FILE_32_BYTE_ALIGNMENT" },
{ FILE_64_BYTE_ALIGNMENT, "FILE_64_BYTE_ALIGNMENT" },
{ FILE_128_BYTE_ALIGNMENT, "FILE_128_BYTE_ALIGNMENT" },
{ FILE_256_BYTE_ALIGNMENT, "FILE_256_BYTE_ALIGNMENT" },
{ FILE_512_BYTE_ALIGNMENT, "FILE_512_BYTE_ALIGNMENT" },
{ 0, NULL }
};
#define SMB2_CLASS_FILE_INFO 0x01
#define SMB2_CLASS_FS_INFO 0x02
#define SMB2_CLASS_SEC_INFO 0x03
#define SMB2_CLASS_QUOTA_INFO 0x04
static const value_string smb2_class_vals[] = {
{ SMB2_CLASS_FILE_INFO, "FILE_INFO"},
{ SMB2_CLASS_FS_INFO, "FS_INFO"},
{ SMB2_CLASS_SEC_INFO, "SEC_INFO"},
{ SMB2_CLASS_QUOTA_INFO, "QUOTA_INFO"},
{ 0, NULL }
};
#define SMB2_SHARE_TYPE_DISK 0x01
#define SMB2_SHARE_TYPE_PIPE 0x02
#define SMB2_SHARE_TYPE_PRINT 0x03
static const value_string smb2_share_type_vals[] = {
{ SMB2_SHARE_TYPE_DISK, "Physical disk" },
{ SMB2_SHARE_TYPE_PIPE, "Named pipe" },
{ SMB2_SHARE_TYPE_PRINT, "Printer" },
{ 0, NULL }
};
#define SMB2_FILE_BASIC_INFO 0x04
#define SMB2_FILE_STANDARD_INFO 0x05
#define SMB2_FILE_INTERNAL_INFO 0x06
#define SMB2_FILE_EA_INFO 0x07
#define SMB2_FILE_ACCESS_INFO 0x08
#define SMB2_FILE_RENAME_INFO 0x0a
#define SMB2_FILE_DISPOSITION_INFO 0x0d
#define SMB2_FILE_POSITION_INFO 0x0e
#define SMB2_FILE_FULL_EA_INFO 0x0f
#define SMB2_FILE_MODE_INFO 0x10
#define SMB2_FILE_ALIGNMENT_INFO 0x11
#define SMB2_FILE_ALL_INFO 0x12
#define SMB2_FILE_ALLOCATION_INFO 0x13
#define SMB2_FILE_ENDOFFILE_INFO 0x14
#define SMB2_FILE_ALTERNATE_NAME_INFO 0x15
#define SMB2_FILE_STREAM_INFO 0x16
#define SMB2_FILE_PIPE_INFO 0x17
#define SMB2_FILE_COMPRESSION_INFO 0x1c
#define SMB2_FILE_NETWORK_OPEN_INFO 0x22
#define SMB2_FILE_ATTRIBUTE_TAG_INFO 0x23
#define SMB2_FILE_NORMALIZED_NAME_INFO 0x30
#define SMB2_FILE_POSIX_INFO 0x64
static const value_string smb2_file_info_levels[] = {
{SMB2_FILE_BASIC_INFO, "SMB2_FILE_BASIC_INFO" },
{SMB2_FILE_STANDARD_INFO, "SMB2_FILE_STANDARD_INFO" },
{SMB2_FILE_INTERNAL_INFO, "SMB2_FILE_INTERNAL_INFO" },
{SMB2_FILE_EA_INFO, "SMB2_FILE_EA_INFO" },
{SMB2_FILE_ACCESS_INFO, "SMB2_FILE_ACCESS_INFO" },
{SMB2_FILE_RENAME_INFO, "SMB2_FILE_RENAME_INFO" },
{SMB2_FILE_DISPOSITION_INFO, "SMB2_FILE_DISPOSITION_INFO" },
{SMB2_FILE_POSITION_INFO, "SMB2_FILE_POSITION_INFO" },
{SMB2_FILE_FULL_EA_INFO, "SMB2_FILE_FULL_EA_INFO" },
{SMB2_FILE_MODE_INFO, "SMB2_FILE_MODE_INFO" },
{SMB2_FILE_ALIGNMENT_INFO, "SMB2_FILE_ALIGNMENT_INFO" },
{SMB2_FILE_ALL_INFO, "SMB2_FILE_ALL_INFO" },
{SMB2_FILE_ALLOCATION_INFO, "SMB2_FILE_ALLOCATION_INFO" },
{SMB2_FILE_ENDOFFILE_INFO, "SMB2_FILE_ENDOFFILE_INFO" },
{SMB2_FILE_ALTERNATE_NAME_INFO, "SMB2_FILE_ALTERNATE_NAME_INFO" },
{SMB2_FILE_STREAM_INFO, "SMB2_FILE_STREAM_INFO" },
{SMB2_FILE_PIPE_INFO, "SMB2_FILE_PIPE_INFO" },
{SMB2_FILE_COMPRESSION_INFO, "SMB2_FILE_COMPRESSION_INFO" },
{SMB2_FILE_NETWORK_OPEN_INFO, "SMB2_FILE_NETWORK_OPEN_INFO" },
{SMB2_FILE_ATTRIBUTE_TAG_INFO, "SMB2_FILE_ATTRIBUTE_TAG_INFO" },
{SMB2_FILE_NORMALIZED_NAME_INFO,"SMB2_FILE_NORMALIZED_NAME_INFO" },
{SMB2_FILE_POSIX_INFO, "SMB2_FILE_POSIX_INFO" },
{ 0, NULL }
};
static value_string_ext smb2_file_info_levels_ext = VALUE_STRING_EXT_INIT(smb2_file_info_levels);
#define SMB2_FS_INFO_01 0x01
#define SMB2_FS_LABEL_INFO 0x02
#define SMB2_FS_INFO_03 0x03
#define SMB2_FS_INFO_04 0x04
#define SMB2_FS_INFO_05 0x05
#define SMB2_FS_INFO_06 0x06
#define SMB2_FS_INFO_07 0x07
#define SMB2_FS_OBJECTID_INFO 0x08
#define SMB2_FS_DRIVER_PATH_INFO 0x09
#define SMB2_FS_VOLUME_FLAGS_INFO 0x0a
#define SMB2_FS_SECTOR_SIZE_INFO 0x0b
static const value_string smb2_fs_info_levels[] = {
{SMB2_FS_INFO_01, "FileFsVolumeInformation" },
{SMB2_FS_LABEL_INFO, "FileFsLabelInformation" },
{SMB2_FS_INFO_03, "FileFsSizeInformation" },
{SMB2_FS_INFO_04, "FileFsDeviceInformation" },
{SMB2_FS_INFO_05, "FileFsAttributeInformation" },
{SMB2_FS_INFO_06, "FileFsControlInformation" },
{SMB2_FS_INFO_07, "FileFsFullSizeInformation" },
{SMB2_FS_OBJECTID_INFO, "FileFsObjectIdInformation" },
{SMB2_FS_DRIVER_PATH_INFO, "FileFsDriverPathInformation" },
{SMB2_FS_VOLUME_FLAGS_INFO, "FileFsVolumeFlagsInformation" },
{SMB2_FS_SECTOR_SIZE_INFO, "FileFsSectorSizeInformation" },
{ 0, NULL }
};
static value_string_ext smb2_fs_info_levels_ext = VALUE_STRING_EXT_INIT(smb2_fs_info_levels);
#define SMB2_SEC_INFO_00 0x00
static const value_string smb2_sec_info_levels[] = {
{SMB2_SEC_INFO_00, "SMB2_SEC_INFO_00" },
{ 0, NULL }
};
static value_string_ext smb2_sec_info_levels_ext = VALUE_STRING_EXT_INIT(smb2_sec_info_levels);
#define SMB2_FIND_DIRECTORY_INFO 0x01
#define SMB2_FIND_FULL_DIRECTORY_INFO 0x02
#define SMB2_FIND_BOTH_DIRECTORY_INFO 0x03
#define SMB2_FIND_INDEX_SPECIFIED 0x04
#define SMB2_FIND_NAME_INFO 0x0C
#define SMB2_FIND_ID_BOTH_DIRECTORY_INFO 0x25
#define SMB2_FIND_ID_FULL_DIRECTORY_INFO 0x26
#define SMB2_FIND_POSIX_INFO 0x64
static const value_string smb2_find_info_levels[] = {
{ SMB2_FIND_DIRECTORY_INFO, "SMB2_FIND_DIRECTORY_INFO" },
{ SMB2_FIND_FULL_DIRECTORY_INFO, "SMB2_FIND_FULL_DIRECTORY_INFO" },
{ SMB2_FIND_BOTH_DIRECTORY_INFO, "SMB2_FIND_BOTH_DIRECTORY_INFO" },
{ SMB2_FIND_INDEX_SPECIFIED, "SMB2_FIND_INDEX_SPECIFIED" },
{ SMB2_FIND_NAME_INFO, "SMB2_FIND_NAME_INFO" },
{ SMB2_FIND_ID_BOTH_DIRECTORY_INFO, "SMB2_FIND_ID_BOTH_DIRECTORY_INFO" },
{ SMB2_FIND_ID_FULL_DIRECTORY_INFO, "SMB2_FIND_ID_FULL_DIRECTORY_INFO" },
{ SMB2_FIND_POSIX_INFO, "SMB2_FIND_POSIX_INFO" },
{ 0, NULL }
};
#define SMB2_PREAUTH_INTEGRITY_CAPABILITIES 0x0001
#define SMB2_ENCRYPTION_CAPABILITIES 0x0002
#define SMB2_COMPRESSION_CAPABILITIES 0x0003
#define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID 0x0005
#define SMB2_TRANSPORT_CAPABILITIES 0x0006
#define SMB2_RDMA_TRANSFORM_CAPABILITIES 0x0007
#define SMB2_SIGNING_CAPABILITIES 0x0008
#define SMB2_POSIX_EXTENSIONS_CAPABILITIES 0x0100
static const value_string smb2_negotiate_context_types[] = {
{ SMB2_PREAUTH_INTEGRITY_CAPABILITIES, "SMB2_PREAUTH_INTEGRITY_CAPABILITIES" },
{ SMB2_ENCRYPTION_CAPABILITIES, "SMB2_ENCRYPTION_CAPABILITIES" },
{ SMB2_COMPRESSION_CAPABILITIES, "SMB2_COMPRESSION_CAPABILITIES" },
{ SMB2_NETNAME_NEGOTIATE_CONTEXT_ID, "SMB2_NETNAME_NEGOTIATE_CONTEXT_ID" },
{ SMB2_TRANSPORT_CAPABILITIES, "SMB2_TRANSPORT_CAPABILITIES" },
{ SMB2_RDMA_TRANSFORM_CAPABILITIES, "SMB2_RDMA_TRANSFORM_CAPABILITIES" },
{ SMB2_SIGNING_CAPABILITIES, "SMB2_SIGNING_CAPABILITIES" },
{ SMB2_POSIX_EXTENSIONS_CAPABILITIES, "SMB2_POSIX_EXTENSIONS_CAPABILITIES" },
{ 0, NULL }
};
#define SMB2_HASH_ALGORITHM_SHA_512 0x0001
static const value_string smb2_hash_algorithm_types[] = {
{ SMB2_HASH_ALGORITHM_SHA_512, "SHA-512" },
{ 0, NULL }
};
#define SMB2_SIGNING_ALG_HMAC_SHA256 0x0000
#define SMB2_SIGNING_ALG_AES_CMAC 0x0001
#define SMB2_SIGNING_ALG_AES_GMAC 0x0002
static const value_string smb2_signing_alg_types[] = {
{ SMB2_SIGNING_ALG_HMAC_SHA256, "HMAC-SHA256" },
{ SMB2_SIGNING_ALG_AES_CMAC, "AES-CMAC" },
{ SMB2_SIGNING_ALG_AES_GMAC, "AES-GMAC" },
{ 0, NULL },
};
#define SMB2_CIPHER_AES_128_CCM 0x0001
#define SMB2_CIPHER_AES_128_GCM 0x0002
#define SMB2_CIPHER_AES_256_CCM 0x0003
#define SMB2_CIPHER_AES_256_GCM 0x0004
static const value_string smb2_cipher_types[] = {
{ SMB2_CIPHER_AES_128_CCM, "AES-128-CCM" },
{ SMB2_CIPHER_AES_128_GCM, "AES-128-GCM" },
{ SMB2_CIPHER_AES_256_CCM, "AES-256-CCM" },
{ SMB2_CIPHER_AES_256_GCM, "AES-256-GCM" },
{ 0, NULL }
};
#define SMB2_TRANSFORM_FLAGS_ENCRYPTED 0x0001
static int * const smb2_transform_flags[] = {
&hf_smb2_transform_flags_encrypted,
NULL,
};
#define SMB2_COMP_ALG_FLAGS_CHAINED 0x00000001
#define SMB2_COMP_ALG_NONE 0x0000
#define SMB2_COMP_ALG_LZNT1 0x0001
#define SMB2_COMP_ALG_LZ77 0x0002
#define SMB2_COMP_ALG_LZ77HUFF 0x0003
#define SMB2_COMP_ALG_PATTERN_V1 0x0004
static const value_string smb2_comp_alg_types[] = {
{ SMB2_COMP_ALG_NONE, "None" },
{ SMB2_COMP_ALG_LZNT1, "LZNT1" },
{ SMB2_COMP_ALG_LZ77, "LZ77" },
{ SMB2_COMP_ALG_LZ77HUFF, "LZ77+Huffman" },
{ SMB2_COMP_ALG_PATTERN_V1, "Pattern_V1" },
{ 0, NULL }
};
#define SMB2_COMP_FLAG_NONE 0x0000
#define SMB2_COMP_FLAG_CHAINED 0x0001
static const value_string smb2_comp_transform_flags_vals[] = {
{ SMB2_COMP_FLAG_NONE, "None" },
{ SMB2_COMP_FLAG_CHAINED, "Chained" },
{ 0, NULL }
};
#define SMB2_RDMA_TRANSFORM_NONE 0x0000
#define SMB2_RDMA_TRANSFORM_ENCRYPTION 0x0001
#define SMB2_RDMA_TRANSFORM_SIGNING 0x0002
static const value_string smb2_rdma_transform_types[] = {
{ SMB2_RDMA_TRANSFORM_NONE, "None" },
{ SMB2_RDMA_TRANSFORM_ENCRYPTION, "Encryption" },
{ SMB2_RDMA_TRANSFORM_SIGNING, "Signing" },
{ 0, NULL }
};
#define OPLOCK_BREAK_OPLOCK_STRUCTURE_SIZE 24 /* [MS-SMB2] 2.2.23.1, 2.2.24.1 and 2.2.25.1 */
#define OPLOCK_BREAK_LEASE_NOTIFICATION_STRUCTURE_SIZE 44 /* [MS-SMB2] 2.2.23.2 Lease Break Notification */
#define OPLOCK_BREAK_LEASE_ACKNOWLEDGMENT_STRUCTURE_SIZE 36 /* [MS-SMB2] 2.2.24.2 Lease Break Acknowledgment */
#define OPLOCK_BREAK_LEASE_RESPONSE_STRUCTURE_SIZE 36 /* [MS-SMB2] 2.2.25.2 Lease Break Response */
static const val64_string unique_unsolicited_response[] = {
{ 0xffffffffffffffff, "unsolicited response" },
{ 0, NULL }
};
#define SMB2_ERROR_ID_DEFAULT 0x00000000
#define SMB2_ERROR_ID_SHARE_REDIRECT 0x72645253
static const value_string smb2_error_id_vals[] = {
{ SMB2_ERROR_ID_DEFAULT, "ERROR_ID_DEFAULT" },
{ SMB2_ERROR_ID_SHARE_REDIRECT, "ERROR_ID_SHARE_REDIRECT" },
{ 0, NULL }
};
#define SMB2_ACCEPT_TRANSPORT_LEVEL_SECURITY 0x00000001
static const value_string smb2_transport_ctx_flags_vals[] = {
{ SMB2_ACCEPT_TRANSPORT_LEVEL_SECURITY, "SMB2_ACCEPT_TRANSPORT_LEVEL_SECURITY" },
{ 0, NULL }
};
#define REPARSE_TAG_RESERVED_ZERO 0x00000000 /* Reserved reparse tag value. */
#define REPARSE_TAG_RESERVED_ONE 0x00000001 /* Reserved reparse tag value. */
#define REPARSE_TAG_MOUNT_POINT 0xA0000003 /* Used for mount point */
#define REPARSE_TAG_HSM 0xC0000004 /* Obsolete. Used by legacy Hierarchical Storage Manager Product. */
#define REPARSE_TAG_DRIVER_EXTENDER 0x80000005 /* Home server drive extender. */
#define REPARSE_TAG_HSM2 0x80000006 /* Obsolete. Used by legacy Hierarchical Storage Manager Product. */
#define REPARSE_TAG_SIS 0x80000007 /* Used by single-instance storage (SIS) filter driver. */
#define REPARSE_TAG_DFS 0x8000000A /* Used by the DFS filter. */
#define REPARSE_TAG_FILTER_MANAGER 0x8000000B /* Used by filter manager test harness */
#define REPARSE_TAG_SYMLINK 0xA000000C /* Used for symbolic link support. */
#define REPARSE_TAG_DFSR 0x80000012 /* Used by the DFS filter. */
#define REPARSE_TAG_NFS 0x80000014 /* Used by the Network File System (NFS) component. */
#define REPARSE_TAG_LX_SYMLINK 0xA000001D /* WSL symbolic link */
#define REPARSE_TAG_AF_UNIX 0x80000023 /* WSL unix socket */
#define REPARSE_TAG_LX_FIFO 0x80000024 /* WSL fifo pipe */
#define REPARSE_TAG_LX_CHR 0x80000025 /* WSL char device */
#define REPARSE_TAG_LX_BLK 0x80000026 /* WSL block device */
static const value_string reparse_tag_vals[] = {
{ REPARSE_TAG_RESERVED_ZERO, "REPARSE_TAG_RESERVED_ZERO"},
{ REPARSE_TAG_RESERVED_ONE, "REPARSE_TAG_RESERVED_ONE"},
{ REPARSE_TAG_MOUNT_POINT, "REPARSE_TAG_MOUNT_POINT"},
{ REPARSE_TAG_HSM, "REPARSE_TAG_HSM"},
{ REPARSE_TAG_DRIVER_EXTENDER, "REPARSE_TAG_DRIVER_EXTENDER"},
{ REPARSE_TAG_HSM2, "REPARSE_TAG_HSM2"},
{ REPARSE_TAG_SIS, "REPARSE_TAG_SIS"},
{ REPARSE_TAG_DFS, "REPARSE_TAG_DFS"},
{ REPARSE_TAG_FILTER_MANAGER, "REPARSE_TAG_FILTER_MANAGER"},
{ REPARSE_TAG_SYMLINK, "REPARSE_TAG_SYMLINK"},
{ REPARSE_TAG_DFSR, "REPARSE_TAG_DFSR"},
{ REPARSE_TAG_NFS, "REPARSE_TAG_NFS"},
{ REPARSE_TAG_LX_SYMLINK, "REPARSE_TAG_LX_SYMLINK"},
{ REPARSE_TAG_AF_UNIX, "REPARSE_TAG_AF_UNIX"},
{ REPARSE_TAG_LX_FIFO, "REPARSE_TAG_LX_FIFO"},
{ REPARSE_TAG_LX_CHR, "REPARSE_TAG_LX_CHR"},
{ REPARSE_TAG_LX_BLK, "REPARSE_TAG_LX_BLK"},
{ 0, NULL }
};
#define NFS_SPECFILE_LNK 0x00000000014B4E4C
#define NFS_SPECFILE_CHR 0x0000000000524843
#define NFS_SPECFILE_BLK 0x00000000004B4C42
#define NFS_SPECFILE_FIFO 0x000000004F464946
#define NFS_SPECFILE_SOCK 0x000000004B434F53
static const val64_string nfs_type_vals[] = {
{ NFS_SPECFILE_LNK, "Symbolic Link" },
{ NFS_SPECFILE_CHR, "Character Device" },
{ NFS_SPECFILE_BLK, "Block Device" },
{ NFS_SPECFILE_FIFO, "FIFO" },
{ NFS_SPECFILE_SOCK, "UNIX Socket" },
{ 0, NULL }
};
#define SMB2_NUM_PROCEDURES 256
#define MAX_UNCOMPRESSED_SIZE (1<<24) /* 16MB */
#define SMB2_DIALECT_202 0x0202
#define SMB2_DIALECT_210 0x0210
#define SMB2_DIALECT_2FF 0x02FF
#define SMB2_DIALECT_222 0x0222
#define SMB2_DIALECT_224 0x0224
#define SMB2_DIALECT_300 0x0300
#define SMB2_DIALECT_302 0x0302
#define SMB2_DIALECT_310 0x0310
#define SMB2_DIALECT_311 0x0311
static const value_string smb2_dialect_vals[] = {
{ SMB2_DIALECT_202, "SMB 2.0.2" },
{ SMB2_DIALECT_210, "SMB 2.1" },
{ SMB2_DIALECT_2FF, "SMB2 wildcard" },
{ SMB2_DIALECT_222, "SMB 2.2.2 (deprecated; should be 3.0)" },
{ SMB2_DIALECT_224, "SMB 2.2.4 (deprecated; should be 3.0)" },
{ SMB2_DIALECT_300, "SMB 3.0" },
{ SMB2_DIALECT_302, "SMB 3.0.2" },
{ SMB2_DIALECT_310, "SMB 3.1.0 (deprecated; should be 3.1.1)" },
{ SMB2_DIALECT_311, "SMB 3.1.1" },
{ 0, NULL }
};
static int dissect_windows_sockaddr_storage(tvbuff_t *, packet_info *, proto_tree *, int, int);
static void dissect_smb2_error_data(tvbuff_t *, packet_info *, proto_tree *, int, int, smb2_info_t *);
static guint smb2_eo_files_hash(gconstpointer k);
static gint smb2_eo_files_equal(gconstpointer k1, gconstpointer k2);
static void update_preauth_hash(void *buf, packet_info *pinfo, tvbuff_t *tvb)
{
gcry_error_t err;
gcry_md_hd_t md;
void *pkt;
err = gcry_md_open(&md, GCRY_MD_SHA512, 0);
if (err)
return;
/* we dup in case of non-contiguous packet */
pkt = tvb_memdup(pinfo->pool, tvb, 0, tvb_captured_length(tvb));
gcry_md_write(md, buf, SMB2_PREAUTH_HASH_SIZE);
gcry_md_write(md, pkt, tvb_captured_length(tvb));
gcry_md_final(md);
memcpy(buf, gcry_md_read(md, 0), SMB2_PREAUTH_HASH_SIZE);
gcry_md_close(md);
}
static void
smb2stat_init(struct register_srt* srt _U_, GArray* srt_array)
{
srt_stat_table *smb2_srt_table;
guint32 i;
smb2_srt_table = init_srt_table("SMB2", NULL, srt_array, SMB2_NUM_PROCEDURES, "Commands", "smb2.cmd", NULL);
for (i = 0; i < SMB2_NUM_PROCEDURES; i++)
{
init_srt_table_row(smb2_srt_table, i, val_to_str_ext_const(i, &smb2_cmd_vals_ext, "<unknown>"));
}
}
static tap_packet_status
smb2stat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv, tap_flags_t flags _U_)
{
guint i = 0;
srt_stat_table *smb2_srt_table;
srt_data_t *data = (srt_data_t *)pss;
const smb2_info_t *si=(const smb2_info_t *)prv;
/* we are only interested in response packets */
if(!(si->flags&SMB2_FLAGS_RESPONSE)){
return TAP_PACKET_DONT_REDRAW;
}
/* We should not include cancel and oplock break requests either */
if (si->opcode == SMB2_COM_CANCEL || si->opcode == SMB2_COM_BREAK) {
return TAP_PACKET_DONT_REDRAW;
}
/* if we haven't seen the request, just ignore it */
if(!si->saved){
return TAP_PACKET_DONT_REDRAW;
}
/* SMB2 SRT can be very inaccurate in the presence of retransmissions. Retransmitted responses
* not only add additional (bogus) transactions but also the latency associated with them.
* This can greatly inflate the maximum and average SRT stats especially in the case of
* retransmissions triggered by the expiry of the rexmit timer (RTOs). Only calculating SRT
* for the last received response accomplishes this goal without requiring the TCP pref
* "Do not call subdissectors for error packets" to be set. */
if ((si->saved->frame_req == 0) || (si->saved->frame_res != pinfo->num))
return TAP_PACKET_DONT_REDRAW;
smb2_srt_table = g_array_index(data->srt_array, srt_stat_table*, i);
add_srt_table_data(smb2_srt_table, si->opcode, &si->saved->req_time, pinfo);
return TAP_PACKET_REDRAW;
}
/* Structure for SessionID <=> SessionKey mapping for decryption. */
typedef struct _smb2_seskey_field_t {
/* session id */
guchar *id; /* *little-endian* - not necessarily host-endian! */
guint id_len;
/* session key */
guchar *seskey;
guint seskey_len;
/* server to client key */
guchar *s2ckey;
guint s2ckey_len;
/* client to server key */
guchar *c2skey;
guint c2skey_len;
} smb2_seskey_field_t;
static smb2_seskey_field_t *seskey_list = NULL;
static guint num_seskey_list = 0;
static const gint8 zeros[NTLMSSP_KEY_LEN] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
/* Callbacks for SessionID <=> SessionKey mapping. */
UAT_BUFFER_CB_DEF(seskey_list, id, smb2_seskey_field_t, id, id_len)
UAT_BUFFER_CB_DEF(seskey_list, seskey, smb2_seskey_field_t, seskey, seskey_len)
UAT_BUFFER_CB_DEF(seskey_list, s2ckey, smb2_seskey_field_t, s2ckey, s2ckey_len)
UAT_BUFFER_CB_DEF(seskey_list, c2skey, smb2_seskey_field_t, c2skey, c2skey_len)
#define SMB_SESSION_ID_SIZE 8
static gboolean seskey_list_update_cb(void *r, char **err)
{
smb2_seskey_field_t *rec = (smb2_seskey_field_t *)r;
gboolean has_seskey = rec->seskey_len != 0;
gboolean has_s2ckey = rec->s2ckey_len != 0;
gboolean has_c2skey = rec->c2skey_len != 0;
*err = NULL;
if (rec->id_len != SMB_SESSION_ID_SIZE) {
*err = g_strdup("Session ID must be " G_STRINGIFY(SMB_SESSION_ID_SIZE) " bytes long and in hexadecimal");
return FALSE;
}
if (!has_seskey && !(has_c2skey || has_s2ckey)) {
*err = g_strdup("Decryption requires either the Session Key or at least one of the client-server AES keys");
return FALSE;
}
if (rec->seskey_len > NTLMSSP_KEY_LEN) {
*err = g_strdup("Session Key must be a hexadecimal string representing at most " G_STRINGIFY(NTLMSSP_KEY_LEN) " bytes");
return FALSE;
}
if (has_s2ckey && ((rec->s2ckey_len != AES_KEY_SIZE) && (rec->s2ckey_len != AES_KEY_SIZE*2))) {
*err = g_strdup("Server-to-Client key must be a hexadecimal string representing "
G_STRINGIFY(AES_KEY_SIZE) " or " G_STRINGIFY(AES_KEY_SIZE*2));
return FALSE;
}
if (has_c2skey && ((rec->c2skey_len != AES_KEY_SIZE) && (rec->c2skey_len != AES_KEY_SIZE*2))) {
*err = g_strdup("Client-to-Server key must be a hexadecimal string representing "
G_STRINGIFY(AES_KEY_SIZE) " or " G_STRINGIFY(AES_KEY_SIZE*2));
return FALSE;
}
return TRUE;
}
static void* seskey_list_copy_cb(void *n, const void *o, size_t siz _U_)
{
smb2_seskey_field_t *new_rec = (smb2_seskey_field_t *)n;
const smb2_seskey_field_t *old_rec = (const smb2_seskey_field_t *)o;
new_rec->id_len = old_rec->id_len;
new_rec->id = old_rec->id ? (guchar *)g_memdup2(old_rec->id, old_rec->id_len) : NULL;
new_rec->seskey_len = old_rec->seskey_len;
new_rec->seskey = old_rec->seskey ? (guchar *)g_memdup2(old_rec->seskey, old_rec->seskey_len) : NULL;
new_rec->s2ckey_len = old_rec->s2ckey_len;
new_rec->s2ckey = old_rec->s2ckey ? (guchar *)g_memdup2(old_rec->s2ckey, old_rec->s2ckey_len) : NULL;
new_rec->c2skey_len = old_rec->c2skey_len;
new_rec->c2skey = old_rec->c2skey ? (guchar *)g_memdup2(old_rec->c2skey, old_rec->c2skey_len) : NULL;
return new_rec;
}
static void seskey_list_free_cb(void *r)
{
smb2_seskey_field_t *rec = (smb2_seskey_field_t *)r;
g_free(rec->id);
g_free(rec->seskey);
g_free(rec->s2ckey);
g_free(rec->c2skey);
}
static gboolean seskey_find_sid_key(guint64 sesid, guint8 *out_seskey,
guint8 *out_s2ckey16,
guint8 *out_c2skey16,
guint8 *out_s2ckey32,
guint8 *out_c2skey32)
{
guint i;
guint64 sesid_le;
/*
* The session IDs in the UAT are octet arrays, in little-endian
* byte order (as it appears on the wire); they have been
* checked to make sure they're 8 bytes (SMB_SESSION_ID_SIZE)
* long. They're *probably* aligned on an appropriate boundary,
* but let's not assume that - let's just use memcmp().
*
* The session ID passed to us, however, is in *host* byte order.
* This is *NOT* necessarily little-endian; it's big-endian on,
* for example, System/390 and z/Architecture ("s390" and "s390x"
* in Linuxland), SPARC, and most PowerPC systems. We must,
* therefore, put it into little-endian byte order before
* comparing it with the IDs in the UAT values.
*/
sesid_le = GUINT64_TO_LE(sesid);
for (i = 0; i < num_seskey_list; i++) {
const smb2_seskey_field_t *p = &seskey_list[i];
if (memcmp(&sesid_le, p->id, SMB_SESSION_ID_SIZE) == 0) {
memset(out_seskey, 0, NTLMSSP_KEY_LEN);
memset(out_s2ckey16, 0, AES_KEY_SIZE);
memset(out_c2skey16, 0, AES_KEY_SIZE);
memset(out_s2ckey32, 0, AES_KEY_SIZE*2);
memset(out_c2skey32, 0, AES_KEY_SIZE*2);
if (p->seskey_len != 0)
memcpy(out_seskey, p->seskey, p->seskey_len);
if (p->s2ckey_len == AES_KEY_SIZE)
memcpy(out_s2ckey16, p->s2ckey, p->s2ckey_len);
if (p->s2ckey_len == AES_KEY_SIZE*2)
memcpy(out_s2ckey32, p->s2ckey, p->s2ckey_len);
if (p->c2skey_len == AES_KEY_SIZE)
memcpy(out_c2skey16, p->c2skey, p->c2skey_len);
if (p->c2skey_len == AES_KEY_SIZE*2)
memcpy(out_c2skey32, p->c2skey, p->c2skey_len);
return TRUE;
}
}
return FALSE;
}
/* ExportObject preferences variable */
gboolean eosmb2_take_name_as_fid = FALSE ;
/* unmatched smb_saved_info structures.
For unmatched smb_saved_info structures we store the smb_saved_info
structure using the msg_id field.
*/
static gint
smb2_saved_info_equal_unmatched(gconstpointer k1, gconstpointer k2)
{
const smb2_saved_info_t *key1 = (const smb2_saved_info_t *)k1;
const smb2_saved_info_t *key2 = (const smb2_saved_info_t *)k2;
return key1->msg_id == key2->msg_id;
}
static guint
smb2_saved_info_hash_unmatched(gconstpointer k)
{
const smb2_saved_info_t *key = (const smb2_saved_info_t *)k;
guint32 hash;
hash = (guint32) (key->msg_id&0xffffffff);
return hash;
}
/* matched smb_saved_info structures.
For matched smb_saved_info structures we store the smb_saved_info
structure using the msg_id field.
*/
static gint
smb2_saved_info_equal_matched(gconstpointer k1, gconstpointer k2)
{
const smb2_saved_info_t *key1 = (const smb2_saved_info_t *)k1;
const smb2_saved_info_t *key2 = (const smb2_saved_info_t *)k2;
return key1->msg_id == key2->msg_id;
}
static guint
smb2_saved_info_hash_matched(gconstpointer k)
{
const smb2_saved_info_t *key = (const smb2_saved_info_t *)k;
guint32 hash;
hash = (guint32) (key->msg_id&0xffffffff);
return hash;
}
/* For Tids of a specific conversation.
This keeps track of tid->sharename mappings and other information about the
tid.
qqq
We might need to refine this if it occurs that tids are reused on a single
conversation. we don't worry about that yet for simplicity
*/
static gint
smb2_tid_info_equal(gconstpointer k1, gconstpointer k2)
{
const smb2_tid_info_t *key1 = (const smb2_tid_info_t *)k1;
const smb2_tid_info_t *key2 = (const smb2_tid_info_t *)k2;
return key1->tid == key2->tid;
}
static guint
smb2_tid_info_hash(gconstpointer k)
{
const smb2_tid_info_t *key = (const smb2_tid_info_t *)k;
guint32 hash;
hash = key->tid;
return hash;
}
/* For Uids of a specific conversation.
This keeps track of uid->acct_name mappings and other information about the
uid.
qqq
We might need to refine this if it occurs that uids are reused on a single
conversation. we don't worry about that yet for simplicity
*/
static gint
smb2_sesid_info_equal(gconstpointer k1, gconstpointer k2)
{
const smb2_sesid_info_t *key1 = (const smb2_sesid_info_t *)k1;
const smb2_sesid_info_t *key2 = (const smb2_sesid_info_t *)k2;
return key1->sesid == key2->sesid;
}
static guint
smb2_sesid_info_hash(gconstpointer k)
{
const smb2_sesid_info_t *key = (const smb2_sesid_info_t *)k;
guint32 hash;
hash = (guint32)( ((key->sesid>>32)&0xffffffff)+((key->sesid)&0xffffffff) );
return hash;
}
/*
* For File IDs of a specific conversation.
* This keeps track of fid to name mapping and application level conversations
* over named pipes.
*
* This handles implementation bugs, where the fid_persitent is 0 or
* the fid_persitent/fid_volative is not unique per conversation.
*/
static gint
smb2_fid_info_equal(gconstpointer k1, gconstpointer k2)
{
const smb2_fid_info_t *key = (const smb2_fid_info_t *)k1;
const smb2_fid_info_t *val = (const smb2_fid_info_t *)k2;
if (!key->frame_key) {
key = (const smb2_fid_info_t *)k2;
val = (const smb2_fid_info_t *)k1;
}
if (key->fid_persistent != val->fid_persistent) {
return 0;
}
if (key->fid_volatile != val->fid_volatile) {
return 0;
}
if (key->sesid != val->sesid) {
return 0;
}
if (key->tid != val->tid) {
return 0;
}
if (!(val->frame_beg <= key->frame_key && key->frame_key <= val->frame_end)) {
return 0;
}
return 1;
}
static guint
smb2_fid_info_hash(gconstpointer k)
{
const smb2_fid_info_t *key = (const smb2_fid_info_t *)k;
guint32 hash;
if (key->fid_persistent != 0) {
hash = (guint32)( ((key->fid_persistent>>32)&0xffffffff)+((key->fid_persistent)&0xffffffff) );
} else {
hash = (guint32)( ((key->fid_volatile>>32)&0xffffffff)+((key->fid_volatile)&0xffffffff) );
}
return hash;
}
/* Callback for destroying the glib hash tables associated with a conversation
* struct. */
static bool
smb2_conv_destroy(wmem_allocator_t *allocator _U_, wmem_cb_event_t event _U_,
void *user_data)
{
smb2_conv_info_t *conv = (smb2_conv_info_t *)user_data;
g_hash_table_destroy(conv->matched);
g_hash_table_destroy(conv->unmatched);
/* This conversation is gone, return FALSE to indicate we don't
* want to be called again for this conversation. */
return FALSE;
}
static smb2_sesid_info_t *
smb2_get_session(smb2_conv_info_t *conv _U_, guint64 id, packet_info *pinfo, smb2_info_t *si)
{
smb2_sesid_info_t key = {.sesid = id};
smb2_sesid_info_t *ses = (smb2_sesid_info_t *)wmem_map_lookup(smb2_sessions, &key);
if (!ses) {
ses = wmem_new0(wmem_file_scope(), smb2_sesid_info_t);
ses->sesid = id;
ses->auth_frame = (guint32)-1;
ses->tids = wmem_map_new(wmem_file_scope(), smb2_tid_info_hash, smb2_tid_info_equal);
ses->fids = wmem_map_new(wmem_file_scope(), smb2_fid_info_hash, smb2_fid_info_equal);
ses->files = wmem_map_new(wmem_file_scope(), smb2_eo_files_hash, smb2_eo_files_equal);
seskey_find_sid_key(id, ses->session_key,
ses->client_decryption_key16,
ses->server_decryption_key16,
ses->client_decryption_key32,
ses->server_decryption_key32);
if (pinfo && si) {
if (si->flags & SMB2_FLAGS_RESPONSE) {
ses->server_port = pinfo->srcport;
} else {
ses->server_port = pinfo->destport;
}
}
wmem_map_insert(smb2_sessions, ses, ses);
}
return ses;
}
static void
smb2_add_session_info(proto_tree *ses_tree, proto_item *ses_item, tvbuff_t *tvb, gint start, smb2_sesid_info_t *ses)
{
proto_item *new_item;
if (!ses)
return;
if (ses->acct_name) {
new_item = proto_tree_add_string(ses_tree, hf_smb2_acct_name, tvb, start, 0, ses->acct_name);
proto_item_set_generated(new_item);
proto_item_append_text(ses_item, " Acct:%s", ses->acct_name);
}
if (ses->domain_name) {
new_item = proto_tree_add_string(ses_tree, hf_smb2_domain_name, tvb, start, 0, ses->domain_name);
proto_item_set_generated(new_item);
proto_item_append_text(ses_item, " Domain:%s", ses->domain_name);
}
if (ses->host_name) {
new_item = proto_tree_add_string(ses_tree, hf_smb2_host_name, tvb, start, 0, ses->host_name);
proto_item_set_generated(new_item);
proto_item_append_text(ses_item, " Host:%s", ses->host_name);
}
if (ses->auth_frame != (guint32)-1) {
new_item = proto_tree_add_uint(ses_tree, hf_smb2_auth_frame, tvb, start, 0, ses->auth_frame);
proto_item_set_generated(new_item);
}
}
static void smb2_key_derivation(const guint8 *KI, guint32 KI_len,
const guint8 *Label, guint32 Label_len,
const guint8 *Context, guint32 Context_len,
guint8 KO[16], guint32 KO_len)
{
gcry_md_hd_t hd = NULL;
guint8 buf[4];
guint8 *digest = NULL;
guint32 L;
/*
* a simplified version of
* "NIST Special Publication 800-108" section 5.1
* using hmac-sha256.
*/
gcry_md_open(&hd, GCRY_MD_SHA256, GCRY_MD_FLAG_HMAC);
gcry_md_setkey(hd, KI, KI_len);
memset(buf, 0, sizeof(buf));
buf[3] = 1;
gcry_md_write(hd, buf, sizeof(buf));
gcry_md_write(hd, Label, Label_len);
gcry_md_write(hd, buf, 1);
gcry_md_write(hd, Context, Context_len);
L = KO_len * 8;
memset(buf, 0, sizeof(buf));
buf[3] = ((L) >> (0)) & 0xff;
buf[2] = ((L) >> (8)) & 0xff;
gcry_md_write(hd, buf, sizeof(buf));
digest = gcry_md_read(hd, GCRY_MD_SHA256);
memcpy(KO, digest, KO_len);
gcry_md_close(hd);
}
/* for export-object-smb2 */
static gchar *policy_hnd_to_file_id(wmem_allocator_t *pool, const e_ctx_hnd *hnd) {
return guid_to_str(pool, &hnd->uuid);
}
static guint smb2_eo_files_hash(gconstpointer k) {
return g_str_hash(policy_hnd_to_file_id(wmem_packet_scope(), (const e_ctx_hnd *)k));
}
static gint smb2_eo_files_equal(gconstpointer k1, gconstpointer k2) {
int are_equal;
const e_ctx_hnd *key1 = (const e_ctx_hnd *)k1;
const e_ctx_hnd *key2 = (const e_ctx_hnd *)k2;
are_equal = (key1->uuid.data1==key2->uuid.data1 &&
key1->uuid.data2==key2->uuid.data2 &&
key1->uuid.data3==key2->uuid.data3 &&
key1->uuid.data4[0]==key2->uuid.data4[0] &&
key1->uuid.data4[1]==key2->uuid.data4[1] &&
key1->uuid.data4[2]==key2->uuid.data4[2] &&
key1->uuid.data4[3]==key2->uuid.data4[3] &&
key1->uuid.data4[4]==key2->uuid.data4[4] &&
key1->uuid.data4[5]==key2->uuid.data4[5] &&
key1->uuid.data4[6]==key2->uuid.data4[6] &&
key1->uuid.data4[7]==key2->uuid.data4[7]);
return are_equal;
}
static void
feed_eo_smb2(tvbuff_t * tvb,packet_info *pinfo,smb2_info_t * si, guint16 dataoffset,guint32 length, guint64 file_offset) {
char *fid_name = NULL;
guint32 open_frame = 0, close_frame = 0;
tvbuff_t *data_tvb = NULL;
smb_eo_t *eo_info;
gchar *file_id;
gchar *auxstring;
gchar **aux_string_v;
/* Create a new tvb to point to the payload data */
data_tvb = tvb_new_subset_length(tvb, dataoffset, length);
/* Create the eo_info to pass to the listener */
eo_info = wmem_new(pinfo->pool, smb_eo_t);
/* Fill in eo_info */
eo_info->smbversion=2;
/* cmd == opcode */
eo_info->cmd=si->opcode;
/* We don't keep track of uid in SMB v2 */
eo_info->uid=0;
/* Try to get file id and filename */
file_id=policy_hnd_to_file_id(pinfo->pool, &si->saved->policy_hnd);
dcerpc_fetch_polhnd_data(&si->saved->policy_hnd, &fid_name, NULL, &open_frame, &close_frame, pinfo->num);
if (fid_name && g_strcmp0(fid_name,"File: ")!=0) {
auxstring=fid_name;
/* Remove "File: " from filename */
if (g_str_has_prefix(auxstring, "File: ")) {
aux_string_v = g_strsplit(auxstring, "File: ", -1);
eo_info->filename = wmem_strdup_printf(pinfo->pool, "\\%s",aux_string_v[g_strv_length(aux_string_v)-1]);
g_strfreev(aux_string_v);
} else {
if (g_str_has_prefix(auxstring, "\\")) {
eo_info->filename = wmem_strdup(pinfo->pool, auxstring);
} else {
eo_info->filename = wmem_strdup_printf(pinfo->pool, "\\%s",auxstring);
}
}
} else {
auxstring=wmem_strdup_printf(pinfo->pool, "File_Id_%s", file_id);
eo_info->filename=auxstring;
}
if (eosmb2_take_name_as_fid) {
eo_info->fid = g_str_hash(eo_info->filename);
} else {
eo_info->fid = g_str_hash(file_id);
}
/* tid, hostname, tree_id */
if (si->tree) {
eo_info->tid=si->tree->tid;
if (strlen(si->tree->name)>0 && strlen(si->tree->name)<=256) {
eo_info->hostname = wmem_strdup(pinfo->pool, si->tree->name);
} else {
eo_info->hostname = wmem_strdup_printf(pinfo->pool, "\\\\%s\\TREEID_%i",tree_ip_str(pinfo,si->opcode),si->tree->tid);
}
} else {
eo_info->tid=0;
eo_info->hostname = wmem_strdup_printf(pinfo->pool, "\\\\%s\\TREEID_UNKNOWN",tree_ip_str(pinfo,si->opcode));
}
/* packet number */
eo_info->pkt_num = pinfo->num;
/* fid type */
if (si->eo_file_info->attr_mask & SMB2_FLAGS_ATTR_DIRECTORY) {
eo_info->fid_type=SMB2_FID_TYPE_DIR;
} else {
if (si->eo_file_info->attr_mask &
(SMB2_FLAGS_ATTR_ARCHIVE | SMB2_FLAGS_ATTR_NORMAL |
SMB2_FLAGS_ATTR_HIDDEN | SMB2_FLAGS_ATTR_READONLY |
SMB2_FLAGS_ATTR_SYSTEM) ) {
eo_info->fid_type=SMB2_FID_TYPE_FILE;
} else {
eo_info->fid_type=SMB2_FID_TYPE_OTHER;
}
}
/* end_of_file */
eo_info->end_of_file=si->eo_file_info->end_of_file;
/* data offset and chunk length */
eo_info->smb_file_offset=file_offset;
eo_info->smb_chunk_len=length;
/* XXX is this right? */
if (length<si->saved->bytes_moved) {
si->saved->file_offset=si->saved->file_offset+length;
si->saved->bytes_moved=si->saved->bytes_moved-length;
}
/* Payload */
eo_info->payload_len = length;
eo_info->payload_data = tvb_get_ptr(data_tvb, 0, length);
tap_queue_packet(smb2_eo_tap, pinfo, eo_info);
}
static int dissect_smb2_file_full_ea_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, smb2_info_t *si);
/* This is a helper to dissect the common string type
* uint16 offset
* uint16 length
* ...
* char *string
*
* This function is called twice, first to decode the offset/length and
* second time to dissect the actual string.
* It is done this way since there is no guarantee that we have the full packet and we don't
* want to abort dissection too early if the packet ends somewhere between the
* length/offset and the actual buffer.
*
*/
enum offset_length_buffer_offset_size {
OLB_O_UINT16_S_UINT16,
OLB_O_UINT16_S_UINT32,
OLB_O_UINT8_P_UINT8_S_UINT32,
OLB_O_UINT32_S_UINT32,
OLB_S_UINT32_O_UINT32
};
typedef struct _offset_length_buffer_t {
guint32 off;
guint32 len;
int off_offset;
int len_offset;
enum offset_length_buffer_offset_size offset_size;
int hfindex;
} offset_length_buffer_t;
static int
dissect_smb2_olb_length_offset(tvbuff_t *tvb, int offset, offset_length_buffer_t *olb,
enum offset_length_buffer_offset_size offset_size, int hfindex)
{
olb->hfindex = hfindex;
olb->offset_size = offset_size;
switch (offset_size) {
case OLB_O_UINT16_S_UINT16:
olb->off = tvb_get_letohs(tvb, offset);
olb->off_offset = offset;
offset += 2;
olb->len = tvb_get_letohs(tvb, offset);
olb->len_offset = offset;
offset += 2;
break;
case OLB_O_UINT16_S_UINT32:
olb->off = tvb_get_letohs(tvb, offset);
olb->off_offset = offset;
offset += 2;
olb->len = tvb_get_letohl(tvb, offset);
olb->len_offset = offset;
offset += 4;
break;
case OLB_O_UINT8_P_UINT8_S_UINT32:
olb->off = tvb_get_guint8(tvb, offset);
olb->off_offset = offset;
offset += 1;
/* 1 byte reserved */
offset += 1;
olb->len = tvb_get_letohl(tvb, offset);
olb->len_offset = offset;
offset += 4;
break;
case OLB_O_UINT32_S_UINT32:
olb->off = tvb_get_letohl(tvb, offset);
olb->off_offset = offset;
offset += 4;
olb->len = tvb_get_letohl(tvb, offset);
olb->len_offset = offset;
offset += 4;
break;
case OLB_S_UINT32_O_UINT32:
olb->len = tvb_get_letohl(tvb, offset);
olb->len_offset = offset;
offset += 4;
olb->off = tvb_get_letohl(tvb, offset);
olb->off_offset = offset;
offset += 4;
break;
}
return offset;
}
#define OLB_TYPE_UNICODE_STRING 0x01
#define OLB_TYPE_ASCII_STRING 0x02
static const guint8 *
dissect_smb2_olb_off_string(packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, offset_length_buffer_t *olb, int base, int type)
{
int len, off;
proto_item *item = NULL;
proto_tree *tree = NULL;
const guint8 *name = NULL;
olb->off += base;
len = olb->len;
off = olb->off;
/* sanity check */
tvb_ensure_bytes_exist(tvb, off, len);
if (((off+len)<off)
|| ((off+len)>(off+tvb_reported_length_remaining(tvb, off)))) {
proto_tree_add_expert_format(tree, pinfo, &ei_smb2_invalid_length, tvb, off, -1,
"Invalid offset/length. Malformed packet");
col_append_str(pinfo->cinfo, COL_INFO, " [Malformed packet]");
return NULL;
}
switch (type) {
case OLB_TYPE_UNICODE_STRING:
item = proto_tree_add_item_ret_string(parent_tree,
olb->hfindex, tvb, off, len, ENC_UTF_16|ENC_LITTLE_ENDIAN,
pinfo->pool, &name);
tree = proto_item_add_subtree(item, ett_smb2_olb);
break;
case OLB_TYPE_ASCII_STRING:
item = proto_tree_add_item_ret_string(parent_tree,
olb->hfindex, tvb, off, len, ENC_ASCII|ENC_NA,
pinfo->pool, &name);
tree = proto_item_add_subtree(item, ett_smb2_olb);
break;
}
switch (olb->offset_size) {
case OLB_O_UINT16_S_UINT16:
proto_tree_add_item(tree, hf_smb2_olb_offset, tvb, olb->off_offset, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_smb2_olb_length, tvb, olb->len_offset, 2, ENC_LITTLE_ENDIAN);
break;
case OLB_O_UINT16_S_UINT32:
proto_tree_add_item(tree, hf_smb2_olb_offset, tvb, olb->off_offset, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_smb2_olb_length, tvb, olb->len_offset, 4, ENC_LITTLE_ENDIAN);
break;
case OLB_O_UINT8_P_UINT8_S_UINT32:
proto_tree_add_item(tree, hf_smb2_olb_offset, tvb, olb->off_offset, 1, ENC_NA);
proto_tree_add_item(tree, hf_smb2_reserved, tvb, olb->off_offset+1, 1, ENC_NA);
proto_tree_add_item(tree, hf_smb2_olb_length, tvb, olb->len_offset, 4, ENC_LITTLE_ENDIAN);
break;
case OLB_O_UINT32_S_UINT32:
proto_tree_add_item(tree, hf_smb2_olb_offset, tvb, olb->off_offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_smb2_olb_length, tvb, olb->len_offset, 4, ENC_LITTLE_ENDIAN);
break;
case OLB_S_UINT32_O_UINT32:
proto_tree_add_item(tree, hf_smb2_olb_length, tvb, olb->len_offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_smb2_olb_offset, tvb, olb->off_offset, 4, ENC_LITTLE_ENDIAN);
break;
}
return name;
}
static const guint8 *
dissect_smb2_olb_string(packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, offset_length_buffer_t *olb, int type)
{
return dissect_smb2_olb_off_string(pinfo, parent_tree, tvb, olb, 0, type);
}
static void
dissect_smb2_olb_buffer(packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb,
offset_length_buffer_t *olb, smb2_info_t *si,
void (*dissector)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si))
{
int len, off;
proto_item *sub_item = NULL;
proto_tree *sub_tree = NULL;
tvbuff_t *sub_tvb = NULL;
int offset;
offset = olb->off;
len = olb->len;
off = olb->off;
/* sanity check */
tvb_ensure_bytes_exist(tvb, off, len);
if (((off+len)<off)
|| ((off+len)>(off+tvb_reported_length_remaining(tvb, off)))) {
proto_tree_add_expert_format(parent_tree, pinfo, &ei_smb2_invalid_length, tvb, offset, -1,
"Invalid offset/length. Malformed packet");
col_append_str(pinfo->cinfo, COL_INFO, " [Malformed packet]");
return;
}
switch (olb->offset_size) {
case OLB_O_UINT16_S_UINT16:
proto_tree_add_item(parent_tree, hf_smb2_olb_offset, tvb, olb->off_offset, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(parent_tree, hf_smb2_olb_length, tvb, olb->len_offset, 2, ENC_LITTLE_ENDIAN);
break;
case OLB_O_UINT16_S_UINT32:
proto_tree_add_item(parent_tree, hf_smb2_olb_offset, tvb, olb->off_offset, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(parent_tree, hf_smb2_olb_length, tvb, olb->len_offset, 4, ENC_LITTLE_ENDIAN);
break;
case OLB_O_UINT8_P_UINT8_S_UINT32:
proto_tree_add_item(parent_tree, hf_smb2_olb_offset, tvb, olb->off_offset, 1, ENC_NA);
proto_tree_add_item(parent_tree, hf_smb2_reserved, tvb, olb->off_offset+1, 1, ENC_NA);
proto_tree_add_item(parent_tree, hf_smb2_olb_length, tvb, olb->len_offset, 4, ENC_LITTLE_ENDIAN);
break;
case OLB_O_UINT32_S_UINT32:
proto_tree_add_item(parent_tree, hf_smb2_olb_offset, tvb, olb->off_offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(parent_tree, hf_smb2_olb_length, tvb, olb->len_offset, 4, ENC_LITTLE_ENDIAN);
break;
case OLB_S_UINT32_O_UINT32:
proto_tree_add_item(parent_tree, hf_smb2_olb_length, tvb, olb->len_offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(parent_tree, hf_smb2_olb_offset, tvb, olb->off_offset, 4, ENC_LITTLE_ENDIAN);
break;
}
/* if we don't want/need a subtree */
if (olb->hfindex == -1) {
sub_item = parent_tree;
sub_tree = parent_tree;
} else {
if (parent_tree) {
sub_item = proto_tree_add_item(parent_tree, olb->hfindex, tvb, offset, len, ENC_NA);
sub_tree = proto_item_add_subtree(sub_item, ett_smb2_olb);
}
}
if (off == 0 || len == 0) {
proto_item_append_text(sub_item, ": NO DATA");
return;
}
if (!dissector) {
return;
}
sub_tvb = tvb_new_subset_length_caplen(tvb, off, MIN((int)len, tvb_captured_length_remaining(tvb, off)), len);
dissector(sub_tvb, pinfo, sub_tree, si);
}
static int
dissect_smb2_olb_tvb_max_offset(int offset, offset_length_buffer_t *olb)
{
if (olb->off == 0) {
return offset;
}
return MAX(offset, (int)(olb->off + olb->len));
}
typedef struct _smb2_function {
int (*request) (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si);
int (*response)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si);
} smb2_function;
static const true_false_string tfs_smb2_svhdx_has_initiator_id = {
"Has an initiator id",
"Does not have an initiator id"
};
static const true_false_string tfs_flags_response = {
"This is a RESPONSE",
"This is a REQUEST"
};
static const true_false_string tfs_flags_async_cmd = {
"This is an ASYNC command",
"This is a SYNC command"
};
static const true_false_string tfs_flags_dfs_op = {
"This is a DFS OPERATION",
"This is a normal operation"
};
static const true_false_string tfs_flags_chained = {
"This pdu is a CHAINED command",
"This pdu is NOT a chained command"
};
static const true_false_string tfs_flags_signature = {
"This pdu is SIGNED",
"This pdu is NOT signed"
};
static const true_false_string tfs_flags_replay_operation = {
"This is a REPLAY OPERATION",
"This is NOT a replay operation"
};
static const true_false_string tfs_flags_priority_mask = {
"This pdu contains a PRIORITY",
"This pdu does NOT contain a PRIORITY"
};
static const true_false_string tfs_cap_dfs = {
"This host supports DFS",
"This host does NOT support DFS"
};
static const true_false_string tfs_cap_leasing = {
"This host supports LEASING",
"This host does NOT support LEASING"
};
static const true_false_string tfs_cap_large_mtu = {
"This host supports LARGE_MTU",
"This host does NOT support LARGE_MTU"
};
static const true_false_string tfs_cap_multi_channel = {
"This host supports MULTI CHANNEL",
"This host does NOT support MULTI CHANNEL"
};
static const true_false_string tfs_cap_persistent_handles = {
"This host supports PERSISTENT HANDLES",
"This host does NOT support PERSISTENT HANDLES"
};
static const true_false_string tfs_cap_directory_leasing = {
"This host supports DIRECTORY LEASING",
"This host does NOT support DIRECTORY LEASING"
};
static const true_false_string tfs_cap_encryption = {
"This host supports ENCRYPTION",
"This host does NOT support ENCRYPTION"
};
static const true_false_string tfs_smb2_ioctl_network_interface_capability_rss = {
"This interface supports RSS",
"This interface does not support RSS"
};
static const true_false_string tfs_smb2_ioctl_network_interface_capability_rdma = {
"This interface supports RDMA",
"This interface does not support RDMA"
};
static const value_string file_region_usage_vals[] = {
{ 0x00000001, "FILE_REGION_USAGE_VALID_CACHED_DATA" },
{ 0, NULL }
};
static const value_string originator_flags_vals[] = {
{ 1, "SVHDX_ORIGINATOR_PVHDPARSER" },
{ 4, "SVHDX_ORIGINATOR_VHDMP" },
{ 0, NULL }
};
static const value_string compression_format_vals[] = {
{ 0, "COMPRESSION_FORMAT_NONE" },
{ 1, "COMPRESSION_FORMAT_DEFAULT" },
{ 2, "COMPRESSION_FORMAT_LZNT1" },
{ 0, NULL }
};
static const value_string checksum_algorithm_vals[] = {
{ 0x0000, "CHECKSUM_TYPE_NONE" },
{ 0x0002, "CHECKSUM_TYPE_CRC64" },
{ 0xFFFF, "CHECKSUM_TYPE_UNCHANGED" },
{ 0, NULL }
};
/* Note: All uncommented are "dissector not implemented" */
static const value_string smb2_ioctl_vals[] = {
{0x00060194, "FSCTL_DFS_GET_REFERRALS"}, /* dissector implemented */
{0x000601B0, "FSCTL_DFS_GET_REFERRALS_EX"},
{0x00090000, "FSCTL_REQUEST_OPLOCK_LEVEL_1"},
{0x00090004, "FSCTL_REQUEST_OPLOCK_LEVEL_2"},
{0x00090008, "FSCTL_REQUEST_BATCH_OPLOCK"},
{0x0009000C, "FSCTL_OPLOCK_BREAK_ACKNOWLEDGE"},
{0x00090010, "FSCTL_OPBATCH_ACK_CLOSE_PENDING"},
{0x00090014, "FSCTL_OPLOCK_BREAK_NOTIFY"},
{0x00090018, "FSCTL_LOCK_VOLUME"},
{0x0009001C, "FSCTL_UNLOCK_VOLUME"},
{0x00090020, "FSCTL_DISMOUNT_VOLUME"},
{0x00090028, "FSCTL_IS_VOLUME_MOUNTED"},
{0x0009002C, "FSCTL_IS_PATHNAME_VALID"},
{0x00090030, "FSCTL_MARK_VOLUME_DIRTY"},
{0x0009003B, "FSCTL_QUERY_RETRIEVAL_POINTERS"},
{0x0009003C, "FSCTL_GET_COMPRESSION"}, /* dissector implemented */
{0x0009004F, "FSCTL_MARK_AS_SYSTEM_HIVE"},
{0x00090050, "FSCTL_OPLOCK_BREAK_ACK_NO_2"},
{0x00090054, "FSCTL_INVALIDATE_VOLUMES"},
{0x00090058, "FSCTL_QUERY_FAT_BPB"},
{0x0009005C, "FSCTL_REQUEST_FILTER_OPLOCK"},
{0x00090060, "FSCTL_FILESYSTEM_GET_STATISTICS"},
{0x00090064, "FSCTL_GET_NTFS_VOLUME_DATA"},
{0x00090068, "FSCTL_GET_NTFS_FILE_RECORD"},
{0x0009006F, "FSCTL_GET_VOLUME_BITMAP"},
{0x00090073, "FSCTL_GET_RETRIEVAL_POINTERS"},
{0x00090074, "FSCTL_MOVE_FILE"},
{0x00090078, "FSCTL_IS_VOLUME_DIRTY"},
{0x0009007C, "FSCTL_GET_HFS_INFORMATION"},
{0x00090083, "FSCTL_ALLOW_EXTENDED_DASD_IO"},
{0x00090087, "FSCTL_READ_PROPERTY_DATA"},
{0x0009008B, "FSCTL_WRITE_PROPERTY_DATA"},
{0x0009008F, "FSCTL_FIND_FILES_BY_SID"},
{0x00090097, "FSCTL_DUMP_PROPERTY_DATA"},
{0x0009009C, "FSCTL_GET_OBJECT_ID"}, /* dissector implemented */
{0x000900A4, "FSCTL_SET_REPARSE_POINT"}, /* dissector implemented */
{0x000900A8, "FSCTL_GET_REPARSE_POINT"}, /* dissector implemented */
{0x000900C0, "FSCTL_CREATE_OR_GET_OBJECT_ID"}, /* dissector implemented */
{0x000900C4, "FSCTL_SET_SPARSE"}, /* dissector implemented */
{0x000900D4, "FSCTL_SET_ENCRYPTION"},
{0x000900DB, "FSCTL_ENCRYPTION_FSCTL_IO"},
{0x000900DF, "FSCTL_WRITE_RAW_ENCRYPTED"},
{0x000900E3, "FSCTL_READ_RAW_ENCRYPTED"},
{0x000900F0, "FSCTL_EXTEND_VOLUME"},
{0x00090244, "FSCTL_CSV_TUNNEL_REQUEST"},
{0x0009027C, "FSCTL_GET_INTEGRITY_INFORMATION"},
{0x00090284, "FSCTL_QUERY_FILE_REGIONS"}, /* dissector implemented */
{0x000902c8, "FSCTL_CSV_SYNC_TUNNEL_REQUEST"},
{0x00090300, "FSCTL_QUERY_SHARED_VIRTUAL_DISK_SUPPORT"}, /* dissector implemented */
{0x00090304, "FSCTL_SVHDX_SYNC_TUNNEL_REQUEST"}, /* dissector implemented */
{0x00090308, "FSCTL_SVHDX_SET_INITIATOR_INFORMATION"},
{0x0009030C, "FSCTL_SET_EXTERNAL_BACKING"},
{0x00090310, "FSCTL_GET_EXTERNAL_BACKING"},
{0x00090314, "FSCTL_DELETE_EXTERNAL_BACKING"},
{0x00090318, "FSCTL_ENUM_EXTERNAL_BACKING"},
{0x0009031F, "FSCTL_ENUM_OVERLAY"},
{0x00090350, "FSCTL_STORAGE_QOS_CONTROL"}, /* dissector implemented */
{0x00090364, "FSCTL_SVHDX_ASYNC_TUNNEL_REQUEST"}, /* dissector implemented */
{0x000940B3, "FSCTL_ENUM_USN_DATA"},
{0x000940B7, "FSCTL_SECURITY_ID_CHECK"},
{0x000940BB, "FSCTL_READ_USN_JOURNAL"},
{0x000940CF, "FSCTL_QUERY_ALLOCATED_RANGES"}, /* dissector implemented */
{0x000940E7, "FSCTL_CREATE_USN_JOURNAL"},
{0x000940EB, "FSCTL_READ_FILE_USN_DATA"},
{0x000940EF, "FSCTL_WRITE_USN_CLOSE_RECORD"},
{0x00094264, "FSCTL_OFFLOAD_READ"}, /* dissector implemented */
{0x00098098, "FSCTL_SET_OBJECT_ID"}, /* dissector implemented */
{0x000980A0, "FSCTL_DELETE_OBJECT_ID"}, /* no data in/out */
{0x000980A4, "FSCTL_SET_REPARSE_POINT"},
{0x000980AC, "FSCTL_DELETE_REPARSE_POINT"},
{0x000980BC, "FSCTL_SET_OBJECT_ID_EXTENDED"}, /* dissector implemented */
{0x000980C8, "FSCTL_SET_ZERO_DATA"}, /* dissector implemented */
{0x000980D0, "FSCTL_ENABLE_UPGRADE"},
{0x00098208, "FSCTL_FILE_LEVEL_TRIM"},
{0x00098268, "FSCTL_OFFLOAD_WRITE"}, /* dissector implemented */
{0x0009C040, "FSCTL_SET_COMPRESSION"}, /* dissector implemented */
{0x0009C280, "FSCTL_SET_INTEGRITY_INFORMATION"}, /* dissector implemented */
{0x00110018, "FSCTL_PIPE_WAIT"}, /* dissector implemented */
{0x0011400C, "FSCTL_PIPE_PEEK"},
{0x0011C017, "FSCTL_PIPE_TRANSCEIVE"}, /* dissector implemented */
{0x00140078, "FSCTL_SRV_REQUEST_RESUME_KEY"},
{0x001401D4, "FSCTL_LMR_REQUEST_RESILIENCY"}, /* dissector implemented */
{0x001401FC, "FSCTL_QUERY_NETWORK_INTERFACE_INFO"}, /* dissector implemented */
{0x00140200, "FSCTL_VALIDATE_NEGOTIATE_INFO_224"}, /* dissector implemented */
{0x00140204, "FSCTL_VALIDATE_NEGOTIATE_INFO"}, /* dissector implemented */
{0x00144064, "FSCTL_SRV_ENUMERATE_SNAPSHOTS"}, /* dissector implemented */
{0x001440F2, "FSCTL_SRV_COPYCHUNK"},
{0x001441bb, "FSCTL_SRV_READ_HASH"},
{0x001480F2, "FSCTL_SRV_COPYCHUNK_WRITE"},
{ 0, NULL }
};
static value_string_ext smb2_ioctl_vals_ext = VALUE_STRING_EXT_INIT(smb2_ioctl_vals);
static const value_string smb2_ioctl_device_vals[] = {
{ 0x0001, "BEEP" },
{ 0x0002, "CD_ROM" },
{ 0x0003, "CD_ROM_FILE_SYSTEM" },
{ 0x0004, "CONTROLLER" },
{ 0x0005, "DATALINK" },
{ 0x0006, "DFS" },
{ 0x0007, "DISK" },
{ 0x0008, "DISK_FILE_SYSTEM" },
{ 0x0009, "FILE_SYSTEM" },
{ 0x000a, "INPORT_PORT" },
{ 0x000b, "KEYBOARD" },
{ 0x000c, "MAILSLOT" },
{ 0x000d, "MIDI_IN" },
{ 0x000e, "MIDI_OUT" },
{ 0x000f, "MOUSE" },
{ 0x0010, "MULTI_UNC_PROVIDER" },
{ 0x0011, "NAMED_PIPE" },
{ 0x0012, "NETWORK" },
{ 0x0013, "NETWORK_BROWSER" },
{ 0x0014, "NETWORK_FILE_SYSTEM" },
{ 0x0015, "NULL" },
{ 0x0016, "PARALLEL_PORT" },
{ 0x0017, "PHYSICAL_NETCARD" },
{ 0x0018, "PRINTER" },
{ 0x0019, "SCANNER" },
{ 0x001a, "SERIAL_MOUSE_PORT" },
{ 0x001b, "SERIAL_PORT" },
{ 0x001c, "SCREEN" },
{ 0x001d, "SOUND" },
{ 0x001e, "STREAMS" },
{ 0x001f, "TAPE" },
{ 0x0020, "TAPE_FILE_SYSTEM" },
{ 0x0021, "TRANSPORT" },
{ 0x0022, "UNKNOWN" },
{ 0x0023, "VIDEO" },
{ 0x0024, "VIRTUAL_DISK" },
{ 0x0025, "WAVE_IN" },
{ 0x0026, "WAVE_OUT" },
{ 0x0027, "8042_PORT" },
{ 0x0028, "NETWORK_REDIRECTOR" },
{ 0x0029, "BATTERY" },
{ 0x002a, "BUS_EXTENDER" },
{ 0x002b, "MODEM" },
{ 0x002c, "VDM" },
{ 0x002d, "MASS_STORAGE" },
{ 0x002e, "SMB" },
{ 0x002f, "KS" },
{ 0x0030, "CHANGER" },
{ 0x0031, "SMARTCARD" },
{ 0x0032, "ACPI" },
{ 0x0033, "DVD" },
{ 0x0034, "FULLSCREEN_VIDEO" },
{ 0x0035, "DFS_FILE_SYSTEM" },
{ 0x0036, "DFS_VOLUME" },
{ 0x0037, "SERENUM" },
{ 0x0038, "TERMSRV" },
{ 0x0039, "KSEC" },
{ 0, NULL }
};
static value_string_ext smb2_ioctl_device_vals_ext = VALUE_STRING_EXT_INIT(smb2_ioctl_device_vals);
static const value_string smb2_ioctl_access_vals[] = {
{ 0x00, "FILE_ANY_ACCESS" },
{ 0x01, "FILE_READ_ACCESS" },
{ 0x02, "FILE_WRITE_ACCESS" },
{ 0x03, "FILE_READ_WRITE_ACCESS" },
{ 0, NULL }
};
static const value_string smb2_ioctl_method_vals[] = {
{ 0x00, "METHOD_BUFFERED" },
{ 0x01, "METHOD_IN_DIRECT" },
{ 0x02, "METHOD_OUT_DIRECT" },
{ 0x03, "METHOD_NEITHER" },
{ 0, NULL }
};
static const value_string smb2_ioctl_shared_virtual_disk_vals[] = {
{ 0x01, "SharedVirtualDisksSupported" },
{ 0x07, "SharedVirtualDiskCDPSnapshotsSupported" },
{ 0, NULL }
};
static const value_string smb2_ioctl_shared_virtual_disk_hstate_vals[] = {
{ 0x00, "HandleStateNone" },
{ 0x01, "HandleStateFileShared" },
{ 0x03, "HandleStateShared" },
{ 0, NULL }
};
/* this is called from both smb and smb2. */
int
dissect_smb2_ioctl_function(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, guint32 *ioctlfunc)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint32 ioctl_function;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_ioctl_function, tvb, offset, 4, ENC_LITTLE_ENDIAN);
tree = proto_item_add_subtree(item, ett_smb2_ioctl_function);
}
ioctl_function = tvb_get_letohl(tvb, offset);
if (ioctlfunc)
*ioctlfunc = ioctl_function;
if (ioctl_function) {
const gchar *unknown = "unknown";
const gchar *ioctl_name = val_to_str_ext_const(ioctl_function,
&smb2_ioctl_vals_ext,
unknown);
/*
* val_to_str_const() doesn't work with a unknown == NULL
*/
if (ioctl_name == unknown) {
ioctl_name = NULL;
}
if (ioctl_name != NULL) {
col_append_fstr(
pinfo->cinfo, COL_INFO, " %s", ioctl_name);
}
/* device */
proto_tree_add_item(tree, hf_smb2_ioctl_function_device, tvb, offset, 4, ENC_LITTLE_ENDIAN);
if (ioctl_name == NULL) {
col_append_fstr(
pinfo->cinfo, COL_INFO, " %s",
val_to_str_ext((ioctl_function>>16)&0xffff, &smb2_ioctl_device_vals_ext,
"Unknown (0x%08X)"));
}
/* access */
proto_tree_add_item(tree, hf_smb2_ioctl_function_access, tvb, offset, 4, ENC_LITTLE_ENDIAN);
/* function */
proto_tree_add_item(tree, hf_smb2_ioctl_function_function, tvb, offset, 4, ENC_LITTLE_ENDIAN);
if (ioctl_name == NULL) {
col_append_fstr(
pinfo->cinfo, COL_INFO, " Function:0x%04x",
(ioctl_function>>2)&0x0fff);
}
/* method */
proto_tree_add_item(tree, hf_smb2_ioctl_function_method, tvb, offset, 4, ENC_LITTLE_ENDIAN);
}
offset += 4;
return offset;
}
/* fake the dce/rpc support structures so we can piggy back on
* dissect_nt_policy_hnd() since this will allow us
* a cheap way to track where FIDs are opened, closed
* and fid->filename mappings
* if we want to do those things in the future.
*/
#define FID_MODE_OPEN 0
#define FID_MODE_CLOSE 1
#define FID_MODE_USE 2
#define FID_MODE_DHNQ 3
#define FID_MODE_DHNC 4
static int
dissect_smb2_fid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si, int mode)
{
guint8 drep[4] = { 0x10, 0x00, 0x00, 0x00}; /* fake DREP struct */
static dcerpc_info di; /* fake dcerpc_info struct */
static dcerpc_call_value call_data;
e_ctx_hnd policy_hnd;
e_ctx_hnd *policy_hnd_hashtablekey;
proto_item *hnd_item = NULL;
char *fid_name;
guint32 open_frame = 0, close_frame = 0;
smb2_eo_file_info_t *eo_file_info;
smb2_fid_info_t sfi_key;
smb2_fid_info_t *sfi = NULL;
memset(&sfi_key, 0, sizeof(sfi_key));
sfi_key.fid_persistent = tvb_get_letoh64(tvb, offset);
sfi_key.fid_volatile = tvb_get_letoh64(tvb, offset+8);
sfi_key.sesid = si->sesid;
sfi_key.tid = si->tid;
sfi_key.frame_key = pinfo->num;
sfi_key.name = NULL;
di.conformant_run = 0;
/* we need di->call_data->flags.NDR64 == 0 */
di.call_data = &call_data;
switch (mode) {
case FID_MODE_OPEN:
offset = dissect_nt_guid_hnd(tvb, offset, pinfo, tree, &di, drep, hf_smb2_fid, &policy_hnd, &hnd_item, TRUE, FALSE);
if (!pinfo->fd->visited) {
sfi = wmem_new(wmem_file_scope(), smb2_fid_info_t);
*sfi = sfi_key;
sfi->frame_key = 0;
sfi->frame_beg = si->saved ? si->saved->frame_req : pinfo->num;
sfi->frame_end = G_MAXUINT32;
if (si->saved && si->saved->extra_info_type == SMB2_EI_FILENAME) {
sfi->name = wmem_strdup(wmem_file_scope(), (char *)si->saved->extra_info);
} else {
sfi->name = wmem_strdup_printf(wmem_file_scope(), "[unknown]");
}
if (si->saved && si->saved->extra_info_type == SMB2_EI_FILENAME) {
fid_name = wmem_strdup_printf(wmem_file_scope(), "File: %s", (char *)si->saved->extra_info);
} else {
fid_name = wmem_strdup_printf(wmem_file_scope(), "File: ");
}
dcerpc_store_polhnd_name(&policy_hnd, pinfo,
fid_name);
wmem_map_insert(si->session->fids, sfi, sfi);
si->file = sfi;
/* If needed, create the file entry and save the policy hnd */
if (si->saved) {
si->saved->file = sfi;
si->saved->policy_hnd = policy_hnd;
}
if (si->conv) {
eo_file_info = (smb2_eo_file_info_t *)wmem_map_lookup(si->session->files,&policy_hnd);
if (!eo_file_info) {
eo_file_info = wmem_new(wmem_file_scope(), smb2_eo_file_info_t);
policy_hnd_hashtablekey = wmem_new(wmem_file_scope(), e_ctx_hnd);
memcpy(policy_hnd_hashtablekey, &policy_hnd, sizeof(e_ctx_hnd));
eo_file_info->end_of_file=0;
wmem_map_insert(si->session->files,policy_hnd_hashtablekey,eo_file_info);
}
si->eo_file_info=eo_file_info;
}
}
break;
case FID_MODE_CLOSE:
if (!pinfo->fd->visited) {
smb2_fid_info_t *fid = (smb2_fid_info_t *)wmem_map_lookup(si->session->fids, &sfi_key);
if (fid) {
/* set last frame */
fid->frame_end = pinfo->num;
}
}
offset = dissect_nt_guid_hnd(tvb, offset, pinfo, tree, &di, drep, hf_smb2_fid, &policy_hnd, &hnd_item, FALSE, TRUE);
break;
case FID_MODE_USE:
case FID_MODE_DHNQ:
case FID_MODE_DHNC:
offset = dissect_nt_guid_hnd(tvb, offset, pinfo, tree, &di, drep, hf_smb2_fid, &policy_hnd, &hnd_item, FALSE, FALSE);
break;
}
si->file = (smb2_fid_info_t *)wmem_map_lookup(si->session->fids, &sfi_key);
if (si->file) {
if (si->saved) {
si->saved->file = si->file;
}
if (si->file->name) {
if (hnd_item) {
proto_item_append_text(hnd_item, " File: %s", si->file->name);
}
col_append_fstr(pinfo->cinfo, COL_INFO, " File: %s", si->file->name);
}
}
if (dcerpc_fetch_polhnd_data(&policy_hnd, &fid_name, NULL, &open_frame, &close_frame, pinfo->num)) {
/* look for the eo_file_info */
if (!si->eo_file_info) {
if (si->saved) { si->saved->policy_hnd = policy_hnd; }
if (si->conv) {
eo_file_info = (smb2_eo_file_info_t *)wmem_map_lookup(si->session->files,&policy_hnd);
if (eo_file_info) {
si->eo_file_info=eo_file_info;
} else { /* XXX This should never happen */
eo_file_info = wmem_new(wmem_file_scope(), smb2_eo_file_info_t);
policy_hnd_hashtablekey = wmem_new(wmem_file_scope(), e_ctx_hnd);
memcpy(policy_hnd_hashtablekey, &policy_hnd, sizeof(e_ctx_hnd));
eo_file_info->end_of_file=0;
wmem_map_insert(si->session->files,policy_hnd_hashtablekey,eo_file_info);
}
}
}
}
return offset;
}
#define SMB2_FSCC_FILE_ATTRIBUTE_READ_ONLY 0x00000001
#define SMB2_FSCC_FILE_ATTRIBUTE_HIDDEN 0x00000002
#define SMB2_FSCC_FILE_ATTRIBUTE_SYSTEM 0x00000004
#define SMB2_FSCC_FILE_ATTRIBUTE_DIRECTORY 0x00000010
#define SMB2_FSCC_FILE_ATTRIBUTE_ARCHIVE 0x00000020
#define SMB2_FSCC_FILE_ATTRIBUTE_NORMAL 0x00000080
#define SMB2_FSCC_FILE_ATTRIBUTE_TEMPORARY 0x00000100
#define SMB2_FSCC_FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
#define SMB2_FSCC_FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
#define SMB2_FSCC_FILE_ATTRIBUTE_COMPRESSED 0x00000800
#define SMB2_FSCC_FILE_ATTRIBUTE_OFFLINE 0x00001000
#define SMB2_FSCC_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
#define SMB2_FSCC_FILE_ATTRIBUTE_ENCRYPTED 0x00004000
#define SMB2_FSCC_FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
#define SMB2_FSCC_FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
static const true_false_string tfs_fscc_file_attribute_reparse = {
"Has an associated REPARSE POINT",
"Does NOT have an associated reparse point"
};
static const true_false_string tfs_fscc_file_attribute_compressed = {
"COMPRESSED",
"Uncompressed"
};
static const true_false_string tfs_fscc_file_attribute_offline = {
"OFFLINE",
"Online"
};
static const true_false_string tfs_fscc_file_attribute_not_content_indexed = {
"Is not indexed by the content indexing service",
"Is indexed by the content indexing service"
};
static const true_false_string tfs_fscc_file_attribute_integrity_stream = {
"Has Integrity Support",
"Does NOT have Integrity Support"
};
static const true_false_string tfs_fscc_file_attribute_no_scrub_data = {
"Is excluded from the data integrity scan",
"Is not excluded from the data integrity scan"
};
/*
* File Attributes, section 2.6 in the [MS-FSCC] spec
*/
static int
dissect_fscc_file_attr(tvbuff_t* tvb, proto_tree* parent_tree, int offset, guint32* attr)
{
guint32 mask = tvb_get_letohl(tvb, offset);
static int* const mask_fields[] = {
&hf_smb2_fscc_file_attr_read_only,
&hf_smb2_fscc_file_attr_hidden,
&hf_smb2_fscc_file_attr_system,
&hf_smb2_fscc_file_attr_directory,
&hf_smb2_fscc_file_attr_archive,
&hf_smb2_fscc_file_attr_normal,
&hf_smb2_fscc_file_attr_temporary,
&hf_smb2_fscc_file_attr_sparse_file,
&hf_smb2_fscc_file_attr_reparse_point,
&hf_smb2_fscc_file_attr_compressed,
&hf_smb2_fscc_file_attr_offline,
&hf_smb2_fscc_file_attr_not_content_indexed,
&hf_smb2_fscc_file_attr_encrypted,
&hf_smb2_fscc_file_attr_integrity_stream,
&hf_smb2_fscc_file_attr_no_scrub_data,
NULL
};
proto_tree_add_bitmask_value_with_flags(parent_tree, tvb, offset, hf_smb2_fscc_file_attr, ett_smb2_fscc_file_attributes, mask_fields, mask, BMT_NO_APPEND);
offset += 4;
if (attr)
*attr = mask;
return offset;
}
/* this info level is unique to SMB2 and differst from the corresponding
* SMB_FILE_ALL_INFO in SMB
*/
static int
dissect_smb2_file_all_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
int length;
static int * const mode_fields[] = {
&hf_smb2_mode_file_write_through,
&hf_smb2_mode_file_sequential_only,
&hf_smb2_mode_file_no_intermediate_buffering,
&hf_smb2_mode_file_synchronous_io_alert,
&hf_smb2_mode_file_synchronous_io_nonalert,
&hf_smb2_mode_file_delete_on_close,
NULL,
};
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_all_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_all_info);
}
/* create time */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
/* last access */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
/* last write */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
/* last change */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
/* File Attributes */
offset = dissect_fscc_file_attr(tvb, tree, offset, NULL);
/* some unknown bytes */
proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 4, ENC_NA);
offset += 4;
/* allocation size */
proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* end of file */
proto_tree_add_item(tree, hf_smb2_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* number of links */
proto_tree_add_item(tree, hf_smb2_nlinks, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* delete pending */
proto_tree_add_item(tree, hf_smb2_delete_pending, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* is directory */
proto_tree_add_item(tree, hf_smb2_is_directory, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* padding */
offset += 2;
/* file id */
proto_tree_add_item(tree, hf_smb2_file_id, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* ea size */
proto_tree_add_item(tree, hf_smb2_ea_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* access mask */
offset = dissect_smb_access_mask(tvb, tree, offset);
/* Position Information */
proto_tree_add_item(tree, hf_smb2_position_information, tvb, offset, 8, ENC_NA);
offset += 8;
/* Mode Information */
proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_mode_information, ett_smb2_file_mode_info, mode_fields, ENC_LITTLE_ENDIAN);
offset += 4;
/* Alignment Information */
proto_tree_add_item(tree, hf_smb2_alignment_information, tvb, offset, 4, ENC_NA);
offset +=4;
/* file name length */
length = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* file name */
if (length) {
proto_tree_add_item(tree, hf_smb2_filename,
tvb, offset, length, ENC_UTF_16|ENC_LITTLE_ENDIAN);
offset += length;
}
return offset;
}
static int
dissect_smb2_file_allocation_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
gboolean trunc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_allocation_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_allocation_info);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qsfi_SMB_FILE_ALLOCATION_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
return offset;
}
static int
dissect_smb2_file_endoffile_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
gboolean trunc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_endoffile_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_endoffile_info);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qsfi_SMB_FILE_ENDOFFILE_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
return offset;
}
static int
dissect_smb2_file_alternate_name_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
gboolean trunc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_alternate_name_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_alternate_name_info);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qfi_SMB_FILE_NAME_INFO(tvb, pinfo, tree, offset, &bc, &trunc, /* XXX assumption hack */ TRUE);
return offset;
}
static int
dissect_smb2_file_normalized_name_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
gboolean trunc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_normalized_name_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_normalized_name_info);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qfi_SMB_FILE_NAME_INFO(tvb, pinfo, tree, offset, &bc, &trunc, /* XXX assumption hack */ TRUE);
return offset;
}
static int
dissect_smb2_file_basic_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_basic_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_basic_info);
}
/* create time */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
/* last access */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
/* last write */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
/* last change */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
/* File Attributes */
offset = dissect_fscc_file_attr(tvb, tree, offset, NULL);
/* some unknown bytes */
proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 4, ENC_NA);
offset += 4;
return offset;
}
static int
dissect_smb2_file_standard_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
gboolean trunc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_standard_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_standard_info);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qfi_SMB_FILE_STANDARD_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
return offset;
}
static int
dissect_smb2_file_internal_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
gboolean trunc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_internal_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_internal_info);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qfi_SMB_FILE_INTERNAL_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
return offset;
}
static int
dissect_smb2_file_mode_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
gboolean trunc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_mode_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_mode_info);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qsfi_SMB_FILE_MODE_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
return offset;
}
static int
dissect_smb2_file_alignment_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
gboolean trunc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_alignment_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_alignment_info);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qfi_SMB_FILE_ALIGNMENT_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
return offset;
}
static int
dissect_smb2_file_position_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
gboolean trunc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_position_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_position_info);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qsfi_SMB_FILE_POSITION_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
return offset;
}
static int
dissect_smb2_file_access_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_access_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_access_info);
}
/* access mask */
offset = dissect_smb_access_mask(tvb, tree, offset);
return offset;
}
static int
dissect_smb2_file_ea_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
gboolean trunc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_ea_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_ea_info);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qfi_SMB_FILE_EA_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
return offset;
}
static int
dissect_smb2_file_stream_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
gboolean trunc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_stream_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_stream_info);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qfi_SMB_FILE_STREAM_INFO(tvb, pinfo, tree, offset, &bc, &trunc, TRUE);
return offset;
}
static int
dissect_smb2_file_pipe_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
gboolean trunc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_pipe_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_pipe_info);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_sfi_SMB_FILE_PIPE_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
return offset;
}
static int
dissect_smb2_file_compression_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
gboolean trunc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_compression_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_compression_info);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qfi_SMB_FILE_COMPRESSION_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
return offset;
}
static int
dissect_smb2_file_network_open_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
gboolean trunc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_network_open_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_network_open_info);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qfi_SMB_FILE_NETWORK_OPEN_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
return offset;
}
static int
dissect_smb2_file_attribute_tag_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
gboolean trunc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_attribute_tag_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_attribute_tag_info);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qfi_SMB_FILE_ATTRIBUTE_TAG_INFO(tvb, pinfo, tree, offset, &bc, &trunc);
return offset;
}
static const true_false_string tfs_disposition_delete_on_close = {
"DELETE this file when closed",
"Normal access, do not delete on close"
};
static int
dissect_smb2_file_disposition_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_disposition_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_disposition_info);
}
/* file disposition */
proto_tree_add_item(tree, hf_smb2_disposition_delete_on_close, tvb, offset, 1, ENC_LITTLE_ENDIAN);
return offset;
}
static int
dissect_smb2_file_full_ea_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint32 next_offset;
guint8 ea_name_len;
guint16 ea_data_len;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_full_ea_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_full_ea_info);
}
while (1) {
char *name = NULL;
char *data = NULL;
int start_offset = offset;
proto_item *ea_item;
proto_tree *ea_tree;
ea_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb2_ea, &ea_item, "EA:");
/* next offset */
next_offset = tvb_get_letohl(tvb, offset);
proto_tree_add_item(ea_tree, hf_smb2_next_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* EA flags */
proto_tree_add_item(ea_tree, hf_smb2_ea_flags, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* EA Name Length */
ea_name_len = tvb_get_guint8(tvb, offset);
proto_tree_add_item(ea_tree, hf_smb2_ea_name_len, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* EA Data Length */
ea_data_len = tvb_get_letohs(tvb, offset);
proto_tree_add_item(ea_tree, hf_smb2_ea_data_len, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* ea name */
if (ea_name_len) {
proto_tree_add_item_ret_display_string(ea_tree, hf_smb2_ea_name,
tvb, offset, ea_name_len, ENC_ASCII|ENC_NA,
pinfo->pool, &name);
}
/* The name is terminated with a NULL */
offset += ea_name_len + 1;
/* ea data */
if (ea_data_len) {
proto_tree_add_item_ret_display_string(ea_tree, hf_smb2_ea_data,
tvb, offset, ea_data_len, ENC_NA,
pinfo->pool, &data);
}
offset += ea_data_len;
if (ea_item) {
proto_item_append_text(ea_item, " %s := %s",
name ? name : "",
data ? data : "");
}
proto_item_set_len(ea_item, offset-start_offset);
if (!next_offset) {
break;
}
offset = start_offset+next_offset;
}
return offset;
}
static const true_false_string tfs_replace_if_exists = {
"Replace the target if it exists",
"Fail if the target exists"
};
static int
dissect_smb2_file_rename_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
int length;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_rename_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_rename_info);
}
/* ReplaceIfExists */
proto_tree_add_item(tree, hf_smb2_replace_if, tvb, offset, 1, ENC_NA);
offset += 1;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved_random, tvb, offset, 7, ENC_NA);
offset += 7;
/* Root Directory Handle, MBZ */
proto_tree_add_item(tree, hf_smb2_root_directory_mbz, tvb, offset, 8, ENC_NA);
offset += 8;
/* file name length */
length = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* file name */
if (length) {
char *display_string;
proto_tree_add_item_ret_display_string(tree, hf_smb2_filename,
tvb, offset, length, ENC_UTF_16|ENC_LITTLE_ENDIAN,
pinfo->pool, &display_string);
col_append_fstr(pinfo->cinfo, COL_INFO, " NewName:%s",
display_string);
offset += length;
}
return offset;
}
static int
dissect_smb2_sec_info_00(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_sec_info_00, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_sec_info_00);
}
/* security descriptor */
offset = dissect_nt_sec_desc(tvb, offset, pinfo, tree, NULL, TRUE, tvb_captured_length_remaining(tvb, offset), NULL);
return offset;
}
static int
dissect_smb2_quota_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bcp;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_quota_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_quota_info);
}
bcp = tvb_captured_length_remaining(tvb, offset);
offset = dissect_nt_user_quota(tvb, tree, offset, &bcp);
return offset;
}
static int
dissect_smb2_fs_info_05(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_fs_info_05, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_fs_info_05);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qfsi_FS_ATTRIBUTE_INFO(tvb, pinfo, tree, offset, &bc);
return offset;
}
static int
dissect_smb2_fs_info_06(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_fs_info_06, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_fs_info_06);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_nt_quota(tvb, tree, offset, &bc);
return offset;
}
static int
dissect_smb2_FS_OBJECTID_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_fs_objectid_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_fs_objectid_info);
}
/* FILE_OBJECTID_BUFFER */
offset = dissect_smb2_FILE_OBJECTID_BUFFER(tvb, pinfo, tree, offset);
return offset;
}
static int
dissect_smb2_fs_info_07(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_fs_info_07, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_fs_info_07);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qfsi_FS_FULL_SIZE_INFO(tvb, pinfo, tree, offset, &bc);
return offset;
}
static int
dissect_smb2_fs_info_01(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_fs_info_01, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_fs_info_01);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qfsi_FS_VOLUME_INFO(tvb, pinfo, tree, offset, &bc, TRUE);
return offset;
}
static int
dissect_smb2_fs_info_03(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_fs_info_03, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_fs_info_03);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qfsi_FS_SIZE_INFO(tvb, pinfo, tree, offset, &bc);
return offset;
}
static int
dissect_smb2_fs_info_04(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint16 bc;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_fs_info_04, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_fs_info_04);
}
bc = tvb_captured_length_remaining(tvb, offset);
offset = dissect_qfsi_FS_DEVICE_INFO(tvb, pinfo, tree, offset, &bc);
return offset;
}
static const value_string oplock_vals[] = {
{ 0x00, "No oplock" },
{ 0x01, "Level2 oplock" },
{ 0x08, "Exclusive oplock" },
{ 0x09, "Batch oplock" },
{ 0xff, "Lease" },
{ 0, NULL }
};
static int
dissect_smb2_oplock(proto_tree *parent_tree, tvbuff_t *tvb, int offset)
{
proto_tree_add_item(parent_tree, hf_smb2_oplock, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
return offset;
}
static int
dissect_smb2_buffercode(proto_tree *parent_tree, tvbuff_t *tvb, int offset, guint16 *length)
{
proto_tree *tree;
proto_item *item;
guint16 buffer_code;
/* dissect the first 2 bytes of the command PDU */
buffer_code = tvb_get_letohs(tvb, offset);
item = proto_tree_add_uint(parent_tree, hf_smb2_buffer_code, tvb, offset, 2, buffer_code);
tree = proto_item_add_subtree(item, ett_smb2_buffercode);
proto_tree_add_item(tree, hf_smb2_buffer_code_len, tvb, offset, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_smb2_buffer_code_flags_dyn, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
if (length) {
*length = buffer_code; /*&0xfffe don't mask it here, mask it on caller side */
}
return offset;
}
#define NEGPROT_CAP_DFS 0x00000001
#define NEGPROT_CAP_LEASING 0x00000002
#define NEGPROT_CAP_LARGE_MTU 0x00000004
#define NEGPROT_CAP_MULTI_CHANNEL 0x00000008
#define NEGPROT_CAP_PERSISTENT_HANDLES 0x00000010
#define NEGPROT_CAP_DIRECTORY_LEASING 0x00000020
#define NEGPROT_CAP_ENCRYPTION 0x00000040
static int
dissect_smb2_capabilities(proto_tree *parent_tree, tvbuff_t *tvb, int offset)
{
static int * const flags[] = {
&hf_smb2_cap_dfs,
&hf_smb2_cap_leasing,
&hf_smb2_cap_large_mtu,
&hf_smb2_cap_multi_channel,
&hf_smb2_cap_persistent_handles,
&hf_smb2_cap_directory_leasing,
&hf_smb2_cap_encryption,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb2_capabilities, ett_smb2_capabilities, flags, ENC_LITTLE_ENDIAN);
offset += 4;
return offset;
}
#define NEGPROT_SIGN_REQ 0x02
#define NEGPROT_SIGN_ENABLED 0x01
static int
dissect_smb2_secmode(proto_tree *parent_tree, tvbuff_t *tvb, int offset)
{
static int * const flags[] = {
&hf_smb2_secmode_flags_sign_enabled,
&hf_smb2_secmode_flags_sign_required,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb2_security_mode, ett_smb2_sec_mode, flags, ENC_LITTLE_ENDIAN);
offset += 1;
return offset;
}
#define SES_REQ_FLAGS_SESSION_BINDING 0x01
static int
dissect_smb2_ses_req_flags(proto_tree *parent_tree, tvbuff_t *tvb, int offset)
{
static int * const flags[] = {
&hf_smb2_ses_req_flags_session_binding,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb2_ses_req_flags, ett_smb2_ses_req_flags, flags, ENC_LITTLE_ENDIAN);
offset += 1;
return offset;
}
#define SES_FLAGS_GUEST 0x0001
#define SES_FLAGS_NULL 0x0002
#define SES_FLAGS_ENCRYPT 0x0004
static int
dissect_smb2_ses_flags(proto_tree *parent_tree, tvbuff_t *tvb, int offset)
{
static int * const flags[] = {
&hf_smb2_ses_flags_guest,
&hf_smb2_ses_flags_null,
&hf_smb2_ses_flags_encrypt,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb2_session_flags, ett_smb2_ses_flags, flags, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
#define SHARE_FLAGS_manual_caching 0x00000000
#define SHARE_FLAGS_auto_caching 0x00000010
#define SHARE_FLAGS_vdo_caching 0x00000020
#define SHARE_FLAGS_no_caching 0x00000030
static const value_string share_cache_vals[] = {
{ SHARE_FLAGS_manual_caching, "Manual caching" },
{ SHARE_FLAGS_auto_caching, "Auto caching" },
{ SHARE_FLAGS_vdo_caching, "VDO caching" },
{ SHARE_FLAGS_no_caching, "No caching" },
{ 0, NULL }
};
#define SHARE_FLAGS_dfs 0x00000001
#define SHARE_FLAGS_dfs_root 0x00000002
#define SHARE_FLAGS_restrict_exclusive_opens 0x00000100
#define SHARE_FLAGS_force_shared_delete 0x00000200
#define SHARE_FLAGS_allow_namespace_caching 0x00000400
#define SHARE_FLAGS_access_based_dir_enum 0x00000800
#define SHARE_FLAGS_force_levelii_oplock 0x00001000
#define SHARE_FLAGS_enable_hash_v1 0x00002000
#define SHARE_FLAGS_enable_hash_v2 0x00004000
#define SHARE_FLAGS_encryption_required 0x00008000
#define SHARE_FLAGS_identity_remoting 0x00040000
#define SHARE_FLAGS_compress_data 0x00100000
#define SHARE_FLAGS_isolated_transport 0x00200000
static int
dissect_smb2_share_flags(proto_tree *tree, tvbuff_t *tvb, int offset)
{
static int * const sf_fields[] = {
&hf_smb2_share_flags_dfs,
&hf_smb2_share_flags_dfs_root,
&hf_smb2_share_flags_restrict_exclusive_opens,
&hf_smb2_share_flags_force_shared_delete,
&hf_smb2_share_flags_allow_namespace_caching,
&hf_smb2_share_flags_access_based_dir_enum,
&hf_smb2_share_flags_force_levelii_oplock,
&hf_smb2_share_flags_enable_hash_v1,
&hf_smb2_share_flags_enable_hash_v2,
&hf_smb2_share_flags_encrypt_data,
&hf_smb2_share_flags_identity_remoting,
&hf_smb2_share_flags_compress_data,
&hf_smb2_share_flags_isolated_transport,
NULL
};
proto_item *item;
guint32 cp;
item = proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_share_flags, ett_smb2_share_flags, sf_fields, ENC_LITTLE_ENDIAN);
cp = tvb_get_letohl(tvb, offset);
cp &= 0x00000030;
proto_tree_add_uint_format(item, hf_smb2_share_caching, tvb, offset, 4, cp, "Caching policy: %s (%08x)", val_to_str(cp, share_cache_vals, "Unknown:%u"), cp);
offset += 4;
return offset;
}
#define SHARE_CAPS_DFS 0x00000008
#define SHARE_CAPS_CONTINUOUS_AVAILABILITY 0x00000010
#define SHARE_CAPS_SCALEOUT 0x00000020
#define SHARE_CAPS_CLUSTER 0x00000040
#define SHARE_CAPS_ASSYMETRIC 0x00000080
#define SHARE_CAPS_REDIRECT_TO_OWNER 0x00000100
static int
dissect_smb2_share_caps(proto_tree *tree, tvbuff_t *tvb, int offset)
{
static int * const sc_fields[] = {
&hf_smb2_share_caps_dfs,
&hf_smb2_share_caps_continuous_availability,
&hf_smb2_share_caps_scaleout,
&hf_smb2_share_caps_cluster,
&hf_smb2_share_caps_assymetric,
&hf_smb2_share_caps_redirect_to_owner,
NULL
};
proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_share_caps, ett_smb2_share_caps, sc_fields, ENC_LITTLE_ENDIAN);
offset += 4;
return offset;
}
static void
dissect_smb2_secblob(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si _U_)
{
if ((tvb_captured_length(tvb)>=7)
&& (!tvb_memeql(tvb, 0, (const guint8*)"NTLMSSP", 7))) {
call_dissector(ntlmssp_handle, tvb, pinfo, tree);
} else {
call_dissector(gssapi_handle, tvb, pinfo, tree);
}
}
/*
* Derive client and server decryption keys from the secret session key
* and set them in the session object.
*/
static void smb2_generate_decryption_keys(smb2_conv_info_t *conv, smb2_sesid_info_t *ses)
{
gboolean has_seskey = memcmp(ses->session_key, zeros, NTLMSSP_KEY_LEN) != 0;
gboolean has_signkey = memcmp(ses->signing_key, zeros, NTLMSSP_KEY_LEN) != 0;
gboolean has_client_key = memcmp(ses->client_decryption_key16, zeros, AES_KEY_SIZE) != 0;
gboolean has_server_key = memcmp(ses->server_decryption_key16, zeros, AES_KEY_SIZE) != 0;
/* if all decryption keys are provided, nothing to do */
if (has_client_key && has_server_key && has_signkey)
return;
/* otherwise, generate them from session key, if it's there */
if (!has_seskey)
return;
/* generate decryption keys */
if (conv->dialect <= SMB2_DIALECT_210) {
if (!has_signkey)
memcpy(ses->signing_key, ses->session_key,
NTLMSSP_KEY_LEN);
} else if (conv->dialect < SMB2_DIALECT_311) {
if (!has_server_key)
smb2_key_derivation(ses->session_key,
NTLMSSP_KEY_LEN,
"SMB2AESCCM", 11,
"ServerIn ", 10,
ses->server_decryption_key16, 16);
if (!has_client_key)
smb2_key_derivation(ses->session_key,
NTLMSSP_KEY_LEN,
"SMB2AESCCM", 11,
"ServerOut", 10,
ses->client_decryption_key16, 16);
if (!has_signkey)
smb2_key_derivation(ses->session_key,
NTLMSSP_KEY_LEN,
"SMB2AESCMAC", 12,
"SmbSign", 8,
ses->signing_key, 16);
} else if (conv->dialect >= SMB2_DIALECT_311) {
if (!has_server_key) {
smb2_key_derivation(ses->session_key,
NTLMSSP_KEY_LEN,
"SMBC2SCipherKey", 16,
ses->preauth_hash, SMB2_PREAUTH_HASH_SIZE,
ses->server_decryption_key16, 16);
smb2_key_derivation(ses->session_key,
NTLMSSP_KEY_LEN,
"SMBC2SCipherKey", 16,
ses->preauth_hash, SMB2_PREAUTH_HASH_SIZE,
ses->server_decryption_key32, 32);
}
if (!has_client_key) {
smb2_key_derivation(ses->session_key,
NTLMSSP_KEY_LEN,
"SMBS2CCipherKey", 16,
ses->preauth_hash, SMB2_PREAUTH_HASH_SIZE,
ses->client_decryption_key16, 16);
smb2_key_derivation(ses->session_key,
NTLMSSP_KEY_LEN,
"SMBS2CCipherKey", 16,
ses->preauth_hash, SMB2_PREAUTH_HASH_SIZE,
ses->client_decryption_key32, 32);
}
if (!has_signkey)
smb2_key_derivation(ses->session_key,
NTLMSSP_KEY_LEN,
"SMBSigningKey", 14,
ses->preauth_hash, SMB2_PREAUTH_HASH_SIZE,
ses->signing_key, 16);
}
DEBUG("Generated Sign key");
HEXDUMP(ses->signing_key, NTLMSSP_KEY_LEN);
DEBUG("Generated S2C key16");
HEXDUMP(ses->client_decryption_key16, AES_KEY_SIZE);
DEBUG("Generated S2C key32");
HEXDUMP(ses->client_decryption_key32, AES_KEY_SIZE*2);
DEBUG("Generated C2S key16");
HEXDUMP(ses->server_decryption_key16, AES_KEY_SIZE);
DEBUG("Generated C2S key32");
HEXDUMP(ses->server_decryption_key32, AES_KEY_SIZE*2);
}
static int
dissect_smb2_session_setup_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
offset_length_buffer_t s_olb;
const ntlmssp_header_t *ntlmssph;
static int ntlmssp_tap_id = 0;
smb2_saved_info_t *ssi = si->saved;
proto_item *hash_item;
int idx;
if (!ntlmssp_tap_id) {
GString *error_string;
/* We don't specify any callbacks at all.
* Instead we manually fetch the tapped data after the
* security blob has been fully dissected and before
* we exit from this dissector.
*/
error_string = register_tap_listener("ntlmssp", NULL, NULL,
TL_IS_DISSECTOR_HELPER, NULL, NULL, NULL, NULL);
if (!error_string) {
ntlmssp_tap_id = find_tap_id("ntlmssp");
} else {
g_string_free(error_string, TRUE);
}
}
if (!pinfo->fd->visited && ssi) {
/* compute preauth hash on first pass */
/* start from last preauth hash of the connection if 1st request */
if (si->sesid == 0)
memcpy(si->conv->preauth_hash_ses, si->conv->preauth_hash_con, SMB2_PREAUTH_HASH_SIZE);
ssi->preauth_hash_req = (guint8*)wmem_alloc0(wmem_file_scope(), SMB2_PREAUTH_HASH_SIZE);
update_preauth_hash(si->conv->preauth_hash_current, pinfo, tvb);
memcpy(ssi->preauth_hash_req, si->conv->preauth_hash_current, SMB2_PREAUTH_HASH_SIZE);
}
if (ssi && ssi->preauth_hash_req) {
hash_item = proto_tree_add_bytes_with_length(tree, hf_smb2_preauth_hash, tvb,
0, tvb_captured_length(tvb),
ssi->preauth_hash_req, SMB2_PREAUTH_HASH_SIZE);
proto_item_set_generated(hash_item);
}
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* some unknown bytes */
/* flags */
offset = dissect_smb2_ses_req_flags(tree, tvb, offset);
/* security mode */
offset = dissect_smb2_secmode(tree, tvb, offset);
/* capabilities */
offset = dissect_smb2_capabilities(tree, tvb, offset);
/* channel */
proto_tree_add_item(tree, hf_smb2_channel, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* security blob offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &s_olb, OLB_O_UINT16_S_UINT16, hf_smb2_security_blob);
/* previous session id */
proto_tree_add_item(tree, hf_smb2_previous_sesid, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* the security blob itself */
dissect_smb2_olb_buffer(pinfo, tree, tvb, &s_olb, si, dissect_smb2_secblob);
offset = dissect_smb2_olb_tvb_max_offset(offset, &s_olb);
/* If we have found a uid->acct_name mapping, store it */
if (!pinfo->fd->visited) {
idx = 0;
while ((ntlmssph = (const ntlmssp_header_t *)fetch_tapped_data(ntlmssp_tap_id, idx++)) != NULL) {
if (ntlmssph && ntlmssph->type == NTLMSSP_AUTH) {
si->session = smb2_get_session(si->conv, si->sesid, pinfo, si);
si->session->acct_name = wmem_strdup(wmem_file_scope(), ntlmssph->acct_name);
si->session->domain_name = wmem_strdup(wmem_file_scope(), ntlmssph->domain_name);
si->session->host_name = wmem_strdup(wmem_file_scope(), ntlmssph->host_name);
/* don't overwrite session key from preferences */
if (memcmp(si->session->session_key, zeros, SMB_SESSION_ID_SIZE) == 0) {
memcpy(si->session->session_key, ntlmssph->session_key, NTLMSSP_KEY_LEN);
}
si->session->auth_frame = pinfo->num;
}
}
}
return offset;
}
static void
dissect_smb2_share_redirect_error(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_tree *tree;
proto_item *item;
proto_tree *ips_tree;
proto_item *ips_item;
offset_length_buffer_t res_olb;
guint32 i, ip_count;
item = proto_tree_add_item(parent_tree, hf_smb2_error_redir_context, tvb, offset, 0, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_error_redir_context);
/* structure size */
proto_tree_add_item(tree, hf_smb2_error_redir_struct_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* notification type */
proto_tree_add_item(tree, hf_smb2_error_redir_notif_type, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* resource name offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &res_olb, OLB_O_UINT32_S_UINT32, hf_smb2_error_redir_res_name);
/* flags */
proto_tree_add_item(tree, hf_smb2_error_redir_flags, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* target type */
proto_tree_add_item(tree, hf_smb2_error_redir_target_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* ip addr count */
proto_tree_add_item_ret_uint(tree, hf_smb2_error_redir_ip_count, tvb, offset, 4, ENC_LITTLE_ENDIAN, &ip_count);
offset += 4;
/* ip addr list */
ips_item = proto_tree_add_item(tree, hf_smb2_error_redir_ip_list, tvb, offset, 0, ENC_NA);
ips_tree = proto_item_add_subtree(ips_item, ett_smb2_error_redir_ip_list);
for (i = 0; i < ip_count; i++)
offset += dissect_windows_sockaddr_storage(tvb, pinfo, ips_tree, offset, -1);
/* resource name */
dissect_smb2_olb_off_string(pinfo, tree, tvb, &res_olb, offset, OLB_TYPE_UNICODE_STRING);
}
static void
dissect_smb2_STATUS_STOPPED_ON_SYMLINK(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_tree *tree;
proto_item *item;
offset_length_buffer_t s_olb, p_olb;
item = proto_tree_add_item(parent_tree, hf_smb2_symlink_error_response, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_symlink_error_response);
/* symlink length */
proto_tree_add_item(tree, hf_smb2_symlink_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* symlink error tag */
proto_tree_add_item(tree, hf_smb2_symlink_error_tag, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* reparse tag */
proto_tree_add_item(tree, hf_smb2_reparse_tag, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_smb2_reparse_data_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_smb2_unparsed_path_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* substitute name offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &s_olb, OLB_O_UINT16_S_UINT16, hf_smb2_symlink_substitute_name);
/* print name offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &p_olb, OLB_O_UINT16_S_UINT16, hf_smb2_symlink_print_name);
/* flags */
proto_tree_add_item(tree, hf_smb2_symlink_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* substitute name string */
dissect_smb2_olb_off_string(pinfo, tree, tvb, &s_olb, offset, OLB_TYPE_UNICODE_STRING);
/* print name string */
dissect_smb2_olb_off_string(pinfo, tree, tvb, &p_olb, offset, OLB_TYPE_UNICODE_STRING);
}
static int
dissect_smb2_error_context(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
proto_tree *tree;
proto_item *item;
tvbuff_t *sub_tvb;
guint32 length;
guint32 id;
item = proto_tree_add_item(parent_tree, hf_smb2_error_context, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_error_context);
proto_tree_add_item_ret_uint(tree, hf_smb2_error_context_length, tvb, offset, 4, ENC_LITTLE_ENDIAN, &length);
offset += 4;
proto_tree_add_item_ret_uint(tree, hf_smb2_error_context_id, tvb, offset, 4, ENC_LITTLE_ENDIAN, &id);
offset += 4;
sub_tvb = tvb_new_subset_length(tvb, offset, length);
dissect_smb2_error_data(sub_tvb, pinfo, tree, 0, id, si);
offset += length;
return offset;
}
/*
* Assumes it is being called with a sub-tvb (dissects at offsets 0)
*/
static void
dissect_smb2_error_data(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree,
int error_context_count, int error_id,
smb2_info_t *si _U_)
{
proto_tree *tree;
proto_item *item;
int offset = 0;
int i;
item = proto_tree_add_item(parent_tree, hf_smb2_error_data, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_error_data);
if (error_context_count == 0) {
if (tvb_captured_length_remaining(tvb, offset) <= 1)
return;
switch (si->status) {
case NT_STATUS_STOPPED_ON_SYMLINK:
dissect_smb2_STATUS_STOPPED_ON_SYMLINK(tvb, pinfo, tree, offset, si);
break;
case NT_STATUS_BUFFER_TOO_SMALL:
proto_tree_add_item(tree, hf_smb2_error_min_buf_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
break;
case NT_STATUS_BAD_NETWORK_NAME:
if (error_id == SMB2_ERROR_ID_SHARE_REDIRECT)
dissect_smb2_share_redirect_error(tvb, pinfo, tree, offset, si);
default:
break;
}
} else {
for (i = 0; i < error_context_count; i++)
offset += dissect_smb2_error_context(tvb, pinfo, tree, offset, si);
}
}
/*
* SMB2 Error responses are a bit convoluted. Error data can be a list
* of error contexts which themselves can hold an error data field.
* See [MS-SMB2] 2.2.2.1.
*
* ERROR_RESP := ERROR_DATA
*
* ERROR_DATA := ( ERROR_CONTEXT + )
* | ERROR_STATUS_STOPPED_ON_SYMLINK
* | ERROR_ID_SHARE_REDIRECT
* | ERROR_BUFFER_TOO_SMALL
*
* ERROR_CONTEXT := ... + ERROR_DATA
* | ERROR_ID_SHARE_REDIRECT
*
* This needs more fixes for cases when the original header had also the constant value of 9.
* This should be fixed on caller side where it decides if it has to call this or not.
*
*/
static int
dissect_smb2_error_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si,
gboolean* continue_dissection)
{
gint byte_count;
guint8 error_context_count;
guint16 length;
tvbuff_t *sub_tvb;
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, &length);
/* FIX: error response uses this constant, if not then it is not an error response */
if(length != 9)
{
if(continue_dissection)
*continue_dissection = TRUE;
} else {
if(continue_dissection)
*continue_dissection = FALSE;
/* ErrorContextCount (1 bytes) */
error_context_count = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_smb2_error_context_count, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* Reserved (1 bytes) */
proto_tree_add_item(tree, hf_smb2_error_reserved, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* ByteCount (4 bytes): The number of bytes of data contained in ErrorData[]. */
byte_count = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_error_byte_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* If the ByteCount field is zero then the server MUST supply an ErrorData field
that is one byte in length */
if (byte_count == 0) byte_count = 1;
/* ErrorData (variable): A variable-length data field that contains extended
error information.*/
sub_tvb = tvb_new_subset_length(tvb, offset, byte_count);
offset += byte_count;
dissect_smb2_error_data(sub_tvb, pinfo, tree, error_context_count, 0, si);
}
return offset;
}
static int
dissect_smb2_session_setup_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
offset_length_buffer_t s_olb;
proto_item *hash_item;
smb2_saved_info_t *ssi = si->saved;
si->session = smb2_get_session(si->conv, si->sesid, pinfo, si);
if (si->status == 0) {
si->session->auth_frame = pinfo->num;
}
/* compute preauth hash on first pass */
if (!pinfo->fd->visited && ssi) {
ssi->preauth_hash_res = (guint8*)wmem_alloc0(wmem_file_scope(), SMB2_PREAUTH_HASH_SIZE);
/*
* Preauth hash can only be used if the session is
* established i.e. last session setup response has a
* success status. As per the specification, the last
* response is NOT hashed.
*/
if (si->status != 0) {
/*
* Not sucessful means either more req/rsp
* processing is required or we reached an
* error, so update hash.
*/
update_preauth_hash(si->conv->preauth_hash_current, pinfo, tvb);
} else {
/*
* Session is established, we can generate the keys
*/
memcpy(si->session->preauth_hash, si->conv->preauth_hash_current, SMB2_PREAUTH_HASH_SIZE);
smb2_generate_decryption_keys(si->conv, si->session);
}
/* In all cases, stash the preauth hash */
memcpy(ssi->preauth_hash_res, si->conv->preauth_hash_current, SMB2_PREAUTH_HASH_SIZE);
}
if (ssi && ssi->preauth_hash_res) {
hash_item = proto_tree_add_bytes_with_length(tree, hf_smb2_preauth_hash, tvb,
0, tvb_captured_length(tvb),
ssi->preauth_hash_res, SMB2_PREAUTH_HASH_SIZE);
proto_item_set_generated(hash_item);
}
/* session_setup is special and we don't use dissect_smb2_error_response() here! */
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* session flags */
offset = dissect_smb2_ses_flags(tree, tvb, offset);
/* security blob offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &s_olb, OLB_O_UINT16_S_UINT16, hf_smb2_security_blob);
/* the security blob itself */
dissect_smb2_olb_buffer(pinfo, tree, tvb, &s_olb, si, dissect_smb2_secblob);
offset = dissect_smb2_olb_tvb_max_offset(offset, &s_olb);
/* If we have found a uid->acct_name mapping, store it */
#ifdef HAVE_KERBEROS
if (!pinfo->fd->visited && si->status == 0) {
enc_key_t *ek;
if (krb_decrypt) {
read_keytab_file_from_preferences();
}
for (ek=enc_key_list;ek;ek=ek->next) {
if (ek->fd_num == (int)pinfo->num) {
break;
}
}
if (ek != NULL) {
/* TODO: fill in the correct user/dom/host information */
}
}
#endif
return offset;
}
static int
dissect_smb2_tree_connect_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si _U_)
{
offset_length_buffer_t olb;
const guint8 *buf;
guint16 flags;
proto_item *item;
static int * const connect_flags[] = {
&hf_smb2_tc_cluster_reconnect,
&hf_smb2_tc_redirect_to_owner,
&hf_smb2_tc_extension_present,
&hf_smb2_tc_reserved,
NULL
};
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* flags */
item = proto_tree_get_parent(tree);
flags = tvb_get_letohs(tvb, offset);
proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_tree_connect_flags, ett_smb2_tree_connect_flags, connect_flags, ENC_LITTLE_ENDIAN);
if (flags != 0) {
proto_item_append_text(item, "%s%s%s",
(flags & 0x0001)?", CLUSTER_RECONNECT":"",
(flags & 0x0002)?", REDIRECT_TO_OWNER":"",
(flags & 0x0004)?", EXTENSION_PRESENT":"");
}
offset += 2;
/* tree offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &olb, OLB_O_UINT16_S_UINT16, hf_smb2_tree);
/* tree string */
buf = dissect_smb2_olb_string(pinfo, tree, tvb, &olb, OLB_TYPE_UNICODE_STRING);
offset = dissect_smb2_olb_tvb_max_offset(offset, &olb);
if (!pinfo->fd->visited && si->saved && buf && olb.len) {
si->saved->extra_info_type = SMB2_EI_TREENAME;
si->saved->extra_info = wmem_strdup(wmem_file_scope(), buf);
}
if (buf) {
col_append_fstr(pinfo->cinfo, COL_INFO, " Tree: %s",
format_text(pinfo->pool, buf, strlen(buf)));
}
return offset;
}
static int
dissect_smb2_tree_connect_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si _U_)
{
guint8 share_type;
gboolean continue_dissection;
switch (si->status) {
/* buffer code */
case 0x00000000: offset = dissect_smb2_buffercode(tree, tvb, offset, NULL); break;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
/* share type */
share_type = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_smb2_share_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* byte is reserved and must be set to zero */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
if (!pinfo->fd->visited && si->saved && si->saved->extra_info_type == SMB2_EI_TREENAME && si->session) {
smb2_tid_info_t *tid, tid_key;
tid_key.tid = si->tid;
tid = (smb2_tid_info_t *)wmem_map_lookup(si->session->tids, &tid_key);
if (tid) {
wmem_map_remove(si->session->tids, &tid_key);
}
tid = wmem_new(wmem_file_scope(), smb2_tid_info_t);
tid->tid = si->tid;
tid->name = (char *)si->saved->extra_info;
tid->connect_frame = pinfo->num;
tid->share_type = share_type;
wmem_map_insert(si->session->tids, tid, tid);
si->saved->extra_info_type = SMB2_EI_NONE;
si->saved->extra_info = NULL;
}
/* share flags */
offset = dissect_smb2_share_flags(tree, tvb, offset);
/* share capabilities */
offset = dissect_smb2_share_caps(tree, tvb, offset);
/* this is some sort of access mask */
offset = dissect_smb_access_mask(tvb, tree, offset);
return offset;
}
static int
dissect_smb2_tree_disconnect_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
{
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
return offset;
}
static int
dissect_smb2_tree_disconnect_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
{
gboolean continue_dissection;
switch (si->status) {
/* buffer code */
case 0x00000000: offset = dissect_smb2_buffercode(tree, tvb, offset, NULL); break;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
return offset;
}
static int
dissect_smb2_sessionlogoff_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
{
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* reserved bytes */
offset += 2;
return offset;
}
static int
dissect_smb2_sessionlogoff_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
{
gboolean continue_dissection;
switch (si->status) {
/* buffer code */
case 0x00000000: offset = dissect_smb2_buffercode(tree, tvb, offset, NULL); break;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
/* reserved bytes */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
return offset;
}
static int
dissect_smb2_keepalive_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
{
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* some unknown bytes */
proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, ENC_NA);
offset += 2;
return offset;
}
static int
dissect_smb2_keepalive_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
{
gboolean continue_dissection;
switch (si->status) {
/* buffer code */
case 0x00000000: offset = dissect_smb2_buffercode(tree, tvb, offset, NULL); break;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
/* some unknown bytes */
proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, ENC_NA);
offset += 2;
return offset;
}
static int
dissect_smb2_notify_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
proto_tree *flags_tree = NULL;
proto_item *flags_item = NULL;
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* notify flags */
if (tree) {
flags_item = proto_tree_add_item(tree, hf_smb2_notify_flags, tvb, offset, 2, ENC_LITTLE_ENDIAN);
flags_tree = proto_item_add_subtree(flags_item, ett_smb2_notify_flags);
}
proto_tree_add_item(flags_tree, hf_smb2_notify_watch_tree, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* output buffer length */
proto_tree_add_item(tree, hf_smb2_output_buffer_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* fid */
offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
/* completion filter */
offset = dissect_nt_notify_completion_filter(tvb, tree, offset);
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
return offset;
}
static const value_string notify_action_vals[] = {
{0x01, "FILE_ACTION_ADDED"},
{0x02, "FILE_ACTION_REMOVED"},
{0x03, "FILE_ACTION_MODIFIED"},
{0x04, "FILE_ACTION_RENAMED_OLD_NAME"},
{0x05, "FILE_ACTION_RENAMED_NEW_NAME"},
{0x06, "FILE_ACTION_ADDED_STREAM"},
{0x07, "FILE_ACTION_REMOVED_STREAM"},
{0x08, "FILE_ACTION_MODIFIED_STREAM"},
{0x09, "FILE_ACTION_REMOVED_BY_DELETE"},
{0, NULL}
};
static void
dissect_smb2_notify_data_out(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, smb2_info_t *si _U_)
{
proto_tree *tree = NULL;
proto_item *item = NULL;
int offset = 0;
while (tvb_reported_length_remaining(tvb, offset) > 4) {
guint32 start_offset = offset;
guint32 next_offset;
guint32 length;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_notify_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_notify_info);
}
/* next offset */
proto_tree_add_item_ret_uint(tree, hf_smb2_notify_next_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN, &next_offset);
offset += 4;
proto_tree_add_item(tree, hf_smb2_notify_action, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* file name length */
proto_tree_add_item_ret_uint(tree, hf_smb2_filename_len, tvb, offset, 4, ENC_LITTLE_ENDIAN, &length);
offset += 4;
/* file name */
if (length) {
proto_tree_add_item(tree, hf_smb2_filename,
tvb, offset, length, ENC_UTF_16|ENC_LITTLE_ENDIAN);
}
if (!next_offset) {
break;
}
offset = start_offset+next_offset;
}
}
static int
dissect_smb2_notify_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si)
{
offset_length_buffer_t olb;
gboolean continue_dissection;
switch (si->status) {
/* MS-SMB2 3.3.4.4 says STATUS_NOTIFY_ENUM_DIR is not treated as an error */
case 0x0000010c: /* STATUS_NOTIFY_ENUM_DIR */
case 0x00000000: /* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL); break;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
/* out buffer offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &olb, OLB_O_UINT16_S_UINT32, hf_smb2_notify_out_data);
/* out buffer */
dissect_smb2_olb_buffer(pinfo, tree, tvb, &olb, si, dissect_smb2_notify_data_out);
offset = dissect_smb2_olb_tvb_max_offset(offset, &olb);
return offset;
}
#define SMB2_FIND_FLAG_RESTART_SCANS 0x01
#define SMB2_FIND_FLAG_SINGLE_ENTRY 0x02
#define SMB2_FIND_FLAG_INDEX_SPECIFIED 0x04
#define SMB2_FIND_FLAG_REOPEN 0x10
static int
dissect_smb2_find_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
offset_length_buffer_t olb;
const guint8 *buf;
guint8 il;
static int * const f_fields[] = {
&hf_smb2_find_flags_restart_scans,
&hf_smb2_find_flags_single_entry,
&hf_smb2_find_flags_index_specified,
&hf_smb2_find_flags_reopen,
NULL
};
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
il = tvb_get_guint8(tvb, offset);
if (si->saved) {
si->saved->infolevel = il;
}
/* infolevel */
proto_tree_add_uint(tree, hf_smb2_find_info_level, tvb, offset, 1, il);
offset += 1;
/* find flags */
proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_find_flags, ett_smb2_find_flags, f_fields, ENC_LITTLE_ENDIAN);
offset += 1;
/* file index */
proto_tree_add_item(tree, hf_smb2_file_index, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* fid */
offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
/* search pattern offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &olb, OLB_O_UINT16_S_UINT16, hf_smb2_find_pattern);
/* output buffer length */
proto_tree_add_item(tree, hf_smb2_output_buffer_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* search pattern */
buf = dissect_smb2_olb_string(pinfo, tree, tvb, &olb, OLB_TYPE_UNICODE_STRING);
offset = dissect_smb2_olb_tvb_max_offset(offset, &olb);
if (!pinfo->fd->visited && si->saved && olb.len) {
si->saved->extra_info_type = SMB2_EI_FINDPATTERN;
si->saved->extra_info = wmem_strdup(wmem_file_scope(), buf);
}
col_append_fstr(pinfo->cinfo, COL_INFO, " %s Pattern: %s",
val_to_str(il, smb2_find_info_levels, "(Level:0x%02x)"),
buf);
return offset;
}
static void dissect_smb2_file_directory_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item = NULL;
proto_tree *tree = NULL;
while (tvb_reported_length_remaining(tvb, offset) > 4) {
int old_offset = offset;
int next_offset;
int file_name_len;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_file_directory_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_file_directory_info);
}
/* next offset */
next_offset = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_next_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* file index */
proto_tree_add_item(tree, hf_smb2_file_index, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* create time */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
/* last access */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
/* last write */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
/* last change */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
/* end of file */
proto_tree_add_item(tree, hf_smb2_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* allocation size */
proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* File Attributes */
offset = dissect_fscc_file_attr(tvb, tree, offset, NULL);
/* file name length */
file_name_len = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* file name */
if (file_name_len) {
char *display_string;
proto_tree_add_item_ret_display_string(tree, hf_smb2_filename,
tvb, offset, file_name_len, ENC_UTF_16|ENC_LITTLE_ENDIAN,
pinfo->pool, &display_string);
proto_item_append_text(item, ": %s", display_string);
offset += file_name_len;
}
proto_item_set_len(item, offset-old_offset);
if (next_offset == 0) {
return;
}
offset = old_offset+next_offset;
if (offset < old_offset) {
proto_tree_add_expert_format(tree, pinfo, &ei_smb2_invalid_length, tvb, offset, -1,
"Invalid offset/length. Malformed packet");
return;
}
}
}
static void dissect_smb2_full_directory_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item = NULL;
proto_tree *tree = NULL;
while (tvb_reported_length_remaining(tvb, offset) > 4) {
int old_offset = offset;
int next_offset;
int file_name_len;
guint32 attr;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_full_directory_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_full_directory_info);
}
/* next offset */
next_offset = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_next_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* file index */
proto_tree_add_item(tree, hf_smb2_file_index, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* create time */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
/* last access */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
/* last write */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
/* last change */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
/* end of file */
proto_tree_add_item(tree, hf_smb2_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* allocation size */
proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* File Attributes */
offset = dissect_fscc_file_attr(tvb, tree, offset, &attr);
/* file name length */
file_name_len = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* ea size or reparse tag */
if (attr & SMB2_FSCC_FILE_ATTRIBUTE_REPARSE_POINT)
proto_tree_add_item(tree, hf_smb2_reparse_tag, tvb, offset, 4, ENC_LITTLE_ENDIAN);
else
proto_tree_add_item(tree, hf_smb2_ea_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* file name */
if (file_name_len) {
char *display_string;
proto_tree_add_item_ret_display_string(tree, hf_smb2_filename,
tvb, offset, file_name_len, ENC_UTF_16|ENC_LITTLE_ENDIAN,
pinfo->pool, &display_string);
proto_item_append_text(item, ": %s", display_string);
offset += file_name_len;
}
proto_item_set_len(item, offset-old_offset);
if (next_offset == 0) {
return;
}
offset = old_offset+next_offset;
if (offset < old_offset) {
proto_tree_add_expert_format(tree, pinfo, &ei_smb2_invalid_length, tvb, offset, -1,
"Invalid offset/length. Malformed packet");
return;
}
}
}
static void dissect_smb2_both_directory_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item = NULL;
proto_tree *tree = NULL;
while (tvb_reported_length_remaining(tvb, offset) > 4) {
int old_offset = offset;
int next_offset;
int file_name_len;
int short_name_len;
guint32 attr;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_both_directory_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_both_directory_info);
}
/* next offset */
next_offset = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_next_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* file index */
proto_tree_add_item(tree, hf_smb2_file_index, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* create time */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
/* last access */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
/* last write */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
/* last change */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
/* end of file */
proto_tree_add_item(tree, hf_smb2_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* allocation size */
proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* File Attributes */
offset = dissect_fscc_file_attr(tvb, tree, offset, &attr);
/* file name length */
file_name_len = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* ea size or reparse tag */
if (attr & SMB2_FSCC_FILE_ATTRIBUTE_REPARSE_POINT)
proto_tree_add_item(tree, hf_smb2_reparse_tag, tvb, offset, 4, ENC_LITTLE_ENDIAN);
else
proto_tree_add_item(tree, hf_smb2_ea_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* short name length */
short_name_len = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_smb2_short_name_len, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* short name */
if (short_name_len) {
proto_tree_add_item(tree, hf_smb2_short_name,
tvb, offset, short_name_len, ENC_UTF_16|ENC_LITTLE_ENDIAN);
}
offset += 24;
/* file name */
if (file_name_len) {
char *display_string;
proto_tree_add_item_ret_display_string(tree, hf_smb2_filename,
tvb, offset, file_name_len, ENC_UTF_16|ENC_LITTLE_ENDIAN,
pinfo->pool, &display_string);
proto_item_append_text(item, ": %s", display_string);
offset += file_name_len;
}
proto_item_set_len(item, offset-old_offset);
if (next_offset == 0) {
return;
}
offset = old_offset+next_offset;
if (offset < old_offset) {
proto_tree_add_expert_format(tree, pinfo, &ei_smb2_invalid_length, tvb, offset, -1,
"Invalid offset/length. Malformed packet");
return;
}
}
}
static void dissect_smb2_file_name_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item = NULL;
proto_tree *tree = NULL;
while (tvb_reported_length_remaining(tvb, offset) > 4) {
int old_offset = offset;
int next_offset;
int file_name_len;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_both_directory_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_both_directory_info);
}
/* next offset */
next_offset = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_next_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* file index */
proto_tree_add_item(tree, hf_smb2_file_index, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* file name length */
file_name_len = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* file name */
if (file_name_len) {
char *display_string;
proto_tree_add_item_ret_display_string(tree, hf_smb2_filename,
tvb, offset, file_name_len, ENC_UTF_16|ENC_LITTLE_ENDIAN,
pinfo->pool, &display_string);
proto_item_append_text(item, ": %s", display_string);
offset += file_name_len;
}
proto_item_set_len(item, offset-old_offset);
if (next_offset == 0) {
return;
}
offset = old_offset+next_offset;
if (offset < old_offset) {
proto_tree_add_expert_format(tree, pinfo, &ei_smb2_invalid_length, tvb, offset, -1,
"Invalid offset/length. Malformed packet");
return;
}
}
}
static void dissect_smb2_id_both_directory_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item = NULL;
proto_tree *tree = NULL;
while (tvb_reported_length_remaining(tvb, offset) > 4) {
int old_offset = offset;
int next_offset;
int file_name_len;
int short_name_len;
guint32 attr;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_id_both_directory_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_id_both_directory_info);
}
/* next offset */
next_offset = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_next_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* file index */
proto_tree_add_item(tree, hf_smb2_file_index, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* create time */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
/* last access */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
/* last write */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
/* last change */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
/* end of file */
proto_tree_add_item(tree, hf_smb2_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* allocation size */
proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* File Attributes */
offset = dissect_fscc_file_attr(tvb, tree, offset, &attr);
/* file name length */
file_name_len = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* ea size or reparse tag */
if (attr & SMB2_FSCC_FILE_ATTRIBUTE_REPARSE_POINT)
proto_tree_add_item(tree, hf_smb2_reparse_tag, tvb, offset, 4, ENC_LITTLE_ENDIAN);
else
proto_tree_add_item(tree, hf_smb2_ea_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* short name length */
short_name_len = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_smb2_short_name_len, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* short name */
if (short_name_len) {
proto_tree_add_item(tree, hf_smb2_short_name,
tvb, offset, short_name_len, ENC_UTF_16|ENC_LITTLE_ENDIAN);
}
offset += 24;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* file id */
proto_tree_add_item(tree, hf_smb2_file_id, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* file name */
if (file_name_len) {
char *display_string;
proto_tree_add_item_ret_display_string(tree, hf_smb2_filename,
tvb, offset, file_name_len, ENC_UTF_16|ENC_LITTLE_ENDIAN,
pinfo->pool, &display_string);
proto_item_append_text(item, ": %s", display_string);
offset += file_name_len;
}
proto_item_set_len(item, offset-old_offset);
if (next_offset == 0) {
return;
}
offset = old_offset+next_offset;
if (offset < old_offset) {
proto_tree_add_expert_format(tree, pinfo, &ei_smb2_invalid_length, tvb, offset, -1,
"Invalid offset/length. Malformed packet");
return;
}
}
}
static void dissect_smb2_id_full_directory_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item = NULL;
proto_tree *tree = NULL;
while (tvb_reported_length_remaining(tvb, offset) > 4) {
int old_offset = offset;
int next_offset;
int file_name_len;
guint32 attr;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_id_both_directory_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_id_both_directory_info);
}
/* next offset */
next_offset = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_next_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* file index */
proto_tree_add_item(tree, hf_smb2_file_index, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* create time */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
/* last access */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
/* last write */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
/* last change */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
/* end of file */
proto_tree_add_item(tree, hf_smb2_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* allocation size */
proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* File Attributes */
offset = dissect_fscc_file_attr(tvb, tree, offset, &attr);
/* file name length */
file_name_len = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_filename_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* ea size or reparse tag */
if (attr & SMB2_FSCC_FILE_ATTRIBUTE_REPARSE_POINT)
proto_tree_add_item(tree, hf_smb2_reparse_tag, tvb, offset, 4, ENC_LITTLE_ENDIAN);
else
proto_tree_add_item(tree, hf_smb2_ea_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
/* file id */
proto_tree_add_item(tree, hf_smb2_file_id, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* file name */
if (file_name_len) {
char *display_string;
proto_tree_add_item_ret_display_string(tree, hf_smb2_filename,
tvb, offset, file_name_len, ENC_UTF_16|ENC_LITTLE_ENDIAN,
pinfo->pool, &display_string);
proto_item_append_text(item, ": %s", display_string);
offset += file_name_len;
}
proto_item_set_len(item, offset-old_offset);
if (next_offset == 0) {
return;
}
offset = old_offset+next_offset;
if (offset < old_offset) {
proto_tree_add_expert_format(tree, pinfo, &ei_smb2_invalid_length, tvb, offset, -1,
"Invalid offset/length. Malformed packet");
return;
}
}
}
static int dissect_smb2_posix_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
{
/* create time */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
/* last access */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
/* last write */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
/* last change */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
/* allocation size */
proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* end of file */
proto_tree_add_item(tree, hf_smb2_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* File Attributes */
offset = dissect_fscc_file_attr(tvb, tree, offset, NULL);
/* file index */
proto_tree_add_item(tree, hf_smb2_inode, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* dev id */
proto_tree_add_item(tree, hf_smb2_file_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* zero */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
/* Hardlinks */
proto_tree_add_item(tree, hf_smb2_nlinks, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* Reparse tag */
proto_tree_add_item(tree, hf_smb2_reparse_tag, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* POSIX mode bits */
proto_tree_add_item(tree, hf_smb2_posix_perms, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* Owner and Group SID */
offset = dissect_nt_sid(tvb, offset, tree, "Owner SID", NULL, -1);
offset = dissect_nt_sid(tvb, offset, tree, "Group SID", NULL, -1);
return offset;
}
static void dissect_smb2_posix_directory_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item = NULL;
proto_tree *tree = NULL;
while (tvb_reported_length_remaining(tvb, offset) > 4) {
int old_offset = offset;
int next_offset;
int file_name_len;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_posix_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_posix_info);
}
/* next offset */
next_offset = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_next_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
offset += 4;
offset = dissect_smb2_posix_info(tvb, pinfo, tree, offset, si);
/* file name length */
proto_tree_add_item_ret_uint(tree, hf_smb2_filename_len, tvb, offset, 4, ENC_LITTLE_ENDIAN, &file_name_len);
offset += 4;
/* file name */
if (file_name_len) {
proto_tree_add_item(tree, hf_smb2_filename, tvb, offset, file_name_len, ENC_UTF_16|ENC_LITTLE_ENDIAN);
offset += file_name_len;
}
proto_item_set_len(item, offset-old_offset);
if (next_offset == 0) {
return;
}
offset = old_offset+next_offset;
if (offset < old_offset) {
proto_tree_add_expert_format(tree, pinfo, &ei_smb2_invalid_length, tvb, offset, -1,
"Invalid offset/length. Malformed packet");
return;
}
}
}
typedef struct _smb2_find_dissector_t {
guint32 level;
void (*dissector)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si);
} smb2_find_dissector_t;
static smb2_find_dissector_t smb2_find_dissectors[] = {
{SMB2_FIND_DIRECTORY_INFO, dissect_smb2_file_directory_info},
{SMB2_FIND_FULL_DIRECTORY_INFO, dissect_smb2_full_directory_info},
{SMB2_FIND_BOTH_DIRECTORY_INFO, dissect_smb2_both_directory_info},
{SMB2_FIND_NAME_INFO, dissect_smb2_file_name_info},
{SMB2_FIND_ID_BOTH_DIRECTORY_INFO,dissect_smb2_id_both_directory_info},
{SMB2_FIND_ID_FULL_DIRECTORY_INFO,dissect_smb2_id_full_directory_info},
{SMB2_FIND_POSIX_INFO, dissect_smb2_posix_directory_info},
{0, NULL}
};
static void
dissect_smb2_find_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
{
smb2_find_dissector_t *dis = smb2_find_dissectors;
while (dis->dissector) {
if (si && si->saved) {
if (dis->level == si->saved->infolevel) {
dis->dissector(tvb, pinfo, tree, si);
return;
}
}
dis++;
}
proto_tree_add_item(tree, hf_smb2_unknown, tvb, 0, tvb_captured_length(tvb), ENC_NA);
}
static int
dissect_smb2_find_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
{
offset_length_buffer_t olb;
proto_item *item = NULL;
gboolean continue_dissection;
if (si->saved) {
/* infolevel */
item = proto_tree_add_uint(tree, hf_smb2_find_info_level, tvb, offset, 0, si->saved->infolevel);
proto_item_set_generated(item);
}
if (!pinfo->fd->visited && si->saved && si->saved->extra_info_type == SMB2_EI_FINDPATTERN) {
col_append_fstr(pinfo->cinfo, COL_INFO, " %s Pattern: %s",
val_to_str(si->saved->infolevel, smb2_find_info_levels, "(Level:0x%02x)"),
(const char *)si->saved->extra_info);
wmem_free(wmem_file_scope(), si->saved->extra_info);
si->saved->extra_info_type = SMB2_EI_NONE;
si->saved->extra_info = NULL;
}
switch (si->status) {
/* buffer code */
case 0x00000000: offset = dissect_smb2_buffercode(tree, tvb, offset, NULL); break;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
/* findinfo offset */
offset = dissect_smb2_olb_length_offset(tvb, offset, &olb, OLB_O_UINT16_S_UINT32, hf_smb2_find_info_blob);
/* the buffer */
dissect_smb2_olb_buffer(pinfo, tree, tvb, &olb, si, dissect_smb2_find_data);
offset = dissect_smb2_olb_tvb_max_offset(offset, &olb);
return offset;
}
static int
dissect_smb2_negotiate_context(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
guint16 type;
const gchar *type_str;
guint32 i, data_length, salt_length, hash_count, cipher_count, comp_count, transform_count;
guint32 signing_count;
proto_item *sub_item;
proto_tree *sub_tree;
static int * const comp_alg_flags_fields[] = {
&hf_smb2_comp_alg_flags_chained,
&hf_smb2_comp_alg_flags_reserved,
NULL
};
sub_tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_smb2_negotiate_context_element, &sub_item, "Negotiate Context");
/* type */
type = tvb_get_letohl(tvb, offset);
type_str = val_to_str(type, smb2_negotiate_context_types, "Unknown Type: (0x%0x)");
proto_item_append_text(sub_item, ": %s ", type_str);
proto_tree_add_item(sub_tree, hf_smb2_negotiate_context_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* data length */
proto_tree_add_item_ret_uint(sub_tree, hf_smb2_negotiate_context_data_length, tvb, offset, 2, ENC_LITTLE_ENDIAN, &data_length);
proto_item_set_len(sub_item, data_length + 8);
offset += 2;
/* reserved */
proto_tree_add_item(sub_tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
switch (type)
{
case SMB2_PREAUTH_INTEGRITY_CAPABILITIES:
proto_tree_add_item_ret_uint(sub_tree, hf_smb2_hash_alg_count, tvb, offset, 2, ENC_LITTLE_ENDIAN, &hash_count);
offset += 2;
proto_tree_add_item_ret_uint(sub_tree, hf_smb2_salt_length, tvb, offset, 2, ENC_LITTLE_ENDIAN, &salt_length);
offset += 2;
for (i = 0; i < hash_count; i++)
{
proto_tree_add_item(sub_tree, hf_smb2_hash_algorithm, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
}
if (salt_length)
{
proto_tree_add_item(sub_tree, hf_smb2_salt, tvb, offset, salt_length, ENC_NA);
offset += salt_length;
}
break;
case SMB2_ENCRYPTION_CAPABILITIES:
proto_tree_add_item_ret_uint(sub_tree, hf_smb2_cipher_count, tvb, offset, 2, ENC_LITTLE_ENDIAN, &cipher_count);
offset += 2;
for (i = 0; i < cipher_count; i ++)
{
/* in SMB3.1.1 the first cipher returned by the server session encryption algorithm */
if (i == 0 && si && si->conv && (si->flags & SMB2_FLAGS_RESPONSE)) {
guint16 first_cipher = tvb_get_letohs(tvb, offset);
si->conv->enc_alg = first_cipher;
}
proto_tree_add_item(sub_tree, hf_smb2_cipher_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
}
break;
case SMB2_COMPRESSION_CAPABILITIES:
proto_tree_add_item_ret_uint(sub_tree, hf_smb2_comp_alg_count, tvb, offset, 2, ENC_LITTLE_ENDIAN, &comp_count);
offset += 2;
/* padding */
offset += 2;
/* flags */
proto_tree_add_bitmask(sub_tree, tvb, offset, hf_smb2_comp_alg_flags, ett_smb2_comp_alg_flags, comp_alg_flags_fields, ENC_LITTLE_ENDIAN);
offset += 4;
for (i = 0; i < comp_count; i ++) {
proto_tree_add_item(sub_tree, hf_smb2_comp_alg_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
}
break;
case SMB2_NETNAME_NEGOTIATE_CONTEXT_ID:
proto_tree_add_item(sub_tree, hf_smb2_netname_neg_id, tvb, offset,
data_length, ENC_UTF_16|ENC_LITTLE_ENDIAN);
offset += data_length;
break;
case SMB2_TRANSPORT_CAPABILITIES:
proto_tree_add_item(sub_tree, hf_smb2_transport_ctx_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case SMB2_RDMA_TRANSFORM_CAPABILITIES:
proto_tree_add_item_ret_uint(sub_tree, hf_smb2_rdma_transform_count, tvb, offset, 2, ENC_LITTLE_ENDIAN, &transform_count);
offset += 2;
proto_tree_add_item(sub_tree, hf_smb2_rdma_transform_reserved1, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(sub_tree, hf_smb2_rdma_transform_reserved2, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
for (i = 0; i < transform_count; i++) {
proto_tree_add_item(sub_tree, hf_smb2_rdma_transform_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
}
break;
case SMB2_SIGNING_CAPABILITIES:
proto_tree_add_item_ret_uint(sub_tree, hf_smb2_signing_alg_count, tvb, offset, 2, ENC_LITTLE_ENDIAN, &signing_count);
offset += 2;
for (i = 0; i < signing_count; i++) {
/* in SMB3.1.1 the first cipher returned by the server session encryption algorithm */
if (i == 0 && si && si->conv && (si->flags & SMB2_FLAGS_RESPONSE)) {
guint16 first_sign_alg = tvb_get_letohs(tvb, offset);
si->conv->sign_alg = first_sign_alg;
}
proto_tree_add_item(sub_tree, hf_smb2_signing_alg_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
}
break;
case SMB2_POSIX_EXTENSIONS_CAPABILITIES:
proto_tree_add_item(sub_tree, hf_smb2_posix_reserved, tvb, offset, data_length, ENC_NA);
offset += data_length;
break;
default:
proto_tree_add_item(sub_tree, hf_smb2_unknown, tvb, offset, data_length, ENC_NA);
offset += data_length;
break;
}
return offset;
}
static int
dissect_smb2_negotiate_protocol_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
guint16 dc;
guint16 i;
gboolean supports_smb_3_10 = FALSE;
guint32 nco;
guint16 ncc;
proto_item *hash_item = NULL;
smb2_saved_info_t *ssi = si->saved;
/* compute preauth hash on first pass */
if (!pinfo->fd->visited && ssi) {
ssi->preauth_hash_req = (guint8*)wmem_alloc0(wmem_file_scope(), SMB2_PREAUTH_HASH_SIZE);
memset(si->conv->preauth_hash_ses, 0, SMB2_PREAUTH_HASH_SIZE);
memset(si->conv->preauth_hash_con, 0, SMB2_PREAUTH_HASH_SIZE);
si->conv->preauth_hash_current = si->conv->preauth_hash_con;
update_preauth_hash(si->conv->preauth_hash_current, pinfo, tvb);
memcpy(ssi->preauth_hash_req, si->conv->preauth_hash_current, SMB2_PREAUTH_HASH_SIZE);
}
if (ssi && ssi->preauth_hash_req) {
hash_item = proto_tree_add_bytes_with_length(tree,
hf_smb2_preauth_hash, tvb,
0, tvb_captured_length(tvb),
ssi->preauth_hash_req, SMB2_PREAUTH_HASH_SIZE);
proto_item_set_generated(hash_item);
}
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* dialect count */
dc = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb2_dialect_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* security mode, skip second byte */
offset = dissect_smb2_secmode(tree, tvb, offset);
offset++;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* capabilities */
offset = dissect_smb2_capabilities(tree, tvb, offset);
/* client guid */
proto_tree_add_item(tree, hf_smb2_client_guid, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
/* negotiate context offset */
nco = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_negotiate_context_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* negotiate context count */
ncc = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb2_negotiate_context_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
for (i = 0 ; i < dc; i++) {
guint16 d = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb2_dialect, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
if (d >= SMB2_DIALECT_310) {
supports_smb_3_10 = TRUE;
}
}
if (!supports_smb_3_10) {
ncc = 0;
}
if (nco != 0) {
guint32 tmp = 0x40 + 36 + dc * 2;
if (nco >= tmp) {
offset += nco - tmp;
} else {
ncc = 0;
}
}
for (i = 0; i < ncc; i++) {
offset = WS_ROUNDUP_8(offset);
offset = dissect_smb2_negotiate_context(tvb, pinfo, tree, offset, si);
}
return offset;
}
static int
dissect_smb2_negotiate_protocol_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
offset_length_buffer_t s_olb;
guint16 i;
guint32 nco;
guint16 ncc;
gboolean continue_dissection;
proto_item *hash_item = NULL;
smb2_saved_info_t *ssi = si->saved;
/* compute preauth hash on first pass */
if (!pinfo->fd->visited && ssi) {
ssi->preauth_hash_res = (guint8*)wmem_alloc0(wmem_file_scope(), SMB2_PREAUTH_HASH_SIZE);
update_preauth_hash(si->conv->preauth_hash_current, pinfo, tvb);
memcpy(ssi->preauth_hash_res, si->conv->preauth_hash_current, SMB2_PREAUTH_HASH_SIZE);
/*
* All new sessions on this conversation must reuse
* the preauth hash value at the time of the negprot
* response, so we stash it and switch buffers
*/
memcpy(si->conv->preauth_hash_ses, si->conv->preauth_hash_current, SMB2_PREAUTH_HASH_SIZE);
si->conv->preauth_hash_current = si->conv->preauth_hash_ses;
}
if (ssi && ssi->preauth_hash_res) {
hash_item = proto_tree_add_bytes_with_length(tree,
hf_smb2_preauth_hash, tvb,
0, tvb_captured_length(tvb),
ssi->preauth_hash_res, SMB2_PREAUTH_HASH_SIZE);
proto_item_set_generated(hash_item);
}
switch (si->status) {
/* buffer code */
case 0x00000000: offset = dissect_smb2_buffercode(tree, tvb, offset, NULL); break;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
/* security mode, skip second byte */
offset = dissect_smb2_secmode(tree, tvb, offset);
offset++;
/* dialect picked */
si->conv->dialect = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb2_dialect, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* negotiate context count */
ncc = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb2_negotiate_context_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* server GUID */
proto_tree_add_item(tree, hf_smb2_server_guid, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
/* capabilities */
offset = dissect_smb2_capabilities(tree, tvb, offset);
/* max trans size */
proto_tree_add_item(tree, hf_smb2_max_trans_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* max read size */
proto_tree_add_item(tree, hf_smb2_max_read_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* max write size */
proto_tree_add_item(tree, hf_smb2_max_write_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* current time */
dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_current_time);
offset += 8;
/* boot time */
dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_boot_time);
offset += 8;
/* security blob offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &s_olb, OLB_O_UINT16_S_UINT16, hf_smb2_security_blob);
/* the security blob itself */
dissect_smb2_olb_buffer(pinfo, tree, tvb, &s_olb, si, dissect_smb2_secblob);
/* negotiate context offset */
nco = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_negotiate_context_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
offset = dissect_smb2_olb_tvb_max_offset(offset, &s_olb);
if (si->conv->dialect == SMB2_DIALECT_300 || si->conv->dialect == SMB2_DIALECT_302) {
/* If we know we are decrypting SMB3.0, it must be CCM */
si->conv->enc_alg = SMB2_CIPHER_AES_128_CCM;
}
if (si->conv->dialect >= SMB2_DIALECT_300) {
/* If we know we are decrypting SMB3.0, it's CMAC by default */
si->conv->sign_alg = SMB2_SIGNING_ALG_AES_CMAC;
} else {
si->conv->sign_alg = SMB2_SIGNING_ALG_HMAC_SHA256;
}
if (si->conv->dialect < SMB2_DIALECT_310) {
ncc = 0;
}
if (nco != 0) {
guint32 tmp = 0x40 + 64 + s_olb.len;
if (nco >= tmp) {
offset += nco - tmp;
} else {
ncc = 0;
}
}
for (i = 0; i < ncc; i++) {
offset = WS_ROUNDUP_8(offset);
offset = dissect_smb2_negotiate_context(tvb, pinfo, tree, offset, si);
}
return offset;
}
static const true_false_string tfs_additional_owner = {
"Requesting OWNER security information",
"NOT requesting owner security information",
};
static const true_false_string tfs_additional_group = {
"Requesting GROUP security information",
"NOT requesting group security information",
};
static const true_false_string tfs_additional_dacl = {
"Requesting DACL security information",
"NOT requesting DACL security information",
};
static const true_false_string tfs_additional_sacl = {
"Requesting SACL security information",
"NOT requesting SACL security information",
};
static const true_false_string tfs_additional_label = {
"Requesting integrity label security information",
"NOT requesting integrity label security information",
};
static const true_false_string tfs_additional_attribute = {
"Requesting resource attribute security information",
"NOT requesting resource attribute security information",
};
static const true_false_string tfs_additional_scope = {
"Requesting central access policy security information",
"NOT requesting central access policy security information",
};
static const true_false_string tfs_additional_backup = {
"Requesting backup operation security information",
"NOT requesting backup operation security information",
};
static int
dissect_additional_information_sec_mask(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
/* Note that in SMB1 protocol some security flags were not defined yet - see dissect_security_information_mask()
So for SMB2 we have to use own dissector */
static int * const flags[] = {
&hf_smb2_getsetinfo_additional_owner,
&hf_smb2_getsetinfo_additional_group,
&hf_smb2_getsetinfo_additional_dacl,
&hf_smb2_getsetinfo_additional_sacl,
&hf_smb2_getsetinfo_additional_label,
&hf_smb2_getsetinfo_additional_attribute,
&hf_smb2_getsetinfo_additional_scope,
&hf_smb2_getsetinfo_additional_backup,
NULL
};
proto_tree_add_bitmask(parent_tree, tvb, offset, hf_smb2_getsetinfo_additionals,
ett_smb2_additional_information_sec_mask, flags, ENC_LITTLE_ENDIAN);
offset += 4;
return offset;
}
static int
dissect_smb2_getinfo_parameters(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si)
{
/* Additional Info */
switch (si->saved->smb2_class) {
case SMB2_CLASS_SEC_INFO:
dissect_additional_information_sec_mask(tvb, tree, offset);
break;
default:
proto_tree_add_item(tree, hf_smb2_getsetinfo_additional, tvb, offset, 4, ENC_LITTLE_ENDIAN);
}
offset += 4;
/* Flags */
proto_tree_add_item(tree, hf_smb2_getinfo_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
return offset;
}
static int
dissect_smb2_getinfo_buffer_quota(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, smb2_info_t *si _U_)
{
guint32 sidlist_len = 0;
guint32 startsid_len = 0;
guint32 startsid_offset = 0;
proto_item *item = NULL;
proto_tree *tree = NULL;
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_query_quota_info, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_query_quota_info);
}
proto_tree_add_item(tree, hf_smb2_qq_single, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(tree, hf_smb2_qq_restart, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
proto_tree_add_item_ret_uint(tree, hf_smb2_qq_sidlist_len, tvb, offset, 4, ENC_LITTLE_ENDIAN, &sidlist_len);
offset += 4;
proto_tree_add_item_ret_uint(tree, hf_smb2_qq_start_sid_len, tvb, offset, 4, ENC_LITTLE_ENDIAN, &startsid_len);
offset += 4;
proto_tree_add_item_ret_uint(tree, hf_smb2_qq_start_sid_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN, &startsid_offset);
offset += 4;
if (sidlist_len != 0) {
offset = dissect_nt_get_user_quota(tvb, tree, offset, &sidlist_len);
} else if (startsid_len != 0) {
offset = dissect_nt_sid(tvb, offset + startsid_offset, tree, "Start SID", NULL, -1);
}
return offset;
}
static int
dissect_smb2_class_infolevel(packet_info *pinfo, tvbuff_t *tvb, int offset, proto_tree *tree, smb2_info_t *si)
{
guint8 cl, il;
proto_item *item;
int hfindex;
value_string_ext *vsx;
if (si->flags & SMB2_FLAGS_RESPONSE) {
if (!si->saved) {
return offset;
}
cl = si->saved->smb2_class;
il = si->saved->infolevel;
} else {
cl = tvb_get_guint8(tvb, offset);
il = tvb_get_guint8(tvb, offset+1);
if (si->saved) {
si->saved->smb2_class = cl;
si->saved->infolevel = il;
}
}
switch (cl) {
case SMB2_CLASS_FILE_INFO:
hfindex = hf_smb2_infolevel_file_info;
vsx = &smb2_file_info_levels_ext;
break;
case SMB2_CLASS_FS_INFO:
hfindex = hf_smb2_infolevel_fs_info;
vsx = &smb2_fs_info_levels_ext;
break;
case SMB2_CLASS_SEC_INFO:
hfindex = hf_smb2_infolevel_sec_info;
vsx = &smb2_sec_info_levels_ext;
break;
case SMB2_CLASS_QUOTA_INFO:
/* infolevel is not being used for quota */
hfindex = hf_smb2_infolevel;
vsx = NULL;
break;
default:
hfindex = hf_smb2_infolevel;
vsx = NULL; /* allowed arg to val_to_str_ext() */
}
/* class */
item = proto_tree_add_uint(tree, hf_smb2_class, tvb, offset, 1, cl);
if (si->flags & SMB2_FLAGS_RESPONSE) {
proto_item_set_generated(item);
}
/* infolevel */
item = proto_tree_add_uint(tree, hfindex, tvb, offset+1, 1, il);
if (si->flags & SMB2_FLAGS_RESPONSE) {
proto_item_set_generated(item);
}
offset += 2;
if (!(si->flags & SMB2_FLAGS_RESPONSE)) {
/* Only update COL_INFO for requests. It clutters the
* display a bit too much if we do it for replies
* as well.
*/
col_append_fstr(pinfo->cinfo, COL_INFO, " %s/%s",
val_to_str(cl, smb2_class_vals, "(Class:0x%02x)"),
val_to_str_ext(il, vsx, "(Level:0x%02x)"));
}
return offset;
}
static int
dissect_smb2_getinfo_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
guint32 getinfo_size = 0;
guint32 getinfo_offset = 0;
proto_item *offset_item;
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* class and info level */
offset = dissect_smb2_class_infolevel(pinfo, tvb, offset, tree, si);
/* max response size */
proto_tree_add_item(tree, hf_smb2_max_response_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* offset */
offset_item = proto_tree_add_item_ret_uint(tree, hf_smb2_getinfo_input_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN, &getinfo_offset);
offset += 2;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* size */
proto_tree_add_item_ret_uint(tree, hf_smb2_getinfo_input_size, tvb, offset, 4, ENC_LITTLE_ENDIAN, &getinfo_size);
offset += 4;
/* parameters */
if (si->saved) {
offset = dissect_smb2_getinfo_parameters(tvb, pinfo, tree, offset, si);
} else {
/* some unknown bytes */
proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 8, ENC_NA);
offset += 8;
}
/* fid */
offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
/* buffer */
if (si->saved) {
if (getinfo_size != 0) {
/*
* 2.2.37 says "For quota requests, this MUST be
* the length of the contained SMB2_QUERY_QUOTA_INFO
* embedded in the request. For FileFullEaInformation
* requests, this MUST be set to the length of the
* user supplied EA list specified in [MS-FSCC]
* section 2.4.15.1. For other information queries,
* this field SHOULD be set to 0 and the server MUST
* ignore it on receipt.
*
* This seems to imply that, for requests other
* than those to types, we should either completely
* ignore a non-zero getinfo_size or should, at
* most, add a warning-level expert info at the
* protocol level saying that it should be zero,
* but not try and interpret it or check its
* validity.
*/
if (si->saved->smb2_class == SMB2_CLASS_QUOTA_INFO ||
(si->saved->smb2_class == SMB2_CLASS_FILE_INFO &&
si->saved->infolevel == SMB2_FILE_FULL_EA_INFO)) {
/*
* According to 2.2.37 SMB2 QUERY_INFO
* Request in the current MS-SMB2 spec,
* these are the only info requests that
* have an input buffer.
*/
/*
* Make sure that the input buffer is after
* the fixed-length part of the message.
*/
if (getinfo_offset < (guint)offset) {
expert_add_info(pinfo, offset_item, &ei_smb2_invalid_getinfo_offset);
return offset;
}
/*
* Make sure the input buffer is within the
* message, i.e. that it's within the tvbuff.
*
* We check for offset+length overflowing and
* for offset+length being beyond the reported
* length of the tvbuff.
*/
if (getinfo_offset + getinfo_size < getinfo_offset ||
getinfo_offset + getinfo_size > tvb_reported_length(tvb)) {
expert_add_info(pinfo, offset_item, &ei_smb2_invalid_getinfo_size);
return offset;
}
if (si->saved->smb2_class == SMB2_CLASS_QUOTA_INFO) {
dissect_smb2_getinfo_buffer_quota(tvb, pinfo, tree, getinfo_offset, si);
} else {
/*
* XXX - handle user supplied EA info.
*/
proto_tree_add_item(tree, hf_smb2_unknown, tvb, getinfo_offset, getinfo_size, ENC_NA);
}
offset = getinfo_offset + getinfo_size;
}
} else {
/*
* The buffer size is 0, meaning it's not present.
*
* 2.2.37 says "For FileFullEaInformation requests,
* the input buffer MUST contain the user supplied
* EA list with zero or more FILE_GET_EA_INFORMATION
* structures, specified in [MS-FSCC] section
* 2.4.15.1.", so it seems that, for a "get full
* EA information" request, the size can be zero -
* there's no other obvious way for the list to
* have zero structures.
*
* 2.2.37 also says "For quota requests, the input
* buffer MUST contain an SMB2_QUERY_QUOTA_INFO,
* as specified in section 2.2.37.1."; that seems
* to imply that the input buffer must not be empty
* in that case.
*/
if (si->saved->smb2_class == SMB2_CLASS_QUOTA_INFO)
expert_add_info(pinfo, offset_item, &ei_smb2_empty_getinfo_buffer);
}
}
return offset;
}
static int
dissect_smb2_infolevel(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si, guint8 smb2_class, guint8 infolevel)
{
int old_offset = offset;
switch (smb2_class) {
case SMB2_CLASS_FILE_INFO:
switch (infolevel) {
case SMB2_FILE_BASIC_INFO:
offset = dissect_smb2_file_basic_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_STANDARD_INFO:
offset = dissect_smb2_file_standard_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_INTERNAL_INFO:
offset = dissect_smb2_file_internal_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_EA_INFO:
offset = dissect_smb2_file_ea_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_ACCESS_INFO:
offset = dissect_smb2_file_access_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_RENAME_INFO:
offset = dissect_smb2_file_rename_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_DISPOSITION_INFO:
offset = dissect_smb2_file_disposition_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_POSITION_INFO:
offset = dissect_smb2_file_position_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_FULL_EA_INFO:
offset = dissect_smb2_file_full_ea_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_MODE_INFO:
offset = dissect_smb2_file_mode_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_ALIGNMENT_INFO:
offset = dissect_smb2_file_alignment_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_ALL_INFO:
offset = dissect_smb2_file_all_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_ALLOCATION_INFO:
offset = dissect_smb2_file_allocation_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_ENDOFFILE_INFO:
dissect_smb2_file_endoffile_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_ALTERNATE_NAME_INFO:
offset = dissect_smb2_file_alternate_name_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_STREAM_INFO:
offset = dissect_smb2_file_stream_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_PIPE_INFO:
offset = dissect_smb2_file_pipe_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_COMPRESSION_INFO:
offset = dissect_smb2_file_compression_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_NETWORK_OPEN_INFO:
offset = dissect_smb2_file_network_open_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_ATTRIBUTE_TAG_INFO:
offset = dissect_smb2_file_attribute_tag_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_NORMALIZED_NAME_INFO:
offset = dissect_smb2_file_normalized_name_info(tvb, pinfo, tree, offset, si);
break;
case SMB2_FILE_POSIX_INFO:
offset = dissect_smb2_posix_info(tvb, pinfo, tree, offset, si);
break;
default:
/* we don't handle this infolevel yet */
proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_captured_length_remaining(tvb, offset), ENC_NA);
offset += tvb_captured_length_remaining(tvb, offset);
}
break;
case SMB2_CLASS_FS_INFO:
switch (infolevel) {
case SMB2_FS_INFO_01:
offset = dissect_smb2_fs_info_01(tvb, pinfo, tree, offset, si);
break;
case SMB2_FS_INFO_03:
offset = dissect_smb2_fs_info_03(tvb, pinfo, tree, offset, si);
break;
case SMB2_FS_INFO_04:
offset = dissect_smb2_fs_info_04(tvb, pinfo, tree, offset, si);
break;
case SMB2_FS_INFO_05:
offset = dissect_smb2_fs_info_05(tvb, pinfo, tree, offset, si);
break;
case SMB2_FS_INFO_06:
offset = dissect_smb2_fs_info_06(tvb, pinfo, tree, offset, si);
break;
case SMB2_FS_INFO_07:
offset = dissect_smb2_fs_info_07(tvb, pinfo, tree, offset, si);
break;
case SMB2_FS_OBJECTID_INFO:
offset = dissect_smb2_FS_OBJECTID_INFO(tvb, pinfo, tree, offset, si);
break;
default:
/* we don't handle this infolevel yet */
proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_captured_length_remaining(tvb, offset), ENC_NA);
offset += tvb_captured_length_remaining(tvb, offset);
}
break;
case SMB2_CLASS_SEC_INFO:
switch (infolevel) {
case SMB2_SEC_INFO_00:
offset = dissect_smb2_sec_info_00(tvb, pinfo, tree, offset, si);
break;
default:
/* we don't handle this infolevel yet */
proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_captured_length_remaining(tvb, offset), ENC_NA);
offset += tvb_captured_length_remaining(tvb, offset);
}
break;
case SMB2_CLASS_QUOTA_INFO:
offset = dissect_smb2_quota_info(tvb, pinfo, tree, offset, si);
break;
default:
/* we don't handle this class yet */
proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, tvb_captured_length_remaining(tvb, offset), ENC_NA);
offset += tvb_captured_length_remaining(tvb, offset);
}
/* if we get BUFFER_OVERFLOW there will be truncated data */
if (si->status == 0x80000005) {
proto_item *item;
item = proto_tree_add_item(tree, hf_smb2_truncated, tvb, old_offset, 0, ENC_NA);
proto_item_set_generated(item);
}
return offset;
}
static void
dissect_smb2_getinfo_response_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
{
/* data */
if (si->saved) {
dissect_smb2_infolevel(tvb, pinfo, tree, 0, si, si->saved->smb2_class, si->saved->infolevel);
} else {
/* some unknown bytes */
proto_tree_add_item(tree, hf_smb2_unknown, tvb, 0, tvb_captured_length(tvb), ENC_NA);
}
}
static int
dissect_smb2_getinfo_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
offset_length_buffer_t olb;
gboolean continue_dissection;
/* class/infolevel */
dissect_smb2_class_infolevel(pinfo, tvb, offset, tree, si);
switch (si->status) {
case 0x00000000:
/* if we get BUFFER_OVERFLOW there will be truncated data */
case 0x80000005:
/* if we get BUFFER_TOO_SMALL there will not be any data there, only
* a guin32 specifying how big the buffer needs to be
*/
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
break;
case 0xc0000023:
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
offset = dissect_smb2_olb_length_offset(tvb, offset, &olb, OLB_O_UINT16_S_UINT32, -1);
proto_tree_add_item(tree, hf_smb2_required_buffer_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
return offset;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
/* response buffer offset and size */
offset = dissect_smb2_olb_length_offset(tvb, offset, &olb, OLB_O_UINT16_S_UINT32, -1);
/* response data*/
dissect_smb2_olb_buffer(pinfo, tree, tvb, &olb, si, dissect_smb2_getinfo_response_data);
return offset;
}
static int
dissect_smb2_close_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
proto_tree *flags_tree = NULL;
proto_item *flags_item = NULL;
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* close flags */
if (tree) {
flags_item = proto_tree_add_item(tree, hf_smb2_close_flags, tvb, offset, 2, ENC_LITTLE_ENDIAN);
flags_tree = proto_item_add_subtree(flags_item, ett_smb2_close_flags);
}
proto_tree_add_item(flags_tree, hf_smb2_close_pq_attrib, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* padding */
offset += 4;
/* fid */
offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_CLOSE);
return offset;
}
static int
dissect_smb2_close_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
{
proto_tree *flags_tree = NULL;
proto_item *flags_item = NULL;
gboolean continue_dissection;
switch (si->status) {
/* buffer code */
case 0x00000000: offset = dissect_smb2_buffercode(tree, tvb, offset, NULL); break;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
/* close flags */
if (tree) {
flags_item = proto_tree_add_item(tree, hf_smb2_close_flags, tvb, offset, 2, ENC_LITTLE_ENDIAN);
flags_tree = proto_item_add_subtree(flags_item, ett_smb2_close_flags);
}
proto_tree_add_item(flags_tree, hf_smb2_close_pq_attrib, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
/* create time */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
/* last access */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
/* last write */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
/* last change */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
/* allocation size */
proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* end of file */
proto_tree_add_item(tree, hf_smb2_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* File Attributes */
offset = dissect_fscc_file_attr(tvb, tree, offset, NULL);
return offset;
}
static int
dissect_smb2_flush_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* some unknown bytes */
proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 6, ENC_NA);
offset += 6;
/* fid */
offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
return offset;
}
static int
dissect_smb2_flush_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
{
gboolean continue_dissection;
switch (si->status) {
/* buffer code */
case 0x00000000: offset = dissect_smb2_buffercode(tree, tvb, offset, NULL); break;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
/* some unknown bytes */
proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, ENC_NA);
offset += 2;
return offset;
}
static int
dissect_smb2_lock_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
guint16 lock_count;
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* lock count */
lock_count = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb2_lock_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* Lock Sequence Number/Index */
proto_tree_add_item(tree, hf_smb2_lock_sequence_number, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_smb2_lock_sequence_index, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* fid */
offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
while (lock_count--) {
proto_item *lock_item = NULL;
proto_tree *lock_tree = NULL;
static int * const lf_fields[] = {
&hf_smb2_lock_flags_shared,
&hf_smb2_lock_flags_exclusive,
&hf_smb2_lock_flags_unlock,
&hf_smb2_lock_flags_fail_immediately,
NULL
};
if (tree) {
lock_item = proto_tree_add_item(tree, hf_smb2_lock_info, tvb, offset, 24, ENC_NA);
lock_tree = proto_item_add_subtree(lock_item, ett_smb2_lock_info);
}
/* offset */
proto_tree_add_item(tree, hf_smb2_file_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* count */
proto_tree_add_item(lock_tree, hf_smb2_lock_length, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* flags */
proto_tree_add_bitmask(lock_tree, tvb, offset, hf_smb2_lock_flags, ett_smb2_lock_flags, lf_fields, ENC_LITTLE_ENDIAN);
offset += 4;
/* reserved */
proto_tree_add_item(lock_tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
}
return offset;
}
static int
dissect_smb2_lock_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
{
gboolean continue_dissection;
switch (si->status) {
/* buffer code */
case 0x00000000: offset = dissect_smb2_buffercode(tree, tvb, offset, NULL); break;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
/* some unknown bytes */
proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, ENC_NA);
offset += 2;
return offset;
}
static int
dissect_smb2_cancel_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
{
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* some unknown bytes */
proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, 2, ENC_NA);
offset += 2;
return offset;
}
static const smb2_fid_info_t *
smb2_pipe_get_fid_info(const smb2_info_t *si)
{
smb2_fid_info_t *file = NULL;
if (si == NULL) {
return NULL;
}
if (si->file != NULL) {
file = si->file;
} else if (si->saved != NULL) {
file = si->saved->file;
}
if (file == NULL) {
return NULL;
}
return file;
}
static void
smb2_pipe_set_file_id(packet_info *pinfo, smb2_info_t *si)
{
guint64 persistent;
const smb2_fid_info_t *file = NULL;
file = smb2_pipe_get_fid_info(si);
if (file == NULL) {
return;
}
persistent = GPOINTER_TO_UINT(file);
dcerpc_set_transport_salt(persistent, pinfo);
}
static gboolean smb2_pipe_reassembly = TRUE;
static gboolean smb2_verify_signatures = FALSE;
static reassembly_table smb2_pipe_reassembly_table;
static int
dissect_file_data_smb2_pipe(tvbuff_t *raw_tvb, packet_info *pinfo, proto_tree *tree _U_, int offset, guint32 datalen, proto_tree *top_tree, void *data)
{
/*
* Note: si is NULL for some callers from packet-smb.c
*/
const smb2_info_t *si = (const smb2_info_t *)data;
gboolean result=0;
gboolean save_fragmented;
gint remaining;
guint reported_len;
const smb2_fid_info_t *file = NULL;
guint32 id;
fragment_head *fd_head;
fragment_item *fd_i;
tvbuff_t *tvb;
tvbuff_t *new_tvb;
proto_item *frag_tree_item;
heur_dtbl_entry_t *hdtbl_entry;
file = smb2_pipe_get_fid_info(si);
id = (guint32)(GPOINTER_TO_UINT(file) & G_MAXUINT32);
remaining = tvb_captured_length_remaining(raw_tvb, offset);
tvb = tvb_new_subset_length_caplen(raw_tvb, offset,
MIN((int)datalen, remaining),
datalen);
/*
* Offer desegmentation service to Named Pipe subdissectors (e.g. DCERPC)
* if we have all the data. Otherwise, reassembly is (probably) impossible.
*/
pinfo->can_desegment = 0;
pinfo->desegment_offset = 0;
pinfo->desegment_len = 0;
reported_len = tvb_reported_length(tvb);
if (smb2_pipe_reassembly && tvb_captured_length(tvb) >= reported_len) {
pinfo->can_desegment = 2;
}
save_fragmented = pinfo->fragmented;
/*
* if we are not offering desegmentation, just try the heuristics
*and bail out
*/
if (!pinfo->can_desegment) {
result = dissector_try_heuristic(smb2_pipe_subdissector_list,
tvb, pinfo, top_tree,
&hdtbl_entry, data);
goto clean_up_and_exit;
}
/* below this line, we know we are doing reassembly */
/*
* this is a new packet, see if we are already reassembling this
* pdu and if not, check if the dissector wants us
* to reassemble it
*/
if (!pinfo->fd->visited) {
/*
* This is the first pass.
*
* Check if we are already reassembling this PDU or not;
* we check for an in-progress reassembly for this FID
* in this direction, by searching for its reassembly
* structure.
*/
fd_head = fragment_get(&smb2_pipe_reassembly_table,
pinfo, id, NULL);
if (!fd_head) {
/*
* No reassembly, so this is a new pdu. check if the
* dissector wants us to reassemble it or if we
* already got the full pdu in this tvb.
*/
/*
* Try the heuristic dissectors and see if we
* find someone that recognizes this payload.
*/
result = dissector_try_heuristic(smb2_pipe_subdissector_list,
tvb, pinfo, top_tree,
&hdtbl_entry, data);
/* no this didn't look like something we know */
if (!result) {
goto clean_up_and_exit;
}
/* did the subdissector want us to reassemble any
more data ?
*/
if (pinfo->desegment_len) {
fragment_add_check(&smb2_pipe_reassembly_table,
tvb, 0, pinfo, id, NULL,
0, reported_len, TRUE);
fragment_set_tot_len(&smb2_pipe_reassembly_table,
pinfo, id, NULL,
pinfo->desegment_len+reported_len);
}
goto clean_up_and_exit;
}
/* OK, we're already doing a reassembly for this FID.
skip to last segment in the existing reassembly structure
and add this fragment there
XXX we might add code here to use any offset values
we might pick up from the Read/Write calls instead of
assuming we always get them in the correct order
*/
for (fd_i = fd_head->next; fd_i->next; fd_i = fd_i->next) {}
fd_head = fragment_add_check(&smb2_pipe_reassembly_table,
tvb, 0, pinfo, id, NULL,
fd_i->offset+fd_i->len,
reported_len, TRUE);
/* if we completed reassembly */
if (fd_head) {
new_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
add_new_data_source(pinfo, new_tvb,
"Named Pipe over SMB2");
pinfo->fragmented=FALSE;
tvb = new_tvb;
/* list what segments we have */
show_fragment_tree(fd_head, &smb2_pipe_frag_items,
tree, pinfo, tvb, &frag_tree_item);
/* dissect the full PDU */
result = dissector_try_heuristic(smb2_pipe_subdissector_list,
tvb, pinfo, top_tree,
&hdtbl_entry, data);
}
goto clean_up_and_exit;
}
/*
* This is not the first pass; see if it's in the table of
* reassembled packets.
*
* XXX - we know that several of the arguments aren't going to
* be used, so we pass bogus variables. Can we clean this
* up so that we don't have to distinguish between the first
* pass and subsequent passes?
*/
fd_head = fragment_add_check(&smb2_pipe_reassembly_table,
tvb, 0, pinfo, id, NULL, 0, 0, TRUE);
if (!fd_head) {
/* we didn't find it, try any of the heuristic dissectors
and bail out
*/
result = dissector_try_heuristic(smb2_pipe_subdissector_list,
tvb, pinfo, top_tree,
&hdtbl_entry, data);
goto clean_up_and_exit;
}
if (!(fd_head->flags&FD_DEFRAGMENTED)) {
/* we don't have a fully reassembled frame */
result = dissector_try_heuristic(smb2_pipe_subdissector_list,
tvb, pinfo, top_tree,
&hdtbl_entry, data);
goto clean_up_and_exit;
}
/* it is reassembled but it was reassembled in a different frame */
if (pinfo->num != fd_head->reassembled_in) {
proto_item *item;
item = proto_tree_add_uint(top_tree, hf_smb2_pipe_reassembled_in,
tvb, 0, 0, fd_head->reassembled_in);
proto_item_set_generated(item);
goto clean_up_and_exit;
}
/* display the reassembled pdu */
new_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
add_new_data_source(pinfo, new_tvb,
"Named Pipe over SMB2");
pinfo->fragmented = FALSE;
tvb = new_tvb;
/* list what segments we have */
show_fragment_tree(fd_head, &smb2_pipe_frag_items,
top_tree, pinfo, tvb, &frag_tree_item);
/* dissect the full PDU */
result = dissector_try_heuristic(smb2_pipe_subdissector_list,
tvb, pinfo, top_tree,
&hdtbl_entry, data);
clean_up_and_exit:
/* clear out the variables */
pinfo->can_desegment=0;
pinfo->desegment_offset = 0;
pinfo->desegment_len = 0;
if (!result) {
call_data_dissector(tvb, pinfo, top_tree);
}
pinfo->fragmented = save_fragmented;
offset += datalen;
return offset;
}
#define SMB2_CHANNEL_NONE 0x00000000
#define SMB2_CHANNEL_RDMA_V1 0x00000001
#define SMB2_CHANNEL_RDMA_V1_INVALIDATE 0x00000002
#define SMB2_CHANNEL_RDMA_TRANSFORM 0x00000003
static const value_string smb2_channel_vals[] = {
{ SMB2_CHANNEL_NONE, "None" },
{ SMB2_CHANNEL_RDMA_V1, "RDMA V1" },
{ SMB2_CHANNEL_RDMA_V1_INVALIDATE, "RDMA V1_INVALIDATE" },
{ SMB2_CHANNEL_RDMA_TRANSFORM, "RDMA TRANSFORM" },
{ 0, NULL }
};
static void
dissect_smb2_rdma_v1_blob(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree *parent_tree, smb2_info_t *si _U_)
{
int offset = 0;
int len;
int i;
int num;
proto_tree *sub_tree;
proto_item *parent_item;
parent_item = proto_tree_get_parent(parent_tree);
len = tvb_reported_length(tvb);
num = len / 16;
if (parent_item) {
proto_item_append_text(parent_item, ": SMBDirect Buffer Descriptor V1: (%d elements)", num);
}
for (i = 0; i < num; i++) {
sub_tree = proto_tree_add_subtree(parent_tree, tvb, offset, 8, ett_smb2_rdma_v1, NULL, "RDMA V1");
proto_tree_add_item(sub_tree, hf_smb2_rdma_v1_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(sub_tree, hf_smb2_rdma_v1_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(sub_tree, hf_smb2_rdma_v1_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
}
#define SMB2_WRITE_FLAG_WRITE_THROUGH 0x00000001
#define SMB2_WRITE_FLAG_WRITE_UNBUFFERED 0x00000002
static const true_false_string tfs_write_through = {
"Client is asking for WRITE_THROUGH",
"Client is NOT asking for WRITE_THROUGH"
};
static const true_false_string tfs_write_unbuffered = {
"Client is asking for UNBUFFERED write",
"Client is NOT asking for UNBUFFERED write"
};
static int
dissect_smb2_write_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
guint16 dataoffset = 0;
guint32 data_tvb_len;
offset_length_buffer_t c_olb;
guint32 channel;
guint32 length;
guint64 off;
static int * const f_fields[] = {
&hf_smb2_write_flags_write_through,
&hf_smb2_write_flags_write_unbuffered,
NULL
};
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* data offset */
dataoffset=tvb_get_letohs(tvb,offset);
proto_tree_add_item(tree, hf_smb2_data_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* length */
length = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_write_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* offset */
off = tvb_get_letoh64(tvb, offset);
if (si->saved) si->saved->file_offset=off;
proto_tree_add_item(tree, hf_smb2_file_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
col_append_fstr(pinfo->cinfo, COL_INFO, " Len:%d Off:%" PRIu64, length, off);
/* fid */
offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
/* channel */
channel = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_channel, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* remaining bytes */
proto_tree_add_item(tree, hf_smb2_remaining_bytes, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* write channel info blob offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &c_olb, OLB_O_UINT16_S_UINT16, hf_smb2_channel_info_blob);
/* flags */
proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_write_flags, ett_smb2_write_flags, f_fields, ENC_LITTLE_ENDIAN);
offset += 4;
/* the write channel info blob itself */
switch (channel) {
case SMB2_CHANNEL_RDMA_V1:
case SMB2_CHANNEL_RDMA_V1_INVALIDATE:
dissect_smb2_olb_buffer(pinfo, tree, tvb, &c_olb, si, dissect_smb2_rdma_v1_blob);
break;
case SMB2_CHANNEL_NONE:
default:
dissect_smb2_olb_buffer(pinfo, tree, tvb, &c_olb, si, NULL);
break;
}
data_tvb_len=(guint32)tvb_captured_length_remaining(tvb, offset);
/* data or namedpipe ?*/
if (length) {
int oldoffset = offset;
smb2_pipe_set_file_id(pinfo, si);
offset = dissect_file_data_smb2_pipe(tvb, pinfo, tree, offset, length, si->top_tree, si);
if (offset != oldoffset) {
/* managed to dissect pipe data */
goto out;
}
}
/* just ordinary data */
proto_tree_add_item(tree, hf_smb2_write_data, tvb, offset, length, ENC_NA);
offset += MIN(length,(guint32)tvb_captured_length_remaining(tvb, offset));
offset = dissect_smb2_olb_tvb_max_offset(offset, &c_olb);
out:
if (have_tap_listener(smb2_eo_tap) && (data_tvb_len == length)) {
if (si->saved && si->eo_file_info) { /* without this data we don't know wich file this belongs to */
feed_eo_smb2(tvb,pinfo,si,dataoffset,length,off);
}
}
return offset;
}
static int
dissect_smb2_write_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, smb2_info_t *si _U_)
{
gboolean continue_dissection;
switch (si->status) {
/* buffer code */
case 0x00000000: offset = dissect_smb2_buffercode(tree, tvb, offset, NULL); break;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* count */
proto_tree_add_item(tree, hf_smb2_write_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* remaining, must be set to 0 */
proto_tree_add_item(tree, hf_smb2_write_remaining, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* write channel info offset */
proto_tree_add_item(tree, hf_smb2_channel_info_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* write channel info length */
proto_tree_add_item(tree, hf_smb2_channel_info_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
/* The STORAGE_OFFLOAD_TOKEN is used for "Offload Data Transfer" (ODX) operations,
including FSCTL_OFFLOAD_READ, FSCTL_OFFLOAD_WRITE. Ref: MS-FSCC 2.3.79
Note: Unlike most of SMB2, the token fields are BIG-endian! */
static int
dissect_smb2_STORAGE_OFFLOAD_TOKEN(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
proto_tree *sub_tree;
proto_item *sub_item;
guint32 idlen = 0;
guint32 idtype = 0;
sub_tree = proto_tree_add_subtree(tree, tvb, offset, 512, ett_smb2_fsctl_odx_token, &sub_item, "Token");
proto_tree_add_item_ret_uint(sub_tree, hf_smb2_fsctl_odx_token_type, tvb, offset, 4, ENC_BIG_ENDIAN, &idtype);
offset += 4;
proto_item_append_text(sub_item, " (IdType 0x%x)", idtype);
/* reserved */
proto_tree_add_item(sub_tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* TokenIdLength */
proto_tree_add_item_ret_uint(sub_tree, hf_smb2_fsctl_odx_token_idlen, tvb, offset, 2, ENC_BIG_ENDIAN, &idlen);
offset += 2;
/* idlen is what the server says is the "meaningful" part of the token.
However, token ID is always 504 bytes */
proto_tree_add_bytes_format_value(sub_tree, hf_smb2_fsctl_odx_token_idraw, tvb,
offset, idlen, NULL, "Opaque Data");
offset += 504;
return (offset);
}
/* MS-FSCC 2.3.77, 2.3.78 */
static void
dissect_smb2_FSCTL_OFFLOAD_READ(tvbuff_t *tvb,
packet_info *pinfo _U_,
proto_tree *tree,
int offset,
gboolean in)
{
proto_tree_add_item(tree, hf_smb2_fsctl_odx_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_smb2_fsctl_odx_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
if (in) {
proto_tree_add_item(tree, hf_smb2_fsctl_odx_token_ttl, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
proto_tree_add_item(tree, hf_smb2_fsctl_odx_file_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(tree, hf_smb2_fsctl_odx_copy_length, tvb, offset, 8, ENC_LITTLE_ENDIAN);
/* offset += 8; */
} else {
proto_tree_add_item(tree, hf_smb2_fsctl_odx_xfer_length, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
(void) dissect_smb2_STORAGE_OFFLOAD_TOKEN(tvb, pinfo, tree, offset);
}
}
/* MS-FSCC 2.3.80, 2.3.81 */
static void
dissect_smb2_FSCTL_OFFLOAD_WRITE(tvbuff_t *tvb,
packet_info *pinfo _U_,
proto_tree *tree,
int offset,
gboolean in)
{
proto_tree_add_item(tree, hf_smb2_fsctl_odx_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_smb2_fsctl_odx_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
if (in) {
proto_tree_add_item(tree, hf_smb2_fsctl_odx_file_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(tree, hf_smb2_fsctl_odx_copy_length, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(tree, hf_smb2_fsctl_odx_token_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
dissect_smb2_STORAGE_OFFLOAD_TOKEN(tvb, pinfo, tree, offset);
} else {
proto_tree_add_item(tree, hf_smb2_fsctl_odx_xfer_length, tvb, offset, 8, ENC_LITTLE_ENDIAN);
/* offset += 8; */
}
}
static void
dissect_smb2_FSCTL_PIPE_TRANSCEIVE(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *top_tree, gboolean data_in _U_, void *data)
{
dissect_file_data_smb2_pipe(tvb, pinfo, tree, offset, tvb_captured_length_remaining(tvb, offset), top_tree, data);
}
static void
dissect_smb2_FSCTL_PIPE_WAIT(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, int offset, proto_tree *top_tree, gboolean data_in _U_)
{
int timeout_offset;
guint32 name_len;
guint8 timeout_specified;
char *display_string;
/* Timeout */
timeout_offset = offset;
offset += 8;
/* Name length */
/* XXX - put the name length into the tree */
name_len = tvb_get_letohl(tvb, offset);
offset += 4;
/* Timeout specified */
timeout_specified = tvb_get_guint8(tvb, offset);
if (timeout_specified) {
proto_tree_add_item(top_tree, hf_smb2_fsctl_pipe_wait_timeout,
tvb, timeout_offset, 8, ENC_LITTLE_ENDIAN);
}
offset += 1;
/* Padding */
offset += 1;
/* Name */
proto_tree_add_item_ret_display_string(top_tree, hf_smb2_fsctl_pipe_wait_name,
tvb, offset, name_len, ENC_UTF_16|ENC_LITTLE_ENDIAN,
pinfo->pool, &display_string);
col_append_fstr(pinfo->cinfo, COL_INFO, " Pipe: %s", display_string);
}
static int
dissect_smb2_FSCTL_SET_SPARSE(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
{
/* There is no out data */
if (!data_in) {
return offset;
}
/* sparse flag (optional) */
if (tvb_reported_length_remaining(tvb, offset) >= 1) {
proto_tree_add_item(tree, hf_smb2_fsctl_sparse_flag, tvb, offset, 1, ENC_NA);
offset += 1;
}
return offset;
}
static int
dissect_smb2_FSCTL_SET_ZERO_DATA(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
{
proto_tree *sub_tree;
proto_item *sub_item;
/* There is no out data */
if (!data_in) {
return offset;
}
sub_tree = proto_tree_add_subtree(tree, tvb, offset, 16, ett_smb2_fsctl_range_data, &sub_item, "Range");
proto_tree_add_item(sub_tree, hf_smb2_fsctl_range_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(sub_tree, hf_smb2_fsctl_range_length, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
return offset;
}
static void
dissect_smb2_FSCTL_QUERY_ALLOCATED_RANGES(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int offset _U_, gboolean data_in)
{
proto_tree *sub_tree;
proto_item *sub_item;
if (data_in) {
sub_tree = proto_tree_add_subtree(tree, tvb, offset, 16, ett_smb2_fsctl_range_data, &sub_item, "Range");
proto_tree_add_item(sub_tree, hf_smb2_fsctl_range_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(sub_tree, hf_smb2_fsctl_range_length, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
} else {
/* Zero or more allocated ranges may be reported. */
while (tvb_reported_length_remaining(tvb, offset) >= 16) {
sub_tree = proto_tree_add_subtree(tree, tvb, offset, 16, ett_smb2_fsctl_range_data, &sub_item, "Range");
proto_tree_add_item(sub_tree, hf_smb2_fsctl_range_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(sub_tree, hf_smb2_fsctl_range_length, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
}
}
}
static void
dissect_smb2_FSCTL_QUERY_FILE_REGIONS(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int offset _U_, gboolean data_in)
{
if (data_in) {
proto_tree_add_item(tree, hf_smb2_file_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(tree, hf_smb2_qfr_length, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(tree, hf_smb2_qfr_usage, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
} else {
guint32 entry_count = 0;
proto_tree_add_item(tree, hf_smb2_qfr_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_smb2_qfr_total_region_entry_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item_ret_uint(tree, hf_smb2_qfr_region_entry_count, tvb, offset, 4, ENC_LITTLE_ENDIAN, &entry_count);
offset += 4;
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
while (entry_count && tvb_reported_length_remaining(tvb, offset)) {
proto_tree *sub_tree;
proto_item *sub_item;
sub_tree = proto_tree_add_subtree(tree, tvb, offset, 24, ett_qfr_entry, &sub_item, "Entry");
proto_tree_add_item(sub_tree, hf_smb2_file_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(sub_tree, hf_smb2_qfr_length, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(sub_tree, hf_smb2_qfr_usage, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(sub_tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
entry_count--;
}
}
}
static void
dissect_smb2_FSCTL_LMR_REQUEST_RESILIENCY(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
{
/* There is no out data */
if (!data_in) {
return;
}
/* timeout */
proto_tree_add_item(tree, hf_smb2_ioctl_resiliency_timeout, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* reserved */
proto_tree_add_item(tree, hf_smb2_ioctl_resiliency_reserved, tvb, offset, 4, ENC_LITTLE_ENDIAN);
}
static void
dissect_smb2_FSCTL_QUERY_SHARED_VIRTUAL_DISK_SUPPORT(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
{
/* There is no in data */
if (data_in) {
return;
}
proto_tree_add_item(tree, hf_smb2_ioctl_shared_virtual_disk_support, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_smb2_ioctl_shared_virtual_disk_handle_state, tvb, offset, 4, ENC_LITTLE_ENDIAN);
}
#define STORAGE_QOS_CONTROL_FLAG_SET_LOGICAL_FLOW_ID 0x00000001
#define STORAGE_QOS_CONTROL_FLAG_SET_POLICY 0x00000002
#define STORAGE_QOS_CONTROL_FLAG_PROBE_POLICY 0x00000004
#define STORAGE_QOS_CONTROL_FLAG_GET_STATUS 0x00000008
#define STORAGE_QOS_CONTROL_FLAG_UPDATE_COUNTERS 0x00000010
static const value_string smb2_ioctl_sqos_protocol_version_vals[] = {
{ 0x0100, "Storage QoS Protocol Version 1.0" },
{ 0x0101, "Storage QoS Protocol Version 1.1" },
{ 0, NULL }
};
static const value_string smb2_ioctl_sqos_status_vals[] = {
{ 0x00, "StorageQoSStatusOk" },
{ 0x01, "StorageQoSStatusInsufficientThroughput" },
{ 0x02, "StorageQoSUnknownPolicyId" },
{ 0x04, "StorageQoSStatusConfigurationMismatch" },
{ 0x05, "StorageQoSStatusNotAvailable" },
{ 0, NULL }
};
static void
dissect_smb2_FSCTL_STORAGE_QOS_CONTROL(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, gboolean data_in)
{
static int * const operations[] = {
&hf_smb2_ioctl_sqos_op_set_logical_flow_id,
&hf_smb2_ioctl_sqos_op_set_policy,
&hf_smb2_ioctl_sqos_op_probe_policy,
&hf_smb2_ioctl_sqos_op_get_status,
&hf_smb2_ioctl_sqos_op_update_counters,
NULL
};
gint proto_ver;
/* Both request and reply have the same common header */
proto_ver = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_protocol_version, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_reserved, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_ioctl_sqos_options,
ett_smb2_ioctl_sqos_opeations, operations, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_logical_flow_id, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_policy_id, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_initiator_id, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
if (data_in) {
offset_length_buffer_t host_olb, node_olb;
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_limit, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_reservation, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
offset = dissect_smb2_olb_length_offset(tvb, offset, &host_olb, OLB_O_UINT16_S_UINT16, hf_smb2_ioctl_sqos_initiator_name);
offset = dissect_smb2_olb_length_offset(tvb, offset, &node_olb, OLB_O_UINT16_S_UINT16, hf_smb2_ioctl_sqos_initiator_node_name);
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_io_count_increment, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_normalized_io_count_increment, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_latency_increment, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_lower_latency_increment, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
if (proto_ver > 0x0100) {
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_bandwidth_limit, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_kilobyte_count_increment, tvb, offset, 8, ENC_LITTLE_ENDIAN);
/*offset += 8;*/
}
dissect_smb2_olb_string(pinfo, tree, tvb, &host_olb, OLB_TYPE_UNICODE_STRING);
dissect_smb2_olb_string(pinfo, tree, tvb, &node_olb, OLB_TYPE_UNICODE_STRING);
} else {
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_time_to_live, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_status, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_maximum_io_rate, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_minimum_io_rate, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_base_io_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_reserved2, tvb, offset, 4, ENC_LITTLE_ENDIAN);
if (proto_ver > 0x0100) {
offset += 4;
proto_tree_add_item(tree, hf_smb2_ioctl_sqos_maximum_bandwidth, tvb, offset, 8, ENC_LITTLE_ENDIAN);
}
}
}
static int
dissect_windows_sockaddr_in(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, int len)
{
proto_item *sub_item;
proto_tree *sub_tree;
proto_item *parent_item;
if (len == -1) {
len = 8;
}
sub_tree = proto_tree_add_subtree(parent_tree, tvb, offset, len, ett_windows_sockaddr, &sub_item, "Socket Address");
parent_item = proto_tree_get_parent(parent_tree);
/* family */
proto_tree_add_item(sub_tree, hf_windows_sockaddr_family, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* port */
proto_tree_add_item(sub_tree, hf_windows_sockaddr_port, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* IPv4 address */
proto_tree_add_item(sub_tree, hf_windows_sockaddr_in_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_item_append_text(sub_item, ", IPv4: %s", tvb_ip_to_str(pinfo->pool, tvb, offset));
proto_item_append_text(parent_item, ", IPv4: %s", tvb_ip_to_str(pinfo->pool, tvb, offset));
offset += 4;
return offset;
}
static int
dissect_windows_sockaddr_in6(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, int len)
{
proto_item *sub_item;
proto_tree *sub_tree;
proto_item *parent_item;
if (len == -1) {
len = 26;
}
sub_tree = proto_tree_add_subtree(parent_tree, tvb, offset, len, ett_windows_sockaddr, &sub_item, "Socket Address");
parent_item = proto_tree_get_parent(parent_tree);
/* family */
proto_tree_add_item(sub_tree, hf_windows_sockaddr_family, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* port */
proto_tree_add_item(sub_tree, hf_windows_sockaddr_port, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* sin6_flowinfo */
proto_tree_add_item(sub_tree, hf_windows_sockaddr_in6_flowinfo, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 4;
/* IPv6 address */
proto_tree_add_item(sub_tree, hf_windows_sockaddr_in6_addr, tvb, offset, 16, ENC_NA);
proto_item_append_text(sub_item, ", IPv6: %s", tvb_ip6_to_str(pinfo->pool, tvb, offset));
proto_item_append_text(parent_item, ", IPv6: %s", tvb_ip6_to_str(pinfo->pool, tvb, offset));
offset += 16;
/* sin6_scope_id */
proto_tree_add_item(sub_tree, hf_windows_sockaddr_in6_scope_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
static int
dissect_windows_sockaddr_storage(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, int len)
{
proto_item *sub_item;
proto_tree *sub_tree;
proto_item *parent_item;
guint16 family;
family = tvb_get_letohs(tvb, offset);
switch (family) {
case WINSOCK_AF_INET:
return dissect_windows_sockaddr_in(tvb, pinfo, parent_tree, offset, len);
case WINSOCK_AF_INET6:
return dissect_windows_sockaddr_in6(tvb, pinfo, parent_tree, offset, len);
}
sub_tree = proto_tree_add_subtree(parent_tree, tvb, offset, len, ett_windows_sockaddr, &sub_item, "Socket Address");
parent_item = proto_tree_get_parent(parent_tree);
/* ss_family */
proto_tree_add_item(sub_tree, hf_windows_sockaddr_family, tvb, offset, 2, ENC_LITTLE_ENDIAN);
proto_item_append_text(sub_item, ", Family: %d (0x%04x)", family, family);
proto_item_append_text(parent_item, ", Family: %d (0x%04x)", family, family);
return offset + len;
}
#define NETWORK_INTERFACE_CAP_RSS 0x00000001
#define NETWORK_INTERFACE_CAP_RDMA 0x00000002
static void
dissect_smb2_NETWORK_INTERFACE_INFO(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
{
guint32 next_offset;
int offset = 0;
int len = -1;
proto_item *sub_item;
proto_tree *sub_tree;
proto_item *item;
guint32 capabilities;
guint64 link_speed;
gfloat val = 0;
const char *unit = NULL;
static int * const capability_flags[] = {
&hf_smb2_ioctl_network_interface_capability_rdma,
&hf_smb2_ioctl_network_interface_capability_rss,
NULL
};
next_offset = tvb_get_letohl(tvb, offset);
if (next_offset) {
len = next_offset;
}
sub_tree = proto_tree_add_subtree(parent_tree, tvb, offset, len, ett_smb2_ioctl_network_interface, &sub_item, "Network Interface");
item = proto_tree_get_parent(parent_tree);
/* next offset */
proto_tree_add_item(sub_tree, hf_smb2_ioctl_network_interface_next_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* interface index */
proto_tree_add_item(sub_tree, hf_smb2_ioctl_network_interface_index, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* capabilities */
capabilities = tvb_get_letohl(tvb, offset);
proto_tree_add_bitmask(sub_tree, tvb, offset, hf_smb2_ioctl_network_interface_capabilities, ett_smb2_ioctl_network_interface_capabilities, capability_flags, ENC_LITTLE_ENDIAN);
if (capabilities != 0) {
proto_item_append_text(item, "%s%s",
(capabilities & NETWORK_INTERFACE_CAP_RDMA)?", RDMA":"",
(capabilities & NETWORK_INTERFACE_CAP_RSS)?", RSS":"");
proto_item_append_text(sub_item, "%s%s",
(capabilities & NETWORK_INTERFACE_CAP_RDMA)?", RDMA":"",
(capabilities & NETWORK_INTERFACE_CAP_RSS)?", RSS":"");
}
offset += 4;
/* rss queue count */
proto_tree_add_item(sub_tree, hf_smb2_ioctl_network_interface_rss_queue_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* link speed */
link_speed = tvb_get_letoh64(tvb, offset);
item = proto_tree_add_item(sub_tree, hf_smb2_ioctl_network_interface_link_speed, tvb, offset, 8, ENC_LITTLE_ENDIAN);
if (link_speed >= (1000*1000*1000)) {
val = (gfloat)(link_speed / (1000*1000*1000));
unit = "G";
} else if (link_speed >= (1000*1000)) {
val = (gfloat)(link_speed / (1000*1000));
unit = "M";
} else if (link_speed >= (1000)) {
val = (gfloat)(link_speed / (1000));
unit = "K";
} else {
val = (gfloat)(link_speed);
unit = "";
}
proto_item_append_text(item, ", %.1f %sBits/s", val, unit);
proto_item_append_text(sub_item, ", %.1f %sBits/s", val, unit);
offset += 8;
/* socket address */
dissect_windows_sockaddr_storage(tvb, pinfo, sub_tree, offset, -1);
if (next_offset) {
tvbuff_t *next_tvb;
next_tvb = tvb_new_subset_remaining(tvb, next_offset);
/* next extra info */
dissect_smb2_NETWORK_INTERFACE_INFO(next_tvb, pinfo, parent_tree);
}
}
static void
dissect_smb2_FSCTL_QUERY_NETWORK_INTERFACE_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset _U_, gboolean data_in)
{
/* There is no in data */
if (data_in) {
return;
}
dissect_smb2_NETWORK_INTERFACE_INFO(tvb, pinfo, tree);
}
static void
dissect_smb2_FSCTL_VALIDATE_NEGOTIATE_INFO_224(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset _U_, gboolean data_in)
{
/*
* This is only used by Windows 8 beta
*/
if (data_in) {
/* capabilities */
offset = dissect_smb2_capabilities(tree, tvb, offset);
/* client guid */
proto_tree_add_item(tree, hf_smb2_client_guid, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
/* security mode, skip second byte */
offset = dissect_smb2_secmode(tree, tvb, offset);
offset++;
/* dialect */
proto_tree_add_item(tree, hf_smb2_dialect, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
} else {
/* capabilities */
offset = dissect_smb2_capabilities(tree, tvb, offset);
/* server guid */
proto_tree_add_item(tree, hf_smb2_server_guid, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
/* security mode, skip second byte */
offset = dissect_smb2_secmode(tree, tvb, offset);
offset++;
/* dialect */
proto_tree_add_item(tree, hf_smb2_dialect, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
}
}
static void
dissect_smb2_FSCTL_VALIDATE_NEGOTIATE_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset _U_, gboolean data_in)
{
if (data_in) {
guint16 dc;
/* capabilities */
offset = dissect_smb2_capabilities(tree, tvb, offset);
/* client guid */
proto_tree_add_item(tree, hf_smb2_client_guid, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
/* security mode, skip second byte */
offset = dissect_smb2_secmode(tree, tvb, offset);
offset++;
/* dialect count */
dc = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb2_dialect_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
for ( ; dc>0; dc--) {
proto_tree_add_item(tree, hf_smb2_dialect, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
}
} else {
/* capabilities */
offset = dissect_smb2_capabilities(tree, tvb, offset);
/* server guid */
proto_tree_add_item(tree, hf_smb2_server_guid, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
/* security mode, skip second byte */
offset = dissect_smb2_secmode(tree, tvb, offset);
offset++;
/* dialect */
proto_tree_add_item(tree, hf_smb2_dialect, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
}
}
static void
dissect_smb2_FSCTL_SRV_ENUMERATE_SNAPSHOTS(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
{
guint32 num_snapshots;
/* There is no in data */
if (data_in) {
return;
}
/* NumberOfSnapShots */
proto_tree_add_item(tree, hf_smb2_ioctl_enumerate_snapshots_num_snapshots, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* NumberOfSnapshotsReturned */
proto_tree_add_item_ret_uint(tree, hf_smb2_ioctl_enumerate_snapshots_num_snapshots_returned, tvb, offset, 4, ENC_LITTLE_ENDIAN, &num_snapshots);
offset += 4;
/* SnapShotArraySize */
proto_tree_add_item(tree, hf_smb2_ioctl_enumerate_snapshots_snapshot_array_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
while (num_snapshots--) {
gint len;
int old_offset = offset;
proto_tree_add_item_ret_length(tree, hf_smb2_ioctl_enumerate_snapshots_snapshot,
tvb, offset, -1, ENC_UTF_16|ENC_LITTLE_ENDIAN, &len);
offset = old_offset+len;
}
}
int
dissect_smb2_FILE_OBJECTID_BUFFER(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
/* FILE_OBJECTID_BUFFER */
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_FILE_OBJECTID_BUFFER, tvb, offset, 64, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_FILE_OBJECTID_BUFFER);
}
/* Object ID */
proto_tree_add_item(tree, hf_smb2_object_id, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
/* Birth Volume ID */
proto_tree_add_item(tree, hf_smb2_birth_volume_id, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
/* Birth Object ID */
proto_tree_add_item(tree, hf_smb2_birth_object_id, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
/* Domain ID */
proto_tree_add_item(tree, hf_smb2_domain_id, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
return offset;
}
static int
dissect_smb2_FSCTL_CREATE_OR_GET_OBJECT_ID(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
{
/* There is no in data */
if (data_in) {
return offset;
}
/* FILE_OBJECTID_BUFFER */
offset = dissect_smb2_FILE_OBJECTID_BUFFER(tvb, pinfo, tree, offset);
return offset;
}
static int
dissect_smb2_FSCTL_GET_COMPRESSION(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
{
/* There is no in data */
if (data_in) {
return offset;
}
/* compression format */
proto_tree_add_item(tree, hf_smb2_compression_format, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
static int
dissect_smb2_FSCTL_SET_COMPRESSION(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
{
/* There is no out data */
if (!data_in) {
return offset;
}
/* compression format */
proto_tree_add_item(tree, hf_smb2_compression_format, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
return offset;
}
static int
dissect_smb2_FSCTL_SET_INTEGRITY_INFORMATION(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
{
static int * const integrity_flags[] = {
&hf_smb2_integrity_flags_enforcement_off,
NULL
};
/* There is no out data */
if (!data_in) {
return offset;
}
proto_tree_add_item(tree, hf_smb2_checksum_algorithm, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_smb2_integrity_reserved, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_integrity_flags, ett_smb2_integrity_flags, integrity_flags, ENC_LITTLE_ENDIAN);
offset += 4;
return offset;
}
static int
dissect_smb2_FSCTL_SET_OBJECT_ID(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
{
/* There is no out data */
if (!data_in) {
return offset;
}
/* FILE_OBJECTID_BUFFER */
offset = dissect_smb2_FILE_OBJECTID_BUFFER(tvb, pinfo, tree, offset);
return offset;
}
static int
dissect_smb2_FSCTL_SET_OBJECT_ID_EXTENDED(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
{
/* There is no out data */
if (!data_in) {
return offset;
}
/* FILE_OBJECTID_BUFFER->ExtendedInfo */
/* Birth Volume ID */
proto_tree_add_item(tree, hf_smb2_birth_volume_id, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
/* Birth Object ID */
proto_tree_add_item(tree, hf_smb2_birth_object_id, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
/* Domain ID */
proto_tree_add_item(tree, hf_smb2_domain_id, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
return offset;
}
static int
dissect_smb2_cchunk_RESUME_KEY(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
{
proto_tree_add_bytes_format_value(tree, hf_smb2_cchunk_resume_key, tvb,
offset, 24, NULL, "Opaque Data");
offset += 24;
return (offset);
}
static void
dissect_smb2_FSCTL_SRV_REQUEST_RESUME_KEY(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
{
/* There is no in data */
if (data_in) {
return;
}
offset = dissect_smb2_cchunk_RESUME_KEY(tvb, pinfo, tree, offset);
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
}
static void
dissect_smb2_FSCTL_SRV_COPYCHUNK(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, gboolean data_in)
{
proto_tree *sub_tree;
proto_item *sub_item;
guint32 chunk_count = 0;
/* Output is simpler - handle that first. */
if (!data_in) {
proto_tree_add_item(tree, hf_smb2_cchunk_chunks_written, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_smb2_cchunk_bytes_written, tvb, offset+4, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_smb2_cchunk_total_written, tvb, offset+8, 4, ENC_LITTLE_ENDIAN);
return;
}
/* Input data, fixed part */
offset = dissect_smb2_cchunk_RESUME_KEY(tvb, pinfo, tree, offset);
proto_tree_add_item_ret_uint(tree, hf_smb2_cchunk_count, tvb, offset, 4, ENC_LITTLE_ENDIAN, &chunk_count);
offset += 4;
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
/* Zero or more allocated ranges may be reported. */
while (chunk_count && tvb_reported_length_remaining(tvb, offset) >= 24) {
sub_tree = proto_tree_add_subtree(tree, tvb, offset, 24, ett_smb2_cchunk_entry, &sub_item, "Chunk");
proto_tree_add_item(sub_tree, hf_smb2_cchunk_src_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(sub_tree, hf_smb2_cchunk_dst_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(sub_tree, hf_smb2_cchunk_xfer_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(sub_tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
chunk_count--;
}
}
static void
dissect_smb2_reparse_nfs(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, guint32 length)
{
guint64 type;
int symlink_length;
type = tvb_get_letoh64(tvb, offset);
proto_tree_add_item(tree, hf_smb2_nfs_type, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
switch (type) {
case NFS_SPECFILE_LNK:
/*
* According to [MS-FSCC] 2.1.2.6 "length" contains
* the 8-byte type plus the symlink target in Unicode
* non-NULL terminated.
*/
if (length < 8) {
THROW(ReportedBoundsError);
}
symlink_length = length - 8;
proto_tree_add_item(tree, hf_smb2_nfs_symlink_target, tvb, offset,
symlink_length, ENC_UTF_16|ENC_LITTLE_ENDIAN);
break;
case NFS_SPECFILE_CHR:
proto_tree_add_item(tree, hf_smb2_nfs_chr_major, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_smb2_nfs_chr_minor, tvb, offset, 4, ENC_LITTLE_ENDIAN);
break;
case NFS_SPECFILE_BLK:
proto_tree_add_item(tree, hf_smb2_nfs_blk_major, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_smb2_nfs_blk_minor, tvb, offset, 4, ENC_LITTLE_ENDIAN);
break;
case NFS_SPECFILE_FIFO:
case NFS_SPECFILE_SOCK:
/* no data */
break;
}
}
static void
dissect_smb2_FSCTL_REPARSE_POINT(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint32 tag;
guint32 length;
offset_length_buffer_t s_olb, p_olb;
/* REPARSE_DATA_BUFFER */
if (parent_tree) {
item = proto_tree_add_item(parent_tree, hf_smb2_reparse_data_buffer, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2_reparse_data_buffer);
}
/* reparse tag */
tag = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_reparse_tag, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* reparse data length */
length = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb2_reparse_data_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
if (!(tag & 0x80000000)) {
/* if high bit is not set, this buffer has a GUID field */
/* reparse guid */
proto_tree_add_item(tree, hf_smb2_reparse_guid, tvb, offset, 16, ENC_NA);
offset += 16;
}
switch (tag) {
case REPARSE_TAG_SYMLINK:
/* substitute name offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &s_olb, OLB_O_UINT16_S_UINT16, hf_smb2_symlink_substitute_name);
/* print name offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &p_olb, OLB_O_UINT16_S_UINT16, hf_smb2_symlink_print_name);
/* flags */
proto_tree_add_item(tree, hf_smb2_symlink_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* substitute name string */
dissect_smb2_olb_off_string(pinfo, tree, tvb, &s_olb, offset, OLB_TYPE_UNICODE_STRING);
/* print name string */
dissect_smb2_olb_off_string(pinfo, tree, tvb, &p_olb, offset, OLB_TYPE_UNICODE_STRING);
break;
case REPARSE_TAG_NFS:
dissect_smb2_reparse_nfs(tvb, pinfo, tree, offset, length);
break;
default:
proto_tree_add_item(tree, hf_smb2_unknown, tvb, offset, length, ENC_NA);
}
}
static void
dissect_smb2_FSCTL_SET_REPARSE_POINT(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, gboolean data_in)
{
if (!data_in) {
return;
}
dissect_smb2_FSCTL_REPARSE_POINT(tvb, pinfo, parent_tree, offset);
}
static void
dissect_smb2_FSCTL_GET_REPARSE_POINT(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, int offset, gboolean data_in)
{
if (data_in) {
return;
}
dissect_smb2_FSCTL_REPARSE_POINT(tvb, pinfo, parent_tree, offset);
}
void
dissect_smb2_ioctl_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *top_tree, guint32 ioctl_function, gboolean data_in, void *private_data _U_)
{
guint16 dc;
dc = tvb_reported_length(tvb);
switch (ioctl_function) {
case 0x00060194: /* FSCTL_DFS_GET_REFERRALS */
if (data_in) {
dissect_get_dfs_request_data(tvb, pinfo, tree, 0, &dc, TRUE);
} else {
dissect_get_dfs_referral_data(tvb, pinfo, tree, 0, &dc, TRUE);
}
break;
case 0x000940CF: /* FSCTL_QUERY_ALLOCATED_RANGES */
dissect_smb2_FSCTL_QUERY_ALLOCATED_RANGES(tvb, pinfo, tree, 0, data_in);
break;
case 0x00094264: /* FSCTL_OFFLOAD_READ */
dissect_smb2_FSCTL_OFFLOAD_READ(tvb, pinfo, tree, 0, data_in);
break;
case 0x00098268: /* FSCTL_OFFLOAD_WRITE */
dissect_smb2_FSCTL_OFFLOAD_WRITE(tvb, pinfo, tree, 0, data_in);
break;
case 0x0011c017: /* FSCTL_PIPE_TRANSCEIVE */
dissect_smb2_FSCTL_PIPE_TRANSCEIVE(tvb, pinfo, tree, 0, top_tree, data_in, private_data);
break;
case 0x00110018: /* FSCTL_PIPE_WAIT */
dissect_smb2_FSCTL_PIPE_WAIT(tvb, pinfo, tree, 0, top_tree, data_in);
break;
case 0x00140078: /* FSCTL_SRV_REQUEST_RESUME_KEY */
dissect_smb2_FSCTL_SRV_REQUEST_RESUME_KEY(tvb, pinfo, tree, 0, data_in);
break;
case 0x001401D4: /* FSCTL_LMR_REQUEST_RESILIENCY */
dissect_smb2_FSCTL_LMR_REQUEST_RESILIENCY(tvb, pinfo, tree, 0, data_in);
break;
case 0x001401FC: /* FSCTL_QUERY_NETWORK_INTERFACE_INFO */
dissect_smb2_FSCTL_QUERY_NETWORK_INTERFACE_INFO(tvb, pinfo, tree, 0, data_in);
break;
case 0x00140200: /* FSCTL_VALIDATE_NEGOTIATE_INFO_224 */
dissect_smb2_FSCTL_VALIDATE_NEGOTIATE_INFO_224(tvb, pinfo, tree, 0, data_in);
break;
case 0x00140204: /* FSCTL_VALIDATE_NEGOTIATE_INFO */
dissect_smb2_FSCTL_VALIDATE_NEGOTIATE_INFO(tvb, pinfo, tree, 0, data_in);
break;
case 0x00144064: /* FSCTL_SRV_ENUMERATE_SNAPSHOTS */
dissect_smb2_FSCTL_SRV_ENUMERATE_SNAPSHOTS(tvb, pinfo, tree, 0, data_in);
break;
case 0x001440F2: /* FSCTL_SRV_COPYCHUNK */
case 0x001480F2: /* FSCTL_SRV_COPYCHUNK_WRITE */
dissect_smb2_FSCTL_SRV_COPYCHUNK(tvb, pinfo, tree, 0, data_in);
break;
case 0x000900A4: /* FSCTL_SET_REPARSE_POINT */
dissect_smb2_FSCTL_SET_REPARSE_POINT(tvb, pinfo, tree, 0, data_in);
break;
case 0x000900A8: /* FSCTL_GET_REPARSE_POINT */
dissect_smb2_FSCTL_GET_REPARSE_POINT(tvb, pinfo, tree, 0, data_in);
break;
case 0x0009009C: /* FSCTL_GET_OBJECT_ID */
case 0x000900c0: /* FSCTL_CREATE_OR_GET_OBJECT_ID */
dissect_smb2_FSCTL_CREATE_OR_GET_OBJECT_ID(tvb, pinfo, tree, 0, data_in);
break;
case 0x000900c4: /* FSCTL_SET_SPARSE */
dissect_smb2_FSCTL_SET_SPARSE(tvb, pinfo, tree, 0, data_in);
break;
case 0x00098098: /* FSCTL_SET_OBJECT_ID */
dissect_smb2_FSCTL_SET_OBJECT_ID(tvb, pinfo, tree, 0, data_in);
break;
case 0x000980BC: /* FSCTL_SET_OBJECT_ID_EXTENDED */
dissect_smb2_FSCTL_SET_OBJECT_ID_EXTENDED(tvb, pinfo, tree, 0, data_in);
break;
case 0x000980C8: /* FSCTL_SET_ZERO_DATA */
dissect_smb2_FSCTL_SET_ZERO_DATA(tvb, pinfo, tree, 0, data_in);
break;
case 0x0009003C: /* FSCTL_GET_COMPRESSION */
dissect_smb2_FSCTL_GET_COMPRESSION(tvb, pinfo, tree, 0, data_in);
break;
case 0x00090300: /* FSCTL_QUERY_SHARED_VIRTUAL_DISK_SUPPORT */
dissect_smb2_FSCTL_QUERY_SHARED_VIRTUAL_DISK_SUPPORT(tvb, pinfo, tree, 0, data_in);
break;
case 0x00090304: /* FSCTL_SVHDX_SYNC_TUNNEL or response */
case 0x00090364: /* FSCTL_SVHDX_ASYNC_TUNNEL or response */
call_dissector_with_data(rsvd_handle, tvb, pinfo, top_tree, &data_in);
break;
case 0x00090350: /* FSCTL_STORAGE_QOS_CONTROL */
dissect_smb2_FSCTL_STORAGE_QOS_CONTROL(tvb, pinfo, tree, 0, data_in);
break;
case 0x0009C040: /* FSCTL_SET_COMPRESSION */
dissect_smb2_FSCTL_SET_COMPRESSION(tvb, pinfo, tree, 0, data_in);
break;
case 0x00090284: /* FSCTL_QUERY_FILE_REGIONS */
dissect_smb2_FSCTL_QUERY_FILE_REGIONS(tvb, pinfo, tree, 0, data_in);
break;
case 0x0009C280: /* FSCTL_SET_INTEGRITY_INFORMATION request or response */
dissect_smb2_FSCTL_SET_INTEGRITY_INFORMATION(tvb, pinfo, tree, 0, data_in);
break;
default:
proto_tree_add_item(tree, hf_smb2_unknown, tvb, 0, tvb_captured_length(tvb), ENC_NA);
}
}
static void
dissect_smb2_ioctl_data_in(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
{
smb2_pipe_set_file_id(pinfo, si);
dissect_smb2_ioctl_data(tvb, pinfo, tree, si->top_tree, si->ioctl_function, TRUE, si);
}
static void
dissect_smb2_ioctl_data_out(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
{
smb2_pipe_set_file_id(pinfo, si);
dissect_smb2_ioctl_data(tvb, pinfo, tree, si->top_tree, si->ioctl_function, FALSE, si);
}
static int
dissect_smb2_ioctl_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
offset_length_buffer_t o_olb;
offset_length_buffer_t i_olb;
proto_tree *flags_tree = NULL;
proto_item *flags_item = NULL;
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* ioctl function */
offset = dissect_smb2_ioctl_function(tvb, pinfo, tree, offset, &si->ioctl_function);
/* fid */
offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
/* in buffer offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &i_olb, OLB_O_UINT32_S_UINT32, hf_smb2_ioctl_in_data);
/* max ioctl in size */
proto_tree_add_item(tree, hf_smb2_max_ioctl_in_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* out buffer offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &o_olb, OLB_O_UINT32_S_UINT32, hf_smb2_ioctl_out_data);
/* max ioctl out size */
proto_tree_add_item(tree, hf_smb2_max_ioctl_out_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* flags */
if (tree) {
flags_item = proto_tree_add_item(tree, hf_smb2_ioctl_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN);
flags_tree = proto_item_add_subtree(flags_item, ett_smb2_ioctl_flags);
}
proto_tree_add_item(flags_tree, hf_smb2_ioctl_is_fsctl, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
/* try to decode these blobs in the order they were encoded
* so that for "short" packets we will dissect as much as possible
* before aborting with "short packet"
*/
if (i_olb.off>o_olb.off) {
/* out buffer */
dissect_smb2_olb_buffer(pinfo, tree, tvb, &o_olb, si, dissect_smb2_ioctl_data_out);
/* in buffer */
dissect_smb2_olb_buffer(pinfo, tree, tvb, &i_olb, si, dissect_smb2_ioctl_data_in);
} else {
/* in buffer */
dissect_smb2_olb_buffer(pinfo, tree, tvb, &i_olb, si, dissect_smb2_ioctl_data_in);
/* out buffer */
dissect_smb2_olb_buffer(pinfo, tree, tvb, &o_olb, si, dissect_smb2_ioctl_data_out);
}
offset = dissect_smb2_olb_tvb_max_offset(offset, &o_olb);
offset = dissect_smb2_olb_tvb_max_offset(offset, &i_olb);
return offset;
}
static int
dissect_smb2_ioctl_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
offset_length_buffer_t o_olb;
offset_length_buffer_t i_olb;
gboolean continue_dissection;
switch (si->status) {
/* buffer code */
/* if we get BUFFER_OVERFLOW there will be truncated data */
case 0x80000005:
case 0x00000000: offset = dissect_smb2_buffercode(tree, tvb, offset, NULL); break;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* ioctl function */
offset = dissect_smb2_ioctl_function(tvb, pinfo, tree, offset, &si->ioctl_function);
/* fid */
offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
/* in buffer offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &i_olb, OLB_O_UINT32_S_UINT32, hf_smb2_ioctl_in_data);
/* out buffer offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &o_olb, OLB_O_UINT32_S_UINT32, hf_smb2_ioctl_out_data);
/* flags: reserved: must be zero */
proto_tree_add_item(tree, hf_smb2_flags, tvb, offset, 4, ENC_NA);
offset += 4;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
/* try to decode these blobs in the order they were encoded
* so that for "short" packets we will dissect as much as possible
* before aborting with "short packet"
*/
if (i_olb.off>o_olb.off) {
/* out buffer */
dissect_smb2_olb_buffer(pinfo, tree, tvb, &o_olb, si, dissect_smb2_ioctl_data_out);
/* in buffer */
dissect_smb2_olb_buffer(pinfo, tree, tvb, &i_olb, si, dissect_smb2_ioctl_data_in);
} else {
/* in buffer */
dissect_smb2_olb_buffer(pinfo, tree, tvb, &i_olb, si, dissect_smb2_ioctl_data_in);
/* out buffer */
dissect_smb2_olb_buffer(pinfo, tree, tvb, &o_olb, si, dissect_smb2_ioctl_data_out);
}
offset = dissect_smb2_olb_tvb_max_offset(offset, &i_olb);
offset = dissect_smb2_olb_tvb_max_offset(offset, &o_olb);
return offset;
}
#define SMB2_READFLAG_READ_UNBUFFERED 0x01
#define SMB2_READFLAG_READ_COMPRESSED 0x02
static const true_false_string tfs_read_unbuffered = {
"Client is asking for UNBUFFERED read",
"Client is NOT asking for UNBUFFERED read"
};
static const true_false_string tfs_read_compressed = {
"Client is asking for COMPRESSED data",
"Client is NOT asking for COMPRESSED data"
};
static int
dissect_smb2_read_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
offset_length_buffer_t c_olb;
guint32 channel;
guint32 len;
guint64 off;
static int * const flags[] = {
&hf_smb2_read_flags_unbuffered,
&hf_smb2_read_flags_compressed,
NULL
};
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* padding */
proto_tree_add_item(tree, hf_smb2_read_padding, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* flags */
proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_read_flags,
ett_smb2_read_flags, flags, ENC_LITTLE_ENDIAN);
offset += 1;
/* length */
len = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_read_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* offset */
off = tvb_get_letoh64(tvb, offset);
proto_tree_add_item(tree, hf_smb2_file_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
col_append_fstr(pinfo->cinfo, COL_INFO, " Len:%d Off:%" PRIu64, len, off);
/* fid */
offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
/* minimum count */
proto_tree_add_item(tree, hf_smb2_min_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* channel */
channel = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_channel, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* remaining bytes */
proto_tree_add_item(tree, hf_smb2_remaining_bytes, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* read channel info blob offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &c_olb, OLB_O_UINT16_S_UINT16, hf_smb2_channel_info_blob);
/* the read channel info blob itself */
switch (channel) {
case SMB2_CHANNEL_RDMA_V1:
case SMB2_CHANNEL_RDMA_V1_INVALIDATE:
dissect_smb2_olb_buffer(pinfo, tree, tvb, &c_olb, si, dissect_smb2_rdma_v1_blob);
break;
case SMB2_CHANNEL_NONE:
default:
dissect_smb2_olb_buffer(pinfo, tree, tvb, &c_olb, si, NULL);
break;
}
offset = dissect_smb2_olb_tvb_max_offset(offset, &c_olb);
/* Store len and offset */
if (si->saved) {
si->saved->file_offset=off;
si->saved->bytes_moved=len;
}
return offset;
}
static void
dissect_smb2_read_blob(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
{
gint offset = 0;
gint length = tvb_captured_length_remaining(tvb, offset);
smb2_pipe_set_file_id(pinfo, si);
offset = dissect_file_data_smb2_pipe(tvb, pinfo, tree, offset, length, si->top_tree, si);
if (offset != 0) {
/* managed to dissect pipe data */
return;
}
/* data */
proto_tree_add_item(tree, hf_smb2_read_data, tvb, offset, length, ENC_NA);
}
static int
dissect_smb2_read_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si _U_)
{
offset_length_buffer_t olb;
guint32 data_tvb_len;
gboolean continue_dissection;
switch (si->status) {
/* buffer code */
case 0x00000000: offset = dissect_smb2_buffercode(tree, tvb, offset, NULL); break;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
/* data offset 8 bit, 8 bit reserved, length 32bit */
offset = dissect_smb2_olb_length_offset(tvb, offset, &olb,
OLB_O_UINT8_P_UINT8_S_UINT32,
hf_smb2_read_blob);
/* remaining */
proto_tree_add_item(tree, hf_smb2_read_remaining, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
data_tvb_len=(guint32)tvb_captured_length_remaining(tvb, offset);
dissect_smb2_olb_buffer(pinfo, tree, tvb, &olb, si, dissect_smb2_read_blob);
offset += MIN(olb.len, data_tvb_len);
if (have_tap_listener(smb2_eo_tap) && (data_tvb_len == olb.len)) {
if (si->saved && si->eo_file_info) { /* without this data we don't know wich file this belongs to */
feed_eo_smb2(tvb,pinfo,si,olb.off,olb.len,si->saved->file_offset);
}
}
return offset;
}
static void
report_create_context_malformed_buffer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const char *buffer_desc)
{
proto_tree_add_expert_format(tree, pinfo, &ei_smb2_bad_response, tvb, 0, -1,
"%s SHOULD NOT be generated", buffer_desc);
}
static void
dissect_smb2_ExtA_buffer_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
{
proto_item *item = NULL;
if (tree) {
item = proto_tree_get_parent(tree);
proto_item_append_text(item, ": SMB2_FILE_FULL_EA_INFO");
}
dissect_smb2_file_full_ea_info(tvb, pinfo, tree, 0, si);
}
static void
dissect_smb2_ExtA_buffer_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si _U_)
{
report_create_context_malformed_buffer(tvb, pinfo, tree, "ExtA Response");
}
static void
dissect_smb2_SecD_buffer_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
{
proto_item *item = NULL;
if (tree) {
item = proto_tree_get_parent(tree);
proto_item_append_text(item, ": SMB2_SEC_INFO_00");
}
dissect_smb2_sec_info_00(tvb, pinfo, tree, 0, si);
}
static void
dissect_smb2_SecD_buffer_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si _U_)
{
report_create_context_malformed_buffer(tvb, pinfo, tree, "SecD Response");
}
/*
* Add the timestamp to the info column and to the name of the file if
* we have not visited this packet before.
*/
static void
add_timestamp_to_info_col(tvbuff_t *tvb, packet_info *pinfo, smb2_info_t *si,
int offset)
{
guint32 filetime_high, filetime_low;
guint64 ft;
nstime_t ts;
filetime_low = tvb_get_letohl(tvb, offset);
filetime_high = tvb_get_letohl(tvb, offset + 4);
ft = ((guint64)filetime_high << 32) | filetime_low;
if (!filetime_to_nstime(&ts, ft)) {
return;
}
col_append_fstr(pinfo->cinfo, COL_INFO, "@%s",
abs_time_to_str(pinfo->pool, &ts, ABSOLUTE_TIME_UTC,
FALSE));
/* Append the timestamp */
if (!pinfo->fd->visited) {
if (si->saved && si->saved->extra_info_type == SMB2_EI_FILENAME) {
gchar *saved_name = (gchar *)si->saved->extra_info;
si->saved->extra_info = wmem_strdup_printf(wmem_file_scope(),
"%s@%s", (char *)saved_name,
abs_time_to_str(pinfo->pool, &ts,
ABSOLUTE_TIME_UTC, FALSE));
wmem_free(wmem_file_scope(), saved_name);
}
}
}
static void
dissect_smb2_TWrp_buffer_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
proto_item *item = NULL;
if (tree) {
item = proto_tree_get_parent(tree);
proto_item_append_text(item, ": Timestamp");
}
add_timestamp_to_info_col(tvb, pinfo, si, 0);
dissect_nt_64bit_time(tvb, tree, 0, hf_smb2_twrp_timestamp);
}
static void
dissect_smb2_TWrp_buffer_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
report_create_context_malformed_buffer(tvb, pinfo, tree, "TWrp Response");
}
static void
dissect_smb2_QFid_buffer_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
proto_item *item = NULL;
if (tree) {
item = proto_tree_get_parent(tree);
}
if (item) {
if (tvb_reported_length(tvb) == 0) {
proto_item_append_text(item, ": NO DATA");
} else {
proto_item_append_text(item, ": QFid request should have no data, malformed packet");
}
}
}
static void
dissect_smb2_QFid_buffer_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item;
proto_item *sub_tree;
item = proto_tree_get_parent(tree);
proto_item_append_text(item, ": QFid INFO");
sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb2_QFid_buffer, NULL, "QFid INFO");
proto_tree_add_item(sub_tree, hf_smb2_qfid_fid, tvb, offset, 32, ENC_NA);
}
static void
dissect_smb2_AlSi_buffer_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, 0, 8, ENC_LITTLE_ENDIAN);
}
static void
dissect_smb2_AlSi_buffer_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
report_create_context_malformed_buffer(tvb, pinfo, tree, "AlSi Response");
}
static void
dissect_smb2_DHnQ_buffer_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
{
dissect_smb2_fid(tvb, pinfo, tree, 0, si, FID_MODE_DHNQ);
}
static void
dissect_smb2_DHnQ_buffer_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
proto_tree_add_item(tree, hf_smb2_dhnq_buffer_reserved, tvb, 0, 8, ENC_LITTLE_ENDIAN);
}
static void
dissect_smb2_DHnC_buffer_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
{
dissect_smb2_fid(tvb, pinfo, tree, 0, si, FID_MODE_DHNC);
}
static void
dissect_smb2_DHnC_buffer_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si _U_)
{
report_create_context_malformed_buffer(tvb, pinfo, tree, "DHnC Response");
}
/*
* SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2
* 4 - timeout
* 4 - flags
* 8 - reserved
* 16 - create guid
*
* SMB2_CREATE_DURABLE_HANDLE_RESPONSE_V2
* 4 - timeout
* 4 - flags
*
* SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2
* 16 - file id
* 16 - create guid
* 4 - flags
*
* SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2
* - nothing -
*/
#define SMB2_DH2X_FLAGS_PERSISTENT_HANDLE 0x00000002
static void
dissect_smb2_DH2Q_buffer_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
static int * const dh2x_flags_fields[] = {
&hf_smb2_dh2x_buffer_flags_persistent_handle,
NULL
};
int offset = 0;
proto_item *item;
proto_item *sub_tree;
item = proto_tree_get_parent(tree);
proto_item_append_text(item, ": DH2Q Request");
sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb2_DH2Q_buffer, NULL, "DH2Q Request");
/* timeout */
proto_tree_add_item(sub_tree, hf_smb2_dh2x_buffer_timeout, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* flags */
proto_tree_add_bitmask(sub_tree, tvb, offset, hf_smb2_dh2x_buffer_flags,
ett_smb2_dh2x_flags, dh2x_flags_fields, ENC_LITTLE_ENDIAN);
offset += 4;
/* reserved */
proto_tree_add_item(sub_tree, hf_smb2_dh2x_buffer_reserved, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* create guid */
proto_tree_add_item(sub_tree, hf_smb2_dh2x_buffer_create_guid, tvb, offset, 16, ENC_LITTLE_ENDIAN);
}
static void
dissect_smb2_DH2Q_buffer_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item;
proto_item *sub_tree;
item = proto_tree_get_parent(tree);
proto_item_append_text(item, ": DH2Q Response");
sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb2_DH2Q_buffer, NULL, "DH2Q Response");
/* timeout */
proto_tree_add_item(sub_tree, hf_smb2_dh2x_buffer_timeout, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* flags */
proto_tree_add_item(sub_tree, hf_smb2_dh2x_buffer_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN);
}
static void
dissect_smb2_DH2C_buffer_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si)
{
int offset = 0;
proto_item *item;
proto_item *sub_tree;
item = proto_tree_get_parent(tree);
proto_item_append_text(item, ": DH2C Request");
sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb2_DH2C_buffer, NULL, "DH2C Request");
/* file id */
dissect_smb2_fid(tvb, pinfo, sub_tree, offset, si, FID_MODE_DHNC);
offset += 16;
/* create guid */
proto_tree_add_item(sub_tree, hf_smb2_dh2x_buffer_create_guid, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
/* flags */
proto_tree_add_item(sub_tree, hf_smb2_dh2x_buffer_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN);
}
static void
dissect_smb2_DH2C_buffer_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si _U_)
{
report_create_context_malformed_buffer(tvb, pinfo, tree, "DH2C Response");
}
static void
dissect_smb2_MxAc_buffer_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item = NULL;
if (tree) {
item = proto_tree_get_parent(tree);
}
if (tvb_reported_length(tvb) == 0) {
if (item) {
proto_item_append_text(item, ": NO DATA");
}
return;
}
if (item) {
proto_item_append_text(item, ": Timestamp");
}
dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_mxac_timestamp);
}
static void
dissect_smb2_MxAc_buffer_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item;
proto_tree *sub_tree;
item = proto_tree_get_parent(tree);
if (tvb_reported_length(tvb) == 0) {
proto_item_append_text(item, ": NO DATA");
return;
}
proto_item_append_text(item, ": MxAc INFO");
sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb2_MxAc_buffer, NULL, "MxAc INFO");
proto_tree_add_item(sub_tree, hf_smb2_mxac_status, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
dissect_smb_access_mask(tvb, sub_tree, offset);
}
/*
* SMB2_CREATE_REQUEST_LEASE 32
* 16 - lease key
* 4 - lease state
* 4 - lease flags
* 8 - lease duration
*
* SMB2_CREATE_REQUEST_LEASE_V2 52
* 16 - lease key
* 4 - lease state
* 4 - lease flags
* 8 - lease duration
* 16 - parent lease key
* 2 - epoch
* 2 - reserved
*/
#define SMB2_LEASE_STATE_READ_CACHING 0x00000001
#define SMB2_LEASE_STATE_HANDLE_CACHING 0x00000002
#define SMB2_LEASE_STATE_WRITE_CACHING 0x00000004
#define SMB2_LEASE_FLAGS_BREAK_ACK_REQUIRED 0x00000001
#define SMB2_LEASE_FLAGS_BREAK_IN_PROGRESS 0x00000002
#define SMB2_LEASE_FLAGS_PARENT_LEASE_KEY_SET 0x00000004
static int * const lease_state_fields[] = {
&hf_smb2_lease_state_read_caching,
&hf_smb2_lease_state_handle_caching,
&hf_smb2_lease_state_write_caching,
NULL
};
static int * const lease_flags_fields[] = {
&hf_smb2_lease_flags_break_ack_required,
&hf_smb2_lease_flags_break_in_progress,
&hf_smb2_lease_flags_parent_lease_key_set,
NULL
};
static void
dissect_SMB2_CREATE_LEASE_VX(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, smb2_info_t *si _U_)
{
int offset = 0;
int len;
proto_tree *sub_tree = NULL;
proto_item *parent_item;
parent_item = proto_tree_get_parent(parent_tree);
len = tvb_reported_length(tvb);
switch (len) {
case 32: /* SMB2_CREATE_REQUEST/RESPONSE_LEASE */
proto_item_append_text(parent_item, ": LEASE_V1");
sub_tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_smb2_RqLs_buffer, NULL, "LEASE_V1");
break;
case 52: /* SMB2_CREATE_REQUEST/RESPONSE_LEASE_V2 */
proto_item_append_text(parent_item, ": LEASE_V2");
sub_tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_smb2_RqLs_buffer, NULL, "LEASE_V2");
break;
default:
report_create_context_malformed_buffer(tvb, pinfo, parent_tree, "RqLs");
break;
}
proto_tree_add_item(sub_tree, hf_smb2_lease_key, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
proto_tree_add_bitmask(sub_tree, tvb, offset, hf_smb2_lease_state,
ett_smb2_lease_state, lease_state_fields, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_bitmask(sub_tree, tvb, offset, hf_smb2_lease_flags,
ett_smb2_lease_flags, lease_flags_fields, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(sub_tree, hf_smb2_lease_duration, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
if (len < 52) {
return;
}
proto_tree_add_item(sub_tree, hf_smb2_parent_lease_key, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
proto_tree_add_item(sub_tree, hf_smb2_lease_epoch, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(sub_tree, hf_smb2_lease_reserved, tvb, offset, 2, ENC_LITTLE_ENDIAN);
}
static void
dissect_smb2_RqLs_buffer_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
dissect_SMB2_CREATE_LEASE_VX(tvb, pinfo, tree, si);
}
static void
dissect_smb2_RqLs_buffer_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
dissect_SMB2_CREATE_LEASE_VX(tvb, pinfo, tree, si);
}
/*
* SMB2_CREATE_APP_INSTANCE_ID
* 2 - structure size - 20
* 2 - reserved
* 16 - application guid
*/
static void
dissect_smb2_APP_INSTANCE_buffer_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item;
proto_item *sub_tree;
item = proto_tree_get_parent(tree);
proto_item_append_text(item, ": CREATE APP INSTANCE ID");
sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb2_APP_INSTANCE_buffer, NULL, "APP INSTANCE ID");
/* struct size */
proto_tree_add_item(sub_tree, hf_smb2_APP_INSTANCE_buffer_struct_size,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* reserved */
proto_tree_add_item(sub_tree, hf_smb2_APP_INSTANCE_buffer_reserved,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* create guid */
proto_tree_add_item(sub_tree, hf_smb2_APP_INSTANCE_buffer_app_guid, tvb, offset, 16, ENC_LITTLE_ENDIAN);
}
static void
dissect_smb2_APP_INSTANCE_buffer_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
report_create_context_malformed_buffer(tvb, pinfo, tree, "APP INSTANCE Response");
}
/*
* Dissect the MS-RSVD stuff that turns up when HyperV uses SMB3.x
*/
static void
dissect_smb2_svhdx_open_device_context(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
int offset = 0;
guint32 version;
proto_item *item;
proto_item *sub_tree;
item = proto_tree_get_parent(tree);
proto_item_append_text(item, ": SVHDX OPEN DEVICE CONTEXT");
sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb2_svhdx_open_device_context, NULL, "SVHDX OPEN DEVICE CONTEXT");
/* Version */
proto_tree_add_item_ret_uint(sub_tree, hf_smb2_svhdx_open_device_context_version,
tvb, offset, 4, ENC_LITTLE_ENDIAN, &version);
offset += 4;
/* HasInitiatorId */
proto_tree_add_item(sub_tree, hf_smb2_svhdx_open_device_context_has_initiator_id,
tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* Reserved */
proto_tree_add_item(sub_tree, hf_smb2_svhdx_open_device_context_reserved,
tvb, offset, 3, ENC_NA);
offset += 3;
/* InitiatorId */
proto_tree_add_item(sub_tree, hf_smb2_svhdx_open_device_context_initiator_id,
tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
/* Flags TODO: Dissect these*/
proto_tree_add_item(sub_tree, hf_smb2_svhdx_open_device_context_flags,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* OriginatorFlags */
proto_tree_add_item(sub_tree, hf_smb2_svhdx_open_device_context_originator_flags,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* OpenRequestId */
proto_tree_add_item(sub_tree, hf_smb2_svhdx_open_device_context_open_request_id,
tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* InitiatorHostNameLength */
proto_tree_add_item(sub_tree, hf_smb2_svhdx_open_device_context_initiator_host_name_len,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* InitiatorHostName */
proto_tree_add_item(sub_tree, hf_smb2_svhdx_open_device_context_initiator_host_name,
tvb, offset, 126, ENC_ASCII | ENC_NA);
offset += 126;
if (version == 2) {
/* VirtualDiskPropertiesInitialized */
proto_tree_add_item(sub_tree, hf_smb2_svhdx_open_device_context_virtual_disk_properties_initialized,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* ServerServiceVersion */
proto_tree_add_item(sub_tree, hf_smb2_svhdx_open_device_context_server_service_version,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* VirtualSectorSize */
proto_tree_add_item(sub_tree, hf_smb2_svhdx_open_device_context_virtual_sector_size,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* PhysicalSectorSize */
proto_tree_add_item(sub_tree, hf_smb2_svhdx_open_device_context_physical_sector_size,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* VirtualSize */
proto_tree_add_item(sub_tree, hf_smb2_svhdx_open_device_context_virtual_size,
tvb, offset, 8, ENC_LITTLE_ENDIAN);
}
}
/*
* SMB2_CREATE_APP_INSTANCE_VERSION
* 2 - structure size - 24
* 2 - reserved
* 4 - padding
* 8 - AppInstanceVersionHigh
* 8 - AppInstanceVersionHigh
*/
static void
dissect_smb2_app_instance_version_buffer_request(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item;
proto_item *sub_tree;
proto_item *version_sub_tree;
guint64 version_high;
guint64 version_low;
item = proto_tree_get_parent(tree);
proto_item_append_text(item, ": CREATE APP INSTANCE VERSION");
sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb2_app_instance_version_buffer, NULL, "APP INSTANCE VERSION");
/* struct size */
proto_tree_add_item(sub_tree, hf_smb2_app_instance_version_struct_size,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* reserved */
proto_tree_add_item(sub_tree, hf_smb2_app_instance_version_reserved,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* padding */
proto_tree_add_item(sub_tree, hf_smb2_app_instance_version_padding,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
version_sub_tree = proto_tree_add_subtree(sub_tree, tvb, offset, -1, ett_smb2_app_instance_version_buffer_version, NULL, "version");
/* version high */
proto_tree_add_item_ret_uint64(version_sub_tree, hf_smb2_app_instance_version_high,
tvb, offset, 8, ENC_LITTLE_ENDIAN, &version_high);
offset += 8;
/* version low */
proto_tree_add_item_ret_uint64(version_sub_tree, hf_smb2_app_instance_version_low,
tvb, offset, 8, ENC_LITTLE_ENDIAN, &version_low);
proto_item_append_text(version_sub_tree, " : %" PRIu64 ".%" PRIu64, version_high, version_low);
proto_item_append_text(sub_tree, ", version: %" PRIu64 ".%" PRIu64, version_high, version_low);
}
static void
dissect_smb2_app_instance_version_buffer_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, smb2_info_t *si _U_)
{
report_create_context_malformed_buffer(tvb, pinfo, tree, "APP INSTANCE Version Response");
}
static void
dissect_smb2_posix_buffer_request(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item;
item = proto_tree_get_parent(tree);
proto_item_append_text(item, ": POSIX Create Context request");
/* POSIX mode bits */
proto_tree_add_item(tree, hf_smb2_posix_perms, tvb, offset, 4, ENC_LITTLE_ENDIAN);
}
static void
dissect_smb2_posix_buffer_response(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item;
item = proto_tree_get_parent(tree);
proto_item_append_text(item, ": POSIX Create Context response");
/* Hardlinks */
proto_tree_add_item(tree, hf_smb2_nlinks, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* Reparse tag */
proto_tree_add_item(tree, hf_smb2_reparse_tag, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* POSIX mode bits */
proto_tree_add_item(tree, hf_smb2_posix_perms, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* Owner and Group SID */
offset = dissect_nt_sid(tvb, offset, tree, "Owner SID", NULL, -1);
dissect_nt_sid(tvb, offset, tree, "Group SID", NULL, -1);
}
#define SMB2_AAPL_SERVER_QUERY 1
#define SMB2_AAPL_RESOLVE_ID 2
static const value_string aapl_command_code_vals[] = {
{ SMB2_AAPL_SERVER_QUERY, "Server query"},
{ SMB2_AAPL_RESOLVE_ID, "Resolve ID"},
{ 0, NULL }
};
#define SMB2_AAPL_SERVER_CAPS 0x00000001
#define SMB2_AAPL_VOLUME_CAPS 0x00000002
#define SMB2_AAPL_MODEL_INFO 0x00000004
static int * const aapl_server_query_bitmap_fields[] = {
&hf_smb2_aapl_server_query_bitmask_server_caps,
&hf_smb2_aapl_server_query_bitmask_volume_caps,
&hf_smb2_aapl_server_query_bitmask_model_info,
NULL
};
#define SMB2_AAPL_SUPPORTS_READ_DIR_ATTR 0x00000001
#define SMB2_AAPL_SUPPORTS_OSX_COPYFILE 0x00000002
#define SMB2_AAPL_UNIX_BASED 0x00000004
#define SMB2_AAPL_SUPPORTS_NFS_ACE 0x00000008
static int * const aapl_server_query_caps_fields[] = {
&hf_smb2_aapl_server_query_caps_supports_read_dir_attr,
&hf_smb2_aapl_server_query_caps_supports_osx_copyfile,
&hf_smb2_aapl_server_query_caps_unix_based,
&hf_smb2_aapl_server_query_caps_supports_nfs_ace,
NULL
};
static void
dissect_smb2_AAPL_buffer_request(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item;
proto_item *sub_tree;
guint32 command_code;
item = proto_tree_get_parent(tree);
proto_item_append_text(item, ": AAPL Create Context request");
sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb2_aapl_create_context_request, NULL, "AAPL Create Context request");
/* Command code */
proto_tree_add_item_ret_uint(sub_tree, hf_smb2_aapl_command_code,
tvb, offset, 4, ENC_LITTLE_ENDIAN, &command_code);
offset += 4;
/* Reserved */
proto_tree_add_item(sub_tree, hf_smb2_aapl_reserved,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
switch (command_code) {
case SMB2_AAPL_SERVER_QUERY:
/* Request bitmap */
proto_tree_add_bitmask(sub_tree, tvb, offset,
hf_smb2_aapl_server_query_bitmask,
ett_smb2_aapl_server_query_bitmask,
aapl_server_query_bitmap_fields,
ENC_LITTLE_ENDIAN);
offset += 8;
/* Client capabilities */
proto_tree_add_bitmask(sub_tree, tvb, offset,
hf_smb2_aapl_server_query_caps,
ett_smb2_aapl_server_query_caps,
aapl_server_query_caps_fields,
ENC_LITTLE_ENDIAN);
break;
case SMB2_AAPL_RESOLVE_ID:
/* file ID */
proto_tree_add_item(sub_tree, hf_smb2_file_id, tvb, offset, 8, ENC_LITTLE_ENDIAN);
break;
default:
break;
}
}
#define SMB2_AAPL_SUPPORTS_RESOLVE_ID 0x00000001
#define SMB2_AAPL_CASE_SENSITIVE 0x00000002
#define SMB2_AAPL_SUPPORTS_FULL_SYNC 0x00000004
static int * const aapl_server_query_volume_caps_fields[] = {
&hf_smb2_aapl_server_query_volume_caps_support_resolve_id,
&hf_smb2_aapl_server_query_volume_caps_case_sensitive,
&hf_smb2_aapl_server_query_volume_caps_supports_full_sync,
NULL
};
static void
dissect_smb2_AAPL_buffer_response(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, smb2_info_t *si _U_)
{
int offset = 0;
proto_item *item;
proto_item *sub_tree;
guint32 command_code;
guint64 server_query_bitmask;
item = proto_tree_get_parent(tree);
proto_item_append_text(item, ": AAPL Create Context response");
sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb2_aapl_create_context_response, NULL, "AAPL Create Context response");
/* Command code */
proto_tree_add_item_ret_uint(sub_tree, hf_smb2_aapl_command_code,
tvb, offset, 4, ENC_LITTLE_ENDIAN, &command_code);
offset += 4;
/* Reserved */
proto_tree_add_item(sub_tree, hf_smb2_aapl_reserved,
tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
switch (command_code) {
case SMB2_AAPL_SERVER_QUERY:
/* Reply bitmap */
proto_tree_add_bitmask_ret_uint64(sub_tree, tvb, offset,
hf_smb2_aapl_server_query_bitmask,
ett_smb2_aapl_server_query_bitmask,
aapl_server_query_bitmap_fields,
ENC_LITTLE_ENDIAN,
&server_query_bitmask);
offset += 8;
if (server_query_bitmask & SMB2_AAPL_SERVER_CAPS) {
/* Server capabilities */
proto_tree_add_bitmask(sub_tree, tvb, offset,
hf_smb2_aapl_server_query_caps,
ett_smb2_aapl_server_query_caps,
aapl_server_query_caps_fields,
ENC_LITTLE_ENDIAN);
offset += 8;
}
if (server_query_bitmask & SMB2_AAPL_VOLUME_CAPS) {
/* Volume capabilities */
proto_tree_add_bitmask(sub_tree, tvb, offset,
hf_smb2_aapl_server_query_volume_caps,
ett_smb2_aapl_server_query_volume_caps,
aapl_server_query_volume_caps_fields,
ENC_LITTLE_ENDIAN);
offset += 8;
}
if (server_query_bitmask & SMB2_AAPL_MODEL_INFO) {
/* Padding */
offset += 4;
/* Model string */
proto_tree_add_item(sub_tree, hf_smb2_aapl_server_query_model_string,
tvb, offset, 4,
ENC_UTF_16|ENC_LITTLE_ENDIAN);
}
break;
case SMB2_AAPL_RESOLVE_ID:
/* NT status */
proto_tree_add_item(sub_tree, hf_smb2_nt_status, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* Server path */
proto_tree_add_item(sub_tree, hf_smb2_aapl_server_query_server_path,
tvb, offset, 4,
ENC_UTF_16|ENC_LITTLE_ENDIAN);
break;
default:
break;
}
}
typedef void (*create_context_data_dissector_t)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, smb2_info_t *si);
typedef struct create_context_data_dissectors {
create_context_data_dissector_t request;
create_context_data_dissector_t response;
} create_context_data_dissectors_t;
struct create_context_data_tag_dissectors {
const char *tag;
const char *val;
create_context_data_dissectors_t dissectors;
};
static struct create_context_data_tag_dissectors create_context_dissectors_array[] = {
{ "ExtA", "SMB2_CREATE_EA_BUFFER",
{ dissect_smb2_ExtA_buffer_request, dissect_smb2_ExtA_buffer_response } },
{ "SecD", "SMB2_CREATE_SD_BUFFER",
{ dissect_smb2_SecD_buffer_request, dissect_smb2_SecD_buffer_response } },
{ "AlSi", "SMB2_CREATE_ALLOCATION_SIZE",
{ dissect_smb2_AlSi_buffer_request, dissect_smb2_AlSi_buffer_response } },
{ "MxAc", "SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST",
{ dissect_smb2_MxAc_buffer_request, dissect_smb2_MxAc_buffer_response } },
{ "DHnQ", "SMB2_CREATE_DURABLE_HANDLE_REQUEST",
{ dissect_smb2_DHnQ_buffer_request, dissect_smb2_DHnQ_buffer_response } },
{ "DHnC", "SMB2_CREATE_DURABLE_HANDLE_RECONNECT",
{ dissect_smb2_DHnC_buffer_request, dissect_smb2_DHnC_buffer_response } },
{ "DH2Q", "SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2",
{ dissect_smb2_DH2Q_buffer_request, dissect_smb2_DH2Q_buffer_response } },
{ "DH2C", "SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2",
{ dissect_smb2_DH2C_buffer_request, dissect_smb2_DH2C_buffer_response } },
{ "TWrp", "SMB2_CREATE_TIMEWARP_TOKEN",
{ dissect_smb2_TWrp_buffer_request, dissect_smb2_TWrp_buffer_response } },
{ "QFid", "SMB2_CREATE_QUERY_ON_DISK_ID",
{ dissect_smb2_QFid_buffer_request, dissect_smb2_QFid_buffer_response } },
{ "RqLs", "SMB2_CREATE_REQUEST_LEASE",
{ dissect_smb2_RqLs_buffer_request, dissect_smb2_RqLs_buffer_response } },
{ "744D142E-46FA-0890-4AF7-A7EF6AA6BC45", "SMB2_CREATE_APP_INSTANCE_ID",
{ dissect_smb2_APP_INSTANCE_buffer_request, dissect_smb2_APP_INSTANCE_buffer_response } },
{ "6aa6bc45-a7ef-4af7-9008-fa462e144d74", "SMB2_CREATE_APP_INSTANCE_ID",
{ dissect_smb2_APP_INSTANCE_buffer_request, dissect_smb2_APP_INSTANCE_buffer_response } },
{ "9ecfcb9c-c104-43e6-980e-158da1f6ec83", "SVHDX_OPEN_DEVICE_CONTEXT",
{ dissect_smb2_svhdx_open_device_context, dissect_smb2_svhdx_open_device_context} },
{ "b7d082b9-563b-4f07-a07b-524a8116a010", "SMB2_CREATE_APP_INSTANCE_VERSION",
{ dissect_smb2_app_instance_version_buffer_request, dissect_smb2_app_instance_version_buffer_response } },
{ "5025ad93-b49c-e711-b423-83de968bcd7c", "SMB2_POSIX_CREATE_CONTEXT",
{ dissect_smb2_posix_buffer_request, dissect_smb2_posix_buffer_response } },
{ "AAPL", "SMB2_AAPL_CREATE_CONTEXT",
{ dissect_smb2_AAPL_buffer_request, dissect_smb2_AAPL_buffer_response } },
};
static struct create_context_data_tag_dissectors*
get_create_context_data_tag_dissectors(const char *tag)
{
static struct create_context_data_tag_dissectors INVALID = {
NULL, "<invalid>", { NULL, NULL }
};
size_t i;
for (i = 0; i<array_length(create_context_dissectors_array); i++) {
if (!strcmp(tag, create_context_dissectors_array[i].tag))
return &create_context_dissectors_array[i];
}
return &INVALID;
}
static void
dissect_smb2_create_extra_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, smb2_info_t *si)
{
offset_length_buffer_t tag_olb;
offset_length_buffer_t data_olb;
const guint8 *tag;
guint16 chain_offset;
int offset = 0;
int len = -1;
proto_item *sub_item;
proto_tree *sub_tree;
proto_item *parent_item = NULL;
create_context_data_dissectors_t *dissectors = NULL;
create_context_data_dissector_t dissector = NULL;
struct create_context_data_tag_dissectors *tag_dissectors;
chain_offset = tvb_get_letohl(tvb, offset);
if (chain_offset) {
len = chain_offset;
}
sub_tree = proto_tree_add_subtree(parent_tree, tvb, offset, len, ett_smb2_create_chain_element, &sub_item, "Chain Element");
parent_item = proto_tree_get_parent(parent_tree);
/* chain offset */
proto_tree_add_item(sub_tree, hf_smb2_create_chain_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* tag offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &tag_olb, OLB_O_UINT16_S_UINT32, hf_smb2_tag);
/* data offset/length */
dissect_smb2_olb_length_offset(tvb, offset, &data_olb, OLB_O_UINT16_S_UINT32, hf_smb2_create_chain_data);
/*
* These things are all either 4-char strings, like DH2C, or GUIDs,
* however, at least one of them appears to be a GUID as a string and
* one appears to be a binary guid. So, check if the length is
* 16, and if so, pull the GUID and convert it to a string. Otherwise
* call dissect_smb2_olb_string.
*/
if (tag_olb.len == 16) {
e_guid_t tag_guid;
proto_item *tag_item;
proto_tree *tag_tree;
tvb_get_letohguid(tvb, tag_olb.off, &tag_guid);
tag = guid_to_str(pinfo->pool, &tag_guid);
tag_item = proto_tree_add_string(sub_tree, tag_olb.hfindex, tvb, tag_olb.off, tag_olb.len, tag);
tag_tree = proto_item_add_subtree(tag_item, ett_smb2_olb);
proto_tree_add_item(tag_tree, hf_smb2_olb_offset, tvb, tag_olb.off_offset, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tag_tree, hf_smb2_olb_length, tvb, tag_olb.len_offset, 2, ENC_LITTLE_ENDIAN);
} else {
/* tag string */
tag = dissect_smb2_olb_string(pinfo, sub_tree, tvb, &tag_olb, OLB_TYPE_ASCII_STRING);
}
tag_dissectors = get_create_context_data_tag_dissectors(tag);
proto_item_append_text(parent_item, " %s", tag_dissectors->val);
proto_item_append_text(sub_item, ": %s \"%s\"", tag_dissectors->val, tag);
/* data */
dissectors = &tag_dissectors->dissectors;
if (dissectors)
dissector = (si->flags & SMB2_FLAGS_RESPONSE) ? dissectors->response : dissectors->request;
dissect_smb2_olb_buffer(pinfo, sub_tree, tvb, &data_olb, si, dissector);
if (chain_offset) {
tvbuff_t *chain_tvb;
chain_tvb = tvb_new_subset_remaining(tvb, chain_offset);
/* next extra info */
dissect_smb2_create_extra_info(chain_tvb, pinfo, parent_tree, si);
}
}
static int
dissect_smb2_create_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
offset_length_buffer_t f_olb, e_olb;
const guint8 *fname;
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* security flags */
offset++;
/* oplock */
offset = dissect_smb2_oplock(tree, tvb, offset);
/* impersonation level */
proto_tree_add_item(tree, hf_smb2_impersonation_level, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* create flags */
proto_tree_add_item(tree, hf_smb2_create_flags, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 8, ENC_NA);
offset += 8;
/* access mask */
offset = dissect_smb_access_mask(tvb, tree, offset);
/* File Attributes */
offset = dissect_fscc_file_attr(tvb, tree, offset, NULL);
/* share access */
offset = dissect_nt_share_access(tvb, tree, offset);
/* create disposition */
proto_tree_add_item(tree, hf_smb2_create_disposition, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* create options */
offset = dissect_nt_create_options(tvb, tree, offset);
/* filename offset/length */
offset = dissect_smb2_olb_length_offset(tvb, offset, &f_olb, OLB_O_UINT16_S_UINT16, hf_smb2_filename);
/* extrainfo offset */
offset = dissect_smb2_olb_length_offset(tvb, offset, &e_olb, OLB_O_UINT32_S_UINT32, hf_smb2_extrainfo);
/* filename string */
fname = dissect_smb2_olb_string(pinfo, tree, tvb, &f_olb, OLB_TYPE_UNICODE_STRING);
col_append_fstr(pinfo->cinfo, COL_INFO, " File: %s",
format_text(pinfo->pool, fname, strlen(fname)));
/* save the name if it looks sane */
if (!pinfo->fd->visited) {
if (si->saved && si->saved->extra_info_type == SMB2_EI_FILENAME) {
wmem_free(wmem_file_scope(), si->saved->extra_info);
si->saved->extra_info = NULL;
si->saved->extra_info_type = SMB2_EI_NONE;
}
if (si->saved && f_olb.len < 1024) {
si->saved->extra_info_type = SMB2_EI_FILENAME;
si->saved->extra_info = wmem_strdup(wmem_file_scope(), fname);
}
}
/* If extrainfo_offset is non-null then this points to another
* buffer. The offset is relative to the start of the smb packet
*/
dissect_smb2_olb_buffer(pinfo, tree, tvb, &e_olb, si, dissect_smb2_create_extra_info);
offset = dissect_smb2_olb_tvb_max_offset(offset, &f_olb);
offset = dissect_smb2_olb_tvb_max_offset(offset, &e_olb);
return offset;
}
#define SMB2_CREATE_REP_FLAGS_REPARSE_POINT 0x01
static int
dissect_smb2_create_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
guint64 end_of_file;
guint32 attr_mask;
offset_length_buffer_t e_olb;
static int * const create_rep_flags_fields[] = {
&hf_smb2_create_rep_flags_reparse_point,
NULL
};
gboolean continue_dissection;
switch (si->status) {
/* buffer code */
case 0x00000000: offset = dissect_smb2_buffercode(tree, tvb, offset, NULL); break;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
/* oplock */
offset = dissect_smb2_oplock(tree, tvb, offset);
/* reserved */
proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_create_rep_flags,
ett_smb2_create_rep_flags, create_rep_flags_fields, ENC_LITTLE_ENDIAN);
offset += 1;
/* create action */
proto_tree_add_item(tree, hf_smb2_create_action, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* create time */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_create_timestamp);
/* last access */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_access_timestamp);
/* last write */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_write_timestamp);
/* last change */
offset = dissect_nt_64bit_time(tvb, tree, offset, hf_smb2_last_change_timestamp);
/* allocation size */
proto_tree_add_item(tree, hf_smb2_allocation_size, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* end of file */
end_of_file = tvb_get_letoh64(tvb, offset);
if (si->eo_file_info) {
si->eo_file_info->end_of_file = tvb_get_letoh64(tvb, offset);
}
proto_tree_add_item(tree, hf_smb2_end_of_file, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* File Attributes */
offset = dissect_fscc_file_attr(tvb, tree, offset, &attr_mask);
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
/* fid */
offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_OPEN);
/* We save this after dissect_smb2_fid just because it would be
possible to have this response without having the mathing request.
In that case the entry in the file info hash table has been created
in dissect_smb2_fid */
if (si->eo_file_info) {
si->eo_file_info->end_of_file = end_of_file;
si->eo_file_info->attr_mask = attr_mask;
}
/* extrainfo offset */
offset = dissect_smb2_olb_length_offset(tvb, offset, &e_olb, OLB_O_UINT32_S_UINT32, hf_smb2_extrainfo);
/* If extrainfo_offset is non-null then this points to another
* buffer. The offset is relative to the start of the smb packet
*/
dissect_smb2_olb_buffer(pinfo, tree, tvb, &e_olb, si, dissect_smb2_create_extra_info);
offset = dissect_smb2_olb_tvb_max_offset(offset, &e_olb);
/* free si->saved->extra_info we don't need it any more */
if (si->saved && si->saved->extra_info_type == SMB2_EI_FILENAME) {
wmem_free(wmem_file_scope(), si->saved->extra_info);
si->saved->extra_info = NULL;
si->saved->extra_info_type = SMB2_EI_NONE;
}
return offset;
}
static int
dissect_smb2_setinfo_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
guint32 setinfo_size;
guint16 setinfo_offset;
/* buffer code */
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
/* class and info level */
offset = dissect_smb2_class_infolevel(pinfo, tvb, offset, tree, si);
/* size */
setinfo_size = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_smb2_setinfo_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* offset */
setinfo_offset = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_smb2_setinfo_offset, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* reserved */
proto_tree_add_item(tree, hf_smb2_setinfo_reserved, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
if (si->saved && si->saved->smb2_class == SMB2_CLASS_SEC_INFO) {
/* AdditionalInformation (4 bytes): Provides additional information to the server.
If security information is being set, this value MUST contain a 4-byte bit field
of flags indicating what security attributes MUST be applied. */
offset = dissect_additional_information_sec_mask(tvb, tree, offset);
} else {
/* For all other set requests, this field MUST be 0. */
proto_tree_add_item(tree, hf_smb2_getsetinfo_additional, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
/* fid */
dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
/* data */
if (si->saved)
dissect_smb2_infolevel(tvb, pinfo, tree, setinfo_offset, si, si->saved->smb2_class, si->saved->infolevel);
offset = setinfo_offset + setinfo_size;
return offset;
}
static int
dissect_smb2_setinfo_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
gboolean continue_dissection;
/* class/infolevel */
dissect_smb2_class_infolevel(pinfo, tvb, offset, tree, si);
switch (si->status) {
/* buffer code */
case 0x00000000: offset = dissect_smb2_buffercode(tree, tvb, offset, NULL); break;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
return offset;
}
static int
dissect_smb2_break_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
guint16 buffer_code;
/* buffer code */
buffer_code = tvb_get_letohs(tvb, offset);
offset = dissect_smb2_buffercode(tree, tvb, offset, NULL);
if (buffer_code == OPLOCK_BREAK_OPLOCK_STRUCTURE_SIZE) {
/* OPLOCK Break */
/* oplock */
offset = dissect_smb2_oplock(tree, tvb, offset);
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
/* fid */
offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
return offset;
}
if (buffer_code == OPLOCK_BREAK_LEASE_ACKNOWLEDGMENT_STRUCTURE_SIZE) {
/* Lease Break Acknowledgment */
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
offset +=2;
/* lease flags */
proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_lease_flags,
ett_smb2_lease_flags, lease_flags_fields, ENC_LITTLE_ENDIAN);
offset += 4;
/* lease key */
proto_tree_add_item(tree, hf_smb2_lease_key, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
/* lease state */
proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_lease_state,
ett_smb2_lease_state, lease_state_fields, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_smb2_lease_duration, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
return offset;
}
return offset;
}
static int
dissect_smb2_break_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si)
{
guint16 buffer_code;
gboolean continue_dissection;
/* buffer code */
buffer_code = tvb_get_letohs(tvb, offset);
switch (si->status) {
case 0x00000000: offset = dissect_smb2_buffercode(tree, tvb, offset, NULL); break;
default: offset = dissect_smb2_error_response(tvb, pinfo, tree, offset, si, &continue_dissection);
if (!continue_dissection) return offset;
}
if (buffer_code == OPLOCK_BREAK_OPLOCK_STRUCTURE_SIZE) {
/* OPLOCK Break Notification */
/* oplock */
offset = dissect_smb2_oplock(tree, tvb, offset);
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 4, ENC_NA);
offset += 4;
/* fid */
offset = dissect_smb2_fid(tvb, pinfo, tree, offset, si, FID_MODE_USE);
/* in break requests from server to client here're 24 byte zero bytes
* which are likely a bug in windows (they may use 2* 24 bytes instead of just
* 1 *24 bytes
*/
return offset;
}
if (buffer_code == OPLOCK_BREAK_LEASE_NOTIFICATION_STRUCTURE_SIZE) {
proto_item *item;
/* Lease Break Notification */
/* new lease epoch */
proto_tree_add_item(tree, hf_smb2_lease_epoch, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* lease flags */
proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_lease_flags,
ett_smb2_lease_flags, lease_flags_fields, ENC_LITTLE_ENDIAN);
offset += 4;
/* lease key */
proto_tree_add_item(tree, hf_smb2_lease_key, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
/* current lease state */
item = proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_lease_state,
ett_smb2_lease_state, lease_state_fields, ENC_LITTLE_ENDIAN);
if (item) {
proto_item_prepend_text(item, "Current ");
}
offset += 4;
/* new lease state */
item = proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_lease_state,
ett_smb2_lease_state, lease_state_fields, ENC_LITTLE_ENDIAN);
if (item) {
proto_item_prepend_text(item, "New ");
}
offset += 4;
/* break reason - reserved */
proto_tree_add_item(tree, hf_smb2_lease_break_reason, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* access mask hint - reserved */
proto_tree_add_item(tree, hf_smb2_lease_access_mask_hint, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* share mask hint - reserved */
proto_tree_add_item(tree, hf_smb2_lease_share_mask_hint, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
return offset;
}
if (buffer_code == OPLOCK_BREAK_LEASE_RESPONSE_STRUCTURE_SIZE) {
/* Lease Break Response */
/* reserved */
proto_tree_add_item(tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
offset +=2;
/* lease flags */
proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_lease_flags,
ett_smb2_lease_flags, lease_flags_fields, ENC_LITTLE_ENDIAN);
offset += 4;
/* lease key */
proto_tree_add_item(tree, hf_smb2_lease_key, tvb, offset, 16, ENC_LITTLE_ENDIAN);
offset += 16;
/* lease state */
proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_lease_state,
ett_smb2_lease_state, lease_state_fields, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_smb2_lease_duration, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
return offset;
}
return offset;
}
/* names here are just until we find better names for these functions */
static const value_string smb2_cmd_vals[] = {
{ 0x00, "Negotiate Protocol" },
{ 0x01, "Session Setup" },
{ 0x02, "Session Logoff" },
{ 0x03, "Tree Connect" },
{ 0x04, "Tree Disconnect" },
{ 0x05, "Create" },
{ 0x06, "Close" },
{ 0x07, "Flush" },
{ 0x08, "Read" },
{ 0x09, "Write" },
{ 0x0A, "Lock" },
{ 0x0B, "Ioctl" },
{ 0x0C, "Cancel" },
{ 0x0D, "KeepAlive" },
{ 0x0E, "Find" },
{ 0x0F, "Notify" },
{ 0x10, "GetInfo" },
{ 0x11, "SetInfo" },
{ 0x12, "Break" },
{ 0x13, "unknown-0x13" },
{ 0x14, "unknown-0x14" },
{ 0x15, "unknown-0x15" },
{ 0x16, "unknown-0x16" },
{ 0x17, "unknown-0x17" },
{ 0x18, "unknown-0x18" },
{ 0x19, "unknown-0x19" },
{ 0x1A, "unknown-0x1A" },
{ 0x1B, "unknown-0x1B" },
{ 0x1C, "unknown-0x1C" },
{ 0x1D, "unknown-0x1D" },
{ 0x1E, "unknown-0x1E" },
{ 0x1F, "unknown-0x1F" },
{ 0x20, "unknown-0x20" },
{ 0x21, "unknown-0x21" },
{ 0x22, "unknown-0x22" },
{ 0x23, "unknown-0x23" },
{ 0x24, "unknown-0x24" },
{ 0x25, "unknown-0x25" },
{ 0x26, "unknown-0x26" },
{ 0x27, "unknown-0x27" },
{ 0x28, "unknown-0x28" },
{ 0x29, "unknown-0x29" },
{ 0x2A, "unknown-0x2A" },
{ 0x2B, "unknown-0x2B" },
{ 0x2C, "unknown-0x2C" },
{ 0x2D, "unknown-0x2D" },
{ 0x2E, "unknown-0x2E" },
{ 0x2F, "unknown-0x2F" },
{ 0x30, "unknown-0x30" },
{ 0x31, "unknown-0x31" },
{ 0x32, "unknown-0x32" },
{ 0x33, "unknown-0x33" },
{ 0x34, "unknown-0x34" },
{ 0x35, "unknown-0x35" },
{ 0x36, "unknown-0x36" },
{ 0x37, "unknown-0x37" },
{ 0x38, "unknown-0x38" },
{ 0x39, "unknown-0x39" },
{ 0x3A, "unknown-0x3A" },
{ 0x3B, "unknown-0x3B" },
{ 0x3C, "unknown-0x3C" },
{ 0x3D, "unknown-0x3D" },
{ 0x3E, "unknown-0x3E" },
{ 0x3F, "unknown-0x3F" },
{ 0x40, "unknown-0x40" },
{ 0x41, "unknown-0x41" },
{ 0x42, "unknown-0x42" },
{ 0x43, "unknown-0x43" },
{ 0x44, "unknown-0x44" },
{ 0x45, "unknown-0x45" },
{ 0x46, "unknown-0x46" },
{ 0x47, "unknown-0x47" },
{ 0x48, "unknown-0x48" },
{ 0x49, "unknown-0x49" },
{ 0x4A, "unknown-0x4A" },
{ 0x4B, "unknown-0x4B" },
{ 0x4C, "unknown-0x4C" },
{ 0x4D, "unknown-0x4D" },
{ 0x4E, "unknown-0x4E" },
{ 0x4F, "unknown-0x4F" },
{ 0x50, "unknown-0x50" },
{ 0x51, "unknown-0x51" },
{ 0x52, "unknown-0x52" },
{ 0x53, "unknown-0x53" },
{ 0x54, "unknown-0x54" },
{ 0x55, "unknown-0x55" },
{ 0x56, "unknown-0x56" },
{ 0x57, "unknown-0x57" },
{ 0x58, "unknown-0x58" },
{ 0x59, "unknown-0x59" },
{ 0x5A, "unknown-0x5A" },
{ 0x5B, "unknown-0x5B" },
{ 0x5C, "unknown-0x5C" },
{ 0x5D, "unknown-0x5D" },
{ 0x5E, "unknown-0x5E" },
{ 0x5F, "unknown-0x5F" },
{ 0x60, "unknown-0x60" },
{ 0x61, "unknown-0x61" },
{ 0x62, "unknown-0x62" },
{ 0x63, "unknown-0x63" },
{ 0x64, "unknown-0x64" },
{ 0x65, "unknown-0x65" },
{ 0x66, "unknown-0x66" },
{ 0x67, "unknown-0x67" },
{ 0x68, "unknown-0x68" },
{ 0x69, "unknown-0x69" },
{ 0x6A, "unknown-0x6A" },
{ 0x6B, "unknown-0x6B" },
{ 0x6C, "unknown-0x6C" },
{ 0x6D, "unknown-0x6D" },
{ 0x6E, "unknown-0x6E" },
{ 0x6F, "unknown-0x6F" },
{ 0x70, "unknown-0x70" },
{ 0x71, "unknown-0x71" },
{ 0x72, "unknown-0x72" },
{ 0x73, "unknown-0x73" },
{ 0x74, "unknown-0x74" },
{ 0x75, "unknown-0x75" },
{ 0x76, "unknown-0x76" },
{ 0x77, "unknown-0x77" },
{ 0x78, "unknown-0x78" },
{ 0x79, "unknown-0x79" },
{ 0x7A, "unknown-0x7A" },
{ 0x7B, "unknown-0x7B" },
{ 0x7C, "unknown-0x7C" },
{ 0x7D, "unknown-0x7D" },
{ 0x7E, "unknown-0x7E" },
{ 0x7F, "unknown-0x7F" },
{ 0x80, "unknown-0x80" },
{ 0x81, "unknown-0x81" },
{ 0x82, "unknown-0x82" },
{ 0x83, "unknown-0x83" },
{ 0x84, "unknown-0x84" },
{ 0x85, "unknown-0x85" },
{ 0x86, "unknown-0x86" },
{ 0x87, "unknown-0x87" },
{ 0x88, "unknown-0x88" },
{ 0x89, "unknown-0x89" },
{ 0x8A, "unknown-0x8A" },
{ 0x8B, "unknown-0x8B" },
{ 0x8C, "unknown-0x8C" },
{ 0x8D, "unknown-0x8D" },
{ 0x8E, "unknown-0x8E" },
{ 0x8F, "unknown-0x8F" },
{ 0x90, "unknown-0x90" },
{ 0x91, "unknown-0x91" },
{ 0x92, "unknown-0x92" },
{ 0x93, "unknown-0x93" },
{ 0x94, "unknown-0x94" },
{ 0x95, "unknown-0x95" },
{ 0x96, "unknown-0x96" },
{ 0x97, "unknown-0x97" },
{ 0x98, "unknown-0x98" },
{ 0x99, "unknown-0x99" },
{ 0x9A, "unknown-0x9A" },
{ 0x9B, "unknown-0x9B" },
{ 0x9C, "unknown-0x9C" },
{ 0x9D, "unknown-0x9D" },
{ 0x9E, "unknown-0x9E" },
{ 0x9F, "unknown-0x9F" },
{ 0xA0, "unknown-0xA0" },
{ 0xA1, "unknown-0xA1" },
{ 0xA2, "unknown-0xA2" },
{ 0xA3, "unknown-0xA3" },
{ 0xA4, "unknown-0xA4" },
{ 0xA5, "unknown-0xA5" },
{ 0xA6, "unknown-0xA6" },
{ 0xA7, "unknown-0xA7" },
{ 0xA8, "unknown-0xA8" },
{ 0xA9, "unknown-0xA9" },
{ 0xAA, "unknown-0xAA" },
{ 0xAB, "unknown-0xAB" },
{ 0xAC, "unknown-0xAC" },
{ 0xAD, "unknown-0xAD" },
{ 0xAE, "unknown-0xAE" },
{ 0xAF, "unknown-0xAF" },
{ 0xB0, "unknown-0xB0" },
{ 0xB1, "unknown-0xB1" },
{ 0xB2, "unknown-0xB2" },
{ 0xB3, "unknown-0xB3" },
{ 0xB4, "unknown-0xB4" },
{ 0xB5, "unknown-0xB5" },
{ 0xB6, "unknown-0xB6" },
{ 0xB7, "unknown-0xB7" },
{ 0xB8, "unknown-0xB8" },
{ 0xB9, "unknown-0xB9" },
{ 0xBA, "unknown-0xBA" },
{ 0xBB, "unknown-0xBB" },
{ 0xBC, "unknown-0xBC" },
{ 0xBD, "unknown-0xBD" },
{ 0xBE, "unknown-0xBE" },
{ 0xBF, "unknown-0xBF" },
{ 0xC0, "unknown-0xC0" },
{ 0xC1, "unknown-0xC1" },
{ 0xC2, "unknown-0xC2" },
{ 0xC3, "unknown-0xC3" },
{ 0xC4, "unknown-0xC4" },
{ 0xC5, "unknown-0xC5" },
{ 0xC6, "unknown-0xC6" },
{ 0xC7, "unknown-0xC7" },
{ 0xC8, "unknown-0xC8" },
{ 0xC9, "unknown-0xC9" },
{ 0xCA, "unknown-0xCA" },
{ 0xCB, "unknown-0xCB" },
{ 0xCC, "unknown-0xCC" },
{ 0xCD, "unknown-0xCD" },
{ 0xCE, "unknown-0xCE" },
{ 0xCF, "unknown-0xCF" },
{ 0xD0, "unknown-0xD0" },
{ 0xD1, "unknown-0xD1" },
{ 0xD2, "unknown-0xD2" },
{ 0xD3, "unknown-0xD3" },
{ 0xD4, "unknown-0xD4" },
{ 0xD5, "unknown-0xD5" },
{ 0xD6, "unknown-0xD6" },
{ 0xD7, "unknown-0xD7" },
{ 0xD8, "unknown-0xD8" },
{ 0xD9, "unknown-0xD9" },
{ 0xDA, "unknown-0xDA" },
{ 0xDB, "unknown-0xDB" },
{ 0xDC, "unknown-0xDC" },
{ 0xDD, "unknown-0xDD" },
{ 0xDE, "unknown-0xDE" },
{ 0xDF, "unknown-0xDF" },
{ 0xE0, "unknown-0xE0" },
{ 0xE1, "unknown-0xE1" },
{ 0xE2, "unknown-0xE2" },
{ 0xE3, "unknown-0xE3" },
{ 0xE4, "unknown-0xE4" },
{ 0xE5, "unknown-0xE5" },
{ 0xE6, "unknown-0xE6" },
{ 0xE7, "unknown-0xE7" },
{ 0xE8, "unknown-0xE8" },
{ 0xE9, "unknown-0xE9" },
{ 0xEA, "unknown-0xEA" },
{ 0xEB, "unknown-0xEB" },
{ 0xEC, "unknown-0xEC" },
{ 0xED, "unknown-0xED" },
{ 0xEE, "unknown-0xEE" },
{ 0xEF, "unknown-0xEF" },
{ 0xF0, "unknown-0xF0" },
{ 0xF1, "unknown-0xF1" },
{ 0xF2, "unknown-0xF2" },
{ 0xF3, "unknown-0xF3" },
{ 0xF4, "unknown-0xF4" },
{ 0xF5, "unknown-0xF5" },
{ 0xF6, "unknown-0xF6" },
{ 0xF7, "unknown-0xF7" },
{ 0xF8, "unknown-0xF8" },
{ 0xF9, "unknown-0xF9" },
{ 0xFA, "unknown-0xFA" },
{ 0xFB, "unknown-0xFB" },
{ 0xFC, "unknown-0xFC" },
{ 0xFD, "unknown-0xFD" },
{ 0xFE, "unknown-0xFE" },
{ 0xFF, "unknown-0xFF" },
{ 0x00, NULL },
};
value_string_ext smb2_cmd_vals_ext = VALUE_STRING_EXT_INIT(smb2_cmd_vals);
static const char *decode_smb2_name(guint16 cmd)
{
if (cmd > 0xFF) return "unknown";
return(smb2_cmd_vals[cmd & 0xFF].strptr);
}
static smb2_function smb2_dissector[256] = {
/* 0x00 NegotiateProtocol*/
{dissect_smb2_negotiate_protocol_request,
dissect_smb2_negotiate_protocol_response},
/* 0x01 SessionSetup*/
{dissect_smb2_session_setup_request,
dissect_smb2_session_setup_response},
/* 0x02 SessionLogoff*/
{dissect_smb2_sessionlogoff_request,
dissect_smb2_sessionlogoff_response},
/* 0x03 TreeConnect*/
{dissect_smb2_tree_connect_request,
dissect_smb2_tree_connect_response},
/* 0x04 TreeDisconnect*/
{dissect_smb2_tree_disconnect_request,
dissect_smb2_tree_disconnect_response},
/* 0x05 Create*/
{dissect_smb2_create_request,
dissect_smb2_create_response},
/* 0x06 Close*/
{dissect_smb2_close_request,
dissect_smb2_close_response},
/* 0x07 Flush*/
{dissect_smb2_flush_request,
dissect_smb2_flush_response},
/* 0x08 Read*/
{dissect_smb2_read_request,
dissect_smb2_read_response},
/* 0x09 Writew*/
{dissect_smb2_write_request,
dissect_smb2_write_response},
/* 0x0a Lock */
{dissect_smb2_lock_request,
dissect_smb2_lock_response},
/* 0x0b Ioctl*/
{dissect_smb2_ioctl_request,
dissect_smb2_ioctl_response},
/* 0x0c Cancel*/
{dissect_smb2_cancel_request,
NULL},
/* 0x0d KeepAlive*/
{dissect_smb2_keepalive_request,
dissect_smb2_keepalive_response},
/* 0x0e Find*/
{dissect_smb2_find_request,
dissect_smb2_find_response},
/* 0x0f Notify*/
{dissect_smb2_notify_request,
dissect_smb2_notify_response},
/* 0x10 GetInfo*/
{dissect_smb2_getinfo_request,
dissect_smb2_getinfo_response},
/* 0x11 SetInfo*/
{dissect_smb2_setinfo_request,
dissect_smb2_setinfo_response},
/* 0x12 Break */
{dissect_smb2_break_request,
dissect_smb2_break_response},
/* 0x13 */ {NULL, NULL},
/* 0x14 */ {NULL, NULL},
/* 0x15 */ {NULL, NULL},
/* 0x16 */ {NULL, NULL},
/* 0x17 */ {NULL, NULL},
/* 0x18 */ {NULL, NULL},
/* 0x19 */ {NULL, NULL},
/* 0x1a */ {NULL, NULL},
/* 0x1b */ {NULL, NULL},
/* 0x1c */ {NULL, NULL},
/* 0x1d */ {NULL, NULL},
/* 0x1e */ {NULL, NULL},
/* 0x1f */ {NULL, NULL},
/* 0x20 */ {NULL, NULL},
/* 0x21 */ {NULL, NULL},
/* 0x22 */ {NULL, NULL},
/* 0x23 */ {NULL, NULL},
/* 0x24 */ {NULL, NULL},
/* 0x25 */ {NULL, NULL},
/* 0x26 */ {NULL, NULL},
/* 0x27 */ {NULL, NULL},
/* 0x28 */ {NULL, NULL},
/* 0x29 */ {NULL, NULL},
/* 0x2a */ {NULL, NULL},
/* 0x2b */ {NULL, NULL},
/* 0x2c */ {NULL, NULL},
/* 0x2d */ {NULL, NULL},
/* 0x2e */ {NULL, NULL},
/* 0x2f */ {NULL, NULL},
/* 0x30 */ {NULL, NULL},
/* 0x31 */ {NULL, NULL},
/* 0x32 */ {NULL, NULL},
/* 0x33 */ {NULL, NULL},
/* 0x34 */ {NULL, NULL},
/* 0x35 */ {NULL, NULL},
/* 0x36 */ {NULL, NULL},
/* 0x37 */ {NULL, NULL},
/* 0x38 */ {NULL, NULL},
/* 0x39 */ {NULL, NULL},
/* 0x3a */ {NULL, NULL},
/* 0x3b */ {NULL, NULL},
/* 0x3c */ {NULL, NULL},
/* 0x3d */ {NULL, NULL},
/* 0x3e */ {NULL, NULL},
/* 0x3f */ {NULL, NULL},
/* 0x40 */ {NULL, NULL},
/* 0x41 */ {NULL, NULL},
/* 0x42 */ {NULL, NULL},
/* 0x43 */ {NULL, NULL},
/* 0x44 */ {NULL, NULL},
/* 0x45 */ {NULL, NULL},
/* 0x46 */ {NULL, NULL},
/* 0x47 */ {NULL, NULL},
/* 0x48 */ {NULL, NULL},
/* 0x49 */ {NULL, NULL},
/* 0x4a */ {NULL, NULL},
/* 0x4b */ {NULL, NULL},
/* 0x4c */ {NULL, NULL},
/* 0x4d */ {NULL, NULL},
/* 0x4e */ {NULL, NULL},
/* 0x4f */ {NULL, NULL},
/* 0x50 */ {NULL, NULL},
/* 0x51 */ {NULL, NULL},
/* 0x52 */ {NULL, NULL},
/* 0x53 */ {NULL, NULL},
/* 0x54 */ {NULL, NULL},
/* 0x55 */ {NULL, NULL},
/* 0x56 */ {NULL, NULL},
/* 0x57 */ {NULL, NULL},
/* 0x58 */ {NULL, NULL},
/* 0x59 */ {NULL, NULL},
/* 0x5a */ {NULL, NULL},
/* 0x5b */ {NULL, NULL},
/* 0x5c */ {NULL, NULL},
/* 0x5d */ {NULL, NULL},
/* 0x5e */ {NULL, NULL},
/* 0x5f */ {NULL, NULL},
/* 0x60 */ {NULL, NULL},
/* 0x61 */ {NULL, NULL},
/* 0x62 */ {NULL, NULL},
/* 0x63 */ {NULL, NULL},
/* 0x64 */ {NULL, NULL},
/* 0x65 */ {NULL, NULL},
/* 0x66 */ {NULL, NULL},
/* 0x67 */ {NULL, NULL},
/* 0x68 */ {NULL, NULL},
/* 0x69 */ {NULL, NULL},
/* 0x6a */ {NULL, NULL},
/* 0x6b */ {NULL, NULL},
/* 0x6c */ {NULL, NULL},
/* 0x6d */ {NULL, NULL},
/* 0x6e */ {NULL, NULL},
/* 0x6f */ {NULL, NULL},
/* 0x70 */ {NULL, NULL},
/* 0x71 */ {NULL, NULL},
/* 0x72 */ {NULL, NULL},
/* 0x73 */ {NULL, NULL},
/* 0x74 */ {NULL, NULL},
/* 0x75 */ {NULL, NULL},
/* 0x76 */ {NULL, NULL},
/* 0x77 */ {NULL, NULL},
/* 0x78 */ {NULL, NULL},
/* 0x79 */ {NULL, NULL},
/* 0x7a */ {NULL, NULL},
/* 0x7b */ {NULL, NULL},
/* 0x7c */ {NULL, NULL},
/* 0x7d */ {NULL, NULL},
/* 0x7e */ {NULL, NULL},
/* 0x7f */ {NULL, NULL},
/* 0x80 */ {NULL, NULL},
/* 0x81 */ {NULL, NULL},
/* 0x82 */ {NULL, NULL},
/* 0x83 */ {NULL, NULL},
/* 0x84 */ {NULL, NULL},
/* 0x85 */ {NULL, NULL},
/* 0x86 */ {NULL, NULL},
/* 0x87 */ {NULL, NULL},
/* 0x88 */ {NULL, NULL},
/* 0x89 */ {NULL, NULL},
/* 0x8a */ {NULL, NULL},
/* 0x8b */ {NULL, NULL},
/* 0x8c */ {NULL, NULL},
/* 0x8d */ {NULL, NULL},
/* 0x8e */ {NULL, NULL},
/* 0x8f */ {NULL, NULL},
/* 0x90 */ {NULL, NULL},
/* 0x91 */ {NULL, NULL},
/* 0x92 */ {NULL, NULL},
/* 0x93 */ {NULL, NULL},
/* 0x94 */ {NULL, NULL},
/* 0x95 */ {NULL, NULL},
/* 0x96 */ {NULL, NULL},
/* 0x97 */ {NULL, NULL},
/* 0x98 */ {NULL, NULL},
/* 0x99 */ {NULL, NULL},
/* 0x9a */ {NULL, NULL},
/* 0x9b */ {NULL, NULL},
/* 0x9c */ {NULL, NULL},
/* 0x9d */ {NULL, NULL},
/* 0x9e */ {NULL, NULL},
/* 0x9f */ {NULL, NULL},
/* 0xa0 */ {NULL, NULL},
/* 0xa1 */ {NULL, NULL},
/* 0xa2 */ {NULL, NULL},
/* 0xa3 */ {NULL, NULL},
/* 0xa4 */ {NULL, NULL},
/* 0xa5 */ {NULL, NULL},
/* 0xa6 */ {NULL, NULL},
/* 0xa7 */ {NULL, NULL},
/* 0xa8 */ {NULL, NULL},
/* 0xa9 */ {NULL, NULL},
/* 0xaa */ {NULL, NULL},
/* 0xab */ {NULL, NULL},
/* 0xac */ {NULL, NULL},
/* 0xad */ {NULL, NULL},
/* 0xae */ {NULL, NULL},
/* 0xaf */ {NULL, NULL},
/* 0xb0 */ {NULL, NULL},
/* 0xb1 */ {NULL, NULL},
/* 0xb2 */ {NULL, NULL},
/* 0xb3 */ {NULL, NULL},
/* 0xb4 */ {NULL, NULL},
/* 0xb5 */ {NULL, NULL},
/* 0xb6 */ {NULL, NULL},
/* 0xb7 */ {NULL, NULL},
/* 0xb8 */ {NULL, NULL},
/* 0xb9 */ {NULL, NULL},
/* 0xba */ {NULL, NULL},
/* 0xbb */ {NULL, NULL},
/* 0xbc */ {NULL, NULL},
/* 0xbd */ {NULL, NULL},
/* 0xbe */ {NULL, NULL},
/* 0xbf */ {NULL, NULL},
/* 0xc0 */ {NULL, NULL},
/* 0xc1 */ {NULL, NULL},
/* 0xc2 */ {NULL, NULL},
/* 0xc3 */ {NULL, NULL},
/* 0xc4 */ {NULL, NULL},
/* 0xc5 */ {NULL, NULL},
/* 0xc6 */ {NULL, NULL},
/* 0xc7 */ {NULL, NULL},
/* 0xc8 */ {NULL, NULL},
/* 0xc9 */ {NULL, NULL},
/* 0xca */ {NULL, NULL},
/* 0xcb */ {NULL, NULL},
/* 0xcc */ {NULL, NULL},
/* 0xcd */ {NULL, NULL},
/* 0xce */ {NULL, NULL},
/* 0xcf */ {NULL, NULL},
/* 0xd0 */ {NULL, NULL},
/* 0xd1 */ {NULL, NULL},
/* 0xd2 */ {NULL, NULL},
/* 0xd3 */ {NULL, NULL},
/* 0xd4 */ {NULL, NULL},
/* 0xd5 */ {NULL, NULL},
/* 0xd6 */ {NULL, NULL},
/* 0xd7 */ {NULL, NULL},
/* 0xd8 */ {NULL, NULL},
/* 0xd9 */ {NULL, NULL},
/* 0xda */ {NULL, NULL},
/* 0xdb */ {NULL, NULL},
/* 0xdc */ {NULL, NULL},
/* 0xdd */ {NULL, NULL},
/* 0xde */ {NULL, NULL},
/* 0xdf */ {NULL, NULL},
/* 0xe0 */ {NULL, NULL},
/* 0xe1 */ {NULL, NULL},
/* 0xe2 */ {NULL, NULL},
/* 0xe3 */ {NULL, NULL},
/* 0xe4 */ {NULL, NULL},
/* 0xe5 */ {NULL, NULL},
/* 0xe6 */ {NULL, NULL},
/* 0xe7 */ {NULL, NULL},
/* 0xe8 */ {NULL, NULL},
/* 0xe9 */ {NULL, NULL},
/* 0xea */ {NULL, NULL},
/* 0xeb */ {NULL, NULL},
/* 0xec */ {NULL, NULL},
/* 0xed */ {NULL, NULL},
/* 0xee */ {NULL, NULL},
/* 0xef */ {NULL, NULL},
/* 0xf0 */ {NULL, NULL},
/* 0xf1 */ {NULL, NULL},
/* 0xf2 */ {NULL, NULL},
/* 0xf3 */ {NULL, NULL},
/* 0xf4 */ {NULL, NULL},
/* 0xf5 */ {NULL, NULL},
/* 0xf6 */ {NULL, NULL},
/* 0xf7 */ {NULL, NULL},
/* 0xf8 */ {NULL, NULL},
/* 0xf9 */ {NULL, NULL},
/* 0xfa */ {NULL, NULL},
/* 0xfb */ {NULL, NULL},
/* 0xfc */ {NULL, NULL},
/* 0xfd */ {NULL, NULL},
/* 0xfe */ {NULL, NULL},
/* 0xff */ {NULL, NULL},
};
#define SMB3_AES128CCM_NONCE 11
#define SMB3_AES128GCM_NONCE 12
static gboolean is_decrypted_header_ok(guint8 *p, size_t size)
{
if (size < 4)
return FALSE;
if ((p[0] == SMB2_COMP_HEADER || p[0] == SMB2_NORM_HEADER)
&& (p[1] == 'S' || p[2] == 'M' || p[3] == 'B')) {
return TRUE;
}
DEBUG("decrypt: bad SMB header");
return FALSE;
}
static gboolean
do_decrypt(guint8 *data,
size_t data_size,
const guint8 *key,
const guint8 *aad,
int aad_size,
const guint8 *nonce,
int alg)
{
gcry_error_t err;
gcry_cipher_hd_t cipher_hd = NULL;
int algo;
size_t keylen;
int mode;
int iv_size;
guint64 lengths[3];
switch (alg) {
case SMB2_CIPHER_AES_128_CCM:
algo = GCRY_CIPHER_AES128;
keylen = AES_KEY_SIZE;
mode = GCRY_CIPHER_MODE_CCM;
iv_size = SMB3_AES128CCM_NONCE;
break;
case SMB2_CIPHER_AES_128_GCM:
algo = GCRY_CIPHER_AES128;
keylen = AES_KEY_SIZE;
mode = GCRY_CIPHER_MODE_GCM;
iv_size = SMB3_AES128GCM_NONCE;
break;
case SMB2_CIPHER_AES_256_CCM:
algo = GCRY_CIPHER_AES256;
keylen = AES_KEY_SIZE*2;
mode = GCRY_CIPHER_MODE_CCM;
iv_size = SMB3_AES128CCM_NONCE;
break;
case SMB2_CIPHER_AES_256_GCM:
algo = GCRY_CIPHER_AES256;
keylen = AES_KEY_SIZE*2;
mode = GCRY_CIPHER_MODE_GCM;
iv_size = SMB3_AES128GCM_NONCE;
break;
default:
return FALSE;
}
/* Open the cipher */
err = gcry_cipher_open(&cipher_hd, algo, mode, 0);
if (err != GPG_ERR_NO_ERROR) {
DEBUG("GCRY: open %s/%s", gcry_strsource(err), gcry_strerror(err));
return FALSE;
}
/* Set the key */
err = gcry_cipher_setkey(cipher_hd, key, keylen);
if (err != GPG_ERR_NO_ERROR) {
DEBUG("GCRY: setkey %s/%s", gcry_strsource(err), gcry_strerror(err));
gcry_cipher_close(cipher_hd);
return FALSE;
}
/* Set the initial value */
err = gcry_cipher_setiv(cipher_hd, nonce, iv_size);
if (err != GPG_ERR_NO_ERROR) {
DEBUG("GCRY: setiv %s/%s", gcry_strsource(err), gcry_strerror(err));
gcry_cipher_close(cipher_hd);
return FALSE;
}
lengths[0] = data_size; /* encrypted length */
lengths[1] = aad_size; /* AAD length */
lengths[2] = 16; /* tag length (signature size) */
if (mode == GCRY_CIPHER_MODE_CCM) {
err = gcry_cipher_ctl(cipher_hd, GCRYCTL_SET_CCM_LENGTHS, lengths, sizeof(lengths));
if (err != GPG_ERR_NO_ERROR) {
DEBUG("GCRY: ctl %s/%s", gcry_strsource(err), gcry_strerror(err));
gcry_cipher_close(cipher_hd);
return FALSE;
}
}
err = gcry_cipher_authenticate(cipher_hd, aad, aad_size);
if (err != GPG_ERR_NO_ERROR) {
DEBUG("GCRY: auth %s/%s", gcry_strsource(err), gcry_strerror(err));
gcry_cipher_close(cipher_hd);
return FALSE;
}
err = gcry_cipher_decrypt(cipher_hd, data, data_size, NULL, 0);
if (err != GPG_ERR_NO_ERROR) {
DEBUG("GCRY: decrypt %s/%s", gcry_strsource(err), gcry_strerror(err));
gcry_cipher_close(cipher_hd);
return FALSE;
}
/* Done with the cipher */
gcry_cipher_close(cipher_hd);
return is_decrypted_header_ok(data, data_size);
}
static guint8*
decrypt_smb_payload(packet_info *pinfo,
tvbuff_t *tvb, int offset,
int offset_aad,
smb2_transform_info_t *sti)
{
const guint8 *aad = NULL;
guint8 *data = NULL;
guint8 *key16 = NULL;
guint8 *keys16[2];
guint8 *key32 = NULL;
guint8 *keys32[2];
gboolean ok;
int aad_size;
int alg;
/* AAD is the rest of transform header after the ProtocolID and Signature */
aad_size = 32;
if ((unsigned)tvb_captured_length_remaining(tvb, offset) < sti->size)
return NULL;
if (tvb_captured_length_remaining(tvb, offset_aad) < aad_size)
return NULL;
if (pinfo->destport == sti->session->server_port) {
keys16[0] = sti->session->server_decryption_key16;
keys16[1] = sti->session->client_decryption_key16;
keys32[0] = sti->session->server_decryption_key32;
keys32[1] = sti->session->client_decryption_key32;
} else {
keys16[1] = sti->session->server_decryption_key16;
keys16[0] = sti->session->client_decryption_key16;
keys32[1] = sti->session->server_decryption_key32;
keys32[0] = sti->session->client_decryption_key32;
}
aad = tvb_get_ptr(tvb, offset_aad, aad_size);
data = (guint8 *)tvb_memdup(pinfo->pool, tvb, offset, sti->size);
/*
* In SMB3.0 the transform header had a Algorithm field to
* know which type of encryption was used but only CCM was
* supported.
*
* SMB3.1.1 turned that field into a generic "Encrypted" flag
* which cannot be used to determine the encryption
* type. Instead the type is decided in the NegProt response,
* within the Encryption Capability context which should only
* have one element. That element is saved in the conversation
* struct (si->conv) and checked here.
*
* If the trace didn't contain NegProt packets, we have to
* guess the encryption type by trying them all.
*
* Similarly, if we don't have unencrypted packets telling us
* which host is the server and which host is the client, we
* have to guess by trying both keys.
*/
DEBUG("dialect 0x%x alg 0x%x conv alg 0x%x", sti->conv->dialect, sti->flags, sti->conv->enc_alg);
for (guint i = 0; i < G_N_ELEMENTS(keys16); i++) {
gboolean try_ccm16, try_gcm16;
gboolean try_ccm32, try_gcm32;
try_ccm16 = try_gcm16 = FALSE;
try_ccm32 = try_gcm32 = FALSE;
ok = FALSE;
key16 = keys16[i];
key32 = keys32[i];
switch (sti->conv->enc_alg) {
case SMB2_CIPHER_AES_128_CCM:
try_ccm16 = TRUE;
break;
case SMB2_CIPHER_AES_128_GCM:
try_gcm16 = TRUE;
break;
case SMB2_CIPHER_AES_256_CCM:
try_ccm32 = TRUE;
break;
case SMB2_CIPHER_AES_256_GCM:
try_gcm32 = TRUE;
break;
default:
/* we don't know, try all */
try_gcm16 = TRUE;
try_ccm16 = TRUE;
try_gcm32 = TRUE;
try_ccm32 = TRUE;
}
if (try_gcm16) {
guint8 *key = key16;
DEBUG("trying AES-128-GCM decryption");
alg = SMB2_CIPHER_AES_128_GCM;
tvb_memcpy(tvb, data, offset, sti->size);
ok = do_decrypt(data, sti->size, key, aad, aad_size, sti->nonce, alg);
if (ok)
break;
DEBUG("bad decrypted buffer with AES-128-GCM");
}
if (try_ccm16) {
guint8 *key = key16;
DEBUG("trying AES-128-CCM decryption");
alg = SMB2_CIPHER_AES_128_CCM;
ok = do_decrypt(data, sti->size, key, aad, aad_size, sti->nonce, alg);
if (ok)
break;
DEBUG("bad decrypted buffer with AES-128-CCM");
}
if (try_gcm32) {
guint8 *key = key32;
DEBUG("trying AES-256-GCM decryption");
alg = SMB2_CIPHER_AES_256_GCM;
tvb_memcpy(tvb, data, offset, sti->size);
ok = do_decrypt(data, sti->size, key, aad, aad_size, sti->nonce, alg);
if (ok)
break;
DEBUG("bad decrypted buffer with AES-256-GCM");
}
if (try_ccm32) {
guint8 *key = key32;
DEBUG("trying AES-256-CCM decryption");
alg = SMB2_CIPHER_AES_256_CCM;
ok = do_decrypt(data, sti->size, key, aad, aad_size, sti->nonce, alg);
if (ok)
break;
DEBUG("bad decrypted buffer with AES-256-CCM");
}
DEBUG("trying to decrypt with swapped client/server keys");
tvb_memcpy(tvb, data, offset, sti->size);
}
if (!ok)
return NULL;
/* Remember what worked */
sti->conv->enc_alg = alg;
if (key16 == sti->session->server_decryption_key16)
sti->session->server_port = pinfo->destport;
else
sti->session->server_port = pinfo->srcport;
return data;
}
/*
Append tvb[offset:offset+length] to out
*/
static void
append_uncompress_data(wmem_array_t *out, tvbuff_t *tvb, int offset, guint length)
{
wmem_array_append(out, tvb_get_ptr(tvb, offset, length), length);
}
static int
dissect_smb2_compression_pattern_v1(proto_tree *tree,
tvbuff_t *tvb, int offset, int length,
wmem_array_t *out)
{
proto_item *pat_item;
proto_tree *pat_tree;
guint pattern, times;
pat_tree = proto_tree_add_subtree_format(tree, tvb, offset, length,
ett_smb2_comp_pattern_v1, &pat_item,
"Pattern");
proto_tree_add_item_ret_uint(pat_tree, hf_smb2_comp_pattern_v1_pattern, tvb, offset, 1, ENC_LITTLE_ENDIAN, &pattern);
offset += 1;
proto_tree_add_item(pat_tree, hf_smb2_comp_pattern_v1_reserved1, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(pat_tree, hf_smb2_comp_pattern_v1_reserved2, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item_ret_uint(pat_tree, hf_smb2_comp_pattern_v1_repetitions, tvb, offset, 4, ENC_LITTLE_ENDIAN, ×);
offset += 4;
proto_item_append_text(pat_item, " 0x%02x repeated %u times", pattern, times);
if (out && times < MAX_UNCOMPRESSED_SIZE) {
guint8 v = (guint8)pattern;
for (guint i = 0; i < times; i++)
wmem_array_append(out, &v, 1);
}
return offset;
}
static int
dissect_smb2_chained_comp_payload(packet_info *pinfo, proto_tree *tree,
tvbuff_t *tvb, int offset,
wmem_array_t *out,
gboolean *ok)
{
proto_tree *subtree;
proto_item *subitem;
guint alg, length, flags, orig_size = 0;
tvbuff_t *uncomp_tvb = NULL;
gboolean lz_based = FALSE;
*ok = TRUE;
subtree = proto_tree_add_subtree_format(tree, tvb, offset, 0, ett_smb2_comp_payload, &subitem, "COMPRESSION_PAYLOAD_HEADER");
proto_tree_add_item_ret_uint(subtree, hf_smb2_comp_transform_comp_alg, tvb, offset, 2, ENC_LITTLE_ENDIAN, &alg);
offset += 2;
proto_tree_add_item_ret_uint(subtree, hf_smb2_comp_transform_flags, tvb, offset, 2, ENC_LITTLE_ENDIAN, &flags);
offset += 2;
proto_tree_add_item_ret_uint(subtree, hf_smb2_comp_transform_length, tvb, offset, 4, ENC_LITTLE_ENDIAN, &length);
offset += 4;
proto_item_set_len(subitem, length);
lz_based = (SMB2_COMP_ALG_LZNT1 <= alg && alg <= SMB2_COMP_ALG_LZ77HUFF);
if (lz_based) {
proto_tree_add_item_ret_uint(subtree, hf_smb2_comp_transform_orig_payload_size,
tvb, offset, 4, ENC_LITTLE_ENDIAN, &orig_size);
offset += 4;
length -= 4;
}
if (length > MAX_UNCOMPRESSED_SIZE) {
/* decompression error */
col_append_str(pinfo->cinfo, COL_INFO, "Comp. SMB3 (invalid)");
*ok = FALSE;
goto out;
}
switch (alg) {
case SMB2_COMP_ALG_NONE:
append_uncompress_data(out, tvb, offset, length);
break;
case SMB2_COMP_ALG_LZ77:
uncomp_tvb = tvb_uncompress_lz77(tvb, offset, length);
break;
case SMB2_COMP_ALG_LZ77HUFF:
uncomp_tvb = tvb_uncompress_lz77huff(tvb, offset, length);
break;
case SMB2_COMP_ALG_LZNT1:
uncomp_tvb = tvb_uncompress_lznt1(tvb, offset, length);
break;
case SMB2_COMP_ALG_PATTERN_V1:
dissect_smb2_compression_pattern_v1(subtree, tvb, offset, length, out);
break;
default:
col_append_str(pinfo->cinfo, COL_INFO, "Comp. SMB3 (unknown)");
uncomp_tvb = NULL;
break;
}
if (lz_based) {
if (!uncomp_tvb || tvb_reported_length(uncomp_tvb) != orig_size) {
/* decompression error */
col_append_str(pinfo->cinfo, COL_INFO, "Comp. SMB3 (invalid)");
*ok = FALSE;
goto out;
}
append_uncompress_data(out, uncomp_tvb, 0, tvb_reported_length(uncomp_tvb));
}
out:
if (uncomp_tvb)
tvb_free(uncomp_tvb);
proto_tree_add_item(subtree, hf_smb2_comp_transform_data, tvb, offset, length, ENC_NA);
offset += length;
return offset;
}
static int
dissect_smb2_comp_transform_header(packet_info *pinfo, proto_tree *tree,
tvbuff_t *tvb, int offset,
smb2_comp_transform_info_t *scti,
tvbuff_t **comp_tvb,
tvbuff_t **plain_tvb)
{
gint in_size;
tvbuff_t *uncomp_tvb = NULL;
guint flags;
wmem_array_t *uncomp_data;
*comp_tvb = NULL;
*plain_tvb = NULL;
/*
"old" compressed method:
[COMPRESS_TRANSFORM_HEADER with Flags=0]
[OPTIONAL UNCOMPRESSED DATA]
[COMPRESSED DATA]
new "chained" compressed method:
[fist 8 bytes of COMPRESS_TRANSFORM_HEADER with Flags=CHAINED]
[ sequence of
[ COMPRESSION_PAYLOAD_HEADER ]
[ COMPRESSED PAYLOAD ]
]
*/
/* SMB2_COMPRESSION_TRANSFORM marker */
proto_tree_add_item(tree, hf_smb2_protocol_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item_ret_uint(tree, hf_smb2_comp_transform_orig_size, tvb, offset, 4, ENC_LITTLE_ENDIAN, &scti->orig_size);
offset += 4;
uncomp_data = wmem_array_sized_new(pinfo->pool, 1, 1024);
flags = tvb_get_letohs(tvb, offset+2);
if (flags & SMB2_COMP_FLAG_CHAINED) {
gboolean all_ok = TRUE;
*comp_tvb = tvb_new_subset_length(tvb, offset, tvb_reported_length_remaining(tvb, offset));
do {
gboolean ok = FALSE;
offset = dissect_smb2_chained_comp_payload(pinfo, tree, tvb, offset, uncomp_data, &ok);
if (!ok)
all_ok = FALSE;
} while (tvb_reported_length_remaining(tvb, offset) > 8);
if (all_ok)
goto decompression_ok;
else
goto out;
}
proto_tree_add_item_ret_uint(tree, hf_smb2_comp_transform_comp_alg, tvb, offset, 2, ENC_LITTLE_ENDIAN, &scti->alg);
offset += 2;
proto_tree_add_item_ret_uint(tree, hf_smb2_comp_transform_flags, tvb, offset, 2, ENC_LITTLE_ENDIAN, &flags);
offset += 2;
proto_tree_add_item_ret_uint(tree, hf_smb2_comp_transform_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN, &scti->comp_offset);
offset += 4;
*comp_tvb = tvb_new_subset_length(tvb, offset, tvb_reported_length_remaining(tvb, offset));
if (scti->orig_size > MAX_UNCOMPRESSED_SIZE || scti->comp_offset > MAX_UNCOMPRESSED_SIZE) {
col_append_str(pinfo->cinfo, COL_INFO, "Comp. SMB3 (too big)");
goto out;
}
/*
* final uncompressed size is the partial normal packet + uncompressed segment
* final_size = scti->orig_size + scti->comp_offset
*/
append_uncompress_data(uncomp_data, tvb, offset, scti->comp_offset);
in_size = tvb_reported_length_remaining(tvb, offset + scti->comp_offset);
/* decompress compressed segment */
switch (scti->alg) {
case SMB2_COMP_ALG_LZ77:
uncomp_tvb = tvb_uncompress_lz77(tvb, offset + scti->comp_offset, in_size);
break;
case SMB2_COMP_ALG_LZ77HUFF:
uncomp_tvb = tvb_uncompress_lz77huff(tvb, offset + scti->comp_offset, in_size);
break;
case SMB2_COMP_ALG_LZNT1:
uncomp_tvb = tvb_uncompress_lznt1(tvb, offset + scti->comp_offset, in_size);
break;
default:
col_append_str(pinfo->cinfo, COL_INFO, "Comp. SMB3 (unknown)");
uncomp_tvb = NULL;
goto out;
}
if (!uncomp_tvb || tvb_reported_length(uncomp_tvb) != scti->orig_size) {
/* decompression error */
col_append_str(pinfo->cinfo, COL_INFO, "Comp. SMB3 (invalid)");
goto out;
}
/* write decompressed segment at the end of partial packet */
append_uncompress_data(uncomp_data, uncomp_tvb, 0, scti->orig_size);
decompression_ok:
col_append_str(pinfo->cinfo, COL_INFO, "Decomp. SMB3");
*plain_tvb = tvb_new_child_real_data(tvb,
(guint8 *)wmem_array_get_raw(uncomp_data),
wmem_array_get_count(uncomp_data),
wmem_array_get_count(uncomp_data));
add_new_data_source(pinfo, *plain_tvb, "Decomp. SMB3");
out:
if (uncomp_tvb)
tvb_free(uncomp_tvb);
return offset;
}
static int
dissect_smb2_transform_header(packet_info *pinfo, proto_tree *tree,
tvbuff_t *tvb, int offset,
smb2_transform_info_t *sti,
tvbuff_t **enc_tvb, tvbuff_t **plain_tvb)
{
proto_item *sesid_item = NULL;
proto_tree *sesid_tree = NULL;
int sesid_offset;
guint8 *plain_data = NULL;
int offset_aad;
*enc_tvb = NULL;
*plain_tvb = NULL;
/* signature */
proto_tree_add_item(tree, hf_smb2_transform_signature, tvb, offset, 16, ENC_NA);
offset += 16;
offset_aad = offset;
/* nonce */
proto_tree_add_item(tree, hf_smb2_transform_nonce, tvb, offset, 16, ENC_NA);
tvb_memcpy(tvb, sti->nonce, offset, 16);
offset += 16;
/* size */
proto_tree_add_item(tree, hf_smb2_transform_msg_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
sti->size = tvb_get_letohl(tvb, offset);
offset += 4;
/* reserved */
proto_tree_add_item(tree, hf_smb2_transform_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
/* flags */
proto_tree_add_bitmask(tree, tvb, offset, hf_smb2_transform_flags,
ett_smb2_transform_flags,
smb2_transform_flags, ENC_LITTLE_ENDIAN);
sti->flags = tvb_get_letohs(tvb, offset);
offset += 2;
/* session ID */
sesid_offset = offset;
sti->sesid = tvb_get_letoh64(tvb, offset);
sesid_item = proto_tree_add_item(tree, hf_smb2_sesid, tvb, offset, 8, ENC_LITTLE_ENDIAN);
sesid_tree = proto_item_add_subtree(sesid_item, ett_smb2_sesid_tree);
offset += 8;
/* now we need to first lookup the uid session */
sti->session = smb2_get_session(sti->conv, sti->sesid, NULL, NULL);
smb2_add_session_info(sesid_tree, sesid_item, tvb, sesid_offset, sti->session);
if (sti->flags & SMB2_TRANSFORM_FLAGS_ENCRYPTED) {
plain_data = decrypt_smb_payload(pinfo, tvb, offset, offset_aad, sti);
}
*enc_tvb = tvb_new_subset_length(tvb, offset, sti->size);
if (plain_data != NULL) {
*plain_tvb = tvb_new_child_real_data(*enc_tvb, plain_data, sti->size, sti->size);
add_new_data_source(pinfo, *plain_tvb, "Decrypted SMB3");
}
offset += sti->size;
return offset;
}
static const char *
get_special_packet_title(guint16 cmd, guint32 flags, guint64 msg_id, tvbuff_t *tvb, int offset)
{
/* for some types of packets we don't have request/response packets but something else
* to show more correct names while displaying them we use this logic to override standard naming convention
*/
guint16 buffer_code;
/* detect oplock/lease break packets */
if (cmd != SMB2_COM_BREAK) {
return NULL;
}
buffer_code = tvb_get_letohs(tvb, offset);
if (flags & SMB2_FLAGS_RESPONSE) {
switch (buffer_code) {
case OPLOCK_BREAK_OPLOCK_STRUCTURE_SIZE:
/* note - Notification and Response packets for Oplock Break are equivalent,
* we can distinguish them only via msg_id value */
if (msg_id == 0xFFFFFFFFFFFFFFFF) /* see [MS-SMB2] 3.3.4.6 Object Store Indicates an Oplock Break */
return "Oplock Break Notification";
else
return "Oplock Break Response";
case OPLOCK_BREAK_LEASE_NOTIFICATION_STRUCTURE_SIZE:
return "Lease Break Notification";
case OPLOCK_BREAK_LEASE_RESPONSE_STRUCTURE_SIZE:
return "Lease Break Response";
}
} else {
switch (buffer_code) {
case OPLOCK_BREAK_OPLOCK_STRUCTURE_SIZE:
return "Oplock Break Acknowledgment";
case OPLOCK_BREAK_LEASE_ACKNOWLEDGMENT_STRUCTURE_SIZE:
return "Lease Break Acknowledgment";
}
}
/* return back to standard notation if we can't detect packet type of break packet */
return NULL;
}
static int
dissect_smb2_command(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, smb2_info_t *si)
{
int (*cmd_dissector)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, smb2_info_t *si);
proto_item *cmd_item;
proto_tree *cmd_tree;
int old_offset = offset;
const char *packet_title = get_special_packet_title(si->opcode, si->flags, si->msg_id, tvb, offset);
if (packet_title) {
cmd_tree = proto_tree_add_subtree_format(tree, tvb, offset, -1,
ett_smb2_command, &cmd_item, "%s (0x%02x)",
packet_title,
si->opcode);
} else {
cmd_tree = proto_tree_add_subtree_format(tree, tvb, offset, -1,
ett_smb2_command, &cmd_item, "%s %s (0x%02x)",
decode_smb2_name(si->opcode),
(si->flags & SMB2_FLAGS_RESPONSE)?"Response":"Request",
si->opcode);
}
cmd_dissector = (si->flags & SMB2_FLAGS_RESPONSE)?
smb2_dissector[si->opcode&0xff].response:
smb2_dissector[si->opcode&0xff].request;
if (cmd_dissector) {
offset = (*cmd_dissector)(tvb, pinfo, cmd_tree, offset, si);
} else {
proto_tree_add_item(cmd_tree, hf_smb2_unknown, tvb, offset, -1, ENC_NA);
offset = tvb_captured_length(tvb);
}
proto_item_set_len(cmd_item, offset-old_offset);
return offset;
}
static int
dissect_smb2_tid_sesid(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, smb2_info_t *si)
{
proto_item *tid_item = NULL;
proto_tree *tid_tree = NULL;
smb2_tid_info_t tid_key;
int tid_offset = 0;
proto_item *sesid_item = NULL;
proto_tree *sesid_tree = NULL;
smb2_sesid_info_t sesid_key;
int sesid_offset;
proto_item *item;
if (si->flags&SMB2_FLAGS_ASYNC_CMD) {
proto_tree_add_item(tree, hf_smb2_aid, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
} else {
/* Process ID */
proto_tree_add_item(tree, hf_smb2_pid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* Tree ID */
tid_offset = offset;
si->tid = tvb_get_letohl(tvb, offset);
tid_item = proto_tree_add_item(tree, hf_smb2_tid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
tid_tree = proto_item_add_subtree(tid_item, ett_smb2_tid_tree);
offset += 4;
}
/* Session ID */
sesid_offset = offset;
si->sesid = tvb_get_letoh64(tvb, offset);
sesid_item = proto_tree_add_item(tree, hf_smb2_sesid, tvb, offset, 8, ENC_LITTLE_ENDIAN);
sesid_tree = proto_item_add_subtree(sesid_item, ett_smb2_sesid_tree);
offset += 8;
/* now we need to first lookup the uid session */
sesid_key.sesid = si->sesid;
si->session = (smb2_sesid_info_t *)wmem_map_lookup(smb2_sessions, &sesid_key);
if (!si->session) {
si->session = smb2_get_session(si->conv, si->sesid, pinfo, si);
return offset;
}
smb2_add_session_info(sesid_tree, sesid_item, tvb, sesid_offset, si->session);
if (!(si->flags&SMB2_FLAGS_ASYNC_CMD)) {
/* see if we can find the name for this tid */
tid_key.tid = si->tid;
si->tree = (smb2_tid_info_t *)wmem_map_lookup(si->session->tids, &tid_key);
if (!si->tree) return offset;
item = proto_tree_add_string(tid_tree, hf_smb2_tree, tvb, tid_offset, 4, si->tree->name);
proto_item_set_generated(item);
proto_item_append_text(tid_item, " %s", si->tree->name);
item = proto_tree_add_uint(tid_tree, hf_smb2_share_type, tvb, tid_offset, 0, si->tree->share_type);
proto_item_set_generated(item);
item = proto_tree_add_uint(tid_tree, hf_smb2_tcon_frame, tvb, tid_offset, 0, si->tree->connect_frame);
proto_item_set_generated(item);
}
return offset;
}
static void
dissect_smb2_signature(packet_info *pinfo, tvbuff_t *tvb, int offset, proto_tree *tree, smb2_info_t *si)
{
proto_item *item = NULL;
proto_tree *stree = NULL;
gcry_error_t err;
gcry_mac_hd_t md;
guint8 mac[NTLMSSP_KEY_LEN] = { 0, };
size_t len = NTLMSSP_KEY_LEN;
int i, remaining;
gboolean use_mac = FALSE;
item = proto_tree_add_item(tree, hf_smb2_signature, tvb, offset, 16, ENC_NA);
if (!si || !si->session ||!si->conv)
return;
if (!smb2_verify_signatures || !(si->flags & SMB2_FLAGS_SIGNATURE))
return;
if (memcmp(si->session->signing_key, zeros, NTLMSSP_KEY_LEN) == 0) {
return;
}
if (tvb_reported_length(tvb) > tvb_captured_length(tvb))
return;
remaining = tvb_reported_length_remaining(tvb, offset + NTLMSSP_KEY_LEN);
if (si->conv->sign_alg == SMB2_SIGNING_ALG_HMAC_SHA256) {
err = gcry_mac_open(&md, GCRY_MAC_HMAC_SHA256, 0, NULL);
if (err)
return;
use_mac = TRUE;
} else if (si->conv->sign_alg == SMB2_SIGNING_ALG_AES_CMAC) {
err = gcry_mac_open(&md, GCRY_MAC_CMAC_AES, 0, NULL);
if (err)
return;
use_mac = TRUE;
}
if (use_mac) {
gcry_mac_setkey(md, si->session->signing_key, len);
gcry_mac_write(md, tvb_get_ptr(tvb, 0, 48), 48);
gcry_mac_write(md, zeros, NTLMSSP_KEY_LEN);
gcry_mac_write(md, tvb_get_ptr(tvb, offset + NTLMSSP_KEY_LEN, remaining), remaining);
gcry_mac_read(md, &mac[0], &len);
gcry_mac_close(md);
}
stree = proto_item_add_subtree(item, ett_smb2_signature);
if (memcmp(&mac[0], tvb_get_ptr(tvb, offset, NTLMSSP_KEY_LEN), NTLMSSP_KEY_LEN) == 0) {
proto_tree_add_item(stree, hf_smb2_good_signature, tvb, offset, 16, ENC_NA);
return; /* signature matched */
}
item = proto_tree_add_item(stree, hf_smb2_bad_signature, tvb, offset, 16, ENC_NA);
proto_item_append_text(item, " ");
for (i = 0; i < NTLMSSP_KEY_LEN; i++)
proto_item_append_text(item, "%02x", mac[i]);
proto_item_set_generated(item);
expert_add_info(pinfo, item, &ei_smb2_invalid_signature);
return;
}
static int
dissect_smb2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, gboolean first_in_chain)
{
int msg_type;
proto_item *item = NULL;
proto_tree *tree = NULL;
proto_item *header_item = NULL;
proto_tree *header_tree = NULL;
int offset = 0;
int chain_offset = 0;
const char *label = smb_header_label;
conversation_t *conversation;
smb2_saved_info_t *ssi = NULL, ssi_key;
smb2_info_t *si;
smb2_transform_info_t *sti;
smb2_comp_transform_info_t *scti;
char *fid_name;
guint32 open_frame,close_frame;
smb2_eo_file_info_t *eo_file_info;
e_ctx_hnd *policy_hnd_hashtablekey;
const char *packet_title;
sti = wmem_new(pinfo->pool, smb2_transform_info_t);
scti = wmem_new(pinfo->pool, smb2_comp_transform_info_t);
si = wmem_new0(pinfo->pool, smb2_info_t);
si->top_tree = parent_tree;
msg_type = tvb_get_guint8(tvb, 0);
switch (msg_type) {
case SMB2_COMP_HEADER:
label = smb_comp_transform_header_label;
break;
case SMB2_ENCR_HEADER:
label = smb_transform_header_label;
break;
case SMB2_NORM_HEADER:
label = smb_header_label;
break;
default:
label = smb_bad_header_label;
break;
}
/* find which conversation we are part of and get the data for that
* conversation
*/
conversation = find_or_create_conversation(pinfo);
si->conv = (smb2_conv_info_t *)conversation_get_proto_data(conversation, proto_smb2);
if (!si->conv) {
/* no smb2_into_t structure for this conversation yet,
* create it.
*/
si->conv = wmem_new0(wmem_file_scope(), smb2_conv_info_t);
/* qqq this leaks memory for now since we never free
the hashtables */
si->conv->matched = g_hash_table_new(smb2_saved_info_hash_matched,
smb2_saved_info_equal_matched);
si->conv->unmatched = g_hash_table_new(smb2_saved_info_hash_unmatched,
smb2_saved_info_equal_unmatched);
si->conv->preauth_hash_current = si->conv->preauth_hash_con;
/* Bit of a hack to avoid leaking the hash tables - register a
* callback to free them. Ideally wmem would implement a simple
* hash table so we wouldn't have to do this. */
wmem_register_callback(wmem_file_scope(), smb2_conv_destroy,
si->conv);
conversation_add_proto_data(conversation, proto_smb2, si->conv);
}
sti->conv = si->conv;
scti->conv = si->conv;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMB2");
if (first_in_chain) {
/* first packet */
col_clear(pinfo->cinfo, COL_INFO);
} else {
col_append_str(pinfo->cinfo, COL_INFO, ";");
}
item = proto_tree_add_item(parent_tree, proto_smb2, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smb2);
header_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_smb2_header, &header_item, label);
/* Decode the header */
if (msg_type == SMB2_NORM_HEADER) {
/* SMB2 marker */
proto_tree_add_item(header_tree, hf_smb2_protocol_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
/* we need the flags before we know how to parse the credits field */
si->flags = tvb_get_letohl(tvb, offset+12);
/* header length */
proto_tree_add_item(header_tree, hf_smb2_header_len, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* credit charge (previously "epoch" (unused) which has been deprecated as of "SMB 2.1") */
proto_tree_add_item(header_tree, hf_smb2_credit_charge, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* Status Code */
if (si->flags & SMB2_FLAGS_RESPONSE) {
si->status = tvb_get_letohl(tvb, offset);
proto_tree_add_item(header_tree, hf_smb2_nt_status, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
} else {
si->status = 0;
proto_tree_add_item(header_tree, hf_smb2_channel_sequence, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(header_tree, hf_smb2_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
}
/* opcode */
si->opcode = tvb_get_letohs(tvb, offset);
proto_tree_add_item(header_tree, hf_smb2_cmd, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* credits */
if (si->flags & SMB2_FLAGS_RESPONSE) {
proto_tree_add_item(header_tree, hf_smb2_credits_granted, tvb, offset, 2, ENC_LITTLE_ENDIAN);
} else {
proto_tree_add_item(header_tree, hf_smb2_credits_requested, tvb, offset, 2, ENC_LITTLE_ENDIAN);
}
offset += 2;
/* flags */
if (header_tree) {
static int * const flags[] = {
&hf_smb2_flags_response,
&hf_smb2_flags_async_cmd,
&hf_smb2_flags_chained,
&hf_smb2_flags_signature,
&hf_smb2_flags_priority_mask,
&hf_smb2_flags_dfs_op,
&hf_smb2_flags_replay_operation,
NULL
};
proto_tree_add_bitmask(header_tree, tvb, offset, hf_smb2_flags,
ett_smb2_flags, flags, ENC_LITTLE_ENDIAN);
}
offset += 4;
/* Next Command */
chain_offset = tvb_get_letohl(tvb, offset);
proto_tree_add_item(header_tree, hf_smb2_chain_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* Message ID */
si->msg_id = tvb_get_letoh64(tvb, offset);
ssi_key.msg_id = si->msg_id;
proto_tree_add_item(header_tree, hf_smb2_msg_id, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
/* Tree ID and Session ID */
offset = dissect_smb2_tid_sesid(pinfo, header_tree, tvb, offset, si);
/* Signature */
dissect_smb2_signature(pinfo, tvb, offset, header_tree, si);
offset += 16;
proto_item_set_len(header_item, offset);
/* Check if this is a special packet type and it has non-regular title */
packet_title = get_special_packet_title(si->opcode, si->flags, si->msg_id, tvb, offset);
if (packet_title) {
col_append_fstr(pinfo->cinfo, COL_INFO, "%s", packet_title);
} else {
/* Regular packets have standard title */
col_append_fstr(pinfo->cinfo, COL_INFO, "%s %s",
decode_smb2_name(si->opcode),
(si->flags & SMB2_FLAGS_RESPONSE)?"Response":"Request");
}
if (si->status) {
col_append_fstr(
pinfo->cinfo, COL_INFO, ", Error: %s",
val_to_str_ext(si->status, &NT_errors_ext,
"Unknown (0x%08X)"));
}
if (!pinfo->fd->visited) {
/* see if we can find this msg_id in the unmatched table */
ssi = (smb2_saved_info_t *)g_hash_table_lookup(si->conv->unmatched, &ssi_key);
if (!(si->flags & SMB2_FLAGS_RESPONSE)) {
/* This is a request */
if (ssi) {
/* this is a request and we already found
* an older ssi so just delete the previous
* one
*/
g_hash_table_remove(si->conv->unmatched, ssi);
ssi = NULL;
}
if (!ssi) {
/* no we couldn't find it, so just add it then
* if was a request we are decoding
*/
ssi = wmem_new0(wmem_file_scope(), smb2_saved_info_t);
ssi->msg_id = ssi_key.msg_id;
ssi->frame_req = pinfo->num;
ssi->req_time = pinfo->abs_ts;
ssi->extra_info_type = SMB2_EI_NONE;
g_hash_table_insert(si->conv->unmatched, ssi, ssi);
}
} else {
/* This is a response */
if (!((si->flags & SMB2_FLAGS_ASYNC_CMD)
&& si->status == NT_STATUS_PENDING)
&& ssi) {
/* just set the response frame and move it to the matched table */
ssi->frame_res = pinfo->num;
g_hash_table_remove(si->conv->unmatched, ssi);
g_hash_table_insert(si->conv->matched, ssi, ssi);
}
}
} else {
/* see if we can find this msg_id in the matched table */
ssi = (smb2_saved_info_t *)g_hash_table_lookup(si->conv->matched, &ssi_key);
/* if we couldn't find it in the matched table, it might still
* be in the unmatched table
*/
if (!ssi) {
ssi = (smb2_saved_info_t *)g_hash_table_lookup(si->conv->unmatched, &ssi_key);
}
}
if (ssi) {
if (dcerpc_fetch_polhnd_data(&ssi->policy_hnd, &fid_name, NULL, &open_frame, &close_frame, pinfo->num)) {
/* If needed, create the file entry and save the policy hnd */
if (!si->eo_file_info) {
if (si->conv) {
eo_file_info = (smb2_eo_file_info_t *)wmem_map_lookup(si->session->files,&ssi->policy_hnd);
if (!eo_file_info) { /* XXX This should never happen */
/* assert(1==0); */
eo_file_info = wmem_new(wmem_file_scope(), smb2_eo_file_info_t);
policy_hnd_hashtablekey = wmem_new(wmem_file_scope(), e_ctx_hnd);
memcpy(policy_hnd_hashtablekey, &ssi->policy_hnd, sizeof(e_ctx_hnd));
eo_file_info->end_of_file=0;
wmem_map_insert(si->session->files,policy_hnd_hashtablekey,eo_file_info);
}
si->eo_file_info=eo_file_info;
}
}
}
if (!(si->flags & SMB2_FLAGS_RESPONSE)) {
if (ssi->frame_res) {
proto_item *tmp_item;
tmp_item = proto_tree_add_uint(header_tree, hf_smb2_response_in, tvb, 0, 0, ssi->frame_res);
proto_item_set_generated(tmp_item);
}
} else {
if (ssi->frame_req) {
proto_item *tmp_item;
nstime_t t, deltat;
tmp_item = proto_tree_add_uint(header_tree, hf_smb2_response_to, tvb, 0, 0, ssi->frame_req);
proto_item_set_generated(tmp_item);
t = pinfo->abs_ts;
nstime_delta(&deltat, &t, &ssi->req_time);
tmp_item = proto_tree_add_time(header_tree, hf_smb2_time, tvb,
0, 0, &deltat);
proto_item_set_generated(tmp_item);
}
}
if (si->file != NULL) {
ssi->file = si->file;
} else {
si->file = ssi->file;
}
}
/* if we don't have ssi yet we must fake it */
/*qqq*/
si->saved = ssi;
tap_queue_packet(smb2_tap, pinfo, si);
/* Decode the payload */
offset = dissect_smb2_command(pinfo, tree, tvb, offset, si);
} else if (msg_type == SMB2_ENCR_HEADER) {
proto_tree *enc_tree;
tvbuff_t *enc_tvb = NULL;
tvbuff_t *plain_tvb = NULL;
/* SMB2_TRANSFORM marker */
proto_tree_add_item(header_tree, hf_smb2_protocol_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
offset = dissect_smb2_transform_header(pinfo, header_tree, tvb, offset, sti,
&enc_tvb, &plain_tvb);
enc_tree = proto_tree_add_subtree(tree, enc_tvb, 0, sti->size, ett_smb2_encrypted, NULL, "Encrypted SMB3 data");
if (plain_tvb != NULL) {
col_append_str(pinfo->cinfo, COL_INFO, "Decrypted SMB3");
dissect_smb2(plain_tvb, pinfo, enc_tree, FALSE);
} else {
col_append_str(pinfo->cinfo, COL_INFO, "Encrypted SMB3");
proto_tree_add_item(enc_tree, hf_smb2_transform_encrypted_data,
enc_tvb, 0, sti->size, ENC_NA);
}
if (tvb_reported_length_remaining(tvb, offset) > 0) {
chain_offset = offset;
}
} else if (msg_type == SMB2_COMP_HEADER) {
proto_tree *comp_tree;
proto_item *decomp_item;
tvbuff_t *plain_tvb = NULL;
tvbuff_t *comp_tvb = NULL;
offset = dissect_smb2_comp_transform_header(pinfo, header_tree, tvb, offset,
scti, &comp_tvb, &plain_tvb);
if (plain_tvb) {
comp_tree = proto_tree_add_subtree(header_tree, plain_tvb, 0,
tvb_reported_length_remaining(plain_tvb, 0),
ett_smb2_decompressed, &decomp_item,
"Decompressed SMB3 data");
proto_item_set_generated(decomp_item);
dissect_smb2(plain_tvb, pinfo, comp_tree, FALSE);
} else {
comp_tree = proto_tree_add_subtree(header_tree, tvb, offset,
tvb_reported_length_remaining(tvb, offset),
ett_smb2_compressed, NULL,
"Compressed SMB3 data");
/* show the compressed payload only if we cant uncompress it */
proto_tree_add_item(comp_tree, hf_smb2_comp_transform_data,
tvb, offset,
tvb_reported_length_remaining(tvb, offset),
ENC_NA);
}
offset += tvb_reported_length_remaining(tvb, offset);
} else {
col_append_str(pinfo->cinfo, COL_INFO, "Invalid header");
/* bad packet after decompressing/decrypting */
offset += tvb_reported_length_remaining(tvb, offset);
}
if (chain_offset > 0) {
tvbuff_t *next_tvb;
proto_item_set_len(item, chain_offset);
next_tvb = tvb_new_subset_remaining(tvb, chain_offset);
offset = dissect_smb2(next_tvb, pinfo, parent_tree, FALSE);
}
return offset;
}
static gboolean
dissect_smb2_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
{
guint8 b;
/* must check that this really is a smb2 packet */
if (tvb_captured_length(tvb) < 4)
return FALSE;
b = tvb_get_guint8(tvb, 0);
if (((b != SMB2_COMP_HEADER) && (b != SMB2_ENCR_HEADER) && (b != SMB2_NORM_HEADER))
|| (tvb_get_guint8(tvb, 1) != 'S')
|| (tvb_get_guint8(tvb, 2) != 'M')
|| (tvb_get_guint8(tvb, 3) != 'B') ) {
return FALSE;
}
dissect_smb2(tvb, pinfo, parent_tree, TRUE);
return TRUE;
}
void
proto_register_smb2(void)
{
module_t *smb2_module;
static hf_register_info hf[] = {
{ &hf_smb2_cmd,
{ "Command", "smb2.cmd", FT_UINT16, BASE_DEC | BASE_EXT_STRING,
&smb2_cmd_vals_ext, 0, "SMB2 Command Opcode", HFILL }
},
{ &hf_smb2_response_to,
{ "Response to", "smb2.response_to", FT_FRAMENUM, BASE_NONE,
FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0, "This packet is a response to the packet in this frame", HFILL }
},
{ &hf_smb2_response_in,
{ "Response in", "smb2.response_in", FT_FRAMENUM, BASE_NONE,
FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE), 0, "The response to this packet is in this packet", HFILL }
},
{ &hf_smb2_time,
{ "Time from request", "smb2.time", FT_RELATIVE_TIME, BASE_NONE,
NULL, 0, "Time between Request and Response for SMB2 cmds", HFILL }
},
{ &hf_smb2_preauth_hash,
{ "Preauth Hash", "smb2.preauth_hash", FT_BYTES, BASE_NONE,
NULL, 0, "SMB3.1.1 pre-authentication SHA512 hash after hashing the packet", HFILL }
},
{ &hf_smb2_header_len,
{ "Header Length", "smb2.header_len", FT_UINT16, BASE_DEC,
NULL, 0, "SMB2 Size of Header", HFILL }
},
{ &hf_smb2_nt_status,
{ "NT Status", "smb2.nt_status", FT_UINT32, BASE_HEX | BASE_EXT_STRING,
&NT_errors_ext, 0, "NT Status code", HFILL }
},
{ &hf_smb2_msg_id,
{ "Message ID", "smb2.msg_id", FT_UINT64, BASE_DEC|BASE_VAL64_STRING|BASE_SPECIAL_VALS,
VALS64(unique_unsolicited_response), 0, NULL, HFILL }
},
{ &hf_smb2_tid,
{ "Tree Id", "smb2.tid", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_aid,
{ "Async Id", "smb2.aid", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_sesid,
{ "Session Id", "smb2.sesid", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_previous_sesid,
{ "Previous Session Id", "smb2.previous_sesid", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_chain_offset,
{ "Chain Offset", "smb2.chain_offset", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_end_of_file,
{ "End Of File", "smb2.eof", FT_UINT64, BASE_DEC,
NULL, 0, "SMB2 End Of File/File size", HFILL }
},
{ &hf_smb2_nlinks,
{ "Number of Links", "smb2.nlinks", FT_UINT32, BASE_DEC,
NULL, 0, "Number of links to this object", HFILL }
},
{ &hf_smb2_file_id,
{ "File Id", "smb2.file_id", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_allocation_size,
{ "Allocation Size", "smb2.allocation_size", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_max_response_size,
{ "Max Response Size", "smb2.max_response_size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_getinfo_input_size,
{ "Getinfo Input Size", "smb2.getinfo_input_size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_getinfo_input_offset,
{ "Getinfo Input Offset", "smb2.getinfo_input_offset", FT_UINT16, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_getsetinfo_additional,
{ "Additional Info", "smb2.getsetinfo_additional", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_getsetinfo_additionals,
{ "Additional Info", "smb2.getsetinfo_additionals", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_getsetinfo_additional_owner,
{ "Owner", "smb2.getsetinfo_additional_secinfo.owner", FT_BOOLEAN, 32,
TFS(&tfs_additional_owner), OWNER_SECURITY_INFORMATION, "Is owner security information being queried?", HFILL }},
{ &hf_smb2_getsetinfo_additional_group,
{ "Group", "smb2.getsetinfo_additional_secinfo.group", FT_BOOLEAN, 32,
TFS(&tfs_additional_group), GROUP_SECURITY_INFORMATION, "Is group security information being queried?", HFILL }},
{ &hf_smb2_getsetinfo_additional_dacl,
{ "DACL", "smb2.getsetinfo_additional_secinfo.dacl", FT_BOOLEAN, 32,
TFS(&tfs_additional_dacl), DACL_SECURITY_INFORMATION, "Is DACL security information being queried?", HFILL }},
{ &hf_smb2_getsetinfo_additional_sacl,
{ "SACL", "smb2.getsetinfo_additional_secinfo.sacl", FT_BOOLEAN, 32,
TFS(&tfs_additional_sacl), SACL_SECURITY_INFORMATION, "Is SACL security information being queried?", HFILL }},
{ &hf_smb2_getsetinfo_additional_label,
{ "Integrity label", "smb2.getsetinfo_additional_secinfo.label", FT_BOOLEAN, 32,
TFS(&tfs_additional_label), LABEL_SECURITY_INFORMATION, "Is integrity label security information being queried?", HFILL }},
{ &hf_smb2_getsetinfo_additional_attribute,
{ "Resource attribute", "smb2.getsetinfo_additional_secinfo.attribute", FT_BOOLEAN, 32,
TFS(&tfs_additional_attribute), ATTRIBUTE_SECURITY_INFORMATION, "Is resource attribute security information being queried?", HFILL }},
{ &hf_smb2_getsetinfo_additional_scope,
{ "Central access policy", "smb2.getsetinfo_additional_secinfo.scope", FT_BOOLEAN, 32,
TFS(&tfs_additional_scope), SCOPE_SECURITY_INFORMATION, "Is central access policy security information being queried?", HFILL }},
{ &hf_smb2_getsetinfo_additional_backup,
{ "Backup operation", "smb2.getsetinfo_additional_secinfo.backup", FT_BOOLEAN, 32,
TFS(&tfs_additional_backup), BACKUP_SECURITY_INFORMATION, "Is backup operation security information being queried?", HFILL }},
{ &hf_smb2_getinfo_flags,
{ "Flags", "smb2.getinfo_flags", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_setinfo_size,
{ "Setinfo Size", "smb2.setinfo_size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_setinfo_offset,
{ "Setinfo Offset", "smb2.setinfo_offset", FT_UINT16, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_setinfo_reserved,
{ "Reserved", "smb2.setinfo_reserved", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_max_ioctl_out_size,
{ "Max Ioctl Out Size", "smb2.max_ioctl_out_size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_max_ioctl_in_size,
{ "Max Ioctl In Size", "smb2.max_ioctl_in_size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_required_buffer_size,
{ "Required Buffer Size", "smb2.required_size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_pid,
{ "Process Id", "smb2.pid", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
/* SMB2 header flags */
{ &hf_smb2_flags,
{ "Flags", "smb2.flags", FT_UINT32, BASE_HEX,
NULL, 0, "SMB2 flags", HFILL }
},
{ &hf_smb2_flags_response,
{ "Response", "smb2.flags.response", FT_BOOLEAN, 32,
TFS(&tfs_flags_response), SMB2_FLAGS_RESPONSE, "Whether this is an SMB2 Request or Response", HFILL }
},
{ &hf_smb2_flags_async_cmd,
{ "Async command", "smb2.flags.async", FT_BOOLEAN, 32,
TFS(&tfs_flags_async_cmd), SMB2_FLAGS_ASYNC_CMD, NULL, HFILL }
},
{ &hf_smb2_flags_dfs_op,
{ "DFS operation", "smb2.flags.dfs", FT_BOOLEAN, 32,
TFS(&tfs_flags_dfs_op), SMB2_FLAGS_DFS_OP, NULL, HFILL }
},
{ &hf_smb2_flags_chained,
{ "Chained", "smb2.flags.chained", FT_BOOLEAN, 32,
TFS(&tfs_flags_chained), SMB2_FLAGS_CHAINED, "Whether the pdu continues a chain or not", HFILL }
},
{ &hf_smb2_flags_signature,
{ "Signing", "smb2.flags.signature", FT_BOOLEAN, 32,
TFS(&tfs_flags_signature), SMB2_FLAGS_SIGNATURE, "Whether the pdu is signed or not", HFILL }
},
{ &hf_smb2_flags_replay_operation,
{ "Replay operation", "smb2.flags.replay", FT_BOOLEAN, 32,
TFS(&tfs_flags_replay_operation), SMB2_FLAGS_REPLAY_OPERATION, "Whether this is a replay operation", HFILL }
},
{ &hf_smb2_flags_priority_mask,
{ "Priority", "smb2.flags.priority_mask", FT_BOOLEAN, 32,
TFS(&tfs_flags_priority_mask), SMB2_FLAGS_PRIORITY_MASK, "Priority Mask", HFILL }
},
{ &hf_smb2_tree,
{ "Tree", "smb2.tree", FT_STRING, BASE_NONE,
NULL, 0, "Name of the Tree/Share", HFILL }
},
{ &hf_smb2_filename,
{ "Filename", "smb2.filename", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_filename_len,
{ "Filename Length", "smb2.filename.len", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_replace_if,
{ "Replace If", "smb2.rename.replace_if", FT_BOOLEAN, 8,
TFS(&tfs_replace_if_exists), 0xFF, "Whether to replace if the target exists", HFILL }
},
{ &hf_smb2_data_offset,
{ "Data Offset", "smb2.data_offset", FT_UINT16, BASE_HEX,
NULL, 0, "Offset to data", HFILL }
},
{ &hf_smb2_find_info_level,
{ "Info Level", "smb2.find.infolevel", FT_UINT32, BASE_DEC,
VALS(smb2_find_info_levels), 0, "Find_Info Infolevel", HFILL }
},
{ &hf_smb2_find_flags,
{ "Find Flags", "smb2.find.flags", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_find_pattern,
{ "Search Pattern", "smb2.find.pattern", FT_STRING, BASE_NONE,
NULL, 0, "Find pattern", HFILL }
},
{ &hf_smb2_find_info_blob,
{ "Info", "smb2.find.info_blob", FT_BYTES, BASE_NONE,
NULL, 0, "Find Info", HFILL }
},
{ &hf_smb2_ea_size,
{ "EA Size", "smb2.ea_size", FT_UINT32, BASE_DEC,
NULL, 0, "Size of EA data", HFILL }
},
{ &hf_smb2_position_information,
{ "Position Information", "smb2.position_info", FT_UINT64, BASE_DEC,
NULL, 0, "Current file position", HFILL }
},
{ &hf_smb2_mode_information,
{ "Mode Information", "smb2.mode_info", FT_UINT32, BASE_HEX,
NULL, 0, "File mode information", HFILL }
},
{ &hf_smb2_mode_file_write_through,
{ "FILE_WRITE_THROUGH", "smb2.mode.file_write_through", FT_UINT32, BASE_HEX,
NULL, 0x02, NULL, HFILL }
},
{ &hf_smb2_mode_file_sequential_only,
{ "FILE_SEQUENTIAL_ONLY", "smb2.mode.file_sequential_only", FT_UINT32, BASE_HEX,
NULL, 0x04, NULL, HFILL }
},
{ &hf_smb2_mode_file_no_intermediate_buffering,
{ "FILE_NO_INTERMEDIATE_BUFFERING", "smb2.mode.file_no_intermediate_buffering", FT_UINT32, BASE_HEX,
NULL, 0x08, NULL, HFILL }
},
{ &hf_smb2_mode_file_synchronous_io_alert,
{ "FILE_SYNCHRONOUS_IO_ALERT", "smb2.mode.file_synchronous_io_alert", FT_UINT32, BASE_HEX,
NULL, 0x10, NULL, HFILL }
},
{ &hf_smb2_mode_file_synchronous_io_nonalert,
{ "FILE_SYNCHRONOUS_IO_NONALERT", "smb2.mode.file_synchronous_io_nonalert", FT_UINT32, BASE_HEX,
NULL, 0x20, NULL, HFILL }
},
{ &hf_smb2_mode_file_delete_on_close,
{ "FILE_DELETE_ON_CLOSE", "smb2.mode.file_delete_on_close", FT_UINT32, BASE_HEX,
NULL, 0x1000, NULL, HFILL }
},
{ &hf_smb2_alignment_information,
{ "Alignment Information", "smb2.alignment_info", FT_UINT32, BASE_HEX,
VALS(smb2_alignment_vals), 0, "File alignment", HFILL}
},
{ &hf_smb2_class,
{ "Class", "smb2.class", FT_UINT8, BASE_HEX,
VALS(smb2_class_vals), 0, "Info class", HFILL }
},
{ &hf_smb2_infolevel,
{ "InfoLevel", "smb2.infolevel", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_infolevel_file_info,
{ "InfoLevel", "smb2.file_info.infolevel", FT_UINT8, BASE_HEX | BASE_EXT_STRING,
&smb2_file_info_levels_ext, 0, "File_Info Infolevel", HFILL }
},
{ &hf_smb2_infolevel_fs_info,
{ "InfoLevel", "smb2.fs_info.infolevel", FT_UINT8, BASE_HEX | BASE_EXT_STRING,
&smb2_fs_info_levels_ext, 0, "Fs_Info Infolevel", HFILL }
},
{ &hf_smb2_infolevel_sec_info,
{ "InfoLevel", "smb2.sec_info.infolevel", FT_UINT8, BASE_HEX | BASE_EXT_STRING,
&smb2_sec_info_levels_ext, 0, "Sec_Info Infolevel", HFILL }
},
{ &hf_smb2_write_length,
{ "Write Length", "smb2.write_length", FT_UINT32, BASE_DEC,
NULL, 0, "Amount of data to write", HFILL }
},
{ &hf_smb2_read_blob,
{ "Info", "smb2.read.blob", FT_BYTES, BASE_NONE,
NULL, 0, "Read Blob", HFILL }
},
{ &hf_smb2_read_length,
{ "Read Length", "smb2.read_length", FT_UINT32, BASE_DEC,
NULL, 0, "Amount of data to read", HFILL }
},
{ &hf_smb2_read_remaining,
{ "Read Remaining", "smb2.read_remaining", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_read_padding,
{ "Padding", "smb2.read_padding", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_read_flags,
{ "Flags", "smb2.read_flags", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_read_flags_unbuffered,
{ "Unbuffered", "smb2.read_flags.unbuffered", FT_BOOLEAN, 8,
TFS(&tfs_read_unbuffered), SMB2_READFLAG_READ_UNBUFFERED, "If client requests unbuffered read", HFILL }
},
{ &hf_smb2_read_flags_compressed,
{ "Compressed", "smb2.read_flags.compressed", FT_BOOLEAN, 8,
TFS(&tfs_read_compressed), SMB2_READFLAG_READ_COMPRESSED, "If client requests compressed response", HFILL }
},
{ &hf_smb2_create_flags,
{ "Create Flags", "smb2.create_flags", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_offset,
{ "File Offset", "smb2.file_offset", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_fsctl_range_offset,
{ "File Offset", "smb2.fsctl.range_offset", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_fsctl_range_length,
{ "Length", "smb2.fsctl.range_length", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_qfr_length,
{ "Length", "smb2.qfr_length", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_qfr_usage,
{ "Desired Usage", "smb2.qfr_usage", FT_UINT32, BASE_HEX,
VALS(file_region_usage_vals), 0, NULL, HFILL }
},
{ &hf_smb2_qfr_flags,
{ "Flags", "smb2.qfr_flags", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_qfr_total_region_entry_count,
{ "Total Region Entry Count", "smb2.qfr_tot_region_entry_count", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_qfr_region_entry_count,
{ "Region Entry Count", "smb2.qfr_region_entry_count", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_security_blob,
{ "Security Blob", "smb2.security_blob", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_ioctl_out_data,
{ "Out Data", "smb2.ioctl.out", FT_NONE, BASE_NONE,
NULL, 0, "Ioctl Out", HFILL }
},
{ &hf_smb2_ioctl_in_data,
{ "In Data", "smb2.ioctl.in", FT_NONE, BASE_NONE,
NULL, 0, "Ioctl In", HFILL }
},
{ &hf_smb2_server_guid,
{ "Server Guid", "smb2.server_guid", FT_GUID, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_client_guid,
{ "Client Guid", "smb2.client_guid", FT_GUID, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_object_id,
{ "ObjectId", "smb2.object_id", FT_GUID, BASE_NONE,
NULL, 0, "ObjectID for this FID", HFILL }
},
{ &hf_smb2_birth_volume_id,
{ "BirthVolumeId", "smb2.birth_volume_id", FT_GUID, BASE_NONE,
NULL, 0, "ObjectID for the volume where this FID was originally created", HFILL }
},
{ &hf_smb2_birth_object_id,
{ "BirthObjectId", "smb2.birth_object_id", FT_GUID, BASE_NONE,
NULL, 0, "ObjectID for this FID when it was originally created", HFILL }
},
{ &hf_smb2_domain_id,
{ "DomainId", "smb2.domain_id", FT_GUID, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_create_timestamp,
{ "Create", "smb2.create.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "Time when this object was created", HFILL }
},
{ &hf_smb2_fid,
{ "File Id", "smb2.fid", FT_GUID, BASE_NONE,
NULL, 0, "SMB2 File Id", HFILL }
},
{ &hf_smb2_write_data,
{ "Write Data", "smb2.write_data", FT_BYTES, BASE_NONE,
NULL, 0, "SMB2 Data to be written", HFILL }
},
{ &hf_smb2_write_flags,
{ "Write Flags", "smb2.write.flags", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_write_flags_write_through,
{ "Write through", "smb2.write.flags.write_through", FT_BOOLEAN, 32,
TFS(&tfs_write_through), SMB2_WRITE_FLAG_WRITE_THROUGH, "If the client requests WRITE_THROUGH", HFILL }
},
{ &hf_smb2_write_flags_write_unbuffered,
{ "Unbuffered", "smb2.write.flags.unbuffered", FT_BOOLEAN, 32,
TFS(&tfs_write_unbuffered), SMB2_WRITE_FLAG_WRITE_UNBUFFERED, "If client requests UNBUFFERED read", HFILL }
},
{ &hf_smb2_write_count,
{ "Write Count", "smb2.write.count", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_write_remaining,
{ "Write Remaining", "smb2.write.remaining", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_read_data,
{ "Read Data", "smb2.read_data", FT_BYTES, BASE_NONE,
NULL, 0, "SMB2 Data that is read", HFILL }
},
{ &hf_smb2_last_access_timestamp,
{ "Last Access", "smb2.last_access.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "Time when this object was last accessed", HFILL }
},
{ &hf_smb2_last_write_timestamp,
{ "Last Write", "smb2.last_write.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "Time when this object was last written to", HFILL }
},
{ &hf_smb2_last_change_timestamp,
{ "Last Change", "smb2.last_change.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "Time when this object was last changed", HFILL }
},
{ &hf_smb2_file_all_info,
{ "SMB2_FILE_ALL_INFO", "smb2.file_all_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_allocation_info,
{ "SMB2_FILE_ALLOCATION_INFO", "smb2.file_allocation_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_endoffile_info,
{ "SMB2_FILE_ENDOFFILE_INFO", "smb2.file_endoffile_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_good_signature,
{ "Good signature", "smb2.good_signature", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_bad_signature,
{ "Bad signature. Should be", "smb2.bad_signature", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_alternate_name_info,
{ "SMB2_FILE_ALTERNATE_NAME_INFO", "smb2.file_alternate_name_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_normalized_name_info,
{ "SMB2_FILE_NORMALIZED_NAME_INFO", "smb2.file_normalized_name_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_stream_info,
{ "SMB2_FILE_STREAM_INFO", "smb2.file_stream_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_pipe_info,
{ "SMB2_FILE_PIPE_INFO", "smb2.file_pipe_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_compression_info,
{ "SMB2_FILE_COMPRESSION_INFO", "smb2.file_compression_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_basic_info,
{ "SMB2_FILE_BASIC_INFO", "smb2.file_basic_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_standard_info,
{ "SMB2_FILE_STANDARD_INFO", "smb2.file_standard_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_internal_info,
{ "SMB2_FILE_INTERNAL_INFO", "smb2.file_internal_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_mode_info,
{ "SMB2_FILE_MODE_INFO", "smb2.file_mode_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_alignment_info,
{ "SMB2_FILE_ALIGNMENT_INFO", "smb2.file_alignment_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_position_info,
{ "SMB2_FILE_POSITION_INFO", "smb2.file_position_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_access_info,
{ "SMB2_FILE_ACCESS_INFO", "smb2.file_access_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_ea_info,
{ "SMB2_FILE_EA_INFO", "smb2.file_ea_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_network_open_info,
{ "SMB2_FILE_NETWORK_OPEN_INFO", "smb2.file_network_open_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_attribute_tag_info,
{ "SMB2_FILE_ATTRIBUTE_TAG_INFO", "smb2.file_attribute_tag_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_disposition_info,
{ "SMB2_FILE_DISPOSITION_INFO", "smb2.file_disposition_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_full_ea_info,
{ "SMB2_FILE_FULL_EA_INFO", "smb2.file_full_ea_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_rename_info,
{ "SMB2_FILE_RENAME_INFO", "smb2.file_rename_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_fs_info_01,
{ "FileFsVolumeInformation", "smb2.fs_volume_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_fs_info_03,
{ "FileFsSizeInformation", "smb2.fs_size_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_fs_info_04,
{ "FileFsDeviceInformation", "smb2.fs_device_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_fs_info_05,
{ "FileFsAttributeInformation", "smb2.fs_attribute_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_fs_info_06,
{ "FileFsControlInformation", "smb2.fs_control_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_fs_info_07,
{ "FileFsFullSizeInformation", "smb2.fs_full_size_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_fs_objectid_info,
{ "FileFsObjectIdInformation", "smb2.fs_objectid_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_sec_info_00,
{ "SMB2_SEC_INFO_00", "smb2.sec_info_00", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_quota_info,
{ "SMB2_QUOTA_INFO", "smb2.quota_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_query_quota_info,
{ "SMB2_QUERY_QUOTA_INFO", "smb2.query_quota_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_qq_single,
{ "ReturnSingle", "smb2.query_quota_info.single", FT_BOOLEAN, 8,
NULL, 0xff, NULL, HFILL }
},
{ &hf_smb2_qq_restart,
{ "RestartScan", "smb2.query_quota_info.restart", FT_BOOLEAN, 8,
NULL, 0xff, NULL, HFILL }
},
{ &hf_smb2_qq_sidlist_len,
{ "SidListLength", "smb2.query_quota_info.sidlistlen", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_qq_start_sid_len,
{ "StartSidLength", "smb2.query_quota_info.startsidlen", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_qq_start_sid_offset,
{ "StartSidOffset", "smb2.query_quota_info.startsidoffset", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_disposition_delete_on_close,
{ "Delete on close", "smb2.disposition.delete_on_close", FT_BOOLEAN, 8,
TFS(&tfs_disposition_delete_on_close), 0x01, NULL, HFILL }
},
{ &hf_smb2_create_disposition,
{ "Disposition", "smb2.create.disposition", FT_UINT32, BASE_DEC,
VALS(create_disposition_vals), 0, "Create disposition, what to do if the file does/does not exist", HFILL }
},
{ &hf_smb2_create_action,
{ "Create Action", "smb2.create.action", FT_UINT32, BASE_DEC,
VALS(oa_open_vals), 0, NULL, HFILL }
},
{ &hf_smb2_create_rep_flags,
{ "Response Flags", "smb2.create.rep_flags", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_create_rep_flags_reparse_point,
{ "ReparsePoint", "smb2.create.rep_flags.reparse_point", FT_BOOLEAN, 8,
NULL, SMB2_CREATE_REP_FLAGS_REPARSE_POINT, NULL, HFILL }
},
{ &hf_smb2_extrainfo,
{ "ExtraInfo", "smb2.create.extrainfo", FT_NONE, BASE_NONE,
NULL, 0, "Create ExtraInfo", HFILL }
},
{ &hf_smb2_create_chain_offset,
{ "Chain Offset", "smb2.create.chain_offset", FT_UINT32, BASE_HEX,
NULL, 0, "Offset to next entry in chain or 0", HFILL }
},
{ &hf_smb2_create_chain_data,
{ "Data", "smb2.create.chain_data", FT_NONE, BASE_NONE,
NULL, 0, "Chain Data", HFILL }
},
{ &hf_smb2_FILE_OBJECTID_BUFFER,
{ "FILE_OBJECTID_BUFFER", "smb2.FILE_OBJECTID_BUFFER", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_lease_key,
{ "Lease Key", "smb2.lease.lease_key", FT_GUID, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_lease_state,
{ "Lease State", "smb2.lease.lease_state", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_lease_state_read_caching,
{ "Read Caching", "smb2.lease.lease_state.read_caching", FT_BOOLEAN, 32,
NULL, SMB2_LEASE_STATE_READ_CACHING, NULL, HFILL }
},
{ &hf_smb2_lease_state_handle_caching,
{ "Handle Caching", "smb2.lease.lease_state.handle_caching", FT_BOOLEAN, 32,
NULL, SMB2_LEASE_STATE_HANDLE_CACHING, NULL, HFILL }
},
{ &hf_smb2_lease_state_write_caching,
{ "Write Caching", "smb2.lease.lease_state.write_caching", FT_BOOLEAN, 32,
NULL, SMB2_LEASE_STATE_WRITE_CACHING, NULL, HFILL }
},
{ &hf_smb2_lease_flags,
{ "Lease Flags", "smb2.lease.lease_flags", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_lease_flags_break_ack_required,
{ "Break Ack Required", "smb2.lease.lease_state.break_ack_required", FT_BOOLEAN, 32,
NULL, SMB2_LEASE_FLAGS_BREAK_ACK_REQUIRED, NULL, HFILL }
},
{ &hf_smb2_lease_flags_break_in_progress,
{ "Break In Progress", "smb2.lease.lease_state.break_in_progress", FT_BOOLEAN, 32,
NULL, SMB2_LEASE_FLAGS_BREAK_IN_PROGRESS, NULL, HFILL }
},
{ &hf_smb2_lease_flags_parent_lease_key_set,
{ "Parent Lease Key Set", "smb2.lease.lease_state.parent_lease_key_set", FT_BOOLEAN, 32,
NULL, SMB2_LEASE_FLAGS_PARENT_LEASE_KEY_SET, NULL, HFILL }
},
{ &hf_smb2_lease_duration,
{ "Lease Duration", "smb2.lease.lease_duration", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_parent_lease_key,
{ "Parent Lease Key", "smb2.lease.parent_lease_key", FT_GUID, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_lease_epoch,
{ "Lease Epoch", "smb2.lease.lease_oplock", FT_UINT16, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_lease_reserved,
{ "Lease Reserved", "smb2.lease.lease_reserved", FT_UINT16, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_lease_break_reason,
{ "Lease Break Reason", "smb2.lease.lease_break_reason", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_lease_access_mask_hint,
{ "Access Mask Hint", "smb2.lease.access_mask_hint", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_lease_share_mask_hint,
{ "Share Mask Hint", "smb2.lease.share_mask_hint", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_next_offset,
{ "Next Offset", "smb2.next_offset", FT_UINT32, BASE_DEC,
NULL, 0, "Offset to next buffer or 0", HFILL }
},
{ &hf_smb2_negotiate_context_type,
{ "Type", "smb2.negotiate_context.type", FT_UINT16, BASE_HEX,
VALS(smb2_negotiate_context_types), 0, NULL, HFILL }
},
{ &hf_smb2_negotiate_context_data_length,
{ "DataLength", "smb2.negotiate_context.data_length", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_negotiate_context_offset,
{ "NegotiateContextOffset", "smb2.negotiate_context.offset", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_negotiate_context_count,
{ "NegotiateContextCount", "smb2.negotiate_context.count", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_hash_alg_count,
{ "HashAlgorithmCount", "smb2.negotiate_context.hash_alg_count", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb2_hash_algorithm,
{ "HashAlgorithm", "smb2.negotiate_context.hash_algorithm", FT_UINT16, BASE_HEX,
VALS(smb2_hash_algorithm_types), 0, NULL, HFILL }},
{ &hf_smb2_salt_length,
{ "SaltLength", "smb2.negotiate_context.salt_length", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb2_salt,
{ "Salt", "smb2.negotiate_context.salt", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_smb2_signing_alg_count,
{ "SigningAlgorithmCount", "smb2.negotiate_context.signing_alg_count", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb2_signing_alg_id,
{ "SigningAlgorithmId", "smb2.negotiate_context.signing_id", FT_UINT16, BASE_HEX,
VALS(smb2_signing_alg_types), 0, NULL, HFILL }},
{ &hf_smb2_cipher_count,
{ "CipherCount", "smb2.negotiate_context.cipher_count", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb2_cipher_id,
{ "CipherId", "smb2.negotiate_context.cipher_id", FT_UINT16, BASE_HEX,
VALS(smb2_cipher_types), 0, NULL, HFILL }},
{ &hf_smb2_posix_reserved,
{ "POSIX Reserved", "smb2.negotiate_context.posix_reserved", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_inode,
{ "Inode", "smb2.inode", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_comp_alg_count,
{ "CompressionAlgorithmCount", "smb2.negotiate_context.comp_alg_count", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_smb2_comp_alg_id,
{ "CompressionAlgorithmId", "smb2.negotiate_context.comp_alg_id", FT_UINT16, BASE_HEX,
VALS(smb2_comp_alg_types), 0, NULL, HFILL }},
{ &hf_smb2_comp_alg_flags,
{ "Flags", "smb2.negotiate_context.comp_alg_flags", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_comp_alg_flags_chained,
{ "Chained", "smb2.negotiate_context.comp_alg_flags.chained", FT_BOOLEAN, 32,
NULL, SMB2_COMP_ALG_FLAGS_CHAINED, "Chained compression is supported on this connection", HFILL }
},
{ &hf_smb2_comp_alg_flags_reserved,
{ "Reserved", "smb2.negotiate_context.comp_alg_flags.reserved", FT_UINT32, BASE_HEX,
NULL, 0xFFFFFFFE, "Must be zero", HFILL }
},
{ &hf_smb2_netname_neg_id,
{ "Netname", "smb2.negotiate_context.netname", FT_STRING,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_transport_ctx_flags,
{ "Flags", "smb2.negotiate_context.transport_flags", FT_UINT32, BASE_HEX,
VALS(smb2_transport_ctx_flags_vals), 0, NULL, HFILL }
},
{ &hf_smb2_rdma_transform_count,
{ "TransformCount", "smb2.negotiate_context.rdma_transform_count", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_rdma_transform_reserved1,
{ "Reserved1", "smb2.negotiate_context.rdma_transform_reserved1", FT_UINT16, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_rdma_transform_reserved2,
{ "Reserved2", "smb2.negotiate_context.rdma_transform_reserved2", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_rdma_transform_id,
{ "RDMATransformId", "smb2.negotiate_context.rdma_transform_id", FT_UINT16, BASE_HEX,
VALS(smb2_rdma_transform_types), 0, NULL, HFILL }
},
{ &hf_smb2_current_time,
{ "Current Time", "smb2.current_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "Current Time at server", HFILL }
},
{ &hf_smb2_boot_time,
{ "Boot Time", "smb2.boot_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "Boot Time at server", HFILL }
},
{ &hf_smb2_ea_flags,
{ "EA Flags", "smb2.ea.flags", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_ea_name_len,
{ "EA Name Length", "smb2.ea.name_len", FT_UINT8, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_ea_data_len,
{ "EA Data Length", "smb2.ea.data_len", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_delete_pending,
{ "Delete Pending", "smb2.delete_pending", FT_UINT8, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_is_directory,
{ "Is Directory", "smb2.is_directory", FT_UINT8, BASE_DEC,
NULL, 0, "Is this a directory?", HFILL }
},
{ &hf_smb2_oplock,
{ "Oplock", "smb2.create.oplock", FT_UINT8, BASE_HEX,
VALS(oplock_vals), 0, "Oplock type", HFILL }
},
{ &hf_smb2_close_flags,
{ "Close Flags", "smb2.close.flags", FT_UINT16, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_notify_flags,
{ "Notify Flags", "smb2.notify.flags", FT_UINT16, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_buffer_code,
{ "StructureSize", "smb2.buffer_code", FT_UINT16, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_buffer_code_len,
{ "Fixed Part Length", "smb2.buffer_code.length", FT_UINT16, BASE_DEC,
NULL, 0xFFFE, "Length of fixed portion of PDU", HFILL }
},
{ &hf_smb2_olb_length,
{ "Blob Length", "smb2.olb.length", FT_UINT32, BASE_DEC,
NULL, 0, "Length of the buffer", HFILL }
},
{ &hf_smb2_olb_offset,
{ "Blob Offset", "smb2.olb.offset", FT_UINT32, BASE_HEX,
NULL, 0, "Offset to the buffer", HFILL }
},
{ &hf_smb2_buffer_code_flags_dyn,
{ "Dynamic Part", "smb2.buffer_code.dynamic", FT_BOOLEAN, 16,
NULL, 0x0001, "Whether a dynamic length blob follows", HFILL }
},
{ &hf_smb2_ea_data,
{ "EA Data", "smb2.ea.data", FT_BYTES, BASE_NONE|BASE_SHOW_ASCII_PRINTABLE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_ea_name,
{ "EA Name", "smb2.ea.name", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_impersonation_level,
{ "Impersonation level", "smb2.impersonation.level", FT_UINT32, BASE_DEC,
VALS(impersonation_level_vals), 0, NULL, HFILL }
},
{ &hf_smb2_ioctl_function,
{ "Function", "smb2.ioctl.function", FT_UINT32, BASE_HEX | BASE_EXT_STRING,
&smb2_ioctl_vals_ext, 0, "Ioctl function", HFILL }
},
{ &hf_smb2_ioctl_function_device,
{ "Device", "smb2.ioctl.function.device", FT_UINT32, BASE_HEX | BASE_EXT_STRING,
&smb2_ioctl_device_vals_ext, 0xffff0000, "Device for Ioctl", HFILL }
},
{ &hf_smb2_ioctl_function_access,
{ "Access", "smb2.ioctl.function.access", FT_UINT32, BASE_HEX,
VALS(smb2_ioctl_access_vals), 0x0000c000, "Access for Ioctl", HFILL }
},
{ &hf_smb2_ioctl_function_function,
{ "Function", "smb2.ioctl.function.function", FT_UINT32, BASE_HEX,
NULL, 0x00003ffc, "Function for Ioctl", HFILL }
},
{ &hf_smb2_ioctl_function_method,
{ "Method", "smb2.ioctl.function.method", FT_UINT32, BASE_HEX,
VALS(smb2_ioctl_method_vals), 0x00000003, "Method for Ioctl", HFILL }
},
{ &hf_smb2_fsctl_pipe_wait_timeout,
{ "Timeout", "smb2.fsctl.wait.timeout", FT_INT64, BASE_DEC,
NULL, 0, "Wait timeout", HFILL }
},
{ &hf_smb2_fsctl_pipe_wait_name,
{ "Name", "smb2.fsctl.wait.name", FT_STRING, BASE_NONE,
NULL, 0, "Pipe name", HFILL }
},
{ &hf_smb2_fsctl_odx_token_type,
{ "TokenType", "smb2.fsctl.odx.token.type", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_fsctl_odx_token_idlen,
{ "TokenIdLength", "smb2.fsctl.odx.token.idlen", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_fsctl_odx_token_idraw,
{ "TokenId", "smb2.fsctl.odx.token.id", FT_BYTES, BASE_NONE,
NULL, 0, "Token ID (opaque)", HFILL }
},
{ &hf_smb2_fsctl_odx_token_ttl,
{ "TokenTimeToLive", "smb2.fsctl.odx.token_ttl", FT_UINT32, BASE_DEC,
NULL, 0, "TTL requested for the token (in milliseconds)", HFILL }
},
{ &hf_smb2_fsctl_odx_size,
{ "Size", "smb2.fsctl.odx.size", FT_UINT32, BASE_DEC,
NULL, 0, "Size of this data element", HFILL }
},
{ &hf_smb2_fsctl_odx_flags,
{ "Flags", "smb2.fsctl.odx.flags", FT_UINT32, BASE_HEX,
NULL, 0, "Flags for this operation", HFILL }
},
{ &hf_smb2_fsctl_odx_file_offset,
{ "FileOffset", "smb2.fsctl.odx.file_offset", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_fsctl_odx_copy_length,
{ "CopyLength", "smb2.fsctl.odx.copy_length", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_fsctl_odx_xfer_length,
{ "TransferLength", "smb2.fsctl.odx.xfer_length", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_fsctl_odx_token_offset,
{ "TokenOffset", "smb2.fsctl.odx.token_offset", FT_UINT64, BASE_DEC,
NULL, 0, "Token Offset (relative to start of token)", HFILL }
},
{ &hf_smb2_fsctl_sparse_flag,
{ "SetSparse", "smb2.fsctl.set_sparse", FT_BOOLEAN, 8,
NULL, 0xFF, NULL, HFILL }
},
{ &hf_smb2_ioctl_resiliency_timeout,
{ "Timeout", "smb2.ioctl.resiliency.timeout", FT_UINT32, BASE_DEC,
NULL, 0, "Resiliency timeout", HFILL }
},
{ &hf_smb2_ioctl_resiliency_reserved,
{ "Reserved", "smb2.ioctl.resiliency.reserved", FT_UINT32, BASE_DEC,
NULL, 0, "Resiliency reserved", HFILL }
},
{ &hf_smb2_ioctl_shared_virtual_disk_support,
{ "SharedVirtualDiskSupport", "smb2.ioctl.shared_virtual_disk.support", FT_UINT32, BASE_HEX,
VALS(smb2_ioctl_shared_virtual_disk_vals), 0, "Supported shared capabilities", HFILL }
},
{ &hf_smb2_ioctl_shared_virtual_disk_handle_state,
{ "SharedVirtualDiskHandleState", "smb2.ioctl.shared_virtual_disk.handle_state", FT_UINT32, BASE_HEX,
VALS(smb2_ioctl_shared_virtual_disk_hstate_vals), 0, NULL, HFILL }
},
{ &hf_smb2_ioctl_sqos_protocol_version,
{ "ProtocolVersion", "smb2.ioctl.sqos.protocol_version", FT_UINT16, BASE_HEX,
VALS(smb2_ioctl_sqos_protocol_version_vals), 0, NULL, HFILL }
},
{ &hf_smb2_ioctl_sqos_reserved,
{ "Reserved", "smb2.ioctl.sqos.reserved", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_ioctl_sqos_options,
{ "Operations", "smb2.ioctl.sqos.operations", FT_UINT32, BASE_HEX,
NULL, 0, "SQOS operations", HFILL }
},
{ &hf_smb2_ioctl_sqos_op_set_logical_flow_id,
{ "Set Logical Flow ID", "smb2.ioctl.sqos.operations.set_logical_flow_id", FT_BOOLEAN, 32,
NULL, STORAGE_QOS_CONTROL_FLAG_SET_LOGICAL_FLOW_ID, "Whether Set Logical Flow ID operation is performed", HFILL }
},
{ &hf_smb2_ioctl_sqos_op_set_policy,
{ "Set Policy", "smb2.ioctl.sqos.operations.set_policy", FT_BOOLEAN, 32,
NULL, STORAGE_QOS_CONTROL_FLAG_SET_POLICY, "Whether Set Policy operation is performed", HFILL }
},
{ &hf_smb2_ioctl_sqos_op_probe_policy,
{ "Probe Policy", "smb2.ioctl.sqos.operations.probe_policy", FT_BOOLEAN, 32,
NULL, STORAGE_QOS_CONTROL_FLAG_PROBE_POLICY, "Whether Probe Policy operation is performed", HFILL }
},
{ &hf_smb2_ioctl_sqos_op_get_status,
{ "Get Status", "smb2.ioctl.sqos.operations.get_status", FT_BOOLEAN, 32,
NULL, STORAGE_QOS_CONTROL_FLAG_GET_STATUS, "Whether Get Status operation is performed", HFILL }
},
{ &hf_smb2_ioctl_sqos_op_update_counters,
{ "Update Counters", "smb2.ioctl.sqos.operations.update_counters", FT_BOOLEAN, 32,
NULL, STORAGE_QOS_CONTROL_FLAG_UPDATE_COUNTERS, "Whether Update Counters operation is performed", HFILL }
},
{ &hf_smb2_ioctl_sqos_logical_flow_id,
{ "LogicalFlowID", "smb2.ioctl.sqos.logical_flow_id", FT_GUID, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_ioctl_sqos_policy_id,
{ "PolicyID", "smb2.ioctl.sqos.policy_id", FT_GUID, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_ioctl_sqos_initiator_id,
{ "InitiatorID", "smb2.ioctl.sqos.initiator_id", FT_GUID, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_ioctl_sqos_limit,
{ "Limit", "smb2.ioctl.sqos.limit", FT_UINT64, BASE_DEC,
NULL, 0, "Desired maximum throughput for the logical flow, in normalized IOPS", HFILL }
},
{ &hf_smb2_ioctl_sqos_reservation,
{ "Reservation", "smb2.ioctl.sqos.reservation", FT_UINT64, BASE_DEC,
NULL, 0, "Desired minimum throughput for the logical flow, in normalized 8KB IOPS", HFILL }
},
{ &hf_smb2_ioctl_sqos_initiator_name,
{ "InitiatorName", "smb2.ioctl.sqos.initiator_name", FT_STRING, BASE_NONE,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_ioctl_sqos_initiator_node_name,
{ "InitiatorNodeName", "smb2.ioctl.sqos.initiator_node_name", FT_STRING, BASE_NONE,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_ioctl_sqos_io_count_increment,
{ "IoCountIncrement", "smb2.ioctl.sqos.io_count_increment", FT_UINT64, BASE_DEC,
NULL, 0, "The total number of I/O requests issued by the initiator on the logical flow", HFILL }
},
{ &hf_smb2_ioctl_sqos_normalized_io_count_increment,
{ "NormalizedIoCountIncrement", "smb2.ioctl.sqos.normalized_io_count_increment", FT_UINT64, BASE_DEC,
NULL, 0, "The total number of normalized 8-KB I/O requests issued by the initiator on the logical flow", HFILL }
},
{ &hf_smb2_ioctl_sqos_latency_increment,
{ "LatencyIncrement", "smb2.ioctl.sqos.latency_increment", FT_UINT64, BASE_DEC,
NULL, 0, "The total latency (including initiator's queues delays) measured by the initiator", HFILL }
},
{ &hf_smb2_ioctl_sqos_lower_latency_increment,
{ "LowerLatencyIncrement", "smb2.ioctl.sqos.lower_latency_increment", FT_UINT64, BASE_DEC,
NULL, 0, "The total latency (excluding initiator's queues delays) measured by the initiator", HFILL }
},
{ &hf_smb2_ioctl_sqos_bandwidth_limit,
{ "BandwidthLimit", "smb2.ioctl.sqos.bandwidth_limit", FT_UINT64, BASE_DEC,
NULL, 0, "Desired maximum bandwidth for the logical flow, in kilobytes per second", HFILL }
},
{ &hf_smb2_ioctl_sqos_kilobyte_count_increment,
{ "KilobyteCountIncrement", "smb2.ioctl.sqos.kilobyte_count_increment", FT_UINT64, BASE_DEC,
NULL, 0, "The total data transfer length of all I/O requests, in kilobyte units, issued by the initiator on the logical flow", HFILL }
},
{ &hf_smb2_ioctl_sqos_time_to_live,
{ "TimeToLive", "smb2.ioctl.sqos.time_to_live", FT_UINT32, BASE_DEC,
NULL, 0, "The expected period of validity of the Status, MaximumIoRate and MinimumIoRate fields, expressed in milliseconds", HFILL }
},
{ &hf_smb2_ioctl_sqos_status,
{ "Status", "smb2.ioctl.sqos.status", FT_UINT32, BASE_HEX,
VALS(smb2_ioctl_sqos_status_vals), 0, "The current status of the logical flow", HFILL }
},
{ &hf_smb2_ioctl_sqos_maximum_io_rate,
{ "MaximumIoRate", "smb2.ioctl.sqos.maximum_io_rate", FT_UINT64, BASE_DEC,
NULL, 0, "The maximum I/O initiation rate currently assigned to the logical flow, expressed in normalized input/output operations per second (normalized IOPS)", HFILL }
},
{ &hf_smb2_ioctl_sqos_minimum_io_rate,
{ "MinimumIoRate", "smb2.ioctl.sqos.minimum_io_rate", FT_UINT64, BASE_DEC,
NULL, 0, "The minimum I/O completion rate currently assigned to the logical flow, expressed in normalized IOPS", HFILL }
},
{ &hf_smb2_ioctl_sqos_base_io_size,
{ "BaseIoSize", "smb2.ioctl.sqos.base_io_size", FT_UINT32, BASE_DEC,
NULL, 0, "The base I/O size used to compute the normalized size of an I/O request for the logical flow", HFILL }
},
{ &hf_smb2_ioctl_sqos_reserved2,
{ "Reserved", "smb2.ioctl.sqos.reserved2", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_ioctl_sqos_maximum_bandwidth,
{ "MaximumBandwidth", "smb2.ioctl.sqos.maximum_bandwidth", FT_UINT64, BASE_DEC,
NULL, 0, "The maximum bandwidth currently assigned to the logical flow, expressed in kilobytes per second", HFILL }
},
{ &hf_windows_sockaddr_family,
{ "Socket Family", "smb2.windows.sockaddr.family", FT_UINT16, BASE_DEC,
NULL, 0, "The socket address family (on windows)", HFILL }
},
{ &hf_windows_sockaddr_port,
{ "Socket Port", "smb2.windows.sockaddr.port", FT_UINT16, BASE_DEC,
NULL, 0, "The socket address port", HFILL }
},
{ &hf_windows_sockaddr_in_addr,
{ "Socket IPv4", "smb2.windows.sockaddr.in.addr", FT_IPv4, BASE_NONE,
NULL, 0, "The IPv4 address", HFILL }
},
{ &hf_windows_sockaddr_in6_flowinfo,
{ "IPv6 Flow Info", "smb2.windows.sockaddr.in6.flow_info", FT_UINT32, BASE_HEX,
NULL, 0, "The socket IPv6 flow info", HFILL }
},
{ &hf_windows_sockaddr_in6_addr,
{ "Socket IPv6", "smb2.windows.sockaddr.in6.addr", FT_IPv6, BASE_NONE,
NULL, 0, "The IPv6 address", HFILL }
},
{ &hf_windows_sockaddr_in6_scope_id,
{ "IPv6 Scope ID", "smb2.windows.sockaddr.in6.scope_id", FT_UINT32, BASE_DEC,
NULL, 0, "The socket IPv6 scope id", HFILL }
},
{ &hf_smb2_ioctl_network_interface_next_offset,
{ "Next Offset", "smb2.ioctl.network_interfaces.next_offset", FT_UINT32, BASE_HEX,
NULL, 0, "Offset to next entry in chain or 0", HFILL }
},
{ &hf_smb2_ioctl_network_interface_index,
{ "Interface Index", "smb2.ioctl.network_interfaces.index", FT_UINT32, BASE_DEC,
NULL, 0, "The index of the interface", HFILL }
},
{ &hf_smb2_ioctl_network_interface_rss_queue_count,
{ "RSS Queue Count", "smb2.ioctl.network_interfaces.rss_queue_count", FT_UINT32, BASE_DEC,
NULL, 0, "The RSS queue count", HFILL }
},
{ &hf_smb2_ioctl_network_interface_capabilities,
{ "Interface Cababilities", "smb2.ioctl.network_interfaces.capabilities", FT_UINT32, BASE_HEX,
NULL, 0, "The capabilities of the network interface", HFILL }
},
{ &hf_smb2_ioctl_network_interface_capability_rss,
{ "RSS", "smb2.ioctl.network_interfaces.capabilities.rss", FT_BOOLEAN, 32,
TFS(&tfs_smb2_ioctl_network_interface_capability_rss), NETWORK_INTERFACE_CAP_RSS, "If the host supports RSS", HFILL }
},
{ &hf_smb2_ioctl_network_interface_capability_rdma,
{ "RDMA", "smb2.ioctl.network_interfaces.capabilities.rdma", FT_BOOLEAN, 32,
TFS(&tfs_smb2_ioctl_network_interface_capability_rdma), NETWORK_INTERFACE_CAP_RDMA, "If the host supports RDMA", HFILL }
},
{ &hf_smb2_ioctl_network_interface_link_speed,
{ "Link Speed", "smb2.ioctl.network_interfaces.link_speed", FT_UINT64, BASE_DEC,
NULL, 0, "The link speed of the interface", HFILL }
},
{ &hf_smb2_ioctl_enumerate_snapshots_num_snapshots,
{ "Number of snapshots", "smb2.ioctl.enumerate_snapshots.num_snapshots", FT_UINT32, BASE_DEC,
NULL, 0, "Number of previous versions associated with the volume", HFILL }
},
{ &hf_smb2_ioctl_enumerate_snapshots_num_snapshots_returned,
{ "Number of snapshots returned", "smb2.ioctl.enumerate_snapshots.num_snapshots_returned", FT_UINT32, BASE_DEC,
NULL, 0, "Number of previous version time stamps returned", HFILL }
},
{ &hf_smb2_ioctl_enumerate_snapshots_snapshot_array_size,
{ "Array size", "smb2.ioctl.enumerate_snapshots.array_size", FT_UINT32, BASE_DEC,
NULL, 0, "Number of bytes for snapshot time stamp strings", HFILL }
},
{ &hf_smb2_ioctl_enumerate_snapshots_snapshot,
{ "Snapshot", "smb2.ioctl.enumerate_snapshots.snapshot", FT_STRINGZ, BASE_NONE,
NULL, 0, "Time stamp of previous version", HFILL }
},
{ &hf_smb2_tree_connect_flags,
{ "Flags", "smb2.tc.flags", FT_UINT16, BASE_HEX,
NULL, 0, "Tree Connect flags", HFILL }
},
{ &hf_smb2_tc_cluster_reconnect,
{ "Cluster Reconnect", "smb2.tc.cluster_reconnect", FT_BOOLEAN, 16,
TFS(&tfs_set_notset), 0x0001, "If this is a Cluster Reconnect", HFILL }
},
{ &hf_smb2_tc_redirect_to_owner,
{ "Redirect To Owner", "smb2.tc.redirect_to_owner", FT_BOOLEAN, 16,
TFS(&tfs_set_notset), 0x0002, "Set if the client can handle Share Redirects", HFILL }
},
{ &hf_smb2_tc_extension_present,
{ "Extension Present", "smb2.tc.extension_present", FT_BOOLEAN, 16,
TFS(&tfs_set_notset), 0x0004, "Set if an extension structure is present", HFILL }
},
{ &hf_smb2_tc_reserved,
{ "Reserved", "smb2.tc.reserved", FT_UINT16, BASE_HEX,
NULL, 0xFFF8, "Must be zero", HFILL }
},
{ &hf_smb2_compression_format,
{ "Compression Format", "smb2.compression_format", FT_UINT16, BASE_DEC,
VALS(compression_format_vals), 0, NULL, HFILL }
},
{ &hf_smb2_checksum_algorithm,
{ "Checksum Algorithm", "smb2.checksum_algorithm", FT_UINT16, BASE_HEX,
VALS(checksum_algorithm_vals), 0, NULL, HFILL }
},
{ &hf_smb2_integrity_reserved,
{ "Reserved", "smb2.integrity_reserved", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_integrity_flags,
{ "Flags", "smb2.integrity_flags", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_integrity_flags_enforcement_off,
{ "FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF", "smb2.integrity_flags_enforcement", FT_BOOLEAN, 32,
NULL, 0x1, "If checksum error enforcement is off", HFILL }
},
{ &hf_smb2_share_type,
{ "Share Type", "smb2.share_type", FT_UINT8, BASE_HEX,
VALS(smb2_share_type_vals), 0, "Type of share", HFILL }
},
{ &hf_smb2_credit_charge,
{ "Credit Charge", "smb2.credit.charge", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_credits_requested,
{ "Credits requested", "smb2.credits.requested", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_credits_granted,
{ "Credits granted", "smb2.credits.granted", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_channel_sequence,
{ "Channel Sequence", "smb2.channel_sequence", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_dialect_count,
{ "Dialect count", "smb2.dialect_count", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_dialect,
{ "Dialect", "smb2.dialect", FT_UINT16, BASE_HEX,
VALS(smb2_dialect_vals), 0, NULL, HFILL }
},
{ &hf_smb2_security_mode,
{ "Security mode", "smb2.sec_mode", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_session_flags,
{ "Session Flags", "smb2.session_flags", FT_UINT16, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_lock_count,
{ "Lock Count", "smb2.lock_count", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_lock_sequence_number,
{ "Lock Sequence Number", "smb2.lock_sequence_number", FT_UINT32, BASE_DEC,
NULL, 0x0000000F, NULL, HFILL }
},
{ &hf_smb2_lock_sequence_index,
{ "Lock Sequence Index", "smb2.lock_sequence_index", FT_UINT32, BASE_DEC,
NULL, 0xFFFFFFF0, NULL, HFILL }
},
{ &hf_smb2_capabilities,
{ "Capabilities", "smb2.capabilities", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_auth_frame,
{ "Authenticated in Frame", "smb2.auth_frame", FT_UINT32, BASE_DEC,
NULL, 0, "Which frame this user was authenticated in", HFILL }
},
{ &hf_smb2_tcon_frame,
{ "Connected in Frame", "smb2.tcon_frame", FT_UINT32, BASE_DEC,
NULL, 0, "Which frame this share was connected in", HFILL }
},
{ &hf_smb2_tag,
{ "Tag", "smb2.tag", FT_STRING, BASE_NONE,
NULL, 0, "Tag of chain entry", HFILL }
},
{ &hf_smb2_acct_name,
{ "Account", "smb2.acct", FT_STRING, BASE_NONE,
NULL, 0, "Account Name", HFILL }
},
{ &hf_smb2_domain_name,
{ "Domain", "smb2.domain", FT_STRING, BASE_NONE,
NULL, 0, "Domain Name", HFILL }
},
{ &hf_smb2_host_name,
{ "Host", "smb2.host", FT_STRING, BASE_NONE,
NULL, 0, "Host Name", HFILL }
},
{ &hf_smb2_signature,
{ "Signature", "smb2.signature", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_unknown,
{ "Unknown", "smb2.unknown", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_twrp_timestamp,
{ "Timestamp", "smb2.twrp_timestamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "TWrp timestamp", HFILL }
},
{ &hf_smb2_mxac_timestamp,
{ "Timestamp", "smb2.mxac_timestamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "MxAc timestamp", HFILL }
},
{ &hf_smb2_mxac_status,
{ "Query Status", "smb2.mxac_status", FT_UINT32, BASE_HEX | BASE_EXT_STRING,
&NT_errors_ext, 0, "NT Status code", HFILL }
},
{ &hf_smb2_qfid_fid,
{ "Opaque File ID", "smb2.qfid_fid", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_ses_flags_guest,
{ "Guest", "smb2.ses_flags.guest", FT_BOOLEAN, 16,
NULL, SES_FLAGS_GUEST, NULL, HFILL }
},
{ &hf_smb2_ses_flags_null,
{ "Null", "smb2.ses_flags.null", FT_BOOLEAN, 16,
NULL, SES_FLAGS_NULL, NULL, HFILL }
},
{ &hf_smb2_ses_flags_encrypt,
{ "Encrypt", "smb2.ses_flags.encrypt", FT_BOOLEAN, 16,
NULL, SES_FLAGS_ENCRYPT, NULL, HFILL }},
{ &hf_smb2_secmode_flags_sign_required,
{ "Signing required", "smb2.sec_mode.sign_required", FT_BOOLEAN, 8,
NULL, NEGPROT_SIGN_REQ, "Is signing required", HFILL }
},
{ &hf_smb2_secmode_flags_sign_enabled,
{ "Signing enabled", "smb2.sec_mode.sign_enabled", FT_BOOLEAN, 8,
NULL, NEGPROT_SIGN_ENABLED, "Is signing enabled", HFILL }
},
{ &hf_smb2_ses_req_flags,
{ "Flags", "smb2.ses_req_flags", FT_UINT8, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_ses_req_flags_session_binding,
{ "Session Binding Request", "smb2.ses_req_flags.session_binding", FT_BOOLEAN, 8,
NULL, SES_REQ_FLAGS_SESSION_BINDING, "The client wants to bind to an existing session", HFILL }
},
{ &hf_smb2_cap_dfs,
{ "DFS", "smb2.capabilities.dfs", FT_BOOLEAN, 32,
TFS(&tfs_cap_dfs), NEGPROT_CAP_DFS, "If the host supports dfs", HFILL }
},
{ &hf_smb2_cap_leasing,
{ "LEASING", "smb2.capabilities.leasing", FT_BOOLEAN, 32,
TFS(&tfs_cap_leasing), NEGPROT_CAP_LEASING, "If the host supports leasing", HFILL }
},
{ &hf_smb2_cap_large_mtu,
{ "LARGE MTU", "smb2.capabilities.large_mtu", FT_BOOLEAN, 32,
TFS(&tfs_cap_large_mtu), NEGPROT_CAP_LARGE_MTU, "If the host supports LARGE MTU", HFILL }
},
{ &hf_smb2_cap_multi_channel,
{ "MULTI CHANNEL", "smb2.capabilities.multi_channel", FT_BOOLEAN, 32,
TFS(&tfs_cap_multi_channel), NEGPROT_CAP_MULTI_CHANNEL, "If the host supports MULTI CHANNEL", HFILL }
},
{ &hf_smb2_cap_persistent_handles,
{ "PERSISTENT HANDLES", "smb2.capabilities.persistent_handles", FT_BOOLEAN, 32,
TFS(&tfs_cap_persistent_handles), NEGPROT_CAP_PERSISTENT_HANDLES, "If the host supports PERSISTENT HANDLES", HFILL }
},
{ &hf_smb2_cap_directory_leasing,
{ "DIRECTORY LEASING", "smb2.capabilities.directory_leasing", FT_BOOLEAN, 32,
TFS(&tfs_cap_directory_leasing), NEGPROT_CAP_DIRECTORY_LEASING, "If the host supports DIRECTORY LEASING", HFILL }
},
{ &hf_smb2_cap_encryption,
{ "ENCRYPTION", "smb2.capabilities.encryption", FT_BOOLEAN, 32,
TFS(&tfs_cap_encryption), NEGPROT_CAP_ENCRYPTION, "If the host supports ENCRYPTION", HFILL }
},
{ &hf_smb2_max_trans_size,
{ "Max Transaction Size", "smb2.max_trans_size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_max_read_size,
{ "Max Read Size", "smb2.max_read_size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_max_write_size,
{ "Max Write Size", "smb2.max_write_size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_channel,
{ "Channel", "smb2.channel", FT_UINT32, BASE_HEX,
VALS(smb2_channel_vals), 0, NULL, HFILL }
},
{ &hf_smb2_rdma_v1_offset,
{ "Offset", "smb2.buffer_descriptor.offset", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_rdma_v1_token,
{ "Token", "smb2.buffer_descriptor.token", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_rdma_v1_length,
{ "Length", "smb2.buffer_descriptor.length", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_share_flags,
{ "Share flags", "smb2.share_flags", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_share_flags_dfs,
{ "DFS", "smb2.share_flags.dfs", FT_BOOLEAN, 32,
NULL, SHARE_FLAGS_dfs, "The specified share is present in a Distributed File System (DFS) tree structure", HFILL }
},
{ &hf_smb2_share_flags_dfs_root,
{ "DFS root", "smb2.share_flags.dfs_root", FT_BOOLEAN, 32,
NULL, SHARE_FLAGS_dfs_root, "The specified share is present in a Distributed File System (DFS) tree structure", HFILL }
},
{ &hf_smb2_share_flags_restrict_exclusive_opens,
{ "Restrict exclusive opens", "smb2.share_flags.restrict_exclusive_opens", FT_BOOLEAN, 32,
NULL, SHARE_FLAGS_restrict_exclusive_opens, "The specified share disallows exclusive file opens that deny reads to an open file", HFILL }
},
{ &hf_smb2_share_flags_force_shared_delete,
{ "Force shared delete", "smb2.share_flags.force_shared_delete", FT_BOOLEAN, 32,
NULL, SHARE_FLAGS_force_shared_delete, "Shared files in the specified share can be forcibly deleted", HFILL }
},
{ &hf_smb2_share_flags_allow_namespace_caching,
{ "Allow namespace caching", "smb2.share_flags.allow_namespace_caching", FT_BOOLEAN, 32,
NULL, SHARE_FLAGS_allow_namespace_caching, "Clients are allowed to cache the namespace of the specified share", HFILL }
},
{ &hf_smb2_share_flags_access_based_dir_enum,
{ "Access based directory enum", "smb2.share_flags.access_based_dir_enum", FT_BOOLEAN, 32,
NULL, SHARE_FLAGS_access_based_dir_enum, "The server will filter directory entries based on the access permissions of the client", HFILL }
},
{ &hf_smb2_share_flags_force_levelii_oplock,
{ "Force level II oplock", "smb2.share_flags.force_levelii_oplock", FT_BOOLEAN, 32,
NULL, SHARE_FLAGS_force_levelii_oplock, "The server will not issue exclusive caching rights on this share", HFILL }
},
{ &hf_smb2_share_flags_enable_hash_v1,
{ "Enable hash V1", "smb2.share_flags.enable_hash_v1", FT_BOOLEAN, 32,
NULL, SHARE_FLAGS_enable_hash_v1, "The share supports hash generation V1 for branch cache retrieval of data (see also section 2.2.31.2 of MS-SMB2)", HFILL }
},
{ &hf_smb2_share_flags_enable_hash_v2,
{ "Enable hash V2", "smb2.share_flags.enable_hash_v2", FT_BOOLEAN, 32,
NULL, SHARE_FLAGS_enable_hash_v2, "The share supports hash generation V2 for branch cache retrieval of data (see also section 2.2.31.2 of MS-SMB2)", HFILL }
},
{ &hf_smb2_share_flags_encrypt_data,
{ "Encrypted data required", "smb2.share_flags.encrypt_data", FT_BOOLEAN, 32,
NULL, SHARE_FLAGS_encryption_required, "The share require data encryption", HFILL }
},
{ &hf_smb2_share_flags_identity_remoting,
{ "Identity Remoting", "smb2.share_flags.identity_remoting", FT_BOOLEAN, 32,
NULL, SHARE_FLAGS_identity_remoting, "The specified share supports Identity Remoting", HFILL }
},
{ &hf_smb2_share_flags_compress_data,
{ "Compressed IO", "smb2.share_flags.compress_data", FT_BOOLEAN, 32,
NULL, SHARE_FLAGS_compress_data, "The share supports compression of read/write messages", HFILL }
},
{ &hf_smb2_share_flags_isolated_transport,
{ "Isolated Transport", "smb2.share_flags.isolated_transport", FT_BOOLEAN, 32,
NULL, SHARE_FLAGS_isolated_transport, "The server indicates that administrator set share property telling client that it is preferable to isolate communication to that share on a separate set of connections.", HFILL }
},
{ &hf_smb2_share_caching,
{ "Caching policy", "smb2.share.caching", FT_UINT32, BASE_HEX,
VALS(share_cache_vals), 0, NULL, HFILL }
},
{ &hf_smb2_share_caps,
{ "Share Capabilities", "smb2.share_caps", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_share_caps_dfs,
{ "DFS", "smb2.share_caps.dfs", FT_BOOLEAN, 32,
NULL, SHARE_CAPS_DFS, "The specified share is present in a DFS tree structure", HFILL }
},
{ &hf_smb2_share_caps_continuous_availability,
{ "CONTINUOUS AVAILABILITY", "smb2.share_caps.continuous_availability", FT_BOOLEAN, 32,
NULL, SHARE_CAPS_CONTINUOUS_AVAILABILITY, "The specified share is continuously available", HFILL }
},
{ &hf_smb2_share_caps_scaleout,
{ "SCALEOUT", "smb2.share_caps.scaleout", FT_BOOLEAN, 32,
NULL, SHARE_CAPS_SCALEOUT, "The specified share is a scaleout share", HFILL }
},
{ &hf_smb2_share_caps_cluster,
{ "CLUSTER", "smb2.share_caps.cluster", FT_BOOLEAN, 32,
NULL, SHARE_CAPS_CLUSTER, "The specified share is a cluster share", HFILL }
},
{ &hf_smb2_share_caps_assymetric,
{ "ASSYMETRIC", "smb2.share_caps.assymetric", FT_BOOLEAN, 32,
NULL, SHARE_CAPS_ASSYMETRIC, "The specified share allows dynamic changes in ownership of the share", HFILL }
},
{ &hf_smb2_share_caps_redirect_to_owner,
{ "REDIRECT_TO_OWNER", "smb2.share_caps.redirect_to_owner", FT_BOOLEAN, 32,
NULL, SHARE_CAPS_REDIRECT_TO_OWNER, "The specified share supports synchronous share level redirection", HFILL }
},
{ &hf_smb2_ioctl_flags,
{ "Flags", "smb2.ioctl.flags", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_min_count,
{ "Min Count", "smb2.min_count", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_remaining_bytes,
{ "Remaining Bytes", "smb2.remaining_bytes", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_channel_info_offset,
{ "Channel Info Offset", "smb2.channel_info_offset", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_channel_info_length,
{ "Channel Info Length", "smb2.channel_info_length", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_channel_info_blob,
{ "Channel Info Blob", "smb2.channel_info_blob", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_ioctl_is_fsctl,
{ "Is FSCTL", "smb2.ioctl.is_fsctl", FT_BOOLEAN, 32,
NULL, 0x00000001, NULL, HFILL }
},
{ &hf_smb2_output_buffer_len,
{ "Output Buffer Length", "smb2.output_buffer_len", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_close_pq_attrib,
{ "PostQuery Attrib", "smb2.close.pq_attrib", FT_BOOLEAN, 16,
NULL, 0x0001, NULL, HFILL }
},
{ &hf_smb2_notify_watch_tree,
{ "Watch Tree", "smb2.notify.watch_tree", FT_BOOLEAN, 16,
NULL, 0x0001, NULL, HFILL }
},
{ &hf_smb2_notify_out_data,
{ "Out Data", "smb2.notify.out", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_notify_info,
{ "Notify Info", "smb2.notify.info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_notify_next_offset,
{ "Next Offset", "smb2.notify.next_offset", FT_UINT32, BASE_HEX,
NULL, 0, "Offset to next entry in chain or 0", HFILL }
},
{ &hf_smb2_notify_action,
{ "Action", "smb2.notify.action", FT_UINT32, BASE_HEX,
VALS(notify_action_vals), 0, "Notify Action", HFILL }
},
{ &hf_smb2_find_flags_restart_scans,
{ "Restart Scans", "smb2.find.restart_scans", FT_BOOLEAN, 8,
NULL, SMB2_FIND_FLAG_RESTART_SCANS, NULL, HFILL }
},
{ &hf_smb2_find_flags_single_entry,
{ "Single Entry", "smb2.find.single_entry", FT_BOOLEAN, 8,
NULL, SMB2_FIND_FLAG_SINGLE_ENTRY, NULL, HFILL }
},
{ &hf_smb2_find_flags_index_specified,
{ "Index Specified", "smb2.find.index_specified", FT_BOOLEAN, 8,
NULL, SMB2_FIND_FLAG_INDEX_SPECIFIED, NULL, HFILL }
},
{ &hf_smb2_find_flags_reopen,
{ "Reopen", "smb2.find.reopen", FT_BOOLEAN, 8,
NULL, SMB2_FIND_FLAG_REOPEN, NULL, HFILL }
},
{ &hf_smb2_file_index,
{ "File Index", "smb2.file_index", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_file_directory_info,
{ "FileDirectoryInfo", "smb2.find.file_directory_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_full_directory_info,
{ "FullDirectoryInfo", "smb2.find.full_directory_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_both_directory_info,
{ "FileBothDirectoryInfo", "smb2.find.both_directory_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_id_both_directory_info,
{ "FileIdBothDirectoryInfo", "smb2.find.id_both_directory_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_posix_info,
{ "FilePosixInfo", "smb2.find.posix_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_short_name_len,
{ "Short Name Length", "smb2.short_name_len", FT_UINT8, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_short_name,
{ "Short Name", "smb2.shortname", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_lock_info,
{ "Lock Info", "smb2.lock_info", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_lock_length,
{ "Length", "smb2.lock_length", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_lock_flags,
{ "Flags", "smb2.lock_flags", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_lock_flags_shared,
{ "Shared", "smb2.lock_flags.shared", FT_BOOLEAN, 32,
NULL, 0x00000001, NULL, HFILL }
},
{ &hf_smb2_lock_flags_exclusive,
{ "Exclusive", "smb2.lock_flags.exclusive", FT_BOOLEAN, 32,
NULL, 0x00000002, NULL, HFILL }
},
{ &hf_smb2_lock_flags_unlock,
{ "Unlock", "smb2.lock_flags.unlock", FT_BOOLEAN, 32,
NULL, 0x00000004, NULL, HFILL }
},
{ &hf_smb2_lock_flags_fail_immediately,
{ "Fail Immediately", "smb2.lock_flags.fail_immediately", FT_BOOLEAN, 32,
NULL, 0x00000010, NULL, HFILL }
},
{ &hf_smb2_error_context_count,
{ "Error Context Count", "smb2.error.context_count", FT_UINT8, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_error_reserved,
{ "Reserved", "smb2.error.reserved", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_error_byte_count,
{ "Byte Count", "smb2.error.byte_count", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_error_data,
{ "Error Data", "smb2.error.data", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_error_context,
{ "Error Context", "smb2.error.context", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_error_context_id,
{ "Type", "smb2.error.context.id", FT_UINT32, BASE_HEX,
VALS(smb2_error_id_vals), 0, NULL, HFILL }
},
{ &hf_smb2_error_context_length,
{ "Type", "smb2.error.context.length", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_error_min_buf_length,
{ "Minimum required buffer length", "smb2.error.min_buf_length", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_error_redir_context,
{ "Share Redirect", "smb2.error.share_redirect", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_error_redir_struct_size,
{ "Struct Size", "smb2.error.share_redirect.struct_size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_error_redir_notif_type,
{ "Notification Type", "smb2.error.share_redirect.notif_type", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_error_redir_flags,
{ "Flags", "smb2.error.share_redirect.flags", FT_UINT16, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_error_redir_target_type,
{ "Target Type", "smb2.error.share_redirect.target_type", FT_UINT16, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_error_redir_ip_count,
{ "IP Addr Count", "smb2.error.share_redirect.ip_count", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_error_redir_ip_list,
{ "IP Addr List", "smb2.error.share_redirect.ip_list", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_error_redir_res_name,
{ "Resource Name", "smb2.error.share_redirect.res_name", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_reserved,
{ "Reserved", "smb2.reserved", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_reserved_random,
{ "Reserved (Random)", "smb2.reserved.random", FT_BYTES, BASE_NONE,
NULL, 0, "Reserved bytes, random data", HFILL }
},
{ &hf_smb2_root_directory_mbz,
{ "Root Dir Handle (MBZ)", "smb2.root_directory", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_dhnq_buffer_reserved,
{ "Reserved", "smb2.dhnq_buffer_reserved", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_dh2x_buffer_timeout,
{ "Timeout", "smb2.dh2x.timeout", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_dh2x_buffer_flags,
{ "Flags", "smb2.dh2x.flags", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_dh2x_buffer_flags_persistent_handle,
{ "Persistent Handle", "smb2.dh2x.flags.persistent_handle", FT_BOOLEAN, 32,
NULL, SMB2_DH2X_FLAGS_PERSISTENT_HANDLE, NULL, HFILL }
},
{ &hf_smb2_dh2x_buffer_reserved,
{ "Reserved", "smb2.dh2x.reserved", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_dh2x_buffer_create_guid,
{ "Create Guid", "smb2.dh2x.create_guid", FT_GUID, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_APP_INSTANCE_buffer_struct_size,
{ "Struct Size", "smb2.app_instance.struct_size", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_APP_INSTANCE_buffer_reserved,
{ "Reserved", "smb2.app_instance.reserved", FT_UINT16, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_APP_INSTANCE_buffer_app_guid,
{ "Application Guid", "smb2.app_instance.app_guid", FT_GUID, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_svhdx_open_device_context_version,
{ "Version", "smb2.svhdx_open_device_context.version", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_svhdx_open_device_context_has_initiator_id,
{ "HasInitiatorId", "smb2.svhdx_open_device_context.initiator_has_id", FT_BOOLEAN, 8,
TFS(&tfs_smb2_svhdx_has_initiator_id), 0, "Whether the host has an initiator", HFILL }
},
{ &hf_smb2_svhdx_open_device_context_reserved,
{ "Reserved", "smb2.svhdx_open_device_context.reserved", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_svhdx_open_device_context_initiator_id,
{ "InitiatorId", "smb2.svhdx_open_device_context.initiator_id", FT_GUID, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_svhdx_open_device_context_flags,
{ "Flags", "smb2.svhdx_open_device_context.flags", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_svhdx_open_device_context_originator_flags,
{ "OriginatorFlags", "smb2.svhdx_open_device_context.originator_flags", FT_UINT32, BASE_HEX,
VALS(originator_flags_vals), 0, NULL, HFILL }
},
{ &hf_smb2_svhdx_open_device_context_open_request_id,
{ "OpenRequestId","smb2.svhxd_open_device_context.open_request_id", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_svhdx_open_device_context_initiator_host_name_len,
{ "HostNameLength", "smb2.svhxd_open_device_context.initiator_host_name_len", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_svhdx_open_device_context_initiator_host_name,
{ "HostName", "smb2.svhdx_open_device_context.host_name", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_svhdx_open_device_context_virtual_disk_properties_initialized,
{ "VirtualDiskPropertiesInitialized", "smb2.svhdx_open_device_context.virtual_disk_properties_initialized", FT_BOOLEAN, 32,
NULL, 0, "Whether VirtualSectorSize, PhysicalSectorSize, and VirtualSize fields are filled", HFILL }
},
{ &hf_smb2_svhdx_open_device_context_server_service_version,
{ "ServerServiceVersion", "smb2.svhdx_open_device_context.server_service_version", FT_UINT32, BASE_DEC,
NULL, 0, "The current version of the protocol running on the server", HFILL }
},
{ &hf_smb2_svhdx_open_device_context_virtual_sector_size,
{ "VirtualSectorSize", "smb2.svhdx_open_device_context.virtual_sector_size", FT_UINT32, BASE_DEC,
NULL, 0, "The virtual sector size of the virtual disk", HFILL }
},
{ &hf_smb2_svhdx_open_device_context_physical_sector_size,
{ "PhysicalSectorSize", "smb2.svhdx_open_device_context.physical_sector_size", FT_UINT32, BASE_DEC,
NULL, 0, "The physical sector size of the virtual disk", HFILL }
},
{ &hf_smb2_svhdx_open_device_context_virtual_size,
{ "VirtualSize", "smb2.svhdx_open_device_context.virtual_size", FT_UINT64, BASE_DEC,
NULL, 0, "The current length of the virtual disk, in bytes", HFILL }
},
{ &hf_smb2_app_instance_version_struct_size,
{ "Struct Size", "smb2.app_instance_version.struct_size", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_app_instance_version_reserved,
{ "Reserved", "smb2.app_instance_version.reserved", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_app_instance_version_padding,
{ "Padding", "smb2.app_instance_version.padding", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_app_instance_version_high,
{ "AppInstanceVersionHigh", "smb2.app_instance_version.version.high", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_app_instance_version_low,
{ "AppInstanceVersionLow", "smb2.app_instance_version.version.low", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_posix_perms,
{ "POSIX perms", "smb2.posix_perms", FT_UINT32, BASE_OCT,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_aapl_command_code,
{ "Command code", "smb2.aapl.command_code", FT_UINT32, BASE_DEC,
VALS(aapl_command_code_vals), 0, NULL, HFILL }
},
{ &hf_smb2_aapl_reserved,
{ "Reserved", "smb2.aapl.reserved", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_aapl_server_query_bitmask,
{ "Query bitmask", "smb2.aapl.query_bitmask", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_aapl_server_query_bitmask_server_caps,
{ "Server capabilities", "smb2.aapl.bitmask.server_caps", FT_BOOLEAN, 64,
NULL, SMB2_AAPL_SERVER_CAPS, NULL, HFILL }
},
{ &hf_smb2_aapl_server_query_bitmask_volume_caps,
{ "Volume capabilities", "smb2.aapl.bitmask.volume_caps", FT_BOOLEAN, 64,
NULL, SMB2_AAPL_VOLUME_CAPS, NULL, HFILL }
},
{ &hf_smb2_aapl_server_query_bitmask_model_info,
{ "Model information", "smb2.aapl.bitmask.model_info", FT_BOOLEAN, 64,
NULL, SMB2_AAPL_MODEL_INFO, NULL, HFILL }
},
{ &hf_smb2_aapl_server_query_caps,
{ "Client/Server capabilities", "smb2.aapl.caps", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_aapl_server_query_caps_supports_read_dir_attr,
{ "Supports READDIRATTR", "smb2.aapl.caps.supports_read_dir_addr", FT_BOOLEAN, 64,
NULL, SMB2_AAPL_SUPPORTS_READ_DIR_ATTR, NULL, HFILL }
},
{ &hf_smb2_aapl_server_query_caps_supports_osx_copyfile,
{ "Supports macOS copyfile", "smb2.aapl.caps.supports_osx_copyfile", FT_BOOLEAN, 64,
NULL, SMB2_AAPL_SUPPORTS_OSX_COPYFILE, NULL, HFILL }
},
{ &hf_smb2_aapl_server_query_caps_unix_based,
{ "UNIX-based", "smb2.aapl.caps.unix_based", FT_BOOLEAN, 64,
NULL, SMB2_AAPL_UNIX_BASED, NULL, HFILL }
},
{ &hf_smb2_aapl_server_query_caps_supports_nfs_ace,
{ "Supports NFS ACE", "smb2.aapl.supports_nfs_ace", FT_BOOLEAN, 64,
NULL, SMB2_AAPL_SUPPORTS_NFS_ACE, NULL, HFILL }
},
{ &hf_smb2_aapl_server_query_volume_caps,
{ "Volume capabilities", "smb2.aapl.volume_caps", FT_UINT64, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_aapl_server_query_volume_caps_support_resolve_id,
{ "Supports Resolve ID", "smb2.aapl.volume_caps.supports_resolve_id", FT_BOOLEAN, 64,
NULL, SMB2_AAPL_SUPPORTS_RESOLVE_ID, NULL, HFILL }
},
{ &hf_smb2_aapl_server_query_volume_caps_case_sensitive,
{ "Case sensitive", "smb2.aapl.volume_caps.case_sensitive", FT_BOOLEAN, 64,
NULL, SMB2_AAPL_CASE_SENSITIVE, NULL, HFILL }
},
{ &hf_smb2_aapl_server_query_volume_caps_supports_full_sync,
{ "Supports full sync", "smb2.aapl.volume_caps.supports_full_sync", FT_BOOLEAN, 64,
NULL, SMB2_AAPL_SUPPORTS_FULL_SYNC, NULL, HFILL }
},
{ &hf_smb2_aapl_server_query_model_string,
{ "Model string", "smb2.aapl.model_string", FT_UINT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_aapl_server_query_server_path,
{ "Server path", "smb2.aapl.server_path", FT_UINT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_transform_signature,
{ "Signature", "smb2.header.transform.signature", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_transform_nonce,
{ "Nonce", "smb2.header.transform.nonce", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_transform_msg_size,
{ "Message size", "smb2.header.transform.msg_size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_transform_reserved,
{ "Reserved", "smb2.header.transform.reserved", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }
},
/* SMB2 header flags */
{ &hf_smb2_transform_flags,
{ "Flags", "smb2.header.transform.flags", FT_UINT16, BASE_HEX,
NULL, 0, "SMB2 transform flags", HFILL }
},
{ &hf_smb2_transform_flags_encrypted,
{ "Encrypted", "smb2.header.transform.flags.encrypted", FT_BOOLEAN, 16,
NULL, SMB2_TRANSFORM_FLAGS_ENCRYPTED,
"Whether the payload is encrypted", HFILL }
},
{ &hf_smb2_transform_encrypted_data,
{ "Data", "smb2.header.transform.enc_data", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_comp_transform_orig_size,
{ "OriginalSize", "smb2.header.comp_transform.original_size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_comp_transform_comp_alg,
{ "CompressionAlgorithm", "smb2.header.comp_transform.comp_alg", FT_UINT16, BASE_HEX,
VALS(smb2_comp_alg_types), 0, NULL, HFILL }
},
{ &hf_smb2_comp_transform_flags,
{ "Flags", "smb2.header.comp_transform.flags", FT_UINT16, BASE_HEX,
VALS(smb2_comp_transform_flags_vals), 0, NULL, HFILL }
},
{ &hf_smb2_comp_transform_offset,
{ "Offset", "smb2.header.comp_transform.offset", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_comp_transform_length,
{ "Length", "smb2.header.comp_transform.length", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_comp_transform_data,
{ "CompressedData", "smb2.header.comp_transform.data", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_comp_transform_orig_payload_size,
{ "OriginalPayloadSize", "smb2.header.comp_transform.orig_payload_size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_comp_pattern_v1_pattern,
{ "Pattern", "smb2.pattern_v1.pattern", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_comp_pattern_v1_reserved1,
{ "Reserved1", "smb2.pattern_v1.reserved1", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_comp_pattern_v1_reserved2,
{ "Reserved2", "smb2.pattern_v1.reserved2", FT_UINT16, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_comp_pattern_v1_repetitions,
{ "Repetitions", "smb2.pattern_v1.repetitions", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_protocol_id,
{ "ProtocolId", "smb2.protocol_id", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_truncated,
{ "Truncated...", "smb2.truncated", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_pipe_fragment_overlap,
{ "Fragment overlap", "smb2.pipe.fragment.overlap", FT_BOOLEAN, BASE_NONE,
NULL, 0x0, "Fragment overlaps with other fragments", HFILL }
},
{ &hf_smb2_pipe_fragment_overlap_conflict,
{ "Conflicting data in fragment overlap", "smb2.pipe.fragment.overlap.conflict", FT_BOOLEAN, BASE_NONE,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_pipe_fragment_multiple_tails,
{ "Multiple tail fragments found", "smb2.pipe.fragment.multipletails", FT_BOOLEAN, BASE_NONE,
NULL, 0x0, "Several tails were found when defragmenting the packet", HFILL }
},
{ &hf_smb2_pipe_fragment_too_long_fragment,
{ "Fragment too long", "smb2.pipe.fragment.toolongfragment", FT_BOOLEAN, BASE_NONE,
NULL, 0x0, "Fragment contained data past end of packet", HFILL }
},
{ &hf_smb2_pipe_fragment_error,
{ "Defragmentation error", "smb2.pipe.fragment.error", FT_FRAMENUM, BASE_NONE,
NULL, 0x0, "Defragmentation error due to illegal fragments", HFILL }
},
{ &hf_smb2_pipe_fragment_count,
{ "Fragment count", "smb2.pipe.fragment.count", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_pipe_fragment,
{ "Fragment SMB2 Named Pipe", "smb2.pipe.fragment", FT_FRAMENUM, BASE_NONE,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_pipe_fragments,
{ "Reassembled SMB2 Named Pipe fragments", "smb2.pipe.fragments", FT_NONE, BASE_NONE,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_pipe_reassembled_in,
{ "This SMB2 Named Pipe payload is reassembled in frame", "smb2.pipe.reassembled_in", FT_FRAMENUM, BASE_NONE,
NULL, 0x0, "The Named Pipe PDU is completely reassembled in this frame", HFILL }
},
{ &hf_smb2_pipe_reassembled_length,
{ "Reassembled SMB2 Named Pipe length", "smb2.pipe.reassembled.length", FT_UINT32, BASE_DEC,
NULL, 0x0, "The total length of the reassembled payload", HFILL }
},
{ &hf_smb2_pipe_reassembled_data,
{ "Reassembled SMB2 Named Pipe Data", "smb2.pipe.reassembled.data", FT_BYTES, BASE_NONE,
NULL, 0x0, "The reassembled payload", HFILL }
},
{ &hf_smb2_cchunk_resume_key,
{ "ResumeKey", "smb2.fsctl.cchunk.resume_key", FT_BYTES, BASE_NONE,
NULL, 0x0, "Opaque data representing source of copy", HFILL }
},
{ &hf_smb2_cchunk_count,
{ "Chunk Count", "smb2.fsctl.cchunk.count", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_cchunk_src_offset,
{ "Source Offset", "smb2.fsctl.cchunk.src_offset", FT_UINT64, BASE_DEC,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_cchunk_dst_offset,
{ "Target Offset", "smb2.fsctl.cchunk.dst_offset", FT_UINT64, BASE_DEC,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_cchunk_xfer_len,
{ "Transfer Length", "smb2.fsctl.cchunk.xfer_len", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_cchunk_chunks_written,
{ "Chunks Written", "smb2.fsctl.cchunk.chunks_written", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_cchunk_bytes_written,
{ "Chunk Bytes Written", "smb2.fsctl.cchunk.bytes_written", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_cchunk_total_written,
{ "Total Bytes Written", "smb2.fsctl.cchunk.total_written", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_reparse_tag,
{ "Reparse Tag", "smb2.reparse_tag", FT_UINT32, BASE_HEX,
VALS(reparse_tag_vals), 0x0, NULL, HFILL }
},
{ &hf_smb2_reparse_guid,
{ "Reparse GUID", "smb2.reparse_guid", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_reparse_data_length,
{ "Reparse Data Length", "smb2.reparse_data_length", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_reparse_data_buffer,
{ "Reparse Data Buffer", "smb2.reparse_data_buffer", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_nfs_type,
{ "NFS file type", "smb2.nfs.type", FT_UINT64, BASE_HEX|BASE_VAL64_STRING,
VALS64(nfs_type_vals), 0x0, NULL, HFILL }
},
{ &hf_smb2_nfs_symlink_target,
{ "Symlink Target", "smb2.nfs.symlink.target", FT_STRING,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_nfs_chr_major,
{ "Major", "smb2.nfs.char.major", FT_UINT32,
BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_nfs_chr_minor,
{ "Minor", "smb2.nfs.char.minor", FT_UINT32,
BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_nfs_blk_major,
{ "Major", "smb2.nfs.block.major", FT_UINT32,
BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_nfs_blk_minor,
{ "Minor", "smb2.nfs.block.minor", FT_UINT32,
BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_symlink_error_response,
{ "Symbolic Link Error Response", "smb2.symlink_error_response", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }
},
{ &hf_smb2_symlink_length,
{ "SymLink Length", "smb2.symlink.length", FT_UINT32,
BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_symlink_error_tag,
{ "SymLink Error Tag", "smb2.symlink.error_tag", FT_UINT32,
BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_unparsed_path_length,
{ "Unparsed Path Length", "smb2.symlink.unparsed_path_length", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_symlink_substitute_name,
{ "Substitute Name", "smb2.symlink.substitute_name", FT_STRING, BASE_NONE,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_symlink_print_name,
{ "Print Name", "smb2.symlink.print_name", FT_STRING, BASE_NONE,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_symlink_flags,
{ "Flags", "smb2.symlink.flags", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_fscc_file_attr,
{ "File Attributes", "smb2.file_attribute", FT_UINT32, BASE_HEX,
NULL, 0x0, NULL, HFILL }
},
{ &hf_smb2_fscc_file_attr_read_only,
{ "Read Only", "smb2.file_attribute.read_only", FT_BOOLEAN, 32,
TFS(&tfs_yes_no), SMB2_FSCC_FILE_ATTRIBUTE_READ_ONLY, "READ ONLY file attribute", HFILL } },
{ &hf_smb2_fscc_file_attr_hidden,
{ "Hidden", "smb2.file_attribute.hidden", FT_BOOLEAN, 32,
TFS(&tfs_yes_no), SMB2_FSCC_FILE_ATTRIBUTE_HIDDEN, "HIDDEN file attribute", HFILL } },
{ &hf_smb2_fscc_file_attr_system,
{ "System", "smb2.file_attribute.system", FT_BOOLEAN, 32,
TFS(&tfs_yes_no), SMB2_FSCC_FILE_ATTRIBUTE_SYSTEM, "SYSTEM file attribute", HFILL } },
{ &hf_smb2_fscc_file_attr_directory,
{ "Directory", "smb2.file_attribute.directory", FT_BOOLEAN, 32,
TFS(&tfs_yes_no), SMB2_FSCC_FILE_ATTRIBUTE_DIRECTORY, "DIRECTORY file attribute", HFILL } },
{ &hf_smb2_fscc_file_attr_archive,
{ "Requires archived", "smb2.file_attribute.archive", FT_BOOLEAN, 32,
TFS(&tfs_yes_no), SMB2_FSCC_FILE_ATTRIBUTE_ARCHIVE, "ARCHIVE file attribute", HFILL } },
{ &hf_smb2_fscc_file_attr_normal,
{ "Normal", "smb2.file_attribute.normal", FT_BOOLEAN, 32,
TFS(&tfs_yes_no), SMB2_FSCC_FILE_ATTRIBUTE_NORMAL, "Is this a normal file?", HFILL } },
{ &hf_smb2_fscc_file_attr_temporary,
{ "Temporary", "smb2.file_attribute.temporary", FT_BOOLEAN, 32,
TFS(&tfs_yes_no), SMB2_FSCC_FILE_ATTRIBUTE_TEMPORARY, "Is this a temporary file?", HFILL } },
{ &hf_smb2_fscc_file_attr_sparse_file,
{ "Sparse", "smb2.file_attribute.sparse", FT_BOOLEAN, 32,
TFS(&tfs_yes_no), SMB2_FSCC_FILE_ATTRIBUTE_SPARSE_FILE, "Is this a sparse file?", HFILL } },
{ &hf_smb2_fscc_file_attr_reparse_point,
{ "Reparse Point", "smb2.file_attribute.reparse", FT_BOOLEAN, 32,
TFS(&tfs_fscc_file_attribute_reparse), SMB2_FSCC_FILE_ATTRIBUTE_REPARSE_POINT, "Does this file have an associated reparse point?", HFILL } },
{ &hf_smb2_fscc_file_attr_compressed,
{ "Compressed", "smb2.file_attribute.compressed", FT_BOOLEAN, 32,
TFS(&tfs_fscc_file_attribute_compressed), SMB2_FSCC_FILE_ATTRIBUTE_COMPRESSED, "Is this file compressed?", HFILL } },
{ &hf_smb2_fscc_file_attr_offline,
{ "Offline", "smb2.file_attribute.offline", FT_BOOLEAN, 32,
TFS(&tfs_fscc_file_attribute_offline), SMB2_FSCC_FILE_ATTRIBUTE_OFFLINE, "Is this file offline?", HFILL } },
{ &hf_smb2_fscc_file_attr_not_content_indexed,
{ "Not Content Indexed", "smb2.file_attribute.not_content_indexed", FT_BOOLEAN, 32,
TFS(&tfs_fscc_file_attribute_not_content_indexed), SMB2_FSCC_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, "May this file be indexed by the content indexing service", HFILL } },
{ &hf_smb2_fscc_file_attr_encrypted,
{ "Encrypted", "smb2.file_attribute.encrypted", FT_BOOLEAN, 32,
TFS(&tfs_yes_no), SMB2_FSCC_FILE_ATTRIBUTE_ENCRYPTED, "Is this file encrypted?", HFILL } },
{ &hf_smb2_fscc_file_attr_integrity_stream,
{ "Integrity Stream", "smb2.file_attribute.integrity_stream", FT_BOOLEAN, 32,
TFS(&tfs_fscc_file_attribute_integrity_stream), SMB2_FSCC_FILE_ATTRIBUTE_INTEGRITY_STREAM, "Is this file configured with integrity support?", HFILL } },
{ &hf_smb2_fscc_file_attr_no_scrub_data,
{ "No Scrub Data", "smb2.file_attribute.no_scrub_data", FT_BOOLEAN, 32,
TFS(&tfs_fscc_file_attribute_no_scrub_data), SMB2_FSCC_FILE_ATTRIBUTE_NO_SCRUB_DATA, "Is this file configured to be excluded from the data integrity scan?", HFILL } },
};
static gint *ett[] = {
&ett_smb2,
&ett_smb2_ea,
&ett_smb2_olb,
&ett_smb2_header,
&ett_smb2_encrypted,
&ett_smb2_compressed,
&ett_smb2_decompressed,
&ett_smb2_command,
&ett_smb2_secblob,
&ett_smb2_negotiate_context_element,
&ett_smb2_file_basic_info,
&ett_smb2_file_standard_info,
&ett_smb2_file_internal_info,
&ett_smb2_file_ea_info,
&ett_smb2_file_access_info,
&ett_smb2_file_rename_info,
&ett_smb2_file_disposition_info,
&ett_smb2_file_position_info,
&ett_smb2_file_full_ea_info,
&ett_smb2_file_mode_info,
&ett_smb2_file_alignment_info,
&ett_smb2_file_all_info,
&ett_smb2_file_allocation_info,
&ett_smb2_file_endoffile_info,
&ett_smb2_file_alternate_name_info,
&ett_smb2_file_stream_info,
&ett_smb2_file_pipe_info,
&ett_smb2_file_compression_info,
&ett_smb2_file_network_open_info,
&ett_smb2_file_attribute_tag_info,
&ett_smb2_file_normalized_name_info,
&ett_smb2_fs_info_01,
&ett_smb2_fs_info_03,
&ett_smb2_fs_info_04,
&ett_smb2_fs_info_05,
&ett_smb2_fs_info_06,
&ett_smb2_fs_info_07,
&ett_smb2_fs_objectid_info,
&ett_smb2_sec_info_00,
&ett_smb2_additional_information_sec_mask,
&ett_smb2_quota_info,
&ett_smb2_query_quota_info,
&ett_smb2_tid_tree,
&ett_smb2_sesid_tree,
&ett_smb2_create_chain_element,
&ett_smb2_MxAc_buffer,
&ett_smb2_QFid_buffer,
&ett_smb2_RqLs_buffer,
&ett_smb2_ioctl_function,
&ett_smb2_FILE_OBJECTID_BUFFER,
&ett_smb2_flags,
&ett_smb2_sec_mode,
&ett_smb2_capabilities,
&ett_smb2_ses_req_flags,
&ett_smb2_ses_flags,
&ett_smb2_create_rep_flags,
&ett_smb2_lease_state,
&ett_smb2_lease_flags,
&ett_smb2_share_flags,
&ett_smb2_share_caps,
&ett_smb2_comp_alg_flags,
&ett_smb2_ioctl_flags,
&ett_smb2_ioctl_network_interface,
&ett_smb2_ioctl_sqos_opeations,
&ett_smb2_fsctl_range_data,
&ett_windows_sockaddr,
&ett_smb2_close_flags,
&ett_smb2_notify_info,
&ett_smb2_notify_flags,
&ett_smb2_rdma_v1,
&ett_smb2_write_flags,
&ett_smb2_find_flags,
&ett_smb2_file_directory_info,
&ett_smb2_both_directory_info,
&ett_smb2_id_both_directory_info,
&ett_smb2_full_directory_info,
&ett_smb2_posix_info,
&ett_smb2_file_name_info,
&ett_smb2_lock_info,
&ett_smb2_lock_flags,
&ett_smb2_DH2Q_buffer,
&ett_smb2_DH2C_buffer,
&ett_smb2_dh2x_flags,
&ett_smb2_APP_INSTANCE_buffer,
&ett_smb2_svhdx_open_device_context,
&ett_smb2_app_instance_version_buffer,
&ett_smb2_app_instance_version_buffer_version,
&ett_smb2_aapl_create_context_request,
&ett_smb2_aapl_server_query_bitmask,
&ett_smb2_aapl_server_query_caps,
&ett_smb2_aapl_create_context_response,
&ett_smb2_aapl_server_query_volume_caps,
&ett_smb2_integrity_flags,
&ett_smb2_buffercode,
&ett_smb2_ioctl_network_interface_capabilities,
&ett_smb2_tree_connect_flags,
&ett_qfr_entry,
&ett_smb2_pipe_fragment,
&ett_smb2_pipe_fragments,
&ett_smb2_cchunk_entry,
&ett_smb2_fsctl_odx_token,
&ett_smb2_symlink_error_response,
&ett_smb2_reparse_data_buffer,
&ett_smb2_error_data,
&ett_smb2_error_context,
&ett_smb2_error_redir_context,
&ett_smb2_error_redir_ip_list,
&ett_smb2_read_flags,
&ett_smb2_signature,
&ett_smb2_transform_flags,
&ett_smb2_fscc_file_attributes,
&ett_smb2_comp_pattern_v1,
&ett_smb2_comp_payload,
};
static ei_register_info ei[] = {
{ &ei_smb2_invalid_length, { "smb2.invalid_length", PI_MALFORMED, PI_ERROR, "Invalid length", EXPFILL }},
{ &ei_smb2_bad_response, { "smb2.bad_response", PI_MALFORMED, PI_ERROR, "Bad response", EXPFILL }},
{ &ei_smb2_invalid_getinfo_offset, { "smb2.invalid_getinfo_offset", PI_MALFORMED, PI_ERROR, "Input buffer offset isn't past the fixed data in the message", EXPFILL }},
{ &ei_smb2_invalid_getinfo_size, { "smb2.invalid_getinfo_size", PI_MALFORMED, PI_ERROR, "Input buffer length goes past the end of the message", EXPFILL }},
{ &ei_smb2_empty_getinfo_buffer, { "smb2.empty_getinfo_buffer", PI_PROTOCOL, PI_WARN, "Input buffer length is empty for a quota request", EXPFILL }},
{ &ei_smb2_invalid_signature, { "smb2.invalid_signature", PI_MALFORMED, PI_ERROR, "Invalid Signature", EXPFILL }},
};
expert_module_t* expert_smb2;
/* SessionID <=> SessionKey mappings for decryption */
uat_t *seskey_uat;
static uat_field_t seskey_uat_fields[] = {
UAT_FLD_BUFFER(seskey_list, id, "Session ID", "The session ID buffer, coded as hex string, as it appears on the wire (LE)."),
UAT_FLD_BUFFER(seskey_list, seskey, "Session Key", "The secret session key buffer, coded as 16-byte hex string."),
UAT_FLD_BUFFER(seskey_list, s2ckey, "Server-to-Client", "The AES-128 key used by the client to decrypt server messages, coded as 16-byte hex string."),
UAT_FLD_BUFFER(seskey_list, c2skey, "Client-to-Server", "The AES-128 key used by the server to decrypt client messages, coded as 16-byte hex string."),
UAT_END_FIELDS
};
proto_smb2 = proto_register_protocol("SMB2 (Server Message Block Protocol version 2)",
"SMB2", "smb2");
proto_register_subtree_array(ett, array_length(ett));
proto_register_field_array(proto_smb2, hf, array_length(hf));
expert_smb2 = expert_register_protocol(proto_smb2);
expert_register_field_array(expert_smb2, ei, array_length(ei));
smb2_module = prefs_register_protocol(proto_smb2, NULL);
prefs_register_bool_preference(smb2_module, "eosmb2_take_name_as_fid",
"Use the full file name as File ID when exporting an SMB2 object",
"Whether the export object functionality will take the full path file name as file identifier",
&eosmb2_take_name_as_fid);
prefs_register_bool_preference(smb2_module, "pipe_reassembly",
"Reassemble Named Pipes over SMB2",
"Whether the dissector should reassemble Named Pipes over SMB2 commands",
&smb2_pipe_reassembly);
prefs_register_bool_preference(smb2_module, "verify_signatures",
"Verify SMB2 Signatures",
"Whether the dissector should try to verify SMB2 signatures",
&smb2_verify_signatures);
seskey_uat = uat_new("Secret session key to use for decryption",
sizeof(smb2_seskey_field_t),
"smb2_seskey_list",
TRUE,
&seskey_list,
&num_seskey_list,
(UAT_AFFECTS_DISSECTION | UAT_AFFECTS_FIELDS),
NULL,
seskey_list_copy_cb,
seskey_list_update_cb,
seskey_list_free_cb,
NULL,
NULL,
seskey_uat_fields);
prefs_register_uat_preference(smb2_module,
"seskey_list",
"Secret session keys for decryption",
"A table of Session ID to Session keys mappings used to decrypt traffic.",
seskey_uat);
smb2_pipe_subdissector_list = register_heur_dissector_list("smb2_pipe_subdissectors", proto_smb2);
/*
* XXX - addresses_ports_reassembly_table_functions?
* Probably correct for SMB-over-NBT and SMB-over-TCP,
* as stuff from two different connections should
* probably not be combined, but what about other
* transports for SMB, e.g. NBF or Netware?
*/
reassembly_table_register(&smb2_pipe_reassembly_table,
&addresses_reassembly_table_functions);
smb2_tap = register_tap("smb2");
smb2_eo_tap = register_tap("smb_eo"); /* SMB Export Object tap */
register_srt_table(proto_smb2, NULL, 1, smb2stat_packet, smb2stat_init, NULL);
smb2_sessions = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), smb2_sesid_info_hash, smb2_sesid_info_equal);
}
void
proto_reg_handoff_smb2(void)
{
gssapi_handle = find_dissector_add_dependency("gssapi", proto_smb2);
ntlmssp_handle = find_dissector_add_dependency("ntlmssp", proto_smb2);
rsvd_handle = find_dissector_add_dependency("rsvd", proto_smb2);
heur_dissector_add("netbios", dissect_smb2_heur, "SMB2 over Netbios", "smb2_netbios", proto_smb2, HEURISTIC_ENABLE);
heur_dissector_add("smb_direct", dissect_smb2_heur, "SMB2 over SMB Direct", "smb2_smb_direct", proto_smb2, HEURISTIC_ENABLE);
}
/*
* Editor modelines - https://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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-smb2.h
|
/* packet-smb2.h
* Defines for SMB2 packet dissection
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998, 1999 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PACKET_SMB2_H__
#define __PACKET_SMB2_H__
#include "packet-dcerpc.h"
#include "packet-smb.h"
#include "packet-ntlmssp.h"
/* SMB2 command codes. With MSVC and a
* libwireshark.dll, we need a special declaration.
*/
WS_DLL_PUBLIC value_string_ext smb2_cmd_vals_ext;
/* Structure to keep track of information specific to a single
* SMB2 transaction. Here we store things we need to remember between
* a specific request and a specific response.
*
* There is no guarantee we will have this structure available for all
* SMB2 packets so a dissector must check this pointer for NULL
* before dereferencing it.
*
* private data is set to NULL when the structure is created. It is used
* for communications between the Request and the Response packets.
*/
/* extra info needed by export object smb */
typedef struct _smb2_eo_file_info_t {
guint32 attr_mask;
gint64 end_of_file;
} smb2_eo_file_info_t;
typedef struct _smb2_fid_info_t {
guint64 fid_persistent;
guint64 fid_volatile;
guint64 sesid; /* *host* byte order - not necessarily little-endian! */
guint32 tid;
/* only used for key lookup in equal func, must be zero when inserting */
guint32 frame_key;
/* first and last frame nums this FID is valid */
guint32 frame_beg;
guint32 frame_end;
/* file name used to open this FID */
char *name;
} smb2_fid_info_t;
typedef enum {
SMB2_EI_NONE, /* Unassigned / NULL */
SMB2_EI_TREENAME, /* tid tracking char * */
SMB2_EI_FILENAME, /* fid tracking char * */
SMB2_EI_FINDPATTERN /* find tracking char * */
} smb2_extra_info_t;
typedef struct _smb2_saved_info_t {
guint8 smb2_class;
guint8 infolevel;
guint64 msg_id;
guint32 frame_req, frame_res;
nstime_t req_time;
guint8 *preauth_hash_req, *preauth_hash_res;
smb2_fid_info_t *file;
e_ctx_hnd policy_hnd; /* for eo_smb tracking */
smb_eo_t *eo_info_t; /* for storing eo_smb infos */
guint64 file_offset; /* needed file_offset for eo_smb */
guint32 bytes_moved; /* needed for eo_smb */
void *extra_info;
smb2_extra_info_t extra_info_type;
} smb2_saved_info_t;
typedef struct _smb2_tid_info_t {
guint32 tid;
guint32 connect_frame;
guint8 share_type;
char *name;
} smb2_tid_info_t;
#define SMB2_PREAUTH_HASH_SIZE 64
#define AES_KEY_SIZE 16
typedef struct _smb2_sesid_info_t {
guint64 sesid; /* *host* byte order - not necessarily little-endian! */
guint32 auth_frame;
char *acct_name;
char *domain_name;
char *host_name;
guint16 server_port;
guint8 session_key[NTLMSSP_KEY_LEN];
guint8 signing_key[NTLMSSP_KEY_LEN];
guint8 client_decryption_key16[AES_KEY_SIZE];
guint8 server_decryption_key16[AES_KEY_SIZE];
guint8 client_decryption_key32[AES_KEY_SIZE*2];
guint8 server_decryption_key32[AES_KEY_SIZE*2];
wmem_map_t *tids;
wmem_map_t *fids;
/* table to store some infos for smb export object */
wmem_map_t *files;
guint8 preauth_hash[SMB2_PREAUTH_HASH_SIZE];
} smb2_sesid_info_t;
/* Structure to keep track of conversations and the hash tables.
* There is one such structure for each conversation.
*/
typedef struct _smb2_conv_info_t {
/* these two tables are used to match requests with responses */
GHashTable *unmatched;
GHashTable *matched;
guint16 dialect;
guint16 sign_alg;
guint16 enc_alg;
/* preauth hash before session setup */
guint8 *preauth_hash_current;
guint8 preauth_hash_con[SMB2_PREAUTH_HASH_SIZE];
guint8 preauth_hash_ses[SMB2_PREAUTH_HASH_SIZE];
} smb2_conv_info_t;
/* This structure contains information from the SMB2 header
* as well as pointers to the conversation and the transaction specific
* structures.
*/
#define SMB2_FLAGS_RESPONSE 0x00000001
#define SMB2_FLAGS_ASYNC_CMD 0x00000002
#define SMB2_FLAGS_CHAINED 0x00000004
#define SMB2_FLAGS_SIGNATURE 0x00000008
#define SMB2_FLAGS_PRIORITY_MASK 0x00000070
#define SMB2_FLAGS_DFS_OP 0x10000000
#define SMB2_FLAGS_REPLAY_OPERATION 0x20000000
#define SMB2_FLAGS_PRIORITY1 0x00000010
#define SMB2_FLAGS_PRIORITY2 0x00000020
#define SMB2_FLAGS_PRIORITY3 0x00000030
#define SMB2_FLAGS_PRIORITY4 0x00000040
#define SMB2_FLAGS_PRIORITY5 0x00000050
#define SMB2_FLAGS_PRIORITY6 0x00000060
#define SMB2_FLAGS_PRIORITY7 0x00000070
/* SMB2 FLAG MASKS */
#define SMB2_FLAGS_ATTR_ENCRYPTED 0x00004000
#define SMB2_FLAGS_ATTR_INDEXED 0x00002000
#define SMB2_FLAGS_ATTR_OFFLINE 0x00001000
#define SMB2_FLAGS_ATTR_COMPRESSED 0x00000800
#define SMB2_FLAGS_ATTR_REPARSEPOINT 0x00000400
#define SMB2_FLAGS_ATTR_SPARSE 0x00000200
#define SMB2_FLAGS_ATTR_TEMPORARY 0x00000100
#define SMB2_FLAGS_ATTR_NORMAL 0x00000080
#define SMB2_FLAGS_ATTR_DEVICE 0x00000040
#define SMB2_FLAGS_ATTR_ARCHIVE 0x00000020
#define SMB2_FLAGS_ATTR_DIRECTORY 0x00000010
#define SMB2_FLAGS_ATTR_VOLUMEID 0x00000008
#define SMB2_FLAGS_ATTR_SYSTEM 0x00000004
#define SMB2_FLAGS_ATTR_HIDDEN 0x00000002
#define SMB2_FLAGS_ATTR_READONLY 0x00000001
/* SMB2 FILE TYPES ASIGNED TO EXPORT OBJECTS */
#define SMB2_FID_TYPE_UNKNOWN 0
#define SMB2_FID_TYPE_FILE 1
#define SMB2_FID_TYPE_DIR 2
#define SMB2_FID_TYPE_PIPE 3
#define SMB2_FID_TYPE_OTHER 4
/* SMB2 COMMAND CODES */
#define SMB2_COM_NEGOTIATE_PROTOCOL 0x00
#define SMB2_COM_SESSION_SETUP 0x01
#define SMB2_COM_SESSION_LOGOFF 0x02
#define SMB2_COM_TREE_CONNECT 0x03
#define SMB2_COM_TREE_DISCONNECT 0x04
#define SMB2_COM_CREATE 0x05
#define SMB2_COM_CLOSE 0x06
#define SMB2_COM_FLUSH 0x07
#define SMB2_COM_READ 0x08
#define SMB2_COM_WRITE 0x09
#define SMB2_COM_LOCK 0x0A
#define SMB2_COM_IOCTL 0x0B
#define SMB2_COM_CANCEL 0x0C
#define SMB2_COM_KEEPALIVE 0x0D
#define SMB2_COM_FIND 0x0E
#define SMB2_COM_NOTIFY 0x0F
#define SMB2_COM_GETINFO 0x10
#define SMB2_COM_SETINFO 0x11
#define SMB2_COM_BREAK 0x12
typedef struct _smb2_info_t {
guint16 opcode;
guint32 ioctl_function;
guint32 status;
guint32 tid;
guint64 sesid; /* *host* byte order - not necessarily little-endian! */
guint64 msg_id;
guint32 flags;
smb2_eo_file_info_t *eo_file_info; /* eo_smb extra info */
smb2_conv_info_t *conv;
smb2_saved_info_t *saved;
smb2_tid_info_t *tree;
smb2_sesid_info_t *session;
smb2_fid_info_t *file;
proto_tree *top_tree;
} smb2_info_t;
/* for transform content information */
typedef struct _smb2_transform_info_t {
guint8 nonce[16];
guint32 size;
guint16 flags;
guint64 sesid; /* *host* byte order - not necessarily little-endian! */
smb2_conv_info_t *conv;
smb2_sesid_info_t *session;
} smb2_transform_info_t;
typedef struct _smb2_comp_transform_info_t {
guint orig_size;
guint alg;
guint comp_offset;
smb2_conv_info_t *conv;
smb2_sesid_info_t *session;
} smb2_comp_transform_info_t;
int dissect_smb2_FILE_OBJECTID_BUFFER(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset);
int dissect_smb2_ioctl_function(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, guint32 *ioctl_function);
void dissect_smb2_ioctl_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *top_tree, guint32 ioctl_function, gboolean data_in, void *private_data);
#endif
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-smc.c
|
/* packet-smc.c
* SMC dissector for wireshark
* By Joe Fowler <[email protected]>
* By Guvenc Gulce <[email protected]>
* By Karsten Graul <[email protected]>
* (c) Copyright IBM Corporation 2014,2022
* LICENSE: GNU General Public License, version 2, or (at your option) any
* version. http://opensource.org/licenses/gpl-2.0.php
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Please refer to the following specs for protocol:
* - ietf - draft-fox-tcpm-shared-memory-rdma-05
* - https://www.ibm.com/support/pages/node/6326337
*/
#include "config.h"
#include <epan/packet.h>
#include "packet-tcp.h"
#define SMC_TCP_MIN_HEADER_LENGTH 7
#define CLC_MSG_START_OFFSET 5
#define LLC_MSG_START_OFFSET 3
#define RMBE_CTRL_START_OFFSET 2
#define MAC_ADDR_LEN 6
#define SMC_V2 2
#define GID_LEN 16
#define PEERID_LEN 8
#define DIAG_INFO_LEN 4
#define EID_LEN 32
#define ISM_GID_LEN 8
#define ISM_CHID_LEN 2
#define IPV4_SUBNET_MASK_LEN 4
#define IPV6_PREFIX_LEN 16
#define ONE_BYTE_RESERVED 1
#define TWO_BYTE_RESERVED 2
#define QP_LEN 3
#define RKEY_LEN 4
#define VIRTUAL_ADDR_LEN 8
#define FLAG_BYTE_LEN 1
#define LENGTH_BYTE_LEN 2
#define SEQNO_LEN 2
#define CURSOR_LEN 4
#define ALERT_TOKEN_LEN 4
#define DMB_TOKEN_LEN 8
#define PSN_LEN 3
#define CONN_INDEX_LEN 1
#define SMCR_MSG_BYTE_0 0
#define CLC_MSG_BYTE_0 0
#define CLC_MSG_BYTE_1 1
#define CLC_MSG_BYTE_2 2
#define CLC_MSG_BYTE_3 3
#define CLC_MSG_LEN_OFFSET 5
#define LLC_CMD_OFFSET 0
#define LLC_LEN_OFFSET 1
#define LLC_CMD_RSP_OFFSET 3
#define ACCEPT_CONFIRM_QP_OFFSET 38
#define SMCR_CLC_ID 0xe2d4c3d9 /*EBCDIC 'SMCR' */
#define SMCD_CLC_ID 0xe2d4c3c4 /*EBCDIC 'SMCD' */
#define SMC_CLC_V1 0x10
#define SMC_CLC_SMC_R 0x01
#define SMC_MAX_QP_NUM 6
#define SMCD_MAX_BUFSIZE_NUM 6
#define SMCR_MAX_BUFSIZE_NUM 5
#define LLC_FLAG_RESP 0x80
#define RMBE_CTRL 0xfe
#define LLC_MSG_LENGTH 0x2c
typedef enum {
SMC_CLC_PROPOSAL = 1,
SMC_CLC_ACCEPT = 2,
SMC_CLC_CONFIRMATION = 3,
SMC_CLC_DECLINE = 4
} clc_message;
typedef enum {
SMC_CLC_SMCR = 0,
SMC_CLC_SMCD = 1,
SMC_CLC_NONE = 2,
SMC_CLC_BOTH = 3,
} clc_type_message;
typedef enum {
SMC_CLC_OS_ZOS = 1,
SMC_CLC_OS_LINUX = 2,
SMC_CLC_OS_AIX = 3,
SMC_CLC_OS_UNKOWN = 15,
} clc_os_message;
typedef enum {
SMC_CLC_LG_INDIRECT = 0,
SMC_CLC_LG_DIRECT = 1,
} clc_v2_lg_message;
static const value_string smc_clc_os_message_txt[] = {
{ SMC_CLC_OS_ZOS, "z/OS" },
{ SMC_CLC_OS_LINUX, "Linux" },
{ SMC_CLC_OS_AIX, "AIX" },
{ SMC_CLC_OS_UNKOWN, "Unknown" },
{ 0, NULL }
};
static const value_string smc_clc_v2_lg_message_txt[] = {
{ SMC_CLC_LG_INDIRECT, "V2_INDIRECT" },
{ SMC_CLC_LG_DIRECT, "V2_DIRECT" },
{ 0, NULL }
};
static const value_string smc_clc_type_message_txt[] = {
{ SMC_CLC_SMCR, "SMC-R" },
{ SMC_CLC_SMCD, "SMC-D" },
{ SMC_CLC_NONE, "NONE" },
{ SMC_CLC_BOTH, "SMC-R/SMC-D" },
{ 0, NULL }
};
static const value_string smcv2_clc_col_info_message_txt[] = {
{ SMC_CLC_SMCR, "[SMC-Rv2-Proposal]" },
{ SMC_CLC_SMCD, "[SMC-Dv2-Proposal]" },
{ SMC_CLC_NONE, "[NONE]" },
{ SMC_CLC_BOTH, "[SMC-Dv2/SMC-Rv2-Proposal]" },
{ 0, NULL }
};
static const value_string smc_clc_col_info_message_txt[] = {
{ SMC_CLC_SMCR, "[SMC-R-Proposal]" },
{ SMC_CLC_SMCD, "[SMC-D-Proposal]" },
{ SMC_CLC_NONE, "[NONE]" },
{ SMC_CLC_BOTH, "[SMC-D/SMC-R-Proposal]" },
{ 0, NULL }
};
static const value_string smcr_clc_message_txt[] = {
{ SMC_CLC_PROPOSAL, "Proposal" },
{ SMC_CLC_ACCEPT, "Accept" },
{ SMC_CLC_CONFIRMATION, "Confirm" },
{ SMC_CLC_DECLINE, "Decline" },
{ 0, NULL }
};
typedef enum {
LLC_CONFIRM_LINK = 0x01,
LLC_ADD_LINK = 0x02,
LLC_ADD_LINK_CONT = 0x03,
LLC_DEL_LINK = 0x04,
LLC_CONFIRM_RKEY = 0x06,
LLC_CONFIRM_RKEY_CONT = 0x08,
LLC_DELETE_RKEY = 0x09,
LLC_TEST_LINK = 0x07,
/* SMC-Rv2 LLC message types */
LLC_CONFIRM_LINK_V2 = 0x21,
LLC_ADD_LINK_V2 = 0x22,
LLC_DEL_LINK_V2 = 0x24,
LLC_REQUEST_ADD_LINK_V2 = 0x25,
LLC_CONFIRM_RKEY_V2 = 0x26,
LLC_TEST_LINK_V2 = 0x27,
LLC_DELETE_RKEY_V2 = 0x29,
/* Common message types */
LLC_OPT_MSG_CTRL = 0x80,
LLC_NWM_DATA = 0x8A,
LLC_RMBE_CTRL = 0xFE
} llc_message;
static const value_string smcr_llc_message_txt[] = {
{ LLC_CONFIRM_LINK, "Confirm Link" },
{ LLC_ADD_LINK, "Add Link" },
{ LLC_ADD_LINK_CONT, "Add Link Continuous" },
{ LLC_DEL_LINK, "Delete Link" },
{ LLC_CONFIRM_RKEY, "Confirm Rkey" },
{ LLC_CONFIRM_RKEY_CONT, "Confirm Rkey Continuous" },
{ LLC_DELETE_RKEY, "Delete Rkey" },
{ LLC_TEST_LINK, "Test Link" },
/* SMC-Rv2 LLC message types */
{ LLC_CONFIRM_LINK_V2, "Confirm Link (v2)" },
{ LLC_ADD_LINK_V2, "Add Link (v2)" },
{ LLC_DEL_LINK_V2, "Delete Link (v2)" },
{ LLC_REQUEST_ADD_LINK_V2, "Request Add Link (v2)" },
{ LLC_CONFIRM_RKEY_V2, "Confirm Rkey (v2)" },
{ LLC_TEST_LINK_V2, "Test Link (v2)" },
{ LLC_DELETE_RKEY_V2, "Delete Rkey (v2)" },
/* Common message types */
{ LLC_OPT_MSG_CTRL, "OPT Message Control" },
{ LLC_NWM_DATA, "NWM Data" },
{ RMBE_CTRL, "CDC Message" },
{ 0, NULL }
};
static int proto_smc = -1;
static int ett_smcr = -1;
static int hf_smcr_clc_msg = -1;
static int hf_smcr_llc_msg = -1;
/* SMC Proposal for both SMC-D and SMC-R */
static int ett_proposal_flag = -1;
static int ett_proposal_ext_flag2 = -1;
static int hf_proposal_smc_version_release_number = -1;
static int hf_proposal_smc_version_seid = -1;
static int hf_proposal_smc_version = -1;
static int hf_proposal_smc_type = -1;
static int hf_proposal_smc_v2_type = -1;
static int hf_smc_length = -1;
static int hf_smc_proposal_smc_chid = -1;
static int hf_smc_proposal_flags = -1;
static int hf_smc_proposal_eid = -1;
static int hf_smc_proposal_eid_count = -1;
static int hf_smc_proposal_system_eid = -1;
static int hf_smc_proposal_ext_flags = -1;
static int hf_smc_proposal_client_peer_id = -1;
static int hf_smc_proposal_ism_gid_count = -1;
static int hf_smc_proposal_ism_gid = -1;
static int hf_smc_proposal_client_preferred_gid = -1;
static int hf_smc_proposal_client_preferred_mac = -1;
static int hf_smc_proposal_smcv1_subnet_ext_offset = -1;
static int hf_smc_proposal_smcv2_ext_offset = -1;
static int hf_smc_proposal_outgoing_interface_subnet_mask = -1;
static int hf_smc_proposal_smcdv2_ext_offset = -1;
static int hf_smc_proposal_rocev2_gid_ipv4_addr = -1;
static int hf_smc_proposal_rocev2_gid_ipv6_addr = -1;
static int hf_smc_proposal_outgoing_subnet_mask_signifcant_bits = -1;
static int hf_smc_proposal_ipv6_prefix_count = -1;
static int hf_smc_proposal_ipv6_prefix = -1;
static int hf_smc_proposal_ipv6_prefix_length = -1;
static int hf_smc_reserved = -1;
/* SMC-R Accept */
static int ett_accept_flag = -1;
static int ett_accept_flag2 = -1;
static int ett_smcr_accept_fce_flag1 = -1;
static int hf_accept_v2_lg_type = -1;
static int hf_accept_smc_version = -1;
static int hf_accept_first_contact = -1;
static int hf_accept_rmb_buffer_size = -1;
static int hf_accept_qp_mtu_value = -1;
static int hf_smcr_accept_flags = -1;
static int hf_smcr_accept_flags2 = -1;
static int hf_smcr_accept_fce_flags = -1;
static int hf_smcr_accept_server_peer_id = -1;
static int hf_smcr_accept_server_preferred_gid = -1;
static int hf_smcr_accept_server_preferred_mac = -1;
static int hf_smcr_accept_server_qp_number = -1;
static int hf_smcr_accept_server_rmb_rkey = -1;
static int hf_smcr_accept_server_tcp_conn_index = -1;
static int hf_smcr_accept_server_rmb_element_alert_token = -1;
static int hf_smcr_accept_server_rmb_virtual_address = -1;
static int hf_smcr_accept_initial_psn = -1;
/* SMC-R Confirm */
static int ett_confirm_flag = -1;
static int ett_confirm_flag2 = -1;
static int hf_smcr_confirm_flags = -1;
static int hf_smcr_confirm_client_peer_id = -1;
static int hf_smcr_confirm_client_gid = -1;
static int hf_smcr_confirm_client_mac = -1;
static int hf_smcr_confirm_client_qp_number = -1;
static int hf_smcr_confirm_client_rmb_rkey = -1;
static int hf_smcr_confirm_client_tcp_conn_index = -1;
static int hf_smcr_confirm_client_rmb_element_alert_token = -1;
static int hf_smcr_confirm_flags2 = -1;
static int hf_smcr_confirm_client_rmb_virtual_address = -1;
static int hf_smcr_confirm_initial_psn = -1;
static int hf_confirm_smc_version = -1;
static int hf_confirm_rmb_buffer_size = -1;
static int hf_confirm_qp_mtu_value = -1;
/* SMC-D Accept */
static int hf_accept_smc_type = -1;
static int ett_smcd_accept_flag = -1;
static int ett_smc_accept_fce_flag = -1;
static int ett_smcd_accept_flag2 = -1;
static int hf_smcd_accept_smc_version = -1;
static int hf_accept_os_type = -1;
static int hf_accept_smc_version_release_number = -1;
static int hf_smcd_accept_first_contact = -1;
static int hf_accept_dmb_buffer_size = -1;
static int hf_smcd_accept_flags = -1;
static int hf_smc_accept_fce_flags = -1;
static int hf_smcd_accept_flags2 = -1;
static int hf_smcd_accept_server_peer_id = -1;
static int hf_smcd_accept_dmbe_conn_index = -1;
static int hf_smcd_accept_dmb_token = -1;
static int hf_smcd_accept_server_link_id = -1;
static int hf_smcd_accept_smc_chid = -1;
static int hf_smc_accept_eid = -1;
static int hf_smc_accept_peer_name = -1;
/* SMC-D Confirm */
static int hf_confirm_smc_type = -1;
static int ett_smcd_confirm_flag = -1;
static int ett_smc_confirm_fce_flag = -1;
static int ett_smcd_confirm_flag2 = -1;
static int hf_smcd_confirm_smc_version = -1;
static int hf_confirm_os_type = -1;
static int hf_smcd_confirm_flags = -1;
static int hf_smcd_confirm_flags2 = -1;
static int hf_smc_confirm_first_contact = -1;
static int hf_smcd_confirm_client_peer_id = -1;
static int hf_smcd_confirm_dmb_token = -1;
static int hf_smcd_confirm_dmbe_conn_index = -1;
static int hf_smcd_confirm_client_link_id = -1;
static int hf_confirm_smc_version_release_number = -1;
static int hf_smcd_confirm_dmb_buffer_size = -1;
static int hf_smcd_confirm_smc_chid = -1;
static int hf_smc_confirm_eid = -1;
static int hf_smc_confirm_peer_name = -1;
static int hf_smc_confirm_gid_lst_len = -1;
static int hf_smc_confirm_gid_list_entry = -1;
/* SMC-R Decline */
static int ett_decline_flag = -1;
static int ett_decline_flag2 = -1;
static int hf_smc_decline_flags = -1;
static int hf_smc_decline_flags2 = -1;
static int hf_smc_decline_peer_id = -1;
static int hf_smc_decline_diag_info = -1;
static int hf_decline_os_type = -1;
static int hf_decline_smc_version = -1;
static int hf_decline_out_of_sync = -1;
/* SMC-R Confirm Link*/
static int ett_confirm_link_flag = -1;
static int hf_smcr_confirm_link_flags = -1;
static int hf_smcr_confirm_link_mac = -1;
static int hf_smcr_confirm_link_gid = -1;
static int hf_smcr_confirm_link_qp_number = -1;
static int hf_smcr_confirm_link_number = -1;
static int hf_smcr_confirm_link_userid = -1;
static int hf_smcr_confirm_link_max_links = -1;
static int hf_smcr_confirm_link_response = -1;
/* SMC-R Add Link */
static int ett_add_link_flag = -1;
static int ett_add_link_flag2 = -1;
static int ett_add_link_flag3 = -1;
static int hf_smcr_add_link_flags = -1;
static int hf_smcr_add_link_response = -1;
static int hf_smcr_add_link_response_rejected = -1;
static int hf_smcr_add_link_reject_reason = -1;
static int hf_smcr_add_link_mac = -1;
static int hf_smcr_add_link_gid = -1;
static int hf_smcr_add_link_qp_number = -1;
static int hf_smcr_add_link_number = -1;
static int hf_smcr_add_link_initial_psn = -1;
static int hf_smcr_add_link_flags2 = -1;
static int hf_smcr_add_link_qp_mtu_value = -1;
static int hf_smcr_add_link_client_target_gid = -1;
static int hf_smcr_add_link_rkey_count = -1;
static int hf_smcr_add_link_rkey = -1;
static int hf_smcr_add_link_rkey2 = -1;
static int hf_smcr_add_link_virt_addr = -1;
static int hf_smcr_add_link_flags3 = -1;
static int hf_smcr_add_link_flag3_direct_link = -1;
/* SMC-R Add Link Continue*/
static int ett_add_link_cont_flag = -1;
static int hf_smcr_add_link_cont_flags = -1;
static int hf_smcr_add_link_cont_response = -1;
static int hf_smcr_add_link_cont_link_number = -1;
static int hf_smcr_add_link_cont_number_of_rkeys = -1;
static int hf_smcr_add_link_cont_p1_rkey = -1;
static int hf_smcr_add_link_cont_p1_rkey2 = -1;
static int hf_smcr_add_link_cont_p1_virt_addr = -1;
static int hf_smcr_add_link_cont_p2_rkey = -1;
static int hf_smcr_add_link_cont_p2_rkey2 = -1;
static int hf_smcr_add_link_cont_p2_virt_addr = -1;
/* SMC-Rv2 Request Add Link */
static int ett_request_add_link_flag = -1;
static int hf_smcr_request_add_link_flags = -1;
static int hf_smcr_request_add_link_response = -1;
static int hf_smcr_request_add_link_response_rejected = -1;
static int hf_smcr_request_add_link_reject_reason = -1;
static int hf_smc_request_add_link_gid_lst_len = -1;
static int hf_smc_request_add_link_gid_list_entry = -1;
/* SMC-R Delete Link */
static int ett_delete_link_flag = -1;
static int hf_smcr_delete_link_flags = -1;
static int hf_smcr_delete_link_response = -1;
static int hf_smcr_delete_link_all = -1;
static int hf_smcr_delete_link_orderly = -1;
static int hf_smcr_delete_link_number = -1;
static int hf_smcr_delete_link_reason_code = -1;
/* SMC-R Confirm Rkey */
static int ett_confirm_rkey_flag = -1;
static int hf_smcr_confirm_rkey_response = -1;
static int hf_smcr_confirm_rkey_flags = -1;
static int hf_smcr_confirm_rkey_negative_response = -1;
static int hf_smcr_confirm_rkey_retry_rkey_set = -1;
static int hf_smcr_confirm_rkey_number = -1;
static int hf_smcr_confirm_rkey_new_rkey = -1;
static int hf_smcr_confirm_rkey_virtual_address = -1;
static int hf_smcr_confirm_rkey_link_number = -1;
/* SMC-R Delete Rkey */
static int ett_delete_rkey_flag = -1;
static int hf_smcr_delete_rkey_flags = -1;
static int hf_smcr_delete_rkey_response = -1;
static int hf_smcr_delete_rkey_negative_response = -1;
static int hf_smcr_delete_rkey_mask = -1;
static int hf_smcr_delete_rkey_deleted = -1;
static int hf_smcr_delete_rkey_count = -1;
static int hf_smcr_delete_rkey_invalid_count = -1;
/* SMC-R Test Link */
static int ett_test_link_flag = -1;
static int hf_smcr_test_link_flags = -1;
static int hf_smcr_test_link_response = -1;
/* SMC-R RMBE Control */
static int ett_rmbe_ctrl_rw_status_flag = -1;
static int ett_rmbe_ctrl_peer_conn_state_flag = -1;
static int hf_smcr_rmbe_ctrl_seqno = -1;
static int hf_smcr_rmbe_ctrl_alert_token = -1;
static int hf_smcr_rmbe_ctrl_prod_wrap_seqno = -1;
static int hf_smcr_rmbe_ctrl_peer_prod_curs = -1;
static int hf_smcr_rmbe_ctrl_cons_wrap_seqno = -1;
static int hf_smcr_rmbe_ctrl_peer_cons_curs = -1;
static int hf_smcr_rmbe_ctrl_conn_rw_status_flags = -1;
static int hf_smcr_rmbe_ctrl_write_blocked = -1;
static int hf_smcr_rmbe_ctrl_urgent_pending = -1;
static int hf_smcr_rmbe_ctrl_urgent_present = -1;
static int hf_smcr_rmbe_ctrl_cons_update_requested = -1;
static int hf_smcr_rmbe_ctrl_failover_validation = -1;
static int hf_smcr_rmbe_ctrl_peer_conn_state_flags = -1;
static int hf_smcr_rmbe_ctrl_peer_sending_done = -1;
static int hf_smcr_rmbe_ctrl_peer_closed_conn = -1;
static int hf_smcr_rmbe_ctrl_peer_abnormal_close = -1;
void proto_register_smcr(void);
void proto_reg_handoff_smcr(void);
static dissector_handle_t smc_tcp_handle;
static void
disect_smc_uncompress_size(proto_item* ti, guint size, guint max_valid)
{
if (size <= max_valid) {
proto_item_append_text(ti, " (Size: %dk)", 1 << (size + 4)); /* uncompressed size */
} else {
proto_item_append_text(ti, " (Size: invalid)");
}
}
static void
disect_smcr_translate_qp_mtu(proto_item* ti, guint qp_num)
{
if (qp_num > 0 && qp_num < SMC_MAX_QP_NUM) {
proto_item_append_text(ti, " (MTU: %d)", 1 << (7 + qp_num)); /* translated MTU size (1-5) */
} else {
proto_item_append_text(ti, " (MTU: invalid)");
}
}
static void
disect_smc_proposal(tvbuff_t *tvb, proto_tree *tree, bool is_ipv6)
{
guint offset;
guint16 ip_subnet_ext_offset = 0, v2_ext_offset;
guint16 v2_ext_pos = 0, smcd_v2_ext_offset = 0;
guint16 smcd_v2_ext_pos = 0;
guint8 ipv6_prefix_count, smc_version;
guint8 smc_type, num_of_gids = 0, num_of_eids = 0;
guint8 smc_type_v1 = 0, smc_type_v2 = 0;
bool is_smc_v2, is_smcdv1, is_smcdv2 = false, is_smcrv1, is_smcrv2 = false;
proto_item *proposal_flag_item;
proto_tree *proposal_flag_tree;
offset = CLC_MSG_START_OFFSET;
proto_tree_add_item(tree, hf_smc_length, tvb, offset, LENGTH_BYTE_LEN, ENC_BIG_ENDIAN);
offset += LENGTH_BYTE_LEN;
proposal_flag_item = proto_tree_add_item(tree, hf_smc_proposal_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proposal_flag_tree = proto_item_add_subtree(proposal_flag_item, ett_proposal_flag);
proto_tree_add_item(proposal_flag_tree, hf_proposal_smc_version, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
smc_version = tvb_get_guint8(tvb, offset);
smc_type = tvb_get_guint8(tvb, offset);
smc_version = ((smc_version >> 4) & 0x0F);
is_smc_v2 = (smc_version >= SMC_V2);
smc_type_v2 = ((smc_type >> 2) & 0x03);
smc_type_v1 = (smc_type & 0x03);
is_smcdv1 = ((smc_type_v1 == SMC_CLC_SMCD) || (smc_type_v1 == SMC_CLC_BOTH));
is_smcrv1 = ((smc_type_v1 == SMC_CLC_SMCR) || (smc_type_v1 == SMC_CLC_BOTH));
if (is_smc_v2) {
is_smcdv2 = ((smc_type_v2 == SMC_CLC_SMCD) || (smc_type_v2 == SMC_CLC_BOTH));
is_smcrv2 = ((smc_type_v2 == SMC_CLC_SMCR) || (smc_type_v2 == SMC_CLC_BOTH));
}
if (is_smc_v2) {
proto_tree_add_item(proposal_flag_tree, hf_proposal_smc_v2_type, tvb,
offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
}
proto_tree_add_item(proposal_flag_tree, hf_proposal_smc_type, tvb,
offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
if (is_smcrv1 || is_smcrv2) {
proto_tree_add_item(tree, hf_smc_proposal_client_peer_id, tvb, offset,
PEERID_LEN, ENC_BIG_ENDIAN);
} else {
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, PEERID_LEN, ENC_NA);
}
offset += PEERID_LEN;
if (is_smcrv1) {
proto_tree_add_item(tree, hf_smc_proposal_client_preferred_gid, tvb,
offset, GID_LEN, ENC_NA);
offset += GID_LEN;
proto_tree_add_item(tree, hf_smc_proposal_client_preferred_mac, tvb,
offset, MAC_ADDR_LEN, ENC_NA);
offset += MAC_ADDR_LEN;
} else {
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, GID_LEN + MAC_ADDR_LEN, ENC_NA);
offset += GID_LEN + MAC_ADDR_LEN;
}
if (is_smcrv1 || is_smcdv1) {
ip_subnet_ext_offset = tvb_get_ntohs(tvb, offset);
proto_tree_add_item(tree, hf_smc_proposal_smcv1_subnet_ext_offset, tvb,
offset, 2, ENC_BIG_ENDIAN);
offset += 2;
} else {
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 2, ENC_NA);
offset += 2;
}
if (is_smcdv1 || is_smcdv2) {
proto_tree_add_item(tree, hf_smc_proposal_ism_gid, tvb,
offset, ISM_GID_LEN, ENC_NA);
}
offset += ISM_GID_LEN;
if (is_smcdv2) {
proto_tree_add_item(tree, hf_smc_proposal_smc_chid, tvb, offset,
LENGTH_BYTE_LEN, ENC_BIG_ENDIAN);
} else {
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, LENGTH_BYTE_LEN, ENC_NA);
}
offset += LENGTH_BYTE_LEN;
if (is_smc_v2) {
v2_ext_offset = tvb_get_ntohs(tvb, offset);
v2_ext_pos = offset + 2 + v2_ext_offset;
proto_tree_add_item(tree, hf_smc_proposal_smcv2_ext_offset, tvb,
offset, 2, ENC_BIG_ENDIAN);
} else {
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 2, ENC_NA);
}
offset += 2;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 28, ENC_NA);
offset += 28; /* reserved */
if (ip_subnet_ext_offset) {
proto_tree_add_item(tree, hf_smc_proposal_outgoing_interface_subnet_mask, tvb,
offset, IPV4_SUBNET_MASK_LEN, ENC_BIG_ENDIAN);
offset += IPV4_SUBNET_MASK_LEN;
proto_tree_add_item(tree, hf_smc_proposal_outgoing_subnet_mask_signifcant_bits, tvb,
offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, TWO_BYTE_RESERVED, ENC_NA);
offset += TWO_BYTE_RESERVED; /* reserved */
ipv6_prefix_count = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_smc_proposal_ipv6_prefix_count, tvb,
offset, 1, ENC_BIG_ENDIAN);
offset += 1;
while (ipv6_prefix_count != 0) {
proto_tree_add_item(tree, hf_smc_proposal_ipv6_prefix, tvb,
offset, IPV6_PREFIX_LEN, ENC_NA);
offset += IPV6_PREFIX_LEN;
proto_tree_add_item(tree, hf_smc_proposal_ipv6_prefix_length, tvb,
offset, 1, ENC_BIG_ENDIAN);
offset += 1;
ipv6_prefix_count--;
}
}
if (v2_ext_pos >= offset) {
offset = v2_ext_pos;
num_of_eids = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_smc_proposal_eid_count, tvb,
offset, 1, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
num_of_gids = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_smc_proposal_ism_gid_count, tvb,
offset, 1, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, ONE_BYTE_RESERVED, ENC_NA);
offset += ONE_BYTE_RESERVED; /* reserved */
proposal_flag_item = proto_tree_add_item(tree, hf_smc_proposal_ext_flags, tvb,
offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proposal_flag_tree = proto_item_add_subtree(proposal_flag_item, ett_proposal_ext_flag2);
proto_tree_add_item(proposal_flag_tree, hf_proposal_smc_version_release_number,
tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(proposal_flag_tree, hf_proposal_smc_version_seid, tvb,
offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, TWO_BYTE_RESERVED, ENC_NA);
offset += TWO_BYTE_RESERVED; /* reserved */
smcd_v2_ext_offset = tvb_get_ntohs(tvb, offset);
proto_tree_add_item(tree, hf_smc_proposal_smcdv2_ext_offset, tvb,
offset, 2, ENC_BIG_ENDIAN);
offset += 2;
smcd_v2_ext_pos = offset + smcd_v2_ext_offset;
if (is_smcrv2) {
if (is_ipv6) {
proto_tree_add_item(tree, hf_smc_proposal_rocev2_gid_ipv6_addr, tvb,
offset, GID_LEN, ENC_NA);
offset += GID_LEN;
} else {
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 12, ENC_NA);
offset += 12; /* reserved */
proto_tree_add_item(tree, hf_smc_proposal_rocev2_gid_ipv4_addr, tvb,
offset, IPV4_SUBNET_MASK_LEN, ENC_BIG_ENDIAN);
offset += IPV4_SUBNET_MASK_LEN;
}
} else {
offset += GID_LEN;
}
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 16, ENC_NA);
offset += 16; /* reserved */
while (num_of_eids != 0) {
proto_tree_add_item(tree, hf_smc_proposal_eid, tvb,
offset, EID_LEN, ENC_ASCII | ENC_NA);
offset += EID_LEN;
num_of_eids--;
}
if (smcd_v2_ext_pos >= offset) {
offset = smcd_v2_ext_pos;
proto_tree_add_item(tree, hf_smc_proposal_system_eid, tvb,
offset, EID_LEN, ENC_ASCII | ENC_NA);
offset += EID_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 16, ENC_NA);
offset += 16; /* reserved */
while (num_of_gids != 0) {
proto_tree_add_item(tree, hf_smc_proposal_ism_gid, tvb,
offset, ISM_GID_LEN, ENC_NA);
offset += ISM_GID_LEN;
proto_tree_add_item(tree, hf_smc_proposal_smc_chid, tvb, offset,
ISM_CHID_LEN, ENC_BIG_ENDIAN);
offset += ISM_CHID_LEN;
num_of_gids--;
}
}
}
}
static void
disect_smcd_accept(tvbuff_t* tvb, proto_tree* tree)
{
guint offset, dmbe_size;
proto_item* accept_flag_item;
proto_tree* accept_flag_tree;
proto_item* accept_flag2_item;
proto_tree* accept_flag2_tree;
proto_item* ti;
guint8 smc_version, first_contact = 0;
offset = CLC_MSG_START_OFFSET;
proto_tree_add_item(tree, hf_smc_length, tvb, offset,
LENGTH_BYTE_LEN, ENC_BIG_ENDIAN);
offset += LENGTH_BYTE_LEN;
accept_flag_item = proto_tree_add_item(tree, hf_smcd_accept_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
accept_flag_tree = proto_item_add_subtree(accept_flag_item, ett_smcd_accept_flag);
proto_tree_add_item(accept_flag_tree, hf_smcd_accept_smc_version, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(accept_flag_tree, hf_smcd_accept_first_contact, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(accept_flag_tree, hf_accept_smc_type, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
smc_version = tvb_get_guint8(tvb, offset);
first_contact = tvb_get_guint8(tvb, offset);
smc_version = ((smc_version >> 4) & 0x0F);
first_contact = ((first_contact >> 3) & 0x01);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smcd_accept_server_peer_id, tvb, offset,
PEERID_LEN, ENC_BIG_ENDIAN);
offset += PEERID_LEN;
proto_tree_add_item(tree, hf_smcd_accept_dmb_token, tvb,
offset, DMB_TOKEN_LEN, ENC_NA);
offset += DMB_TOKEN_LEN;
proto_tree_add_item(tree, hf_smcd_accept_dmbe_conn_index, tvb,
offset, CONN_INDEX_LEN, ENC_BIG_ENDIAN);
offset += CONN_INDEX_LEN;
accept_flag2_item = proto_tree_add_item(tree, hf_smcd_accept_flags2, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
accept_flag2_tree = proto_item_add_subtree(accept_flag2_item, ett_smcd_accept_flag2);
ti = proto_tree_add_item(accept_flag2_tree, hf_accept_dmb_buffer_size, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
dmbe_size = tvb_get_gint8(tvb, offset) >> 4;
disect_smc_uncompress_size(ti, dmbe_size, SMCD_MAX_BUFSIZE_NUM);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, TWO_BYTE_RESERVED, ENC_NA);
offset += TWO_BYTE_RESERVED; /* reserved */
proto_tree_add_item(tree, hf_smcd_accept_server_link_id, tvb,
offset, ALERT_TOKEN_LEN, ENC_BIG_ENDIAN);
offset += ALERT_TOKEN_LEN;
if (smc_version >= SMC_V2) {
proto_tree_add_item(tree, hf_smcd_accept_smc_chid, tvb, offset, LENGTH_BYTE_LEN, ENC_BIG_ENDIAN);
offset += LENGTH_BYTE_LEN;
proto_tree_add_item(tree, hf_smc_accept_eid, tvb, offset, 32, ENC_ASCII | ENC_NA);
offset += 32;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 8, ENC_NA);
offset += 8; /* reserved */
if (first_contact) {
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, ONE_BYTE_RESERVED, ENC_NA);
offset += ONE_BYTE_RESERVED; /* reserved */
accept_flag_item = proto_tree_add_item(tree, hf_smc_accept_fce_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
accept_flag_tree = proto_item_add_subtree(accept_flag_item, ett_smc_accept_fce_flag);
proto_tree_add_item(accept_flag_tree, hf_accept_os_type, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(accept_flag_tree, hf_accept_smc_version_release_number, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, TWO_BYTE_RESERVED, ENC_NA);
offset += TWO_BYTE_RESERVED; /* reserved */
proto_tree_add_item(tree, hf_smc_accept_peer_name, tvb, offset, 32, ENC_ASCII | ENC_NA);
offset += 32;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 16, ENC_NA);
/* offset += 16; */ /* reserved */
}
}
}
static void
disect_smcd_confirm(tvbuff_t* tvb, proto_tree* tree)
{
guint offset, dmbe_size;
proto_item* confirm_flag_item;
proto_tree* confirm_flag_tree;
proto_item* confirm_flag2_item;
proto_tree* confirm_flag2_tree;
proto_item* ti;
guint8 smc_version, first_contact = 0;
offset = CLC_MSG_START_OFFSET;
proto_tree_add_item(tree, hf_smc_length, tvb, offset,
LENGTH_BYTE_LEN, ENC_BIG_ENDIAN);
offset += LENGTH_BYTE_LEN;
confirm_flag_item = proto_tree_add_item(tree, hf_smcd_confirm_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
confirm_flag_tree = proto_item_add_subtree(confirm_flag_item, ett_smcd_confirm_flag);
proto_tree_add_item(confirm_flag_tree, hf_smcd_confirm_smc_version, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(confirm_flag_tree, hf_smc_confirm_first_contact, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(confirm_flag_tree, hf_confirm_smc_type, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
smc_version = tvb_get_guint8(tvb, offset);
first_contact = tvb_get_guint8(tvb, offset);
smc_version = ((smc_version >> 4) & 0x0F);
first_contact = ((first_contact >> 3) & 0x01);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smcd_confirm_client_peer_id, tvb, offset,
PEERID_LEN, ENC_BIG_ENDIAN);
offset += PEERID_LEN;
proto_tree_add_item(tree, hf_smcd_confirm_dmb_token, tvb,
offset, DMB_TOKEN_LEN, ENC_NA);
offset += DMB_TOKEN_LEN;
proto_tree_add_item(tree, hf_smcd_confirm_dmbe_conn_index, tvb,
offset, CONN_INDEX_LEN, ENC_BIG_ENDIAN);
offset += CONN_INDEX_LEN;
confirm_flag2_item = proto_tree_add_item(tree, hf_smcd_confirm_flags2, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
confirm_flag2_tree = proto_item_add_subtree(confirm_flag2_item, ett_smcd_confirm_flag2);
ti = proto_tree_add_item(confirm_flag2_tree, hf_smcd_confirm_dmb_buffer_size, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
dmbe_size = tvb_get_gint8(tvb, offset) >> 4;
disect_smc_uncompress_size(ti, dmbe_size, SMCD_MAX_BUFSIZE_NUM);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, TWO_BYTE_RESERVED, ENC_NA);
offset += TWO_BYTE_RESERVED; /* reserved */
proto_tree_add_item(tree, hf_smcd_confirm_client_link_id, tvb,
offset, ALERT_TOKEN_LEN, ENC_BIG_ENDIAN);
offset += ALERT_TOKEN_LEN;
if (smc_version >= SMC_V2) {
proto_tree_add_item(tree, hf_smcd_confirm_smc_chid, tvb, offset,
LENGTH_BYTE_LEN, ENC_BIG_ENDIAN);
offset += LENGTH_BYTE_LEN;
proto_tree_add_item(tree, hf_smc_confirm_eid, tvb, offset, 32, ENC_ASCII | ENC_NA);
offset += 32;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 8, ENC_NA);
offset += 8; /* reserved */
if (first_contact) {
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, ONE_BYTE_RESERVED, ENC_NA);
offset += ONE_BYTE_RESERVED; /* reserved */
confirm_flag_item = proto_tree_add_item(tree, hf_smc_accept_fce_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
confirm_flag_tree = proto_item_add_subtree(confirm_flag_item, ett_smc_confirm_fce_flag);
proto_tree_add_item(confirm_flag_tree, hf_confirm_os_type, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(confirm_flag_tree, hf_confirm_smc_version_release_number, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, TWO_BYTE_RESERVED, ENC_NA);
offset += TWO_BYTE_RESERVED; /* reserved */
proto_tree_add_item(tree, hf_smc_confirm_peer_name, tvb, offset, 32, ENC_ASCII | ENC_NA);
}
}
}
static void
disect_smcr_accept(tvbuff_t *tvb, proto_tree *tree)
{
guint offset, qp_num, rmbe_size;
proto_item *accept_flag_item;
proto_tree *accept_flag_tree;
proto_item *accept_flag2_item;
proto_tree *accept_flag2_tree;
proto_item *ti;
guint8 smc_version, first_contact = 0;
offset = CLC_MSG_START_OFFSET;
proto_tree_add_item(tree, hf_smc_length, tvb, offset,
LENGTH_BYTE_LEN, ENC_BIG_ENDIAN);
offset += LENGTH_BYTE_LEN;
accept_flag_item = proto_tree_add_item(tree, hf_smcr_accept_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
accept_flag_tree = proto_item_add_subtree(accept_flag_item, ett_accept_flag);
proto_tree_add_item(accept_flag_tree, hf_accept_smc_version, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(accept_flag_tree, hf_accept_first_contact, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
smc_version = tvb_get_guint8(tvb, offset);
first_contact = tvb_get_guint8(tvb, offset);
smc_version = ((smc_version >> 4) & 0x0F);
first_contact = ((first_contact >> 3) & 0x01);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smcr_accept_server_peer_id, tvb, offset,
PEERID_LEN, ENC_BIG_ENDIAN);
offset += PEERID_LEN;
proto_tree_add_item(tree, hf_smcr_accept_server_preferred_gid, tvb,
offset, GID_LEN, ENC_NA);
offset += GID_LEN;
proto_tree_add_item(tree, hf_smcr_accept_server_preferred_mac, tvb,
offset, MAC_ADDR_LEN, ENC_NA);
offset += MAC_ADDR_LEN;
proto_tree_add_item(tree, hf_smcr_accept_server_qp_number, tvb,
offset, QP_LEN, ENC_BIG_ENDIAN);
offset += QP_LEN;
proto_tree_add_item(tree, hf_smcr_accept_server_rmb_rkey, tvb,
offset, RKEY_LEN, ENC_BIG_ENDIAN);
offset += RKEY_LEN;
proto_tree_add_item(tree, hf_smcr_accept_server_tcp_conn_index, tvb,
offset, CONN_INDEX_LEN, ENC_BIG_ENDIAN);
offset += CONN_INDEX_LEN;
proto_tree_add_item(tree, hf_smcr_accept_server_rmb_element_alert_token, tvb,
offset, ALERT_TOKEN_LEN, ENC_BIG_ENDIAN);
offset += ALERT_TOKEN_LEN;
accept_flag2_item = proto_tree_add_item(tree, hf_smcr_accept_flags2, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
accept_flag2_tree = proto_item_add_subtree(accept_flag2_item, ett_accept_flag2);
ti = proto_tree_add_item(accept_flag2_tree, hf_accept_rmb_buffer_size, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
rmbe_size = tvb_get_gint8(tvb, offset) >> 4;
disect_smc_uncompress_size(ti, rmbe_size, SMCR_MAX_BUFSIZE_NUM);
ti = proto_tree_add_item(accept_flag2_tree, hf_accept_qp_mtu_value, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
qp_num = tvb_get_gint8(tvb, offset) & 0x0F;
disect_smcr_translate_qp_mtu(ti, qp_num);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, ONE_BYTE_RESERVED, ENC_NA);
offset += ONE_BYTE_RESERVED; /* reserved */
proto_tree_add_item(tree, hf_smcr_accept_server_rmb_virtual_address, tvb,
offset, VIRTUAL_ADDR_LEN, ENC_BIG_ENDIAN);
offset += VIRTUAL_ADDR_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, ONE_BYTE_RESERVED, ENC_NA);
offset += ONE_BYTE_RESERVED; /* reserved */
proto_tree_add_item(tree, hf_smcr_accept_initial_psn, tvb,
offset, PSN_LEN, ENC_BIG_ENDIAN);
offset += PSN_LEN;
if (smc_version >= SMC_V2) {
proto_tree_add_item(tree, hf_smc_accept_eid, tvb, offset, 32, ENC_ASCII | ENC_NA);
offset += 32;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 8, ENC_NA);
offset += 8; /* reserved */
if (first_contact) {
accept_flag_item = proto_tree_add_item(tree, hf_smcr_accept_fce_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
accept_flag_tree = proto_item_add_subtree(accept_flag_item, ett_smcr_accept_fce_flag1);
proto_tree_add_item(accept_flag_tree, hf_accept_v2_lg_type, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
accept_flag_item = proto_tree_add_item(tree, hf_smc_accept_fce_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
accept_flag_tree = proto_item_add_subtree(accept_flag_item, ett_smc_accept_fce_flag);
proto_tree_add_item(accept_flag_tree, hf_accept_os_type, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(accept_flag_tree, hf_accept_smc_version_release_number, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, TWO_BYTE_RESERVED, ENC_NA);
offset += TWO_BYTE_RESERVED; /* reserved */
proto_tree_add_item(tree, hf_smc_accept_peer_name, tvb, offset, 32, ENC_ASCII | ENC_NA);
offset += 32;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 16, ENC_NA);
/* offset += 16; */ /* reserved */
}
}
}
static void
disect_smcr_confirm(tvbuff_t *tvb, proto_tree *tree)
{
guint offset, qp_num, rmbe_size;
proto_item *confirm_flag_item;
proto_tree *confirm_flag_tree;
proto_item *confirm_flag2_item;
proto_tree *confirm_flag2_tree;
proto_item *ti;
guint8 smc_version, first_contact = 0;
guint8 gid_list_len;
offset = CLC_MSG_START_OFFSET;
proto_tree_add_item(tree, hf_smc_length, tvb, offset,
LENGTH_BYTE_LEN, ENC_BIG_ENDIAN);
offset += LENGTH_BYTE_LEN;
confirm_flag_item = proto_tree_add_item(tree, hf_smcr_confirm_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
confirm_flag_tree = proto_item_add_subtree(confirm_flag_item, ett_confirm_flag);
proto_tree_add_item(confirm_flag_tree, hf_confirm_smc_version, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(confirm_flag_tree, hf_smc_confirm_first_contact, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(confirm_flag_tree, hf_confirm_smc_type, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
smc_version = tvb_get_guint8(tvb, offset);
first_contact = tvb_get_guint8(tvb, offset);
smc_version = ((smc_version >> 4) & 0x0F);
first_contact = ((first_contact >> 3) & 0x01);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_client_peer_id, tvb, offset,
PEERID_LEN, ENC_BIG_ENDIAN);
offset += PEERID_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_client_gid, tvb,
offset, GID_LEN, ENC_NA);
offset += GID_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_client_mac, tvb,
offset, MAC_ADDR_LEN, ENC_NA);
offset += MAC_ADDR_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_client_qp_number, tvb,
offset, QP_LEN, ENC_BIG_ENDIAN);
offset += QP_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_client_rmb_rkey, tvb,
offset, RKEY_LEN, ENC_BIG_ENDIAN);
offset += RKEY_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_client_tcp_conn_index, tvb,
offset, CONN_INDEX_LEN, ENC_BIG_ENDIAN);
offset += CONN_INDEX_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_client_rmb_element_alert_token, tvb,
offset, ALERT_TOKEN_LEN, ENC_BIG_ENDIAN);
offset += ALERT_TOKEN_LEN;
confirm_flag2_item = proto_tree_add_item(tree, hf_smcr_confirm_flags2, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
confirm_flag2_tree = proto_item_add_subtree(confirm_flag2_item, ett_confirm_flag2);
ti = proto_tree_add_item(confirm_flag2_tree, hf_confirm_rmb_buffer_size, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
rmbe_size = tvb_get_gint8(tvb, offset) >> 4;
disect_smc_uncompress_size(ti, rmbe_size, SMCR_MAX_BUFSIZE_NUM);
ti = proto_tree_add_item(confirm_flag2_tree, hf_confirm_qp_mtu_value, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
qp_num = tvb_get_gint8(tvb, offset) & 0x0F;
disect_smcr_translate_qp_mtu(ti, qp_num);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, ONE_BYTE_RESERVED, ENC_NA);
offset += ONE_BYTE_RESERVED; /* reserved */
proto_tree_add_item(tree, hf_smcr_confirm_client_rmb_virtual_address, tvb,
offset, VIRTUAL_ADDR_LEN, ENC_BIG_ENDIAN);
offset += VIRTUAL_ADDR_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, ONE_BYTE_RESERVED, ENC_NA);
offset += ONE_BYTE_RESERVED; /* reserved */
proto_tree_add_item(tree, hf_smcr_confirm_initial_psn, tvb,
offset, PSN_LEN, ENC_BIG_ENDIAN);
if (smc_version >= SMC_V2) {
offset += PSN_LEN;
proto_tree_add_item(tree, hf_smc_confirm_eid, tvb, offset, 32, ENC_ASCII | ENC_NA);
offset += 32;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 8, ENC_NA);
offset += 8; /* reserved */
if (first_contact) {
confirm_flag_item = proto_tree_add_item(tree, hf_smcr_accept_fce_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
confirm_flag_tree = proto_item_add_subtree(confirm_flag_item, ett_smcr_accept_fce_flag1);
proto_tree_add_item(confirm_flag_tree, hf_accept_v2_lg_type, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
confirm_flag_item = proto_tree_add_item(tree, hf_smc_accept_fce_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
confirm_flag_tree = proto_item_add_subtree(confirm_flag_item, ett_smc_confirm_fce_flag);
proto_tree_add_item(confirm_flag_tree, hf_confirm_os_type, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(confirm_flag_tree, hf_confirm_smc_version_release_number, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, TWO_BYTE_RESERVED, ENC_NA);
offset += TWO_BYTE_RESERVED; /* reserved */
proto_tree_add_item(tree, hf_smc_confirm_peer_name, tvb, offset, 32, ENC_ASCII | ENC_NA);
offset += 32;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 16, ENC_NA);
offset += 16; /* reserved */
gid_list_len = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_smc_confirm_gid_lst_len, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 3, ENC_NA);
offset += 3; /* reserved */
while (gid_list_len > 0) {
proto_tree_add_item(tree, hf_smc_confirm_gid_list_entry, tvb, offset, GID_LEN, ENC_NA);
offset += GID_LEN;
gid_list_len--;
}
}
}
}
static void
disect_smc_decline(tvbuff_t *tvb, proto_tree *tree)
{
proto_item* decline_flag_item;
proto_tree* decline_flag_tree;
proto_item* decline_flag2_item;
proto_tree* decline_flag2_tree;
guint offset, smc_version, smc_length, num_of_diag;
offset = CLC_MSG_START_OFFSET;
proto_tree_add_item(tree, hf_smc_length, tvb, offset,
LENGTH_BYTE_LEN, ENC_BIG_ENDIAN);
smc_length = tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN);
offset += LENGTH_BYTE_LEN;
decline_flag_item = proto_tree_add_item(tree, hf_smc_decline_flags, tvb, offset,
FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
decline_flag_tree = proto_item_add_subtree(decline_flag_item, ett_decline_flag);
proto_tree_add_item(decline_flag_tree, hf_decline_smc_version, tvb, offset,
FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(decline_flag_tree, hf_decline_out_of_sync, tvb, offset,
FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
smc_version = tvb_get_guint8(tvb, offset);
smc_version = ((smc_version >> 4) & 0x0F);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smc_decline_peer_id, tvb, offset,
PEERID_LEN, ENC_BIG_ENDIAN);
offset += PEERID_LEN;
proto_tree_add_item(tree, hf_smc_decline_diag_info, tvb, offset,
DIAG_INFO_LEN, ENC_BIG_ENDIAN);
offset += DIAG_INFO_LEN;
if (smc_version >= SMC_V2) {
decline_flag2_item = proto_tree_add_item(tree, hf_smc_decline_flags2, tvb, offset,
FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
decline_flag2_tree = proto_item_add_subtree(decline_flag2_item, ett_decline_flag2);
proto_tree_add_item(decline_flag2_tree, hf_decline_os_type, tvb, offset,
FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
offset += 3;
if (smc_length >= offset + 16) {
for (num_of_diag = 0; num_of_diag < 4; num_of_diag++) {
proto_tree_add_item(tree, hf_smc_decline_diag_info, tvb, offset,
DIAG_INFO_LEN, ENC_BIG_ENDIAN);
offset += DIAG_INFO_LEN;
}
}
}
}
static void
disect_smcr_confirm_link(tvbuff_t *tvb, proto_tree *tree)
{
guint offset;
proto_item *confirm_flag_item;
proto_tree *confirm_flag_tree;
offset = LLC_MSG_START_OFFSET;
confirm_flag_item = proto_tree_add_item(tree, hf_smcr_confirm_link_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
confirm_flag_tree = proto_item_add_subtree(confirm_flag_item, ett_confirm_link_flag);
proto_tree_add_item(confirm_flag_tree, hf_smcr_confirm_link_response, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_link_mac, tvb,
offset, MAC_ADDR_LEN, ENC_NA);
offset += MAC_ADDR_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_link_gid, tvb,
offset, GID_LEN, ENC_NA);
offset += GID_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_link_qp_number, tvb,
offset, QP_LEN, ENC_BIG_ENDIAN);
offset += QP_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_link_number, tvb,
offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(tree, hf_smcr_confirm_link_userid, tvb,
offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_smcr_confirm_link_max_links, tvb,
offset, 1, ENC_BIG_ENDIAN);
}
static void
disect_smcr_add_link(tvbuff_t *tvb, proto_tree *tree, bool is_smc_v2)
{
guint offset, rkey_count, qp_num;
proto_item *add_link_flag_item;
proto_tree *add_link_flag_tree;
proto_item *add_link_flag2_item;
proto_tree *add_link_flag2_tree;
proto_item *add_link_flag3_item;
proto_tree *add_link_flag3_tree;
proto_item *ti;
bool is_response = tvb_get_guint8(tvb, LLC_CMD_RSP_OFFSET) & LLC_FLAG_RESP;
offset = LLC_MSG_START_OFFSET;
add_link_flag_item = proto_tree_add_item(tree, hf_smcr_add_link_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
add_link_flag_tree = proto_item_add_subtree(add_link_flag_item, ett_add_link_flag);
proto_tree_add_item(add_link_flag_tree, hf_smcr_add_link_response, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(add_link_flag_tree, hf_smcr_add_link_response_rejected, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
if (is_smc_v2 && is_response) {
proto_tree_add_item(add_link_flag_tree, hf_smcr_add_link_reject_reason, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
}
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smcr_add_link_mac, tvb,
offset, MAC_ADDR_LEN, ENC_NA);
offset += MAC_ADDR_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, TWO_BYTE_RESERVED, ENC_NA);
offset += TWO_BYTE_RESERVED; /* reserved */
proto_tree_add_item(tree, hf_smcr_add_link_gid, tvb,
offset, GID_LEN, ENC_NA);
offset += GID_LEN;
proto_tree_add_item(tree, hf_smcr_add_link_qp_number, tvb,
offset, QP_LEN, ENC_BIG_ENDIAN);
offset += QP_LEN;
proto_tree_add_item(tree, hf_smcr_add_link_number, tvb,
offset, 1, ENC_BIG_ENDIAN);
offset += 1;
add_link_flag2_item = proto_tree_add_item(tree, hf_smcr_add_link_flags2, tvb, offset, 1, ENC_BIG_ENDIAN);
add_link_flag2_tree = proto_item_add_subtree(add_link_flag2_item, ett_add_link_flag2);
ti = proto_tree_add_item(add_link_flag2_tree, hf_smcr_add_link_qp_mtu_value, tvb, offset, 1, ENC_BIG_ENDIAN);
qp_num = tvb_get_gint8(tvb, offset) & 0x0F;
disect_smcr_translate_qp_mtu(ti, qp_num);
offset += 1;
proto_tree_add_item(tree, hf_smcr_add_link_initial_psn, tvb,
offset, PSN_LEN, ENC_BIG_ENDIAN);
offset += PSN_LEN;
if (!is_smc_v2 || is_response)
return;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 8, ENC_NA);
offset += 8; /* reserved */
add_link_flag3_item = proto_tree_add_item(tree, hf_smcr_add_link_flags3, tvb, offset, 1, ENC_BIG_ENDIAN);
add_link_flag3_tree = proto_item_add_subtree(add_link_flag3_item, ett_add_link_flag3);
proto_tree_add_item(add_link_flag3_tree, hf_smcr_add_link_flag3_direct_link, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 1, ENC_NA);
offset += 1; /* reserved */
proto_tree_add_item(tree, hf_smcr_add_link_client_target_gid, tvb, offset, GID_LEN, ENC_NA);
offset += GID_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 8, ENC_NA);
offset += 8; /* reserved */
proto_tree_add_item(tree, hf_smcr_add_link_rkey_count, tvb, offset, 2, ENC_BIG_ENDIAN);
rkey_count = tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN);
offset += 2;
while (rkey_count > 0) {
proto_tree_add_item(tree, hf_smcr_add_link_rkey, tvb, offset, RKEY_LEN, ENC_BIG_ENDIAN);
offset += RKEY_LEN;
proto_tree_add_item(tree, hf_smcr_add_link_rkey2, tvb, offset, RKEY_LEN, ENC_BIG_ENDIAN);
offset += RKEY_LEN;
proto_tree_add_item(tree, hf_smcr_add_link_virt_addr, tvb, offset, VIRTUAL_ADDR_LEN, ENC_BIG_ENDIAN);
offset += VIRTUAL_ADDR_LEN;
rkey_count--;
}
}
static void
disect_smcr_add_continuation(tvbuff_t *tvb, proto_tree *tree)
{
guint offset;
guint8 num_of_keys;
proto_item *add_link_flag_item;
proto_tree *add_link_flag_tree;
offset = LLC_MSG_START_OFFSET;
add_link_flag_item = proto_tree_add_item(tree, hf_smcr_add_link_cont_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
add_link_flag_tree = proto_item_add_subtree(add_link_flag_item, ett_add_link_cont_flag);
proto_tree_add_item(add_link_flag_tree, hf_smcr_add_link_cont_response, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smcr_add_link_cont_link_number, tvb,
offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(tree, hf_smcr_add_link_cont_number_of_rkeys, tvb,
offset, 1, ENC_BIG_ENDIAN);
num_of_keys = tvb_get_guint8(tvb,offset);
offset += 1;
if (num_of_keys >= 1) {
proto_tree_add_item(tree, hf_smcr_add_link_cont_p1_rkey, tvb,
offset, RKEY_LEN, ENC_BIG_ENDIAN);
offset += RKEY_LEN;
proto_tree_add_item(tree, hf_smcr_add_link_cont_p1_rkey2, tvb,
offset, RKEY_LEN, ENC_BIG_ENDIAN);
offset += RKEY_LEN;
proto_tree_add_item(tree, hf_smcr_add_link_cont_p1_virt_addr, tvb,
offset, VIRTUAL_ADDR_LEN, ENC_BIG_ENDIAN);
if (num_of_keys >= 2) {
offset += VIRTUAL_ADDR_LEN;
proto_tree_add_item(tree, hf_smcr_add_link_cont_p2_rkey, tvb,
offset, RKEY_LEN, ENC_BIG_ENDIAN);
offset += RKEY_LEN;
proto_tree_add_item(tree, hf_smcr_add_link_cont_p2_rkey2, tvb,
offset, RKEY_LEN, ENC_BIG_ENDIAN);
offset += RKEY_LEN;
proto_tree_add_item(tree, hf_smcr_add_link_cont_p2_virt_addr, tvb,
offset, VIRTUAL_ADDR_LEN, ENC_BIG_ENDIAN);
}
}
}
static void
disect_smcr_request_add_link(tvbuff_t* tvb, proto_tree* tree)
{
bool is_response = tvb_get_guint8(tvb, LLC_CMD_RSP_OFFSET) & LLC_FLAG_RESP;
proto_item* add_link_flag_item;
proto_tree* add_link_flag_tree;
guint offset, gid_list_len;
offset = LLC_MSG_START_OFFSET;
add_link_flag_item = proto_tree_add_item(tree, hf_smcr_request_add_link_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
add_link_flag_tree = proto_item_add_subtree(add_link_flag_item, ett_request_add_link_flag);
proto_tree_add_item(add_link_flag_tree, hf_smcr_request_add_link_response, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(add_link_flag_tree, hf_smcr_request_add_link_response_rejected, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
if (is_response) {
proto_tree_add_item(add_link_flag_tree, hf_smcr_request_add_link_reject_reason, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
}
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 20, ENC_NA);
offset += 20; /* reserved */
gid_list_len = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_smc_request_add_link_gid_lst_len, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 3, ENC_NA);
offset += 3; /* reserved */
while (gid_list_len > 0) {
proto_tree_add_item(tree, hf_smc_request_add_link_gid_list_entry, tvb, offset, GID_LEN, ENC_NA);
offset += GID_LEN;
gid_list_len--;
}
}
static void
disect_smcr_delete_link(tvbuff_t *tvb, proto_tree *tree)
{
guint offset;
proto_item *delete_link_flag_item;
proto_tree *delete_link_flag_tree;
offset = LLC_MSG_START_OFFSET;
delete_link_flag_item = proto_tree_add_item(tree, hf_smcr_delete_link_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
delete_link_flag_tree = proto_item_add_subtree(delete_link_flag_item, ett_delete_link_flag);
proto_tree_add_item(delete_link_flag_tree, hf_smcr_delete_link_response, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(delete_link_flag_tree, hf_smcr_delete_link_all, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(delete_link_flag_tree, hf_smcr_delete_link_orderly, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smcr_delete_link_number, tvb,
offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(tree, hf_smcr_delete_link_reason_code, tvb,
offset, 4, ENC_BIG_ENDIAN);
}
static void
disect_smcr_confirm_rkey(tvbuff_t *tvb, proto_tree *tree)
{
guint offset;
guint8 num_entries;
proto_item *confirm_rkey_flag_item;
proto_tree *confirm_rkey_flag_tree;
offset = LLC_MSG_START_OFFSET;
confirm_rkey_flag_item = proto_tree_add_item(tree, hf_smcr_confirm_rkey_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
confirm_rkey_flag_tree = proto_item_add_subtree(confirm_rkey_flag_item, ett_confirm_rkey_flag);
proto_tree_add_item(confirm_rkey_flag_tree, hf_smcr_confirm_rkey_response, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(confirm_rkey_flag_tree, hf_smcr_confirm_rkey_negative_response,
tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(confirm_rkey_flag_tree, hf_smcr_confirm_rkey_retry_rkey_set,
tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_rkey_number, tvb,
offset, 1, ENC_BIG_ENDIAN);
num_entries = tvb_get_guint8(tvb,offset);
if (num_entries > 2)
num_entries = 2;
offset += 1;
proto_tree_add_item(tree, hf_smcr_confirm_rkey_new_rkey, tvb,
offset, RKEY_LEN, ENC_BIG_ENDIAN);
offset += RKEY_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_rkey_virtual_address, tvb,
offset, VIRTUAL_ADDR_LEN, ENC_BIG_ENDIAN);
for (; num_entries > 0; num_entries--) {
offset += VIRTUAL_ADDR_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_rkey_link_number, tvb,
offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(tree, hf_smcr_confirm_rkey_new_rkey, tvb,
offset, RKEY_LEN, ENC_BIG_ENDIAN);
offset += RKEY_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_rkey_virtual_address, tvb,
offset, VIRTUAL_ADDR_LEN, ENC_BIG_ENDIAN);
}
}
static void
disect_smcr_confirm_rkey_cont(tvbuff_t *tvb, proto_tree *tree)
{
guint offset;
proto_item *confirm_rkey_flag_item;
proto_tree *confirm_rkey_flag_tree;
guint8 num_entries;
offset = LLC_MSG_START_OFFSET;
confirm_rkey_flag_item = proto_tree_add_item(tree, hf_smcr_confirm_rkey_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
confirm_rkey_flag_tree = proto_item_add_subtree(confirm_rkey_flag_item, ett_confirm_rkey_flag);
proto_tree_add_item(confirm_rkey_flag_tree, hf_smcr_confirm_rkey_response, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(confirm_rkey_flag_tree, hf_smcr_confirm_rkey_negative_response,
tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(confirm_rkey_flag_tree, hf_smcr_confirm_rkey_retry_rkey_set,
tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_rkey_number, tvb,
offset, 1, ENC_BIG_ENDIAN);
num_entries = tvb_get_guint8(tvb,offset);
if (num_entries > 3)
num_entries = 3;
offset += 1;
for (; num_entries > 0; num_entries--) {
proto_tree_add_item(tree, hf_smcr_confirm_rkey_link_number, tvb,
offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(tree, hf_smcr_confirm_rkey_new_rkey, tvb,
offset, RKEY_LEN, ENC_BIG_ENDIAN);
offset += RKEY_LEN;
proto_tree_add_item(tree, hf_smcr_confirm_rkey_virtual_address, tvb,
offset, VIRTUAL_ADDR_LEN, ENC_BIG_ENDIAN);
offset += VIRTUAL_ADDR_LEN;
}
}
static void
disect_smcr_delete_rkey(tvbuff_t *tvb, proto_tree *tree, bool is_smc_v2)
{
guint offset;
guint8 count;
proto_item *delete_rkey_flag_item;
proto_tree *delete_rkey_flag_tree;
offset = LLC_MSG_START_OFFSET;
delete_rkey_flag_item = proto_tree_add_item(tree, hf_smcr_delete_rkey_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
delete_rkey_flag_tree = proto_item_add_subtree(delete_rkey_flag_item, ett_delete_rkey_flag);
proto_tree_add_item(delete_rkey_flag_tree, hf_smcr_delete_rkey_response, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(delete_rkey_flag_tree, hf_smcr_delete_rkey_negative_response,
tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
count = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_smcr_delete_rkey_count, tvb, offset, 1, ENC_NA);
offset += 1;
if (!is_smc_v2) {
proto_tree_add_item(tree, hf_smcr_delete_rkey_mask, tvb, offset, 1, ENC_BIG_ENDIAN);
} else {
bool is_response = tvb_get_guint8(tvb, LLC_CMD_RSP_OFFSET) & LLC_FLAG_RESP;
if (is_response) {
proto_tree_add_item(tree, hf_smcr_delete_rkey_invalid_count, tvb, offset, 1, ENC_NA);
count = tvb_get_guint8(tvb, offset);
if (count > 8)
count = 8; /* show a maximum of 8 invalid rkeys in response */
}
}
offset += 1;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, 2, ENC_NA);
offset += 2; /* reserved */
while (count > 0) {
proto_tree_add_item(tree, hf_smcr_delete_rkey_deleted, tvb,
offset, RKEY_LEN, ENC_BIG_ENDIAN);
offset += RKEY_LEN;
count--;
}
}
static void
disect_smcr_test_link(tvbuff_t *tvb, proto_tree *tree)
{
guint offset;
proto_item *test_link_flag_item;
proto_tree *test_link_flag_tree;
offset = LLC_MSG_START_OFFSET;
test_link_flag_item = proto_tree_add_item(tree, hf_smcr_test_link_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
test_link_flag_tree = proto_item_add_subtree(test_link_flag_item, ett_test_link_flag);
proto_tree_add_item(test_link_flag_tree, hf_smcr_test_link_response, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
}
static void
disect_smcr_rmbe_ctrl(tvbuff_t *tvb, proto_tree *tree)
{
gint offset;
proto_item *rmbe_ctrl_rw_status_flag_item;
proto_tree *rmbe_ctrl_rw_status_flag_tree;
proto_item *rmbe_ctrl_peer_conn_state_flag_item;
proto_tree *rmbe_ctrl_peer_conn_state_flag_tree;
offset = RMBE_CTRL_START_OFFSET;
proto_tree_add_item(tree, hf_smcr_rmbe_ctrl_seqno, tvb, offset, SEQNO_LEN, ENC_BIG_ENDIAN);
offset += SEQNO_LEN;
proto_tree_add_item(tree, hf_smcr_rmbe_ctrl_alert_token, tvb, offset, ALERT_TOKEN_LEN, ENC_BIG_ENDIAN);
offset += ALERT_TOKEN_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, TWO_BYTE_RESERVED, ENC_NA);
offset += TWO_BYTE_RESERVED; /* reserved */
proto_tree_add_item(tree, hf_smcr_rmbe_ctrl_prod_wrap_seqno, tvb, offset, SEQNO_LEN, ENC_BIG_ENDIAN);
offset += SEQNO_LEN;
proto_tree_add_item(tree, hf_smcr_rmbe_ctrl_peer_prod_curs, tvb, offset, CURSOR_LEN, ENC_BIG_ENDIAN);
offset += CURSOR_LEN;
proto_tree_add_item(tree, hf_smc_reserved, tvb, offset, TWO_BYTE_RESERVED, ENC_NA);
offset += TWO_BYTE_RESERVED; /* reserved */
proto_tree_add_item(tree, hf_smcr_rmbe_ctrl_cons_wrap_seqno, tvb, offset, SEQNO_LEN, ENC_BIG_ENDIAN);
offset += SEQNO_LEN;
proto_tree_add_item(tree, hf_smcr_rmbe_ctrl_peer_cons_curs, tvb, offset, CURSOR_LEN, ENC_BIG_ENDIAN);
offset += CURSOR_LEN;
rmbe_ctrl_rw_status_flag_item =
proto_tree_add_item(tree, hf_smcr_rmbe_ctrl_conn_rw_status_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
rmbe_ctrl_rw_status_flag_tree =
proto_item_add_subtree(rmbe_ctrl_rw_status_flag_item, ett_rmbe_ctrl_rw_status_flag);
proto_tree_add_item(rmbe_ctrl_rw_status_flag_tree, hf_smcr_rmbe_ctrl_write_blocked,
tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(rmbe_ctrl_rw_status_flag_tree, hf_smcr_rmbe_ctrl_urgent_pending,
tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(rmbe_ctrl_rw_status_flag_tree, hf_smcr_rmbe_ctrl_urgent_present,
tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(rmbe_ctrl_rw_status_flag_tree, hf_smcr_rmbe_ctrl_cons_update_requested,
tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(rmbe_ctrl_rw_status_flag_tree, hf_smcr_rmbe_ctrl_failover_validation,
tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
offset += FLAG_BYTE_LEN;
rmbe_ctrl_peer_conn_state_flag_item =
proto_tree_add_item(tree, hf_smcr_rmbe_ctrl_peer_conn_state_flags, tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
rmbe_ctrl_peer_conn_state_flag_tree =
proto_item_add_subtree(rmbe_ctrl_peer_conn_state_flag_item, ett_rmbe_ctrl_peer_conn_state_flag);
proto_tree_add_item(rmbe_ctrl_peer_conn_state_flag_tree, hf_smcr_rmbe_ctrl_peer_sending_done,
tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(rmbe_ctrl_peer_conn_state_flag_tree, hf_smcr_rmbe_ctrl_peer_closed_conn,
tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
proto_tree_add_item(rmbe_ctrl_peer_conn_state_flag_tree, hf_smcr_rmbe_ctrl_peer_abnormal_close,
tvb, offset, FLAG_BYTE_LEN, ENC_BIG_ENDIAN);
}
static guint8 get_mixed_type(guint8 v1_type, guint8 v2_type)
{
if (v1_type == SMC_CLC_BOTH)
return v1_type;
if (v1_type == SMC_CLC_NONE)
return v2_type;
if (((v2_type == SMC_CLC_SMCD) && (v1_type == SMC_CLC_SMCR)) ||
((v2_type == SMC_CLC_SMCR) && (v1_type == SMC_CLC_SMCD)))
return SMC_CLC_BOTH;
return v2_type;
}
static int
dissect_smc_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data _U_)
{
gint offset;
guint16 msg_len;
guint8 smc_type, smc_v2_type = 0, smc_v1_type = 0, smc_version = 0;
guint8 mixed_type;
clc_message clc_msgid;
proto_item *ti;
proto_tree *smc_tree;
bool is_ipv6, is_smc_v2, is_smcd = false;
msg_len = tvb_get_ntohs(tvb, CLC_MSG_LEN_OFFSET);
offset = 4;
clc_msgid = (clc_message)tvb_get_guint8(tvb, offset);
smc_version = tvb_get_guint8(tvb, offset + 3);
smc_version = ((smc_version >> 4) & 0x0F);
smc_type = tvb_get_guint8(tvb, offset + 3);
is_smc_v2 = (smc_version >= SMC_V2);
if (is_smc_v2 && (clc_msgid == SMC_CLC_PROPOSAL)) {
smc_v1_type = (smc_type & 0x03);
smc_v2_type = ((smc_type >> 2) & 0x03);
}
else if (clc_msgid != SMC_CLC_DECLINE) {
smc_v2_type = (smc_type & 0x03);
smc_v1_type = (smc_type & 0x03);
}
is_ipv6 = (pinfo->src.type == AT_IPv6);
if (is_smc_v2)
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMCv2");
else
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMC");
if (clc_msgid == SMC_CLC_PROPOSAL) {
if (is_smc_v2 && (smc_v2_type != SMC_CLC_NONE)) {
mixed_type = get_mixed_type(smc_v1_type, smc_v2_type);
col_prepend_fstr(pinfo->cinfo, COL_INFO, "%s,",
val_to_str_const((guint32)mixed_type,
smcv2_clc_col_info_message_txt, "Unknown Command"));
} else {
col_prepend_fstr(pinfo->cinfo, COL_INFO, "%s,",
val_to_str_const((guint32)smc_v1_type,
smc_clc_col_info_message_txt, "Unknown Command"));
}
} else if ((smc_v2_type == SMC_CLC_SMCR) && ((clc_msgid == SMC_CLC_ACCEPT) ||
(clc_msgid == SMC_CLC_CONFIRMATION))) {
if (is_smc_v2)
col_prepend_fstr(pinfo->cinfo, COL_INFO, "[SMC-Rv2-%s],",
val_to_str_const((guint32)clc_msgid,
smcr_clc_message_txt, "Unknown Command"));
else
col_prepend_fstr(pinfo->cinfo, COL_INFO, "[SMC-R-%s],",
val_to_str_const((guint32)clc_msgid,
smcr_clc_message_txt, "Unknown Command"));
col_append_fstr(pinfo->cinfo, COL_INFO, " QP=0x%06x",
tvb_get_ntoh24(tvb, ACCEPT_CONFIRM_QP_OFFSET));
}
else if ((smc_v2_type == SMC_CLC_SMCD) && ((clc_msgid == SMC_CLC_ACCEPT) ||
(clc_msgid == SMC_CLC_CONFIRMATION))) {
is_smcd = true;
if (is_smc_v2)
col_prepend_fstr(pinfo->cinfo, COL_INFO, "[SMC-Dv2-%s],",
val_to_str_const((guint32)clc_msgid,
smcr_clc_message_txt, "Unknown Command"));
else
col_prepend_fstr(pinfo->cinfo, COL_INFO, "[SMC-D-%s],",
val_to_str_const((guint32)clc_msgid,
smcr_clc_message_txt, "Unknown Command"));
}
else {
if (is_smc_v2)
col_prepend_fstr(pinfo->cinfo, COL_INFO, "[SMCv2-%s],",
val_to_str_const((guint32)clc_msgid,
smcr_clc_message_txt, "Unknown Command"));
else
col_prepend_fstr(pinfo->cinfo, COL_INFO, "[SMC-%s],",
val_to_str_const((guint32)clc_msgid,
smcr_clc_message_txt, "Unknown Command"));
}
if (!tree)
return tvb_reported_length(tvb);
ti = proto_tree_add_item(tree, proto_smc, tvb, 0, msg_len, ENC_NA);
smc_tree = proto_item_add_subtree(ti, ett_smcr);
proto_tree_add_item(smc_tree, hf_smcr_clc_msg, tvb, offset, 1,
ENC_BIG_ENDIAN);
switch (clc_msgid) {
case SMC_CLC_PROPOSAL:
disect_smc_proposal(tvb, smc_tree, is_ipv6);
break;
case SMC_CLC_ACCEPT:
if (is_smcd)
disect_smcd_accept(tvb, smc_tree);
else
disect_smcr_accept(tvb, smc_tree);
break;
case SMC_CLC_CONFIRMATION:
if (is_smcd)
disect_smcd_confirm(tvb, smc_tree);
else
disect_smcr_confirm(tvb, smc_tree);
break;
case SMC_CLC_DECLINE:
disect_smc_decline(tvb, smc_tree);
break;
default:
/* Unknown Command */
break;
}
return tvb_reported_length(tvb);
}
static int
dissect_smcr_infiniband(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
guint16 msg_len;
llc_message llc_msgid;
proto_item *ti;
proto_tree *smcr_tree;
int smc_version;
bool is_smc_v2;
llc_msgid = (llc_message) tvb_get_guint8(tvb, LLC_CMD_OFFSET);
smc_version = ((llc_msgid >> 4) & 0x0F);
is_smc_v2 = (smc_version == SMC_V2);
if (!is_smc_v2) {
msg_len = tvb_get_guint8(tvb, LLC_LEN_OFFSET);
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMC-R");
col_append_str(pinfo->cinfo, COL_INFO, "[SMC-R] ");
} else {
msg_len = tvb_get_guint16(tvb, LLC_LEN_OFFSET, ENC_BIG_ENDIAN);
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMC-Rv2");
col_append_str(pinfo->cinfo, COL_INFO, "[SMC-Rv2] ");
}
col_append_str(pinfo->cinfo, COL_INFO,
val_to_str_const((guint32)llc_msgid,
smcr_llc_message_txt, "Unknown Command"));
if ((llc_msgid != RMBE_CTRL) &&
(tvb_get_guint8(tvb, LLC_CMD_RSP_OFFSET) & LLC_FLAG_RESP))
col_append_str(pinfo->cinfo, COL_INFO, "(Resp)");
ti = proto_tree_add_item(tree, proto_smc, tvb, 0, msg_len, ENC_NA);
smcr_tree = proto_item_add_subtree(ti, ett_smcr);
ti = proto_tree_add_item(smcr_tree, hf_smcr_llc_msg, tvb, 0, 1, ENC_BIG_ENDIAN);
if ((llc_msgid != RMBE_CTRL) &&
(tvb_get_guint8(tvb, LLC_CMD_RSP_OFFSET) & LLC_FLAG_RESP))
proto_item_append_text(ti, " (Resp)");
proto_tree_add_item(smcr_tree, hf_smc_length, tvb, LLC_LEN_OFFSET, (!is_smc_v2?1:2), ENC_BIG_ENDIAN);
switch (llc_msgid) {
case LLC_CONFIRM_LINK:
case LLC_CONFIRM_LINK_V2:
disect_smcr_confirm_link(tvb, smcr_tree);
break;
case LLC_ADD_LINK:
case LLC_ADD_LINK_V2:
disect_smcr_add_link(tvb, smcr_tree, is_smc_v2);
break;
case LLC_ADD_LINK_CONT:
disect_smcr_add_continuation(tvb, smcr_tree);
break;
case LLC_DEL_LINK:
case LLC_DEL_LINK_V2:
disect_smcr_delete_link(tvb, smcr_tree);
break;
case LLC_CONFIRM_RKEY:
case LLC_CONFIRM_RKEY_V2:
disect_smcr_confirm_rkey(tvb, smcr_tree);
break;
case LLC_CONFIRM_RKEY_CONT:
disect_smcr_confirm_rkey_cont(tvb, smcr_tree);
break;
case LLC_DELETE_RKEY:
case LLC_DELETE_RKEY_V2:
disect_smcr_delete_rkey(tvb, smcr_tree, is_smc_v2);
break;
case LLC_TEST_LINK:
case LLC_TEST_LINK_V2:
disect_smcr_test_link(tvb, smcr_tree);
break;
case LLC_REQUEST_ADD_LINK_V2:
disect_smcr_request_add_link(tvb, smcr_tree);
break;
case RMBE_CTRL:
disect_smcr_rmbe_ctrl(tvb, smcr_tree);
break;
default:
/* Unknown Command */
break;
}
return tvb_captured_length(tvb);
}
static guint
get_smcr_pdu_length(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
{
guint32 length;
length = tvb_get_ntohs(tvb, offset+CLC_MSG_LEN_OFFSET);
return length;
}
static int
dissect_smc_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data)
{
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, SMC_TCP_MIN_HEADER_LENGTH,
get_smcr_pdu_length, dissect_smc_tcp_pdu, data);
return tvb_reported_length(tvb);
}
static gboolean
dissect_smc_tcp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data)
{
if (tvb_captured_length(tvb) < 4) {
return FALSE;
}
if ((tvb_get_ntohl(tvb, CLC_MSG_BYTE_0) != SMCR_CLC_ID) &&
(tvb_get_ntohl(tvb, CLC_MSG_BYTE_0) != SMCD_CLC_ID))
return FALSE;
dissect_smc_tcp(tvb, pinfo, tree, data);
return TRUE;
}
static gboolean
dissect_smcr_infiniband_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data _U_)
{
guint16 msg_len;
llc_message msg_byte0;
guint8 msg_byte1;
int v1_check = TRUE, v2_check = TRUE;
if (tvb_captured_length_remaining(tvb, SMCR_MSG_BYTE_0) < 2) /* need at least 2 bytes */
return FALSE;
/* Grab the first two bytes of the message, as they are needed */
/* for validity checking of both CLC and LLC messages */
msg_byte0 = (llc_message) tvb_get_guint8(tvb,CLC_MSG_BYTE_0);
msg_byte1 = tvb_get_guint8(tvb,CLC_MSG_BYTE_1);
/* Check for possible LLC Messages */
if (!((msg_byte1 == LLC_MSG_LENGTH) &&
(((msg_byte0 >= LLC_CONFIRM_LINK) &&
(msg_byte0 <= LLC_DELETE_RKEY)) ||
(msg_byte0 == LLC_RMBE_CTRL))))
v1_check = FALSE;
if (!(((msg_byte0 >= LLC_CONFIRM_LINK_V2) &&
(msg_byte0 <= LLC_ADD_LINK_V2)) ||
((msg_byte0 >= LLC_DEL_LINK_V2) &&
(msg_byte0 <= LLC_TEST_LINK_V2)) ||
(msg_byte0 == LLC_DELETE_RKEY_V2)))
v2_check = FALSE;
if ((!v1_check && !v2_check) || (v1_check && v2_check))
return FALSE;
if (v1_check)
msg_len = tvb_get_guint8(tvb, LLC_LEN_OFFSET);
else
msg_len = tvb_get_guint16(tvb, LLC_LEN_OFFSET, ENC_BIG_ENDIAN);
if (msg_len != tvb_reported_length_remaining(tvb, LLC_CMD_OFFSET))
return FALSE;
dissect_smcr_infiniband(tvb, pinfo, tree, data);
return TRUE;
}
void
proto_register_smcr(void)
{
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_smcr_clc_msg, {
"CLC Message", "smc.clc_msg",
FT_UINT8, BASE_DEC, VALS(smcr_clc_message_txt), 0x0,
NULL, HFILL}},
{ &hf_smcr_llc_msg, {
"LLC Message", "smc.llc_msg",
FT_UINT8, BASE_HEX, VALS(smcr_llc_message_txt), 0x0,
NULL, HFILL}},
{ &hf_proposal_smc_version_release_number, {
"SMC Version Release Number", "smc.proposal.smc.version.relnum",
FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL }},
{ &hf_proposal_smc_version_seid, {
"SEID Indicator", "smc.proposal.smc.seid",
FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL } },
{ &hf_proposal_smc_version, {
"SMC Version", "smc.proposal.smc.version",
FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL}},
{ &hf_proposal_smc_type, {
"SMC(v1) Type", "smc.proposal.smc.type",
FT_UINT8, BASE_DEC, VALS(smc_clc_type_message_txt),
0x03, NULL, HFILL}},
{ &hf_accept_smc_type, {
"SMC Type", "smc.accept.smc.type",
FT_UINT8, BASE_DEC, VALS(smc_clc_type_message_txt),
0x03, NULL, HFILL}},
{ &hf_confirm_smc_type, {
"SMC Type", "smc.confirm.smc.type",
FT_UINT8, BASE_DEC, VALS(smc_clc_type_message_txt),
0x03, NULL, HFILL}},
{ &hf_proposal_smc_v2_type, {
"SMC(v2) Type", "smc.proposal.smcv2.type",
FT_UINT8, BASE_DEC, VALS(smc_clc_type_message_txt),
0x0C, NULL, HFILL}},
{ &hf_smc_proposal_smc_chid, {
"ISMv2 CHID", "smc.proposal.smc.chid",
FT_UINT16, BASE_HEX, NULL, 0x00, NULL, HFILL}},
{ &hf_smc_length, {
"SMC Length", "smc.length",
FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL}},
{ &hf_accept_smc_version, {
"SMC Version", "smc.proposal.smc.version",
FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL}},
{ &hf_smcd_accept_smc_version, {
"SMC Version", "smc.proposal.smc.version",
FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL}},
{ &hf_smcd_confirm_smc_version, {
"SMC Version", "smc.proposal.smc.version",
FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL}},
{ &hf_accept_first_contact, {
"First Contact", "smc.proposal.first.contact",
FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL}},
{ &hf_confirm_smc_version, {
"SMC Version", "smc.proposal.smc.version",
FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL}},
{ &hf_accept_rmb_buffer_size, {
"Server RMB Buffers Size (Compressed Notation)",
"smc.accept.rmb.buffer.size",
FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL}},
{ &hf_accept_qp_mtu_value, {
"QP MTU Value (enumerated value)",
"smc.accept.qp.mtu.value",
FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL}},
{ &hf_confirm_rmb_buffer_size, {
"Client RMB Buffers Size (Compressed Notation)",
"smc.confirm.rmb.buffer.size",
FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL}},
{ &hf_confirm_qp_mtu_value, {
"QP MTU Value (enumerated value)",
"smc.confirm.qp.mtu.value",
FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL}},
{ &hf_smc_proposal_flags, {
"Flags", "smc.proposal.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smc_proposal_ext_flags, {
"Flag 2", "smc.proposal.extflags.2",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_accept_flags, {
"Flags", "smc.accept.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_accept_flags2, {
"Flags 2", "smc.accept.flags.2",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_flags, {
"Flags", "smc.confirm.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_decline_smc_version, {
"SMC Version", "smc.decline.smc.version",
FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL} },
{ &hf_decline_out_of_sync, {
"Out of Sync", "smc.decline.osync",
FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL} },
{ &hf_smc_decline_flags2, {
"Flags 2", "smc.decline.flags2",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smc_decline_flags, {
"Flags", "smc.decline.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_smcr_confirm_flags2, {
"Flags 2", "smc.confirm.flags.2",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smc_proposal_client_peer_id, {
"Sender (Client) Peer ID", "smc.proposal.sender.client.peer.id",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smc_proposal_ism_gid_count, {
"ISMv2 GID Count", "smc.proposal.ismv2_gid_count",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} },
{ &hf_smc_proposal_ism_gid, {
"ISM GID", "smc.proposal.ism.gid",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smc_proposal_client_preferred_gid, {
"Client Preferred GID", "smc.proposal.client.preferred.gid",
FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{ &hf_smc_proposal_client_preferred_mac, {
"Client Preferred MAC Address",
"smc.proposal.client.preferred.mac",
FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_accept_server_peer_id, {
"Sender (Server) Peer ID", "smc.accept.sender.server.peer.id",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_accept_server_preferred_gid, {
"Server Preferred GID", "smc.accept.server.preferred.gid",
FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_accept_server_preferred_mac, {
"Server Preferred MAC Address",
"smc.accept.server.preferred.mac",
FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{ &hf_smc_proposal_smcv1_subnet_ext_offset, {
"SMCv1 IP Subnet Extension Offset","smc.proposal.smcv1_subnet_ext_offset",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_smc_proposal_smcv2_ext_offset, {
"SMCv2 Extension Offset","smc.proposal.smcv2_ext_offset",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_smc_proposal_smcdv2_ext_offset, {
"SMC-Dv2 Extension Offset","smc.proposal.smcdv2_ext_offset",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_smc_proposal_rocev2_gid_ipv6_addr, {
"RoCEv2 GID IPv6 Address",
"smc.proposal.rocev2.gid.ipv6",
FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} },
{ &hf_smc_proposal_rocev2_gid_ipv4_addr, {
"RoCEv2 GID IPv4 Address",
"smc.proposal.rocev2.gid.ipv4",
FT_IPv4, BASE_NETMASK, NULL, 0x0, NULL, HFILL}},
{ &hf_smc_proposal_outgoing_interface_subnet_mask, {
"Outgoing Interface Subnet Mask",
"smc.outgoing.interface.subnet.mask",
FT_IPv4, BASE_NETMASK, NULL, 0x0, NULL, HFILL}},
{ &hf_smc_proposal_outgoing_subnet_mask_signifcant_bits, {
"Outgoing Interface Subnet Mask Number of Significant Bits",
"smc.outgoing.interface.subnet.mask.number.of.significant.bits",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}},
{ &hf_smc_proposal_ipv6_prefix_count, {
"IPv6 Prefix Count","smc.proposal.ipv6.prefix.count",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} },
{ &hf_smc_proposal_ipv6_prefix, {
"IPv6 Prefix Value","smc.proposal.ipv6.prefix.value",
FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{ &hf_smc_proposal_ipv6_prefix_length, {
"IPv6 Prefix Length", "smc.proposal.ipv6.prefix.length",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_accept_server_qp_number, {
"Server QP Number","smc.accept.server.qp.number",
FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_accept_server_rmb_rkey, {
"Server RMB Rkey","smc.accept.server.rmb.rkey",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_accept_server_tcp_conn_index, {
"Server TCP Connection Index",
"smc.accept.server.tcp.conn.index",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_accept_server_rmb_element_alert_token, {
"Server RMB Element Alert Token",
"smc.accept.server.rmb.element.alert.token",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_accept_server_rmb_virtual_address, {
"Server's RMB Virtual Address",
"smc.accept.server.rmb.virtual.address",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_accept_initial_psn, {
"Initial PSN","smc.accept.initial.psn",
FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_client_peer_id, {
"Sender (Client) Peer ID",
"smc.confirm.sender.client.peer.id",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_client_gid, {
"Client GID", "smc.client.gid",
FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_client_mac, {
"Client MAC Address", "smc.confirm.client.mac",
FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_client_qp_number, {
"Client QP Number","smc.confirm.client.qp.number",
FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_client_rmb_rkey, {
"Client RMB Rkey","smc.confirm.client.rmb.rkey",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_client_tcp_conn_index, {
"Client TCP Connection Index",
"smc.confirm.client.tcp.conn.index",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_client_rmb_element_alert_token, {
"Client RMB Element Alert Token",
"smc.client.rmb.element.alert.token",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_client_rmb_virtual_address, {
"Client's RMB Virtual Address",
"smc.client.rmb.virtual.address",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_initial_psn, {
"Initial PSN","smc.initial.psn",
FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smc_decline_peer_id, {
"Sender Peer ID", "smc.sender.peer.id",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smc_decline_diag_info, {
"Peer Diagnosis Information", "smc.peer.diag.info",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_decline_os_type, {
"OS Type", "smc.decline.os.type",
FT_UINT8, BASE_DEC, VALS(smc_clc_os_message_txt), 0xF0, NULL, HFILL} },
{ &hf_smcr_confirm_link_gid, {
"Sender GID", "smc.sender.gid",
FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_link_mac, {
"Sender MAC Address", "smc.confirm.link.sender.mac",
FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_link_qp_number, {
"Sender QP Number","smc.confirm.link.sender.qp.number",
FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_link_number, {
"Link Number", "smc.confirm.link.number",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_link_userid, {
"Sender Link User ID",
"smc.confirm.link.sender.link.userid",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_link_max_links, {
"Max Links","smc.confirm.link.max.links",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_link_flags, {
"Flags", "smc.confirm.link.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_link_response, {
"Response", "smc.confirm.link.response",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}},
{ &hf_smcr_add_link_gid, {
"Sender GID", "smc.add.link.sender.gid",
FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_mac, {
"Sender MAC Address", "smc.add.link.sender.mac",
FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_qp_number, {
"Sender QP Number","smc.add.link.sender.qp.number",
FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_number, {
"Link Number", "smc.add.link.link.number",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_initial_psn, {
"Initial PSN", "smc.add.link.initial.psn",
FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_flags, {
"Flags", "smc.add.link.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_response, {
"Add Link Response", "smc.add.link.response",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}},
{ &hf_smcr_add_link_response_rejected, {
"Add Link Rejected", "smc.add.link.response.rejected",
FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL}},
{ &hf_smcr_add_link_reject_reason, {
"Reject Reason", "smc.add.link.response.reject_reason",
FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}},
{ &hf_smcr_add_link_flags2, {
"Flags", "smc.add.link.flags2",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_smcr_add_link_qp_mtu_value, {
"QP MTU Value (enumerated value)", "smc.add.link.qp.mtu.value",
FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL}},
{ &hf_smcr_add_link_flags3, {
"V2 Flags", "smc.add.link.flags3",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_smcr_add_link_flag3_direct_link, {
"Direct link attachment to peer", "smc.add.link.direct_link",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}},
{ &hf_smcr_add_link_client_target_gid, {
"Client Target GID", "smc.add.link.client_target_gid",
FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_rkey_count, {
"Number of Rkeys", "smc.add.link.rkey_count",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_rkey, {
"RMB RToken Pair - Rkey as known on this SMC Link",
"smc.add.link.rmb.RTok.Rkey1",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_rkey2, {
"RMB RToken Pair - Equivalent Rkey for the new SMC Link",
"smc.add.link.rmb.RTok.Rkey2",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_virt_addr, {
"RMB RToken Pair - Virtual Address for the new SMC Link",
"smc.add.link.rmb.RTok.virt",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_cont_flags, {
"Flags", "smc.add.link.cont.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_cont_response, {
"Response", "smc.add.link.cont.response",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}},
{ &hf_smcr_add_link_cont_link_number, {
"Link Number", "smc.add.link.cont.link.number",
FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL}},
{ &hf_smcr_add_link_cont_number_of_rkeys, {
"Number of Rkeys", "smc.add.link.cont.rkey.number",
FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL}},
{ &hf_smcr_add_link_cont_p1_rkey, {
"RMB RToken Pair 1 - Rkey as known on this SMC Link",
"smc.add.link.cont.rmb.RTok1.Rkey1",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_cont_p1_rkey2, {
"RMB RToken Pair 1 - Equivalent Rkey for the new SMC Link",
"smc.add.link.cont.rmb.RTok1.Rkey2",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_cont_p1_virt_addr, {
"RMB RToken Pair 1 Virtual Address for the new SMC Link",
"smc.add.link.cont.rmb.RTok1.virt",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_cont_p2_rkey, {
"RMB RToken Pair 2 - Rkey as known on this SMC Link",
"smc.add.link.cont.rmb.RTok2.Rkey1",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_cont_p2_rkey2, {
"RMB RToken Pair 2 - Equivalent Rkey for the new SMC Link",
"smc.add.link.cont.rmb.RTok2.Rkey2",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_add_link_cont_p2_virt_addr, {
"RMB RToken Pair 2 Virtual Address for the new SMC Link",
"smc.add.link.cont.rmb.RTok1.virt",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_request_add_link_flags, {
"Flags", "smc.add.link.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_smcr_request_add_link_response, {
"Request Add Link Response", "smc.request.add.link.response",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL} },
{ &hf_smcr_request_add_link_response_rejected, {
"Request Add Link Rejected", "smc.request.add.link.response.rejected",
FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL} },
{ &hf_smcr_request_add_link_reject_reason, {
"Reject Reason", "smc.request.add.link.response.reject_reason",
FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL} },
{ &hf_smc_request_add_link_gid_lst_len, {
"GID List Entry Count", "smc.request.add.link.gid.list.entry_count",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} },
{ &hf_smc_request_add_link_gid_list_entry, {
"RoCEv2 GID List Entry", "smc.request.add.link.gid.list.entry",
FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} },
{ &hf_smcr_delete_link_flags, {
"Flags", "smc.delete.link.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_delete_link_response, {
"Response", "smc.delete.link.response",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}},
{ &hf_smcr_delete_link_all, {
"Terminate All Links In The Link Group",
"smc.delete.link.all",
FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL}},
{ &hf_smcr_delete_link_orderly, {
"Terminate Links Orderly", "smc.delete.link.orderly",
FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL}},
{ &hf_smcr_delete_link_number, {
"Link Number For The Failed Link", "smc.delete.link.number",
FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL}},
{ &hf_smcr_delete_link_reason_code, {
"Reason Code", "smc.delete.link.reason.code",
FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL}},
{ &hf_smcr_confirm_rkey_flags, {
"Flags", "smc.confirm.rkey.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_rkey_response, {
"Response", "smc.confirm.rkey.response",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}},
{ &hf_smcr_confirm_rkey_negative_response, {
"Negative Response", "smc.confirm.rkey.negative.response",
FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL}},
{ &hf_smcr_confirm_rkey_retry_rkey_set, {
"Retry Rkey Set", "smc.confirm.rkey.retry.rkey.set",
FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL}},
{ &hf_smcr_confirm_rkey_number, {
"Number of other QP", "smc.confirm.rkey.number.qp",
FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL}},
{ &hf_smcr_confirm_rkey_new_rkey, {
"New Rkey for this link","smc.confirm.rkey.new.rkey",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_rkey_virtual_address, {
"New RMB virtual address for this link",
"smc.confirm.rkey.new.virt",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_confirm_rkey_link_number, {
"Link Number", "smc.confirm.rkey.link.number",
FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL}},
{ &hf_smcr_delete_rkey_flags, {
"Flags", "smc.delete.rkey.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_delete_rkey_response, {
"Response", "smc.delete.rkey.response",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}},
{ &hf_smcr_delete_rkey_negative_response, {
"Negative Response", "smc.delete.rkey.negative.response",
FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL}},
{ &hf_smcr_delete_rkey_mask, {
"Error Mask", "smc.delete.rkey.error.mask",
FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL}},
{ &hf_smcr_delete_rkey_deleted, {
"RMB Rkey to be deleted", "smc.delete.rkey.deleted",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_delete_rkey_count, {
"Rkey Count", "smc.delete.rkey.count",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_delete_rkey_invalid_count, {
"Invalid Rkey Count", "smc.delete.rkey.count.invalid",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_test_link_flags, {
"Flags", "smc.test.link.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_test_link_response, {
"Response", "smc.test.link.response",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}},
{ &hf_smcr_rmbe_ctrl_seqno, {
"Sequence Number", "smc.rmbe.ctrl.seqno",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_rmbe_ctrl_alert_token, {
"Alert Token", "smc.rmbe.ctrl.alert.token",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smc_proposal_eid_count, {
"EID Count", "smc.proposal.eid.count",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} },
{ &hf_smc_proposal_eid, {
"EID", "smc.proposal.eid",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL} },
{ &hf_smc_proposal_system_eid, {
"SEID", "smc.proposal.system.eid",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL} },
{ &hf_smcr_rmbe_ctrl_prod_wrap_seqno, {
"Producer window wrap sequence number",
"smc.rmbe.ctrl.prod.wrap.seq",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_rmbe_ctrl_peer_prod_curs, {
"Peer Producer Cursor", "smc.rmbe.ctrl.peer.prod.curs",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_smcr_rmbe_ctrl_cons_wrap_seqno, {
"Consumer window wrap sequence number",
"smc.rmbe.ctrl.prod.wrap.seq",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_rmbe_ctrl_peer_cons_curs, {
"Peer Consumer Cursor", "smc.rmbe.ctrl.peer.prod.curs",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_rmbe_ctrl_conn_rw_status_flags, {
"Connection read/write status flags",
"smc.rmbe.ctrl.conn.rw.status.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_rmbe_ctrl_write_blocked, {
"Write Blocked", "smc.rmbe.ctrl.write.blocked",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}},
{ &hf_smcr_rmbe_ctrl_urgent_pending, {
"Urgent Data Pending", "smc.rmbe.ctrl.urgent.pending",
FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL}},
{ &hf_smcr_rmbe_ctrl_urgent_present, {
"Urgent Data Present", "smc.rmbe.ctrl.urgent.present",
FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL}},
{ &hf_smcr_rmbe_ctrl_cons_update_requested, {
"Consumer Cursor Update Requested",
"smc.rmbe.ctrl.cons.update.requested",
FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL}},
{ &hf_smcr_rmbe_ctrl_failover_validation, {
"Failover Validation Indicator",
"smc.rmbe.ctrl.failover.validation",
FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL}},
{ &hf_smcr_rmbe_ctrl_peer_conn_state_flags, {
"Peer Connection State Flags",
"smc.rmbe.ctrl.peer.conn.state.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_rmbe_ctrl_peer_sending_done, {
"Peer Sending Done", "smc.rmbe.ctrl.peer.sending.done",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}},
{ &hf_smcr_rmbe_ctrl_peer_closed_conn, {
"Peer Closed Connection", "smc.rmbe.ctrl.peer.closed.conn",
FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL}},
{ &hf_smcr_rmbe_ctrl_peer_abnormal_close, {
"Peer Abnormal Close", "smc.rmbe.ctrl.peer.abnormal.close",
FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL}},
{ &hf_smc_accept_eid, {
"Negotiated EID", "smc.accept.eid",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL} },
{ &hf_smc_confirm_eid, {
"Negotiated EID", "smc.confirm.eid",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL} },
{ &hf_smc_accept_peer_name, {
"Peer Host Name", "smc.accept.peer.host.name",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL} },
{ &hf_smc_confirm_peer_name, {
"Peer Host Name", "smc.confirm.peer.host.name",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL} },
{ &hf_smc_confirm_gid_lst_len, {
"GID List Entry Count", "smc.confirm.gid.list.entry_count",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} },
{ &hf_smc_confirm_gid_list_entry, {
"RoCEv2 GID List Entry", "smc.confirm.gid.list.entry",
FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL} },
{ &hf_smcd_accept_first_contact, {
"First Contact", "smc.accept.first.contact",
FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL} },
{ &hf_smc_confirm_first_contact, {
"First Contact", "smc.confirm.first.contact",
FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL} },
{ &hf_accept_smc_version_release_number, {
"SMC Version Release Number", "smc.accept.smc.version.relnum",
FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL } },
{ &hf_confirm_smc_version_release_number, {
"SMC Version Release Number", "smc.confirm.smc.version.relnum",
FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL } },
{ &hf_accept_os_type, {
"OS Type", "smc.accept.os.type",
FT_UINT8, BASE_DEC, VALS(smc_clc_os_message_txt), 0xF0, NULL, HFILL} },
{ &hf_accept_v2_lg_type, {
"V2 LG Type", "smc.accept.v2_lg.type",
FT_UINT8, BASE_DEC, VALS(smc_clc_v2_lg_message_txt), 0x80, NULL, HFILL} },
{ &hf_confirm_os_type, {
"OS Type", "smc.confirm.os.type",
FT_UINT8, BASE_DEC, VALS(smc_clc_os_message_txt), 0xF0, NULL, HFILL} },
{ &hf_smcd_accept_dmb_token, {
"DMB Token", "smc.accept.dmb.token",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_smcd_confirm_dmb_token, {
"DMB Token", "smc.confirm.dmb.token",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_accept_dmb_buffer_size, {
"Server DMBE Buffers Size (Compressed Notation)",
"smc.accept.dmbe.buffer.size",
FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL} },
{ &hf_smcd_confirm_dmb_buffer_size, {
"Client DMBE Buffers Size (Compressed Notation)",
"smc.confirm.dmbe.buffer.size",
FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL} },
{ &hf_smcd_accept_smc_chid, {
"ISMv2 CHID", "smc.accept.smc.chid",
FT_UINT16, BASE_HEX, NULL, 0x00, NULL, HFILL} },
{ &hf_smcd_confirm_smc_chid, {
"ISMv2 CHID", "smc.confirm.smc.chid",
FT_UINT16, BASE_HEX, NULL, 0x00, NULL, HFILL} },
{ &hf_smcd_accept_server_peer_id, {
"Sender (Server) ISM GID", "smc.accept.sender.server.ism.gid",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_smcd_confirm_client_peer_id, {
"Sender (Client) ISM GID", "smc.confirm.sender.client.ism.gid",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_smcd_accept_dmbe_conn_index, {
"DMBE Connection Index",
"smc.accept.dmbe.conn.index",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} },
{ &hf_smcd_accept_server_link_id, {
"Server Link ID",
"smc.accept.server.linkid",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_smcd_confirm_dmbe_conn_index, {
"DMBE Connection Index",
"smc.confirm.dmbe.conn.index",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL} },
{ &hf_smcd_confirm_client_link_id, {
"Client Link ID",
"smc.confirm.client.linkid",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_smcd_accept_flags, {
"Flags", "smc.accept.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_smcd_confirm_flags, {
"Flags", "smc.confirm.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_smcd_accept_flags2, {
"DMBE Size", "smc.accept.dmbe.size",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_smcd_confirm_flags2, {
"DMBE Size", "smc.confirm.dmbe.size",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_smc_accept_fce_flags, {
"Flags", "smc.accept.fce.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_smcr_accept_fce_flags, {
"Flags", "smc.accept.fce1.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL} },
{ &hf_smc_reserved, {
"Reserved", "smc.reserved",
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL} }
};
/* Setup protocol subtree arrays */
static gint* ett[] = {
&ett_smcr,
&ett_proposal_flag,
&ett_proposal_ext_flag2,
&ett_accept_flag,
&ett_accept_flag2,
&ett_smcr_accept_fce_flag1,
&ett_smcd_accept_flag,
&ett_smcd_accept_flag2,
&ett_smc_accept_fce_flag,
&ett_smcd_confirm_flag,
&ett_smc_confirm_fce_flag,
&ett_smcd_confirm_flag2,
&ett_confirm_flag,
&ett_confirm_flag2,
&ett_confirm_link_flag,
&ett_decline_flag,
&ett_decline_flag2,
&ett_add_link_flag,
&ett_add_link_flag2,
&ett_add_link_flag3,
&ett_add_link_cont_flag,
&ett_request_add_link_flag,
&ett_delete_link_flag,
&ett_confirm_rkey_flag,
&ett_delete_rkey_flag,
&ett_test_link_flag,
&ett_rmbe_ctrl_rw_status_flag,
&ett_rmbe_ctrl_peer_conn_state_flag
};
proto_smc = proto_register_protocol("Shared Memory Communications",
"SMC", "smc");
proto_register_field_array(proto_smc, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
smc_tcp_handle = register_dissector("smc", dissect_smc_tcp, proto_smc);
}
void
proto_reg_handoff_smcr(void)
{
heur_dissector_add("tcp", dissect_smc_tcp_heur, "Shared Memory Communications over TCP", "smc_tcp", proto_smc, HEURISTIC_ENABLE);
heur_dissector_add("infiniband.payload", dissect_smcr_infiniband_heur, "Shared Memory Communications Infiniband", "smcr_infiniband", proto_smc, HEURISTIC_ENABLE);
dissector_add_for_decode_as("infiniband", create_dissector_handle( dissect_smcr_infiniband, proto_smc ) );
}
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-sml.c
|
/* packet-sml.c
* Routines for SML dissection
* Copyright 2013, Alexander Gaertner <[email protected]>
*
* Enhancements for SML 1.05 dissection
* Copyright 2022, Uwe Heuert <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
SML dissector is based on v1.03 (12.11.2008) specifications of "smart message language" protocol
Link to specifications: http://www.vde.com/de/fnn/arbeitsgebiete/messwesen/Sym2/infomaterial/seiten/sml-spezifikation.aspx
Short description of the SML protocol on the SML Wireshark Wiki page:
https://gitlab.com/wireshark/wireshark/-/wikis/SML
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/crc16-tvb.h>
#include <epan/expert.h>
#include <wsutil/str_util.h>
#define ESC_SEQ_END G_GUINT64_CONSTANT(0x1b1b1b1b1a)
#define ESC_SEQ 0x1b1b1b1b
#define OPEN_REQ 0x0100
#define OPEN_RES 0x0101
#define CLOSE_REQ 0x0200
#define CLOSE_RES 0x0201
#define PROFILEPACK_REQ 0x0300
#define PROFILEPACK_RES 0x0301
#define PROFILELIST_REQ 0x0400
#define PROFILELIST_RES 0x0401
#define GETPROCPARAMETER_REQ 0x0500
#define GETPROCPARAMETER_RES 0x0501
#define SETPROCPARAMETER_REQ 0x0600
#define GETLIST_REQ 0x0700
#define GETLIST_RES 0x0701
#define ATTENTION 0xFF01
#define PROC_VALUE 0x01
#define PROC_PERIOD 0x02
#define PROC_TUPLE 0x03
#define PROC_TIME 0x04
#define PROC_LISTENTRY 0x05
#define TIME_SECINDEX 0x01
#define TIME_TIMESTAMP 0x02
#define TIME_LOCALTIMESTAMP 0x03
#define LISTTYPE_TIME 0x01
#define LISTTYPE_TIMESTAMPEDVALUE 0x02
#define LISTTYPE_COSEMVALUE 0x03
#define COSEMVALUE_SCALER_UNIT 0x01
#define SHORT_LIST 0x70
#define LONG_LIST 0xF0
#define OPTIONAL 0x01
#define UNSIGNED8 0x62
#define UNSIGNED16 0x63
#define LIST_6_ELEMENTS 0x76
#define MSB 0x80
/* Forward declaration we need below (if using proto_reg_handoff as a prefs callback)*/
void proto_register_sml(void);
void proto_reg_handoff_sml(void);
/* Initialize the protocol and registered fields */
static int proto_sml = -1;
static int hf_sml_esc = -1;
static int hf_sml_version_1 = -1;
static int hf_sml_groupNo = -1;
static int hf_sml_transactionId = -1;
static int hf_sml_length = -1;
static int hf_sml_datatype = -1;
static int hf_sml_abortOnError = -1;
static int hf_sml_MessageBody = -1;
static int hf_sml_crc16 = -1;
static int hf_sml_crc16_status = -1;
static int hf_sml_endOfSmlMsg = -1;
static int hf_sml_end = -1;
static int hf_sml_codepage = -1;
static int hf_sml_clientId = -1;
static int hf_sml_reqFileId = -1;
static int hf_sml_serverId = -1;
static int hf_sml_username = -1;
static int hf_sml_password = -1;
static int hf_sml_smlVersion = -1;
static int hf_sml_listName = -1;
static int hf_sml_globalSignature = -1;
static int hf_sml_timetype = -1;
static int hf_sml_objName = -1;
static int hf_sml_status = -1;
static int hf_sml_unit = -1;
static int hf_sml_scaler = -1;
static int hf_sml_value = -1;
static int hf_sml_simplevalue = -1;
static int hf_sml_valueSignature = -1;
static int hf_sml_listSignature = -1;
static int hf_sml_parameterTreePath = -1;
static int hf_sml_attribute = -1;
static int hf_sml_parameterName = -1;
static int hf_sml_procParValue = -1;
static int hf_sml_padding = -1;
static int hf_sml_secIndex = -1;
static int hf_sml_timestamp = -1;
static int hf_sml_localOffset = -1;
static int hf_sml_seasonTimeOffset = -1;
static int hf_sml_attentionNo = -1;
static int hf_sml_attentionMsg = -1;
static int hf_sml_withRawdata = -1;
static int hf_sml_object_list_Entry = -1;
static int hf_sml_regPeriod = -1;
static int hf_sml_rawdata = -1;
static int hf_sml_periodSignature = -1;
static int hf_sml_profileSignature = -1;
static int hf_sml_signature_mA_R2_R3 = -1;
static int hf_sml_signature_pA_R1_R4 = -1;
static int hf_sml_unit_mA = -1;
static int hf_sml_scaler_mA = -1;
static int hf_sml_value_mA = -1;
static int hf_sml_unit_pA = -1;
static int hf_sml_scaler_pA = -1;
static int hf_sml_value_pA = -1;
static int hf_sml_unit_R1 = -1;
static int hf_sml_scaler_R1 = -1;
static int hf_sml_value_R1 = -1;
static int hf_sml_unit_R2 = -1;
static int hf_sml_scaler_R2 = -1;
static int hf_sml_value_R2 = -1;
static int hf_sml_unit_R3 = -1;
static int hf_sml_scaler_R3 = -1;
static int hf_sml_value_R3 = -1;
static int hf_sml_unit_R4 = -1;
static int hf_sml_scaler_R4 = -1;
static int hf_sml_value_R4 = -1;
static int hf_sml_file_marker = -1;
static int hf_sml_new_file_marker = -1;
static int hf_sml_listtype = -1;
static int hf_sml_cosemvalue = -1;
static const value_string datatype []={
{0x52, "Integer 8"},
{0x53, "Integer 16"},
{0x54, "Integer cropped"},
{0x55, "Integer 32"},
{0x56, "Integer cropped"},
{0x57, "Integer cropped"},
{0x58, "Integer cropped"},
{0x59, "Integer 64"},
{0x62, "Unsigned 8"},
{0x63, "Unsigned 16"},
{0x64, "Unsigned cropped"},
{0x65, "Unsigned 32"},
{0x66, "Unsigned cropped"},
{0x67, "Unsigned cropped"},
{0x68, "Unsigned cropped"},
{0x69, "Unsigned 64"},
{0x42, "Boolean"},
{0x72, "ListType" },
{0, NULL}
};
static const value_string sml_abort[]={
{0x00, "Continue"},
{0x01, "Continue at next group"},
{0x02, "Continue than abort"},
{0xFF, "Abort"},
{0, NULL}
};
static const value_string sml_body[]={
{OPEN_REQ, "PublicOpen.Req"},
{OPEN_RES, "PublicOpen.Res"},
{CLOSE_REQ, "PublicClose.Req"},
{CLOSE_RES, "PublicClose.Res"},
{PROFILEPACK_REQ, "GetProfilePack.Req"},
{PROFILEPACK_RES, "GetProfilePack.Res"},
{PROFILELIST_REQ, "GetProfileList.Req"},
{PROFILELIST_RES, "GetProfileList.Res"},
{GETPROCPARAMETER_REQ, "GetProcParameter.Req"},
{GETPROCPARAMETER_RES, "GetProcParameter.Res"},
{SETPROCPARAMETER_REQ, "SetProcParameter.Req"},
{GETLIST_REQ, "GetList.Req"},
{GETLIST_RES, "GetList.Res"},
{ATTENTION, "Attention.Res"},
{0, NULL}
};
static const value_string sml_timetypes[]={
{0x01, "secIndex"},
{0x02, "timestamp"},
{0x03, "localTimestamp" },
{0, NULL}
};
static const value_string procvalues[]={
{PROC_VALUE, "Value"},
{PROC_PERIOD, "PeriodEntry"},
{PROC_TUPLE, "TupleEntry"},
{PROC_TIME, "Time"},
{PROC_LISTENTRY, "ListEntry"},
{0, NULL}
};
static const value_string listtypevalues[] = {
{ LISTTYPE_TIME, "smlTime" },
{ LISTTYPE_TIMESTAMPEDVALUE, "smlTimestampedValue" },
{ LISTTYPE_COSEMVALUE, "smlCosemValue" },
{ 0, NULL }
};
static const value_string cosemvaluevalues[] = {
{ COSEMVALUE_SCALER_UNIT, "scaler_unit" },
{ 0, NULL }
};
static const range_string attentionValues[]={
{0xE000, 0xFCFF, "application specific"},
{0xFD00, 0xFD00, "acknowledged"},
{0xFD01, 0xFD01, "order will be executed later"},
{0xFE00, 0xFE00, "error undefined"},
{0xFE01, 0xFE01, "unknown SML designator"},
{0xFE02, 0xFE02, "User/Password wrong"},
{0xFE03, 0xFE03, "serverId not available"},
{0xFE04, 0xFE04, "reqFileId not available"},
{0xFE05, 0xFE05, "destination attributes cannot be written"},
{0xFE06, 0xFE06, "destination attributes cannot be read"},
{0xFE07, 0xFE07, "communication disturbed"},
{0xFE08, 0xFE08, "rawdata cannot be interpreted"},
{0xFE09, 0xFE09, "value out of range"},
{0xFE0A, 0xFE0A, "order not executed"},
{0xFE0B, 0xFE0B, "checksum failed"},
{0xFE0C, 0xFE0C, "broadcast not supported"},
{0xFE0D, 0xFE0D, "unexpected message"},
{0xFE0E, 0xFE0E, "unknown object in the profile"},
{0xFE0F, 0xFE0F, "datatype not supported"},
{0xFE10, 0xFE10, "optional element not supported"},
{0xFE11, 0xFE11, "no entry in requested profile"},
{0xFE12, 0xFE12, "end limit before begin limit"},
{0xFE13, 0xFE13, "no entry in requested area"},
{0xFE14, 0xFE14, "SML file without close"},
{0xFE15, 0xFE15, "busy, response cannot be sent"},
{0,0, NULL}
};
static const range_string bools[]={
{0x00, 0x00, "false"},
{0x01, 0xFF, "true"},
{0,0, NULL}
};
/* Initialize the subtree pointers */
static gint ett_sml = -1;
static gint ett_sml_mainlist = -1;
static gint ett_sml_version = -1;
static gint ett_sml_sublist = -1;
static gint ett_sml_trans = -1;
static gint ett_sml_group = -1;
static gint ett_sml_abort = -1;
static gint ett_sml_body = -1;
static gint ett_sml_mblist = -1;
static gint ett_sml_mttree = -1;
static gint ett_sml_crc16 = -1;
static gint ett_sml_clientId = -1;
static gint ett_sml_codepage = -1;
static gint ett_sml_reqFileId= -1;
static gint ett_sml_serverId = -1;
static gint ett_sml_username = -1;
static gint ett_sml_password = -1;
static gint ett_sml_smlVersion = -1;
static gint ett_sml_listName = -1;
static gint ett_sml_globalSignature = -1;
static gint ett_sml_refTime = -1;
static gint ett_sml_actSensorTime = -1;
static gint ett_sml_timetype = -1;
static gint ett_sml_time = -1;
static gint ett_sml_valList = -1;
static gint ett_sml_listEntry = -1;
static gint ett_sml_objName = -1;
static gint ett_sml_status = -1;
static gint ett_sml_valTime = -1;
static gint ett_sml_unit = -1;
static gint ett_sml_scaler = -1;
static gint ett_sml_value = -1;
static gint ett_sml_simplevalue = -1;
static gint ett_sml_valueSignature = -1;
static gint ett_sml_listSignature = -1;
static gint ett_sml_valtree = -1;
static gint ett_sml_actGatewayTime = -1;
static gint ett_sml_treepath = -1;
static gint ett_sml_parameterTreePath = -1;
static gint ett_sml_attribute = -1;
static gint ett_sml_parameterTree = -1;
static gint ett_sml_parameterName = -1;
static gint ett_sml_child = -1;
static gint ett_sml_periodEntry = -1;
static gint ett_sml_procParValue = -1;
static gint ett_sml_procParValueTime = -1;
static gint ett_sml_procParValuetype = -1;
static gint ett_sml_msgend = -1;
static gint ett_sml_tuple = -1;
static gint ett_sml_secIndex = -1;
static gint ett_sml_timestamp = -1;
static gint ett_sml_localTimestamp = -1;
static gint ett_sml_localOffset = -1;
static gint ett_sml_seasonTimeOffset = -1;
static gint ett_sml_signature = -1;
static gint ett_sml_attentionNo = -1;
static gint ett_sml_attentionMsg = -1;
static gint ett_sml_withRawdata = -1;
static gint ett_sml_beginTime = -1;
static gint ett_sml_endTime = -1;
static gint ett_sml_object_list = -1;
static gint ett_sml_object_list_Entry = -1;
static gint ett_sml_actTime = -1;
static gint ett_sml_regPeriod = -1;
static gint ett_sml_rawdata = -1;
static gint ett_sml_periodSignature = -1;
static gint ett_sml_period_List_Entry = -1;
static gint ett_sml_periodList = -1;
static gint ett_sml_headerList = -1;
static gint ett_sml_header_List_Entry = -1;
static gint ett_sml_profileSignature = -1;
static gint ett_sml_valuelist = -1;
static gint ett_sml_value_List_Entry = -1;
static gint ett_sml_signature_mA_R2_R3 = -1;
static gint ett_sml_signature_pA_R1_R4 = -1;
static gint ett_sml_unit_mA = -1;
static gint ett_sml_scaler_mA = -1;
static gint ett_sml_value_mA = -1;
static gint ett_sml_unit_pA = -1;
static gint ett_sml_scaler_pA = -1;
static gint ett_sml_value_pA = -1;
static gint ett_sml_unit_R1 = -1;
static gint ett_sml_scaler_R1 = -1;
static gint ett_sml_value_R1 = -1;
static gint ett_sml_unit_R2 = -1;
static gint ett_sml_scaler_R2 = -1;
static gint ett_sml_value_R2 = -1;
static gint ett_sml_unit_R3 = -1;
static gint ett_sml_scaler_R3 = -1;
static gint ett_sml_value_R3 = -1;
static gint ett_sml_unit_R4 = -1;
static gint ett_sml_scaler_R4 = -1;
static gint ett_sml_value_R4 = -1;
static gint ett_sml_tree_Entry = -1;
static gint ett_sml_dasDetails = -1;
static gint ett_sml_attentionDetails = -1;
static gint ett_sml_listtypetype = -1;
static gint ett_sml_listtype = -1;
static gint ett_sml_timestampedvaluetype = -1;
static gint ett_sml_timestampedvalue = -1;
static gint ett_sml_cosemvaluetype = -1;
static gint ett_sml_cosemvalue = -1;
static gint ett_sml_scaler_unit = -1;
static expert_field ei_sml_messagetype_unknown = EI_INIT;
static expert_field ei_sml_procParValue_errror = EI_INIT;
static expert_field ei_sml_procParValue_invalid = EI_INIT;
static expert_field ei_sml_segment_needed = EI_INIT;
static expert_field ei_sml_endOfSmlMsg = EI_INIT;
static expert_field ei_sml_crc_error = EI_INIT;
static expert_field ei_sml_tuple_error = EI_INIT;
static expert_field ei_sml_crc_error_length = EI_INIT;
static expert_field ei_sml_invalid_count = EI_INIT;
static expert_field ei_sml_MessageBody = EI_INIT;
static expert_field ei_sml_esc_error = EI_INIT;
static expert_field ei_sml_version2_not_supported = EI_INIT;
static expert_field ei_sml_attentionNo = EI_INIT;
static expert_field ei_sml_listtype_invalid = EI_INIT;
static expert_field ei_sml_cosemvalue_invalid = EI_INIT;
/*options*/
static gboolean sml_reassemble = TRUE;
static gboolean sml_crc_enabled = FALSE;
/*get number of length octets and calculate how many data octets, it's like BER but not the same! */
static void get_length(tvbuff_t *tvb, guint *offset, guint *data, guint *length){
guint check = 0;
guint temp_offset = 0;
temp_offset = *offset;
*data = 0;
*length = 0;
check = tvb_get_guint8(tvb, temp_offset);
if (check == OPTIONAL){
*length = 1;
}
else if ((check & 0x80) == MSB){
while ((check & 0x80) == MSB){
check = check & 0x0F;
*data = *data + check;
*data <<= 4;
*length+=1;
temp_offset+=1;
check = tvb_get_guint8(tvb, temp_offset);
}
check = check & 0x0F;
*data = *data + check;
*length+=1;
*data = *data - *length;
}
else{
check = check & 0x0F;
*length+=1;
*data = check - *length;
}
}
/*often used fields*/
static void field_scaler(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length);
static void field_unit(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length);
static void field_status(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length);
static void sml_time_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *SML_time_tree, guint *offset);
static void sml_simplevalue(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *value = NULL;
proto_tree *value_tree = NULL;
get_length(tvb, offset, data, length);
value = proto_tree_add_bytes_format(insert_tree, hf_sml_simplevalue, tvb, *offset, *length + *data, NULL, "value %s", (*data == 0) ? ": NOT SET" : "");
if (tvb_get_guint8(tvb, *offset) != OPTIONAL){
value_tree = proto_item_add_subtree(value, ett_sml_simplevalue);
if ((tvb_get_guint8(tvb, *offset) & 0x80) == MSB || (tvb_get_guint8(tvb, *offset) & 0xF0) == 0){
proto_tree_add_uint(value_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset += *length;
}
else {
proto_tree_add_item(value_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset += 1;
}
proto_tree_add_item(value_tree, hf_sml_simplevalue, tvb, *offset, *data, ENC_NA);
*offset += *data;
}
else
*offset += 1;
}
static void sml_timestampedvalue_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *timestampedvalue_tree, guint *offset){
proto_tree *SML_timestampedvalue_type_tree;
proto_tree *SML_time_tree;
proto_item *SML_time;
guint data = 0;
guint length = 0;
SML_timestampedvalue_type_tree = proto_tree_add_subtree(timestampedvalue_tree, tvb, *offset, -1, ett_sml_timestampedvaluetype, NULL, "SML_TimestampedValue Type");
/*smlTime*/
SML_time_tree = proto_tree_add_subtree(SML_timestampedvalue_type_tree, tvb, *offset, -1, ett_sml_time, &SML_time, "smlTime");
*offset += 1;
sml_time_type(tvb, pinfo, SML_time_tree, offset);
proto_item_set_end(SML_time, tvb, *offset);
/*status*/
field_status(tvb, SML_timestampedvalue_type_tree, offset, &data, &length);
/*simpleValue*/
sml_simplevalue(tvb, SML_timestampedvalue_type_tree, offset, &data, &length);
}
static void sml_cosem_scaler_unit_type(tvbuff_t *tvb, proto_tree *cosem_scaler_unit_tree, guint *offset){
guint data, length;
/*scaler*/
get_length(tvb, offset, &data, &length);
field_scaler(tvb, cosem_scaler_unit_tree, offset, &data, &length);
/*unit*/
get_length(tvb, offset, &data, &length);
field_unit(tvb, cosem_scaler_unit_tree, offset, &data, &length);
}
static void sml_cosemvalue_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *cosemvalue_tree, guint *offset){
guint check = 0;
proto_item *SML_cosem_scaler_unit;
proto_tree *SML_cosemvalue_type_tree;
proto_tree *SML_cosem_scaler_unit_tree;
SML_cosemvalue_type_tree = proto_tree_add_subtree(cosemvalue_tree, tvb, *offset, -1, ett_sml_cosemvaluetype, NULL, "SML_CosemValue Type");
proto_tree_add_item(SML_cosemvalue_type_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset += 1;
proto_tree_add_item(SML_cosemvalue_type_tree, hf_sml_cosemvalue, tvb, *offset, 1, ENC_BIG_ENDIAN);
check = tvb_get_guint8(tvb, *offset);
*offset += 1;
switch (check) {
case COSEMVALUE_SCALER_UNIT:
/*scaler_unit*/
SML_cosem_scaler_unit_tree = proto_tree_add_subtree(SML_cosemvalue_type_tree, tvb, *offset, -1, ett_sml_scaler_unit, &SML_cosem_scaler_unit, "CosemScalerUnit");
*offset += 1;
sml_cosem_scaler_unit_type(tvb, SML_cosem_scaler_unit_tree, offset);
break;
default:
expert_add_info(pinfo, SML_cosemvalue_type_tree, &ei_sml_cosemvalue_invalid);
break;
}
}
static void sml_listtype_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *listtype_tree, guint *offset){
guint check = 0;
proto_tree *SML_listtype_type_tree;
proto_item *SML_time;
proto_tree *SML_time_tree = NULL;
proto_item *SML_timestampedvalue;
proto_tree *SML_timestampedvalue_tree = NULL;
proto_item *SML_cosemvalue;
proto_tree *SML_cosemvalue_tree = NULL;
SML_listtype_type_tree = proto_tree_add_subtree(listtype_tree, tvb, *offset, -1, ett_sml_listtypetype, NULL, "SML_ListType Type");
proto_tree_add_item(SML_listtype_type_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset += 1;
proto_tree_add_item(SML_listtype_type_tree, hf_sml_listtype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset += 1;
check = tvb_get_guint8(tvb, *offset);
*offset += 1;
switch (check) {
case LISTTYPE_TIME:
/*smlTime*/
SML_time_tree = proto_tree_add_subtree(SML_listtype_type_tree, tvb, *offset, -1, ett_sml_time, &SML_time, "Time");
*offset += 1;
sml_time_type(tvb, pinfo, SML_time_tree, offset);
proto_item_set_end(SML_time, tvb, *offset);
break;
case LISTTYPE_TIMESTAMPEDVALUE:
/*smlTimestampedValue*/
SML_timestampedvalue_tree = proto_tree_add_subtree(SML_listtype_type_tree, tvb, *offset, -1, ett_sml_timestampedvalue, &SML_timestampedvalue, "TimestampedValue");
*offset += 1;
sml_timestampedvalue_type(tvb, pinfo, SML_timestampedvalue_tree, offset);
proto_item_set_end(SML_timestampedvalue, tvb, *offset);
break;
case LISTTYPE_COSEMVALUE:
/*smlCosemValue*/
SML_cosemvalue_tree = proto_tree_add_subtree(SML_listtype_type_tree, tvb, *offset, -1, ett_sml_cosemvalue, &SML_cosemvalue, "CosemValue");
*offset += 1;
sml_cosemvalue_type(tvb, pinfo, SML_cosemvalue_tree, offset);
break;
default:
expert_add_info(pinfo, SML_listtype_type_tree, &ei_sml_listtype_invalid);
break;
}
}
static void sml_value(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *value = NULL;
proto_tree *value_tree = NULL;
get_length(tvb, offset, data, length);
value = proto_tree_add_bytes_format (insert_tree, hf_sml_value, tvb, *offset, *length + *data, NULL,"value %s", (*data == 0)? ": NOT SET" : "");
if (tvb_get_guint8(tvb, *offset) != OPTIONAL){
value_tree = proto_item_add_subtree (value, ett_sml_value);
if (tvb_get_guint8(tvb, *offset) == 0x72) {
sml_listtype_type(tvb, pinfo, value_tree, offset);
}
else
{
if ((tvb_get_guint8(tvb, *offset) & 0x80) == MSB || (tvb_get_guint8(tvb, *offset) & 0xF0) == 0){
proto_tree_add_uint(value_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset+= *length;
}
else {
proto_tree_add_item (value_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
}
proto_tree_add_item (value_tree, hf_sml_value, tvb, *offset, *data, ENC_NA);
*offset+= *data;
}
}
else
*offset+=1;
}
static void sml_time_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *SML_time_tree, guint *offset){
guint check = 0;
proto_tree *timetype_tree;
proto_tree *timevalue_tree;
proto_tree *localtimestamptype_tree;
guint data = 0;
guint length = 0;
timetype_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, 2, ett_sml_timetype, NULL, "SML-Time Type");
proto_tree_add_item (timetype_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (timetype_tree, hf_sml_timetype, tvb, *offset, 1, ENC_BIG_ENDIAN);
//*offset+=1;
check = tvb_get_guint8(tvb, *offset);
*offset += 1;
switch (check) {
case TIME_SECINDEX:
/*secIndex*/
get_length(tvb, offset, &data, &length);
timevalue_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length + data, ett_sml_secIndex, NULL, "secIndex");
proto_tree_add_item(timevalue_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset += 1;
proto_tree_add_item(timevalue_tree, hf_sml_secIndex, tvb, *offset, data, ENC_BIG_ENDIAN);
*offset += data;
break;
case TIME_TIMESTAMP:
/*timestamp*/
get_length(tvb, offset, &data, &length);
timevalue_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length + data, ett_sml_timestamp, NULL, "timestamp");
proto_tree_add_item(timevalue_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset += 1;
proto_tree_add_item(timevalue_tree, hf_sml_timestamp, tvb, *offset, data, ENC_BIG_ENDIAN);
*offset += data;
break;
case TIME_LOCALTIMESTAMP:
/*localTimestamp*/
localtimestamptype_tree = proto_tree_add_subtree(SML_time_tree, tvb, *offset, length + data, ett_sml_localTimestamp, NULL, "localTimestamp");
*offset += 1;
get_length(tvb, offset, &data, &length);
timevalue_tree = proto_tree_add_subtree(localtimestamptype_tree, tvb, *offset, length + data, ett_sml_timestamp, NULL, "timestamp");
proto_tree_add_item(timevalue_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset += 1;
proto_tree_add_item(timevalue_tree, hf_sml_timestamp, tvb, *offset, data, ENC_BIG_ENDIAN);
*offset += data;
get_length(tvb, offset, &data, &length);
timevalue_tree = proto_tree_add_subtree(localtimestamptype_tree, tvb, *offset, length + data, ett_sml_localOffset, NULL, "localOffset");
proto_tree_add_item(timevalue_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset += 1;
proto_tree_add_item(timevalue_tree, hf_sml_localOffset, tvb, *offset, data, ENC_BIG_ENDIAN);
*offset += data;
get_length(tvb, offset, &data, &length);
timevalue_tree = proto_tree_add_subtree(localtimestamptype_tree, tvb, *offset, length + data, ett_sml_seasonTimeOffset, NULL, "seasonTimeOffset");
proto_tree_add_item(timevalue_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset += 1;
proto_tree_add_item(timevalue_tree, hf_sml_seasonTimeOffset, tvb, *offset, data, ENC_BIG_ENDIAN);
*offset += data;
break;
default:
expert_add_info(pinfo, timetype_tree, &ei_sml_listtype_invalid);
break;
}
}
static void field_codepage(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *codepage = NULL;
proto_tree *codepage_tree = NULL;
get_length(tvb, offset, data, length);
codepage = proto_tree_add_bytes_format (insert_tree, hf_sml_codepage, tvb, *offset, *length + *data, NULL,"Codepage %s", (*data == 0)? ": NOT SET" : "");
if (*data > 0) {
codepage_tree = proto_item_add_subtree (codepage , ett_sml_codepage);
proto_tree_add_uint(codepage_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset+= *length;
proto_tree_add_item (codepage_tree, hf_sml_codepage, tvb, *offset, *data, ENC_NA);
*offset+= *data;
}
else
*offset+=1;
}
static void field_clientId(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *clientId = NULL;
proto_tree *clientId_tree = NULL;
get_length(tvb, offset, data, length);
clientId = proto_tree_add_bytes_format (insert_tree, hf_sml_clientId, tvb, *offset, *length + *data, NULL, "clientID %s", (*data == 0)? ": NOT SET" : "");
if (*data > 0) {
clientId_tree = proto_item_add_subtree (clientId, ett_sml_clientId);
proto_tree_add_uint(clientId_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset+=*length;
proto_tree_add_item (clientId_tree, hf_sml_clientId, tvb, *offset, *data, ENC_NA);
*offset+=*data;
}
else
*offset+=1;
}
static void field_reqFileId(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_tree *reqFileId_tree;
get_length(tvb, offset, data, length);
reqFileId_tree = proto_tree_add_subtree(insert_tree, tvb, *offset, *length + *data, ett_sml_reqFileId, NULL, "reqFileId");
proto_tree_add_uint (reqFileId_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset+=*length;
proto_tree_add_item (reqFileId_tree, hf_sml_reqFileId, tvb, *offset, *data, ENC_NA);
*offset+=*data;
}
static void field_serverId(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *serverId = NULL;
proto_tree *serverId_tree = NULL;
/*Server ID OPTIONAL*/
get_length(tvb, offset, data, length);
serverId = proto_tree_add_bytes_format (insert_tree,hf_sml_serverId, tvb, *offset, *length + *data, NULL, "Server ID %s", (*data == 0)? ": NOT SET" : "");
if (*data > 0){
serverId_tree = proto_item_add_subtree (serverId , ett_sml_serverId);
proto_tree_add_uint (serverId_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset+=*length;
proto_tree_add_item (serverId_tree, hf_sml_serverId, tvb, *offset, *data, ENC_NA);
*offset+=*data;
}
else
*offset+=1;
}
static void field_username(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *username = NULL;
proto_tree *username_tree = NULL;
/*Username OPTIONAL*/
get_length(tvb, offset, data, length);
username = proto_tree_add_string_format (insert_tree,hf_sml_username, tvb, *offset, *length + *data, NULL, "Username %s", (*data == 0)? ": NOT SET" : "");
if (*data > 0){
username_tree = proto_item_add_subtree (username , ett_sml_username);
proto_tree_add_uint (username_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset+=*length;
proto_tree_add_item (username_tree, hf_sml_username, tvb, *offset, *data, ENC_ASCII | ENC_BIG_ENDIAN);
*offset+=*data;
}
else
*offset+=1;
}
static void field_password(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *password = NULL;
proto_tree *password_tree = NULL;
/*Password OPTIONAL*/
get_length(tvb, offset, data, length);
password = proto_tree_add_string_format (insert_tree,hf_sml_password, tvb, *offset, *length + *data, NULL, "Password %s", (*data == 0)? ": NOT SET" : "");
if (*data > 0) {
password_tree = proto_item_add_subtree (password, ett_sml_password);
proto_tree_add_uint (password_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset+=*length;
proto_tree_add_item (password_tree, hf_sml_password, tvb, *offset, *data, ENC_ASCII | ENC_BIG_ENDIAN);
*offset+=*data;
}
else
*offset+=1;
}
static void field_smlVersion(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *smlVersion = NULL;
proto_tree *smlVersion_tree = NULL;
/*sml-Version OPTIONAL*/
get_length(tvb, offset, data, length);
smlVersion = proto_tree_add_uint_format (insert_tree, hf_sml_smlVersion, tvb, *offset, *length + *data, *length + *data, "SML-Version %s", (*data == 0)? ": Version 1" : "");
if (*data > 0) {
smlVersion_tree = proto_item_add_subtree (smlVersion, ett_sml_smlVersion);
proto_tree_add_item (smlVersion_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (smlVersion_tree, hf_sml_smlVersion, tvb, *offset, 1,ENC_BIG_ENDIAN);
*offset+=1;
}
else
*offset+=1;
}
static void field_globalSignature(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *globalSignature = NULL;
proto_tree *globalSignature_tree = NULL;
/*Global Signature OPTIONAL*/
get_length(tvb, offset, data, length);
globalSignature = proto_tree_add_bytes_format (insert_tree, hf_sml_globalSignature, tvb, *offset, *length + *data, NULL, "global Signature %s", (*data == 0)? ": NOT SET" : "");
if (*data > 0){
globalSignature_tree = proto_item_add_subtree (globalSignature, ett_sml_globalSignature);
proto_tree_add_uint (globalSignature_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset+=*length;
proto_tree_add_item (globalSignature_tree, hf_sml_globalSignature, tvb, *offset, *data, ENC_NA);
*offset+=*data;
}
else
*offset+=1;
}
static void field_listName(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *listName = NULL;
proto_tree *listName_tree = NULL;
/*List Name OPTIONAL*/
get_length(tvb, offset, data, length);
listName = proto_tree_add_bytes_format (insert_tree,hf_sml_listName, tvb, *offset, *length + *data, NULL, "List Name %s", (*data == 0)? ": NOT SET" : "");
if (*data > 0) {
listName_tree = proto_item_add_subtree (listName, ett_sml_listName);
proto_tree_add_uint (listName_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset+=*length;
proto_tree_add_item (listName_tree, hf_sml_listName, tvb, *offset, *data, ENC_NA);
*offset+=*data;
}
else
*offset+=1;
}
static void field_objName(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_tree *objName_tree;
/*Objectname*/
get_length(tvb, offset, data, length);
objName_tree = proto_tree_add_subtree(insert_tree, tvb, *offset, *length + *data, ett_sml_objName, NULL, "Objectname");
proto_tree_add_uint (objName_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset+=*length;
proto_tree_add_item (objName_tree, hf_sml_objName, tvb, *offset, *data, ENC_NA);
*offset+=*data;
}
static void field_status(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_tree *status_tree = NULL;
get_length(tvb, offset, data, length);
status_tree = proto_tree_add_subtree_format(insert_tree, tvb, *offset, *length + *data,
ett_sml_status, NULL, "status %s", (*data == 0)? ": NOT SET" : "");
if (*data > 0){
proto_tree_add_item (status_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (status_tree, hf_sml_status, tvb, *offset, *data, ENC_BIG_ENDIAN);
*offset+= *data;
}
else
*offset+=1;
}
static void field_unit(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *unit = NULL;
proto_tree *unit_tree = NULL;
/*unit OPTIONAL*/
get_length(tvb, offset, data, length);
unit = proto_tree_add_uint_format (insert_tree, hf_sml_unit, tvb, *offset, *length + *data, *length + *data, "Unit %s", (*data == 0)? ": NOT SET" : "");
if (*data > 0) {
unit_tree = proto_item_add_subtree (unit, ett_sml_unit);
proto_tree_add_item (unit_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item(unit_tree, hf_sml_unit, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
}
else
*offset+=1;
}
static void field_scaler(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *scaler = NULL;
proto_tree *scaler_tree = NULL;
/*Scaler OPTIONAL*/
get_length(tvb, offset, data, length);
scaler = proto_tree_add_uint_format (insert_tree, hf_sml_scaler, tvb, *offset, *length + *data, *length + *data, "Scaler %s", (*data == 0)? ": NOT SET" : "");
if (*data > 0){
scaler_tree = proto_item_add_subtree (scaler, ett_sml_scaler);
proto_tree_add_item (scaler_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item(scaler_tree, hf_sml_scaler, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
}
else
*offset+=1;
}
static void field_valueSignature(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *valueSignature = NULL;
proto_tree *valueSignature_tree = NULL;
/*value Signature*/
get_length(tvb, offset, data, length);
valueSignature = proto_tree_add_bytes_format (insert_tree, hf_sml_valueSignature, tvb, *offset, *length + *data, NULL, "ValueSignature %s", (*data == 0)? ": NOT SET" : "");
if (*data > 0){
valueSignature_tree = proto_item_add_subtree (valueSignature, ett_sml_valueSignature);
proto_tree_add_uint (valueSignature_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset+=*length;
proto_tree_add_item (valueSignature_tree, hf_sml_valueSignature, tvb, *offset, *data, ENC_NA);
*offset+=*data;
}
else
*offset+=1;
}
static void field_parameterTreePath(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *parameterTreePath = NULL;
proto_tree *parameterTreePath_tree = NULL;
/*parameterTreePath*/
get_length(tvb, offset, data, length);
parameterTreePath = proto_tree_add_bytes_format (insert_tree, hf_sml_parameterTreePath, tvb, *offset, *length + *data, NULL, "path_Entry %s", (*data == 0)? ": NOT SET" : "");
parameterTreePath_tree = proto_item_add_subtree (parameterTreePath, ett_sml_parameterTreePath);
proto_tree_add_uint (parameterTreePath_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset+=*length;
proto_tree_add_item (parameterTreePath_tree, hf_sml_parameterTreePath, tvb, *offset, *data, ENC_NA);
*offset+=*data;
}
static void field_ObjReqEntry(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_tree *object_list_Entry_tree;
/*parameterTreePath*/
get_length(tvb, offset, data, length);
object_list_Entry_tree = proto_tree_add_subtree(insert_tree, tvb ,*offset, *length + *data, ett_sml_object_list_Entry, NULL, "object_list_Entry");
proto_tree_add_uint (object_list_Entry_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset+=*length;
proto_tree_add_item (object_list_Entry_tree, hf_sml_object_list_Entry, tvb, *offset, *data, ENC_NA);
*offset+=*data;
}
static void field_regPeriod(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_tree *regPeriod_tree;
get_length(tvb, offset, data, length);
regPeriod_tree = proto_tree_add_subtree(insert_tree, tvb, *offset, *length + *data, ett_sml_regPeriod, NULL, "regPeriod");
proto_tree_add_item (regPeriod_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (regPeriod_tree, hf_sml_regPeriod, tvb, *offset, *data, ENC_BIG_ENDIAN);
*offset+=*data;
}
static void field_rawdata(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *rawdata = NULL;
proto_tree *rawdata_tree = NULL;
/*rawdata*/
get_length(tvb, offset, data, length);
rawdata = proto_tree_add_bytes_format (insert_tree, hf_sml_rawdata, tvb, *offset, *length + *data, NULL, "rawdata %s", (*data == 0)? ": NOT SET" : "");
if (*data > 0){
rawdata_tree = proto_item_add_subtree (rawdata, ett_sml_rawdata);
proto_tree_add_uint (rawdata_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset+=*length;
proto_tree_add_item (rawdata_tree, hf_sml_rawdata, tvb, *offset, *data, ENC_NA);
*offset+=*data;
}
else
*offset+=1;
}
static void field_periodSignature(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *periodSignature = NULL;
proto_tree *periodSignature_tree = NULL;
/*periodSignature*/
get_length(tvb, offset, data, length);
periodSignature = proto_tree_add_bytes_format (insert_tree, hf_sml_periodSignature, tvb, *offset, *length + *data, NULL,"periodSignature %s", (*data == 0)? ": NOT SET" : "");
if (*data > 0){
periodSignature_tree = proto_item_add_subtree (periodSignature, ett_sml_periodSignature);
proto_tree_add_uint (periodSignature_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset+=*length;
proto_tree_add_item (periodSignature_tree, hf_sml_periodSignature, tvb, *offset, *data, ENC_NA);
*offset+=*data;
}
else
*offset+=1;
}
/*
static void field_actTime(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_tree *actTime_tree;
get_length(tvb, offset, data, length);
actTime_tree = proto_tree_add_subtree(insert_tree, tvb, *offset, *length + *data, ett_sml_actTime, NULL, "actTime");
proto_tree_add_item (actTime_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item(actTime_tree, hf_sml_actTime, tvb, *offset, *data, ENC_BIG_ENDIAN);
*offset+=*data;
}
static void field_valTime(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_tree *valTime_tree;
get_length(tvb, offset, data, length);
valTime_tree = proto_tree_add_subtree(insert_tree, tvb, *offset, *length + *data, ett_sml_valTime, NULL, "valTime");
proto_tree_add_item (valTime_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item(valTime_tree, hf_sml_valTime, tvb, *offset, *data, ENC_BIG_ENDIAN);
*offset+=*data;
}
*/
static void TupleEntryTree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *procParValue_tree, guint *offset){
proto_item *SML_time;
proto_item *TupleEntry;
proto_tree *TupleEntry_list = NULL;
proto_tree *SML_time_tree = NULL;
//proto_tree *secIndex_tree = NULL;
proto_tree *unit_pA_tree = NULL;
proto_tree *scaler_pA_tree = NULL;
proto_tree *value_pA_tree = NULL;
proto_tree *unit_mA_tree = NULL;
proto_tree *scaler_mA_tree = NULL;
proto_tree *value_mA_tree = NULL;
proto_tree *unit_R1_tree = NULL;
proto_tree *scaler_R1_tree = NULL;
proto_tree *value_R1_tree = NULL;
proto_tree *unit_R2_tree = NULL;
proto_tree *scaler_R2_tree = NULL;
proto_tree *value_R2_tree = NULL;
proto_tree *unit_R3_tree = NULL;
proto_tree *scaler_R3_tree = NULL;
proto_tree *value_R3_tree = NULL;
proto_tree *unit_R4_tree = NULL;
proto_tree *scaler_R4_tree = NULL;
proto_tree *value_R4_tree = NULL;
proto_tree *signature_pA_R1_R4_tree = NULL;
proto_tree *signature_mA_R2_R3_tree = NULL;
guint data = 0;
guint length = 0;
/*Tuple_List*/
TupleEntry_list = proto_tree_add_subtree(procParValue_tree, tvb, *offset, -1, ett_sml_tuple, &TupleEntry, "TupleEntry");
get_length(tvb, offset, &data, &length);
*offset+=length;
/*Server Id*/
field_serverId(tvb, TupleEntry_list, offset, &data, &length);
/*secindex*/
SML_time_tree = proto_tree_add_subtree(procParValue_tree, tvb, *offset, -1, ett_sml_time, &SML_time, "secIndex");
*offset+=1;
sml_time_type(tvb, pinfo, SML_time_tree, offset);
proto_item_set_end(SML_time, tvb, *offset);
/*Sml Status OPTIONAL*/
field_status(tvb, TupleEntry_list, offset, &data, &length);
/*unit_pA*/
unit_pA_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, 2, ett_sml_unit_pA, NULL, "unit_pA");
proto_tree_add_item (unit_pA_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (unit_pA_tree, hf_sml_unit_pA, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
/*scaler_pA*/
scaler_pA_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, 2, ett_sml_scaler_pA, NULL, "scaler_pA");
proto_tree_add_item (scaler_pA_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (scaler_pA_tree, hf_sml_scaler_pA, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
/*value_pA*/
get_length(tvb, offset, &data, &length);
value_pA_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, length+data, ett_sml_value_pA, NULL, "value_pA");
proto_tree_add_item (value_pA_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (value_pA_tree, hf_sml_value_pA, tvb, *offset, data, ENC_BIG_ENDIAN);
*offset+=data;
/*unit_R1*/
unit_R1_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, 2, ett_sml_unit_R1, NULL, "unit_R1");
proto_tree_add_item (unit_R1_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (unit_R1_tree, hf_sml_unit_R1, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
/*scaler_R1*/
scaler_R1_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, 1, ett_sml_scaler_R1, NULL, "scaler_R1");
proto_tree_add_item (scaler_R1_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (scaler_R1_tree, hf_sml_scaler_R1, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
/*value_R1*/
get_length(tvb, offset, &data, &length);
value_R1_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, length+data, ett_sml_value_R1, NULL, "value_R1");
proto_tree_add_item (value_R1_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (value_R1_tree, hf_sml_value_R1, tvb, *offset, data, ENC_BIG_ENDIAN);
*offset+=data;
/*unit_R4*/
unit_R4_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, 2, ett_sml_unit_R4, NULL, "unit_R4");
proto_tree_add_item (unit_R4_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (unit_R4_tree, hf_sml_unit_R4, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
/*scaler_R4*/
scaler_R4_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, 2, ett_sml_scaler_R4, NULL, "scaler_R4");
proto_tree_add_item (scaler_R4_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (scaler_R4_tree, hf_sml_scaler_R4, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
/*value_R4*/
get_length(tvb, offset, &data, &length);
value_R4_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, length+data, ett_sml_value_R4, NULL, "value_R4");
proto_tree_add_item (value_R4_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (value_R4_tree, hf_sml_value_R4, tvb, *offset, data, ENC_BIG_ENDIAN);
*offset+=data;
/*signature_pA_R1_R4*/
get_length(tvb, offset, &data, &length);
signature_pA_R1_R4_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, length+data, ett_sml_signature_pA_R1_R4, NULL, "signature_pa_R1_R4");
proto_tree_add_uint (signature_pA_R1_R4_tree, hf_sml_length, tvb, *offset, length, data);
*offset+=length;
proto_tree_add_item (signature_pA_R1_R4_tree, hf_sml_signature_pA_R1_R4, tvb, *offset, data, ENC_NA);
*offset+=data;
/*unit_mA*/
unit_mA_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, 2, ett_sml_unit_mA, NULL, "unit_mA");
proto_tree_add_item (unit_mA_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (unit_mA_tree, hf_sml_unit_mA, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
/*scaler_mA*/
scaler_mA_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, 2, ett_sml_scaler_mA, NULL, "scaler_mA");
proto_tree_add_item (scaler_mA_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (scaler_mA_tree, hf_sml_scaler_mA, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
/*value_mA*/
get_length(tvb, offset, &data, &length);
value_mA_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, length+data, ett_sml_value_mA, NULL, "value_mA");
proto_tree_add_item (value_mA_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (value_mA_tree, hf_sml_value_mA, tvb, *offset, data, ENC_BIG_ENDIAN);
*offset+=data;
/*unit_R2*/
unit_R2_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, 2, ett_sml_unit_R2, NULL, "unit_R2");
proto_tree_add_item (unit_R2_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (unit_R2_tree, hf_sml_unit_R2, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
/*scaler_R2*/
scaler_R2_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, 2, ett_sml_scaler_R2, NULL, "scaler_R2");
proto_tree_add_item (scaler_R2_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (scaler_R2_tree, hf_sml_scaler_R2, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
/*value_R2*/
get_length(tvb, offset, &data, &length);
value_R2_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, length+data, ett_sml_value_R2, NULL, "value_R2");
proto_tree_add_item (value_R2_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (value_R2_tree, hf_sml_value_R2, tvb, *offset, data, ENC_BIG_ENDIAN);
*offset+=data;
/*unit_R3*/
unit_R3_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, 2, ett_sml_unit_R3, NULL, "unit_R3");
proto_tree_add_item (unit_R3_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (unit_R3_tree, hf_sml_unit_R3, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
/*scaler_R3*/
scaler_R3_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, 2, ett_sml_scaler_R3, NULL, "scaler_R3");
proto_tree_add_item (scaler_R3_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (scaler_R3_tree, hf_sml_scaler_R3, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
/*value_R3*/
get_length(tvb, offset, &data, &length);
value_R3_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, length+data, ett_sml_value_R3, NULL, "value_R3");
proto_tree_add_item (value_R3_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (value_R3_tree, hf_sml_value_R3, tvb, *offset, data, ENC_BIG_ENDIAN);
*offset+=data;
/*signature_mA_R2_R3*/
get_length(tvb, offset, &data, &length);
signature_mA_R2_R3_tree = proto_tree_add_subtree(TupleEntry_list, tvb, *offset, length+data, ett_sml_signature_mA_R2_R3, NULL, "signature_mA_R2_R3");
proto_tree_add_uint (signature_mA_R2_R3_tree, hf_sml_length, tvb, *offset, length, data);
*offset+=length;
proto_tree_add_item (signature_mA_R2_R3_tree, hf_sml_signature_mA_R2_R3, tvb, *offset, data, ENC_NA);
*offset+=data;
proto_item_set_end(TupleEntry, tvb, *offset);
}
static void child_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tree, guint *offset, guint *data, guint *length){
proto_item *parameterName;
proto_item *procParValue;
proto_item *child;
proto_item *periodEntry;
proto_item *SML_time;
proto_item *listEntry;
proto_item *tree_Entry;
proto_tree *parameterName_tree = NULL;
proto_tree *procParValue_tree = NULL;
proto_tree *procParValuetype_tree = NULL;
proto_tree *periodEntry_tree = NULL;
proto_tree *SML_time_tree = NULL;
proto_tree *listEntry_tree = NULL;
//proto_tree *procParValueTime_tree = NULL;
proto_tree *child_list = NULL;
proto_tree *tree_Entry_list = NULL;
guint i = 0;
guint repeat = 0;
guint check = 0;
/*parameterName*/
get_length(tvb, offset, data, length);
parameterName_tree = proto_tree_add_subtree(insert_tree, tvb, *offset, *length + *data, ett_sml_parameterName, ¶meterName, "parameterName");
proto_tree_add_uint (parameterName_tree, hf_sml_length, tvb, *offset, *length, *data);
*offset+=*length;
proto_tree_add_item (parameterName_tree, hf_sml_parameterName, tvb, *offset, *data, ENC_NA);
*offset+=*data;
/*procParValue OPTIONAL*/
check = tvb_get_guint8(tvb, *offset);
if (check == OPTIONAL){
procParValue = proto_tree_add_item(insert_tree, hf_sml_procParValue, tvb, *offset, 1, ENC_BIG_ENDIAN);
proto_item_append_text(procParValue, ": NOT SET");
*offset+=1;
}
else if (check == 0x72){
get_length(tvb, offset, data, length);
procParValue_tree = proto_tree_add_subtree(insert_tree, tvb, *offset, -1, ett_sml_procParValue, &procParValue, "ProcParValue");
*offset+=1;
/*procParValue CHOOSE*/
procParValuetype_tree = proto_tree_add_subtree(procParValue_tree, tvb, *offset, 2, ett_sml_procParValuetype, NULL, "ProcParValueType");
proto_tree_add_item (procParValuetype_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
check = tvb_get_guint8(tvb, *offset);
proto_tree_add_item (procParValuetype_tree, hf_sml_procParValue, tvb, *offset, 1 ,ENC_BIG_ENDIAN);
*offset+=1;
switch (check) {
case PROC_VALUE:
/*value*/
sml_value(tvb, pinfo, procParValue_tree, offset, data, length);
break;
case PROC_PERIOD:
/*period*/
get_length(tvb, offset, data, length);
periodEntry_tree = proto_tree_add_subtree_format(procParValue_tree, tvb, *offset, -1, ett_sml_periodEntry, &periodEntry,
"PeriodEntry List with %d %s", *length + *data, plurality(*length + *data, "element", "elements"));
*offset+=*length;
/*objName*/
field_objName(tvb, periodEntry_tree, offset, data, length);
/*unit OPTIONAL*/
field_unit(tvb, periodEntry_tree, offset, data, length);
/*scaler OPTIONAL*/
field_scaler(tvb, periodEntry_tree, offset, data, length);
/*value*/
sml_value(tvb, pinfo, periodEntry_tree, offset, data, length);
/*value Signature*/
field_valueSignature(tvb, periodEntry_tree, offset, data, length);
proto_item_set_end(periodEntry, tvb, *offset);
break;
case PROC_TUPLE:
/*TupleEntry*/
if (tvb_get_guint8(tvb, *offset) == 0xF1 && tvb_get_guint8(tvb, *offset+1) == 0x07){
TupleEntryTree(tvb, pinfo, procParValue_tree, offset);
}
else {
expert_add_info(pinfo, NULL, &ei_sml_tuple_error);
return;
}
break;
case PROC_TIME:
SML_time_tree = proto_tree_add_subtree(procParValue_tree, tvb, *offset, -1, ett_sml_time, &SML_time, "Time");
*offset+=1;
sml_time_type(tvb, pinfo, SML_time_tree, offset);
proto_item_set_end(SML_time, tvb, *offset);
break;
case PROC_LISTENTRY:
/*listEntry*/
get_length(tvb, offset, data, length);
listEntry_tree = proto_tree_add_subtree_format(procParValue_tree, tvb, *offset, -1, ett_sml_listEntry, &listEntry,
"ListEntry List with %d %s", *length + *data, plurality(*length + *data, "element", "elements"));
*offset += *length;
/*objName*/
field_objName(tvb, listEntry_tree, offset, data, length);
/*status OPTIONAL*/
field_status(tvb, listEntry_tree, offset, data, length);
/*valTime OPTIONAL*/
SML_time_tree = proto_tree_add_subtree(listEntry_tree, tvb, *offset, -1, ett_sml_time, &SML_time, "Time");
*offset += 1;
sml_time_type(tvb, pinfo, SML_time_tree, offset);
proto_item_set_end(SML_time, tvb, *offset);
/*unit OPTIONAL*/
field_unit(tvb, listEntry_tree, offset, data, length);
/*scaler OPTIONAL*/
field_scaler(tvb, listEntry_tree, offset, data, length);
/*value*/
sml_value(tvb, pinfo, listEntry_tree, offset, data, length);
/*valueSignature OPTIONAL*/
field_valueSignature(tvb, listEntry_tree, offset, data, length);
proto_item_set_end(listEntry, tvb, *offset);
break;
default:
expert_add_info(pinfo, procParValue, &ei_sml_procParValue_invalid);
break;
}
proto_item_set_end(procParValue, tvb, *offset);
}
else {
expert_add_info(pinfo, NULL, &ei_sml_procParValue_errror);
return;
}
/*child list OPTIONAL*/
check = tvb_get_guint8(tvb, *offset);
child_list = proto_tree_add_subtree(insert_tree, tvb, *offset, -1, ett_sml_child, &child, "Child List");
if (check == OPTIONAL){
proto_item_append_text(child, ": NOT SET");
proto_item_set_len(child, 1);
*offset+=1;
}
else if ((check & 0x0F) != 0){
if (check == 0x71){
get_length(tvb, offset, data, length);
proto_item_append_text(child, "with %d %s", *length + *data, plurality(*length + *data, "element", "elements"));
*offset+=1;
tree_Entry_list = proto_tree_add_subtree(child_list, tvb, *offset, -1, ett_sml_tree_Entry, &tree_Entry, "tree_Entry");
*offset+=1;
child_tree(tvb, pinfo,tree_Entry_list, offset, data, length);
proto_item_set_end(tree_Entry, tvb, *offset);
proto_item_set_end(child, tvb, *offset);
}
else if ((check & 0xF0) == SHORT_LIST || (check & 0xF0) == LONG_LIST){
get_length(tvb, offset, data, length);
repeat = *length + *data;
proto_item_append_text(child, "with %d %s", *length + *data, plurality(*length + *data, "element", "elements"));
if (repeat <= 0){
expert_add_info_format(pinfo, child, &ei_sml_invalid_count, "invalid loop count");
return;
}
*offset+=*length;
for(i =0 ; i < repeat; i++){
tree_Entry_list = proto_tree_add_subtree(child_list, tvb, *offset, -1, ett_sml_tree_Entry, &tree_Entry, "tree_Entry");
if (tvb_get_guint8(tvb, *offset) != 0x73){
expert_add_info_format(pinfo, tree_Entry, &ei_sml_invalid_count, "invalid count of elements in tree_Entry");
return;
}
*offset+=1;
child_tree(tvb, pinfo, tree_Entry_list, offset, data, length);
proto_item_set_end(tree_Entry, tvb, *offset);
}
proto_item_set_end(child, tvb, *offset);
}
}
else {
expert_add_info_format(pinfo, child, &ei_sml_invalid_count, "invalid count of elements in child List");
}
}
/*messagetypes*/
static void decode_PublicOpenReq (tvbuff_t *tvb, proto_tree *messagebodytree_list, guint *offset){
guint data = 0;
guint length = 0;
/*Codepage OPTIONAL*/
field_codepage (tvb, messagebodytree_list, offset, &data, &length);
/*clientID*/
field_clientId (tvb, messagebodytree_list, offset, &data, &length);
/*reqFileId*/
field_reqFileId (tvb, messagebodytree_list, offset, &data, &length);
/*ServerID*/
field_serverId(tvb,messagebodytree_list, offset, &data, &length);
/*user*/
field_username(tvb,messagebodytree_list, offset, &data, &length);
/*password*/
field_password(tvb,messagebodytree_list, offset, &data, &length);
/*sml-Version OPTIONAL*/
field_smlVersion(tvb,messagebodytree_list, offset, &data, &length);
}
static void decode_PublicOpenRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){
proto_item *SML_time = NULL;
//proto_tree *refTime_tree = NULL;
proto_tree *SML_time_tree = NULL;
guint data = 0;
guint length = 0;
/*Codepage OPTIONAL*/
field_codepage (tvb, messagebodytree_list, offset, &data, &length);
/*clientID OPTIONAL*/
field_clientId (tvb, messagebodytree_list, offset, &data, &length);
/*reqFileId*/
field_reqFileId (tvb, messagebodytree_list, offset, &data, &length);
/*ServerID*/
field_serverId(tvb,messagebodytree_list,offset, &data, &length);
/*RefTime Optional*/
get_length(tvb, offset, &data, &length);
SML_time_tree = proto_tree_add_subtree(messagebodytree_list, tvb, *offset, -1, ett_sml_time, &SML_time, "refTime");
if (data == 0){
proto_item_append_text(SML_time, ": NOT SET");
proto_item_set_len(SML_time, length + data);
*offset+=1;
}
else{
/*SML TIME*/
*offset+=1;
sml_time_type(tvb, pinfo, SML_time_tree, offset);
proto_item_set_end(SML_time,tvb,*offset);
}
/*sml-Version OPTIONAL*/
field_smlVersion(tvb, messagebodytree_list, offset, &data, &length);
}
static gboolean decode_GetProfile_List_Pack_Req (tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){
proto_item *withRawdata = NULL;
proto_item *SML_time = NULL;
proto_item *treepath = NULL;
proto_item *object_list = NULL;
proto_item *dasDetails = NULL;
proto_tree *withRawdata_tree = NULL;
proto_tree *SML_time_tree = NULL;
//proto_tree *beginTime_tree = NULL;
proto_tree *treepath_list = NULL;
proto_tree *object_list_list = NULL;
//proto_tree *endTime_tree = NULL;
proto_tree *dasDetails_list = NULL;
guint i = 0;
guint repeat = 0;
guint check = 0;
guint data = 0;
guint length = 0;
/*ServerID*/
field_serverId(tvb,messagebodytree_list, offset, &data, &length);
/*user*/
field_username(tvb,messagebodytree_list, offset, &data, &length);
/*password*/
field_password(tvb,messagebodytree_list, offset, &data, &length);
/*withRawdata OPTIONAL*/
get_length(tvb, offset, &data, &length);
withRawdata = proto_tree_add_uint_format (messagebodytree_list, hf_sml_withRawdata, tvb, *offset, data+length, data+length, "withRawdata %s", (data == 0)? ": NOT SET" : "");
if (data > 0) {
withRawdata_tree = proto_item_add_subtree (withRawdata, ett_sml_withRawdata);
proto_tree_add_item (withRawdata_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (withRawdata_tree, hf_sml_withRawdata, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
}
else
*offset+=1;
/*beginTime OPTIONAL*/
get_length(tvb, offset, &data, &length);
SML_time_tree = proto_tree_add_subtree(messagebodytree_list, tvb, *offset, -1, ett_sml_time, &SML_time, "beginTime");
if (data == 0){
proto_item_append_text(SML_time, ": NOT SET");
proto_item_set_len(SML_time, length + data);
*offset+=1;
}
else {
/*SML TIME*/
*offset+=1;
sml_time_type(tvb, pinfo, SML_time_tree, offset);
proto_item_set_end(SML_time,tvb,*offset);
}
/*endTime OPTIONAL*/
get_length(tvb, offset, &data, &length);
SML_time_tree = proto_tree_add_subtree(messagebodytree_list, tvb, *offset, -1, ett_sml_time, &SML_time, "endTime");
if (data == 0){
proto_item_append_text(SML_time, ": NOT SET");
proto_item_set_len(SML_time, length + data);
*offset+=1;
}
else {
/*SML TIME*/
*offset+=1;
sml_time_type(tvb, pinfo, SML_time_tree, offset);
proto_item_set_end(SML_time,tvb,*offset);
}
/*Treepath List*/
get_length(tvb, offset, &data, &length);
repeat = (data+length);
treepath_list = proto_tree_add_subtree_format(messagebodytree_list, tvb, *offset, -1, ett_sml_treepath, &treepath,
"parameterTreePath with %d %s", length+data, plurality(length+data, "element", "elements"));
if ((tvb_get_guint8(tvb,*offset) & 0xF0) != LONG_LIST && (tvb_get_guint8(tvb,*offset) & 0xF0) != SHORT_LIST){
expert_add_info_format(pinfo, treepath, &ei_sml_invalid_count, "invalid count of elements in Treepath");
return TRUE;
}
else if (repeat <= 0){
expert_add_info_format(pinfo, treepath, &ei_sml_invalid_count, "invalid loop count");
return TRUE;
}
*offset+=length;
for (i=0; i< repeat; i++) {
field_parameterTreePath(tvb, treepath_list, offset, &data, &length);
}
proto_item_set_end(treepath, tvb, *offset);
/*object_list*/
object_list_list = proto_tree_add_subtree(messagebodytree_list, tvb, *offset, -1, ett_sml_object_list, &object_list, "object_List");
if (tvb_get_guint8(tvb,*offset) == OPTIONAL){
proto_item_append_text(object_list, ": NOT SET");
proto_item_set_len(object_list, 1);
*offset+=1;
}
else{
get_length(tvb, offset, &data, &length);
repeat = (data+length);
proto_item_append_text(object_list, " with %d %s", length+data, plurality(length+data, "element", "elements"));
if ((tvb_get_guint8(tvb,*offset) & 0xF0) != LONG_LIST && (tvb_get_guint8(tvb,*offset) & 0xF0) != SHORT_LIST){
expert_add_info_format(pinfo, object_list, &ei_sml_invalid_count, "invalid count of elements in object_List");
return TRUE;
}
else if (repeat <= 0){
expert_add_info_format(pinfo, treepath, &ei_sml_invalid_count, "invalid loop count");
return TRUE;
}
*offset+=length;
for (i=0; i< repeat; i++) {
field_ObjReqEntry(tvb, object_list_list, offset, &data, &length);
}
proto_item_set_end(object_list, tvb, *offset);
}
/*dasDetails*/
check = tvb_get_guint8(tvb,*offset);
dasDetails_list = proto_tree_add_subtree(messagebodytree_list, tvb, *offset, -1, ett_sml_dasDetails, &dasDetails, "dasDetails");
if (check == OPTIONAL){
proto_item_append_text(dasDetails, ": NOT SET");
proto_item_set_len(dasDetails, 1);
*offset+=1;
}
else if ((check & 0xF0) == LONG_LIST || (check & 0xF0) == SHORT_LIST){
get_length(tvb, offset, &data, &length);
proto_item_append_text(dasDetails, " with %d %s", length+data, plurality(length+data, "element", "elements"));
*offset+=length;
child_tree(tvb, pinfo, dasDetails_list, offset, &data, &length);
proto_item_set_end(dasDetails, tvb, *offset);
}
else {
expert_add_info_format(pinfo, dasDetails, &ei_sml_invalid_count, "invalid count of elements in dasDetails");
return TRUE;
}
return FALSE;
}
static gboolean decode_GetProfilePackRes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){
proto_item *SML_time = NULL;
proto_item *treepath = NULL;
proto_item *periodList = NULL;
proto_item *period_List_Entry = NULL;
proto_item *headerList = NULL;
proto_item *header_List_Entry = NULL;
proto_item *profileSignature = NULL;
proto_item *valuelist = NULL;
proto_item *value_List_Entry = NULL;
proto_tree *SML_time_tree = NULL;
proto_tree *treepath_list = NULL;
proto_tree *periodList_list = NULL;
proto_tree *period_List_Entry_list = NULL;
proto_tree *headerList_subtree = NULL;
proto_tree *header_List_Entry_list = NULL;
proto_tree *profileSignature_tree = NULL;
proto_tree *valuelist_list = NULL;
proto_tree *value_List_Entry_list = NULL;
guint i = 0;
guint d = 0;
guint repeat = 0;
guint repeat2= 0;
guint data = 0;
guint length = 0;
/*ServerID*/
field_serverId(tvb, messagebodytree_list, offset, &data, &length);
/*actTime*/
get_length(tvb, offset, &data, &length);
SML_time_tree = proto_tree_add_subtree_format(messagebodytree_list, tvb, *offset, -1, ett_sml_time, &SML_time,
"actTime List with %d %s", length+data, plurality(length+data, "element", "elements"));
*offset+=1;
sml_time_type(tvb, pinfo, SML_time_tree, offset);
proto_item_set_end(SML_time,tvb,*offset);
/*regPeriod*/
field_regPeriod(tvb, messagebodytree_list, offset, &data, &length);
/*Treepath List*/
get_length(tvb, offset, &data, &length);
repeat = (data+length);
treepath_list = proto_tree_add_subtree_format(messagebodytree_list, tvb, *offset, -1, ett_sml_treepath, &treepath,
"parameterTreePath with %d %s", length+data, plurality(length+data, "element", "elements"));
if ((tvb_get_guint8(tvb,*offset) & 0xF0) != LONG_LIST && (tvb_get_guint8(tvb,*offset) & 0xF0) != SHORT_LIST){
expert_add_info_format(pinfo, treepath, &ei_sml_invalid_count, "invalid count of elements in Treepath");
return TRUE;
}
else if (repeat <= 0){
expert_add_info_format(pinfo, treepath, &ei_sml_invalid_count, "invalid loop count");
return TRUE;
}
*offset+=length;
for (i=0; i< repeat; i++) {
field_parameterTreePath(tvb, treepath_list, offset, &data, &length);
}
proto_item_set_end(treepath, tvb, *offset);
/*headerList*/
get_length(tvb, offset, &data, &length);
repeat = (data+length);
headerList_subtree = proto_tree_add_subtree_format(messagebodytree_list, tvb, *offset, -1, ett_sml_headerList, &headerList,
"header_List with %d %s", length+data, plurality(length+data, "element", "elements"));
if ((tvb_get_guint8(tvb,*offset) & 0xF0) != LONG_LIST && (tvb_get_guint8(tvb,*offset) & 0xF0) != SHORT_LIST){
expert_add_info_format(pinfo, headerList, &ei_sml_invalid_count, "invalid count of elements in headerlist");
return TRUE;
}
else if (repeat <= 0){
expert_add_info_format(pinfo, headerList, &ei_sml_invalid_count, "invalid loop count");
return TRUE;
}
*offset+=length;
for (i=0; i< repeat; i++) {
get_length(tvb, offset, &data, &length);
header_List_Entry_list = proto_tree_add_subtree_format(headerList_subtree, tvb, *offset, -1, ett_sml_header_List_Entry, &header_List_Entry,
"header_List_Entry with %d %s", length+data, plurality(length+data, "element", "elements"));
*offset+=1;
/*objname*/
field_objName(tvb, header_List_Entry_list, offset, &data, &length);
/*unit*/
field_unit(tvb, header_List_Entry_list, offset, &data, &length);
/*scaler*/
field_scaler(tvb, header_List_Entry_list, offset, &data, &length);
proto_item_set_end(header_List_Entry, tvb, *offset);
}
proto_item_set_end(headerList, tvb, *offset);
/*period List*/
get_length(tvb, offset, &data, &length);
repeat = (data+length);
periodList_list = proto_tree_add_subtree_format(messagebodytree_list, tvb, *offset, -1, ett_sml_periodList, &periodList,
"period_List with %d %s", length+data, plurality(length+data, "element", "elements"));
if ((tvb_get_guint8(tvb,*offset) & 0xF0) != LONG_LIST && (tvb_get_guint8(tvb,*offset) & 0xF0) != SHORT_LIST){
expert_add_info_format(pinfo, periodList, &ei_sml_invalid_count, "invalid count of elements in periodList");
return TRUE;
}
else if (repeat <= 0){
expert_add_info_format(pinfo, periodList, &ei_sml_invalid_count, "invalid loop count");
return TRUE;
}
*offset+=length;
for (i=0; i< repeat; i++) {
get_length(tvb, offset, &data, &length);
period_List_Entry_list = proto_tree_add_subtree_format(periodList_list, tvb, *offset, -1, ett_sml_period_List_Entry, &period_List_Entry,
"period_List_Entry with %d %s", length+data, plurality(length+data, "element", "elements"));
*offset+=1;
/*valTime*/
get_length(tvb, offset, &data, &length);
SML_time_tree = proto_tree_add_subtree(period_List_Entry, tvb, *offset, -1, ett_sml_time, &SML_time, "valTime");
*offset+=1;
sml_time_type(tvb, pinfo, SML_time_tree, offset);
proto_item_set_end(SML_time,tvb, *offset);
/*status*/
field_status(tvb, period_List_Entry_list, offset, &data, &length);
/*value List*/
get_length(tvb, offset, &data, &length);
repeat2 = data + length;
valuelist_list = proto_tree_add_subtree_format(period_List_Entry_list, tvb, *offset, -1, ett_sml_valuelist, &valuelist,
"period_List with %d %s", length+data, plurality(length+data, "element", "elements"));
if ((tvb_get_guint8(tvb,*offset) & 0xF0) != LONG_LIST && (tvb_get_guint8(tvb,*offset) & 0xF0) != SHORT_LIST){
expert_add_info_format(pinfo, valuelist, &ei_sml_invalid_count, "invalid count of elements in valueList");
return TRUE;
}
else if (repeat2 <= 0){
expert_add_info_format(pinfo, valuelist, &ei_sml_invalid_count, "invalid loop count");
return TRUE;
}
*offset+=length;
for (d=0; d< repeat2; d++) {
get_length(tvb, offset, &data, &length);
value_List_Entry_list = proto_tree_add_subtree_format(valuelist_list, tvb, *offset, -1, ett_sml_value_List_Entry, NULL,
"value_List_Entry with %d %s", length+data, plurality(length+data, "element", "elements"));
*offset+=1;
/*value*/
sml_value(tvb, pinfo, value_List_Entry_list, offset, &data, &length);
/*value Signature*/
field_valueSignature(tvb, value_List_Entry_list, offset, &data, &length);
proto_item_set_end(value_List_Entry, tvb, *offset);
}
proto_item_set_end(valuelist, tvb, *offset);
/*period Signature*/
field_periodSignature(tvb, period_List_Entry_list, offset, &data, &length);
proto_item_set_end(period_List_Entry, tvb, *offset);
}
proto_item_set_end(periodList,tvb, *offset);
/*rawdata*/
field_rawdata(tvb, messagebodytree_list, offset, &data, &length);
/*profile Signature*/
get_length(tvb, offset, &data, &length);
profileSignature = proto_tree_add_bytes_format (messagebodytree_list, hf_sml_profileSignature, tvb, *offset, length+data, NULL, "profileSignature %s", (data == 0)? ": NOT SET" : "");
if (data > 0){
profileSignature_tree = proto_item_add_subtree (profileSignature, ett_sml_profileSignature);
proto_tree_add_uint (profileSignature_tree, hf_sml_length, tvb, *offset, length, data);
*offset+=length;
proto_tree_add_item (profileSignature_tree, hf_sml_profileSignature, tvb, *offset, data, ENC_NA);
*offset+=data;
}
else
*offset+=1;
return FALSE;
}
static gboolean decode_GetProfileListRes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){
proto_item *SML_time = NULL;
proto_item *treepath = NULL;
proto_item *periodList = NULL;
proto_item *periodList_Entry = NULL;
proto_tree *SML_time_tree = NULL;
proto_tree *treepath_list = NULL;
proto_tree *periodList_list = NULL;
proto_tree *periodList_Entry_list = NULL;
guint i = 0;
guint repeat = 0;
guint data = 0;
guint length = 0;
/*ServerID*/
field_serverId(tvb, messagebodytree_list, offset, &data, &length);
/*actTime*/
get_length(tvb, offset, &data, &length);
SML_time_tree = proto_tree_add_subtree(messagebodytree_list, tvb, *offset, -1, ett_sml_time, &SML_time, "actTime");
*offset+=1;
sml_time_type(tvb, pinfo, SML_time_tree, offset);
proto_item_set_end(SML_time,tvb, *offset);
/*regPeriod*/
field_regPeriod(tvb, messagebodytree_list, offset, &data, &length);
/*Treepath List*/
get_length(tvb, offset, &data, &length);
repeat = (data+length);
treepath_list = proto_tree_add_subtree_format(messagebodytree_list, tvb, *offset, -1, ett_sml_treepath, &treepath,
"parameterTreePath with %d %s", length+data, plurality(length+data, "element", "elements"));
if ((tvb_get_guint8(tvb,*offset) & 0xF0) != LONG_LIST && (tvb_get_guint8(tvb,*offset) & 0xF0) != SHORT_LIST){
expert_add_info_format(pinfo, treepath, &ei_sml_invalid_count, "invalid count of elements in parameterTreePath");
return TRUE;
}
else if (repeat <= 0){
expert_add_info_format(pinfo, treepath, &ei_sml_invalid_count, "invalid loop count");
return TRUE;
}
*offset+=length;
for (i=0; i< repeat; i++) {
field_parameterTreePath(tvb, treepath_list, offset, &data, &length);
}
proto_item_set_end(treepath, tvb,*offset);
/*valTime Optional*/
get_length(tvb, offset, &data, &length);
SML_time_tree = proto_tree_add_subtree(messagebodytree_list, tvb, *offset, -1, ett_sml_time, &SML_time, "valTime");
if (data == 0){
proto_item_append_text(SML_time, ": NOT SET");
proto_item_set_len(SML_time, length + data);
*offset+=1;
}
else {
/*SML TIME*/
*offset+=1;
sml_time_type(tvb, pinfo, SML_time_tree, offset);
proto_item_set_end(SML_time,tvb,*offset);
}
/*Status*/
field_status(tvb, messagebodytree_list, offset, &data, &length);
/*period-List*/
get_length(tvb, offset, &data, &length);
repeat = (data+length);
periodList_list = proto_tree_add_subtree_format(messagebodytree_list, tvb, *offset, -1, ett_sml_periodList, &periodList,
"period-List with %d %s", length+data, plurality(length+data, "element", "elements"));
if ((tvb_get_guint8(tvb,*offset) & 0xF0) != LONG_LIST && (tvb_get_guint8(tvb,*offset) & 0xF0) != SHORT_LIST){
expert_add_info_format(pinfo, periodList, &ei_sml_invalid_count, "invalid count of elements in periodList");
return TRUE;
}
else if (repeat <= 0){
expert_add_info_format(pinfo, periodList, &ei_sml_invalid_count, "invalid loop count");
return TRUE;
}
*offset+=length;
for (i=0; i< repeat; i++) {
get_length(tvb, offset, &data, &length);
periodList_Entry_list = proto_tree_add_subtree(periodList_list, tvb, *offset, -1, ett_sml_period_List_Entry, &periodList_Entry, "PeriodEntry");
*offset+=1;
/*ObjName*/
field_objName(tvb, periodList_Entry_list, offset, &data, &length);
/*Unit*/
field_unit(tvb, periodList_Entry_list, offset, &data, &length);
/*scaler*/
field_scaler(tvb, periodList_Entry_list, offset, &data, &length);
/*value*/
sml_value(tvb, pinfo, periodList_Entry_list, offset, &data, &length);
/*value*/
field_valueSignature(tvb, periodList_Entry_list, offset, &data, &length);
proto_item_set_end(periodList_Entry, tvb, *offset);
}
proto_item_set_end(periodList, tvb, *offset);
/*rawdata*/
field_rawdata(tvb, messagebodytree_list, offset, &data, &length);
/*period Signature*/
field_periodSignature(tvb, messagebodytree_list, offset, &data, &length);
return FALSE;
}
static void decode_GetListReq (tvbuff_t *tvb, proto_tree *messagebodytree_list, guint *offset){
guint data = 0;
guint length = 0;
/*clientID*/
field_clientId (tvb, messagebodytree_list, offset, &data, &length);
/*ServerID*/
field_serverId(tvb,messagebodytree_list,offset, &data, &length);
/*user*/
field_username(tvb,messagebodytree_list,offset, &data, &length);
/*password*/
field_password(tvb,messagebodytree_list,offset, &data, &length);
/*listName*/
field_listName(tvb,messagebodytree_list,offset, &data, &length);
}
static gboolean decode_GetListRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){
proto_item *valList = NULL;
proto_item *listSignature = NULL;
proto_item *valtree = NULL;
proto_item *SML_time;
//proto_tree *actSensorTime_tree = NULL;
proto_tree *valList_list = NULL;
proto_tree *listSignature_tree = NULL;
proto_tree *valtree_list = NULL;
//proto_tree *actGatewayTime_tree = NULL;
proto_tree *SML_time_tree = NULL;
guint repeat = 0;
guint i = 0;
guint data = 0;
guint length = 0;
/*clientID OPTIONAL*/
field_clientId (tvb, messagebodytree_list, offset, &data, &length);
/*ServerID*/
field_serverId(tvb, messagebodytree_list, offset, &data, &length);
/*listName*/
field_listName(tvb, messagebodytree_list, offset, &data, &length);
/*actSensorTime OPTIONAL*/
get_length(tvb, offset, &data, &length);
SML_time_tree = proto_tree_add_subtree(messagebodytree_list, tvb, *offset, -1, ett_sml_time, &SML_time, "actSensorTime");
if (data == 0){
proto_item_append_text(SML_time, ": NOT SET");
proto_item_set_len(SML_time, length + data);
*offset+=1;
}
else {
/*SML TIME*/
*offset+=1;
sml_time_type(tvb, pinfo, SML_time_tree, offset);
proto_item_set_end(SML_time,tvb,*offset);
}
/*valList*/
get_length(tvb, offset, &data, &length);
repeat = (length + data);
valtree_list = proto_tree_add_subtree_format(messagebodytree_list, tvb, *offset, -1, ett_sml_valtree, &valtree,
"valList with %d %s", length+data, plurality(length+data, "element", "elements"));
if ((tvb_get_guint8(tvb,*offset) & 0xF0) != LONG_LIST && (tvb_get_guint8(tvb,*offset) & 0xF0) != SHORT_LIST){
expert_add_info_format(pinfo, valtree, &ei_sml_invalid_count, "invalid count of elements in valList");
return TRUE;
}
else if (repeat <= 0){
expert_add_info_format(pinfo, valtree, &ei_sml_invalid_count, "invalid loop count");
return TRUE;
}
*offset+=length;
for (i=0; i < repeat; i++){
get_length(tvb, offset, &data, &length);
valList_list = proto_tree_add_subtree(valtree_list, tvb, *offset, -1, ett_sml_valList, &valList, "valListEntry");
*offset+=length;
/*objName*/
field_objName(tvb, valList_list, offset, &data, &length);
/*Sml Status OPTIONAL*/
field_status(tvb, valList_list, offset, &data, &length);
/*valTime OPTIONAL*/
get_length(tvb, offset, &data, &length);
SML_time_tree = proto_tree_add_subtree(valList_list, tvb, *offset, -1, ett_sml_time, &SML_time, "valTime");
if (data == 0){
proto_item_append_text(SML_time, ": NOT SET");
proto_item_set_len(SML_time, length + data);
*offset+=1;
}
else {
/*SML TIME*/
*offset+=1;
sml_time_type(tvb, pinfo, SML_time_tree, offset);
proto_item_set_end(SML_time, tvb, *offset);
}
/*unit OPTIONAL*/
field_unit(tvb, valList_list, offset, &data, &length);
/*Scaler OPTIONAL*/
field_scaler(tvb, valList_list, offset, &data, &length);
/*value*/
sml_value(tvb, pinfo, valList_list, offset, &data, &length);
/*value Signature*/
field_valueSignature(tvb, valList_list, offset, &data, &length);
proto_item_set_end(valList, tvb, *offset);
}
proto_item_set_end(valtree, tvb, *offset);
/*List Signature OPTIONAL*/
get_length(tvb, offset, &data, &length);
listSignature = proto_tree_add_bytes_format (messagebodytree_list, hf_sml_listSignature, tvb, *offset, length+data, NULL, "ListSignature %s", (data == 0)? ": NOT SET" : "");
if (data > 0){
listSignature_tree = proto_item_add_subtree (listSignature, ett_sml_listSignature);
proto_tree_add_uint (listSignature_tree, hf_sml_length, tvb, *offset, length, data);
*offset+=length;
proto_tree_add_item (listSignature_tree, hf_sml_listSignature, tvb, *offset, data, ENC_NA);
*offset+=data;
}
else
*offset+=1;
/*actGatewayTime OPTIONAL*/
get_length(tvb, offset, &data, &length);
SML_time_tree = proto_tree_add_subtree(messagebodytree_list, tvb, *offset, -1, ett_sml_time, &SML_time, "actGatewayTime");
if (data == 0){
proto_item_append_text(SML_time, ": NOT SET");
proto_item_set_len(SML_time, length + data);
*offset+=1;
}
else{
/*SML TIME*/
*offset+=1;
sml_time_type(tvb, pinfo, SML_time_tree, offset);
proto_item_set_end(SML_time,tvb,*offset);
}
return FALSE;
}
static gboolean decode_GetProcParameterReq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){
proto_item *treepath = NULL;
proto_item *attribute = NULL;
proto_tree *treepath_list = NULL;
proto_tree *attribute_tree = NULL;
guint i = 0;
guint repeat = 0;
guint data = 0;
guint length = 0;
/*ServerID*/
field_serverId(tvb, messagebodytree_list, offset, &data, &length);
/*user*/
field_username(tvb, messagebodytree_list, offset, &data, &length);
/*password*/
field_password(tvb, messagebodytree_list, offset, &data, &length);
/*Treepath List*/
get_length(tvb, offset, &data, &length);
repeat = data+length;
treepath_list = proto_tree_add_subtree_format(messagebodytree_list, tvb, *offset, -1, ett_sml_treepath, &treepath,
"ParameterTreePath with %d %s", length+data, plurality(length+data, "element", "elements"));
if ((tvb_get_guint8(tvb,*offset) & 0xF0) != LONG_LIST && (tvb_get_guint8(tvb,*offset) & 0xF0) != SHORT_LIST){
expert_add_info_format(pinfo, treepath, &ei_sml_invalid_count, "invalid count of elements in ParameterTreePath");
return TRUE;
}
else if (repeat <= 0){
expert_add_info_format(pinfo, treepath, &ei_sml_invalid_count, "invalid loop count");
return TRUE;
}
*offset+=length;
for (i=0; i< repeat; i++) {
field_parameterTreePath(tvb, treepath_list, offset, &data, &length);
}
proto_item_set_end(treepath, tvb, *offset);
/*attribute*/
get_length(tvb, offset, &data, &length);
attribute = proto_tree_add_bytes_format (messagebodytree_list,hf_sml_attribute, tvb, *offset, length+data, NULL, "attribute %s", (data == 0)? ": NOT SET" : "");
if (data > 0) {
attribute_tree = proto_item_add_subtree (attribute, ett_sml_attribute);
proto_tree_add_uint (attribute_tree, hf_sml_length, tvb, *offset, length, data);
*offset+=length;
proto_tree_add_item (attribute_tree, hf_sml_attribute, tvb, *offset, data, ENC_NA);
*offset+=data;
}
else
*offset+=1;
return FALSE;
}
static gboolean decode_GetProcParameterRes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){
proto_item *treepath = NULL;
proto_item *parameterTree =NULL;
proto_tree *treepath_list = NULL;
proto_tree *parameterTree_list = NULL;
guint i = 0;
guint repeat = 0;
guint data = 0;
guint length = 0;
/*ServerID*/
field_serverId(tvb, messagebodytree_list, offset, &data, &length);
/*Treepath List*/
get_length(tvb, offset, &data, &length);
repeat = (data+length);
treepath_list = proto_tree_add_subtree_format(messagebodytree_list, tvb, *offset, -1, ett_sml_treepath, &treepath,
"parameterTreePath with %d %s", length+data, plurality(length+data, "element", "elements"));
if ((tvb_get_guint8(tvb,*offset) & 0xF0) != LONG_LIST && (tvb_get_guint8(tvb,*offset) & 0xF0) != SHORT_LIST){
expert_add_info_format(pinfo, treepath, &ei_sml_invalid_count, "invalid count of elements in ParameterTreePath");
return TRUE;
}
else if (repeat <= 0){
expert_add_info_format(pinfo, treepath, &ei_sml_invalid_count, "invalid loop count");
return TRUE;
}
*offset+=length;
for (i=0; i< repeat; i++) {
field_parameterTreePath(tvb, treepath_list, offset, &data, &length);
}
proto_item_set_end(treepath, tvb, *offset);
/*parameterTree*/
get_length(tvb, offset, &data, &length);
parameterTree_list = proto_tree_add_subtree_format(messagebodytree_list, tvb, *offset, -1, ett_sml_parameterTree, ¶meterTree,
"parameterTree with %d %s", length+data, plurality(length+data, "element", "elements"));
if ((tvb_get_guint8(tvb,*offset) & 0xF0) != LONG_LIST && (tvb_get_guint8(tvb,*offset) & 0xF0) != SHORT_LIST){
expert_add_info_format(pinfo, parameterTree, &ei_sml_invalid_count, "invalid count of elements in parameterTree");
return TRUE;
}
*offset+=length;
child_tree(tvb, pinfo,parameterTree_list, offset, &data, &length);
proto_item_set_end(parameterTree, tvb, *offset);
return FALSE;
}
static gboolean decode_SetProcParameterReq(tvbuff_t *tvb, packet_info *pinfo,proto_tree *messagebodytree_list, guint *offset){
proto_item *treepath = NULL;
proto_item *parameterTree = NULL;
proto_tree *treepath_list = NULL;
proto_tree *parameterTree_list = NULL;
guint i = 0;
guint repeat = 0;
guint data = 0;
guint length = 0;
/*ServerID*/
field_serverId(tvb, messagebodytree_list, offset, &data, &length);
/*user*/
field_username(tvb, messagebodytree_list, offset, &data, &length);
/*password*/
field_password(tvb, messagebodytree_list, offset, &data, &length);
/*Treepath List*/
get_length(tvb, offset, &data, &length);
repeat = (data+length);
treepath_list = proto_tree_add_subtree_format(messagebodytree_list, tvb, *offset, -1, ett_sml_treepath, &treepath,
"parameterTreePath with %d %s", length+data, plurality(length+data, "element", "elements"));
if ((tvb_get_guint8(tvb,*offset) & 0xF0) != LONG_LIST && (tvb_get_guint8(tvb,*offset) & 0xF0) != SHORT_LIST){
expert_add_info_format(pinfo, treepath, &ei_sml_invalid_count, "invalid count of elements in ParameterTreePath");
return TRUE;
}
else if (repeat <= 0){
expert_add_info_format(pinfo, treepath, &ei_sml_invalid_count, "invalid loop count");
return TRUE;
}
*offset+=length;
for (i=0; i< repeat; i++) {
field_parameterTreePath(tvb, treepath_list, offset, &data, &length);
}
proto_item_set_end(treepath, tvb, *offset);
/*parameterTree*/
get_length(tvb, offset, &data, &length);
parameterTree_list = proto_tree_add_subtree_format(messagebodytree_list, tvb, *offset, -1, ett_sml_parameterTree, ¶meterTree,
"parameterTree with %d %s", length+data, plurality(length+data, "element", "elements"));
if ((tvb_get_guint8(tvb,*offset) & 0xF0) != LONG_LIST && (tvb_get_guint8(tvb,*offset) & 0xF0) != SHORT_LIST){
expert_add_info_format(pinfo, parameterTree, &ei_sml_invalid_count, "invalid count of elements in parameterTree");
return TRUE;
}
*offset+=length;
child_tree(tvb, pinfo,parameterTree_list, offset, &data, &length);
proto_item_set_end(parameterTree, tvb, *offset);
return FALSE;
}
static gboolean decode_AttentionRes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){
proto_item *attentionMsg = NULL;
proto_item *attentionDetails = NULL;
proto_tree *attentionNo_tree = NULL;
proto_tree *attentionMsg_tree = NULL;
proto_tree *attentionDetails_list = NULL;
proto_item *attentionNo_item;
guint data = 0;
guint length = 0;
/*ServerID*/
field_serverId(tvb, messagebodytree_list, offset, &data, &length);
/*attention NO*/
get_length(tvb, offset, &data, &length);
attentionNo_tree = proto_tree_add_subtree(messagebodytree_list, tvb ,*offset, length+data, ett_sml_attentionNo, &attentionNo_item, "attentionNo");
proto_tree_add_uint (attentionNo_tree, hf_sml_length, tvb, *offset, length, data);
*offset+=length;
if (data == 6){
*offset+=4;
proto_tree_add_item (attentionNo_tree, hf_sml_attentionNo, tvb, *offset, 2, ENC_BIG_ENDIAN);
*offset+=2;
}
else {
expert_add_info(pinfo, attentionNo_item, &ei_sml_attentionNo);
*offset+=data;
}
/*attention Msg*/
get_length(tvb, offset, &data, &length);
attentionMsg = proto_tree_add_string_format (messagebodytree_list, hf_sml_attentionMsg, tvb, *offset, length+data, NULL, "attentionMsg %s", (data == 0)? ": NOT SET" : "");
if (data > 0){
attentionMsg_tree = proto_item_add_subtree (attentionMsg, ett_sml_attentionMsg);
proto_tree_add_uint (attentionMsg_tree, hf_sml_length, tvb, *offset, length, data);
*offset+=length;
proto_tree_add_item (attentionMsg_tree, hf_sml_attentionMsg, tvb, *offset, data, ENC_ASCII | ENC_BIG_ENDIAN);
*offset+=data;
}
else
*offset+=1;
/*attentiondetails*/
attentionDetails_list = proto_tree_add_subtree(messagebodytree_list, tvb, *offset, -1, ett_sml_attentionDetails, &attentionDetails, "attentionDetails");
if (tvb_get_guint8(tvb,*offset) == OPTIONAL){
proto_item_append_text(attentionDetails, ": NOT SET");
proto_item_set_len(attentionDetails, 1);
*offset+=1;
}
else{
get_length(tvb, offset, &data, &length);
proto_item_append_text(attentionDetails, " with %d %s", length+data, plurality(length+data, "element", "elements"));
if ((tvb_get_guint8(tvb,*offset) & 0xF0) != LONG_LIST && (tvb_get_guint8(tvb,*offset) & 0xF0) != SHORT_LIST){
expert_add_info_format(pinfo, attentionDetails, &ei_sml_invalid_count, "invalid count of elements in attentionDetails");
return TRUE;
}
*offset+=length;
child_tree(tvb, pinfo,attentionDetails_list, offset, &data, &length);
proto_item_set_end(attentionDetails, tvb, *offset);
}
return FALSE;
}
/*dissect SML-File*/
static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, proto_tree *sml_tree){
proto_item *file = NULL;
proto_item *mainlist;
proto_item *sublist;
proto_item *messagebody;
proto_item *crc16;
proto_item *messagebodytree;
proto_item *msgend;
proto_tree *mainlist_list = NULL;
proto_tree *trans_tree = NULL;
proto_tree *groupNo_tree = NULL;
proto_tree *abortOnError_tree = NULL;
proto_tree *sublist_list = NULL;
proto_tree *messagebody_tree = NULL;
proto_tree *crc16_tree = NULL;
proto_tree *messagebodytree_list = NULL;
proto_tree *msgend_tree = NULL;
guint16 messagebody_switch = 0;
guint16 crc_check = 0;
guint16 crc_ref = 0;
guint check = 0;
guint available = 0;
guint crc_msg_len = 0;
guint crc_file_len = 0;
guint data = 0;
guint length = 0;
gboolean msg_error = FALSE;
gboolean close1 = FALSE;
gboolean close2 = FALSE;
gint end_offset = 0;
guint start_offset;
start_offset = *offset;
end_offset = tvb_reported_length_remaining(tvb, *offset);
if (end_offset <= 0){
return;
}
if (tvb_get_ntoh40(tvb, end_offset-8) != ESC_SEQ_END && pinfo->can_desegment){
if (tvb_get_guint8(tvb, end_offset-1) != 0){
pinfo->desegment_offset = start_offset;
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
return;
}
else if (tvb_get_guint8(tvb, end_offset-4) != UNSIGNED16 && tvb_get_guint8(tvb, end_offset-3) != UNSIGNED8){
pinfo->desegment_offset = start_offset;
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
return;
}
}
else if (!pinfo->can_desegment){
expert_add_info(pinfo, NULL, &ei_sml_segment_needed);
}
while(!close1 && !close2){
if (sml_reassemble){
file = proto_tree_add_item(sml_tree, hf_sml_file_marker, tvb, *offset, -1, ENC_NA);
}
/*check if escape*/
if (tvb_get_ntohl(tvb, *offset) == ESC_SEQ){
crc_file_len = *offset;
/*Escape Start*/
proto_tree_add_item (sml_tree, hf_sml_esc, tvb, *offset, 4, ENC_BIG_ENDIAN);
*offset+=4;
/*Version*/
if (tvb_get_guint8(tvb, *offset) == 0x01){
proto_tree_add_item (sml_tree, hf_sml_version_1, tvb, *offset, 4, ENC_BIG_ENDIAN);
*offset+=4;
}
else{
proto_tree_add_expert(sml_tree, pinfo, &ei_sml_version2_not_supported, tvb, *offset, -1);
return;
}
}
while (!close1){
crc_msg_len = *offset;
/*List*/
get_length(tvb, offset, &data, &length);
mainlist_list = proto_tree_add_subtree_format(sml_tree, tvb, *offset, -1, ett_sml_mainlist, &mainlist, "List with %d %s",
length+data, plurality(length+data, "element", "elements"));
if (tvb_get_guint8(tvb, *offset) != LIST_6_ELEMENTS) {
expert_add_info_format(pinfo, mainlist, &ei_sml_invalid_count, "invalid count of elements");
return;
}
*offset+=1;
/*Transaction ID*/
get_length(tvb, offset, &data, &length);
trans_tree = proto_tree_add_subtree_format(mainlist_list, tvb, *offset, length + data, ett_sml_trans, NULL, "Transaction ID");
proto_tree_add_uint (trans_tree, hf_sml_length, tvb, *offset, length, data);
*offset+=length;
proto_tree_add_item (trans_tree, hf_sml_transactionId, tvb, *offset, data, ENC_NA);
*offset+=data;
/*Group No*/
groupNo_tree = proto_tree_add_subtree(mainlist_list, tvb, *offset, 2, ett_sml_group, NULL, "Group No");
proto_tree_add_item (groupNo_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item (groupNo_tree, hf_sml_groupNo, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
/*abort on Error*/
abortOnError_tree = proto_tree_add_subtree(mainlist_list, tvb, *offset, 2, ett_sml_abort, NULL, "Abort on Error");
proto_tree_add_item(abortOnError_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
proto_tree_add_item(abortOnError_tree, hf_sml_abortOnError, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
/*Sub List*/
sublist_list = proto_tree_add_subtree(mainlist_list, tvb, *offset, -1, ett_sml_sublist, &sublist, "MessageBody");
*offset+=1;
/*Zero Cutting Check*/
get_length(tvb, offset, &data, &length);
messagebody_tree = proto_tree_add_subtree(sublist_list, tvb, *offset, length + data, ett_sml_mttree, &messagebody, "Messagetype");
proto_tree_add_item (messagebody_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
if (data == 4){
*offset+=2;
}
else if (data !=2){
expert_add_info(pinfo, messagebody, &ei_sml_messagetype_unknown);
return;
}
messagebody_switch = tvb_get_ntohs(tvb, *offset);
proto_tree_add_item (messagebody_tree, hf_sml_MessageBody, tvb, *offset, 2, ENC_BIG_ENDIAN);
*offset+=2;
/*MessageBody List*/
get_length(tvb, offset, &data, &length);
messagebodytree_list = proto_tree_add_subtree_format(sublist_list, tvb, *offset, -1, ett_sml_mblist, &messagebodytree,
"List with %d %s", length+data, plurality(length+data, "element", "elements"));
*offset+=length;
switch (messagebody_switch){
case OPEN_REQ:
col_append_str (pinfo->cinfo, COL_INFO, "OpenReq; ");
proto_item_append_text(mainlist, " [Open Request]");
decode_PublicOpenReq(tvb, messagebodytree_list, offset);
break;
case OPEN_RES:
col_append_str (pinfo->cinfo, COL_INFO, "OpenRes; ");
proto_item_append_text(mainlist, " [Open Response]");
decode_PublicOpenRes(tvb, pinfo, messagebodytree_list, offset);
break;
case CLOSE_REQ:
col_append_str (pinfo->cinfo, COL_INFO, "CloseReq; ");
proto_item_append_text(mainlist, " [Close Request]");
field_globalSignature(tvb, messagebodytree_list, offset, &data, &length);
break;
case CLOSE_RES:
col_append_str (pinfo->cinfo, COL_INFO, "CloseRes; ");
proto_item_append_text(mainlist, " [Close Response]");
field_globalSignature(tvb, messagebodytree_list, offset, &data, &length);
break;
case PROFILEPACK_REQ:
col_append_str (pinfo->cinfo, COL_INFO, "GetProfilePackReq; ");
proto_item_append_text(mainlist, " [GetProfilePack Request]");
msg_error = decode_GetProfile_List_Pack_Req(tvb, pinfo,messagebodytree_list, offset);
break;
case PROFILEPACK_RES:
col_append_str (pinfo->cinfo, COL_INFO, "GetProfilePackRes; ");
proto_item_append_text(mainlist, " [GetProfilePack Response]");
msg_error = decode_GetProfilePackRes(tvb, pinfo,messagebodytree_list, offset);
break;
case PROFILELIST_REQ:
col_append_str (pinfo->cinfo, COL_INFO, "GetProfileListReq; ");
proto_item_append_text(mainlist, " [GetProfileList Request]");
msg_error = decode_GetProfile_List_Pack_Req(tvb, pinfo,messagebodytree_list, offset);
break;
case PROFILELIST_RES:
col_append_str (pinfo->cinfo, COL_INFO, "GetProfileListRes; ");
proto_item_append_text(mainlist, " [GetProfileList Response]");
msg_error = decode_GetProfileListRes(tvb, pinfo,messagebodytree_list, offset);
break;
case GETPROCPARAMETER_REQ:
col_append_str (pinfo->cinfo, COL_INFO, "GetProcParameterReq; ");
proto_item_append_text(mainlist, " [GetProcParameter Request]");
msg_error = decode_GetProcParameterReq(tvb, pinfo,messagebodytree_list, offset);
break;
case GETPROCPARAMETER_RES:
col_append_str (pinfo->cinfo, COL_INFO, "GetProcParameterRes; ");
proto_item_append_text(mainlist, " [GetProcParameter Response]");
msg_error = decode_GetProcParameterRes(tvb, pinfo,messagebodytree_list, offset);
break;
case SETPROCPARAMETER_REQ:
col_append_str (pinfo->cinfo, COL_INFO, "SetProcParameterReq; ");
proto_item_append_text(mainlist, " [SetProcParameter Request]");
msg_error = decode_SetProcParameterReq(tvb, pinfo,messagebodytree_list, offset);
break;
case GETLIST_REQ:
col_append_str (pinfo->cinfo, COL_INFO, "GetListReq; ");
proto_item_append_text(mainlist, " [GetList Request]");
decode_GetListReq(tvb, messagebodytree_list, offset);
break;
case GETLIST_RES:
col_append_str (pinfo->cinfo, COL_INFO, "GetListRes; ");
proto_item_append_text(mainlist, " [GetList Response]");
msg_error = decode_GetListRes(tvb, pinfo,messagebodytree_list, offset);
break;
case ATTENTION:
col_append_str (pinfo->cinfo, COL_INFO, "AttentionRes; ");
proto_item_append_text(mainlist, " [Attention Response]");
msg_error = decode_AttentionRes(tvb, pinfo,messagebodytree_list, offset);
break;
default :
expert_add_info(pinfo, messagebodytree, &ei_sml_messagetype_unknown);
return;
}
if (msg_error){
expert_add_info(pinfo, messagebodytree, &ei_sml_MessageBody);
return;
}
proto_item_set_end(messagebodytree, tvb, *offset);
proto_item_set_end(sublist, tvb, *offset);
/* CRC 16*/
get_length(tvb, offset, &data, &length);
crc16_tree = proto_tree_add_subtree(mainlist_list, tvb, *offset, data + length, ett_sml_crc16, &crc16, "CRC");
if(tvb_get_guint8(tvb, *offset) != UNSIGNED8 && tvb_get_guint8(tvb, *offset) != UNSIGNED16){
expert_add_info(pinfo, crc16, &ei_sml_crc_error_length);
return;
}
proto_tree_add_item (crc16_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
if (sml_crc_enabled) {
crc_msg_len = (*offset - crc_msg_len - 1);
crc_check = crc16_ccitt_tvb_offset(tvb, (*offset - crc_msg_len - 1), crc_msg_len);
if (data == 1){
crc_ref = crc_ref & 0xFF00;
}
proto_tree_add_checksum(crc16_tree, tvb, *offset, hf_sml_crc16, hf_sml_crc16_status, &ei_sml_crc_error, pinfo, crc_check,
ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
}
else {
proto_tree_add_checksum(crc16_tree, tvb, *offset, hf_sml_crc16, hf_sml_crc16_status, &ei_sml_crc_error, pinfo, 0,
ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
*offset+=data;
/*Message END*/
if (tvb_get_guint8 (tvb, *offset) == 0){
proto_tree_add_item (mainlist_list, hf_sml_endOfSmlMsg, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
}
else {
expert_add_info(pinfo, NULL, &ei_sml_endOfSmlMsg);
return;
}
proto_item_set_end(mainlist, tvb, *offset);
if (tvb_reported_length_remaining(tvb, *offset) > 0){
check = tvb_get_guint8(tvb, *offset);
if (check == LIST_6_ELEMENTS){
close1 = FALSE;
}
else if (check == 0x1b || check == 0){
close1 = TRUE;
}
}
else if (sml_reassemble && pinfo->can_desegment){
pinfo->desegment_offset = start_offset;
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
return;
}
else
return;
}
/*Padding*/
if (check == 0){
length = 1;
*offset+=1;
while (tvb_get_guint8(tvb, *offset) == 0){
length++;
*offset+=1;
}
*offset-=length;
proto_tree_add_item (sml_tree, hf_sml_padding, tvb, *offset, length, ENC_NA);
*offset+=length;
}
/*Escape End*/
if(tvb_get_ntoh40(tvb, *offset) != ESC_SEQ_END){
expert_add_info(pinfo, NULL, &ei_sml_esc_error);
return;
}
proto_tree_add_item (sml_tree, hf_sml_esc, tvb, *offset, 4, ENC_BIG_ENDIAN);
*offset+=4;
/*MSG END*/
msgend = proto_tree_add_item (sml_tree, hf_sml_end, tvb, *offset, 4, ENC_BIG_ENDIAN);
msgend_tree = proto_item_add_subtree (msgend, ett_sml_msgend);
*offset+=1;
proto_tree_add_item (msgend_tree, hf_sml_padding, tvb, *offset, 1, ENC_NA);
*offset+=1;
if (sml_crc_enabled && sml_reassemble){
crc_file_len = *offset - crc_file_len;
crc_check = crc16_ccitt_tvb_offset(tvb,*offset-crc_file_len, crc_file_len);
proto_tree_add_checksum(msgend_tree, tvb, *offset, hf_sml_crc16, hf_sml_crc16_status, &ei_sml_crc_error, pinfo, crc_check,
ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
}
else {
proto_tree_add_checksum(msgend_tree, tvb, *offset, hf_sml_crc16, hf_sml_crc16_status, &ei_sml_crc_error, pinfo, crc_check,
ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
*offset+=2;
available = tvb_reported_length_remaining(tvb, *offset);
if (available <= 0){
close2 = TRUE;
}
else {
if (sml_reassemble){
proto_item_set_end(file, tvb, *offset);
}
else {
proto_tree_add_item(sml_tree, hf_sml_new_file_marker, tvb, *offset, 0, ENC_NA);
}
close1 = FALSE;
}
}
}
/* main */
static int dissect_sml (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) {
proto_item *sml_item;
proto_tree *sml_tree;
guint offset = 0;
/*Check if not SML*/
if (tvb_get_ntohl(tvb, offset) != ESC_SEQ && tvb_get_guint8(tvb, offset) != LIST_6_ELEMENTS){
return 0;
}
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SML");
col_clear(pinfo->cinfo,COL_INFO);
/* create display subtree for the protocol */
sml_item = proto_tree_add_item(tree, proto_sml, tvb, 0, -1, ENC_NA);
sml_tree = proto_item_add_subtree(sml_item, ett_sml);
dissect_sml_file(tvb, pinfo, &offset, sml_tree);
return tvb_captured_length(tvb);
}
static void
sml_fmt_length( gchar *result, guint32 length )
{
snprintf( result, ITEM_LABEL_LENGTH, "%d %s", length, plurality(length, "octet", "octets"));
}
void proto_register_sml (void) {
module_t *sml_module;
expert_module_t* expert_sml;
static hf_register_info hf[] = {
{ &hf_sml_esc,
{ "Escape", "sml.esc", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_version_1,
{ "Version 1", "sml.version_1", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_smlVersion,
{ "SML Version", "sml.version", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_crc16,
{ "CRC16", "sml.crc", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_crc16_status,
{ "CRC16 Status", "sml.crc.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0, NULL, HFILL }},
{ &hf_sml_endOfSmlMsg,
{ "End of SML Msg", "sml.end", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_transactionId,
{ "Transaction ID", "sml.transactionid", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_length,
{ "Length", "sml.length", FT_UINT32, BASE_CUSTOM, CF_FUNC(sml_fmt_length), 0x0, NULL, HFILL }},
{ &hf_sml_groupNo,
{ "GroupNo", "sml.groupno", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_datatype,
{ "Datatype", "sml.datatype", FT_UINT8, BASE_HEX, VALS (datatype), 0x0, NULL, HFILL }},
{ &hf_sml_abortOnError,
{ "Abort On Error", "sml.abort", FT_UINT8, BASE_HEX, VALS (sml_abort), 0x0, NULL, HFILL }},
{ &hf_sml_MessageBody,
{ "Messagebody", "sml.messagebody", FT_UINT16, BASE_HEX, VALS (sml_body), 0x0, NULL, HFILL }},
{ &hf_sml_end,
{ "End of Msg", "sml.end", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_codepage,
{ "Codepage", "sml.codepage", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_clientId,
{ "Client ID", "sml.clientid", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_reqFileId,
{ "reqFile ID", "sml.reqfileid", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_serverId,
{ "server ID", "sml.serverid", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_username,
{ "Username", "sml.username", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_password,
{ "Password", "sml.password", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_listName,
{ "List Name", "sml.listname", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_globalSignature,
{ "Global Signature", "sml.globalsignature", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_timetype,
{ "Time type", "sml.timetype", FT_UINT8, BASE_HEX, VALS (sml_timetypes), 0x0, NULL, HFILL }},
{ &hf_sml_objName,
{ "objName", "sml.objname", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_status,
{ "Status", "sml.status", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_unit,
{ "unit", "sml.unit", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_scaler,
{ "scaler", "sml.scaler", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_value,
{ "value", "sml.value", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_simplevalue,
{ "simplevalue", "sml.simplevalue", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sml_valueSignature,
{ "ValueSignature", "sml.valuesignature", FT_BYTES, BASE_NONE, NULL, 0x0,NULL, HFILL }},
{ &hf_sml_listSignature,
{ "ListSignature", "sml.listsignature", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_parameterTreePath,
{ "path_Entry", "sml.parametertreepath", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_attribute,
{ "attribute", "sml.attribute", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_parameterName,
{ "parameterName", "sml.parametername", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_procParValue,
{ "procParValue", "sml.procparvalue", FT_UINT8, BASE_HEX, VALS(procvalues), 0x0, NULL, HFILL }},
{ &hf_sml_padding,
{ "Padding", "sml.padding", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_secIndex,
{ "secIndex", "sml.secindex", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_timestamp,
{ "timestamp", "sml.timestamp", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_sml_localOffset,
{ "localOffset", "sml.localOffset", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_sml_seasonTimeOffset,
{ "seasonTimeOffset", "sml.seasonTimeOffset", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_sml_attentionNo,
{ "attentionNo", "sml.attentionno", FT_UINT16, BASE_HEX|BASE_RANGE_STRING, RVALS(attentionValues), 0x0, NULL, HFILL }},
{ &hf_sml_attentionMsg,
{ "attentionMsg", "sml.attentionmsg", FT_STRING, BASE_NONE, NULL, 0x0 , NULL, HFILL }},
{ &hf_sml_withRawdata,
{ "withRawdata", "sml.withrawdata", FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(bools), 0x0 , NULL, HFILL }},
{ &hf_sml_object_list_Entry,
{ "object_list_Entry", "sml.objectentry", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_regPeriod,
{ "regPeriod", "sml.regperiod", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_rawdata,
{ "rawdata", "sml.rawdata", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_periodSignature,
{ "periodSignature", "sml.periodsignature", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_profileSignature,
{ "profileSignature", "sml.profilesignature", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_signature_mA_R2_R3,
{ "signature_mA_R2_R3", "sml.signaturema", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_signature_pA_R1_R4,
{ "signature_pA_R1_R4", "sml.signaturepa", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_unit_mA,
{ "unit_mA", "sml.unitmA", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_unit_pA,
{ "unit_pA", "sml.unitpA", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_unit_R1,
{ "unit_R1", "sml.unitR1", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_unit_R2,
{ "unit_R2", "sml.unitR2", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_unit_R3,
{ "unit_R3", "sml.unitR3", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_unit_R4,
{ "unit_R4", "sml.unitR4", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_scaler_mA,
{ "scaler_mA", "sml.scalermA", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_scaler_pA,
{ "scaler_pA", "sml.scalerpA", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_scaler_R1,
{ "scaler_R1", "sml.scalerR1", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_scaler_R2,
{ "scaler_R2", "sml.scalerR2", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_scaler_R3,
{ "scaler_R3", "sml.scalerR3", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_scaler_R4,
{ "scaler_R4", "sml.scalerR4", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_value_mA,
{ "value_mA", "sml.valuemA", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_value_pA,
{ "value_pA", "sml.valuepA", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_value_R1,
{ "value_R1", "sml.valueR1", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_value_R2,
{ "value_R2", "sml.valueR2", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_value_R3,
{ "value_R3", "sml.valueR3", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_value_R4,
{ "value_R4", "sml.valueR4", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_file_marker,
{ "---SML-File---", "sml.file_marker", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_new_file_marker,
{ "---New SML File---", "sml.new_file_marker", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_listtype,
{ "listType", "sml.listtype", FT_UINT8, BASE_HEX, VALS(listtypevalues), 0x0, NULL, HFILL }},
{ &hf_sml_cosemvalue,
{ "cosemvalue", "sml.cosemvalue", FT_UINT8, BASE_HEX, VALS(cosemvaluevalues), 0x0, NULL, HFILL } },
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_sml,
&ett_sml_mainlist,
&ett_sml_version,
&ett_sml_sublist,
&ett_sml_trans,
&ett_sml_group,
&ett_sml_abort,
&ett_sml_body,
&ett_sml_mblist,
&ett_sml_mttree,
&ett_sml_clientId,
&ett_sml_codepage,
&ett_sml_reqFileId,
&ett_sml_serverId,
&ett_sml_username,
&ett_sml_password,
&ett_sml_smlVersion,
&ett_sml_crc16,
&ett_sml_listName,
&ett_sml_globalSignature,
&ett_sml_refTime,
&ett_sml_actSensorTime,
&ett_sml_timetype,
&ett_sml_time,
&ett_sml_valList,
&ett_sml_objName,
&ett_sml_listEntry,
&ett_sml_status,
&ett_sml_valTime,
&ett_sml_unit,
&ett_sml_scaler,
&ett_sml_value,
&ett_sml_simplevalue,
&ett_sml_valueSignature,
&ett_sml_valtree,
&ett_sml_listSignature,
&ett_sml_actGatewayTime,
&ett_sml_treepath,
&ett_sml_parameterTreePath,
&ett_sml_attribute,
&ett_sml_parameterTree,
&ett_sml_parameterName,
&ett_sml_child,
&ett_sml_periodEntry,
&ett_sml_procParValueTime,
&ett_sml_procParValuetype,
&ett_sml_procParValue,
&ett_sml_msgend,
&ett_sml_tuple,
&ett_sml_secIndex,
&ett_sml_timestamp,
&ett_sml_localTimestamp,
&ett_sml_localOffset,
&ett_sml_seasonTimeOffset,
&ett_sml_signature,
&ett_sml_attentionNo,
&ett_sml_attentionMsg,
&ett_sml_withRawdata,
&ett_sml_beginTime,
&ett_sml_endTime,
&ett_sml_object_list,
&ett_sml_object_list_Entry,
&ett_sml_actTime,
&ett_sml_regPeriod,
&ett_sml_rawdata,
&ett_sml_periodSignature,
&ett_sml_period_List_Entry,
&ett_sml_periodList,
&ett_sml_header_List_Entry,
&ett_sml_profileSignature,
&ett_sml_valuelist,
&ett_sml_headerList,
&ett_sml_value_List_Entry,
&ett_sml_signature_mA_R2_R3,
&ett_sml_signature_pA_R1_R4,
&ett_sml_unit_mA,
&ett_sml_scaler_mA,
&ett_sml_value_mA,
&ett_sml_unit_pA,
&ett_sml_scaler_pA,
&ett_sml_value_pA,
&ett_sml_unit_R1,
&ett_sml_scaler_R1,
&ett_sml_value_R1,
&ett_sml_unit_R2,
&ett_sml_scaler_R2,
&ett_sml_value_R2,
&ett_sml_unit_R3,
&ett_sml_scaler_R3,
&ett_sml_value_R3,
&ett_sml_unit_R4,
&ett_sml_scaler_R4,
&ett_sml_value_R4,
&ett_sml_tree_Entry,
&ett_sml_dasDetails,
&ett_sml_attentionDetails,
&ett_sml_listtypetype,
&ett_sml_listtype,
&ett_sml_timestampedvaluetype,
&ett_sml_timestampedvalue,
&ett_sml_cosemvaluetype,
&ett_sml_cosemvalue,
&ett_sml_scaler_unit
};
static ei_register_info ei[] = {
{ &ei_sml_tuple_error, { "sml.tuple_error_", PI_PROTOCOL, PI_ERROR, "error in Tuple", EXPFILL }},
{ &ei_sml_procParValue_invalid, { "sml.procparvalue.invalid", PI_PROTOCOL, PI_WARN, "invalid procParValue", EXPFILL }},
{ &ei_sml_procParValue_errror, { "sml.procparvalue.error", PI_PROTOCOL, PI_ERROR, "error in procParValue", EXPFILL }},
{ &ei_sml_invalid_count, { "sml.invalid_count", PI_PROTOCOL, PI_ERROR, "invalid loop count", EXPFILL }},
{ &ei_sml_segment_needed, { "sml.segment_needed", PI_REASSEMBLE, PI_NOTE, "probably segment needed", EXPFILL }},
{ &ei_sml_messagetype_unknown, { "sml.messagetype.unknown", PI_PROTOCOL, PI_ERROR, "unknown Messagetype", EXPFILL }},
{ &ei_sml_MessageBody, { "sml.messagebody.error", PI_PROTOCOL, PI_ERROR, "Error in MessageBody", EXPFILL }},
{ &ei_sml_crc_error_length, { "sml.crc.length_error", PI_PROTOCOL, PI_ERROR, "CRC length error", EXPFILL }},
{ &ei_sml_crc_error, { "sml.crc.error", PI_CHECKSUM, PI_WARN, "CRC error", EXPFILL }},
{ &ei_sml_endOfSmlMsg, { "sml.end.not_zero", PI_PROTOCOL, PI_ERROR, "MsgEnd not 0x00", EXPFILL }},
{ &ei_sml_esc_error, { "sml.esc.error", PI_PROTOCOL, PI_ERROR, "escapesequence error", EXPFILL }},
{ &ei_sml_version2_not_supported, { "sml.version2_not_supported", PI_UNDECODED, PI_WARN, "SML Version 2 not supported", EXPFILL }},
{ &ei_sml_attentionNo, { "sml.attentionno.unknown", PI_PROTOCOL, PI_WARN, "unknown attentionNo", EXPFILL }},
{ &ei_sml_listtype_invalid, { "sml.listtype.invalid", PI_PROTOCOL, PI_WARN, "invalid listtype", EXPFILL } },
{ &ei_sml_cosemvalue_invalid, { "sml.cosemvalue.invalid", PI_PROTOCOL, PI_WARN, "invalid cosemvalue", EXPFILL } },
};
proto_sml = proto_register_protocol("Smart Message Language","SML", "sml");
sml_module = prefs_register_protocol(proto_sml, NULL);
prefs_register_bool_preference (sml_module, "reassemble", "Enable reassemble", "Enable reassembling (default is enabled)", &sml_reassemble);
prefs_register_bool_preference (sml_module, "crc", "Enable crc calculation", "Enable crc (default is disabled)", &sml_crc_enabled);
proto_register_field_array(proto_sml, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_sml = expert_register_protocol(proto_sml);
expert_register_field_array(expert_sml, ei, array_length(ei));
}
void proto_reg_handoff_sml(void) {
dissector_handle_t sml_handle;
sml_handle = create_dissector_handle(dissect_sml, proto_sml);
dissector_add_for_decode_as_with_preference("tcp.port", sml_handle);
dissector_add_for_decode_as_with_preference("udp.port", sml_handle);
register_dissector("sml", dissect_sml, proto_sml);
}
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-smp.c
|
/* packet-smp.c
* Routines for Session Multiplex Protocol (SMP) dissection
* January 2017 Uli Heilmeier with the help of Michael Mann
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
* References:
*
* MC-SMP - https://docs.microsoft.com/en-us/openspecs/windows_protocols/mc-smp
* MS-TDS - https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-tds
* https://docs.microsoft.com/en-us/sql/relational-databases/native-client/features/using-multiple-active-result-sets-mars
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | SMID | FLAGS | SID |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | LENGTH |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | SEQNUM |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | WNDW |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | |
* / DATA (variable) /
* | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
#include <config.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/decode_as.h>
#include "packet-tcp.h"
void proto_reg_handoff_smp(void);
void proto_register_smp(void);
static int proto_smp = -1;
static int hf_smp_smid = -1;
static int hf_smp_flags = -1;
static int hf_smp_flags_syn = -1;
static int hf_smp_flags_ack = -1;
static int hf_smp_flags_fin = -1;
static int hf_smp_flags_data = -1;
static int hf_smp_sid = -1;
static int hf_smp_length = -1;
static int hf_smp_seqnum = -1;
static int hf_smp_wndw = -1;
static int hf_smp_data = -1;
static gint ett_smp = -1;
static gint ett_smp_flags = -1;
#define SMP_FLAGS_SYN 0x01
#define SMP_FLAGS_ACK 0x02
#define SMP_FLAGS_FIN 0x04
#define SMP_FLAGS_DATA 0x08
#define SMP_MIN_LENGTH 16
static dissector_handle_t tds_handle;
static dissector_table_t smp_payload_table;
static gboolean reassemble_smp = TRUE;
static void smp_prompt(packet_info *pinfo _U_, gchar* result)
{
snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Payload as");
}
/* Code to actually dissect the packets */
static int
dissect_smp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean tds_payload)
{
guint offset = 0;
guint remaining_bytes;
proto_item *ti;
proto_tree *smp_tree;
guint32 flags, sid, smp_length;
tvbuff_t* next_tvb;
int parsed_bytes;
static int * const flag_fields[] = {
&hf_smp_flags_syn,
&hf_smp_flags_ack,
&hf_smp_flags_fin,
&hf_smp_flags_data,
NULL
};
if (tvb_reported_length(tvb) < SMP_MIN_LENGTH)
return 0;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMP");
col_clear(pinfo->cinfo, COL_INFO);
ti = proto_tree_add_item(tree, proto_smp, tvb, 0, -1, ENC_NA);
smp_tree = proto_item_add_subtree(ti, ett_smp);
proto_tree_add_item(smp_tree, hf_smp_smid, tvb, offset, 1, ENC_NA);
offset+=1;
proto_tree_add_bitmask(smp_tree, tvb, offset, hf_smp_flags, ett_smp_flags, flag_fields, ENC_NA);
flags = tvb_get_guint8(tvb, offset);
offset += 1;
proto_tree_add_item_ret_uint(smp_tree, hf_smp_sid, tvb, offset, 2, ENC_LITTLE_ENDIAN, &sid);
col_append_fstr(pinfo->cinfo, COL_INFO, "SID: %u", sid);
offset += 2;
if (flags & SMP_FLAGS_SYN)
col_append_str(pinfo->cinfo, COL_INFO, ", Syn");
if (flags & SMP_FLAGS_ACK)
col_append_str(pinfo->cinfo, COL_INFO, ", Ack");
if (flags & SMP_FLAGS_FIN)
col_append_str(pinfo->cinfo, COL_INFO, ", Fin");
if (flags & SMP_FLAGS_DATA)
col_append_str(pinfo->cinfo, COL_INFO, ", Data");
proto_tree_add_item_ret_uint(smp_tree, hf_smp_length, tvb, offset, 4, ENC_LITTLE_ENDIAN, &smp_length);
offset += 4;
proto_tree_add_item(smp_tree, hf_smp_seqnum, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(smp_tree, hf_smp_wndw, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
if ((flags & SMP_FLAGS_DATA) && (tvb_reported_length(tvb) > SMP_MIN_LENGTH)) {
next_tvb = tvb_new_subset_remaining(tvb, offset);
if (tds_payload) {
parsed_bytes = call_dissector(tds_handle, next_tvb, pinfo, tree);
} else {
parsed_bytes = dissector_try_payload(smp_payload_table, next_tvb, pinfo, tree);
}
if (parsed_bytes <= 0)
{
remaining_bytes = tvb_reported_length_remaining(tvb, offset);
if ( remaining_bytes < (smp_length - SMP_MIN_LENGTH)) {
// Fragmented
proto_tree_add_item(smp_tree, hf_smp_data, tvb, offset, remaining_bytes, ENC_NA);
offset += remaining_bytes;
}
else {
proto_tree_add_item(smp_tree, hf_smp_data, tvb, offset, smp_length - SMP_MIN_LENGTH, ENC_NA);
offset += (smp_length - SMP_MIN_LENGTH);
}
}
else {
offset += parsed_bytes;
}
}
return offset;
}
static guint get_smp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
{
return tvb_get_letohl(tvb, offset + 4);
}
static int
dissect_smp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
return dissect_smp_common(tvb, pinfo, tree, FALSE);
}
static int dissect_smp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
if ((tvb_reported_length(tvb) > 0) && (tvb_get_guint8(tvb, 0) == 0x53)) {
tcp_dissect_pdus(tvb, pinfo, tree, reassemble_smp, SMP_MIN_LENGTH,
get_smp_pdu_len, dissect_smp_pdu, data);
return tvb_captured_length(tvb);
}
return 0;
}
static int
dissect_smp_tds(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
return dissect_smp_common(tvb, pinfo, tree, TRUE);
}
void
proto_register_smp(void)
{
static hf_register_info hf[] = {
{ &hf_smp_smid,
{ "Smid", "smp.smid", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }},
{ &hf_smp_flags,
{ "Flags", "smp.flags", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } },
{ &hf_smp_flags_syn,
{ "Syn", "smp.flags.syn", FT_BOOLEAN, 8, TFS(&tfs_set_notset), SMP_FLAGS_SYN, NULL, HFILL }},
{ &hf_smp_flags_ack,
{ "Ack", "smp.flags.ack", FT_BOOLEAN, 8, TFS(&tfs_set_notset), SMP_FLAGS_ACK, NULL, HFILL }},
{ &hf_smp_flags_fin,
{ "Fin", "smp.flags.fin", FT_BOOLEAN, 8, TFS(&tfs_set_notset), SMP_FLAGS_FIN, NULL, HFILL }},
{ &hf_smp_flags_data,
{ "Data", "smp.flags.data", FT_BOOLEAN, 8, TFS(&tfs_set_notset), SMP_FLAGS_DATA, NULL, HFILL }},
{ &hf_smp_sid,
{ "SID", "smp.sid", FT_UINT16, BASE_DEC, NULL, 0, "Session ID", HFILL }},
{ &hf_smp_length,
{ "Length", "smp.length", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }},
{ &hf_smp_seqnum,
{ "SeqNum", "smp.seqnum", FT_UINT32, BASE_HEX, NULL, 0, "Sequence Number", HFILL }},
{ &hf_smp_wndw,
{ "Wndw", "smp.wndw", FT_UINT32, BASE_HEX, NULL, 0, "Window Size", HFILL }},
{ &hf_smp_data,
{ "Data", "smp.data", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
};
static gint *ett[] = {
&ett_smp,
&ett_smp_flags,
};
module_t *smp_module;
proto_smp = proto_register_protocol("Session Multiplex Protocol", "SMP", "smp");
proto_register_field_array(proto_smp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_dissector("smp_tds", dissect_smp_tds, proto_smp);
smp_payload_table = register_decode_as_next_proto(proto_smp, "smp.payload", "SMP Payload", smp_prompt);
smp_module = prefs_register_protocol(proto_smp, NULL);
prefs_register_bool_preference(smp_module, "desegment",
"Reassemble SMP messages spanning multiple TCP segments",
"Whether the SMP dissector should reassemble messages spanning multiple TCP segments."
" To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
&reassemble_smp);
}
void
proto_reg_handoff_smp(void)
{
dissector_handle_t smp_handle;
smp_handle = create_dissector_handle(dissect_smp, proto_smp);
dissector_add_for_decode_as_with_preference("tcp.port", smp_handle);
tds_handle = find_dissector_add_dependency("tds", proto_smp);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-smpp.c
|
/* packet-smpp.c
* Routines for Short Message Peer to Peer dissection
* Copyright 2001, Tom Uijldert.
*
* Data Coding Scheme decoding for GSM (SMS and CBS),
* provided by Olivier Biot.
*
* Dissection of multiple SMPP PDUs within one packet
* provided by Chris Wilson.
*
* Statistics support using Stats Tree API
* provided by Abhik Sarkar
*
* Support for SMPP 5.0
* introduced by Abhik Sarkar
*
* Support for Huawei SMPP+ extensions
* introduced by Xu Bo and enhanced by Abhik Sarkar
*
* Enhanced error code handling
* provided by Stipe Tolj from Kannel.
*
* Refer to the AUTHORS file or the AUTHORS section in the man page
* for contacting the author(s) of this file.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* ----------
*
* Dissector of an SMPP (Short Message Peer to Peer) PDU, as defined by the
* SMS forum (www.smsforum.net) in "SMPP protocol specification v3.4"
* (document version: 12-Oct-1999 Issue 1.2)
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/expert.h>
#include <epan/exceptions.h>
#include <epan/stats_tree.h>
#include <epan/prefs.h>
#include <epan/exported_pdu.h>
#include <epan/conversation.h>
#include <epan/proto_data.h>
#include <wsutil/time_util.h>
#include "packet-tcp.h"
#include "packet-smpp.h"
#include <epan/strutil.h>
#define SMPP_FIXED_HEADER_LENGTH 16
#define SMPP_MIN_LENGTH SMPP_FIXED_HEADER_LENGTH
/* Forward declarations */
void proto_register_smpp(void);
void proto_reg_handoff_smpp(void);
static gint exported_pdu_tap = -1;
/*
* Initialize the protocol and registered fields
*
* Fixed header section
*/
static int proto_smpp = -1;
static int st_smpp_ops = -1;
static int st_smpp_req = -1;
static int st_smpp_res = -1;
static int st_smpp_res_status = -1;
static int hf_smpp_command_id = -1;
static int hf_smpp_command_request = -1;
static int hf_smpp_command_response = -1;
static int hf_smpp_command_length = -1;
static int hf_smpp_command_status = -1;
static int hf_smpp_sequence_number = -1;
/*
* Fixed body section
*/
static int hf_smpp_system_id = -1;
static int hf_smpp_password = -1;
static int hf_smpp_system_type = -1;
static int hf_smpp_interface_version = -1;
static int hf_smpp_addr_ton = -1;
static int hf_smpp_addr_npi = -1;
static int hf_smpp_address_range = -1;
static int hf_smpp_service_type = -1;
static int hf_smpp_source_addr_ton = -1;
static int hf_smpp_source_addr_npi = -1;
static int hf_smpp_source_addr = -1;
static int hf_smpp_dest_addr_ton = -1;
static int hf_smpp_dest_addr_npi = -1;
static int hf_smpp_destination_addr = -1;
static int hf_smpp_esm_submit_msg_mode = -1;
static int hf_smpp_esm_submit_msg_type = -1;
static int hf_smpp_esm_submit_features = -1;
static int hf_smpp_protocol_id = -1;
static int hf_smpp_priority_flag = -1;
static int hf_smpp_schedule_delivery_time = -1;
static int hf_smpp_schedule_delivery_time_r = -1;
static int hf_smpp_validity_period = -1;
static int hf_smpp_validity_period_r = -1;
static int hf_smpp_regdel_receipt = -1;
static int hf_smpp_regdel_acks = -1;
static int hf_smpp_regdel_notif = -1;
static int hf_smpp_replace_if_present_flag = -1;
static int hf_smpp_data_coding = -1;
static int hf_smpp_sm_default_msg_id = -1;
static int hf_smpp_sm_length = -1;
static int hf_smpp_short_message = -1;
static int hf_smpp_short_message_bin = -1;
static int hf_smpp_message_id = -1;
static int hf_smpp_dlist = -1;
static int hf_smpp_dlist_resp = -1;
static int hf_smpp_dl_name = -1;
static int hf_smpp_final_date = -1;
static int hf_smpp_final_date_r = -1;
static int hf_smpp_message_state = -1;
static int hf_smpp_error_code = -1;
static int hf_smpp_error_status_code = -1;
static int hf_smpp_esme_addr_ton = -1;
static int hf_smpp_esme_addr_npi = -1;
static int hf_smpp_esme_addr = -1;
/*
* Optional parameter section
*/
static int hf_smpp_opt_params = -1;
static int hf_smpp_opt_param = -1;
static int hf_smpp_opt_param_tag = -1;
static int hf_smpp_opt_param_len = -1;
static int hf_smpp_vendor_op = -1;
static int hf_smpp_reserved_op = -1;
static int hf_smpp_dest_addr_subunit = -1;
static int hf_smpp_dest_network_type = -1;
static int hf_smpp_dest_bearer_type = -1;
static int hf_smpp_dest_telematics_id = -1;
static int hf_smpp_source_addr_subunit = -1;
static int hf_smpp_source_network_type = -1;
static int hf_smpp_source_bearer_type = -1;
static int hf_smpp_source_telematics_id = -1;
static int hf_smpp_qos_time_to_live = -1;
static int hf_smpp_payload_type = -1;
static int hf_smpp_additional_status_info_text = -1;
static int hf_smpp_receipted_message_id = -1;
static int hf_smpp_msg_wait_ind = -1;
static int hf_smpp_msg_wait_type = -1;
static int hf_smpp_privacy_indicator = -1;
static int hf_smpp_source_subaddress = -1;
static int hf_smpp_dest_subaddress = -1;
static int hf_smpp_user_message_reference = -1;
static int hf_smpp_user_response_code = -1;
static int hf_smpp_source_port = -1;
static int hf_smpp_destination_port = -1;
static int hf_smpp_sar_msg_ref_num = -1;
static int hf_smpp_language_indicator = -1;
static int hf_smpp_sar_total_segments = -1;
static int hf_smpp_sar_segment_seqnum = -1;
static int hf_smpp_SC_interface_version = -1;
static int hf_smpp_callback_num_pres = -1;
static int hf_smpp_callback_num_scrn = -1;
static int hf_smpp_callback_num_atag = -1;
static int hf_smpp_number_of_messages = -1;
static int hf_smpp_callback_num = -1;
static int hf_smpp_dpf_result = -1;
static int hf_smpp_set_dpf = -1;
static int hf_smpp_ms_availability_status = -1;
static int hf_smpp_network_error_type = -1;
static int hf_smpp_network_error_code = -1;
static int hf_smpp_message_payload = -1;
static int hf_smpp_delivery_failure_reason = -1;
static int hf_smpp_more_messages_to_send = -1;
static int hf_smpp_ussd_service_op = -1;
static int hf_smpp_display_time = -1;
static int hf_smpp_sms_signal = -1;
static int hf_smpp_ms_validity = -1;
static int hf_smpp_alert_on_message_delivery_null = -1;
static int hf_smpp_alert_on_message_delivery_type = -1;
static int hf_smpp_its_reply_type = -1;
static int hf_smpp_its_session_number = -1;
static int hf_smpp_its_session_sequence = -1;
static int hf_smpp_its_session_ind = -1;
/* Optional Parameters introduced in SMPP 5.0 */
static int hf_smpp_congestion_state = -1;
static int hf_smpp_billing_identification = -1;
static int hf_smpp_dest_addr_np_country = -1;
static int hf_smpp_dest_addr_np_information = -1;
static int hf_smpp_dest_addr_np_resolution = -1;
static int hf_smpp_source_network_id = -1;
static int hf_smpp_source_node_id = -1;
static int hf_smpp_dest_network_id = -1;
static int hf_smpp_dest_node_id = -1;
/* Optional Parameters for Cell Broadcast Operations */
static int hf_smpp_broadcast_channel_indicator = -1;
static int hf_smpp_broadcast_content_type_nw = -1;
static int hf_smpp_broadcast_content_type_type = -1;
static int hf_smpp_broadcast_content_type_info = -1;
static int hf_smpp_broadcast_message_class = -1;
static int hf_smpp_broadcast_rep_num = -1;
static int hf_smpp_broadcast_frequency_interval_unit = -1;
static int hf_smpp_broadcast_frequency_interval_value = -1;
static int hf_smpp_broadcast_area_identifier = -1;
static int hf_smpp_broadcast_area_identifier_format = -1;
static int hf_smpp_broadcast_error_status = -1;
static int hf_smpp_broadcast_area_success = -1;
static int hf_smpp_broadcast_end_time = -1;
static int hf_smpp_broadcast_end_time_r = -1;
static int hf_smpp_broadcast_service_group = -1;
/*
* Data Coding Scheme section
*/
static int hf_smpp_dcs_sms_coding_group = -1;
static int hf_smpp_dcs_reserved = -1;
static int hf_smpp_dcs_charset = -1;
static int hf_smpp_dcs_class = -1;
static int hf_smpp_dcs_wait_ind = -1;
static int hf_smpp_dcs_reserved2 = -1;
static int hf_smpp_dcs_wait_type = -1;
/*
* Huawei SMPP+ extensions
*/
static int hf_huawei_smpp_smsc_addr = -1;
static int hf_huawei_smpp_msc_addr_noa = -1;
static int hf_huawei_smpp_msc_addr_npi = -1;
static int hf_huawei_smpp_msc_addr = -1;
static int hf_huawei_smpp_mo_mt_flag = -1;
static int hf_huawei_smpp_length_auth = -1;
static int hf_huawei_smpp_sm_id = -1;
static int hf_huawei_smpp_service_id = -1;
static int hf_huawei_smpp_operation_result = -1;
static int hf_huawei_smpp_notify_mode = -1;
static int hf_huawei_smpp_delivery_result = -1;
static expert_field ei_smpp_message_payload_duplicate = EI_INIT;
/* Initialize the subtree pointers */
static gint ett_smpp = -1;
static gint ett_dlist = -1;
static gint ett_dlist_resp = -1;
static gint ett_opt_params = -1;
static gint ett_opt_param = -1;
static gint ett_dcs = -1;
static dissector_handle_t smpp_handle;
/* Reassemble SMPP TCP segments */
static gboolean reassemble_over_tcp = TRUE;
static gboolean smpp_gsm7_unpacked = TRUE;
typedef enum {
DECODE_AS_DEFAULT = 0,
DECODE_AS_ASCII = 1,
DECODE_AS_OCTET = 2, /* 8-bit binary */
DECODE_AS_ISO_8859_1 = 3,
DECODE_AS_ISO_8859_5 = 6,
DECODE_AS_ISO_8859_8 = 7,
DECODE_AS_UCS2 = 8,
DECODE_AS_KSC5601 = 14, /* Korean, EUC-KR as in ANSI 637 */
DECODE_AS_GSM7 = 241, /* One of many GSM DCS values that means GSM7 */
} SMPP_DCS_Type;
/* ENC_NA is the same as ENC_ASCII, so use an artifical value to mean
* "treat this as 8-bit binary / FT_BYTES, not a string."
*/
#define DO_NOT_DECODE G_MAXUINT
/* Default preference whether to decode the SMS over SMPP when DCS = 0 */
static gint smpp_decode_dcs_0_sms = DO_NOT_DECODE;
/* Tap */
static int smpp_tap = -1;
#define SMPP_COMMAND_ID_GENERIC_NACK 0x00000000
#define SMPP_COMMAND_ID_BIND_RECEIVER 0x00000001
#define SMPP_COMMAND_ID_BIND_TRANSMITTER 0x00000002
#define SMPP_COMMAND_ID_QUERY_SM 0x00000003
#define SMPP_COMMAND_ID_SUBMIT_SM 0x00000004
#define SMPP_COMMAND_ID_DELIVER_SM 0x00000005
#define SMPP_COMMAND_ID_UNBIND 0x00000006
#define SMPP_COMMAND_ID_REPLACE_SM 0x00000007
#define SMPP_COMMAND_ID_CANCEL_SM 0x00000008
#define SMPP_COMMAND_ID_BIND_TRANSCEIVER 0x00000009
#define SMPP_COMMAND_ID_OUTBIND 0x0000000B
#define SMPP_COMMAND_ID_ENQUIRE_LINK 0x00000015
#define SMPP_COMMAND_ID_SUBMIT_MULTI 0x00000021
#define SMPP_COMMAND_ID_ALERT_NOTIFICATION 0x00000102
#define SMPP_COMMAND_ID_DATA_SM 0x00000103
/* Introduced in SMPP 5.0 */
#define SMPP_COMMAND_ID_BROADCAST_SM 0x00000111
#define SMPP_COMMAND_ID_QUERY_BROADCAST_SM 0x00000112
#define SMPP_COMMAND_ID_CANCEL_BROADCAST_SM 0x00000113
/* Huawei SMPP+ extensions */
#define SMPP_COMMAND_ID_HUAWEI_AUTH_ACC 0x01000001
#define SMPP_COMMAND_ID_HUAWEI_SM_RESULT_NOTIFY 0X01000002
#define SMPP_COMMAND_ID_RESPONSE_MASK 0x80000000
#define SMPP_UDHI_MASK 0x40
/*
* Value-arrays for field-contents
*/
static const value_string vals_command_id[] = { /* Operation */
{ SMPP_COMMAND_ID_BIND_RECEIVER, "Bind_receiver" },
{ SMPP_COMMAND_ID_BIND_TRANSMITTER, "Bind_transmitter" },
{ SMPP_COMMAND_ID_QUERY_SM, "Query_sm" },
{ SMPP_COMMAND_ID_SUBMIT_SM, "Submit_sm" },
{ SMPP_COMMAND_ID_DELIVER_SM, "Deliver_sm" },
{ SMPP_COMMAND_ID_UNBIND, "Unbind" },
{ SMPP_COMMAND_ID_REPLACE_SM, "Replace_sm" },
{ SMPP_COMMAND_ID_CANCEL_SM, "Cancel_sm" },
{ SMPP_COMMAND_ID_BIND_TRANSCEIVER, "Bind_transceiver" },
{ SMPP_COMMAND_ID_OUTBIND, "Outbind" },
{ SMPP_COMMAND_ID_ENQUIRE_LINK, "Enquire_link" },
{ SMPP_COMMAND_ID_SUBMIT_MULTI, "Submit_multi" },
{ SMPP_COMMAND_ID_ALERT_NOTIFICATION, "Alert_notification" },
{ SMPP_COMMAND_ID_DATA_SM, "Data_sm" },
{ SMPP_COMMAND_ID_BROADCAST_SM, "Broadcast_sm" },
{ SMPP_COMMAND_ID_QUERY_BROADCAST_SM, "Query_broadcast_sm" },
{ SMPP_COMMAND_ID_CANCEL_BROADCAST_SM, "Cancel_broadcast_sm" },
{ SMPP_COMMAND_ID_HUAWEI_AUTH_ACC, "Auth_acc" },
{ SMPP_COMMAND_ID_HUAWEI_SM_RESULT_NOTIFY, "Sm_result_notify" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_GENERIC_NACK, "Generic_nack" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_BIND_RECEIVER, "Bind_receiver - resp" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_BIND_TRANSMITTER, "Bind_transmitter - resp" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_QUERY_SM, "Query_sm - resp" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_SUBMIT_SM, "Submit_sm - resp" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_DELIVER_SM, "Deliver_sm - resp" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_UNBIND, "Unbind - resp" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_REPLACE_SM, "Replace_sm - resp" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_CANCEL_SM, "Cancel_sm - resp" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_BIND_TRANSCEIVER, "Bind_transceiver - resp" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_ENQUIRE_LINK, "Enquire_link - resp" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_SUBMIT_MULTI, "Submit_multi - resp" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_DATA_SM, "Data_sm - resp" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_BROADCAST_SM, "Broadcast_sm - resp" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_QUERY_BROADCAST_SM, "Query_broadcast_sm - resp" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_CANCEL_BROADCAST_SM, "Cancel_broadcast_sm - resp" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_HUAWEI_AUTH_ACC, "Auth_acc - resp" },
{ SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_HUAWEI_SM_RESULT_NOTIFY, "Sm_result_notify - resp" },
{ 0, NULL }
};
static const range_string rvals_command_status[] = { /* Status */
{ 0x00000000, 0x00000000, "Ok" },
{ 0x00000001, 0x00000001, "Message length is invalid" },
{ 0x00000002, 0x00000002, "Command length is invalid" },
{ 0x00000003, 0x00000003, "Invalid command ID" },
{ 0x00000004, 0x00000004, "Incorrect BIND status for given command" },
{ 0x00000005, 0x00000005, "ESME already in bound state" },
{ 0x00000006, 0x00000006, "Invalid priority flag" },
{ 0x00000007, 0x00000007, "Invalid registered delivery flag" },
{ 0x00000008, 0x00000008, "System error" },
{ 0x00000009, 0x00000009, "[Reserved]" },
{ 0x0000000A, 0x0000000A, "Invalid source address" },
{ 0x0000000B, 0x0000000B, "Invalid destination address" },
{ 0x0000000C, 0x0000000C, "Message ID is invalid" },
{ 0x0000000D, 0x0000000D, "Bind failed" },
{ 0x0000000E, 0x0000000E, "Invalid password" },
{ 0x0000000F, 0x0000000F, "Invalid system ID" },
{ 0x00000010, 0x00000010, "[Reserved]" },
{ 0x00000011, 0x00000011, "Cancel SM failed" },
{ 0x00000012, 0x00000012, "[Reserved]" },
{ 0x00000013, 0x00000013, "Replace SM failed" },
{ 0x00000014, 0x00000014, "Message queue full" },
{ 0x00000015, 0x00000015, "Invalid service type" },
{ 0x00000016, 0x00000032, "[Reserved]" },
{ 0x00000033, 0x00000033, "Invalid number of destinations" },
{ 0x00000034, 0x00000034, "Invalid distribution list name" },
{ 0x00000035, 0x0000003F, "[Reserved]" },
{ 0x00000040, 0x00000040, "Destination flag is invalid (submit_multi)" },
{ 0x00000041, 0x00000041, "[Reserved]" },
{ 0x00000042, 0x00000042, "Invalid 'submit with replace' request" },
{ 0x00000043, 0x00000043, "Invalid esm_class field data" },
{ 0x00000044, 0x00000044, "Cannot submit to distribution list" },
{ 0x00000045, 0x00000045, "submit_sm or submit_multi failed" },
{ 0x00000046, 0x00000047, "[Reserved]" },
{ 0x00000048, 0x00000048, "Invalid source address TON" },
{ 0x00000049, 0x00000049, "Invalid source address NPI" },
{ 0x00000050, 0x00000050, "Invalid destination address TON" },
{ 0x00000051, 0x00000051, "Invalid destination address NPI" },
{ 0x00000052, 0x00000052, "[Reserved]" },
{ 0x00000053, 0x00000053, "Invalid system_type field" },
{ 0x00000054, 0x00000054, "Invalid replace_if_present flag" },
{ 0x00000055, 0x00000055, "Invalid number of messages" },
{ 0x00000056, 0x00000057, "[Reserved]" },
{ 0x00000058, 0x00000058, "Throttling error (ESME exceeded allowed message limits)" },
{ 0x00000059, 0x00000060, "[Reserved]" },
{ 0x00000061, 0x00000061, "Invalid scheduled delivery time" },
{ 0x00000062, 0x00000062, "Invalid message validity period (expiry time)" },
{ 0x00000063, 0x00000063, "Predefined message invalid or not found" },
{ 0x00000064, 0x00000064, "ESME receiver temporary app error code" },
{ 0x00000065, 0x00000065, "ESME receiver permanent app error code" },
{ 0x00000066, 0x00000066, "ESME receiver reject message error code" },
{ 0x00000067, 0x00000067, "query_sm request failed" },
{ 0x00000068, 0x000000BF, "[Reserved]" },
{ 0x000000C0, 0x000000C0, "Error in the optional part of the PDU body" },
{ 0x000000C1, 0x000000C1, "Optional parameter not allowed" },
{ 0x000000C2, 0x000000C2, "Invalid parameter length" },
{ 0x000000C3, 0x000000C3, "Expected optional parameter missing" },
{ 0x000000C4, 0x000000C4, "Invalid optional parameter value" },
{ 0x000000C5, 0x000000FD, "[Reserved]" },
{ 0x000000FE, 0x000000FE, "(Transaction) Delivery failure (used for data_sm_resp)" },
{ 0x000000FF, 0x000000FF, "Unknown error" },
/* Introduced in SMPP 5.0 */
{ 0x00000100, 0x00000100, "ESME Not authorised to use specified service_type." },
{ 0x00000101, 0x00000101, "ESME Prohibited from using specified operation."},
{ 0x00000102, 0x00000102, "Specified service_type is unavailable." },
{ 0x00000103, 0x00000103, "Specified service_type is denied." },
{ 0x00000104, 0x00000104, "Invalid Data Coding Scheme." },
{ 0x00000105, 0x00000105, "Source Address Sub unit is Invalid." },
{ 0x00000106, 0x00000106, "Destination Address Sub unit is Invalid." },
{ 0x00000107, 0x00000107, "Broadcast Frequency Interval is invalid." },
{ 0x00000108, 0x00000108, "Broadcast Alias Name is invalid." },
{ 0x00000109, 0x00000109, "Broadcast Area Format is invalid." },
{ 0x0000010A, 0x0000010A, "Number of Broadcast Areas is invalid." },
{ 0x0000010B, 0x0000010B, "Broadcast Content Type is invalid." },
{ 0x0000010C, 0x0000010C, "Broadcast Message Class is invalid." },
{ 0x0000010D, 0x0000010D, "broadcast_sm operation failed." },
{ 0x0000010E, 0x0000010E, "query_broadcast_sm operation failed." },
{ 0x0000010F, 0x0000010F, "cancel_broadcast_sm operation failed." },
{ 0x00000110, 0x00000110, "Number of Repeated Broadcasts is invalid." },
{ 0x00000111, 0x00000111, "Broadcast Service Group is invalid." },
{ 0x00000112, 0x00000112, "Broadcast Channel Indicator is invalid." },
{ 0x00000400, 0x000004FF, "[Vendor-specific Error]" },
{ 0x00000500, 0xFFFFFFFF, "[Reserved]" },
{ 0, 0, NULL }
};
static const value_string vals_tlv_tags[] = {
{ 0x0005, "dest_addr_subunit" },
{ 0x0006, "dest_network_type" },
{ 0x0007, "dest_bearer_type" },
{ 0x0008, "dest_telematics_id" },
{ 0x000D, "source_addr_subunit" },
{ 0x000E, "source_network_type" },
{ 0x000F, "source_bearer_type" },
{ 0x0010, "source_telematics_id" },
{ 0x0017, "qos_time_to_live" },
{ 0x0019, "payload_type" },
{ 0x001D, "additional_status_info_text" },
{ 0x001E, "receipted_message_id" },
{ 0x0030, "ms_msg_wait_facilities" },
{ 0x0201, "privacy_indicator" },
{ 0x0202, "source_subaddress" },
{ 0x0203, "dest_subaddress" },
{ 0x0204, "user_message_reference" },
{ 0x0205, "user_response_code" },
{ 0x020A, "source_port" },
{ 0x020B, "dest_port" },
{ 0x020C, "sar_msg_ref_num" },
{ 0x020D, "language_indicator" },
{ 0x020E, "sar_total_segments" },
{ 0x020F, "sar_segment_seqnum" },
{ 0x0210, "sc_interface_version" },
{ 0x0302, "callback_num_pres_ind" },
{ 0x0303, "callback_num_atag" },
{ 0x0304, "number_of_messages" },
{ 0x0381, "callback_num" },
{ 0x0420, "dpf_result" },
{ 0x0421, "set_dpf" },
{ 0x0422, "ms_availability_status" },
{ 0x0423, "network_error_code" },
{ 0x0424, "message_payload" },
{ 0x0425, "delivery_failure_reason" },
{ 0x0426, "more_messages_to_send" },
{ 0x0427, "message_state" },
{ 0x0428, "congestion_state" },
{ 0x0501, "ussd_service_op" },
{ 0x0600, "broadcast_channel_indicator" },
{ 0x0601, "broadcast_content_type" },
{ 0x0602, "broadcast_content_type_info" },
{ 0x0603, "broadcast_message_class" },
{ 0x0604, "broadcast_rep_num" },
{ 0x0605, "broadcast_frequency_interval" },
{ 0x0606, "broadcast_area_identifier" },
{ 0x0607, "broadcast_error_status" },
{ 0x0608, "broadcast_area_success" },
{ 0x0609, "broadcast_end_time" },
{ 0x060A, "broadcast_service_group" },
{ 0x060B, "billing_identification" },
{ 0x060D, "source_network_id" },
{ 0x060E, "dest_network_id" },
{ 0x060F, "source_node_id" },
{ 0x0610, "dest_node_id" },
{ 0x0611, "dest_addr_np_resolution" },
{ 0x0612, "dest_addr_np_information" },
{ 0x0613, "dest_addr_np_country" },
{ 0x1201, "display_time" },
{ 0x1203, "sms_signal" },
{ 0x1204, "ms_validity" },
{ 0x130C, "alert_on_message_delivery" },
{ 0x1380, "its_reply_type" },
{ 0x1383, "its_session_info" },
{ 0, NULL }
};
static const value_string vals_addr_ton[] = {
{ 0, "Unknown" },
{ 1, "International" },
{ 2, "National" },
{ 3, "Network specific" },
{ 4, "Subscriber number" },
{ 5, "Alphanumeric" },
{ 6, "Abbreviated" },
{ 0, NULL }
};
static const value_string vals_addr_npi[] = {
{ 0, "Unknown" },
{ 1, "ISDN (E163/E164)" },
{ 3, "Data (X.121)" },
{ 4, "Telex (F.69)" },
{ 6, "Land mobile (E.212)" },
{ 8, "National" },
{ 9, "Private" },
{ 10, "ERMES" },
{ 14, "Internet (IP)" },
{ 18, "WAP client Id" },
{ 0, NULL }
};
static const value_string vals_esm_submit_msg_mode[] = {
{ 0x0, "Default SMSC mode" },
{ 0x1, "Datagram mode" },
{ 0x2, "Forward mode" },
{ 0x3, "Store and forward mode" },
{ 0, NULL }
};
static const value_string vals_esm_submit_msg_type[] = {
{ 0x0, "Default message type" },
{ 0x1, "Short message contains SMSC Delivery Receipt" },
{ 0x2, "Short message contains (E)SME delivery acknowledgement" },
{ 0x3, "Reserved" },
{ 0x4, "Short message contains (E)SME manual/user acknowledgement" },
{ 0x5, "Reserved" },
{ 0x6, "Short message contains conversation abort" },
{ 0x7, "Reserved" },
{ 0x8, "Short message contains intermediate delivery notification" },
{ 0, NULL }
};
static const value_string vals_esm_submit_features[] = {
{ 0x0, "No specific features selected" },
{ 0x1, "UDHI indicator" },
{ 0x2, "Reply path" },
{ 0x3, "UDHI and reply path" },
{ 0, NULL }
};
static const value_string vals_priority_flag[] = {
{ 0, "GSM: None ANSI-136: Bulk IS-95: Normal" },
{ 1, "GSM: priority ANSI-136: Normal IS-95: Interactive" },
{ 2, "GSM: priority ANSI-136: Urgent IS-95: Urgent" },
{ 3, "GSM: priority ANSI-136: Very Urgent IS-95: Emergency" },
{ 0, NULL }
};
static const value_string vals_regdel_receipt[] = {
{ 0x0, "No SMSC delivery receipt requested" },
{ 0x1, "Delivery receipt requested (for success or failure)" },
{ 0x2, "Delivery receipt requested (for failure)" },
{ 0x3, "Reserved in version <= 3.4; Delivery receipt requested (for success) in 5.0" },
{ 0, NULL }
};
static const value_string vals_regdel_acks[] = {
{ 0x0, "No recipient SME acknowledgement requested" },
{ 0x1, "SME delivery acknowledgement requested" },
{ 0x2, "SME manual/user acknowledgement requested" },
{ 0x3, "Both delivery and manual/user acknowledgement requested" },
{ 0, NULL }
};
static const value_string vals_regdel_notif[] = {
{ 0x0, "No intermediate notification requested" },
{ 0x1, "Intermediate notification requested" },
{ 0, NULL }
};
static const value_string vals_replace_if_present_flag[] = {
{ 0x0, "Don't replace" },
{ 0x1, "Replace" },
{ 0, NULL }
};
static const range_string rvals_data_coding[] = {
{ 0, 0, "SMSC default alphabet" },
{ 1, 1, "IA5 (CCITT T.50)/ASCII (ANSI X3.4)" },
{ 2, 2, "Octet unspecified (8-bit binary)" },
{ 3, 3, "Latin 1 (ISO-8859-1)" },
{ 4, 4, "Octet unspecified (8-bit binary)" },
{ 5, 5, "JIS (X 0208-1990)" },
{ 6, 6, "Cyrillic (ISO-8859-5)" },
{ 7, 7, "Latin/Hebrew (ISO-8859-8)" },
{ 8, 8, "UCS2 (ISO/IEC-10646)" },
{ 9, 9, "Pictogram Encoding" },
{ 10, 10, "ISO-2022-JP (Music codes)" },
{ 11, 12, "Reserved" },
{ 13, 13, "Extended Kanji JIS (X 0212-1990)" },
{ 14, 14, "KS C 5601" },
{ 15, 0xBF, "Reserved" },
{ 0xC0, 0xEF, "GSM MWI control - see [GSM 03.38]" },
{ 0xF0, 0xFF, "GSM message class control - see [GSM 03.38]" },
{ 0, 0, NULL }
};
static const value_string vals_message_state[] = {
{ 1, "ENROUTE" },
{ 2, "DELIVERED" },
{ 3, "EXPIRED" },
{ 4, "DELETED" },
{ 5, "UNDELIVERABLE" },
{ 6, "ACCEPTED" },
{ 7, "UNKNOWN" },
{ 8, "REJECTED" },
{ 0, NULL }
};
static const value_string vals_addr_subunit[] = {
{ 0, "Unknown -default-" },
{ 1, "MS Display" },
{ 2, "Mobile equipment" },
{ 3, "Smart card 1" },
{ 4, "External unit 1" },
{ 0, NULL }
};
static const value_string vals_network_type[] = {
{ 0, "Unknown" },
{ 1, "GSM" },
{ 2, "ANSI-136/TDMA" },
{ 3, "IS-95/CDMA" },
{ 4, "PDC" },
{ 5, "PHS" },
{ 6, "iDEN" },
{ 7, "AMPS" },
{ 8, "Paging network" },
{ 0, NULL }
};
static const value_string vals_bearer_type[] = {
{ 0, "Unknown" },
{ 1, "SMS" },
{ 2, "Circuit Switched Data (CSD)" },
{ 3, "Packet data" },
{ 4, "USSD" },
{ 5, "CDPD" },
{ 6, "DataTAC" },
{ 7, "FLEX/ReFLEX" },
{ 8, "Cell Broadcast" },
{ 0, NULL }
};
static const value_string vals_payload_type[] = {
{ 0, "Default" },
{ 1, "WCMP message" },
{ 0, NULL }
};
static const value_string vals_privacy_indicator[] = {
{ 0, "Not restricted -default-" },
{ 1, "Restricted" },
{ 2, "Confidential" },
{ 3, "Secret" },
{ 0, NULL }
};
static const value_string vals_language_indicator[] = {
{ 0, "Unspecified -default-" },
{ 1, "english" },
{ 2, "french" },
{ 3, "spanish" },
{ 4, "german" },
{ 5, "portuguese" },
{ 0, NULL }
};
static const value_string vals_display_time[] = {
{ 0, "Temporary" },
{ 1, "Default -default-" },
{ 2, "Invoke" },
{ 0, NULL }
};
static const value_string vals_ms_validity[] = {
{ 0, "Store indefinitely -default-" },
{ 1, "Power down" },
{ 2, "SID based registration area" },
{ 3, "Display only" },
{ 0, NULL }
};
static const value_string vals_dpf_result[] = {
{ 0, "DPF not set" },
{ 1, "DPF set" },
{ 0, NULL }
};
static const value_string vals_set_dpf[] = {
{ 0, "Not requested (Set DPF for delivery failure)" },
{ 1, "Requested (Set DPF for delivery failure)" },
{ 0, NULL }
};
static const value_string vals_ms_availability_status[] = {
{ 0, "Available -default-" },
{ 1, "Denied" },
{ 2, "Unavailable" },
{ 0, NULL }
};
static const value_string vals_delivery_failure_reason[] = {
{ 0, "Destination unavailable" },
{ 1, "Destination address invalid" },
{ 2, "Permanent network error" },
{ 3, "Temporary network error" },
{ 0, NULL }
};
static const value_string vals_more_messages_to_send[] = {
{ 0, "No more messages" },
{ 1, "More messages -default-" },
{ 0, NULL }
};
static const value_string vals_its_reply_type[] = {
{ 0, "Digit" },
{ 1, "Number" },
{ 2, "Telephone no." },
{ 3, "Password" },
{ 4, "Character line" },
{ 5, "Menu" },
{ 6, "Date" },
{ 7, "Time" },
{ 8, "Continue" },
{ 0, NULL }
};
static const value_string vals_ussd_service_op[] = {
{ 0, "PSSD indication" },
{ 1, "PSSR indication" },
{ 2, "USSR request" },
{ 3, "USSN request" },
{ 16, "PSSD response" },
{ 17, "PSSR response" },
{ 18, "USSR confirm" },
{ 19, "USSN confirm" },
{ 0, NULL }
};
static const value_string vals_msg_wait_ind[] = {
{ 0, "Set indication inactive" },
{ 1, "Set indication active" },
{ 0, NULL }
};
static const value_string vals_msg_wait_type[] = {
{ 0, "Voicemail message waiting" },
{ 1, "Fax message waiting" },
{ 2, "Electronic mail message waiting" },
{ 3, "Other message waiting" },
{ 0, NULL }
};
static const value_string vals_callback_num_pres[] = {
{ 0, "Presentation allowed" },
{ 1, "Presentation restricted" },
{ 2, "Number not available" },
{ 3, "[Reserved]" },
{ 0, NULL }
};
static const value_string vals_callback_num_scrn[] = {
{ 0, "User provided, not screened" },
{ 1, "User provided, verified and passed" },
{ 2, "User provided, verified and failed" },
{ 3, "Network provided" },
{ 0, NULL }
};
static const value_string vals_network_error_type[] = {
{ 1, "ANSI-136 (Access Denied Reason)" },
{ 2, "IS-95 (Access Denied Reason)" },
{ 3, "GSM" },
{ 4, "[Reserved] in <= 3.4; ANSI 136 Cause Code in 5.0" },
{ 5, "[Reserved] in <= 3.4; IS 95 Cause Code in 5.0" },
{ 6, "[Reserved] in <= 3.4; ANSI-41 Error in 5.0" },
{ 7, "[Reserved] in <= 3.4; SMPP Error in 5.0" },
{ 8, "[Reserved] in <= 3.4; Message Center Specific in 5.0" },
{ 0, NULL }
};
static const value_string vals_its_session_ind[] = {
{ 0, "End of session indicator inactive" },
{ 1, "End of session indicator active" },
{ 0, NULL }
};
/* Data Coding Scheme: see 3GPP TS 23.040 and 3GPP TS 23.038.
* Note values below 0x0C are not used in SMPP. */
static const value_string vals_dcs_sms_coding_group[] = {
#if 0
{ 0x00, "SMS DCS: General Data Coding indication - Uncompressed text, no message class" },
{ 0x01, "SMS DCS: General Data Coding indication - Uncompressed text" },
{ 0x02, "SMS DCS: General Data Coding indication - Compressed text, no message class" },
{ 0x03, "SMS DCS: General Data Coding indication - Compressed text" },
{ 0x04, "SMS DCS: Message Marked for Automatic Deletion - Uncompressed text, no message class" },
{ 0x05, "SMS DCS: Message Marked for Automatic Deletion - Uncompressed text" },
{ 0x06, "SMS DCS: Message Marked for Automatic Deletion - Compressed text, no message class" },
{ 0x07, "SMS DCS: Message Marked for Automatic Deletion - Compressed text" },
{ 0x08, "SMS DCS: Reserved" },
{ 0x09, "SMS DCS: Reserved" },
{ 0x0A, "SMS DCS: Reserved" },
{ 0x0B, "SMS DCS: Reserved" },
#endif
{ 0x0C, "SMS DCS: Message Waiting Indication - Discard Message" },
{ 0x0D, "SMS DCS: Message Waiting Indication - Store Message (GSM 7-bit default alphabet)" },
{ 0x0E, "SMS DCS: Message Waiting Indication - Store Message (UCS-2 character set)" },
{ 0x0F, "SMS DCS: Data coding / message class" },
{ 0x00, NULL }
};
static const value_string vals_dcs_charset[] = {
{ 0x00, "GSM 7-bit default alphabet" },
{ 0x01, "8-bit data" },
{ 0x00, NULL }
};
static const value_string vals_dcs_class[] = {
{ 0x00, "Class 0" },
{ 0x01, "Class 1 - ME specific" },
{ 0x02, "Class 2 - (U)SIM specific" },
{ 0x03, "Class 3 - TE specific" },
{ 0x00, NULL }
};
static const value_string vals_alert_on_message_delivery[] = {
{ 0x00, "Use mobile default alert (Default)" },
{ 0x01, "Use low-priority alert" },
{ 0x02, "Use medium-priority alert" },
{ 0x03, "Use high-priority alert" },
{ 0x00, NULL }
};
static const range_string vals_congestion_state[] = {
{0, 0, "Idle"},
{1, 29, "Low Load"},
{30, 49, "Medium Load"},
{50, 79, "High Load"},
{80, 89, "Optimum Load"}, /*Specs says 80-90, but that is probably a mistake */
{90, 99, "Nearing Congestion"},
{100, 100, "Congested / Maximum Load"},
{ 0, 0, NULL }
};
static const range_string vals_broadcast_channel_indicator[] = {
{0, 0, "Basic Broadcast Channel (Default)"},
{1, 1, "Extended Broadcast Channel"},
{2, 255, "[Reserved]"},
{ 0, 0, NULL }
};
static const value_string vals_broadcast_message_class[] = {
{0, "No Class Specified (default)"},
{1, "Class 1 (User Defined)"},
{2, "Class 2 (User Defined)"},
{3, "Class 3 (Terminal Equipment)"},
{0, NULL }
};
static const range_string vals_broadcast_area_success[] = {
{0, 100, "%"},
{101, 254, "[Reserved]"},
{255, 255, "Information not available"},
{ 0, 0, NULL }
};
static const value_string vals_broadcast_content_type_nw[] = {
{0, "Generic"},
{1, "GSM [23041]"},
{2, "TDMA [IS824][ANSI-41]"},
{3, "CDMA [IS824][IS637]"},
{0, NULL }
};
static const value_string vals_broadcast_content_type_type[] = {
{0x0000, "[System Service] Index"},
{0x0001, "[System Service] Emergency Broadcasts"},
{0x0002, "[System Service] IRDB Download"},
{0x0010, "[News Service] News Flashes"},
{0x0011, "[News Service] General News (Local)"},
{0x0012, "[News Service] General News (Regional)"},
{0x0013, "[News Service] General News (National)"},
{0x0014, "[News Service] General News (International)"},
{0x0015, "[News Service] Business/Financial News (Local)"},
{0x0016, "[News Service] Business/Financial News (Regional)"},
{0x0017, "[News Service] Business/Financial News (National)"},
{0x0018, "[News Service] Business/Financial News (International)"},
{0x0019, "[News Service] Sports News (Local)"},
{0x001A, "[News Service] Sports News (Regional)"},
{0x001B, "[News Service] Sports News (National)"},
{0x001C, "[News Service] Sports News (International)"},
{0x001D, "[News Service] Entertainment News (Local)"},
{0x001E, "[News Service] Entertainment News (Regional)"},
{0x001F, "[News Service] Entertainment News (National)"},
{0x0020, "[News Service] Entertainment News (International)"},
{0x0021, "[Subscriber Information Services] Medical/Health/Hospitals"},
{0x0022, "[Subscriber Information Services] Doctors"},
{0x0023, "[Subscriber Information Services] Pharmacy"},
{0x0030, "[Subscriber Information Services] Local Traffic/Road Reports"},
{0x0031, "[Subscriber Information Services] Long Distance Traffic/Road Reports"},
{0x0032, "[Subscriber Information Services] Taxis"},
{0x0033, "[Subscriber Information Services] Weather"},
{0x0034, "[Subscriber Information Services] Local Airport Flight Schedules"},
{0x0035, "[Subscriber Information Services] Restaurants"},
{0x0036, "[Subscriber Information Services] Lodgings"},
{0x0037, "[Subscriber Information Services] Retail Directory"},
{0x0038, "[Subscriber Information Services] Advertisements"},
{0x0039, "[Subscriber Information Services] Stock Quotes"},
{0x0040, "[Subscriber Information Services] Employment Opportunities"},
{0x0041, "[Subscriber Information Services] Technology News"},
{0x0070, "[Carrier Information Services] District (Base Station Info)"},
{0x0071, "[Carrier Information Services] Network Information"},
{0x0080, "[Subscriber Care Services] Operator Services"},
{0x0081, "[Subscriber Care Services] Directory Enquiries (National)"},
{0x0082, "[Subscriber Care Services] Directory Enquiries (International)"},
{0x0083, "[Subscriber Care Services] Customer Care (National)"},
{0x0084, "[Subscriber Care Services] Customer Care (International)"},
{0x0085, "[Subscriber Care Services] Local Date/Time/Time Zone"},
{0x0100, "[Multi Category Services] Multi Category Services"},
{0x0000, NULL }
};
static const value_string vals_broadcast_frequency_interval_unit[] = {
{0x00, "As frequently as possible"},
{0x08, "seconds"},
{0x09, "minutes"},
{0x0A, "hours"},
{0x0B, "days"},
{0x0C, "weeks"},
{0x0D, "months"},
{0x0E, "years"},
{0x00, NULL }
};
static const value_string vals_dest_addr_np_resolution[] = {
{0x00, "query has not been performed (default)"},
{0x01, "query has been performed, number not ported"},
{0x02, "query has been performed, number ported"},
{0x00, NULL }
};
static const range_string vals_broadcast_area_identifier_format[] = {
{0, 0, "Alias / Name"},
{1, 1, "Ellipsoid Arc"},
{2, 2, "Polygon"},
{3, 255, "[Reserved]"},
{0, 0, NULL }
};
/* Huawei SMPP+ extensions */
static const value_string vals_mo_mt_flag[] = {
{ 0x01, "MO" },
{ 0x02, "MT" },
{ 0x03, "Reserved" },
{ 0x00, NULL }
};
static const value_string vals_operation_result[] = {
{ 0x00, "Successful" },
{ 0x01, "Protocol is not supported" },
{ 0x0a, "Others" },
{ 0x0b, "MO account does not exist" },
{ 0x0c, "MT account does not exist" },
{ 0x0d, "MO account state is abnormal" },
{ 0x0e, "MT account state is abnormal" },
{ 0x0f, "MO account balance is not enough" },
{ 0x10, "MT account balance is not enough" },
{ 0x11, "MO VAS is not supported" },
{ 0x12, "MT VAS is not supported" },
{ 0x13, "MO user is post-paid user and checked success" },
{ 0x14, "MT user is post-paid user and checked success" },
{ 0x15, "MO post-paid user status is incorrect" },
{ 0x16, "MT post-paid user status is incorrect" },
{ 0x17, "MO post-paid user account balance is not sufficient" },
{ 0x18, "MT post-paid user account balance is not sufficient" },
{ 0x19, "MO post-paid user value-added services are not supported" },
{ 0x1a, "MT post-paid user value-added services are not supported" },
{ 0x00, NULL }
};
static const value_string vals_notify_mode[] = {
{ 0x01, "Deliver the report when it's successful or failed" },
{ 0x02, "Deliver the report only when it's failed" },
{ 0x03, "Deliver the report only when it's successful" },
{ 0x04, "Never deliver the report" },
{ 0x00, NULL }
};
static const value_string vals_delivery_result[] = {
{ 0x00, "Successful" },
{ 0x01, "Unsuccessful" },
{ 0x00, NULL }
};
static const value_string vals_msc_addr_noa [] = {
{ 0x00, "Spare" },
{ 0x01, "Subscriber number" },
{ 0x02, "Unknown" },
{ 0x03, "National number" },
{ 0x04, "International" },
{ 0x00, NULL }
};
static const value_string vals_msc_addr_npi [] = {
{ 0x00, "Spare" },
{ 0x01, "ISDN (Telephony) numbering plan (Recommendation E.164)" },
{ 0x02, "Spare" },
{ 0x03, "Data numbering plan (Recommendation X.121) (national use)" },
{ 0x04, "Telex numbering plan (Recommendation F.69) (national use)" },
{ 0x05, "Reserved for national use" },
{ 0x06, "Reserved for national use" },
{ 0x07, "Spare" },
{ 0x00, NULL }
};
static int * const regdel_fields[] = {
&hf_smpp_regdel_receipt,
&hf_smpp_regdel_acks,
&hf_smpp_regdel_notif,
NULL
};
static int * const submit_msg_fields[] = {
&hf_smpp_esm_submit_msg_mode,
&hf_smpp_esm_submit_msg_type,
&hf_smpp_esm_submit_features,
NULL
};
static dissector_handle_t gsm_sms_handle;
static smpp_data_t *
get_smpp_data(packet_info *pinfo)
{
smpp_data_t *smpp_data = NULL;
smpp_data = (smpp_data_t*)p_get_proto_data(pinfo->pool, pinfo, proto_smpp, 0);
if (!smpp_data) {
smpp_data = wmem_new0(pinfo->pool, smpp_data_t);
p_add_proto_data(pinfo->pool, pinfo, proto_smpp, 0, smpp_data);
}
return smpp_data;
}
/*
* For Stats Tree
*/
static void
smpp_stats_tree_init(stats_tree* st)
{
st_smpp_ops = stats_tree_create_node(st, "SMPP Operations", 0, STAT_DT_INT, TRUE);
st_smpp_req = stats_tree_create_node(st, "SMPP Requests", st_smpp_ops, STAT_DT_INT, TRUE);
st_smpp_res = stats_tree_create_node(st, "SMPP Responses", st_smpp_ops, STAT_DT_INT, TRUE);
st_smpp_res_status = stats_tree_create_node(st, "SMPP Response Status", 0, STAT_DT_INT, TRUE);
}
static tap_packet_status
smpp_stats_tree_per_packet(stats_tree *st, /* st as it was passed to us */
packet_info *pinfo _U_,
epan_dissect_t *edt _U_,
const void *p,
tap_flags_t flags _U_) /* Used for getting SMPP command_id values */
{
const smpp_tap_rec_t* tap_rec = (const smpp_tap_rec_t*)p;
tick_stat_node(st, "SMPP Operations", 0, TRUE);
if ((tap_rec->command_id & SMPP_COMMAND_ID_RESPONSE_MASK) == SMPP_COMMAND_ID_RESPONSE_MASK) /* Response */
{
tick_stat_node(st, "SMPP Responses", st_smpp_ops, TRUE);
tick_stat_node(st, val_to_str(tap_rec->command_id, vals_command_id, "Unknown 0x%08x"), st_smpp_res, FALSE);
tick_stat_node(st, "SMPP Response Status", 0, TRUE);
tick_stat_node(st, rval_to_str(tap_rec->command_status, rvals_command_status, "Unknown 0x%08x"), st_smpp_res_status, FALSE);
}
else /* Request */
{
tick_stat_node(st, "SMPP Requests", st_smpp_ops, TRUE);
tick_stat_node(st, val_to_str(tap_rec->command_id, vals_command_id, "Unknown 0x%08x"), st_smpp_req, FALSE);
}
return TAP_PACKET_REDRAW;
}
/*!
* SMPP equivalent of mktime() (3). Convert date to standard 'time_t' format
*
* \param datestr The SMPP-formatted date to convert
* \param secs Returns the 'time_t' equivalent
* \param nsecs Returns the additional nano-seconds
*
* \return Whether time is specified relative (TRUE) or absolute (FALSE)
* If invalid abs time: return *secs = (time_t)(-1) and *nsecs=0
*/
/* XXX: This function needs better error checking and handling */
static gboolean
smpp_mktime(const char *datestr, time_t *secs, int *nsecs)
{
struct tm r_time;
time_t t_diff;
gboolean relative = (datestr[15] == 'R') ? TRUE : FALSE;
r_time.tm_year = 10 * (datestr[0] - '0') + (datestr[1] - '0');
/*
* Y2K rollover date as recommended in appendix C
*/
if (r_time.tm_year < 38)
r_time.tm_year += 100;
r_time.tm_mon = 10 * (datestr[2] - '0') + (datestr[3] - '0');
r_time.tm_mon--;
r_time.tm_mday = 10 * (datestr[4] - '0') + (datestr[5] - '0');
r_time.tm_hour = 10 * (datestr[6] - '0') + (datestr[7] - '0');
r_time.tm_min = 10 * (datestr[8] - '0') + (datestr[9] - '0');
r_time.tm_sec = 10 * (datestr[10] - '0') + (datestr[11] - '0');
r_time.tm_isdst = -1;
if (relative == FALSE) {
*secs = mktime_utc(&r_time);
*nsecs = 0;
if (*secs == (time_t)(-1)) {
return relative;
}
*nsecs = (datestr[12] - '0') * 100000000;
t_diff = (10 * (datestr[13] - '0') + (datestr[14] - '0')) * 900;
if (datestr[15] == '-')
/* Represented time is behind UTC, shift it forward to UTC */
*secs += t_diff;
else if (datestr[15] == '+')
/* Represented time is ahead of UTC, shift it backward to UTC */
*secs -= t_diff;
} else {
*secs = r_time.tm_sec + 60 *
(r_time.tm_min + 60 *
(r_time.tm_hour + 24 *
r_time.tm_mday));
*nsecs = 0;
}
return relative;
}
/*!
* Scanning routines to add standard types (byte, int, string...) to the
* protocol tree.
*
* \param tree The protocol tree to add to
* \param tvb Buffer containing the data
* \param field Actual field whose value needs displaying
* \param offset Location of field in buffer, returns location of
* next field
*/
static void
smpp_handle_string(proto_tree *tree, tvbuff_t *tvb, int field, int *offset)
{
guint len;
len = tvb_strsize(tvb, *offset);
if (len > 1) {
proto_tree_add_item(tree, field, tvb, *offset, len, ENC_NA);
}
(*offset) += len;
}
static const char *
smpp_handle_string_return(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int field, int *offset)
{
gint len;
const char* str = (const char *)tvb_get_stringz_enc(pinfo->pool, tvb, *offset, &len, ENC_ASCII);
if (len > 0)
proto_tree_add_string(tree, field, tvb, *offset, len, str);
(*offset) += len;
return str;
}
static void
smpp_handle_string_z(proto_tree *tree, tvbuff_t *tvb, int field, int *offset,
const char *null_string)
{
gint len;
len = tvb_strsize(tvb, *offset);
if (len > 1) {
proto_tree_add_item(tree, field, tvb, *offset, len, ENC_NA);
} else {
proto_tree_add_string(tree, field, tvb, *offset, len, null_string);
}
(*offset) += len;
}
static void
smpp_handle_time(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo,
int field, int field_R, int *offset)
{
char *strval;
gint len;
nstime_t tmptime;
strval = (char *) tvb_get_stringz_enc(pinfo->pool, tvb, *offset, &len, ENC_ASCII);
if (*strval)
{
if (len >= 16)
{
if (smpp_mktime(strval, &tmptime.secs, &tmptime.nsecs))
proto_tree_add_time(tree, field_R, tvb, *offset, len, &tmptime);
else
proto_tree_add_time(tree, field, tvb, *offset, len, &tmptime);
}
else
{
tmptime.secs = 0;
tmptime.nsecs = 0;
proto_tree_add_time_format_value(tree, field_R, tvb, *offset, len, &tmptime, "%s", strval);
}
}
*offset += len;
}
/*!
* Scanning routine to handle the destination-list of 'submit_multi'
*
* \param tree The protocol tree to add to
* \param tvb Buffer containing the data
* \param offset Location of field in buffer, returns location of
* next field
*/
static void
smpp_handle_dlist(proto_tree *tree, tvbuff_t *tvb, int *offset)
{
guint8 entries;
int tmpoff = *offset;
proto_tree *sub_tree = NULL;
guint8 dest_flag;
if ((entries = tvb_get_guint8(tvb, tmpoff++))) {
proto_item *pi;
pi = proto_tree_add_item(tree, hf_smpp_dlist, tvb, *offset, 1, ENC_NA);
sub_tree = proto_item_add_subtree(pi, ett_dlist);
}
while (entries--)
{
dest_flag = tvb_get_guint8(tvb, tmpoff++);
if (dest_flag == 1) /* SME address */
{
proto_tree_add_item(sub_tree, hf_smpp_dest_addr_ton, tvb, tmpoff, 1, ENC_NA);
tmpoff += 1;
proto_tree_add_item(sub_tree, hf_smpp_dest_addr_npi, tvb, tmpoff, 1, ENC_NA);
tmpoff += 1;
smpp_handle_string(sub_tree,tvb,hf_smpp_destination_addr,&tmpoff);
}
else /* Distribution list */
{
smpp_handle_string(sub_tree, tvb, hf_smpp_dl_name, &tmpoff);
}
}
*offset = tmpoff;
}
/*!
* Scanning routine to handle the destination result list
* of 'submit_multi_resp'
*
* \param tree The protocol tree to add to
* \param tvb Buffer containing the data
* \param offset Location of field in buffer, returns location of
* next field
*/
static void
smpp_handle_dlist_resp(proto_tree *tree, tvbuff_t *tvb, int *offset)
{
guint8 entries;
int tmpoff = *offset;
proto_tree *sub_tree = NULL;
if ((entries = tvb_get_guint8(tvb, tmpoff++))) {
proto_item *pi;
pi = proto_tree_add_item(tree, hf_smpp_dlist_resp,
tvb, *offset, 1, ENC_NA);
sub_tree = proto_item_add_subtree(pi, ett_dlist_resp);
}
while (entries--)
{
proto_tree_add_item(sub_tree, hf_smpp_dest_addr_ton, tvb, tmpoff, 1, ENC_NA);
tmpoff += 1;
proto_tree_add_item(sub_tree, hf_smpp_dest_addr_npi, tvb, tmpoff, 1, ENC_NA);
tmpoff += 1;
smpp_handle_string(sub_tree,tvb,hf_smpp_destination_addr,&tmpoff);
proto_tree_add_item(sub_tree, hf_smpp_error_status_code, tvb, tmpoff, 4, ENC_BIG_ENDIAN);
tmpoff += 4;
}
*offset = tmpoff;
}
/*!
* Scanning routine to handle all optional parameters of SMPP-operations.
* The parameters have the format Tag Length Value (TLV), with a 2-byte tag
* and 2-byte length.
*
* \param tree The protocol tree to add to
* \param tvb Buffer containing the data
* \param offset Location of field in buffer, returns location of
* next field
*/
static void
smpp_handle_tlv(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int *offset, tvbuff_t **tvb_msg)
{
proto_tree *tlvs_tree = NULL;
proto_item *pi;
smpp_data_t *smpp_data;
guint16 source_port = 0, dest_port = 0, sm_id = 0;
guint8 frags = 0, frag = 0;
gboolean source_port_found = FALSE, dest_port_found = FALSE;
gboolean sm_id_found = FALSE;
if (tvb_reported_length_remaining(tvb, *offset) >= 1) {
pi = proto_tree_add_item(tree, hf_smpp_opt_params,
tvb, *offset, -1, ENC_NA);
tlvs_tree = proto_item_add_subtree(pi, ett_opt_params);
}
while (tvb_reported_length_remaining(tvb, *offset) >= 1)
{
proto_item *sub_tree;
guint16 tag;
guint16 length;
tag = tvb_get_ntohs(tvb, *offset);
length = tvb_get_ntohs(tvb, (*offset+2));
pi = proto_tree_add_none_format(tlvs_tree, hf_smpp_opt_param, tvb,
*offset, length+4,
"Optional parameter: %s (0x%04x)",
val_to_str(tag, vals_tlv_tags, "0x%04x"), tag);
sub_tree = proto_item_add_subtree(pi, ett_opt_param);
proto_tree_add_uint(sub_tree,hf_smpp_opt_param_tag,tvb,*offset,2,tag);
proto_tree_add_uint(sub_tree,hf_smpp_opt_param_len,tvb,*offset+2,2,length);
*offset += 4;
switch (tag) {
case 0x0005: /* dest_addr_subunit */
proto_tree_add_item(sub_tree, hf_smpp_dest_addr_subunit, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0006: /* dest_network_type */
proto_tree_add_item(sub_tree, hf_smpp_dest_network_type, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0007: /* dest_bearer_type */
proto_tree_add_item(sub_tree, hf_smpp_dest_bearer_type, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0008: /* dest_telematics_id */
proto_tree_add_item(sub_tree, hf_smpp_dest_telematics_id, tvb, *offset, 2, ENC_BIG_ENDIAN);
(*offset) += 2;
break;
case 0x000D: /* source_addr_subunit */
proto_tree_add_item(sub_tree, hf_smpp_source_addr_subunit, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x000E: /* source_network_type */
proto_tree_add_item(sub_tree, hf_smpp_source_network_type, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x000F: /* source_bearer_type */
proto_tree_add_item(sub_tree, hf_smpp_source_bearer_type, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0010: /* source_telematics_id */
proto_tree_add_item(sub_tree, hf_smpp_source_telematics_id, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0017: /* qos_time_to_live */
proto_tree_add_item(sub_tree, hf_smpp_qos_time_to_live, tvb, *offset, 4, ENC_BIG_ENDIAN);
(*offset) += 4;
break;
case 0x0019: /* payload_type */
proto_tree_add_item(sub_tree, hf_smpp_payload_type, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x001D: /* additional_status_info_text */
if (length)
proto_tree_add_item(sub_tree, hf_smpp_additional_status_info_text,
tvb, *offset, length, ENC_NA | ENC_ASCII);
(*offset) += length;
break;
case 0x001E: /* receipted_message_id */
if (length)
proto_tree_add_item(sub_tree, hf_smpp_receipted_message_id,
tvb, *offset, length, ENC_NA | ENC_ASCII);
(*offset) += length;
break;
case 0x0030: { /* ms_msg_wait_facilities */
static int * const fields[] = {
&hf_smpp_msg_wait_ind,
&hf_smpp_msg_wait_type,
NULL
};
proto_tree_add_bitmask_list(sub_tree, tvb, *offset, 1, fields, ENC_NA);
(*offset)++;
}
break;
case 0x0201: /* privacy_indicator */
proto_tree_add_item(sub_tree, hf_smpp_privacy_indicator, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0202: /* source_subaddress */
if (length) {
proto_tree_add_item(sub_tree, hf_smpp_source_subaddress,
tvb, *offset, length, ENC_NA);
(*offset) += length;
}
break;
case 0x0203: /* dest_subaddress */
if (length) {
proto_tree_add_item(sub_tree, hf_smpp_dest_subaddress,
tvb, *offset, length, ENC_NA);
(*offset) += length;
}
break;
case 0x0204: /* user_message_reference */
proto_tree_add_item(sub_tree, hf_smpp_user_message_reference, tvb, *offset, 2, ENC_BIG_ENDIAN);
(*offset) += 2;
break;
case 0x0205: /* user_response_code */
proto_tree_add_item(sub_tree, hf_smpp_user_response_code, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x020A: /* source_port */
proto_tree_add_item(sub_tree, hf_smpp_source_port, tvb, *offset, 2, ENC_BIG_ENDIAN);
source_port = tvb_get_ntohs(tvb, *offset);
source_port_found = TRUE;
(*offset) += 2;
break;
case 0x020B: /* destination_port */
proto_tree_add_item(sub_tree, hf_smpp_destination_port, tvb, *offset, 2, ENC_BIG_ENDIAN);
dest_port = tvb_get_ntohs(tvb, *offset);
dest_port_found = TRUE;
(*offset) += 2;
break;
case 0x020C: /* sar_msg_ref_num */
proto_tree_add_item(sub_tree, hf_smpp_sar_msg_ref_num, tvb, *offset, 2, ENC_BIG_ENDIAN);
sm_id = tvb_get_ntohs(tvb, *offset);
sm_id_found = TRUE;
(*offset) += 2;
break;
case 0x020D: /* language_indicator */
proto_tree_add_item(sub_tree, hf_smpp_language_indicator, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x020E: /* sar_total_segments */
proto_tree_add_item(sub_tree, hf_smpp_sar_total_segments, tvb, *offset, 1, ENC_NA);
frags = tvb_get_guint8(tvb, *offset);
(*offset) += 1;
break;
case 0x020F: /* sar_segment_seqnum */
proto_tree_add_item(sub_tree, hf_smpp_sar_segment_seqnum, tvb, *offset, 1, ENC_NA);
frag = tvb_get_guint8(tvb, *offset);
(*offset) += 1;
break;
case 0x0210: /* SC_interface_version */
proto_tree_add_item(sub_tree, hf_smpp_SC_interface_version, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0302: { /* callback_num_pres_ind */
static int * const fields[] = {
&hf_smpp_callback_num_pres,
&hf_smpp_callback_num_scrn,
NULL
};
proto_tree_add_bitmask_list(sub_tree, tvb, *offset, 1, fields, ENC_NA);
(*offset)++;
}
break;
case 0x0303: /* callback_num_atag */
if (length)
proto_tree_add_item(sub_tree, hf_smpp_callback_num_atag,
tvb, *offset, length, ENC_NA);
(*offset) += length;
break;
case 0x0304: /* number_of_messages */
proto_tree_add_item(sub_tree, hf_smpp_number_of_messages, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0381: /* callback_num */
if (length)
proto_tree_add_item(sub_tree, hf_smpp_callback_num,
tvb, *offset, length, ENC_NA);
(*offset) += length;
break;
case 0x0420: /* dpf_result */
proto_tree_add_item(sub_tree, hf_smpp_dpf_result, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0421: /* set_dpf */
proto_tree_add_item(sub_tree, hf_smpp_set_dpf, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0422: /* ms_availability_status */
proto_tree_add_item(sub_tree, hf_smpp_ms_availability_status, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0423: /* network_error_code */
proto_tree_add_item(sub_tree, hf_smpp_network_error_type, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
proto_tree_add_item(sub_tree, hf_smpp_network_error_code, tvb, *offset, 2, ENC_BIG_ENDIAN);
(*offset) += 2;
break;
case 0x0424: /* message_payload */
if (length) {
pi = proto_tree_add_item(sub_tree, hf_smpp_message_payload,
tvb, *offset, length, ENC_NA);
if (tvb_msg) {
if (*tvb_msg != NULL) {
expert_add_info(pinfo, pi, &ei_smpp_message_payload_duplicate);
}
*tvb_msg = tvb_new_subset_length(tvb, *offset, length);
}
}
(*offset) += length;
break;
case 0x0425: /* delivery_failure_reason */
proto_tree_add_item(sub_tree, hf_smpp_delivery_failure_reason, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0426: /* more_messages_to_send */
proto_tree_add_item(sub_tree, hf_smpp_more_messages_to_send, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0427: /* message_state */
proto_tree_add_item(sub_tree, hf_smpp_message_state, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0428: /* congestion_state */
proto_tree_add_item(sub_tree, hf_smpp_congestion_state, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0501: /* ussd_service_op */
proto_tree_add_item(sub_tree, hf_smpp_ussd_service_op, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0600: /* broadcast_channel_indicator */
proto_tree_add_item(sub_tree, hf_smpp_broadcast_channel_indicator, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0601: /* broadcast_content_type */
proto_tree_add_item(sub_tree, hf_smpp_broadcast_content_type_nw, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
proto_tree_add_item(sub_tree, hf_smpp_broadcast_content_type_type, tvb, *offset, 2, ENC_BIG_ENDIAN);
(*offset) += 2;
break;
case 0x0602: /* broadcast_content_type_info */
if (length)
proto_tree_add_item(sub_tree, hf_smpp_broadcast_content_type_info,
tvb, *offset, length, ENC_NA);
(*offset) += length;
break;
case 0x0603: /* broadcast_message_class */
proto_tree_add_item(sub_tree, hf_smpp_broadcast_message_class, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0604: /* broadcast_rep_num */
proto_tree_add_item(sub_tree, hf_smpp_broadcast_rep_num, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0605: /* broadcast_frequency_interval */
proto_tree_add_item(sub_tree, hf_smpp_broadcast_frequency_interval_unit, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
proto_tree_add_item(sub_tree, hf_smpp_broadcast_frequency_interval_value, tvb, *offset, 2, ENC_BIG_ENDIAN);
(*offset) += 2;
break;
case 0x0606: /* broadcast_area_identifier */
proto_tree_add_item(sub_tree, hf_smpp_broadcast_area_identifier_format, tvb, *offset, 1, ENC_NA);
proto_tree_add_item(sub_tree, hf_smpp_broadcast_area_identifier,
tvb, *offset, length, ENC_NA);
(*offset) += length;
break;
case 0x0607: /* broadcast_error_status */
proto_tree_add_item(sub_tree, hf_smpp_broadcast_error_status, tvb, *offset, 4, ENC_BIG_ENDIAN);
(*offset) += 4;
break;
case 0x0608: /* broadcast_area_success */
proto_tree_add_item(sub_tree, hf_smpp_broadcast_area_success, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0609: /* broadcast_end_time */
smpp_handle_time(sub_tree, tvb, pinfo, hf_smpp_broadcast_end_time,
hf_smpp_broadcast_end_time_r, offset);
break;
case 0x060A: /* broadcast_service_group */
if (length)
proto_tree_add_item(sub_tree, hf_smpp_broadcast_service_group,
tvb, *offset, length, ENC_NA);
(*offset) += length;
break;
case 0x060B: /* billing_identification */
if (length)
proto_tree_add_item(sub_tree, hf_smpp_billing_identification,
tvb, *offset, length, ENC_NA);
(*offset) += length;
break;
/* 0x060C is skipped in the specs for some reason :-? */
case 0x060D: /* source_network_id */
if (length)
proto_tree_add_item(sub_tree, hf_smpp_source_network_id,
tvb, *offset, length, ENC_NA|ENC_ASCII);
(*offset) += length;
break;
case 0x060E: /* dest_network_id */
if (length)
proto_tree_add_item(sub_tree, hf_smpp_dest_network_id,
tvb, *offset, length, ENC_NA | ENC_ASCII);
(*offset) += length;
break;
case 0x060F: /* source_node_id */
if (length)
proto_tree_add_item(sub_tree, hf_smpp_source_node_id,
tvb, *offset, length, ENC_NA);
(*offset) += length;
break;
case 0x0610: /* dest_node_id */
if (length)
proto_tree_add_item(sub_tree, hf_smpp_dest_node_id,
tvb, *offset, length, ENC_NA);
(*offset) += length;
break;
case 0x0611: /* dest_addr_np_resolution */
proto_tree_add_item(sub_tree, hf_smpp_dest_addr_np_resolution, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x0612: /* dest_addr_np_information */
if (length)
proto_tree_add_item(sub_tree, hf_smpp_dest_addr_np_information,
tvb, *offset, length, ENC_NA);
(*offset) += length;
break;
case 0x0613: /* dest_addr_np_country */
/* TODO : Fetch values from packet-e164? */
if (length)
proto_tree_add_item(sub_tree, hf_smpp_dest_addr_np_country,
tvb, *offset, length, ENC_NA);
(*offset) += length;
break;
case 0x1201: /* display_time */
proto_tree_add_item(sub_tree, hf_smpp_display_time, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x1203: /* sms_signal */
proto_tree_add_item(sub_tree, hf_smpp_sms_signal, tvb, *offset, 2, ENC_BIG_ENDIAN);
(*offset) += 2;
/*! \todo Fill as per TIA/EIA-136-710-A */
break;
case 0x1204: /* ms_validity */
proto_tree_add_item(sub_tree, hf_smpp_ms_validity, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x130C: /* alert_on_message_delivery */
if (length == 0) {
proto_tree_add_item(sub_tree,
hf_smpp_alert_on_message_delivery_null,
tvb, *offset, length, ENC_NA);
} else {
proto_tree_add_item(sub_tree, hf_smpp_alert_on_message_delivery_type, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
}
break;
case 0x1380: /* its_reply_type */
proto_tree_add_item(sub_tree, hf_smpp_its_reply_type, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
break;
case 0x1383: { /* its_session_info */
static int * const fields[] = {
&hf_smpp_its_session_sequence,
&hf_smpp_its_session_ind,
NULL
};
proto_tree_add_item(sub_tree, hf_smpp_its_session_number, tvb, *offset, 1, ENC_NA);
(*offset) += 1;
proto_tree_add_bitmask_list(sub_tree, tvb, *offset, 1, fields, ENC_NA);
(*offset) += 1;
}
break;
default:
/* TODO : Hopefully to be implemented soon - handle vendor specific TLVs
* from a dictionary before treating them as unknown! */
if ((tag >= 0x1400) && (tag <= 0x3FFF)) {
proto_tree_add_item(sub_tree, hf_smpp_vendor_op, tvb,
*offset, length, ENC_NA);
} else {
proto_tree_add_item(sub_tree, hf_smpp_reserved_op, tvb,
*offset, length, ENC_NA);
}
if (length > 0) {
char *str;
str = tvb_bytes_to_str(NULL, tvb,*offset,length);
proto_item_append_text(sub_tree,": %s", str);
wmem_free(NULL, str);
}
(*offset) += length;
break;
}
}
if (source_port_found && dest_port_found) {
smpp_data = get_smpp_data(pinfo);
if (smpp_data->udh_fields == NULL) {
smpp_data->udh_fields = wmem_new0(pinfo->pool, gsm_sms_udh_fields_t);
}
smpp_data->udh_fields->port_src = source_port;
smpp_data->udh_fields->port_dst = dest_port;
}
if (sm_id_found && frags && frag) {
/* frags and frag must be at least 1 */
smpp_data = get_smpp_data(pinfo);
if (smpp_data->udh_fields == NULL) {
smpp_data->udh_fields = wmem_new0(pinfo->pool, gsm_sms_udh_fields_t);
}
smpp_data->udh_fields->sm_id = sm_id;
smpp_data->udh_fields->frags = frags;
smpp_data->udh_fields->frag = frag;
}
}
void
smpp_handle_dcs(proto_tree *tree, tvbuff_t *tvb, int *offset, guint *encoding)
{
guint32 val;
guint8 dataCoding;
int off = *offset;
proto_tree *subtree;
proto_item *pi;
/* SMPP Data Coding Scheme */
pi = proto_tree_add_item_ret_uint(tree, hf_smpp_data_coding, tvb, off, 1, ENC_NA, &val);
if (val & 0xC0) {
/* GSM SMS Data Coding Scheme */
subtree = proto_item_add_subtree(pi, ett_dcs);
if ((val & 0xF0) == 0xF0) {
static int * const gsm_msg_control_fields[] = {
&hf_smpp_dcs_sms_coding_group,
&hf_smpp_dcs_reserved,
&hf_smpp_dcs_charset,
&hf_smpp_dcs_class,
NULL
};
proto_tree_add_bitmask_list(subtree, tvb, off, 1, gsm_msg_control_fields, ENC_NA);
if ((val & 0x04) == 0x04) {
dataCoding = DECODE_AS_OCTET;
} else {
dataCoding = DECODE_AS_GSM7;
}
} else {
static int * const gsm_mwi_control_fields[] = {
&hf_smpp_dcs_sms_coding_group,
&hf_smpp_dcs_wait_ind,
&hf_smpp_dcs_reserved2,
&hf_smpp_dcs_wait_type,
NULL
};
proto_tree_add_bitmask_list(subtree, tvb, off, 1, gsm_mwi_control_fields, ENC_NA);
if ((val & 0xF0) == 0xE0) {
dataCoding = DECODE_AS_UCS2;
} else {
dataCoding = DECODE_AS_GSM7;
}
}
} else {
dataCoding = val;
}
if (encoding != NULL) {
switch (dataCoding)
{
case DECODE_AS_DEFAULT:
*encoding = smpp_decode_dcs_0_sms;
break;
case DECODE_AS_ASCII:
*encoding = ENC_ASCII;
break;
case DECODE_AS_OCTET:
*encoding = DO_NOT_DECODE;
break;
case DECODE_AS_ISO_8859_1:
*encoding = ENC_ISO_8859_1;
break;
case DECODE_AS_ISO_8859_5:
*encoding = ENC_ISO_8859_5;
break;
case DECODE_AS_ISO_8859_8:
*encoding = ENC_ISO_8859_8;
break;
case DECODE_AS_UCS2:
*encoding = ENC_UCS_2|ENC_BIG_ENDIAN;
break;
case DECODE_AS_KSC5601:
*encoding = ENC_EUC_KR;
break;
case DECODE_AS_GSM7:
*encoding = smpp_gsm7_unpacked ? ENC_3GPP_TS_23_038_7BITS_UNPACKED :
ENC_3GPP_TS_23_038_7BITS_PACKED;
break;
default:
/* XXX: Support decoding unknown values according to the pref? */
*encoding = DO_NOT_DECODE;
break;
}
}
(*offset)++;
}
static void
smpp_handle_msg(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, const char *src_str, const char *dst_str)
{
smpp_data_t *smpp_data;
address save_src, save_dst;
guint encoding;
int udh_offset = 0;
int length;
smpp_data = get_smpp_data(pinfo);
encoding = smpp_data->encoding;
length = tvb_reported_length(tvb);
if (smpp_data->udhi) /* UDHI indicator present */
{
udh_offset = tvb_get_guint8(tvb, 0) + 1;
}
if (smpp_data->udhi || smpp_data->udh_fields) {
/* Save original addresses */
copy_address_shallow(&save_src, &pinfo->src);
copy_address_shallow(&save_dst, &pinfo->dst);
/* Set SMPP source and destination address */
set_address(&(pinfo->src), AT_STRINGZ, 1+(int)strlen(src_str), src_str);
set_address(&(pinfo->dst), AT_STRINGZ, 1+(int)strlen(dst_str), dst_str);
call_dissector_with_data(gsm_sms_handle, tvb, pinfo, proto_tree_get_parent_tree(tree), smpp_data);
/* Restore original addresses */
copy_address_shallow(&pinfo->src, &save_src);
copy_address_shallow(&pinfo->dst, &save_dst);
}
if (smpp_data->encoding != DO_NOT_DECODE) {
if (smpp_data->encoding == ENC_3GPP_TS_23_038_7BITS_PACKED && smpp_data->udhi) {
/* SMPP only has the number of octets of the payload, but when
* packed 7-bit GSM alphabet is used with a UDH, there are fill
* bits after the UDH to align the SM start with a septet boundary.
* Calculate the fill bits after the UDH as well as the number of
* septets that could fit in the bytes. (In certain circumstances
* there are two possible numbers of septets that would require
* a certain number of octets. This is part of why packet 7-bit
* GSM alphabet is not usually used in SMPP, but there are reports
* of some servers out there.)
*/
guint8 fill_bits = 6 - ((udh_offset - 1) * 8) % 7;
int septets = ((length - udh_offset) * 8 - fill_bits) / 7;
proto_tree_add_ts_23_038_7bits_packed_item(tree, hf_smpp_short_message, tvb, udh_offset * 8 + fill_bits, septets);
} else {
proto_tree_add_item(tree, hf_smpp_short_message, tvb,
udh_offset, length-udh_offset, encoding);
}
}
}
/*!
* The next set of routines handle the different operations, associated
* with SMPP.
*/
static void
bind_receiver(proto_tree *tree, tvbuff_t *tvb, int offset)
{
smpp_handle_string(tree, tvb, hf_smpp_system_id, &offset);
smpp_handle_string(tree, tvb, hf_smpp_password, &offset);
smpp_handle_string(tree, tvb, hf_smpp_system_type, &offset);
proto_tree_add_item(tree, hf_smpp_interface_version, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_addr_ton, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
smpp_handle_string_z(tree, tvb, hf_smpp_address_range, &offset, "NULL");
}
static void
query_sm(proto_tree *tree, tvbuff_t *tvb, int offset)
{
smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
smpp_handle_string(tree, tvb, hf_smpp_source_addr, &offset);
}
static void
outbind(proto_tree *tree, tvbuff_t *tvb, int offset)
{
smpp_handle_string(tree, tvb, hf_smpp_system_id, &offset);
smpp_handle_string(tree, tvb, hf_smpp_password, &offset);
}
static void
submit_sm(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
{
tvbuff_t *tvb_msg = NULL;
smpp_data_t *smpp_data;
guint32 length;
const char *src_str = NULL;
const char *dst_str = NULL;
nstime_t zero_time = NSTIME_INIT_ZERO;
smpp_data = get_smpp_data(pinfo);
smpp_handle_string_z(tree, tvb, hf_smpp_service_type, &offset, "(Default)");
proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
src_str = smpp_handle_string_return(tree, tvb, pinfo, hf_smpp_source_addr, &offset);
proto_tree_add_item(tree, hf_smpp_dest_addr_ton, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_dest_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
dst_str = smpp_handle_string_return(tree, tvb, pinfo, hf_smpp_destination_addr, &offset);
smpp_data->udhi = tvb_get_guint8(tvb, offset) & SMPP_UDHI_MASK;
proto_tree_add_bitmask_list(tree, tvb, offset, 1, submit_msg_fields, ENC_NA);
offset++;
proto_tree_add_item(tree, hf_smpp_protocol_id, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_priority_flag, tvb, offset, 1, ENC_NA);
offset += 1;
if (tvb_get_guint8(tvb,offset)) {
smpp_handle_time(tree, tvb, pinfo, hf_smpp_schedule_delivery_time,
hf_smpp_schedule_delivery_time_r, &offset);
} else { /* Time = NULL means Immediate delivery */
proto_tree_add_time_format_value(tree, hf_smpp_schedule_delivery_time_r, tvb, offset++, 1, &zero_time, "Immediate delivery");
}
if (tvb_get_guint8(tvb,offset)) {
smpp_handle_time(tree, tvb, pinfo, hf_smpp_validity_period,
hf_smpp_validity_period_r, &offset);
} else { /* Time = NULL means SMSC default validity */
proto_tree_add_time_format_value(tree, hf_smpp_validity_period_r, tvb, offset++, 1, &zero_time, "SMSC default validity period");
}
proto_tree_add_bitmask_list(tree, tvb, offset, 1, regdel_fields, ENC_NA);
offset++;
proto_tree_add_item(tree, hf_smpp_replace_if_present_flag, tvb, offset, 1, ENC_NA);
offset += 1;
smpp_handle_dcs(tree, tvb, &offset, &smpp_data->encoding);
proto_tree_add_item(tree, hf_smpp_sm_default_msg_id, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item_ret_uint(tree, hf_smpp_sm_length, tvb, offset++, 1, ENC_NA, &length);
if (length)
{
proto_tree_add_item(tree, hf_smpp_short_message_bin,
tvb, offset, length, ENC_NA);
tvb_msg = tvb_new_subset_length(tvb, offset, length);
offset += length;
}
/* Get rid of SMPP text string addresses */
smpp_handle_tlv(tree, tvb, pinfo, &offset, &tvb_msg);
if (tvb_msg) {
smpp_handle_msg(tree, tvb_msg, pinfo, src_str, dst_str);
}
}
static void
replace_sm(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
{
tvbuff_t *tvb_msg = NULL;
smpp_data_t *smpp_data;
guint32 length;
const char *src_str = NULL;
nstime_t zero_time = NSTIME_INIT_ZERO;
smpp_data = get_smpp_data(pinfo);
smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
src_str = smpp_handle_string_return(tree, tvb, pinfo, hf_smpp_source_addr, &offset);
if (tvb_get_guint8(tvb,offset)) {
smpp_handle_time(tree, tvb, pinfo, hf_smpp_schedule_delivery_time,
hf_smpp_schedule_delivery_time_r, &offset);
} else { /* Time = NULL */
proto_tree_add_time_format_value(tree, hf_smpp_schedule_delivery_time_r, tvb, offset++, 1, &zero_time, "Keep initial delivery time setting");
}
if (tvb_get_guint8(tvb,offset)) {
smpp_handle_time(tree, tvb, pinfo, hf_smpp_validity_period,
hf_smpp_validity_period_r, &offset);
} else { /* Time = NULL */
proto_tree_add_time_format_value(tree, hf_smpp_validity_period_r, tvb, offset++, 1,&zero_time, "Keep initial validity period setting");
}
proto_tree_add_bitmask_list(tree, tvb, offset, 1, regdel_fields, ENC_NA);
offset++;
proto_tree_add_item(tree, hf_smpp_sm_default_msg_id, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item_ret_uint(tree, hf_smpp_sm_length, tvb, offset++, 1, ENC_NA, &length);
/* XXX: replace_sm does not contain a DCS element, so theoretically
* the encoding must be the same as the previously submitted message
* with the same message ID. We don't track that, though, so just assume
* default.
*/
smpp_data->encoding = smpp_decode_dcs_0_sms;
if (length) {
proto_tree_add_item(tree, hf_smpp_short_message_bin,
tvb, offset, length, ENC_NA);
tvb_msg = tvb_new_subset_length(tvb, offset, length);
}
offset += length;
smpp_handle_tlv(tree, tvb, pinfo, &offset, &tvb_msg);
if (tvb_msg) {
smpp_handle_msg(tree, tvb_msg, pinfo, src_str, "");
}
}
static void
cancel_sm(proto_tree *tree, tvbuff_t *tvb, int offset)
{
smpp_handle_string_z(tree, tvb, hf_smpp_service_type, &offset, "(Default)");
smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
smpp_handle_string(tree, tvb, hf_smpp_source_addr, &offset);
proto_tree_add_item(tree, hf_smpp_dest_addr_ton, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_dest_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
smpp_handle_string(tree, tvb, hf_smpp_destination_addr, &offset);
}
static void
submit_multi(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
{
tvbuff_t *tvb_msg = NULL;
smpp_data_t *smpp_data;
guint32 length;
const char *src_str = NULL;
nstime_t zero_time = NSTIME_INIT_ZERO;
smpp_data = get_smpp_data(pinfo);
smpp_handle_string_z(tree, tvb, hf_smpp_service_type, &offset, "(Default)");
proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
src_str = smpp_handle_string_return(tree, tvb, pinfo, hf_smpp_source_addr, &offset);
smpp_handle_dlist(tree, tvb, &offset);
smpp_data->udhi = tvb_get_guint8(tvb, offset) & SMPP_UDHI_MASK;
proto_tree_add_bitmask_list(tree, tvb, offset, 1, submit_msg_fields, ENC_NA);
offset++;
proto_tree_add_item(tree, hf_smpp_protocol_id, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_priority_flag, tvb, offset, 1, ENC_NA);
offset += 1;
if (tvb_get_guint8(tvb,offset)) {
smpp_handle_time(tree, tvb, pinfo, hf_smpp_schedule_delivery_time,
hf_smpp_schedule_delivery_time_r, &offset);
} else { /* Time = NULL means Immediate delivery */
proto_tree_add_time_format_value(tree, hf_smpp_schedule_delivery_time_r, tvb, offset++, 1, &zero_time, "Immediate delivery");
}
if (tvb_get_guint8(tvb,offset)) {
smpp_handle_time(tree, tvb, pinfo, hf_smpp_validity_period, hf_smpp_validity_period_r, &offset);
} else { /* Time = NULL means SMSC default validity */
proto_tree_add_time_format_value(tree, hf_smpp_schedule_delivery_time_r, tvb, offset++, 1, &zero_time, "SMSC default validity period");
}
proto_tree_add_bitmask_list(tree, tvb, offset, 1, regdel_fields, ENC_NA);
offset++;
proto_tree_add_item(tree, hf_smpp_replace_if_present_flag, tvb, offset, 1, ENC_NA);
offset += 1;
smpp_handle_dcs(tree, tvb, &offset, &smpp_data->encoding);
proto_tree_add_item(tree, hf_smpp_sm_default_msg_id, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item_ret_uint(tree, hf_smpp_sm_length, tvb, offset++, 1, ENC_NA, &length);
if (length) {
proto_tree_add_item(tree, hf_smpp_short_message_bin,
tvb, offset, length, ENC_NA);
tvb_msg = tvb_new_subset_length(tvb, offset, length);
}
offset += length;
smpp_handle_tlv(tree, tvb, pinfo, &offset, &tvb_msg);
if (tvb_msg) {
/* submit_multi can have many destinations; for reassembly purposes
* use the null address, like a broadcast.
*/
smpp_handle_msg(tree, tvb_msg, pinfo, src_str, "");
}
}
static void
alert_notification(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
{
proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
smpp_handle_string(tree, tvb, hf_smpp_source_addr, &offset);
proto_tree_add_item(tree, hf_smpp_esme_addr_ton, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_esme_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
smpp_handle_string(tree, tvb, hf_smpp_esme_addr, &offset);
smpp_handle_tlv(tree, tvb, pinfo, &offset, NULL);
}
static void
data_sm(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
{
tvbuff_t *tvb_msg = NULL;
smpp_data_t *smpp_data;
const char *src_str = NULL;
const char *dst_str = NULL;
smpp_data = get_smpp_data(pinfo);
smpp_handle_string_z(tree, tvb, hf_smpp_service_type, &offset, "(Default)");
proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
src_str = smpp_handle_string_return(tree, tvb, pinfo, hf_smpp_source_addr, &offset);
proto_tree_add_item(tree, hf_smpp_dest_addr_ton, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_dest_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
dst_str = smpp_handle_string_return(tree, tvb, pinfo, hf_smpp_destination_addr, &offset);
smpp_data->udhi = tvb_get_guint8(tvb, offset) & SMPP_UDHI_MASK;
proto_tree_add_bitmask_list(tree, tvb, offset, 1, submit_msg_fields, ENC_NA);
offset++;
proto_tree_add_bitmask_list(tree, tvb, offset, 1, regdel_fields, ENC_NA);
offset++;
smpp_handle_dcs(tree, tvb, &offset, &smpp_data->encoding);
smpp_handle_tlv(tree, tvb, pinfo, &offset, &tvb_msg);
if (tvb_msg) {
smpp_handle_msg(tree, tvb_msg, pinfo, src_str, dst_str);
}
}
/*
* Request operations introduced in the SMPP 5.0
*/
static void
broadcast_sm(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
{
nstime_t zero_time = NSTIME_INIT_ZERO;
tvbuff_t *tvb_msg = NULL;
smpp_data_t *smpp_data;
const char *src_str = NULL;
smpp_data = get_smpp_data(pinfo);
smpp_handle_string_z(tree, tvb, hf_smpp_service_type, &offset, "(Default)");
proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
src_str = smpp_handle_string_return(tree, tvb, pinfo, hf_smpp_source_addr, &offset);
smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
proto_tree_add_item(tree, hf_smpp_priority_flag, tvb, offset, 1, ENC_NA);
offset += 1;
if (tvb_get_guint8(tvb,offset)) {
smpp_handle_time(tree, tvb, pinfo, hf_smpp_schedule_delivery_time,
hf_smpp_schedule_delivery_time_r, &offset);
} else { /* Time = NULL means Immediate delivery */
proto_tree_add_time_format_value(tree, hf_smpp_schedule_delivery_time_r, tvb, offset++, 1, &zero_time, "Immediate delivery");
}
if (tvb_get_guint8(tvb,offset)) {
smpp_handle_time(tree, tvb, pinfo, hf_smpp_validity_period, hf_smpp_validity_period_r, &offset);
} else { /* Time = NULL means SMSC default validity */
proto_tree_add_time_format_value(tree, hf_smpp_validity_period_r, tvb, offset++, 1, &zero_time, "SMSC default validity period");
}
proto_tree_add_item(tree, hf_smpp_replace_if_present_flag, tvb, offset, 1, ENC_NA);
offset += 1;
smpp_handle_dcs(tree, tvb, &offset, &smpp_data->encoding);
proto_tree_add_item(tree, hf_smpp_sm_default_msg_id, tvb, offset, 1, ENC_NA);
offset += 1;
smpp_handle_tlv(tree, tvb, pinfo, &offset, &tvb_msg);
if (tvb_msg) {
smpp_handle_msg(tree, tvb_msg, pinfo, src_str, "");
}
}
static void
query_broadcast_sm(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
{
smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
smpp_handle_string(tree, tvb, hf_smpp_source_addr, &offset);
smpp_handle_tlv(tree, tvb, pinfo, &offset, NULL);
}
static void
cancel_broadcast_sm(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
{
smpp_handle_string_z(tree, tvb, hf_smpp_service_type, &offset, "(Default)");
smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
smpp_handle_string(tree, tvb, hf_smpp_source_addr, &offset);
smpp_handle_tlv(tree, tvb, pinfo, &offset, NULL);
}
/*!
* The next set of routines handle the different operation-responses,
* associated with SMPP.
*/
static void
bind_receiver_resp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
{
smpp_handle_string(tree, tvb, hf_smpp_system_id, &offset);
smpp_handle_tlv(tree, tvb, pinfo, &offset, NULL);
}
static void
query_sm_resp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
{
smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
smpp_handle_time(tree, tvb, pinfo, hf_smpp_final_date,
hf_smpp_final_date_r, &offset);
proto_tree_add_item(tree, hf_smpp_message_state, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_smpp_error_code, tvb, offset, 1, ENC_NA);
offset += 1;
}
static void
submit_sm_resp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
{
smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
smpp_handle_tlv(tree, tvb, pinfo, &offset, NULL);
}
static void
submit_multi_resp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
{
smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
smpp_handle_dlist_resp(tree, tvb, &offset);
smpp_handle_tlv(tree, tvb, pinfo, &offset, NULL);
}
static void
data_sm_resp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
{
smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
smpp_handle_tlv(tree, tvb, pinfo, &offset, NULL);
}
static void
query_broadcast_sm_resp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
{
smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
smpp_handle_tlv(tree, tvb, pinfo, &offset, NULL);
}
/* Huawei SMPP+ extensions */
static void
huawei_auth_acc(proto_tree *tree, tvbuff_t *tvb, int offset)
{
guint32 version;
proto_tree_add_item_ret_uint(tree, hf_smpp_error_code, tvb, offset, 1, ENC_NA, &version);
offset += 1;
smpp_handle_string(tree, tvb, hf_huawei_smpp_smsc_addr, &offset);
if ( version == '3' ) {
proto_tree_add_item(tree, hf_huawei_smpp_msc_addr_noa, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_huawei_smpp_msc_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
smpp_handle_string(tree, tvb, hf_huawei_smpp_msc_addr, &offset);
}
smpp_handle_string(tree, tvb, hf_smpp_source_addr, &offset);
smpp_handle_string(tree, tvb, hf_smpp_destination_addr, &offset);
proto_tree_add_item(tree, hf_huawei_smpp_mo_mt_flag, tvb, offset, 1, ENC_NA);
offset += 1;
smpp_handle_string(tree, tvb, hf_huawei_smpp_sm_id, &offset);
proto_tree_add_item(tree, hf_huawei_smpp_length_auth, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_huawei_smpp_service_id, tvb, offset, 4, ENC_BIG_ENDIAN);
}
static void
huawei_auth_acc_resp(proto_tree *tree, tvbuff_t *tvb, int offset)
{
proto_tree_add_item(tree, hf_huawei_smpp_operation_result, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_huawei_smpp_notify_mode, tvb, offset, 1, ENC_NA);
}
static void
huawei_sm_result_notify(proto_tree *tree, tvbuff_t *tvb, int offset)
{
guint32 version;
proto_tree_add_item_ret_uint(tree, hf_smpp_error_code, tvb, offset, 1, ENC_NA, &version);
offset += 1;
smpp_handle_string(tree, tvb, hf_huawei_smpp_smsc_addr, &offset);
if ( version == '3' ) {
proto_tree_add_item(tree, hf_huawei_smpp_msc_addr_noa, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_huawei_smpp_msc_addr_npi, tvb, offset, 1, ENC_NA);
offset += 1;
smpp_handle_string(tree, tvb, hf_huawei_smpp_msc_addr, &offset);
}
smpp_handle_string(tree, tvb, hf_smpp_source_addr, &offset);
smpp_handle_string(tree, tvb, hf_smpp_destination_addr, &offset);
proto_tree_add_item(tree, hf_huawei_smpp_mo_mt_flag, tvb, offset, 1, ENC_NA);
offset += 1;
smpp_handle_string(tree, tvb, hf_huawei_smpp_sm_id, &offset);
proto_tree_add_item(tree, hf_huawei_smpp_length_auth, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_huawei_smpp_delivery_result, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_huawei_smpp_service_id, tvb, offset, 4, ENC_BIG_ENDIAN);
}
static void
huawei_sm_result_notify_resp(proto_tree *tree, tvbuff_t *tvb, int offset)
{
proto_tree_add_item(tree, hf_huawei_smpp_delivery_result, tvb, offset, 4, ENC_BIG_ENDIAN);
}
static gboolean
test_smpp(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
{
guint32 command_id; /* SMPP command */
guint32 command_status; /* Status code */
guint32 command_length; /* length of PDU */
if (tvb_reported_length_remaining(tvb, offset) < SMPP_MIN_LENGTH || /* Mandatory header */
tvb_captured_length_remaining(tvb, offset) < 12)
return FALSE;
command_length = tvb_get_ntohl(tvb, offset);
if (command_length > 64 * 1024 || command_length < SMPP_MIN_LENGTH)
return FALSE;
command_id = tvb_get_ntohl(tvb, offset + 4); /* Only known commands */
if (try_val_to_str(command_id, vals_command_id) == NULL)
return FALSE;
command_status = tvb_get_ntohl(tvb, offset + 8); /* ..with known status */
if (try_rval_to_str(command_status, rvals_command_status) == NULL)
return FALSE;
return TRUE;
}
static guint
get_smpp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
{
return tvb_get_ntohl(tvb, offset);
}
static void
export_smpp_pdu(packet_info *pinfo, tvbuff_t *tvb)
{
exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, "smpp", EXP_PDU_TAG_DISSECTOR_NAME);
exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb);
exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
exp_pdu_data->pdu_tvb = tvb;
tap_queue_packet(exported_pdu_tap, pinfo, exp_pdu_data);
}
/* Dissect a single SMPP PDU contained within "tvb". */
static int
dissect_smpp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
int offset = 0; /* Offset within tvbuff */
guint command_length; /* length of PDU */
guint command_id; /* SMPP command */
guint command_status; /* Status code */
guint sequence_number; /* ...of command */
smpp_tap_rec_t *tap_rec; /* Tap record */
const gchar *command_str;
const gchar *command_status_str = NULL;
/* Set up structures needed to add the protocol subtree and manage it */
proto_item *ti;
proto_tree *smpp_tree;
/*
* Safety: don't even try to dissect the PDU
* when the mandatory header isn't present.
*/
if (tvb_reported_length(tvb) < SMPP_MIN_LENGTH)
return 0;
command_length = tvb_get_ntohl(tvb, offset);
offset += 4;
command_id = tvb_get_ntohl(tvb, offset);
command_str = val_to_str(command_id, vals_command_id,
"(Unknown SMPP Operation 0x%08X)");
offset += 4;
command_status = tvb_get_ntohl(tvb, offset);
if (command_id & SMPP_COMMAND_ID_RESPONSE_MASK) {
/* PDU is a response. */
command_status_str = rval_to_str(command_status, rvals_command_status, "Unknown (0x%08x)");
}
offset += 4;
sequence_number = tvb_get_ntohl(tvb, offset);
if (have_tap_listener(exported_pdu_tap)){
export_smpp_pdu(pinfo,tvb);
}
/*
* Update the protocol column.
*/
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMPP");
col_clear(pinfo->cinfo, COL_INFO);
/*
* Create display subtree for the protocol
*/
ti = proto_tree_add_item (tree, proto_smpp, tvb, 0, tvb_captured_length(tvb), ENC_NA);
smpp_tree = proto_item_add_subtree (ti, ett_smpp);
/*
* Make entries in the Info column on the summary display
*/
col_append_sep_str(pinfo->cinfo, COL_INFO, ", ", command_str);
/*
* Display command status of responses in Info column
*/
if (command_id & SMPP_COMMAND_ID_RESPONSE_MASK) {
col_append_fstr(pinfo->cinfo, COL_INFO, ": \"%s\"", command_status_str);
}
/*
* Set the fence before dissecting the PDU because if the PDU is invalid it
* may throw an exception and the next PDU will clear the info about the
* current PDU
*/
col_set_fence(pinfo->cinfo, COL_INFO);
/*
* Dissect the PDU
*/
/*
* Create display subtree for the PDU
*/
proto_tree_add_uint(smpp_tree, hf_smpp_command_length, tvb, 0, 4, command_length);
if (command_id & SMPP_COMMAND_ID_RESPONSE_MASK) {
ti = proto_tree_add_boolean(smpp_tree, hf_smpp_command_response, tvb, 4, 4, TRUE);
}
else {
ti = proto_tree_add_boolean(smpp_tree, hf_smpp_command_request, tvb, 4, 4, TRUE);
}
proto_item_set_generated(ti);
proto_tree_add_uint(smpp_tree, hf_smpp_command_id, tvb, 4, 4, command_id);
proto_item_append_text(smpp_tree, ", Command: %s", command_str);
/*
* Status is only meaningful with responses
*/
if (command_id & SMPP_COMMAND_ID_RESPONSE_MASK) {
proto_tree_add_uint(smpp_tree, hf_smpp_command_status, tvb, 8, 4, command_status);
proto_item_append_text (smpp_tree, ", Status: \"%s\"", command_status_str);
}
proto_tree_add_uint(smpp_tree, hf_smpp_sequence_number, tvb, 12, 4, sequence_number);
proto_item_append_text(smpp_tree, ", Seq: %u, Len: %u", sequence_number, command_length);
if (command_length <= tvb_reported_length(tvb))
{
if (command_id & SMPP_COMMAND_ID_RESPONSE_MASK)
{
switch (command_id & (~SMPP_COMMAND_ID_RESPONSE_MASK)) {
/*
* All of these only have a fixed header
*/
case SMPP_COMMAND_ID_GENERIC_NACK:
case SMPP_COMMAND_ID_UNBIND:
case SMPP_COMMAND_ID_REPLACE_SM:
case SMPP_COMMAND_ID_CANCEL_SM:
case SMPP_COMMAND_ID_ENQUIRE_LINK:
case SMPP_COMMAND_ID_CANCEL_BROADCAST_SM:
break;
/* FIXME: The body of the response PDUs are only
* only dissected if the request was successful.
* However, in SMPP 5.0 some responses might
* contain body to provide additional information
* about the error. This needs to be handled.
*/
case SMPP_COMMAND_ID_BIND_RECEIVER:
case SMPP_COMMAND_ID_BIND_TRANSMITTER:
case SMPP_COMMAND_ID_BIND_TRANSCEIVER:
if (!command_status)
bind_receiver_resp(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_QUERY_SM:
if (!command_status)
query_sm_resp(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_SUBMIT_SM:
case SMPP_COMMAND_ID_DELIVER_SM:
case SMPP_COMMAND_ID_BROADCAST_SM:
if (!command_status)
submit_sm_resp(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_SUBMIT_MULTI:
if (!command_status)
submit_multi_resp(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_DATA_SM:
if (!command_status)
data_sm_resp(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_QUERY_BROADCAST_SM:
if (!command_status)
query_broadcast_sm_resp(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_HUAWEI_AUTH_ACC:
if (!command_status)
huawei_auth_acc_resp(smpp_tree, tvb, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_HUAWEI_SM_RESULT_NOTIFY:
if (!command_status)
huawei_sm_result_notify_resp(smpp_tree, tvb, SMPP_FIXED_HEADER_LENGTH);
break;
default:
break;
} /* switch (command_id & 0x7FFFFFFF) */
}
else
{
switch (command_id) {
case SMPP_COMMAND_ID_BIND_RECEIVER:
case SMPP_COMMAND_ID_BIND_TRANSMITTER:
case SMPP_COMMAND_ID_BIND_TRANSCEIVER:
bind_receiver(smpp_tree, tvb, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_QUERY_SM:
query_sm(smpp_tree, tvb, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_SUBMIT_SM:
case SMPP_COMMAND_ID_DELIVER_SM:
submit_sm(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_UNBIND:
case SMPP_COMMAND_ID_ENQUIRE_LINK:
break;
case SMPP_COMMAND_ID_REPLACE_SM:
replace_sm(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_CANCEL_SM:
cancel_sm(smpp_tree, tvb, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_OUTBIND:
outbind(smpp_tree, tvb, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_SUBMIT_MULTI:
submit_multi(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_ALERT_NOTIFICATION:
alert_notification(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_DATA_SM:
data_sm(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_BROADCAST_SM:
broadcast_sm(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_QUERY_BROADCAST_SM:
query_broadcast_sm(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_CANCEL_BROADCAST_SM:
cancel_broadcast_sm(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_HUAWEI_AUTH_ACC:
huawei_auth_acc(smpp_tree, tvb, SMPP_FIXED_HEADER_LENGTH);
break;
case SMPP_COMMAND_ID_HUAWEI_SM_RESULT_NOTIFY:
huawei_sm_result_notify(smpp_tree, tvb, SMPP_FIXED_HEADER_LENGTH);
break;
default:
break;
} /* switch (command_id) */
}
}
/* Queue packet for Tap */
tap_rec = wmem_new0(pinfo->pool, smpp_tap_rec_t);
tap_rec->command_id = command_id;
tap_rec->command_status = command_status;
tap_queue_packet(smpp_tap, pinfo, tap_rec);
return tvb_captured_length(tvb);
}
static int
dissect_smpp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
if (pinfo->ptype == PT_TCP) { /* are we running on top of TCP */
if (!test_smpp(pinfo, tvb, 0, data)) {
return 0;
}
tcp_dissect_pdus(tvb, pinfo, tree,
reassemble_over_tcp, /* Do we try to reassemble */
SMPP_FIXED_HEADER_LENGTH, /* Length of fixed header */
/* XXX: We only use the first 4 bytes for the length, do we
* really need to pass in the entire fixed header? */
get_smpp_pdu_len, /* Function returning PDU len */
dissect_smpp_pdu, data); /* PDU dissector */
}
else { /* no? probably X.25 */
guint32 offset = 0;
while (tvb_reported_length_remaining(tvb, offset) > 0) {
guint16 pdu_len = tvb_get_ntohl(tvb, offset);
gint pdu_real_len = tvb_captured_length_remaining(tvb, offset);
tvbuff_t *pdu_tvb;
if (pdu_len < 1)
return offset;
if (pdu_real_len <= 0)
return offset;
if (pdu_real_len > pdu_len)
pdu_real_len = pdu_len;
pdu_tvb = tvb_new_subset_length_caplen(tvb, offset, pdu_real_len, pdu_len);
dissect_smpp_pdu(pdu_tvb, pinfo, tree, data);
offset += pdu_len;
}
}
return tvb_captured_length(tvb);
}
/*
* A 'heuristic dissector' that attemtps to establish whether we have
* a genuine SMPP PDU here.
* Only works when:
* at least the fixed header is there
* it has a correct overall PDU length
* it is a 'well-known' operation
* has a 'well-known' or 'reserved' status
*/
static gboolean
dissect_smpp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
guint32 command_id; /* SMPP command */
conversation_t* conversation;
if (!test_smpp(pinfo, tvb, 0, data)) {
return FALSE;
}
// Test a few extra bytes in the heuristic dissector, past the
// minimum fixed header length, to reduce false positives.
command_id = tvb_get_ntohl(tvb, 4);
//Check for specific values in commands (to avoid false positives)
switch (command_id)
{
case SMPP_COMMAND_ID_ALERT_NOTIFICATION:
{
guint8 ton, npi;
if (tvb_reported_length(tvb) < 19)
return FALSE;
ton = tvb_get_guint8(tvb, 16);
if (try_val_to_str(ton, vals_addr_ton) == NULL)
return FALSE;
npi = tvb_get_guint8(tvb, 17);
if (try_val_to_str(npi, vals_addr_npi) == NULL)
return FALSE;
//address must be NULL-terminated string of up to 65 ascii characters
int end = tvb_find_guint8(tvb, 18, -1, 0);
if ((end <= 0) || (end > 65))
return FALSE;
if (!tvb_ascii_isprint(tvb, 18, end - 18))
return FALSE;
}
break;
}
/* This is called on TCP or X.25, both of which are endpoint types.
* Set the conversation so we can handle TCP segmentation. */
conversation = find_or_create_conversation(pinfo);
conversation_set_dissector(conversation, smpp_handle);
dissect_smpp(tvb, pinfo, tree, data);
return TRUE;
}
static void
smpp_fmt_version(gchar *result, guint32 revision)
{
snprintf(result, ITEM_LABEL_LENGTH, "%u.%u", (guint8)((revision & 0xF0) >> 4), (guint8)(revision & 0x0F));
}
/* Register the protocol with Wireshark */
void
proto_register_smpp(void)
{
module_t *smpp_module; /* Preferences for SMPP */
expert_module_t *expert_smpp;
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_smpp_command_length,
{ "Length", "smpp.command_length",
FT_UINT32, BASE_DEC, NULL, 0x00,
"Total length of the SMPP PDU.",
HFILL
}
},
{ &hf_smpp_command_id,
{ "Operation", "smpp.command_id",
FT_UINT32, BASE_HEX, VALS(vals_command_id), 0x00,
"Defines the SMPP PDU.",
HFILL
}
},
{ &hf_smpp_command_request,
{ "Request", "smpp.request",
FT_BOOLEAN, BASE_NONE, NULL, 0x00,
"TRUE if this is a SMPP request.",
HFILL
}
},
{ &hf_smpp_command_response,
{ "Response", "smpp.response",
FT_BOOLEAN, BASE_NONE, NULL, 0x00,
"TRUE if this is a SMPP response.",
HFILL
}
},
{ &hf_smpp_command_status,
{ "Result", "smpp.command_status",
FT_UINT32, BASE_HEX | BASE_RANGE_STRING, RVALS(rvals_command_status), 0x00,
"Indicates success or failure of the SMPP request.",
HFILL
}
},
{ &hf_smpp_sequence_number,
{ "Sequence #", "smpp.sequence_number",
FT_UINT32, BASE_DEC, NULL, 0x00,
"A number to correlate requests with responses.",
HFILL
}
},
{ &hf_smpp_system_id,
{ "System ID", "smpp.system_id",
FT_STRING, BASE_NONE, NULL, 0x00,
"Identifies a system.",
HFILL
}
},
{ &hf_smpp_password,
{ "Password", "smpp.password",
FT_STRING, BASE_NONE, NULL, 0x00,
"Password used for authentication.",
HFILL
}
},
{ &hf_smpp_system_type,
{ "System type", "smpp.system_type",
FT_STRING, BASE_NONE, NULL, 0x00,
"Categorizes the system.",
HFILL
}
},
{ &hf_smpp_interface_version,
{ "Version (if)", "smpp.interface_version",
FT_UINT8, BASE_CUSTOM, CF_FUNC(smpp_fmt_version), 0x00,
"Version of SMPP interface supported.",
HFILL
}
},
{ &hf_smpp_service_type,
{ "Service type", "smpp.service_type",
FT_STRING, BASE_NONE, NULL, 0x00,
"SMS application service associated with the message.",
HFILL
}
},
{ &hf_smpp_addr_ton,
{ "Type of number", "smpp.addr_ton",
FT_UINT8, BASE_HEX, VALS(vals_addr_ton), 0x00,
"Indicates the type of number, given in the address.",
HFILL
}
},
{ &hf_smpp_source_addr_ton,
{ "Type of number (originator)", "smpp.source_addr_ton",
FT_UINT8, BASE_HEX, VALS(vals_addr_ton), 0x00,
"Indicates originator type of number, given in the address.",
HFILL
}
},
{ &hf_smpp_dest_addr_ton,
{ "Type of number (recipient)", "smpp.dest_addr_ton",
FT_UINT8, BASE_HEX, VALS(vals_addr_ton), 0x00,
"Indicates recipient type of number, given in the address.",
HFILL
}
},
{ &hf_smpp_addr_npi,
{ "Numbering plan indicator", "smpp.addr_npi",
FT_UINT8, BASE_HEX, VALS(vals_addr_npi), 0x00,
"Gives the numbering plan this address belongs to.",
HFILL
}
},
{ &hf_smpp_source_addr_npi,
{ "Numbering plan indicator (originator)", "smpp.source_addr_npi",
FT_UINT8, BASE_HEX, VALS(vals_addr_npi), 0x00,
"Gives originator numbering plan this address belongs to.",
HFILL
}
},
{ &hf_smpp_dest_addr_npi,
{ "Numbering plan indicator (recipient)", "smpp.dest_addr_npi",
FT_UINT8, BASE_HEX, VALS(vals_addr_npi), 0x00,
"Gives recipient numbering plan this address belongs to.",
HFILL
}
},
{ &hf_smpp_address_range,
{ "Address", "smpp.address_range",
FT_STRING, BASE_NONE, NULL, 0x00,
"Given address or address range.",
HFILL
}
},
{ &hf_smpp_source_addr,
{ "Originator address", "smpp.source_addr",
FT_STRING, BASE_NONE, NULL, 0x00,
"Address of SME originating this message.",
HFILL
}
},
{ &hf_smpp_destination_addr,
{ "Recipient address", "smpp.destination_addr",
FT_STRING, BASE_NONE, NULL, 0x00,
"Address of SME receiving this message.",
HFILL
}
},
{ &hf_smpp_esm_submit_msg_mode,
{ "Messaging mode", "smpp.esm.submit.msg_mode",
FT_UINT8, BASE_HEX, VALS(vals_esm_submit_msg_mode), 0x03,
"Mode attribute for this message.",
HFILL
}
},
{ &hf_smpp_esm_submit_msg_type,
{ "Message type", "smpp.esm.submit.msg_type",
FT_UINT8, BASE_HEX, VALS(vals_esm_submit_msg_type), 0x3C,
"Type attribute for this message.",
HFILL
}
},
{ &hf_smpp_esm_submit_features,
{ "GSM features", "smpp.esm.submit.features",
FT_UINT8, BASE_HEX, VALS(vals_esm_submit_features), 0xC0,
"GSM network specific features.",
HFILL
}
},
/*! \todo Get proper values from GSM-spec. */
{ &hf_smpp_protocol_id,
{ "Protocol id.", "smpp.protocol_id",
FT_UINT8, BASE_HEX, NULL, 0x00,
"Protocol identifier according GSM 03.40.",
HFILL
}
},
{ &hf_smpp_priority_flag,
{ "Priority level", "smpp.priority_flag",
FT_UINT8, BASE_HEX, VALS(vals_priority_flag), 0x00,
"The priority level of the short message.",
HFILL
}
},
{ &hf_smpp_schedule_delivery_time,
{ "Scheduled delivery time", "smpp.schedule_delivery_time",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x00,
"Scheduled time for delivery of short message.",
HFILL
}
},
{ &hf_smpp_schedule_delivery_time_r,
{ "Scheduled delivery time", "smpp.schedule_delivery_time_r",
FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
"Scheduled time for delivery of short message.",
HFILL
}
},
{ &hf_smpp_validity_period,
{ "Validity period", "smpp.validity_period",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x00,
"Validity period of this message.",
HFILL
}
},
{ &hf_smpp_validity_period_r,
{ "Validity period", "smpp.validity_period_r",
FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
"Validity period of this message.",
HFILL
}
},
{ &hf_smpp_regdel_receipt,
{ "Delivery receipt", "smpp.regdel.receipt",
FT_UINT8, BASE_HEX, VALS(vals_regdel_receipt), 0x03,
"SMSC delivery receipt request.",
HFILL
}
},
{ &hf_smpp_regdel_acks,
{ "Message type", "smpp.regdel.acks",
FT_UINT8, BASE_HEX, VALS(vals_regdel_acks), 0x0C,
"SME acknowledgement request.",
HFILL
}
},
{ &hf_smpp_regdel_notif,
{ "Intermediate notif", "smpp.regdel.notif",
FT_UINT8, BASE_HEX, VALS(vals_regdel_notif), 0x10,
"Intermediate notification request.",
HFILL
}
},
{ &hf_smpp_replace_if_present_flag,
{ "Replace", "smpp.replace_if_present_flag",
FT_UINT8, BASE_HEX, VALS(vals_replace_if_present_flag), 0x01,
"Replace the short message with this one or not.",
HFILL
}
},
{ &hf_smpp_data_coding,
{ "Data coding", "smpp.data_coding",
FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(rvals_data_coding), 0x00,
"Defines the encoding scheme of the message.",
HFILL
}
},
{ &hf_smpp_sm_default_msg_id,
{ "Predefined message", "smpp.sm_default_msg_id",
FT_UINT8, BASE_DEC, NULL, 0x00,
"Index of a predefined ('canned') short message.",
HFILL
}
},
{ &hf_smpp_sm_length,
{ "Message length", "smpp.sm_length",
FT_UINT8, BASE_DEC, NULL, 0x00,
"Length of the message content.",
HFILL
}
},
{ &hf_smpp_short_message,
{ "Message", "smpp.message_text",
FT_STRING, BASE_NONE, NULL, 0x00,
"The actual message or data.",
HFILL
}
},
{ &hf_smpp_short_message_bin,
{ "Message bytes", "smpp.message",
FT_BYTES, BASE_NONE, NULL, 0x00,
"The actual message bytes.",
HFILL
}
},
{ &hf_smpp_message_id,
{ "Message id.", "smpp.message_id",
FT_STRING, BASE_NONE, NULL, 0x00,
"Identifier of the submitted short message.",
HFILL
}
},
{ &hf_smpp_dlist,
{ "Destination list", "smpp.dlist",
FT_NONE, BASE_NONE, NULL, 0x00,
"The list of destinations for a short message.",
HFILL
}
},
{ &hf_smpp_dlist_resp,
{ "Unsuccessful delivery list", "smpp.dlist_resp",
FT_NONE, BASE_NONE, NULL, 0x00,
"The list of unsuccessful deliveries to destinations.",
HFILL
}
},
{ &hf_smpp_dl_name,
{ "Distr. list name", "smpp.dl_name",
FT_STRING, BASE_NONE, NULL, 0x00,
"The name of the distribution list.",
HFILL
}
},
{ &hf_smpp_final_date,
{ "Final date", "smpp.final_date",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x00,
"Date-time when the queried message reached a final state.",
HFILL
}
},
{ &hf_smpp_final_date_r,
{ "Final date", "smpp.final_date_r",
FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
"Date-time when the queried message reached a final state.",
HFILL
}
},
{ &hf_smpp_message_state,
{ "Message state", "smpp.message_state",
FT_UINT8, BASE_DEC, VALS(vals_message_state), 0x00,
"Specifies the status of the queried short message.",
HFILL
}
},
{ &hf_smpp_error_code,
{ "Error code", "smpp.error_code",
FT_UINT8, BASE_DEC, NULL, 0x00,
"Network specific error code defining reason for failure.",
HFILL
}
},
{ &hf_smpp_error_status_code,
{ "Status", "smpp.error_status_code",
FT_UINT32, BASE_HEX | BASE_RANGE_STRING, RVALS(rvals_command_status), 0x00,
"Indicates success/failure of request for this address.",
HFILL
}
},
{ &hf_smpp_esme_addr_ton,
{ "Type of number (ESME)", "smpp.esme_addr_ton",
FT_UINT8, BASE_HEX, VALS(vals_addr_ton), 0x00,
"Indicates recipient type of number, given in the address.",
HFILL
}
},
{ &hf_smpp_esme_addr_npi,
{ "Numbering plan indicator (ESME)", "smpp.esme_addr_npi",
FT_UINT8, BASE_HEX, VALS(vals_addr_npi), 0x00,
"Gives the numbering plan this address belongs to.",
HFILL
}
},
{ &hf_smpp_esme_addr,
{ "ESME address", "smpp.esme_addr",
FT_STRING, BASE_NONE, NULL, 0x00,
"Address of ESME originating this message.",
HFILL
}
},
{ &hf_smpp_dest_addr_subunit,
{ "Subunit destination", "smpp.dest_addr_subunit",
FT_UINT8, BASE_HEX, VALS(vals_addr_subunit), 0x00,
"Subunit address within mobile to route message to.",
HFILL
}
},
{ &hf_smpp_source_addr_subunit,
{ "Subunit origin", "smpp.source_addr_subunit",
FT_UINT8, BASE_HEX, VALS(vals_addr_subunit), 0x00,
"Subunit address within mobile that generated the message.",
HFILL
}
},
{ &hf_smpp_dest_network_type,
{ "Destination network", "smpp.dest_network_type",
FT_UINT8, BASE_HEX, VALS(vals_network_type), 0x00,
"Network associated with the destination address.",
HFILL
}
},
{ &hf_smpp_source_network_type,
{ "Originator network", "smpp.source_network_type",
FT_UINT8, BASE_HEX, VALS(vals_network_type), 0x00,
"Network associated with the originator address.",
HFILL
}
},
{ &hf_smpp_dest_bearer_type,
{ "Destination bearer", "smpp.dest_bearer_type",
FT_UINT8, BASE_HEX, VALS(vals_bearer_type), 0x00,
"Desired bearer for delivery of message.",
HFILL
}
},
{ &hf_smpp_source_bearer_type,
{ "Originator bearer", "smpp.source_bearer_type",
FT_UINT8, BASE_HEX, VALS(vals_bearer_type), 0x00,
"Bearer over which the message originated.",
HFILL
}
},
{ &hf_smpp_dest_telematics_id,
{ "Telematic interworking (dest)", "smpp.dest_telematics_id",
FT_UINT16, BASE_HEX, NULL, 0x00,
"Telematic interworking to be used for message delivery.",
HFILL
}
},
{ &hf_smpp_source_telematics_id,
{ "Telematic interworking (orig)", "smpp.source_telematics_id",
FT_UINT8, BASE_HEX, NULL, 0x00,
"Telematic interworking used for message submission.",
HFILL
}
},
{ &hf_smpp_qos_time_to_live,
{ "Validity period", "smpp.qos_time_to_live",
FT_UINT32, BASE_DEC, NULL, 0x00,
"Number of seconds to retain message before expiry.",
HFILL
}
},
{ &hf_smpp_payload_type,
{ "Payload", "smpp.payload_type",
FT_UINT8, BASE_DEC, VALS(vals_payload_type), 0x00,
"PDU type contained in the message payload.",
HFILL
}
},
{ &hf_smpp_additional_status_info_text,
{ "Information", "smpp.additional_status_info_text",
FT_STRING, BASE_NONE, NULL, 0x00,
"Description of the meaning of a response PDU.",
HFILL
}
},
{ &hf_smpp_receipted_message_id,
{ "SMSC identifier", "smpp.receipted_message_id",
FT_STRING, BASE_NONE, NULL, 0x00,
"SMSC handle of the message being received.",
HFILL
}
},
{ &hf_smpp_privacy_indicator,
{ "Privacy indicator", "smpp.privacy_indicator",
FT_UINT8, BASE_DEC, VALS(vals_privacy_indicator), 0x00,
"Indicates the privacy level of the message.",
HFILL
}
},
{ &hf_smpp_source_subaddress,
{ "Source Subaddress", "smpp.source_subaddress",
FT_BYTES, BASE_NONE, NULL, 0x00,
NULL,
HFILL
}
},
{ &hf_smpp_dest_subaddress,
{ "Destination Subaddress", "smpp.dest_subaddress",
FT_BYTES, BASE_NONE, NULL, 0x00,
NULL,
HFILL
}
},
{ &hf_smpp_user_message_reference,
{ "Message reference", "smpp.user_message_reference",
FT_UINT16, BASE_HEX, NULL, 0x00,
"Reference to the message, assigned by the user.",
HFILL
}
},
{ &hf_smpp_user_response_code,
{ "Application response code", "smpp.user_response_code",
FT_UINT8, BASE_HEX, NULL, 0x00,
"A response code set by the user.",
HFILL
}
},
{ &hf_smpp_language_indicator,
{ "Language", "smpp.language_indicator",
FT_UINT8, BASE_DEC, VALS(vals_language_indicator), 0x00,
"Indicates the language of the short message.",
HFILL
}
},
{ &hf_smpp_source_port,
{ "Source port", "smpp.source_port",
FT_UINT16, BASE_HEX, NULL, 0x00,
"Application port associated with the source of the message.",
HFILL
}
},
{ &hf_smpp_destination_port,
{ "Destination port", "smpp.destination_port",
FT_UINT16, BASE_HEX, NULL, 0x00,
"Application port associated with the destination of the message.",
HFILL
}
},
{ &hf_smpp_sar_msg_ref_num,
{ "SAR reference number", "smpp.sar_msg_ref_num",
FT_UINT16, BASE_DEC, NULL, 0x00,
"Reference number for a concatenated short message.",
HFILL
}
},
{ &hf_smpp_sar_total_segments,
{ "SAR size", "smpp.sar_total_segments",
FT_UINT16, BASE_DEC, NULL, 0x00,
"Number of segments of a concatenated short message.",
HFILL
}
},
{ &hf_smpp_sar_segment_seqnum,
{ "SAR sequence number", "smpp.sar_segment_seqnum",
FT_UINT8, BASE_DEC, NULL, 0x00,
"Segment number within a concatenated short message.",
HFILL
}
},
{ &hf_smpp_display_time,
{ "Display time", "smpp.display_time",
FT_UINT8, BASE_DEC, VALS(vals_display_time), 0x00,
"Associates a display time with the message on the handset.",
HFILL
}
},
{ &hf_smpp_sms_signal,
{ "SMS signal", "smpp.sms_signal",
FT_UINT16, BASE_HEX, NULL, 0x00,
"Alert the user according to the information contained within this information element.",
HFILL
}
},
{ &hf_smpp_ms_validity,
{ "Validity info", "smpp.ms_validity",
FT_UINT8, BASE_DEC, VALS(vals_ms_validity), 0x00,
"Associates validity info with the message on the handset.",
HFILL
}
},
{ &hf_smpp_dpf_result,
{ "Delivery pending set?", "smpp.dpf_result",
FT_UINT8, BASE_DEC, VALS(vals_dpf_result), 0x00,
"Indicates whether Delivery Pending Flag was set.",
HFILL
}
},
{ &hf_smpp_set_dpf,
{ "Request DPF set", "smpp.set_dpf",
FT_UINT8, BASE_DEC, VALS(vals_set_dpf), 0x00,
"Request to set the DPF for certain failure scenario's.",
HFILL
}
},
{ &hf_smpp_ms_availability_status,
{ "Availability status", "smpp.ms_availability_status",
FT_UINT8, BASE_DEC, VALS(vals_ms_availability_status), 0x00,
"Indicates the availability state of the handset.",
HFILL
}
},
{ &hf_smpp_delivery_failure_reason,
{ "Delivery failure reason", "smpp.delivery_failure_reason",
FT_UINT8, BASE_DEC, VALS(vals_delivery_failure_reason), 0x00,
"Indicates the reason for a failed delivery attempt.",
HFILL
}
},
{ &hf_smpp_more_messages_to_send,
{ "More messages?", "smpp.more_messages_to_send",
FT_UINT8, BASE_DEC, VALS(vals_more_messages_to_send), 0x00,
"Indicates more messages pending for the same destination.",
HFILL
}
},
{ &hf_smpp_number_of_messages,
{ "Number of messages", "smpp.number_of_messages",
FT_UINT8, BASE_DEC, NULL, 0x00,
"Indicates number of messages stored in a mailbox.",
HFILL
}
},
{ &hf_smpp_its_reply_type,
{ "Reply method", "smpp.its_reply_type",
FT_UINT8, BASE_DEC, VALS(vals_its_reply_type), 0x00,
"Indicates the handset reply method on message receipt.",
HFILL
}
},
{ &hf_smpp_ussd_service_op,
{ "USSD service operation", "smpp.ussd_service_op",
FT_UINT8, BASE_DEC, VALS(vals_ussd_service_op), 0x00,
"Indicates the USSD service operation.",
HFILL
}
},
{ &hf_smpp_vendor_op,
{ "Value", "smpp.vendor_op",
FT_BYTES, BASE_NONE|BASE_ALLOW_ZERO, NULL, 0x00,
"A supplied optional parameter specific to an SMSC-vendor.",
HFILL
}
},
{ &hf_smpp_reserved_op,
{ "Value", "smpp.reserved_op",
FT_BYTES, BASE_NONE|BASE_ALLOW_ZERO, NULL, 0x00,
"An optional parameter that is reserved in this version.",
HFILL
}
},
{ &hf_smpp_msg_wait_ind,
{ "Indication", "smpp.msg_wait.ind",
FT_UINT8, BASE_HEX, VALS(vals_msg_wait_ind), 0x80,
"Indicates to the handset that a message is waiting.",
HFILL
}
},
{ &hf_smpp_msg_wait_type,
{ "Type", "smpp.msg_wait.type",
FT_UINT8, BASE_HEX, VALS(vals_msg_wait_type), 0x03,
"Indicates type of message that is waiting.",
HFILL
}
},
{ &hf_smpp_SC_interface_version,
{ "SMSC-supported version", "smpp.SC_interface_version",
FT_UINT8, BASE_CUSTOM, CF_FUNC(smpp_fmt_version), 0x00,
"Version of SMPP interface supported by the SMSC.",
HFILL
}
},
{ &hf_smpp_callback_num_pres,
{ "Presentation", "smpp.callback_num.pres",
FT_UINT8, BASE_HEX, VALS(vals_callback_num_pres), 0x0C,
"Controls the presentation indication.",
HFILL
}
},
{ &hf_smpp_callback_num_scrn,
{ "Screening", "smpp.callback_num.scrn",
FT_UINT8, BASE_HEX, VALS(vals_callback_num_scrn), 0x03,
"Controls screening of the callback-number.",
HFILL
}
},
{ &hf_smpp_callback_num_atag,
{ "Callback number - alphanumeric display tag",
"smpp.callback_num_atag",
FT_NONE, BASE_NONE, NULL, 0x00,
"Associates an alphanumeric display with call back number.",
HFILL
}
},
{ &hf_smpp_callback_num,
{ "Callback number", "smpp.callback_num",
FT_NONE, BASE_NONE, NULL, 0x00,
"Associates a call back number with the message.",
HFILL
}
},
{ &hf_smpp_network_error_type,
{ "Error type", "smpp.network_error.type",
FT_UINT8, BASE_DEC, VALS(vals_network_error_type), 0x00,
"Indicates the network type.",
HFILL
}
},
{ &hf_smpp_network_error_code,
{ "Error code", "smpp.network_error.code",
FT_UINT16, BASE_HEX, NULL, 0x00,
"Gives the actual network error code.",
HFILL
}
},
{ &hf_smpp_message_payload,
{ "Payload", "smpp.message_payload",
FT_BYTES, BASE_NONE, NULL, 0x00,
"Short message user data.",
HFILL
}
},
{ &hf_smpp_alert_on_message_delivery_null,
{ "Alert on delivery", "smpp.alert_on_message_delivery_null",
FT_NONE, BASE_NONE, NULL, 0x00,
"Instructs the handset to alert user on message delivery.",
HFILL
}
},
{ &hf_smpp_alert_on_message_delivery_type,
{ "Alert on delivery", "smpp.alert_on_message_delivery_type",
FT_UINT8, BASE_DEC, VALS(vals_alert_on_message_delivery), 0x00,
"Instructs the handset to alert user on message delivery.",
HFILL
}
},
{ &hf_smpp_its_session_number,
{ "Session number", "smpp.its_session.number",
FT_UINT8, BASE_DEC, NULL, 0x00,
"Session number of interactive teleservice.",
HFILL
}
},
{ &hf_smpp_its_session_sequence,
{ "Sequence number", "smpp.its_session.sequence",
FT_UINT8, BASE_HEX, NULL, 0xFE,
"Sequence number of the dialogue unit.",
HFILL
}
},
{ &hf_smpp_its_session_ind,
{ "Session indicator", "smpp.its_session.ind",
FT_UINT8, BASE_HEX, VALS(vals_its_session_ind), 0x01,
"Indicates whether this message is end of conversation.",
HFILL
}
},
{ &hf_smpp_opt_params,
{ "Optional parameters", "smpp.opt_params",
FT_NONE, BASE_NONE, NULL, 0x00,
"The list of optional parameters in this operation.",
HFILL
}
},
{ &hf_smpp_opt_param,
{ "Optional parameter", "smpp.opt_param",
FT_NONE, BASE_NONE, NULL, 0x00,
NULL,
HFILL
}
},
{ &hf_smpp_opt_param_tag,
{ "Tag", "smpp.opt_param_tag",
FT_UINT16, BASE_HEX, NULL, 0x00,
"Optional parameter identifier tag",
HFILL
}
},
{ &hf_smpp_opt_param_len,
{ "Length", "smpp.opt_param_len",
FT_UINT16, BASE_DEC, NULL, 0x00,
"Optional parameter length",
HFILL
}
},
/*
* Data Coding Scheme
*/
{ &hf_smpp_dcs_sms_coding_group,
{ "DCS Coding Group for SMS", "smpp.dcs.sms_coding_group",
FT_UINT8, BASE_HEX, VALS(vals_dcs_sms_coding_group), 0xF0,
"Data Coding Scheme coding group for GSM Short Message Service.",
HFILL
}
},
{ &hf_smpp_dcs_reserved,
{ "Reserved (should be zero)", "smpp.dcs.reserved",
FT_UINT8, BASE_DEC, NULL, 0x08,
NULL, HFILL
}
},
{ &hf_smpp_dcs_charset,
{ "DCS Character set", "smpp.dcs.charset",
FT_UINT8, BASE_HEX, VALS(vals_dcs_charset), 0x04,
"Specifies the character set used in the message.", HFILL
}
},
{ &hf_smpp_dcs_class,
{ "DCS Message class", "smpp.dcs.class",
FT_UINT8, BASE_HEX, VALS(vals_dcs_class), 0x03,
"Specifies the message class.", HFILL
}
},
{ &hf_smpp_dcs_wait_ind,
{ "Indication", "smpp.dcs.wait_ind",
FT_UINT8, BASE_HEX, VALS(vals_msg_wait_ind), 0x08,
"Indicates to the handset that a message is waiting.",
HFILL
}
},
{ &hf_smpp_dcs_reserved2,
{ "Reserved (should be zero)", "smpp.dcs.reserved",
FT_UINT8, BASE_DEC, NULL, 0x04,
NULL, HFILL
}
},
{ &hf_smpp_dcs_wait_type,
{ "Type", "smpp.dcs.wait_type",
FT_UINT8, BASE_HEX, VALS(vals_msg_wait_type), 0x03,
"Indicates type of message that is waiting.",
HFILL
}
},
/* Changes in SMPP 5.0 */
{ &hf_smpp_congestion_state,
{ "Congestion State", "smpp.congestion_state",
FT_UINT8, BASE_DEC | BASE_RANGE_STRING, RVALS(vals_congestion_state), 0x00,
"Congestion info between ESME and MC for flow control/cong. control", HFILL
}
},
{ &hf_smpp_billing_identification,
{ "Billing Identification", "smpp.billing_id",
FT_BYTES, BASE_NONE, NULL, 0x00,
"Billing identification info", HFILL
}
},
{ &hf_smpp_dest_addr_np_country,
{ "Destination Country Code", "smpp.dest_addr_np_country",
FT_BYTES, BASE_NONE, NULL, 0x00,
"Destination Country Code (E.164 Region Code)", HFILL
}
},
{ &hf_smpp_dest_addr_np_information,
{ "Number Portability information", "smpp.dest_addr_np_info",
FT_BYTES, BASE_NONE, NULL, 0x00,
NULL, HFILL
}
},
{ &hf_smpp_dest_addr_np_resolution,
{ "Number Portability query information", "smpp.dest_addr_np_resolution",
FT_UINT8, BASE_DEC, VALS(vals_dest_addr_np_resolution), 0x00,
"Number Portability query information - method used to resolve number", HFILL
}
},
{ &hf_smpp_source_network_id,
{ "Source Network ID", "smpp.source_network_id",
FT_STRING, BASE_NONE, NULL, 0x00,
"Unique ID for a network or ESME operator", HFILL
}
},
{ &hf_smpp_source_node_id,
{ "Source Node ID", "smpp.source_node_id",
FT_BYTES, BASE_NONE, NULL, 0x00,
"Unique ID for a ESME or MC node", HFILL
}
},
{ &hf_smpp_dest_network_id,
{ "Destination Network ID", "smpp.dest_network_id",
FT_STRING, BASE_NONE, NULL, 0x00,
"Unique ID for a network or ESME operator", HFILL
}
},
{ &hf_smpp_dest_node_id,
{ "Destination Node ID", "smpp.dest_node_id",
FT_BYTES, BASE_NONE, NULL, 0x00,
"Unique ID for a ESME or MC node", HFILL
}
},
{ &hf_smpp_broadcast_channel_indicator,
{ "Cell Broadcast channel", "smpp.broadcast_channel_indicator",
FT_UINT8, BASE_DEC | BASE_RANGE_STRING, RVALS(vals_broadcast_channel_indicator), 0x00,
NULL, HFILL
}
},
{ &hf_smpp_broadcast_content_type_nw,
{ "Broadcast Content Type - Network Tag", "smpp.broadcast_content_type.nw",
FT_UINT8, BASE_DEC, VALS(vals_broadcast_content_type_nw), 0x00,
"Cell Broadcast content type", HFILL
}
},
{ &hf_smpp_broadcast_content_type_type,
{ "Broadcast Content Type - Content Type", "smpp.broadcast_content_type.type",
FT_UINT16, BASE_HEX, VALS(vals_broadcast_content_type_type), 0x00,
"Cell Broadcast content type", HFILL
}
},
{ &hf_smpp_broadcast_content_type_info,
{ "Broadcast Content Type Info", "smpp.broadcast_content_type.info",
FT_BYTES, BASE_NONE, NULL, 0x00,
"Cell Broadcast content type Info", HFILL
}
},
{ &hf_smpp_broadcast_message_class,
{ "Broadcast Message Class", "smpp.broadcast_message_class",
FT_UINT8, BASE_HEX, VALS(vals_broadcast_message_class), 0x00,
"Cell Broadcast Message Class", HFILL
}
},
{ &hf_smpp_broadcast_rep_num,
{ "Broadcast Message - Number of repetitions requested", "smpp.broadcast_rep_num",
FT_UINT16, BASE_DEC, NULL, 0x00,
"Cell Broadcast Message - Number of repetitions requested", HFILL
}
},
{ &hf_smpp_broadcast_frequency_interval_unit,
{ "Broadcast Message - frequency interval - Unit", "smpp.broadcast_frequency_interval.unit",
FT_UINT8, BASE_HEX, VALS(vals_broadcast_frequency_interval_unit), 0x00,
"Cell Broadcast Message - frequency interval at which broadcast must be repeated", HFILL
}
},
{ &hf_smpp_broadcast_frequency_interval_value,
{ "Broadcast Message - frequency interval - Unit", "smpp.broadcast_frequency_interval.value",
FT_UINT16, BASE_DEC, NULL, 0x00,
"Cell Broadcast Message - frequency interval at which broadcast must be repeated", HFILL
}
},
{ &hf_smpp_broadcast_area_identifier,
{ "Broadcast Message - Area Identifier", "smpp.broadcast_area_identifier",
FT_BYTES, BASE_NONE, NULL, 0x00,
"Cell Broadcast Message - Area Identifier", HFILL
}
},
{ &hf_smpp_broadcast_area_identifier_format,
{ "Broadcast Message - Area Identifier Format", "smpp.broadcast_area_identifier.format",
FT_UINT8, BASE_HEX | BASE_RANGE_STRING, RVALS(vals_broadcast_area_identifier_format), 0x00,
"Cell Broadcast Message - Area Identifier Format", HFILL
}
},
{ &hf_smpp_broadcast_error_status,
{ "Broadcast Message - Error Status", "smpp.broadcast_error_status",
FT_UINT32, BASE_HEX | BASE_RANGE_STRING, RVALS(rvals_command_status), 0x00,
"Cell Broadcast Message - Error Status", HFILL
}
},
{ &hf_smpp_broadcast_area_success,
{ "Broadcast Message - Area Success", "smpp.broadcast_area_success",
FT_UINT8, BASE_DEC | BASE_RANGE_STRING, RVALS(vals_broadcast_area_success), 0x00,
"Cell Broadcast Message - success rate indicator (ratio) - No. of BTS which accepted Message:Total BTS", HFILL
}
},
{ &hf_smpp_broadcast_end_time,
{ "Broadcast Message - End Time", "smpp.broadcast_end_time",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x00,
"Cell Broadcast Message - Date and time at which MC set the state of the message to terminated", HFILL
}
},
{ &hf_smpp_broadcast_end_time_r,
{ "Broadcast Message - End Time", "smpp.broadcast_end_time_r",
FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
"Cell Broadcast Message - Date and time at which MC set the state of the message to terminated", HFILL
}
},
{ &hf_smpp_broadcast_service_group,
{ "Broadcast Message - Service Group", "smpp.broadcast_service_group",
FT_BYTES, BASE_NONE, NULL, 0x00,
"Cell Broadcast Message - Service Group", HFILL
}
},
/* Huawei SMPP+ extensions */
{ &hf_huawei_smpp_smsc_addr,
{ "SMPP+: GT of SMSC", "smpp.smsc_addr",
FT_STRING, BASE_NONE, NULL, 0x00,
NULL, HFILL
}
},
{ &hf_huawei_smpp_msc_addr_noa,
{ "SMPP+: NOA of MSC address", "smpp.msc_addr_noa",
FT_UINT8, BASE_DEC, VALS(vals_msc_addr_noa), 0x00,
"SMPP+: Indicates the TON of MSC address", HFILL
}
},
{ &hf_huawei_smpp_msc_addr_npi,
{ "SMPP+: NPI of MSC address", "smpp.msc_addr_npi",
FT_UINT8, BASE_DEC, VALS(vals_msc_addr_npi), 0x00,
"SMPP+: Indicates the NPI of MSC address", HFILL
}
},
{ &hf_huawei_smpp_msc_addr,
{ "SMPP+: GT of MSC", "smpp.msc_addr",
FT_STRING, BASE_NONE, NULL, 0x00,
NULL, HFILL
}
},
{ &hf_huawei_smpp_mo_mt_flag,
{ "SMPP+: Charge for MO or MT", "smpp.mo_mt_flag",
FT_UINT8, BASE_DEC, VALS(vals_mo_mt_flag), 0x00,
"SMPP+: Indicates the Charge side of MO or MT", HFILL
}
},
{ &hf_huawei_smpp_sm_id,
{ "SMPP+: Unique SM ID", "smpp.sm_id",
FT_STRING, BASE_NONE, NULL, 0x00,
"SMPP+: Unique SM ID which is generated by SMSC", HFILL
}
},
{ &hf_huawei_smpp_length_auth,
{ "SMPP+: Length of SMS", "smpp.length_auth",
FT_UINT32, BASE_DEC, NULL, 0x00,
"SMPP+: Indicates the Length of SMS", HFILL
}
},
{ &hf_huawei_smpp_service_id,
{ "SMPP+: Service ID of SMSC", "smpp.service_id",
FT_UINT32, BASE_DEC, NULL, 0x00,
"SMPP+: Indicates the Service ID of SMSC", HFILL
}
},
{ &hf_huawei_smpp_operation_result,
{ "SMPP+: Authentication result of SCP", "smpp.operation_result",
FT_UINT32, BASE_DEC, VALS(vals_operation_result), 0x00,
"SMPP+: Indicates the Authentication result of SCP", HFILL
}
},
{ &hf_huawei_smpp_notify_mode,
{ "SMPP+: SMS notify mode", "smpp.notify_mode",
FT_UINT8, BASE_DEC, VALS(vals_notify_mode), 0x00,
"SMPP+: Indicates the SMS notify mode", HFILL
}
},
{ &hf_huawei_smpp_delivery_result,
{ "SMPP+: Delivery result of SMS", "smpp.delivery_result",
FT_UINT32, BASE_DEC, VALS(vals_delivery_result), 0x00,
"SMPP+: Indicates the Delivery result of SMS", HFILL
}
}
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_smpp,
&ett_dlist,
&ett_dlist_resp,
&ett_opt_params,
&ett_opt_param,
&ett_dcs,
};
static ei_register_info ei[] = {
{ &ei_smpp_message_payload_duplicate,
{ "smpp.message_payload.duplicate", PI_PROTOCOL, PI_WARN,
"short_message field and message_payload TLV can only appear once in total",
EXPFILL }
}
};
/* Encoding used to decode the SMS over SMPP when DCS is 0 */
static const enum_val_t smpp_dcs_0_sms_decode_options[] = {
{ "none", "None", DO_NOT_DECODE },
{ "ascii", "ASCII", ENC_ASCII },
{ "gsm7", "GSM 7-bit", ENC_3GPP_TS_23_038_7BITS_UNPACKED },
{ "gsm7-packed", "GSM 7-bit (packed)", ENC_3GPP_TS_23_038_7BITS_PACKED },
{ "iso-8859-1", "ISO-8859-1", ENC_ISO_8859_1 },
{ "iso-8859-5", "ISO-8859-5", ENC_ISO_8859_5 },
{ "iso-8859-8", "ISO-8859-8", ENC_ISO_8859_8 },
{ "ucs2", "UCS2", ENC_UCS_2|ENC_BIG_ENDIAN },
{ "ks-c-5601", "KS C 5601 (Korean)", ENC_EUC_KR },
{ NULL, NULL, 0 }
};
/* Register the protocol name and description */
proto_smpp = proto_register_protocol("Short Message Peer to Peer",
"SMPP", "smpp");
/* Required function calls to register header fields and subtrees used */
proto_register_field_array(proto_smpp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_smpp = expert_register_protocol(proto_smpp);
expert_register_field_array(expert_smpp, ei, array_length(ei));
/* Allow other dissectors to find this one by name. */
smpp_handle = register_dissector("smpp", dissect_smpp, proto_smpp);
/* Register for tapping */
smpp_tap = register_tap("smpp");
/* Preferences */
smpp_module = prefs_register_protocol (proto_smpp, NULL);
prefs_register_bool_preference (smpp_module,
"reassemble_smpp_over_tcp",
"Reassemble SMPP over TCP messages spanning multiple TCP segments",
"Whether the SMPP dissector should reassemble messages spanning multiple TCP segments."
" To use this option, you must also enable "
"\"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
&reassemble_over_tcp);
prefs_register_enum_preference(smpp_module, "decode_sms_over_smpp",
"Decode DCS 0 SMS as",
"Whether to decode the SMS contents when DCS is equal to 0 (zero).",
&smpp_decode_dcs_0_sms, smpp_dcs_0_sms_decode_options, FALSE);
prefs_register_bool_preference(smpp_module, "gsm7_unpacked",
"GSM 7-bit alphabet unpacked",
"When the DCS indicates that the encoding is the GSM 7-bit "
"alphabet, whether to decode it as unpacked (one character "
"per octet) instead of packed.",
&smpp_gsm7_unpacked);
}
void
proto_reg_handoff_smpp(void)
{
/*
* SMPP can be spoken on any port under TCP or X.25
* ...how *do* we do that under X.25?
*
* We can register the heuristic SMPP dissector with X.25, for one
* thing. We don't currently have any mechanism to allow the user
* to specify that a given X.25 circuit is to be dissected as SMPP,
* however.
*/
dissector_add_for_decode_as_with_preference("tcp.port", smpp_handle);
heur_dissector_add("tcp", dissect_smpp_heur, "SMPP over TCP Heuristics", "smpp_tcp", proto_smpp, HEURISTIC_ENABLE);
heur_dissector_add("x.25", dissect_smpp_heur, "SMPP over X.25 Heuristics", "smpp_x25", proto_smpp, HEURISTIC_ENABLE);
/* Required for call_dissector() */
gsm_sms_handle = find_dissector_add_dependency("gsm_sms_ud", proto_smpp);
DISSECTOR_ASSERT(gsm_sms_handle);
/* Tapping setup */
stats_tree_register_with_group("smpp","smpp_commands", "SM_PP Operations", 0,
smpp_stats_tree_per_packet, smpp_stats_tree_init,
NULL, REGISTER_STAT_GROUP_TELEPHONY);
exported_pdu_tap = find_tap_id(EXPORT_PDU_TAP_NAME_LAYER_7);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-smpp.h
|
/* packet-smpp.h
* Routines for Short Message Peer to Peer dissection
* Copyright 2001, Tom Uijldert.
*
* Data Coding Scheme decoding for GSM (SMS and CBS),
* provided by Olivier Biot.
*
* Dissection of multiple SMPP PDUs within one packet
* provided by Chris Wilson.
*
* Refer to the AUTHORS file or the AUTHORS section in the man page
* for contacting the author(s) of this file.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
* ----------
*
* Dissector of an SMPP (Short Message Peer to Peer) PDU, as defined by the
* SMS forum (www.smsforum.net) in "SMPP protocol specification v3.4"
* (document version: 12-Oct-1999 Issue 1.2)
*/
#ifndef __PACKET_SMPP_H_
#define __PACKET_SMPP_H_
#include "packet-gsm_sms.h"
typedef struct _smpp_data_t {
gboolean udhi;
guint encoding;
gsm_sms_udh_fields_t *udh_fields;
} smpp_data_t;
/*
* Export dissection of some parameters
*/
void smpp_handle_dcs(proto_tree *tree, tvbuff_t *tvb, int *offset, guint *encoding);
/* Tap Record */
typedef struct _smpp_tap_rec_t {
guint command_id;
guint command_status;
} smpp_tap_rec_t;
#endif
|
C
|
wireshark/epan/dissectors/packet-smrse.c
|
/* Do not modify this file. Changes will be overwritten. */
/* Generated automatically by the ASN.1 to Wireshark dissector compiler */
/* packet-smrse.c */
/* asn2wrs.py -b -L -p smrse -c ./smrse.cnf -s ./packet-smrse-template -D . -O ../.. SMRSE.asn */
/* packet-smrse.c
* Routines for SMRSE Short Message Relay Service packet dissection
* Ronnie Sahlberg 2004
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/asn1.h>
#include "packet-ber.h"
#include "packet-smrse.h"
#define PNAME "Short Message Relaying Service"
#define PSNAME "SMRSE"
#define PFNAME "smrse"
#define TCP_PORT_SMRSE 4321 /* Not IANA registered */
void proto_register_smrse(void);
void proto_reg_handoff_smrse(void);
static dissector_handle_t smrse_handle;
/* Initialize the protocol and registered fields */
static int proto_smrse = -1;
static int hf_smrse_reserved = -1;
static int hf_smrse_tag = -1;
static int hf_smrse_length = -1;
static int hf_smrse_Octet_Format = -1;
static int hf_smrse_sc_address = -1; /* SMS_Address */
static int hf_smrse_password = -1; /* Password */
static int hf_smrse_address_type = -1; /* T_address_type */
static int hf_smrse_numbering_plan = -1; /* T_numbering_plan */
static int hf_smrse_address_value = -1; /* T_address_value */
static int hf_smrse_octet_format = -1; /* T_octet_format */
static int hf_smrse_connect_fail_reason = -1; /* Connect_fail */
static int hf_smrse_mt_priority_request = -1; /* BOOLEAN */
static int hf_smrse_mt_mms = -1; /* BOOLEAN */
static int hf_smrse_mt_message_reference = -1; /* RP_MR */
static int hf_smrse_mt_originating_address = -1; /* SMS_Address */
static int hf_smrse_mt_destination_address = -1; /* SMS_Address */
static int hf_smrse_mt_user_data = -1; /* RP_UD */
static int hf_smrse_mt_origVMSCAddr = -1; /* SMS_Address */
static int hf_smrse_mt_tariffClass = -1; /* SM_TC */
static int hf_smrse_mo_message_reference = -1; /* RP_MR */
static int hf_smrse_mo_originating_address = -1; /* SMS_Address */
static int hf_smrse_mo_user_data = -1; /* RP_UD */
static int hf_smrse_origVMSCAddr = -1; /* SMS_Address */
static int hf_smrse_moimsi = -1; /* IMSI_Address */
static int hf_smrse_message_reference = -1; /* RP_MR */
static int hf_smrse_error_reason = -1; /* Error_reason */
static int hf_smrse_msg_waiting_set = -1; /* BOOLEAN */
static int hf_smrse_alerting_MS_ISDN = -1; /* SMS_Address */
static int hf_smrse_sm_diag_info = -1; /* RP_UD */
static int hf_smrse_ms_address = -1; /* SMS_Address */
/* Initialize the subtree pointers */
static gint ett_smrse = -1;
static gint ett_smrse_SMR_Bind = -1;
static gint ett_smrse_SMS_Address = -1;
static gint ett_smrse_T_address_value = -1;
static gint ett_smrse_SMR_Bind_Confirm = -1;
static gint ett_smrse_SMR_Bind_Failure = -1;
static gint ett_smrse_SMR_Unbind = -1;
static gint ett_smrse_RPDataMT = -1;
static gint ett_smrse_RPDataMO = -1;
static gint ett_smrse_RPAck = -1;
static gint ett_smrse_RPError = -1;
static gint ett_smrse_RPAlertSC = -1;
static const value_string smrse_T_address_type_vals[] = {
{ 0, "unknown-type" },
{ 1, "internat-number" },
{ 2, "national-number" },
{ 3, "net-spec-number" },
{ 4, "short-number" },
{ 0, NULL }
};
static int
dissect_smrse_T_address_type(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static const value_string smrse_T_numbering_plan_vals[] = {
{ 0, "unknown-numbering" },
{ 1, "iSDN-numbering" },
{ 3, "data-network-numbering" },
{ 4, "telex-numbering" },
{ 8, "national-numbering" },
{ 9, "private-numbering" },
{ 0, NULL }
};
static int
dissect_smrse_T_numbering_plan(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static int
dissect_smrse_T_octet_format(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
char *strp,tmpstr[21];
guint32 i, start_offset;
gint8 ber_class;
bool pc, ind;
gint32 tag;
guint32 len;
static char n2a[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
start_offset=offset;
/* skip the tag and length */
offset=dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &ber_class, &pc, &tag);
offset=dissect_ber_length(actx->pinfo, tree, tvb, offset, &len, &ind);
if(len>10){
len=10;
}
strp=tmpstr;
for(i=0;i<len;i++){
*strp++=n2a[tvb_get_guint8(tvb, offset)&0x0f];
*strp++=n2a[(tvb_get_guint8(tvb, offset)>>4)&0x0f];
offset++;
}
*strp=0;
proto_tree_add_string(tree, hf_smrse_Octet_Format, tvb, start_offset, offset-start_offset, tmpstr);
return offset;
}
static const value_string smrse_T_address_value_vals[] = {
{ 0, "octet-format" },
{ 0, NULL }
};
static const ber_choice_t T_address_value_choice[] = {
{ 0, &hf_smrse_octet_format , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_smrse_T_octet_format },
{ 0, NULL, 0, 0, 0, NULL }
};
static int
dissect_smrse_T_address_value(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_choice(actx, tree, tvb, offset,
T_address_value_choice, hf_index, ett_smrse_T_address_value,
NULL);
return offset;
}
static const ber_sequence_t SMS_Address_sequence[] = {
{ &hf_smrse_address_type , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_smrse_T_address_type },
{ &hf_smrse_numbering_plan, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_smrse_T_numbering_plan },
{ &hf_smrse_address_value , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_smrse_T_address_value },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_smrse_SMS_Address(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
SMS_Address_sequence, hf_index, ett_smrse_SMS_Address);
return offset;
}
static int
dissect_smrse_Password(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_PrintableString,
actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static const ber_sequence_t SMR_Bind_sequence[] = {
{ &hf_smrse_sc_address , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_smrse_SMS_Address },
{ &hf_smrse_password , BER_CLASS_UNI, BER_UNI_TAG_PrintableString, BER_FLAGS_NOOWNTAG, dissect_smrse_Password },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_smrse_SMR_Bind(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
SMR_Bind_sequence, hf_index, ett_smrse_SMR_Bind);
return offset;
}
static int
dissect_smrse_IMSI_Address(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static const ber_sequence_t SMR_Bind_Confirm_sequence[] = {
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_smrse_SMR_Bind_Confirm(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
SMR_Bind_Confirm_sequence, hf_index, ett_smrse_SMR_Bind_Confirm);
return offset;
}
static const value_string smrse_Connect_fail_vals[] = {
{ 0, "not-entitled" },
{ 1, "tmp-overload" },
{ 2, "tmp-failure" },
{ 3, "id-or-passwd" },
{ 4, "not-supported" },
{ 5, "inv-SC-addr" },
{ 0, NULL }
};
static int
dissect_smrse_Connect_fail(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static const ber_sequence_t SMR_Bind_Failure_sequence[] = {
{ &hf_smrse_connect_fail_reason, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_smrse_Connect_fail },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_smrse_SMR_Bind_Failure(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
SMR_Bind_Failure_sequence, hf_index, ett_smrse_SMR_Bind_Failure);
return offset;
}
static const ber_sequence_t SMR_Unbind_sequence[] = {
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_smrse_SMR_Unbind(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
SMR_Unbind_sequence, hf_index, ett_smrse_SMR_Unbind);
return offset;
}
static int
dissect_smrse_BOOLEAN(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_boolean(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
return offset;
}
static int
dissect_smrse_RP_MR(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static int
dissect_smrse_RP_UD(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static int
dissect_smrse_SM_TC(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static const ber_sequence_t RPDataMT_sequence[] = {
{ &hf_smrse_mt_priority_request, BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_NOOWNTAG, dissect_smrse_BOOLEAN },
{ &hf_smrse_mt_mms , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_NOOWNTAG, dissect_smrse_BOOLEAN },
{ &hf_smrse_mt_message_reference, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_smrse_RP_MR },
{ &hf_smrse_mt_originating_address, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_smrse_SMS_Address },
{ &hf_smrse_mt_destination_address, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_smrse_SMS_Address },
{ &hf_smrse_mt_user_data , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_smrse_RP_UD },
{ &hf_smrse_mt_origVMSCAddr, BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_smrse_SMS_Address },
{ &hf_smrse_mt_tariffClass, BER_CLASS_CON, 2, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_smrse_SM_TC },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_smrse_RPDataMT(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
RPDataMT_sequence, hf_index, ett_smrse_RPDataMT);
return offset;
}
static const ber_sequence_t RPDataMO_sequence[] = {
{ &hf_smrse_mo_message_reference, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_smrse_RP_MR },
{ &hf_smrse_mo_originating_address, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_smrse_SMS_Address },
{ &hf_smrse_mo_user_data , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_smrse_RP_UD },
{ &hf_smrse_origVMSCAddr , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_smrse_SMS_Address },
{ &hf_smrse_moimsi , BER_CLASS_CON, 2, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_smrse_IMSI_Address },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_smrse_RPDataMO(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
RPDataMO_sequence, hf_index, ett_smrse_RPDataMO);
return offset;
}
static const ber_sequence_t RPAck_sequence[] = {
{ &hf_smrse_message_reference, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_smrse_RP_MR },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_smrse_RPAck(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
RPAck_sequence, hf_index, ett_smrse_RPAck);
return offset;
}
static const value_string smrse_Error_reason_vals[] = {
{ 1, "unknown-subscriber" },
{ 9, "illegal-subscriber" },
{ 11, "teleservice-not-provisioned" },
{ 13, "call-barred" },
{ 15, "cug-reject" },
{ 19, "sMS-ll-capabilities-not-prov" },
{ 20, "error-in-MS" },
{ 21, "facility-not-supported" },
{ 22, "memory-capacity-exceeded" },
{ 29, "absent-subscriber" },
{ 30, "ms-busy-for-MT-sms" },
{ 36, "system-failure" },
{ 44, "illegal-equipment" },
{ 60, "no-resp-to-paging" },
{ 61, "gMSC-congestion" },
{ 70, "dublicate-sm" },
{ 101, "sC-congestion" },
{ 103, "mS-not-SC-Subscriber" },
{ 104, "invalid-sme-address" },
{ 0, NULL }
};
static int
dissect_smrse_Error_reason(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static const ber_sequence_t RPError_sequence[] = {
{ &hf_smrse_error_reason , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_smrse_Error_reason },
{ &hf_smrse_msg_waiting_set, BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_NOOWNTAG, dissect_smrse_BOOLEAN },
{ &hf_smrse_message_reference, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_smrse_RP_MR },
{ &hf_smrse_alerting_MS_ISDN, BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_smrse_SMS_Address },
{ &hf_smrse_sm_diag_info , BER_CLASS_CON, 2, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_smrse_RP_UD },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_smrse_RPError(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
RPError_sequence, hf_index, ett_smrse_RPError);
return offset;
}
static const ber_sequence_t RPAlertSC_sequence[] = {
{ &hf_smrse_ms_address , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_smrse_SMS_Address },
{ &hf_smrse_message_reference, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_smrse_RP_MR },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_smrse_RPAlertSC(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
RPAlertSC_sequence, hf_index, ett_smrse_RPAlertSC);
return offset;
}
static const value_string tag_vals[] = {
{ 1, "AliveTest" },
{ 2, "AliveTestRsp" },
{ 3, "Bind" },
{ 4, "BindRsp" },
{ 5, "BindFail" },
{ 6, "Unbind" },
{ 7, "MT" },
{ 8, "MO" },
{ 9, "Ack" },
{ 10, "Error" },
{ 11, "Alert" },
{ 0, NULL }
};
static int
dissect_smrse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
guint8 reserved, tag;
int offset=0;
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
reserved=tvb_get_guint8(tvb, 0);
tag=tvb_get_guint8(tvb, 3);
if( reserved!= 126 )
return 0;
if( (tag<1)||(tag>11) )
return 0;
if(parent_tree){
item = proto_tree_add_item(parent_tree, proto_smrse, tvb, 0, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_smrse);
}
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMRSE");
col_add_str(pinfo->cinfo, COL_INFO, val_to_str(tag, tag_vals,"Unknown Tag:0x%02x"));
proto_tree_add_item(tree, hf_smrse_reserved, tvb, 0, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_smrse_length, tvb, 1, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_smrse_tag, tvb, 3, 1, ENC_BIG_ENDIAN);
switch(tag){
case 1:
case 2:
offset=4;
break;
case 3:
offset=dissect_smrse_SMR_Bind(FALSE, tvb, 4, &asn1_ctx, tree, -1);
break;
case 4:
offset=dissect_smrse_SMR_Bind_Confirm(FALSE, tvb, 4, &asn1_ctx, tree, -1);
break;
case 5:
offset=dissect_smrse_SMR_Bind_Failure(FALSE, tvb, 4, &asn1_ctx, tree, -1);
break;
case 6:
offset=dissect_smrse_SMR_Unbind(FALSE, tvb, 4, &asn1_ctx, tree, -1);
break;
case 7:
offset=dissect_smrse_RPDataMT(FALSE, tvb, 4, &asn1_ctx, tree, -1);
break;
case 8:
offset=dissect_smrse_RPDataMO(FALSE, tvb, 4, &asn1_ctx, tree, -1);
break;
case 9:
offset=dissect_smrse_RPAck(FALSE, tvb, 4, &asn1_ctx, tree, -1);
break;
case 10:
offset=dissect_smrse_RPError(FALSE, tvb, 4, &asn1_ctx, tree, -1);
break;
case 11:
offset=dissect_smrse_RPAlertSC(FALSE, tvb, 4, &asn1_ctx, tree, -1);
break;
}
return offset;
}
/*--- proto_register_smrse ----------------------------------------------*/
void proto_register_smrse(void) {
/* List of fields */
static hf_register_info hf[] = {
{ &hf_smrse_reserved, {
"Reserved", "smrse.reserved", FT_UINT8, BASE_DEC,
NULL, 0, "Reserved byte, must be 126", HFILL }},
{ &hf_smrse_tag, {
"Tag", "smrse.tag", FT_UINT8, BASE_DEC,
VALS(tag_vals), 0, NULL, HFILL }},
{ &hf_smrse_length, {
"Length", "smrse.length", FT_UINT16, BASE_DEC,
NULL, 0, "Length of SMRSE PDU", HFILL }},
{ &hf_smrse_Octet_Format,
{ "octet-Format", "smrse.octet_Format",
FT_STRING, BASE_NONE, NULL, 0,
"SMS-Address/address-value/octet-format", HFILL }},
{ &hf_smrse_sc_address,
{ "sc-address", "smrse.sc_address_element",
FT_NONE, BASE_NONE, NULL, 0,
"SMS_Address", HFILL }},
{ &hf_smrse_password,
{ "password", "smrse.password",
FT_STRING, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_smrse_address_type,
{ "address-type", "smrse.address_type",
FT_INT32, BASE_DEC, VALS(smrse_T_address_type_vals), 0,
NULL, HFILL }},
{ &hf_smrse_numbering_plan,
{ "numbering-plan", "smrse.numbering_plan",
FT_INT32, BASE_DEC, VALS(smrse_T_numbering_plan_vals), 0,
NULL, HFILL }},
{ &hf_smrse_address_value,
{ "address-value", "smrse.address_value",
FT_UINT32, BASE_DEC, VALS(smrse_T_address_value_vals), 0,
NULL, HFILL }},
{ &hf_smrse_octet_format,
{ "octet-format", "smrse.octet_format",
FT_BYTES, BASE_NONE, NULL, 0,
"T_octet_format", HFILL }},
{ &hf_smrse_connect_fail_reason,
{ "connect-fail-reason", "smrse.connect_fail_reason",
FT_INT32, BASE_DEC, VALS(smrse_Connect_fail_vals), 0,
"Connect_fail", HFILL }},
{ &hf_smrse_mt_priority_request,
{ "mt-priority-request", "smrse.mt_priority_request",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_smrse_mt_mms,
{ "mt-mms", "smrse.mt_mms",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_smrse_mt_message_reference,
{ "mt-message-reference", "smrse.mt_message_reference",
FT_UINT32, BASE_DEC, NULL, 0,
"RP_MR", HFILL }},
{ &hf_smrse_mt_originating_address,
{ "mt-originating-address", "smrse.mt_originating_address_element",
FT_NONE, BASE_NONE, NULL, 0,
"SMS_Address", HFILL }},
{ &hf_smrse_mt_destination_address,
{ "mt-destination-address", "smrse.mt_destination_address_element",
FT_NONE, BASE_NONE, NULL, 0,
"SMS_Address", HFILL }},
{ &hf_smrse_mt_user_data,
{ "mt-user-data", "smrse.mt_user_data",
FT_BYTES, BASE_NONE, NULL, 0,
"RP_UD", HFILL }},
{ &hf_smrse_mt_origVMSCAddr,
{ "mt-origVMSCAddr", "smrse.mt_origVMSCAddr_element",
FT_NONE, BASE_NONE, NULL, 0,
"SMS_Address", HFILL }},
{ &hf_smrse_mt_tariffClass,
{ "mt-tariffClass", "smrse.mt_tariffClass",
FT_UINT32, BASE_DEC, NULL, 0,
"SM_TC", HFILL }},
{ &hf_smrse_mo_message_reference,
{ "mo-message-reference", "smrse.mo_message_reference",
FT_UINT32, BASE_DEC, NULL, 0,
"RP_MR", HFILL }},
{ &hf_smrse_mo_originating_address,
{ "mo-originating-address", "smrse.mo_originating_address_element",
FT_NONE, BASE_NONE, NULL, 0,
"SMS_Address", HFILL }},
{ &hf_smrse_mo_user_data,
{ "mo-user-data", "smrse.mo_user_data",
FT_BYTES, BASE_NONE, NULL, 0,
"RP_UD", HFILL }},
{ &hf_smrse_origVMSCAddr,
{ "origVMSCAddr", "smrse.origVMSCAddr_element",
FT_NONE, BASE_NONE, NULL, 0,
"SMS_Address", HFILL }},
{ &hf_smrse_moimsi,
{ "moimsi", "smrse.moimsi",
FT_BYTES, BASE_NONE, NULL, 0,
"IMSI_Address", HFILL }},
{ &hf_smrse_message_reference,
{ "message-reference", "smrse.message_reference",
FT_UINT32, BASE_DEC, NULL, 0,
"RP_MR", HFILL }},
{ &hf_smrse_error_reason,
{ "error-reason", "smrse.error_reason",
FT_INT32, BASE_DEC, VALS(smrse_Error_reason_vals), 0,
NULL, HFILL }},
{ &hf_smrse_msg_waiting_set,
{ "msg-waiting-set", "smrse.msg_waiting_set",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_smrse_alerting_MS_ISDN,
{ "alerting-MS-ISDN", "smrse.alerting_MS_ISDN_element",
FT_NONE, BASE_NONE, NULL, 0,
"SMS_Address", HFILL }},
{ &hf_smrse_sm_diag_info,
{ "sm-diag-info", "smrse.sm_diag_info",
FT_BYTES, BASE_NONE, NULL, 0,
"RP_UD", HFILL }},
{ &hf_smrse_ms_address,
{ "ms-address", "smrse.ms_address_element",
FT_NONE, BASE_NONE, NULL, 0,
"SMS_Address", HFILL }},
};
/* List of subtrees */
static gint *ett[] = {
&ett_smrse,
&ett_smrse_SMR_Bind,
&ett_smrse_SMS_Address,
&ett_smrse_T_address_value,
&ett_smrse_SMR_Bind_Confirm,
&ett_smrse_SMR_Bind_Failure,
&ett_smrse_SMR_Unbind,
&ett_smrse_RPDataMT,
&ett_smrse_RPDataMO,
&ett_smrse_RPAck,
&ett_smrse_RPError,
&ett_smrse_RPAlertSC,
};
/* Register protocol */
proto_smrse = proto_register_protocol(PNAME, PSNAME, PFNAME);
/* Register dissector */
smrse_handle = register_dissector(PFNAME, dissect_smrse, proto_smrse);
/* Register fields and subtrees */
proto_register_field_array(proto_smrse, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
/*--- proto_reg_handoff_smrse -------------------------------------------*/
void proto_reg_handoff_smrse(void) {
dissector_add_uint_with_preference("tcp.port",TCP_PORT_SMRSE, smrse_handle);
}
|
C/C++
|
wireshark/epan/dissectors/packet-smrse.h
|
/* Do not modify this file. Changes will be overwritten. */
/* Generated automatically by the ASN.1 to Wireshark dissector compiler */
/* packet-smrse.h */
/* asn2wrs.py -b -L -p smrse -c ./smrse.cnf -s ./packet-smrse-template -D . -O ../.. SMRSE.asn */
/* packet-smrse.h
* Routines for SMRSE Short Message Relay Service packet dissection
* Ronnie Sahlberg 2004
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef PACKET_SMRSE_H
#define PACKET_SMRSE_H
/*#include "packet-smrse-exp.h"*/
#endif /* PACKET_SMRSE_H */
|
C
|
wireshark/epan/dissectors/packet-smtp.c
|
/* packet-smtp.c
* Routines for SMTP packet disassembly
*
* Copyright (c) 2000 by Richard Sharpe <[email protected]>
*
* Added RFC 4954 SMTP Authentication
* Michael Mann * Copyright 2012
* Added RFC 2920 Pipelining and RFC 3030 BDAT Pipelining
* John Thacker <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1999 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdlib.h>
#include <epan/packet.h>
#include <epan/conversation.h>
#include <epan/prefs.h>
#include <epan/strutil.h>
#include <epan/reassemble.h>
#include <epan/proto_data.h>
#include <ui/tap-credentials.h>
#include <tap.h>
#include <wsutil/str_util.h>
#include "packet-tls.h"
#include "packet-tls-utils.h"
/* RFC 2821 */
#define TCP_PORT_SMTP "25"
#define TCP_PORT_SSL_SMTP 465
/* RFC 4409 */
#define TCP_PORT_SUBMISSION 587
void proto_register_smtp(void);
void proto_reg_handoff_smtp(void);
static int proto_smtp = -1;
static int credentials_tap = -1;
static int hf_smtp_req = -1;
static int hf_smtp_rsp = -1;
static int hf_smtp_message = -1;
static int hf_smtp_command_line = -1;
static int hf_smtp_req_command = -1;
static int hf_smtp_req_parameter = -1;
static int hf_smtp_response = -1;
static int hf_smtp_rsp_code = -1;
static int hf_smtp_rsp_parameter = -1;
static int hf_smtp_username = -1;
static int hf_smtp_password = -1;
static int hf_smtp_username_password = -1;
static int hf_smtp_eom = -1;
static int hf_smtp_data_fragments = -1;
static int hf_smtp_data_fragment = -1;
static int hf_smtp_data_fragment_overlap = -1;
static int hf_smtp_data_fragment_overlap_conflicts = -1;
static int hf_smtp_data_fragment_multiple_tails = -1;
static int hf_smtp_data_fragment_too_long_fragment = -1;
static int hf_smtp_data_fragment_error = -1;
static int hf_smtp_data_fragment_count = -1;
static int hf_smtp_data_reassembled_in = -1;
static int hf_smtp_data_reassembled_length = -1;
static int ett_smtp = -1;
static int ett_smtp_cmdresp = -1;
static gint ett_smtp_data_fragment = -1;
static gint ett_smtp_data_fragments = -1;
static expert_field ei_smtp_base64_decode = EI_INIT;
static expert_field ei_smtp_rsp_code = EI_INIT;
static gboolean smtp_auth_parameter_decoding_enabled = FALSE;
/* desegmentation of SMTP command and response lines */
static gboolean smtp_desegment = TRUE;
static gboolean smtp_data_desegment = TRUE;
static reassembly_table smtp_data_reassembly_table;
static const fragment_items smtp_data_frag_items = {
/* Fragment subtrees */
&ett_smtp_data_fragment,
&ett_smtp_data_fragments,
/* Fragment fields */
&hf_smtp_data_fragments,
&hf_smtp_data_fragment,
&hf_smtp_data_fragment_overlap,
&hf_smtp_data_fragment_overlap_conflicts,
&hf_smtp_data_fragment_multiple_tails,
&hf_smtp_data_fragment_too_long_fragment,
&hf_smtp_data_fragment_error,
&hf_smtp_data_fragment_count,
/* Reassembled in field */
&hf_smtp_data_reassembled_in,
/* Reassembled length field */
&hf_smtp_data_reassembled_length,
/* Reassembled data field */
NULL,
/* Tag */
"DATA fragments"
};
static dissector_handle_t smtp_handle;
static dissector_handle_t tls_handle;
static dissector_handle_t imf_handle;
static dissector_handle_t ntlmssp_handle;
static dissector_handle_t data_text_lines_handle;
/*
* A CMD is an SMTP command, MESSAGE is the message portion, and EOM is the
* last part of a message
*/
#define SMTP_PDU_CMD 0
#define SMTP_PDU_MESSAGE 1
#define SMTP_PDU_EOM 2
struct smtp_proto_data {
guint16 pdu_type;
guint16 conversation_id;
gboolean more_frags;
int end_offset;
struct smtp_proto_data *next;
};
/*
* State information stored with a conversation.
*/
typedef enum {
SMTP_STATE_START, /* Start of SMTP conversion */
SMTP_STATE_READING_CMDS, /* reading commands */
SMTP_STATE_READING_DATA, /* reading message data */
SMTP_STATE_AWAITING_STARTTLS_RESPONSE /* sent STARTTLS, awaiting response */
} smtp_state_t;
typedef enum {
SMTP_AUTH_STATE_NONE, /* No authentication seen or used */
SMTP_AUTH_STATE_START, /* Authentication started, waiting for username */
SMTP_AUTH_STATE_USERNAME_REQ, /* Received username request from server */
SMTP_AUTH_STATE_USERNAME_RSP, /* Received username response from client */
SMTP_AUTH_STATE_PASSWORD_REQ, /* Received password request from server */
SMTP_AUTH_STATE_PASSWORD_RSP, /* Received password request from server */
SMTP_AUTH_STATE_PLAIN_START_REQ, /* Received AUTH PLAIN command from client*/
SMTP_AUTH_STATE_PLAIN_CRED_REQ, /* Received AUTH PLAIN command including creds from client*/
SMTP_AUTH_STATE_PLAIN_REQ, /* Received AUTH PLAIN request from server */
SMTP_AUTH_STATE_PLAIN_RSP, /* Received AUTH PLAIN response from client */
SMTP_AUTH_STATE_NTLM_REQ, /* Received ntlm negotiate request from client */
SMTP_AUTH_STATE_NTLM_CHALLANGE, /* Received ntlm challange request from server */
SMTP_AUTH_STATE_NTLM_RSP, /* Received ntlm auth request from client */
SMTP_AUTH_STATE_SUCCESS, /* Password received, authentication successful, start decoding */
SMTP_AUTH_STATE_FAILED /* authentication failed, no decoding */
} smtp_auth_state_t;
typedef enum {
SMTP_MULTILINE_NONE,
SMTP_MULTILINE_START,
SMTP_MULTILINE_CONTINUE,
SMTP_MULTILINE_END
} smtp_multiline_state_t;
struct smtp_session_state {
smtp_state_t smtp_state; /* Current state */
smtp_auth_state_t auth_state; /* Current authentication state */
/* Values that need to be saved because state machine can't be used during tree dissection */
guint32 first_auth_frame; /* First frame involving authentication. */
guint32 username_frame; /* Frame containing client username */
guint32 password_frame; /* Frame containing client password */
guint32 last_auth_frame; /* Last frame involving authentication. */
guint8* username; /* The username in the authentication. */
gboolean crlf_seen; /* Have we seen a CRLF on the end of a packet */
gboolean data_seen; /* Have we seen a DATA command yet */
guint32 msg_read_len; /* Length of BDAT message read so far */
guint32 msg_tot_len; /* Total length of BDAT message */
gboolean msg_last; /* Is this the last BDAT chunk */
guint32 username_cmd_frame; /* AUTH command contains username */
guint32 user_pass_cmd_frame; /* AUTH command contains username and password */
guint32 user_pass_frame; /* Frame contains username and password */
guint32 ntlm_req_frame; /* Frame containing NTLM request */
guint32 ntlm_cha_frame; /* Frame containing NTLM challange. */
guint32 ntlm_rsp_frame; /* Frame containing NTLM response. */
};
/*
* See
*
* http://support.microsoft.com/default.aspx?scid=kb;[LN];812455
*
* for the Exchange extensions.
*/
static const struct {
const char *command;
int len;
} commands[] = {
{ "STARTTLS", 8 }, /* RFC 2487 */
{ "X-EXPS", 6 }, /* Microsoft Exchange */
{ "X-LINK2STATE", 12 }, /* Microsoft Exchange */
{ "XEXCH50", 7 } /* Microsoft Exchange */
};
#define NCOMMANDS (sizeof commands / sizeof commands[0])
/* The following were copied from RFC 2821 */
static const value_string response_codes_vs[] = {
{ 211, "System status, or system help reply" },
{ 214, "Help message" },
{ 220, "<domain> Service ready" },
{ 221, "<domain> Service closing transmission channel" },
{ 235, "Authentication successful" },
{ 250, "Requested mail action okay, completed" },
{ 251, "User not local; will forward to <forward-path>" },
{ 252, "Cannot VRFY user, but will accept message and attempt delivery" },
{ 334, "AUTH input" },
{ 354, "Start mail input; end with <CRLF>.<CRLF>" },
{ 421, "<domain> Service not available, closing transmission channel" },
{ 432, "A password transition is needed" },
{ 450, "Requested mail action not taken: mailbox unavailable" },
{ 451, "Requested action aborted: local error in processing" },
{ 452, "Requested action not taken: insufficient system storage" },
{ 454, "Temporary authentication failed" },
{ 500, "Syntax error, command unrecognized" },
{ 501, "Syntax error in parameters or arguments" },
{ 502, "Command not implemented" },
{ 503, "Bad sequence of commands" },
{ 504, "Command parameter not implemented" },
{ 530, "Authentication required" },
{ 534, "Authentication mechanism is too weak" },
{ 535, "Authentication credentials invalid" },
{ 538, "Encryption required for requested authentication mechanism" },
{ 550, "Requested action not taken: mailbox unavailable" },
{ 551, "User not local; please try <forward-path>" },
{ 552, "Requested mail action aborted: exceeded storage allocation" },
{ 553, "Requested action not taken: mailbox name not allowed" },
{ 554, "Transaction failed" },
{ 0, NULL }
};
static value_string_ext response_codes_vs_ext = VALUE_STRING_EXT_INIT(response_codes_vs);
static struct smtp_proto_data*
append_pdu(struct smtp_proto_data *spd_frame_data)
{
DISSECTOR_ASSERT(spd_frame_data && spd_frame_data->next == NULL);
struct smtp_proto_data *new_pdu = wmem_new0(wmem_file_scope(), struct smtp_proto_data);
new_pdu->conversation_id = spd_frame_data->conversation_id;
new_pdu->more_frags = TRUE;
spd_frame_data->next = new_pdu;
return new_pdu;
}
static gboolean
line_is_smtp_command(const guchar *command, int commandlen)
{
size_t i;
/*
* To quote RFC 821, "Command codes are four alphabetic
* characters".
*
* However, there are some SMTP extensions that involve commands
* longer than 4 characters and/or that contain non-alphabetic
* characters; we treat them specially.
*
* XXX - should we just have a table of known commands? Or would
* that fail to catch some extensions we don't know about?
*/
if (commandlen == 4 && g_ascii_isalpha(command[0]) &&
g_ascii_isalpha(command[1]) && g_ascii_isalpha(command[2]) &&
g_ascii_isalpha(command[3])) {
/* standard 4-alphabetic command */
return TRUE;
}
/*
* Check the list of non-4-alphabetic commands.
*/
for (i = 0; i < NCOMMANDS; i++) {
if (commandlen == commands[i].len &&
g_ascii_strncasecmp(command, commands[i].command, commands[i].len) == 0)
return TRUE;
}
return FALSE;
}
static void
dissect_smtp_data(tvbuff_t *tvb, int offset, proto_tree *smtp_tree)
{
gint next_offset;
if (smtp_tree) {
while (tvb_offset_exists(tvb, offset)) {
/*
* Find the end of the line.
*/
tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
/*
* Put this line.
*/
proto_tree_add_item(smtp_tree, hf_smtp_message, tvb,
offset, next_offset - offset, ENC_ASCII);
/*
* Step to the next line.
*/
offset = next_offset;
}
}
}
static void
dissect_ntlm_auth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
const char *line)
{
tvbuff_t *ntlm_tvb;
ntlm_tvb = base64_to_tvb(tvb, line);
if(tvb_strneql(ntlm_tvb, 0, "NTLMSSP", 7) == 0) {
add_new_data_source(pinfo, ntlm_tvb, "NTLMSSP Data");
call_dissector(ntlmssp_handle, ntlm_tvb, pinfo, tree);
}
}
static void
decode_plain_auth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gint a_offset, int a_linelen)
{
gint returncode;
gint length_user1;
gint length_user2;
gint length_pass;
guint8 *decrypt = NULL;
proto_item *ti;
gsize len = 0;
decrypt = tvb_get_string_enc(pinfo->pool, tvb, a_offset, a_linelen, ENC_ASCII);
if (smtp_auth_parameter_decoding_enabled) {
if (strlen(decrypt) > 1) {
g_base64_decode_inplace(decrypt, &len);
decrypt[len] = 0;
}
returncode = (gint)len;
if (returncode) {
gchar* username;
length_user1 = (gint)strlen(decrypt);
if (returncode >= (length_user1 + 1)) {
length_user2 = (gint)strlen(decrypt + length_user1 + 1);
proto_tree_add_string(tree, hf_smtp_username, tvb,
a_offset, a_linelen, decrypt + length_user1 + 1);
username = format_text(pinfo->pool, decrypt + length_user1 + 1, length_user2);
col_append_fstr(pinfo->cinfo, COL_INFO, "User: %s", username);
if (returncode >= (length_user1 + 1 + length_user2 + 1)) {
length_pass = (gint)strlen(decrypt + length_user1 + length_user2 + 2);
proto_tree_add_string(tree, hf_smtp_password, tvb,
a_offset, length_pass, decrypt + length_user1 + length_user2 + 2);
col_append_str(pinfo->cinfo, COL_INFO, " ");
col_append_fstr(pinfo->cinfo, COL_INFO, " Pass: %s",
format_text(pinfo->pool, decrypt + length_user1 + length_user2 + 2, length_pass));
tap_credential_t* auth = wmem_new0(pinfo->pool, tap_credential_t);
auth->num = pinfo->num;
auth->username_num = pinfo->num;
auth->password_hf_id = hf_smtp_password;
auth->username = username;
auth->proto = "SMTP";
tap_queue_packet(credentials_tap, pinfo, auth);
}
}
}
}
else {
ti = proto_tree_add_item(tree, hf_smtp_username_password, tvb,
a_offset, a_linelen, ENC_ASCII);
expert_add_info(pinfo, ti, &ei_smtp_base64_decode);
col_append_str(pinfo->cinfo, COL_INFO, format_text(pinfo->pool, decrypt, a_linelen));
}
}
static int
dissect_smtp_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *smtp_tree, struct smtp_session_state *session_state, struct smtp_proto_data *spd_frame_data, gboolean first_pdu)
{
proto_item *ti, *hidden_item;
proto_tree *cmdresp_tree = NULL;
int offset = 0;
int next_offset;
int linelen = 0;
int length_remaining;
int cmdlen;
fragment_head *frag_msg = NULL;
tvbuff_t *next_tvb;
guint8 *decrypt = NULL;
gsize decrypt_len = 0;
guint8 *base64_string = NULL;
switch (spd_frame_data->pdu_type) {
case SMTP_PDU_MESSAGE:
/* Column Info */
length_remaining = tvb_reported_length_remaining(tvb, offset);
if (first_pdu)
col_append_str(pinfo->cinfo, COL_INFO, "C: ");
else
col_append_str(pinfo->cinfo, COL_INFO, " | ");
col_append_str(pinfo->cinfo, COL_INFO, smtp_data_desegment ? "DATA fragment" : "Message Body");
col_append_fstr(pinfo->cinfo, COL_INFO, ", %d byte%s", length_remaining,
plurality (length_remaining, "", "s"));
if (smtp_data_desegment) {
frag_msg = fragment_add_seq_next(&smtp_data_reassembly_table, tvb, 0,
pinfo, spd_frame_data->conversation_id, NULL,
tvb_reported_length(tvb),
spd_frame_data->more_frags);
if (spd_frame_data->more_frags) {
/* Show the text lines within this PDU fragment
* Calling this on the last fragment would interfere with
* process reassembled data below, by changing the layer number.
* (We'll display the data anyway as part of the reassembly.)
*/
call_dissector(data_text_lines_handle, tvb, pinfo, smtp_tree);
}
} else {
/*
* Message body.
* Put its lines into the protocol tree, a line at a time.
*/
dissect_smtp_data(tvb, offset, smtp_tree);
}
break;
case SMTP_PDU_EOM:
/*
* End-of-message-body indicator.
*/
if (first_pdu)
col_append_str(pinfo->cinfo, COL_INFO, "C: ");
else
col_append_str(pinfo->cinfo, COL_INFO, " | ");
col_append_str(pinfo->cinfo, COL_INFO, ".");
proto_tree_add_none_format(smtp_tree, hf_smtp_eom, tvb, offset, 3, "C: .");
break;
case SMTP_PDU_CMD:
/*
* Command.
*/
while (tvb_offset_exists(tvb, offset)) {
/*
* Find the end of the line.
*/
linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
/* Column Info */
if (first_pdu && offset == 0)
col_append_str(pinfo->cinfo, COL_INFO, "C: ");
else
col_append_str(pinfo->cinfo, COL_INFO, " | ");
hidden_item = proto_tree_add_boolean(smtp_tree, hf_smtp_req, tvb,
0, 0, TRUE);
proto_item_set_hidden(hidden_item);
if (session_state->username_frame == pinfo->num) {
if (decrypt == NULL) {
/* This line wasn't already decrypted through the state machine */
decrypt = tvb_get_string_enc(pinfo->pool, tvb, offset, linelen, ENC_ASCII);
decrypt_len = linelen;
if (smtp_auth_parameter_decoding_enabled) {
if (strlen(decrypt) > 1) {
g_base64_decode_inplace(decrypt, &decrypt_len);
decrypt[decrypt_len] = 0;
} else {
decrypt_len = 0;
}
if (decrypt_len == 0) {
/* Go back to the original string */
decrypt = tvb_get_string_enc(pinfo->pool, tvb, offset, linelen, ENC_ASCII);
decrypt_len = linelen;
}
}
}
if (!session_state->username)
session_state->username = wmem_strdup(wmem_file_scope(), decrypt);
proto_tree_add_string(smtp_tree, hf_smtp_username, tvb,
offset, linelen, decrypt);
col_append_fstr(pinfo->cinfo, COL_INFO, "User: %s", format_text(pinfo->pool, decrypt, decrypt_len));
} else if (session_state->password_frame == pinfo->num) {
if (decrypt == NULL) {
/* This line wasn't already decrypted through the state machine */
decrypt = tvb_get_string_enc(pinfo->pool, tvb, offset, linelen, ENC_ASCII);
decrypt_len = linelen;
if (smtp_auth_parameter_decoding_enabled) {
if (strlen(decrypt) > 1) {
g_base64_decode_inplace(decrypt, &decrypt_len);
decrypt[decrypt_len] = 0;
} else {
decrypt_len = 0;
}
if (decrypt_len == 0) {
/* Go back to the original string */
decrypt = tvb_get_string_enc(pinfo->pool, tvb, offset, linelen, ENC_ASCII);
decrypt_len = linelen;
}
}
}
proto_tree_add_string(smtp_tree, hf_smtp_password, tvb,
offset, linelen, decrypt);
col_append_fstr(pinfo->cinfo, COL_INFO, "Pass: %s", format_text(pinfo->pool, decrypt, decrypt_len));
tap_credential_t* auth = wmem_new0(pinfo->pool, tap_credential_t);
auth->num = pinfo->num;
auth->username_num = session_state->username_frame;
auth->password_hf_id = hf_smtp_password;
auth->username = session_state->username;
auth->proto = "SMTP";
auth->info = wmem_strdup_printf(pinfo->pool, "Username in packet %u", auth->username_num);
tap_queue_packet(credentials_tap, pinfo, auth);
} else if (session_state->ntlm_rsp_frame == pinfo->num) {
decrypt = tvb_get_string_enc(pinfo->pool, tvb, offset, linelen, ENC_ASCII);
decrypt_len = linelen;
if (smtp_auth_parameter_decoding_enabled) {
if (strlen(decrypt) > 1) {
g_base64_decode_inplace(decrypt, &decrypt_len);
decrypt[decrypt_len] = 0;
} else {
decrypt_len = 0;
}
if (decrypt_len == 0) {
/* Go back to the original string */
decrypt = tvb_get_string_enc(pinfo->pool, tvb, offset, linelen, ENC_ASCII);
decrypt_len = linelen;
col_append_str(pinfo->cinfo, COL_INFO, format_text(pinfo->pool, decrypt, linelen));
proto_tree_add_item(smtp_tree, hf_smtp_command_line, tvb,
offset, linelen, ENC_ASCII);
}
else {
base64_string = tvb_get_string_enc(pinfo->pool, tvb, offset, linelen, ENC_ASCII);
dissect_ntlm_auth(tvb, pinfo, smtp_tree, base64_string);
}
}
else {
col_append_str(pinfo->cinfo, COL_INFO, format_text(pinfo->pool, decrypt, linelen));
proto_tree_add_item(smtp_tree, hf_smtp_command_line, tvb,
offset, linelen, ENC_ASCII);
}
} else if (session_state->user_pass_frame == pinfo->num) {
decode_plain_auth(tvb, pinfo, smtp_tree, offset, linelen);
} else {
if (linelen >= 4)
cmdlen = 4;
else
cmdlen = linelen;
/*
* Put the command line into the protocol tree.
*/
ti = proto_tree_add_item(smtp_tree, hf_smtp_command_line, tvb,
offset, next_offset - offset, ENC_ASCII);
cmdresp_tree = proto_item_add_subtree(ti, ett_smtp_cmdresp);
proto_tree_add_item(cmdresp_tree, hf_smtp_req_command, tvb,
offset, cmdlen, ENC_ASCII);
if ((linelen > 5) && (session_state->username_cmd_frame == pinfo->num) ) {
proto_tree_add_item(cmdresp_tree, hf_smtp_req_parameter, tvb,
offset + 5, linelen - 5, ENC_ASCII);
if (linelen >= 11) {
if (decrypt == NULL) {
/* This line wasn't already decrypted through the state machine */
decrypt = tvb_get_string_enc(pinfo->pool, tvb, offset + 11, linelen - 11, ENC_ASCII);
decrypt_len = linelen - 11;
if (smtp_auth_parameter_decoding_enabled) {
if (strlen(decrypt) > 1) {
g_base64_decode_inplace(decrypt, &decrypt_len);
decrypt[decrypt_len] = 0;
} else {
decrypt_len = 0;
}
if (decrypt_len == 0) {
/* Go back to the original string */
decrypt = tvb_get_string_enc(pinfo->pool, tvb, offset + 11, linelen - 11, ENC_ASCII);
decrypt_len = linelen - 11;
}
}
}
proto_tree_add_string(cmdresp_tree, hf_smtp_username, tvb, offset + 11, linelen - 11, decrypt);
col_append_str(pinfo->cinfo, COL_INFO,
tvb_format_text(pinfo->pool, tvb, offset, 11));
col_append_fstr(pinfo->cinfo, COL_INFO, "User: %s", format_text(pinfo->pool, decrypt, decrypt_len));
}
}
else if ((linelen > 5) && (session_state->ntlm_req_frame == pinfo->num) ) {
proto_tree_add_item(cmdresp_tree, hf_smtp_req_parameter, tvb,
offset + 5, linelen - 5, ENC_ASCII);
if (linelen >= 10) {
decrypt = tvb_get_string_enc(pinfo->pool, tvb, offset + 10, linelen - 10, ENC_ASCII);
decrypt_len = linelen - 10;
if (smtp_auth_parameter_decoding_enabled) {
if (strlen(decrypt) > 1) {
g_base64_decode_inplace(decrypt, &decrypt_len);
decrypt[decrypt_len] = 0;
} else {
decrypt_len = 0;
}
if (decrypt_len == 0) {
/* Go back to the original string */
decrypt = tvb_get_string_enc(pinfo->pool, tvb, offset + 10, linelen - 10, ENC_ASCII);
decrypt_len = linelen - 10;
col_append_str(pinfo->cinfo, COL_INFO,
tvb_format_text(pinfo->pool, tvb, offset, 10));
col_append_str(pinfo->cinfo, COL_INFO, format_text(pinfo->pool, decrypt, linelen - 10));
}
else {
base64_string = tvb_get_string_enc(pinfo->pool, tvb, offset + 10, linelen - 10, ENC_ASCII);
col_append_str(pinfo->cinfo, COL_INFO,
tvb_format_text(pinfo->pool, tvb, offset, 10));
dissect_ntlm_auth(tvb, pinfo, cmdresp_tree, format_text(pinfo->pool, base64_string, linelen - 10));
}
}
else {
col_append_str(pinfo->cinfo, COL_INFO,
tvb_format_text(pinfo->pool, tvb, offset, 10));
col_append_str(pinfo->cinfo, COL_INFO, format_text(pinfo->pool, decrypt, linelen - 10));
}
}
}
else if ((linelen > 5) && (session_state->user_pass_cmd_frame == pinfo->num) ) {
proto_tree_add_item(cmdresp_tree, hf_smtp_req_parameter, tvb,
offset + 5, linelen - 5, ENC_ASCII);
col_append_str(pinfo->cinfo, COL_INFO,
tvb_format_text(pinfo->pool, tvb, offset, 11));
decode_plain_auth(tvb, pinfo, cmdresp_tree, offset + 11, linelen - 11);
}
else if (linelen > 5) {
proto_tree_add_item(cmdresp_tree, hf_smtp_req_parameter, tvb,
offset + 5, linelen - 5, ENC_ASCII);
col_append_str(pinfo->cinfo, COL_INFO,
tvb_format_text(pinfo->pool, tvb, offset, linelen));
}
else {
col_append_str(pinfo->cinfo, COL_INFO,
tvb_format_text(pinfo->pool, tvb, offset, linelen));
}
if (smtp_data_desegment && !spd_frame_data->more_frags) {
/* terminate the desegmentation */
frag_msg = fragment_end_seq_next(&smtp_data_reassembly_table,
pinfo, spd_frame_data->conversation_id, NULL);
}
}
/*
* Step past this line.
*/
offset = next_offset;
}
}
if (smtp_data_desegment && (spd_frame_data->pdu_type == SMTP_PDU_MESSAGE || spd_frame_data->more_frags == FALSE) ) {
/* XXX: fragment_add_seq_next() only supports one PDU with a given ID
* being completed in a frame.
*
* RFCs 2920 and 3030 imply that even with pipelining, a frame only
* contains one message that ends, as the client needs to handle
* responses. If it does happen, we need to track message numbers within
* the conversation and use those as part of the frag ID.
*/
next_tvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled SMTP",
frag_msg, &smtp_data_frag_items, NULL, smtp_tree);
if (next_tvb) {
/* XXX: this is presumptuous - we may have negotiated something else */
if (imf_handle) {
call_dissector(imf_handle, next_tvb, pinfo, tree);
} else {
/*
* Message body.
* Put its lines into the protocol tree, a line at a time.
*/
dissect_smtp_data(tvb, offset, smtp_tree);
}
pinfo->fragmented = FALSE;
} else {
pinfo->fragmented = TRUE;
}
}
return tvb_captured_length(tvb);
}
static int
dissect_smtp_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *smtp_tree, struct smtp_session_state *session_state)
{
proto_item *ti, *hidden_item;
proto_tree *cmdresp_tree = NULL;
int offset = 0;
int next_offset;
int linelen = 0;
guint32 code;
guint8 line_code[3];
guint8 *decrypt = NULL;
gsize decrypt_len = 0;
guint8 *base64_string = NULL;
/*
* Process the response, a line at a time, until we hit a line
* that doesn't have a continuation indication on it.
*/
hidden_item = proto_tree_add_boolean(smtp_tree, hf_smtp_rsp, tvb, 0, 0, TRUE);
proto_item_set_hidden(hidden_item);
//Multiline information
smtp_multiline_state_t multiline_state = SMTP_MULTILINE_NONE;
guint32 multiline_code = 0;
proto_item* code_item = NULL;
while (tvb_offset_exists(tvb, offset)) {
/*
* Find the end of the line.
*/
linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
if (offset == 0)
col_append_str(pinfo->cinfo, COL_INFO, "S: ");
else
col_append_str(pinfo->cinfo, COL_INFO, " | ");
if (linelen >= 3) {
line_code[0] = tvb_get_guint8(tvb, offset);
line_code[1] = tvb_get_guint8(tvb, offset+1);
line_code[2] = tvb_get_guint8(tvb, offset+2);
if (g_ascii_isdigit(line_code[0]) && g_ascii_isdigit(line_code[1])
&& g_ascii_isdigit(line_code[2])) {
/*
* We have a 3-digit response code.
*/
code = (line_code[0] - '0')*100 + (line_code[1] - '0')*10 + (line_code[2] - '0');
if ((linelen > 3) && (tvb_get_guint8(tvb, offset + 3) == '-')) {
if (multiline_state == SMTP_MULTILINE_NONE) {
multiline_state = SMTP_MULTILINE_START;
multiline_code = code;
} else {
multiline_state = SMTP_MULTILINE_CONTINUE;
}
} else if ((multiline_state == SMTP_MULTILINE_START) || (multiline_state == SMTP_MULTILINE_CONTINUE)) {
multiline_state = SMTP_MULTILINE_END;
}
/*
* If we're awaiting the response to a STARTTLS code, this
* is it - if it's 220, all subsequent traffic will
* be TLS, otherwise we're back to boring old SMTP.
*/
if (session_state->smtp_state == SMTP_STATE_AWAITING_STARTTLS_RESPONSE) {
if (code == 220) {
/* This is the last non-TLS frame. */
ssl_starttls_ack(tls_handle, pinfo, smtp_handle);
}
session_state->smtp_state = SMTP_STATE_READING_CMDS;
}
if (code == 334) {
switch(session_state->auth_state)
{
case SMTP_AUTH_STATE_START:
session_state->auth_state = SMTP_AUTH_STATE_USERNAME_REQ;
break;
case SMTP_AUTH_STATE_USERNAME_RSP:
session_state->auth_state = SMTP_AUTH_STATE_PASSWORD_REQ;
break;
case SMTP_AUTH_STATE_PLAIN_REQ:
session_state->auth_state = SMTP_AUTH_STATE_PLAIN_RSP;
break;
case SMTP_AUTH_STATE_PLAIN_START_REQ:
session_state->auth_state = SMTP_AUTH_STATE_PLAIN_REQ;
break;
case SMTP_AUTH_STATE_NTLM_REQ:
session_state->auth_state = SMTP_AUTH_STATE_NTLM_CHALLANGE;
break;
case SMTP_AUTH_STATE_NONE:
case SMTP_AUTH_STATE_USERNAME_REQ:
case SMTP_AUTH_STATE_PASSWORD_REQ:
case SMTP_AUTH_STATE_PASSWORD_RSP:
case SMTP_AUTH_STATE_PLAIN_RSP:
case SMTP_AUTH_STATE_PLAIN_CRED_REQ:
case SMTP_AUTH_STATE_NTLM_RSP:
case SMTP_AUTH_STATE_NTLM_CHALLANGE:
case SMTP_AUTH_STATE_SUCCESS:
case SMTP_AUTH_STATE_FAILED:
/* ignore */
break;
}
} else if ((session_state->auth_state == SMTP_AUTH_STATE_PASSWORD_RSP) ||
( session_state->auth_state == SMTP_AUTH_STATE_PLAIN_RSP) ||
( session_state->auth_state == SMTP_AUTH_STATE_NTLM_RSP) ||
( session_state->auth_state == SMTP_AUTH_STATE_PLAIN_CRED_REQ) ) {
if (code == 235) {
session_state->auth_state = SMTP_AUTH_STATE_SUCCESS;
} else {
session_state->auth_state = SMTP_AUTH_STATE_FAILED;
}
session_state->last_auth_frame = pinfo->num;
}
/*
* Put the response code and parameters into the protocol tree.
* Only create a new response tree when not in the middle of multiline response.
*/
if ((multiline_state != SMTP_MULTILINE_CONTINUE) &&
(multiline_state != SMTP_MULTILINE_END))
{
ti = proto_tree_add_item(smtp_tree, hf_smtp_response, tvb,
offset, next_offset - offset, ENC_ASCII | ENC_NA);
cmdresp_tree = proto_item_add_subtree(ti, ett_smtp_cmdresp);
code_item = proto_tree_add_uint(cmdresp_tree, hf_smtp_rsp_code, tvb, offset, 3, code);
} else if (multiline_code != code) {
expert_add_info_format(pinfo, code_item, &ei_smtp_rsp_code, "Unexpected response code %u in multiline response. Expected %u", code, multiline_code);
}
decrypt = NULL;
if (linelen >= 4) {
if ((smtp_auth_parameter_decoding_enabled) && (code == 334)) {
decrypt = tvb_get_string_enc(pinfo->pool, tvb, offset + 4, linelen - 4, ENC_ASCII);
if (strlen(decrypt) > 1 && (g_base64_decode_inplace(decrypt, &decrypt_len)) && decrypt_len > 0) {
decrypt[decrypt_len] = 0;
if (g_ascii_strncasecmp(decrypt, "NTLMSSP", 7) == 0) {
base64_string = tvb_get_string_enc(pinfo->pool, tvb, offset + 4, linelen - 4, ENC_ASCII);
col_append_fstr(pinfo->cinfo, COL_INFO, "%d ", code);
proto_tree_add_string(cmdresp_tree, hf_smtp_rsp_parameter, tvb,
offset + 4, linelen - 4, (const char*)base64_string);
dissect_ntlm_auth(tvb, pinfo, cmdresp_tree, base64_string);
}
else {
proto_tree_add_string(cmdresp_tree, hf_smtp_rsp_parameter, tvb,
offset + 4, linelen - 4, (const char*)decrypt);
col_append_fstr(pinfo->cinfo, COL_INFO, "%d %s", code, format_text(pinfo->pool, decrypt, decrypt_len));
}
} else {
decrypt = NULL;
}
}
if (decrypt == NULL) {
proto_tree_add_item(cmdresp_tree, hf_smtp_rsp_parameter, tvb,
offset + 4, linelen - 4, ENC_ASCII);
if ((multiline_state != SMTP_MULTILINE_CONTINUE) &&
(multiline_state != SMTP_MULTILINE_END)) {
col_append_fstr(pinfo->cinfo, COL_INFO, "%s",
tvb_format_text(pinfo->pool, tvb, offset, linelen));
} else {
col_append_fstr(pinfo->cinfo, COL_INFO, "%s",
tvb_format_text(pinfo->pool, tvb, offset+4, linelen-4));
}
}
} else {
col_append_str(pinfo->cinfo, COL_INFO,
tvb_format_text(pinfo->pool, tvb, offset, linelen));
}
}
//Clear multiline state if this is the last line
if (multiline_state == SMTP_MULTILINE_END)
multiline_state = SMTP_MULTILINE_NONE;
}
/*
* Step past this line.
*/
offset = next_offset;
}
return offset;
}
static int
dissect_smtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
struct smtp_proto_data *spd_frame_data;
proto_tree *smtp_tree = NULL;
proto_item *ti;
int offset = 0;
int request = 0;
conversation_t *conversation;
struct smtp_session_state *session_state;
const guchar *line, *linep, *lineend;
int linelen = 0;
gboolean eom_seen = FALSE;
gint next_offset;
gint loffset = 0;
int cmdlen;
guint8 *decrypt = NULL;
gsize decrypt_len = 0;
/* As there is no guarantee that we will only see frames in the
* the SMTP conversation once, and that we will see them in
* order - in Wireshark, the user could randomly click on frames
* in the conversation in any order in which they choose - we
* have to store information with each frame indicating whether
* it contains commands or data or an EOM indication.
*
* XXX - what about frames that contain *both*? TCP is a
* byte-stream protocol, and there are no guarantees that
* TCP segment boundaries will correspond to SMTP commands
* or EOM indications.
*
* We only need that for the client->server stream; responses
* are easy to manage.
*
* If we have per frame data, use that, else, we must be on the first
* pass, so we figure it out on the first pass.
*/
/*
* Find or create the conversation for this.
*/
conversation = find_or_create_conversation(pinfo);
/*
* Is there a request structure attached to this conversation?
*/
session_state = (struct smtp_session_state *)conversation_get_proto_data(conversation, proto_smtp);
if (!session_state) {
/*
* No - create one and attach it.
*/
session_state = wmem_new0(wmem_file_scope(), struct smtp_session_state);
session_state->smtp_state = SMTP_STATE_START;
session_state->auth_state = SMTP_AUTH_STATE_NONE;
session_state->msg_last = TRUE;
conversation_add_proto_data(conversation, proto_smtp, session_state);
}
/* Is this a request or a response? */
request = pinfo->destport == pinfo->match_uint;
/*
* Is there any data attached to this frame?
*/
spd_frame_data = (struct smtp_proto_data *)p_get_proto_data(wmem_file_scope(), pinfo, proto_smtp, 0);
if (!spd_frame_data) {
/*
* No frame data.
*/
if (request) {
/*
* Create a frame data structure and attach it to the packet.
*/
spd_frame_data = wmem_new0(wmem_file_scope(), struct smtp_proto_data);
spd_frame_data->conversation_id = conversation->conv_index;
spd_frame_data->more_frags = TRUE;
spd_frame_data->end_offset = tvb_reported_length(tvb);
p_add_proto_data(wmem_file_scope(), pinfo, proto_smtp, 0, spd_frame_data);
}
/*
* Get the first line from the buffer.
*
* Note that "tvb_find_line_end()" will, if it doesn't return
* -1, return a value that is not longer than what's in the buffer,
* and "tvb_find_line_end()" will always return a value that is not
* longer than what's in the buffer, so the "tvb_get_ptr()" call
* won't throw an exception.
*/
loffset = offset;
while (tvb_offset_exists(tvb, loffset)) {
linelen = tvb_find_line_end(tvb, loffset, -1, &next_offset,
smtp_desegment && pinfo->can_desegment);
if (linelen == -1) {
if (offset == loffset) {
/*
* We didn't find a line ending, and we're doing desegmentation;
* tell the TCP dissector where the data for this message starts
* in the data it handed us, and tell it we need more bytes
*/
pinfo->desegment_offset = loffset;
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
return tvb_captured_length(tvb);
} else {
linelen = tvb_reported_length_remaining(tvb, loffset);
next_offset = loffset + linelen;
}
}
/*
* Check whether or not this packet is an end of message packet
* We should look for CRLF.CRLF and they may be split.
* We have to keep in mind that we may see what we want on
* two passes through here ...
*/
if (request) {
/*
* The order of these is important ... We want to avoid
* cases where there is a CRLF at the end of a packet and a
* .CRLF at the beginning of the same packet.
*/
if (session_state->crlf_seen && tvb_strneql(tvb, loffset, ".\r\n", 3) == 0)
eom_seen = TRUE;
if (tvb_strneql(tvb, next_offset-2, "\r\n", 2) == 0) {
session_state->crlf_seen = TRUE;
} else {
session_state->crlf_seen = FALSE;
}
}
/*
* OK, Check if we have seen a DATA request. We do it here for
* simplicity, but we have to be careful below.
*/
if (request) {
if (session_state->smtp_state == SMTP_STATE_READING_DATA) {
/*
* This is message data.
*/
if (eom_seen) { /* Seen the EOM */
/*
* EOM.
* Everything that comes before it is a message.
* Everything that comes after it is commands.
*/
spd_frame_data->pdu_type = SMTP_PDU_MESSAGE;
spd_frame_data->more_frags = FALSE;
spd_frame_data->end_offset = loffset;
spd_frame_data = append_pdu(spd_frame_data);
spd_frame_data->pdu_type = SMTP_PDU_EOM;
spd_frame_data->end_offset = next_offset;
spd_frame_data = append_pdu(spd_frame_data);
spd_frame_data->end_offset = tvb_reported_length(tvb);
session_state->smtp_state = SMTP_STATE_READING_CMDS;
} else {
/*
* Message data with no EOM.
*/
spd_frame_data->pdu_type = SMTP_PDU_MESSAGE;
if (session_state->msg_tot_len > 0) {
/*
* We are handling a BDAT message.
* Check if we have reached end of the data chunk.
*/
guint32 msg_len = MIN((guint32)tvb_reported_length_remaining(tvb, loffset), (session_state->msg_tot_len - session_state->msg_read_len));
session_state->msg_read_len += msg_len;
/*
* Since we're grabbing the rest of the packet or the data chunk,
* update the offset accordingly.
*/
next_offset = loffset + msg_len;
spd_frame_data->end_offset = next_offset;
if (session_state->msg_read_len == session_state->msg_tot_len) {
/*
* We have reached end of BDAT data chunk.
* Everything that comes after this is commands.
*/
if (session_state->msg_last) {
/*
* We have found the LAST data chunk.
* The message can now be reassembled.
*/
spd_frame_data->more_frags = FALSE;
}
spd_frame_data = append_pdu(spd_frame_data);
spd_frame_data->end_offset = tvb_reported_length(tvb);
session_state->smtp_state = SMTP_STATE_READING_CMDS;
}
}
}
} else {
/*
* This is commands - unless the capture started in the
* middle of a session, and we're in the middle of data.
*
* Commands are not necessarily 4 characters; look
* for a space or the end of the line to see where
* the putative command ends.
*/
if ((session_state->auth_state != SMTP_AUTH_STATE_NONE) &&
(pinfo->num >= session_state->first_auth_frame) &&
((session_state->last_auth_frame == 0) || (pinfo->num <= session_state->last_auth_frame))) {
decrypt = tvb_get_string_enc(pinfo->pool, tvb, loffset, linelen, ENC_ASCII);
if ((smtp_auth_parameter_decoding_enabled) &&
(strlen(decrypt) > 1) &&
(g_base64_decode_inplace(decrypt, &decrypt_len)) &&
(decrypt_len > 0)) {
decrypt[decrypt_len] = 0;
line = decrypt;
linelen = (int)decrypt_len;
} else {
line = tvb_get_ptr(tvb, loffset, linelen);
decrypt_len = linelen;
}
} else {
line = tvb_get_ptr(tvb, loffset, linelen);
}
linep = line;
lineend = line + linelen;
while (linep < lineend && *linep != ' ')
linep++;
cmdlen = (int)(linep - line);
if (line_is_smtp_command(line, cmdlen)) {
if (g_ascii_strncasecmp(line, "DATA", 4) == 0) {
/*
* DATA command.
* This is a command, but everything that comes after it,
* until an EOM, is data.
*/
spd_frame_data->pdu_type = SMTP_PDU_CMD;
session_state->smtp_state = SMTP_STATE_READING_DATA;
session_state->data_seen = TRUE;
} else if (g_ascii_strncasecmp(line, "BDAT", 4) == 0) {
/*
* BDAT command.
* This is a command, but everything that comes after it,
* until given length is received, is data.
*/
guint32 msg_len;
msg_len = (guint32)strtoul (line+5, NULL, 10);
spd_frame_data->pdu_type = SMTP_PDU_CMD;
session_state->data_seen = TRUE;
session_state->msg_tot_len += msg_len;
if (g_ascii_strncasecmp(line+linelen-4, "LAST", 4) == 0) {
/*
* This is the last data chunk.
*/
session_state->msg_last = TRUE;
if (msg_len == 0) {
/*
* No more data to expect.
* The message can now be reassembled.
*/
spd_frame_data->more_frags = FALSE;
}
} else {
session_state->msg_last = FALSE;
}
if (msg_len == 0) {
/* No data to read, next will be another command */
session_state->smtp_state = SMTP_STATE_READING_CMDS;
} else {
session_state->smtp_state = SMTP_STATE_READING_DATA;
spd_frame_data->end_offset = next_offset;
spd_frame_data = append_pdu(spd_frame_data);
spd_frame_data->end_offset = tvb_reported_length(tvb);
}
} else if (g_ascii_strncasecmp(line, "RSET", 4) == 0) {
/*
* RSET command.
* According to RFC 3030, the RSET command clears all BDAT
* segments and resets the transaction. It is possible to
* use DATA and BDAT in the same session, so long as they
* are not mixed in the same transaction.
*/
spd_frame_data->pdu_type = SMTP_PDU_CMD;
session_state->msg_last = TRUE;
session_state->msg_tot_len = 0;
session_state->msg_read_len = 0;
} else if ((g_ascii_strncasecmp(line, "AUTH LOGIN", 10) == 0) && (linelen <= 11)) {
/*
* AUTH LOGIN command.
* Username is in a separate frame
*/
spd_frame_data->pdu_type = SMTP_PDU_CMD;
session_state->smtp_state = SMTP_STATE_READING_CMDS;
session_state->auth_state = SMTP_AUTH_STATE_START;
session_state->first_auth_frame = pinfo->num;
} else if ((g_ascii_strncasecmp(line, "AUTH LOGIN", 10) == 0) && (linelen > 11)) {
/*
* AUTH LOGIN command.
* Username follows the 'AUTH LOGIN' string
*/
spd_frame_data->pdu_type = SMTP_PDU_CMD;
session_state->smtp_state = SMTP_STATE_READING_CMDS;
session_state->auth_state = SMTP_AUTH_STATE_USERNAME_RSP;
session_state->first_auth_frame = pinfo->num;
session_state->username_cmd_frame = pinfo->num;
} else if ((g_ascii_strncasecmp(line, "AUTH PLAIN", 10) == 0) && (linelen <= 11)) {
/*
* AUTH PLAIN command.
* Username and Password is in one separate frame
*/
spd_frame_data->pdu_type = SMTP_PDU_CMD;
session_state->smtp_state = SMTP_STATE_READING_CMDS;
session_state->auth_state = SMTP_AUTH_STATE_PLAIN_START_REQ;
session_state->first_auth_frame = pinfo->num;
} else if ((g_ascii_strncasecmp(line, "AUTH PLAIN", 10) == 0) && (linelen > 11)) {
/*
* AUTH PLAIN command.
* Username and Password follows the 'AUTH PLAIN' string
*/
spd_frame_data->pdu_type = SMTP_PDU_CMD;
session_state->smtp_state = SMTP_STATE_READING_CMDS;
session_state->auth_state = SMTP_AUTH_STATE_PLAIN_CRED_REQ;
session_state->first_auth_frame = pinfo->num;
session_state->user_pass_cmd_frame = pinfo->num;
} else if ((g_ascii_strncasecmp(line, "AUTH NTLM", 9) == 0) && (linelen > 10)) {
/*
* AUTH NTLM command with nlmssp request
*/
spd_frame_data->pdu_type = SMTP_PDU_CMD;
session_state->smtp_state = SMTP_STATE_READING_CMDS;
session_state->auth_state = SMTP_AUTH_STATE_NTLM_REQ;
session_state->ntlm_req_frame = pinfo->num;
} else if (g_ascii_strncasecmp(line, "STARTTLS", 8) == 0) {
/*
* STARTTLS command.
* This is a command, but if the response is 220,
* everything after the response is TLS.
*/
session_state->smtp_state = SMTP_STATE_AWAITING_STARTTLS_RESPONSE;
spd_frame_data->pdu_type = SMTP_PDU_CMD;
} else {
/*
* Regular command.
*/
spd_frame_data->pdu_type = SMTP_PDU_CMD;
}
} else if (session_state->auth_state == SMTP_AUTH_STATE_USERNAME_REQ) {
session_state->auth_state = SMTP_AUTH_STATE_USERNAME_RSP;
session_state->username_frame = pinfo->num;
} else if (session_state->auth_state == SMTP_AUTH_STATE_PASSWORD_REQ) {
session_state->auth_state = SMTP_AUTH_STATE_PASSWORD_RSP;
session_state->password_frame = pinfo->num;
} else if (session_state->auth_state == SMTP_AUTH_STATE_PLAIN_REQ) {
session_state->auth_state = SMTP_AUTH_STATE_PLAIN_RSP;
session_state->user_pass_frame = pinfo->num;
} else if (session_state->auth_state == SMTP_AUTH_STATE_NTLM_CHALLANGE) {
session_state->auth_state = SMTP_AUTH_STATE_NTLM_RSP;
session_state->ntlm_rsp_frame = pinfo->num;
}
else {
/*
* Assume it's message data.
*/
spd_frame_data->pdu_type = (session_state->data_seen || (session_state->smtp_state == SMTP_STATE_START)) ? SMTP_PDU_MESSAGE : SMTP_PDU_CMD;
}
}
}
/*
* Step past this line.
*/
loffset = next_offset;
}
}
/*
* From here, we simply add items to the tree and info to the info
* fields ...
*/
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMTP");
col_clear(pinfo->cinfo, COL_INFO);
ti = proto_tree_add_item(tree, proto_smtp, tvb, offset, -1, ENC_NA);
smtp_tree = proto_item_add_subtree(ti, ett_smtp);
if (request) {
/*
* Check out whether or not we can see a command in there ...
* What we are looking for is not data_seen and the word DATA
* and not eom_seen.
*
* We will see DATA and session_state->data_seen when we process the
* tree view after we have seen a DATA packet when processing
* the packet list pane.
*
* On the first pass, we will not have any info on the packets
* On second and subsequent passes, we will.
*/
spd_frame_data = (struct smtp_proto_data *)p_get_proto_data(wmem_file_scope(), pinfo, proto_smtp, 0);
offset = 0;
while (spd_frame_data != NULL && tvb_reported_length_remaining(tvb, offset)) {
DISSECTOR_ASSERT_CMPINT(offset, <=, spd_frame_data->end_offset);
dissect_smtp_request(tvb_new_subset_length(tvb, offset, spd_frame_data->end_offset - offset), pinfo, tree, smtp_tree, session_state, spd_frame_data, (offset == 0));
offset = spd_frame_data->end_offset;
spd_frame_data = spd_frame_data->next;
}
} else {
dissect_smtp_response(tvb, pinfo, smtp_tree, session_state);
}
return tvb_captured_length(tvb);
}
/* Register all the bits needed by the filtering engine */
void
proto_register_smtp(void)
{
static hf_register_info hf[] = {
{ &hf_smtp_req,
{ "Request", "smtp.req",
FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_smtp_rsp,
{ "Response", "smtp.rsp",
FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_smtp_message,
{ "Message", "smtp.message",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_smtp_command_line,
{ "Command Line", "smtp.command_line",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_smtp_req_command,
{ "Command", "smtp.req.command",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_smtp_req_parameter,
{ "Request parameter", "smtp.req.parameter",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_smtp_response,
{ "Response", "smtp.response",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_smtp_rsp_code,
{ "Response code", "smtp.response.code",
FT_UINT32, BASE_DEC|BASE_EXT_STRING, &response_codes_vs_ext, 0x0, NULL, HFILL }},
{ &hf_smtp_rsp_parameter,
{ "Response parameter", "smtp.rsp.parameter",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_smtp_username,
{ "Username", "smtp.auth.username",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_smtp_password,
{ "Password", "smtp.auth.password",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_smtp_username_password,
{ "Username/Password", "smtp.auth.username_password",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_smtp_eom,
{ "EOM", "smtp.eom",
FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } },
/* Fragment entries */
{ &hf_smtp_data_fragments,
{ "DATA fragments", "smtp.data.fragments",
FT_NONE, BASE_NONE, NULL, 0x00, "Message fragments", HFILL } },
{ &hf_smtp_data_fragment,
{ "DATA fragment", "smtp.data.fragment",
FT_FRAMENUM, BASE_NONE, NULL, 0x00, "Message fragment", HFILL } },
{ &hf_smtp_data_fragment_overlap,
{ "DATA fragment overlap", "smtp.data.fragment.overlap", FT_BOOLEAN,
BASE_NONE, NULL, 0x0, "Message fragment overlap", HFILL } },
{ &hf_smtp_data_fragment_overlap_conflicts,
{ "DATA fragment overlapping with conflicting data",
"smtp.data.fragment.overlap.conflicts", FT_BOOLEAN, BASE_NONE, NULL,
0x0, "Message fragment overlapping with conflicting data", HFILL } },
{ &hf_smtp_data_fragment_multiple_tails,
{ "DATA has multiple tail fragments", "smtp.data.fragment.multiple_tails",
FT_BOOLEAN, BASE_NONE, NULL, 0x0, "Message has multiple tail fragments", HFILL } },
{ &hf_smtp_data_fragment_too_long_fragment,
{ "DATA fragment too long", "smtp.data.fragment.too_long_fragment",
FT_BOOLEAN, BASE_NONE, NULL, 0x0, "Message fragment too long", HFILL } },
{ &hf_smtp_data_fragment_error,
{ "DATA defragmentation error", "smtp.data.fragment.error",
FT_FRAMENUM, BASE_NONE, NULL, 0x00, "Message defragmentation error", HFILL } },
{ &hf_smtp_data_fragment_count,
{ "DATA fragment count", "smtp.data.fragment.count",
FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } },
{ &hf_smtp_data_reassembled_in,
{ "Reassembled DATA in frame", "smtp.data.reassembled.in",
FT_FRAMENUM, BASE_NONE, NULL, 0x00, "This DATA fragment is reassembled in this frame", HFILL } },
{ &hf_smtp_data_reassembled_length,
{ "Reassembled DATA length", "smtp.data.reassembled.length",
FT_UINT32, BASE_DEC, NULL, 0x00, "The total length of the reassembled payload", HFILL } },
};
static gint *ett[] = {
&ett_smtp,
&ett_smtp_cmdresp,
&ett_smtp_data_fragment,
&ett_smtp_data_fragments,
};
static ei_register_info ei[] = {
{ &ei_smtp_base64_decode, { "smtp.base64_decode", PI_PROTOCOL, PI_WARN, "base64 decode failed or is not enabled (check SMTP preferences)", EXPFILL }},
{ &ei_smtp_rsp_code,{ "smtp.response.code.unexpected", PI_PROTOCOL, PI_WARN, "Unexpected response code in multiline response", EXPFILL } },
};
module_t *smtp_module;
expert_module_t* expert_smtp;
proto_smtp = proto_register_protocol("Simple Mail Transfer Protocol",
"SMTP", "smtp");
proto_register_field_array(proto_smtp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_smtp = expert_register_protocol(proto_smtp);
expert_register_field_array(expert_smtp, ei, array_length(ei));
reassembly_table_register(&smtp_data_reassembly_table,
&addresses_ports_reassembly_table_functions);
/* Allow dissector to find be found by name. */
smtp_handle = register_dissector("smtp", dissect_smtp, proto_smtp);
/* Preferences */
smtp_module = prefs_register_protocol(proto_smtp, NULL);
prefs_register_bool_preference(smtp_module, "desegment_lines",
"Reassemble SMTP command and response lines spanning multiple TCP segments",
"Whether the SMTP dissector should reassemble command and response lines"
" spanning multiple TCP segments. To use this option, you must also enable "
"\"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
&smtp_desegment);
prefs_register_bool_preference(smtp_module, "desegment_data",
"Reassemble SMTP DATA commands spanning multiple TCP segments",
"Whether the SMTP dissector should reassemble DATA command and lines"
" spanning multiple TCP segments. To use this option, you must also enable "
"\"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
&smtp_data_desegment);
prefs_register_bool_preference(smtp_module, "decryption",
"Decode Base64 encoded AUTH parameters",
"Whether the SMTP dissector should decode Base64 encoded AUTH parameters",
&smtp_auth_parameter_decoding_enabled);
credentials_tap = register_tap("credentials"); /* credentials tap */
}
/* The registration hand-off routine */
void
proto_reg_handoff_smtp(void)
{
dissector_add_uint_range_with_preference("tcp.port", TCP_PORT_SMTP, smtp_handle);
ssl_dissector_add(TCP_PORT_SSL_SMTP, smtp_handle);
/* No "auto" preference since handle is shared with SMTP */
dissector_add_uint("tcp.port", TCP_PORT_SUBMISSION, smtp_handle);
/* find the IMF dissector */
imf_handle = find_dissector_add_dependency("imf", proto_smtp);
/* find the TLS dissector */
tls_handle = find_dissector_add_dependency("tls", proto_smtp);
/* find the NTLM dissector */
ntlmssp_handle = find_dissector_add_dependency("ntlmssp", proto_smtp);
/* find the data-text-lines dissector */
data_text_lines_handle = find_dissector_add_dependency("data-text-lines", proto_smtp);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true
*/
|
C
|
wireshark/epan/dissectors/packet-sna.c
|
/* packet-sna.c
* Routines for SNA
* Gilbert Ramirez <[email protected]>
* Jochen Friedrich <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/llcsaps.h>
#include <epan/ppptypes.h>
#include <epan/address_types.h>
#include <epan/prefs.h>
#include <epan/reassemble.h>
#include <epan/to_str.h>
#include "wsutil/pint.h"
/*
* See:
*
* http://web.archive.org/web/20020206033700/http://www.wanresources.com/snacell.html
*
* http://web.archive.org/web/20150522015710/http://www.protocols.com/pbook/sna.htm
*
* Systems Network Architecture Formats, GA27-3136-20:
* https://publibz.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/D50A5007/CCONTENTS
*
* Systems Network Architecture Management Services Formats, GC31-8302-03:
* https://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/d50x4002/CCONTENTS
*/
void proto_register_sna(void);
void proto_reg_handoff_sna(void);
static int proto_sna = -1;
static int proto_sna_xid = -1;
static int hf_sna_th = -1;
static int hf_sna_th_0 = -1;
static int hf_sna_th_fid = -1;
static int hf_sna_th_mpf = -1;
static int hf_sna_th_odai = -1;
static int hf_sna_th_efi = -1;
static int hf_sna_th_daf = -1;
static int hf_sna_th_oaf = -1;
static int hf_sna_th_snf = -1;
static int hf_sna_th_dcf = -1;
static int hf_sna_th_lsid = -1;
static int hf_sna_th_tg_sweep = -1;
static int hf_sna_th_er_vr_supp_ind = -1;
static int hf_sna_th_vr_pac_cnt_ind = -1;
static int hf_sna_th_ntwk_prty = -1;
static int hf_sna_th_tgsf = -1;
static int hf_sna_th_mft = -1;
static int hf_sna_th_piubf = -1;
static int hf_sna_th_iern = -1;
static int hf_sna_th_nlpoi = -1;
static int hf_sna_th_nlp_cp = -1;
static int hf_sna_th_ern = -1;
static int hf_sna_th_vrn = -1;
static int hf_sna_th_tpf = -1;
static int hf_sna_th_vr_cwi = -1;
static int hf_sna_th_tg_nonfifo_ind = -1;
static int hf_sna_th_vr_sqti = -1;
static int hf_sna_th_tg_snf = -1;
static int hf_sna_th_vrprq = -1;
static int hf_sna_th_vrprs = -1;
static int hf_sna_th_vr_cwri = -1;
static int hf_sna_th_vr_rwi = -1;
static int hf_sna_th_vr_snf_send = -1;
static int hf_sna_th_dsaf = -1;
static int hf_sna_th_osaf = -1;
static int hf_sna_th_snai = -1;
static int hf_sna_th_def = -1;
static int hf_sna_th_oef = -1;
static int hf_sna_th_sa = -1;
static int hf_sna_th_cmd_fmt = -1;
static int hf_sna_th_cmd_type = -1;
static int hf_sna_th_cmd_sn = -1;
static int hf_sna_th_byte1 = -1;
static int hf_sna_th_byte2 = -1;
static int hf_sna_th_byte3 = -1;
static int hf_sna_th_byte4 = -1;
static int hf_sna_th_byte6 = -1;
static int hf_sna_th_byte16 = -1;
static int hf_sna_nlp_nhdr = -1;
static int hf_sna_nlp_nhdr_0 = -1;
static int hf_sna_nlp_sm = -1;
static int hf_sna_nlp_tpf = -1;
static int hf_sna_nlp_nhdr_1 = -1;
static int hf_sna_nlp_ft = -1;
static int hf_sna_nlp_tspi = -1;
static int hf_sna_nlp_slowdn1 = -1;
static int hf_sna_nlp_slowdn2 = -1;
static int hf_sna_nlp_fra = -1;
static int hf_sna_nlp_anr = -1;
static int hf_sna_nlp_frh = -1;
static int hf_sna_nlp_thdr = -1;
static int hf_sna_nlp_tcid = -1;
static int hf_sna_nlp_thdr_8 = -1;
static int hf_sna_nlp_setupi = -1;
static int hf_sna_nlp_somi = -1;
static int hf_sna_nlp_eomi = -1;
static int hf_sna_nlp_sri = -1;
static int hf_sna_nlp_rasapi = -1;
static int hf_sna_nlp_retryi = -1;
static int hf_sna_nlp_thdr_9 = -1;
static int hf_sna_nlp_lmi = -1;
static int hf_sna_nlp_cqfi = -1;
static int hf_sna_nlp_osi = -1;
static int hf_sna_nlp_offset = -1;
static int hf_sna_nlp_dlf = -1;
static int hf_sna_nlp_bsn = -1;
static int hf_sna_nlp_opti_len = -1;
static int hf_sna_nlp_opti_type = -1;
static int hf_sna_nlp_opti_0d_version = -1;
static int hf_sna_nlp_opti_0d_4 = -1;
static int hf_sna_nlp_opti_0d_target = -1;
static int hf_sna_nlp_opti_0d_arb = -1;
static int hf_sna_nlp_opti_0d_reliable = -1;
static int hf_sna_nlp_opti_0d_dedicated = -1;
static int hf_sna_nlp_opti_0e_stat = -1;
static int hf_sna_nlp_opti_0e_gap = -1;
static int hf_sna_nlp_opti_0e_idle = -1;
static int hf_sna_nlp_opti_0e_nabsp = -1;
static int hf_sna_nlp_opti_0e_sync = -1;
static int hf_sna_nlp_opti_0e_echo = -1;
static int hf_sna_nlp_opti_0e_rseq = -1;
/* static int hf_sna_nlp_opti_0e_abspbeg = -1; */
/* static int hf_sna_nlp_opti_0e_abspend = -1; */
static int hf_sna_nlp_opti_0f_bits = -1;
static int hf_sna_nlp_opti_10_tcid = -1;
static int hf_sna_nlp_opti_12_sense = -1;
static int hf_sna_nlp_opti_14_si_len = -1;
static int hf_sna_nlp_opti_14_si_key = -1;
static int hf_sna_nlp_opti_14_si_2 = -1;
static int hf_sna_nlp_opti_14_si_refifo = -1;
static int hf_sna_nlp_opti_14_si_mobility = -1;
static int hf_sna_nlp_opti_14_si_dirsearch = -1;
static int hf_sna_nlp_opti_14_si_limitres = -1;
static int hf_sna_nlp_opti_14_si_ncescope = -1;
static int hf_sna_nlp_opti_14_si_mnpsrscv = -1;
static int hf_sna_nlp_opti_14_si_maxpsize = -1;
static int hf_sna_nlp_opti_14_si_switch = -1;
static int hf_sna_nlp_opti_14_si_alive = -1;
static int hf_sna_nlp_opti_14_rr_len = -1;
static int hf_sna_nlp_opti_14_rr_key = -1;
static int hf_sna_nlp_opti_14_rr_2 = -1;
static int hf_sna_nlp_opti_14_rr_bfe = -1;
static int hf_sna_nlp_opti_14_rr_num = -1;
static int hf_sna_nlp_opti_22_2 = -1;
static int hf_sna_nlp_opti_22_type = -1;
static int hf_sna_nlp_opti_22_raa = -1;
static int hf_sna_nlp_opti_22_parity = -1;
static int hf_sna_nlp_opti_22_arb = -1;
static int hf_sna_nlp_opti_22_3 = -1;
static int hf_sna_nlp_opti_22_ratereq = -1;
static int hf_sna_nlp_opti_22_raterep = -1;
static int hf_sna_nlp_opti_22_field1 = -1;
static int hf_sna_nlp_opti_22_field2 = -1;
static int hf_sna_nlp_opti_22_field3 = -1;
static int hf_sna_nlp_opti_22_field4 = -1;
static int hf_sna_rh = -1;
static int hf_sna_rh_0 = -1;
static int hf_sna_rh_1 = -1;
static int hf_sna_rh_2 = -1;
static int hf_sna_rh_rri = -1;
static int hf_sna_rh_ru_category = -1;
static int hf_sna_rh_fi = -1;
static int hf_sna_rh_sdi = -1;
static int hf_sna_rh_bci = -1;
static int hf_sna_rh_eci = -1;
static int hf_sna_rh_dr1 = -1;
static int hf_sna_rh_lcci = -1;
static int hf_sna_rh_dr2 = -1;
static int hf_sna_rh_eri = -1;
static int hf_sna_rh_rti = -1;
static int hf_sna_rh_rlwi = -1;
static int hf_sna_rh_qri = -1;
static int hf_sna_rh_pi = -1;
static int hf_sna_rh_bbi = -1;
static int hf_sna_rh_ebi = -1;
static int hf_sna_rh_cdi = -1;
static int hf_sna_rh_csi = -1;
static int hf_sna_rh_edi = -1;
static int hf_sna_rh_pdi = -1;
static int hf_sna_rh_cebi = -1;
/*static int hf_sna_ru = -1;*/
static int hf_sna_gds = -1;
static int hf_sna_gds_len = -1;
static int hf_sna_gds_type = -1;
static int hf_sna_gds_cont = -1;
static int hf_sna_gds_info = -1;
/* static int hf_sna_xid = -1; */
static int hf_sna_xid_0 = -1;
static int hf_sna_xid_id = -1;
static int hf_sna_xid_format = -1;
static int hf_sna_xid_type = -1;
static int hf_sna_xid_len = -1;
static int hf_sna_xid_idblock = -1;
static int hf_sna_xid_idnum = -1;
static int hf_sna_xid_3_8 = -1;
static int hf_sna_xid_3_init_self = -1;
static int hf_sna_xid_3_stand_bind = -1;
static int hf_sna_xid_3_gener_bind = -1;
static int hf_sna_xid_3_recve_bind = -1;
static int hf_sna_xid_3_actpu = -1;
static int hf_sna_xid_3_nwnode = -1;
static int hf_sna_xid_3_cp = -1;
static int hf_sna_xid_3_cpcp = -1;
static int hf_sna_xid_3_state = -1;
static int hf_sna_xid_3_nonact = -1;
static int hf_sna_xid_3_cpchange = -1;
static int hf_sna_xid_3_10 = -1;
static int hf_sna_xid_3_asend_bind = -1;
static int hf_sna_xid_3_arecv_bind = -1;
static int hf_sna_xid_3_quiesce = -1;
static int hf_sna_xid_3_pucap = -1;
static int hf_sna_xid_3_pbn = -1;
static int hf_sna_xid_3_pacing = -1;
static int hf_sna_xid_3_11 = -1;
static int hf_sna_xid_3_tgshare = -1;
static int hf_sna_xid_3_dedsvc = -1;
static int hf_sna_xid_3_12 = -1;
static int hf_sna_xid_3_negcsup = -1;
static int hf_sna_xid_3_negcomp = -1;
static int hf_sna_xid_3_15 = -1;
static int hf_sna_xid_3_partg = -1;
static int hf_sna_xid_3_dlur = -1;
static int hf_sna_xid_3_dlus = -1;
static int hf_sna_xid_3_exbn = -1;
static int hf_sna_xid_3_genodai = -1;
static int hf_sna_xid_3_branch = -1;
static int hf_sna_xid_3_brnn = -1;
static int hf_sna_xid_3_tg = -1;
static int hf_sna_xid_3_dlc = -1;
static int hf_sna_xid_3_dlen = -1;
static int hf_sna_control_len = -1;
static int hf_sna_control_key = -1;
static int hf_sna_control_hprkey = -1;
static int hf_sna_control_05_delay = -1;
static int hf_sna_control_05_type = -1;
static int hf_sna_control_05_ptp = -1;
static int hf_sna_control_0e_type = -1;
static int hf_sna_control_0e_value = -1;
static int hf_sna_padding = -1;
static int hf_sna_reserved = -1;
static int hf_sna_biu_segment_data = -1;
static gint ett_sna = -1;
static gint ett_sna_th = -1;
static gint ett_sna_th_fid = -1;
static gint ett_sna_nlp_nhdr = -1;
static gint ett_sna_nlp_nhdr_0 = -1;
static gint ett_sna_nlp_nhdr_1 = -1;
static gint ett_sna_nlp_thdr = -1;
static gint ett_sna_nlp_thdr_8 = -1;
static gint ett_sna_nlp_thdr_9 = -1;
static gint ett_sna_nlp_opti_un = -1;
static gint ett_sna_nlp_opti_0d = -1;
static gint ett_sna_nlp_opti_0d_4 = -1;
static gint ett_sna_nlp_opti_0e = -1;
static gint ett_sna_nlp_opti_0e_stat = -1;
static gint ett_sna_nlp_opti_0e_absp = -1;
static gint ett_sna_nlp_opti_0f = -1;
static gint ett_sna_nlp_opti_10 = -1;
static gint ett_sna_nlp_opti_12 = -1;
static gint ett_sna_nlp_opti_14 = -1;
static gint ett_sna_nlp_opti_14_si = -1;
static gint ett_sna_nlp_opti_14_si_2 = -1;
static gint ett_sna_nlp_opti_14_rr = -1;
static gint ett_sna_nlp_opti_14_rr_2 = -1;
static gint ett_sna_nlp_opti_22 = -1;
static gint ett_sna_nlp_opti_22_2 = -1;
static gint ett_sna_nlp_opti_22_3 = -1;
static gint ett_sna_rh = -1;
static gint ett_sna_rh_0 = -1;
static gint ett_sna_rh_1 = -1;
static gint ett_sna_rh_2 = -1;
static gint ett_sna_gds = -1;
static gint ett_sna_xid_0 = -1;
static gint ett_sna_xid_id = -1;
static gint ett_sna_xid_3_8 = -1;
static gint ett_sna_xid_3_10 = -1;
static gint ett_sna_xid_3_11 = -1;
static gint ett_sna_xid_3_12 = -1;
static gint ett_sna_xid_3_15 = -1;
static gint ett_sna_control_un = -1;
static gint ett_sna_control_05 = -1;
static gint ett_sna_control_05hpr = -1;
static gint ett_sna_control_05hpr_type = -1;
static gint ett_sna_control_0e = -1;
static dissector_handle_t sna_handle;
static dissector_handle_t sna_xid_handle;
static int sna_address_type = -1;
/* Defragment fragmented SNA BIUs*/
static gboolean sna_defragment = TRUE;
static reassembly_table sna_reassembly_table;
/* Format Identifier */
static const value_string sna_th_fid_vals[] = {
{ 0x0, "SNA device <--> Non-SNA Device" },
{ 0x1, "Subarea Nodes, without ER or VR" },
{ 0x2, "Subarea Node <--> PU2" },
{ 0x3, "Subarea Node or SNA host <--> Subarea Node" },
{ 0x4, "Subarea Nodes, supporting ER and VR" },
{ 0x5, "HPR RTP endpoint nodes" },
{ 0xa, "HPR NLP Frame Routing" },
{ 0xb, "HPR NLP Frame Routing" },
{ 0xc, "HPR NLP Automatic Network Routing" },
{ 0xd, "HPR NLP Automatic Network Routing" },
{ 0xf, "Adjacent Subarea Nodes, supporting ER and VR" },
{ 0x0, NULL }
};
/* Mapping Field */
#define MPF_MIDDLE_SEGMENT 0
#define MPF_LAST_SEGMENT 1
#define MPF_FIRST_SEGMENT 2
#define MPF_WHOLE_BIU 3
static const value_string sna_th_mpf_vals[] = {
{ MPF_MIDDLE_SEGMENT, "Middle segment of a BIU" },
{ MPF_LAST_SEGMENT, "Last segment of a BIU" },
{ MPF_FIRST_SEGMENT, "First segment of a BIU" },
{ MPF_WHOLE_BIU, "Whole BIU" },
{ 0, NULL }
};
/* Expedited Flow Indicator */
static const value_string sna_th_efi_vals[] = {
{ 0, "Normal Flow" },
{ 1, "Expedited Flow" },
{ 0x0, NULL }
};
/* Request/Response Unit Category */
static const value_string sna_rh_ru_category_vals[] = {
{ 0, "Function Management Data (FMD)" },
{ 1, "Network Control (NC)" },
{ 2, "Data Flow Control (DFC)" },
{ 3, "Session Control (SC)" },
{ 0x0, NULL }
};
/* Format Indicator */
static const true_false_string sna_rh_fi_truth =
{ "FM Header", "No FM Header" };
/* Begin Chain Indicator */
static const true_false_string sna_rh_bci_truth =
{ "First in Chain", "Not First in Chain" };
/* End Chain Indicator */
static const true_false_string sna_rh_eci_truth =
{ "Last in Chain", "Not Last in Chain" };
/* Lengith-Checked Compression Indicator */
static const true_false_string sna_rh_lcci_truth =
{ "Compressed", "Not Compressed" };
/* Response Type Indicator */
static const true_false_string sna_rh_rti_truth =
{ "Negative", "Positive" };
/* Queued Response Indicator */
static const true_false_string sna_rh_qri_truth =
{ "Enqueue response in TC queues", "Response bypasses TC queues" };
/* Code Selection Indicator */
static const value_string sna_rh_csi_vals[] = {
{ 0, "EBCDIC" },
{ 1, "ASCII" },
{ 0x0, NULL }
};
/* TG Sweep */
static const value_string sna_th_tg_sweep_vals[] = {
{ 0, "This PIU may overtake any PU ahead of it." },
{ 1, "This PIU does not overtake any PIU ahead of it." },
{ 0x0, NULL }
};
/* ER_VR_SUPP_IND */
static const value_string sna_th_er_vr_supp_ind_vals[] = {
{ 0, "Each node supports ER and VR protocols" },
{ 1, "Includes at least one node that does not support ER and VR"
" protocols" },
{ 0x0, NULL }
};
/* VR_PAC_CNT_IND */
static const value_string sna_th_vr_pac_cnt_ind_vals[] = {
{ 0, "Pacing count on the VR has not reached 0" },
{ 1, "Pacing count on the VR has reached 0" },
{ 0x0, NULL }
};
/* NTWK_PRTY */
static const value_string sna_th_ntwk_prty_vals[] = {
{ 0, "PIU flows at a lower priority" },
{ 1, "PIU flows at network priority (highest transmission priority)" },
{ 0x0, NULL }
};
/* TGSF */
static const value_string sna_th_tgsf_vals[] = {
{ 0, "Not segmented" },
{ 1, "Last segment" },
{ 2, "First segment" },
{ 3, "Middle segment" },
{ 0x0, NULL }
};
/* PIUBF */
static const value_string sna_th_piubf_vals[] = {
{ 0, "Single PIU frame" },
{ 1, "Last PIU of a multiple PIU frame" },
{ 2, "First PIU of a multiple PIU frame" },
{ 3, "Middle PIU of a multiple PIU frame" },
{ 0x0, NULL }
};
/* NLPOI */
static const value_string sna_th_nlpoi_vals[] = {
{ 0, "NLP starts within this FID4 TH" },
{ 1, "NLP byte 0 starts after RH byte 0 following NLP C/P pad" },
{ 0x0, NULL }
};
/* TPF */
static const value_string sna_th_tpf_vals[] = {
{ 0, "Low Priority" },
{ 1, "Medium Priority" },
{ 2, "High Priority" },
{ 3, "Network Priority" },
{ 0x0, NULL }
};
/* VR_CWI */
static const value_string sna_th_vr_cwi_vals[] = {
{ 0, "Increment window size" },
{ 1, "Decrement window size" },
{ 0x0, NULL }
};
/* TG_NONFIFO_IND */
static const true_false_string sna_th_tg_nonfifo_ind_truth =
{ "TG FIFO is not required", "TG FIFO is required" };
/* VR_SQTI */
static const value_string sna_th_vr_sqti_vals[] = {
{ 0, "Non-sequenced, Non-supervisory" },
{ 1, "Non-sequenced, Supervisory" },
{ 2, "Singly-sequenced" },
{ 0x0, NULL }
};
/* VRPRQ */
static const true_false_string sna_th_vrprq_truth = {
"VR pacing request is sent asking for a VR pacing response",
"No VR pacing response is requested",
};
/* VRPRS */
static const true_false_string sna_th_vrprs_truth = {
"VR pacing response is sent in response to a VRPRQ bit set",
"No pacing response sent",
};
/* VR_CWRI */
static const value_string sna_th_vr_cwri_vals[] = {
{ 0, "Increment window size by 1" },
{ 1, "Decrement window size by 1" },
{ 0x0, NULL }
};
/* VR_RWI */
static const true_false_string sna_th_vr_rwi_truth = {
"Reset window size to the minimum specified in NC_ACTVR",
"Do not reset window size",
};
/* Switching Mode */
static const value_string sna_nlp_sm_vals[] = {
{ 5, "Function routing" },
{ 6, "Automatic network routing" },
{ 0x0, NULL }
};
static const true_false_string sna_nlp_tspi_truth =
{ "Time sensitive", "Not time sensitive" };
static const true_false_string sna_nlp_slowdn1_truth =
{ "Minor congestion", "No minor congestion" };
static const true_false_string sna_nlp_slowdn2_truth =
{ "Major congestion", "No major congestion" };
/* Function Type */
static const value_string sna_nlp_ft_vals[] = {
{ 0x10, "LDLC" },
{ 0x0, NULL }
};
static const value_string sna_nlp_frh_vals[] = {
{ 0x03, "XID complete request" },
{ 0x04, "XID complete response" },
{ 0x0, NULL }
};
static const true_false_string sna_nlp_setupi_truth =
{ "Connection setup segment present", "Connection setup segment not"
" present" };
static const true_false_string sna_nlp_somi_truth =
{ "Start of message", "Not start of message" };
static const true_false_string sna_nlp_eomi_truth =
{ "End of message", "Not end of message" };
static const true_false_string sna_nlp_sri_truth =
{ "Status requested", "No status requested" };
static const true_false_string sna_nlp_rasapi_truth =
{ "Reply as soon as possible", "No need to reply as soon as possible" };
static const true_false_string sna_nlp_retryi_truth =
{ "Undefined", "Sender will retransmit" };
static const true_false_string sna_nlp_lmi_truth =
{ "Last message", "Not last message" };
static const true_false_string sna_nlp_cqfi_truth =
{ "CQFI included", "CQFI not included" };
static const true_false_string sna_nlp_osi_truth =
{ "Optional segments present", "No optional segments present" };
static const value_string sna_xid_3_state_vals[] = {
{ 0x00, "Exchange state indicators not supported" },
{ 0x01, "Negotiation-proceeding exchange" },
{ 0x02, "Prenegotiation exchange" },
{ 0x03, "Nonactivation exchange" },
{ 0x0, NULL }
};
static const value_string sna_xid_3_branch_vals[] = {
{ 0x00, "Sender does not support branch extender" },
{ 0x01, "TG is branch uplink" },
{ 0x02, "TG is branch downlink" },
{ 0x03, "TG is neither uplink nor downlink" },
{ 0x0, NULL }
};
static const value_string sna_xid_type_vals[] = {
{ 0x01, "T1 node" },
{ 0x02, "T2.0 or T2.1 node" },
{ 0x03, "Reserved" },
{ 0x04, "T4 or T5 node" },
{ 0x0, NULL }
};
static const value_string sna_nlp_opti_vals[] = {
{ 0x0d, "Connection Setup Segment" },
{ 0x0e, "Status Segment" },
{ 0x0f, "Client Out Of Band Bits Segment" },
{ 0x10, "Connection Identifier Exchange Segment" },
{ 0x12, "Connection Fault Segment" },
{ 0x14, "Switching Information Segment" },
{ 0x22, "Adaptive Rate-Based Segment" },
{ 0x0, NULL }
};
static const value_string sna_nlp_opti_0d_version_vals[] = {
{ 0x0101, "Version 1.1" },
{ 0x0, NULL }
};
static const value_string sna_nlp_opti_0f_bits_vals[] = {
{ 0x0001, "Request Deactivation" },
{ 0x8000, "Reply - OK" },
{ 0x8004, "Reply - Reject" },
{ 0x0, NULL }
};
static const value_string sna_nlp_opti_22_type_vals[] = {
{ 0x00, "Setup" },
{ 0x01, "Rate Reply" },
{ 0x02, "Rate Request" },
{ 0x03, "Rate Request/Rate Reply" },
{ 0x0, NULL }
};
static const value_string sna_nlp_opti_22_raa_vals[] = {
{ 0x00, "Normal" },
{ 0x01, "Restraint" },
{ 0x02, "Slowdown1" },
{ 0x03, "Slowdown2" },
{ 0x04, "Critical" },
{ 0x0, NULL }
};
static const value_string sna_nlp_opti_22_arb_vals[] = {
{ 0x00, "Base Mode ARB" },
{ 0x01, "Responsive Mode ARB" },
{ 0x0, NULL }
};
/* GDS Variable Type */
static const value_string sna_gds_var_vals[] = {
{ 0x1210, "Change Number Of Sessions" },
{ 0x1211, "Exchange Log Name" },
{ 0x1212, "Control Point Management Services Unit" },
{ 0x1213, "Compare States" },
{ 0x1214, "LU Names Position" },
{ 0x1215, "LU Name" },
{ 0x1217, "Do Know" },
{ 0x1218, "Partner Restart" },
{ 0x1219, "Don't Know" },
{ 0x1220, "Sign-Off" },
{ 0x1221, "Sign-On" },
{ 0x1222, "SNMP-over-SNA" },
{ 0x1223, "Node Address Service" },
{ 0x12C1, "CP Capabilities" },
{ 0x12C2, "Topology Database Update" },
{ 0x12C3, "Register Resource" },
{ 0x12C4, "Locate" },
{ 0x12C5, "Cross-Domain Initiate" },
{ 0x12C9, "Delete Resource" },
{ 0x12CA, "Find Resource" },
{ 0x12CB, "Found Resource" },
{ 0x12CC, "Notify" },
{ 0x12CD, "Initiate-Other Cross-Domain" },
{ 0x12CE, "Route Setup" },
{ 0x12E1, "Error Log" },
{ 0x12F1, "Null Data" },
{ 0x12F2, "User Control Date" },
{ 0x12F3, "Map Name" },
{ 0x12F4, "Error Data" },
{ 0x12F6, "Authentication Token Data" },
{ 0x12F8, "Service Flow Authentication Token Data" },
{ 0x12FF, "Application Data" },
{ 0x1310, "MDS Message Unit" },
{ 0x1311, "MDS Routing Information" },
{ 0x1500, "FID2 Encapsulation" },
{ 0x0, NULL }
};
/* Control Vector Type */
static const value_string sna_control_vals[] = {
{ 0x00, "SSCP-LU Session Capabilities Control Vector" },
{ 0x01, "Date-Time Control Vector" },
{ 0x02, "Subarea Routing Control Vector" },
{ 0x03, "SDLC Secondary Station Control Vector" },
{ 0x04, "LU Control Vector" },
{ 0x05, "Channel Control Vector" },
{ 0x06, "Cross-Domain Resource Manager (CDRM) Control Vector" },
{ 0x07, "PU FMD-RU-Usage Control Vector" },
{ 0x08, "Intensive Mode Control Vector" },
{ 0x09, "Activation Request / Response Sequence Identifier Control"
" Vector" },
{ 0x0a, "User Request Correlator Control Vector" },
{ 0x0b, "SSCP-PU Session Capabilities Control Vector" },
{ 0x0c, "LU-LU Session Capabilities Control Vector" },
{ 0x0d, "Mode / Class-of-Service / Virtual-Route-Identifier List"
" Control Vector" },
{ 0x0e, "Network Name Control Vector" },
{ 0x0f, "Link Capabilities and Status Control Vector" },
{ 0x10, "Product Set ID Control Vector" },
{ 0x11, "Load Module Correlation Control Vector" },
{ 0x12, "Network Identifier Control Vector" },
{ 0x13, "Gateway Support Capabilities Control Vector" },
{ 0x14, "Session Initiation Control Vector" },
{ 0x15, "Network-Qualified Address Pair Control Vector" },
{ 0x16, "Names Substitution Control Vector" },
{ 0x17, "SSCP Identifier Control Vector" },
{ 0x18, "SSCP Name Control Vector" },
{ 0x19, "Resource Identifier Control Vector" },
{ 0x1a, "NAU Address Control Vector" },
{ 0x1b, "VRID List Control Vector" },
{ 0x1c, "Network-Qualified Name Pair Control Vector" },
{ 0x1e, "VR-ER Mapping Data Control Vector" },
{ 0x1f, "ER Configuration Control Vector" },
{ 0x23, "Local-Form Session Identifier Control Vector" },
{ 0x24, "IPL Load Module Request Control Vector" },
{ 0x25, "Security ID Control Control Vector" },
{ 0x26, "Network Connection Endpoint Identifier Control Vector" },
{ 0x27, "XRF Session Activation Control Vector" },
{ 0x28, "Related Session Identifier Control Vector" },
{ 0x29, "Session State Data Control Vector" },
{ 0x2a, "Session Information Control Vector" },
{ 0x2b, "Route Selection Control Vector" },
{ 0x2c, "COS/TPF Control Vector" },
{ 0x2d, "Mode Control Vector" },
{ 0x2f, "LU Definition Control Vector" },
{ 0x30, "Assign LU Characteristics Control Vector" },
{ 0x31, "BIND Image Control Vector" },
{ 0x32, "Short-Hold Mode Control Vector" },
{ 0x33, "ENCP Search Control Control Vector" },
{ 0x34, "LU Definition Override Control Vector" },
{ 0x35, "Extended Sense Data Control Vector" },
{ 0x36, "Directory Error Control Vector" },
{ 0x37, "Directory Entry Correlator Control Vector" },
{ 0x38, "Short-Hold Mode Emulation Control Vector" },
{ 0x39, "Network Connection Endpoint (NCE) Instance Identifier"
" Control Vector" },
{ 0x3a, "Route Status Data Control Vector" },
{ 0x3b, "VR Congestion Data Control Vector" },
{ 0x3c, "Associated Resource Entry Control Vector" },
{ 0x3d, "Directory Entry Control Vector" },
{ 0x3e, "Directory Entry Characteristic Control Vector" },
{ 0x3f, "SSCP (SLU) Capabilities Control Vector" },
{ 0x40, "Real Associated Resource Control Vector" },
{ 0x41, "Station Parameters Control Vector" },
{ 0x42, "Dynamic Path Update Data Control Vector" },
{ 0x43, "Extended SDLC Station Control Vector" },
{ 0x44, "Node Descriptor Control Vector" },
{ 0x45, "Node Characteristics Control Vector" },
{ 0x46, "TG Descriptor Control Vector" },
{ 0x47, "TG Characteristics Control Vector" },
{ 0x48, "Topology Resource Descriptor Control Vector" },
{ 0x49, "Multinode Persistent Sessions (MNPS) LU Names Control"
" Vector" },
{ 0x4a, "Real Owning Control Point Control Vector" },
{ 0x4b, "RTP Transport Connection Identifier Control Vector" },
{ 0x51, "DLUR/S Capabilities Control Vector" },
{ 0x52, "Primary Send Pacing Window Size Control Vector" },
{ 0x56, "Call Security Verification Control Vector" },
{ 0x57, "DLC Connection Data Control Vector" },
{ 0x59, "Installation-Defined CDINIT Data Control Vector" },
{ 0x5a, "Session Services Extension Support Control Vector" },
{ 0x5b, "Interchange Node Support Control Vector" },
{ 0x5c, "APPN Message Transport Control Vector" },
{ 0x5d, "Subarea Message Transport Control Vector" },
{ 0x5e, "Related Request Control Vector" },
{ 0x5f, "Extended Fully Qualified PCID Control Vector" },
{ 0x60, "Fully Qualified PCID Control Vector" },
{ 0x61, "HPR Capabilities Control Vector" },
{ 0x62, "Session Address Control Vector" },
{ 0x63, "Cryptographic Key Distribution Control Vector" },
{ 0x64, "TCP/IP Information Control Vector" },
{ 0x65, "Device Characteristics Control Vector" },
{ 0x66, "Length-Checked Compression Control Vector" },
{ 0x67, "Automatic Network Routing (ANR) Path Control Vector" },
{ 0x68, "XRF/Session Cryptography Control Vector" },
{ 0x69, "Switched Parameters Control Vector" },
{ 0x6a, "ER Congestion Data Control Vector" },
{ 0x71, "Triple DES Cryptography Key Continuation Control Vector" },
{ 0xfe, "Control Vector Keys Not Recognized" },
{ 0x0, NULL }
};
static const value_string sna_control_hpr_vals[] = {
{ 0x00, "Node Identifier Control Vector" },
{ 0x03, "Network ID Control Vector" },
{ 0x05, "Network Address Control Vector" },
{ 0x0, NULL }
};
static const value_string sna_control_0e_type_vals[] = {
{ 0xF1, "PU Name" },
{ 0xF3, "LU Name" },
{ 0xF4, "CP Name" },
{ 0xF5, "SSCP Name" },
{ 0xF6, "NNCP Name" },
{ 0xF7, "Link Station Name" },
{ 0xF8, "CP Name of CP(PLU)" },
{ 0xF9, "CP Name of CP(SLU)" },
{ 0xFA, "Generic Name" },
{ 0x0, NULL }
};
/* Values to direct the top-most dissector what to dissect
* after the TH. */
enum next_dissection_enum {
stop_here,
rh_only,
everything
};
enum parse {
LT,
KL
};
/*
* Structure used to represent an FID Type 4 address; gives the layout of the
* data pointed to by an AT_SNA "address" structure if the size is
* SNA_FID_TYPE_4_ADDR_LEN.
*/
#define SNA_FID_TYPE_4_ADDR_LEN 6
struct sna_fid_type_4_addr {
guint32 saf;
guint16 ef;
};
typedef enum next_dissection_enum next_dissection_t;
static void dissect_xid (tvbuff_t*, packet_info*, proto_tree*, proto_tree*);
static void dissect_fid (tvbuff_t*, packet_info*, proto_tree*, proto_tree*);
static void dissect_nlp (tvbuff_t*, packet_info*, proto_tree*, proto_tree*);
static void dissect_gds (tvbuff_t*, packet_info*, proto_tree*, proto_tree*);
static void dissect_rh (tvbuff_t*, int, proto_tree*);
static void dissect_sna_control(tvbuff_t* parent_tvb, int offset, int control_len, proto_tree* tree, int hpr, enum parse parse);
static int sna_fid_to_str_buf(const address *addr, gchar *buf, int buf_len _U_)
{
const guint8 *addrdata;
struct sna_fid_type_4_addr sna_fid_type_4_addr;
gchar *bufp = buf;
switch (addr->len) {
case 1:
addrdata = (const guint8 *)addr->data;
word_to_hex(buf, addrdata[0]);
buf[4] = '\0';
break;
case 2:
addrdata = (const guint8 *)addr->data;
word_to_hex(buf, pntoh16(&addrdata[0]));
buf[4] = '\0';
break;
case SNA_FID_TYPE_4_ADDR_LEN:
/* FID Type 4 */
memcpy(&sna_fid_type_4_addr, addr->data, SNA_FID_TYPE_4_ADDR_LEN);
bufp = dword_to_hex(bufp, sna_fid_type_4_addr.saf);
*bufp++ = '.';
bufp = word_to_hex(bufp, sna_fid_type_4_addr.ef);
*bufp++ = '\0'; /* NULL terminate */
break;
default:
buf[0] = '\0';
return 1;
}
return (int)strlen(buf)+1;
}
static int sna_address_str_len(const address* addr _U_)
{
/* We could do this based on address length, but 14 bytes isn't THAT much space */
return 14;
}
/* --------------------------------------------------------------------
* Chapter 2 High-Performance Routing (HPR) Headers
* --------------------------------------------------------------------
*/
static void
dissect_optional_0d(tvbuff_t *tvb, proto_tree *tree)
{
int offset, len, pad;
static int * const fields[] = {
&hf_sna_nlp_opti_0d_target,
&hf_sna_nlp_opti_0d_arb,
&hf_sna_nlp_opti_0d_reliable,
&hf_sna_nlp_opti_0d_dedicated,
NULL
};
if (!tree)
return;
proto_tree_add_item(tree, hf_sna_nlp_opti_0d_version, tvb, 2, 2, ENC_BIG_ENDIAN);
proto_tree_add_bitmask(tree, tvb, 4, hf_sna_nlp_opti_0d_4,
ett_sna_nlp_opti_0d_4, fields, ENC_NA);
proto_tree_add_item(tree, hf_sna_reserved, tvb, 5, 3, ENC_NA);
offset = 8;
while (tvb_offset_exists(tvb, offset)) {
len = tvb_get_guint8(tvb, offset+0);
if (len) {
dissect_sna_control(tvb, offset, len, tree, 1, LT);
pad = (len+3) & 0xfffc;
if (pad > len)
proto_tree_add_item(tree, hf_sna_padding, tvb, offset+len, pad-len, ENC_NA);
offset += pad;
} else {
/* Avoid endless loop */
return;
}
}
}
static void
dissect_optional_0e(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
int bits, offset;
static int * const fields[] = {
&hf_sna_nlp_opti_0e_gap,
&hf_sna_nlp_opti_0e_idle,
NULL
};
bits = tvb_get_guint8(tvb, 2);
offset = 20;
proto_tree_add_bitmask(tree, tvb, 2, hf_sna_nlp_opti_0e_stat,
ett_sna_nlp_opti_0e_stat, fields, ENC_NA);
proto_tree_add_item(tree, hf_sna_nlp_opti_0e_nabsp,
tvb, 3, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_sna_nlp_opti_0e_sync,
tvb, 4, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_sna_nlp_opti_0e_echo,
tvb, 6, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_sna_nlp_opti_0e_rseq,
tvb, 8, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_sna_reserved, tvb, 12, 8, ENC_NA);
if (tvb_offset_exists(tvb, offset))
call_data_dissector(tvb_new_subset_remaining(tvb, 4), pinfo, tree);
if (bits & 0x40) {
col_set_str(pinfo->cinfo, COL_INFO, "HPR Idle Message");
} else {
col_set_str(pinfo->cinfo, COL_INFO, "HPR Status Message");
}
}
static void
dissect_optional_0f(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree_add_item(tree, hf_sna_nlp_opti_0f_bits, tvb, 2, 2, ENC_BIG_ENDIAN);
if (tvb_offset_exists(tvb, 4))
call_data_dissector(tvb_new_subset_remaining(tvb, 4), pinfo, tree);
}
static void
dissect_optional_10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree_add_item(tree, hf_sna_reserved, tvb, 2, 2, ENC_NA);
proto_tree_add_item(tree, hf_sna_nlp_opti_10_tcid, tvb, 4, 8, ENC_NA);
if (tvb_offset_exists(tvb, 12))
call_data_dissector(tvb_new_subset_remaining(tvb, 12), pinfo, tree);
}
static void
dissect_optional_12(tvbuff_t *tvb, proto_tree *tree)
{
proto_tree_add_item(tree, hf_sna_reserved, tvb, 2, 2, ENC_NA);
proto_tree_add_item(tree, hf_sna_nlp_opti_12_sense, tvb, 4, -1, ENC_NA);
}
static void
dissect_optional_14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree *sub_tree;
int len, pad, type, offset, num, sublen;
static int * const opti_14_si_fields[] = {
&hf_sna_nlp_opti_14_si_refifo,
&hf_sna_nlp_opti_14_si_mobility,
&hf_sna_nlp_opti_14_si_dirsearch,
&hf_sna_nlp_opti_14_si_limitres,
&hf_sna_nlp_opti_14_si_ncescope,
&hf_sna_nlp_opti_14_si_mnpsrscv,
NULL
};
static int * const opti_14_rr_fields[] = {
&hf_sna_nlp_opti_14_rr_bfe,
NULL
};
proto_tree_add_item(tree, hf_sna_reserved, tvb, 2, 2, ENC_NA);
offset = 4;
len = tvb_get_guint8(tvb, offset);
type = tvb_get_guint8(tvb, offset+1);
if ((type != 0x83) || (len <= 16)) {
/* Invalid */
call_data_dissector(tvb_new_subset_remaining(tvb, offset), pinfo, tree);
return;
}
sub_tree = proto_tree_add_subtree(tree, tvb, offset, len,
ett_sna_nlp_opti_14_si, NULL, "Switching Information Control Vector");
proto_tree_add_uint(sub_tree, hf_sna_nlp_opti_14_si_len,
tvb, offset, 1, len);
proto_tree_add_uint(sub_tree, hf_sna_nlp_opti_14_si_key,
tvb, offset+1, 1, type);
proto_tree_add_bitmask(tree, tvb, offset+2, hf_sna_nlp_opti_14_si_2,
ett_sna_nlp_opti_14_si_2, opti_14_si_fields, ENC_NA);
proto_tree_add_item(sub_tree, hf_sna_reserved, tvb, offset+3, 1, ENC_NA);
proto_tree_add_item(sub_tree, hf_sna_nlp_opti_14_si_maxpsize,
tvb, offset+4, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_sna_nlp_opti_14_si_switch,
tvb, offset+8, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_sna_nlp_opti_14_si_alive,
tvb, offset+12, 4, ENC_BIG_ENDIAN);
dissect_sna_control(tvb, offset+16, len-16, sub_tree, 1, LT);
pad = (len+3) & 0xfffc;
if (pad > len)
proto_tree_add_item(sub_tree, hf_sna_padding, tvb, offset+len, pad-len, ENC_NA);
offset += pad;
len = tvb_get_guint8(tvb, offset);
type = tvb_get_guint8(tvb, offset+1);
if ((type != 0x85) || ( len < 4)) {
/* Invalid */
call_data_dissector(tvb_new_subset_remaining(tvb, offset), pinfo, tree);
return;
}
sub_tree = proto_tree_add_subtree(tree, tvb, offset, len,
ett_sna_nlp_opti_14_rr, NULL, "Return Route TG Descriptor Control Vector");
proto_tree_add_uint(sub_tree, hf_sna_nlp_opti_14_rr_len,
tvb, offset, 1, len);
proto_tree_add_uint(sub_tree, hf_sna_nlp_opti_14_rr_key,
tvb, offset+1, 1, type);
proto_tree_add_bitmask(tree, tvb, offset+2, hf_sna_nlp_opti_14_rr_2,
ett_sna_nlp_opti_14_rr_2, opti_14_rr_fields, ENC_NA);
num = tvb_get_guint8(tvb, offset+3);
proto_tree_add_uint(sub_tree, hf_sna_nlp_opti_14_rr_num,
tvb, offset+3, 1, num);
offset += 4;
while (num) {
sublen = tvb_get_guint8(tvb, offset);
if (sublen) {
dissect_sna_control(tvb, offset, sublen, sub_tree, 1, LT);
} else {
/* Invalid */
call_data_dissector(tvb_new_subset_remaining(tvb, offset), pinfo, tree);
return;
}
/* No padding here */
offset += sublen;
num--;
}
}
static void
dissect_optional_22(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
int bits, type;
static int * const opti_22_2_fields[] = {
&hf_sna_nlp_opti_22_type,
&hf_sna_nlp_opti_22_raa,
&hf_sna_nlp_opti_22_parity,
&hf_sna_nlp_opti_22_arb,
NULL
};
static int * const opti_22_3_fields[] = {
&hf_sna_nlp_opti_22_ratereq,
&hf_sna_nlp_opti_22_raterep,
NULL
};
bits = tvb_get_guint8(tvb, 2);
type = (bits & 0xc0) >> 6;
proto_tree_add_bitmask(tree, tvb, 2, hf_sna_nlp_opti_22_2,
ett_sna_nlp_opti_22_2, opti_22_2_fields, ENC_NA);
proto_tree_add_bitmask(tree, tvb, 3, hf_sna_nlp_opti_22_3,
ett_sna_nlp_opti_22_3, opti_22_3_fields, ENC_NA);
proto_tree_add_item(tree, hf_sna_nlp_opti_22_field1,
tvb, 4, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_sna_nlp_opti_22_field2,
tvb, 8, 4, ENC_BIG_ENDIAN);
if (type == 0) {
proto_tree_add_item(tree, hf_sna_nlp_opti_22_field3,
tvb, 12, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_sna_nlp_opti_22_field4,
tvb, 16, 4, ENC_BIG_ENDIAN);
if (tvb_offset_exists(tvb, 20))
call_data_dissector(tvb_new_subset_remaining(tvb, 20), pinfo, tree);
} else {
if (tvb_offset_exists(tvb, 12))
call_data_dissector(tvb_new_subset_remaining(tvb, 12), pinfo, tree);
}
}
static void
dissect_optional(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree *sub_tree;
int offset, type, len;
gint ett;
sub_tree = NULL;
offset = 0;
while (tvb_offset_exists(tvb, offset)) {
len = tvb_get_guint8(tvb, offset);
type = tvb_get_guint8(tvb, offset+1);
/* Prevent loop for invalid crap in packet */
if (len == 0) {
call_data_dissector(tvb_new_subset_remaining(tvb, offset), pinfo, tree);
return;
}
ett = ett_sna_nlp_opti_un;
if(type == 0x0d) ett = ett_sna_nlp_opti_0d;
if(type == 0x0e) ett = ett_sna_nlp_opti_0e;
if(type == 0x0f) ett = ett_sna_nlp_opti_0f;
if(type == 0x10) ett = ett_sna_nlp_opti_10;
if(type == 0x12) ett = ett_sna_nlp_opti_12;
if(type == 0x14) ett = ett_sna_nlp_opti_14;
if(type == 0x22) ett = ett_sna_nlp_opti_22;
if (tree) {
sub_tree = proto_tree_add_subtree(tree, tvb,
offset, len << 2, ett, NULL,
val_to_str_const(type, sna_nlp_opti_vals, "Unknown Segment Type"));
proto_tree_add_uint(sub_tree, hf_sna_nlp_opti_len,
tvb, offset, 1, len);
proto_tree_add_uint(sub_tree, hf_sna_nlp_opti_type,
tvb, offset+1, 1, type);
}
switch(type) {
case 0x0d:
dissect_optional_0d(tvb_new_subset_length_caplen(tvb, offset,
len << 2, -1), sub_tree);
break;
case 0x0e:
dissect_optional_0e(tvb_new_subset_length_caplen(tvb, offset,
len << 2, -1), pinfo, sub_tree);
break;
case 0x0f:
dissect_optional_0f(tvb_new_subset_length_caplen(tvb, offset,
len << 2, -1), pinfo, sub_tree);
break;
case 0x10:
dissect_optional_10(tvb_new_subset_length_caplen(tvb, offset,
len << 2, -1), pinfo, sub_tree);
break;
case 0x12:
dissect_optional_12(tvb_new_subset_length_caplen(tvb, offset,
len << 2, -1), sub_tree);
break;
case 0x14:
dissect_optional_14(tvb_new_subset_length_caplen(tvb, offset,
len << 2, -1), pinfo, sub_tree);
break;
case 0x22:
dissect_optional_22(tvb_new_subset_length_caplen(tvb, offset,
len << 2, -1), pinfo, sub_tree);
break;
default:
call_data_dissector(tvb_new_subset_length_caplen(tvb, offset,
len << 2, -1), pinfo, sub_tree);
}
offset += (len << 2);
}
}
static void
dissect_nlp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
proto_tree *parent_tree)
{
proto_tree *nlp_tree;
proto_item *nlp_item;
guint8 nhdr_0, nhdr_1, nhdr_x, thdr_8, thdr_9, fid;
guint32 thdr_len, thdr_dlf;
guint16 subindx;
static int * const nlp_nhdr_0_fields[] = {
&hf_sna_nlp_sm,
&hf_sna_nlp_tpf,
NULL
};
static int * const nlp_nhdr_1_fields[] = {
&hf_sna_nlp_ft,
&hf_sna_nlp_tspi,
&hf_sna_nlp_slowdn1,
&hf_sna_nlp_slowdn2,
NULL
};
static int * const nlp_nhdr_8_fields[] = {
&hf_sna_nlp_setupi,
&hf_sna_nlp_somi,
&hf_sna_nlp_eomi,
&hf_sna_nlp_sri,
&hf_sna_nlp_rasapi,
&hf_sna_nlp_retryi,
NULL
};
static int * const nlp_nhdr_9_fields[] = {
&hf_sna_nlp_lmi,
&hf_sna_nlp_cqfi,
&hf_sna_nlp_osi,
NULL
};
int indx = 0, counter = 0;
nlp_tree = NULL;
nlp_item = NULL;
nhdr_0 = tvb_get_guint8(tvb, indx);
nhdr_1 = tvb_get_guint8(tvb, indx+1);
col_set_str(pinfo->cinfo, COL_INFO, "HPR NLP Packet");
if (tree) {
/* Don't bother setting length. We'll set it later after we
* find the lengths of NHDR */
nlp_item = proto_tree_add_item(tree, hf_sna_nlp_nhdr, tvb,
indx, -1, ENC_NA);
nlp_tree = proto_item_add_subtree(nlp_item, ett_sna_nlp_nhdr);
proto_tree_add_bitmask(nlp_tree, tvb, indx, hf_sna_nlp_nhdr_0,
ett_sna_nlp_nhdr_0, nlp_nhdr_0_fields, ENC_NA);
proto_tree_add_bitmask(nlp_tree, tvb, indx+1, hf_sna_nlp_nhdr_1,
ett_sna_nlp_nhdr_1, nlp_nhdr_1_fields, ENC_NA);
}
/* ANR or FR lists */
indx += 2;
counter = 0;
if ((nhdr_0 & 0xe0) == 0xa0) {
do {
nhdr_x = tvb_get_guint8(tvb, indx + counter);
counter ++;
} while (nhdr_x != 0xff);
proto_tree_add_item(nlp_tree,
hf_sna_nlp_fra, tvb, indx, counter, ENC_NA);
indx += counter;
proto_tree_add_item(nlp_tree, hf_sna_reserved, tvb, indx, 1, ENC_NA);
indx++;
if (tree)
proto_item_set_len(nlp_item, indx);
if ((nhdr_1 & 0xf0) == 0x10) {
proto_tree_add_item(tree, hf_sna_nlp_frh,
tvb, indx, 1, ENC_BIG_ENDIAN);
indx ++;
if (tvb_offset_exists(tvb, indx))
call_data_dissector(tvb_new_subset_remaining(tvb, indx),
pinfo, parent_tree);
return;
}
}
if ((nhdr_0 & 0xe0) == 0xc0) {
do {
nhdr_x = tvb_get_guint8(tvb, indx + counter);
counter ++;
} while (nhdr_x != 0xff);
proto_tree_add_item(nlp_tree, hf_sna_nlp_anr,
tvb, indx, counter, ENC_NA);
indx += counter;
proto_tree_add_item(nlp_tree, hf_sna_reserved, tvb, indx, 1, ENC_NA);
indx++;
if (tree)
proto_item_set_len(nlp_item, indx);
}
thdr_8 = tvb_get_guint8(tvb, indx+8);
thdr_9 = tvb_get_guint8(tvb, indx+9);
thdr_len = tvb_get_ntohs(tvb, indx+10);
thdr_dlf = tvb_get_ntohl(tvb, indx+12);
if (tree) {
nlp_item = proto_tree_add_item(tree, hf_sna_nlp_thdr, tvb,
indx, thdr_len << 2, ENC_NA);
nlp_tree = proto_item_add_subtree(nlp_item, ett_sna_nlp_thdr);
proto_tree_add_item(nlp_tree, hf_sna_nlp_tcid, tvb,
indx, 8, ENC_NA);
proto_tree_add_bitmask(nlp_tree, tvb, indx+8, hf_sna_nlp_thdr_8,
ett_sna_nlp_thdr_8, nlp_nhdr_8_fields, ENC_NA);
proto_tree_add_bitmask(nlp_tree, tvb, indx+9, hf_sna_nlp_thdr_9,
ett_sna_nlp_thdr_9, nlp_nhdr_9_fields, ENC_NA);
proto_tree_add_uint(nlp_tree, hf_sna_nlp_offset, tvb, indx+10,
2, thdr_len);
proto_tree_add_uint(nlp_tree, hf_sna_nlp_dlf, tvb, indx+12,
4, thdr_dlf);
proto_tree_add_item(nlp_tree, hf_sna_nlp_bsn, tvb, indx+16,
4, ENC_BIG_ENDIAN);
}
subindx = 20;
if (((thdr_9 & 0x18) == 0x08) && ((thdr_len << 2) > subindx)) {
counter = tvb_get_guint8(tvb, indx + subindx);
if (tvb_get_guint8(tvb, indx+subindx+1) == 5)
dissect_sna_control(tvb, indx + subindx, counter+2, nlp_tree, 1, LT);
else
call_data_dissector(tvb_new_subset_length_caplen(tvb, indx + subindx, counter+2,
-1), pinfo, nlp_tree);
subindx += (counter+2);
}
if ((thdr_9 & 0x04) && ((thdr_len << 2) > subindx))
dissect_optional(
tvb_new_subset_length_caplen(tvb, indx + subindx,
(thdr_len << 2) - subindx, -1),
pinfo, nlp_tree);
indx += (thdr_len << 2);
if (((thdr_8 & 0x20) == 0) && thdr_dlf) {
col_set_str(pinfo->cinfo, COL_INFO, "HPR Fragment");
if (tvb_offset_exists(tvb, indx)) {
call_data_dissector(tvb_new_subset_remaining(tvb, indx), pinfo,
parent_tree);
}
return;
}
if (tvb_offset_exists(tvb, indx)) {
/* Transmission Header Format Identifier */
fid = hi_nibble(tvb_get_guint8(tvb, indx));
if (fid == 5) /* Only FID5 allowed for HPR */
dissect_fid(tvb_new_subset_remaining(tvb, indx), pinfo,
tree, parent_tree);
else {
if (tvb_get_ntohs(tvb, indx+2) == 0x12ce) {
/* Route Setup */
col_set_str(pinfo->cinfo, COL_INFO, "HPR Route Setup");
dissect_gds(tvb_new_subset_remaining(tvb, indx),
pinfo, tree, parent_tree);
} else
call_data_dissector(tvb_new_subset_remaining(tvb, indx),
pinfo, parent_tree);
}
}
}
/* --------------------------------------------------------------------
* Chapter 3 Exchange Identification (XID) Information Fields
* --------------------------------------------------------------------
*/
static void
dissect_xid1(tvbuff_t *tvb, proto_tree *tree)
{
proto_tree_add_item(tree, hf_sna_reserved, tvb, 0, 2, ENC_NA);
}
static void
dissect_xid2(tvbuff_t *tvb, proto_tree *tree)
{
guint dlen, offset;
if (!tree)
return;
dlen = tvb_get_guint8(tvb, 0);
offset = dlen;
while (tvb_offset_exists(tvb, offset)) {
dlen = tvb_get_guint8(tvb, offset+1);
dissect_sna_control(tvb, offset, dlen+2, tree, 0, KL);
offset += (dlen + 2);
}
}
static void
dissect_xid3(tvbuff_t *tvb, proto_tree *tree)
{
guint dlen, offset;
static int * const sna_xid_3_fields[] = {
&hf_sna_xid_3_init_self,
&hf_sna_xid_3_stand_bind,
&hf_sna_xid_3_gener_bind,
&hf_sna_xid_3_recve_bind,
&hf_sna_xid_3_actpu,
&hf_sna_xid_3_nwnode,
&hf_sna_xid_3_cp,
&hf_sna_xid_3_cpcp,
&hf_sna_xid_3_state,
&hf_sna_xid_3_nonact,
&hf_sna_xid_3_cpchange,
NULL
};
static int * const sna_xid_10_fields[] = {
&hf_sna_xid_3_asend_bind,
&hf_sna_xid_3_arecv_bind,
&hf_sna_xid_3_quiesce,
&hf_sna_xid_3_pucap,
&hf_sna_xid_3_pbn,
&hf_sna_xid_3_pacing,
NULL
};
static int * const sna_xid_11_fields[] = {
&hf_sna_xid_3_tgshare,
&hf_sna_xid_3_dedsvc,
NULL
};
static int * const sna_xid_12_fields[] = {
&hf_sna_xid_3_negcsup,
&hf_sna_xid_3_negcomp,
NULL
};
static int * const sna_xid_15_fields[] = {
&hf_sna_xid_3_partg,
&hf_sna_xid_3_dlur,
&hf_sna_xid_3_dlus,
&hf_sna_xid_3_exbn,
&hf_sna_xid_3_genodai,
&hf_sna_xid_3_branch,
&hf_sna_xid_3_brnn,
NULL
};
if (!tree)
return;
proto_tree_add_item(tree, hf_sna_reserved, tvb, 0, 2, ENC_NA);
proto_tree_add_bitmask(tree, tvb, 2, hf_sna_xid_3_8,
ett_sna_xid_3_8, sna_xid_3_fields, ENC_BIG_ENDIAN);
proto_tree_add_bitmask(tree, tvb, 4, hf_sna_xid_3_10,
ett_sna_xid_3_10, sna_xid_10_fields, ENC_BIG_ENDIAN);
proto_tree_add_bitmask(tree, tvb, 5, hf_sna_xid_3_11,
ett_sna_xid_3_11, sna_xid_11_fields, ENC_BIG_ENDIAN);
proto_tree_add_bitmask(tree, tvb, 6, hf_sna_xid_3_12,
ett_sna_xid_3_12, sna_xid_12_fields, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_sna_reserved, tvb, 7, 2, ENC_NA);
proto_tree_add_bitmask(tree, tvb, 9, hf_sna_xid_3_15,
ett_sna_xid_3_15, sna_xid_15_fields, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_sna_xid_3_tg, tvb, 10, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_sna_xid_3_dlc, tvb, 11, 1, ENC_BIG_ENDIAN);
dlen = tvb_get_guint8(tvb, 12);
proto_tree_add_uint(tree, hf_sna_xid_3_dlen, tvb, 12, 1, dlen);
/* FIXME: DLC Dependent Data Go Here */
offset = 12 + dlen;
while (tvb_offset_exists(tvb, offset)) {
dlen = tvb_get_guint8(tvb, offset+1);
dissect_sna_control(tvb, offset, dlen+2, tree, 0, KL);
offset += (dlen+2);
}
}
static void
dissect_xid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
proto_tree *parent_tree)
{
proto_tree *sub_tree;
proto_item *sub_ti = NULL;
int format, type, len;
guint32 id;
len = tvb_get_guint8(tvb, 1);
type = tvb_get_guint8(tvb, 0);
id = tvb_get_ntohl(tvb, 2);
format = hi_nibble(type);
/* Summary information */
col_add_fstr(pinfo->cinfo, COL_INFO,
"SNA XID Format:%d Type:%s", format,
val_to_str_const(lo_nibble(type), sna_xid_type_vals,
"Unknown Type"));
if (tree) {
sub_ti = proto_tree_add_item(tree, hf_sna_xid_0, tvb,
0, 1, ENC_BIG_ENDIAN);
sub_tree = proto_item_add_subtree(sub_ti, ett_sna_xid_0);
proto_tree_add_uint(sub_tree, hf_sna_xid_format, tvb, 0, 1,
type);
proto_tree_add_uint(sub_tree, hf_sna_xid_type, tvb, 0, 1,
type);
proto_tree_add_uint(tree, hf_sna_xid_len, tvb, 1, 1, len);
sub_ti = proto_tree_add_item(tree, hf_sna_xid_id, tvb,
2, 4, ENC_BIG_ENDIAN);
sub_tree = proto_item_add_subtree(sub_ti, ett_sna_xid_id);
proto_tree_add_uint(sub_tree, hf_sna_xid_idblock, tvb, 2, 4,
id);
proto_tree_add_uint(sub_tree, hf_sna_xid_idnum, tvb, 2, 4,
id);
switch(format) {
case 0:
break;
case 1:
dissect_xid1(tvb_new_subset_length_caplen(tvb, 6, len-6, -1),
tree);
break;
case 2:
dissect_xid2(tvb_new_subset_length_caplen(tvb, 6, len-6, -1),
tree);
break;
case 3:
dissect_xid3(tvb_new_subset_length_caplen(tvb, 6, len-6, -1),
tree);
break;
default:
/* external standards organizations */
call_data_dissector(tvb_new_subset_length_caplen(tvb, 6, len-6, -1),
pinfo, tree);
}
}
if (format == 0)
len = 6;
if (tvb_offset_exists(tvb, len))
call_data_dissector(tvb_new_subset_remaining(tvb, len), pinfo, parent_tree);
}
/* --------------------------------------------------------------------
* Chapter 4 Transmission Headers (THs)
* --------------------------------------------------------------------
*/
#define RH_LEN 3
static unsigned int
mpf_value(guint8 th_byte)
{
return (th_byte & 0x0c) >> 2;
}
#define FIRST_FRAG_NUMBER 0
#define MIDDLE_FRAG_NUMBER 1
#define LAST_FRAG_NUMBER 2
/* FID2 is defragged by sequence. The weird thing is that we have neither
* absolute sequence numbers, nor byte offets. Other FIDs have byte offsets
* (the DCF field), but not FID2. The only thing we have to go with is "FIRST",
* "MIDDLE", or "LAST". If the BIU is split into 3 frames, then everything is
* fine, * "FIRST", "MIDDLE", and "LAST" map nicely onto frag-number 0, 1,
* and 2. However, if the BIU is split into 2 frames, then we only have
* "FIRST" and "LAST", and the mapping *should* be frag-number 0 and 1,
* *NOT* 0 and 2.
*
* The SNA docs say "FID2 PIUs cannot be blocked because there is no DCF in the
* TH format for deblocking" (note on Figure 4-2 in the IBM SNA documention,
* see the FTP URL in the comment near the top of this file). I *think*
* this means that the fragmented frames cannot arrive out of order.
* Well, I *want* it to mean this, because w/o this limitation, if you
* get a "FIRST" frame and a "LAST" frame, how long should you wait to
* see if a "MIDDLE" frame every arrives????? Thus, if frames *have* to
* arrive in order, then we're saved.
*
* The problem then boils down to figuring out if "LAST" means frag-number 1
* (in the case of a BIU split into 2 frames) or frag-number 2
* (in the case of a BIU split into 3 frames).
*
* Assuming fragmented FID2 BIU frames *do* arrive in order, the obvious
* way to handle the mapping of "LAST" to either frag-number 1 or
* frag-number 2 is to keep a hash which tracks the frames seen, etc.
* This consumes resources. A trickier way, but a way which works, is to
* always map the "LAST" BIU segment to frag-number 2. Here's the trickery:
* if we add frag-number 2, which we know to be the "LAST" BIU segment,
* and the reassembly code tells us that the BIU is still not reassmebled,
* then, owing to the, ahem, /fact/, that fragmented BIU segments arrive
* in order :), we know that 1) "FIRST" did come, and 2) there's no "MIDDLE",
* because this BIU was fragmented into 2 frames, not 3. So, we'll be
* tricky and add a zero-length "MIDDLE" BIU frame (i.e, frag-number 1)
* to complete the reassembly.
*/
static tvbuff_t*
defragment_by_sequence(packet_info *pinfo, tvbuff_t *tvb, int offset, int mpf,
int id)
{
fragment_head *fd_head;
int frag_number = -1;
int more_frags = TRUE;
tvbuff_t *rh_tvb = NULL;
gint frag_len;
/* Determine frag_number and more_frags */
switch(mpf) {
case MPF_WHOLE_BIU:
/* nothing */
break;
case MPF_FIRST_SEGMENT:
frag_number = FIRST_FRAG_NUMBER;
break;
case MPF_MIDDLE_SEGMENT:
frag_number = MIDDLE_FRAG_NUMBER;
break;
case MPF_LAST_SEGMENT:
frag_number = LAST_FRAG_NUMBER;
more_frags = FALSE;
break;
default:
DISSECTOR_ASSERT_NOT_REACHED();
}
/* If sna_defragment is on, and this is a fragment.. */
if (frag_number > -1) {
/* XXX - check length ??? */
frag_len = tvb_reported_length_remaining(tvb, offset);
if (tvb_bytes_exist(tvb, offset, frag_len)) {
fd_head = fragment_add_seq(&sna_reassembly_table,
tvb, offset, pinfo, id, NULL,
frag_number, frag_len, more_frags, 0);
/* We added the LAST segment and reassembly didn't
* complete. Insert a zero-length MIDDLE segment to
* turn a 2-frame BIU-fragmentation into a 3-frame
* BIU-fragmentation (empty middle frag).
* See above long comment about this trickery. */
if (mpf == MPF_LAST_SEGMENT && !fd_head) {
fd_head = fragment_add_seq(&sna_reassembly_table,
tvb, offset, pinfo, id, NULL,
MIDDLE_FRAG_NUMBER, 0, TRUE, 0);
}
if (fd_head != NULL) {
/* We have the complete reassembled payload. */
rh_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
/* Add the defragmented data to the data
* source list. */
add_new_data_source(pinfo, rh_tvb,
"Reassembled SNA BIU");
}
}
}
return rh_tvb;
}
#define SNA_FID01_ADDR_LEN 2
/* FID Types 0 and 1 */
static int
dissect_fid0_1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree *bf_tree;
proto_item *bf_item;
guint8 th_0;
const int bytes_in_header = 10;
if (tree) {
/* Byte 0 */
th_0 = tvb_get_guint8(tvb, 0);
bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1,
th_0);
bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
/* Byte 1 */
proto_tree_add_item(tree, hf_sna_reserved, tvb, 1, 1, ENC_NA);
/* Bytes 2-3 */
proto_tree_add_item(tree, hf_sna_th_daf, tvb, 2, 2, ENC_BIG_ENDIAN);
}
/* Set DST addr */
set_address_tvb(&pinfo->net_dst, sna_address_type, SNA_FID01_ADDR_LEN, tvb, 2);
copy_address_shallow(&pinfo->dst, &pinfo->net_dst);
proto_tree_add_item(tree, hf_sna_th_oaf, tvb, 4, 2, ENC_BIG_ENDIAN);
/* Set SRC addr */
set_address_tvb(&pinfo->net_src, sna_address_type, SNA_FID01_ADDR_LEN, tvb, 4);
copy_address_shallow(&pinfo->src, &pinfo->net_src);
proto_tree_add_item(tree, hf_sna_th_snf, tvb, 6, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_sna_th_dcf, tvb, 8, 2, ENC_BIG_ENDIAN);
return bytes_in_header;
}
#define SNA_FID2_ADDR_LEN 1
/* FID Type 2 */
static int
dissect_fid2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
tvbuff_t **rh_tvb_ptr, next_dissection_t *continue_dissecting)
{
proto_tree *bf_tree;
proto_item *bf_item;
guint8 th_0;
unsigned int mpf, id;
const int bytes_in_header = 6;
th_0 = tvb_get_guint8(tvb, 0);
mpf = mpf_value(th_0);
if (tree) {
/* Byte 0 */
bf_item = proto_tree_add_item(tree, hf_sna_th_0, tvb, 0, 1, ENC_BIG_ENDIAN);
bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
proto_tree_add_item(bf_tree, hf_sna_th_fid, tvb, 0, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(bf_tree, hf_sna_th_mpf, tvb, 0, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(bf_tree, hf_sna_th_odai,tvb, 0, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(bf_tree, hf_sna_th_efi, tvb, 0, 1, ENC_BIG_ENDIAN);
/* Byte 1 */
proto_tree_add_item(tree, hf_sna_reserved, tvb, 1, 1, ENC_NA);
/* Byte 2 */
proto_tree_add_item(tree, hf_sna_th_daf, tvb, 2, 1, ENC_BIG_ENDIAN);
}
/* Set DST addr */
set_address_tvb(&pinfo->net_dst, sna_address_type, SNA_FID2_ADDR_LEN, tvb, 2);
copy_address_shallow(&pinfo->dst, &pinfo->net_dst);
/* Byte 3 */
proto_tree_add_item(tree, hf_sna_th_oaf, tvb, 3, 1, ENC_BIG_ENDIAN);
/* Set SRC addr */
set_address_tvb(&pinfo->net_src, sna_address_type, SNA_FID2_ADDR_LEN, tvb, 3);
copy_address_shallow(&pinfo->src, &pinfo->net_src);
id = tvb_get_ntohs(tvb, 4);
proto_tree_add_item(tree, hf_sna_th_snf, tvb, 4, 2, ENC_BIG_ENDIAN);
if (mpf != MPF_WHOLE_BIU && !sna_defragment) {
if (mpf == MPF_FIRST_SEGMENT) {
*continue_dissecting = rh_only;
} else {
*continue_dissecting = stop_here;
}
}
else if (sna_defragment) {
*rh_tvb_ptr = defragment_by_sequence(pinfo, tvb,
bytes_in_header, mpf, id);
}
return bytes_in_header;
}
/* FID Type 3 */
static int
dissect_fid3(tvbuff_t *tvb, proto_tree *tree)
{
proto_tree *bf_tree;
proto_item *bf_item;
guint8 th_0;
const int bytes_in_header = 2;
/* If we're not filling a proto_tree, return now */
if (!tree)
return bytes_in_header;
th_0 = tvb_get_guint8(tvb, 0);
/* Create the bitfield tree */
bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
proto_tree_add_item(tree, hf_sna_th_lsid, tvb, 1, 1, ENC_BIG_ENDIAN);
return bytes_in_header;
}
static int
dissect_fid4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
int offset = 0;
guint8 th_byte, mft;
guint16 def, oef;
guint32 dsaf, osaf;
static int * const byte0_fields[] = {
&hf_sna_th_fid,
&hf_sna_th_tg_sweep,
&hf_sna_th_er_vr_supp_ind,
&hf_sna_th_vr_pac_cnt_ind,
&hf_sna_th_ntwk_prty,
NULL
};
static int * const byte1_fields[] = {
&hf_sna_th_tgsf,
&hf_sna_th_mft,
&hf_sna_th_piubf,
NULL
};
static int * const byte2_mft_fields[] = {
&hf_sna_th_nlpoi,
&hf_sna_th_nlp_cp,
&hf_sna_th_ern,
NULL
};
static int * const byte2_fields[] = {
&hf_sna_th_iern,
&hf_sna_th_ern,
NULL
};
static int * const byte3_fields[] = {
&hf_sna_th_vrn,
&hf_sna_th_tpf,
NULL
};
static int * const byte4_fields[] = {
&hf_sna_th_vr_cwi,
&hf_sna_th_tg_nonfifo_ind,
&hf_sna_th_vr_sqti,
/* I'm not sure about byte-order on this one... */
&hf_sna_th_tg_snf,
NULL
};
static int * const byte6_fields[] = {
&hf_sna_th_vrprq,
&hf_sna_th_vrprs,
&hf_sna_th_vr_cwri,
&hf_sna_th_vr_rwi,
/* I'm not sure about byte-order on this one... */
&hf_sna_th_vr_snf_send,
NULL
};
static int * const byte16_fields[] = {
&hf_sna_th_snai,
/* We luck out here because in their infinite wisdom the SNA
* architects placed the MPF and EFI fields in the same bitfield
* locations, even though for FID4 they're not in byte 0.
* Thank you IBM! */
&hf_sna_th_mpf,
&hf_sna_th_efi,
NULL
};
struct sna_fid_type_4_addr *src, *dst;
const int bytes_in_header = 26;
/* If we're not filling a proto_tree, return now */
if (!tree)
return bytes_in_header;
/* Byte 0 */
proto_tree_add_bitmask(tree, tvb, offset, hf_sna_th_0,
ett_sna_th_fid, byte0_fields, ENC_NA);
offset += 1;
th_byte = tvb_get_guint8(tvb, offset);
/* Byte 1 */
proto_tree_add_bitmask(tree, tvb, offset, hf_sna_th_byte1,
ett_sna_th_fid, byte1_fields, ENC_NA);
mft = th_byte & 0x04;
offset += 1;
/* Byte 2 */
if (mft) {
proto_tree_add_bitmask(tree, tvb, offset, hf_sna_th_byte2,
ett_sna_th_fid, byte2_mft_fields, ENC_NA);
} else {
proto_tree_add_bitmask(tree, tvb, offset, hf_sna_th_byte2,
ett_sna_th_fid, byte2_fields, ENC_NA);
}
offset += 1;
/* Byte 3 */
proto_tree_add_bitmask(tree, tvb, offset, hf_sna_th_byte3,
ett_sna_th_fid, byte3_fields, ENC_NA);
offset += 1;
/* Bytes 4-5 */
proto_tree_add_bitmask(tree, tvb, offset, hf_sna_th_byte4,
ett_sna_th_fid, byte4_fields, ENC_BIG_ENDIAN);
offset += 2;
/* Create the bitfield tree */
proto_tree_add_bitmask(tree, tvb, offset, hf_sna_th_byte6,
ett_sna_th_fid, byte6_fields, ENC_BIG_ENDIAN);
offset += 2;
dsaf = tvb_get_ntohl(tvb, 8);
/* Bytes 8-11 */
proto_tree_add_uint(tree, hf_sna_th_dsaf, tvb, offset, 4, dsaf);
offset += 4;
osaf = tvb_get_ntohl(tvb, 12);
/* Bytes 12-15 */
proto_tree_add_uint(tree, hf_sna_th_osaf, tvb, offset, 4, osaf);
offset += 4;
/* Byte 16 */
proto_tree_add_bitmask(tree, tvb, offset, hf_sna_th_byte16,
ett_sna_th_fid, byte16_fields, ENC_NA);
/* 1 for byte 16, 1 for byte 17 which is reserved */
offset += 2;
def = tvb_get_ntohs(tvb, 18);
/* Bytes 18-25 */
proto_tree_add_uint(tree, hf_sna_th_def, tvb, offset, 2, def);
/* Addresses in FID 4 are discontiguous, sigh */
dst = wmem_new0(pinfo->pool, struct sna_fid_type_4_addr);
dst->saf = dsaf;
dst->ef = def;
set_address(&pinfo->net_dst, sna_address_type, SNA_FID_TYPE_4_ADDR_LEN, dst);
copy_address_shallow(&pinfo->dst, &pinfo->net_dst);
oef = tvb_get_ntohs(tvb, 20);
proto_tree_add_uint(tree, hf_sna_th_oef, tvb, offset+2, 2, oef);
/* Addresses in FID 4 are discontiguous, sigh */
src = wmem_new0(pinfo->pool, struct sna_fid_type_4_addr);
src->saf = osaf;
src->ef = oef;
set_address(&pinfo->net_src, sna_address_type, SNA_FID_TYPE_4_ADDR_LEN, src);
copy_address_shallow(&pinfo->src, &pinfo->net_src);
proto_tree_add_item(tree, hf_sna_th_snf, tvb, offset+4, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_sna_th_dcf, tvb, offset+6, 2, ENC_BIG_ENDIAN);
return bytes_in_header;
}
/* FID Type 5 */
static int
dissect_fid5(tvbuff_t *tvb, proto_tree *tree)
{
proto_tree *bf_tree;
proto_item *bf_item;
guint8 th_0;
const int bytes_in_header = 12;
/* If we're not filling a proto_tree, return now */
if (!tree)
return bytes_in_header;
th_0 = tvb_get_guint8(tvb, 0);
/* Create the bitfield tree */
bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
proto_tree_add_item(tree, hf_sna_reserved, tvb, 1, 1, ENC_NA);
proto_tree_add_item(tree, hf_sna_th_snf, tvb, 2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_sna_th_sa, tvb, 4, 8, ENC_NA);
return bytes_in_header;
}
/* FID Type f */
static int
dissect_fidf(tvbuff_t *tvb, proto_tree *tree)
{
proto_tree *bf_tree;
proto_item *bf_item;
guint8 th_0;
const int bytes_in_header = 26;
/* If we're not filling a proto_tree, return now */
if (!tree)
return bytes_in_header;
th_0 = tvb_get_guint8(tvb, 0);
/* Create the bitfield tree */
bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
proto_tree_add_item(tree, hf_sna_reserved, tvb, 1, 1, ENC_NA);
proto_tree_add_item(tree, hf_sna_th_cmd_fmt, tvb, 2, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_sna_th_cmd_type, tvb, 3, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_sna_th_cmd_sn, tvb, 4, 2, ENC_BIG_ENDIAN);
/* Yup, bytes 6-23 are reserved! */
proto_tree_add_item(tree, hf_sna_reserved, tvb, 6, 18, ENC_NA);
proto_tree_add_item(tree, hf_sna_th_dcf, tvb, 24, 2, ENC_BIG_ENDIAN);
return bytes_in_header;
}
static void
dissect_fid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
proto_tree *parent_tree)
{
proto_tree *th_tree = NULL, *rh_tree = NULL;
proto_item *th_ti = NULL, *rh_ti = NULL;
guint8 th_fid;
int th_header_len = 0;
int offset, rh_offset;
tvbuff_t *rh_tvb = NULL;
next_dissection_t continue_dissecting = everything;
/* Transmission Header Format Identifier */
th_fid = hi_nibble(tvb_get_guint8(tvb, 0));
/* Summary information */
col_add_str(pinfo->cinfo, COL_INFO,
val_to_str(th_fid, sna_th_fid_vals, "Unknown FID: %01x"));
if (tree) {
/* --- TH --- */
/* Don't bother setting length. We'll set it later after we
* find the length of TH */
th_ti = proto_tree_add_item(tree, hf_sna_th, tvb, 0, -1,
ENC_NA);
th_tree = proto_item_add_subtree(th_ti, ett_sna_th);
}
/* Get size of TH */
switch(th_fid) {
case 0x0:
case 0x1:
th_header_len = dissect_fid0_1(tvb, pinfo, th_tree);
break;
case 0x2:
th_header_len = dissect_fid2(tvb, pinfo, th_tree,
&rh_tvb, &continue_dissecting);
break;
case 0x3:
th_header_len = dissect_fid3(tvb, th_tree);
break;
case 0x4:
th_header_len = dissect_fid4(tvb, pinfo, th_tree);
break;
case 0x5:
th_header_len = dissect_fid5(tvb, th_tree);
break;
case 0xf:
th_header_len = dissect_fidf(tvb, th_tree);
break;
default:
call_data_dissector(tvb_new_subset_remaining(tvb, 1), pinfo, parent_tree);
return;
}
offset = th_header_len;
/* Short-circuit ? */
if (continue_dissecting == stop_here) {
proto_tree_add_item(tree, hf_sna_biu_segment_data, tvb, offset, -1, ENC_NA);
return;
}
/* If the FID dissector function didn't create an rh_tvb, then we just
* use the rest of our tvbuff as the rh_tvb. */
if (!rh_tvb)
rh_tvb = tvb_new_subset_remaining(tvb, offset);
rh_offset = 0;
/* Process the rest of the SNA packet, starting with RH */
if (tree) {
proto_item_set_len(th_ti, th_header_len);
/* --- RH --- */
rh_ti = proto_tree_add_item(tree, hf_sna_rh, rh_tvb, rh_offset,
RH_LEN, ENC_NA);
rh_tree = proto_item_add_subtree(rh_ti, ett_sna_rh);
dissect_rh(rh_tvb, rh_offset, rh_tree);
}
rh_offset += RH_LEN;
if (tvb_offset_exists(rh_tvb, rh_offset)) {
/* Short-circuit ? */
if (continue_dissecting == rh_only) {
proto_tree_add_item(tree, hf_sna_biu_segment_data, rh_tvb, rh_offset, -1, ENC_NA);
return;
}
call_data_dissector(tvb_new_subset_remaining(rh_tvb, rh_offset),
pinfo, parent_tree);
}
}
/* --------------------------------------------------------------------
* Chapter 5 Request/Response Headers (RHs)
* --------------------------------------------------------------------
*/
static void
dissect_rh(tvbuff_t *tvb, int offset, proto_tree *tree)
{
gboolean is_response;
guint8 rh_0;
static int * const sna_rh_fields[] = {
&hf_sna_rh_rri,
&hf_sna_rh_ru_category,
&hf_sna_rh_fi,
&hf_sna_rh_sdi,
&hf_sna_rh_bci,
&hf_sna_rh_eci,
NULL
};
static int * const sna_rh_1_req_fields[] = {
&hf_sna_rh_dr1,
&hf_sna_rh_lcci,
&hf_sna_rh_dr2,
&hf_sna_rh_eri,
&hf_sna_rh_rlwi,
&hf_sna_rh_qri,
&hf_sna_rh_pi,
NULL
};
static int * const sna_rh_1_rsp_fields[] = {
&hf_sna_rh_dr1,
&hf_sna_rh_dr2,
&hf_sna_rh_rti,
&hf_sna_rh_qri,
&hf_sna_rh_pi,
NULL
};
static int * const sna_rh_2_req_fields[] = {
&hf_sna_rh_bbi,
&hf_sna_rh_ebi,
&hf_sna_rh_cdi,
&hf_sna_rh_csi,
&hf_sna_rh_edi,
&hf_sna_rh_pdi,
&hf_sna_rh_cebi,
NULL
};
if (!tree)
return;
/* Create the bitfield tree for byte 0*/
rh_0 = tvb_get_guint8(tvb, offset);
is_response = (rh_0 & 0x80);
proto_tree_add_bitmask(tree, tvb, offset, hf_sna_rh_0,
ett_sna_rh_0, sna_rh_fields, ENC_BIG_ENDIAN);
offset += 1;
/* Create the bitfield tree for byte 1*/
if (is_response) {
proto_tree_add_bitmask(tree, tvb, offset, hf_sna_rh_1,
ett_sna_rh_1, sna_rh_1_rsp_fields, ENC_BIG_ENDIAN);
} else {
proto_tree_add_bitmask(tree, tvb, offset, hf_sna_rh_1,
ett_sna_rh_1, sna_rh_1_req_fields, ENC_BIG_ENDIAN);
}
offset += 1;
/* Create the bitfield tree for byte 2*/
if (!is_response) {
proto_tree_add_bitmask(tree, tvb, offset, hf_sna_rh_2,
ett_sna_rh_2, sna_rh_2_req_fields, ENC_BIG_ENDIAN);
} else {
proto_tree_add_item(tree, hf_sna_rh_2, tvb, offset, 1, ENC_BIG_ENDIAN);
}
/* XXX - check for sdi. If TRUE, the next 4 bytes will be sense data */
}
/* --------------------------------------------------------------------
* Chapter 6 Request/Response Units (RUs)
* --------------------------------------------------------------------
*/
/* --------------------------------------------------------------------
* Chapter 9 Common Fields
* --------------------------------------------------------------------
*/
static void
dissect_control_05hpr(tvbuff_t *tvb, proto_tree *tree, int hpr,
enum parse parse)
{
guint16 offset, len, pad;
static int * const sna_control_05hpr_fields[] = {
&hf_sna_control_05_ptp,
NULL
};
if (!tree)
return;
proto_tree_add_bitmask(tree, tvb, 2, hf_sna_control_05_type,
ett_sna_control_05hpr_type, sna_control_05hpr_fields, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_sna_reserved, tvb, 3, 1, ENC_NA);
offset = 4;
while (tvb_offset_exists(tvb, offset)) {
if (parse == LT) {
len = tvb_get_guint8(tvb, offset+0);
} else {
len = tvb_get_guint8(tvb, offset+1);
}
if (len) {
dissect_sna_control(tvb, offset, len, tree, hpr, parse);
pad = (len+3) & 0xfffc;
if (pad > len) {
proto_tree_add_item(tree, hf_sna_padding, tvb, offset+len, pad-len, ENC_NA);
}
offset += pad;
} else {
return;
}
}
}
static void
dissect_control_05(tvbuff_t *tvb, proto_tree *tree)
{
if(!tree)
return;
proto_tree_add_item(tree, hf_sna_control_05_delay, tvb, 2, 2, ENC_BIG_ENDIAN);
}
static void
dissect_control_0e(tvbuff_t *tvb, proto_tree *tree)
{
gint len;
if (!tree)
return;
proto_tree_add_item(tree, hf_sna_control_0e_type, tvb, 2, 1, ENC_BIG_ENDIAN);
len = tvb_reported_length_remaining(tvb, 3);
if (len <= 0)
return;
proto_tree_add_item(tree, hf_sna_control_0e_value, tvb, 3, len, ENC_EBCDIC);
}
static void
dissect_sna_control(tvbuff_t *parent_tvb, int offset, int control_len,
proto_tree *tree, int hpr, enum parse parse)
{
tvbuff_t *tvb;
gint length, reported_length;
proto_tree *sub_tree;
int len, key;
gint ett;
length = tvb_captured_length_remaining(parent_tvb, offset);
reported_length = tvb_reported_length_remaining(parent_tvb, offset);
if (control_len < length)
length = control_len;
if (control_len < reported_length)
reported_length = control_len;
tvb = tvb_new_subset_length_caplen(parent_tvb, offset, length, reported_length);
sub_tree = NULL;
if (parse == LT) {
len = tvb_get_guint8(tvb, 0);
key = tvb_get_guint8(tvb, 1);
} else {
key = tvb_get_guint8(tvb, 0);
len = tvb_get_guint8(tvb, 1);
}
ett = ett_sna_control_un;
if (tree) {
if (key == 5) {
if (hpr) ett = ett_sna_control_05hpr;
else ett = ett_sna_control_05;
}
if (key == 0x0e) ett = ett_sna_control_0e;
if (((key == 0) || (key == 3) || (key == 5)) && hpr)
sub_tree = proto_tree_add_subtree(tree, tvb, 0, -1, ett, NULL,
val_to_str_const(key, sna_control_hpr_vals,
"Unknown Control Vector"));
else
sub_tree = proto_tree_add_subtree(tree, tvb, 0, -1, ett, NULL,
val_to_str_const(key, sna_control_vals,
"Unknown Control Vector"));
if (parse == LT) {
proto_tree_add_uint(sub_tree, hf_sna_control_len,
tvb, 0, 1, len);
if (((key == 0) || (key == 3) || (key == 5)) && hpr)
proto_tree_add_uint(sub_tree,
hf_sna_control_hprkey, tvb, 1, 1, key);
else
proto_tree_add_uint(sub_tree,
hf_sna_control_key, tvb, 1, 1, key);
} else {
if (((key == 0) || (key == 3) || (key == 5)) && hpr)
proto_tree_add_uint(sub_tree,
hf_sna_control_hprkey, tvb, 0, 1, key);
else
proto_tree_add_uint(sub_tree,
hf_sna_control_key, tvb, 0, 1, key);
proto_tree_add_uint(sub_tree, hf_sna_control_len,
tvb, 1, 1, len);
}
}
switch(key) {
case 0x05:
if (hpr)
dissect_control_05hpr(tvb, sub_tree, hpr,
parse);
else
dissect_control_05(tvb, sub_tree);
break;
case 0x0e:
dissect_control_0e(tvb, sub_tree);
break;
}
}
/* --------------------------------------------------------------------
* Chapter 11 Function Management (FM) Headers
* --------------------------------------------------------------------
*/
/* --------------------------------------------------------------------
* Chapter 12 Presentation Services (PS) Headers
* --------------------------------------------------------------------
*/
/* --------------------------------------------------------------------
* Chapter 13 GDS Variables
* --------------------------------------------------------------------
*/
static void
dissect_gds(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
proto_tree *parent_tree)
{
guint16 length;
int cont;
int offset = 0;
proto_item *pi;
proto_tree *subtree;
gboolean first_ll = TRUE;
do {
length = tvb_get_ntohs(tvb, offset) & 0x7fff;
cont = (tvb_get_ntohs(tvb, offset) & 0x8000) ? 1 : 0;
pi = proto_tree_add_item(tree, hf_sna_gds, tvb, offset, -1, ENC_NA);
subtree = proto_item_add_subtree(pi, ett_sna_gds);
proto_tree_add_item(subtree, hf_sna_gds_len, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(subtree, hf_sna_gds_cont, tvb, offset, 2, ENC_BIG_ENDIAN);
if (length < 2 ) /* escape sequence */
return;
offset += 2;
length -= 2;
if (first_ll) {
proto_tree_add_item(subtree, hf_sna_gds_type, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
length -= 2;
first_ll = FALSE;
}
if (length > 0) {
proto_tree_add_item(subtree, hf_sna_gds_info, tvb, offset, length, ENC_NA);
offset += length;
}
} while(cont);
proto_item_set_len(pi, offset);
if (tvb_offset_exists(tvb, offset))
call_data_dissector(tvb_new_subset_remaining(tvb, offset), pinfo, parent_tree);
}
/* --------------------------------------------------------------------
* General stuff
* --------------------------------------------------------------------
*/
static int
dissect_sna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
guint8 fid;
proto_tree *sna_tree = NULL;
proto_item *sna_ti = NULL;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SNA");
col_clear(pinfo->cinfo, COL_INFO);
/* SNA data should be printed in EBCDIC, not ASCII */
pinfo->fd->encoding = PACKET_CHAR_ENC_CHAR_EBCDIC;
if (tree) {
/* Don't bother setting length. We'll set it later after we find
* the lengths of TH/RH/RU */
sna_ti = proto_tree_add_item(tree, proto_sna, tvb, 0, -1,
ENC_NA);
sna_tree = proto_item_add_subtree(sna_ti, ett_sna);
}
/* Transmission Header Format Identifier */
fid = hi_nibble(tvb_get_guint8(tvb, 0));
switch(fid) {
case 0xa: /* HPR Network Layer Packet */
case 0xb:
case 0xc:
case 0xd:
dissect_nlp(tvb, pinfo, sna_tree, tree);
break;
default:
dissect_fid(tvb, pinfo, sna_tree, tree);
}
return tvb_captured_length(tvb);
}
static int
dissect_sna_xid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
proto_tree *sna_tree = NULL;
proto_item *sna_ti = NULL;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SNA");
col_clear(pinfo->cinfo, COL_INFO);
/* SNA data should be printed in EBCDIC, not ASCII */
pinfo->fd->encoding = PACKET_CHAR_ENC_CHAR_EBCDIC;
if (tree) {
/* Don't bother setting length. We'll set it later after we find
* the lengths of XID */
sna_ti = proto_tree_add_item(tree, proto_sna_xid, tvb, 0, -1,
ENC_NA);
sna_tree = proto_item_add_subtree(sna_ti, ett_sna);
}
dissect_xid(tvb, pinfo, sna_tree, tree);
return tvb_captured_length(tvb);
}
void
proto_register_sna(void)
{
static hf_register_info hf[] = {
{ &hf_sna_th,
{ "Transmission Header", "sna.th", FT_NONE, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_0,
{ "Transmission Header Byte 0", "sna.th.0", FT_UINT8, BASE_HEX,
NULL, 0x0,
"TH Byte 0", HFILL }},
{ &hf_sna_th_fid,
{ "Format Identifier", "sna.th.fid", FT_UINT8, BASE_HEX,
VALS(sna_th_fid_vals), 0xf0, NULL, HFILL }},
{ &hf_sna_th_mpf,
{ "Mapping Field", "sna.th.mpf", FT_UINT8,
BASE_DEC, VALS(sna_th_mpf_vals), 0x0c, NULL, HFILL }},
{ &hf_sna_th_odai,
{ "ODAI Assignment Indicator", "sna.th.odai", FT_UINT8,
BASE_DEC, NULL, 0x02, NULL, HFILL }},
{ &hf_sna_th_efi,
{ "Expedited Flow Indicator", "sna.th.efi", FT_UINT8,
BASE_DEC, VALS(sna_th_efi_vals), 0x01, NULL, HFILL }},
{ &hf_sna_th_daf,
{ "Destination Address Field", "sna.th.daf", FT_UINT16,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_oaf,
{ "Origin Address Field", "sna.th.oaf", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_snf,
{ "Sequence Number Field", "sna.th.snf", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_dcf,
{ "Data Count Field", "sna.th.dcf", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_lsid,
{ "Local Session Identification", "sna.th.lsid", FT_UINT8,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_tg_sweep,
{ "Transmission Group Sweep", "sna.th.tg_sweep", FT_UINT8,
BASE_DEC, VALS(sna_th_tg_sweep_vals), 0x08, NULL, HFILL }},
{ &hf_sna_th_er_vr_supp_ind,
{ "ER and VR Support Indicator", "sna.th.er_vr_supp_ind",
FT_UINT8, BASE_DEC, VALS(sna_th_er_vr_supp_ind_vals),
0x04, NULL, HFILL }},
{ &hf_sna_th_vr_pac_cnt_ind,
{ "Virtual Route Pacing Count Indicator",
"sna.th.vr_pac_cnt_ind", FT_UINT8, BASE_DEC,
VALS(sna_th_vr_pac_cnt_ind_vals), 0x02, NULL, HFILL }},
{ &hf_sna_th_ntwk_prty,
{ "Network Priority", "sna.th.ntwk_prty", FT_UINT8, BASE_DEC,
VALS(sna_th_ntwk_prty_vals), 0x01, NULL, HFILL }},
{ &hf_sna_th_tgsf,
{ "Transmission Group Segmenting Field", "sna.th.tgsf",
FT_UINT8, BASE_HEX, VALS(sna_th_tgsf_vals), 0xc0,
NULL, HFILL }},
{ &hf_sna_th_mft,
{ "MPR FID4 Type", "sna.th.mft", FT_BOOLEAN, 8,
NULL, 0x04, NULL, HFILL }},
{ &hf_sna_th_piubf,
{ "PIU Blocking Field", "sna.th.piubf", FT_UINT8, BASE_HEX,
VALS(sna_th_piubf_vals), 0x03, NULL, HFILL }},
{ &hf_sna_th_iern,
{ "Initial Explicit Route Number", "sna.th.iern", FT_UINT8,
BASE_DEC, NULL, 0xf0, NULL, HFILL }},
{ &hf_sna_th_nlpoi,
{ "NLP Offset Indicator", "sna.th.nlpoi", FT_UINT8, BASE_DEC,
VALS(sna_th_nlpoi_vals), 0x80, NULL, HFILL }},
{ &hf_sna_th_nlp_cp,
{ "NLP Count or Padding", "sna.th.nlp_cp", FT_UINT8, BASE_DEC,
NULL, 0x70, NULL, HFILL }},
{ &hf_sna_th_ern,
{ "Explicit Route Number", "sna.th.ern", FT_UINT8, BASE_DEC,
NULL, 0x0f, NULL, HFILL }},
{ &hf_sna_th_vrn,
{ "Virtual Route Number", "sna.th.vrn", FT_UINT8, BASE_DEC,
NULL, 0xf0, NULL, HFILL }},
{ &hf_sna_th_tpf,
{ "Transmission Priority Field", "sna.th.tpf", FT_UINT8,
BASE_HEX, VALS(sna_th_tpf_vals), 0x03, NULL, HFILL }},
{ &hf_sna_th_vr_cwi,
{ "Virtual Route Change Window Indicator", "sna.th.vr_cwi",
FT_UINT16, BASE_DEC, VALS(sna_th_vr_cwi_vals), 0x8000,
"Change Window Indicator", HFILL }},
{ &hf_sna_th_tg_nonfifo_ind,
{ "Transmission Group Non-FIFO Indicator",
"sna.th.tg_nonfifo_ind", FT_BOOLEAN, 16,
TFS(&sna_th_tg_nonfifo_ind_truth), 0x4000, NULL, HFILL }},
{ &hf_sna_th_vr_sqti,
{ "Virtual Route Sequence and Type Indicator", "sna.th.vr_sqti",
FT_UINT16, BASE_HEX, VALS(sna_th_vr_sqti_vals), 0x3000,
"Route Sequence and Type", HFILL }},
{ &hf_sna_th_tg_snf,
{ "Transmission Group Sequence Number Field", "sna.th.tg_snf",
FT_UINT16, BASE_DEC, NULL, 0x0fff, NULL, HFILL }},
{ &hf_sna_th_vrprq,
{ "Virtual Route Pacing Request", "sna.th.vrprq", FT_BOOLEAN,
16, TFS(&sna_th_vrprq_truth), 0x8000, NULL, HFILL }},
{ &hf_sna_th_vrprs,
{ "Virtual Route Pacing Response", "sna.th.vrprs", FT_BOOLEAN,
16, TFS(&sna_th_vrprs_truth), 0x4000, NULL, HFILL }},
{ &hf_sna_th_vr_cwri,
{ "Virtual Route Change Window Reply Indicator",
"sna.th.vr_cwri", FT_UINT16, BASE_DEC,
VALS(sna_th_vr_cwri_vals), 0x2000, NULL, HFILL }},
{ &hf_sna_th_vr_rwi,
{ "Virtual Route Reset Window Indicator", "sna.th.vr_rwi",
FT_BOOLEAN, 16, TFS(&sna_th_vr_rwi_truth), 0x1000,
NULL, HFILL }},
{ &hf_sna_th_vr_snf_send,
{ "Virtual Route Send Sequence Number Field",
"sna.th.vr_snf_send", FT_UINT16, BASE_DEC, NULL, 0x0fff,
"Send Sequence Number Field", HFILL }},
{ &hf_sna_th_dsaf,
{ "Destination Subarea Address Field", "sna.th.dsaf",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_osaf,
{ "Origin Subarea Address Field", "sna.th.osaf", FT_UINT32,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_snai,
{ "SNA Indicator", "sna.th.snai", FT_BOOLEAN, 8, NULL, 0x10,
"Used to identify whether the PIU originated or is destined for an SNA or non-SNA device.", HFILL }},
{ &hf_sna_th_def,
{ "Destination Element Field", "sna.th.def", FT_UINT16,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_oef,
{ "Origin Element Field", "sna.th.oef", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_sa,
{ "Session Address", "sna.th.sa", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_cmd_fmt,
{ "Command Format", "sna.th.cmd_fmt", FT_UINT8, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_cmd_type,
{ "Command Type", "sna.th.cmd_type", FT_UINT8, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_cmd_sn,
{ "Command Sequence Number", "sna.th.cmd_sn", FT_UINT16,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_byte1,
{ "Transmission Header Bytes 1", "sna.th.byte1", FT_UINT8,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_byte2,
{ "Transmission Header Bytes 2", "sna.th.byte2", FT_UINT8,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_byte3,
{ "Transmission Header Bytes 3", "sna.th.byte3", FT_UINT8,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_byte4,
{ "Transmission Header Bytes 4-5", "sna.th.byte4", FT_UINT16,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_byte6,
{ "Transmission Header Bytes 6-7", "sna.th.byte6", FT_UINT16,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_th_byte16,
{ "Transmission Header Bytes 16", "sna.th.byte16", FT_UINT8,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_nhdr,
{ "Network Layer Packet Header", "sna.nlp.nhdr", FT_NONE,
BASE_NONE, NULL, 0x0, "NHDR", HFILL }},
{ &hf_sna_nlp_nhdr_0,
{ "Network Layer Packet Header Byte 0", "sna.nlp.nhdr.0",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_nhdr_1,
{ "Network Layer Packet Header Byte 1", "sna.nlp.nhdr.1",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_sm,
{ "Switching Mode Field", "sna.nlp.nhdr.sm", FT_UINT8,
BASE_HEX, VALS(sna_nlp_sm_vals), 0xe0, NULL, HFILL }},
{ &hf_sna_nlp_tpf,
{ "Transmission Priority Field", "sna.nlp.nhdr.tpf", FT_UINT8,
BASE_HEX, VALS(sna_th_tpf_vals), 0x06, NULL, HFILL }},
{ &hf_sna_nlp_ft,
{ "Function Type", "sna.nlp.nhdr.ft", FT_UINT8, BASE_HEX,
VALS(sna_nlp_ft_vals), 0xF0, NULL, HFILL }},
{ &hf_sna_nlp_tspi,
{ "Time Sensitive Packet Indicator", "sna.nlp.nhdr.tspi",
FT_BOOLEAN, 8, TFS(&sna_nlp_tspi_truth), 0x08, NULL, HFILL }},
{ &hf_sna_nlp_slowdn1,
{ "Slowdown 1", "sna.nlp.nhdr.slowdn1", FT_BOOLEAN, 8,
TFS(&sna_nlp_slowdn1_truth), 0x04, NULL, HFILL }},
{ &hf_sna_nlp_slowdn2,
{ "Slowdown 2", "sna.nlp.nhdr.slowdn2", FT_BOOLEAN, 8,
TFS(&sna_nlp_slowdn2_truth), 0x02, NULL, HFILL }},
{ &hf_sna_nlp_fra,
{ "Function Routing Address Entry", "sna.nlp.nhdr.fra",
FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_sna_nlp_anr,
{ "Automatic Network Routing Entry", "sna.nlp.nhdr.anr",
FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_sna_nlp_frh,
{ "Transmission Priority Field", "sna.nlp.frh", FT_UINT8,
BASE_HEX, VALS(sna_nlp_frh_vals), 0, NULL, HFILL }},
{ &hf_sna_nlp_thdr,
{ "RTP Transport Header", "sna.nlp.thdr", FT_NONE, BASE_NONE,
NULL, 0x0, "THDR", HFILL }},
{ &hf_sna_nlp_tcid,
{ "Transport Connection Identifier", "sna.nlp.thdr.tcid",
FT_BYTES, BASE_NONE, NULL, 0x0, "TCID", HFILL }},
{ &hf_sna_nlp_thdr_8,
{ "RTP Transport Packet Header Byte 8", "sna.nlp.thdr.8",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_setupi,
{ "Setup Indicator", "sna.nlp.thdr.setupi", FT_BOOLEAN, 8,
TFS(&sna_nlp_setupi_truth), 0x40, NULL, HFILL }},
{ &hf_sna_nlp_somi,
{ "Start Of Message Indicator", "sna.nlp.thdr.somi",
FT_BOOLEAN, 8, TFS(&sna_nlp_somi_truth), 0x20, NULL, HFILL }},
{ &hf_sna_nlp_eomi,
{ "End Of Message Indicator", "sna.nlp.thdr.eomi", FT_BOOLEAN,
8, TFS(&sna_nlp_eomi_truth), 0x10, NULL, HFILL }},
{ &hf_sna_nlp_sri,
{ "Session Request Indicator", "sna.nlp.thdr.sri", FT_BOOLEAN,
8, TFS(&sna_nlp_sri_truth), 0x08, NULL, HFILL }},
{ &hf_sna_nlp_rasapi,
{ "Reply ASAP Indicator", "sna.nlp.thdr.rasapi", FT_BOOLEAN,
8, TFS(&sna_nlp_rasapi_truth), 0x04, NULL, HFILL }},
{ &hf_sna_nlp_retryi,
{ "Retry Indicator", "sna.nlp.thdr.retryi", FT_BOOLEAN,
8, TFS(&sna_nlp_retryi_truth), 0x02, NULL, HFILL }},
{ &hf_sna_nlp_thdr_9,
{ "RTP Transport Packet Header Byte 9", "sna.nlp.thdr.9",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_lmi,
{ "Last Message Indicator", "sna.nlp.thdr.lmi", FT_BOOLEAN,
8, TFS(&sna_nlp_lmi_truth), 0x80, NULL, HFILL }},
{ &hf_sna_nlp_cqfi,
{ "Connection Qualifier Field Indicator", "sna.nlp.thdr.cqfi",
FT_BOOLEAN, 8, TFS(&sna_nlp_cqfi_truth), 0x08, NULL, HFILL }},
{ &hf_sna_nlp_osi,
{ "Optional Segments Present Indicator", "sna.nlp.thdr.osi",
FT_BOOLEAN, 8, TFS(&sna_nlp_osi_truth), 0x04, NULL, HFILL }},
{ &hf_sna_nlp_offset,
{ "Data Offset/4", "sna.nlp.thdr.offset", FT_UINT16, BASE_HEX,
NULL, 0x0, "Data Offset in Words", HFILL }},
{ &hf_sna_nlp_dlf,
{ "Data Length Field", "sna.nlp.thdr.dlf", FT_UINT32, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_bsn,
{ "Byte Sequence Number", "sna.nlp.thdr.bsn", FT_UINT32,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_len,
{ "Optional Segment Length/4", "sna.nlp.thdr.optional.len",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_type,
{ "Optional Segment Type", "sna.nlp.thdr.optional.type",
FT_UINT8, BASE_HEX, VALS(sna_nlp_opti_vals), 0x0, NULL,
HFILL }},
{ &hf_sna_nlp_opti_0d_version,
{ "Version", "sna.nlp.thdr.optional.0d.version",
FT_UINT16, BASE_HEX, VALS(sna_nlp_opti_0d_version_vals),
0, NULL, HFILL }},
{ &hf_sna_nlp_opti_0d_4,
{ "Connection Setup Byte 4", "sna.nlp.thdr.optional.0e.4",
FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }},
{ &hf_sna_nlp_opti_0d_target,
{ "Target Resource ID Present",
"sna.nlp.thdr.optional.0d.target",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
{ &hf_sna_nlp_opti_0d_arb,
{ "ARB Flow Control", "sna.nlp.thdr.optional.0d.arb",
FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
{ &hf_sna_nlp_opti_0d_reliable,
{ "Reliable Connection", "sna.nlp.thdr.optional.0d.reliable",
FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
{ &hf_sna_nlp_opti_0d_dedicated,
{ "Dedicated RTP Connection",
"sna.nlp.thdr.optional.0d.dedicated",
FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
{ &hf_sna_nlp_opti_0e_stat,
{ "Status", "sna.nlp.thdr.optional.0e.stat",
FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }},
{ &hf_sna_nlp_opti_0e_gap,
{ "Gap Detected", "sna.nlp.thdr.optional.0e.gap",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
{ &hf_sna_nlp_opti_0e_idle,
{ "RTP Idle Packet", "sna.nlp.thdr.optional.0e.idle",
FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
{ &hf_sna_nlp_opti_0e_nabsp,
{ "Number Of ABSP", "sna.nlp.thdr.optional.0e.nabsp",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_0e_sync,
{ "Status Report Number", "sna.nlp.thdr.optional.0e.sync",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_0e_echo,
{ "Status Acknowledge Number", "sna.nlp.thdr.optional.0e.echo",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_0e_rseq,
{ "Received Sequence Number", "sna.nlp.thdr.optional.0e.rseq",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
#if 0
{ &hf_sna_nlp_opti_0e_abspbeg,
{ "ABSP Begin", "sna.nlp.thdr.optional.0e.abspbeg",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
#endif
#if 0
{ &hf_sna_nlp_opti_0e_abspend,
{ "ABSP End", "sna.nlp.thdr.optional.0e.abspend",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
#endif
{ &hf_sna_nlp_opti_0f_bits,
{ "Client Bits", "sna.nlp.thdr.optional.0f.bits",
FT_UINT16, BASE_HEX, VALS(sna_nlp_opti_0f_bits_vals),
0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_10_tcid,
{ "Transport Connection Identifier",
"sna.nlp.thdr.optional.10.tcid",
FT_BYTES, BASE_NONE, NULL, 0x0, "TCID", HFILL }},
{ &hf_sna_nlp_opti_12_sense,
{ "Sense Data", "sna.nlp.thdr.optional.12.sense",
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_si_len,
{ "Length", "sna.nlp.thdr.optional.14.si.len",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_si_key,
{ "Key", "sna.nlp.thdr.optional.14.si.key",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_si_2,
{ "Switching Information Byte 2",
"sna.nlp.thdr.optional.14.si.2",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_si_refifo,
{ "Resequencing (REFIFO) Indicator",
"sna.nlp.thdr.optional.14.si.refifo",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_si_mobility,
{ "Mobility Indicator",
"sna.nlp.thdr.optional.14.si.mobility",
FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_si_dirsearch,
{ "Directory Search Required on Path Switch Indicator",
"sna.nlp.thdr.optional.14.si.dirsearch",
FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_si_limitres,
{ "Limited Resource Link Indicator",
"sna.nlp.thdr.optional.14.si.limitres",
FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_si_ncescope,
{ "NCE Scope Indicator",
"sna.nlp.thdr.optional.14.si.ncescope",
FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_si_mnpsrscv,
{ "MNPS RSCV Retention Indicator",
"sna.nlp.thdr.optional.14.si.mnpsrscv",
FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_si_maxpsize,
{ "Maximum Packet Size On Return Path",
"sna.nlp.thdr.optional.14.si.maxpsize",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_si_switch,
{ "Path Switch Time", "sna.nlp.thdr.optional.14.si.switch",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_si_alive,
{ "RTP Alive Timer", "sna.nlp.thdr.optional.14.si.alive",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_rr_len,
{ "Length", "sna.nlp.thdr.optional.14.rr.len",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_rr_key,
{ "Key", "sna.nlp.thdr.optional.14.rr.key",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_rr_2,
{ "Return Route TG Descriptor Byte 2",
"sna.nlp.thdr.optional.14.rr.2",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_rr_bfe,
{ "BF Entry Indicator",
"sna.nlp.thdr.optional.14.rr.bfe",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
{ &hf_sna_nlp_opti_14_rr_num,
{ "Number Of TG Control Vectors",
"sna.nlp.thdr.optional.14.rr.num",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_22_2,
{ "Adaptive Rate Based Segment Byte 2",
"sna.nlp.thdr.optional.22.2",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_22_type,
{ "Message Type",
"sna.nlp.thdr.optional.22.type",
FT_UINT8, BASE_HEX,
VALS(sna_nlp_opti_22_type_vals), 0xc0, NULL, HFILL }},
{ &hf_sna_nlp_opti_22_raa,
{ "Rate Adjustment Action",
"sna.nlp.thdr.optional.22.raa",
FT_UINT8, BASE_HEX,
VALS(sna_nlp_opti_22_raa_vals), 0x38, NULL, HFILL }},
{ &hf_sna_nlp_opti_22_parity,
{ "Parity Indicator",
"sna.nlp.thdr.optional.22.parity",
FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
{ &hf_sna_nlp_opti_22_arb,
{ "ARB Mode",
"sna.nlp.thdr.optional.22.arb",
FT_UINT8, BASE_HEX,
VALS(sna_nlp_opti_22_arb_vals), 0x03, NULL, HFILL }},
{ &hf_sna_nlp_opti_22_3,
{ "Adaptive Rate Based Segment Byte 3",
"sna.nlp.thdr.optional.22.3",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_22_ratereq,
{ "Rate Request Correlator",
"sna.nlp.thdr.optional.22.ratereq",
FT_UINT8, BASE_DEC, NULL, 0xf0, NULL, HFILL }},
{ &hf_sna_nlp_opti_22_raterep,
{ "Rate Reply Correlator",
"sna.nlp.thdr.optional.22.raterep",
FT_UINT8, BASE_DEC, NULL, 0x0f, NULL, HFILL }},
{ &hf_sna_nlp_opti_22_field1,
{ "Field 1", "sna.nlp.thdr.optional.22.field1",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_22_field2,
{ "Field 2", "sna.nlp.thdr.optional.22.field2",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_22_field3,
{ "Field 3", "sna.nlp.thdr.optional.22.field3",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_nlp_opti_22_field4,
{ "Field 4", "sna.nlp.thdr.optional.22.field4",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_rh,
{ "Request/Response Header", "sna.rh", FT_NONE, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_sna_rh_0,
{ "Request/Response Header Byte 0", "sna.rh.0", FT_UINT8,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_rh_1,
{ "Request/Response Header Byte 1", "sna.rh.1", FT_UINT8,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_rh_2,
{ "Request/Response Header Byte 2", "sna.rh.2", FT_UINT8,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_rh_rri,
{ "Request/Response Indicator", "sna.rh.rri", FT_BOOLEAN,
8, TFS(&tfs_response_request), 0x80, NULL, HFILL }},
{ &hf_sna_rh_ru_category,
{ "Request/Response Unit Category", "sna.rh.ru_category",
FT_UINT8, BASE_HEX, VALS(sna_rh_ru_category_vals), 0x60,
NULL, HFILL }},
{ &hf_sna_rh_fi,
{ "Format Indicator", "sna.rh.fi", FT_BOOLEAN, 8,
TFS(&sna_rh_fi_truth), 0x08, NULL, HFILL }},
{ &hf_sna_rh_sdi,
{ "Sense Data Included", "sna.rh.sdi", FT_BOOLEAN, 8,
TFS(&tfs_included_not_included), 0x04, NULL, HFILL }},
{ &hf_sna_rh_bci,
{ "Begin Chain Indicator", "sna.rh.bci", FT_BOOLEAN, 8,
TFS(&sna_rh_bci_truth), 0x02, NULL, HFILL }},
{ &hf_sna_rh_eci,
{ "End Chain Indicator", "sna.rh.eci", FT_BOOLEAN, 8,
TFS(&sna_rh_eci_truth), 0x01, NULL, HFILL }},
{ &hf_sna_rh_dr1,
{ "Definite Response 1 Indicator", "sna.rh.dr1", FT_BOOLEAN,
8, NULL, 0x80, NULL, HFILL }},
{ &hf_sna_rh_lcci,
{ "Length-Checked Compression Indicator", "sna.rh.lcci",
FT_BOOLEAN, 8, TFS(&sna_rh_lcci_truth), 0x40, NULL, HFILL }},
{ &hf_sna_rh_dr2,
{ "Definite Response 2 Indicator", "sna.rh.dr2", FT_BOOLEAN,
8, NULL, 0x20, NULL, HFILL }},
{ &hf_sna_rh_eri,
{ "Exception Response Indicator", "sna.rh.eri", FT_BOOLEAN,
8, NULL, 0x10, NULL, HFILL }},
{ &hf_sna_rh_rti,
{ "Response Type Indicator", "sna.rh.rti", FT_BOOLEAN,
8, TFS(&sna_rh_rti_truth), 0x10, NULL, HFILL }},
{ &hf_sna_rh_rlwi,
{ "Request Larger Window Indicator", "sna.rh.rlwi", FT_BOOLEAN,
8, NULL, 0x04, NULL, HFILL }},
{ &hf_sna_rh_qri,
{ "Queued Response Indicator", "sna.rh.qri", FT_BOOLEAN,
8, TFS(&sna_rh_qri_truth), 0x02, NULL, HFILL }},
{ &hf_sna_rh_pi,
{ "Pacing Indicator", "sna.rh.pi", FT_BOOLEAN,
8, NULL, 0x01, NULL, HFILL }},
{ &hf_sna_rh_bbi,
{ "Begin Bracket Indicator", "sna.rh.bbi", FT_BOOLEAN,
8, NULL, 0x80, NULL, HFILL }},
{ &hf_sna_rh_ebi,
{ "End Bracket Indicator", "sna.rh.ebi", FT_BOOLEAN,
8, NULL, 0x40, NULL, HFILL }},
{ &hf_sna_rh_cdi,
{ "Change Direction Indicator", "sna.rh.cdi", FT_BOOLEAN,
8, NULL, 0x20, NULL, HFILL }},
{ &hf_sna_rh_csi,
{ "Code Selection Indicator", "sna.rh.csi", FT_UINT8, BASE_DEC,
VALS(sna_rh_csi_vals), 0x08, NULL, HFILL }},
{ &hf_sna_rh_edi,
{ "Enciphered Data Indicator", "sna.rh.edi", FT_BOOLEAN, 8,
NULL, 0x04, NULL, HFILL }},
{ &hf_sna_rh_pdi,
{ "Padded Data Indicator", "sna.rh.pdi", FT_BOOLEAN, 8, NULL,
0x02, NULL, HFILL }},
{ &hf_sna_rh_cebi,
{ "Conditional End Bracket Indicator", "sna.rh.cebi",
FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
/* { &hf_sna_ru,
{ "Request/Response Unit", "sna.ru", FT_NONE, BASE_NONE,
NULL, 0x0, NULL, HFILL }},*/
{ &hf_sna_gds,
{ "GDS Variable", "sna.gds", FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_sna_gds_len,
{ "GDS Variable Length", "sna.gds.len", FT_UINT16, BASE_DEC,
NULL, 0x7fff, NULL, HFILL }},
{ &hf_sna_gds_cont,
{ "Continuation Flag", "sna.gds.cont", FT_BOOLEAN, 16, NULL,
0x8000, NULL, HFILL }},
{ &hf_sna_gds_type,
{ "Type of Variable", "sna.gds.type", FT_UINT16, BASE_HEX,
VALS(sna_gds_var_vals), 0x0, NULL, HFILL }},
{ &hf_sna_gds_info,
{ "Information", "sna.gds.info", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
#if 0
{ &hf_sna_xid,
{ "XID", "sna.xid", FT_NONE, BASE_NONE, NULL, 0x0,
"XID Frame", HFILL }},
#endif
{ &hf_sna_xid_0,
{ "XID Byte 0", "sna.xid.0", FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_sna_xid_format,
{ "XID Format", "sna.xid.format", FT_UINT8, BASE_DEC, NULL,
0xf0, NULL, HFILL }},
{ &hf_sna_xid_type,
{ "XID Type", "sna.xid.type", FT_UINT8, BASE_DEC,
VALS(sna_xid_type_vals), 0x0f, NULL, HFILL }},
{ &hf_sna_xid_len,
{ "XID Length", "sna.xid.len", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_sna_xid_id,
{ "Node Identification", "sna.xid.id", FT_UINT32, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_sna_xid_idblock,
{ "ID Block", "sna.xid.idblock", FT_UINT32, BASE_HEX, NULL,
0xfff00000, NULL, HFILL }},
{ &hf_sna_xid_idnum,
{ "ID Number", "sna.xid.idnum", FT_UINT32, BASE_HEX, NULL,
0x0fffff, NULL, HFILL }},
{ &hf_sna_xid_3_8,
{ "Characteristics of XID sender", "sna.xid.type3.8", FT_UINT16,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_xid_3_init_self,
{ "INIT-SELF support", "sna.xid.type3.initself",
FT_BOOLEAN, 16, NULL, 0x8000, NULL, HFILL }},
{ &hf_sna_xid_3_stand_bind,
{ "Stand-Alone BIND Support", "sna.xid.type3.stand_bind",
FT_BOOLEAN, 16, NULL, 0x4000, NULL, HFILL }},
{ &hf_sna_xid_3_gener_bind,
{ "Whole BIND PIU generated indicator",
"sna.xid.type3.gener_bind", FT_BOOLEAN, 16, NULL, 0x2000,
"Whole BIND PIU generated", HFILL }},
{ &hf_sna_xid_3_recve_bind,
{ "Whole BIND PIU required indicator",
"sna.xid.type3.recve_bind", FT_BOOLEAN, 16, NULL, 0x1000,
"Whole BIND PIU required", HFILL }},
{ &hf_sna_xid_3_actpu,
{ "ACTPU suppression indicator", "sna.xid.type3.actpu",
FT_BOOLEAN, 16, NULL, 0x0080, NULL, HFILL }},
{ &hf_sna_xid_3_nwnode,
{ "Sender is network node", "sna.xid.type3.nwnode",
FT_BOOLEAN, 16, NULL, 0x0040, NULL, HFILL }},
{ &hf_sna_xid_3_cp,
{ "Control Point Services", "sna.xid.type3.cp",
FT_BOOLEAN, 16, NULL, 0x0020, NULL, HFILL }},
{ &hf_sna_xid_3_cpcp,
{ "CP-CP session support", "sna.xid.type3.cpcp",
FT_BOOLEAN, 16, NULL, 0x0010, NULL, HFILL }},
{ &hf_sna_xid_3_state,
{ "XID exchange state indicator", "sna.xid.type3.state",
FT_UINT16, BASE_HEX, VALS(sna_xid_3_state_vals),
0x000c, NULL, HFILL }},
{ &hf_sna_xid_3_nonact,
{ "Nonactivation Exchange", "sna.xid.type3.nonact",
FT_BOOLEAN, 16, NULL, 0x0002, NULL, HFILL }},
{ &hf_sna_xid_3_cpchange,
{ "CP name change support", "sna.xid.type3.cpchange",
FT_BOOLEAN, 16, NULL, 0x0001, NULL, HFILL }},
{ &hf_sna_xid_3_10,
{ "XID Type 3 Byte 10", "sna.xid.type3.10", FT_UINT8, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_sna_xid_3_asend_bind,
{ "Adaptive BIND pacing support as sender",
"sna.xid.type3.asend_bind", FT_BOOLEAN, 8, NULL, 0x80,
"Pacing support as sender", HFILL }},
{ &hf_sna_xid_3_arecv_bind,
{ "Adaptive BIND pacing support as receiver",
"sna.xid.type3.asend_recv", FT_BOOLEAN, 8, NULL, 0x40,
"Pacing support as receive", HFILL }},
{ &hf_sna_xid_3_quiesce,
{ "Quiesce TG Request",
"sna.xid.type3.quiesce", FT_BOOLEAN, 8, NULL, 0x20,
NULL, HFILL }},
{ &hf_sna_xid_3_pucap,
{ "PU Capabilities",
"sna.xid.type3.pucap", FT_BOOLEAN, 8, NULL, 0x10,
NULL, HFILL }},
{ &hf_sna_xid_3_pbn,
{ "Peripheral Border Node",
"sna.xid.type3.pbn", FT_BOOLEAN, 8, NULL, 0x08,
NULL, HFILL }},
{ &hf_sna_xid_3_pacing,
{ "Qualifier for adaptive BIND pacing support",
"sna.xid.type3.pacing", FT_UINT8, BASE_HEX, NULL, 0x03,
NULL, HFILL }},
{ &hf_sna_xid_3_11,
{ "XID Type 3 Byte 11", "sna.xid.type3.11", FT_UINT8, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_sna_xid_3_tgshare,
{ "TG Sharing Prohibited Indicator",
"sna.xid.type3.tgshare", FT_BOOLEAN, 8, NULL, 0x40,
NULL, HFILL }},
{ &hf_sna_xid_3_dedsvc,
{ "Dedicated SVC Indicator",
"sna.xid.type3.dedsvc", FT_BOOLEAN, 8, NULL, 0x20,
NULL, HFILL }},
{ &hf_sna_xid_3_12,
{ "XID Type 3 Byte 12", "sna.xid.type3.12", FT_UINT8, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_sna_xid_3_negcsup,
{ "Negotiation Complete Supported",
"sna.xid.type3.negcsup", FT_BOOLEAN, 8, NULL, 0x80,
NULL, HFILL }},
{ &hf_sna_xid_3_negcomp,
{ "Negotiation Complete",
"sna.xid.type3.negcomp", FT_BOOLEAN, 8, NULL, 0x40,
NULL, HFILL }},
{ &hf_sna_xid_3_15,
{ "XID Type 3 Byte 15", "sna.xid.type3.15", FT_UINT8, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
{ &hf_sna_xid_3_partg,
{ "Parallel TG Support",
"sna.xid.type3.partg", FT_BOOLEAN, 8, NULL, 0x80,
NULL, HFILL }},
{ &hf_sna_xid_3_dlur,
{ "Dependent LU Requester Indicator",
"sna.xid.type3.dlur", FT_BOOLEAN, 8, NULL, 0x40,
NULL, HFILL }},
{ &hf_sna_xid_3_dlus,
{ "DLUS Served LU Registration Indicator",
"sna.xid.type3.dlus", FT_BOOLEAN, 8, NULL, 0x20,
NULL, HFILL }},
{ &hf_sna_xid_3_exbn,
{ "Extended HPR Border Node",
"sna.xid.type3.exbn", FT_BOOLEAN, 8, NULL, 0x10,
NULL, HFILL }},
{ &hf_sna_xid_3_genodai,
{ "Generalized ODAI Usage Option",
"sna.xid.type3.genodai", FT_BOOLEAN, 8, NULL, 0x08,
NULL, HFILL }},
{ &hf_sna_xid_3_branch,
{ "Branch Indicator", "sna.xid.type3.branch",
FT_UINT8, BASE_HEX, VALS(sna_xid_3_branch_vals),
0x06, NULL, HFILL }},
{ &hf_sna_xid_3_brnn,
{ "Option Set 1123 Indicator",
"sna.xid.type3.brnn", FT_BOOLEAN, 8, NULL, 0x01,
NULL, HFILL }},
{ &hf_sna_xid_3_tg,
{ "XID TG", "sna.xid.type3.tg", FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_sna_xid_3_dlc,
{ "XID DLC", "sna.xid.type3.dlc", FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_sna_xid_3_dlen,
{ "DLC Dependent Section Length", "sna.xid.type3.dlen",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_control_len,
{ "Control Vector Length", "sna.control.len",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_control_key,
{ "Control Vector Key", "sna.control.key",
FT_UINT8, BASE_HEX, VALS(sna_control_vals), 0x0, NULL,
HFILL }},
{ &hf_sna_control_hprkey,
{ "Control Vector HPR Key", "sna.control.hprkey",
FT_UINT8, BASE_HEX, VALS(sna_control_hpr_vals), 0x0, NULL,
HFILL }},
{ &hf_sna_control_05_delay,
{ "Channel Delay", "sna.control.05.delay",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_control_05_type,
{ "Network Address Type", "sna.control.05.type",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sna_control_05_ptp,
{ "Point-to-point", "sna.control.05.ptp",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
{ &hf_sna_control_0e_type,
{ "Type", "sna.control.0e.type",
FT_UINT8, BASE_HEX, VALS(sna_control_0e_type_vals),
0, NULL, HFILL }},
{ &hf_sna_control_0e_value,
{ "Value", "sna.control.0e.value",
FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_sna_padding,
{ "Padding", "sna.padding",
FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_sna_reserved,
{ "Reserved", "sna.reserved",
FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_sna_biu_segment_data,
{ "BIU segment data", "sna.biu_segment_data",
FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
};
static gint *ett[] = {
&ett_sna,
&ett_sna_th,
&ett_sna_th_fid,
&ett_sna_nlp_nhdr,
&ett_sna_nlp_nhdr_0,
&ett_sna_nlp_nhdr_1,
&ett_sna_nlp_thdr,
&ett_sna_nlp_thdr_8,
&ett_sna_nlp_thdr_9,
&ett_sna_nlp_opti_un,
&ett_sna_nlp_opti_0d,
&ett_sna_nlp_opti_0d_4,
&ett_sna_nlp_opti_0e,
&ett_sna_nlp_opti_0e_stat,
&ett_sna_nlp_opti_0e_absp,
&ett_sna_nlp_opti_0f,
&ett_sna_nlp_opti_10,
&ett_sna_nlp_opti_12,
&ett_sna_nlp_opti_14,
&ett_sna_nlp_opti_14_si,
&ett_sna_nlp_opti_14_si_2,
&ett_sna_nlp_opti_14_rr,
&ett_sna_nlp_opti_14_rr_2,
&ett_sna_nlp_opti_22,
&ett_sna_nlp_opti_22_2,
&ett_sna_nlp_opti_22_3,
&ett_sna_rh,
&ett_sna_rh_0,
&ett_sna_rh_1,
&ett_sna_rh_2,
&ett_sna_gds,
&ett_sna_xid_0,
&ett_sna_xid_id,
&ett_sna_xid_3_8,
&ett_sna_xid_3_10,
&ett_sna_xid_3_11,
&ett_sna_xid_3_12,
&ett_sna_xid_3_15,
&ett_sna_control_un,
&ett_sna_control_05,
&ett_sna_control_05hpr,
&ett_sna_control_05hpr_type,
&ett_sna_control_0e,
};
module_t *sna_module;
proto_sna = proto_register_protocol("Systems Network Architecture",
"SNA", "sna");
proto_register_field_array(proto_sna, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
sna_handle = register_dissector("sna", dissect_sna, proto_sna);
proto_sna_xid = proto_register_protocol(
"Systems Network Architecture XID", "SNA XID", "sna_xid");
sna_xid_handle = register_dissector("sna_xid", dissect_sna_xid, proto_sna_xid);
sna_address_type = address_type_dissector_register("AT_SNA", "SNA Address", sna_fid_to_str_buf, sna_address_str_len, NULL, NULL, NULL, NULL, NULL);
/* Register configuration options */
sna_module = prefs_register_protocol(proto_sna, NULL);
prefs_register_bool_preference(sna_module, "defragment",
"Reassemble fragmented BIUs",
"Whether fragmented BIUs should be reassembled",
&sna_defragment);
reassembly_table_register(&sna_reassembly_table,
&addresses_reassembly_table_functions);
}
void
proto_reg_handoff_sna(void)
{
dissector_add_uint("llc.dsap", SAP_SNA_PATHCTRL, sna_handle);
dissector_add_uint("llc.dsap", SAP_SNA1, sna_handle);
dissector_add_uint("llc.dsap", SAP_SNA2, sna_handle);
dissector_add_uint("llc.dsap", SAP_SNA3, sna_handle);
dissector_add_uint("llc.dsap", SAP_SNA4, sna_handle);
dissector_add_uint("llc.xid_dsap", SAP_SNA_PATHCTRL, sna_xid_handle);
dissector_add_uint("llc.xid_dsap", SAP_SNA1, sna_xid_handle);
dissector_add_uint("llc.xid_dsap", SAP_SNA2, sna_xid_handle);
dissector_add_uint("llc.xid_dsap", SAP_SNA3, sna_xid_handle);
/* RFC 2043 */
dissector_add_uint("ppp.protocol", PPP_SNA, sna_handle);
}
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-snaeth.c
|
/* packet-snaeth.c
* Routines for SNA-over-Ethernet (Ethernet type 80d5)
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/etypes.h>
/*
* See
*
* http://www.cisco.com/univercd/cc/td/doc/product/software/ssr90/rpc_r/18059.pdf
*/
void proto_register_snaeth(void);
void proto_reg_handoff_snaeth(void);
static int proto_snaeth = -1;
static int hf_snaeth_len = -1;
static int hf_snaeth_padding = -1;
static gint ett_snaeth = -1;
static dissector_handle_t llc_handle;
static int
dissect_snaeth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
proto_tree *snaeth_tree;
proto_item *snaeth_ti;
guint16 len;
tvbuff_t *next_tvb;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SNAETH");
col_set_str(pinfo->cinfo, COL_INFO, "SNA over Ethernet");
/* length */
len = tvb_get_ntohs(tvb, 0);
if (tree) {
snaeth_ti = proto_tree_add_item(tree, proto_snaeth, tvb, 0, 3,
ENC_NA);
snaeth_tree = proto_item_add_subtree(snaeth_ti, ett_snaeth);
proto_tree_add_uint(snaeth_tree, hf_snaeth_len, tvb, 0, 2, len);
proto_tree_add_item(snaeth_tree, hf_snaeth_padding, tvb, 2, 1, ENC_BIG_ENDIAN);
}
/*
* Adjust the length of this tvbuff to include only the SNA-over-
* Ethernet header and data.
*/
set_actual_length(tvb, 3 + len);
/*
* Rest of packet starts with an 802.2 LLC header.
*/
next_tvb = tvb_new_subset_remaining(tvb, 3);
call_dissector(llc_handle, next_tvb, pinfo, tree);
return tvb_captured_length(tvb);
}
void
proto_register_snaeth(void)
{
static hf_register_info hf[] = {
{ &hf_snaeth_len,
{ "Length", "snaeth.len", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of LLC payload", HFILL }},
{ &hf_snaeth_padding,
{ "Padding", "snaeth.padding", FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
};
static gint *ett[] = {
&ett_snaeth,
};
proto_snaeth = proto_register_protocol("SNA-over-Ethernet",
"SNAETH", "snaeth");
proto_register_field_array(proto_snaeth, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_snaeth(void)
{
dissector_handle_t snaeth_handle;
/*
* Get handle for the LLC dissector.
*/
llc_handle = find_dissector_add_dependency("llc", proto_snaeth);
snaeth_handle = create_dissector_handle(dissect_snaeth, proto_snaeth);
dissector_add_uint("ethertype", ETHERTYPE_SNA, snaeth_handle);
}
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-sndcp-xid.c
|
/* packet-sndcp-xid.c
* Routines for Subnetwork Dependent Convergence Protocol (SNDCP) XID dissection
* Used to dissect XID compression parameters negotiated in GSM (TS44.065)
* Copyright 2008, Vincent Helfre <vincent.helfre [AT] ericsson.com>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
/* Parameter types: TS 44.065 8
*/
#define SNDCP_VERSION_PAR_TYPE 0
#define DATA_COMPRESSION_PAR_TYPE 1
#define PROTOCOL_COMPRESSION_PAR_TYPE 2
/* Algorithm identifiers: TS 44.065 6.6.1.1.4 and 6.5.1.1.4
*/
#define ALGO_V42BIS 0
#define ALGO_V44 1
#define ALGO_RFC1144 0
#define ALGO_RFC2507 1
#define ALGO_ROHC 2
void proto_register_sndcp_xid(void);
static const value_string sndcp_xid_dcomp_algo_str[] = {
{0x0, "V.42 bis"},
{0x1, "V.44"},
{0, NULL}
};
static const value_string sndcp_xid_pcomp_algo_str[] = {
{0x0, "RFC 1144"},
{0x1, "RFC 2507"},
{0x2, "ROHC (RFC 3095)"},
{0, NULL}
};
typedef struct
{
guint8 nb_of_dcomp_pcomp; /* note that a DCOMP or a PCOMP is 4 bit wide */
guint16 (**func_array_ptr) (tvbuff_t *, proto_tree *, guint16);
} algo_parameters_t;
/* Initialize the protocol and registered fields
*/
static int proto_sndcp_xid = -1;
/* These fields are used to store the algorithm ID
* When the P bit is not set, try to decode the algo based on what whas stored.
* Entity ranges from 0 to 31 (6.5.1.1.3)
*/
static guint8 dcomp_entity_algo_id[32]={-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1};
static guint8 pcomp_entity_algo_id[32]={-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1};
/* L3 XID parsing */
static int hf_sndcp_xid_type = -1;
static int hf_sndcp_xid_len = -1;
static int hf_sndcp_xid_value = -1;
static int hf_sndcp_xid_comp_pbit = -1;
static int hf_sndcp_xid_comp_spare_byte1 = -1;
static int hf_sndcp_xid_comp_entity = -1;
static int hf_sndcp_xid_comp_spare_byte2 = -1;
static int hf_sndcp_xid_comp_algo_id = -1;
static int hf_sndcp_xid_comp_len = -1;
/* There is currently a maximum of 15 DCOMP/PCOMP: 6.5.1.1.5 */
static int hf_sndcp_xid_comp[15] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
static int hf_sndcp_xid_comp_spare = -1;
static int hf_element_applicable_nsapi_15 = -1;
static int hf_element_applicable_nsapi_14 = -1;
static int hf_element_applicable_nsapi_13 = -1;
static int hf_element_applicable_nsapi_12 = -1;
static int hf_element_applicable_nsapi_11 = -1;
static int hf_element_applicable_nsapi_10 = -1;
static int hf_element_applicable_nsapi_9 = -1;
static int hf_element_applicable_nsapi_8 = -1;
static int hf_element_applicable_nsapi_7 = -1;
static int hf_element_applicable_nsapi_6 = -1;
static int hf_element_applicable_nsapi_5 = -1;
static int hf_element_applicable_nsapi_spare = -1;
static int hf_sndcp_xid_rfc1144_s0 = -1;
static int hf_sndcp_xid_rfc2507_f_max_period_msb = -1;
static int hf_sndcp_xid_rfc2507_f_max_period_lsb = -1;
static int hf_sndcp_xid_rfc2507_f_max_time = -1;
static int hf_sndcp_xid_rfc2507_max_header = -1;
static int hf_sndcp_xid_rfc2507_tcp_space = -1;
static int hf_sndcp_xid_rfc2507_non_tcp_space_msb = -1;
static int hf_sndcp_xid_rfc2507_non_tcp_space_lsb = -1;
static int hf_sndcp_xid_rohc_max_cid_spare = -1;
static int hf_sndcp_xid_rohc_max_cid_msb = -1;
static int hf_sndcp_xid_rohc_max_cid_lsb = -1;
static int hf_sndcp_xid_rohc_max_header = -1;
static int hf_sndcp_xid_rohc_profile_msb = -1;
static int hf_sndcp_xid_rohc_profile_lsb = -1;
static int hf_sndcp_xid_V42bis_p0_spare = -1;
static int hf_sndcp_xid_V42bis_p0 = -1;
static int hf_sndcp_xid_V42bis_p1_msb = -1;
static int hf_sndcp_xid_V42bis_p1_lsb = -1;
static int hf_sndcp_xid_V42bis_p2 = -1;
static int hf_sndcp_xid_V44_c0 = -1;
static int hf_sndcp_xid_V44_c0_spare = -1;
static int hf_sndcp_xid_V44_p0_spare = -1;
static int hf_sndcp_xid_V44_p0 = -1;
static int hf_sndcp_xid_V44_p1t_msb = -1;
static int hf_sndcp_xid_V44_p1t_lsb = -1;
static int hf_sndcp_xid_V44_p1r_msb = -1;
static int hf_sndcp_xid_V44_p1r_lsb = -1;
static int hf_sndcp_xid_V44_p3t_msb = -1;
static int hf_sndcp_xid_V44_p3t_lsb = -1;
static int hf_sndcp_xid_V44_p3r_msb = -1;
static int hf_sndcp_xid_V44_p3r_lsb = -1;
/* Initialize the subtree pointers
*/
static gint ett_sndcp_xid = -1;
static gint ett_sndcp_xid_version_field = -1;
static gint ett_sndcp_comp_field = -1;
static void parse_compression_parameters(tvbuff_t *tvb, proto_tree *tree, gboolean dcomp);
/******************************************************/
/* Compression algorithms element dissector functions */
/******************************************************/
static guint16 parse_applicable_nsapi(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 nsapi_byte1, nsapi_byte2;
nsapi_byte1 = tvb_get_guint8(tvb, offset);
nsapi_byte2 = tvb_get_guint8(tvb, offset+1);
proto_tree_add_uint(tree, hf_element_applicable_nsapi_15, tvb, offset, 1, nsapi_byte1);
proto_tree_add_uint(tree, hf_element_applicable_nsapi_14, tvb, offset, 1, nsapi_byte1);
proto_tree_add_uint(tree, hf_element_applicable_nsapi_13, tvb, offset, 1, nsapi_byte1);
proto_tree_add_uint(tree, hf_element_applicable_nsapi_12, tvb, offset, 1, nsapi_byte1);
proto_tree_add_uint(tree, hf_element_applicable_nsapi_11, tvb, offset, 1, nsapi_byte1);
proto_tree_add_uint(tree, hf_element_applicable_nsapi_10, tvb, offset, 1, nsapi_byte1);
proto_tree_add_uint(tree, hf_element_applicable_nsapi_9, tvb, offset, 1, nsapi_byte1);
proto_tree_add_uint(tree, hf_element_applicable_nsapi_8, tvb, offset, 1, nsapi_byte1);
proto_tree_add_uint(tree, hf_element_applicable_nsapi_7, tvb, offset+1, 1, nsapi_byte2);
proto_tree_add_uint(tree, hf_element_applicable_nsapi_6, tvb, offset+1, 1, nsapi_byte2);
proto_tree_add_uint(tree, hf_element_applicable_nsapi_5, tvb, offset+1, 1, nsapi_byte2);
proto_tree_add_uint(tree, hf_element_applicable_nsapi_spare, tvb, offset+1, 1, nsapi_byte2);
return 2U;
}
static guint16 parse_rfc1144_s0(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 s0;
s0 = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_sndcp_xid_rfc1144_s0, tvb, offset, 1, s0);
return 1U;
}
static guint16 parse_rfc2507_f_max_period(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 f_max_period_byte1, f_max_period_byte2;
f_max_period_byte1 = tvb_get_guint8(tvb, offset);
f_max_period_byte2 = tvb_get_guint8(tvb, offset+1);
proto_tree_add_uint(tree, hf_sndcp_xid_rfc2507_f_max_period_msb, tvb, offset, 1, f_max_period_byte1);
proto_tree_add_uint(tree, hf_sndcp_xid_rfc2507_f_max_period_lsb, tvb, offset, 1, f_max_period_byte2);
return 2U;
}
static guint16 parse_rfc2507_f_max_time(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 f_max_time;
f_max_time = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_sndcp_xid_rfc2507_f_max_time, tvb, offset, 1, f_max_time);
return 1U;
}
static guint16 parse_rfc2507_max_header(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 max_header;
max_header = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_sndcp_xid_rfc2507_max_header, tvb, offset, 1, max_header);
return 1U;
}
static guint16 parse_rfc2507_tcp_space(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 tcp_space;
tcp_space = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_sndcp_xid_rfc2507_tcp_space, tvb, offset, 1, tcp_space);
return 1U;
}
static guint16 parse_rfc2507_non_tcp_space(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 tcp_space_msb, tcp_space_lsb;
tcp_space_msb = tvb_get_guint8(tvb, offset);
tcp_space_lsb = tvb_get_guint8(tvb, offset+1);
proto_tree_add_uint(tree, hf_sndcp_xid_rfc2507_non_tcp_space_msb, tvb, offset, 1, tcp_space_msb);
proto_tree_add_uint(tree, hf_sndcp_xid_rfc2507_non_tcp_space_lsb, tvb, offset, 1, tcp_space_lsb);
return 2U;
}
static guint16 parse_rohc_max_cid(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 max_cid_msb, max_cid_lsb;
max_cid_msb = tvb_get_guint8(tvb, offset);
max_cid_lsb = tvb_get_guint8(tvb, offset+1);
proto_tree_add_uint(tree, hf_sndcp_xid_rohc_max_cid_spare, tvb, offset, 1, max_cid_msb);
proto_tree_add_uint(tree, hf_sndcp_xid_rohc_max_cid_msb, tvb, offset, 1, max_cid_msb);
proto_tree_add_uint(tree, hf_sndcp_xid_rohc_max_cid_lsb, tvb, offset+1, 1, max_cid_lsb);
return 2U;
}
static guint16 parse_rohc_max_header(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 max_header;
max_header = tvb_get_guint8(tvb, offset+1);
proto_tree_add_uint(tree, hf_sndcp_xid_rohc_max_header, tvb, offset+1, 1, max_header);
return 2U;
}
static guint16 parse_rohc_profile(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 profile_msb, profile_lsb;
profile_msb = tvb_get_guint8(tvb, offset);
profile_lsb = tvb_get_guint8(tvb, offset+1);
proto_tree_add_uint(tree, hf_sndcp_xid_rohc_profile_msb, tvb, offset, 1, profile_msb);
proto_tree_add_uint(tree, hf_sndcp_xid_rohc_profile_lsb, tvb, offset+1, 1, profile_lsb);
return 2U;
}
static guint16 parse_V42bis_p0(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 p0;
p0 = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_sndcp_xid_V42bis_p0_spare, tvb, offset, 1, p0);
proto_tree_add_uint(tree, hf_sndcp_xid_V42bis_p0, tvb, offset, 1, p0);
return 1U;
}
static guint16 parse_V42bis_p1(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 p1_msb, p1_lsb;
p1_msb = tvb_get_guint8(tvb, offset);
p1_lsb = tvb_get_guint8(tvb, offset+1);
proto_tree_add_uint(tree, hf_sndcp_xid_V42bis_p1_msb, tvb, offset, 1, p1_msb);
proto_tree_add_uint(tree, hf_sndcp_xid_V42bis_p1_lsb, tvb, offset+1, 1, p1_lsb);
return 2U;
}
static guint16 parse_V42bis_p2(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 p2;
p2 = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_sndcp_xid_V42bis_p2, tvb, offset, 1, p2);
return 1U;
}
static guint16 parse_V44_c0(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 c0;
c0 = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_sndcp_xid_V44_c0_spare, tvb, offset, 1, c0);
proto_tree_add_uint(tree, hf_sndcp_xid_V44_c0, tvb, offset, 1, c0);
return 1U;
}
static guint16 parse_V44_p0(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 p0;
p0 = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_sndcp_xid_V44_p0_spare, tvb, offset, 1, p0);
proto_tree_add_uint(tree, hf_sndcp_xid_V44_p0, tvb, offset, 1, p0);
return 1U;
}
static guint16 parse_V44_p1t(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 p1t_msb, p1t_lsb;
p1t_msb = tvb_get_guint8(tvb, offset);
p1t_lsb = tvb_get_guint8(tvb, offset+1);
proto_tree_add_uint(tree, hf_sndcp_xid_V44_p1t_msb, tvb, offset, 1, p1t_msb);
proto_tree_add_uint(tree, hf_sndcp_xid_V44_p1t_lsb, tvb, offset+1, 1, p1t_lsb);
return 2U;
}
static guint16 parse_V44_p1r(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 p1r_msb, p1r_lsb;
p1r_msb = tvb_get_guint8(tvb, offset);
p1r_lsb = tvb_get_guint8(tvb, offset+1);
proto_tree_add_uint(tree, hf_sndcp_xid_V44_p1r_msb, tvb, offset, 1, p1r_msb);
proto_tree_add_uint(tree, hf_sndcp_xid_V44_p1r_lsb, tvb, offset+1, 1, p1r_lsb);
return 2U;
}
static guint16 parse_V44_p3t(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 p3t_msb, p3t_lsb;
p3t_msb = tvb_get_guint8(tvb, offset);
p3t_lsb = tvb_get_guint8(tvb, offset+1);
proto_tree_add_uint(tree, hf_sndcp_xid_V44_p3t_msb, tvb, offset, 1, p3t_msb);
proto_tree_add_uint(tree, hf_sndcp_xid_V44_p3t_lsb, tvb, offset+1, 1, p3t_lsb);
return 2U;
}
static guint16 parse_V44_p3r(tvbuff_t *tvb, proto_tree *tree, guint16 offset)
{
guint8 p3r_msb, p3r_lsb;
p3r_msb = tvb_get_guint8(tvb, offset);
p3r_lsb = tvb_get_guint8(tvb, offset+1);
proto_tree_add_uint(tree, hf_sndcp_xid_V44_p3r_msb, tvb, offset, 1, p3r_msb);
proto_tree_add_uint(tree, hf_sndcp_xid_V44_p3r_lsb, tvb, offset+1, 1, p3r_lsb);
return 2U;
}
/***************************************************/
/* Compression algorithms element dissector arrays */
/***************************************************/
static guint16 (*rfc1144_elem_fcn[])(tvbuff_t *, proto_tree *, guint16) = {
parse_applicable_nsapi,
parse_rfc1144_s0,
NULL
};
static guint16 (*rfc2507_elem_fcn[])(tvbuff_t *, proto_tree *, guint16) = {
parse_applicable_nsapi,
parse_rfc2507_f_max_period,
parse_rfc2507_f_max_time,
parse_rfc2507_max_header,
parse_rfc2507_tcp_space,
parse_rfc2507_non_tcp_space,
NULL
};
static guint16 (*rohc_elem_fcn[])(tvbuff_t *, proto_tree *, guint16) = {
parse_applicable_nsapi,
parse_rohc_max_cid,
parse_rohc_max_header,
parse_rohc_profile, /* Profile 1 */
parse_rohc_profile, /* Profile 2 */
parse_rohc_profile, /* Profile 3 */
parse_rohc_profile, /* Profile 4 */
parse_rohc_profile, /* Profile 5 */
parse_rohc_profile, /* Profile 6 */
parse_rohc_profile, /* Profile 7 */
parse_rohc_profile, /* Profile 8 */
parse_rohc_profile, /* Profile 9 */
parse_rohc_profile, /* Profile 10 */
parse_rohc_profile, /* Profile 11 */
parse_rohc_profile, /* Profile 12 */
parse_rohc_profile, /* Profile 13 */
parse_rohc_profile, /* Profile 14 */
parse_rohc_profile, /* Profile 15 */
parse_rohc_profile, /* Profile 16 */
NULL
};
/* Array containing the number of pcomp and the function array pointer */
static algo_parameters_t pcomp_algo_pars[] = {
{2, rfc1144_elem_fcn},
{5, rfc2507_elem_fcn},
{2, rohc_elem_fcn}
};
/* Data compression algorithms */
static guint16 (*v42bis_elem_fcn[])(tvbuff_t *, proto_tree *, guint16) = {
parse_applicable_nsapi,
parse_V42bis_p0,
parse_V42bis_p1,
parse_V42bis_p2,
NULL
};
static guint16 (*v44_elem_fcn[])(tvbuff_t *, proto_tree *, guint16) = {
parse_applicable_nsapi,
parse_V44_c0,
parse_V44_p0,
parse_V44_p1t,
parse_V44_p1r,
parse_V44_p3t,
parse_V44_p3r,
NULL
};
/* Array containing the number of dcomp and the function array pointer */
static algo_parameters_t dcomp_algo_pars[] = {
{1, v42bis_elem_fcn},
{2, v44_elem_fcn},
};
/* Code to actually dissect the packets
*/
static int
dissect_sndcp_xid(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
/* Set up structures needed to add the protocol subtree and manage it
*/
proto_item *ti, *dcomp_item;
proto_tree *sndcp_tree, *version_tree, *dcomp_tree, *pcomp_tree;
guint16 offset = 0, l3_param_len;
guint8 parameter_type, parameter_len;
/* create display subtree for the protocol
*/
ti = proto_tree_add_item(tree, proto_sndcp_xid, tvb, 0, -1, ENC_NA);
sndcp_tree = proto_item_add_subtree(ti, ett_sndcp_xid);
l3_param_len = tvb_reported_length(tvb);
while (offset < l3_param_len-1)
{
parameter_type = tvb_get_guint8(tvb, offset);
parameter_len = tvb_get_guint8(tvb, offset+1);
if (parameter_type == SNDCP_VERSION_PAR_TYPE)
{
guint8 value = tvb_get_guint8(tvb, offset+2);
version_tree = proto_tree_add_subtree_format(sndcp_tree, tvb, offset, parameter_len+2,
ett_sndcp_xid_version_field, NULL, "Version (SNDCP version number) - Value %d", value);
proto_tree_add_uint(version_tree, hf_sndcp_xid_type, tvb, offset,
1, parameter_type);
proto_tree_add_uint(version_tree, hf_sndcp_xid_len, tvb, offset+1,
1, parameter_len);
proto_tree_add_uint(version_tree, hf_sndcp_xid_value, tvb, offset+2,
1, value);
offset += 3;
}
else if (parameter_type == DATA_COMPRESSION_PAR_TYPE)
{
tvbuff_t * dcomp_tvb;
dcomp_tree = proto_tree_add_subtree(sndcp_tree, tvb, offset, parameter_len+2,
ett_sndcp_comp_field, &dcomp_item, "Data Compression");
proto_tree_add_uint(dcomp_tree, hf_sndcp_xid_type, tvb, offset,
1, parameter_type);
proto_tree_add_uint(dcomp_tree, hf_sndcp_xid_len, tvb, offset+1,
1, parameter_len);
offset += 2;
dcomp_tvb = tvb_new_subset_length(tvb, offset, parameter_len);
parse_compression_parameters(dcomp_tvb, dcomp_tree, TRUE);
offset += parameter_len;
}
else if (parameter_type == PROTOCOL_COMPRESSION_PAR_TYPE)
{
tvbuff_t * pcomp_tvb;
pcomp_tree = proto_tree_add_subtree(sndcp_tree, tvb, offset, parameter_len+2,
ett_sndcp_comp_field, NULL, "Protocol Control Information Compression");
proto_tree_add_uint(pcomp_tree, hf_sndcp_xid_type, tvb, offset,
1, parameter_type);
proto_tree_add_uint(pcomp_tree, hf_sndcp_xid_len, tvb, offset+1,
1, parameter_len);
offset += 2;
pcomp_tvb = tvb_new_subset_length(tvb, offset, parameter_len);
parse_compression_parameters(pcomp_tvb, pcomp_tree, FALSE);
offset += parameter_len;
}
else
{
break; /* error: exit */
}
}
return tvb_captured_length(tvb);
}
static void parse_compression_parameters(tvbuff_t *tvb, proto_tree *tree, gboolean dcomp)
{
guint8 entity, len, algo_id;
guint8 number_of_comp, i;
gboolean p_bit_set;
algo_parameters_t * algo_pars;
guint8 function_index;
proto_tree *comp_entity_tree = NULL;
guint16 tvb_len, offset=0 , new_offset, entity_offset;
value_string const * comp_algo_str;
tvb_len = tvb_reported_length(tvb);
if (tvb_len < 3) return; /* entity, algo and length bytes should always be present 6.5.1.1 and 6.6.1.1 */
/* Loop to decode each entity (cf Figure 10) */
while (offset < tvb_len)
{
/* Read the entity byte */
entity = tvb_get_guint8(tvb, offset);
p_bit_set = ((entity & 0x80) == 0x80) ? 1 : 0;
entity = entity & 0x1F;
/* P bit is set: means that algo identifier and dcomp are present */
if (p_bit_set)
{
/* Read the algorithm id. TODO: store the algo in a different variable for each different entity */
algo_id = tvb_get_guint8(tvb, offset+1) & 0x1F;
/* sanity check: check that the algo id that will be used inside the array has a valid range */
if (dcomp)
{
if(algo_id <= ALGO_V44)
{
algo_pars = dcomp_algo_pars;
dcomp_entity_algo_id[entity] = algo_id;
comp_algo_str = sndcp_xid_dcomp_algo_str;
}
else return;
}
else
{
if (algo_id <= ALGO_ROHC)
{
algo_pars = pcomp_algo_pars;
pcomp_entity_algo_id[entity] = algo_id;
comp_algo_str = sndcp_xid_pcomp_algo_str;
}
else return;
}
/* Read the length */
len = tvb_get_guint8(tvb, offset+2);
comp_entity_tree = proto_tree_add_subtree_format(tree, tvb, offset, len + 3,
ett_sndcp_comp_field, NULL, "Entity %d, Algorithm %s",
entity & 0x1F, val_to_str(algo_id & 0x1F, comp_algo_str,"Undefined Algorithm Identifier:%X"));
proto_tree_add_uint(comp_entity_tree, hf_sndcp_xid_comp_pbit, tvb, offset, 1, p_bit_set << 7);
proto_tree_add_uint(comp_entity_tree, hf_sndcp_xid_comp_spare_byte1, tvb, offset, 1, entity);
proto_tree_add_uint(comp_entity_tree, hf_sndcp_xid_comp_entity, tvb, offset, 1, entity);
proto_tree_add_uint(comp_entity_tree, hf_sndcp_xid_comp_spare_byte2, tvb, offset+1, 1, algo_id);
proto_tree_add_uint(comp_entity_tree, hf_sndcp_xid_comp_algo_id, tvb, offset+1, 1, algo_id);
proto_tree_add_uint(comp_entity_tree, hf_sndcp_xid_comp_len, tvb, offset+2, 1, len);
/* Read the dcomp/pcomp field */
offset += 3; /* entity_offset will be used as the offset from length byte */
number_of_comp = algo_pars[algo_id].nb_of_dcomp_pcomp;
for (i=0; i < (number_of_comp+1) / 2; i++)
{
guint8 byte;
byte = tvb_get_guint8(tvb, offset+i);
proto_tree_add_uint(comp_entity_tree, hf_sndcp_xid_comp[2*i], tvb, offset+i, 1, byte);
/* if there is an even number of dcomp/pcomp */
if (2*i+1 < number_of_comp)
{
proto_tree_add_uint(comp_entity_tree, hf_sndcp_xid_comp[2*i+1], tvb, offset+i, 1, byte);
}
/* else there is padding in the end */
else
{
proto_tree_add_uint(comp_entity_tree, hf_sndcp_xid_comp_spare, tvb, offset+i, 1, byte);
}
}
entity_offset = i;
function_index = 0;
/* Process the elements byte per byte */
while ((entity_offset < len) && (algo_pars[algo_id].func_array_ptr[function_index] != NULL))
{
new_offset = offset+entity_offset;
entity_offset += algo_pars[algo_id].func_array_ptr[function_index](tvb, comp_entity_tree, new_offset);
function_index++;
}
offset += entity_offset;
}
else /* P bit not set */
{
len = tvb_get_guint8(tvb, offset+1);
if (dcomp)
{
algo_pars = dcomp_algo_pars;
algo_id = dcomp_entity_algo_id[entity];
comp_algo_str = sndcp_xid_dcomp_algo_str;
}
else
{
algo_pars = pcomp_algo_pars;
algo_id = pcomp_entity_algo_id[entity];
comp_algo_str = sndcp_xid_pcomp_algo_str;
}
comp_entity_tree = proto_tree_add_subtree_format(tree, tvb, offset, len + 2,
ett_sndcp_comp_field, NULL, "Entity %d decoded as Algorithm %s",
entity & 0x1F, val_to_str(algo_id & 0x1F, comp_algo_str,"Undefined Algorithm Identifier:%X"));
proto_tree_add_uint(comp_entity_tree, hf_sndcp_xid_comp_pbit, tvb, offset, 1, p_bit_set << 7);
proto_tree_add_uint(comp_entity_tree, hf_sndcp_xid_comp_spare_byte1, tvb, offset, 1, entity);
proto_tree_add_uint(comp_entity_tree, hf_sndcp_xid_comp_entity, tvb, offset, 1, entity);
proto_tree_add_uint(comp_entity_tree, hf_sndcp_xid_comp_len, tvb, offset+2, 1, len);
offset += 2;
entity_offset = 0;
function_index = 0;
if (dcomp)
{
if (algo_id > ALGO_V44) return;
}
else
{
if (algo_id > ALGO_ROHC) return;
}
/* Process the elements byte per byte */
while ((entity_offset < len) && (algo_pars[algo_id].func_array_ptr[function_index] != NULL))
{
new_offset = offset+entity_offset;
entity_offset += algo_pars[algo_id].func_array_ptr[function_index](tvb, comp_entity_tree, new_offset);
function_index++;
}
offset += entity_offset;
}
}
/* Else if length is lower than 3, the packet is not correctly formatted */
}
/* Register the protocol with Wireshark
this format is required because a script is used to build the C function
that calls all the protocol registration.
*/
void
proto_register_sndcp_xid(void)
{
/* Setup list of header fields
*/
static hf_register_info hf[] = {
/* L3 XID Parameter Parsing Info */
{&hf_sndcp_xid_type,
{ "Parameter type","llcgprs.l3xidpartype", FT_UINT8, BASE_DEC, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_len,
{ "Length","llcgprs.l3xidparlen", FT_UINT8, BASE_DEC, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_value,
{ "Value","llcgprs.l3xidparvalue", FT_UINT8, BASE_DEC, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_comp_pbit,
{ "P bit","llcgprs.l3xiddcomppbit", FT_UINT8, BASE_DEC, NULL, 0x80, "Data", HFILL}},
{&hf_sndcp_xid_comp_spare_byte1,
{ "Spare","llcgprs.l3xidspare", FT_UINT8, BASE_HEX, NULL, 0x60, "Ignore", HFILL}},
{&hf_sndcp_xid_comp_entity,
{ "Entity","llcgprs.l3xidentity", FT_UINT8, BASE_DEC, NULL, 0x1F, "Data", HFILL}},
{&hf_sndcp_xid_comp_spare_byte2,
{ "Spare","llcgprs.l3xidspare", FT_UINT8, BASE_HEX, NULL, 0xE0, "Ignore", HFILL}},
{&hf_sndcp_xid_comp_algo_id,
{ "Algorithm identifier","llcgprs.l3xidalgoid", FT_UINT8, BASE_DEC, NULL, 0x1F, "Data", HFILL}},
{&hf_sndcp_xid_comp_len,
{ "Length","llcgprs.l3xidcomplen", FT_UINT8, BASE_DEC, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_comp[0],
{ "DCOMP1","llcgprs.l3xiddcomp", FT_UINT8, BASE_DEC, NULL, 0xF0, "Data", HFILL}},
{&hf_sndcp_xid_comp[1],
{ "DCOMP2","llcgprs.l3xiddcomp", FT_UINT8, BASE_DEC, NULL, 0x0F, "Data", HFILL}},
{&hf_sndcp_xid_comp[2],
{ "DCOMP3","llcgprs.l3xiddcomp", FT_UINT8, BASE_DEC, NULL, 0xF0, "Data", HFILL}},
{&hf_sndcp_xid_comp[3],
{ "DCOMP4","llcgprs.l3xiddcomp", FT_UINT8, BASE_DEC, NULL, 0x0F, "Data", HFILL}},
{&hf_sndcp_xid_comp[4],
{ "DCOMP5","llcgprs.l3xiddcomp", FT_UINT8, BASE_DEC, NULL, 0xF0, "Data", HFILL}},
{&hf_sndcp_xid_comp[5],
{ "DCOMP6","llcgprs.l3xiddcomp", FT_UINT8, BASE_DEC, NULL, 0x0F, "Data", HFILL}},
{&hf_sndcp_xid_comp[6],
{ "DCOMP7","llcgprs.l3xiddcomp", FT_UINT8, BASE_DEC, NULL, 0xF0, "Data", HFILL}},
{&hf_sndcp_xid_comp[7],
{ "DCOMP8","llcgprs.l3xiddcomp", FT_UINT8, BASE_DEC, NULL, 0x0F, "Data", HFILL}},
{&hf_sndcp_xid_comp[8],
{ "DCOMP9","llcgprs.l3xiddcomp", FT_UINT8, BASE_DEC, NULL, 0xF0, "Data", HFILL}},
{&hf_sndcp_xid_comp[9],
{ "DCOMP10","llcgprs.l3xiddcomp", FT_UINT8, BASE_DEC, NULL, 0x0F, "Data", HFILL}},
{&hf_sndcp_xid_comp[10],
{ "DCOMP11","llcgprs.l3xiddcomp", FT_UINT8, BASE_DEC, NULL, 0xF0, "Data", HFILL}},
{&hf_sndcp_xid_comp[11],
{ "DCOMP12","llcgprs.l3xiddcomp", FT_UINT8, BASE_DEC, NULL, 0x0F, "Data", HFILL}},
{&hf_sndcp_xid_comp[12],
{ "DCOMP13","llcgprs.l3xiddcomp", FT_UINT8, BASE_DEC, NULL, 0xF0, "Data", HFILL}},
{&hf_sndcp_xid_comp[13],
{ "DCOMP14","llcgprs.l3xiddcomp", FT_UINT8, BASE_DEC, NULL, 0x0F, "Data", HFILL}},
{&hf_sndcp_xid_comp[14],
{ "DCOMP15","llcgprs.l3xiddcomp", FT_UINT8, BASE_DEC, NULL, 0xF0, "Data", HFILL}},
{&hf_sndcp_xid_comp_spare,
{ "Spare","llcgprs.l3xidspare", FT_UINT8, BASE_HEX, NULL, 0x0F, "Ignore", HFILL}},
{&hf_element_applicable_nsapi_15,
{ "NSAPI 15","sndcpxid.nsapi15", FT_UINT8, BASE_DEC, NULL, 0x80, "Data", HFILL}},
{&hf_element_applicable_nsapi_14,
{ "NSAPI 14","sndcpxid.nsapi14", FT_UINT8, BASE_DEC, NULL, 0x40, "Data", HFILL}},
{&hf_element_applicable_nsapi_13,
{ "NSAPI 13","sndcpxid.nsapi13", FT_UINT8, BASE_DEC, NULL, 0x20, "Data", HFILL}},
{&hf_element_applicable_nsapi_12,
{ "NSAPI 12","sndcpxid.nsapi12", FT_UINT8, BASE_DEC, NULL, 0x10, "Data", HFILL}},
{&hf_element_applicable_nsapi_11,
{ "NSAPI 11","sndcpxid.nsapi11", FT_UINT8, BASE_DEC, NULL, 0x08, "Data", HFILL}},
{&hf_element_applicable_nsapi_10,
{ "NSAPI 10","sndcpxid.nsapi10", FT_UINT8, BASE_DEC, NULL, 0x04, "Data", HFILL}},
{&hf_element_applicable_nsapi_9,
{ "NSAPI 9","sndcpxid.nsapi9", FT_UINT8, BASE_DEC, NULL, 0x02, "Data", HFILL}},
{&hf_element_applicable_nsapi_8,
{ "NSAPI 8","sndcpxid.nsapi8", FT_UINT8, BASE_DEC, NULL, 0x01, "Data", HFILL}},
{&hf_element_applicable_nsapi_7,
{ "NSAPI 7","sndcpxid.nsapi7", FT_UINT8, BASE_DEC, NULL, 0x80, "Data", HFILL}},
{&hf_element_applicable_nsapi_6,
{ "NSAPI 6","sndcpxid.nsapi6", FT_UINT8, BASE_DEC, NULL, 0x40, "Data", HFILL}},
{&hf_element_applicable_nsapi_5,
{ "NSAPI 5","sndcpxid.nsapi5", FT_UINT8, BASE_DEC, NULL, 0x20, "Data", HFILL}},
{&hf_element_applicable_nsapi_spare,
{ "Spare","sndcpxid.spare", FT_UINT8, BASE_DEC, NULL, 0x1F, "Ignore", HFILL}},
{&hf_sndcp_xid_rfc1144_s0,
{ "S0 - 1","sndcpxid.rfc1144_s0", FT_UINT8, BASE_DEC, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_rfc2507_f_max_period_msb,
{ "F Max Period MSB","sndcpxid.rfc2507_f_max_period_msb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_rfc2507_f_max_period_lsb,
{ "F Max Period LSB","sndcpxid.rfc2507_f_max_period_lsb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_rfc2507_f_max_time,
{ "F Max Time","sndcpxid.rfc2507_f_max_time", FT_UINT8, BASE_DEC, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_rfc2507_max_header,
{ "Max Header","sndcpxid.rfc2507_max_header", FT_UINT8, BASE_DEC, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_rfc2507_tcp_space,
{ "TCP Space","sndcpxid.rfc2507_max_tcp_space", FT_UINT8, BASE_DEC, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_rfc2507_non_tcp_space_msb,
{ "TCP non space MSB","sndcpxid.rfc2507_max_non_tcp_space_msb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_rfc2507_non_tcp_space_lsb,
{ "TCP non space LSB","sndcpxid.rfc2507_max_non_tcp_space_lsb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_rohc_max_cid_spare,
{ "Spare","sndcpxid.rohc_max_cid_spare", FT_UINT8, BASE_DEC, NULL, 0xC0, "Ignore", HFILL}},
{&hf_sndcp_xid_rohc_max_cid_msb,
{ "Max CID MSB","sndcpxid.rohc_max_cid_msb", FT_UINT8, BASE_HEX, NULL, 0x3F, "Data", HFILL}},
{&hf_sndcp_xid_rohc_max_cid_lsb,
{ "Max CID LSB","sndcpxid.rohc_max_cid_lsb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_rohc_max_header,
{ "Max header","sndcpxid.rohc_max_header", FT_UINT8, BASE_DEC, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_rohc_profile_msb,
{ "Profile MSB","sndcpxid.rohc_profile_msb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_rohc_profile_lsb,
{ "Profile LSB","sndcpxid.rohc_profile_lsb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_V42bis_p0_spare,
{ "Spare","sndcpxid.V42bis_p0spare", FT_UINT8, BASE_DEC, NULL, 0xFC, "Ignore", HFILL}},
{&hf_sndcp_xid_V42bis_p0,
{ "P0","sndcpxid.V42bis_p0", FT_UINT8, BASE_HEX, NULL, 0x03, "Data", HFILL}},
{&hf_sndcp_xid_V42bis_p1_msb,
{ "P1 MSB","sndcpxid.V42bis_p1_msb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_V42bis_p1_lsb,
{ "P1 LSB","sndcpxid.V42bis_p1_lsb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_V42bis_p2,
{ "P2","sndcpxid.V42bis_p2", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_V44_c0_spare,
{ "P2","sndcpxid.V44_c0_spare", FT_UINT8, BASE_HEX, NULL, 0x3F, "Ignore", HFILL}},
{&hf_sndcp_xid_V44_c0,
{ "P2","sndcpxid.V44_c0", FT_UINT8, BASE_HEX, NULL, 0xC0, "Data", HFILL}},
{&hf_sndcp_xid_V44_p0_spare,
{ "Spare","sndcpxid.V44_p0spare", FT_UINT8, BASE_DEC, NULL, 0xFC, "Ignore", HFILL}},
{&hf_sndcp_xid_V44_p0,
{ "P0","sndcpxid.V44_p0", FT_UINT8, BASE_HEX, NULL, 0x03, "Data", HFILL}},
{&hf_sndcp_xid_V44_p1t_msb,
{ "P1t MSB","sndcpxid.V44_p1t_msb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_V44_p1t_lsb,
{ "P1t LSB","sndcpxid.V44_p1t_lsb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_V44_p1r_msb,
{ "P1r MSB","sndcpxid.V44_p1r_msb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_V44_p1r_lsb,
{ "P1r LSB","sndcpxid.V44_p1r_lsb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_V44_p3t_msb,
{ "P3t MSB","sndcpxid.V44_p3t_msb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_V44_p3t_lsb,
{ "P3t LSB","sndcpxid.V44_p3t_lsb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_V44_p3r_msb,
{ "P3r MSB","sndcpxid.V44_p3r_msb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
{&hf_sndcp_xid_V44_p3r_lsb,
{ "P3r LSB","sndcpxid.V44_p3r_lsb", FT_UINT8, BASE_HEX, NULL, 0x0, "Data", HFILL}},
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_sndcp_xid,
&ett_sndcp_xid_version_field,
&ett_sndcp_comp_field
};
/* Register the protocol name and description */
proto_sndcp_xid = proto_register_protocol("Subnetwork Dependent Convergence Protocol XID",
"SNDCP XID", "sndcpxid");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_sndcp_xid, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_dissector("sndcpxid", dissect_sndcp_xid, proto_sndcp_xid);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-sndcp.c
|
/* packet-sndcp.c
* Routines for Subnetwork Dependent Convergence Protocol (SNDCP) dissection
* Copyright 2000, Christian Falckenberg <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/reassemble.h>
/* Bitmasks for the bits in the address field
*/
#define MASK_X 0x80
#define MASK_F 0x40
#define MASK_T 0x20
#define MASK_M 0x10
void proto_register_sndcp(void);
void proto_reg_handoff_sndcp(void);
/* Initialize the protocol and registered fields
*/
static int proto_sndcp = -1;
static int hf_sndcp_x = -1;
static int hf_sndcp_f = -1;
static int hf_sndcp_t = -1;
static int hf_sndcp_m = -1;
static int hf_sndcp_nsapi = -1;
static int hf_sndcp_nsapib = -1;
static int hf_sndcp_dcomp = -1;
static int hf_sndcp_pcomp = -1;
static int hf_sndcp_segment = -1;
static int hf_sndcp_npdu1 = -1;
static int hf_sndcp_npdu2 = -1;
static int hf_sndcp_payload = -1;
/* These fields are used when reassembling N-PDU fragments
*/
static int hf_npdu_fragments = -1;
static int hf_npdu_fragment = -1;
static int hf_npdu_fragment_overlap = -1;
static int hf_npdu_fragment_overlap_conflict = -1;
static int hf_npdu_fragment_multiple_tails = -1;
static int hf_npdu_fragment_too_long_fragment = -1;
static int hf_npdu_fragment_error = -1;
static int hf_npdu_fragment_count = -1;
static int hf_npdu_reassembled_in = -1;
static int hf_npdu_reassembled_length = -1;
/* Initialize the subtree pointers
*/
static gint ett_sndcp = -1;
static gint ett_sndcp_address_field = -1;
static gint ett_sndcp_compression_field = -1;
static gint ett_sndcp_npdu_field = -1;
static gint ett_npdu_fragment = -1;
static gint ett_npdu_fragments = -1;
/* Structure needed for the fragmentation routines in reassemble.c
*/
static const fragment_items npdu_frag_items = {
&ett_npdu_fragment,
&ett_npdu_fragments,
&hf_npdu_fragments,
&hf_npdu_fragment,
&hf_npdu_fragment_overlap,
&hf_npdu_fragment_overlap_conflict,
&hf_npdu_fragment_multiple_tails,
&hf_npdu_fragment_too_long_fragment,
&hf_npdu_fragment_error,
&hf_npdu_fragment_count,
&hf_npdu_reassembled_in,
&hf_npdu_reassembled_length,
/* Reassembled data field */
NULL,
"fragments"
};
/* dissectors for the data portion of this protocol
*/
static dissector_handle_t ip_handle;
static dissector_handle_t sndcp_handle;
/* reassembly of N-PDU
*/
static reassembly_table npdu_reassembly_table;
/* value strings
*/
static const value_string nsapi_t[] = {
{ 0, "Escape mechanism for future extensions"},
{ 1, "Point-to-Multipoint (PTM-M) Information" },
{ 2, "Reserved for future use" },
{ 3, "Reserved for future use" },
{ 4, "Reserved for future use" },
{ 5, "Dynamically allocated"},
{ 6, "Dynamically allocated"},
{ 7, "Dynamically allocated"},
{ 8, "Dynamically allocated"},
{ 9, "Dynamically allocated"},
{ 10, "Dynamically allocated"},
{ 11, "Dynamically allocated"},
{ 12, "Dynamically allocated"},
{ 13, "Dynamically allocated"},
{ 14, "Dynamically allocated"},
{ 15, "Dynamically allocated"},
{ 0, NULL },
};
static const value_string nsapi_abrv[] = {
{ 0, "0"},
{ 1, "PTM-M" },
{ 2, "2" },
{ 3, "3"},
{ 4, "4" },
{ 5, "DYN5" },
{ 6, "DYN6" },
{ 7, "DYN7" },
{ 8, "DYN8" },
{ 9, "DYN9" },
{ 10, "DYN10" },
{ 11, "DYN11" },
{ 12, "DYN12" },
{ 13, "DYN13" },
{ 14, "DYN14" },
{ 15, "DYN15" },
{ 0, NULL },
};
static const value_string compression_vals[] = {
{ 0, "No compression"},
{ 1, "Pointer to selected protocol/data compression mechanism" },
{ 2, "Pointer to selected protocol/data compression mechanism" },
{ 3, "Pointer to selected protocol/data compression mechanism" },
{ 4, "Pointer to selected protocol/data compression mechanism" },
{ 5, "Pointer to selected protocol/data compression mechanism" },
{ 6, "Pointer to selected protocol/data compression mechanism" },
{ 7, "Pointer to selected protocol/data compression mechanism" },
{ 8, "Pointer to selected protocol/data compression mechanism" },
{ 9, "Pointer to selected protocol/data compression mechanism" },
{ 10, "Pointer to selected protocol/data compression mechanism" },
{ 11, "Pointer to selected protocol/data compression mechanism" },
{ 12, "Pointer to selected protocol/data compression mechanism" },
{ 13, "Pointer to selected protocol/data compression mechanism" },
{ 14, "Pointer to selected protocol/data compression mechanism" },
{ 15, "Pointer to selected protocol/data compression mechanism" },
{ 0, NULL },
};
static const true_false_string x_bit = {
"Invalid",
"Set to 0 by transmitting SNDCP entity (ignored by receiver)"
};
static const true_false_string f_bit = {
"This SN-PDU is the first segment of an N-PDU",
"This SN-PDU is not the first segment of an N-PDU"
};
static const true_false_string t_bit = {
"SN-UNITDATA PDU",
"SN-DATA PDU"
};
static const true_false_string m_bit = {
"Not the last segment of N-PDU, more segments to follow",
"Last segment of N-PDU"
};
/* Code to actually dissect the packets
*/
static int
dissect_sndcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
guint8 addr_field, comp_field, npdu_field1, dcomp=0, pcomp=0;
guint16 offset=0, npdu=0, segment=0, npdu_field2;
tvbuff_t *next_tvb, *npdu_tvb;
gint len;
gboolean first, more_frags, unack;
static int * const addr_fields[] = {
&hf_sndcp_x,
&hf_sndcp_f,
&hf_sndcp_t,
&hf_sndcp_m,
&hf_sndcp_nsapib,
NULL
};
/* Set up structures needed to add the protocol subtree and manage it
*/
proto_item *ti;
proto_tree *sndcp_tree, *compression_field_tree, *npdu_field_tree;
/* Make entries in Protocol column and clear Info column on summary display
*/
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SNDCP");
col_clear(pinfo->cinfo, COL_INFO);
/* create display subtree for the protocol
*/
ti = proto_tree_add_item(tree, proto_sndcp, tvb, 0, -1, ENC_NA);
sndcp_tree = proto_item_add_subtree(ti, ett_sndcp);
/* get address field from next byte
*/
addr_field = tvb_get_guint8(tvb,offset);
first = addr_field & MASK_F;
more_frags = addr_field & MASK_M;
unack = addr_field & MASK_T;
/* add subtree for the address field
*/
proto_tree_add_bitmask_with_flags(sndcp_tree, tvb, offset, hf_sndcp_nsapi,
ett_sndcp_address_field, addr_fields, ENC_NA, BMT_NO_APPEND);
offset++;
/* get compression pointers from next byte if this is the first segment
*/
if (first) {
comp_field = tvb_get_guint8(tvb,offset);
dcomp = comp_field & 0xF0;
pcomp = comp_field & 0x0F;
/* add subtree for the compression field
*/
if (tree) {
if (!pcomp) {
if (!dcomp) {
compression_field_tree = proto_tree_add_subtree(sndcp_tree, tvb, offset, 1, ett_sndcp_compression_field, NULL, "No compression");
}
else {
compression_field_tree = proto_tree_add_subtree(sndcp_tree, tvb, offset, 1, ett_sndcp_compression_field, NULL, "Data compression");
}
}
else {
if (!dcomp) {
compression_field_tree = proto_tree_add_subtree(sndcp_tree, tvb, offset, 1, ett_sndcp_compression_field, NULL, "Protocol compression");
}
else {
compression_field_tree = proto_tree_add_subtree(sndcp_tree, tvb, offset, 1, ett_sndcp_compression_field, NULL, "Data and Protocol compression");
}
}
proto_tree_add_uint(compression_field_tree, hf_sndcp_dcomp, tvb, offset, 1, comp_field );
proto_tree_add_uint(compression_field_tree, hf_sndcp_pcomp, tvb, offset, 1, comp_field );
}
offset++;
/* get N-PDU number from next byte for acknowledged mode (only for first segment)
*/
if (!unack) {
npdu = npdu_field1 = tvb_get_guint8(tvb,offset);
col_add_fstr(pinfo->cinfo, COL_INFO, "SN-DATA N-PDU %d", npdu_field1);
if (tree) {
npdu_field_tree = proto_tree_add_subtree_format(sndcp_tree, tvb, offset, 1, ett_sndcp_npdu_field, NULL, "Acknowledged mode, N-PDU %d", npdu_field1 );
proto_tree_add_uint(npdu_field_tree, hf_sndcp_npdu1, tvb, offset, 1, npdu_field1 );
}
offset++;
}
}
/* get segment and N-PDU number from next two bytes for unacknowledged mode
*/
if (unack) {
npdu_field2 = tvb_get_ntohs(tvb, offset);
segment = (npdu_field2 & 0xF000) >> 12;
npdu = (npdu_field2 & 0x0FFF);
col_add_fstr(pinfo->cinfo, COL_INFO, "SN-UNITDATA N-PDU %d (segment %d)", npdu, segment);
if (tree) {
npdu_field_tree = proto_tree_add_subtree_format(sndcp_tree, tvb, offset, 2, ett_sndcp_npdu_field, NULL,
"Unacknowledged mode, N-PDU %d (segment %d)", npdu, segment );
proto_tree_add_uint(npdu_field_tree, hf_sndcp_segment, tvb, offset, 2, npdu_field2 );
proto_tree_add_uint(npdu_field_tree, hf_sndcp_npdu2, tvb, offset, 2, npdu_field2 );
}
offset += 2;
}
/* handle N-PDU data, reassemble if necessary
*/
if (first && !more_frags) {
next_tvb = tvb_new_subset_remaining (tvb, offset);
if (!dcomp && !pcomp) {
call_dissector(ip_handle, next_tvb, pinfo, tree);
}
else {
call_data_dissector(next_tvb, pinfo, tree);
}
}
else {
/* Try reassembling fragments
*/
fragment_head *fd_npdu = NULL;
guint32 reassembled_in = 0;
gboolean save_fragmented = pinfo->fragmented;
len = tvb_captured_length_remaining(tvb, offset);
if(len<=0){
return offset;
}
pinfo->fragmented = TRUE;
if (unack)
fd_npdu = fragment_add_seq_check(&npdu_reassembly_table, tvb, offset,
pinfo, npdu, NULL, segment, len, more_frags);
else
fd_npdu = fragment_add(&npdu_reassembly_table, tvb, offset, pinfo, npdu, NULL,
offset, len, more_frags);
npdu_tvb = process_reassembled_data(tvb, offset, pinfo,
"Reassembled N-PDU", fd_npdu, &npdu_frag_items,
NULL, sndcp_tree);
if (fd_npdu) {
/* Reassembled
*/
reassembled_in = fd_npdu->reassembled_in;
if (pinfo->num == reassembled_in) {
/* Reassembled in this very packet:
* We can safely hand the tvb to the IP dissector
*/
call_dissector(ip_handle, npdu_tvb, pinfo, tree);
}
else {
/* Not reassembled in this packet
*/
col_append_fstr(pinfo->cinfo, COL_INFO,
" (N-PDU payload reassembled in packet %u)",
fd_npdu->reassembled_in);
proto_tree_add_item(sndcp_tree, hf_sndcp_payload, tvb, offset, -1, ENC_NA);
}
} else {
/* Not reassembled yet, or not reassembled at all
*/
if (unack)
col_append_fstr(pinfo->cinfo, COL_INFO, " (Unreassembled fragment %u)", segment);
else
col_append_str(pinfo->cinfo, COL_INFO, " (Unreassembled fragment)");
proto_tree_add_item(sndcp_tree, hf_sndcp_payload, tvb, offset, -1, ENC_NA);
}
/* Now reset fragmentation information in pinfo
*/
pinfo->fragmented = save_fragmented;
}
return tvb_captured_length(tvb);
}
/* Register the protocol with Wireshark
this format is required because a script is used to build the C function
that calls all the protocol registration.
*/
void
proto_register_sndcp(void)
{
/* Setup list of header fields
*/
static hf_register_info hf[] = {
{ &hf_sndcp_nsapi,
{ "Address field NSAPI",
"sndcp.nsapi",
FT_UINT8, BASE_DEC, VALS(nsapi_abrv), 0x0,
"Network Layer Service Access Point Identifier", HFILL
}
},
{ &hf_sndcp_x,
{ "Spare bit",
"sndcp.x",
FT_BOOLEAN,8, TFS(&x_bit), MASK_X,
"Spare bit (should be 0)", HFILL
}
},
{ &hf_sndcp_f,
{ "First segment indicator bit",
"sndcp.f",
FT_BOOLEAN,8, TFS(&f_bit), MASK_F,
NULL, HFILL
}
},
{ &hf_sndcp_t,
{ "Type",
"sndcp.t",
FT_BOOLEAN,8, TFS(&t_bit), MASK_T,
"SN-PDU Type", HFILL
}
},
{ &hf_sndcp_m,
{ "More bit",
"sndcp.m",
FT_BOOLEAN,8, TFS(&m_bit), MASK_M,
NULL, HFILL
}
},
{ &hf_sndcp_dcomp,
{ "DCOMP",
"sndcp.dcomp",
FT_UINT8, BASE_DEC, VALS(compression_vals), 0xF0,
"Data compression coding", HFILL
}
},
{ &hf_sndcp_pcomp,
{ "PCOMP",
"sndcp.pcomp",
FT_UINT8, BASE_DEC, VALS(compression_vals), 0x0F,
"Protocol compression coding", HFILL
}
},
{ &hf_sndcp_nsapib,
{ "NSAPI",
"sndcp.nsapib",
FT_UINT8, BASE_DEC , VALS(nsapi_t), 0xf,
"Network Layer Service Access Point Identifier",HFILL
}
},
{ &hf_sndcp_segment,
{ "Segment",
"sndcp.segment",
FT_UINT16, BASE_DEC, NULL, 0xF000,
"Segment number", HFILL
}
},
{ &hf_sndcp_npdu1,
{ "N-PDU",
"sndcp.npdu",
FT_UINT8, BASE_DEC, NULL, 0,
NULL, HFILL
}
},
{ &hf_sndcp_npdu2,
{ "N-PDU",
"sndcp.npdu",
FT_UINT16, BASE_DEC, NULL, 0x0FFF,
NULL, HFILL
}
},
{ &hf_sndcp_payload,
{ "Payload",
"sndcp.payload",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL
}
},
/* Fragment fields
*/
{ &hf_npdu_fragment_overlap,
{ "Fragment overlap",
"sndcp.npdu.fragment.overlap",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"Fragment overlaps with other fragments", HFILL
}
},
{ &hf_npdu_fragment_overlap_conflict,
{ "Conflicting data in fragment overlap",
"sndcp.npdu.fragment.overlap.conflict",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"Overlapping fragments contained conflicting data", HFILL
}
},
{ &hf_npdu_fragment_multiple_tails,
{ "Multiple tail fragments found",
"sndcp.npdu.fragment.multipletails",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"Several tails were found when defragmenting the packet", HFILL
}
},
{ &hf_npdu_fragment_too_long_fragment,
{ "Fragment too long",
"sndcp.npdu.fragment.toolongfragment",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"Fragment contained data past end of packet", HFILL
}
},
{ &hf_npdu_fragment_error,
{ "Defragmentation error",
"sndcp.npdu.fragment.error",
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
"Defragmentation error due to illegal fragments", HFILL
}
},
{ &hf_npdu_fragment_count,
{ "Fragment count",
"sndcp.npdu.fragment.count",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL
}
},
{ &hf_npdu_reassembled_in,
{ "Reassembled in",
"sndcp.npdu.reassembled.in",
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
"N-PDU fragments are reassembled in the given packet", HFILL
}
},
{ &hf_npdu_reassembled_length,
{ "Reassembled N-PDU length",
"sndcp.npdu.reassembled.length",
FT_UINT32, BASE_DEC, NULL, 0x0,
"The total length of the reassembled payload", HFILL
}
},
{ &hf_npdu_fragment,
{ "N-PDU Fragment",
"sndcp.npdu.fragment",
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
NULL, HFILL
}
},
{ &hf_npdu_fragments,
{ "N-PDU Fragments",
"sndcp.npdu.fragments",
FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL
}
},
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_sndcp ,
&ett_sndcp_address_field,
&ett_sndcp_compression_field,
&ett_sndcp_npdu_field,
&ett_npdu_fragment,
&ett_npdu_fragments,
};
/* Register the protocol name and description */
proto_sndcp = proto_register_protocol("Subnetwork Dependent Convergence Protocol",
"SNDCP", "sndcp");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_sndcp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
sndcp_handle = register_dissector("sndcp", dissect_sndcp, proto_sndcp);
reassembly_table_register(&npdu_reassembly_table, &addresses_reassembly_table_functions);
}
/* If this dissector uses sub-dissector registration add a registration routine.
This format is required because a script is used to find these routines and
create the code that calls these routines.
*/
void
proto_reg_handoff_sndcp(void)
{
/* Register SNDCP dissector with LLC layer for SAPI 3,5,9 and 11
*/
dissector_add_uint("llcgprs.sapi", 3, sndcp_handle);
dissector_add_uint("llcgprs.sapi", 5, sndcp_handle);
dissector_add_uint("llcgprs.sapi", 9, sndcp_handle);
dissector_add_uint("llcgprs.sapi", 11, sndcp_handle);
/* Find IP and data handle for upper layer dissectors
*/
ip_handle = find_dissector_add_dependency("ip", proto_sndcp);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|
C
|
wireshark/epan/dissectors/packet-snmp.c
|
/* Do not modify this file. Changes will be overwritten. */
/* Generated automatically by the ASN.1 to Wireshark dissector compiler */
/* packet-snmp.c */
/* asn2wrs.py -b -L -p snmp -c ./snmp.cnf -s ./packet-snmp-template -D . -O ../.. snmp.asn */
/* packet-snmp.c
* Routines for SNMP (simple network management protocol)
* Copyright (C) 1998 Didier Jorand
*
* See RFC 1157 for SNMPv1.
*
* See RFCs 1901, 1905, and 1906 for SNMPv2c.
*
* See RFCs 1905, 1906, 1909, and 1910 for SNMPv2u [historic].
*
* See RFCs 2570-2576 for SNMPv3
* Updated to use the asn2wrs compiler made by Tomas Kukosa
* Copyright (C) 2005 - 2006 Anders Broman [AT] ericsson.com
*
* See RFC 3414 for User-based Security Model for SNMPv3
* See RFC 3826 for (AES) Cipher Algorithm in the SNMP USM
* See RFC 2578 for Structure of Management Information Version 2 (SMIv2)
* Copyright (C) 2007 Luis E. Garcia Ontanon <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Some stuff from:
*
* GXSNMP -- An snmp mangament application
* Copyright (C) 1998 Gregory McLean & Jochen Friedrich
* Beholder RMON ethernet network monitor,Copyright (C) 1993 DNPAP group
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#if 0
#include <stdio.h>
#define D(args) do {printf args; fflush(stdout); } while(0)
#endif
#include "config.h"
#include <epan/packet.h>
#include <epan/strutil.h>
#include <epan/conversation.h>
#include <epan/etypes.h>
#include <epan/prefs.h>
#include <epan/addr_resolv.h>
#include <epan/next_tvb.h>
#include <epan/uat.h>
#include <epan/asn1.h>
#include <epan/expert.h>
#include <epan/oids.h>
#include <epan/srt_table.h>
#include <epan/tap.h>
#include "packet-ipx.h"
#include "packet-hpext.h"
#include "packet-ber.h"
#include "packet-snmp.h"
#include <wsutil/wsgcrypt.h>
#define PNAME "Simple Network Management Protocol"
#define PSNAME "SNMP"
#define PFNAME "snmp"
#define UDP_PORT_SNMP 161
#define UDP_PORT_SNMP_TRAP 162
#define TCP_PORT_SNMP 161
#define TCP_PORT_SNMP_TRAP 162
#define TCP_PORT_SMUX 199
#define UDP_PORT_SNMP_PATROL 8161
#define SNMP_NUM_PROCEDURES 8
/* Initialize the protocol and registered fields */
static int snmp_tap = -1;
static int proto_snmp = -1;
static int proto_smux = -1;
static gboolean display_oid = TRUE;
static gboolean snmp_var_in_tree = TRUE;
void proto_register_snmp(void);
void proto_reg_handoff_snmp(void);
void proto_register_smux(void);
void proto_reg_handoff_smux(void);
static void snmp_usm_password_to_key(const snmp_usm_auth_model_t model, const guint8 *password, guint passwordlen,
const guint8 *engineID, guint engineLength, guint8 *key);
static tvbuff_t* snmp_usm_priv_des(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, gchar const**);
static tvbuff_t* snmp_usm_priv_aes128(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, gchar const**);
static tvbuff_t* snmp_usm_priv_aes192(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, gchar const**);
static tvbuff_t* snmp_usm_priv_aes256(snmp_usm_params_t*, tvbuff_t*, packet_info *pinfo, gchar const**);
static bool snmp_usm_auth(const packet_info *pinfo, const snmp_usm_auth_model_t model, snmp_usm_params_t* p, guint8**, guint*, gchar const**);
static const value_string auth_types[] = {
{SNMP_USM_AUTH_MD5,"MD5"},
{SNMP_USM_AUTH_SHA1,"SHA1"},
{SNMP_USM_AUTH_SHA2_224,"SHA2-224"},
{SNMP_USM_AUTH_SHA2_256,"SHA2-256"},
{SNMP_USM_AUTH_SHA2_384,"SHA2-384"},
{SNMP_USM_AUTH_SHA2_512,"SHA2-512"},
{0,NULL}
};
static const guint auth_hash_len[] = {
HASH_MD5_LENGTH,
HASH_SHA1_LENGTH,
HASH_SHA2_224_LENGTH,
HASH_SHA2_256_LENGTH,
HASH_SHA2_384_LENGTH,
HASH_SHA2_512_LENGTH
};
static const guint auth_tag_len[] = {
12,
12,
16,
24,
32,
48
};
static const enum gcry_md_algos auth_hash_algo[] = {
GCRY_MD_MD5,
GCRY_MD_SHA1,
GCRY_MD_SHA224,
GCRY_MD_SHA256,
GCRY_MD_SHA384,
GCRY_MD_SHA512
};
#define PRIV_DES 0
#define PRIV_AES128 1
#define PRIV_AES192 2
#define PRIV_AES256 3
static const value_string priv_types[] = {
{ PRIV_DES, "DES" },
{ PRIV_AES128, "AES" },
{ PRIV_AES192, "AES192" },
{ PRIV_AES256, "AES256" },
{ 0, NULL}
};
static snmp_usm_decoder_t priv_protos[] = {
snmp_usm_priv_des,
snmp_usm_priv_aes128,
snmp_usm_priv_aes192,
snmp_usm_priv_aes256
};
static snmp_ue_assoc_t* ueas = NULL;
static guint num_ueas = 0;
static snmp_ue_assoc_t* localized_ues = NULL;
static snmp_ue_assoc_t* unlocalized_ues = NULL;
/****/
/* Variables used for handling enterprise specific trap types */
typedef struct _snmp_st_assoc_t {
char *enterprise;
guint trap;
char *desc;
} snmp_st_assoc_t;
static guint num_specific_traps = 0;
static snmp_st_assoc_t *specific_traps = NULL;
static const char *enterprise_oid = NULL;
static guint generic_trap = 0;
static guint32 snmp_version = 0;
static guint32 RequestID = -1;
static snmp_usm_params_t usm_p = {FALSE,FALSE,0,0,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,FALSE};
#define TH_AUTH 0x01
#define TH_CRYPT 0x02
#define TH_REPORT 0x04
/* desegmentation of SNMP-over-TCP */
static gboolean snmp_desegment = TRUE;
/* Global variables */
guint32 MsgSecurityModel;
tvbuff_t *oid_tvb=NULL;
tvbuff_t *value_tvb=NULL;
static dissector_handle_t snmp_handle;
static dissector_handle_t snmp_tcp_handle;
static dissector_handle_t data_handle;
static dissector_handle_t smux_handle;
static next_tvb_list_t *var_list;
static int hf_snmp_response_in = -1;
static int hf_snmp_response_to = -1;
static int hf_snmp_time = -1;
static int hf_snmp_v3_flags_auth = -1;
static int hf_snmp_v3_flags_crypt = -1;
static int hf_snmp_v3_flags_report = -1;
static int hf_snmp_engineid_conform = -1;
static int hf_snmp_engineid_enterprise = -1;
static int hf_snmp_engineid_format = -1;
static int hf_snmp_engineid_ipv4 = -1;
static int hf_snmp_engineid_ipv6 = -1;
static int hf_snmp_engineid_cisco_type = -1;
static int hf_snmp_engineid_mac = -1;
static int hf_snmp_engineid_text = -1;
static int hf_snmp_engineid_time = -1;
static int hf_snmp_engineid_data = -1;
static int hf_snmp_decryptedPDU = -1;
static int hf_snmp_msgAuthentication = -1;
static int hf_snmp_noSuchObject = -1;
static int hf_snmp_noSuchInstance = -1;
static int hf_snmp_endOfMibView = -1;
static int hf_snmp_unSpecified = -1;
static int hf_snmp_integer32_value = -1;
static int hf_snmp_octetstring_value = -1;
static int hf_snmp_oid_value = -1;
static int hf_snmp_null_value = -1;
static int hf_snmp_ipv4_value = -1;
static int hf_snmp_ipv6_value = -1;
static int hf_snmp_anyaddress_value = -1;
static int hf_snmp_unsigned32_value = -1;
static int hf_snmp_unknown_value = -1;
static int hf_snmp_opaque_value = -1;
static int hf_snmp_nsap_value = -1;
static int hf_snmp_counter_value = -1;
static int hf_snmp_timeticks_value = -1;
static int hf_snmp_big_counter_value = -1;
static int hf_snmp_gauge32_value = -1;
static int hf_snmp_objectname = -1;
static int hf_snmp_scalar_instance_index = -1;
static int hf_snmp_var_bind_str = -1;
static int hf_snmp_agentid_trailer = -1;
static int hf_snmp_SMUX_PDUs_PDU = -1; /* SMUX_PDUs */
static int hf_snmp_version = -1; /* Version */
static int hf_snmp_community = -1; /* Community */
static int hf_snmp_data = -1; /* PDUs */
static int hf_snmp_parameters = -1; /* OCTET_STRING */
static int hf_snmp_datav2u = -1; /* T_datav2u */
static int hf_snmp_v2u_plaintext = -1; /* PDUs */
static int hf_snmp_encrypted = -1; /* OCTET_STRING */
static int hf_snmp_msgAuthoritativeEngineID = -1; /* T_msgAuthoritativeEngineID */
static int hf_snmp_msgAuthoritativeEngineBoots = -1; /* T_msgAuthoritativeEngineBoots */
static int hf_snmp_msgAuthoritativeEngineTime = -1; /* T_msgAuthoritativeEngineTime */
static int hf_snmp_msgUserName = -1; /* T_msgUserName */
static int hf_snmp_msgAuthenticationParameters = -1; /* T_msgAuthenticationParameters */
static int hf_snmp_msgPrivacyParameters = -1; /* T_msgPrivacyParameters */
static int hf_snmp_msgVersion = -1; /* Version */
static int hf_snmp_msgGlobalData = -1; /* HeaderData */
static int hf_snmp_msgSecurityParameters = -1; /* T_msgSecurityParameters */
static int hf_snmp_msgData = -1; /* ScopedPduData */
static int hf_snmp_msgID = -1; /* INTEGER_0_2147483647 */
static int hf_snmp_msgMaxSize = -1; /* INTEGER_484_2147483647 */
static int hf_snmp_msgFlags = -1; /* T_msgFlags */
static int hf_snmp_msgSecurityModel = -1; /* T_msgSecurityModel */
static int hf_snmp_plaintext = -1; /* ScopedPDU */
static int hf_snmp_encryptedPDU = -1; /* T_encryptedPDU */
static int hf_snmp_contextEngineID = -1; /* SnmpEngineID */
static int hf_snmp_contextName = -1; /* OCTET_STRING */
static int hf_snmp_get_request = -1; /* GetRequest_PDU */
static int hf_snmp_get_next_request = -1; /* GetNextRequest_PDU */
static int hf_snmp_get_response = -1; /* GetResponse_PDU */
static int hf_snmp_set_request = -1; /* SetRequest_PDU */
static int hf_snmp_trap = -1; /* Trap_PDU */
static int hf_snmp_getBulkRequest = -1; /* GetBulkRequest_PDU */
static int hf_snmp_informRequest = -1; /* InformRequest_PDU */
static int hf_snmp_snmpV2_trap = -1; /* SNMPv2_Trap_PDU */
static int hf_snmp_report = -1; /* Report_PDU */
static int hf_snmp_request_id = -1; /* T_request_id */
static int hf_snmp_error_status = -1; /* T_error_status */
static int hf_snmp_error_index = -1; /* INTEGER */
static int hf_snmp_variable_bindings = -1; /* VarBindList */
static int hf_snmp_bulkPDU_request_id = -1; /* Integer32 */
static int hf_snmp_non_repeaters = -1; /* INTEGER_0_2147483647 */
static int hf_snmp_max_repetitions = -1; /* INTEGER_0_2147483647 */
static int hf_snmp_enterprise = -1; /* EnterpriseOID */
static int hf_snmp_agent_addr = -1; /* NetworkAddress */
static int hf_snmp_generic_trap = -1; /* GenericTrap */
static int hf_snmp_specific_trap = -1; /* SpecificTrap */
static int hf_snmp_time_stamp = -1; /* TimeTicks */
static int hf_snmp_name = -1; /* ObjectName */
static int hf_snmp_valueType = -1; /* ValueType */
static int hf_snmp_VarBindList_item = -1; /* VarBind */
static int hf_snmp_open = -1; /* OpenPDU */
static int hf_snmp_close = -1; /* ClosePDU */
static int hf_snmp_registerRequest = -1; /* RReqPDU */
static int hf_snmp_registerResponse = -1; /* RegisterResponse */
static int hf_snmp_commitOrRollback = -1; /* SOutPDU */
static int hf_snmp_rRspPDU = -1; /* RRspPDU */
static int hf_snmp_pDUs = -1; /* PDUs */
static int hf_snmp_smux_simple = -1; /* SimpleOpen */
static int hf_snmp_smux_version = -1; /* T_smux_version */
static int hf_snmp_identity = -1; /* OBJECT_IDENTIFIER */
static int hf_snmp_description = -1; /* DisplayString */
static int hf_snmp_password = -1; /* OCTET_STRING */
static int hf_snmp_subtree = -1; /* ObjectName */
static int hf_snmp_priority = -1; /* INTEGER_M1_2147483647 */
static int hf_snmp_operation = -1; /* T_operation */
/* Initialize the subtree pointers */
static gint ett_smux = -1;
static gint ett_snmp = -1;
static gint ett_engineid = -1;
static gint ett_msgFlags = -1;
static gint ett_encryptedPDU = -1;
static gint ett_decrypted = -1;
static gint ett_authParameters = -1;
static gint ett_internet = -1;
static gint ett_varbind = -1;
static gint ett_name = -1;
static gint ett_value = -1;
static gint ett_decoding_error = -1;
static gint ett_snmp_Message = -1;
static gint ett_snmp_Messagev2u = -1;
static gint ett_snmp_T_datav2u = -1;
static gint ett_snmp_UsmSecurityParameters = -1;
static gint ett_snmp_SNMPv3Message = -1;
static gint ett_snmp_HeaderData = -1;
static gint ett_snmp_ScopedPduData = -1;
static gint ett_snmp_ScopedPDU = -1;
static gint ett_snmp_PDUs = -1;
static gint ett_snmp_PDU = -1;
static gint ett_snmp_BulkPDU = -1;
static gint ett_snmp_Trap_PDU_U = -1;
static gint ett_snmp_VarBind = -1;
static gint ett_snmp_VarBindList = -1;
static gint ett_snmp_SMUX_PDUs = -1;
static gint ett_snmp_RegisterResponse = -1;
static gint ett_snmp_OpenPDU = -1;
static gint ett_snmp_SimpleOpen_U = -1;
static gint ett_snmp_RReqPDU_U = -1;
static expert_field ei_snmp_failed_decrypted_data_pdu = EI_INIT;
static expert_field ei_snmp_decrypted_data_bad_formatted = EI_INIT;
static expert_field ei_snmp_verify_authentication_error = EI_INIT;
static expert_field ei_snmp_authentication_ok = EI_INIT;
static expert_field ei_snmp_authentication_error = EI_INIT;
static expert_field ei_snmp_varbind_not_uni_class_seq = EI_INIT;
static expert_field ei_snmp_varbind_has_indicator = EI_INIT;
static expert_field ei_snmp_objectname_not_oid = EI_INIT;
static expert_field ei_snmp_objectname_has_indicator = EI_INIT;
static expert_field ei_snmp_value_not_primitive_encoding = EI_INIT;
static expert_field ei_snmp_invalid_oid = EI_INIT;
static expert_field ei_snmp_varbind_wrong_tag = EI_INIT;
static expert_field ei_snmp_varbind_response = EI_INIT;
static expert_field ei_snmp_no_instance_subid = EI_INIT;
static expert_field ei_snmp_wrong_num_of_subids = EI_INIT;
static expert_field ei_snmp_index_suboid_too_short = EI_INIT;
static expert_field ei_snmp_unimplemented_instance_index = EI_INIT;
static expert_field ei_snmp_index_suboid_len0 = EI_INIT;
static expert_field ei_snmp_index_suboid_too_long = EI_INIT;
static expert_field ei_snmp_index_string_too_long = EI_INIT;
static expert_field ei_snmp_column_parent_not_row = EI_INIT;
static expert_field ei_snmp_uint_too_large = EI_INIT;
static expert_field ei_snmp_int_too_large = EI_INIT;
static expert_field ei_snmp_integral_value0 = EI_INIT;
static expert_field ei_snmp_missing_mib = EI_INIT;
static expert_field ei_snmp_varbind_wrong_length_value = EI_INIT;
static expert_field ei_snmp_varbind_wrong_class_tag = EI_INIT;
static expert_field ei_snmp_rfc1910_non_conformant = EI_INIT;
static expert_field ei_snmp_rfc3411_non_conformant = EI_INIT;
static expert_field ei_snmp_version_unknown = EI_INIT;
static expert_field ei_snmp_trap_pdu_obsolete = EI_INIT;
static const true_false_string auth_flags = {
"OK",
"Failed"
};
/* Security Models */
#define SNMP_SEC_ANY 0
#define SNMP_SEC_V1 1
#define SNMP_SEC_V2C 2
#define SNMP_SEC_USM 3
static const value_string sec_models[] = {
{ SNMP_SEC_ANY, "Any" },
{ SNMP_SEC_V1, "V1" },
{ SNMP_SEC_V2C, "V2C" },
{ SNMP_SEC_USM, "USM" },
{ 0, NULL }
};
#if 0
/* SMUX PDU types */
#define SMUX_MSG_OPEN 0
#define SMUX_MSG_CLOSE 1
#define SMUX_MSG_RREQ 2
#define SMUX_MSG_RRSP 3
#define SMUX_MSG_SOUT 4
static const value_string smux_types[] = {
{ SMUX_MSG_OPEN, "Open" },
{ SMUX_MSG_CLOSE, "Close" },
{ SMUX_MSG_RREQ, "Registration Request" },
{ SMUX_MSG_RRSP, "Registration Response" },
{ SMUX_MSG_SOUT, "Commit Or Rollback" },
{ 0, NULL }
};
#endif
/* Procedure names (used in Service Response Time) */
const value_string snmp_procedure_names[] = {
{ 0, "Get" },
{ 1, "GetNext" },
{ 3, "Set" },
{ 4, "Register" },
{ 5, "Bulk" },
{ 6, "Inform" },
{ 0, NULL }
};
#define SNMP_IPA 0 /* IP Address */
#define SNMP_CNT 1 /* Counter (Counter32) */
#define SNMP_GGE 2 /* Gauge (Gauge32) */
#define SNMP_TIT 3 /* TimeTicks */
#define SNMP_OPQ 4 /* Opaque */
#define SNMP_NSP 5 /* NsapAddress */
#define SNMP_C64 6 /* Counter64 */
#define SNMP_U32 7 /* Uinteger32 */
#define SERR_NSO 0
#define SERR_NSI 1
#define SERR_EOM 2
dissector_table_t value_sub_dissectors_table;
/*
* Data structure attached to a conversation, request/response information
*/
typedef struct snmp_conv_info_t {
wmem_map_t *request_response;
} snmp_conv_info_t;
static snmp_conv_info_t*
snmp_find_conversation_and_get_conv_data(packet_info *pinfo);
static snmp_request_response_t *
snmp_get_request_response_pointer(wmem_map_t *map, guint32 requestId)
{
snmp_request_response_t *srrp=(snmp_request_response_t *)wmem_map_lookup(map, &requestId);
if (!srrp) {
srrp=wmem_new0(wmem_file_scope(), snmp_request_response_t);
srrp->requestId=requestId;
wmem_map_insert(map, &(srrp->requestId), (void *)srrp);
}
return srrp;
}
static snmp_request_response_t*
snmp_match_request_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint requestId, guint procedure_id, snmp_conv_info_t *snmp_info)
{
snmp_request_response_t *srrp=NULL;
DISSECTOR_ASSERT_HINT(snmp_info, "No SNMP info from ASN1 context");
/* get or create request/response pointer based on request id */
srrp=(snmp_request_response_t *)snmp_get_request_response_pointer(snmp_info->request_response, requestId);
// if not visited fill the request/response data
if (!PINFO_FD_VISITED(pinfo)) {
switch(procedure_id)
{
case SNMP_REQ_GET:
case SNMP_REQ_GETNEXT:
case SNMP_REQ_SET:
case SNMP_REQ_GETBULK:
case SNMP_REQ_INFORM:
srrp->request_frame_id=pinfo->fd->num;
srrp->response_frame_id=0;
srrp->request_time=pinfo->abs_ts;
srrp->request_procedure_id=procedure_id;
break;
case SNMP_RES_GET:
srrp->response_frame_id=pinfo->fd->num;
break;
default:
return NULL;
}
}
/* if request and response was matched */
if (srrp->request_frame_id!=0 && srrp->response_frame_id!=0)
{
proto_item *it;
// if it is a request
if (srrp->request_frame_id == pinfo->fd->num)
{
it=proto_tree_add_uint(tree, hf_snmp_response_in, tvb, 0, 0, srrp->response_frame_id);
proto_item_set_generated(it);
} else {
nstime_t ns;
it=proto_tree_add_uint(tree, hf_snmp_response_to, tvb, 0, 0, srrp->request_frame_id);
proto_item_set_generated(it);
nstime_delta(&ns, &pinfo->abs_ts, &srrp->request_time);
it=proto_tree_add_time(tree, hf_snmp_time, tvb, 0, 0, &ns);
proto_item_set_generated(it);
return srrp;
}
}
return NULL;
}
static void
snmpstat_init(struct register_srt* srt _U_, GArray* srt_array)
{
srt_stat_table *snmp_srt_table;
guint32 i;
snmp_srt_table = init_srt_table("SNMP Commands", NULL, srt_array, SNMP_NUM_PROCEDURES, NULL, "snmp.data", NULL);
for (i = 0; i < SNMP_NUM_PROCEDURES; i++)
{
init_srt_table_row(snmp_srt_table, i, val_to_str_const(i, snmp_procedure_names, "<unknown>"));
}
}
/* This is called only if request and response was matched -> no need to return anything than TAP_PACKET_REDRAW */
static tap_packet_status
snmpstat_packet(void *psnmp, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi, tap_flags_t flags _U_)
{
guint i = 0;
srt_stat_table *snmp_srt_table;
const snmp_request_response_t *snmp=(const snmp_request_response_t *)psi;
srt_data_t *data = (srt_data_t *)psnmp;
snmp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i);
add_srt_table_data(snmp_srt_table, snmp->request_procedure_id, &snmp->request_time, pinfo);
return TAP_PACKET_REDRAW;
}
static const gchar *
snmp_lookup_specific_trap (guint specific_trap)
{
guint i;
for (i = 0; i < num_specific_traps; i++) {
snmp_st_assoc_t *u = &(specific_traps[i]);
if ((u->trap == specific_trap) &&
(strcmp (u->enterprise, enterprise_oid) == 0))
{
return u->desc;
}
}
return NULL;
}
static int
dissect_snmp_variable_string(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
{
proto_tree_add_item(tree, hf_snmp_var_bind_str, tvb, 0, -1, ENC_ASCII);
return tvb_captured_length(tvb);
}
/*
DateAndTime ::= TEXTUAL-CONVENTION
DISPLAY-HINT "2d-1d-1d,1d:1d:1d.1d,1a1d:1d"
STATUS current
DESCRIPTION
"A date-time specification.
field octets contents range
----- ------ -------- -----
1 1-2 year* 0..65536
2 3 month 1..12
3 4 day 1..31
4 5 hour 0..23
5 6 minutes 0..59
6 7 seconds 0..60
(use 60 for leap-second)
7 8 deci-seconds 0..9
8 9 direction from UTC '+' / '-'
9 10 hours from UTC* 0..13
10 11 minutes from UTC 0..59
* Notes:
- the value of year is in network-byte order
- daylight saving time in New Zealand is +13
For example, Tuesday May 26, 1992 at 1:30:15 PM EDT would be
displayed as:
1992-5-26,13:30:15.0,-4:0
Note that if only local time is known, then timezone
information (fields 8-10) is not present."
SYNTAX OCTET STRING (SIZE (8 | 11))
*/
static proto_item *
dissect_snmp_variable_date_and_time(proto_tree *tree, packet_info *pinfo, int hfid, tvbuff_t *tvb, int offset, int length)
{
guint16 year;
guint8 month;
guint8 day;
guint8 hour;
guint8 minutes;
guint8 seconds;
guint8 deci_seconds;
guint8 hour_from_utc;
guint8 min_from_utc;
gchar *str;
year = tvb_get_ntohs(tvb,offset);
month = tvb_get_guint8(tvb,offset+2);
day = tvb_get_guint8(tvb,offset+3);
hour = tvb_get_guint8(tvb,offset+4);
minutes = tvb_get_guint8(tvb,offset+5);
seconds = tvb_get_guint8(tvb,offset+6);
deci_seconds = tvb_get_guint8(tvb,offset+7);
if(length > 8){
hour_from_utc = tvb_get_guint8(tvb,offset+9);
min_from_utc = tvb_get_guint8(tvb,offset+10);
str = wmem_strdup_printf(pinfo->pool,
"%u-%u-%u, %u:%u:%u.%u UTC %s%u:%u",
year,
month,
day,
hour,
minutes,
seconds,
deci_seconds,
tvb_get_string_enc(pinfo->pool,tvb,offset+8,1,ENC_ASCII|ENC_NA),
hour_from_utc,
min_from_utc);
}else{
str = wmem_strdup_printf(pinfo->pool,
"%u-%u-%u, %u:%u:%u.%u",
year,
month,
day,
hour,
minutes,
seconds,
deci_seconds);
}
return proto_tree_add_string(tree, hfid, tvb, offset, length, str);
}
/*
* dissect_snmp_VarBind
* this routine dissects variable bindings, looking for the oid information in our oid reporsitory
* to format and add the value adequatelly.
*
* The choice to handwrite this code instead of using the asn compiler is to avoid having tons
* of uses of global variables distributed in very different parts of the code.
* Other than that there's a cosmetic thing: the tree from ASN generated code would be so
* convoluted due to the nesting of CHOICEs in the definition of VarBind/value.
*
* XXX: the length of this function (~400 lines) is an aberration!
* oid_key_t:key_type could become a series of callbacks instead of an enum
* the (! oid_info_is_ok) switch could be made into an array (would be slower)
*
NetworkAddress ::= CHOICE { internet IpAddress }
IpAddress ::= [APPLICATION 0] IMPLICIT OCTET STRING (SIZE (4))
TimeTicks ::= [APPLICATION 3] IMPLICIT INTEGER (0..4294967295)
Integer32 ::= INTEGER (-2147483648..2147483647)
ObjectName ::= OBJECT IDENTIFIER
Counter32 ::= [APPLICATION 1] IMPLICIT INTEGER (0..4294967295)
Gauge32 ::= [APPLICATION 2] IMPLICIT INTEGER (0..4294967295)
Unsigned32 ::= [APPLICATION 2] IMPLICIT INTEGER (0..4294967295)
Integer-value ::= INTEGER (-2147483648..2147483647)
Integer32 ::= INTEGER (-2147483648..2147483647)
ObjectID-value ::= OBJECT IDENTIFIER
Empty ::= NULL
TimeTicks ::= [APPLICATION 3] IMPLICIT INTEGER (0..4294967295)
Opaque ::= [APPLICATION 4] IMPLICIT OCTET STRING
Counter64 ::= [APPLICATION 6] IMPLICIT INTEGER (0..18446744073709551615)
ObjectSyntax ::= CHOICE {
simple SimpleSyntax,
application-wide ApplicationSyntax
}
SimpleSyntax ::= CHOICE {
integer-value Integer-value,
string-value String-value,
objectID-value ObjectID-value,
empty Empty
}
ApplicationSyntax ::= CHOICE {
ipAddress-value IpAddress,
counter-value Counter32,
timeticks-value TimeTicks,
arbitrary-value Opaque,
big-counter-value Counter64,
unsigned-integer-value Unsigned32
}
ValueType ::= CHOICE {
value ObjectSyntax,
unSpecified NULL,
noSuchObject[0] IMPLICIT NULL,
noSuchInstance[1] IMPLICIT NULL,
endOfMibView[2] IMPLICIT NULL
}
VarBind ::= SEQUENCE {
name ObjectName,
valueType ValueType
}
*/
static int
dissect_snmp_VarBind(bool implicit_tag _U_, tvbuff_t *tvb, int offset,
asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_)
{
int seq_offset, name_offset, value_offset, value_start;
guint32 seq_len, name_len, value_len;
gint8 ber_class;
bool pc;
gint32 tag;
bool ind;
guint32* subids;
guint8* oid_bytes;
oid_info_t* oid_info = NULL;
guint oid_matched, oid_left;
proto_item *pi_name, *pi_varbind, *pi_value = NULL;
proto_tree *pt, *pt_varbind, *pt_name, *pt_value;
char label[ITEM_LABEL_LENGTH];
const char* repr = NULL;
const char* info_oid = NULL;
char* valstr;
int hfid = -1;
int min_len = 0, max_len = 0;
bool oid_info_is_ok;
const char* oid_string = NULL;
enum {BER_NO_ERROR, BER_WRONG_LENGTH, BER_WRONG_TAG} format_error = BER_NO_ERROR;
seq_offset = offset;
/* first have the VarBind's sequence header */
offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &ber_class, &pc, &tag);
offset = dissect_ber_length(actx->pinfo, tree, tvb, offset, &seq_len, &ind);
if (!pc && ber_class==BER_CLASS_UNI && tag==BER_UNI_TAG_SEQUENCE) {
proto_item* pi;
pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len + (offset - seq_offset),
ett_decoding_error, &pi, "VarBind must be an universal class sequence");
expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_not_uni_class_seq);
return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt);
}
if (ind) {
proto_item* pi;
pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len + (offset - seq_offset),
ett_decoding_error, &pi, "Indicator must be clear in VarBind");
expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_has_indicator);
return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt);
}
/* we add the varbind tree root with a dummy label we'll fill later on */
pt_varbind = proto_tree_add_subtree(tree,tvb,offset,seq_len,ett_varbind,&pi_varbind,"VarBind");
*label = '\0';
seq_len += offset - seq_offset;
/* then we have the ObjectName's header */
offset = dissect_ber_identifier(actx->pinfo, pt_varbind, tvb, offset, &ber_class, &pc, &tag);
name_offset = offset = dissect_ber_length(actx->pinfo, pt_varbind, tvb, offset, &name_len, &ind);
if (! ( !pc && ber_class==BER_CLASS_UNI && tag==BER_UNI_TAG_OID) ) {
proto_item* pi;
pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len,
ett_decoding_error, &pi, "ObjectName must be an OID in primitive encoding");
expert_add_info(actx->pinfo, pi, &ei_snmp_objectname_not_oid);
return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt);
}
if (ind) {
proto_item* pi;
pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len,
ett_decoding_error, &pi, "Indicator must be clear in ObjectName");
expert_add_info(actx->pinfo, pi, &ei_snmp_objectname_has_indicator);
return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt);
}
pi_name = proto_tree_add_item(pt_varbind,hf_snmp_objectname,tvb,name_offset,name_len,ENC_NA);
pt_name = proto_item_add_subtree(pi_name,ett_name);
offset += name_len;
value_start = offset;
/* then we have the value's header */
offset = dissect_ber_identifier(actx->pinfo, pt_varbind, tvb, offset, &ber_class, &pc, &tag);
value_offset = dissect_ber_length(actx->pinfo, pt_varbind, tvb, offset, &value_len, &ind);
if (! (!pc) ) {
proto_item* pi;
pt = proto_tree_add_subtree(pt_varbind, tvb, value_start, value_len,
ett_decoding_error, &pi, "the value must be in primitive encoding");
expert_add_info(actx->pinfo, pi, &ei_snmp_value_not_primitive_encoding);
return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt);
}
/* Now, we know where everithing is */
/* fetch ObjectName and its relative oid_info */
oid_bytes = (guint8*)tvb_memdup(actx->pinfo->pool, tvb, name_offset, name_len);
oid_info = oid_get_from_encoded(actx->pinfo->pool, oid_bytes, name_len, &subids, &oid_matched, &oid_left);
add_oid_debug_subtree(oid_info,pt_name);
if (!subids) {
proto_item* pi;
repr = oid_encoded2string(actx->pinfo->pool, oid_bytes, name_len);
pt = proto_tree_add_subtree_format(pt_name,tvb, 0, 0, ett_decoding_error, &pi, "invalid oid: %s", repr);
expert_add_info_format(actx->pinfo, pi, &ei_snmp_invalid_oid, "invalid oid: %s", repr);
return dissect_unknown_ber(actx->pinfo, tvb, name_offset, pt);
}
if (oid_matched+oid_left) {
oid_string = oid_subid2string(actx->pinfo->pool, subids,oid_matched+oid_left);
}
if (ber_class == BER_CLASS_CON) {
/* if we have an error value just add it and get out the way ASAP */
proto_item* pi;
const char* note;
if (value_len != 0) {
min_len = max_len = 0;
format_error = BER_WRONG_LENGTH;
}
switch (tag) {
case SERR_NSO:
hfid = hf_snmp_noSuchObject;
note = "noSuchObject";
break;
case SERR_NSI:
hfid = hf_snmp_noSuchInstance;
note = "noSuchInstance";
break;
case SERR_EOM:
hfid = hf_snmp_endOfMibView;
note = "endOfMibView";
break;
default: {
pt = proto_tree_add_subtree_format(pt_varbind,tvb,0,0,ett_decoding_error,&pi,
"Wrong tag for Error Value: expected 0, 1, or 2 but got: %d",tag);
expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_wrong_tag);
return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt);
}
}
pi = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN);
expert_add_info_format(actx->pinfo, pi, &ei_snmp_varbind_response, "%s",note);
(void) g_strlcpy (label, note, ITEM_LABEL_LENGTH);
goto set_label;
}
/* now we'll try to figure out which are the indexing sub-oids and whether the oid we know about is the one oid we have to use */
switch (oid_info->kind) {
case OID_KIND_SCALAR:
if (oid_left == 1) {
/* OK: we got the instance sub-id */
proto_tree_add_uint64(pt_name,hf_snmp_scalar_instance_index,tvb,name_offset,name_len,subids[oid_matched]);
oid_info_is_ok = TRUE;
goto indexing_done;
} else if (oid_left == 0) {
if (ber_class == BER_CLASS_UNI && tag == BER_UNI_TAG_NULL) {
/* unSpecified does not require an instance sub-id add the new value and get off the way! */
pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,ENC_NA);
goto set_label;
} else {
proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_no_instance_subid,tvb,0,0);
oid_info_is_ok = FALSE;
goto indexing_done;
}
} else {
proto_tree_add_expert_format(pt_name,actx->pinfo,&ei_snmp_wrong_num_of_subids,tvb,0,0,"A scalar should have only one instance sub-id this has: %d",oid_left);
oid_info_is_ok = FALSE;
goto indexing_done;
}
break;
case OID_KIND_COLUMN:
if ( oid_info->parent->kind == OID_KIND_ROW) {
oid_key_t* k = oid_info->parent->key;
guint key_start = oid_matched;
guint key_len = oid_left;
oid_info_is_ok = TRUE;
if ( key_len == 0 && ber_class == BER_CLASS_UNI && tag == BER_UNI_TAG_NULL) {
/* unSpecified does not require an instance sub-id add the new value and get off the way! */
pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,ENC_NA);
goto set_label;
}
if (k) {
for (;k;k = k->next) {
guint suboid_len;
if (key_start >= oid_matched+oid_left) {
proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_suboid_too_short,tvb,0,0);
oid_info_is_ok = FALSE;
goto indexing_done;
}
switch(k->key_type) {
case OID_KEY_TYPE_WRONG: {
proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_unimplemented_instance_index,tvb,0,0);
oid_info_is_ok = FALSE;
goto indexing_done;
}
case OID_KEY_TYPE_INTEGER: {
if (FT_IS_INT(k->ft_type)) {
proto_tree_add_int(pt_name,k->hfid,tvb,name_offset,name_len,(guint)subids[key_start]);
} else { /* if it's not an unsigned int let proto_tree_add_uint throw a warning */
proto_tree_add_uint64(pt_name,k->hfid,tvb,name_offset,name_len,(guint)subids[key_start]);
}
key_start++;
key_len--;
continue; /* k->next */
}
case OID_KEY_TYPE_IMPLIED_OID:
suboid_len = key_len;
goto show_oid_index;
case OID_KEY_TYPE_OID: {
guint8* suboid_buf;
guint suboid_buf_len;
guint32* suboid;
suboid_len = subids[key_start++];
key_len--;
show_oid_index:
suboid = &(subids[key_start]);
if( suboid_len == 0 ) {
proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_suboid_len0,tvb,0,0);
oid_info_is_ok = FALSE;
goto indexing_done;
}
if( key_len < suboid_len ) {
proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_suboid_too_long,tvb,0,0);
oid_info_is_ok = FALSE;
goto indexing_done;
}
suboid_buf_len = oid_subid2encoded(actx->pinfo->pool, suboid_len, suboid, &suboid_buf);
DISSECTOR_ASSERT(suboid_buf_len);
proto_tree_add_oid(pt_name,k->hfid,tvb,name_offset, suboid_buf_len, suboid_buf);
key_start += suboid_len;
key_len -= suboid_len + 1;
continue; /* k->next */
}
default: {
guint8* buf;
guint buf_len;
guint32* suboid;
guint i;
switch (k->key_type) {
case OID_KEY_TYPE_IPADDR:
suboid = &(subids[key_start]);
buf_len = 4;
break;
case OID_KEY_TYPE_IMPLIED_STRING:
case OID_KEY_TYPE_IMPLIED_BYTES:
case OID_KEY_TYPE_ETHER:
suboid = &(subids[key_start]);
buf_len = key_len;
break;
default:
buf_len = k->num_subids;
suboid = &(subids[key_start]);
if(!buf_len) {
buf_len = *suboid++;
key_len--;
key_start++;
}
break;
}
if( key_len < buf_len ) {
proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_index_string_too_long,tvb,0,0);
oid_info_is_ok = FALSE;
goto indexing_done;
}
buf = (guint8*)wmem_alloc(actx->pinfo->pool, buf_len+1);
for (i = 0; i < buf_len; i++)
buf[i] = (guint8)suboid[i];
buf[i] = '\0';
switch(k->key_type) {
case OID_KEY_TYPE_STRING:
case OID_KEY_TYPE_IMPLIED_STRING:
proto_tree_add_string(pt_name,k->hfid,tvb,name_offset,buf_len, buf);
break;
case OID_KEY_TYPE_BYTES:
case OID_KEY_TYPE_NSAP:
case OID_KEY_TYPE_IMPLIED_BYTES:
proto_tree_add_bytes(pt_name,k->hfid,tvb,name_offset,buf_len, buf);
break;
case OID_KEY_TYPE_ETHER:
proto_tree_add_ether(pt_name,k->hfid,tvb,name_offset,buf_len, buf);
break;
case OID_KEY_TYPE_IPADDR: {
guint32* ipv4_p = (guint32*)buf;
proto_tree_add_ipv4(pt_name,k->hfid,tvb,name_offset,buf_len, *ipv4_p);
}
break;
default:
DISSECTOR_ASSERT_NOT_REACHED();
break;
}
key_start += buf_len;
key_len -= buf_len;
continue; /* k->next*/
}
}
}
goto indexing_done;
} else {
proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_unimplemented_instance_index,tvb,0,0);
oid_info_is_ok = FALSE;
goto indexing_done;
}
} else {
proto_tree_add_expert(pt_name,actx->pinfo,&ei_snmp_column_parent_not_row,tvb,0,0);
oid_info_is_ok = FALSE;
goto indexing_done;
}
default: {
/* proto_tree_add_expert (pt_name,actx->pinfo,PI_MALFORMED, PI_WARN,tvb,0,0,"This kind OID should have no value"); */
oid_info_is_ok = FALSE;
goto indexing_done;
}
}
indexing_done:
if (oid_info_is_ok && oid_info->value_type) {
if (ber_class == BER_CLASS_UNI && tag == BER_UNI_TAG_NULL) {
pi_value = proto_tree_add_item(pt_varbind,hf_snmp_unSpecified,tvb,value_offset,value_len,ENC_NA);
} else {
/* Provide a tree_item to attach errors to, if needed. */
pi_value = pi_name;
if ((oid_info->value_type->ber_class != BER_CLASS_ANY) &&
(ber_class != oid_info->value_type->ber_class))
format_error = BER_WRONG_TAG;
else if ((oid_info->value_type->ber_tag != BER_TAG_ANY) &&
(tag != oid_info->value_type->ber_tag))
format_error = BER_WRONG_TAG;
else {
max_len = oid_info->value_type->max_len == -1 ? 0xffffff : oid_info->value_type->max_len;
min_len = oid_info->value_type->min_len;
if ((int)value_len < min_len || (int)value_len > max_len)
format_error = BER_WRONG_LENGTH;
}
if (format_error == BER_NO_ERROR)
pi_value = proto_tree_add_item(pt_varbind,oid_info->value_hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN);
}
} else {
switch(ber_class|(tag<<4)) {
case BER_CLASS_UNI|(BER_UNI_TAG_INTEGER<<4):
{
gint64 val=0;
unsigned int int_val_offset = value_offset;
unsigned int i;
max_len = 4; min_len = 1;
if (value_len > (guint)max_len || value_len < (guint)min_len) {
hfid = hf_snmp_integer32_value;
format_error = BER_WRONG_LENGTH;
break;
}
if(value_len > 0) {
/* extend sign bit */
if(tvb_get_guint8(tvb, int_val_offset)&0x80) {
val=-1;
}
for(i=0;i<value_len;i++) {
val=(val<<8)|tvb_get_guint8(tvb, int_val_offset);
int_val_offset++;
}
}
pi_value = proto_tree_add_int64(pt_varbind, hf_snmp_integer32_value, tvb,value_offset,value_len, val);
goto already_added;
}
case BER_CLASS_UNI|(BER_UNI_TAG_OCTETSTRING<<4):
if(oid_info->value_hfid> -1){
hfid = oid_info->value_hfid;
}else{
hfid = hf_snmp_octetstring_value;
}
break;
case BER_CLASS_UNI|(BER_UNI_TAG_OID<<4):
max_len = -1; min_len = 1;
if (value_len < (guint)min_len) format_error = BER_WRONG_LENGTH;
hfid = hf_snmp_oid_value;
break;
case BER_CLASS_UNI|(BER_UNI_TAG_NULL<<4):
max_len = 0; min_len = 0;
if (value_len != 0) format_error = BER_WRONG_LENGTH;
hfid = hf_snmp_null_value;
break;
case BER_CLASS_APP: /* | (SNMP_IPA<<4)*/
switch(value_len) {
case 4: hfid = hf_snmp_ipv4_value; break;
case 16: hfid = hf_snmp_ipv6_value; break;
default: hfid = hf_snmp_anyaddress_value; break;
}
break;
case BER_CLASS_APP|(SNMP_U32<<4):
hfid = hf_snmp_unsigned32_value;
break;
case BER_CLASS_APP|(SNMP_GGE<<4):
hfid = hf_snmp_gauge32_value;
break;
case BER_CLASS_APP|(SNMP_CNT<<4):
hfid = hf_snmp_counter_value;
break;
case BER_CLASS_APP|(SNMP_TIT<<4):
hfid = hf_snmp_timeticks_value;
break;
case BER_CLASS_APP|(SNMP_OPQ<<4):
hfid = hf_snmp_opaque_value;
break;
case BER_CLASS_APP|(SNMP_NSP<<4):
hfid = hf_snmp_nsap_value;
break;
case BER_CLASS_APP|(SNMP_C64<<4):
hfid = hf_snmp_big_counter_value;
break;
default:
hfid = hf_snmp_unknown_value;
break;
}
if (value_len > 8) {
/*
* Too long for an FT_UINT64 or an FT_INT64.
*/
header_field_info *hfinfo = proto_registrar_get_nth(hfid);
if (hfinfo->type == FT_UINT64) {
/*
* Check if this is an unsigned int64 with
* a big value.
*/
if (value_len > 9 || tvb_get_guint8(tvb, value_offset) != 0) {
/* It is. Fail. */
proto_tree_add_expert_format(pt_varbind,actx->pinfo,&ei_snmp_uint_too_large,tvb,value_offset,value_len,"Integral value too large");
goto already_added;
}
/* Cheat and skip the leading 0 byte */
value_len--;
value_offset++;
} else if (hfinfo->type == FT_INT64) {
/*
* For now, just reject these.
*/
proto_tree_add_expert_format(pt_varbind,actx->pinfo,&ei_snmp_int_too_large,tvb,value_offset,value_len,"Integral value too large or too small");
goto already_added;
}
} else if (value_len == 0) {
/*
* X.690 section 8.3.1 "Encoding of an integer value":
* "The encoding of an integer value shall be
* primitive. The contents octets shall consist of
* one or more octets."
*
* Zero is not "one or more".
*/
header_field_info *hfinfo = proto_registrar_get_nth(hfid);
if (hfinfo->type == FT_UINT64 || hfinfo->type == FT_INT64) {
proto_tree_add_expert_format(pt_varbind,actx->pinfo,&ei_snmp_integral_value0,tvb,value_offset,value_len,"Integral value is zero-length");
goto already_added;
}
}
/* Special case DATE AND TIME */
if((oid_info->value_type)&&(oid_info->value_type->keytype == OID_KEY_TYPE_DATE_AND_TIME)&&(value_len > 7)){
pi_value = dissect_snmp_variable_date_and_time(pt_varbind, actx->pinfo, hfid, tvb, value_offset, value_len);
}else{
pi_value = proto_tree_add_item(pt_varbind,hfid,tvb,value_offset,value_len,ENC_BIG_ENDIAN);
}
if (format_error != BER_NO_ERROR) {
expert_add_info(actx->pinfo, pi_value, &ei_snmp_missing_mib);
}
}
already_added:
pt_value = proto_item_add_subtree(pi_value,ett_value);
if (value_len > 0 && oid_string) {
tvbuff_t* sub_tvb = tvb_new_subset_length(tvb, value_offset, value_len);
next_tvb_add_string(var_list, sub_tvb, (snmp_var_in_tree) ? pt_value : NULL, value_sub_dissectors_table, oid_string);
}
set_label:
if (pi_value) proto_item_fill_label(PITEM_FINFO(pi_value), label);
if (oid_info && oid_info->name) {
if (oid_left >= 1) {
repr = wmem_strdup_printf(actx->pinfo->pool, "%s.%s (%s)", oid_info->name,
oid_subid2string(actx->pinfo->pool, &(subids[oid_matched]),oid_left),
oid_subid2string(actx->pinfo->pool, subids,oid_matched+oid_left));
info_oid = wmem_strdup_printf(actx->pinfo->pool, "%s.%s", oid_info->name,
oid_subid2string(actx->pinfo->pool, &(subids[oid_matched]),oid_left));
} else {
repr = wmem_strdup_printf(actx->pinfo->pool, "%s (%s)", oid_info->name,
oid_subid2string(actx->pinfo->pool, subids,oid_matched));
info_oid = oid_info->name;
}
} else if (oid_string) {
repr = wmem_strdup(actx->pinfo->pool, oid_string);
info_oid = oid_string;
} else {
repr = wmem_strdup(actx->pinfo->pool, "[Bad OID]");
}
valstr = strstr(label,": ");
valstr = valstr ? valstr+2 : label;
proto_item_set_text(pi_varbind,"%s: %s",repr,valstr);
if (display_oid && info_oid) {
col_append_fstr (actx->pinfo->cinfo, COL_INFO, " %s", info_oid);
}
switch (format_error) {
case BER_WRONG_LENGTH: {
proto_item* pi;
proto_tree* p_tree = proto_item_add_subtree(pi_value,ett_decoding_error);
pt = proto_tree_add_subtree_format(p_tree,tvb,0,0,ett_decoding_error,&pi,
"Wrong value length: %u expecting: %u <= len <= %u",
value_len, min_len, max_len == -1 ? 0xFFFFFF : max_len);
expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_wrong_length_value);
return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt);
}
case BER_WRONG_TAG: {
proto_item* pi;
proto_tree* p_tree = proto_item_add_subtree(pi_value,ett_decoding_error);
pt = proto_tree_add_subtree_format(p_tree,tvb,0,0,ett_decoding_error,&pi,
"Wrong class/tag for Value expected: %d,%d got: %d,%d",
oid_info->value_type->ber_class, oid_info->value_type->ber_tag,
ber_class, tag);
expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_wrong_class_tag);
return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt);
}
default:
break;
}
return seq_offset + seq_len;
}
#define F_SNMP_ENGINEID_CONFORM 0x80
#define SNMP_ENGINEID_RFC1910 0x00
#define SNMP_ENGINEID_RFC3411 0x01
static const true_false_string tfs_snmp_engineid_conform = {
"RFC3411 (SNMPv3)",
"RFC1910 (Non-SNMPv3)"
};
#define SNMP_ENGINEID_FORMAT_IPV4 0x01
#define SNMP_ENGINEID_FORMAT_IPV6 0x02
#define SNMP_ENGINEID_FORMAT_MACADDRESS 0x03
#define SNMP_ENGINEID_FORMAT_TEXT 0x04
#define SNMP_ENGINEID_FORMAT_OCTETS 0x05
static const value_string snmp_engineid_format_vals[] = {
{ SNMP_ENGINEID_FORMAT_IPV4, "IPv4 address" },
{ SNMP_ENGINEID_FORMAT_IPV6, "IPv6 address" },
{ SNMP_ENGINEID_FORMAT_MACADDRESS, "MAC address" },
{ SNMP_ENGINEID_FORMAT_TEXT, "Text, administratively assigned" },
{ SNMP_ENGINEID_FORMAT_OCTETS, "Octets, administratively assigned" },
{ 0, NULL }
};
#define SNMP_ENGINEID_CISCO_AGENT 0x00
#define SNMP_ENGINEID_CISCO_MANAGER 0x01
static const value_string snmp_engineid_cisco_type_vals[] = {
{ SNMP_ENGINEID_CISCO_AGENT, "Agent" },
{ SNMP_ENGINEID_CISCO_MANAGER, "Manager" },
{ 0, NULL }
};
/*
* SNMP Engine ID dissection according to RFC 3411 (SnmpEngineID TC)
* or historic RFC 1910 (AgentID)
*/
int
dissect_snmp_engineid(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, int offset, int len)
{
proto_item *item = NULL;
guint8 conformance, format;
guint32 enterpriseid;
time_t seconds;
nstime_t ts;
int len_remain = len;
/* first bit: engine id conformance */
if (len_remain<1) return offset;
conformance = ((tvb_get_guint8(tvb, offset)>>7) & 0x01);
proto_tree_add_item(tree, hf_snmp_engineid_conform, tvb, offset, 1, ENC_BIG_ENDIAN);
/* 4-byte enterprise number/name */
if (len_remain<4) return offset;
enterpriseid = tvb_get_ntohl(tvb, offset);
if (conformance)
enterpriseid -= 0x80000000; /* ignore first bit */
proto_tree_add_uint(tree, hf_snmp_engineid_enterprise, tvb, offset, 4, enterpriseid);
offset+=4;
len_remain-=4;
switch(conformance) {
case SNMP_ENGINEID_RFC1910:
/* 12-byte AgentID w/ 8-byte trailer */
if (len_remain==8) {
proto_tree_add_item(tree, hf_snmp_agentid_trailer, tvb, offset, 8, ENC_NA);
offset+=8;
len_remain-=8;
} else {
proto_tree_add_expert(tree, pinfo, &ei_snmp_rfc1910_non_conformant, tvb, offset, len_remain);
return offset;
}
break;
case SNMP_ENGINEID_RFC3411: /* variable length: 5..32 */
/* 1-byte format specifier */
if (len_remain<1) return offset;
format = tvb_get_guint8(tvb, offset);
item = proto_tree_add_uint_format(tree, hf_snmp_engineid_format, tvb, offset, 1, format, "Engine ID Format: %s (%d)",
val_to_str_const(format, snmp_engineid_format_vals, "Reserved/Enterprise-specific"),
format);
offset+=1;
len_remain-=1;
switch(format) {
case SNMP_ENGINEID_FORMAT_IPV4:
/* 4-byte IPv4 address */
if (len_remain==4) {
proto_tree_add_item(tree, hf_snmp_engineid_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN);
offset+=4;
len_remain=0;
}
break;
case SNMP_ENGINEID_FORMAT_IPV6:
/* 16-byte IPv6 address */
if (len_remain==16) {
proto_tree_add_item(tree, hf_snmp_engineid_ipv6, tvb, offset, 16, ENC_NA);
offset+=16;
len_remain=0;
}
break;
case SNMP_ENGINEID_FORMAT_MACADDRESS:
/* See: https://supportforums.cisco.com/message/3010617#3010617 for details. */
if ((enterpriseid==9)&&(len_remain==7)) {
proto_tree_add_item(tree, hf_snmp_engineid_cisco_type, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
len_remain--;
}
/* 6-byte MAC address */
if (len_remain==6) {
proto_tree_add_item(tree, hf_snmp_engineid_mac, tvb, offset, 6, ENC_NA);
offset+=6;
len_remain=0;
}
break;
case SNMP_ENGINEID_FORMAT_TEXT:
/* max. 27-byte string, administratively assigned */
if (len_remain<=27) {
proto_tree_add_item(tree, hf_snmp_engineid_text, tvb, offset, len_remain, ENC_ASCII);
offset+=len_remain;
len_remain=0;
}
break;
case 128:
/* most common enterprise-specific format: (ucd|net)-snmp random */
if ((enterpriseid==2021)||(enterpriseid==8072)) {
proto_item_append_text(item, (enterpriseid==2021) ? ": UCD-SNMP Random" : ": Net-SNMP Random");
/* demystify: 4B random, 4B/8B epoch seconds */
if ((len_remain==8) || (len_remain==12)) {
proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, 4, ENC_NA);
if (len_remain==8) {
seconds = (time_t)tvb_get_letohl(tvb, offset + 4);
} else {
seconds = (time_t)tvb_get_letohi64(tvb, offset + 4);
}
ts.secs = seconds;
ts.nsecs = 0;
proto_tree_add_time_format_value(tree, hf_snmp_engineid_time, tvb, offset + 4, len_remain - 4,
&ts, "%s",
abs_time_secs_to_str(pinfo->pool, seconds, ABSOLUTE_TIME_LOCAL, TRUE));
offset+=len_remain;
len_remain=0;
}
break;
}
/* fall through */
case SNMP_ENGINEID_FORMAT_OCTETS:
default:
/* max. 27 bytes, administratively assigned or unknown format */
if (len_remain<=27) {
proto_tree_add_item(tree, hf_snmp_engineid_data, tvb, offset, len_remain, ENC_NA);
offset+=len_remain;
len_remain=0;
}
break;
}
}
if (len_remain>0) {
proto_tree_add_expert(tree, pinfo, &ei_snmp_rfc3411_non_conformant, tvb, offset, len_remain);
offset+=len_remain;
}
return offset;
}
static void set_ue_keys(snmp_ue_assoc_t* n ) {
guint key_size = auth_hash_len[n->user.authModel];
n->user.authKey.data = (guint8 *)g_malloc(key_size);
n->user.authKey.len = key_size;
snmp_usm_password_to_key(n->user.authModel,
n->user.authPassword.data,
n->user.authPassword.len,
n->engine.data,
n->engine.len,
n->user.authKey.data);
if (n->priv_proto == PRIV_AES128 || n->priv_proto == PRIV_AES192 || n->priv_proto == PRIV_AES256) {
guint need_key_len =
(n->priv_proto == PRIV_AES128) ? 16 :
(n->priv_proto == PRIV_AES192) ? 24 :
(n->priv_proto == PRIV_AES256) ? 32 :
0;
guint key_len = key_size;
while (key_len < need_key_len)
key_len += key_size;
n->user.privKey.data = (guint8 *)g_malloc(key_len);
n->user.privKey.len = need_key_len;
snmp_usm_password_to_key(n->user.authModel,
n->user.privPassword.data,
n->user.privPassword.len,
n->engine.data,
n->engine.len,
n->user.privKey.data);
key_len = key_size;
/* extend key if needed */
while (key_len < need_key_len) {
snmp_usm_password_to_key(n->user.authModel,
n->user.privKey.data,
key_len,
n->engine.data,
n->engine.len,
n->user.privKey.data + key_len);
key_len += key_size;
}
} else {
n->user.privKey.data = (guint8 *)g_malloc(key_size);
n->user.privKey.len = key_size;
snmp_usm_password_to_key(n->user.authModel,
n->user.privPassword.data,
n->user.privPassword.len,
n->engine.data,
n->engine.len,
n->user.privKey.data);
}
}
static snmp_ue_assoc_t*
ue_dup(snmp_ue_assoc_t* o)
{
snmp_ue_assoc_t* d = (snmp_ue_assoc_t*)g_memdup2(o,sizeof(snmp_ue_assoc_t));
d->user.authModel = o->user.authModel;
d->user.privProtocol = o->user.privProtocol;
d->user.userName.data = (guint8 *)g_memdup2(o->user.userName.data,o->user.userName.len);
d->user.userName.len = o->user.userName.len;
d->user.authPassword.data = o->user.authPassword.data ? (guint8 *)g_memdup2(o->user.authPassword.data,o->user.authPassword.len) : NULL;
d->user.authPassword.len = o->user.authPassword.len;
d->user.privPassword.data = o->user.privPassword.data ? (guint8 *)g_memdup2(o->user.privPassword.data,o->user.privPassword.len) : NULL;
d->user.privPassword.len = o->user.privPassword.len;
d->engine.len = o->engine.len;
if (d->engine.len) {
d->engine.data = (guint8 *)g_memdup2(o->engine.data,o->engine.len);
set_ue_keys(d);
}
return d;
}
static void*
snmp_users_copy_cb(void* dest, const void* orig, size_t len _U_)
{
const snmp_ue_assoc_t* o = (const snmp_ue_assoc_t*)orig;
snmp_ue_assoc_t* d = (snmp_ue_assoc_t*)dest;
d->auth_model = o->auth_model;
d->user.authModel = (snmp_usm_auth_model_t) o->auth_model;
d->priv_proto = o->priv_proto;
d->user.privProtocol = priv_protos[o->priv_proto];
d->user.userName.data = (guint8*)g_memdup2(o->user.userName.data,o->user.userName.len);
d->user.userName.len = o->user.userName.len;
d->user.authPassword.data = o->user.authPassword.data ? (guint8*)g_memdup2(o->user.authPassword.data,o->user.authPassword.len) : NULL;
d->user.authPassword.len = o->user.authPassword.len;
d->user.privPassword.data = o->user.privPassword.data ? (guint8*)g_memdup2(o->user.privPassword.data,o->user.privPassword.len) : NULL;
d->user.privPassword.len = o->user.privPassword.len;
d->engine.len = o->engine.len;
if (o->engine.data) {
d->engine.data = (guint8*)g_memdup2(o->engine.data,o->engine.len);
}
d->user.authKey.data = o->user.authKey.data ? (guint8*)g_memdup2(o->user.authKey.data,o->user.authKey.len) : NULL;
d->user.authKey.len = o->user.authKey.len;
d->user.privKey.data = o->user.privKey.data ? (guint8*)g_memdup2(o->user.privKey.data,o->user.privKey.len) : NULL;
d->user.privKey.len = o->user.privKey.len;
return d;
}
static void
snmp_users_free_cb(void* p)
{
snmp_ue_assoc_t* ue = (snmp_ue_assoc_t*)p;
g_free(ue->user.userName.data);
g_free(ue->user.authPassword.data);
g_free(ue->user.privPassword.data);
g_free(ue->user.authKey.data);
g_free(ue->user.privKey.data);
g_free(ue->engine.data);
}
static gboolean
snmp_users_update_cb(void* p _U_, char** err)
{
snmp_ue_assoc_t* ue = (snmp_ue_assoc_t*)p;
GString* es = g_string_new("");
unsigned int i;
*err = NULL;
if (! ue->user.userName.len) {
g_string_append_printf(es,"no userName\n");
} else if ((ue->engine.len > 0) && (ue->engine.len < 5 || ue->engine.len > 32)) {
/* RFC 3411 section 5 */
g_string_append_printf(es, "Invalid engineId length (%u). Must be between 5 and 32 (10 and 64 hex digits)\n", ue->engine.len);
} else if (num_ueas) {
for (i=0; i<num_ueas-1; i++) {
snmp_ue_assoc_t* u = &(ueas[i]);
if ( u->user.userName.len == ue->user.userName.len
&& u->engine.len == ue->engine.len && (u != ue)) {
if (u->engine.len > 0 && memcmp( u->engine.data, ue->engine.data, u->engine.len ) == 0) {
if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {
/* XXX: make a string for the engineId */
g_string_append_printf(es,"Duplicate key (userName='%s')\n",ue->user.userName.data);
break;
}
}
if (u->engine.len == 0) {
if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {
g_string_append_printf(es,"Duplicate key (userName='%s' engineId=NONE)\n",ue->user.userName.data);
break;
}
}
}
}
}
if (es->len) {
es = g_string_truncate(es,es->len-1);
*err = g_string_free(es, FALSE);
return FALSE;
}
return TRUE;
}
static void
free_ue_cache(snmp_ue_assoc_t **cache)
{
static snmp_ue_assoc_t *a, *nxt;
for (a = *cache; a; a = nxt) {
nxt = a->next;
snmp_users_free_cb(a);
g_free(a);
}
*cache = NULL;
}
#define CACHE_INSERT(c,a) if (c) { snmp_ue_assoc_t* t = c; c = a; c->next = t; } else { c = a; a->next = NULL; }
static void
init_ue_cache(void)
{
guint i;
for (i = 0; i < num_ueas; i++) {
snmp_ue_assoc_t* a = ue_dup(&(ueas[i]));
if (a->engine.len) {
CACHE_INSERT(localized_ues,a);
} else {
CACHE_INSERT(unlocalized_ues,a);
}
}
}
static void
cleanup_ue_cache(void)
{
free_ue_cache(&localized_ues);
free_ue_cache(&unlocalized_ues);
}
/* Called when the user applies changes to UAT preferences. */
static void
renew_ue_cache(void)
{
cleanup_ue_cache();
init_ue_cache();
}
static snmp_ue_assoc_t*
localize_ue( snmp_ue_assoc_t* o, const guint8* engine, guint engine_len )
{
snmp_ue_assoc_t* n = (snmp_ue_assoc_t*)g_memdup2(o,sizeof(snmp_ue_assoc_t));
n->user.userName.data = (guint8*)g_memdup2(o->user.userName.data,o->user.userName.len);
n->user.authModel = o->user.authModel;
n->user.authPassword.data = (guint8*)g_memdup2(o->user.authPassword.data,o->user.authPassword.len);
n->user.authPassword.len = o->user.authPassword.len;
n->user.privPassword.data = (guint8*)g_memdup2(o->user.privPassword.data,o->user.privPassword.len);
n->user.privPassword.len = o->user.privPassword.len;
n->user.authKey.data = (guint8*)g_memdup2(o->user.authKey.data,o->user.authKey.len);
n->user.privKey.data = (guint8*)g_memdup2(o->user.privKey.data,o->user.privKey.len);
n->engine.data = (guint8*)g_memdup2(engine,engine_len);
n->engine.len = engine_len;
n->priv_proto = o->priv_proto;
set_ue_keys(n);
return n;
}
#define localized_match(a,u,ul,e,el) \
( a->user.userName.len == ul \
&& a->engine.len == el \
&& memcmp( a->user.userName.data, u, ul ) == 0 \
&& memcmp( a->engine.data, e, el ) == 0 )
#define unlocalized_match(a,u,l) \
( a->user.userName.len == l && memcmp( a->user.userName.data, u, l) == 0 )
static snmp_ue_assoc_t*
get_user_assoc(tvbuff_t* engine_tvb, tvbuff_t* user_tvb, packet_info *pinfo)
{
static snmp_ue_assoc_t* a;
guint given_username_len;
guint8* given_username;
guint given_engine_len = 0;
guint8* given_engine = NULL;
if ( ! (localized_ues || unlocalized_ues ) ) return NULL;
if (! ( user_tvb && engine_tvb ) ) return NULL;
given_username_len = tvb_captured_length(user_tvb);
given_engine_len = tvb_captured_length(engine_tvb);
if (! ( given_engine_len && given_username_len ) ) return NULL;
given_username = (guint8*)tvb_memdup(pinfo->pool,user_tvb,0,-1);
given_engine = (guint8*)tvb_memdup(pinfo->pool,engine_tvb,0,-1);
for (a = localized_ues; a; a = a->next) {
if ( localized_match(a, given_username, given_username_len, given_engine, given_engine_len) ) {
return a;
}
}
for (a = unlocalized_ues; a; a = a->next) {
if ( unlocalized_match(a, given_username, given_username_len) ) {
snmp_ue_assoc_t* n = localize_ue( a, given_engine, given_engine_len );
CACHE_INSERT(localized_ues,n);
return n;
}
}
return NULL;
}
static bool
snmp_usm_auth(const packet_info *pinfo, const snmp_usm_auth_model_t model, snmp_usm_params_t* p, guint8** calc_auth_p,
guint* calc_auth_len_p, gchar const** error)
{
gint msg_len;
guint8* msg;
guint auth_len;
guint8* auth;
guint8* key;
guint key_len;
guint8 *calc_auth;
guint start;
guint end;
guint i;
if (!p->auth_tvb) {
*error = "No Authenticator";
return FALSE;
}
key = p->user_assoc->user.authKey.data;
key_len = p->user_assoc->user.authKey.len;
if (! key ) {
*error = "User has no authKey";
return FALSE;
}
auth_len = tvb_captured_length(p->auth_tvb);
if (auth_len != auth_tag_len[model]) {
*error = "Authenticator length wrong";
return FALSE;
}
msg_len = tvb_captured_length(p->msg_tvb);
if (msg_len <= 0) {
*error = "Not enough data remaining";
return FALSE;
}
msg = (guint8*)tvb_memdup(pinfo->pool,p->msg_tvb,0,msg_len);
auth = (guint8*)tvb_memdup(pinfo->pool,p->auth_tvb,0,auth_len);
start = p->auth_offset - p->start_offset;
end = start + auth_len;
/* fill the authenticator with zeros */
for ( i = start ; i < end ; i++ ) {
msg[i] = '\0';
}
calc_auth = (guint8*)wmem_alloc(pinfo->pool, auth_hash_len[model]);
if (ws_hmac_buffer(auth_hash_algo[model], calc_auth, msg, msg_len, key, key_len)) {
return FALSE;
}
if (calc_auth_p) *calc_auth_p = calc_auth;
if (calc_auth_len_p) *calc_auth_len_p = auth_len;
return ( memcmp(auth,calc_auth,auth_len) != 0 ) ? FALSE : TRUE;
}
static tvbuff_t*
snmp_usm_priv_des(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, gchar const** error)
{
gcry_error_t err;
gcry_cipher_hd_t hd = NULL;
guint8* cleartext;
guint8* des_key = p->user_assoc->user.privKey.data; /* first 8 bytes */
guint8* pre_iv = &(p->user_assoc->user.privKey.data[8]); /* last 8 bytes */
guint8* salt;
gint salt_len;
gint cryptgrm_len;
guint8* cryptgrm;
tvbuff_t* clear_tvb;
guint8 iv[8];
guint i;
salt_len = tvb_captured_length(p->priv_tvb);
if (salt_len != 8) {
*error = "decryptionError: msgPrivacyParameters length != 8";
return NULL;
}
salt = (guint8*)tvb_memdup(pinfo->pool,p->priv_tvb,0,salt_len);
/*
The resulting "salt" is XOR-ed with the pre-IV to obtain the IV.
*/
for (i=0; i<8; i++) {
iv[i] = pre_iv[i] ^ salt[i];
}
cryptgrm_len = tvb_captured_length(encryptedData);
if ((cryptgrm_len <= 0) || (cryptgrm_len % 8)) {
*error = "decryptionError: the length of the encrypted data is not a multiple of 8 octets";
return NULL;
}
cryptgrm = (guint8*)tvb_memdup(pinfo->pool,encryptedData,0,-1);
cleartext = (guint8*)wmem_alloc(pinfo->pool, cryptgrm_len);
err = gcry_cipher_open(&hd, GCRY_CIPHER_DES, GCRY_CIPHER_MODE_CBC, 0);
if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
err = gcry_cipher_setiv(hd, iv, 8);
if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
err = gcry_cipher_setkey(hd,des_key,8);
if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
err = gcry_cipher_decrypt(hd, cleartext, cryptgrm_len, cryptgrm, cryptgrm_len);
if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
gcry_cipher_close(hd);
clear_tvb = tvb_new_child_real_data(encryptedData, cleartext, cryptgrm_len, cryptgrm_len);
return clear_tvb;
on_gcry_error:
*error = (const gchar *)gcry_strerror(err);
if (hd) gcry_cipher_close(hd);
return NULL;
}
static tvbuff_t*
snmp_usm_priv_aes_common(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, gchar const** error, int algo)
{
gcry_error_t err;
gcry_cipher_hd_t hd = NULL;
guint8* cleartext;
guint8* aes_key = p->user_assoc->user.privKey.data;
int aes_key_len = p->user_assoc->user.privKey.len;
guint8 iv[16];
gint priv_len;
gint cryptgrm_len;
guint8* cryptgrm;
tvbuff_t* clear_tvb;
priv_len = tvb_captured_length(p->priv_tvb);
if (priv_len != 8) {
*error = "decryptionError: msgPrivacyParameters length != 8";
return NULL;
}
iv[0] = (p->boots & 0xff000000) >> 24;
iv[1] = (p->boots & 0x00ff0000) >> 16;
iv[2] = (p->boots & 0x0000ff00) >> 8;
iv[3] = (p->boots & 0x000000ff);
iv[4] = (p->snmp_time & 0xff000000) >> 24;
iv[5] = (p->snmp_time & 0x00ff0000) >> 16;
iv[6] = (p->snmp_time & 0x0000ff00) >> 8;
iv[7] = (p->snmp_time & 0x000000ff);
tvb_memcpy(p->priv_tvb,&(iv[8]),0,8);
cryptgrm_len = tvb_captured_length(encryptedData);
if (cryptgrm_len <= 0) {
*error = "Not enough data remaining";
return NULL;
}
cryptgrm = (guint8*)tvb_memdup(pinfo->pool,encryptedData,0,-1);
cleartext = (guint8*)wmem_alloc(pinfo->pool, cryptgrm_len);
err = gcry_cipher_open(&hd, algo, GCRY_CIPHER_MODE_CFB, 0);
if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
err = gcry_cipher_setiv(hd, iv, 16);
if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
err = gcry_cipher_setkey(hd,aes_key,aes_key_len);
if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
err = gcry_cipher_decrypt(hd, cleartext, cryptgrm_len, cryptgrm, cryptgrm_len);
if (err != GPG_ERR_NO_ERROR) goto on_gcry_error;
gcry_cipher_close(hd);
clear_tvb = tvb_new_child_real_data(encryptedData, cleartext, cryptgrm_len, cryptgrm_len);
return clear_tvb;
on_gcry_error:
*error = (const gchar *)gcry_strerror(err);
if (hd) gcry_cipher_close(hd);
return NULL;
}
static tvbuff_t*
snmp_usm_priv_aes128(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, gchar const** error)
{
return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES);
}
static tvbuff_t*
snmp_usm_priv_aes192(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, gchar const** error)
{
return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES192);
}
static tvbuff_t*
snmp_usm_priv_aes256(snmp_usm_params_t* p, tvbuff_t* encryptedData, packet_info *pinfo, gchar const** error)
{
return snmp_usm_priv_aes_common(p, encryptedData, pinfo, error, GCRY_CIPHER_AES256);
}
static gboolean
check_ScopedPdu(tvbuff_t* tvb)
{
int offset;
gint8 ber_class;
bool pc;
gint32 tag;
int hoffset, eoffset;
guint32 len;
offset = get_ber_identifier(tvb, 0, &ber_class, &pc, &tag);
offset = get_ber_length(tvb, offset, NULL, NULL);
if ( ! (((ber_class!=BER_CLASS_APP) && (ber_class!=BER_CLASS_PRI) )
&& ( (!pc) || (ber_class!=BER_CLASS_UNI) || (tag!=BER_UNI_TAG_ENUMERATED) )
)) return FALSE;
if((tvb_get_guint8(tvb, offset)==0)&&(tvb_get_guint8(tvb, offset+1)==0))
return TRUE;
hoffset = offset;
offset = get_ber_identifier(tvb, offset, &ber_class, &pc, &tag);
offset = get_ber_length(tvb, offset, &len, NULL);
eoffset = offset + len;
if (eoffset <= hoffset) return FALSE;
if ((ber_class!=BER_CLASS_APP)&&(ber_class!=BER_CLASS_PRI))
if( (ber_class!=BER_CLASS_UNI)
||((tag<BER_UNI_TAG_NumericString)&&(tag!=BER_UNI_TAG_OCTETSTRING)&&(tag!=BER_UNI_TAG_UTF8String)) )
return FALSE;
return TRUE;
}
static int
dissect_snmp_EnterpriseOID(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
const gchar* name;
offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &enterprise_oid);
if (display_oid && enterprise_oid) {
name = oid_resolved_from_string(actx->pinfo->pool, enterprise_oid);
if (name) {
col_append_fstr (actx->pinfo->cinfo, COL_INFO, " %s", name);
}
}
return offset;
}
static int
dissect_snmp_OCTET_STRING_SIZE_4(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static int
dissect_snmp_NetworkAddress(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_APP, 0, TRUE, dissect_snmp_OCTET_STRING_SIZE_4);
return offset;
}
static int
dissect_snmp_INTEGER_0_4294967295(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static int
dissect_snmp_TimeTicks(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_APP, 3, TRUE, dissect_snmp_INTEGER_0_4294967295);
return offset;
}
static int
dissect_snmp_Integer32(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
&RequestID);
return offset;
}
static int
dissect_snmp_ObjectName(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_object_identifier(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
return offset;
}
static const value_string snmp_Version_vals[] = {
{ 0, "version-1" },
{ 1, "v2c" },
{ 2, "v2u" },
{ 3, "snmpv3" },
{ 0, NULL }
};
static int
dissect_snmp_Version(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
&snmp_version);
return offset;
}
static int
dissect_snmp_Community(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static int
dissect_snmp_T_request_id(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
&RequestID);
return offset;
}
static const value_string snmp_T_error_status_vals[] = {
{ 0, "noError" },
{ 1, "tooBig" },
{ 2, "noSuchName" },
{ 3, "badValue" },
{ 4, "readOnly" },
{ 5, "genErr" },
{ 6, "noAccess" },
{ 7, "wrongType" },
{ 8, "wrongLength" },
{ 9, "wrongEncoding" },
{ 10, "wrongValue" },
{ 11, "noCreation" },
{ 12, "inconsistentValue" },
{ 13, "resourceUnavailable" },
{ 14, "commitFailed" },
{ 15, "undoFailed" },
{ 16, "authorizationError" },
{ 17, "notWritable" },
{ 18, "inconsistentName" },
{ 0, NULL }
};
static int
dissect_snmp_T_error_status(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static int
dissect_snmp_INTEGER(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static const ber_sequence_t VarBindList_sequence_of[1] = {
{ &hf_snmp_VarBindList_item, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_snmp_VarBind },
};
static int
dissect_snmp_VarBindList(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
VarBindList_sequence_of, hf_index, ett_snmp_VarBindList);
return offset;
}
static const ber_sequence_t PDU_sequence[] = {
{ &hf_snmp_request_id , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_T_request_id },
{ &hf_snmp_error_status , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_T_error_status },
{ &hf_snmp_error_index , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_INTEGER },
{ &hf_snmp_variable_bindings, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_snmp_VarBindList },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_PDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
PDU_sequence, hf_index, ett_snmp_PDU);
return offset;
}
static int
dissect_snmp_GetRequest_PDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_CON, 0, TRUE, dissect_snmp_PDU);
return offset;
}
static int
dissect_snmp_GetNextRequest_PDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_CON, 1, TRUE, dissect_snmp_PDU);
return offset;
}
static int
dissect_snmp_GetResponse_PDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_CON, 2, TRUE, dissect_snmp_PDU);
return offset;
}
static int
dissect_snmp_SetRequest_PDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_CON, 3, TRUE, dissect_snmp_PDU);
return offset;
}
static const value_string snmp_GenericTrap_vals[] = {
{ 0, "coldStart" },
{ 1, "warmStart" },
{ 2, "linkDown" },
{ 3, "linkUp" },
{ 4, "authenticationFailure" },
{ 5, "egpNeighborLoss" },
{ 6, "enterpriseSpecific" },
{ 0, NULL }
};
static int
dissect_snmp_GenericTrap(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
&generic_trap);
return offset;
}
static int
dissect_snmp_SpecificTrap(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
guint specific_trap;
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
&specific_trap);
if (generic_trap == 6) { /* enterprise specific */
const gchar *specific_str = snmp_lookup_specific_trap (specific_trap);
if (specific_str) {
proto_item_append_text(actx->created_item, " (%s)", specific_str);
}
}
return offset;
}
static const ber_sequence_t Trap_PDU_U_sequence[] = {
{ &hf_snmp_enterprise , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_snmp_EnterpriseOID },
{ &hf_snmp_agent_addr , BER_CLASS_APP, 0, BER_FLAGS_NOOWNTAG, dissect_snmp_NetworkAddress },
{ &hf_snmp_generic_trap , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_GenericTrap },
{ &hf_snmp_specific_trap , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_SpecificTrap },
{ &hf_snmp_time_stamp , BER_CLASS_APP, 3, BER_FLAGS_NOOWNTAG, dissect_snmp_TimeTicks },
{ &hf_snmp_variable_bindings, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_snmp_VarBindList },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_Trap_PDU_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
generic_trap = 0;
enterprise_oid = NULL;
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
Trap_PDU_U_sequence, hf_index, ett_snmp_Trap_PDU_U);
if (snmp_version != 0) {
expert_add_info(actx->pinfo, tree, &ei_snmp_trap_pdu_obsolete);
}
return offset;
}
static int
dissect_snmp_Trap_PDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_CON, 4, TRUE, dissect_snmp_Trap_PDU_U);
return offset;
}
static int
dissect_snmp_INTEGER_0_2147483647(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static const ber_sequence_t BulkPDU_sequence[] = {
{ &hf_snmp_bulkPDU_request_id, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_Integer32 },
{ &hf_snmp_non_repeaters , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_INTEGER_0_2147483647 },
{ &hf_snmp_max_repetitions, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_INTEGER_0_2147483647 },
{ &hf_snmp_variable_bindings, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_snmp_VarBindList },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_BulkPDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
BulkPDU_sequence, hf_index, ett_snmp_BulkPDU);
return offset;
}
static int
dissect_snmp_GetBulkRequest_PDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_CON, 5, TRUE, dissect_snmp_BulkPDU);
return offset;
}
static int
dissect_snmp_InformRequest_PDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_CON, 6, TRUE, dissect_snmp_PDU);
return offset;
}
static int
dissect_snmp_SNMPv2_Trap_PDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_CON, 7, TRUE, dissect_snmp_PDU);
return offset;
}
static int
dissect_snmp_Report_PDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_CON, 8, TRUE, dissect_snmp_PDU);
return offset;
}
static const value_string snmp_PDUs_vals[] = {
{ 0, "get-request" },
{ 1, "get-next-request" },
{ 2, "get-response" },
{ 3, "set-request" },
{ 4, "trap" },
{ 5, "getBulkRequest" },
{ 6, "informRequest" },
{ 7, "snmpV2-trap" },
{ 8, "report" },
{ 0, NULL }
};
static const ber_choice_t PDUs_choice[] = {
{ 0, &hf_snmp_get_request , BER_CLASS_CON, 0, BER_FLAGS_NOOWNTAG, dissect_snmp_GetRequest_PDU },
{ 1, &hf_snmp_get_next_request, BER_CLASS_CON, 1, BER_FLAGS_NOOWNTAG, dissect_snmp_GetNextRequest_PDU },
{ 2, &hf_snmp_get_response , BER_CLASS_CON, 2, BER_FLAGS_NOOWNTAG, dissect_snmp_GetResponse_PDU },
{ 3, &hf_snmp_set_request , BER_CLASS_CON, 3, BER_FLAGS_NOOWNTAG, dissect_snmp_SetRequest_PDU },
{ 4, &hf_snmp_trap , BER_CLASS_CON, 4, BER_FLAGS_NOOWNTAG, dissect_snmp_Trap_PDU },
{ 5, &hf_snmp_getBulkRequest , BER_CLASS_CON, 5, BER_FLAGS_NOOWNTAG, dissect_snmp_GetBulkRequest_PDU },
{ 6, &hf_snmp_informRequest , BER_CLASS_CON, 6, BER_FLAGS_NOOWNTAG, dissect_snmp_InformRequest_PDU },
{ 7, &hf_snmp_snmpV2_trap , BER_CLASS_CON, 7, BER_FLAGS_NOOWNTAG, dissect_snmp_SNMPv2_Trap_PDU },
{ 8, &hf_snmp_report , BER_CLASS_CON, 8, BER_FLAGS_NOOWNTAG, dissect_snmp_Report_PDU },
{ 0, NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_PDUs(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
gint pdu_type=-1;
snmp_request_response_t *srrp;
snmp_conv_info_t *snmp_info = (snmp_conv_info_t *)actx->private_data;
col_clear(actx->pinfo->cinfo, COL_INFO);
offset = dissect_ber_choice(actx, tree, tvb, offset,
PDUs_choice, hf_index, ett_snmp_PDUs,
&pdu_type);
if( (pdu_type!=-1) && snmp_PDUs_vals[pdu_type].strptr ){
col_prepend_fstr(actx->pinfo->cinfo, COL_INFO, "%s", snmp_PDUs_vals[pdu_type].strptr);
/* pdu_type is the index, not the tag so convert it to the tag value */
pdu_type = snmp_PDUs_vals[pdu_type].value;
srrp=snmp_match_request_response(tvb, actx->pinfo, tree, RequestID, pdu_type, snmp_info);
if (srrp) {
tap_queue_packet(snmp_tap, actx->pinfo, srrp);
}
}
return offset;
}
static const ber_sequence_t Message_sequence[] = {
{ &hf_snmp_version , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_Version },
{ &hf_snmp_community , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_snmp_Community },
{ &hf_snmp_data , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_snmp_PDUs },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_Message(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
Message_sequence, hf_index, ett_snmp_Message);
return offset;
}
static int
dissect_snmp_OCTET_STRING(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static const value_string snmp_T_datav2u_vals[] = {
{ 0, "plaintext" },
{ 1, "encrypted" },
{ 0, NULL }
};
static const ber_choice_t T_datav2u_choice[] = {
{ 0, &hf_snmp_v2u_plaintext , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG, dissect_snmp_PDUs },
{ 1, &hf_snmp_encrypted , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_snmp_OCTET_STRING },
{ 0, NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_T_datav2u(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_choice(actx, tree, tvb, offset,
T_datav2u_choice, hf_index, ett_snmp_T_datav2u,
NULL);
return offset;
}
static const ber_sequence_t Messagev2u_sequence[] = {
{ &hf_snmp_version , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_Version },
{ &hf_snmp_parameters , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_snmp_OCTET_STRING },
{ &hf_snmp_datav2u , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_snmp_T_datav2u },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_Messagev2u(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
Messagev2u_sequence, hf_index, ett_snmp_Messagev2u);
return offset;
}
static int
dissect_snmp_SnmpEngineID(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
tvbuff_t* param_tvb = NULL;
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, ¶m_tvb);
if (param_tvb) {
proto_tree* engine_tree = proto_item_add_subtree(actx->created_item,ett_engineid);
dissect_snmp_engineid(engine_tree, actx->pinfo, param_tvb, 0, tvb_reported_length_remaining(param_tvb,0));
}
return offset;
}
static int
dissect_snmp_T_msgAuthoritativeEngineID(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &usm_p.engine_tvb);
if (usm_p.engine_tvb) {
proto_tree* engine_tree = proto_item_add_subtree(actx->created_item,ett_engineid);
dissect_snmp_engineid(engine_tree, actx->pinfo, usm_p.engine_tvb, 0, tvb_reported_length_remaining(usm_p.engine_tvb,0));
}
return offset;
}
static int
dissect_snmp_T_msgAuthoritativeEngineBoots(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
&usm_p.boots);
return offset;
}
static int
dissect_snmp_T_msgAuthoritativeEngineTime(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
&usm_p.snmp_time);
return offset;
}
static int
dissect_snmp_T_msgUserName(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
&usm_p.user_tvb);
return offset;
}
static int
dissect_snmp_T_msgAuthenticationParameters(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_octet_string(FALSE, actx, tree, tvb, offset, hf_index, &usm_p.auth_tvb);
if (usm_p.auth_tvb) {
usm_p.auth_item = actx->created_item;
usm_p.auth_offset = tvb_offset_from_real_beginning(usm_p.auth_tvb);
}
return offset;
}
static int
dissect_snmp_T_msgPrivacyParameters(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
&usm_p.priv_tvb);
return offset;
}
static const ber_sequence_t UsmSecurityParameters_sequence[] = {
{ &hf_snmp_msgAuthoritativeEngineID, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_snmp_T_msgAuthoritativeEngineID },
{ &hf_snmp_msgAuthoritativeEngineBoots, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_T_msgAuthoritativeEngineBoots },
{ &hf_snmp_msgAuthoritativeEngineTime, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_T_msgAuthoritativeEngineTime },
{ &hf_snmp_msgUserName , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_snmp_T_msgUserName },
{ &hf_snmp_msgAuthenticationParameters, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_snmp_T_msgAuthenticationParameters },
{ &hf_snmp_msgPrivacyParameters, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_snmp_T_msgPrivacyParameters },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_UsmSecurityParameters(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
UsmSecurityParameters_sequence, hf_index, ett_snmp_UsmSecurityParameters);
return offset;
}
static int
dissect_snmp_INTEGER_484_2147483647(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static int
dissect_snmp_T_msgFlags(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
tvbuff_t *parameter_tvb = NULL;
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
¶meter_tvb);
if (parameter_tvb){
guint8 v3_flags = tvb_get_guint8(parameter_tvb, 0);
proto_tree* flags_tree = proto_item_add_subtree(actx->created_item,ett_msgFlags);
proto_tree_add_item(flags_tree, hf_snmp_v3_flags_report, parameter_tvb, 0, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(flags_tree, hf_snmp_v3_flags_crypt, parameter_tvb, 0, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(flags_tree, hf_snmp_v3_flags_auth, parameter_tvb, 0, 1, ENC_BIG_ENDIAN);
usm_p.encrypted = v3_flags & TH_CRYPT ? TRUE : FALSE;
usm_p.authenticated = v3_flags & TH_AUTH ? TRUE : FALSE;
}
return offset;
}
static int
dissect_snmp_T_msgSecurityModel(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
&MsgSecurityModel);
return offset;
}
static const ber_sequence_t HeaderData_sequence[] = {
{ &hf_snmp_msgID , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_INTEGER_0_2147483647 },
{ &hf_snmp_msgMaxSize , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_INTEGER_484_2147483647 },
{ &hf_snmp_msgFlags , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_snmp_T_msgFlags },
{ &hf_snmp_msgSecurityModel, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_T_msgSecurityModel },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_HeaderData(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
HeaderData_sequence, hf_index, ett_snmp_HeaderData);
return offset;
}
static int
dissect_snmp_T_msgSecurityParameters(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
switch(MsgSecurityModel){
case SNMP_SEC_USM: /* 3 */
offset = get_ber_identifier(tvb, offset, NULL, NULL, NULL);
offset = get_ber_length(tvb, offset, NULL, NULL);
offset = dissect_snmp_UsmSecurityParameters(FALSE, tvb, offset, actx, tree, -1);
usm_p.user_assoc = get_user_assoc(usm_p.engine_tvb, usm_p.user_tvb, actx->pinfo);
break;
case SNMP_SEC_ANY: /* 0 */
case SNMP_SEC_V1: /* 1 */
case SNMP_SEC_V2C: /* 2 */
default:
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
break;
}
return offset;
}
static const ber_sequence_t ScopedPDU_sequence[] = {
{ &hf_snmp_contextEngineID, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_snmp_SnmpEngineID },
{ &hf_snmp_contextName , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_snmp_OCTET_STRING },
{ &hf_snmp_data , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_snmp_PDUs },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_ScopedPDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
ScopedPDU_sequence, hf_index, ett_snmp_ScopedPDU);
return offset;
}
static int
dissect_snmp_T_encryptedPDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
tvbuff_t* crypt_tvb;
offset = dissect_ber_octet_string(FALSE, actx, tree, tvb, offset, hf_snmp_encryptedPDU, &crypt_tvb);
if( usm_p.encrypted && crypt_tvb
&& usm_p.user_assoc
&& usm_p.user_assoc->user.privProtocol ) {
const gchar* error = NULL;
proto_tree* encryptedpdu_tree = proto_item_add_subtree(actx->created_item,ett_encryptedPDU);
tvbuff_t* cleartext_tvb = usm_p.user_assoc->user.privProtocol(&usm_p, crypt_tvb, actx->pinfo, &error );
if (! cleartext_tvb) {
proto_tree_add_expert_format(encryptedpdu_tree, actx->pinfo, &ei_snmp_failed_decrypted_data_pdu,
crypt_tvb, 0, -1, "Failed to decrypt encryptedPDU: %s", error);
col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: Failed to decrypt");
return offset;
} else {
proto_item* decrypted_item;
proto_tree* decrypted_tree;
if (! check_ScopedPdu(cleartext_tvb)) {
proto_tree_add_expert(encryptedpdu_tree, actx->pinfo, &ei_snmp_decrypted_data_bad_formatted, cleartext_tvb, 0, -1);
col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: Decrypted data not formatted as expected");
return offset;
}
add_new_data_source(actx->pinfo, cleartext_tvb, "Decrypted ScopedPDU");
decrypted_item = proto_tree_add_item(encryptedpdu_tree, hf_snmp_decryptedPDU,cleartext_tvb,0,-1,ENC_NA);
decrypted_tree = proto_item_add_subtree(decrypted_item,ett_decrypted);
dissect_snmp_ScopedPDU(FALSE, cleartext_tvb, 0, actx, decrypted_tree, -1);
}
} else {
col_set_str(actx->pinfo->cinfo, COL_INFO, "encryptedPDU: privKey Unknown");
}
return offset;
}
static const value_string snmp_ScopedPduData_vals[] = {
{ 0, "plaintext" },
{ 1, "encryptedPDU" },
{ 0, NULL }
};
static const ber_choice_t ScopedPduData_choice[] = {
{ 0, &hf_snmp_plaintext , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_snmp_ScopedPDU },
{ 1, &hf_snmp_encryptedPDU , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_snmp_T_encryptedPDU },
{ 0, NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_ScopedPduData(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_choice(actx, tree, tvb, offset,
ScopedPduData_choice, hf_index, ett_snmp_ScopedPduData,
NULL);
return offset;
}
static const ber_sequence_t SNMPv3Message_sequence[] = {
{ &hf_snmp_msgVersion , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_Version },
{ &hf_snmp_msgGlobalData , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_snmp_HeaderData },
{ &hf_snmp_msgSecurityParameters, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_snmp_T_msgSecurityParameters },
{ &hf_snmp_msgData , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_snmp_ScopedPduData },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_SNMPv3Message(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
SNMPv3Message_sequence, hf_index, ett_snmp_SNMPv3Message);
if( usm_p.authenticated
&& usm_p.user_assoc ) {
const gchar* error = NULL;
proto_item* authen_item;
proto_tree* authen_tree = proto_item_add_subtree(usm_p.auth_item,ett_authParameters);
guint8* calc_auth = NULL;
guint calc_auth_len = 0;
usm_p.authOK = snmp_usm_auth(actx->pinfo, usm_p.user_assoc->user.authModel, &usm_p, &calc_auth, &calc_auth_len, &error );
if (error) {
expert_add_info_format( actx->pinfo, usm_p.auth_item, &ei_snmp_verify_authentication_error, "Error while verifying Message authenticity: %s", error );
} else {
expert_field* expert;
authen_item = proto_tree_add_boolean(authen_tree, hf_snmp_msgAuthentication, tvb, 0, 0, usm_p.authOK);
proto_item_set_generated(authen_item);
if (usm_p.authOK) {
expert = &ei_snmp_authentication_ok;
} else {
const gchar* calc_auth_str = bytes_to_str_punct(actx->pinfo->pool, calc_auth,calc_auth_len,' ');
proto_item_append_text(authen_item, " calculated = %s", calc_auth_str);
expert = &ei_snmp_authentication_error;
}
expert_add_info( actx->pinfo, authen_item, expert);
}
}
return offset;
}
static const value_string snmp_T_smux_version_vals[] = {
{ 0, "version-1" },
{ 0, NULL }
};
static int
dissect_snmp_T_smux_version(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static int
dissect_snmp_OBJECT_IDENTIFIER(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_object_identifier(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
return offset;
}
static int
dissect_snmp_DisplayString(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static const ber_sequence_t SimpleOpen_U_sequence[] = {
{ &hf_snmp_smux_version , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_T_smux_version },
{ &hf_snmp_identity , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_snmp_OBJECT_IDENTIFIER },
{ &hf_snmp_description , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_snmp_DisplayString },
{ &hf_snmp_password , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_snmp_OCTET_STRING },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_SimpleOpen_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
SimpleOpen_U_sequence, hf_index, ett_snmp_SimpleOpen_U);
return offset;
}
static int
dissect_snmp_SimpleOpen(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_APP, 0, TRUE, dissect_snmp_SimpleOpen_U);
return offset;
}
static const value_string snmp_OpenPDU_vals[] = {
{ 0, "smux-simple" },
{ 0, NULL }
};
static const ber_choice_t OpenPDU_choice[] = {
{ 0, &hf_snmp_smux_simple , BER_CLASS_APP, 0, BER_FLAGS_NOOWNTAG, dissect_snmp_SimpleOpen },
{ 0, NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_OpenPDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_choice(actx, tree, tvb, offset,
OpenPDU_choice, hf_index, ett_snmp_OpenPDU,
NULL);
return offset;
}
static const value_string snmp_ClosePDU_U_vals[] = {
{ 0, "goingDown" },
{ 1, "unsupportedVersion" },
{ 2, "packetFormat" },
{ 3, "protocolError" },
{ 4, "internalError" },
{ 5, "authenticationFailure" },
{ 0, NULL }
};
static int
dissect_snmp_ClosePDU_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static int
dissect_snmp_ClosePDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_APP, 1, TRUE, dissect_snmp_ClosePDU_U);
return offset;
}
static int
dissect_snmp_INTEGER_M1_2147483647(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static const value_string snmp_T_operation_vals[] = {
{ 0, "delete" },
{ 1, "readOnly" },
{ 2, "readWrite" },
{ 0, NULL }
};
static int
dissect_snmp_T_operation(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static const ber_sequence_t RReqPDU_U_sequence[] = {
{ &hf_snmp_subtree , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_snmp_ObjectName },
{ &hf_snmp_priority , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_INTEGER_M1_2147483647 },
{ &hf_snmp_operation , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_snmp_T_operation },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_RReqPDU_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
RReqPDU_U_sequence, hf_index, ett_snmp_RReqPDU_U);
return offset;
}
static int
dissect_snmp_RReqPDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_APP, 2, TRUE, dissect_snmp_RReqPDU_U);
return offset;
}
static const value_string snmp_RRspPDU_U_vals[] = {
{ -1, "failure" },
{ 0, NULL }
};
static int
dissect_snmp_RRspPDU_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static int
dissect_snmp_RRspPDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_APP, 3, TRUE, dissect_snmp_RRspPDU_U);
return offset;
}
static const value_string snmp_RegisterResponse_vals[] = {
{ 0, "rRspPDU" },
{ 1, "pDUs" },
{ 0, NULL }
};
static const ber_choice_t RegisterResponse_choice[] = {
{ 0, &hf_snmp_rRspPDU , BER_CLASS_APP, 3, BER_FLAGS_NOOWNTAG, dissect_snmp_RRspPDU },
{ 1, &hf_snmp_pDUs , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG, dissect_snmp_PDUs },
{ 0, NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_RegisterResponse(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_choice(actx, tree, tvb, offset,
RegisterResponse_choice, hf_index, ett_snmp_RegisterResponse,
NULL);
return offset;
}
static const value_string snmp_SOutPDU_U_vals[] = {
{ 0, "commit" },
{ 1, "rollback" },
{ 0, NULL }
};
static int
dissect_snmp_SOutPDU_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static int
dissect_snmp_SOutPDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_APP, 4, TRUE, dissect_snmp_SOutPDU_U);
return offset;
}
static const value_string snmp_SMUX_PDUs_vals[] = {
{ 0, "open" },
{ 1, "close" },
{ 2, "registerRequest" },
{ 3, "registerResponse" },
{ 4, "commitOrRollback" },
{ 0, NULL }
};
static const ber_choice_t SMUX_PDUs_choice[] = {
{ 0, &hf_snmp_open , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG, dissect_snmp_OpenPDU },
{ 1, &hf_snmp_close , BER_CLASS_APP, 1, BER_FLAGS_NOOWNTAG, dissect_snmp_ClosePDU },
{ 2, &hf_snmp_registerRequest, BER_CLASS_APP, 2, BER_FLAGS_NOOWNTAG, dissect_snmp_RReqPDU },
{ 3, &hf_snmp_registerResponse, BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG, dissect_snmp_RegisterResponse },
{ 4, &hf_snmp_commitOrRollback, BER_CLASS_APP, 4, BER_FLAGS_NOOWNTAG, dissect_snmp_SOutPDU },
{ 0, NULL, 0, 0, 0, NULL }
};
static int
dissect_snmp_SMUX_PDUs(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
snmp_conv_info_t *snmp_info = snmp_find_conversation_and_get_conv_data(actx->pinfo);
actx->private_data = snmp_info;
offset = dissect_ber_choice(actx, tree, tvb, offset,
SMUX_PDUs_choice, hf_index, ett_snmp_SMUX_PDUs,
NULL);
return offset;
}
/*--- PDUs ---*/
static int dissect_SMUX_PDUs_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
int offset = 0;
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
offset = dissect_snmp_SMUX_PDUs(FALSE, tvb, offset, &asn1_ctx, tree, hf_snmp_SMUX_PDUs_PDU);
return offset;
}
static snmp_conv_info_t*
snmp_find_conversation_and_get_conv_data(packet_info *pinfo) {
conversation_t *conversation = NULL;
snmp_conv_info_t *snmp_info = NULL;
/* Get the conversation with the wildcarded port, if it exists
* and is associated with SNMP, so that requests and responses
* can be matched even if the response comes from a different,
* ephemeral, source port, as originally done in OS/400.
* On UDP, we do not automatically call conversation_set_port2()
* and we do not want to do so. Possibly this should eventually
* use find_conversation_full and separate the "SNMP conversation"
* from "the transport layer conversation that carries SNMP."
*/
if (pinfo->destport == UDP_PORT_SNMP) {
conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, conversation_pt_to_conversation_type(pinfo->ptype),
pinfo->srcport, 0, NO_PORT_B);
} else if (pinfo->srcport == UDP_PORT_SNMP) {
conversation = find_conversation(pinfo->fd->num, &pinfo->dst, &pinfo->src, conversation_pt_to_conversation_type(pinfo->ptype),
pinfo->destport, 0, NO_PORT_B);
}
if ((conversation == NULL) || (conversation_get_dissector(conversation, pinfo->num) != snmp_handle)) {
conversation = find_or_create_conversation(pinfo);
}
snmp_info = (snmp_conv_info_t *)conversation_get_proto_data(conversation, proto_snmp);
if (snmp_info == NULL) {
snmp_info = wmem_new0(wmem_file_scope(), snmp_conv_info_t);
snmp_info->request_response=wmem_map_new(wmem_file_scope(), g_int_hash, g_int_equal);
conversation_add_proto_data(conversation, proto_snmp, snmp_info);
}
return snmp_info;
}
guint
dissect_snmp_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *tree, int proto, gint ett, gboolean is_tcp)
{
guint length_remaining;
gint8 ber_class;
bool pc, ind = 0;
gint32 tag;
guint32 len;
guint message_length;
int start_offset = offset;
guint32 version = 0;
tvbuff_t *next_tvb;
proto_tree *snmp_tree = NULL;
proto_item *item = NULL;
snmp_conv_info_t *snmp_info = snmp_find_conversation_and_get_conv_data(pinfo);
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
asn1_ctx.private_data = snmp_info;
usm_p.msg_tvb = tvb;
usm_p.start_offset = tvb_offset_from_real_beginning(tvb);
usm_p.engine_tvb = NULL;
usm_p.user_tvb = NULL;
usm_p.auth_item = NULL;
usm_p.auth_tvb = NULL;
usm_p.auth_offset = 0;
usm_p.priv_tvb = NULL;
usm_p.user_assoc = NULL;
usm_p.authenticated = FALSE;
usm_p.encrypted = FALSE;
usm_p.boots = 0;
usm_p.snmp_time = 0;
usm_p.authOK = FALSE;
/*
* This will throw an exception if we don't have any data left.
* That's what we want. (See "tcp_dissect_pdus()", which is
* similar, but doesn't have to deal with ASN.1.
* XXX - can we make "tcp_dissect_pdus()" provide enough
* information to the "get_pdu_len" routine so that we could
* have that routine deal with ASN.1, and just use
* "tcp_dissect_pdus()"?)
*/
length_remaining = tvb_ensure_captured_length_remaining(tvb, offset);
/* NOTE: we have to parse the message piece by piece, since the
* capture length may be less than the message length: a 'global'
* parsing is likely to fail.
*/
/*
* If this is SNMP-over-TCP, we might have to do reassembly
* in order to read the "Sequence Of" header.
*/
if (is_tcp && snmp_desegment && pinfo->can_desegment) {
/*
* This is TCP, and we should, and can, do reassembly.
*
* Is the "Sequence Of" header split across segment
* boundaries? We require at least 6 bytes for the
* header, which allows for a 4-byte length (ASN.1
* BER).
*/
if (length_remaining < 6) {
/*
* Yes. Tell the TCP dissector where the data
* for this message starts in the data it handed
* us and that we need "some more data." Don't tell
* it exactly how many bytes we need because if/when
* we ask for even more (after the header) that will
* break reassembly.
*/
pinfo->desegment_offset = offset;
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
return 0;
}
}
/*
* OK, try to read the "Sequence Of" header; this gets the total
* length of the SNMP message.
*/
offset = get_ber_identifier(tvb, offset, &ber_class, &pc, &tag);
/*Get the total octet length of the SNMP data*/
offset = get_ber_length(tvb, offset, &len, &ind);
message_length = len + offset;
/*Get the SNMP version data*/
/*offset =*/ dissect_ber_integer(FALSE, &asn1_ctx, 0, tvb, offset, -1, &version);
/*
* If this is SNMP-over-TCP, we might have to do reassembly
* to get all of this message.
*/
if (is_tcp && snmp_desegment && pinfo->can_desegment) {
/*
* Yes - is the message split across segment boundaries?
*/
if (length_remaining < message_length) {
/*
* Yes. Tell the TCP dissector where the data
* for this message starts in the data it handed
* us, and how many more bytes we need, and
* return.
*/
pinfo->desegment_offset = start_offset;
pinfo->desegment_len =
message_length - length_remaining;
/*
* Return 0, which means "I didn't dissect anything
* because I don't have enough data - we need
* to desegment".
*/
return 0;
}
}
var_list = next_tvb_list_new(pinfo->pool);
col_set_str(pinfo->cinfo, COL_PROTOCOL, proto_get_protocol_short_name(find_protocol_by_id(proto)));
item = proto_tree_add_item(tree, proto, tvb, start_offset, message_length, ENC_BIG_ENDIAN);
snmp_tree = proto_item_add_subtree(item, ett);
switch (version) {
case 0: /* v1 */
case 1: /* v2c */
offset = dissect_snmp_Message(FALSE , tvb, start_offset, &asn1_ctx, snmp_tree, -1);
break;
case 2: /* v2u */
offset = dissect_snmp_Messagev2u(FALSE , tvb, start_offset, &asn1_ctx, snmp_tree, -1);
break;
/* v3 */
case 3:
offset = dissect_snmp_SNMPv3Message(FALSE , tvb, start_offset, &asn1_ctx, snmp_tree, -1);
break;
default:
/*
* Return the length remaining in the tvbuff, so
* if this is SNMP-over-TCP, our caller thinks there's
* nothing left to dissect.
*/
expert_add_info(pinfo, item, &ei_snmp_version_unknown);
return length_remaining;
break;
}
/* There may be appended data after the SNMP data, so treat as raw
* data which needs to be dissected in case of UDP as UDP is PDU oriented.
*/
if((!is_tcp) && (length_remaining > (guint)offset)) {
next_tvb = tvb_new_subset_remaining(tvb, offset);
call_dissector(data_handle, next_tvb, pinfo, tree);
} else {
next_tvb_call(var_list, pinfo, tree, NULL, data_handle);
}
return offset;
}
static gint
dissect_snmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
int offset;
gint8 tmp_class;
bool tmp_pc;
gint32 tmp_tag;
guint32 tmp_length;
bool tmp_ind;
/*
* See if this looks like SNMP or not. if not, return 0 so
* wireshark can try some other dissector instead.
*/
/* All SNMP packets are BER encoded and consist of a SEQUENCE
* that spans the entire PDU. The first item is an INTEGER that
* has the values 0-2 (version 1-3).
* if not it is not snmp.
*/
/* SNMP starts with a SEQUENCE */
offset = get_ber_identifier(tvb, 0, &tmp_class, &tmp_pc, &tmp_tag);
if((tmp_class!=BER_CLASS_UNI)||(tmp_tag!=BER_UNI_TAG_SEQUENCE)) {
return 0;
}
/* then comes a length which spans the rest of the tvb */
offset = get_ber_length(tvb, offset, &tmp_length, &tmp_ind);
/* Loosen the heuristic a bit to handle the case where data has intentionally
* been added after the snmp PDU ( UDP case) (#3684)
* If this is fragmented or carried in ICMP, we don't expect the tvb to
* have the full legnth, so don't check.
*/
if (!pinfo->fragmented && !pinfo->flags.in_error_pkt) {
if ( pinfo->ptype == PT_UDP ) {
if(tmp_length>(guint32)tvb_reported_length_remaining(tvb, offset)) {
return 0;
}
}else{
if(tmp_length!=(guint32)tvb_reported_length_remaining(tvb, offset)) {
return 0;
}
}
}
/* then comes an INTEGER (version)*/
get_ber_identifier(tvb, offset, &tmp_class, &tmp_pc, &tmp_tag);
if((tmp_class!=BER_CLASS_UNI)||(tmp_tag!=BER_UNI_TAG_INTEGER)) {
return 0;
}
/* do we need to test that version is 0 - 2 (version1-3) ? */
/*
* The IBM i (OS/400) SNMP agent, at least originally, would
* send responses back from some *other* UDP port, an ephemeral
* port above 5000, going back to the same IP address and port
* from which the request came, similar to TFTP. This only happens
* with the agent port, 161, not with the trap port, etc. As of
* 2015 with the latest fixes applied, it no longer does this:
* https://www.ibm.com/support/pages/ptf/SI55487
* https://www.ibm.com/support/pages/ptf/SI55537
*
* The SNMP RFCs are silent on this (cf. L2TP RFC 2661, which
* supports using either the well-known port or an ephemeral
* port as the source port for responses, while noting that
* the latter can cause issues with firewalls and NATs.) so
* possibly some other implementations could do this.
*
* If this packet went to the SNMP port, we check to see if
* there's already a conversation with one address/port pair
* matching the source IP address and port of this packet,
* the other address matching the destination IP address of this
* packet, and any destination port.
*
* If not, we create one, with its address 1/port 1 pair being
* the source address/port of this packet, its address 2 being
* the destination address of this packet, and its port 2 being
* wildcarded, and give it the SNMP dissector as a dissector.
*/
if (pinfo->destport == UDP_PORT_SNMP) {
conversation_t *conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, conversation_pt_to_conversation_type(pinfo->ptype),
pinfo->srcport, 0, NO_PORT_B);
if( (conversation == NULL) || (conversation_get_dissector(conversation, pinfo->num)!=snmp_handle) ) {
conversation = conversation_new(pinfo->num, &pinfo->src, &pinfo->dst, conversation_pt_to_conversation_type(pinfo->ptype),
pinfo->srcport, 0, NO_PORT2);
conversation_set_dissector(conversation, snmp_handle);
}
}
return dissect_snmp_pdu(tvb, 0, pinfo, tree, proto_snmp, ett_snmp, FALSE);
}
static int
dissect_snmp_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
int offset = 0;
guint message_len;
while (tvb_reported_length_remaining(tvb, offset) > 0) {
message_len = dissect_snmp_pdu(tvb, offset, pinfo, tree, proto_snmp, ett_snmp, TRUE);
if (message_len == 0) {
/*
* We don't have all the data for that message,
* so we need to do desegmentation;
* "dissect_snmp_pdu()" has set that up.
*/
break;
}
offset += message_len;
}
return tvb_captured_length(tvb);
}
static int
dissect_smux(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
proto_tree *smux_tree = NULL;
proto_item *item = NULL;
var_list = next_tvb_list_new(pinfo->pool);
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMUX");
item = proto_tree_add_item(tree, proto_smux, tvb, 0, -1, ENC_NA);
smux_tree = proto_item_add_subtree(item, ett_smux);
return dissect_SMUX_PDUs_PDU(tvb, pinfo, smux_tree, data);
}
/*
MD5 Password to Key Algorithm from RFC 3414 A.2.1
SHA1 Password to Key Algorithm from RFC 3414 A.2.2
SHA2 Password to Key Algorithm from RFC 7860 9.3
*/
static void
snmp_usm_password_to_key(const snmp_usm_auth_model_t model, const guint8 *password,
guint passwordlen, const guint8 *engineID, guint engineLength, guint8 *key)
{
gcry_md_hd_t hash_handle;
guint8 *cp, password_buf[64];
guint32 password_index = 0;
guint32 count = 0, i;
guint hash_len;
if (gcry_md_open(&hash_handle, auth_hash_algo[model], 0)) {
return;
}
hash_len = auth_hash_len[model];
/**********************************************/
/* Use while loop until we've done 1 Megabyte */
/**********************************************/
while (count < 1048576) {
cp = password_buf;
if (passwordlen != 0) {
for (i = 0; i < 64; i++) {
/*************************************************/
/* Take the next octet of the password, wrapping */
/* to the beginning of the password as necessary.*/
/*************************************************/
*cp++ = password[password_index++ % passwordlen];
}
} else {
*cp = 0;
}
gcry_md_write(hash_handle, password_buf, 64);
count += 64;
}
memcpy(key, gcry_md_read(hash_handle, 0), hash_len);
gcry_md_close(hash_handle);
/*****************************************************/
/* Now localise the key with the engineID and pass */
/* through hash function to produce final key */
/* We ignore invalid engineLengths here. More strict */
/* checking is done in snmp_users_update_cb. */
/*****************************************************/
if (gcry_md_open(&hash_handle, auth_hash_algo[model], 0)) {
return;
}
gcry_md_write(hash_handle, key, hash_len);
gcry_md_write(hash_handle, engineID, engineLength);
gcry_md_write(hash_handle, key, hash_len);
memcpy(key, gcry_md_read(hash_handle, 0), hash_len);
gcry_md_close(hash_handle);
return;
}
static void
process_prefs(void)
{
}
UAT_LSTRING_CB_DEF(snmp_users,userName,snmp_ue_assoc_t,user.userName.data,user.userName.len)
UAT_LSTRING_CB_DEF(snmp_users,authPassword,snmp_ue_assoc_t,user.authPassword.data,user.authPassword.len)
UAT_LSTRING_CB_DEF(snmp_users,privPassword,snmp_ue_assoc_t,user.privPassword.data,user.privPassword.len)
UAT_BUFFER_CB_DEF(snmp_users,engine_id,snmp_ue_assoc_t,engine.data,engine.len)
UAT_VS_DEF(snmp_users,auth_model,snmp_ue_assoc_t,guint,0,"MD5")
UAT_VS_DEF(snmp_users,priv_proto,snmp_ue_assoc_t,guint,0,"DES")
static void *
snmp_specific_trap_copy_cb(void *dest, const void *orig, size_t len _U_)
{
snmp_st_assoc_t *u = (snmp_st_assoc_t *)dest;
const snmp_st_assoc_t *o = (const snmp_st_assoc_t *)orig;
u->enterprise = g_strdup(o->enterprise);
u->trap = o->trap;
u->desc = g_strdup(o->desc);
return dest;
}
static void
snmp_specific_trap_free_cb(void *r)
{
snmp_st_assoc_t *u = (snmp_st_assoc_t *)r;
g_free(u->enterprise);
g_free(u->desc);
}
UAT_CSTRING_CB_DEF(specific_traps, enterprise, snmp_st_assoc_t)
UAT_DEC_CB_DEF(specific_traps, trap, snmp_st_assoc_t)
UAT_CSTRING_CB_DEF(specific_traps, desc, snmp_st_assoc_t)
/*--- proto_register_snmp -------------------------------------------*/
void proto_register_snmp(void) {
/* List of fields */
static hf_register_info hf[] = {
{ &hf_snmp_response_in,
{ "Response In", "snmp.response_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
"The response to this SNMP request is in this frame", HFILL }},
{ &hf_snmp_response_to,
{ "Response To", "snmp.response_to", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
"This is a response to the SNMP request in this frame", HFILL }},
{ &hf_snmp_time,
{ "Time", "snmp.time", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
"The time between the Request and the Response", HFILL }},
{ &hf_snmp_v3_flags_auth,
{ "Authenticated", "snmp.v3.flags.auth", FT_BOOLEAN, 8,
TFS(&tfs_set_notset), TH_AUTH, NULL, HFILL }},
{ &hf_snmp_v3_flags_crypt,
{ "Encrypted", "snmp.v3.flags.crypt", FT_BOOLEAN, 8,
TFS(&tfs_set_notset), TH_CRYPT, NULL, HFILL }},
{ &hf_snmp_v3_flags_report,
{ "Reportable", "snmp.v3.flags.report", FT_BOOLEAN, 8,
TFS(&tfs_set_notset), TH_REPORT, NULL, HFILL }},
{ &hf_snmp_engineid_conform, {
"Engine ID Conformance", "snmp.engineid.conform", FT_BOOLEAN, 8,
TFS(&tfs_snmp_engineid_conform), F_SNMP_ENGINEID_CONFORM, "Engine ID RFC3411 Conformance", HFILL }},
{ &hf_snmp_engineid_enterprise, {
"Engine Enterprise ID", "snmp.engineid.enterprise", FT_UINT32, BASE_ENTERPRISES,
STRINGS_ENTERPRISES, 0, NULL, HFILL }},
{ &hf_snmp_engineid_format, {
"Engine ID Format", "snmp.engineid.format", FT_UINT8, BASE_DEC,
VALS(snmp_engineid_format_vals), 0, NULL, HFILL }},
{ &hf_snmp_engineid_ipv4, {
"Engine ID Data: IPv4 address", "snmp.engineid.ipv4", FT_IPv4, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_engineid_ipv6, {
"Engine ID Data: IPv6 address", "snmp.engineid.ipv6", FT_IPv6, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_engineid_cisco_type, {
"Engine ID Data: Cisco type", "snmp.engineid.cisco.type", FT_UINT8, BASE_HEX,
VALS(snmp_engineid_cisco_type_vals), 0, NULL, HFILL }},
{ &hf_snmp_engineid_mac, {
"Engine ID Data: MAC address", "snmp.engineid.mac", FT_ETHER, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_engineid_text, {
"Engine ID Data: Text", "snmp.engineid.text", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_engineid_time, {
"Engine ID Data: Creation Time", "snmp.engineid.time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_engineid_data, {
"Engine ID Data", "snmp.engineid.data", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_msgAuthentication, {
"Authentication", "snmp.v3.auth", FT_BOOLEAN, BASE_NONE,
TFS(&auth_flags), 0, NULL, HFILL }},
{ &hf_snmp_decryptedPDU, {
"Decrypted ScopedPDU", "snmp.decrypted_pdu", FT_BYTES, BASE_NONE,
NULL, 0, "Decrypted PDU", HFILL }},
{ &hf_snmp_noSuchObject, {
"noSuchObject", "snmp.noSuchObject", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_noSuchInstance, {
"noSuchInstance", "snmp.noSuchInstance", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_endOfMibView, {
"endOfMibView", "snmp.endOfMibView", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_unSpecified, {
"unSpecified", "snmp.unSpecified", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_integer32_value, {
"Value (Integer32)", "snmp.value.int", FT_INT64, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_octetstring_value, {
"Value (OctetString)", "snmp.value.octets", FT_BYTES, BASE_SHOW_ASCII_PRINTABLE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_oid_value, {
"Value (OID)", "snmp.value.oid", FT_OID, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_null_value, {
"Value (Null)", "snmp.value.null", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_ipv4_value, {
"Value (IpAddress)", "snmp.value.ipv4", FT_IPv4, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_ipv6_value, {
"Value (IpAddress)", "snmp.value.ipv6", FT_IPv6, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_anyaddress_value, {
"Value (IpAddress)", "snmp.value.addr", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_unsigned32_value, {
"Value (Unsigned32)", "snmp.value.u32", FT_INT64, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_gauge32_value, {
"Value (Gauge32)", "snmp.value.g32", FT_INT64, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_unknown_value, {
"Value (Unknown)", "snmp.value.unk", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_counter_value, {
"Value (Counter32)", "snmp.value.counter", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_big_counter_value, {
"Value (Counter64)", "snmp.value.counter", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_nsap_value, {
"Value (NSAP)", "snmp.value.nsap", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_timeticks_value, {
"Value (Timeticks)", "snmp.value.timeticks", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_opaque_value, {
"Value (Opaque)", "snmp.value.opaque", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_objectname, {
"Object Name", "snmp.name", FT_OID, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_scalar_instance_index, {
"Scalar Instance Index", "snmp.name.index", FT_UINT64, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_var_bind_str, {
"Variable-binding-string", "snmp.var-bind_str", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_agentid_trailer, {
"AgentID Trailer", "snmp.agentid_trailer", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_snmp_SMUX_PDUs_PDU,
{ "SMUX-PDUs", "snmp.SMUX_PDUs",
FT_UINT32, BASE_DEC, VALS(snmp_SMUX_PDUs_vals), 0,
NULL, HFILL }},
{ &hf_snmp_version,
{ "version", "snmp.version",
FT_INT32, BASE_DEC, VALS(snmp_Version_vals), 0,
NULL, HFILL }},
{ &hf_snmp_community,
{ "community", "snmp.community",
FT_STRING, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_snmp_data,
{ "data", "snmp.data",
FT_UINT32, BASE_DEC, VALS(snmp_PDUs_vals), 0,
"PDUs", HFILL }},
{ &hf_snmp_parameters,
{ "parameters", "snmp.parameters",
FT_BYTES, BASE_NONE, NULL, 0,
"OCTET_STRING", HFILL }},
{ &hf_snmp_datav2u,
{ "datav2u", "snmp.datav2u",
FT_UINT32, BASE_DEC, VALS(snmp_T_datav2u_vals), 0,
NULL, HFILL }},
{ &hf_snmp_v2u_plaintext,
{ "plaintext", "snmp.plaintext",
FT_UINT32, BASE_DEC, VALS(snmp_PDUs_vals), 0,
"PDUs", HFILL }},
{ &hf_snmp_encrypted,
{ "encrypted", "snmp.encrypted",
FT_BYTES, BASE_NONE, NULL, 0,
"OCTET_STRING", HFILL }},
{ &hf_snmp_msgAuthoritativeEngineID,
{ "msgAuthoritativeEngineID", "snmp.msgAuthoritativeEngineID",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_snmp_msgAuthoritativeEngineBoots,
{ "msgAuthoritativeEngineBoots", "snmp.msgAuthoritativeEngineBoots",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_snmp_msgAuthoritativeEngineTime,
{ "msgAuthoritativeEngineTime", "snmp.msgAuthoritativeEngineTime",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_snmp_msgUserName,
{ "msgUserName", "snmp.msgUserName",
FT_STRING, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_snmp_msgAuthenticationParameters,
{ "msgAuthenticationParameters", "snmp.msgAuthenticationParameters",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_snmp_msgPrivacyParameters,
{ "msgPrivacyParameters", "snmp.msgPrivacyParameters",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_snmp_msgVersion,
{ "msgVersion", "snmp.msgVersion",
FT_INT32, BASE_DEC, VALS(snmp_Version_vals), 0,
"Version", HFILL }},
{ &hf_snmp_msgGlobalData,
{ "msgGlobalData", "snmp.msgGlobalData_element",
FT_NONE, BASE_NONE, NULL, 0,
"HeaderData", HFILL }},
{ &hf_snmp_msgSecurityParameters,
{ "msgSecurityParameters", "snmp.msgSecurityParameters",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_snmp_msgData,
{ "msgData", "snmp.msgData",
FT_UINT32, BASE_DEC, VALS(snmp_ScopedPduData_vals), 0,
"ScopedPduData", HFILL }},
{ &hf_snmp_msgID,
{ "msgID", "snmp.msgID",
FT_UINT32, BASE_DEC, NULL, 0,
"INTEGER_0_2147483647", HFILL }},
{ &hf_snmp_msgMaxSize,
{ "msgMaxSize", "snmp.msgMaxSize",
FT_UINT32, BASE_DEC, NULL, 0,
"INTEGER_484_2147483647", HFILL }},
{ &hf_snmp_msgFlags,
{ "msgFlags", "snmp.msgFlags",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_snmp_msgSecurityModel,
{ "msgSecurityModel", "snmp.msgSecurityModel",
FT_UINT32, BASE_DEC, VALS(sec_models), 0,
NULL, HFILL }},
{ &hf_snmp_plaintext,
{ "plaintext", "snmp.plaintext_element",
FT_NONE, BASE_NONE, NULL, 0,
"ScopedPDU", HFILL }},
{ &hf_snmp_encryptedPDU,
{ "encryptedPDU", "snmp.encryptedPDU",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_snmp_contextEngineID,
{ "contextEngineID", "snmp.contextEngineID",
FT_BYTES, BASE_NONE, NULL, 0,
"SnmpEngineID", HFILL }},
{ &hf_snmp_contextName,
{ "contextName", "snmp.contextName",
FT_STRING, BASE_NONE, NULL, 0,
"OCTET_STRING", HFILL }},
{ &hf_snmp_get_request,
{ "get-request", "snmp.get_request_element",
FT_NONE, BASE_NONE, NULL, 0,
"GetRequest_PDU", HFILL }},
{ &hf_snmp_get_next_request,
{ "get-next-request", "snmp.get_next_request_element",
FT_NONE, BASE_NONE, NULL, 0,
"GetNextRequest_PDU", HFILL }},
{ &hf_snmp_get_response,
{ "get-response", "snmp.get_response_element",
FT_NONE, BASE_NONE, NULL, 0,
"GetResponse_PDU", HFILL }},
{ &hf_snmp_set_request,
{ "set-request", "snmp.set_request_element",
FT_NONE, BASE_NONE, NULL, 0,
"SetRequest_PDU", HFILL }},
{ &hf_snmp_trap,
{ "trap", "snmp.trap_element",
FT_NONE, BASE_NONE, NULL, 0,
"Trap_PDU", HFILL }},
{ &hf_snmp_getBulkRequest,
{ "getBulkRequest", "snmp.getBulkRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
"GetBulkRequest_PDU", HFILL }},
{ &hf_snmp_informRequest,
{ "informRequest", "snmp.informRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
"InformRequest_PDU", HFILL }},
{ &hf_snmp_snmpV2_trap,
{ "snmpV2-trap", "snmp.snmpV2_trap_element",
FT_NONE, BASE_NONE, NULL, 0,
"SNMPv2_Trap_PDU", HFILL }},
{ &hf_snmp_report,
{ "report", "snmp.report_element",
FT_NONE, BASE_NONE, NULL, 0,
"Report_PDU", HFILL }},
{ &hf_snmp_request_id,
{ "request-id", "snmp.request_id",
FT_INT32, BASE_DEC, NULL, 0,
"T_request_id", HFILL }},
{ &hf_snmp_error_status,
{ "error-status", "snmp.error_status",
FT_INT32, BASE_DEC, VALS(snmp_T_error_status_vals), 0,
NULL, HFILL }},
{ &hf_snmp_error_index,
{ "error-index", "snmp.error_index",
FT_INT32, BASE_DEC, NULL, 0,
"INTEGER", HFILL }},
{ &hf_snmp_variable_bindings,
{ "variable-bindings", "snmp.variable_bindings",
FT_UINT32, BASE_DEC, NULL, 0,
"VarBindList", HFILL }},
{ &hf_snmp_bulkPDU_request_id,
{ "request-id", "snmp.request_id",
FT_INT32, BASE_DEC, NULL, 0,
"Integer32", HFILL }},
{ &hf_snmp_non_repeaters,
{ "non-repeaters", "snmp.non_repeaters",
FT_UINT32, BASE_DEC, NULL, 0,
"INTEGER_0_2147483647", HFILL }},
{ &hf_snmp_max_repetitions,
{ "max-repetitions", "snmp.max_repetitions",
FT_UINT32, BASE_DEC, NULL, 0,
"INTEGER_0_2147483647", HFILL }},
{ &hf_snmp_enterprise,
{ "enterprise", "snmp.enterprise",
FT_OID, BASE_NONE, NULL, 0,
"EnterpriseOID", HFILL }},
{ &hf_snmp_agent_addr,
{ "agent-addr", "snmp.agent_addr",
FT_IPv4, BASE_NONE, NULL, 0,
"NetworkAddress", HFILL }},
{ &hf_snmp_generic_trap,
{ "generic-trap", "snmp.generic_trap",
FT_INT32, BASE_DEC, VALS(snmp_GenericTrap_vals), 0,
"GenericTrap", HFILL }},
{ &hf_snmp_specific_trap,
{ "specific-trap", "snmp.specific_trap",
FT_INT32, BASE_DEC, NULL, 0,
"SpecificTrap", HFILL }},
{ &hf_snmp_time_stamp,
{ "time-stamp", "snmp.time_stamp",
FT_UINT32, BASE_DEC, NULL, 0,
"TimeTicks", HFILL }},
{ &hf_snmp_name,
{ "name", "snmp.name",
FT_OID, BASE_NONE, NULL, 0,
"ObjectName", HFILL }},
{ &hf_snmp_valueType,
{ "valueType", "snmp.valueType_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_snmp_VarBindList_item,
{ "VarBind", "snmp.VarBind_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_snmp_open,
{ "open", "snmp.open",
FT_UINT32, BASE_DEC, VALS(snmp_OpenPDU_vals), 0,
"OpenPDU", HFILL }},
{ &hf_snmp_close,
{ "close", "snmp.close",
FT_INT32, BASE_DEC, VALS(snmp_ClosePDU_U_vals), 0,
"ClosePDU", HFILL }},
{ &hf_snmp_registerRequest,
{ "registerRequest", "snmp.registerRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
"RReqPDU", HFILL }},
{ &hf_snmp_registerResponse,
{ "registerResponse", "snmp.registerResponse",
FT_UINT32, BASE_DEC, VALS(snmp_RegisterResponse_vals), 0,
NULL, HFILL }},
{ &hf_snmp_commitOrRollback,
{ "commitOrRollback", "snmp.commitOrRollback",
FT_INT32, BASE_DEC, VALS(snmp_SOutPDU_U_vals), 0,
"SOutPDU", HFILL }},
{ &hf_snmp_rRspPDU,
{ "rRspPDU", "snmp.rRspPDU",
FT_INT32, BASE_DEC, VALS(snmp_RRspPDU_U_vals), 0,
NULL, HFILL }},
{ &hf_snmp_pDUs,
{ "pDUs", "snmp.pDUs",
FT_UINT32, BASE_DEC, VALS(snmp_PDUs_vals), 0,
NULL, HFILL }},
{ &hf_snmp_smux_simple,
{ "smux-simple", "snmp.smux_simple_element",
FT_NONE, BASE_NONE, NULL, 0,
"SimpleOpen", HFILL }},
{ &hf_snmp_smux_version,
{ "smux-version", "snmp.smux_version",
FT_INT32, BASE_DEC, VALS(snmp_T_smux_version_vals), 0,
NULL, HFILL }},
{ &hf_snmp_identity,
{ "identity", "snmp.identity",
FT_OID, BASE_NONE, NULL, 0,
"OBJECT_IDENTIFIER", HFILL }},
{ &hf_snmp_description,
{ "description", "snmp.description",
FT_BYTES, BASE_NONE, NULL, 0,
"DisplayString", HFILL }},
{ &hf_snmp_password,
{ "password", "snmp.password",
FT_BYTES, BASE_NONE, NULL, 0,
"OCTET_STRING", HFILL }},
{ &hf_snmp_subtree,
{ "subtree", "snmp.subtree",
FT_OID, BASE_NONE, NULL, 0,
"ObjectName", HFILL }},
{ &hf_snmp_priority,
{ "priority", "snmp.priority",
FT_INT32, BASE_DEC, NULL, 0,
"INTEGER_M1_2147483647", HFILL }},
{ &hf_snmp_operation,
{ "operation", "snmp.operation",
FT_INT32, BASE_DEC, VALS(snmp_T_operation_vals), 0,
NULL, HFILL }},
};
/* List of subtrees */
static gint *ett[] = {
&ett_snmp,
&ett_engineid,
&ett_msgFlags,
&ett_encryptedPDU,
&ett_decrypted,
&ett_authParameters,
&ett_internet,
&ett_varbind,
&ett_name,
&ett_value,
&ett_decoding_error,
&ett_snmp_Message,
&ett_snmp_Messagev2u,
&ett_snmp_T_datav2u,
&ett_snmp_UsmSecurityParameters,
&ett_snmp_SNMPv3Message,
&ett_snmp_HeaderData,
&ett_snmp_ScopedPduData,
&ett_snmp_ScopedPDU,
&ett_snmp_PDUs,
&ett_snmp_PDU,
&ett_snmp_BulkPDU,
&ett_snmp_Trap_PDU_U,
&ett_snmp_VarBind,
&ett_snmp_VarBindList,
&ett_snmp_SMUX_PDUs,
&ett_snmp_RegisterResponse,
&ett_snmp_OpenPDU,
&ett_snmp_SimpleOpen_U,
&ett_snmp_RReqPDU_U,
};
static ei_register_info ei[] = {
{ &ei_snmp_failed_decrypted_data_pdu, { "snmp.failed_decrypted_data_pdu", PI_MALFORMED, PI_WARN, "Failed to decrypt encryptedPDU", EXPFILL }},
{ &ei_snmp_decrypted_data_bad_formatted, { "snmp.decrypted_data_bad_formatted", PI_MALFORMED, PI_WARN, "Decrypted data not formatted as expected, wrong key?", EXPFILL }},
{ &ei_snmp_verify_authentication_error, { "snmp.verify_authentication_error", PI_MALFORMED, PI_ERROR, "Error while verifying Message authenticity", EXPFILL }},
{ &ei_snmp_authentication_ok, { "snmp.authentication_ok", PI_CHECKSUM, PI_CHAT, "SNMP Authentication OK", EXPFILL }},
{ &ei_snmp_authentication_error, { "snmp.authentication_error", PI_CHECKSUM, PI_WARN, "SNMP Authentication Error", EXPFILL }},
{ &ei_snmp_varbind_not_uni_class_seq, { "snmp.varbind.not_uni_class_seq", PI_MALFORMED, PI_WARN, "VarBind is not an universal class sequence", EXPFILL }},
{ &ei_snmp_varbind_has_indicator, { "snmp.varbind.has_indicator", PI_MALFORMED, PI_WARN, "VarBind has indicator set", EXPFILL }},
{ &ei_snmp_objectname_not_oid, { "snmp.objectname_not_oid", PI_MALFORMED, PI_WARN, "ObjectName not an OID", EXPFILL }},
{ &ei_snmp_objectname_has_indicator, { "snmp.objectname_has_indicator", PI_MALFORMED, PI_WARN, "ObjectName has indicator set", EXPFILL }},
{ &ei_snmp_value_not_primitive_encoding, { "snmp.value_not_primitive_encoding", PI_MALFORMED, PI_WARN, "value not in primitive encoding", EXPFILL }},
{ &ei_snmp_invalid_oid, { "snmp.invalid_oid", PI_MALFORMED, PI_WARN, "invalid oid", EXPFILL }},
{ &ei_snmp_varbind_wrong_tag, { "snmp.varbind.wrong_tag", PI_MALFORMED, PI_WARN, "Wrong tag for SNMP VarBind error value", EXPFILL }},
{ &ei_snmp_varbind_response, { "snmp.varbind.response", PI_RESPONSE_CODE, PI_NOTE, "Response", EXPFILL }},
{ &ei_snmp_no_instance_subid, { "snmp.no_instance_subid", PI_MALFORMED, PI_WARN, "No instance sub-id in scalar value", EXPFILL }},
{ &ei_snmp_wrong_num_of_subids, { "snmp.wrong_num_of_subids", PI_MALFORMED, PI_WARN, "Wrong number of instance sub-ids in scalar value", EXPFILL }},
{ &ei_snmp_index_suboid_too_short, { "snmp.index_suboid_too_short", PI_MALFORMED, PI_WARN, "index sub-oid shorter than expected", EXPFILL }},
{ &ei_snmp_unimplemented_instance_index, { "snmp.unimplemented_instance_index", PI_UNDECODED, PI_WARN, "OID instaces not handled, if you want this implemented please contact the wireshark developers", EXPFILL }},
{ &ei_snmp_index_suboid_len0, { "snmp.ndex_suboid_len0", PI_MALFORMED, PI_WARN, "an index sub-oid OID cannot be 0 bytes long!", EXPFILL }},
{ &ei_snmp_index_suboid_too_long, { "snmp.index_suboid_too_long", PI_MALFORMED, PI_WARN, "index sub-oid should not be longer than remaining oid size", EXPFILL }},
{ &ei_snmp_index_string_too_long, { "snmp.index_string_too_long", PI_MALFORMED, PI_WARN, "index string should not be longer than remaining oid size", EXPFILL }},
{ &ei_snmp_column_parent_not_row, { "snmp.column_parent_not_row", PI_MALFORMED, PI_ERROR, "COLUMNS's parent is not a ROW", EXPFILL }},
{ &ei_snmp_uint_too_large, { "snmp.uint_too_large", PI_UNDECODED, PI_NOTE, "Unsigned integer value > 2^64 - 1", EXPFILL }},
{ &ei_snmp_int_too_large, { "snmp.int_too_large", PI_UNDECODED, PI_NOTE, "Signed integer value > 2^63 - 1 or <= -2^63", EXPFILL }},
{ &ei_snmp_integral_value0, { "snmp.integral_value0", PI_UNDECODED, PI_NOTE, "Integral value is zero-length", EXPFILL }},
{ &ei_snmp_missing_mib, { "snmp.missing_mib", PI_UNDECODED, PI_NOTE, "Unresolved value, Missing MIB", EXPFILL }},
{ &ei_snmp_varbind_wrong_length_value, { "snmp.varbind.wrong_length_value", PI_MALFORMED, PI_WARN, "Wrong length for SNMP VarBind/value", EXPFILL }},
{ &ei_snmp_varbind_wrong_class_tag, { "snmp.varbind.wrong_class_tag", PI_MALFORMED, PI_WARN, "Wrong class/tag for SNMP VarBind/value", EXPFILL }},
{ &ei_snmp_rfc1910_non_conformant, { "snmp.rfc1910_non_conformant", PI_PROTOCOL, PI_WARN, "Data not conforming to RFC1910", EXPFILL }},
{ &ei_snmp_rfc3411_non_conformant, { "snmp.rfc3411_non_conformant", PI_PROTOCOL, PI_WARN, "Data not conforming to RFC3411", EXPFILL }},
{ &ei_snmp_version_unknown, { "snmp.version.unknown", PI_PROTOCOL, PI_WARN, "Unknown version", EXPFILL }},
{ &ei_snmp_trap_pdu_obsolete, { "snmp.trap_pdu_obsolete", PI_PROTOCOL, PI_WARN, "Trap-PDU is obsolete in this SNMP version", EXPFILL }},
};
expert_module_t* expert_snmp;
module_t *snmp_module;
static uat_field_t users_fields[] = {
UAT_FLD_BUFFER(snmp_users,engine_id,"Engine ID","Engine-id for this entry (empty = any)"),
UAT_FLD_LSTRING(snmp_users,userName,"Username","The username"),
UAT_FLD_VS(snmp_users,auth_model,"Authentication model",auth_types,"Algorithm to be used for authentication."),
UAT_FLD_LSTRING(snmp_users,authPassword,"Password","The password used for authenticating packets for this entry"),
UAT_FLD_VS(snmp_users,priv_proto,"Privacy protocol",priv_types,"Algorithm to be used for privacy."),
UAT_FLD_LSTRING(snmp_users,privPassword,"Privacy password","The password used for encrypting packets for this entry"),
UAT_END_FIELDS
};
uat_t *assocs_uat = uat_new("SNMP Users",
sizeof(snmp_ue_assoc_t),
"snmp_users",
TRUE,
&ueas,
&num_ueas,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChSNMPUsersSection",
snmp_users_copy_cb,
snmp_users_update_cb,
snmp_users_free_cb,
renew_ue_cache,
NULL,
users_fields);
static uat_field_t specific_traps_flds[] = {
UAT_FLD_CSTRING(specific_traps,enterprise,"Enterprise OID","Enterprise Object Identifier"),
UAT_FLD_DEC(specific_traps,trap,"Trap Id","The specific-trap value"),
UAT_FLD_CSTRING(specific_traps,desc,"Description","Trap type description"),
UAT_END_FIELDS
};
uat_t* specific_traps_uat = uat_new("SNMP Enterprise Specific Trap Types",
sizeof(snmp_st_assoc_t),
"snmp_specific_traps",
TRUE,
&specific_traps,
&num_specific_traps,
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
"ChSNMPEnterpriseSpecificTrapTypes",
snmp_specific_trap_copy_cb,
NULL,
snmp_specific_trap_free_cb,
NULL,
NULL,
specific_traps_flds);
/* Register protocol */
proto_snmp = proto_register_protocol(PNAME, PSNAME, PFNAME);
snmp_handle = register_dissector("snmp", dissect_snmp, proto_snmp);
/* Register fields and subtrees */
proto_register_field_array(proto_snmp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_snmp = expert_register_protocol(proto_snmp);
expert_register_field_array(expert_snmp, ei, array_length(ei));
/* Register dissector */
snmp_tcp_handle = register_dissector("snmp.tcp", dissect_snmp_tcp, proto_snmp);
/* Register configuration preferences */
snmp_module = prefs_register_protocol(proto_snmp, process_prefs);
prefs_register_bool_preference(snmp_module, "display_oid",
"Show SNMP OID in info column",
"Whether the SNMP OID should be shown in the info column",
&display_oid);
prefs_register_obsolete_preference(snmp_module, "mib_modules");
prefs_register_obsolete_preference(snmp_module, "users_file");
prefs_register_bool_preference(snmp_module, "desegment",
"Reassemble SNMP-over-TCP messages spanning multiple TCP segments",
"Whether the SNMP dissector should reassemble messages spanning multiple TCP segments."
" To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
&snmp_desegment);
prefs_register_bool_preference(snmp_module, "var_in_tree",
"Display dissected variables inside SNMP tree",
"ON - display dissected variables inside SNMP tree, OFF - display dissected variables in root tree after SNMP",
&snmp_var_in_tree);
prefs_register_uat_preference(snmp_module, "users_table",
"Users Table",
"Table of engine-user associations used for authentication and decryption",
assocs_uat);
prefs_register_uat_preference(snmp_module, "specific_traps_table",
"Enterprise Specific Trap Types",
"Table of enterprise specific-trap type descriptions",
specific_traps_uat);
#ifdef HAVE_LIBSMI
prefs_register_static_text_preference(snmp_module, "info_mibs",
"MIB settings can be changed in the Name Resolution preferences",
"MIB settings can be changed in the Name Resolution preferences");
#endif
value_sub_dissectors_table = register_dissector_table("snmp.variable_oid","SNMP Variable OID", proto_snmp, FT_STRING, STRING_CASE_SENSITIVE);
register_init_routine(init_ue_cache);
register_cleanup_routine(cleanup_ue_cache);
register_ber_syntax_dissector("SNMP", proto_snmp, dissect_snmp_tcp);
snmp_tap=register_tap("snmp");
register_srt_table(proto_snmp, NULL, 1, snmpstat_packet, snmpstat_init, NULL);
}
/*--- proto_reg_handoff_snmp ---------------------------------------*/
void proto_reg_handoff_snmp(void) {
dissector_add_uint_with_preference("udp.port", UDP_PORT_SNMP, snmp_handle);
dissector_add_uint("ethertype", ETHERTYPE_SNMP, snmp_handle);
dissector_add_uint("ipx.socket", IPX_SOCKET_SNMP_AGENT, snmp_handle);
dissector_add_uint("ipx.socket", IPX_SOCKET_SNMP_SINK, snmp_handle);
dissector_add_uint("hpext.dxsap", HPEXT_SNMP, snmp_handle);
dissector_add_uint_with_preference("tcp.port", TCP_PORT_SNMP, snmp_tcp_handle);
/* Since "regular" SNMP port and "trap" SNMP port use the same handler,
the "trap" port doesn't really need a separate preference. Just register
normally */
dissector_add_uint("tcp.port", TCP_PORT_SNMP_TRAP, snmp_tcp_handle);
dissector_add_uint("udp.port", UDP_PORT_SNMP_TRAP, snmp_handle);
dissector_add_uint("udp.port", UDP_PORT_SNMP_PATROL, snmp_handle);
data_handle = find_dissector("data");
/* SNMPv2-MIB sysDescr "1.3.6.1.2.1.1.1.0" */
dissector_add_string("snmp.variable_oid", "1.3.6.1.2.1.1.1.0",
create_dissector_handle(dissect_snmp_variable_string, proto_snmp));
/* SNMPv2-MIB::sysName.0 (1.3.6.1.2.1.1.5.0) */
dissector_add_string("snmp.variable_oid", "1.3.6.1.2.1.1.5.0",
create_dissector_handle(dissect_snmp_variable_string, proto_snmp));
/*
* Process preference settings.
*
* We can't do this in the register routine, as preferences aren't
* read until all dissector register routines have been called (so
* that all dissector preferences have been registered).
*/
process_prefs();
}
void
proto_register_smux(void)
{
static gint *ett[] = {
&ett_smux,
};
proto_smux = proto_register_protocol("SNMP Multiplex Protocol",
"SMUX", "smux");
proto_register_subtree_array(ett, array_length(ett));
smux_handle = register_dissector("smux", dissect_smux, proto_smux);
}
void
proto_reg_handoff_smux(void)
{
dissector_add_uint_with_preference("tcp.port", TCP_PORT_SMUX, smux_handle);
}
/*
* Editor modelines - https://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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-snmp.h
|
/* Do not modify this file. Changes will be overwritten. */
/* Generated automatically by the ASN.1 to Wireshark dissector compiler */
/* packet-snmp.h */
/* asn2wrs.py -b -L -p snmp -c ./snmp.cnf -s ./packet-snmp-template -D . -O ../.. snmp.asn */
/* packet-snmp.h
* Routines for snmp packet dissection
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef PACKET_SNMP_H
#define PACKET_SNMP_H
#define SNMP_REQ_GET 0
#define SNMP_REQ_GETNEXT 1
#define SNMP_REQ_SET 3
#define SNMP_REQ_GETBULK 5
#define SNMP_REQ_INFORM 6
#define SNMP_RES_GET 2
#define SNMP_TRAP 4
#define SNMP_TRAPV2 7
#define SNMP_REPORT 8
typedef struct _snmp_usm_key {
guint8* data;
guint len;
} snmp_usm_key_t;
typedef struct _snmp_ue_assoc_t snmp_ue_assoc_t;
typedef struct _snmp_usm_params_t snmp_usm_params_t;
typedef tvbuff_t* (*snmp_usm_decoder_t)(snmp_usm_params_t*, tvbuff_t* encryptedData, packet_info *pinfo, gchar const** error);
typedef enum _snmp_usm_auth_model_t {
SNMP_USM_AUTH_MD5 = 0,
SNMP_USM_AUTH_SHA1,
SNMP_USM_AUTH_SHA2_224,
SNMP_USM_AUTH_SHA2_256,
SNMP_USM_AUTH_SHA2_384,
SNMP_USM_AUTH_SHA2_512
} snmp_usm_auth_model_t;
typedef struct _snmp_user_t {
snmp_usm_key_t userName;
snmp_usm_auth_model_t authModel;
snmp_usm_key_t authPassword;
snmp_usm_key_t authKey;
snmp_usm_decoder_t privProtocol;
snmp_usm_key_t privPassword;
snmp_usm_key_t privKey;
} snmp_user_t;
typedef struct {
guint8* data;
guint len;
} snmp_engine_id_t;
struct _snmp_ue_assoc_t {
snmp_user_t user;
snmp_engine_id_t engine;
guint auth_model;
guint priv_proto;
struct _snmp_ue_assoc_t* next;
};
struct _snmp_usm_params_t {
gboolean authenticated;
gboolean encrypted;
guint start_offset;
guint auth_offset;
guint32 boots;
guint32 snmp_time;
tvbuff_t* engine_tvb;
tvbuff_t* user_tvb;
proto_item* auth_item;
tvbuff_t* auth_tvb;
tvbuff_t* priv_tvb;
tvbuff_t* msg_tvb;
snmp_ue_assoc_t* user_assoc;
gboolean authOK;
};
typedef struct snmp_request_response {
guint32 request_frame_id;
guint32 response_frame_id;
nstime_t request_time;
guint requestId;
guint request_procedure_id;
} snmp_request_response_t;
/*
* Guts of the SNMP dissector - exported for use by protocols such as
* ILMI.
*/
extern guint dissect_snmp_pdu(tvbuff_t *, int, packet_info *, proto_tree *tree,
int, gint, gboolean);
extern int dissect_snmp_engineid(proto_tree *, packet_info *, tvbuff_t *, int, int);
/*#include "packet-snmp-exp.h"*/
#endif /* PACKET_SNMP_H */
|
C
|
wireshark/epan/dissectors/packet-snort-config.c
|
/* packet-snort-config.c
*
* Copyright 2016, Martin Mathieson
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <wsutil/file_util.h>
#include <wsutil/strtoi.h>
#include <wsutil/report_message.h>
#include "packet-snort-config.h"
#include "ws_attributes.h"
/* Forward declaration */
static void parse_config_file(SnortConfig_t *snort_config, FILE *config_file_fd, const char *filename, const char *dirname, int recursion_level);
/* Skip white space from 'source', return pointer to first non-whitespace char */
static char *skipWhiteSpace(char *source, int *accumulated_offset)
{
int offset = 0;
/* Skip any leading whitespace */
while ((source[offset] == ' ') || (source[offset] == '\t')) {
offset++;
}
*accumulated_offset += offset;
return source + offset;
}
/* Read a token from source, stop when get to end of string or delimiter. */
/* - source: input string
* - delimiter: char to stop at
* - length: out param set to delimiter or end-of-string offset
* - accumulated_Length: out param that gets length added to it
* - copy: whether or an allocated string should be returned
* - returns: requested string. Returns from static buffer when copy is FALSE */
static char* read_token(char* source, char delimeter, int *length, int *accumulated_length, gboolean copy)
{
static char static_buffer[1024];
int offset = 0;
char *source_proper = skipWhiteSpace(source, accumulated_length);
while (source_proper[offset] != '\0' && source_proper[offset] != delimeter) {
offset++;
}
*length = offset;
*accumulated_length += offset;
if (copy) {
/* Copy into new string */
char *new_string = g_strndup(source_proper, offset+1);
new_string[offset] = '\0';
return new_string;
}
else {
/* Return in static buffer */
memcpy(&static_buffer, source_proper, offset);
static_buffer[offset] = '\0';
return static_buffer;
}
}
/* Add a new content field to the rule */
static gboolean rule_add_content(Rule_t *rule, const char *content_string, gboolean negated)
{
if (rule->number_contents < MAX_CONTENT_ENTRIES) {
content_t *new_content = &(rule->contents[rule->number_contents++]);
new_content->str = g_strdup(content_string);
new_content->negation = negated;
rule->last_added_content = new_content;
return TRUE;
}
return FALSE;
}
/* Set the nocase property for a rule */
static void rule_set_content_nocase(Rule_t *rule)
{
if (rule->last_added_content) {
rule->last_added_content->nocase = TRUE;
}
}
/* Set the offset property of a content field */
static void rule_set_content_offset(Rule_t *rule, gint value)
{
if (rule->last_added_content) {
rule->last_added_content->offset = value;
rule->last_added_content->offset_set = TRUE;
}
}
/* Set the depth property of a content field */
static void rule_set_content_depth(Rule_t *rule, guint value)
{
if (rule->last_added_content) {
rule->last_added_content->depth = value;
}
}
/* Set the distance property of a content field */
static void rule_set_content_distance(Rule_t *rule, gint value)
{
if (rule->last_added_content) {
rule->last_added_content->distance = value;
rule->last_added_content->distance_set = TRUE;
}
}
/* Set the distance property of a content field */
static void rule_set_content_within(Rule_t *rule, guint value)
{
if (rule->last_added_content) {
/* Assuming won't be 0... */
rule->last_added_content->within = value;
}
}
/* Set the fastpattern property of a content field */
static void rule_set_content_fast_pattern(Rule_t *rule)
{
if (rule->last_added_content) {
rule->last_added_content->fastpattern = TRUE;
}
}
/* Set the rawbytes property of a content field */
static void rule_set_content_rawbytes(Rule_t *rule)
{
if (rule->last_added_content) {
rule->last_added_content->rawbytes = TRUE;
}
}
/* Set the http_method property of a content field */
static void rule_set_content_http_method(Rule_t *rule)
{
if (rule->last_added_content) {
rule->last_added_content->http_method = TRUE;
}
}
/* Set the http_client property of a content field */
static void rule_set_content_http_client_body(Rule_t *rule)
{
if (rule->last_added_content) {
rule->last_added_content->http_client_body = TRUE;
}
}
/* Set the http_cookie property of a content field */
static void rule_set_content_http_cookie(Rule_t *rule)
{
if (rule->last_added_content) {
rule->last_added_content->http_cookie = TRUE;
}
}
/* Set the http_UserAgent property of a content field */
static void rule_set_content_http_user_agent(Rule_t *rule)
{
if (rule->last_added_content) {
rule->last_added_content->http_user_agent = TRUE;
}
}
/* Add a uricontent field to the rule */
static gboolean rule_add_uricontent(Rule_t *rule, const char *uricontent_string, gboolean negated)
{
if (rule_add_content(rule, uricontent_string, negated)) {
rule->last_added_content->content_type = UriContent;
return TRUE;
}
return FALSE;
}
/* This content field now becomes a uricontent after seeing modifier */
static void rule_set_http_uri(Rule_t *rule)
{
if (rule->last_added_content != NULL) {
rule->last_added_content->content_type = UriContent;
}
}
/* Add a pcre field to the rule */
static gboolean rule_add_pcre(Rule_t *rule, const char *pcre_string)
{
if (rule_add_content(rule, pcre_string, FALSE)) {
rule->last_added_content->content_type = Pcre;
return TRUE;
}
return FALSE;
}
/* Set the rule's classtype field */
static gboolean rule_set_classtype(Rule_t *rule, const char *classtype)
{
rule->classtype = g_strdup(classtype);
return TRUE;
}
/* Add a reference string to the rule */
static void rule_add_reference(Rule_t *rule, const char *reference_string)
{
if (rule->number_references < MAX_REFERENCE_ENTRIES) {
rule->references[rule->number_references++] = g_strdup(reference_string);
}
}
/* Check to see if the ip 'field' corresponds to an entry in the ipvar dictionary.
* If it is add entry to rule */
static void rule_check_ip_vars(SnortConfig_t *snort_config, Rule_t *rule, char *field)
{
gpointer original_key = NULL;
gpointer value = NULL;
/* Make sure field+1 not NULL. */
if (strlen(field) < 2) {
return;
}
/* Make sure there is room for another entry */
if (rule->relevant_vars.num_ip_vars >= MAX_RULE_IP_VARS) {
return;
}
/* TODO: a loop re-looking up the answer until its not just another ipvar! */
if (g_hash_table_lookup_extended(snort_config->ipvars, field+1, &original_key, &value)) {
rule->relevant_vars.ip_vars[rule->relevant_vars.num_ip_vars].name = (char*)original_key;
rule->relevant_vars.ip_vars[rule->relevant_vars.num_ip_vars].value = (char*)value;
rule->relevant_vars.num_ip_vars++;
}
}
/* Check to see if the port 'field' corresponds to an entry in the portvar dictionary.
* If it is add entry to rule */
static void rule_check_port_vars(SnortConfig_t *snort_config, Rule_t *rule, char *field)
{
gpointer original_key = NULL;
gpointer value = NULL;
/* Make sure field+1 not NULL. */
if (strlen(field) < 2) {
return;
}
/* Make sure there is room for another entry */
if (rule->relevant_vars.num_port_vars >= MAX_RULE_PORT_VARS) {
return;
}
/* TODO: a loop re-looking up the answer until its not just another portvar! */
if (g_hash_table_lookup_extended(snort_config->portvars, field+1, &original_key, &value)) {
rule->relevant_vars.port_vars[rule->relevant_vars.num_port_vars].name = (char*)original_key;
rule->relevant_vars.port_vars[rule->relevant_vars.num_port_vars].value = (char*)value;
rule->relevant_vars.num_port_vars++;
}
}
/* Look over the IP addresses and ports, and work out which variables/values are being used */
void rule_set_relevant_vars(SnortConfig_t *snort_config, Rule_t *rule)
{
int length;
int accumulated_length = 0;
char *field;
/* No need to do this twice */
if (rule->relevant_vars.relevant_vars_set) {
return;
}
/* Walk tokens up to the options, and look up ones that are addresses or ports. */
/* Skip "alert" */
read_token(rule->rule_string+accumulated_length, ' ', &length, &accumulated_length, FALSE);
/* Skip protocol. */
read_token(rule->rule_string+accumulated_length, ' ', &length, &accumulated_length, FALSE);
/* Read source address */
field = read_token(rule->rule_string+accumulated_length, ' ', &length, &accumulated_length, FALSE);
rule_check_ip_vars(snort_config, rule, field);
/* Read source port */
field = read_token(rule->rule_string+accumulated_length, ' ', &length, &accumulated_length, FALSE);
rule_check_port_vars(snort_config, rule, field);
/* Read direction */
read_token(rule->rule_string+accumulated_length, ' ', &length, &accumulated_length, FALSE);
/* Dest address */
field = read_token(rule->rule_string+accumulated_length, ' ', &length, &accumulated_length, FALSE);
rule_check_ip_vars(snort_config, rule, field);
/* Dest port */
field = read_token(rule->rule_string+accumulated_length, ' ', &length, &accumulated_length, FALSE);
rule_check_port_vars(snort_config, rule, field);
/* Set flag so won't do again for this rule */
rule->relevant_vars.relevant_vars_set = TRUE;
}
typedef enum vartype_e { var, ipvar, portvar, unknownvar } vartype_e;
/* Look for a "var", "ipvar" or "portvar" entry in this line */
static gboolean parse_variables_line(SnortConfig_t *snort_config, char *line)
{
vartype_e var_type = unknownvar;
char * variable_type;
char * variable_name;
char * value;
int length;
int accumulated_length = 0;
/* Get variable type */
variable_type = read_token(line, ' ', &length, &accumulated_length, FALSE);
if (variable_type == NULL) {
return FALSE;
}
if (strncmp(variable_type, "var", 3) == 0) {
var_type = var;
}
else if (strncmp(variable_type, "ipvar", 5) == 0) {
var_type = ipvar;
}
else if (strncmp(variable_type, "portvar", 7) == 0) {
var_type = portvar;
}
else {
return FALSE;
}
/* Get variable name */
variable_name = read_token(line+ accumulated_length, ' ', &length, &accumulated_length, TRUE);
if (variable_name == NULL) {
return FALSE;
}
/* Now value */
value = read_token(line + accumulated_length, ' ', &length, &accumulated_length, TRUE);
if (value == NULL) {
return FALSE;
}
/* Add (name->value) to table according to variable type. */
switch (var_type) {
case var:
if (strcmp(variable_name, "RULE_PATH") == 0) {
/* This can be relative or absolute. */
snort_config->rule_path = value;
snort_config->rule_path_is_absolute = g_path_is_absolute(value);
snort_debug_printf("rule_path set to %s (is_absolute=%d)\n",
snort_config->rule_path, snort_config->rule_path_is_absolute);
}
g_hash_table_insert(snort_config->vars, variable_name, value);
break;
case ipvar:
g_hash_table_insert(snort_config->ipvars, variable_name, value);
break;
case portvar:
g_hash_table_insert(snort_config->portvars, variable_name, value);
break;
default:
return FALSE;
}
return FALSE;
}
/* Hash function for where key is a string. Just add up the value of each character and return that.. */
static guint string_hash(gconstpointer key)
{
guint total=0, n=0;
const char *key_string = (const char *)key;
char c = key_string[n];
while (c != '\0') {
total += (int)c;
c = key_string[++n];
}
return total;
}
/* Comparison function for where key is a string. Simple comparison using strcmp() */
static gboolean string_equal(gconstpointer a, gconstpointer b)
{
const char *stringa = (const char*)a;
const char *stringb = (const char*)b;
return (strcmp(stringa, stringb) == 0);
}
/* Process a line that configures a reference line (invariably from 'reference.config') */
static gboolean parse_references_prefix_file_line(SnortConfig_t *snort_config, char *line)
{
char *source;
char *prefix_name, *prefix_value;
int length=0, accumulated_length=0;
int n;
if (strncmp(line, "config reference: ", 18) != 0) {
return FALSE;
}
/* Read the prefix and value */
source = line+18;
prefix_name = read_token(source, ' ', &length, &accumulated_length, TRUE);
/* Store all name chars in lower case. */
for (n=0; prefix_name[n] != '\0'; n++) {
prefix_name[n] = g_ascii_tolower(prefix_name[n]);
}
prefix_value = read_token(source+accumulated_length, ' ', &length, &accumulated_length, TRUE);
/* Add entry into table */
g_hash_table_insert(snort_config->references_prefixes, prefix_name, prefix_value);
return FALSE;
}
/* Try to expand the reference using the prefixes stored in the config */
char *expand_reference(SnortConfig_t *snort_config, char *reference)
{
static char expanded_reference[512];
int length = (int)strlen(reference);
int accumulated_length = 0;
/* Extract up to ',', then substitute prefix! */
snort_debug_printf("expand_reference(%s)\n", reference);
char *prefix = read_token(reference, ',', &length, &accumulated_length, FALSE);
if (*prefix != '\0') {
/* Convert to lowercase before lookup */
guint n;
for (n=0; prefix[n] != '\0'; n++) {
prefix[n] = g_ascii_tolower(prefix[n]);
}
/* Look up prefix in table. */
char *prefix_replacement;
prefix_replacement = (char*)g_hash_table_lookup(snort_config->references_prefixes, prefix);
/* Append prefix and remainder, and return!!!! */
if (prefix_replacement) {
snprintf(expanded_reference, 512, "%s%s", prefix_replacement, reference+length+1);
return expanded_reference;
}
else {
/* Just return the original reference */
return reference;
}
}
return "ERROR: Reference didn't contain prefix and ','!";
}
/* The rule has been matched with an alert, so update global config stats */
void rule_set_alert(SnortConfig_t *snort_config, Rule_t *rule,
guint *global_match_number,
guint *rule_match_number)
{
snort_config->stat_alerts_detected++;
*global_match_number = snort_config->stat_alerts_detected;
if (rule != NULL) {
*rule_match_number = ++rule->matches_seen;
}
}
/* Delete an individual entry from a string table. */
static gboolean delete_string_entry(gpointer key,
gpointer value,
gpointer user_data _U_)
{
char *key_string = (char*)key;
char *value_string = (char*)value;
g_free(key_string);
g_free(value_string);
return TRUE;
}
/* See if this is an include line, if it is open the file and call parse_config_file() */
static gboolean parse_include_file(SnortConfig_t *snort_config, char *line, const char *config_directory, int recursion_level)
{
int length;
int accumulated_length = 0;
char *include_filename;
/* Look for "include " */
char *include_token = read_token(line, ' ', &length, &accumulated_length, FALSE);
if (strlen(include_token) == 0) {
return FALSE;
}
if (strncmp(include_token, "include", 7) != 0) {
return FALSE;
}
/* Read the filename */
include_filename = read_token(line+accumulated_length, ' ', &length, &accumulated_length, FALSE);
if (*include_filename != '\0') {
FILE *new_config_fd;
char *substituted_filename;
gboolean is_rule_file = FALSE;
/* May need to substitute variables into include path. */
if (strncmp(include_filename, "$RULE_PATH", 10) == 0) {
/* Write rule path variable value */
/* Don't assume $RULE_PATH will end in a file separator */
if (snort_config->rule_path_is_absolute) {
/* Rule path is absolute, so it can go at start */
substituted_filename = g_build_path(G_DIR_SEPARATOR_S,
snort_config->rule_path,
include_filename + 11,
NULL);
}
else {
/* Rule path is relative to config directory, so it goes first */
substituted_filename = g_build_path(G_DIR_SEPARATOR_S,
config_directory,
snort_config->rule_path,
include_filename + 11,
NULL);
}
is_rule_file = TRUE;
}
else {
/* No $RULE_PATH, just use directory and filename */
/* But may not even need directory if included_folder is absolute! */
if (!g_path_is_absolute(include_filename)) {
substituted_filename = g_build_path(G_DIR_SEPARATOR_S,
config_directory, include_filename, NULL);
}
else {
substituted_filename = g_strdup(include_filename);
}
}
/* Try to open the file. */
new_config_fd = ws_fopen(substituted_filename, "r");
if (new_config_fd == NULL) {
snort_debug_printf("Failed to open config file %s\n", substituted_filename);
report_failure("Snort dissector: Failed to open config file %s\n", substituted_filename);
g_free(substituted_filename);
return FALSE;
}
/* Parse the file */
if (is_rule_file) {
snort_config->stat_rules_files++;
}
parse_config_file(snort_config, new_config_fd, substituted_filename, config_directory, recursion_level + 1);
g_free(substituted_filename);
/* Close the file */
fclose(new_config_fd);
return TRUE;
}
return FALSE;
}
/* Process an individual option - i.e. the elements found between '(' and ')' */
static void process_rule_option(Rule_t *rule, char *options, int option_start_offset, int options_end_offset, int colon_offset)
{
static char name[1024], value[1024];
name[0] = '\0';
value[0] = '\0';
gint value_length = 0;
guint32 value32 = 0;
gint spaces_after_colon = 0;
if (colon_offset != 0) {
/* Name and value */
(void) g_strlcpy(name, options+option_start_offset, colon_offset-option_start_offset);
if (options[colon_offset] == ' ') {
spaces_after_colon = 1;
}
(void) g_strlcpy(value, options+colon_offset+spaces_after_colon, options_end_offset-spaces_after_colon-colon_offset);
value_length = (gint)strlen(value);
}
else {
/* Just name */
(void) g_strlcpy(name, options+option_start_offset, options_end_offset-option_start_offset);
}
/* Some rule options expect a number, parse it now. Note that any space
* after the value will currently result in the number being ignored. */
ws_strtoi32(value, NULL, &value32);
/* Think this is space at end of all options - don't compare with option names */
if (name[0] == '\0') {
return;
}
/* Process the rule options that we are interested in */
if (strcmp(name, "msg") == 0) {
rule->msg = g_strdup(value);
}
else if (strcmp(name, "sid") == 0) {
rule->sid = value32;
}
else if (strcmp(name, "rev") == 0) {
rule->rev = value32;
}
else if (strcmp(name, "content") == 0) {
int value_start = 0;
if (value_length < 3) {
return;
}
/* Need to trim off " ", but first check for ! */
if (value[0] == '!') {
value_start = 1;
if (value_length < 4) {
/* i.e. also need quotes + at least one character */
return;
}
}
value[options_end_offset-colon_offset-spaces_after_colon-2] = '\0';
rule_add_content(rule, value+value_start+1, value_start == 1);
}
else if (strcmp(name, "uricontent") == 0) {
int value_start = 0;
if (value_length < 3) {
return;
}
/* Need to trim off " ", but first check for ! */
if (value[0] == '!') {
value_start = 1;
if (value_length < 4) {
return;
}
}
value[options_end_offset-colon_offset-spaces_after_colon-2] = '\0';
rule_add_uricontent(rule, value+value_start+1, value_start == 1);
}
else if (strcmp(name, "http_uri") == 0) {
rule_set_http_uri(rule);
}
else if (strcmp(name, "pcre") == 0) {
int value_start = 0;
/* Need at least opening and closing / */
if (value_length < 3) {
return;
}
/* Not expecting negation (!)... */
value[options_end_offset-colon_offset-spaces_after_colon-2] = '\0';
rule_add_pcre(rule, value+value_start+1);
}
else if (strcmp(name, "nocase") == 0) {
rule_set_content_nocase(rule);
}
else if (strcmp(name, "offset") == 0) {
rule_set_content_offset(rule, value32);
}
else if (strcmp(name, "depth") == 0) {
rule_set_content_depth(rule, value32);
}
else if (strcmp(name, "within") == 0) {
rule_set_content_within(rule, value32);
}
else if (strcmp(name, "distance") == 0) {
rule_set_content_distance(rule, value32);
}
else if (strcmp(name, "fast_pattern") == 0) {
rule_set_content_fast_pattern(rule);
}
else if (strcmp(name, "http_method") == 0) {
rule_set_content_http_method(rule);
}
else if (strcmp(name, "http_client_body") == 0) {
rule_set_content_http_client_body(rule);
}
else if (strcmp(name, "http_cookie") == 0) {
rule_set_content_http_cookie(rule);
}
else if (strcmp(name, "http_user_agent") == 0) {
rule_set_content_http_user_agent(rule);
}
else if (strcmp(name, "rawbytes") == 0) {
rule_set_content_rawbytes(rule);
}
else if (strcmp(name, "classtype") == 0) {
rule_set_classtype(rule, value);
}
else if (strcmp(name, "reference") == 0) {
rule_add_reference(rule, value);
}
else {
/* Ignore an option we don't currently handle */
}
}
/* Parse a Snort alert, return TRUE if successful */
static gboolean parse_rule(SnortConfig_t *snort_config, char *line, const char *filename, int line_number, int line_length)
{
char *options_start;
char *options;
gboolean in_quotes = FALSE;
int options_start_index = 0, options_index = 0, colon_offset = 0;
char c;
int length = 0; /* CID 1398227 (bogus - read_token() always sets it) */
Rule_t *rule = NULL;
/* Rule will begin with alert */
if (strncmp(line, "alert ", 6) != 0) {
return FALSE;
}
/* Allocate the rule itself */
rule = g_new(Rule_t, 1);
snort_debug_printf("looks like a rule: %s\n", line);
memset(rule, 0, sizeof(Rule_t));
rule->rule_string = g_strdup(line);
rule->file = g_strdup(filename);
rule->line_number = line_number;
/* Next token is the protocol */
rule->protocol = read_token(line+6, ' ', &length, &length, TRUE);
/* Find start of options. */
options_start = strstr(line, "(");
if (options_start == NULL) {
snort_debug_printf("start of options not found\n");
g_free(rule);
return FALSE;
}
options_index = (int)(options_start-line) + 1;
/* To make parsing simpler, replace final ')' with ';' */
if (line[line_length-1] != ')') {
g_free(rule);
return FALSE;
}
else {
line[line_length-1] = ';';
}
/* Skip any spaces before next option */
while (line[options_index] == ' ') options_index++;
/* Now look for next ';', process one option at a time */
options = &line[options_index];
options_index = 0;
while ((c = options[options_index++])) {
/* Keep track of whether inside quotes */
if (c == '"') {
in_quotes = !in_quotes;
}
/* Ignore ';' while inside quotes */
if (!in_quotes) {
if (c == ':') {
colon_offset = options_index;
}
if (c == ';') {
/* End of current option - add to rule. */
process_rule_option(rule, options, options_start_index, options_index, colon_offset);
/* Skip any spaces before next option */
while (options[options_index] == ' ') options_index++;
/* Next rule will start here */
options_start_index = options_index;
colon_offset = 0;
in_quotes = FALSE;
}
}
}
/* Add rule to map of rules. */
g_hash_table_insert(snort_config->rules, GUINT_TO_POINTER((guint)rule->sid), rule);
snort_debug_printf("Snort rule with SID=%u added to table\n", rule->sid);
return TRUE;
}
/* Delete an individual rule */
static gboolean delete_rule(gpointer key _U_,
gpointer value,
gpointer user_data _U_)
{
Rule_t *rule = (Rule_t*)value;
unsigned int n;
/* Delete strings on heap. */
g_free(rule->rule_string);
g_free(rule->file);
g_free(rule->msg);
g_free(rule->classtype);
g_free(rule->protocol);
for (n=0; n < rule->number_contents; n++) {
g_free(rule->contents[n].str);
g_free(rule->contents[n].translated_str);
}
for (n=0; n < rule->number_references; n++) {
g_free(rule->references[n]);
}
snort_debug_printf("Freeing rule at :%p\n", rule);
g_free(rule);
return TRUE;
}
/* Parse this file, adding details to snort_config. */
/* N.B. using recursion_level to limit stack depth. */
#define MAX_CONFIG_FILE_RECURSE_DEPTH 8
static void parse_config_file(SnortConfig_t *snort_config, FILE *config_file_fd,
const char *filename, const char *dirname, int recursion_level)
{
#define MAX_LINE_LENGTH 4096
char line[MAX_LINE_LENGTH];
int line_number = 0;
snort_debug_printf("parse_config_file(filename=%s, recursion_level=%d)\n", filename, recursion_level);
if (recursion_level > MAX_CONFIG_FILE_RECURSE_DEPTH) {
return;
}
/* Read each line of the file in turn, and see if we want any info from it. */
while (fgets(line, MAX_LINE_LENGTH, config_file_fd)) {
int line_length;
++line_number;
/* Nothing interesting to parse */
if ((line[0] == '\0') || (line[0] == '#')) {
continue;
}
/* Trim newline from end */
line_length = (int)strlen(line);
while (line_length && ((line[line_length - 1] == '\n') || (line[line_length - 1] == '\r'))) {
--line_length;
}
line[line_length] = '\0';
if (line_length == 0) {
continue;
}
/* Offer line to the various parsing functions. Could optimise order.. */
if (parse_variables_line(snort_config, line)) {
continue;
}
if (parse_references_prefix_file_line(snort_config, line)) {
continue;
}
if (parse_include_file(snort_config, line, dirname, recursion_level)) {
continue;
}
if (parse_rule(snort_config, line, filename, line_number, line_length)) {
snort_config->stat_rules++;
continue;
}
}
}
/* Create the global ConfigParser */
void create_config(SnortConfig_t **snort_config, const char *snort_config_file)
{
gchar* dirname;
gchar* basename;
FILE *config_file_fd;
snort_debug_printf("create_config (%s)\n", snort_config_file);
*snort_config = g_new(SnortConfig_t, 1);
memset(*snort_config, 0, sizeof(SnortConfig_t));
/* Create rule table */
(*snort_config)->rules = g_hash_table_new(g_direct_hash, g_direct_equal);
/* Create reference prefix table */
(*snort_config)->references_prefixes = g_hash_table_new(string_hash, string_equal);
/* Vars tables */
(*snort_config)->vars = g_hash_table_new(string_hash, string_equal);
(*snort_config)->ipvars = g_hash_table_new(string_hash, string_equal);
(*snort_config)->portvars = g_hash_table_new(string_hash, string_equal);
/* Extract separate directory and filename. */
dirname = g_path_get_dirname(snort_config_file);
basename = g_path_get_basename(snort_config_file);
/* Attempt to open the config file */
config_file_fd = ws_fopen(snort_config_file, "r");
if (config_file_fd == NULL) {
snort_debug_printf("Failed to open config file %s\n", snort_config_file);
report_failure("Snort dissector: Failed to open config file %s\n", snort_config_file);
}
else {
/* Start parsing from the top-level config file. */
parse_config_file(*snort_config, config_file_fd, snort_config_file, dirname, 1 /* recursion level */);
fclose(config_file_fd);
}
g_free(dirname);
g_free(basename);
}
/* Delete the entire config */
void delete_config(SnortConfig_t **snort_config)
{
snort_debug_printf("delete_config()\n");
/* Iterate over all rules, freeing each one! */
g_hash_table_foreach_remove((*snort_config)->rules, delete_rule, NULL);
g_hash_table_destroy((*snort_config)->rules);
/* References table */
g_hash_table_foreach_remove((*snort_config)->references_prefixes, delete_string_entry, NULL);
g_hash_table_destroy((*snort_config)->references_prefixes);
/* Free up variable tables */
g_hash_table_foreach_remove((*snort_config)->vars, delete_string_entry, NULL);
g_hash_table_destroy((*snort_config)->vars);
g_hash_table_foreach_remove((*snort_config)->ipvars, delete_string_entry, NULL);
g_hash_table_destroy((*snort_config)->ipvars);
g_hash_table_foreach_remove((*snort_config)->portvars, delete_string_entry, NULL);
g_hash_table_destroy((*snort_config)->portvars);
g_free(*snort_config);
*snort_config = NULL;
}
/* Look for a rule corresponding to the given SID */
Rule_t *get_rule(SnortConfig_t *snort_config, guint32 sid)
{
if ((snort_config == NULL) || (snort_config->rules == NULL)) {
return NULL;
}
else {
return (Rule_t*)g_hash_table_lookup(snort_config->rules, GUINT_TO_POINTER(sid));
}
}
/* Fetch some statistics. */
void get_global_rule_stats(SnortConfig_t *snort_config, unsigned int sid,
unsigned int *number_rules_files, unsigned int *number_rules,
unsigned int *alerts_detected, unsigned int *this_rule_alerts_detected)
{
*number_rules_files = snort_config->stat_rules_files;
*number_rules = snort_config->stat_rules;
*alerts_detected = snort_config->stat_alerts_detected;
Rule_t *rule;
/* Look up rule and get current/total matches */
rule = get_rule(snort_config, sid);
if (rule) {
*this_rule_alerts_detected = rule->matches_seen;
}
else {
*this_rule_alerts_detected = 0;
}
}
/* Reset stats on individual rule */
static void reset_rule_stats(gpointer key _U_,
gpointer value,
gpointer user_data _U_)
{
Rule_t *rule = (Rule_t*)value;
rule->matches_seen = 0;
}
/* Reset stats on all rules */
void reset_global_rule_stats(SnortConfig_t *snort_config)
{
/* Reset global stats */
if (snort_config == NULL) {
return;
}
snort_config->stat_alerts_detected = 0;
/* Iterate over all rules, resetting the stats of each */
g_hash_table_foreach(snort_config->rules, reset_rule_stats, NULL);
}
/*************************************************************************************/
/* Dealing with content fields and trying to find where it matches within the packet */
/* Parse content strings to interpret binary and escaped characters. Do this */
/* so we can look for in frame using memcmp(). */
static unsigned char content_get_nibble_value(char c)
{
static unsigned char values[256];
static gboolean values_set = FALSE;
if (!values_set) {
/* Set table once and for all */
unsigned char ch;
for (ch='a'; ch <= 'f'; ch++) {
values[ch] = 0xa + (ch-'a');
}
for (ch='A'; ch <= 'F'; ch++) {
values[ch] = 0xa + (ch-'A');
}
for (ch='0'; ch <= '9'; ch++) {
values[ch] = (ch-'0');
}
values_set = TRUE;
}
return values[(unsigned char)c];
}
/* Go through string, converting hex digits into guint8, and removing escape characters. */
guint content_convert_to_binary(content_t *content)
{
int output_idx = 0;
gboolean in_binary_mode = FALSE; /* Are we in a binary region of the string? */
gboolean have_one_nibble = FALSE; /* Do we have the first nibble of the pair needed to make a byte? */
unsigned char one_nibble = 0; /* Value of first nibble if we have it */
char c;
int n;
gboolean have_backslash = FALSE;
static gchar binary_str[1024];
/* Just return length if have previously translated in binary string. */
if (content->translated) {
return content->translated_length;
}
/* Walk over each character, work out what needs to be written into output */
for (n=0; content->str[n] != '\0'; n++) {
c = content->str[n];
if (c == '|') {
/* Flip binary mode */
in_binary_mode = !in_binary_mode;
continue;
}
if (!in_binary_mode) {
/* Not binary mode. Copying characters into output buffer, but watching out for escaped chars. */
if (!have_backslash) {
if (c == '\\') {
/* Just note that we have a backslash */
have_backslash = TRUE;
continue;
}
else {
/* Just copy the character straight into output. */
binary_str[output_idx++] = (unsigned char)c;
}
}
else {
/* Currently have a backslash. Reset flag. */
have_backslash = 0;
/* Just copy the character into output. Really, the only characters that should be escaped
are ';' and '\' and '"' */
binary_str[output_idx++] = (unsigned char)c;
}
}
else {
/* Binary mode. Handle pairs of hex digits and translate into guint8 */
if (c == ' ') {
/* Ignoring inside binary mode */
continue;
}
else {
unsigned char nibble = content_get_nibble_value(c);
if (!have_one_nibble) {
/* Store first nibble of a pair */
one_nibble = nibble;
have_one_nibble = TRUE;
}
else {
/* Combine both nibbles into a byte */
binary_str[output_idx++] = (one_nibble << 4) + nibble;
/* Reset flag - looking for new pair of nibbles */
have_one_nibble = FALSE;
}
}
}
}
/* Store result for next time. */
content->translated_str = (guchar*)g_malloc(output_idx+1);
memcpy(content->translated_str, binary_str, output_idx+1);
content->translated = TRUE;
content->translated_length = output_idx;
return output_idx;
}
/* In order to use glib's regex library, need to trim
'/' delimiters and any modifiers from the end of the string */
gboolean content_convert_pcre_for_regex(content_t *content)
{
guint pcre_length, i, end_delimiter_offset = 0;
/* Return if already converted */
if (content->translated_str) {
return TRUE;
}
pcre_length = (guint)strlen(content->str);
/* Start with content->str */
if (pcre_length < 3) {
/* Can't be valid. Expect /regex/[modifiers] */
return FALSE;
}
if (pcre_length >= 512) {
/* Have seen regex library crash on very long expressions
* (830 bytes) as seen in SID=2019326, REV=6 */
return FALSE;
}
/* Verify that string starts with / */
if (content->str[0] != '/') {
return FALSE;
}
/* Next, look for closing / near end of string */
for (i=pcre_length-1; i > 2; i--) {
if (content->str[i] == '/') {
end_delimiter_offset = i;
break;
}
else {
switch (content->str[i]) {
case 'i':
content->pcre_case_insensitive = TRUE;
break;
case 's':
content->pcre_dot_includes_newline = TRUE;
break;
case 'B':
content->pcre_raw = TRUE;
break;
case 'm':
content->pcre_multiline = TRUE;
break;
default:
/* TODO: handle other modifiers that will get seen? */
/* N.B. 'U' (match in decoded URI buffers) can't be handled, so don't store in flag. */
/* N.B. not sure if/how to handle 'R' (effectively distance:0) */
snort_debug_printf("Unhandled pcre modifier '%c'\n", content->str[i]);
break;
}
}
}
if (end_delimiter_offset == 0) {
/* Didn't find it */
return FALSE;
}
/* Store result for next time. */
content->translated_str = (guchar*)g_malloc(end_delimiter_offset);
memcpy(content->translated_str, content->str+1, end_delimiter_offset - 1);
content->translated_str[end_delimiter_offset-1] = '\0';
content->translated = TRUE;
content->translated_length = end_delimiter_offset - 1;
return TRUE;
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-snort-config.h
|
/* packet-snort-config.h
*
* Copyright 2016, Martin Mathieson
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PACKET_SNORT_CONFIG_H__
#define __PACKET_SNORT_CONFIG_H__
#include <glib.h>
/* #define SNORT_CONFIG_DEBUG */
#ifdef SNORT_CONFIG_DEBUG
#include <stdio.h>
#define snort_debug_printf printf
#else
#define snort_debug_printf(...)
#endif
/************************************************************************/
/* Rule related data types */
typedef enum content_type_t {
Content,
UriContent,
Pcre
} content_type_t;
/* Content (within an alert/rule) */
typedef struct content_t {
/* Details as parsed from rule */
content_type_t content_type;
char *str;
gboolean negation; /* i.e. pattern must not appear */
gboolean nocase; /* when set, do case insensitive match */
gboolean offset_set; /* Where to start looking within packet. -65535 -> 65535 */
gint offset;
guint depth; /* How far to look into packet. Can't be 0 */
gboolean distance_set;
gint distance; /* Same as offset but relative to last match. -65535 -> 65535 */
guint within; /* Most bytes from end of previous match. Max 65535 */
gboolean fastpattern; /* Is most distinctive content in rule */
gboolean rawbytes; /* Match should be done against raw bytes (which we do anyway) */
/* http preprocessor modifiers */
gboolean http_method;
gboolean http_client_body;
gboolean http_cookie;
gboolean http_user_agent;
/* Pattern converted into bytes for matching against packet.
Used for regular patterns and PCREs alike. */
guchar *translated_str;
gboolean translated;
guint translated_length;
gboolean pcre_case_insensitive;
gboolean pcre_dot_includes_newline;
gboolean pcre_raw;
gboolean pcre_multiline;
} content_t;
/* This is to keep track of a variable referenced by a rule */
typedef struct used_variable_t {
char *name;
char *value;
} used_variable_t;
/* The collection of variables referenced by a rule */
typedef struct relevant_vars_t {
gboolean relevant_vars_set;
#define MAX_RULE_PORT_VARS 6
guint num_port_vars;
used_variable_t port_vars[MAX_RULE_PORT_VARS];
#define MAX_RULE_IP_VARS 6
guint num_ip_vars;
used_variable_t ip_vars[MAX_RULE_IP_VARS];
} relevant_vars_t;
/* This is purely the information parsed from the config */
typedef struct Rule_t {
char *rule_string; /* The whole rule as read from the rule file */
char *file; /* Name of the rule file */
guint line_number; /* Line number of rule within rule file */
char *msg; /* Description of the rule */
char *classtype;
guint32 sid, rev;
char *protocol;
/* content strings to match on */
unsigned int number_contents;
#define MAX_CONTENT_ENTRIES 30
content_t contents[MAX_CONTENT_ENTRIES];
/* Keep this pointer so can update attributes as parse modifier options */
content_t *last_added_content;
/* References describing the rule */
unsigned int number_references;
#define MAX_REFERENCE_ENTRIES 20
char *references[MAX_REFERENCE_ENTRIES];
relevant_vars_t relevant_vars;
/* Statistics */
guint matches_seen;
} Rule_t;
/* Whole global snort config as learned by parsing config files */
typedef struct SnortConfig_t
{
/* Variables (var, ipvar, portvar) */
GHashTable *vars;
GHashTable *ipvars;
GHashTable *portvars;
char *rule_path;
gboolean rule_path_is_absolute;
/* (sid -> Rule_t*) table */
GHashTable *rules;
/* Reference (web .link) prefixes */
GHashTable *references_prefixes;
/* Statistics (that may be reset) */
guint stat_rules_files;
guint stat_rules;
guint stat_alerts_detected;
} SnortConfig_t;
/*************************************************************************************/
/* API functions */
void create_config(SnortConfig_t **snort_config, const char *snort_config_file);
void delete_config(SnortConfig_t **snort_config);
/* Look up rule by SID */
Rule_t *get_rule(SnortConfig_t *snort_config, guint32 sid);
void rule_set_alert(SnortConfig_t *snort_config, Rule_t *rule, guint *global_match_number, guint *rule_match_number);
/* IP and port vars */
void rule_set_relevant_vars(SnortConfig_t *snort_config, Rule_t *rule);
/* Substitute prefix (from reference.config) into reference string */
char *expand_reference(SnortConfig_t *snort_config, char *reference);
/* Rule stats */
void get_global_rule_stats(SnortConfig_t *snort_config, unsigned int sid,
unsigned int *number_rules_files, unsigned int *number_rules,
unsigned int *alerts_detected, unsigned int *this_rule_alerts_detected);
void reset_global_rule_stats(SnortConfig_t *snort_config);
/* Expanding a content field string to the expected binary bytes */
guint content_convert_to_binary(content_t *content);
gboolean content_convert_pcre_for_regex(content_t *content);
#endif
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-snort.c
|
/* packet-snort.c
*
* Copyright 2011, Jakub Zawadzki <[email protected]>
* Copyright 2016, Martin Mathieson
*
* Google Summer of Code 2011 for The Honeynet Project
* Mentors:
* Guillaume Arcas <guillaume.arcas (at) retiaire.org>
* Jeff Nathan <jeffnathan (at) gmail.com>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* TODO:
* - sort out threading/channel-sync so works reliably in tshark
* - postponed for now, as Qt crashes if call g_main_context_iteration()
* at an inopportune time
* - have looked into writing a tap that could provide an interface for error messages/events and snort stats,
* but not easy as taps are not usually listening when alerts are detected
* - for a content/pcre match, find all protocol fields that cover same bytes and show in tree
* - other use-cases as suggested in https://sharkfesteurope.wireshark.org/assets/presentations16eu/14.pptx
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/expert.h>
#include <wsutil/file_util.h>
#include <wsutil/report_message.h>
#include <wiretap/wtap.h>
#include "packet-snort-config.h"
/* Forward declarations */
void proto_register_snort(void);
void proto_reg_handoff_snort(void);
static int proto_snort = -1;
/* These are from parsing snort fast_alert output and/or looking up snort config */
static int hf_snort_raw_alert = -1;
static int hf_snort_classification = -1;
static int hf_snort_rule = -1;
static int hf_snort_msg = -1;
static int hf_snort_rev = -1;
static int hf_snort_sid = -1;
static int hf_snort_generator = -1;
static int hf_snort_priority = -1;
static int hf_snort_rule_string = -1;
static int hf_snort_rule_protocol = -1;
static int hf_snort_rule_filename = -1;
static int hf_snort_rule_line_number = -1;
static int hf_snort_rule_ip_var = -1;
static int hf_snort_rule_port_var = -1;
static int hf_snort_reassembled_in = -1;
static int hf_snort_reassembled_from = -1;
/* Patterns to match */
static int hf_snort_content = -1;
static int hf_snort_uricontent = -1;
static int hf_snort_pcre = -1;
/* Web links */
static int hf_snort_reference = -1;
/* General stats about the rule set */
static int hf_snort_global_stats = -1;
static int hf_snort_global_stats_rule_file_count = -1; /* number of rules files */
static int hf_snort_global_stats_rule_count = -1; /* number of rules in config */
static int hf_snort_global_stats_total_alerts_count = -1;
static int hf_snort_global_stats_alert_match_number = -1;
static int hf_snort_global_stats_rule_alerts_count = -1;
static int hf_snort_global_stats_rule_match_number = -1;
/* Subtrees */
static int ett_snort = -1;
static int ett_snort_rule = -1;
static int ett_snort_global_stats = -1;
/* Expert info */
static expert_field ei_snort_alert = EI_INIT;
static expert_field ei_snort_content_not_matched = EI_INIT;
static dissector_handle_t snort_handle;
/*****************************************/
/* Preferences */
/* Where to look for alerts. */
enum alerts_source {
FromNowhere, /* disabled */
FromRunningSnort,
FromUserComments /* see https://blog.packet-foo.com/2015/08/verifying-iocs-with-snort-and-tracewrangler/ */
};
/* By default, dissector is effectively disabled */
static gint pref_snort_alerts_source = (gint)FromNowhere;
/* Snort binary and config file */
#ifndef _WIN32
static const char *pref_snort_binary_filename = "/usr/sbin/snort";
static const char *pref_snort_config_filename = "/etc/snort/snort.conf";
#else
/* Default locations from Snort Windows installer */
static const char *pref_snort_binary_filename = "C:\\Snort\\bin\\snort.exe";
static const char *pref_snort_config_filename = "C:\\Snort\\etc\\snort.conf";
#endif
/* Should rule stats be shown in protocol tree? */
static gboolean snort_show_rule_stats = FALSE;
/* Should alerts be added as expert info? */
static gboolean snort_show_alert_expert_info = FALSE;
/* Should we try to attach the alert to the tcp.reassembled_in frame instead of current one? */
static gboolean snort_alert_in_reassembled_frame = FALSE;
/* Should Snort ignore checksum errors (as will likely be seen because of check offloading or
* possibly if trying to capture live in a container)? */
static gboolean snort_ignore_checksum_errors = TRUE;
/********************************************************/
/* Global variable with single parsed snort config */
static SnortConfig_t *g_snort_config = NULL;
/******************************************************/
/* This is to keep track of the running Snort process */
typedef struct {
gboolean running;
gboolean working;
GPid pid;
int in, out, err; /* fds for talking to snort process */
GString *buf; /* Incomplete alert output that has been read */
wtap_dumper *pdh; /* wiretap dumper used to deliver packets to 'in' */
GIOChannel *channel; /* IO channel used for readimg stdout (alerts) */
wmem_tree_t *alerts_tree; /* Lookup from frame-number -> Alerts_t* */
} snort_session_t;
/* Global instance of the snort session */
static snort_session_t current_session;
static int snort_config_ok = TRUE; /* N.B. Not running test at the moment... */
/*************************************************/
/* An alert.
Created by parsing alert from snort, hopefully with more details linked from matched_rule. */
typedef struct Alert_t {
/* Rule */
guint32 sid; /* Rule identifier */
guint32 rev; /* Revision number of rule */
guint32 gen; /* Which engine generated alert (not often interesting) */
int prio; /* Priority as reported in alert (not usually interesting) */
char *raw_alert; /* The whole alert string as reported by snort */
gboolean raw_alert_ts_fixed; /* Set when correct timestamp is restored before displaying */
char *msg; /* Rule msg/description as it appears in the alert */
char *classification; /* Classification type of rule */
Rule_t *matched_rule; /* Link to corresponding rule from snort config */
guint32 original_frame;
guint32 reassembled_frame;
/* Stats for this alert among the capture file. */
unsigned int overall_match_number;
unsigned int rule_match_number;
} Alert_t;
/* Can have multiple alerts fire on same frame, so define this container */
typedef struct Alerts_t {
/* N.B. Snort limit appears to be 6 (at least with default config..) */
#define MAX_ALERTS_PER_FRAME 8
Alert_t alerts[MAX_ALERTS_PER_FRAME];
guint num_alerts;
} Alerts_t;
/* Add an alert to the map stored in current_session.
* N.B. even if preference 'snort_alert_in_reassembled_frame' is set,
* need to set to original frame now, and try to update it in the 2nd pass... */
static void add_alert_to_session_tree(guint frame_number, Alert_t *alert)
{
/* First look up tree to see if there is an existing entry */
Alerts_t *alerts = (Alerts_t*)wmem_tree_lookup32(current_session.alerts_tree, frame_number);
if (alerts == NULL) {
/* Create a new entry for the table */
alerts = g_new(Alerts_t, 1);
/* Deep copy of alert */
alerts->alerts[0] = *alert;
alerts->num_alerts = 1;
wmem_tree_insert32(current_session.alerts_tree, frame_number, alerts);
}
else {
/* See if there is room in the existing Alerts_t struct for this frame */
if (alerts->num_alerts < MAX_ALERTS_PER_FRAME) {
/* Deep copy of alert */
alerts->alerts[alerts->num_alerts++] = *alert;
}
}
}
/******************************************************************/
/* Given an alert struct, look up by Snort ID (sid) and try to fill in other details to display. */
static void fill_alert_config(SnortConfig_t *snort_config, Alert_t *alert)
{
guint global_match_number=0, rule_match_number=0;
/* Look up rule by sid */
alert->matched_rule = get_rule(snort_config, alert->sid);
/* Classtype usually filled in from alert rather than rule, but missing for supsported
comment format. */
if (pref_snort_alerts_source == FromUserComments) {
alert->classification = g_strdup(alert->matched_rule->classtype);
}
/* Inform the config/rule about the alert */
rule_set_alert(snort_config, alert->matched_rule,
&global_match_number, &rule_match_number);
/* Copy updated counts into the alert */
alert->overall_match_number = global_match_number;
alert->rule_match_number = rule_match_number;
}
/* Helper functions for matching expected bytes against the packet buffer.
Case-sensitive comparison - can just memcmp().
Case-insensitive comparison - need to look at each byte and compare uppercase version */
static gboolean content_compare_case_sensitive(const guint8* memory, const char* target, guint length)
{
return (memcmp(memory, target, length) == 0);
}
static gboolean content_compare_case_insensitive(const guint8* memory, const char* target, guint length)
{
for (guint n=0; n < length; n++) {
if (g_ascii_isalpha(target[n])) {
if (g_ascii_toupper(memory[n]) != g_ascii_toupper(target[n])) {
return FALSE;
}
}
else {
if ((guint8)memory[n] != (guint8)target[n]) {
return FALSE;
}
}
}
return TRUE;
}
/* Move through the bytes of the tvbuff, looking for a match against the
* regexp from the given content.
*/
static gboolean look_for_pcre(content_t *content, tvbuff_t *tvb, guint start_offset, guint *match_offset, guint *match_length)
{
/* Create a regex object for the pcre in the content. */
GRegex *regex;
GMatchInfo *match_info;
gboolean match_found = FALSE;
GRegexCompileFlags regex_compile_flags = (GRegexCompileFlags)0;
/* Make sure pcre string is ready for regex library. */
if (!content_convert_pcre_for_regex(content)) {
return FALSE;
}
/* Copy remaining bytes into NULL-terminated string. Unfortunately, this interface does't allow
us to find patterns that involve bytes with value 0.. */
int length_remaining = tvb_captured_length_remaining(tvb, start_offset);
gchar *string = (gchar*)g_malloc(length_remaining + 1);
tvb_memcpy(tvb, (void*)string, start_offset, length_remaining);
string[length_remaining] = '\0';
/* For pcre, translated_str already has / /[modifiers] removed.. */
/* Apply any set modifier flags */
if (content->pcre_case_insensitive) {
regex_compile_flags = (GRegexCompileFlags)(regex_compile_flags | G_REGEX_CASELESS);
}
if (content->pcre_dot_includes_newline) {
regex_compile_flags = (GRegexCompileFlags)(regex_compile_flags | G_REGEX_DOTALL);
}
if (content->pcre_raw) {
regex_compile_flags = (GRegexCompileFlags)(regex_compile_flags | G_REGEX_RAW);
}
if (content->pcre_multiline) {
regex_compile_flags = (GRegexCompileFlags)(regex_compile_flags | G_REGEX_MULTILINE);
}
/* Create regex */
regex = g_regex_new(content->translated_str,
regex_compile_flags,
(GRegexMatchFlags)0, NULL);
/* Lookup PCRE match */
g_regex_match(regex, string, (GRegexMatchFlags)0, &match_info);
/* Only first match needed */
/* TODO: need to restart at any NULL before the final end? */
if (g_match_info_matches(match_info)) {
gint start_pos, end_pos;
/* Find out where the match is */
g_match_info_fetch_pos(match_info,
0, /* match_num */
&start_pos, &end_pos);
*match_offset = start_offset + start_pos;
*match_length = end_pos - start_pos;
match_found = TRUE;
}
g_match_info_free(match_info);
g_regex_unref(regex);
g_free(string);
return match_found;
}
/* Move through the bytes of the tvbuff, looking for a match against the expanded
binary contents of this content object.
*/
static gboolean look_for_content(content_t *content, tvbuff_t *tvb, guint start_offset, guint *match_offset, guint *match_length)
{
gint tvb_len = tvb_captured_length(tvb);
/* Make sure content has been translated into binary string. */
guint converted_content_length = content_convert_to_binary(content);
/* Look for a match at each position. */
for (guint m=start_offset; m <= (tvb_len-converted_content_length); m++) {
const guint8 *ptr = tvb_get_ptr(tvb, m, converted_content_length);
if (content->nocase) {
if (content_compare_case_insensitive(ptr, content->translated_str, content->translated_length)) {
*match_offset = m;
*match_length = content->translated_length;
return TRUE;
}
}
else {
if (content_compare_case_sensitive(ptr, content->translated_str, content->translated_length)) {
*match_offset = m;
*match_length = content->translated_length;
return TRUE;
}
}
}
return FALSE;
}
/* Look for where the content match happens within the tvb.
* Set out parameters match_offset and match_length */
static gboolean get_content_match(Alert_t *alert, guint content_idx,
tvbuff_t *tvb, guint content_start_match,
guint *match_offset, guint *match_length)
{
content_t *content;
Rule_t *rule = alert->matched_rule;
/* Can't match if don't know rule */
if (rule == NULL) {
return FALSE;
}
/* Get content object. */
content = &(rule->contents[content_idx]);
/* Look for content match in the packet */
if (content->content_type == Pcre) {
return look_for_pcre(content, tvb, content_start_match, match_offset, match_length);
}
else {
return look_for_content(content, tvb, content_start_match, match_offset, match_length);
}
}
/* Gets called when snort process has died */
static void snort_reaper(GPid pid, gint status _U_, gpointer data)
{
snort_session_t *session = (snort_session_t *)data;
if (session->running && session->pid == pid) {
session->working = session->running = FALSE;
/* XXX, cleanup */
} else {
g_print("Errrrmm snort_reaper() %"PRIdMAX" != %"PRIdMAX"\n", (intmax_t)session->pid, (intmax_t)pid);
}
/* Close the snort pid (may only make a difference on Windows?) */
g_spawn_close_pid(pid);
}
/* Parse timestamp line of output. This is done in part to get the packet_number back out of usec field...
* Return value is the input stream moved onto the next field following the timestamp */
static const char* snort_parse_ts(const char *ts, guint32 *frame_number)
{
struct tm tm;
unsigned int usec;
/* Timestamp */
memset(&tm, 0, sizeof(tm));
tm.tm_isdst = -1;
if (sscanf(ts, "%02d/%02d/%02d-%02d:%02d:%02d.%06u ",
&(tm.tm_mon), &(tm.tm_mday), &(tm.tm_year), &(tm.tm_hour), &(tm.tm_min), &(tm.tm_sec), &usec) != 7) {
return NULL;
}
tm.tm_mon -= 1;
tm.tm_year += 100;
/* Store frame number (which was passed into this position when packet was submitted to snort) */
*frame_number = usec;
return strchr(ts, ' ');
}
/* Parse a fast output alert string */
static gboolean snort_parse_fast_line(const char *line, Alert_t *alert)
{
static const char stars[] = " [**] ";
static const char classification[] = "[Classification: ";
static const char priority[] = "[Priority: ";
const char *tmp_msg;
/* Look for timestamp/frame-number */
if (!(line = snort_parse_ts(line, &(alert->original_frame)))) {
return FALSE;
}
/* [**] */
if (!g_str_has_prefix(line+1, stars)) {
return FALSE;
}
line += sizeof(stars);
/* [%u:%u:%u] */
if (sscanf(line, "[%u:%u:%u] ", &(alert->gen), &(alert->sid), &(alert->rev)) != 3) {
return FALSE;
}
if (!(line = strchr(line, ' '))) {
return FALSE;
}
/* [**] again */
tmp_msg = line+1;
if (!(line = strstr(line, stars))) {
return FALSE;
}
/* msg */
alert->msg = g_strndup(tmp_msg, line - tmp_msg);
line += (sizeof(stars)-1);
/* [Classification: Attempted Administrator Privilege Gain] [Priority: 10] */
if (g_str_has_prefix(line, classification)) {
/* [Classification: %s] */
char *tmp;
line += (sizeof(classification)-1);
if (!(tmp = (char*)strstr(line, "] [Priority: "))) {
return FALSE;
}
/* assume "] [Priority: " is not inside classification text :) */
alert->classification = g_strndup(line, tmp - line);
line = tmp+2;
} else
alert->classification = NULL;
/* Optimized: if al->classification we already checked this in strstr() above */
if (alert->classification || g_str_has_prefix(line, priority)) {
/* [Priority: %d] */
line += (sizeof(priority)-1);
if ((sscanf(line, "%d", &(alert->prio))) != 1) {
return FALSE;
}
if (!strstr(line, "] ")) {
return FALSE;
}
} else {
alert->prio = -1; /* XXX */
}
return TRUE;
}
/**
* snort_parse_user_comment()
*
* Parse line as written by TraceWranger
* e.g. "1:2011768:4 - ET WEB_SERVER PHP tags in HTTP POST"
*/
static gboolean snort_parse_user_comment(const char *line, Alert_t *alert)
{
/* %u:%u:%u */
if (sscanf(line, "%u:%u:%u", &(alert->gen), &(alert->sid), &(alert->rev)) != 3) {
return FALSE;
}
/* Skip separator between numbers and msg */
if (!(line = strstr(line, " - "))) {
return FALSE;
}
/* Copy to be consistent with other use of Alert_t */
alert->msg = g_strdup(line);
/* No need to set other fields as assume zero'd out before this call.. */
return TRUE;
}
/* Output data has been received from snort. Read from channel and look for whole alerts. */
static gboolean snort_fast_output(GIOChannel *source, GIOCondition condition, gpointer data)
{
snort_session_t *session = (snort_session_t *)data;
/* Loop here until all available input read */
while (condition & G_IO_IN) {
GIOStatus status;
char _buf[1024];
gsize len = 0;
char *old_buf = NULL;
char *buf = _buf;
char *line;
/* Try to read snort output info _buf */
status = g_io_channel_read_chars(source, _buf, sizeof(_buf)-1, &len, NULL);
if (status != G_IO_STATUS_NORMAL) {
if (status == G_IO_STATUS_AGAIN) {
/* Blocked, so unset G_IO_IN and get out of this function */
condition = (GIOCondition)(condition & ~G_IO_IN);
break;
}
/* Other conditions here could be G_IO_STATUS_ERROR, G_IO_STATUS_EOF */
return FALSE;
}
/* Terminate buffer */
buf[len] = '\0';
/* If we previously had part of a line, append the new bit we just saw */
if (session->buf) {
g_string_append(session->buf, buf);
buf = old_buf = g_string_free(session->buf, FALSE);
session->buf = NULL;
}
/* Extract every complete line we find in the output */
while ((line = strchr(buf, '\n'))) {
/* Have a whole line, so can parse */
Alert_t alert;
memset(&alert, 0, sizeof(alert));
/* Terminate received line */
*line = '\0';
if (snort_parse_fast_line(buf, &alert)) {
/*******************************************************/
/* We have an alert line. */
#if 0
g_print("%ld.%lu [%u,%u,%u] %s {%s} [%d]\n",
alert.tv.tv_sec, alert.tv.tv_usec,
alert.gen, alert.sid, alert.rev,
alert.msg,
alert.classification ? alert.classification : "(null)",
alert.prio);
#endif
/* Copy the raw alert string itself */
alert.raw_alert = g_strdup(buf);
/* See if we can get more info from the parsed config details */
fill_alert_config(g_snort_config, &alert);
/* Add parsed alert into session->tree */
/* Store in tree. Frame number hidden in fraction of second field, so associate
alert with that frame. */
add_alert_to_session_tree((guint)alert.original_frame, &alert);
}
else {
g_print("snort_fast_output() line: '%s'\n", buf);
}
buf = line+1;
}
if (buf[0]) {
/* Only had part of a line - store it */
/* N.B. typically happens maybe once every 5-6 alerts. */
session->buf = g_string_new(buf);
}
g_free(old_buf);
}
if ((condition == G_IO_ERR) || (condition == G_IO_HUP) || (condition == G_IO_NVAL)) {
/* Will report errors (hung-up, or error) */
/* g_print("snort_fast_output() cond: (h:%d,e:%d,r:%d)\n",
* !!(condition & G_IO_HUP), !!(condition & G_IO_ERR), condition); */
return FALSE;
}
return TRUE;
}
/* Return the offset in the frame where snort should begin looking inside payload. */
static guint get_protocol_payload_start(const char *protocol, proto_tree *tree)
{
guint value = 0;
/* For icmp, look from start, whereas for others start after them. */
gboolean look_after_protocol = (strcmp(protocol, "icmp") != 0);
if (tree != NULL) {
GPtrArray *items = proto_all_finfos(tree);
if (items) {
guint i;
for (i=0; i< items->len; i++) {
field_info *field = (field_info *)g_ptr_array_index(items,i);
if (strcmp(field->hfinfo->abbrev, protocol) == 0) {
value = field->start;
if (look_after_protocol) {
value += field->length;
}
break;
}
}
g_ptr_array_free(items,TRUE);
}
}
return value;
}
/* Return offset that application layer traffic will begin from. */
static guint get_content_start_match(Rule_t *rule, proto_tree *tree)
{
/* Work out where snort would start looking for data in the frame */
return get_protocol_payload_start(rule->protocol, tree);
}
/* Where this frame is later part of a reassembled complete PDU running over TCP, look up
and return that frame number. */
static guint get_reassembled_in_frame(proto_tree *tree)
{
guint value = 0;
if (tree != NULL) {
GPtrArray *items = proto_all_finfos(tree);
if (items) {
guint i;
for (i=0; i< items->len; i++) {
field_info *field = (field_info *)g_ptr_array_index(items,i);
if (strcmp(field->hfinfo->abbrev, "tcp.reassembled_in") == 0) {
value = fvalue_get_uinteger(field->value);
break;
}
}
g_ptr_array_free(items,TRUE);
}
}
return value;
}
/* Show the Snort protocol tree based on the info in alert */
static void snort_show_alert(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, Alert_t *alert)
{
proto_tree *snort_tree = NULL;
guint n;
proto_item *ti, *rule_ti;
proto_tree *rule_tree;
Rule_t *rule = alert->matched_rule;
/* May need to move to reassembled frame to show there instead of here */
if (snort_alert_in_reassembled_frame && pinfo->fd->visited && (tree != NULL)) {
guint reassembled_frame = get_reassembled_in_frame(tree);
if (reassembled_frame && (reassembled_frame != pinfo->num)) {
Alerts_t *alerts;
/* Look up alerts for this frame */
alerts = (Alerts_t*)wmem_tree_lookup32(current_session.alerts_tree, pinfo->num);
if (!alerts->alerts[0].reassembled_frame) {
/* Update all alerts from this frame! */
for (n=0; n < alerts->num_alerts; n++) {
/* Set forward/back frame numbers */
alerts->alerts[n].original_frame = pinfo->num;
alerts->alerts[n].reassembled_frame = reassembled_frame;
/* Add these alerts to reassembled frame */
add_alert_to_session_tree(reassembled_frame, &alerts->alerts[n]);
}
}
}
}
/* Can only find start if we have the rule and know the protocol */
guint content_start_match = 0;
guint payload_start = 0;
if (rule) {
payload_start = content_start_match = get_content_start_match(rule, tree);
}
/* Snort output arrived and was previously stored - so add to tree */
/* Take care not to try to highlight bytes that aren't there.. */
proto_item *alert_ti = proto_tree_add_protocol_format(tree, proto_snort, tvb,
content_start_match >= tvb_captured_length(tvb) ? 0 : content_start_match,
content_start_match >= tvb_captured_length(tvb) ? 0 : -1,
"Snort: (msg: \"%s\" sid: %u rev: %u) [from %s]",
alert->msg, alert->sid, alert->rev,
(pref_snort_alerts_source == FromUserComments) ?
"User Comment" :
"Running Snort");
snort_tree = proto_item_add_subtree(alert_ti, ett_snort);
if (snort_alert_in_reassembled_frame && (alert->reassembled_frame != 0)) {
if (alert->original_frame == pinfo->num) {
/* Show link forward to where alert is now shown! */
ti = proto_tree_add_uint(tree, hf_snort_reassembled_in, tvb, 0, 0,
alert->reassembled_frame);
proto_item_set_generated(ti);
return;
}
else {
tvbuff_t *reassembled_tvb;
/* Show link back to segment where alert was detected. */
ti = proto_tree_add_uint(tree, hf_snort_reassembled_from, tvb, 0, 0,
alert->original_frame);
proto_item_set_generated(ti);
/* Should find this if look late enough.. */
reassembled_tvb = get_data_source_tvb_by_name(pinfo, "Reassembled TCP");
if (reassembled_tvb) {
/* Will look for content using the TVB instead of just this frame's one */
tvb = reassembled_tvb;
}
/* TODO: for correctness, would be good to lookup + remember the offset of the source
* frame within the reassembled PDU frame, to make sure we find the content in the
* correct place for every alert */
}
}
snort_debug_printf("Showing alert (sid=%u) in frame %u\n", alert->sid, pinfo->num);
/* Show in expert info if configured to. */
if (snort_show_alert_expert_info) {
expert_add_info_format(pinfo, alert_ti, &ei_snort_alert, "Alert %u: \"%s\"", alert->sid, alert->msg);
}
/* Show the 'raw' alert string. */
if (rule) {
/* Fix up alert->raw_alert if not already done so first. */
if (!alert->raw_alert_ts_fixed) {
/* Write 6 figures to position after decimal place in timestamp. Must have managed to
parse out fields already, so will definitely be long enough for memcpy() to succeed. */
char digits[7];
snprintf(digits, 7, "%06d", pinfo->abs_ts.nsecs / 1000);
memcpy(alert->raw_alert+18, digits, 6);
alert->raw_alert_ts_fixed = TRUE;
}
ti = proto_tree_add_string(snort_tree, hf_snort_raw_alert, tvb, 0, 0, alert->raw_alert);
proto_item_set_generated(ti);
}
/* Rule classification */
if (alert->classification) {
ti = proto_tree_add_string(snort_tree, hf_snort_classification, tvb, 0, 0, alert->classification);
proto_item_set_generated(ti);
}
/* Put rule fields under a rule subtree */
rule_ti = proto_tree_add_string_format(snort_tree, hf_snort_rule, tvb, 0, 0, "", "Rule");
proto_item_set_generated(rule_ti);
rule_tree = proto_item_add_subtree(rule_ti, ett_snort_rule);
/* msg/description */
ti = proto_tree_add_string(rule_tree, hf_snort_msg, tvb, 0, 0, alert->msg);
proto_item_set_generated(ti);
/* Snort ID */
ti = proto_tree_add_uint(rule_tree, hf_snort_sid, tvb, 0, 0, alert->sid);
proto_item_set_generated(ti);
/* Rule revision */
ti = proto_tree_add_uint(rule_tree, hf_snort_rev, tvb, 0, 0, alert->rev);
proto_item_set_generated(ti);
/* Generator seems to correspond to gid. */
ti = proto_tree_add_uint(rule_tree, hf_snort_generator, tvb, 0, 0, alert->gen);
proto_item_set_generated(ti);
/* Default priority is 2 - very few rules have a different priority... */
ti = proto_tree_add_uint(rule_tree, hf_snort_priority, tvb, 0, 0, alert->prio);
proto_item_set_generated(ti);
/* If we know the rule for this alert, show some of the rule fields */
if (rule && rule->rule_string) {
size_t rule_string_length = strlen(rule->rule_string);
/* Show rule string itself. Add it as a separate data source so can read it all */
if (rule_string_length > 60) {
tvbuff_t *rule_string_tvb = tvb_new_child_real_data(tvb, rule->rule_string,
(guint)rule_string_length,
(guint)rule_string_length);
add_new_data_source(pinfo, rule_string_tvb, "Rule String");
ti = proto_tree_add_string(rule_tree, hf_snort_rule_string, rule_string_tvb, 0,
(gint)rule_string_length,
rule->rule_string);
}
else {
ti = proto_tree_add_string(rule_tree, hf_snort_rule_string, tvb, 0, 0,
rule->rule_string);
}
proto_item_set_generated(ti);
/* Protocol from rule */
ti = proto_tree_add_string(rule_tree, hf_snort_rule_protocol, tvb, 0, 0, rule->protocol);
proto_item_set_generated(ti);
/* Show file alert came from */
ti = proto_tree_add_string(rule_tree, hf_snort_rule_filename, tvb, 0, 0, rule->file);
proto_item_set_generated(ti);
/* Line number within file */
ti = proto_tree_add_uint(rule_tree, hf_snort_rule_line_number, tvb, 0, 0, rule->line_number);
proto_item_set_generated(ti);
/* Show IP vars */
for (n=0; n < rule->relevant_vars.num_ip_vars; n++) {
ti = proto_tree_add_none_format(rule_tree, hf_snort_rule_ip_var, tvb, 0, 0, "IP Var: ($%s -> %s)",
rule->relevant_vars.ip_vars[n].name,
rule->relevant_vars.ip_vars[n].value);
proto_item_set_generated(ti);
}
/* Show Port vars */
for (n=0; n < rule->relevant_vars.num_port_vars; n++) {
ti = proto_tree_add_none_format(rule_tree, hf_snort_rule_port_var, tvb, 0, 0, "Port Var: ($%s -> %s)",
rule->relevant_vars.port_vars[n].name,
rule->relevant_vars.port_vars[n].value);
proto_item_set_generated(ti);
}
}
/* Show summary information in rule tree root */
proto_item_append_text(rule_ti, " %s (sid=%u, rev=%u)",
alert->msg, alert->sid, alert->rev);
/* More fields retrieved from the parsed config */
if (rule) {
guint content_last_match_end = 0;
/* Work out which ip and port vars are relevant */
rule_set_relevant_vars(g_snort_config, rule);
/* Contents */
for (n=0; n < rule->number_contents; n++) {
/* Search for string among tvb contents so we can highlight likely bytes. */
unsigned int content_offset = 0;
gboolean match_found = FALSE;
unsigned int converted_content_length = 0;
int content_hf_item;
char *content_text_template;
/* Choose type of content field to add */
switch (rule->contents[n].content_type) {
case Content:
content_hf_item = hf_snort_content;
content_text_template = "Content: \"%s\"";
break;
case UriContent:
content_hf_item = hf_snort_uricontent;
content_text_template = "Uricontent: \"%s\"";
break;
case Pcre:
content_hf_item = hf_snort_pcre;
content_text_template = "Pcre: \"%s\"";
break;
default:
continue;
}
/* Will only try to look for content in packet ourselves if not
a negated content entry (i.e. beginning with '!') */
if (!rule->contents[n].negation) {
/* Look up offset of match. N.B. would only expect to see on first content... */
guint distance_to_add = 0;
/* May need to start looking from absolute offset into packet... */
if (rule->contents[n].offset_set) {
content_start_match = payload_start + rule->contents[n].offset;
}
/* ... or a number of bytes beyond the previous content match */
else if (rule->contents[n].distance_set) {
distance_to_add = (content_last_match_end-content_start_match) + rule->contents[n].distance;
}
else {
/* No constraints about where it appears - go back to the start of the frame. */
content_start_match = payload_start;
}
/* Now actually look for match from calculated position */
/* TODO: could take 'depth' and 'within' into account to limit extent of search,
but OK if just trying to verify what Snort already found. */
match_found = get_content_match(alert, n,
tvb, content_start_match+distance_to_add,
&content_offset, &converted_content_length);
if (match_found) {
content_last_match_end = content_offset + converted_content_length;
}
}
/* Show content in tree (showing position if known) */
ti = proto_tree_add_string_format(snort_tree, content_hf_item, tvb,
(match_found) ? content_offset : 0,
(match_found) ? converted_content_length : 0,
rule->contents[n].str,
content_text_template,
rule->contents[n].str);
/* Next match position will be after this one */
if (match_found) {
content_start_match = content_last_match_end;
}
/* Show (only as text) attributes of content field */
if (rule->contents[n].fastpattern) {
proto_item_append_text(ti, " (fast_pattern)");
}
if (rule->contents[n].rawbytes) {
proto_item_append_text(ti, " (rawbytes)");
}
if (rule->contents[n].nocase) {
proto_item_append_text(ti, " (nocase)");
}
if (rule->contents[n].negation) {
proto_item_append_text(ti, " (negated)");
}
if (rule->contents[n].offset_set) {
proto_item_append_text(ti, " (offset=%d)", rule->contents[n].offset);
}
if (rule->contents[n].depth != 0) {
proto_item_append_text(ti, " (depth=%u)", rule->contents[n].depth);
}
if (rule->contents[n].distance_set) {
proto_item_append_text(ti, " (distance=%d)", rule->contents[n].distance);
}
if (rule->contents[n].within != 0) {
proto_item_append_text(ti, " (within=%u)", rule->contents[n].within);
}
/* HTTP preprocessor modifiers */
if (rule->contents[n].http_method != 0) {
proto_item_append_text(ti, " (http_method)");
}
if (rule->contents[n].http_client_body != 0) {
proto_item_append_text(ti, " (http_client_body)");
}
if (rule->contents[n].http_cookie != 0) {
proto_item_append_text(ti, " (http_cookie)");
}
if (rule->contents[n].http_user_agent != 0) {
proto_item_append_text(ti, " (http_user_agent)");
}
if (!rule->contents[n].negation && !match_found) {
/* Useful for debugging, may also happen when Snort is reassembling.. */
/* TODO: not sure why, but PCREs might not be found first time through, but will be
* found later, with the result that there will be 'not located' expert warnings,
* but when you click on the packet, it is matched after all... */
proto_item_append_text(ti, " - not located");
expert_add_info_format(pinfo, ti, &ei_snort_content_not_matched,
"%s \"%s\" not found in frame",
rule->contents[n].content_type==Pcre ? "PCRE" : "Content",
rule->contents[n].str);
}
}
/* References */
for (n=0; n < rule->number_references; n++) {
/* Substitute prefix and add to tree as clickable web links */
ti = proto_tree_add_string(snort_tree, hf_snort_reference, tvb, 0, 0,
expand_reference(g_snort_config, rule->references[n]));
/* Make clickable */
proto_item_set_url(ti);
proto_item_set_generated(ti);
}
}
/* Global rule stats if configured to. */
if (snort_show_rule_stats) {
unsigned int number_rule_files, number_rules, alerts_detected, this_rule_alerts_detected;
proto_item *stats_ti;
proto_tree *stats_tree;
/* Create tree for these items */
stats_ti = proto_tree_add_string_format(snort_tree, hf_snort_global_stats, tvb, 0, 0, "", "Global Stats");
proto_item_set_generated(rule_ti);
stats_tree = proto_item_add_subtree(stats_ti, ett_snort_global_stats);
/* Get overall number of rules */
get_global_rule_stats(g_snort_config, alert->sid, &number_rule_files, &number_rules, &alerts_detected,
&this_rule_alerts_detected);
ti = proto_tree_add_uint(stats_tree, hf_snort_global_stats_rule_file_count, tvb, 0, 0, number_rule_files);
proto_item_set_generated(ti);
ti = proto_tree_add_uint(stats_tree, hf_snort_global_stats_rule_count, tvb, 0, 0, number_rules);
proto_item_set_generated(ti);
/* Overall alert stats (total, and where this one comes in order) */
ti = proto_tree_add_uint(stats_tree, hf_snort_global_stats_total_alerts_count, tvb, 0, 0, alerts_detected);
proto_item_set_generated(ti);
ti = proto_tree_add_uint(stats_tree, hf_snort_global_stats_alert_match_number, tvb, 0, 0, alert->overall_match_number);
proto_item_set_generated(ti);
if (rule) {
/* Stats just for this rule (overall, and where this one comes in order) */
ti = proto_tree_add_uint(stats_tree, hf_snort_global_stats_rule_alerts_count, tvb, 0, 0, this_rule_alerts_detected);
proto_item_set_generated(ti);
ti = proto_tree_add_uint(stats_tree, hf_snort_global_stats_rule_match_number, tvb, 0, 0, alert->rule_match_number);
proto_item_set_generated(ti);
/* Add a summary to the stats root */
proto_item_append_text(stats_ti, " (%u rules from %u files, #%u of %u alerts seen (%u/%u for sid %u))",
number_rules, number_rule_files, alert->overall_match_number, alerts_detected,
alert->rule_match_number, this_rule_alerts_detected, alert->sid);
}
else {
/* Add a summary to the stats root */
proto_item_append_text(stats_ti, " (%u rules from %u files, #%u of %u alerts seen)",
number_rules, number_rule_files, alert->overall_match_number, alerts_detected);
}
}
}
/* Look for, and return, any user comment set for this packet.
Currently used for fetching alerts in the format TraceWrangler can write out to */
static const char *get_user_comment_string(proto_tree *tree)
{
const char *value = NULL;
if (tree != NULL) {
GPtrArray *items = proto_all_finfos(tree);
if (items) {
guint i;
for (i=0; i< items->len; i++) {
field_info *field = (field_info *)g_ptr_array_index(items,i);
if (strcmp(field->hfinfo->abbrev, "frame.comment") == 0) {
value = fvalue_get_string(field->value);
break;
}
/* This is the only item that can come before "frame.comment", so otherwise break out */
if (strncmp(field->hfinfo->abbrev, "pkt_comment", 11) != 0) {
break;
}
}
g_ptr_array_free(items,TRUE);
}
}
return value;
}
/********************************************************************************/
/* Main (post-)dissector function. */
static int
snort_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
Alerts_t *alerts;
/* If not looking for alerts, return quickly */
if (pref_snort_alerts_source == FromNowhere) {
return 0;
}
/* Are we looking for alerts in user comments? */
else if (pref_snort_alerts_source == FromUserComments) {
/* Look for user comments containing alerts */
const char *alert_string = get_user_comment_string(tree);
if (alert_string) {
alerts = (Alerts_t*)wmem_tree_lookup32(current_session.alerts_tree, pinfo->num);
if (!alerts) {
Alert_t alert;
memset(&alert, 0, sizeof(alert));
if (snort_parse_user_comment(alert_string, &alert)) {
/* Copy the raw alert itself */
alert.raw_alert = g_strdup(alert_string);
/* See if we can get more info from the parsed config details */
fill_alert_config(g_snort_config, &alert);
/* Add parsed alert into session->tree */
add_alert_to_session_tree(pinfo->num, &alert);
}
}
}
}
else {
/* We expect alerts from Snort. Pass frame into snort on first pass. */
if (!pinfo->fd->visited && current_session.working) {
int write_err = 0;
gchar *err_info;
wtap_rec rec;
/* First time, open current_session.in to write to for dumping into snort with */
if (!current_session.pdh) {
wtap_dump_params params = WTAP_DUMP_PARAMS_INIT;
int open_err;
gchar *open_err_info;
/* Older versions of Snort don't support capture file with several encapsulations (like pcapng),
* so write in pcap format and hope we have just one encap.
* Newer versions of Snort can read pcapng now, but still
* write in pcap format; if "newer versions of Snort" really
* means "Snort, when using newer versions of libpcap", then,
* yes, they can read pcapng, but they can't read pcapng
* files with more than one encapsulation type, as libpcap's
* API currently can't handle that, so even those "newer
* versions of Snort" wouldn't handle multiple encapsulation
* types.
*/
params.encap = pinfo->rec->rec_header.packet_header.pkt_encap;
params.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
current_session.pdh = wtap_dump_fdopen(current_session.in,
wtap_pcap_file_type_subtype(),
WTAP_UNCOMPRESSED,
¶ms,
&open_err,
&open_err_info);
if (!current_session.pdh) {
/* XXX - report the error somehow? */
g_free(open_err_info);
current_session.working = FALSE;
return 0;
}
}
/* Start with all same values... */
rec = *pinfo->rec;
/* Copying packet details into wtp for writing */
rec.ts = pinfo->abs_ts;
/* NB: overwriting the time stamp so we can see packet number back if an alert is written for this frame!!!! */
/* TODO: does this seriously affect snort's ability to reason about time?
* At least all packets will still be in order... */
rec.ts.nsecs = pinfo->fd->num * 1000; /* XXX, max 999'999 frames */
rec.rec_header.packet_header.caplen = tvb_captured_length(tvb);
rec.rec_header.packet_header.len = tvb_reported_length(tvb);
/* Dump frame into snort's stdin */
if (!wtap_dump(current_session.pdh, &rec, tvb_get_ptr(tvb, 0, tvb_reported_length(tvb)), &write_err, &err_info)) {
/* XXX - report the error somehow? */
g_free(err_info);
current_session.working = FALSE;
return 0;
}
if (!wtap_dump_flush(current_session.pdh, &write_err)) {
/* XXX - report the error somehow? */
current_session.working = FALSE;
return 0;
}
/* Give the io channel a chance to deliver alerts.
TODO: g_main_context_iteration(NULL, FALSE); causes crashes sometimes when Qt events get to execute.. */
}
}
/* Now look up stored alerts for this packet number, and display if found */
if (current_session.alerts_tree && (alerts = (Alerts_t*)wmem_tree_lookup32(current_session.alerts_tree, pinfo->fd->num))) {
guint n;
for (n=0; n < alerts->num_alerts; n++) {
snort_show_alert(tree, tvb, pinfo, &(alerts->alerts[n]));
}
} else {
/* XXX, here either this frame doesn't generate alerts or we haven't received data from snort (async)
*
* It's problem when user want to filter tree on initial run, or is running one-pass tshark.
*/
}
return tvb_reported_length(tvb);
}
/*------------------------------------------------------------------*/
/* Start up Snort. */
static void snort_start(void)
{
GIOChannel *channel;
/* int snort_output_id; */
const gchar *argv[] = {
pref_snort_binary_filename, "-c", pref_snort_config_filename,
/* read from stdin */
"-r", "-",
/* don't log */
"-N",
/* output to console and silence snort */
"-A", "console", "-q",
/* normalize time */
"-y", /* -U", */
/* Optionally ignore checksum errors */
"-k", "none",
NULL
};
/* Truncate command to before -k if this pref off */
if (!snort_ignore_checksum_errors) {
argv[10] = NULL;
}
/* Enable field priming if required. */
if (snort_alert_in_reassembled_frame) {
/* Add items we want to try to get to find before we get called.
For now, just ask for tcp.reassembled_in, which won't be seen
on the first pass through the packets. */
GArray *wanted_hfids = g_array_new(FALSE, FALSE, (guint)sizeof(int));
int id = proto_registrar_get_id_byname("tcp.reassembled_in");
g_array_append_val(wanted_hfids, id);
set_postdissector_wanted_hfids(snort_handle, wanted_hfids);
}
/* Nothing to do if not enabled, but registered init function gets called anyway */
if ((pref_snort_alerts_source == FromNowhere) ||
!proto_is_protocol_enabled(find_protocol_by_id(proto_snort))) {
return;
}
/* Create tree mapping packet_number -> Alerts_t*. It will get recreated when packet list is reloaded */
current_session.alerts_tree = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
/* Create afresh the config object by parsing the same file that snort uses */
if (g_snort_config) {
delete_config(&g_snort_config);
}
create_config(&g_snort_config, pref_snort_config_filename);
/* Don't run Snort if not configured to */
if (pref_snort_alerts_source == FromUserComments) {
return;
}
/* Don't start if already running */
if (current_session.running) {
return;
}
/* Reset global stats */
reset_global_rule_stats(g_snort_config);
/* Need to test that we can run snort --version and that config can be parsed... */
/* Does nothing at present */
if (!snort_config_ok) {
/* Can carry on without snort... */
return;
}
/* About to run snort, so check that configured files exist, and that binary could be executed. */
ws_statb64 binary_stat, config_stat;
if (ws_stat64(pref_snort_binary_filename, &binary_stat) != 0) {
snort_debug_printf("Can't run snort - executable '%s' not found\n", pref_snort_binary_filename);
report_failure("Snort dissector: Can't run snort - executable '%s' not found\n", pref_snort_binary_filename);
return;
}
if (ws_stat64(pref_snort_config_filename, &config_stat) != 0) {
snort_debug_printf("Can't run snort - config file '%s' not found\n", pref_snort_config_filename);
report_failure("Snort dissector: Can't run snort - config file '%s' not found\n", pref_snort_config_filename);
return;
}
#ifdef S_IXUSR
if (!(binary_stat.st_mode & S_IXUSR)) {
snort_debug_printf("Snort binary '%s' is not executable\n", pref_snort_binary_filename);
report_failure("Snort dissector: Snort binary '%s' is not executable\n", pref_snort_binary_filename);
return;
}
#endif
#ifdef _WIN32
report_failure("Snort dissector: not yet able to launch Snort process under Windows");
current_session.working = FALSE;
return;
#endif
/* Create snort process and set up pipes */
snort_debug_printf("\nRunning %s with config file %s\n", pref_snort_binary_filename, pref_snort_config_filename);
if (!g_spawn_async_with_pipes(NULL, /* working_directory */
(char **)argv,
NULL, /* envp */
(GSpawnFlags)( G_SPAWN_DO_NOT_REAP_CHILD), /* Leave out G_SPAWN_SEARCH_PATH */
NULL, /* child setup - not supported in Windows, so we can't use it */
NULL, /* user-data */
¤t_session.pid, /* PID */
¤t_session.in, /* stdin */
¤t_session.out, /* stdout */
¤t_session.err, /* stderr */
NULL)) /* error */
{
current_session.running = FALSE;
current_session.working = FALSE;
return;
}
else {
current_session.running = TRUE;
current_session.working = TRUE;
}
/* Setup handler for when process goes away */
g_child_watch_add(current_session.pid, snort_reaper, ¤t_session);
/******************************************************************/
/* Create channel to get notified of snort alert output on stdout */
/* Create channel itself */
channel = g_io_channel_unix_new(current_session.out);
current_session.channel = channel;
/* NULL encoding supports binary or whatever the application outputs */
g_io_channel_set_encoding(channel, NULL, NULL);
/* Don't buffer the channel (settable because encoding set to NULL). */
g_io_channel_set_buffered(channel, FALSE);
/* Set flags */
/* TODO: could set to be blocking and get sync that way? */
g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL);
/* Try setting a large buffer here. */
g_io_channel_set_buffer_size(channel, 256000);
current_session.buf = NULL;
/* Set callback for receiving data from the channel */
g_io_add_watch_full(channel,
G_PRIORITY_HIGH,
(GIOCondition)(G_IO_IN|G_IO_ERR|G_IO_HUP),
snort_fast_output, /* Callback upon data being written by snort */
¤t_session, /* User data */
NULL); /* Destroy notification callback */
current_session.working = TRUE;
}
/* This is the cleanup routine registered with register_postseq_cleanup_routine() */
static void snort_cleanup(void)
{
/* Only close if we think its running */
if (!current_session.running) {
return;
}
/* Close dumper writing into snort's stdin. This will cause snort to exit! */
if (current_session.pdh) {
int write_err;
gchar *write_err_info;
if (!wtap_dump_close(current_session.pdh, NULL, &write_err, &write_err_info)) {
/* XXX - somehow report the error? */
g_free(write_err_info);
}
current_session.pdh = NULL;
}
}
static void snort_file_cleanup(void)
{
if (g_snort_config) {
delete_config(&g_snort_config);
}
/* Disable field priming that got enabled in the init routine. */
set_postdissector_wanted_hfids(snort_handle, NULL);
}
void
proto_reg_handoff_snort(void)
{
/* N.B. snort self-test here deleted, as I was struggling to get it to
* work as a non-root user (couldn't read stdin)
* TODO: could run snort just to get the version number and check the config file is readable?
* TODO: could make snort config parsing less forgiving and use that as a test? */
}
void
proto_register_snort(void)
{
static hf_register_info hf[] = {
{ &hf_snort_sid,
{ "Rule SID", "snort.sid", FT_UINT32, BASE_DEC, NULL, 0x00,
"Snort Rule identifier", HFILL }},
{ &hf_snort_raw_alert,
{ "Raw Alert", "snort.raw-alert", FT_STRING, BASE_NONE, NULL, 0x00,
"Full text of Snort alert", HFILL }},
{ &hf_snort_rule,
{ "Rule", "snort.rule", FT_STRING, BASE_NONE, NULL, 0x00,
"Entire Snort rule string", HFILL }},
{ &hf_snort_msg,
{ "Alert Message", "snort.msg", FT_STRINGZ, BASE_NONE, NULL, 0x00,
"Description of what the rule detects", HFILL }},
{ &hf_snort_classification,
{ "Alert Classification", "snort.class", FT_STRINGZ, BASE_NONE, NULL, 0x00,
NULL, HFILL }},
{ &hf_snort_priority,
{ "Alert Priority", "snort.priority", FT_UINT32, BASE_DEC, NULL, 0x00,
NULL, HFILL }},
{ &hf_snort_generator,
{ "Rule Generator", "snort.generator", FT_UINT32, BASE_DEC, NULL, 0x00,
NULL, HFILL }},
{ &hf_snort_rev,
{ "Rule Revision", "snort.rev", FT_UINT32, BASE_DEC, NULL, 0x00,
NULL, HFILL }},
{ &hf_snort_rule_string,
{ "Rule String", "snort.rule-string", FT_STRINGZ, BASE_NONE, NULL, 0x00,
"Full text of Snort rule", HFILL }},
{ &hf_snort_rule_protocol,
{ "Protocol", "snort.protocol", FT_STRINGZ, BASE_NONE, NULL, 0x00,
"Protocol name as given in the rule", HFILL }},
{ &hf_snort_rule_filename,
{ "Rule Filename", "snort.rule-filename", FT_STRINGZ, BASE_NONE, NULL, 0x00,
"Rules file where Snort rule was parsed from", HFILL }},
{ &hf_snort_rule_line_number,
{ "Line number within rules file where rule was parsed from", "snort.rule-line-number", FT_UINT32, BASE_DEC, NULL, 0x00,
NULL, HFILL }},
{ &hf_snort_rule_ip_var,
{ "IP variable", "snort.rule-ip-var", FT_NONE, BASE_NONE, NULL, 0x00,
"IP variable used in rule", HFILL }},
{ &hf_snort_rule_port_var,
{ "Port variable used in rule", "snort.rule-port-var", FT_NONE, BASE_NONE, NULL, 0x00,
NULL, HFILL }},
{ &hf_snort_reassembled_in,
{ "Reassembled frame where alert is shown", "snort.reassembled_in", FT_FRAMENUM, BASE_NONE, NULL, 0x00,
NULL, HFILL }},
{ &hf_snort_reassembled_from,
{ "Segment where alert was triggered", "snort.reassembled_from", FT_FRAMENUM, BASE_NONE, NULL, 0x00,
NULL, HFILL }},
{ &hf_snort_content,
{ "Content", "snort.content", FT_STRINGZ, BASE_NONE, NULL, 0x00,
"Snort content field", HFILL }},
{ &hf_snort_uricontent,
{ "URI Content", "snort.uricontent", FT_STRINGZ, BASE_NONE, NULL, 0x00,
"Snort URI content field", HFILL }},
{ &hf_snort_pcre,
{ "PCRE", "snort.pcre", FT_STRINGZ, BASE_NONE, NULL, 0x00,
"Perl Compatible Regular Expression", HFILL }},
{ &hf_snort_reference,
{ "Reference", "snort.reference", FT_STRINGZ, BASE_NONE, NULL, 0x00,
"Web reference provided as part of rule", HFILL }},
/* Global stats */
{ &hf_snort_global_stats,
{ "Global Stats", "snort.global-stats", FT_STRING, BASE_NONE, NULL, 0x00,
"Global statistics for rules and alerts", HFILL }},
{ &hf_snort_global_stats_rule_file_count,
{ "Number of rule files", "snort.global-stats.rule-file-count", FT_UINT32, BASE_DEC, NULL, 0x00,
"Total number of rules files found in Snort config", HFILL }},
{ &hf_snort_global_stats_rule_count,
{ "Number of rules", "snort.global-stats.rule-count", FT_UINT32, BASE_DEC, NULL, 0x00,
"Total number of rules found in Snort config", HFILL }},
{ &hf_snort_global_stats_total_alerts_count,
{ "Number of alerts detected", "snort.global-stats.total-alerts", FT_UINT32, BASE_DEC, NULL, 0x00,
"Total number of alerts detected in this capture", HFILL }},
{ &hf_snort_global_stats_alert_match_number,
{ "Match number", "snort.global-stats.match-number", FT_UINT32, BASE_DEC, NULL, 0x00,
"Number of match for this alert among all alerts", HFILL }},
{ &hf_snort_global_stats_rule_alerts_count,
{ "Number of alerts for this rule", "snort.global-stats.rule.alerts-count", FT_UINT32, BASE_DEC, NULL, 0x00,
"Number of alerts detected for this rule", HFILL }},
{ &hf_snort_global_stats_rule_match_number,
{ "Match number for this rule", "snort.global-stats.rule.match-number", FT_UINT32, BASE_DEC, NULL, 0x00,
"Number of match for this alert among those for this rule", HFILL }}
};
static gint *ett[] = {
&ett_snort,
&ett_snort_rule,
&ett_snort_global_stats
};
static const enum_val_t alerts_source_vals[] = {
{"from-nowhere", "Not looking for Snort alerts", FromNowhere},
{"from-running-snort", "From running Snort", FromRunningSnort},
{"from-user-comments", "From user packet comments", FromUserComments},
{NULL, NULL, -1}
};
static ei_register_info ei[] = {
{ &ei_snort_alert, { "snort.alert.expert", PI_SECURITY, PI_WARN, "Snort alert detected", EXPFILL }},
{ &ei_snort_content_not_matched, { "snort.content.not-matched", PI_PROTOCOL, PI_NOTE, "Failed to find content field of alert in frame", EXPFILL }},
};
expert_module_t* expert_snort;
module_t *snort_module;
proto_snort = proto_register_protocol("Snort Alerts", "Snort", "snort");
proto_register_field_array(proto_snort, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
/* Expert info */
expert_snort = expert_register_protocol(proto_snort);
expert_register_field_array(expert_snort, ei, array_length(ei));
snort_module = prefs_register_protocol(proto_snort, NULL);
prefs_register_obsolete_preference(snort_module, "enable_snort_dissector");
prefs_register_enum_preference(snort_module, "alerts_source",
"Source of Snort alerts",
"Set whether dissector should run Snort and pass frames into it, or read alerts from user packet comments",
&pref_snort_alerts_source, alerts_source_vals, FALSE);
prefs_register_filename_preference(snort_module, "binary",
"Snort binary",
"The name of the snort binary file to run",
&pref_snort_binary_filename, FALSE);
prefs_register_filename_preference(snort_module, "config",
"Configuration filename",
"The name of the file containing the snort IDS configuration. Typically snort.conf",
&pref_snort_config_filename, FALSE);
prefs_register_bool_preference(snort_module, "show_rule_set_stats",
"Show rule stats in protocol tree",
"Whether or not information about the rule set and detected alerts should "
"be shown in the tree of every snort PDU tree",
&snort_show_rule_stats);
prefs_register_bool_preference(snort_module, "show_alert_expert_info",
"Show alerts in expert info",
"Whether or not expert info should be used to highlight fired alerts",
&snort_show_alert_expert_info);
prefs_register_bool_preference(snort_module, "show_alert_in_reassembled_frame",
"Try to show alerts in reassembled frame",
"Attempt to show alert in reassembled frame where possible. Note that this won't work during live capture",
&snort_alert_in_reassembled_frame);
prefs_register_bool_preference(snort_module, "ignore_checksum_errors",
"Tell Snort to ignore checksum errors",
"When enabled, will run Snort with '-k none'",
&snort_ignore_checksum_errors);
snort_handle = create_dissector_handle(snort_dissector, proto_snort);
register_init_routine(snort_start);
register_postdissector(snort_handle);
/* Callback to make sure we cleanup dumper being used to deliver packets to snort (this will tsnort). */
register_postseq_cleanup_routine(snort_cleanup);
/* Callback to allow us to delete snort config */
register_cleanup_routine(snort_file_cleanup);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-socketcan.c
|
/* packet-socketcan.c
* Routines for disassembly of packets from SocketCAN
* Felix Obenhuber <[email protected]>
*
* Added support for the DeviceNet Dissector
* Hans-Joergen Gunnarsson <[email protected]>
* Copyright 2013
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/expert.h>
#include <epan/decode_as.h>
#include <epan/uat.h>
#include <wiretap/wtap.h>
#include "packet-sll.h"
#include "packet-socketcan.h"
void proto_register_socketcan(void);
void proto_reg_handoff_socketcan(void);
static int hf_can_len = -1;
static int hf_can_infoent_ext = -1;
static int hf_can_infoent_std = -1;
static int hf_can_extflag = -1;
static int hf_can_rtrflag = -1;
static int hf_can_errflag = -1;
static int hf_can_reserved = -1;
static int hf_can_padding = -1;
static int hf_can_err_tx_timeout = -1;
static int hf_can_err_lostarb = -1;
static int hf_can_err_ctrl = -1;
static int hf_can_err_prot = -1;
static int hf_can_err_trx = -1;
static int hf_can_err_ack = -1;
static int hf_can_err_busoff = -1;
static int hf_can_err_buserror = -1;
static int hf_can_err_restarted = -1;
static int hf_can_err_reserved = -1;
static int hf_can_err_lostarb_bit_number = -1;
static int hf_can_err_ctrl_rx_overflow = -1;
static int hf_can_err_ctrl_tx_overflow = -1;
static int hf_can_err_ctrl_rx_warning = -1;
static int hf_can_err_ctrl_tx_warning = -1;
static int hf_can_err_ctrl_rx_passive = -1;
static int hf_can_err_ctrl_tx_passive = -1;
static int hf_can_err_ctrl_active = -1;
static int hf_can_err_prot_error_type_bit = -1;
static int hf_can_err_prot_error_type_form = -1;
static int hf_can_err_prot_error_type_stuff = -1;
static int hf_can_err_prot_error_type_bit0 = -1;
static int hf_can_err_prot_error_type_bit1 = -1;
static int hf_can_err_prot_error_type_overload = -1;
static int hf_can_err_prot_error_type_active = -1;
static int hf_can_err_prot_error_type_tx = -1;
static int hf_can_err_prot_error_location = -1;
static int hf_can_err_trx_canh = -1;
static int hf_can_err_trx_canl = -1;
static int hf_can_err_ctrl_specific = -1;
static expert_field ei_can_err_dlc_mismatch = EI_INIT;
static int hf_canfd_brsflag = -1;
static int hf_canfd_esiflag = -1;
static gint ett_can = -1;
static gint ett_can_fd = -1;
static int proto_can = -1;
static int proto_canfd = -1;
static gboolean byte_swap = FALSE;
static gboolean heuristic_first = FALSE;
static heur_dissector_list_t heur_subdissector_list;
static heur_dtbl_entry_t *heur_dtbl_entry;
#define LINUX_CAN_STD 0
#define LINUX_CAN_EXT 1
#define LINUX_CAN_ERR 2
#define CAN_LEN_OFFSET 4
#define CAN_DATA_OFFSET 8
#define CANFD_FLAG_OFFSET 5
#define CANFD_BRS 0x01 /* bit rate switch (second bitrate for payload data) */
#define CANFD_ESI 0x02 /* error state indicator of the transmitting node */
static dissector_table_t can_id_dissector_table = NULL;
static dissector_table_t can_extended_id_dissector_table = NULL;
static dissector_table_t subdissector_table = NULL;
static dissector_handle_t socketcan_classic_handle;
static dissector_handle_t socketcan_fd_handle;
static const value_string can_err_prot_error_location_vals[] =
{
{ 0x00, "unspecified" },
{ 0x02, "ID bits 28 - 21 (SFF: 10 - 3)" },
{ 0x03, "start of frame" },
{ 0x04, "substitute RTR (SFF: RTR)" },
{ 0x05, "identifier extension" },
{ 0x06, "ID bits 20 - 18 (SFF: 2 - 0)" },
{ 0x07, "ID bits 17-13" },
{ 0x08, "CRC sequence" },
{ 0x09, "reserved bit 0" },
{ 0x0A, "data section" },
{ 0x0B, "data length code" },
{ 0x0C, "RTR" },
{ 0x0D, "reserved bit 1" },
{ 0x0E, "ID bits 4-0" },
{ 0x0F, "ID bits 12-5" },
{ 0x12, "intermission" },
{ 0x18, "CRC delimiter" },
{ 0x19, "ACK slot" },
{ 0x1A, "end of frame" },
{ 0x1B, "ACK delimiter" },
{ 0, NULL }
};
static const value_string can_err_trx_canh_vals[] =
{
{ 0x00, "unspecified" },
{ 0x04, "no wire" },
{ 0x05, "short to BAT" },
{ 0x06, "short to VCC" },
{ 0x07, "short to GND" },
{ 0, NULL }
};
static const value_string can_err_trx_canl_vals[] =
{
{ 0x00, "unspecified" },
{ 0x04, "no wire" },
{ 0x05, "short to BAT" },
{ 0x06, "short to VCC" },
{ 0x07, "short to GND" },
{ 0x08, "short to CANH" },
{ 0, NULL }
};
/********* UATs *********/
/* Interface Config UAT */
typedef struct _interface_config {
guint interface_id;
gchar *interface_name;
guint bus_id;
} interface_config_t;
#define DATAFILE_CAN_INTERFACE_MAPPING "CAN_interface_mapping"
static GHashTable *data_can_interfaces_by_id = NULL;
static GHashTable *data_can_interfaces_by_name = NULL;
static interface_config_t* interface_configs = NULL;
static guint interface_config_num = 0;
UAT_HEX_CB_DEF(interface_configs, interface_id, interface_config_t)
UAT_CSTRING_CB_DEF(interface_configs, interface_name, interface_config_t)
UAT_HEX_CB_DEF(interface_configs, bus_id, interface_config_t)
static void *
copy_interface_config_cb(void *n, const void *o, size_t size _U_) {
interface_config_t *new_rec = (interface_config_t *)n;
const interface_config_t *old_rec = (const interface_config_t *)o;
new_rec->interface_id = old_rec->interface_id;
new_rec->interface_name = g_strdup(old_rec->interface_name);
new_rec->bus_id = old_rec->bus_id;
return new_rec;
}
static gboolean
update_interface_config(void *r, char **err) {
interface_config_t *rec = (interface_config_t *)r;
if (rec->interface_id > 0xffffffff) {
*err = ws_strdup_printf("We currently only support 32 bit identifiers (ID: %i Name: %s)",
rec->interface_id, rec->interface_name);
return FALSE;
}
if (rec->bus_id > 0xffff) {
*err = ws_strdup_printf("We currently only support 16 bit bus identifiers (ID: %i Name: %s Bus-ID: %i)",
rec->interface_id, rec->interface_name, rec->bus_id);
return FALSE;
}
return TRUE;
}
static void
free_interface_config_cb(void *r) {
interface_config_t *rec = (interface_config_t *)r;
/* freeing result of g_strdup */
g_free(rec->interface_name);
rec->interface_name = NULL;
}
static interface_config_t *
ht_lookup_interface_config_by_id(unsigned int identifier) {
interface_config_t *tmp = NULL;
unsigned int *id = NULL;
if (interface_configs == NULL) {
return NULL;
}
id = wmem_new(wmem_epan_scope(), unsigned int);
*id = (unsigned int)identifier;
tmp = (interface_config_t *)g_hash_table_lookup(data_can_interfaces_by_id, id);
wmem_free(wmem_epan_scope(), id);
return tmp;
}
static interface_config_t *
ht_lookup_interface_config_by_name(const gchar *name) {
interface_config_t *tmp = NULL;
gchar *key = NULL;
if (interface_configs == NULL) {
return NULL;
}
key = wmem_strdup(wmem_epan_scope(), name);
tmp = (interface_config_t *)g_hash_table_lookup(data_can_interfaces_by_name, key);
wmem_free(wmem_epan_scope(), key);
return tmp;
}
static void
can_free_key(gpointer key) {
wmem_free(wmem_epan_scope(), key);
}
static void
post_update_can_interfaces_cb(void) {
guint i;
int *key_id = NULL;
gchar *key_name = NULL;
/* destroy old hash tables, if they exist */
if (data_can_interfaces_by_id) {
g_hash_table_destroy(data_can_interfaces_by_id);
data_can_interfaces_by_id = NULL;
}
if (data_can_interfaces_by_name) {
g_hash_table_destroy(data_can_interfaces_by_name);
data_can_interfaces_by_name = NULL;
}
/* create new hash table */
data_can_interfaces_by_id = g_hash_table_new_full(g_int_hash, g_int_equal, &can_free_key, NULL);
data_can_interfaces_by_name = g_hash_table_new_full(g_str_hash, g_str_equal, &can_free_key, NULL);
if (data_can_interfaces_by_id == NULL || data_can_interfaces_by_name == NULL || interface_configs == NULL || interface_config_num == 0) {
return;
}
for (i = 0; i < interface_config_num; i++) {
if (interface_configs[i].interface_id != 0xfffffff) {
key_id = wmem_new(wmem_epan_scope(), int);
*key_id = interface_configs[i].interface_id;
g_hash_table_insert(data_can_interfaces_by_id, key_id, &interface_configs[i]);
}
if (interface_configs[i].interface_name != NULL && interface_configs[i].interface_name[0] != 0) {
key_name = wmem_strdup(wmem_epan_scope(), interface_configs[i].interface_name);
g_hash_table_insert(data_can_interfaces_by_name, key_name, &interface_configs[i]);
}
}
}
/* We match based on the config in the following order:
* - interface_name matches and interface_id matches
* - interface_name matches and interface_id = 0xffffffff
* - interface_name = "" and interface_id matches
*/
static guint
get_bus_id(packet_info *pinfo) {
guint32 interface_id = pinfo->rec->rec_header.packet_header.interface_id;
const char *interface_name = epan_get_interface_name(pinfo->epan, interface_id);
interface_config_t *tmp = NULL;
if (!(pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)) {
return 0;
}
if (interface_name != NULL && interface_name[0] != 0) {
tmp = ht_lookup_interface_config_by_name(interface_name);
if (tmp != NULL && (tmp->interface_id == 0xffffffff || tmp->interface_id == interface_id)) {
/* name + id match or name match and id = any */
return tmp->bus_id;
}
tmp = ht_lookup_interface_config_by_id(interface_id);
if (tmp != NULL && (tmp->interface_name == NULL || tmp->interface_name[0] == 0)) {
/* id matches and name is any */
return tmp->bus_id;
}
}
/* we found nothing */
return 0;
}
/* Senders and Receivers UAT */
typedef struct _sender_receiver_config {
guint bus_id;
guint can_id;
gchar *sender_name;
gchar *receiver_name;
} sender_receiver_config_t;
#define DATAFILE_CAN_SENDER_RECEIVER "CAN_senders_receivers"
static GHashTable *data_sender_receiver = NULL;
static sender_receiver_config_t* sender_receiver_configs = NULL;
static guint sender_receiver_config_num = 0;
UAT_HEX_CB_DEF(sender_receiver_configs, bus_id, sender_receiver_config_t)
UAT_HEX_CB_DEF(sender_receiver_configs, can_id, sender_receiver_config_t)
UAT_CSTRING_CB_DEF(sender_receiver_configs, sender_name, sender_receiver_config_t)
UAT_CSTRING_CB_DEF(sender_receiver_configs, receiver_name, sender_receiver_config_t)
static void *
copy_sender_receiver_config_cb(void *n, const void *o, size_t size _U_) {
sender_receiver_config_t *new_rec = (sender_receiver_config_t *)n;
const sender_receiver_config_t *old_rec = (const sender_receiver_config_t *)o;
new_rec->bus_id = old_rec->bus_id;
new_rec->can_id = old_rec->can_id;
new_rec->sender_name = g_strdup(old_rec->sender_name);
new_rec->receiver_name = g_strdup(old_rec->receiver_name);
return new_rec;
}
static gboolean
update_sender_receiver_config(void *r, char **err) {
sender_receiver_config_t *rec = (sender_receiver_config_t *)r;
if (rec->bus_id > 0xffff) {
*err = ws_strdup_printf("We currently only support 16 bit bus identifiers (Bus ID: %i CAN ID: %i)", rec->bus_id, rec->can_id);
return FALSE;
}
return TRUE;
}
static void
free_sender_receiver_config_cb(void *r) {
sender_receiver_config_t *rec = (sender_receiver_config_t *)r;
/* freeing result of g_strdup */
g_free(rec->sender_name);
rec->sender_name = NULL;
g_free(rec->receiver_name);
rec->receiver_name = NULL;
}
static guint64
sender_receiver_key(guint16 bus_id, guint32 can_id) {
return ((guint64)bus_id << 32) | can_id;
}
static sender_receiver_config_t *
ht_lookup_sender_receiver_config(guint16 bus_id, guint32 can_id) {
sender_receiver_config_t *tmp = NULL;
guint64 key = 0;
if (sender_receiver_configs == NULL) {
return NULL;
}
key = sender_receiver_key(bus_id, can_id);
tmp = (sender_receiver_config_t *)g_hash_table_lookup(data_sender_receiver, &key);
if (tmp == NULL) {
key = sender_receiver_key(0, can_id);
tmp = (sender_receiver_config_t *)g_hash_table_lookup(data_sender_receiver, &key);
}
return tmp;
}
static void
sender_receiver_free_key(gpointer key) {
wmem_free(wmem_epan_scope(), key);
}
static void
post_update_sender_receiver_cb(void) {
guint i;
guint64 *key_id = NULL;
/* destroy old hash table, if it exist */
if (data_sender_receiver) {
g_hash_table_destroy(data_sender_receiver);
data_sender_receiver = NULL;
}
/* create new hash table */
data_sender_receiver = g_hash_table_new_full(g_int64_hash, g_int64_equal, &sender_receiver_free_key, NULL);
if (data_sender_receiver == NULL || sender_receiver_configs == NULL || sender_receiver_config_num == 0) {
return;
}
for (i = 0; i < sender_receiver_config_num; i++) {
key_id = wmem_new(wmem_epan_scope(), guint64);
*key_id = sender_receiver_key(sender_receiver_configs[i].bus_id, sender_receiver_configs[i].can_id);
g_hash_table_insert(data_sender_receiver, key_id, &sender_receiver_configs[i]);
}
}
gboolean
socketcan_set_source_and_destination_columns(packet_info* pinfo, can_info_t *caninfo)
{
sender_receiver_config_t *tmp = ht_lookup_sender_receiver_config(caninfo->bus_id, caninfo->id);
if (tmp != NULL) {
/* remove all addresses to support CAN as payload (e.g., TECMP) */
clear_address(&pinfo->net_src);
clear_address(&pinfo->dl_src);
clear_address(&pinfo->src);
clear_address(&pinfo->net_dst);
clear_address(&pinfo->dl_dst);
clear_address(&pinfo->dst);
col_add_fstr(pinfo->cinfo, COL_DEF_SRC, "%s", tmp->sender_name);
col_add_fstr(pinfo->cinfo, COL_DEF_DST, "%s", tmp->receiver_name);
return true;
}
return false;
}
gboolean
socketcan_call_subdissectors(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, struct can_info* can_info, const gboolean use_heuristics_first)
{
dissector_table_t effective_can_id_dissector_table = (can_info->id & CAN_EFF_FLAG) ? can_extended_id_dissector_table : can_id_dissector_table;
guint32 effective_can_id = (can_info->id & CAN_EFF_FLAG) ? can_info->id & CAN_EFF_MASK : can_info->id & CAN_SFF_MASK;
if (!dissector_try_uint_new(effective_can_id_dissector_table, effective_can_id, tvb, pinfo, tree, TRUE, can_info))
{
if (!use_heuristics_first)
{
if (!dissector_try_payload_new(subdissector_table, tvb, pinfo, tree, TRUE, can_info))
{
if (!dissector_try_heuristic(heur_subdissector_list, tvb, pinfo, tree, &heur_dtbl_entry, can_info))
{
return FALSE;
}
}
}
else
{
if (!dissector_try_heuristic(heur_subdissector_list, tvb, pinfo, tree, &heur_dtbl_entry, can_info))
{
if (!dissector_try_payload_new(subdissector_table, tvb, pinfo, tree, FALSE, can_info))
{
return FALSE;
}
}
}
}
return TRUE;
}
/*
* Either:
*
* 1) a given SocketCAN frame is known to contain a classic CAN
* packet based on information outside the SocketCAN header;
*
* 2) a given SocketCAN frame is known to contain a CAN FD
* packet based on information outside the SocketCAN header;
*
* 3) we don't know whether the given SocketCAN frame is a
* classic CAN packet or a CAN FD packet, and will have
* to check the CANFD_FDF bit in the "FD flags" field of
* the SocketCAN header to determine that.
*/
typedef enum {
PACKET_TYPE_CAN,
PACKET_TYPE_CAN_FD,
PACKET_TYPE_UNKNOWN
} can_packet_type_t;
static int
dissect_socketcan_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
guint encoding, can_packet_type_t can_packet_type)
{
proto_tree *can_tree;
proto_item *ti;
guint8 frame_type;
struct can_info can_info;
int * const *can_flags;
static int * const can_std_flags[] = {
&hf_can_infoent_std,
&hf_can_extflag,
&hf_can_rtrflag,
&hf_can_errflag,
NULL,
};
static int * const can_ext_flags[] = {
&hf_can_infoent_ext,
&hf_can_extflag,
&hf_can_rtrflag,
&hf_can_errflag,
NULL,
};
static int * const can_std_flags_fd[] = {
&hf_can_infoent_std,
&hf_can_extflag,
NULL,
};
static int * const can_ext_flags_fd[] = {
&hf_can_infoent_ext,
&hf_can_extflag,
NULL,
};
static int * const canfd_flag_fields[] = {
&hf_canfd_brsflag,
&hf_canfd_esiflag,
NULL,
};
static int * const can_err_flags[] = {
&hf_can_errflag,
&hf_can_err_tx_timeout,
&hf_can_err_lostarb,
&hf_can_err_ctrl,
&hf_can_err_prot,
&hf_can_err_trx,
&hf_can_err_ack,
&hf_can_err_busoff,
&hf_can_err_buserror,
&hf_can_err_restarted,
&hf_can_err_reserved,
NULL,
};
can_info.id = tvb_get_guint32(tvb, 0, encoding);
can_info.len = tvb_get_guint8(tvb, CAN_LEN_OFFSET);
/*
* If we weren't told the type of this frame, check
* whether the CANFD_FDF flag is set in the FD flags
* field of the header; if so, it's a CAN FD frame.
* otherwise, it's a CAN frame.
*
* However, trust the CANFD_FDF flag only if the only
* bits set in the FD flags field are the known bits,
* and the two bytes following that field are both
* zero. This is because some older LINKTYPE_CAN_SOCKETCAN
* frames had uninitialized junk in the FD flags field,
* so we treat a frame with what appears to be uninitialized
* junk as being CAN rather than CAN FD, under the assumption
* that the CANFD_FDF bit is set because the field is
* uninitialized, not because it was explicitly set because
* it's a CAN FD frame. At least some newer code that sets
* that flag also makes sure that the fields in question are
* initialized, so we assume that if they're not initialized
* the code is older code that didn't support CAN FD.
*/
if (can_packet_type == PACKET_TYPE_UNKNOWN) {
guint8 fd_flags;
fd_flags = tvb_get_guint8(tvb, CANFD_FLAG_OFFSET);
if ((fd_flags & CANFD_FDF) &&
((fd_flags & ~(CANFD_BRS|CANFD_ESI|CANFD_FDF)) == 0) &&
tvb_get_guint8(tvb, CANFD_FLAG_OFFSET + 1) == 0 &&
tvb_get_guint8(tvb, CANFD_FLAG_OFFSET + 2) == 0)
can_packet_type = PACKET_TYPE_CAN_FD;
else
can_packet_type = PACKET_TYPE_CAN;
}
can_info.fd = (can_packet_type == PACKET_TYPE_CAN_FD);
can_info.bus_id = get_bus_id(pinfo);
/* Error Message Frames are only encapsulated in Classic CAN frames */
if (can_packet_type == PACKET_TYPE_CAN && (can_info.id & CAN_ERR_FLAG))
{
frame_type = LINUX_CAN_ERR;
can_flags = can_err_flags;
}
else if (can_info.id & CAN_EFF_FLAG)
{
frame_type = LINUX_CAN_EXT;
can_info.id &= (CAN_EFF_MASK | CAN_FLAG_MASK);
can_flags = (can_packet_type == PACKET_TYPE_CAN_FD) ? can_ext_flags_fd : can_ext_flags;
}
else
{
frame_type = LINUX_CAN_STD;
can_info.id &= (CAN_SFF_MASK | CAN_FLAG_MASK);
can_flags = (can_packet_type == PACKET_TYPE_CAN_FD) ? can_std_flags_fd : can_std_flags;
}
col_set_str(pinfo->cinfo, COL_PROTOCOL, (can_packet_type == PACKET_TYPE_CAN_FD) ? "CANFD" : "CAN");
col_clear(pinfo->cinfo, COL_INFO);
guint32 effective_can_id = (can_info.id & CAN_EFF_FLAG) ? can_info.id & CAN_EFF_MASK : can_info.id & CAN_SFF_MASK;
char* id_name = (can_info.id & CAN_EFF_FLAG) ? "Ext. ID" : "ID";
col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %d (0x%" PRIx32 "), Length: %d", id_name, effective_can_id, effective_can_id, can_info.len);
socketcan_set_source_and_destination_columns(pinfo, &can_info);
ti = proto_tree_add_item(tree, (can_packet_type == PACKET_TYPE_CAN_FD) ? proto_canfd : proto_can, tvb, 0, -1, ENC_NA);
can_tree = proto_item_add_subtree(ti, (can_packet_type == PACKET_TYPE_CAN_FD) ? ett_can_fd : ett_can);
proto_item_append_text(can_tree, ", %s: %d (0x%" PRIx32 "), Length: %d", id_name, effective_can_id, effective_can_id, can_info.len);
proto_tree_add_bitmask_list(can_tree, tvb, 0, 4, can_flags, encoding);
proto_tree_add_item(can_tree, hf_can_len, tvb, CAN_LEN_OFFSET, 1, ENC_NA);
if (frame_type == LINUX_CAN_ERR && can_info.len != CAN_ERR_DLC)
{
proto_tree_add_expert(tree, pinfo, &ei_can_err_dlc_mismatch, tvb, CAN_LEN_OFFSET, 1);
}
if (can_packet_type == PACKET_TYPE_CAN_FD) {
proto_tree_add_bitmask_list(can_tree, tvb, CANFD_FLAG_OFFSET, 1, canfd_flag_fields, ENC_NA);
proto_tree_add_item(can_tree, hf_can_reserved, tvb, CANFD_FLAG_OFFSET+1, 2, ENC_NA);
} else
proto_tree_add_item(can_tree, hf_can_reserved, tvb, CANFD_FLAG_OFFSET, 3, ENC_NA);
if (frame_type == LINUX_CAN_ERR)
{
int * const *flag;
const char *sepa = ": ";
col_set_str(pinfo->cinfo, COL_INFO, "ERR");
for (flag = can_err_flags; *flag; flag++)
{
header_field_info *hfi;
hfi = proto_registrar_get_nth(**flag);
if (!hfi)
continue;
if ((can_info.id & hfi->bitmask & ~CAN_FLAG_MASK) == 0)
continue;
col_append_sep_str(pinfo->cinfo, COL_INFO, sepa, hfi->name);
sepa = ", ";
}
if (can_info.id & CAN_ERR_LOSTARB)
proto_tree_add_item(can_tree, hf_can_err_lostarb_bit_number, tvb, CAN_DATA_OFFSET+0, 1, ENC_NA);
if (can_info.id & CAN_ERR_CTRL)
{
static int * const can_err_ctrl_flags[] = {
&hf_can_err_ctrl_rx_overflow,
&hf_can_err_ctrl_tx_overflow,
&hf_can_err_ctrl_rx_warning,
&hf_can_err_ctrl_tx_warning,
&hf_can_err_ctrl_rx_passive,
&hf_can_err_ctrl_tx_passive,
&hf_can_err_ctrl_active,
NULL,
};
proto_tree_add_bitmask_list(can_tree, tvb, CAN_DATA_OFFSET+1, 1, can_err_ctrl_flags, ENC_NA);
}
if (can_info.id & CAN_ERR_PROT)
{
static int * const can_err_prot_error_type_flags[] = {
&hf_can_err_prot_error_type_bit,
&hf_can_err_prot_error_type_form,
&hf_can_err_prot_error_type_stuff,
&hf_can_err_prot_error_type_bit0,
&hf_can_err_prot_error_type_bit1,
&hf_can_err_prot_error_type_overload,
&hf_can_err_prot_error_type_active,
&hf_can_err_prot_error_type_tx,
NULL
};
proto_tree_add_bitmask_list(can_tree, tvb, CAN_DATA_OFFSET+2, 1, can_err_prot_error_type_flags, ENC_NA);
proto_tree_add_item(can_tree, hf_can_err_prot_error_location, tvb, CAN_DATA_OFFSET+3, 1, ENC_NA);
}
if (can_info.id & CAN_ERR_TRX)
{
proto_tree_add_item(can_tree, hf_can_err_trx_canh, tvb, CAN_DATA_OFFSET+4, 1, ENC_NA);
proto_tree_add_item(can_tree, hf_can_err_trx_canl, tvb, CAN_DATA_OFFSET+4, 1, ENC_NA);
}
proto_tree_add_item(can_tree, hf_can_err_ctrl_specific, tvb, CAN_DATA_OFFSET+5, 3, ENC_NA);
}
else
{
tvbuff_t *next_tvb;
if (can_info.id & CAN_RTR_FLAG)
{
col_append_str(pinfo->cinfo, COL_INFO, "(Remote Transmission Request)");
}
next_tvb = tvb_new_subset_length(tvb, CAN_DATA_OFFSET, can_info.len);
if (!socketcan_call_subdissectors(next_tvb, pinfo, tree, &can_info, heuristic_first))
{
call_data_dissector(next_tvb, pinfo, tree);
}
}
if (tvb_captured_length_remaining(tvb, CAN_DATA_OFFSET+can_info.len) > 0)
{
proto_tree_add_item(can_tree, hf_can_padding, tvb, CAN_DATA_OFFSET+can_info.len, -1, ENC_NA);
}
return tvb_captured_length(tvb);
}
static int
dissect_socketcan_bigendian(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void* data _U_)
{
return dissect_socketcan_common(tvb, pinfo, tree,
byte_swap ? ENC_LITTLE_ENDIAN : ENC_BIG_ENDIAN, PACKET_TYPE_UNKNOWN);
}
static int
dissect_socketcan_classic(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void* data _U_)
{
return dissect_socketcan_common(tvb, pinfo, tree,
byte_swap ? ENC_ANTI_HOST_ENDIAN : ENC_HOST_ENDIAN, PACKET_TYPE_CAN);
}
static int
dissect_socketcan_fd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void* data _U_)
{
return dissect_socketcan_common(tvb, pinfo, tree,
byte_swap ? ENC_ANTI_HOST_ENDIAN : ENC_HOST_ENDIAN, PACKET_TYPE_CAN_FD);
}
void
proto_register_socketcan(void)
{
static hf_register_info hf[] = {
{
&hf_can_infoent_ext,
{
"ID", "can.id",
FT_UINT32, BASE_DEC_HEX,
NULL, CAN_EFF_MASK,
NULL, HFILL
}
},
{
&hf_can_infoent_std,
{
"ID", "can.id",
FT_UINT32, BASE_DEC_HEX,
NULL, CAN_SFF_MASK,
NULL, HFILL
}
},
{
&hf_can_extflag,
{
"Extended Flag", "can.flags.xtd",
FT_BOOLEAN, 32,
NULL, CAN_EFF_FLAG,
NULL, HFILL
}
},
{
&hf_can_rtrflag,
{
"Remote Transmission Request Flag", "can.flags.rtr",
FT_BOOLEAN, 32,
NULL, CAN_RTR_FLAG,
NULL, HFILL
}
},
{
&hf_can_errflag,
{
"Error Message Flag", "can.flags.err",
FT_BOOLEAN, 32,
NULL, CAN_ERR_FLAG,
NULL, HFILL
}
},
{
&hf_can_len,
{
"Frame-Length", "can.len",
FT_UINT8, BASE_DEC,
NULL, 0x0,
NULL, HFILL
}
},
{
&hf_can_reserved,
{
"Reserved", "can.reserved",
FT_BYTES, BASE_NONE,
NULL, 0x0,
NULL, HFILL
}
},
{
&hf_can_padding,
{
"Padding", "can.padding",
FT_BYTES, BASE_NONE,
NULL, 0x0,
NULL, HFILL
}
},
{
&hf_canfd_brsflag,
{
"Bit Rate Setting", "canfd.flags.brs",
FT_BOOLEAN, 8,
NULL, CANFD_BRS,
NULL, HFILL
}
},
{
&hf_canfd_esiflag,
{
"Error State Indicator", "canfd.flags.esi",
FT_BOOLEAN, 8,
NULL, CANFD_ESI,
NULL, HFILL
}
},
{
&hf_can_err_tx_timeout,
{
"Transmit timeout", "can.err.tx_timeout",
FT_BOOLEAN, 32,
NULL, CAN_ERR_TX_TIMEOUT,
NULL, HFILL
}
},
{
&hf_can_err_lostarb,
{
"Lost arbitration", "can.err.lostarb",
FT_BOOLEAN, 32,
NULL, CAN_ERR_LOSTARB,
NULL, HFILL
}
},
{
&hf_can_err_ctrl,
{
"Controller problems", "can.err.ctrl",
FT_BOOLEAN, 32,
NULL, CAN_ERR_CTRL,
NULL, HFILL
}
},
{
&hf_can_err_prot,
{
"Protocol violation", "can.err.prot",
FT_BOOLEAN, 32,
NULL, CAN_ERR_PROT,
NULL, HFILL
}
},
{
&hf_can_err_trx,
{
"Transceiver status", "can.err.trx",
FT_BOOLEAN, 32,
NULL, CAN_ERR_TRX,
NULL, HFILL
}
},
{
&hf_can_err_ack,
{
"No acknowledgement", "can.err.ack",
FT_BOOLEAN, 32,
NULL, CAN_ERR_ACK,
NULL, HFILL
}
},
{
&hf_can_err_busoff,
{
"Bus off", "can.err.busoff",
FT_BOOLEAN, 32,
NULL, CAN_ERR_BUSOFF,
NULL, HFILL
}
},
{
&hf_can_err_buserror,
{
"Bus error", "can.err.buserror",
FT_BOOLEAN, 32,
NULL, CAN_ERR_BUSERROR,
NULL, HFILL
}
},
{
&hf_can_err_restarted,
{
"Controller restarted", "can.err.restarted",
FT_BOOLEAN, 32,
NULL, CAN_ERR_RESTARTED,
NULL, HFILL
}
},
{
&hf_can_err_reserved,
{
"Reserved", "can.err.reserved",
FT_UINT32, BASE_HEX,
NULL, CAN_ERR_RESERVED,
NULL, HFILL
}
},
{
&hf_can_err_lostarb_bit_number,
{
"Lost arbitration in bit number", "can.err.lostarb.bitnum",
FT_UINT8, BASE_DEC,
NULL, 0,
NULL, HFILL
}
},
{
&hf_can_err_ctrl_rx_overflow,
{
"RX buffer overflow", "can.err.ctrl.rx_overflow",
FT_BOOLEAN, 8,
NULL, 0x01,
NULL, HFILL
}
},
{
&hf_can_err_ctrl_tx_overflow,
{
"TX buffer overflow", "can.err.ctrl.tx_overflow",
FT_BOOLEAN, 8,
NULL, 0x02,
NULL, HFILL
}
},
{
&hf_can_err_ctrl_rx_warning,
{
"Reached warning level for RX errors", "can.err.ctrl.rx_warning",
FT_BOOLEAN, 8,
NULL, 0x04,
NULL, HFILL
}
},
{
&hf_can_err_ctrl_tx_warning,
{
"Reached warning level for TX errors", "can.err.ctrl.tx_warning",
FT_BOOLEAN, 8,
NULL, 0x08,
NULL, HFILL
}
},
{
&hf_can_err_ctrl_rx_passive,
{
"Reached error passive status RX", "can.err.ctrl.rx_passive",
FT_BOOLEAN, 8,
NULL, 0x10,
NULL, HFILL
}
},
{
&hf_can_err_ctrl_tx_passive,
{
"Reached error passive status TX", "can.err.ctrl.tx_passive",
FT_BOOLEAN, 8,
NULL, 0x20,
NULL, HFILL
}
},
{
&hf_can_err_ctrl_active,
{
"Recovered to error active state", "can.err.ctrl.active",
FT_BOOLEAN, 8,
NULL, 0x40,
NULL, HFILL
}
},
{
&hf_can_err_prot_error_type_bit,
{
"Single bit error", "can.err.prot.type.bit",
FT_BOOLEAN, 8,
NULL, CAN_ERR_PROT_BIT,
NULL, HFILL
}
},
{
&hf_can_err_prot_error_type_form,
{
"Frame format error", "can.err.prot.type.form",
FT_BOOLEAN, 8,
NULL, CAN_ERR_PROT_FORM,
NULL, HFILL
}
},
{
&hf_can_err_prot_error_type_stuff,
{
"Bit stuffing error", "can.err.prot.type.stuff",
FT_BOOLEAN, 8,
NULL, CAN_ERR_PROT_STUFF,
NULL, HFILL
}
},
{
&hf_can_err_prot_error_type_bit0,
{
"Unable to send dominant bit", "can.err.prot.type.bit0",
FT_BOOLEAN, 8,
NULL, CAN_ERR_PROT_BIT0,
NULL, HFILL
}
},
{
&hf_can_err_prot_error_type_bit1,
{
"Unable to send recessive bit", "can.err.prot.type.bit1",
FT_BOOLEAN, 8,
NULL, CAN_ERR_PROT_BIT1,
NULL, HFILL
}
},
{
&hf_can_err_prot_error_type_overload,
{
"Bus overload", "can.err.prot.type.overload",
FT_BOOLEAN, 8,
NULL, CAN_ERR_PROT_OVERLOAD,
NULL, HFILL
}
},
{
&hf_can_err_prot_error_type_active,
{
"Active error announcement", "can.err.prot.type.active",
FT_BOOLEAN, 8,
NULL, CAN_ERR_PROT_ACTIVE,
NULL, HFILL
}
},
{
&hf_can_err_prot_error_type_tx,
{
"Error occurred on transmission", "can.err.prot.type.tx",
FT_BOOLEAN, 8,
NULL, CAN_ERR_PROT_TX,
NULL, HFILL
}
},
{
&hf_can_err_prot_error_location,
{
"Protocol error location", "can.err.prot.location",
FT_UINT8, BASE_DEC,
VALS(can_err_prot_error_location_vals), 0,
NULL, HFILL
}
},
{
&hf_can_err_trx_canh,
{
"Transceiver CANH status", "can.err.trx.canh",
FT_UINT8, BASE_DEC,
VALS(can_err_trx_canh_vals), 0x0F,
NULL, HFILL
}
},
{
&hf_can_err_trx_canl,
{
"Transceiver CANL status", "can.err.trx.canl",
FT_UINT8, BASE_DEC,
VALS(can_err_trx_canl_vals), 0xF0,
NULL, HFILL
}
},
{
&hf_can_err_ctrl_specific,
{
"Controller specific data", "can.err.ctrl_specific",
FT_BYTES, SEP_SPACE,
NULL, 0,
NULL, HFILL
}
},
};
uat_t *can_interface_uat = NULL;
uat_t *sender_receiver_uat = NULL;
/* Setup protocol subtree array */
static gint *ett[] =
{
&ett_can,
&ett_can_fd
};
static ei_register_info ei[] = {
{
&ei_can_err_dlc_mismatch,
{
"can.err.dlc_mismatch", PI_MALFORMED, PI_ERROR,
"ERROR: DLC mismatch", EXPFILL
}
}
};
module_t *can_module;
proto_can = proto_register_protocol("Controller Area Network", "CAN", "can");
/*
* "can-hostendian" is a legacy name (there never was, in any libpcap
* release, a SocketCAN LINKTYPE_ value for a host-endian CAN ID
* and flags field); we need to keep it around in case some candump
* or Busmaster capture that was saved as a pcap or pcapng file,
* as those use a linktype of LINKTYPE_WIRESHARK_UPPER_PDU with
* "can-hostendian" as the dissector name.
*/
socketcan_classic_handle = register_dissector("can-hostendian", dissect_socketcan_classic, proto_can);
proto_canfd = proto_register_protocol("Controller Area Network FD", "CANFD", "canfd");
socketcan_fd_handle = register_dissector("canfd", dissect_socketcan_fd, proto_canfd);
proto_register_field_array(proto_can, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_register_field_array(expert_register_protocol(proto_can), ei, array_length(ei));
can_module = prefs_register_protocol(proto_can, NULL);
prefs_register_obsolete_preference(can_module, "protocol");
prefs_register_bool_preference(can_module, "byte_swap",
"Byte-swap the CAN ID/flags field",
"Whether the CAN ID/flags field should be byte-swapped",
&byte_swap);
prefs_register_bool_preference(can_module, "try_heuristic_first",
"Try heuristic sub-dissectors first",
"Try to decode a packet using an heuristic sub-dissector"
" before using a sub-dissector registered to \"decode as\"",
&heuristic_first);
can_id_dissector_table = register_dissector_table("can.id", "CAN ID", proto_can, FT_UINT32, BASE_DEC);
can_extended_id_dissector_table = register_dissector_table("can.extended_id", "CAN Extended ID", proto_can, FT_UINT32, BASE_DEC);
subdissector_table = register_decode_as_next_proto(proto_can, "can.subdissector", "CAN next level dissector", NULL);
heur_subdissector_list = register_heur_dissector_list("can", proto_can);
static uat_field_t can_interface_mapping_uat_fields[] = {
UAT_FLD_HEX(interface_configs, interface_id, "Interface ID", "ID of the Interface with 0xffffffff = any (hex uint32 without leading 0x)"),
UAT_FLD_CSTRING(interface_configs, interface_name, "Interface Name", "Name of the Interface, empty = any (string)"),
UAT_FLD_HEX(interface_configs, bus_id, "Bus ID", "Bus ID of the Interface (hex uint16 without leading 0x)"),
UAT_END_FIELDS
};
can_interface_uat = uat_new("CAN Interface Mapping",
sizeof(interface_config_t), /* record size */
DATAFILE_CAN_INTERFACE_MAPPING, /* filename */
TRUE, /* from profile */
(void**)&interface_configs, /* data_ptr */
&interface_config_num, /* numitems_ptr */
UAT_AFFECTS_DISSECTION, /* but not fields */
NULL, /* help */
copy_interface_config_cb, /* copy callback */
update_interface_config, /* update callback */
free_interface_config_cb, /* free callback */
post_update_can_interfaces_cb, /* post update callback */
NULL, /* reset callback */
can_interface_mapping_uat_fields /* UAT field definitions */
);
prefs_register_uat_preference(can_module, "_can_interface_mapping", "Interface Mapping",
"A table to define the mapping between interface and Bus ID.", can_interface_uat);
static uat_field_t sender_receiver_mapping_uat_fields[] = {
UAT_FLD_HEX(sender_receiver_configs, bus_id, "Bus ID", "Bus ID of the Interface with 0 meaning any (hex uint16 without leading 0x)."),
UAT_FLD_HEX(sender_receiver_configs, can_id, "CAN ID", "ID of the CAN Message (hex uint32 without leading 0x)"),
UAT_FLD_CSTRING(sender_receiver_configs, sender_name, "Sender Name", "Name of Sender(s)"),
UAT_FLD_CSTRING(sender_receiver_configs, receiver_name, "Receiver Name", "Name of Receiver(s)"),
UAT_END_FIELDS
};
sender_receiver_uat = uat_new("Sender Receiver Config",
sizeof(sender_receiver_config_t), /* record size */
DATAFILE_CAN_SENDER_RECEIVER, /* filename */
TRUE, /* from profile */
(void**)&sender_receiver_configs, /* data_ptr */
&sender_receiver_config_num, /* numitems_ptr */
UAT_AFFECTS_DISSECTION, /* but not fields */
NULL, /* help */
copy_sender_receiver_config_cb, /* copy callback */
update_sender_receiver_config, /* update callback */
free_sender_receiver_config_cb, /* free callback */
post_update_sender_receiver_cb, /* post update callback */
NULL, /* reset callback */
sender_receiver_mapping_uat_fields /* UAT field definitions */
);
prefs_register_uat_preference(can_module, "_sender_receiver_config", "Sender Receiver Config",
"A table to define the mapping between Bus ID and CAN ID to Sender and Receiver.", sender_receiver_uat);
}
void
proto_reg_handoff_socketcan(void)
{
dissector_handle_t socketcan_bigendian_handle;
socketcan_bigendian_handle = create_dissector_handle(dissect_socketcan_bigendian, proto_can);
dissector_add_uint("wtap_encap", WTAP_ENCAP_SOCKETCAN, socketcan_bigendian_handle);
dissector_add_uint("sll.ltype", LINUX_SLL_P_CAN, socketcan_classic_handle);
dissector_add_uint("sll.ltype", LINUX_SLL_P_CANFD, socketcan_fd_handle);
}
/*
* Editor modelines - https://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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-socketcan.h
|
/* packet-socketcan.h
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PACKET_SOCKETCAN_H__
#define __PACKET_SOCKETCAN_H__
#include <epan/tvbuff.h>
#include <epan/packet_info.h>
#include <epan/proto.h>
/* Flags for CAN FD frames. */
#define CANFD_BRS 0x01 /* Bit Rate Switch (second bitrate for payload data) */
#define CANFD_ESI 0x02 /* Error State Indicator of the transmitting node */
#define CANFD_FDF 0x04 /* FD flag - if set, this is an FD frame */
/* Structure that gets passed between dissectors. */
struct can_info
{
guint32 id;
guint32 len;
gboolean fd;
guint16 bus_id;
};
typedef struct can_info can_info_t;
/* controller area network (CAN) kernel definitions
* These masks are usually defined within <linux/can.h> but are not
* available on non-Linux platforms; that's the reason for the
* redefinitions below
*
* special address description flags for the CAN_ID */
#define CAN_EFF_FLAG 0x80000000 /* EFF/SFF is set in the MSB */
#define CAN_RTR_FLAG 0x40000000 /* remote transmission request */
#define CAN_ERR_FLAG 0x20000000 /* error frame */
#define CAN_FLAG_MASK (CAN_EFF_FLAG | CAN_RTR_FLAG | CAN_ERR_FLAG)
#define CAN_EFF_MASK 0x1FFFFFFF /* extended frame format (EFF) has a 29 bit identifier */
#define CAN_SFF_MASK 0x000007FF /* standard frame format (SFF) has a 11 bit identifier */
#define CAN_ERR_DLC 8 /* dlc for error message frames */
/* error class (mask) in can_id */
#define CAN_ERR_TX_TIMEOUT 0x00000001U /* TX timeout (by netdevice driver) */
#define CAN_ERR_LOSTARB 0x00000002U /* lost arbitration / data[0] */
#define CAN_ERR_CTRL 0x00000004U /* controller problems / data[1] */
#define CAN_ERR_PROT 0x00000008U /* protocol violations / data[2..3] */
#define CAN_ERR_TRX 0x00000010U /* transceiver status / data[4] */
#define CAN_ERR_ACK 0x00000020U /* received no ACK on transmission */
#define CAN_ERR_BUSOFF 0x00000040U /* bus off */
#define CAN_ERR_BUSERROR 0x00000080U /* bus error (may flood!) */
#define CAN_ERR_RESTARTED 0x00000100U /* controller restarted */
#define CAN_ERR_RESERVED 0x1FFFFE00U /* reserved bits */
/* error in CAN protocol (type) / data[2] */
#define CAN_ERR_PROT_UNSPEC 0x00 /* unspecified */
#define CAN_ERR_PROT_BIT 0x01 /* single bit error */
#define CAN_ERR_PROT_FORM 0x02 /* frame format error */
#define CAN_ERR_PROT_STUFF 0x04 /* bit stuffing error */
#define CAN_ERR_PROT_BIT0 0x08 /* unable to send dominant bit */
#define CAN_ERR_PROT_BIT1 0x10 /* unable to send recessive bit */
#define CAN_ERR_PROT_OVERLOAD 0x20 /* bus overload */
#define CAN_ERR_PROT_ACTIVE 0x40 /* active error announcement */
#define CAN_ERR_PROT_TX 0x80 /* error occured on transmission */
/* error in CAN protocol (location) / data[3] */
#define CAN_ERR_PROT_LOC_UNSPEC 0x00 /* unspecified */
#define CAN_ERR_PROT_LOC_SOF 0x03 /* start of frame */
#define CAN_ERR_PROT_LOC_ID28_21 0x02 /* ID bits 28 - 21 (SFF: 10 - 3) */
#define CAN_ERR_PROT_LOC_ID20_18 0x06 /* ID bits 20 - 18 (SFF: 2 - 0 )*/
#define CAN_ERR_PROT_LOC_SRTR 0x04 /* substitute RTR (SFF: RTR) */
#define CAN_ERR_PROT_LOC_IDE 0x05 /* identifier extension */
#define CAN_ERR_PROT_LOC_ID17_13 0x07 /* ID bits 17-13 */
#define CAN_ERR_PROT_LOC_ID12_05 0x0F /* ID bits 12-5 */
#define CAN_ERR_PROT_LOC_ID04_00 0x0E /* ID bits 4-0 */
#define CAN_ERR_PROT_LOC_RTR 0x0C /* RTR */
#define CAN_ERR_PROT_LOC_RES1 0x0D /* reserved bit 1 */
#define CAN_ERR_PROT_LOC_RES0 0x09 /* reserved bit 0 */
#define CAN_ERR_PROT_LOC_DLC 0x0B /* data length code */
#define CAN_ERR_PROT_LOC_DATA 0x0A /* data section */
#define CAN_ERR_PROT_LOC_CRC_SEQ 0x08 /* CRC sequence */
#define CAN_ERR_PROT_LOC_CRC_DEL 0x18 /* CRC delimiter */
#define CAN_ERR_PROT_LOC_ACK 0x19 /* ACK slot */
#define CAN_ERR_PROT_LOC_ACK_DEL 0x1B /* ACK delimiter */
#define CAN_ERR_PROT_LOC_EOF 0x1A /* end of frame */
#define CAN_ERR_PROT_LOC_INTERM 0x12 /* intermission */
gboolean socketcan_call_subdissectors(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, struct can_info *can_info, const gboolean use_heuristics_first);
gboolean socketcan_set_source_and_destination_columns(packet_info* pinfo, can_info_t *caninfo);
#endif /* __PACKET_SOCKETCAN_H__ */
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-socks.c
|
/* packet-socks.c
* Routines for socks versions 4 &5 packet dissection
* Copyright 2000, Jeffrey C. Foster <[email protected]>
* Copyright 2008, Jelmer Vernooij <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
*
* The Version 4 decode is based on SOCKS4.protocol and SOCKS4A.protocol.
* The Version 5 decoder is based upon rfc-1928
* The Version 5 User/Password authentication is based on rfc-1929.
*
* See
* http://www.openssh.org/txt/socks4.protocol
* http://www.openssh.org/txt/socks4a.protocol
*
* for information on SOCKS version 4 and 4a.
*
* Revisions:
*
* 2003-09-18 JCFoster Fixed problem with socks tunnel in socks tunnel
* causing heap overflow because of an infinite loop
* where the socks dissect was call over and over.
*
* Also remove some old code marked with __JUNK__
*
* 2001-01-08 JCFoster Fixed problem with NULL pointer for hash data.
* Now test and exit if hash_info is null.
*/
/* Possible enhancements -
*
* Add GSS-API authentication per rfc-1961
* Add CHAP authentication
* Decode FLAG bits per
* https://tools.ietf.org/html/draft-ietf-aft-socks-pro-v5-04
* In call_next_dissector, could load the destination address into
* pinfo->src or pinfo->dst structure before calling next dissector.
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/proto_data.h>
#include "packet-tcp.h"
#include "packet-udp.h"
#include "packet-tls.h"
#include <epan/strutil.h>
#define TCP_PORT_SOCKS 1080
/**************** Socks commands ******************/
#define CONNECT_COMMAND 1
#define BIND_COMMAND 2
#define UDP_ASSOCIATE_COMMAND 3
#define PING_COMMAND 0x80
#define TRACERT_COMMAND 0x81
/********** V5 Authentication methods *************/
#define NO_AUTHENTICATION 0
#define GSS_API_AUTHENTICATION 1
#define USER_NAME_AUTHENTICATION 2
#define CHAP_AUTHENTICATION 3
#define AUTHENTICATION_FAILED 0xff
void proto_register_socks(void);
void proto_reg_handoff_socks(void);
/*********** Header field identifiers *************/
static int proto_socks = -1;
static int ett_socks = -1;
static int ett_socks_auth = -1;
static int ett_socks_name = -1;
static int hf_socks_ver = -1;
static int hf_socks_ip_dst = -1;
static int hf_socks_ip6_dst = -1;
static int hf_gssapi_payload = -1;
static int hf_gssapi_command = -1;
static int hf_gssapi_length = -1;
static int hf_v4a_dns_name = -1;
static int hf_socks_dstport = -1;
static int hf_socks_cmd = -1;
static int hf_socks_results_4 = -1;
static int hf_socks_results_5 = -1;
static int hf_client_auth_method_count = -1;
static int hf_client_auth_method = -1;
static int hf_socks_reserved = -1;
static int hf_socks_reserved2 = -1;
static int hf_client_port = -1;
static int hf_server_accepted_auth_method = -1;
static int hf_server_auth_status = -1;
static int hf_server_remote_host_port = -1;
static int hf_socks_subnegotiation_version = -1;
static int hf_socks_username = -1;
static int hf_socks_password = -1;
static int hf_socks_remote_name = -1;
static int hf_socks_address_type = -1;
static int hf_socks_fragment_number = -1;
static int hf_socks_ping_end_command = -1;
static int hf_socks_ping_results = -1;
static int hf_socks_traceroute_end_command = -1;
static int hf_socks_traceroute_results = -1;
/************* Dissector handles ***********/
static dissector_handle_t socks_handle;
static dissector_handle_t socks_handle_tls;
static dissector_handle_t socks_udp_handle;
/************* State Machine names ***********/
enum ClientState {
clientNoInit = -1,
clientStart = 0,
clientWaitForAuthReply,
clientV5Command,
clientUserNameRequest,
clientGssApiAuthRequest,
clientDone,
clientError
};
enum ServerState {
serverNoInit = -1,
serverStart = 0,
serverInitReply,
serverCommandReply,
serverUserReply,
serverGssApiReply,
serverBindReply,
serverDone,
serverError
};
typedef struct {
int in_socks_dissector_flag;
enum ClientState client;
enum ServerState server;
} sock_state_t;
typedef struct {
enum ClientState clientState;
enum ServerState serverState;
int version;
int command;
int authentication_method;
guint32 server_port;
guint32 port;
guint32 udp_port;
guint32 udp_remote_port;
address dst_addr;
guint32 start_done_frame;
}socks_hash_entry_t;
static const value_string address_type_table[] = {
{1, "IPv4"},
{3, "Domain Name"},
{4, "IPv6"},
{0, NULL}
};
/* String table for the V4 reply status messages */
static const value_string reply_table_v4[] = {
{90, "Granted"},
{91, "Rejected or Failed"},
{92, "Rejected because SOCKS server cannot connect to identd on the client"},
{93, "Rejected because the client program and identd report different user-ids"},
{0, NULL}
};
/* String table for the V5 reply status messages */
static const value_string reply_table_v5[] = {
{0, "Succeeded"},
{1, "General SOCKS server failure"},
{2, "Connection not allowed by ruleset"},
{3, "Network unreachable"},
{4, "Host unreachable"},
{5, "Connection refused"},
{6, "TTL expired"},
{7, "Command not supported"},
{8, "Address type not supported"},
{0, NULL},
};
static const value_string cmd_strings[] = {
{CONNECT_COMMAND, "Connect"},
{BIND_COMMAND, "Bind"},
{UDP_ASSOCIATE_COMMAND, "UdpAssociate"},
{PING_COMMAND, "Ping"},
{TRACERT_COMMAND, "Traceroute"},
{0, NULL}
};
static const value_string gssapi_command_table[] = {
{ 1, "Authentication" },
{ 0xFF, "Failure" },
{ 0, NULL }
};
/************************* Support routines ***************************/
static const char *get_auth_method_name( guint Number){
/* return the name of the authentication method */
if ( Number == 0) return "No authentication";
if ( Number == 1) return "GSSAPI";
if ( Number == 2) return "Username/Password";
if ( Number == 3) return "Chap";
if (( Number >= 4) && ( Number <= 0x7f))return "IANA assigned";
if (( Number >= 0x80) && ( Number <= 0xfe)) return "private method";
if ( Number == 0xff) return "no acceptable method";
/* shouldn't reach here */
return "Bad method number (not 0-0xff)";
}
static int display_address(packet_info *pinfo, tvbuff_t *tvb, int offset, proto_tree *tree) {
/* decode and display the v5 address, return offset of next byte */
int a_type = tvb_get_guint8(tvb, offset);
proto_tree_add_item( tree, hf_socks_address_type, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
switch (a_type)
{
case 1: /* IPv4 address */
proto_tree_add_item( tree, hf_socks_ip_dst, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
break;
case 3: /* domain name address */
{
guint8 len;
gchar* str;
len = tvb_get_guint8(tvb, offset);
str = tvb_get_string_enc(pinfo->pool, tvb, offset+1, len, ENC_ASCII);
proto_tree_add_string(tree, hf_socks_remote_name, tvb, offset, len+1, str);
offset += (len+1);
}
break;
case 4: /* IPv6 address */
proto_tree_add_item( tree, hf_socks_ip6_dst, tvb, offset, 16, ENC_NA);
offset += 16;
break;
}
return offset;
}
static int get_address_v5(tvbuff_t *tvb, int offset,
socks_hash_entry_t *hash_info) {
/* decode the v5 address and return offset of next byte */
int a_type;
address addr;
a_type = tvb_get_guint8(tvb, offset);
offset += 1;
switch(a_type)
{
case 1: /* IPv4 address */
if ( hash_info) {
set_address_tvb(&addr, AT_IPv4, 4, tvb, offset);
copy_address_wmem(wmem_file_scope(), &hash_info->dst_addr, &addr);
}
offset += 4;
break;
case 4: /* IPv6 address */
if ( hash_info) {
set_address_tvb(&addr, AT_IPv6, 16, tvb, offset);
copy_address_wmem(wmem_file_scope(), &hash_info->dst_addr, &addr);
}
offset += 16;
break;
case 3: /* domain name address */
offset += tvb_get_guint8(tvb, offset) + 1;
break;
}
return offset;
}
/********************* V5 UDP Associate handlers ***********************/
static int
socks_udp_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) {
/* Conversation dissector called from UDP dissector. Decode and display */
/* the socks header, the pass the rest of the data to the udp port */
/* decode routine to handle the payload. */
int offset = 0;
guint32 *ptr;
socks_hash_entry_t *hash_info;
conversation_t *conversation;
proto_tree *socks_tree;
proto_item *ti;
conversation = find_conversation_pinfo( pinfo, 0);
DISSECTOR_ASSERT( conversation); /* should always find a conversation */
hash_info = (socks_hash_entry_t *)conversation_get_proto_data(conversation, proto_socks);
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Socks");
col_set_str(pinfo->cinfo, COL_INFO, "Version: 5, UDP Associated packet");
if ( tree) {
ti = proto_tree_add_protocol_format( tree, proto_socks, tvb, offset, -1, "Socks" );
socks_tree = proto_item_add_subtree(ti, ett_socks);
proto_tree_add_item(socks_tree, hf_socks_reserved2, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(socks_tree, hf_socks_fragment_number, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
offset = display_address(pinfo, tvb, offset, socks_tree);
hash_info->udp_remote_port = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint( socks_tree, hf_socks_dstport, tvb,
offset, 2, hash_info->udp_remote_port);
offset += 2;
}
else { /* no tree, skip past the socks header */
offset += 3;
offset = get_address_v5( tvb, offset, 0) + 2;
}
/* set pi src/dst port and call the udp sub-dissector lookup */
if ( pinfo->srcport == hash_info->port)
ptr = &pinfo->destport;
else
ptr = &pinfo->srcport;
*ptr = hash_info->udp_remote_port;
decode_udp_ports( tvb, offset, pinfo, tree, pinfo->srcport, pinfo->destport, -1);
*ptr = hash_info->udp_port;
return tvb_captured_length(tvb);
}
static void
new_udp_conversation( socks_hash_entry_t *hash_info, packet_info *pinfo){
conversation_t *conversation = conversation_new( pinfo->num, &pinfo->src, &pinfo->dst, CONVERSATION_UDP,
hash_info->udp_port, hash_info->port, 0);
DISSECTOR_ASSERT( conversation);
conversation_add_proto_data(conversation, proto_socks, hash_info);
conversation_set_dissector(conversation, socks_udp_handle);
}
static void
save_client_state(packet_info *pinfo, enum ClientState state)
{
sock_state_t* state_info = (sock_state_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_socks, 0);
if ((state_info != NULL) && (state_info->client == clientNoInit)) {
state_info->client = state;
}
}
static void
save_server_state(packet_info *pinfo, enum ServerState state)
{
sock_state_t* state_info = (sock_state_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_socks, 0);
if ((state_info != NULL) && (state_info->server == serverNoInit)) {
state_info->server = state;
}
}
/**************** Protocol Tree Display routines ******************/
static void
display_socks_v4(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *tree, socks_hash_entry_t *hash_info, sock_state_t* state_info) {
/* Display the protocol tree for the V4 version. This routine uses the */
/* stored frame information to decide what to do with the row. */
unsigned char ipaddr[4];
guint str_len;
/* Either there is an error, or we're done with the state machine
(so there's nothing to display) */
if (state_info == NULL)
return;
if (hash_info->server_port == pinfo->destport) {
/* Client side */
switch (state_info->client)
{
case clientStart:
proto_tree_add_item( tree, hf_socks_ver, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item( tree, hf_socks_cmd, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
/* Do remote port */
proto_tree_add_item( tree, hf_socks_dstport, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* Do destination address */
tvb_memcpy(tvb, ipaddr, offset, 4);
proto_tree_add_item( tree, hf_socks_ip_dst, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
/* display user name */
str_len = tvb_strsize(tvb, offset);
proto_tree_add_item( tree, hf_socks_username, tvb, offset, str_len, ENC_ASCII);
offset += str_len;
if ( ipaddr[0] == 0 && ipaddr[1] == 0 &&
ipaddr[2] == 0 && ipaddr[3] != 0) {
/* 0.0.0.x , where x!=0 means v4a support */
str_len = tvb_strsize(tvb, offset);
proto_tree_add_item( tree, hf_v4a_dns_name, tvb, offset, str_len, ENC_ASCII);
}
break;
default:
break;
}
} else {
/* Server side */
switch (state_info->server)
{
case serverStart:
proto_tree_add_item( tree, hf_socks_ver, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
/* Do results code */
proto_tree_add_item( tree, hf_socks_results_4, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
/* Do remote port */
proto_tree_add_item( tree, hf_socks_dstport, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* Do remote address */
proto_tree_add_item( tree, hf_socks_ip_dst, tvb, offset, 4, ENC_BIG_ENDIAN);
break;
default:
break;
}
}
}
static void
client_display_socks_v5(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *tree, socks_hash_entry_t *hash_info, sock_state_t* state_info) {
/* Display the protocol tree for the version. This routine uses the */
/* stored conversation information to decide what to do with the row. */
/* Per packet information would have been better to do this, but we */
/* didn't have that when I wrote this. And I didn't expect this to get */
/* so messy. */
unsigned int i;
const char *AuthMethodStr;
sock_state_t new_state_info;
proto_item *ti;
/* Either there is an error, or we're done with the state machine
(so there's nothing to display) */
if (state_info == NULL)
return;
if (state_info->client == clientStart)
{
proto_tree *AuthTree;
guint8 num_auth_methods, auth;
col_append_str(pinfo->cinfo, COL_INFO, " Connect to server request");
proto_tree_add_item( tree, hf_socks_ver, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
AuthTree = proto_tree_add_subtree( tree, tvb, offset, -1, ett_socks_auth, &ti, "Client Authentication Methods");
num_auth_methods = tvb_get_guint8(tvb, offset);
proto_item_set_len(ti, num_auth_methods+1);
proto_tree_add_item( AuthTree, hf_client_auth_method_count, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
for( i = 0; i < num_auth_methods; ++i) {
auth = tvb_get_guint8( tvb, offset);
AuthMethodStr = get_auth_method_name(auth);
proto_tree_add_uint_format(AuthTree, hf_client_auth_method, tvb, offset, 1, auth,
"Method[%u]: %u (%s)", i, auth, AuthMethodStr);
offset += 1;
}
if ((num_auth_methods == 1) &&
(tvb_bytes_exist(tvb, offset + 2, 1)) &&
(tvb_get_guint8(tvb, offset + 2) == 0) &&
(tvb_reported_length_remaining(tvb, offset + 2 + num_auth_methods) > 0)) {
new_state_info.client = clientV5Command;
client_display_socks_v5(tvb, offset, pinfo, tree, hash_info, &new_state_info);
}
}
else if (state_info->client == clientV5Command) {
col_append_fstr(pinfo->cinfo, COL_INFO, " Command Request - %s",
val_to_str_const(hash_info->command, cmd_strings, "Unknown"));
proto_tree_add_item( tree, hf_socks_ver, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item( tree, hf_socks_cmd, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item( tree, hf_socks_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
offset = display_address(pinfo, tvb, offset, tree);
proto_tree_add_item( tree, hf_client_port, tvb, offset, 2, ENC_BIG_ENDIAN);
}
else if ((state_info->client == clientWaitForAuthReply) &&
(state_info->server == serverInitReply)) {
guint16 len;
gchar* str;
ti = proto_tree_add_uint( tree, hf_socks_ver, tvb, offset, 0, 5);
proto_item_set_generated(ti);
proto_tree_add_item( tree, hf_socks_subnegotiation_version, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
switch(hash_info->authentication_method)
{
case NO_AUTHENTICATION:
break;
case USER_NAME_AUTHENTICATION:
col_append_str(pinfo->cinfo, COL_INFO, " User authentication request");
/* process user name */
len = tvb_get_guint8(tvb, offset);
str = tvb_get_string_enc(pinfo->pool, tvb, offset+1, len, ENC_ASCII);
proto_tree_add_string(tree, hf_socks_username, tvb, offset, len+1, str);
offset += (len+1);
len = tvb_get_guint8(tvb, offset);
str = tvb_get_string_enc(pinfo->pool, tvb, offset+1, len, ENC_ASCII);
proto_tree_add_string(tree, hf_socks_password, tvb, offset, len+1, str);
/* offset += (len+1); */
break;
case GSS_API_AUTHENTICATION:
col_append_str(pinfo->cinfo, COL_INFO, " GSSAPI authentication request");
proto_tree_add_item( tree, hf_gssapi_command, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item( tree, hf_gssapi_length, tvb, offset+1, 2, ENC_BIG_ENDIAN);
len = tvb_get_ntohs(tvb, offset+1);
if (len > 0)
proto_tree_add_item( tree, hf_gssapi_payload, tvb, offset+3, len, ENC_NA);
break;
default:
break;
}
}
else {
if (hash_info->port != 0)
col_append_fstr(pinfo->cinfo, COL_INFO, ", Remote Port: %u",
hash_info->port);
}
}
static void
server_display_socks_v5(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *tree, socks_hash_entry_t *hash_info _U_, sock_state_t* state_info) {
/* Display the protocol tree for the version. This routine uses the */
/* stored conversation information to decide what to do with the row. */
/* Per packet information would have been better to do this, but we */
/* didn't have that when I wrote this. And I didn't expect this to get */
/* so messy. */
const char *AuthMethodStr;
guint8 auth, auth_status;
proto_item *ti;
/* Either there is an error, or we're done with the state machine
(so there's nothing to display) */
if (state_info == NULL)
return;
switch(state_info->server)
{
case serverStart:
col_append_str(pinfo->cinfo, COL_INFO, " Connect to server response");
proto_tree_add_item( tree, hf_socks_ver, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
auth = tvb_get_guint8( tvb, offset);
AuthMethodStr = get_auth_method_name(auth);
proto_tree_add_uint_format_value(tree, hf_server_accepted_auth_method, tvb, offset, 1, auth,
"0x%0x (%s)", auth, AuthMethodStr);
break;
case serverUserReply:
col_append_str(pinfo->cinfo, COL_INFO, " User authentication reply");
ti = proto_tree_add_uint( tree, hf_socks_ver, tvb, offset, 0, 5);
proto_item_set_generated(ti);
proto_tree_add_item( tree, hf_socks_subnegotiation_version, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
auth_status = tvb_get_guint8(tvb, offset);
ti = proto_tree_add_item(tree, hf_server_auth_status, tvb, offset, 1, ENC_BIG_ENDIAN);
if(auth_status != 0)
proto_item_append_text(ti, " (failure)");
else
proto_item_append_text(ti, " (success)");
break;
case serverGssApiReply:
col_append_str(pinfo->cinfo, COL_INFO, " GSSAPI authentication reply");
ti = proto_tree_add_uint( tree, hf_socks_ver, tvb, offset, 0, 5);
proto_item_set_generated(ti);
proto_tree_add_item( tree, hf_socks_subnegotiation_version, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
auth_status = tvb_get_guint8(tvb, offset);
proto_tree_add_item( tree, hf_gssapi_command, tvb, offset, 1, ENC_BIG_ENDIAN);
if (auth_status != 0xFF) {
guint16 len;
proto_tree_add_item( tree, hf_gssapi_length, tvb, offset+1, 2, ENC_BIG_ENDIAN);
len = tvb_get_ntohs(tvb, offset+1);
if (len > 0)
proto_tree_add_item( tree, hf_gssapi_payload, tvb, offset+3, len, ENC_NA);
}
break;
case serverCommandReply:
col_append_fstr(pinfo->cinfo, COL_INFO, " Command Response - %s",
val_to_str_const(hash_info->command, cmd_strings, "Unknown"));
proto_tree_add_item( tree, hf_socks_ver, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item( tree, hf_socks_results_5, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item( tree, hf_socks_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
offset = display_address(pinfo, tvb, offset, tree);
proto_tree_add_item( tree, hf_client_port, tvb, offset, 2, ENC_BIG_ENDIAN);
break;
case serverBindReply:
col_append_str(pinfo->cinfo, COL_INFO, " Command Response: Bind remote host info");
proto_tree_add_item( tree, hf_socks_ver, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item( tree, hf_socks_results_5, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item( tree, hf_socks_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
offset = display_address(pinfo, tvb, offset, tree);
proto_tree_add_item( tree, hf_server_remote_host_port, tvb, offset, 2, ENC_BIG_ENDIAN);
break;
default:
if ( hash_info->port != 0)
col_append_fstr(pinfo->cinfo, COL_INFO, ", Remote Port: %u",
hash_info->port);
break;
}
}
/**************** Decoder State Machines ******************/
static void
state_machine_v4( socks_hash_entry_t *hash_info, tvbuff_t *tvb,
int offset, packet_info *pinfo) {
/* Decode V4 protocol. This is done on the first pass through the */
/* list. Based upon the current state, decode the packet and determine */
/* what the next state should be. */
address addr;
if (hash_info->clientState != clientDone)
save_client_state(pinfo, hash_info->clientState);
if (hash_info->serverState != serverDone)
save_server_state(pinfo, hash_info->serverState);
if (hash_info->server_port == pinfo->destport) {
/* Client side, only a single request */
col_append_str(pinfo->cinfo, COL_INFO, " Connect to server request");
hash_info->command = tvb_get_guint8(tvb, offset + 1);
/* get remote port */
if ( hash_info->command == CONNECT_COMMAND)
hash_info->port = tvb_get_ntohs(tvb, offset + 2);
/* get remote address */
set_address_tvb(&addr, AT_IPv4, 4, tvb, offset);
copy_address_wmem(wmem_file_scope(), &hash_info->dst_addr, &addr);
hash_info->clientState = clientDone;
}
else {
col_append_str(pinfo->cinfo, COL_INFO, " Connect Response");
if (tvb_get_guint8(tvb, offset + 1) == 90)
hash_info->serverState = serverDone;
else
hash_info->serverState = serverError;
}
}
static void
client_state_machine_v5( socks_hash_entry_t *hash_info, tvbuff_t *tvb,
int offset, packet_info *pinfo, gboolean start_of_frame) {
/* Decode client side of V5 protocol. This is done on the first pass through the */
/* list. Based upon the current state, decode the packet and determine */
/* what the next state should be. */
if (start_of_frame) {
save_client_state(pinfo, hash_info->clientState);
save_server_state(pinfo, hash_info->serverState);
}
if (hash_info->clientState == clientStart)
{
guint8 num_auth_methods;
num_auth_methods = tvb_get_guint8(tvb, offset + 1);
/* skip past auth methods */
if ((num_auth_methods == 0) ||
((num_auth_methods == 1) &&
(tvb_get_guint8(tvb, offset + 2) == 0))) {
/* No authentication needed */
hash_info->clientState = clientV5Command;
if (tvb_reported_length_remaining(tvb, offset + 2 + num_auth_methods) > 0) {
client_state_machine_v5(hash_info, tvb, offset + 2 + num_auth_methods, pinfo, FALSE);
}
} else {
hash_info->clientState = clientWaitForAuthReply;
}
} else if ((hash_info->clientState == clientWaitForAuthReply) &&
(hash_info->serverState == serverInitReply)) {
switch(hash_info->authentication_method)
{
case NO_AUTHENTICATION:
hash_info->clientState = clientV5Command;
hash_info->serverState = serverCommandReply;
break;
case USER_NAME_AUTHENTICATION:
hash_info->clientState = clientV5Command;
hash_info->serverState = serverUserReply;
break;
case GSS_API_AUTHENTICATION:
hash_info->clientState = clientV5Command;
hash_info->serverState = serverGssApiReply;
break;
default:
hash_info->clientState = clientError; /*Auth failed or error*/
break;
}
} else if (hash_info->clientState == clientV5Command) {
hash_info->command = tvb_get_guint8(tvb, offset + 1); /* get command */
offset += 3; /* skip to address type */
offset = get_address_v5(tvb, offset, hash_info);
/** temp = tvb_get_guint8(tvb, offset); XX: what was this for ? **/
if (( hash_info->command == CONNECT_COMMAND) ||
( hash_info->command == UDP_ASSOCIATE_COMMAND))
/* get remote port */
hash_info->port = tvb_get_ntohs(tvb, offset);
hash_info->clientState = clientDone;
}
}
static void
server_state_machine_v5( socks_hash_entry_t *hash_info, tvbuff_t *tvb,
int offset, packet_info *pinfo, gboolean start_of_frame) {
/* Decode server side of V5 protocol. This is done on the first pass through the */
/* list. Based upon the current state, decode the packet and determine */
/* what the next state should be. */
if (start_of_frame)
save_server_state(pinfo, hash_info->serverState);
switch (hash_info->serverState) {
case serverStart:
hash_info->authentication_method = tvb_get_guint8(tvb, offset + 1);
switch (hash_info->authentication_method)
{
case NO_AUTHENTICATION:
/* If there is no authentication, client should expect command immediately */
hash_info->serverState = serverCommandReply;
hash_info->clientState = clientV5Command;
break;
case USER_NAME_AUTHENTICATION:
hash_info->serverState = serverInitReply;
break;
case GSS_API_AUTHENTICATION:
hash_info->serverState = serverInitReply;
break;
default:
hash_info->serverState = serverError;
break;
}
break;
case serverUserReply:
hash_info->serverState = serverCommandReply;
break;
case serverGssApiReply:
if (tvb_get_guint8(tvb, offset+1) == 0xFF) {
hash_info->serverState = serverError;
} else {
if (tvb_get_ntohs(tvb, offset+2) == 0)
hash_info->serverState = serverCommandReply;
}
break;
case serverCommandReply:
switch(hash_info->command)
{
case CONNECT_COMMAND:
case PING_COMMAND:
case TRACERT_COMMAND:
hash_info->serverState = serverDone;
break;
case BIND_COMMAND:
hash_info->serverState = serverBindReply;
if ((tvb_get_guint8(tvb, offset + 2) == 0) &&
(tvb_reported_length_remaining(tvb, offset) > 5)) {
offset = display_address(pinfo, tvb, offset, NULL);
client_state_machine_v5(hash_info, tvb, offset, pinfo, FALSE);
}
break;
case UDP_ASSOCIATE_COMMAND:
offset += 3; /* skip to address type */
offset = get_address_v5(tvb, offset, hash_info);
/* save server udp port and create udp conversation */
hash_info->udp_port = tvb_get_ntohs(tvb, offset);
if (!pinfo->fd->visited)
new_udp_conversation( hash_info, pinfo);
break;
}
break;
case serverBindReply:
break;
default:
break;
}
}
static void
display_ping_and_tracert(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, socks_hash_entry_t *hash_info) {
/* Display the ping/trace_route conversation */
const guchar *data, *dataend;
const guchar *lineend, *eol;
int linelen;
/* handle the end command */
if ( pinfo->destport == TCP_PORT_SOCKS){
col_append_str(pinfo->cinfo, COL_INFO, ", Terminate Request");
proto_tree_add_item(tree, (hash_info->command == PING_COMMAND) ? hf_socks_ping_end_command : hf_socks_traceroute_end_command, tvb, offset, 1, ENC_NA);
}
else { /* display the PING or Traceroute results */
col_append_str(pinfo->cinfo, COL_INFO, ", Results");
if ( tree){
proto_tree_add_item(tree, (hash_info->command == PING_COMMAND) ? hf_socks_ping_results : hf_socks_traceroute_results, tvb, offset, -1, ENC_NA);
data = tvb_get_ptr(tvb, offset, -1);
dataend = data + tvb_captured_length_remaining(tvb, offset);
while (data < dataend) {
lineend = find_line_end(data, dataend, &eol);
linelen = (int)(lineend - data);
proto_tree_add_format_text( tree, tvb, offset, linelen);
offset += linelen;
data = lineend;
}
}
}
}
static void clear_in_socks_dissector_flag(void *s)
{
sock_state_t* state_info = (sock_state_t*)s;
state_info->in_socks_dissector_flag = 0; /* avoid recursive overflow */
}
static void call_next_dissector(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *tree, proto_tree *socks_tree,
socks_hash_entry_t *hash_info, sock_state_t* state_info, struct tcpinfo *tcpinfo)
{
/* Display the results for PING and TRACERT extensions or */
/* Call TCP dissector for the port that was passed during the */
/* connect process */
/* Load pointer to pinfo->XXXport depending upon the direction, */
/* change pinfo port to the remote port, call next dissector to decode */
/* the payload, and restore the pinfo port after that is done. */
guint32 *ptr;
guint16 save_can_desegment;
struct tcp_analysis *tcpd=NULL;
if (( hash_info->command == PING_COMMAND) ||
( hash_info->command == TRACERT_COMMAND))
display_ping_and_tracert(tvb, offset, pinfo, tree, hash_info);
else { /* call the tcp port decoder to handle the payload */
/*XXX may want to load dest address here */
if (pinfo->destport == TCP_PORT_SOCKS) {
ptr = &pinfo->destport;
} else {
ptr = &pinfo->srcport;
}
*ptr = hash_info->port;
tcpd = get_tcp_conversation_data(NULL, pinfo);
/* 2003-09-18 JCFoster Fixed problem with socks tunnel in socks tunnel */
state_info->in_socks_dissector_flag = 1; /* avoid recursive overflow */
CLEANUP_PUSH(clear_in_socks_dissector_flag, state_info);
save_can_desegment = pinfo->can_desegment;
pinfo->can_desegment = pinfo->saved_can_desegment;
dissect_tcp_payload(tvb, pinfo, offset, tcpinfo->seq,
tcpinfo->nxtseq, pinfo->srcport, pinfo->destport,
tree, socks_tree, tcpd, tcpinfo);
pinfo->can_desegment = save_can_desegment;
CLEANUP_CALL_AND_POP;
*ptr = TCP_PORT_SOCKS;
}
}
static int
dissect_socks(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
int offset = 0;
proto_tree *socks_tree = NULL;
proto_item *ti;
socks_hash_entry_t *hash_info;
conversation_t *conversation;
sock_state_t* state_info;
guint8 version;
struct tcpinfo *tcpinfo = (struct tcpinfo*)data;
state_info = (sock_state_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_socks, 0);
if (state_info == NULL) {
state_info = wmem_new(wmem_file_scope(), sock_state_t);
state_info->in_socks_dissector_flag = 0;
state_info->client = clientNoInit;
state_info->server = serverNoInit;
p_add_proto_data(wmem_file_scope(), pinfo, proto_socks, 0, state_info);
}
/* avoid recursive overflow */
if (state_info->in_socks_dissector_flag)
return 0;
conversation = find_conversation_pinfo(pinfo, 0);
if (conversation == NULL) {
/* If we don't already have a conversation, make sure the first
byte is a valid version number */
version = tvb_get_guint8(tvb, offset);
if ((version != 4) && (version != 5))
return 0;
conversation = conversation_new(pinfo->num, &pinfo->src, &pinfo->dst,
conversation_pt_to_conversation_type(pinfo->ptype), pinfo->srcport, pinfo->destport, 0);
}
hash_info = (socks_hash_entry_t *)conversation_get_proto_data(conversation,proto_socks);
if (hash_info == NULL){
hash_info = wmem_new0(wmem_file_scope(), socks_hash_entry_t);
hash_info->start_done_frame = G_MAXINT;
hash_info->clientState = clientStart;
hash_info->serverState = serverStart;
hash_info->server_port = pinfo->destport;
hash_info->port = 0;
hash_info->version = tvb_get_guint8(tvb, offset); /* get version*/
conversation_add_proto_data(conversation, proto_socks, hash_info);
/* set dissector for now */
if (conversation_get_dissector(conversation, pinfo->num) != NULL) {
conversation_set_dissector(conversation, socks_handle);
}
}
/* display summary window information */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Socks");
if (( hash_info->version == 4) || ( hash_info->version == 5)){
col_add_fstr(pinfo->cinfo, COL_INFO, "Version: %d",
hash_info->version);
}
else /* unknown version display error */
col_set_str(pinfo->cinfo, COL_INFO, "Unknown");
if ( hash_info->command == PING_COMMAND)
col_append_str(pinfo->cinfo, COL_INFO, ", Ping Req");
if ( hash_info->command == TRACERT_COMMAND)
col_append_str(pinfo->cinfo, COL_INFO, ", Traceroute Req");
/* run state machine if needed */
if ((!pinfo->fd->visited) &&
(!((hash_info->clientState == clientDone) &&
(hash_info->serverState == serverDone)))) {
if (hash_info->server_port == pinfo->destport) {
if ((hash_info->clientState != clientError) &&
(hash_info->clientState != clientDone))
{
if ( hash_info->version == 4) {
state_machine_v4( hash_info, tvb, offset, pinfo);
} else if ( hash_info->version == 5) {
client_state_machine_v5( hash_info, tvb, offset, pinfo, TRUE);
}
}
} else {
if ((hash_info->serverState != serverError) &&
(hash_info->serverState != serverDone)) {
if ( hash_info->version == 4) {
state_machine_v4( hash_info, tvb, offset, pinfo);
} else if ( hash_info->version == 5) {
server_state_machine_v5( hash_info, tvb, offset, pinfo, TRUE);
}
}
}
if ((hash_info->clientState == clientDone) &&
(hash_info->serverState == serverDone)) { /* if done now */
hash_info->start_done_frame = pinfo->num;
}
}
/* if proto tree, decode and display */
if (tree) {
ti = proto_tree_add_item( tree, proto_socks, tvb, offset, -1, ENC_NA );
socks_tree = proto_item_add_subtree(ti, ett_socks);
/* if past startup, add the faked stuff */
if ( pinfo->num > hash_info->start_done_frame){
/* add info to tree */
ti = proto_tree_add_uint( socks_tree, hf_socks_ver, tvb, offset, 0, hash_info->version);
proto_item_set_generated(ti);
ti = proto_tree_add_uint( socks_tree, hf_socks_cmd, tvb, offset, 0, hash_info->command);
proto_item_set_generated(ti);
if (hash_info->dst_addr.type == AT_IPv4) {
ti = proto_tree_add_ipv4( socks_tree, hf_socks_ip_dst, tvb,
offset, 0, *((const guint32*)hash_info->dst_addr.data));
proto_item_set_generated(ti);
} else if (hash_info->dst_addr.type == AT_IPv6) {
ti = proto_tree_add_ipv6( socks_tree, hf_socks_ip6_dst, tvb,
offset, 0, (const ws_in6_addr *)hash_info->dst_addr.data);
proto_item_set_generated(ti);
}
/* no fake address for ping & traceroute */
if (( hash_info->command != PING_COMMAND) &&
( hash_info->command != TRACERT_COMMAND)){
ti = proto_tree_add_uint( socks_tree, hf_socks_dstport, tvb, offset, 0, hash_info->port);
proto_item_set_generated(ti);
}
} else {
if (hash_info->server_port == pinfo->destport) {
if ( hash_info->version == 4) {
display_socks_v4(tvb, offset, pinfo, socks_tree, hash_info, state_info);
} else if ( hash_info->version == 5) {
client_display_socks_v5(tvb, offset, pinfo, socks_tree, hash_info, state_info);
}
} else {
if ( hash_info->version == 4) {
display_socks_v4(tvb, offset, pinfo, socks_tree, hash_info, state_info);
} else if ( hash_info->version == 5) {
server_display_socks_v5(tvb, offset, pinfo, socks_tree, hash_info, state_info);
}
}
}
}
/* call next dissector if ready */
if ( pinfo->num > hash_info->start_done_frame){
call_next_dissector(tvb, offset, pinfo, tree, socks_tree,
hash_info, state_info, tcpinfo);
}
return tvb_reported_length(tvb);
}
static int
dissect_socks_tls(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
if (data != NULL) {
return dissect_socks(tvb, pinfo, tree, data);
} else {
/* lets fake a tcpinfo, which TLS does not give us */
struct tcpinfo tmp;
tmp.flags = 0;
tmp.is_reassembled = FALSE;
tmp.lastackseq = 0;
tmp.nxtseq = 0;
tmp.seq = 0;
tmp.urgent_pointer = 0;
return dissect_socks(tvb, pinfo, tree, &tmp);
}
}
void
proto_register_socks( void){
static gint *ett[] = {
&ett_socks,
&ett_socks_auth,
&ett_socks_name
};
static hf_register_info hf[] = {
{ &hf_socks_ver,
{ "Version", "socks.version", FT_UINT8, BASE_DEC, NULL,
0x0, NULL, HFILL
}
},
{ &hf_socks_ip_dst,
{ "Remote Address", "socks.dst", FT_IPv4, BASE_NONE, NULL,
0x0, NULL, HFILL
}
},
{ &hf_socks_ip6_dst,
{ "Remote Address(ipv6)", "socks.dstV6", FT_IPv6, BASE_NONE, NULL,
0x0, NULL, HFILL
}
},
{ &hf_gssapi_payload,
{ "GSSAPI data", "socks.gssapi.data", FT_BYTES, BASE_NONE, NULL,
0x0, NULL, HFILL
}
},
{ &hf_gssapi_command,
{ "SOCKS/GSSAPI command", "socks.gssapi.command", FT_UINT8, BASE_DEC,
VALS(gssapi_command_table), 0x0, NULL, HFILL
}
},
{ &hf_gssapi_length,
{ "SOCKS/GSSAPI data length", "socks.gssapi.length", FT_UINT16, BASE_DEC, NULL,
0x0, NULL, HFILL
}
},
{ &hf_v4a_dns_name,
{ "SOCKS v4a Remote Domain Name", "socks.v4a_dns_name", FT_STRINGZ, BASE_NONE,
NULL, 0x0, NULL, HFILL
}
},
{ &hf_socks_dstport,
{ "Remote Port", "socks.dstport", FT_UINT16,
BASE_DEC, NULL, 0x0, NULL, HFILL
}
},
{ &hf_socks_cmd,
{ "Command", "socks.command", FT_UINT8,
BASE_DEC, VALS(cmd_strings), 0x0, NULL, HFILL
}
},
{ &hf_socks_results_4,
{ "Results(V4)", "socks.results", FT_UINT8,
BASE_DEC, VALS(reply_table_v4), 0x0, NULL, HFILL
}
},
{ &hf_socks_results_5,
{ "Results(V5)", "socks.results", FT_UINT8,
BASE_DEC, VALS(reply_table_v5), 0x0, NULL, HFILL
}
},
{ &hf_client_auth_method_count,
{ "Authentication Method Count", "socks.auth_method_count", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL
}
},
{ &hf_client_auth_method,
{ "Method", "socks.auth_method", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL
}
},
{ &hf_socks_reserved,
{ "Reserved", "socks.reserved", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL
}
},
{ &hf_socks_reserved2,
{ "Reserved", "socks.reserved", FT_UINT16,
BASE_DEC, NULL, 0x0, NULL, HFILL
}
},
{ &hf_client_port,
{ "Port", "socks.port", FT_UINT16,
BASE_DEC, NULL, 0x0, NULL, HFILL
}
},
{ &hf_server_accepted_auth_method,
{ "Accepted Auth Method", "socks.auth_accepted_method", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL
}
},
{ &hf_server_auth_status,
{ "Status", "socks.auth_status", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL
}
},
{ &hf_server_remote_host_port,
{ "Remote Host Port", "socks.remote_host_port", FT_UINT16,
BASE_DEC, NULL, 0x0, NULL, HFILL
}
},
{ &hf_socks_subnegotiation_version,
{ "Subnegotiation Version", "socks.subnegotiation_version", FT_UINT8, BASE_DEC, NULL,
0x0, NULL, HFILL
}
},
{ &hf_socks_username,
{ "User name", "socks.username", FT_STRING, BASE_NONE,
NULL, 0x0, NULL, HFILL
}
},
{ &hf_socks_password,
{ "Password", "socks.password", FT_STRING, BASE_NONE,
NULL, 0x0, NULL, HFILL
}
},
{ &hf_socks_remote_name,
{ "Remote name", "socks.remote_name", FT_STRING, BASE_NONE,
NULL, 0x0, NULL, HFILL
}
},
{ &hf_socks_address_type,
{ "Address Type", "socks.address_type", FT_UINT8,
BASE_DEC, VALS(address_type_table), 0x0, NULL, HFILL
}
},
{ &hf_socks_fragment_number,
{ "Fragment Number", "socks.fragment_number", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL
}
},
{ &hf_socks_ping_end_command,
{ "Ping: End command", "socks.ping_end_command", FT_NONE,
BASE_NONE, NULL, 0x0, NULL, HFILL
}
},
{ &hf_socks_ping_results,
{ "Ping Results", "socks.ping_results", FT_NONE,
BASE_NONE, NULL, 0x0, NULL, HFILL
}
},
{ &hf_socks_traceroute_end_command,
{ "Traceroute: End command", "socks.traceroute_end_command", FT_NONE,
BASE_NONE, NULL, 0x0, NULL, HFILL
}
},
{ &hf_socks_traceroute_results,
{ "Traceroute Results", "socks.traceroute_results", FT_NONE,
BASE_NONE, NULL, 0x0, NULL, HFILL
}
},
};
proto_socks = proto_register_protocol ( "Socks Protocol", "Socks", "socks");
proto_register_field_array(proto_socks, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
socks_udp_handle = register_dissector_with_description("socks_udp", "SOCKS over UDP", socks_udp_dissector, proto_socks);
socks_handle = register_dissector_with_description("socks_tcp", "SOCKS over TCP", dissect_socks, proto_socks);
socks_handle_tls = register_dissector_with_description("socks_tls", "SOCKS over TLS", dissect_socks_tls, proto_socks);
}
void
proto_reg_handoff_socks(void) {
/* dissector install routine */
dissector_add_uint_with_preference("tcp.port", TCP_PORT_SOCKS, socks_handle);
ssl_dissector_add(0, socks_handle_tls);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-solaredge.c
|
/* packet-solaredge.c
* Dissector routines for the SolarEdge monitoring protocol
* By Erik de Jong <[email protected]>
* Copyright 2017 Erik de Jong
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/conversation.h>
#include <epan/expert.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/strutil.h>
#include <range.h>
#include <wsutil/crc16-plain.h>
#include <wsutil/pint.h>
#include <wsutil/wsgcrypt.h>
#define SOLAREDGE_MAGIC_NUMBER 0x79563412
#define SOLAREDGE_ENCRYPTION_KEY_LENGTH 16
#define SOLAREDGE_HEADER_LENGTH 20
#define SOLAREDGE_POST_HEADER_LENGTH 8
#define SOLAREDGE_COMMAND_PARAMS_RESET 0x0010
#define SOLAREDGE_COMMAND_PARAMS_SET_SINGLE 0x0011
#define SOLAREDGE_COMMAND_PARAMS_GET_SINGLE 0x0012
#define SOLAREDGE_COMMAND_PARAMS_GET_INFO 0x0013
#define SOLAREDGE_COMMAND_PARAMS_GET_NAME 0x0014
#define SOLAREDGE_COMMAND_PARAMS_GET_NUM 0x0015
#define SOLAREDGE_COMMAND_PARAMS_GET_ALL 0x0016
#define SOLAREDGE_COMMAND_PARAMS_SET_ALL 0x0017
#define SOLAREDGE_COMMAND_PARAMS_SET_SINGLE_NOSAVE 0x0018
#define SOLAREDGE_COMMAND_PARAMS_SAVE 0x0019
#define SOLAREDGE_COMMAND_PARAMS_POLICY_ENABLE 0x001a
#define SOLAREDGE_COMMAND_PARAMS_POLICY_DISABLE 0x001b
#define SOLAREDGE_COMMAND_PARAMS_POLICY_DISABLE_VOLATILE 0x001c
#define SOLAREDGE_COMMAND_PARAMS_SET_POLICY_PASSWORD 0x001d
#define SOLAREDGE_COMMAND_PARAMS_GET_VOLATILE 0x001e
#define SOLAREDGE_COMMAND_PARAMS_SET_VOLATILE 0x001f
#define SOLAREDGE_COMMAND_UPGRADE_START 0x0020
#define SOLAREDGE_COMMAND_UPGRADE_WRITE 0x0021
#define SOLAREDGE_COMMAND_UPGRADE_FINISH 0x0022
#define SOLAREDGE_COMMAND_UPGRADE_READ_DATA 0x0023
#define SOLAREDGE_COMMAND_UPGRADE_READ_SIZE 0x0024
#define SOLAREDGE_COMMAND_MISC_RESET 0x0030
#define SOLAREDGE_COMMAND_MISC_STOP 0x0031
#define SOLAREDGE_COMMAND_MISC_DUMMY 0x0032
#define SOLAREDGE_COMMAND_MISC_GET_VER 0x0033
#define SOLAREDGE_COMMAND_MISC_GET_TYPE 0x0034
#define SOLAREDGE_COMMAND_MISC_PAYLOAD 0x0035
#define SOLAREDGE_COMMAND_MISC_SET_ID 0x0036
#define SOLAREDGE_COMMAND_MISC_READ_MEMORY 0x0037
#define SOLAREDGE_COMMAND_MISC_PARAMS_PARTIAL_RESET 0x0038
#define SOLAREDGE_COMMAND_MISC_GET_MAX_PACKET_SIZE 0x0039
#define SOLAREDGE_COMMAND_MISC_ENCRYPTED 0x003d
#define SOLAREDGE_COMMAND_PARAMS_SMART_LOAD_PARAMS 0x0040
#define SOLAREDGE_COMMAND_MISC_PARAMS_PARTIAL_RESET2 0x0041
#define SOLAREDGE_COMMAND_PARAMS_IGNORE_PARAMS_LIST 0x0042
#define SOLAREDGE_COMMAND_PARAMS_PARTIAL_RESET_AS_LEVEL 0x0043
#define SOLAREDGE_COMMAND_PARAMS_PARTIAL_RESET_PCB_LEVEL 0x0044
#define SOLAREDGE_COMMAND_RESP_ACK 0x0080
#define SOLAREDGE_COMMAND_RESP_NACK 0x0081
#define SOLAREDGE_COMMAND_RESP_PARAMS_SINGLE 0x0090
#define SOLAREDGE_COMMAND_RESP_PARAMS_INFO 0x0091
#define SOLAREDGE_COMMAND_RESP_PARAMS_NAME 0x0092
#define SOLAREDGE_COMMAND_RESP_PARAMS_NUM 0x0093
#define SOLAREDGE_COMMAND_RESP_PARAMS_ALL 0x0094
#define SOLAREDGE_COMMAND_RESP_PARAMS_INCORRECT_PASSWORD 0x0095
#define SOLAREDGE_COMMAND_RESP_UPGRADE_DATA 0x00a0
#define SOLAREDGE_COMMAND_RESP_UPGRADE_SIZE 0x00a1
#define SOLAREDGE_COMMAND_RESP_MISC_GET_VER 0x00b0
#define SOLAREDGE_COMMAND_RESP_MISC_GET_TYPE 0x00b1
#define SOLAREDGE_COMMAND_RESP_MISC_PAYLOAD 0x00b2
#define SOLAREDGE_COMMAND_RESP_MISC_READ_MEMORY 0x00b3
#define SOLAREDGE_COMMAND_RESP_MISC_GET_MAX_PACKET_SIZE 0x00b4
#define SOLAREDGE_COMMAND_MERCURY_PWM_SET 0x0100
#define SOLAREDGE_COMMAND_MERCURY_PWM_ENABLE 0x0101
#define SOLAREDGE_COMMAND_MERCURY_A2D_SAMPLE 0x0102
#define SOLAREDGE_COMMAND_MERCURY_KA 0x0103
#define SOLAREDGE_COMMAND_MERCURY_SET_VIREF 0x0104
#define SOLAREDGE_COMMAND_MERCURY_SET_VOMAXREF 0x0105
#define SOLAREDGE_COMMAND_MERCURY_SET_VOMINREF 0x0106
#define SOLAREDGE_COMMAND_MERCURY_READ_MEAS 0x0107
#define SOLAREDGE_COMMAND_MERCURY_CLOSED_LOOP_START 0x0108
#define SOLAREDGE_COMMAND_MERCURY_OPEN_LOOP_START 0x0109
#define SOLAREDGE_COMMAND_MERCURY_OPEN_LOOP_SET 0x010a
#define SOLAREDGE_COMMAND_MERCURY_SET_12V_10V 0x010b
#define SOLAREDGE_COMMAND_MERCURY_SET_5V_35V 0x010c
#define SOLAREDGE_COMMAND_MERCURY_SET_VO_RANGE 0x010d
#define SOLAREDGE_COMMAND_MERCURY_START_MPPT 0x010e
#define SOLAREDGE_COMMAND_MERCURY_TX_ENABLE 0x010f
#define SOLAREDGE_COMMAND_MERCURY_TX_TEST 0x0110
#define SOLAREDGE_COMMAND_MERCURY_RX_TEST 0x0111
#define SOLAREDGE_COMMAND_MERCURY_FORCE_TELEM 0x0112
#define SOLAREDGE_COMMAND_MERCURY_READ_SAMPLES_DIRECT 0x0113
#define SOLAREDGE_COMMAND_MERCURY_SET_OTP_BLOCK 0x0114
#define SOLAREDGE_COMMAND_MERCURY_SET_CAL_MODE 0x0115
#define SOLAREDGE_COMMAND_MERCURY_SET_VI_RANGE 0x0116
#define SOLAREDGE_COMMAND_MERCURY_AVG_SAMPLE 0x0117
#define SOLAREDGE_COMMAND_MERCURY_GET_TELEM 0x0118
#define SOLAREDGE_COMMAND_MERCURY_DISABLE_PROTECTION 0x0119
#define SOLAREDGE_COMMAND_MERCURY_BYPASS_MODE 0x011a
#define SOLAREDGE_COMMAND_MERCURY_SET_TEMP_CAL_PIN 0x011b
#define SOLAREDGE_COMMAND_MERCURY_SAVE_VOLATILE 0x011c
#define SOLAREDGE_COMMAND_MERCURY_BBB_MODE 0x011d
#define SOLAREDGE_COMMAND_MERCURY_GET_REG 0x011e
#define SOLAREDGE_COMMAND_MERCURY_SET_RES_CIRC_GPIOS 0x011f
#define SOLAREDGE_COMMAND_MERCURY_GET_SNR 0x0120
#define SOLAREDGE_COMMAND_MERCURY_GET_LOOP_MODE 0x0121
#define SOLAREDGE_COMMAND_MERCURY_SET_REG 0x0122
#define SOLAREDGE_COMMAND_MERCURY_DFT 0x0123
#define SOLAREDGE_COMMAND_MERCURY_SET_COMM_SW 0x0124
#define SOLAREDGE_COMMAND_MERCURY_GET_SPI_SAMPLES 0x0125
#define SOLAREDGE_COMMAND_MERCURY_SET_DT 0x0126
#define SOLAREDGE_COMMAND_MERCURY_GET_DFT_AVG 0x0127
#define SOLAREDGE_COMMAND_MERCURY_CONTROL_TEST 0x0128
#define SOLAREDGE_COMMAND_MERCURY_GET_STATUS_REG 0x0129
#define SOLAREDGE_COMMAND_MERCURY_RESET_STATUS_REG 0x012a
#define SOLAREDGE_COMMAND_MERCURY_SET_DPWM_FREQ 0x012b
#define SOLAREDGE_COMMAND_RESP_MERCURY_SAMPLES 0x0180
#define SOLAREDGE_COMMAND_RESP_MERCURY_MON 0x0181
#define SOLAREDGE_COMMAND_RESP_MERCURY_TELEM 0x0182
#define SOLAREDGE_COMMAND_RESP_MERCURY_MEAS 0x0183
#define SOLAREDGE_COMMAND_RESP_MERCURY_RX_TEST_RES 0x0184
#define SOLAREDGE_COMMAND_RESP_MERCURY_SAMPLES_DIRECT 0x0185
#define SOLAREDGE_COMMAND_RESP_MERCURY_AVG_SAMPLE 0x0186
#define SOLAREDGE_COMMAND_RESP_MERCURY_GET_TELEM 0x0187
#define SOLAREDGE_COMMAND_RESP_MERCURY_CONTROL_TEST 0x0188
#define SOLAREDGE_COMMAND_VENUSMNGR_READ_ISE_MEAS1 0x0200
#define SOLAREDGE_COMMAND_VENUSMNGR_READ_ISE_MEAS2 0x0201
#define SOLAREDGE_COMMAND_VENUSMNGR_READ_SE_MEAS 0x0202
#define SOLAREDGE_COMMAND_VENUSMNGR_START_INVERTER 0x0203
#define SOLAREDGE_COMMAND_VENUSMNGR_ISE_DUTY_CYCLE 0x0204
#define SOLAREDGE_COMMAND_VENUSMNGR_GET_SYS_STATUS 0x0205
#define SOLAREDGE_COMMAND_VENUSMNGR_GET_TELEM 0x0206
#define SOLAREDGE_COMMAND_VENUSMNGR_RX_TEST_INIT 0x0207
#define SOLAREDGE_COMMAND_VENUSMNGR_RX_TEST 0x0208
#define SOLAREDGE_COMMAND_VENUSMNGR_TX_TEST_START 0x0209
#define SOLAREDGE_COMMAND_VENUSMNGR_TX_TEST_STOP 0x020a
#define SOLAREDGE_COMMAND_VENUSMNGR_SET_TX_ENABLE 0x020b
#define SOLAREDGE_COMMAND_VENUSMNGR_ENABLE_ISE_WD 0x020c
#define SOLAREDGE_COMMAND_VENUSMNGR_DISABLE_ISE_WD 0x020d
#define SOLAREDGE_COMMAND_VENUSMNGR_GET_COUNTRY_CODE 0x020e
#define SOLAREDGE_COMMAND_VENUSMNGR_SET_COUNTRY 0x020f
#define SOLAREDGE_COMMAND_VENUSMNGR_PRIVILEGED_MODE 0x0210
#define SOLAREDGE_COMMAND_VENUSMNGR_PRIVILEGED_SET_PARAM 0x0211
#define SOLAREDGE_COMMAND_VENUSMNGR_PRIVILEGED_GET_EVENT 0x0212
#define SOLAREDGE_COMMAND_VENUSMNGR_PRIVILEGED_GET_STATUS 0x0213
#define SOLAREDGE_COMMAND_VENUSMNGR_CURRENT_MODEM_START 0x0214
#define SOLAREDGE_COMMAND_VENUSMNGR_CURRENT_MODEM_SEND 0x0215
#define SOLAREDGE_COMMAND_VENUSMNGR_CURRENT_MODEM_SEND_PAIRING 0x0216
#define SOLAREDGE_COMMAND_VENUSMNGR_CURRENT_MODEM_GET_STATUS 0x0217
#define SOLAREDGE_COMMAND_VENUSMNGR_KA_DATA_SEND 0x0218
#define SOLAREDGE_COMMAND_VENUSMNGR_CURRENT_MODEM_END_PAIRING 0x0219
#define SOLAREDGE_COMMAND_VENUSMNGR_FORCE_GRID_MON 0x021a
#define SOLAREDGE_COMMAND_VENUSMNGR_FORCE_SKIP_GRID_MON 0x021b
#define SOLAREDGE_COMMAND_VENUSMNGR_START_SUPERVISE 0x021c
#define SOLAREDGE_COMMAND_VENUSMNGR_READ_A2D_MEAS 0x021d
#define SOLAREDGE_COMMAND_VENUSMNGR_GET_COUNTRY_DEFAULTS 0x021e
#define SOLAREDGE_COMMAND_VENUSMNGR_SET_PRODUCT_MODEL 0x021f
#define SOLAREDGE_COMMAND_VENUSMNGR_GET_PRODUCT_MODEL 0x0220
#define SOLAREDGE_COMMAND_VENUSMNGR_SET_DYNAMIC_INVPWR_PARAM 0x0221
#define SOLAREDGE_COMMAND_INVERTER_ENTER_BURN_INVPWR_MODE 0x0222
#define SOLAREDGE_COMMAND_VENUSMNGR_MPPT_TRAVEL 0x0223
#define SOLAREDGE_COMMAND_VENUSMNGR_SET_PWR_PARAM 0x0224
#define SOLAREDGE_COMMAND_INVERTER_CURRENT_MODEM_SET_DATA_BIT 0x0225
#define SOLAREDGE_COMMAND_RESP_VENUSMNGR_READ_ISE_MEAS1 0x0280
#define SOLAREDGE_COMMAND_RESP_VENUSMNGR_READ_ISE_MEAS2 0x0281
#define SOLAREDGE_COMMAND_RESP_VENUSMNGR_READ_SE_MEAS 0x0282
#define SOLAREDGE_COMMAND_RESP_VENUSMNGR_GET_SYS_STATUS 0x0283
#define SOLAREDGE_COMMAND_RESP_VENUSMNGR_GET_TELEM 0x0284
#define SOLAREDGE_COMMAND_RESP_VENUSMNGR_RX_TEST 0x0285
#define SOLAREDGE_COMMAND_RESP_VENUSMNGR_GET_COUNTRY_CODE 0x0286
#define SOLAREDGE_COMMAND_RESP_VENUSMNGR_PRIVILEGED_GET_EVENT 0x0287
#define SOLAREDGE_COMMAND_RESP_VENUSMNGR_PRIVILEGED_GET_STATUS 0x0288
#define SOLAREDGE_COMMAND_RESP_VENUSMNGR_CURRENT_MODEM_GET_STATUS 0x0289
#define SOLAREDGE_COMMAND_RESP_VENUSMNGR_READ_A2D_MEAS 0x028a
#define SOLAREDGE_COMMAND_RESP_VENUSMNGR_GET_COUNTRY_DEFAULTS 0x028b
#define SOLAREDGE_COMMAND_RESP_VENUSMNGR_GET_PRODUCT_MODEL 0x028c
#define SOLAREDGE_COMMAND_RESP_VENUSMNGR_SET_DYNAMIC_ISE_PARAM 0x028d
#define SOLAREDGE_COMMAND_POLESTAR_TELEMS_START 0x0300
#define SOLAREDGE_COMMAND_POLESTAR_TELEMS_STOP 0x0301
#define SOLAREDGE_COMMAND_POLESTAR_MASTER_GRANT 0x0302
#define SOLAREDGE_COMMAND_POLESTAR_RTC_SET 0x0303
#define SOLAREDGE_COMMAND_POLESTAR_TEST_RAM 0x0304
#define SOLAREDGE_COMMAND_POLESTAR_TEST_FLASH 0x0305
#define SOLAREDGE_COMMAND_POLESTAR_MAC_ADDR_GET 0x0306
#define SOLAREDGE_COMMAND_POLESTAR_IP_ADDR_GET 0x0307
#define SOLAREDGE_COMMAND_POLESTAR_SLAVE_ID_DETECT_INIT 0x0308
#define SOLAREDGE_COMMAND_POLESTAR_SLAVE_ID_DETECT_GET_ID 0x0309
#define SOLAREDGE_COMMAND_POLESTAR_SLAVE_ID_DETECT_STOP 0x030a
#define SOLAREDGE_COMMAND_POLESTAR_UART_ZB_BRIDGE 0x030b
#define SOLAREDGE_COMMAND_POLESTAR_SEND_PING 0x030c
#define SOLAREDGE_COMMAND_POLESTAR_LCD_TEST_MODE 0x030d
#define SOLAREDGE_COMMAND_POLESTAR_CONFTOOL_START 0x030e
#define SOLAREDGE_COMMAND_POLESTAR_ETHERNET_STAT 0x030f
#define SOLAREDGE_COMMAND_POLESTAR_GET_FIFO_FLASH_INFO 0x0310
#define SOLAREDGE_COMMAND_POLESTAR_RESET_FIFO_FLASH 0x0311
#define SOLAREDGE_COMMAND_POLESTAR_RESET_FLASH 0x0312
#define SOLAREDGE_COMMAND_POLESTAR_RS485_MSTR_SLV_DET_START 0x0313
#define SOLAREDGE_COMMAND_POLESTAR_RS485_MSTR_SLV_DET_STATUS 0x0314
#define SOLAREDGE_COMMAND_POLESTAR_UART_ZB_SET 0x0315
#define SOLAREDGE_COMMAND_POLESTAR_TCP_TEST 0x0316
#define SOLAREDGE_COMMAND_POLESTAR_TIMER_ADVANCE 0x0317
#define SOLAREDGE_COMMAND_POLESTAR_ERASE_FLASH_FIFO_FAST 0x0318
#define SOLAREDGE_COMMAND_POLESTAR_SELF_KA 0x0319
#define SOLAREDGE_COMMAND_POLESTAR_ISE_BRIDGE 0x031a
#define SOLAREDGE_COMMAND_POLESTAR_ERASE_STATISTICS 0x031b
#define SOLAREDGE_COMMAND_POLESTAR_GET_POK_STATUS 0x031c
#define SOLAREDGE_COMMAND_POLESTAR_INVERTER_HW_RESET 0x031d
#define SOLAREDGE_COMMAND_POLESTAR_ZB_PRESENT_STATUS 0x031e
#define SOLAREDGE_COMMAND_POLESTAR_GET_ALL_SUPPORTED_LANGUAGES_INDEXES 0x031f
#define SOLAREDGE_COMMAND_POLESTAR_GET_ALL_SUPPORTED_GSM_MODEMS_INDEXES 0x0320
#define SOLAREDGE_COMMAND_POLESTAR_GET_S_OK_STATUS 0x0321
#define SOLAREDGE_COMMAND_POLESTAR_GET_ENERGY_STATISTICS_STATUS 0x0322
#define SOLAREDGE_COMMAND_POLESTAR_GET_GSM_PRESENT_STATUS 0x0323
#define SOLAREDGE_COMMAND_POLESTAR_SET_STATISTICS_ELEMENT 0x0324
#define SOLAREDGE_COMMAND_POLESTAR_GEMINI_RS485_MSTR_SLV_DET_START 0x0325
#define SOLAREDGE_COMMAND_POLESTAR_GEMINI_RS485_MSTR_SLV_DET_STATUS 0x0326
#define SOLAREDGE_COMMAND_POLESTAR_GET_GEMINI_GFD_STATUS 0x0327
#define SOLAREDGE_COMMAND_POLESTAR_GET_ERROR_LOG 0x0328
#define SOLAREDGE_COMMAND_POLESTAR_BLOCK_SERVER_CONTROL 0x0329
#define SOLAREDGE_COMMAND_POLESTAR_GET_SERVER_CONTROL_STATUS 0x032a
#define SOLAREDGE_COMMAND_POLESTAR_TEST_SD_FLASH 0x032b
#define SOLAREDGE_COMMAND_POLESTAR_GET_WARNING_LOG 0x032c
#define SOLAREDGE_COMMAND_POLESTAR_RESET_MODBUS_DEVICE_DATA 0x032d
#define SOLAREDGE_COMMAND_POLESTAR_TURN_OFF_INTERNAL_SRAM_BATTERY_BACKUP 0x032e
#define SOLAREDGE_COMMAND_POLESTAR_WRITE_LCD 0x032f
#define SOLAREDGE_COMMAND_POLESTAR_READ_LAST_BUTTONS 0x0330
#define SOLAREDGE_COMMAND_POLESTAR_GET_STATISTICS_ELEMENT 0x0331
#define SOLAREDGE_COMMAND_POLESTAR_SEND_POWER_REDUCER_SLAVE_PACKET 0x0332
#define SOLAREDGE_COMMAND_POLESTAR_SEND_POWER_REDUCER_MASTER_PACKET 0x0333
#define SOLAREDGE_COMMAND_POLESTAR_GET_WIFI_PRESENT_STATUS 0x0334
#define SOLAREDGE_COMMAND_POLESTAR_GET_PORT_EXPANDER_GPIO_DATA 0x0335
#define SOLAREDGE_COMMAND_POLESTAR_SET_PORT_EXPANDER_GPIO_DATA 0x0336
#define SOLAREDGE_COMMAND_POLESTAR_READ_LCD 0x0337
#define SOLAREDGE_COMMAND_POLESTAR_SIMULATE_BUTTON_PRESSING 0x0338
#define SOLAREDGE_COMMAND_POLESTAR_INV_ACTIVATE 0x0339
#define SOLAREDGE_COMMAND_POLESTAR_MODBUS_SLAVE_PACKET 0x033a
#define SOLAREDGE_COMMAND_POLESTAR_GET_BUTTON_STATE 0x033b
#define SOLAREDGE_COMMAND_POLESTAR_GET_A2D_VALS 0x033c
#define SOLAREDGE_COMMAND_POLESTAR_GET_OPMODE 0x033d
#define SOLAREDGE_COMMAND_POLESTAR_SET_BACKLIGHT 0x033e
#define SOLAREDGE_COMMAND_POLESTAR_READ_FIFO_PAGE 0x033f
#define SOLAREDGE_COMMAND_POLESTAR_GET_CURRENT_SCREEN_INDEX 0x0340
#define SOLAREDGE_COMMAND_POLESTAR_GET_IDENTITY 0x0341
#define SOLAREDGE_COMMAND_POLESTAR_GET_SUPPORTED_COMMANDS 0x0342
#define SOLAREDGE_COMMAND_POLESTAR_PAIRING_START 0x0343
#define SOLAREDGE_COMMAND_POLESTAR_PAIRING_STATUS 0x0344
#define SOLAREDGE_COMMAND_POLESTAR_PRODUCT_RESET 0x0345
#define SOLAREDGE_COMMAND_POLESTAR_PLC_CMD_EXECUTE 0x0346
#define SOLAREDGE_COMMAND_POLESTAR_GET_STATUS 0x0347
#define SOLAREDGE_COMMAND_POLESTAR_FIRE_SAFETY_LOCK_MASTER 0x0348
#define SOLAREDGE_COMMAND_POLESTAR_FIRE_SAFETY_LOCK_SLAVE 0x0349
#define SOLAREDGE_COMMAND_POLESTAR_FIRE_SAFETY_REPORT 0x034a
#define SOLAREDGE_COMMAND_POLESTAR_UART_BRIDGE_INIT 0x034b
#define SOLAREDGE_COMMAND_POLESTAR_SEND_UART_DATA 0x034c
#define SOLAREDGE_COMMAND_POLESTAR_LED_TEST 0x034d
#define SOLAREDGE_COMMAND_POLESTAR_SEND_FAKE_TELEMS 0x034e
#define SOLAREDGE_COMMAND_RESP_POLESTAR_RTC_SET 0x0380
#define SOLAREDGE_COMMAND_RESP_POLESTAR_MAC_ADDR_GET 0x0381
#define SOLAREDGE_COMMAND_RESP_POLESTAR_IP_ADDR_GET 0x0382
#define SOLAREDGE_COMMAND_RESP_POLESTAR_SEND_PING 0x0383
#define SOLAREDGE_COMMAND_RESP_POLESTAR_ETHERNET_STAT 0x0384
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_FIFO_FLASH_INFO 0x0385
#define SOLAREDGE_COMMAND_RESP_POLESTAR_RS485_MSTR_SLV_DET_STATUS 0x0386
#define SOLAREDGE_COMMAND_RESP_POLESTAR_TCP_TEST_RESP 0x0387
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_POK_STATUS 0x0388
#define SOLAREDGE_COMMAND_RESP_POLESTAR_INVERTER_HW_RESET 0x0389
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_ALL_SUPPORTED_LANGUAGES_INDEXES 0x038a
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_ALL_SUPPORTED_GSM_MODEMS_INDEXES 0x038b
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_S_OK_STATUS 0x038c
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_ENERGY_STATISTICS_STATUS 0x038d
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_GSM_PRESENT_STATUS 0x038e
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GEMINI_RS485_MSTR_SLV_DET_STATUS 0x038f
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_GEMINI_GFD_STATUS 0x0390
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_ERROR_LOG 0x0391
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_SERVER_CONTROL_STATUS 0x0392
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_WARNING_LOG 0x0393
#define SOLAREDGE_COMMAND_RESP_POLESTAR_READ_LAST_BUTTONS 0x0394
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_STATISTICS_ELEMENT 0x0395
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_WIFI_PRESENT_STATUS 0x0396
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_PORT_EXPANDER_GPIO_DATA 0x0397
#define SOLAREDGE_COMMAND_RESP_POLESTAR_READ_LCD 0x0398
#define SOLAREDGE_COMMAND_RESP_POLESTAR_MODBUS_SLAVE_PACKET 0x0399
#define SOLAREDGE_COMMAND_RESP_POLESTAR_MASTER_GRANT_ACK 0x039a
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_IDENTITY 0x039b
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_SUPPORTED_COMMANDS 0x039c
#define SOLAREDGE_COMMAND_RESP_POLESTAR_PAIRING_START 0x039d
#define SOLAREDGE_COMMAND_RESP_POLESTAR_PAIRING_STATUS 0x039e
#define SOLAREDGE_COMMAND_RESP_POLESTAR_GET_STATUS 0x039f
#define SOLAREDGE_COMMAND_RESP_POLESTAR_FIRE_SAFETY_REPORT 0x03a0
#define SOLAREDGE_COMMAND_RESP_POLESTAR_SEND_UART_DATA 0x03a1
#define SOLAREDGE_COMMAND_SUNTRACER_READ_FLASH 0x0400
#define SOLAREDGE_COMMAND_SUNTRACER_START 0x0401
#define SOLAREDGE_COMMAND_SUNTRACER_SET_RTC 0x0402
#define SOLAREDGE_COMMAND_SUNTRACER_DEL_FLASH 0x0403
#define SOLAREDGE_COMMAND_SUNTRACER_DEL_FLASH_SECTOR 0x0404
#define SOLAREDGE_COMMAND_RESP_SUNTRACER_TRACE 0x0480
#define SOLAREDGE_COMMAND_RESP_SUNTRACER_FLASH 0x0481
#define SOLAREDGE_COMMAND_SERVER_POST_DATA 0x0500
#define SOLAREDGE_COMMAND_SERVER_GET_GMT 0x0501
#define SOLAREDGE_COMMAND_SERVER_GET_NAME 0x0502
#define SOLAREDGE_COMMAND_SERVER_SET_KEY 0x0503
#define SOLAREDGE_COMMAND_RESP_SERVER_GMT 0x0580
#define SOLAREDGE_COMMAND_RESP_SERVER_NAME 0x0581
#define SOLAREDGE_COMMAND_RESP_CONFTOOL_PLC_DATA 0x0680
#define SOLAREDGE_COMMAND_JUPMNGR_READ_JUPPWR_MEAS1 0x0800
#define SOLAREDGE_COMMAND_JUPMNGR_READ_JUPPWR_MEAS2 0x0801
#define SOLAREDGE_COMMAND_JUPMNGR_READ_JUPPWR_MEAS3 0x0802
#define SOLAREDGE_COMMAND_JUPMNGR_READ_JUPPWR_MEAS4 0x0803
#define SOLAREDGE_COMMAND_JUPMNGR_READ_JUPPWR_MEAS5 0x0804
#define SOLAREDGE_COMMAND_JUPMNGR_READ_MEAS 0x0805
#define SOLAREDGE_COMMAND_JUPMNGR_GET_SYS_STATUS 0x0806
#define SOLAREDGE_COMMAND_JUPMNGR_GET_TELEM 0x0807
#define SOLAREDGE_COMMAND_JUPMNGR_GET_COUNTRY_CODE 0x0808
#define SOLAREDGE_COMMAND_JUPMNGR_SET_COUNTRY 0x0809
#define SOLAREDGE_COMMAND_JUPMNGR_GET_COUNTRY_DEFAULTS 0x080a
#define SOLAREDGE_COMMAND_JUPMNGR_PRIVILEGED_MODE 0x080b
#define SOLAREDGE_COMMAND_JUPMNGR_PRIVILEGED_SET_PARAM 0x080c
#define SOLAREDGE_COMMAND_JUPMNGR_PRIVILEGED_GET_EVENT 0x080d
#define SOLAREDGE_COMMAND_JUPMNGR_PRIVILEGED_GET_STATUS 0x080e
#define SOLAREDGE_COMMAND_JUPMNGR_SET_PRODUCT_MODEL 0x080f
#define SOLAREDGE_COMMAND_JUPMNGR_GET_PRODUCT_MODEL 0x0810
#define SOLAREDGE_COMMAND_JUPMNGR_DYNAMIC_SET_INVPWR_PARAM 0x0811
#define SOLAREDGE_COMMAND_JUPMNGR_GET_INVPWR_PARAM_TYPE 0x0812
#define SOLAREDGE_COMMAND_JUPMNGR_GET_FANS_STATUS 0x0813
#define SOLAREDGE_COMMAND_RESP_JUPMNGR_READ_JUPPWR_MEAS1 0x0880
#define SOLAREDGE_COMMAND_RESP_JUPMNGR_READ_JUPPWR_MEAS2 0x0881
#define SOLAREDGE_COMMAND_RESP_JUPMNGR_READ_JUPPWR_MEAS3 0x0882
#define SOLAREDGE_COMMAND_RESP_JUPMNGR_READ_JUPPWR_MEAS4 0x0883
#define SOLAREDGE_COMMAND_RESP_JUPMNGR_READ_JUPPWR_MEAS5 0x0884
#define SOLAREDGE_COMMAND_RESP_JUPMNGR_READ_MEAS 0x0885
#define SOLAREDGE_COMMAND_RESP_JUPMNGR_GET_SYS_STATUS 0x0886
#define SOLAREDGE_COMMAND_RESP_JUPMNGR_GET_TELEM 0x0887
#define SOLAREDGE_COMMAND_RESP_JUPMNGR_GET_COUNTRY_CODE 0x0888
#define SOLAREDGE_COMMAND_RESP_JUPMNGR_GET_COUNTRY_DEFAULTS 0x0889
#define SOLAREDGE_COMMAND_RESP_JUPMNGR_PRIVILEGED_GET_EVENT 0x088a
#define SOLAREDGE_COMMAND_RESP_JUPMNGR_PRIVILEGED_GET_STATUS 0x088b
#define SOLAREDGE_COMMAND_RESP_JUPMNGR_GET_PRODUCT_MODEL 0x088c
#define SOLAREDGE_COMMAND_RESP_JUPMNGR_GET_INVPWR_PARAM_TYPE 0x088d
#define SOLAREDGE_COMMAND_RESP_JUPMNGR_GET_FANS_STATUS 0x088e
#define SOLAREDGE_COMMAND_INVERTER_TURN_15V_ON 0x0900
#define SOLAREDGE_COMMAND_INVERTER_TURN_15V_OFF 0x0901
#define SOLAREDGE_COMMAND_INVERTER_ENABLE_RELAYS 0x0902
#define SOLAREDGE_COMMAND_INVERTER_DISABLE_RELAYS 0x0903
#define SOLAREDGE_COMMAND_INVERTER_DYNAMIC_POWER_LIMIT 0x0904
#define SOLAREDGE_COMMAND_INVERTER_IVTRACE_START 0x0905
#define SOLAREDGE_COMMAND_INVERTER_GRID_TRIP_TEST 0x0906
#define SOLAREDGE_COMMAND_INVERTER_SET_LMVGC_PARAMS1 0x0907
#define SOLAREDGE_COMMAND_INVERTER_GET_LMVGC_PARAMS1 0x0908
#define SOLAREDGE_COMMAND_INVERTER_SET_PWR_GAIN_PARAMS 0x0909
#define SOLAREDGE_COMMAND_INVERTER_SET_LMVGC_PARAMS2 0x090a
#define SOLAREDGE_COMMAND_INVERTER_GET_LMVGC_PARAMS2 0x090b
#define SOLAREDGE_COMMAND_INVERTER_SET_LMVGC_PARAMS3 0x090c
#define SOLAREDGE_COMMAND_INVERTER_GET_LMVGC_PARAMS3 0x090d
#define SOLAREDGE_COMMAND_INVERTER_LOCK_IN 0x090e
#define SOLAREDGE_COMMAND_INVERTER_LOCK_OUT 0x090f
#define SOLAREDGE_COMMAND_INVERTER_GET_VDC 0x0910
#define SOLAREDGE_COMMAND_INVERTER_PAIRING_DO_NOTHING 0x0911
#define SOLAREDGE_COMMAND_INVERTER_PAIRING_DO_SAFETY 0x0912
#define SOLAREDGE_COMMAND_RESP_INVERTER_DYNAMIC_POWER_LIMIT 0x0980
#define SOLAREDGE_COMMAND_RESP_INVERTER_GET_LMVGC_PARAMS 0x0981
#define SOLAREDGE_COMMAND_VEGA_READ_MEAS 0x0a00
#define SOLAREDGE_COMMAND_VEGA_GET_SYS_STATUS 0x0a01
#define SOLAREDGE_COMMAND_VEGA_GET_TELEM 0x0a02
#define SOLAREDGE_COMMAND_VEGA_GET_MAX_VDC_VALUE 0x0a03
#define SOLAREDGE_COMMAND_VEGA_SET_MAX_VDC_VALUE 0x0a04
#define SOLAREDGE_COMMAND_VEGA_RELAY_SET 0x0a05
#define SOLAREDGE_COMMAND_VEGA_SET_OPMODE 0x0a06
#define SOLAREDGE_COMMAND_VEGA_GET_OPMODE 0x0a07
#define SOLAREDGE_COMMAND_VEGA_SET_RANGE 0x0a08
#define SOLAREDGE_COMMAND_RESP_VEGA_READ_MEAS 0x0a80
#define SOLAREDGE_COMMAND_RESP_VEGA_GET_SYS_STATUS 0x0a81
#define SOLAREDGE_COMMAND_RESP_VEGA_GET_TELEM 0x0a82
#define SOLAREDGE_COMMAND_RESP_VEGA_GET_MAX_VDC_VALUE 0x0a83
#define SOLAREDGE_COMMAND_COMBI_PAUSE_MONITORING 0x0b00
#define SOLAREDGE_COMMAND_COMBI_SET_TIME_STAMP 0x0b01
#define SOLAREDGE_COMMAND_COMBI_RCD_CALIBRATION 0x0b02
#define SOLAREDGE_COMMAND_COMBI_GET_TELEM 0x0b03
#define SOLAREDGE_COMMAND_COMBI_FORCE_TELEM 0x0b04
#define SOLAREDGE_COMMAND_COMBI_SWITCHES_CONNECT 0x0b05
#define SOLAREDGE_COMMAND_COMBI_SWITCHES_DISCONNECT 0x0b06
#define SOLAREDGE_COMMAND_COMBI_SWITCHES_CONNECT_ALL 0x0b07
#define SOLAREDGE_COMMAND_COMBI_SWITCHES_DISCONNECT_ALL 0x0b08
#define SOLAREDGE_COMMAND_COMBI_RCD_TEST_EXECUTE 0x0b09
#define SOLAREDGE_COMMAND_COMBI_RELAYS_TEST_EXECUTE 0x0b0a
#define SOLAREDGE_COMMAND_COMBI_GET_COMBISTRING_PARAM 0x0b0b
#define SOLAREDGE_COMMAND_COMBI_SET_COMBISTRING_PARAM 0x0b0c
#define SOLAREDGE_COMMAND_COMBI_GET_ALL_COMBISTRING_PARAMS 0x0b0d
#define SOLAREDGE_COMMAND_COMBI_GET_ALL_COMBI_PARAMS 0x0b0e
#define SOLAREDGE_COMMAND_COMBI_READ_MEASUREMENTS 0x0b0f
#define SOLAREDGE_COMMAND_COMBI_GET_STRING_STATUS 0x0b10
#define SOLAREDGE_COMMAND_COMBI_GET_COMBI_STATUS 0x0b11
#define SOLAREDGE_COMMAND_COMBI_GET_ACTIVE_STRINGS 0x0b12
#define SOLAREDGE_COMMAND_COMBI_FWD_STRING_TELEM 0x0b13
#define SOLAREDGE_COMMAND_COMBI_FWD_COMBI_TELEM 0x0b14
#define SOLAREDGE_COMMAND_COMBI_GET_UNIFIED_STRING_STATUS 0x0b15
#define SOLAREDGE_COMMAND_COMBI_GET_UNIFIED_COMBI_STATUS 0x0b16
#define SOLAREDGE_COMMAND_COMBI_CHECK_INNER_PROTOCOL 0x0b17
#define SOLAREDGE_COMMAND_COMBI_SWITCHES_CONNECT_RELAY 0x0b18
#define SOLAREDGE_COMMAND_COMBI_SWITCHES_DISCONNECT_RELAY 0x0b19
#define SOLAREDGE_COMMAND_COMBI_GET_GEMINI_STRING_IDS 0x0b1a
#define SOLAREDGE_COMMAND_COMBI_GET_ALL_SWITCHES_STATUS 0x0b1b
#define SOLAREDGE_COMMAND_COMBI_SET_RCD_TEST_PIN 0x0b1c
#define SOLAREDGE_COMMAND_COMBI_RELAYS_TEST_CHECK_CONDS 0x0b1d
#define SOLAREDGE_COMMAND_RESP_COMBI_GET_TELEM 0x0b80
#define SOLAREDGE_COMMAND_RESP_COMBI_GET_STRING_STATUS 0x0b81
#define SOLAREDGE_COMMAND_RESP_COMBI_GET_COMBI_STATUS 0x0b82
#define SOLAREDGE_COMMAND_RESP_COMBI_GET_ACTIVE_STRINGS 0x0b83
#define SOLAREDGE_COMMAND_RESP_COMBI_GET_UNIFIED_STRING_STATUS 0x0b84
#define SOLAREDGE_COMMAND_RESP_COMBI_GET_UNIFIED_COMBI_STATUS 0x0b85
#define SOLAREDGE_COMMAND_RESP_COMBI_GET_GEMINI_STRING_IDS 0x0b86
#define SOLAREDGE_COMMAND_INVPWR_GET_ERROR_STATUS 0x0c00
#define SOLAREDGE_COMMAND_INVPWR_GET_STATUS 0x0c01
#define SOLAREDGE_COMMAND_INVPWR_GO 0x0c02
#define SOLAREDGE_COMMAND_INVPWR_HALT 0x0c03
#define SOLAREDGE_COMMAND_INVPWR_CONST_DUTY_CYCLE 0x0c04
#define SOLAREDGE_COMMAND_INVPWR_DUMY_ERROR 0x0c05
#define SOLAREDGE_COMMAND_INVPWR_PAIRING_SET_STATE 0x0c06
#define SOLAREDGE_COMMAND_INVPWR_TEST_IAC_CONTROL 0x0c07
#define SOLAREDGE_COMMAND_RESP_INVPWR_GET_ERROR_STATUS 0x0c80
#define SOLAREDGE_COMMAND_RESP_INVPWR_GET_STATUS 0x0c81
#define SOLAREDGE_COMMAND_RESP_INVPWR_GO 0x0c82
#define SOLAREDGE_COMMAND_RESP_INVPWR_HALT 0x0c83
#define SOLAREDGE_COMMAND_RESP_INVPWR_CONST_DUTY_CYCLE 0x0c84
#define SOLAREDGE_COMMAND_RESP_INVPWR_DUMY_ERROR 0x0c85
#define SOLAREDGE_COMMAND_BOOTLOADER_SECURE 0x1400
#define SOLAREDGE_COMMAND_BOOTLOADER_UNSECURE 0x1401
#define SOLAREDGE_COMMAND_ACTIVATOR_ACTIVATE 0x1500
#define SOLAREDGE_COMMAND_ACTIVATOR_GET_ADC_SAMPLES 0x1501
#define SOLAREDGE_COMMAND_ACTIVATOR_SET_VO_RANGE 0x1502
#define SOLAREDGE_COMMAND_ACTIVATOR_GET_AVG_SAMPLES 0x1503
#define SOLAREDGE_COMMAND_ACTIVATOR_TX_TEST 0x1504
#define SOLAREDGE_COMMAND_ACTIVATOR_LCD_TEST 0x1505
#define SOLAREDGE_COMMAND_ACTIVATOR_BUTTONS_TEST 0x1506
#define SOLAREDGE_COMMAND_FANCONTROL_SET_PWM 0x1600
#define SOLAREDGE_COMMAND_FANCONTROL_GET_PWM 0x1601
#define SOLAREDGE_COMMAND_FANCONTROL_GET_ALL_PWM 0x1602
#define SOLAREDGE_COMMAND_FANCONTROL_SHUT_ALL_PWM 0x1603
#define SOLAREDGE_COMMAND_FANCONTROL_RES 0x1680
#define SOLAREDGE_COMMAND_DISPLAY_BOARD_LCD_WRITE 0x1700
#define SOLAREDGE_COMMAND_DISPLAY_BOARD_LED_SET 0x1701
#define SOLAREDGE_DEVICETYPE_OPTIMIZER 0x0000
#define SOLAREDGE_DEVICETYPE_INVERTER_1PHASE 0x0010
#define SOLAREDGE_DEVICETYPE_INVERTER_3PHASE 0x0011
#define SOLAREDGE_DEVICETYPE_OPTIMIZER2 0x0080
#define SOLAREDGE_DEVICETYPE_EVENT 0x0300
typedef struct solaredge_packet_header {
guint16 length;
guint16 length_inverse;
guint16 sequence_number;
guint32 source_address;
guint32 destination_address;
guint16 command_type;
} t_solaredge_packet_header;
typedef struct solaredge_device_header {
guint16 type;
guint32 id;
guint16 device_length;
} t_solaredge_device_header;
typedef struct solaredge_conversion_data {
gboolean session_key_found;
gcry_cipher_hd_t cipher_hd_session;
guint16 expected_sequence_number;
} t_solaredge_conversion_data;
void proto_reg_handoff_solaredge(void);
void proto_register_solaredge(void);
static gboolean global_show_unknown_fields = TRUE;
static expert_field ei_solaredge_invalid_length = EI_INIT;
static expert_field ei_solaredge_invalid_crc = EI_INIT;
static int proto_solaredge = -1;
static int hf_solaredge_length_type = -1;
static int hf_solaredge_length_inverse_type = -1;
static int hf_solaredge_sequence_number_type = -1;
static int hf_solaredge_source_address_type = -1;
static int hf_solaredge_destination_address_type = -1;
static int hf_solaredge_command_type = -1;
static int hf_solaredge_crc_type = -1;
static int hf_solaredge_crc_status_type = -1;
static int hf_solaredge_payload_type = -1;
static int hf_solaredge_session_key_type = -1;
static int hf_solaredge_post_type = -1;
static int hf_solaredge_post_device_type = -1;
static int hf_solaredge_post_device_type_type = -1;
static int hf_solaredge_post_device_id_type = -1;
static int hf_solaredge_post_length_type = -1;
static int hf_solaredge_post_padding_uint32_type = -1;
static int hf_solaredge_post_padding_float_type = -1;
static int hf_solaredge_post_singlephase_inverter_timestamp_type = -1;
static int hf_solaredge_post_singlephase_inverter_uptime_type = -1;
static int hf_solaredge_post_singlephase_inverter_interval_type = -1;
static int hf_solaredge_post_singlephase_inverter_temperature_type = -1;
static int hf_solaredge_post_singlephase_inverter_energy_day_type = -1;
static int hf_solaredge_post_singlephase_inverter_energy_interval_type = -1;
static int hf_solaredge_post_singlephase_inverter_ac_voltage_type = -1;
static int hf_solaredge_post_singlephase_inverter_ac_current_type = -1;
static int hf_solaredge_post_singlephase_inverter_ac_frequency_type = -1;
static int hf_solaredge_post_singlephase_inverter_dc_voltage_type = -1;
static int hf_solaredge_post_singlephase_inverter_energy_total_type = -1;
static int hf_solaredge_post_singlephase_inverter_power_max_type = -1;
static int hf_solaredge_post_singlephase_inverter_ac_power_type = -1;
static int hf_solaredge_post_optimizer_inverter_type = -1;
static int hf_solaredge_post_optimizer_uptime_type = -1;
static int hf_solaredge_post_optimizer_dc_current_panel_type = -1;
static int hf_solaredge_post_optimizer_timestamp_type = -1;
static int hf_solaredge_post_optimizer_uptime_short_type = -1;
static int hf_solaredge_post_optimizer_dc_voltage_panel_type = -1;
static int hf_solaredge_post_optimizer_dc_voltage_optimzer_type = -1;
static int hf_solaredge_post_optimizer_dc_current_optimzer_type = -1;
static int hf_solaredge_post_optimizer_energy_day_type = -1;
static int hf_solaredge_post_optimizer_temperature_type = -1;
static int hf_solaredge_post_event_timestamp_type = -1;
static int hf_solaredge_post_event_type_type = -1;
static int hf_solaredge_post_event_event_start_timestamp_type = -1;
static int hf_solaredge_post_event_event_timezone_offset_type = -1;
static int hf_solaredge_post_event_event_end_timestamp_type = -1;
static gint ett_solaredge_packet = -1;
static gint ett_solaredge_packet_decrypted = -1;
static gint ett_solaredge_packet_post = -1;
static gint ett_solaredge_packet_post_device = -1;
static const value_string solaredge_packet_commandtypes[] = {
{ SOLAREDGE_COMMAND_PARAMS_RESET, "PARAMS_RESET" },
{ SOLAREDGE_COMMAND_PARAMS_SET_SINGLE, "PARAMS_SET_SINGLE" },
{ SOLAREDGE_COMMAND_PARAMS_GET_SINGLE, "PARAMS_GET_SINGLE" },
{ SOLAREDGE_COMMAND_PARAMS_GET_INFO, "PARAMS_GET_INFO" },
{ SOLAREDGE_COMMAND_PARAMS_GET_NAME, "PARAMS_GET_NAME" },
{ SOLAREDGE_COMMAND_PARAMS_GET_NUM, "PARAMS_GET_NUM" },
{ SOLAREDGE_COMMAND_PARAMS_GET_ALL, "PARAMS_GET_ALL" },
{ SOLAREDGE_COMMAND_PARAMS_SET_ALL, "PARAMS_SET_ALL" },
{ SOLAREDGE_COMMAND_PARAMS_SET_SINGLE_NOSAVE, "PARAMS_SET_SINGLE_NOSAVE" },
{ SOLAREDGE_COMMAND_PARAMS_SAVE, "PARAMS_SAVE" },
{ SOLAREDGE_COMMAND_PARAMS_POLICY_ENABLE, "PARAMS_POLICY_ENABLE" },
{ SOLAREDGE_COMMAND_PARAMS_POLICY_DISABLE, "PARAMS_POLICY_DISABLE" },
{ SOLAREDGE_COMMAND_PARAMS_POLICY_DISABLE_VOLATILE, "PARAMS_POLICY_DISABLE_VOLATILE" },
{ SOLAREDGE_COMMAND_PARAMS_SET_POLICY_PASSWORD, "PARAMS_SET_POLICY_PASSWORD" },
{ SOLAREDGE_COMMAND_PARAMS_GET_VOLATILE, "PARAMS_GET_VOLATILE" },
{ SOLAREDGE_COMMAND_PARAMS_SET_VOLATILE, "PARAMS_SET_VOLATILE" },
{ SOLAREDGE_COMMAND_UPGRADE_START, "UPGRADE_START" },
{ SOLAREDGE_COMMAND_UPGRADE_WRITE, "UPGRADE_WRITE" },
{ SOLAREDGE_COMMAND_UPGRADE_FINISH, "UPGRADE_FINISH" },
{ SOLAREDGE_COMMAND_UPGRADE_READ_DATA, "UPGRADE_READ_DATA" },
{ SOLAREDGE_COMMAND_UPGRADE_READ_SIZE, "UPGRADE_READ_SIZE" },
{ SOLAREDGE_COMMAND_MISC_RESET, "MISC_RESET" },
{ SOLAREDGE_COMMAND_MISC_STOP, "MISC_STOP" },
{ SOLAREDGE_COMMAND_MISC_DUMMY, "MISC_DUMMY" },
{ SOLAREDGE_COMMAND_MISC_GET_VER, "MISC_GET_VER" },
{ SOLAREDGE_COMMAND_MISC_GET_TYPE, "MISC_GET_TYPE" },
{ SOLAREDGE_COMMAND_MISC_PAYLOAD, "MISC_PAYLOAD" },
{ SOLAREDGE_COMMAND_MISC_SET_ID, "MISC_SET_ID" },
{ SOLAREDGE_COMMAND_MISC_READ_MEMORY, "MISC_READ_MEMORY" },
{ SOLAREDGE_COMMAND_MISC_PARAMS_PARTIAL_RESET, "MISC_PARAMS_PARTIAL_RESET" },
{ SOLAREDGE_COMMAND_MISC_GET_MAX_PACKET_SIZE, "MISC_GET_MAX_PACKET_SIZE" },
{ SOLAREDGE_COMMAND_MISC_ENCRYPTED, "MISC_ENCRYPTED" },
{ SOLAREDGE_COMMAND_PARAMS_SMART_LOAD_PARAMS, "PARAMS_SMART_LOAD_PARAMS" },
{ SOLAREDGE_COMMAND_MISC_PARAMS_PARTIAL_RESET2, "MISC_PARAMS_PARTIAL_RESET2" },
{ SOLAREDGE_COMMAND_PARAMS_IGNORE_PARAMS_LIST, "PARAMS_IGNORE_PARAMS_LIST" },
{ SOLAREDGE_COMMAND_PARAMS_PARTIAL_RESET_AS_LEVEL, "PARAMS_PARTIAL_RESET_AS_LEVEL" },
{ SOLAREDGE_COMMAND_PARAMS_PARTIAL_RESET_PCB_LEVEL, "PARAMS_PARTIAL_RESET_PCB_LEVEL" },
{ SOLAREDGE_COMMAND_RESP_ACK, "RESP_ACK" },
{ SOLAREDGE_COMMAND_RESP_NACK, "RESP_NACK" },
{ SOLAREDGE_COMMAND_RESP_PARAMS_SINGLE, "RESP_PARAMS_SINGLE" },
{ SOLAREDGE_COMMAND_RESP_PARAMS_INFO, "RESP_PARAMS_INFO" },
{ SOLAREDGE_COMMAND_RESP_PARAMS_NAME, "RESP_PARAMS_NAME" },
{ SOLAREDGE_COMMAND_RESP_PARAMS_NUM, "RESP_PARAMS_NUM" },
{ SOLAREDGE_COMMAND_RESP_PARAMS_ALL, "RESP_PARAMS_ALL" },
{ SOLAREDGE_COMMAND_RESP_PARAMS_INCORRECT_PASSWORD, "RESP_PARAMS_INCORRECT_PASSWORD" },
{ SOLAREDGE_COMMAND_RESP_UPGRADE_DATA, "RESP_UPGRADE_DATA" },
{ SOLAREDGE_COMMAND_RESP_UPGRADE_SIZE, "RESP_UPGRADE_SIZE" },
{ SOLAREDGE_COMMAND_RESP_MISC_GET_VER, "RESP_MISC_GET_VER" },
{ SOLAREDGE_COMMAND_RESP_MISC_GET_TYPE, "RESP_MISC_GET_TYPE" },
{ SOLAREDGE_COMMAND_RESP_MISC_PAYLOAD, "RESP_MISC_PAYLOAD" },
{ SOLAREDGE_COMMAND_RESP_MISC_READ_MEMORY, "RESP_MISC_READ_MEMORY" },
{ SOLAREDGE_COMMAND_RESP_MISC_GET_MAX_PACKET_SIZE, "RESP_MISC_GET_MAX_PACKET_SIZE" },
{ SOLAREDGE_COMMAND_MERCURY_PWM_SET, "MERCURY_PWM_SET" },
{ SOLAREDGE_COMMAND_MERCURY_PWM_ENABLE, "MERCURY_PWM_ENABLE" },
{ SOLAREDGE_COMMAND_MERCURY_A2D_SAMPLE, "MERCURY_A2D_SAMPLE" },
{ SOLAREDGE_COMMAND_MERCURY_KA, "MERCURY_KA" },
{ SOLAREDGE_COMMAND_MERCURY_SET_VIREF, "MERCURY_SET_VIREF" },
{ SOLAREDGE_COMMAND_MERCURY_SET_VOMAXREF, "MERCURY_SET_VOMAXREF" },
{ SOLAREDGE_COMMAND_MERCURY_SET_VOMINREF, "MERCURY_SET_VOMINREF" },
{ SOLAREDGE_COMMAND_MERCURY_READ_MEAS, "MERCURY_READ_MEAS" },
{ SOLAREDGE_COMMAND_MERCURY_CLOSED_LOOP_START, "MERCURY_CLOSED_LOOP_START" },
{ SOLAREDGE_COMMAND_MERCURY_OPEN_LOOP_START, "MERCURY_OPEN_LOOP_START" },
{ SOLAREDGE_COMMAND_MERCURY_OPEN_LOOP_SET, "MERCURY_OPEN_LOOP_SET" },
{ SOLAREDGE_COMMAND_MERCURY_SET_12V_10V, "MERCURY_SET_12V_10V" },
{ SOLAREDGE_COMMAND_MERCURY_SET_5V_35V, "MERCURY_SET_5V_35V" },
{ SOLAREDGE_COMMAND_MERCURY_SET_VO_RANGE, "MERCURY_SET_VO_RANGE" },
{ SOLAREDGE_COMMAND_MERCURY_START_MPPT, "MERCURY_START_MPPT" },
{ SOLAREDGE_COMMAND_MERCURY_TX_ENABLE, "MERCURY_TX_ENABLE" },
{ SOLAREDGE_COMMAND_MERCURY_TX_TEST, "MERCURY_TX_TEST" },
{ SOLAREDGE_COMMAND_MERCURY_RX_TEST, "MERCURY_RX_TEST" },
{ SOLAREDGE_COMMAND_MERCURY_FORCE_TELEM, "MERCURY_FORCE_TELEM" },
{ SOLAREDGE_COMMAND_MERCURY_READ_SAMPLES_DIRECT, "MERCURY_READ_SAMPLES_DIRECT" },
{ SOLAREDGE_COMMAND_MERCURY_SET_OTP_BLOCK, "MERCURY_SET_OTP_BLOCK" },
{ SOLAREDGE_COMMAND_MERCURY_SET_CAL_MODE, "MERCURY_SET_CAL_MODE" },
{ SOLAREDGE_COMMAND_MERCURY_SET_VI_RANGE, "MERCURY_SET_VI_RANGE" },
{ SOLAREDGE_COMMAND_MERCURY_AVG_SAMPLE, "MERCURY_AVG_SAMPLE" },
{ SOLAREDGE_COMMAND_MERCURY_GET_TELEM, "MERCURY_GET_TELEM" },
{ SOLAREDGE_COMMAND_MERCURY_DISABLE_PROTECTION, "MERCURY_DISABLE_PROTECTION" },
{ SOLAREDGE_COMMAND_MERCURY_BYPASS_MODE, "MERCURY_BYPASS_MODE" },
{ SOLAREDGE_COMMAND_MERCURY_SET_TEMP_CAL_PIN, "MERCURY_SET_TEMP_CAL_PIN" },
{ SOLAREDGE_COMMAND_MERCURY_SAVE_VOLATILE, "MERCURY_SAVE_VOLATILE" },
{ SOLAREDGE_COMMAND_MERCURY_BBB_MODE, "MERCURY_BBB_MODE" },
{ SOLAREDGE_COMMAND_MERCURY_GET_REG, "MERCURY_GET_REG" },
{ SOLAREDGE_COMMAND_MERCURY_SET_RES_CIRC_GPIOS, "MERCURY_SET_RES_CIRC_GPIOS" },
{ SOLAREDGE_COMMAND_MERCURY_GET_SNR, "MERCURY_GET_SNR" },
{ SOLAREDGE_COMMAND_MERCURY_GET_LOOP_MODE, "MERCURY_GET_LOOP_MODE" },
{ SOLAREDGE_COMMAND_MERCURY_SET_REG, "MERCURY_SET_REG" },
{ SOLAREDGE_COMMAND_MERCURY_DFT, "MERCURY_DFT" },
{ SOLAREDGE_COMMAND_MERCURY_SET_COMM_SW, "MERCURY_SET_COMM_SW" },
{ SOLAREDGE_COMMAND_MERCURY_GET_SPI_SAMPLES, "MERCURY_GET_SPI_SAMPLES" },
{ SOLAREDGE_COMMAND_MERCURY_SET_DT, "MERCURY_SET_DT" },
{ SOLAREDGE_COMMAND_MERCURY_GET_DFT_AVG, "MERCURY_GET_DFT_AVG" },
{ SOLAREDGE_COMMAND_MERCURY_CONTROL_TEST, "MERCURY_CONTROL_TEST" },
{ SOLAREDGE_COMMAND_MERCURY_GET_STATUS_REG, "MERCURY_GET_STATUS_REG" },
{ SOLAREDGE_COMMAND_MERCURY_RESET_STATUS_REG, "MERCURY_RESET_STATUS_REG" },
{ SOLAREDGE_COMMAND_MERCURY_SET_DPWM_FREQ, "MERCURY_SET_DPWM_FREQ" },
{ SOLAREDGE_COMMAND_RESP_MERCURY_SAMPLES, "RESP_MERCURY_SAMPLES" },
{ SOLAREDGE_COMMAND_RESP_MERCURY_MON, "RESP_MERCURY_MON" },
{ SOLAREDGE_COMMAND_RESP_MERCURY_TELEM, "RESP_MERCURY_TELEM" },
{ SOLAREDGE_COMMAND_RESP_MERCURY_MEAS, "RESP_MERCURY_MEAS" },
{ SOLAREDGE_COMMAND_RESP_MERCURY_RX_TEST_RES, "RESP_MERCURY_RX_TEST_RES" },
{ SOLAREDGE_COMMAND_RESP_MERCURY_SAMPLES_DIRECT, "RESP_MERCURY_SAMPLES_DIRECT" },
{ SOLAREDGE_COMMAND_RESP_MERCURY_AVG_SAMPLE, "RESP_MERCURY_AVG_SAMPLE" },
{ SOLAREDGE_COMMAND_RESP_MERCURY_GET_TELEM, "RESP_MERCURY_GET_TELEM" },
{ SOLAREDGE_COMMAND_RESP_MERCURY_CONTROL_TEST, "RESP_MERCURY_CONTROL_TEST" },
{ SOLAREDGE_COMMAND_VENUSMNGR_READ_ISE_MEAS1, "VENUSMNGR_READ_ISE_MEAS1" },
{ SOLAREDGE_COMMAND_VENUSMNGR_READ_ISE_MEAS2, "VENUSMNGR_READ_ISE_MEAS2" },
{ SOLAREDGE_COMMAND_VENUSMNGR_READ_SE_MEAS, "VENUSMNGR_READ_SE_MEAS" },
{ SOLAREDGE_COMMAND_VENUSMNGR_START_INVERTER, "VENUSMNGR_START_INVERTER" },
{ SOLAREDGE_COMMAND_VENUSMNGR_ISE_DUTY_CYCLE, "VENUSMNGR_ISE_DUTY_CYCLE" },
{ SOLAREDGE_COMMAND_VENUSMNGR_GET_SYS_STATUS, "VENUSMNGR_GET_SYS_STATUS" },
{ SOLAREDGE_COMMAND_VENUSMNGR_GET_TELEM, "VENUSMNGR_GET_TELEM" },
{ SOLAREDGE_COMMAND_VENUSMNGR_RX_TEST_INIT, "VENUSMNGR_RX_TEST_INIT" },
{ SOLAREDGE_COMMAND_VENUSMNGR_RX_TEST, "VENUSMNGR_RX_TEST" },
{ SOLAREDGE_COMMAND_VENUSMNGR_TX_TEST_START, "VENUSMNGR_TX_TEST_START" },
{ SOLAREDGE_COMMAND_VENUSMNGR_TX_TEST_STOP, "VENUSMNGR_TX_TEST_STOP" },
{ SOLAREDGE_COMMAND_VENUSMNGR_SET_TX_ENABLE, "VENUSMNGR_SET_TX_ENABLE" },
{ SOLAREDGE_COMMAND_VENUSMNGR_ENABLE_ISE_WD, "VENUSMNGR_ENABLE_ISE_WD" },
{ SOLAREDGE_COMMAND_VENUSMNGR_DISABLE_ISE_WD, "VENUSMNGR_DISABLE_ISE_WD" },
{ SOLAREDGE_COMMAND_VENUSMNGR_GET_COUNTRY_CODE, "VENUSMNGR_GET_COUNTRY_CODE" },
{ SOLAREDGE_COMMAND_VENUSMNGR_SET_COUNTRY, "VENUSMNGR_SET_COUNTRY" },
{ SOLAREDGE_COMMAND_VENUSMNGR_PRIVILEGED_MODE, "VENUSMNGR_PRIVILEGED_MODE" },
{ SOLAREDGE_COMMAND_VENUSMNGR_PRIVILEGED_SET_PARAM, "VENUSMNGR_PRIVILEGED_SET_PARAM" },
{ SOLAREDGE_COMMAND_VENUSMNGR_PRIVILEGED_GET_EVENT, "VENUSMNGR_PRIVILEGED_GET_EVENT" },
{ SOLAREDGE_COMMAND_VENUSMNGR_PRIVILEGED_GET_STATUS, "VENUSMNGR_PRIVILEGED_GET_STATUS" },
{ SOLAREDGE_COMMAND_VENUSMNGR_CURRENT_MODEM_START, "VENUSMNGR_CURRENT_MODEM_START" },
{ SOLAREDGE_COMMAND_VENUSMNGR_CURRENT_MODEM_SEND, "VENUSMNGR_CURRENT_MODEM_SEND" },
{ SOLAREDGE_COMMAND_VENUSMNGR_CURRENT_MODEM_SEND_PAIRING, "VENUSMNGR_CURRENT_MODEM_SEND_PAIRING" },
{ SOLAREDGE_COMMAND_VENUSMNGR_CURRENT_MODEM_GET_STATUS, "VENUSMNGR_CURRENT_MODEM_GET_STATUS" },
{ SOLAREDGE_COMMAND_VENUSMNGR_KA_DATA_SEND, "VENUSMNGR_KA_DATA_SEND" },
{ SOLAREDGE_COMMAND_VENUSMNGR_CURRENT_MODEM_END_PAIRING, "VENUSMNGR_CURRENT_MODEM_END_PAIRING" },
{ SOLAREDGE_COMMAND_VENUSMNGR_FORCE_GRID_MON, "VENUSMNGR_FORCE_GRID_MON" },
{ SOLAREDGE_COMMAND_VENUSMNGR_FORCE_SKIP_GRID_MON, "VENUSMNGR_FORCE_SKIP_GRID_MON" },
{ SOLAREDGE_COMMAND_VENUSMNGR_START_SUPERVISE, "VENUSMNGR_START_SUPERVISE" },
{ SOLAREDGE_COMMAND_VENUSMNGR_READ_A2D_MEAS, "VENUSMNGR_READ_A2D_MEAS" },
{ SOLAREDGE_COMMAND_VENUSMNGR_GET_COUNTRY_DEFAULTS, "VENUSMNGR_GET_COUNTRY_DEFAULTS" },
{ SOLAREDGE_COMMAND_VENUSMNGR_SET_PRODUCT_MODEL, "VENUSMNGR_SET_PRODUCT_MODEL" },
{ SOLAREDGE_COMMAND_VENUSMNGR_GET_PRODUCT_MODEL, "VENUSMNGR_GET_PRODUCT_MODEL" },
{ SOLAREDGE_COMMAND_VENUSMNGR_SET_DYNAMIC_INVPWR_PARAM, "VENUSMNGR_SET_DYNAMIC_INVPWR_PARAM" },
{ SOLAREDGE_COMMAND_INVERTER_ENTER_BURN_INVPWR_MODE, "INVERTER_ENTER_BURN_INVPWR_MODE" },
{ SOLAREDGE_COMMAND_VENUSMNGR_MPPT_TRAVEL, "VENUSMNGR_MPPT_TRAVEL" },
{ SOLAREDGE_COMMAND_VENUSMNGR_SET_PWR_PARAM, "VENUSMNGR_SET_PWR_PARAM" },
{ SOLAREDGE_COMMAND_INVERTER_CURRENT_MODEM_SET_DATA_BIT, "INVERTER_CURRENT_MODEM_SET_DATA_BIT" },
{ SOLAREDGE_COMMAND_RESP_VENUSMNGR_READ_ISE_MEAS1, "RESP_VENUSMNGR_READ_ISE_MEAS1" },
{ SOLAREDGE_COMMAND_RESP_VENUSMNGR_READ_ISE_MEAS2, "RESP_VENUSMNGR_READ_ISE_MEAS2" },
{ SOLAREDGE_COMMAND_RESP_VENUSMNGR_READ_SE_MEAS, "RESP_VENUSMNGR_READ_SE_MEAS" },
{ SOLAREDGE_COMMAND_RESP_VENUSMNGR_GET_SYS_STATUS, "RESP_VENUSMNGR_GET_SYS_STATUS" },
{ SOLAREDGE_COMMAND_RESP_VENUSMNGR_GET_TELEM, "RESP_VENUSMNGR_GET_TELEM" },
{ SOLAREDGE_COMMAND_RESP_VENUSMNGR_RX_TEST, "RESP_VENUSMNGR_RX_TEST" },
{ SOLAREDGE_COMMAND_RESP_VENUSMNGR_GET_COUNTRY_CODE, "RESP_VENUSMNGR_GET_COUNTRY_CODE" },
{ SOLAREDGE_COMMAND_RESP_VENUSMNGR_PRIVILEGED_GET_EVENT, "RESP_VENUSMNGR_PRIVILEGED_GET_EVENT" },
{ SOLAREDGE_COMMAND_RESP_VENUSMNGR_PRIVILEGED_GET_STATUS, "RESP_VENUSMNGR_PRIVILEGED_GET_STATUS" },
{ SOLAREDGE_COMMAND_RESP_VENUSMNGR_CURRENT_MODEM_GET_STATUS, "RESP_VENUSMNGR_CURRENT_MODEM_GET_STATUS" },
{ SOLAREDGE_COMMAND_RESP_VENUSMNGR_READ_A2D_MEAS, "RESP_VENUSMNGR_READ_A2D_MEAS" },
{ SOLAREDGE_COMMAND_RESP_VENUSMNGR_GET_COUNTRY_DEFAULTS, "RESP_VENUSMNGR_GET_COUNTRY_DEFAULTS" },
{ SOLAREDGE_COMMAND_RESP_VENUSMNGR_GET_PRODUCT_MODEL, "RESP_VENUSMNGR_GET_PRODUCT_MODEL" },
{ SOLAREDGE_COMMAND_RESP_VENUSMNGR_SET_DYNAMIC_ISE_PARAM, "RESP_VENUSMNGR_SET_DYNAMIC_ISE_PARAM" },
{ SOLAREDGE_COMMAND_POLESTAR_TELEMS_START, "POLESTAR_TELEMS_START" },
{ SOLAREDGE_COMMAND_POLESTAR_TELEMS_STOP, "POLESTAR_TELEMS_STOP" },
{ SOLAREDGE_COMMAND_POLESTAR_MASTER_GRANT, "POLESTAR_MASTER_GRANT" },
{ SOLAREDGE_COMMAND_POLESTAR_RTC_SET, "POLESTAR_RTC_SET" },
{ SOLAREDGE_COMMAND_POLESTAR_TEST_RAM, "POLESTAR_TEST_RAM" },
{ SOLAREDGE_COMMAND_POLESTAR_TEST_FLASH, "POLESTAR_TEST_FLASH" },
{ SOLAREDGE_COMMAND_POLESTAR_MAC_ADDR_GET, "POLESTAR_MAC_ADDR_GET" },
{ SOLAREDGE_COMMAND_POLESTAR_IP_ADDR_GET, "POLESTAR_IP_ADDR_GET" },
{ SOLAREDGE_COMMAND_POLESTAR_SLAVE_ID_DETECT_INIT, "POLESTAR_SLAVE_ID_DETECT_INIT" },
{ SOLAREDGE_COMMAND_POLESTAR_SLAVE_ID_DETECT_GET_ID, "POLESTAR_SLAVE_ID_DETECT_GET_ID" },
{ SOLAREDGE_COMMAND_POLESTAR_SLAVE_ID_DETECT_STOP, "POLESTAR_SLAVE_ID_DETECT_STOP" },
{ SOLAREDGE_COMMAND_POLESTAR_UART_ZB_BRIDGE, "POLESTAR_UART_ZB_BRIDGE" },
{ SOLAREDGE_COMMAND_POLESTAR_SEND_PING, "POLESTAR_SEND_PING" },
{ SOLAREDGE_COMMAND_POLESTAR_LCD_TEST_MODE, "POLESTAR_LCD_TEST_MODE" },
{ SOLAREDGE_COMMAND_POLESTAR_CONFTOOL_START, "POLESTAR_CONFTOOL_START" },
{ SOLAREDGE_COMMAND_POLESTAR_ETHERNET_STAT, "POLESTAR_ETHERNET_STAT" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_FIFO_FLASH_INFO, "POLESTAR_GET_FIFO_FLASH_INFO" },
{ SOLAREDGE_COMMAND_POLESTAR_RESET_FIFO_FLASH, "POLESTAR_RESET_FIFO_FLASH" },
{ SOLAREDGE_COMMAND_POLESTAR_RESET_FLASH, "POLESTAR_RESET_FLASH" },
{ SOLAREDGE_COMMAND_POLESTAR_RS485_MSTR_SLV_DET_START, "POLESTAR_RS485_MSTR_SLV_DET_START" },
{ SOLAREDGE_COMMAND_POLESTAR_RS485_MSTR_SLV_DET_STATUS, "POLESTAR_RS485_MSTR_SLV_DET_STATUS" },
{ SOLAREDGE_COMMAND_POLESTAR_UART_ZB_SET, "POLESTAR_UART_ZB_SET" },
{ SOLAREDGE_COMMAND_POLESTAR_TCP_TEST, "POLESTAR_TCP_TEST" },
{ SOLAREDGE_COMMAND_POLESTAR_TIMER_ADVANCE, "POLESTAR_TIMER_ADVANCE" },
{ SOLAREDGE_COMMAND_POLESTAR_ERASE_FLASH_FIFO_FAST, "POLESTAR_ERASE_FLASH_FIFO_FAST" },
{ SOLAREDGE_COMMAND_POLESTAR_SELF_KA, "POLESTAR_SELF_KA" },
{ SOLAREDGE_COMMAND_POLESTAR_ISE_BRIDGE, "POLESTAR_ISE_BRIDGE" },
{ SOLAREDGE_COMMAND_POLESTAR_ERASE_STATISTICS, "POLESTAR_ERASE_STATISTICS" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_POK_STATUS, "POLESTAR_GET_POK_STATUS" },
{ SOLAREDGE_COMMAND_POLESTAR_INVERTER_HW_RESET, "POLESTAR_INVERTER_HW_RESET" },
{ SOLAREDGE_COMMAND_POLESTAR_ZB_PRESENT_STATUS, "POLESTAR_ZB_PRESENT_STATUS" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_ALL_SUPPORTED_LANGUAGES_INDEXES, "POLESTAR_GET_ALL_SUPPORTED_LANGUAGES_INDEXES" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_ALL_SUPPORTED_GSM_MODEMS_INDEXES, "POLESTAR_GET_ALL_SUPPORTED_GSM_MODEMS_INDEXES" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_S_OK_STATUS, "POLESTAR_GET_S_OK_STATUS" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_ENERGY_STATISTICS_STATUS, "POLESTAR_GET_ENERGY_STATISTICS_STATUS" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_GSM_PRESENT_STATUS, "POLESTAR_GET_GSM_PRESENT_STATUS" },
{ SOLAREDGE_COMMAND_POLESTAR_SET_STATISTICS_ELEMENT, "POLESTAR_SET_STATISTICS_ELEMENT" },
{ SOLAREDGE_COMMAND_POLESTAR_GEMINI_RS485_MSTR_SLV_DET_START, "POLESTAR_GEMINI_RS485_MSTR_SLV_DET_START" },
{ SOLAREDGE_COMMAND_POLESTAR_GEMINI_RS485_MSTR_SLV_DET_STATUS, "POLESTAR_GEMINI_RS485_MSTR_SLV_DET_STATUS" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_GEMINI_GFD_STATUS, "POLESTAR_GET_GEMINI_GFD_STATUS" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_ERROR_LOG, "POLESTAR_GET_ERROR_LOG" },
{ SOLAREDGE_COMMAND_POLESTAR_BLOCK_SERVER_CONTROL, "POLESTAR_BLOCK_SERVER_CONTROL" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_SERVER_CONTROL_STATUS, "POLESTAR_GET_SERVER_CONTROL_STATUS" },
{ SOLAREDGE_COMMAND_POLESTAR_TEST_SD_FLASH, "POLESTAR_TEST_SD_FLASH" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_WARNING_LOG, "POLESTAR_GET_WARNING_LOG" },
{ SOLAREDGE_COMMAND_POLESTAR_RESET_MODBUS_DEVICE_DATA, "POLESTAR_RESET_MODBUS_DEVICE_DATA" },
{ SOLAREDGE_COMMAND_POLESTAR_TURN_OFF_INTERNAL_SRAM_BATTERY_BACKUP, "POLESTAR_TURN_OFF_INTERNAL_SRAM_BATTERY_BACKUP" },
{ SOLAREDGE_COMMAND_POLESTAR_WRITE_LCD, "POLESTAR_WRITE_LCD" },
{ SOLAREDGE_COMMAND_POLESTAR_READ_LAST_BUTTONS, "POLESTAR_READ_LAST_BUTTONS" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_STATISTICS_ELEMENT, "POLESTAR_GET_STATISTICS_ELEMENT" },
{ SOLAREDGE_COMMAND_POLESTAR_SEND_POWER_REDUCER_SLAVE_PACKET, "POLESTAR_SEND_POWER_REDUCER_SLAVE_PACKET" },
{ SOLAREDGE_COMMAND_POLESTAR_SEND_POWER_REDUCER_MASTER_PACKET, "POLESTAR_SEND_POWER_REDUCER_MASTER_PACKET" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_WIFI_PRESENT_STATUS, "POLESTAR_GET_WIFI_PRESENT_STATUS" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_PORT_EXPANDER_GPIO_DATA, "POLESTAR_GET_PORT_EXPANDER_GPIO_DATA" },
{ SOLAREDGE_COMMAND_POLESTAR_SET_PORT_EXPANDER_GPIO_DATA, "POLESTAR_SET_PORT_EXPANDER_GPIO_DATA" },
{ SOLAREDGE_COMMAND_POLESTAR_READ_LCD, "POLESTAR_READ_LCD" },
{ SOLAREDGE_COMMAND_POLESTAR_SIMULATE_BUTTON_PRESSING, "POLESTAR_SIMULATE_BUTTON_PRESSING" },
{ SOLAREDGE_COMMAND_POLESTAR_INV_ACTIVATE, "POLESTAR_INV_ACTIVATE" },
{ SOLAREDGE_COMMAND_POLESTAR_MODBUS_SLAVE_PACKET, "POLESTAR_MODBUS_SLAVE_PACKET" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_BUTTON_STATE, "POLESTAR_GET_BUTTON_STATE" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_A2D_VALS, "POLESTAR_GET_A2D_VALS" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_OPMODE, "POLESTAR_GET_OPMODE" },
{ SOLAREDGE_COMMAND_POLESTAR_SET_BACKLIGHT, "POLESTAR_SET_BACKLIGHT" },
{ SOLAREDGE_COMMAND_POLESTAR_READ_FIFO_PAGE, "POLESTAR_READ_FIFO_PAGE" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_CURRENT_SCREEN_INDEX, "POLESTAR_GET_CURRENT_SCREEN_INDEX" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_IDENTITY, "POLESTAR_GET_IDENTITY" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_SUPPORTED_COMMANDS, "POLESTAR_GET_SUPPORTED_COMMANDS" },
{ SOLAREDGE_COMMAND_POLESTAR_PAIRING_START, "POLESTAR_PAIRING_START" },
{ SOLAREDGE_COMMAND_POLESTAR_PAIRING_STATUS, "POLESTAR_PAIRING_STATUS" },
{ SOLAREDGE_COMMAND_POLESTAR_PRODUCT_RESET, "POLESTAR_PRODUCT_RESET" },
{ SOLAREDGE_COMMAND_POLESTAR_PLC_CMD_EXECUTE, "POLESTAR_PLC_CMD_EXECUTE" },
{ SOLAREDGE_COMMAND_POLESTAR_GET_STATUS, "POLESTAR_GET_STATUS" },
{ SOLAREDGE_COMMAND_POLESTAR_FIRE_SAFETY_LOCK_MASTER, "POLESTAR_FIRE_SAFETY_LOCK_MASTER" },
{ SOLAREDGE_COMMAND_POLESTAR_FIRE_SAFETY_LOCK_SLAVE, "POLESTAR_FIRE_SAFETY_LOCK_SLAVE" },
{ SOLAREDGE_COMMAND_POLESTAR_FIRE_SAFETY_REPORT, "POLESTAR_FIRE_SAFETY_REPORT" },
{ SOLAREDGE_COMMAND_POLESTAR_UART_BRIDGE_INIT, "POLESTAR_UART_BRIDGE_INIT" },
{ SOLAREDGE_COMMAND_POLESTAR_SEND_UART_DATA, "POLESTAR_SEND_UART_DATA" },
{ SOLAREDGE_COMMAND_POLESTAR_LED_TEST, "POLESTAR_LED_TEST" },
{ SOLAREDGE_COMMAND_POLESTAR_SEND_FAKE_TELEMS, "POLESTAR_SEND_FAKE_TELEMS" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_RTC_SET, "RESP_POLESTAR_RTC_SET" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_MAC_ADDR_GET, "RESP_POLESTAR_MAC_ADDR_GET" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_IP_ADDR_GET, "RESP_POLESTAR_IP_ADDR_GET" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_SEND_PING, "RESP_POLESTAR_SEND_PING" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_ETHERNET_STAT, "RESP_POLESTAR_ETHERNET_STAT" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_FIFO_FLASH_INFO, "RESP_POLESTAR_GET_FIFO_FLASH_INFO" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_RS485_MSTR_SLV_DET_STATUS, "RESP_POLESTAR_RS485_MSTR_SLV_DET_STATUS" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_TCP_TEST_RESP, "RESP_POLESTAR_TCP_TEST_RESP" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_POK_STATUS, "RESP_POLESTAR_GET_POK_STATUS" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_INVERTER_HW_RESET, "RESP_POLESTAR_INVERTER_HW_RESET" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_ALL_SUPPORTED_LANGUAGES_INDEXES, "RESP_POLESTAR_GET_ALL_SUPPORTED_LANGUAGES_INDEXES" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_ALL_SUPPORTED_GSM_MODEMS_INDEXES, "RESP_POLESTAR_GET_ALL_SUPPORTED_GSM_MODEMS_INDEXES" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_S_OK_STATUS, "RESP_POLESTAR_GET_S_OK_STATUS" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_ENERGY_STATISTICS_STATUS, "RESP_POLESTAR_GET_ENERGY_STATISTICS_STATUS" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_GSM_PRESENT_STATUS, "RESP_POLESTAR_GET_GSM_PRESENT_STATUS" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GEMINI_RS485_MSTR_SLV_DET_STATUS, "RESP_POLESTAR_GEMINI_RS485_MSTR_SLV_DET_STATUS" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_GEMINI_GFD_STATUS, "RESP_POLESTAR_GET_GEMINI_GFD_STATUS" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_ERROR_LOG, "RESP_POLESTAR_GET_ERROR_LOG" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_SERVER_CONTROL_STATUS, "RESP_POLESTAR_GET_SERVER_CONTROL_STATUS" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_WARNING_LOG, "RESP_POLESTAR_GET_WARNING_LOG" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_READ_LAST_BUTTONS, "RESP_POLESTAR_READ_LAST_BUTTONS" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_STATISTICS_ELEMENT, "RESP_POLESTAR_GET_STATISTICS_ELEMENT" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_WIFI_PRESENT_STATUS, "RESP_POLESTAR_GET_WIFI_PRESENT_STATUS" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_PORT_EXPANDER_GPIO_DATA, "RESP_POLESTAR_GET_PORT_EXPANDER_GPIO_DATA" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_READ_LCD, "RESP_POLESTAR_READ_LCD" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_MODBUS_SLAVE_PACKET, "RESP_POLESTAR_MODBUS_SLAVE_PACKET" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_MASTER_GRANT_ACK, "RESP_POLESTAR_MASTER_GRANT_ACK" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_IDENTITY, "RESP_POLESTAR_GET_IDENTITY" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_SUPPORTED_COMMANDS, "RESP_POLESTAR_GET_SUPPORTED_COMMANDS" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_PAIRING_START, "RESP_POLESTAR_PAIRING_START" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_PAIRING_STATUS, "RESP_POLESTAR_PAIRING_STATUS" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_GET_STATUS, "RESP_POLESTAR_GET_STATUS" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_FIRE_SAFETY_REPORT, "RESP_POLESTAR_FIRE_SAFETY_REPORT" },
{ SOLAREDGE_COMMAND_RESP_POLESTAR_SEND_UART_DATA, "RESP_POLESTAR_SEND_UART_DATA" },
{ SOLAREDGE_COMMAND_SUNTRACER_READ_FLASH, "SUNTRACER_READ_FLASH" },
{ SOLAREDGE_COMMAND_SUNTRACER_START, "SUNTRACER_START" },
{ SOLAREDGE_COMMAND_SUNTRACER_SET_RTC, "SUNTRACER_SET_RTC" },
{ SOLAREDGE_COMMAND_SUNTRACER_DEL_FLASH, "SUNTRACER_DEL_FLASH" },
{ SOLAREDGE_COMMAND_SUNTRACER_DEL_FLASH_SECTOR, "SUNTRACER_DEL_FLASH_SECTOR" },
{ SOLAREDGE_COMMAND_RESP_SUNTRACER_TRACE, "RESP_SUNTRACER_TRACE" },
{ SOLAREDGE_COMMAND_RESP_SUNTRACER_FLASH, "RESP_SUNTRACER_FLASH" },
{ SOLAREDGE_COMMAND_SERVER_POST_DATA, "SERVER_POST_DATA" },
{ SOLAREDGE_COMMAND_SERVER_GET_GMT, "SERVER_GET_GMT" },
{ SOLAREDGE_COMMAND_SERVER_GET_NAME, "SERVER_GET_NAME" },
{ SOLAREDGE_COMMAND_SERVER_SET_KEY, "SERVER_SET_KEY" },
{ SOLAREDGE_COMMAND_RESP_SERVER_GMT, "RESP_SERVER_GMT" },
{ SOLAREDGE_COMMAND_RESP_SERVER_NAME, "RESP_SERVER_NAME" },
{ SOLAREDGE_COMMAND_RESP_CONFTOOL_PLC_DATA, "RESP_CONFTOOL_PLC_DATA" },
{ SOLAREDGE_COMMAND_JUPMNGR_READ_JUPPWR_MEAS1, "JUPMNGR_READ_JUPPWR_MEAS1" },
{ SOLAREDGE_COMMAND_JUPMNGR_READ_JUPPWR_MEAS2, "JUPMNGR_READ_JUPPWR_MEAS2" },
{ SOLAREDGE_COMMAND_JUPMNGR_READ_JUPPWR_MEAS3, "JUPMNGR_READ_JUPPWR_MEAS3" },
{ SOLAREDGE_COMMAND_JUPMNGR_READ_JUPPWR_MEAS4, "JUPMNGR_READ_JUPPWR_MEAS4" },
{ SOLAREDGE_COMMAND_JUPMNGR_READ_JUPPWR_MEAS5, "JUPMNGR_READ_JUPPWR_MEAS5" },
{ SOLAREDGE_COMMAND_JUPMNGR_READ_MEAS, "JUPMNGR_READ_MEAS" },
{ SOLAREDGE_COMMAND_JUPMNGR_GET_SYS_STATUS, "JUPMNGR_GET_SYS_STATUS" },
{ SOLAREDGE_COMMAND_JUPMNGR_GET_TELEM, "JUPMNGR_GET_TELEM" },
{ SOLAREDGE_COMMAND_JUPMNGR_GET_COUNTRY_CODE, "JUPMNGR_GET_COUNTRY_CODE" },
{ SOLAREDGE_COMMAND_JUPMNGR_SET_COUNTRY, "JUPMNGR_SET_COUNTRY" },
{ SOLAREDGE_COMMAND_JUPMNGR_GET_COUNTRY_DEFAULTS, "JUPMNGR_GET_COUNTRY_DEFAULTS" },
{ SOLAREDGE_COMMAND_JUPMNGR_PRIVILEGED_MODE, "JUPMNGR_PRIVILEGED_MODE" },
{ SOLAREDGE_COMMAND_JUPMNGR_PRIVILEGED_SET_PARAM, "JUPMNGR_PRIVILEGED_SET_PARAM" },
{ SOLAREDGE_COMMAND_JUPMNGR_PRIVILEGED_GET_EVENT, "JUPMNGR_PRIVILEGED_GET_EVENT" },
{ SOLAREDGE_COMMAND_JUPMNGR_PRIVILEGED_GET_STATUS, "JUPMNGR_PRIVILEGED_GET_STATUS" },
{ SOLAREDGE_COMMAND_JUPMNGR_SET_PRODUCT_MODEL, "JUPMNGR_SET_PRODUCT_MODEL" },
{ SOLAREDGE_COMMAND_JUPMNGR_GET_PRODUCT_MODEL, "JUPMNGR_GET_PRODUCT_MODEL" },
{ SOLAREDGE_COMMAND_JUPMNGR_DYNAMIC_SET_INVPWR_PARAM, "JUPMNGR_DYNAMIC_SET_INVPWR_PARAM" },
{ SOLAREDGE_COMMAND_JUPMNGR_GET_INVPWR_PARAM_TYPE, "JUPMNGR_GET_INVPWR_PARAM_TYPE" },
{ SOLAREDGE_COMMAND_JUPMNGR_GET_FANS_STATUS, "JUPMNGR_GET_FANS_STATUS" },
{ SOLAREDGE_COMMAND_RESP_JUPMNGR_READ_JUPPWR_MEAS1, "RESP_JUPMNGR_READ_JUPPWR_MEAS1" },
{ SOLAREDGE_COMMAND_RESP_JUPMNGR_READ_JUPPWR_MEAS2, "RESP_JUPMNGR_READ_JUPPWR_MEAS2" },
{ SOLAREDGE_COMMAND_RESP_JUPMNGR_READ_JUPPWR_MEAS3, "RESP_JUPMNGR_READ_JUPPWR_MEAS3" },
{ SOLAREDGE_COMMAND_RESP_JUPMNGR_READ_JUPPWR_MEAS4, "RESP_JUPMNGR_READ_JUPPWR_MEAS4" },
{ SOLAREDGE_COMMAND_RESP_JUPMNGR_READ_JUPPWR_MEAS5, "RESP_JUPMNGR_READ_JUPPWR_MEAS5" },
{ SOLAREDGE_COMMAND_RESP_JUPMNGR_READ_MEAS, "RESP_JUPMNGR_READ_MEAS" },
{ SOLAREDGE_COMMAND_RESP_JUPMNGR_GET_SYS_STATUS, "RESP_JUPMNGR_GET_SYS_STATUS" },
{ SOLAREDGE_COMMAND_RESP_JUPMNGR_GET_TELEM, "RESP_JUPMNGR_GET_TELEM" },
{ SOLAREDGE_COMMAND_RESP_JUPMNGR_GET_COUNTRY_CODE, "RESP_JUPMNGR_GET_COUNTRY_CODE" },
{ SOLAREDGE_COMMAND_RESP_JUPMNGR_GET_COUNTRY_DEFAULTS, "RESP_JUPMNGR_GET_COUNTRY_DEFAULTS" },
{ SOLAREDGE_COMMAND_RESP_JUPMNGR_PRIVILEGED_GET_EVENT, "RESP_JUPMNGR_PRIVILEGED_GET_EVENT" },
{ SOLAREDGE_COMMAND_RESP_JUPMNGR_PRIVILEGED_GET_STATUS, "RESP_JUPMNGR_PRIVILEGED_GET_STATUS" },
{ SOLAREDGE_COMMAND_RESP_JUPMNGR_GET_PRODUCT_MODEL, "RESP_JUPMNGR_GET_PRODUCT_MODEL" },
{ SOLAREDGE_COMMAND_RESP_JUPMNGR_GET_INVPWR_PARAM_TYPE, "RESP_JUPMNGR_GET_INVPWR_PARAM_TYPE" },
{ SOLAREDGE_COMMAND_RESP_JUPMNGR_GET_FANS_STATUS, "RESP_JUPMNGR_GET_FANS_STATUS" },
{ SOLAREDGE_COMMAND_INVERTER_TURN_15V_ON, "INVERTER_TURN_15V_ON" },
{ SOLAREDGE_COMMAND_INVERTER_TURN_15V_OFF, "INVERTER_TURN_15V_OFF" },
{ SOLAREDGE_COMMAND_INVERTER_ENABLE_RELAYS, "INVERTER_ENABLE_RELAYS" },
{ SOLAREDGE_COMMAND_INVERTER_DISABLE_RELAYS, "INVERTER_DISABLE_RELAYS" },
{ SOLAREDGE_COMMAND_INVERTER_DYNAMIC_POWER_LIMIT, "INVERTER_DYNAMIC_POWER_LIMIT" },
{ SOLAREDGE_COMMAND_INVERTER_IVTRACE_START, "INVERTER_IVTRACE_START" },
{ SOLAREDGE_COMMAND_INVERTER_GRID_TRIP_TEST, "INVERTER_GRID_TRIP_TEST" },
{ SOLAREDGE_COMMAND_INVERTER_SET_LMVGC_PARAMS1, "INVERTER_SET_LMVGC_PARAMS1" },
{ SOLAREDGE_COMMAND_INVERTER_GET_LMVGC_PARAMS1, "INVERTER_GET_LMVGC_PARAMS1" },
{ SOLAREDGE_COMMAND_INVERTER_SET_PWR_GAIN_PARAMS, "INVERTER_SET_PWR_GAIN_PARAMS" },
{ SOLAREDGE_COMMAND_INVERTER_SET_LMVGC_PARAMS2, "INVERTER_SET_LMVGC_PARAMS2" },
{ SOLAREDGE_COMMAND_INVERTER_GET_LMVGC_PARAMS2, "INVERTER_GET_LMVGC_PARAMS2" },
{ SOLAREDGE_COMMAND_INVERTER_SET_LMVGC_PARAMS3, "INVERTER_SET_LMVGC_PARAMS3" },
{ SOLAREDGE_COMMAND_INVERTER_GET_LMVGC_PARAMS3, "INVERTER_GET_LMVGC_PARAMS3" },
{ SOLAREDGE_COMMAND_INVERTER_LOCK_IN, "INVERTER_LOCK_IN" },
{ SOLAREDGE_COMMAND_INVERTER_LOCK_OUT, "INVERTER_LOCK_OUT" },
{ SOLAREDGE_COMMAND_INVERTER_GET_VDC, "INVERTER_GET_VDC" },
{ SOLAREDGE_COMMAND_INVERTER_PAIRING_DO_NOTHING, "INVERTER_PAIRING_DO_NOTHING" },
{ SOLAREDGE_COMMAND_INVERTER_PAIRING_DO_SAFETY, "INVERTER_PAIRING_DO_SAFETY" },
{ SOLAREDGE_COMMAND_RESP_INVERTER_DYNAMIC_POWER_LIMIT, "RESP_INVERTER_DYNAMIC_POWER_LIMIT" },
{ SOLAREDGE_COMMAND_RESP_INVERTER_GET_LMVGC_PARAMS, "RESP_INVERTER_GET_LMVGC_PARAMS" },
{ SOLAREDGE_COMMAND_VEGA_READ_MEAS, "VEGA_READ_MEAS" },
{ SOLAREDGE_COMMAND_VEGA_GET_SYS_STATUS, "VEGA_GET_SYS_STATUS" },
{ SOLAREDGE_COMMAND_VEGA_GET_TELEM, "VEGA_GET_TELEM" },
{ SOLAREDGE_COMMAND_VEGA_GET_MAX_VDC_VALUE, "VEGA_GET_MAX_VDC_VALUE" },
{ SOLAREDGE_COMMAND_VEGA_SET_MAX_VDC_VALUE, "VEGA_SET_MAX_VDC_VALUE" },
{ SOLAREDGE_COMMAND_VEGA_RELAY_SET, "VEGA_RELAY_SET" },
{ SOLAREDGE_COMMAND_VEGA_SET_OPMODE, "VEGA_SET_OPMODE" },
{ SOLAREDGE_COMMAND_VEGA_GET_OPMODE, "VEGA_GET_OPMODE" },
{ SOLAREDGE_COMMAND_VEGA_SET_RANGE, "VEGA_SET_RANGE" },
{ SOLAREDGE_COMMAND_RESP_VEGA_READ_MEAS, "RESP_VEGA_READ_MEAS" },
{ SOLAREDGE_COMMAND_RESP_VEGA_GET_SYS_STATUS, "RESP_VEGA_GET_SYS_STATUS" },
{ SOLAREDGE_COMMAND_RESP_VEGA_GET_TELEM, "RESP_VEGA_GET_TELEM" },
{ SOLAREDGE_COMMAND_RESP_VEGA_GET_MAX_VDC_VALUE, "RESP_VEGA_GET_MAX_VDC_VALUE" },
{ SOLAREDGE_COMMAND_COMBI_PAUSE_MONITORING, "COMBI_PAUSE_MONITORING" },
{ SOLAREDGE_COMMAND_COMBI_SET_TIME_STAMP, "COMBI_SET_TIME_STAMP" },
{ SOLAREDGE_COMMAND_COMBI_RCD_CALIBRATION, "COMBI_RCD_CALIBRATION" },
{ SOLAREDGE_COMMAND_COMBI_GET_TELEM, "COMBI_GET_TELEM" },
{ SOLAREDGE_COMMAND_COMBI_FORCE_TELEM, "COMBI_FORCE_TELEM" },
{ SOLAREDGE_COMMAND_COMBI_SWITCHES_CONNECT, "COMBI_SWITCHES_CONNECT" },
{ SOLAREDGE_COMMAND_COMBI_SWITCHES_DISCONNECT, "COMBI_SWITCHES_DISCONNECT" },
{ SOLAREDGE_COMMAND_COMBI_SWITCHES_CONNECT_ALL, "COMBI_SWITCHES_CONNECT_ALL" },
{ SOLAREDGE_COMMAND_COMBI_SWITCHES_DISCONNECT_ALL, "COMBI_SWITCHES_DISCONNECT_ALL" },
{ SOLAREDGE_COMMAND_COMBI_RCD_TEST_EXECUTE, "COMBI_RCD_TEST_EXECUTE" },
{ SOLAREDGE_COMMAND_COMBI_RELAYS_TEST_EXECUTE, "COMBI_RELAYS_TEST_EXECUTE" },
{ SOLAREDGE_COMMAND_COMBI_GET_COMBISTRING_PARAM, "COMBI_GET_COMBISTRING_PARAM" },
{ SOLAREDGE_COMMAND_COMBI_SET_COMBISTRING_PARAM, "COMBI_SET_COMBISTRING_PARAM" },
{ SOLAREDGE_COMMAND_COMBI_GET_ALL_COMBISTRING_PARAMS, "COMBI_GET_ALL_COMBISTRING_PARAMS" },
{ SOLAREDGE_COMMAND_COMBI_GET_ALL_COMBI_PARAMS, "COMBI_GET_ALL_COMBI_PARAMS" },
{ SOLAREDGE_COMMAND_COMBI_READ_MEASUREMENTS, "COMBI_READ_MEASUREMENTS" },
{ SOLAREDGE_COMMAND_COMBI_GET_STRING_STATUS, "COMBI_GET_STRING_STATUS" },
{ SOLAREDGE_COMMAND_COMBI_GET_COMBI_STATUS, "COMBI_GET_COMBI_STATUS" },
{ SOLAREDGE_COMMAND_COMBI_GET_ACTIVE_STRINGS, "COMBI_GET_ACTIVE_STRINGS" },
{ SOLAREDGE_COMMAND_COMBI_FWD_STRING_TELEM, "COMBI_FWD_STRING_TELEM" },
{ SOLAREDGE_COMMAND_COMBI_FWD_COMBI_TELEM, "COMBI_FWD_COMBI_TELEM" },
{ SOLAREDGE_COMMAND_COMBI_GET_UNIFIED_STRING_STATUS, "COMBI_GET_UNIFIED_STRING_STATUS" },
{ SOLAREDGE_COMMAND_COMBI_GET_UNIFIED_COMBI_STATUS, "COMBI_GET_UNIFIED_COMBI_STATUS" },
{ SOLAREDGE_COMMAND_COMBI_CHECK_INNER_PROTOCOL, "COMBI_CHECK_INNER_PROTOCOL" },
{ SOLAREDGE_COMMAND_COMBI_SWITCHES_CONNECT_RELAY, "COMBI_SWITCHES_CONNECT_RELAY" },
{ SOLAREDGE_COMMAND_COMBI_SWITCHES_DISCONNECT_RELAY, "COMBI_SWITCHES_DISCONNECT_RELAY" },
{ SOLAREDGE_COMMAND_COMBI_GET_GEMINI_STRING_IDS, "COMBI_GET_GEMINI_STRING_IDS" },
{ SOLAREDGE_COMMAND_COMBI_GET_ALL_SWITCHES_STATUS, "COMBI_GET_ALL_SWITCHES_STATUS" },
{ SOLAREDGE_COMMAND_COMBI_SET_RCD_TEST_PIN, "COMBI_SET_RCD_TEST_PIN" },
{ SOLAREDGE_COMMAND_COMBI_RELAYS_TEST_CHECK_CONDS, "COMBI_RELAYS_TEST_CHECK_CONDS" },
{ SOLAREDGE_COMMAND_RESP_COMBI_GET_TELEM, "RESP_COMBI_GET_TELEM" },
{ SOLAREDGE_COMMAND_RESP_COMBI_GET_STRING_STATUS, "RESP_COMBI_GET_STRING_STATUS" },
{ SOLAREDGE_COMMAND_RESP_COMBI_GET_COMBI_STATUS, "RESP_COMBI_GET_COMBI_STATUS" },
{ SOLAREDGE_COMMAND_RESP_COMBI_GET_ACTIVE_STRINGS, "RESP_COMBI_GET_ACTIVE_STRINGS" },
{ SOLAREDGE_COMMAND_RESP_COMBI_GET_UNIFIED_STRING_STATUS, "RESP_COMBI_GET_UNIFIED_STRING_STATUS" },
{ SOLAREDGE_COMMAND_RESP_COMBI_GET_UNIFIED_COMBI_STATUS, "RESP_COMBI_GET_UNIFIED_COMBI_STATUS" },
{ SOLAREDGE_COMMAND_RESP_COMBI_GET_GEMINI_STRING_IDS, "RESP_COMBI_GET_GEMINI_STRING_IDS" },
{ SOLAREDGE_COMMAND_INVPWR_GET_ERROR_STATUS, "INVPWR_GET_ERROR_STATUS" },
{ SOLAREDGE_COMMAND_INVPWR_GET_STATUS, "INVPWR_GET_STATUS" },
{ SOLAREDGE_COMMAND_INVPWR_GO, "INVPWR_GO" },
{ SOLAREDGE_COMMAND_INVPWR_HALT, "INVPWR_HALT" },
{ SOLAREDGE_COMMAND_INVPWR_CONST_DUTY_CYCLE, "INVPWR_CONST_DUTY_CYCLE" },
{ SOLAREDGE_COMMAND_INVPWR_DUMY_ERROR, "INVPWR_DUMY_ERROR" },
{ SOLAREDGE_COMMAND_INVPWR_PAIRING_SET_STATE, "INVPWR_PAIRING_SET_STATE" },
{ SOLAREDGE_COMMAND_INVPWR_TEST_IAC_CONTROL, "INVPWR_TEST_IAC_CONTROL" },
{ SOLAREDGE_COMMAND_RESP_INVPWR_GET_ERROR_STATUS, "RESP_INVPWR_GET_ERROR_STATUS" },
{ SOLAREDGE_COMMAND_RESP_INVPWR_GET_STATUS, "RESP_INVPWR_GET_STATUS" },
{ SOLAREDGE_COMMAND_RESP_INVPWR_GO, "RESP_INVPWR_GO" },
{ SOLAREDGE_COMMAND_RESP_INVPWR_HALT, "RESP_INVPWR_HALT" },
{ SOLAREDGE_COMMAND_RESP_INVPWR_CONST_DUTY_CYCLE, "RESP_INVPWR_CONST_DUTY_CYCLE" },
{ SOLAREDGE_COMMAND_RESP_INVPWR_DUMY_ERROR, "RESP_INVPWR_DUMY_ERROR" },
{ SOLAREDGE_COMMAND_BOOTLOADER_SECURE, "BOOTLOADER_SECURE" },
{ SOLAREDGE_COMMAND_BOOTLOADER_UNSECURE, "BOOTLOADER_UNSECURE" },
{ SOLAREDGE_COMMAND_ACTIVATOR_ACTIVATE, "ACTIVATOR_ACTIVATE" },
{ SOLAREDGE_COMMAND_ACTIVATOR_GET_ADC_SAMPLES, "ACTIVATOR_GET_ADC_SAMPLES" },
{ SOLAREDGE_COMMAND_ACTIVATOR_SET_VO_RANGE, "ACTIVATOR_SET_VO_RANGE" },
{ SOLAREDGE_COMMAND_ACTIVATOR_GET_AVG_SAMPLES, "ACTIVATOR_GET_AVG_SAMPLES" },
{ SOLAREDGE_COMMAND_ACTIVATOR_TX_TEST, "ACTIVATOR_TX_TEST" },
{ SOLAREDGE_COMMAND_ACTIVATOR_LCD_TEST, "ACTIVATOR_LCD_TEST" },
{ SOLAREDGE_COMMAND_ACTIVATOR_BUTTONS_TEST, "ACTIVATOR_BUTTONS_TEST" },
{ SOLAREDGE_COMMAND_FANCONTROL_SET_PWM, "FANCONTROL_SET_PWM" },
{ SOLAREDGE_COMMAND_FANCONTROL_GET_PWM, "FANCONTROL_GET_PWM" },
{ SOLAREDGE_COMMAND_FANCONTROL_GET_ALL_PWM, "FANCONTROL_GET_ALL_PWM" },
{ SOLAREDGE_COMMAND_FANCONTROL_SHUT_ALL_PWM, "FANCONTROL_SHUT_ALL_PWM" },
{ SOLAREDGE_COMMAND_FANCONTROL_RES, "FANCONTROL_RES" },
{ SOLAREDGE_COMMAND_DISPLAY_BOARD_LCD_WRITE, "DISPLAY_BOARD_LCD_WRITE" },
{ SOLAREDGE_COMMAND_DISPLAY_BOARD_LED_SET, "DISPLAY_BOARD_LED_SET" },
{ 0, NULL }
};
static const value_string solaredge_data_devicetypes[] = {
{ SOLAREDGE_DEVICETYPE_OPTIMIZER, "Optimizer" },
{ SOLAREDGE_DEVICETYPE_INVERTER_1PHASE, "Single phase inverter"},
{ SOLAREDGE_DEVICETYPE_INVERTER_3PHASE, "Three phase inverter"},
{ SOLAREDGE_DEVICETYPE_OPTIMIZER2, "Optimizer" },
{ SOLAREDGE_DEVICETYPE_EVENT, "Wake/sleep event" },
{ 0, NULL }
};
static gcry_cipher_hd_t cipher_hd_system;
static const gchar *global_system_encryption_key = NULL;
static
guint16 calculate_crc(t_solaredge_packet_header *header, const guint8 *data, gint length)
{
/* Concatenate in network endinaness header items followed by unmodified data */
guint16 crc = 0x5a5a;
guint16 sequence_number = g_htons(header->sequence_number);
guint32 source_address = g_htonl(header->source_address);
guint32 destination_address = g_htonl(header->destination_address);
guint16 command_type = g_htons(header->command_type);
crc = crc16_plain_update(crc, (unsigned char *)&sequence_number, 2);
crc = crc16_plain_update(crc, (unsigned char *)&source_address, 4);
crc = crc16_plain_update(crc, (unsigned char *)&destination_address, 4);
crc = crc16_plain_update(crc, (unsigned char *)&command_type, 2);
return crc16_plain_update(crc, data, length);
}
static
void solaredge_decrypt(const guint8 *in, gint length, guint8 *out, gcry_cipher_hd_t cipher)
{
guint8 rand1[SOLAREDGE_ENCRYPTION_KEY_LENGTH];
guint8 rand2[SOLAREDGE_ENCRYPTION_KEY_LENGTH];
gint payload_length = length - SOLAREDGE_ENCRYPTION_KEY_LENGTH;
guint8 *payload = (guint8 *) wmem_alloc(wmem_packet_scope(), payload_length);
guint8 *intermediate_decrypted_payload = (guint8 *) wmem_alloc(wmem_packet_scope(), payload_length);
gint i = 0, posa = 0, posb = 0, posc = 0;
memcpy(rand2, in, SOLAREDGE_ENCRYPTION_KEY_LENGTH);
memcpy(payload, in + SOLAREDGE_ENCRYPTION_KEY_LENGTH, payload_length);
gcry_cipher_encrypt(cipher, rand1, SOLAREDGE_ENCRYPTION_KEY_LENGTH, rand2, SOLAREDGE_ENCRYPTION_KEY_LENGTH);
for (posb = 0; posb < payload_length; posb++) {
intermediate_decrypted_payload[posb] = payload[posb] ^ rand1[posa++];
if (posa == 16) {
posa = 0;
for (posc = 15; posc >= 0; posc--) {
rand2[posc] = (rand2[posc] + 1) & 0xFF;
if (rand2[posc]) {
break;
}
}
gcry_cipher_encrypt(cipher, rand1, SOLAREDGE_ENCRYPTION_KEY_LENGTH, rand2, SOLAREDGE_ENCRYPTION_KEY_LENGTH);
}
}
for (i = 0; i < payload_length; i++) {
out[i] = intermediate_decrypted_payload[i + 6] ^ intermediate_decrypted_payload[2+(i&3)];
}
}
static int
dissect_solaredge_devicedata(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset, gint length)
{
gint current_offset;
t_solaredge_device_header device_header;
proto_item *post_item;
proto_tree *post_tree;
const guint8 *optimizer_data;
gfloat dc_voltage_panel;
gfloat dc_voltage_optimizer;
gfloat dc_current_optimizer;
gfloat energy_day_optimizer;
gfloat temperature_optimizer;
guint32 event_type;
device_header.type = tvb_get_letohs(tvb, offset);
device_header.id = tvb_get_letohl(tvb, offset + 2);
device_header.device_length = tvb_get_letohs(tvb, offset + 6);
post_item = proto_tree_add_item(tree, hf_solaredge_post_device_type, tvb, offset, device_header.device_length + SOLAREDGE_POST_HEADER_LENGTH, ENC_NA);
post_tree = proto_item_add_subtree(post_item, ett_solaredge_packet_post_device);
proto_tree_add_item(post_tree, hf_solaredge_post_device_type_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(post_tree, hf_solaredge_post_device_id_type, tvb, offset + 2, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(post_tree, hf_solaredge_post_length_type, tvb, offset + 6, 2, ENC_LITTLE_ENDIAN);
current_offset = offset + SOLAREDGE_POST_HEADER_LENGTH;
col_append_str(pinfo->cinfo, COL_INFO, " ");
switch(device_header.type) {
case SOLAREDGE_DEVICETYPE_OPTIMIZER:
col_append_str(pinfo->cinfo, COL_INFO, "Optimizer");
proto_tree_add_item(post_tree, hf_solaredge_post_optimizer_timestamp_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_optimizer_inverter_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
if (global_show_unknown_fields == TRUE) {
proto_tree_add_item(post_tree, hf_solaredge_post_padding_uint32_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
}
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_optimizer_uptime_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_optimizer_dc_voltage_panel_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_optimizer_dc_voltage_optimzer_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_optimizer_dc_current_panel_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_optimizer_energy_day_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_optimizer_temperature_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
break;
case SOLAREDGE_DEVICETYPE_INVERTER_1PHASE:
col_append_str(pinfo->cinfo, COL_INFO, "Single phase inverter");
proto_tree_add_item(post_tree, hf_solaredge_post_singlephase_inverter_timestamp_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_singlephase_inverter_uptime_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_singlephase_inverter_interval_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_singlephase_inverter_temperature_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_singlephase_inverter_energy_day_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_singlephase_inverter_energy_interval_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_singlephase_inverter_ac_voltage_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_singlephase_inverter_ac_current_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_singlephase_inverter_ac_frequency_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
if (global_show_unknown_fields == TRUE) {
proto_tree_add_item(post_tree, hf_solaredge_post_padding_uint32_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
}
current_offset += 4;
if (global_show_unknown_fields == TRUE) {
proto_tree_add_item(post_tree, hf_solaredge_post_padding_uint32_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
}
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_singlephase_inverter_dc_voltage_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
if (global_show_unknown_fields == TRUE) {
proto_tree_add_item(post_tree, hf_solaredge_post_padding_uint32_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
}
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_singlephase_inverter_energy_total_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
if (global_show_unknown_fields == TRUE) {
proto_tree_add_item(post_tree, hf_solaredge_post_padding_float_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
}
current_offset += 4;
if (global_show_unknown_fields == TRUE) {
proto_tree_add_item(post_tree, hf_solaredge_post_padding_uint32_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
}
current_offset += 4;
if (global_show_unknown_fields == TRUE) {
proto_tree_add_item(post_tree, hf_solaredge_post_padding_float_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
}
current_offset += 4;
if (global_show_unknown_fields == TRUE) {
proto_tree_add_item(post_tree, hf_solaredge_post_padding_float_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
}
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_singlephase_inverter_power_max_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
if (global_show_unknown_fields == TRUE) {
proto_tree_add_item(post_tree, hf_solaredge_post_padding_float_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
}
current_offset += 4;
if (global_show_unknown_fields == TRUE) {
proto_tree_add_item(post_tree, hf_solaredge_post_padding_float_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
}
current_offset += 4;
if (global_show_unknown_fields == TRUE) {
proto_tree_add_item(post_tree, hf_solaredge_post_padding_uint32_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
}
current_offset += 4;
if (global_show_unknown_fields == TRUE) {
proto_tree_add_item(post_tree, hf_solaredge_post_padding_uint32_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
}
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_singlephase_inverter_ac_power_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
if (global_show_unknown_fields == TRUE) {
proto_tree_add_item(post_tree, hf_solaredge_post_padding_float_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
}
current_offset += 4;
if (global_show_unknown_fields == TRUE) {
proto_tree_add_item(post_tree, hf_solaredge_post_padding_uint32_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
}
current_offset += 4;
break;
case SOLAREDGE_DEVICETYPE_INVERTER_3PHASE:
col_append_str(pinfo->cinfo, COL_INFO, "Three phase inverter");
current_offset += device_header.device_length;
// Not implemented yet
break;
case SOLAREDGE_DEVICETYPE_OPTIMIZER2:
col_append_str(pinfo->cinfo, COL_INFO, "Optimizer");
proto_tree_add_item(post_tree, hf_solaredge_post_optimizer_timestamp_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_optimizer_uptime_short_type, tvb, current_offset, 2, ENC_LITTLE_ENDIAN);
current_offset += 2;
optimizer_data = tvb_get_ptr(tvb, current_offset, 6);
dc_voltage_panel = (gfloat)(0.125 * (gfloat)(optimizer_data[0] | (optimizer_data[1] << 8 & 0x300)));
proto_tree_add_float_format_value(post_tree, hf_solaredge_post_optimizer_dc_voltage_panel_type, tvb, current_offset, 6, dc_voltage_panel, "%.2f", dc_voltage_panel);
dc_voltage_optimizer = (gfloat)(0.125 * (gfloat)(optimizer_data[1] >> 2 | (optimizer_data[2] << 6 & 0x3c0)));
proto_tree_add_float_format_value(post_tree, hf_solaredge_post_optimizer_dc_voltage_optimzer_type, tvb, current_offset, 6, dc_voltage_optimizer, "%.2f", dc_voltage_optimizer);
dc_current_optimizer = (gfloat)(0.00625 * (gfloat)(optimizer_data[3] <<4 | (optimizer_data[2] >>4 & 0xf)));
proto_tree_add_float_format_value(post_tree, hf_solaredge_post_optimizer_dc_current_optimzer_type, tvb, current_offset, 6, dc_current_optimizer, "%.2f", dc_current_optimizer);
energy_day_optimizer = (gfloat)(0.25 * (gfloat)(optimizer_data[6] <<8 | optimizer_data[5]));
proto_tree_add_float_format_value(post_tree, hf_solaredge_post_optimizer_energy_day_type, tvb, current_offset, 6, energy_day_optimizer, "%.2f", energy_day_optimizer);
current_offset += 6;
temperature_optimizer = (gfloat)(2.0 * (gfloat)tvb_get_guint8(tvb, current_offset));
proto_tree_add_float_format_value(post_tree, hf_solaredge_post_optimizer_temperature_type, tvb, current_offset, 2, temperature_optimizer, "%.2f", temperature_optimizer);
current_offset++;
break;
case SOLAREDGE_DEVICETYPE_EVENT:
col_append_str(pinfo->cinfo, COL_INFO, "Wake/sleep event");
proto_tree_add_item(post_tree, hf_solaredge_post_event_timestamp_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
event_type = tvb_get_guint32(tvb, current_offset, ENC_LITTLE_ENDIAN);
proto_tree_add_item(post_tree, hf_solaredge_post_event_type_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_event_event_start_timestamp_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
if (event_type == 1) {
/* Timezone offset, then end time*/
proto_tree_add_item(post_tree, hf_solaredge_post_event_event_timezone_offset_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
proto_tree_add_item(post_tree, hf_solaredge_post_event_event_end_timestamp_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
} else {
/* End time, then unused */
proto_tree_add_item(post_tree, hf_solaredge_post_event_event_end_timestamp_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 8;
}
if (global_show_unknown_fields == TRUE) {
proto_tree_add_item(post_tree, hf_solaredge_post_padding_uint32_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
}
current_offset += 4;
if (global_show_unknown_fields == TRUE) {
proto_tree_add_item(post_tree, hf_solaredge_post_padding_uint32_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
}
current_offset += 4;
break;
default:
col_append_str(pinfo->cinfo, COL_INFO, "Unknown device");
current_offset += device_header.device_length;
break;
}
if (current_offset < length) {
col_append_str(pinfo->cinfo, COL_INFO, ", ");
dissect_solaredge_devicedata(tvb, pinfo, tree, current_offset, length);
}
return current_offset;
}
static int
dissect_solaredge_recursive(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void *data _U_, gint ett, conversation_t *conv)
{
proto_item *ti;
proto_tree *solaredge_header_tree;
proto_item *solaredge_payload_item;
proto_tree *solaredge_payload_tree;
gint32 current_offset = 0;
t_solaredge_packet_header header;
GByteArray *system_key;
guint8 session_key_message_part1[SOLAREDGE_ENCRYPTION_KEY_LENGTH];
guint8 session_key_message_part2[SOLAREDGE_ENCRYPTION_KEY_LENGTH];
guint8 session_key_intermediate[SOLAREDGE_ENCRYPTION_KEY_LENGTH];
guint i;
t_solaredge_conversion_data *conv_data;
gboolean system_key_valid;
/* Starts with magic number */
if ( tvb_get_guint32(tvb, 0, ENC_LITTLE_ENDIAN) != SOLAREDGE_MAGIC_NUMBER) {
return 0;
}
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SolarEdge");
col_clear(pinfo->cinfo,COL_INFO);
ti = proto_tree_add_item(tree, proto_solaredge, tvb, 0, -1, ENC_NA);
current_offset += 4;
solaredge_header_tree = proto_item_add_subtree(ti, ett);
header.length = tvb_get_guint16(tvb, current_offset, ENC_LITTLE_ENDIAN);
proto_tree_add_item(solaredge_header_tree, hf_solaredge_length_type, tvb, current_offset, 2, ENC_LITTLE_ENDIAN);
current_offset += 2;
header.length_inverse = tvb_get_guint16(tvb, current_offset, ENC_LITTLE_ENDIAN);
if (header.length_inverse != (G_MAXUINT16 - header.length)) {
proto_tree_add_expert_format(solaredge_header_tree, pinfo, &ei_solaredge_invalid_length, tvb, current_offset - 2, current_offset + 2, "Invalid length: inverse length %d not matching length %d", header.length_inverse, header.length);
}
proto_tree_add_item(solaredge_header_tree, hf_solaredge_length_inverse_type, tvb, current_offset, 2, ENC_LITTLE_ENDIAN);
current_offset += 2;
header.sequence_number = tvb_get_guint16(tvb, current_offset, ENC_LITTLE_ENDIAN);
proto_tree_add_item(solaredge_header_tree, hf_solaredge_sequence_number_type, tvb, current_offset, 2, ENC_LITTLE_ENDIAN);
current_offset += 2;
header.source_address = tvb_get_guint32(tvb, current_offset, ENC_LITTLE_ENDIAN);
proto_tree_add_item(solaredge_header_tree, hf_solaredge_source_address_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
header.destination_address = tvb_get_guint32(tvb, current_offset, ENC_LITTLE_ENDIAN);
proto_tree_add_item(solaredge_header_tree, hf_solaredge_destination_address_type, tvb, current_offset, 4, ENC_LITTLE_ENDIAN);
current_offset += 4;
header.command_type = tvb_get_guint16(tvb, current_offset, ENC_LITTLE_ENDIAN);
proto_tree_add_item(solaredge_header_tree, hf_solaredge_command_type, tvb, current_offset, 2, ENC_LITTLE_ENDIAN);
current_offset += 2;
col_append_str(pinfo->cinfo, COL_INFO, val_to_str_const(header.command_type, solaredge_packet_commandtypes, "Unknown command"));
switch (header.command_type) {
case SOLAREDGE_COMMAND_MISC_ENCRYPTED:
proto_tree_add_item(solaredge_header_tree, hf_solaredge_payload_type, tvb, current_offset, header.length, ENC_NA);
conv_data = (t_solaredge_conversion_data *)conversation_get_proto_data(conv, proto_solaredge);
if ((conv_data != NULL) && (conv_data->session_key_found == TRUE)) {
guint8 *decrypted_buffer = (guint8*)wmem_alloc(pinfo->pool, header.length);
solaredge_decrypt(tvb_get_ptr(tvb, current_offset, header.length), header.length, decrypted_buffer, conv_data->cipher_hd_session);
tvbuff_t *next_tvb = tvb_new_child_real_data(tvb, decrypted_buffer, header.length, header.length);
if ( tvb_get_guint32(next_tvb, 0, ENC_LITTLE_ENDIAN) == SOLAREDGE_MAGIC_NUMBER) {
add_new_data_source(pinfo, next_tvb, "Decrypted Packet");
dissect_solaredge_recursive(next_tvb, pinfo, tree, data, ett_solaredge_packet_decrypted, conv);
}
}
current_offset += header.length;
break;
case SOLAREDGE_COMMAND_SERVER_POST_DATA:
solaredge_payload_item = proto_tree_add_item(solaredge_header_tree, hf_solaredge_post_type, tvb, current_offset, header.length, ENC_NA);
solaredge_payload_tree = proto_item_add_subtree(solaredge_payload_item, ett_solaredge_packet_post);
dissect_solaredge_devicedata(tvb, pinfo, solaredge_payload_tree, current_offset, header.length);
break;
case SOLAREDGE_COMMAND_SERVER_SET_KEY:
proto_tree_add_item(solaredge_header_tree, hf_solaredge_session_key_type, tvb, current_offset, header.length, ENC_NA);
if (!gcry_cipher_open(&cipher_hd_system, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_ECB, 0)) {
/* Load the system key to generate session key */
system_key = g_byte_array_new();
system_key_valid = hex_str_to_bytes(global_system_encryption_key, system_key, FALSE);
if ((system_key_valid == TRUE) && (system_key->len == SOLAREDGE_ENCRYPTION_KEY_LENGTH)) {
if (!gcry_cipher_setkey(cipher_hd_system, system_key->data, SOLAREDGE_ENCRYPTION_KEY_LENGTH)) {
/* Read first part of message */
tvb_memcpy(tvb, session_key_message_part1, current_offset, SOLAREDGE_ENCRYPTION_KEY_LENGTH);
current_offset += SOLAREDGE_ENCRYPTION_KEY_LENGTH;
/* Read second part of message */
tvb_memcpy(tvb, session_key_message_part2, current_offset, SOLAREDGE_ENCRYPTION_KEY_LENGTH);
current_offset += SOLAREDGE_ENCRYPTION_KEY_LENGTH;
/* Encrypt first part with system key */
gcry_cipher_encrypt(cipher_hd_system, session_key_intermediate, SOLAREDGE_ENCRYPTION_KEY_LENGTH, session_key_message_part1, SOLAREDGE_ENCRYPTION_KEY_LENGTH);
/* XOR result with second part to obtain session key */
for (i = 0; i < SOLAREDGE_ENCRYPTION_KEY_LENGTH; i++) {
session_key_message_part2[i] = session_key_intermediate[i] ^ session_key_message_part2[i];
}
conv_data = (t_solaredge_conversion_data *)conversation_get_proto_data(conv, proto_solaredge);
if (!gcry_cipher_open(&conv_data->cipher_hd_session, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_ECB, 0)) {
/* Load the session key */
if (!gcry_cipher_setkey(conv_data->cipher_hd_session, session_key_message_part2, SOLAREDGE_ENCRYPTION_KEY_LENGTH)) {
conv_data->session_key_found = TRUE;
} else {
gcry_cipher_close(conv_data->cipher_hd_session);
}
}
}
gcry_cipher_close(cipher_hd_system);
}
}
break;
default:
/* If not implemented, skip command */
current_offset += header.length;
break;
}
/* Validate CRC */
proto_tree_add_checksum(solaredge_header_tree, tvb, SOLAREDGE_HEADER_LENGTH + header.length, hf_solaredge_crc_type, hf_solaredge_crc_status_type, &ei_solaredge_invalid_crc, pinfo, calculate_crc(&header, tvb_get_ptr(tvb, SOLAREDGE_HEADER_LENGTH, header.length), header.length), ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
current_offset += 2;
return current_offset;
}
static int
dissect_solaredge(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void *data _U_)
{
conversation_t *conv = find_or_create_conversation(pinfo);
t_solaredge_conversion_data *conv_data;
if (conversation_get_proto_data(conv, proto_solaredge) == NULL) {
/* Setup empty encryption key */
conv_data = wmem_new(wmem_file_scope(), t_solaredge_conversion_data);
conv_data->session_key_found = FALSE;
conversation_add_proto_data(conv, proto_solaredge, conv_data);
}
return dissect_solaredge_recursive(tvb, pinfo, tree, data, ett_solaredge_packet, conv);
}
void
proto_reg_handoff_solaredge(void)
{
dissector_handle_t solaredge_handle;
solaredge_handle = create_dissector_handle(dissect_solaredge, proto_solaredge);
dissector_add_for_decode_as("tcp.port", solaredge_handle);
}
void
proto_register_solaredge(void)
{
static hf_register_info hf[] = {
{ &hf_solaredge_length_type,
{ "Length", "solaredge.length",
FT_UINT16, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_length_inverse_type,
{ "Length inverse", "solaredge.length_inverse",
FT_UINT16, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_sequence_number_type,
{ "Sequence number", "solaredge.sequence_number",
FT_UINT16, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_source_address_type,
{ "Source address", "solaredge.source_address",
FT_UINT32, BASE_HEX,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_destination_address_type,
{ "Destination address", "solaredge.destination_address",
FT_UINT32, BASE_HEX,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_command_type,
{ "Command Type", "solaredge.command",
FT_UINT16, BASE_HEX,
VALS(solaredge_packet_commandtypes), 0x0,
NULL, HFILL }
},
{ &hf_solaredge_crc_type,
{ "CRC", "solaredge.crc",
FT_UINT16, BASE_HEX,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_crc_status_type,
{ "CRC Status", "solaredge.crc.status",
FT_UINT8, BASE_NONE,
VALS(proto_checksum_vals), 0x0,
NULL, HFILL }
},
{ &hf_solaredge_payload_type,
{ "Payload", "solaredge.payload",
FT_BYTES, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_session_key_type,
{ "Session key", "solaredge.session_key",
FT_BYTES, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_type,
{ "Post data", "solaredge.post",
FT_NONE, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_device_type,
{ "Device", "solaredge.post.device",
FT_NONE, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_device_type_type,
{ "Device Type", "solaredge.post.device.type",
FT_UINT16, BASE_HEX,
VALS(solaredge_data_devicetypes), 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_device_id_type,
{ "Device ID", "solaredge.post.device.id",
FT_UINT32, BASE_HEX,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_length_type,
{ "Length", "solaredge.post.device.length",
FT_UINT16, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_padding_uint32_type,
{ "Padding (uint32)", "solaredge.post.device.padding_uint32",
FT_UINT32, BASE_HEX,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_padding_float_type,
{ "Padding (float)", "solaredge.post.device.padding_float",
FT_FLOAT, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_singlephase_inverter_timestamp_type,
{ "Timestamp", "solaredge.post.device.singlephase_inverter.timestamp",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_singlephase_inverter_uptime_type,
{ "Uptime", "solaredge.post.device.singlephase_inverter.uptime",
FT_RELATIVE_TIME, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_singlephase_inverter_interval_type,
{ "Interval", "solaredge.post.device.singlephase_inverter.interval",
FT_UINT32, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_singlephase_inverter_temperature_type,
{ "Temperature", "solaredge.post.device.singlephase_inverter.temperature",
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING,
&units_degree_celsius, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_singlephase_inverter_energy_day_type,
{ "Energy current day", "solaredge.post.device.singlephase_inverter.energy_day",
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING,
&units_watthour, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_singlephase_inverter_energy_interval_type,
{ "Energy current interval", "solaredge.post.device.singlephase_inverter.energy_interval",
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING,
&units_watthour, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_singlephase_inverter_ac_voltage_type,
{ "AC Voltage", "solaredge.post.device.singlephase_inverter.ac_voltage",
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING,
&units_volt, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_singlephase_inverter_ac_current_type,
{ "AC Current", "solaredge.post.device.singlephase_inverter.ac_current",
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING,
&units_amp, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_singlephase_inverter_ac_frequency_type,
{ "AC Frequency", "solaredge.post.device.singlephase_inverter.ac_frequency",
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING,
&units_hz, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_singlephase_inverter_dc_voltage_type,
{ "DC Voltage", "solaredge.post.device.singlephase_inverter.dc_voltage",
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING,
&units_volt, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_singlephase_inverter_energy_total_type,
{ "Energy total", "solaredge.post.device.singlephase_inverter.energy_total",
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING,
&units_watthour, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_singlephase_inverter_power_max_type,
{ "Power Max", "solaredge.post.device.singlephase_inverter.power_max",
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING,
&units_watt, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_singlephase_inverter_ac_power_type,
{ "AC Power", "solaredge.post.device.singlephase_inverter.ac_power",
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING,
&units_watt, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_optimizer_inverter_type,
{ "Inverter ID", "solaredge.post.device.optimizer.inverter",
FT_UINT32, BASE_HEX,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_optimizer_dc_current_panel_type,
{ "DC Current Panel", "solaredge.post.device.optimizer.panel_dc_current",
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING,
&units_amp, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_optimizer_timestamp_type,
{ "Timestamp", "solaredge.post.device.optimizer.timestamp",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_optimizer_uptime_type,
{ "Uptime", "solaredge.post.device.optimizer.uptime",
FT_RELATIVE_TIME, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_optimizer_uptime_short_type,
{ "Uptime (short format)", "solaredge.post.device.optimizer.uptime_short",
FT_UINT16, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_optimizer_dc_voltage_panel_type,
{ "DC Voltage Panel", "solaredge.post.device.optimizer.panel_dc_voltage",
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING,
&units_volt, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_optimizer_dc_voltage_optimzer_type,
{ "DC Voltage Optimizer", "solaredge.post.device.optimizer.optimizer_dc_voltage",
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING,
&units_volt, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_optimizer_dc_current_optimzer_type,
{ "DC Current Optimizer", "solaredge.post.device.optimizer.optimizer_dc_current",
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING,
&units_amp, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_optimizer_energy_day_type,
{ "Energy current day", "solaredge.post.device.optimizer.energy_day",
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING,
&units_watthour, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_optimizer_temperature_type,
{ "Temperature", "solaredge.post.device.optimizer.temperature",
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING,
&units_degree_celsius, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_event_timestamp_type,
{ "Timestamp", "solaredge.post.device.event.timestamp",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_event_type_type,
{ "Type", "solaredge.post.device.event.type",
FT_UINT32, BASE_HEX,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_event_event_start_timestamp_type,
{ "Event start", "solaredge.post.device.event.start",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_event_event_timezone_offset_type,
{ "Timezone offset", "solaredge.post.device.event.timezone_offset",
FT_INT32, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_solaredge_post_event_event_end_timestamp_type,
{ "Event stop", "solaredge.post.device.event.stop",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0x0,
NULL, HFILL }
},
};
static ei_register_info ei[] = {
{ &ei_solaredge_invalid_length, { "solaredge.invalid_length", PI_MALFORMED, PI_WARN, "Inverse length field not matching length field", EXPFILL }},
{ &ei_solaredge_invalid_crc, { "solaredge.invalid_crc", PI_CHECKSUM, PI_WARN, "CRC does not match data", EXPFILL }}
};
expert_module_t* expert_solaredge;
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_solaredge_packet,
&ett_solaredge_packet_decrypted,
&ett_solaredge_packet_post,
&ett_solaredge_packet_post_device
};
proto_solaredge = proto_register_protocol (
"SolarEdge monitoring protocol",
"SolarEdge",
"solaredge"
);
module_t * module_solaredge = prefs_register_protocol(proto_solaredge, NULL);
prefs_register_bool_preference(module_solaredge, "unknown", "Show unknown fields", "Show unidentified fields (\"padding\") in packet dissections", &global_show_unknown_fields);
prefs_register_string_preference(module_solaredge, "system_encryption_key", "System encryption key", "Inverter system encryption key", &global_system_encryption_key);
proto_register_field_array(proto_solaredge, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_solaredge = expert_register_protocol(proto_solaredge);
expert_register_field_array(expert_solaredge, ei, array_length(ei));
}
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-someip-sd.c
|
/* packet-someip-sd.c
* SOME/IP-SD dissector.
* By Dr. Lars Voelker <[email protected]> / <[email protected]>
* Copyright 2012-2022 Dr. Lars Voelker
* Copyright 2020 Ayoub Kaanich
* Copyright 2019 Ana Pantar
* Copyright 2019 Guenter Ebermann
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config.h>
#include <epan/prefs.h>
#include <epan/expert.h>
#include <epan/to_str.h>
#include <epan/uat.h>
#include <epan/stats_tree.h>
#include "packet-udp.h"
#include "packet-someip.h"
/*
* Dissector for SOME/IP Service Discovery (SOME/IP-SD).
*
* See
* http://www.some-ip.com
*/
#define SOMEIP_SD_NAME "SOME/IP-SD"
#define SOMEIP_SD_NAME_LONG "SOME/IP Service Discovery Protocol"
#define SOMEIP_SD_NAME_FILTER "someipsd"
#define SOMEIP_SD_MESSAGEID 0xffff8100
#define SOMEIP_SD_SERVICE_ID_OTHER_SERVICE 0xfffe
/* Header */
#define SOMEIP_SD_REBOOT_FLAG 0x80
#define SOMEIP_SD_UNICAST_FLAG 0x40
#define SOMEIP_SD_EXPL_INIT_EVENT_REQ_FLAG 0x20
#define SOMEIP_SD_MIN_LENGTH 12
/* Entries */
#define SD_ENTRY_LENGTH 16
#define SD_ENTRY_UNKNOWN 0x00
#define SD_ENTRY_SERVICE 0x01
#define SD_ENTRY_EVENTGROUP 0x02
/* TTL>0 */
#define SD_ENTRY_FIND_SERVICE 0x00
#define SD_ENTRY_OFFER_SERVICE 0x01
#define SD_ENTRY_SUBSCRIBE_EVENTGROUP 0x06
#define SD_ENTRY_SUBSCRIBE_EVENTGROUP_ACK 0x07
/* TTL=0 */
#define SD_ENTRY_STOP_OFFER_SERVICE 0x01
#define SD_ENTRY_STOP_SUBSCRIBE_EVENTGROUP 0x06
#define SD_ENTRY_SUBSCRIBE_EVENTGROUP_NACK 0x07
#define SD_EVENTGROUP_ENTRY_COUNTER_MASK 0x0f
#define SD_EVENTGROUP_ENTRY_RES2_MASK 0x70
#define SD_ENTRY_INIT_EVENT_REQ_MASK 0x80
/* Options */
#define SD_OPTION_MINLENGTH 3
#define SD_OPTION_IPV4_LENGTH 12
#define SD_OPTION_IPV6_LENGTH 24
#define SD_OPTION_UNKNOWN 0x00
#define SD_OPTION_CONFIGURATION 0x01
#define SD_OPTION_LOADBALANCING 0x02
#define SD_OPTION_IPV4_ENDPOINT 0x04
#define SD_OPTION_IPV6_ENDPOINT 0x06
#define SD_OPTION_IPV4_MULTICAST 0x14
#define SD_OPTION_IPV6_MULTICAST 0x16
#define SD_OPTION_IPV4_SD_ENDPOINT 0x24
#define SD_OPTION_IPV6_SD_ENDPOINT 0x26
#define SD_OPTION_L4PROTO_TCP 6
#define SD_OPTION_L4PROTO_UDP 17
/* option start 0..255, num 0..15 -> 0..270 */
#define SD_MAX_NUM_OPTIONS 271
/* ID wireshark identifies the dissector by */
static int proto_someip_sd = -1;
/* header field */
static int hf_someip_sd_flags = -1;
static int hf_someip_sd_rebootflag = -1;
static int hf_someip_sd_unicastflag = -1;
static int hf_someip_sd_explicitiniteventflag = -1;
static int hf_someip_sd_reserved = -1;
static int hf_someip_sd_length_entriesarray = -1;
static int hf_someip_sd_entries = -1;
static int hf_someip_sd_entry = -1;
static int hf_someip_sd_entry_type = -1;
static int hf_someip_sd_entry_type_offerservice = -1;
static int hf_someip_sd_entry_type_stopofferservice = -1;
static int hf_someip_sd_entry_type_findservice = -1;
static int hf_someip_sd_entry_type_subscribeeventgroup = -1;
static int hf_someip_sd_entry_type_stopsubscribeeventgroup = -1;
static int hf_someip_sd_entry_type_subscribeeventgroupack = -1;
static int hf_someip_sd_entry_type_subscribeeventgroupnack = -1;
static int hf_someip_sd_entry_index1 = -1;
static int hf_someip_sd_entry_index2 = -1;
static int hf_someip_sd_entry_numopt1 = -1;
static int hf_someip_sd_entry_numopt2 = -1;
static int hf_someip_sd_entry_opts_referenced = -1;
static int hf_someip_sd_entry_serviceid = -1;
static int hf_someip_sd_entry_servicename = -1;
static int hf_someip_sd_entry_instanceid = -1;
static int hf_someip_sd_entry_majorver = -1;
static int hf_someip_sd_entry_ttl = -1;
static int hf_someip_sd_entry_minorver = -1;
static int hf_someip_sd_entry_eventgroupid = -1;
static int hf_someip_sd_entry_eventgroupname = -1;
static int hf_someip_sd_entry_reserved = -1;
static int hf_someip_sd_entry_counter = -1;
static int hf_someip_sd_entry_intial_event_flag = -1;
static int hf_someip_sd_entry_reserved2 = -1;
static int hf_someip_sd_length_optionsarray = -1;
static int hf_someip_sd_options = -1;
static int hf_someip_sd_option_type = -1;
static int hf_someip_sd_option_length = -1;
static int hf_someip_sd_option_reserved = -1;
static int hf_someip_sd_option_ipv4 = -1;
static int hf_someip_sd_option_ipv6 = -1;
static int hf_someip_sd_option_port = -1;
static int hf_someip_sd_option_proto = -1;
static int hf_someip_sd_option_reserved2 = -1;
static int hf_someip_sd_option_data = -1;
static int hf_someip_sd_option_config_string = -1;
static int hf_someip_sd_option_config_string_element = -1;
static int hf_someip_sd_option_lb_priority = -1;
static int hf_someip_sd_option_lb_weight = -1;
/* protocol tree items */
static gint ett_someip_sd = -1;
static gint ett_someip_sd_flags = -1;
static gint ett_someip_sd_entries = -1;
static gint ett_someip_sd_entry = -1;
static gint ett_someip_sd_options = -1;
static gint ett_someip_sd_option = -1;
static gint ett_someip_sd_config_string = -1;
/*** Taps ***/
static int tap_someip_sd_entries = -1;
typedef struct _someip_sd_entries_tap {
guint8 entry_type;
guint16 service_id;
guint8 major_version;
guint32 minor_version;
guint16 instance_id;
guint16 eventgroup_id;
guint32 ttl;
} someip_sd_entries_tap_t;
/*** Stats ***/
static const gchar *st_str_ip_src = "Source Addresses";
static const gchar *st_str_ip_dst = "Destination Addresses";
static int st_node_ip_src = -1;
static int st_node_ip_dst = -1;
/*** Preferences ***/
static range_t *someip_ignore_ports_udp = NULL;
static range_t *someip_ignore_ports_tcp = NULL;
/* SOME/IP-SD Entry Names for TTL>0 */
static const value_string sd_entry_type_positive[] = {
{SD_ENTRY_FIND_SERVICE, "Find Service"},
{SD_ENTRY_OFFER_SERVICE, "Offer Service"},
{SD_ENTRY_SUBSCRIBE_EVENTGROUP, "Subscribe Eventgroup"},
{SD_ENTRY_SUBSCRIBE_EVENTGROUP_ACK, "Subscribe Eventgroup Ack"},
{0, NULL}
};
/* SOME/IP-SD Entry Names for TTL=0 */
static const value_string sd_entry_type_negative[] = {
{SD_ENTRY_STOP_OFFER_SERVICE, "Stop Offer Service"},
{SD_ENTRY_STOP_SUBSCRIBE_EVENTGROUP, "Stop Subscribe Eventgroup"},
{SD_ENTRY_SUBSCRIBE_EVENTGROUP_NACK, "Subscribe Eventgroup Negative Ack"},
{0, NULL}
};
/* SOME/IP-SD Option Names */
static const value_string sd_option_type[] = {
{SD_OPTION_UNKNOWN, "Unknown"},
{SD_OPTION_CONFIGURATION, "Configuration"},
{SD_OPTION_LOADBALANCING, "Load Balancing"},
{SD_OPTION_IPV4_ENDPOINT, "IPv4 Endpoint"},
{SD_OPTION_IPV6_ENDPOINT, "IPv6 Endpoint"},
{SD_OPTION_IPV4_MULTICAST, "IPv4 Multicast"},
{SD_OPTION_IPV6_MULTICAST, "IPv6 Multicast"},
{SD_OPTION_IPV4_SD_ENDPOINT, "IPv4 SD Endpoint"},
{SD_OPTION_IPV6_SD_ENDPOINT, "IPv6 SD Endpoint"},
{0, NULL}
};
/* L4 Protocol Names for SOME/IP-SD Endpoints */
static const value_string sd_option_l4protos[] = {
{SD_OPTION_L4PROTO_TCP, "TCP"},
{SD_OPTION_L4PROTO_UDP, "UDP"},
{0, NULL}
};
static const true_false_string sd_reboot_flag = {
"Session ID did not roll over since last reboot",
"Session ID rolled over since last reboot"
};
static const true_false_string sd_unicast_flag = {
"Unicast messages support",
"Unicast messages not supported (deprecated)"
};
static const true_false_string sd_eiec_flag = {
"Explicit Initial Event control supported",
"Explicit Initial Event control not supported"
};
/*** expert info items ***/
static expert_field ef_someipsd_message_truncated = EI_INIT;
static expert_field ef_someipsd_entry_array_malformed = EI_INIT;
static expert_field ef_someipsd_entry_array_empty = EI_INIT;
static expert_field ef_someipsd_entry_unknown = EI_INIT;
static expert_field ef_someipsd_option_array_truncated = EI_INIT;
static expert_field ef_someipsd_option_array_bytes_left = EI_INIT;
static expert_field ef_someipsd_option_unknown = EI_INIT;
static expert_field ef_someipsd_option_wrong_length = EI_INIT;
static expert_field ef_someipsd_L4_protocol_unsupported = EI_INIT;
static expert_field ef_someipsd_config_string_malformed = EI_INIT;
/*** prototypes ***/
void proto_register_someip_sd(void);
void proto_reg_handoff_someip_sd(void);
/**************************************
******** SOME/IP-SD Dissector ********
*************************************/
static void
someip_sd_register_ports(guint32 opt_index, guint32 opt_num, guint32 option_count, guint32 option_ports[]) {
guint i;
for (i = opt_index; i < opt_index + opt_num && i < option_count; i++) {
guint32 l4port = 0x0000ffff & option_ports[i];
guint32 l4proto = (0xff000000 & option_ports[i]) >> 24;
if (l4proto == SD_OPTION_L4PROTO_UDP && !value_is_in_range(someip_ignore_ports_udp, l4port)) {
register_someip_port_udp(l4port);
}
if (l4proto == SD_OPTION_L4PROTO_TCP && !value_is_in_range(someip_ignore_ports_tcp, l4port)) {
register_someip_port_tcp(l4port);
}
/* delete port from list to ensure only registering once per SD message */
option_ports[i] = 0;
}
}
static void
dissect_someip_sd_pdu_option_configuration(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset, guint32 length, int optionnum) {
guint32 offset_orig = offset;
const guint8 *config_string;
proto_item *ti;
proto_tree *subtree;
tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_someip_sd_option, NULL, "%d: Configuration Option", optionnum);
/* Add common fields */
proto_tree_add_item(tree, hf_someip_sd_option_length, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_someip_sd_option_type, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_someip_sd_option_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
gint config_string_length = length - offset + offset_orig;
ti = proto_tree_add_item_ret_string(tree, hf_someip_sd_option_config_string, tvb, offset, config_string_length, ENC_ASCII | ENC_NA, pinfo->pool, &config_string);
subtree = proto_item_add_subtree(ti, ett_someip_sd_config_string);
guint8 pos = 0;
guint8 element_length;
while (config_string != NULL && config_string_length - pos > 0) {
element_length = config_string[pos];
pos++;
if (element_length == 0) {
break;
}
if (element_length > config_string_length - pos) {
expert_add_info(pinfo, ti, &ef_someipsd_config_string_malformed);
break;
}
proto_tree_add_item(subtree, hf_someip_sd_option_config_string_element, tvb, offset + pos, element_length, ENC_ASCII | ENC_NA);
pos += element_length;
}
}
static void
dissect_someip_sd_pdu_option_loadbalancing(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint32 offset, guint32 length, int optionnum) {
tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_someip_sd_option, NULL, "%d: Load Balancing Option", optionnum);
/* Add common fields */
proto_tree_add_item(tree, hf_someip_sd_option_length, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_someip_sd_option_type, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_someip_sd_option_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_someip_sd_option_lb_priority, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_someip_sd_option_lb_weight, tvb, offset, 2, ENC_BIG_ENDIAN);
}
static void
dissect_someip_sd_pdu_option_ipv4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset, guint32 length, int optionnum, guint32 option_ports[]) {
guint8 type = 255;
const gchar *description = NULL;
guint32 l4port = 0;
guint32 l4proto = 0;
const gchar *l4protoname = NULL;
const gchar *ipstring = NULL;
proto_item *ti = NULL;
proto_item *ti_top = NULL;
type = tvb_get_guint8(tvb, offset + 2);
description = val_to_str(type, sd_option_type, "(Unknown Option: %d)");
tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_someip_sd_option, &ti_top, "%d: %s Option", optionnum, description);
if (length != SD_OPTION_IPV4_LENGTH) {
expert_add_info(pinfo, ti_top, &ef_someipsd_option_wrong_length);
return;
}
/* Add common fields */
proto_tree_add_item(tree, hf_someip_sd_option_length, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_someip_sd_option_type, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_someip_sd_option_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_someip_sd_option_ipv4, tvb, offset, 4, ENC_NA);
ipstring = tvb_ip_to_str(pinfo->pool, tvb, offset);
offset += 4;
proto_tree_add_item(tree, hf_someip_sd_option_reserved2, tvb, offset, 1, ENC_NA);
offset += 1;
ti = proto_tree_add_item_ret_uint(tree, hf_someip_sd_option_proto, tvb, offset, 1, ENC_NA, &l4proto);
l4protoname = val_to_str(l4proto, sd_option_l4protos, "Unknown Transport Protocol: %d");
proto_item_append_text(ti, " (%s)", l4protoname);
if (type != SD_OPTION_IPV4_ENDPOINT && l4proto == SD_OPTION_L4PROTO_TCP) {
expert_add_info(pinfo, ti_top, &ef_someipsd_L4_protocol_unsupported);
}
offset += 1;
proto_tree_add_item_ret_uint(tree, hf_someip_sd_option_port, tvb, offset, 2, ENC_BIG_ENDIAN, &l4port);
proto_item_append_text(ti_top, " (%s:%d (%s))", ipstring, l4port, l4protoname);
option_ports[optionnum] = ((guint32)l4proto << 24) + l4port;
}
static void
dissect_someip_sd_pdu_option_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset, guint32 length, int optionnum, guint32 option_ports[]) {
guint8 type = 255;
const gchar *description = NULL;
guint32 l4port = 0;
guint32 l4proto = 0;
const gchar *l4protoname = NULL;
const gchar *ipstring = NULL;
proto_item *ti = NULL;
proto_item *ti_top = NULL;
type = tvb_get_guint8(tvb, offset + 2);
description = val_to_str(type, sd_option_type, "(Unknown Option: %d)");
tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_someip_sd_option, &ti_top, "%d: %s Option", optionnum, description);
if (length != SD_OPTION_IPV6_LENGTH) {
expert_add_info(pinfo, ti_top, &ef_someipsd_option_wrong_length);
return;
}
proto_tree_add_item(tree, hf_someip_sd_option_length, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_someip_sd_option_type, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_someip_sd_option_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_someip_sd_option_ipv6, tvb, offset, 16, ENC_NA);
ipstring = tvb_ip6_to_str(pinfo->pool, tvb, offset);
offset += 16;
proto_tree_add_item(tree, hf_someip_sd_option_reserved2, tvb, offset, 1, ENC_NA);
offset += 1;
ti = proto_tree_add_item_ret_uint(tree, hf_someip_sd_option_proto, tvb, offset, 1, ENC_NA, &l4proto);
l4protoname = val_to_str(l4proto, sd_option_l4protos, "(Unknown Transport Protocol: %d)");
proto_item_append_text(ti, " (%s)", l4protoname);
if (type != SD_OPTION_IPV6_ENDPOINT && l4proto == SD_OPTION_L4PROTO_TCP) {
expert_add_info(pinfo, ti_top, &ef_someipsd_L4_protocol_unsupported);
}
offset += 1;
proto_tree_add_item_ret_uint(tree, hf_someip_sd_option_port, tvb, offset, 2, ENC_BIG_ENDIAN, &l4port);
proto_item_append_text(ti_top, " (%s:%d (%s))", ipstring, l4port, l4protoname);
option_ports[optionnum] = ((guint32)l4proto << 24) + l4port;
}
static void
dissect_someip_sd_pdu_option_unknown(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset, guint32 length, int optionnum) {
guint32 len = 0;
proto_item *ti;
tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_someip_sd_option, &ti, "%d: %s Option", optionnum,
val_to_str_const(tvb_get_guint8(tvb, offset + 2), sd_option_type, "Unknown"));
expert_add_info(pinfo, ti, &ef_someipsd_option_unknown);
proto_tree_add_item_ret_uint(tree, hf_someip_sd_option_length, tvb, offset, 2, ENC_BIG_ENDIAN, &len);
offset += 2;
proto_tree_add_item(tree, hf_someip_sd_option_type, tvb, offset, 1, ENC_NA);
offset += 1;
if (length > 3) {
proto_tree_add_item(tree, hf_someip_sd_option_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
if (length > 4) {
proto_tree_add_item(tree, hf_someip_sd_option_data, tvb, offset, length - 4, ENC_NA);
}
}
}
static int
dissect_someip_sd_pdu_options(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *ti, guint32 offset_orig, guint32 length, guint32 option_ports[], guint *option_count) {
guint16 real_length = 0;
guint8 option_type = 0;
int optionnum = 0;
tvbuff_t *subtvb = NULL;
guint32 offset = offset_orig;
if (!tvb_bytes_exist(tvb, offset, SD_OPTION_MINLENGTH) || !tvb_bytes_exist(tvb, offset, length)) {
expert_add_info(pinfo, ti, &ef_someipsd_option_array_truncated);
return offset;
}
while (tvb_bytes_exist(tvb, offset, SD_OPTION_MINLENGTH)) {
ws_assert(optionnum >= 0 && optionnum < SD_MAX_NUM_OPTIONS);
option_ports[optionnum] = 0;
real_length = tvb_get_ntohs(tvb, offset) + 3;
option_type = tvb_get_guint8(tvb, offset + 2);
if (!tvb_bytes_exist(tvb, offset, (gint)real_length) || offset - offset_orig + real_length > length) {
expert_add_info(pinfo, ti, &ef_someipsd_option_array_truncated);
return offset;
}
subtvb = tvb_new_subset_length(tvb, offset, (gint)real_length);
switch (option_type) {
case SD_OPTION_CONFIGURATION:
dissect_someip_sd_pdu_option_configuration(subtvb, pinfo, tree, 0, real_length, optionnum);
break;
case SD_OPTION_LOADBALANCING:
dissect_someip_sd_pdu_option_loadbalancing(subtvb, pinfo, tree, 0, real_length, optionnum);
break;
case SD_OPTION_IPV4_ENDPOINT:
case SD_OPTION_IPV4_MULTICAST:
case SD_OPTION_IPV4_SD_ENDPOINT:
dissect_someip_sd_pdu_option_ipv4(subtvb, pinfo, tree, 0, real_length, optionnum, option_ports);
break;
case SD_OPTION_IPV6_ENDPOINT:
case SD_OPTION_IPV6_MULTICAST:
case SD_OPTION_IPV6_SD_ENDPOINT:
dissect_someip_sd_pdu_option_ipv6(subtvb, pinfo, tree, 0, real_length, optionnum, option_ports);
break;
default:
dissect_someip_sd_pdu_option_unknown(subtvb, pinfo, tree, 0, real_length, optionnum);
break;
}
optionnum++;
offset += real_length;
}
*option_count = optionnum;
return offset;
}
static void
dissect_someip_sd_pdu_entry(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset_orig, guint32 length, guint32 *entry_flags, guint32 *stop_entry_flags, guint32 option_ports[], guint option_count) {
guint8 type = 255;
guint32 serviceid = 0;
guint32 instanceid = 0;
guint32 eventgroupid = 0;
guint32 majorver = 0;
guint32 minorver = 0;
guint32 ttl = 0;
guint32 opt_index1;
guint32 opt_index2;
guint32 opt_num1;
guint32 opt_num2;
guint64 uniqueid = 0;
guint8 category = SD_ENTRY_UNKNOWN;
const gchar *description = NULL;
static gchar buf_opt_ref[32];
proto_item *ti;
proto_item *ti_top;
guint32 offset = offset_orig;
if (length < SD_ENTRY_LENGTH || !tvb_bytes_exist(tvb, offset, length)) {
return;
}
/* lets look ahead and find out the type and ttl */
type = tvb_get_guint8(tvb, offset);
ttl = tvb_get_ntoh24(tvb, offset + 9);
if (type < 4) {
category = SD_ENTRY_SERVICE;
} else if (type >= 4 && type < 8) {
category = SD_ENTRY_EVENTGROUP;
} else {
ti_top = proto_tree_add_none_format(tree, hf_someip_sd_entry, tvb, offset, SD_ENTRY_LENGTH, "Unknown Entry (Type: %d)", type);
expert_add_info(pinfo, ti_top, &ef_someipsd_entry_unknown);
return;
}
if (ttl == 0) {
description = val_to_str(type, sd_entry_type_negative, "(Unknown Entry: %d)");
} else {
description = val_to_str(type, sd_entry_type_positive, "(Unknown Entry: %d)");
}
ti_top = proto_tree_add_none_format(tree, hf_someip_sd_entry, tvb, offset, SD_ENTRY_LENGTH, "%s Entry", description);
tree = proto_item_add_subtree(ti_top, ett_someip_sd_entry);
proto_tree_add_uint_format_value(tree, hf_someip_sd_entry_type, tvb, offset, 1, type, "0x%02x (%s)", type, description);
offset += 1;
proto_tree_add_item_ret_uint(tree, hf_someip_sd_entry_index1, tvb, offset, 1, ENC_BIG_ENDIAN, &opt_index1);
offset += 1;
proto_tree_add_item_ret_uint(tree, hf_someip_sd_entry_index2, tvb, offset, 1, ENC_BIG_ENDIAN, &opt_index2);
offset += 1;
proto_tree_add_item_ret_uint(tree, hf_someip_sd_entry_numopt1, tvb, offset, 1, ENC_NA, &opt_num1);
proto_tree_add_item_ret_uint(tree, hf_someip_sd_entry_numopt2, tvb, offset, 1, ENC_NA, &opt_num2);
offset += 1;
if (opt_num1 != 0 && opt_num2 == 0) {
snprintf(buf_opt_ref, 32, "%d-%d", opt_index1, opt_index1 + opt_num1 - 1);
} else if (opt_num1 == 0 && opt_num2 != 0) {
snprintf(buf_opt_ref, 32, "%d-%d", opt_index2, opt_index2 + opt_num2 - 1);
} else if (opt_num1 != 0 && opt_num2 != 0) {
snprintf(buf_opt_ref, 32, "%d-%d,%d-%d", opt_index1, opt_index1 + opt_num1 - 1, opt_index2, opt_index2 + opt_num2 - 1);
} else {
snprintf(buf_opt_ref, 32, "None");
}
ti = proto_tree_add_string(tree, hf_someip_sd_entry_opts_referenced, tvb, offset - 3, 3, buf_opt_ref);
proto_item_set_generated(ti);
ti = proto_tree_add_item_ret_uint(tree, hf_someip_sd_entry_serviceid, tvb, offset, 2, ENC_BIG_ENDIAN, &serviceid);
description = someip_lookup_service_name((guint16)serviceid);
if (description != NULL) {
proto_item_append_text(ti, " (%s)", description);
ti = proto_tree_add_string(tree, hf_someip_sd_entry_servicename, tvb, offset, 2, description);
proto_item_set_generated(ti);
proto_item_set_hidden(ti);
}
offset += 2;
proto_tree_add_item_ret_uint(tree, hf_someip_sd_entry_instanceid, tvb, offset, 2, ENC_BIG_ENDIAN, &instanceid);
offset += 2;
proto_tree_add_item_ret_uint(tree, hf_someip_sd_entry_majorver, tvb, offset, 1, ENC_BIG_ENDIAN, &majorver);
offset += 1;
proto_tree_add_item(tree, hf_someip_sd_entry_ttl, tvb, offset, 3, ENC_BIG_ENDIAN);
offset += 3;
/* Add specific fields - i.e. the last line */
if (category == SD_ENTRY_SERVICE) {
proto_tree_add_item_ret_uint(tree, hf_someip_sd_entry_minorver, tvb, offset, 4, ENC_BIG_ENDIAN, &minorver);
proto_item_append_text(ti_top, " (Service ID 0x%04x, Instance ID 0x%04x, Version %u.%u, Options: %s)", serviceid, instanceid, majorver, minorver, buf_opt_ref);
} else if (category == SD_ENTRY_EVENTGROUP) {
proto_tree_add_item(tree, hf_someip_sd_entry_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_someip_sd_entry_intial_event_flag, tvb, offset, 1, ENC_NA);
proto_tree_add_item(tree, hf_someip_sd_entry_reserved2, tvb, offset, 1, ENC_NA);
proto_tree_add_item(tree, hf_someip_sd_entry_counter, tvb, offset, 1, ENC_NA);
offset += 1;
ti = proto_tree_add_item_ret_uint(tree, hf_someip_sd_entry_eventgroupid, tvb, offset, 2, ENC_BIG_ENDIAN, &eventgroupid);
description = someip_lookup_eventgroup_name((guint16)serviceid, (guint16)eventgroupid);
if (description != NULL) {
proto_item_append_text(ti, " (%s)", description);
ti = proto_tree_add_string(tree, hf_someip_sd_entry_eventgroupname, tvb, offset, 2, description);
proto_item_set_generated(ti);
proto_item_set_hidden(ti);
}
proto_item_append_text(ti_top, " (Service ID 0x%04x, Instance ID 0x%04x, Eventgroup ID 0x%04x, Version %u, Options: %s)", serviceid, instanceid, eventgroupid, majorver, buf_opt_ref);
}
/* mark for attaching to info column */
if (type < 32) {
if (ttl == 0) {
*stop_entry_flags = *stop_entry_flags | (1 << type);
} else {
*entry_flags = *entry_flags | (1 << type);
}
}
/* lets add some combined filtering term */
uniqueid = (((guint64)serviceid) << 32) | (guint64)instanceid << 16 | (guint64)eventgroupid;
ti = NULL;
if (ttl > 0) {
switch (type) {
case SD_ENTRY_FIND_SERVICE:
ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_findservice, tvb, offset_orig, SD_ENTRY_LENGTH, uniqueid, "on 0x%012" PRIx64, uniqueid);
break;
case SD_ENTRY_OFFER_SERVICE:
ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_offerservice, tvb, offset_orig, SD_ENTRY_LENGTH, uniqueid, "on 0x%012" PRIx64, uniqueid);
break;
case SD_ENTRY_SUBSCRIBE_EVENTGROUP:
ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_subscribeeventgroup, tvb, offset_orig, SD_ENTRY_LENGTH, uniqueid, "on 0x%012" PRIx64, uniqueid);
break;
case SD_ENTRY_SUBSCRIBE_EVENTGROUP_ACK:
ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_subscribeeventgroupack, tvb, offset_orig, SD_ENTRY_LENGTH, uniqueid, "on 0x%012" PRIx64, uniqueid);
break;
}
} else {
switch (type) {
case SD_ENTRY_STOP_OFFER_SERVICE:
ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_stopofferservice, tvb, offset_orig, SD_ENTRY_LENGTH, uniqueid, "on 0x%012" PRIx64, uniqueid);
break;
case SD_ENTRY_STOP_SUBSCRIBE_EVENTGROUP:
ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_stopsubscribeeventgroup, tvb, offset_orig, SD_ENTRY_LENGTH, uniqueid, "on 0x%012" PRIx64, uniqueid);
break;
case SD_ENTRY_SUBSCRIBE_EVENTGROUP_NACK:
ti = proto_tree_add_uint64_format_value(tree, hf_someip_sd_entry_type_subscribeeventgroupnack, tvb, offset_orig, SD_ENTRY_LENGTH, uniqueid, "on 0x%012" PRIx64, uniqueid);
break;
}
}
proto_item_set_hidden(ti);
/* register ports but we skip 0xfffe because of other-serv */
if (serviceid != SOMEIP_SD_SERVICE_ID_OTHER_SERVICE && !PINFO_FD_VISITED(pinfo)) {
someip_sd_register_ports(opt_index1, opt_num1, option_count, option_ports);
someip_sd_register_ports(opt_index2, opt_num2, option_count, option_ports);
}
/* TAP */
if (have_tap_listener(tap_someip_sd_entries)) {
someip_sd_entries_tap_t *data = wmem_alloc(pinfo->pool, sizeof(someip_sd_entries_tap_t));
data->entry_type = type;
data->service_id = (guint16)serviceid;
data->major_version = (guint8)majorver;
data->minor_version = minorver;
data->instance_id = (guint16)instanceid;
data->eventgroup_id = (guint16)eventgroupid;
data->ttl = ttl;
tap_queue_packet(tap_someip_sd_entries, pinfo, data);
}
}
static int
dissect_someip_sd_pdu_entries(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *ti, guint32 offset, guint32 length, guint32 option_ports[], guint option_count) {
guint32 entry_flags = 0;
guint32 stop_entry_flags = 0;
while (length >= SD_ENTRY_LENGTH) {
dissect_someip_sd_pdu_entry(tvb, pinfo, tree, offset, SD_ENTRY_LENGTH, &entry_flags, &stop_entry_flags, option_ports, option_count);
offset += SD_ENTRY_LENGTH;
length -= SD_ENTRY_LENGTH;
}
/* Add entry flags */
if (stop_entry_flags != 0 || entry_flags != 0) {
col_append_str(pinfo->cinfo, COL_INFO, " ");
}
if (entry_flags & (1 << SD_ENTRY_FIND_SERVICE)) {
col_append_str(pinfo->cinfo, COL_INFO, "[Find]");
}
if (stop_entry_flags & (1 << SD_ENTRY_OFFER_SERVICE)) {
col_append_str(pinfo->cinfo, COL_INFO, "[StopOffer]");
}
if (entry_flags & (1 << SD_ENTRY_OFFER_SERVICE)) {
col_append_str(pinfo->cinfo, COL_INFO, "[Offer]");
}
if (stop_entry_flags & (1 << SD_ENTRY_SUBSCRIBE_EVENTGROUP)) {
col_append_str(pinfo->cinfo, COL_INFO, "[StopSubscribe]");
}
if (entry_flags & (1 << SD_ENTRY_SUBSCRIBE_EVENTGROUP)) {
col_append_str(pinfo->cinfo, COL_INFO, "[Subscribe]");
}
if (stop_entry_flags & (1 << SD_ENTRY_SUBSCRIBE_EVENTGROUP_ACK)) {
col_append_str(pinfo->cinfo, COL_INFO, "[SubscribeNack]");
}
if (entry_flags & (1 << SD_ENTRY_SUBSCRIBE_EVENTGROUP_ACK)) {
col_append_str(pinfo->cinfo, COL_INFO, "[SubscribeAck]");
}
if (length != 0) {
expert_add_info(pinfo, ti, &ef_someipsd_entry_array_malformed);
}
return length;
}
static int
dissect_someip_sd_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) {
guint32 offset = 0;
guint32 length_entriesarray = 0;
guint32 length_optionsarray = 0;
proto_item *ti = NULL;
proto_item *ti_sd_entries = NULL;
proto_tree *someip_sd_entries_tree = NULL;
proto_tree *someip_sd_options_tree = NULL;
gboolean stop_parsing_after_entries = FALSE;
guint32 offset_entriesarray;
/* format for option_ports entries: 1 byte proto | 1 byte reserved | 2 byte port number*/
static guint32 option_ports[SD_MAX_NUM_OPTIONS];
guint option_count = 0;
static int * const someipsd_flags[] = {
&hf_someip_sd_rebootflag,
&hf_someip_sd_unicastflag,
&hf_someip_sd_explicitiniteventflag,
NULL
};
col_set_str(pinfo->cinfo, COL_PROTOCOL, SOMEIP_SD_NAME);
col_set_str(pinfo->cinfo, COL_INFO, SOMEIP_SD_NAME_LONG);
ti = proto_tree_add_item(tree, proto_someip_sd, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(ti, ett_someip_sd);
if (!tvb_bytes_exist(tvb, offset, SOMEIP_SD_MIN_LENGTH)) {
expert_add_info(pinfo, ti, &ef_someipsd_message_truncated);
return tvb_reported_length(tvb);
}
/* add flags */
proto_tree_add_bitmask(tree, tvb, offset, hf_someip_sd_flags, ett_someip_sd_flags, someipsd_flags, ENC_BIG_ENDIAN);
offset += 1;
/* add reserved */
proto_tree_add_item(tree, hf_someip_sd_reserved, tvb, offset, 3, ENC_BIG_ENDIAN);
offset += 3;
/* add length of entries */
proto_tree_add_item_ret_uint(tree, hf_someip_sd_length_entriesarray, tvb, offset, 4, ENC_BIG_ENDIAN, &length_entriesarray);
offset += 4;
if (!tvb_bytes_exist(tvb, offset, length_entriesarray)) {
expert_add_info(pinfo, ti , &ef_someipsd_message_truncated);
return tvb_reported_length(tvb);
}
if (!tvb_bytes_exist(tvb, offset, length_entriesarray)) {
/* truncated SD message - need to shorten buffer */
length_entriesarray = tvb_captured_length_remaining(tvb, offset);
expert_add_info(pinfo, ti, &ef_someipsd_message_truncated);
stop_parsing_after_entries = TRUE;
}
/* preparing entries array but not parsing it yet */
ti_sd_entries = proto_tree_add_item(tree, hf_someip_sd_entries, tvb, offset, length_entriesarray, ENC_NA);
someip_sd_entries_tree = proto_item_add_subtree(ti_sd_entries, ett_someip_sd_entries);
/* save offset to parse entries later since we need to parse options first */
offset_entriesarray = offset;
offset += length_entriesarray;
if (!stop_parsing_after_entries) {
/* make sure we have a length field */
if (tvb_bytes_exist(tvb, offset, 4)) {
/* add options length */
proto_tree_add_item_ret_uint(tree, hf_someip_sd_length_optionsarray, tvb, offset, 4, ENC_BIG_ENDIAN, &length_optionsarray);
offset += 4;
if (length_optionsarray > 0) {
if (tvb_bytes_exist(tvb, offset, 1)) {
ti = proto_tree_add_item(tree, hf_someip_sd_options, tvb, offset, -1, ENC_NA);
someip_sd_options_tree = proto_item_add_subtree(ti, ett_someip_sd_options);
/* check, if enough bytes are left for optionsarray */
if (!tvb_bytes_exist(tvb, offset, length_optionsarray)) {
length_optionsarray = tvb_captured_length_remaining(tvb, offset);
expert_add_info(pinfo, ti, &ef_someipsd_message_truncated);
proto_item_append_text(ti, " (truncated!)");
}
/* updating to length we will work with */
if (length_optionsarray > 0) {
proto_item_set_len(ti, length_optionsarray);
}
dissect_someip_sd_pdu_options(tvb, pinfo, someip_sd_options_tree, ti, offset, length_optionsarray, option_ports, &option_count);
offset += length_optionsarray;
} else {
expert_add_info(pinfo, ti, &ef_someipsd_message_truncated);
}
}
}
}
if (length_entriesarray >= SD_ENTRY_LENGTH) {
offset += dissect_someip_sd_pdu_entries(tvb, pinfo, someip_sd_entries_tree, ti_sd_entries, offset_entriesarray, length_entriesarray, option_ports, option_count);
} else {
expert_add_info(pinfo, ti_sd_entries, &ef_someipsd_entry_array_empty);
}
return offset;
}
/*******************************************
**************** Statistics ***************
*******************************************/
static void
someipsd_entries_stats_tree_init(stats_tree *st) {
st_node_ip_src = stats_tree_create_node(st, st_str_ip_src, 0, STAT_DT_INT, TRUE);
stat_node_set_flags(st, st_str_ip_src, 0, FALSE, ST_FLG_SORT_TOP);
st_node_ip_dst = stats_tree_create_node(st, st_str_ip_dst, 0, STAT_DT_INT, TRUE);
}
static void
stat_number_to_string_with_any(guint32 value, guint max, gchar *format_string, gchar *ret, size_t size_limit) {
if (value == max) {
snprintf(ret, size_limit, "%s", "MAX");
} else {
snprintf(ret, size_limit, format_string, value);
}
}
static void
stat_create_entry_summary_string(const someip_sd_entries_tap_t *data, gchar *ret, size_t size_limit) {
gchar service_str[128];
gchar instance_str[128];
gchar majorver_str[128];
gchar minorver_str[128];
gchar eventgrp_str[128];
gchar tmp[128];
char *service_name = someip_lookup_service_name(data->service_id);
char *eventgrp_name = someip_lookup_eventgroup_name(data->service_id, data->eventgroup_id);
stat_number_to_string_with_any(data->service_id, UINT32_MAX, "0x%04x", service_str, sizeof(service_str) - 1);
stat_number_to_string_with_any(data->instance_id, UINT32_MAX, "0x%04x", instance_str, sizeof(instance_str) - 1);
stat_number_to_string_with_any(data->major_version, UINT8_MAX, "%d", majorver_str, sizeof(majorver_str) - 1);
switch (data->entry_type) {
case SD_ENTRY_FIND_SERVICE:
case SD_ENTRY_OFFER_SERVICE:
stat_number_to_string_with_any(data->minor_version, UINT32_MAX, "%d", minorver_str, sizeof(minorver_str) - 1);
if (service_name != NULL) {
snprintf(ret, size_limit, "Service %s (%s) Version %s.%s Instance %s", service_str, service_name, majorver_str, minorver_str, instance_str);
} else {
snprintf(ret, size_limit, "Service %s Version %s.%s Instance %s", service_str, majorver_str, minorver_str, instance_str);
}
break;
case SD_ENTRY_SUBSCRIBE_EVENTGROUP:
case SD_ENTRY_SUBSCRIBE_EVENTGROUP_ACK:
stat_number_to_string_with_any(data->eventgroup_id, UINT32_MAX, "0x%04x", eventgrp_str, sizeof(eventgrp_str) - 1);
if (service_name != NULL) {
snprintf(tmp, sizeof(tmp) - 1, "Service %s (%s) Version %s Instance %s Eventgroup %s", service_str, service_name, majorver_str, instance_str, eventgrp_str);
} else {
snprintf(tmp, sizeof(tmp) - 1, "Service %s Version %s Instance %s Eventgroup %s", service_str, majorver_str, instance_str, eventgrp_str);
}
if (eventgrp_name != NULL) {
snprintf(ret, size_limit, "%s (%s)", tmp, eventgrp_name);
}
break;
}
}
static tap_packet_status
someipsd_entries_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p, tap_flags_t flags _U_) {
DISSECTOR_ASSERT(p);
const someip_sd_entries_tap_t *data = (const someip_sd_entries_tap_t *)p;
static gchar tmp_addr_str[256];
snprintf(tmp_addr_str, sizeof(tmp_addr_str) - 1, "%s (%s)", address_to_str(pinfo->pool, &pinfo->net_src), address_to_name(&pinfo->net_src));
tick_stat_node(st, st_str_ip_src, 0, FALSE);
int src_id = tick_stat_node(st, tmp_addr_str, st_node_ip_src, TRUE);
snprintf(tmp_addr_str, sizeof(tmp_addr_str) - 1, "%s (%s)", address_to_str(pinfo->pool, &pinfo->net_dst), address_to_name(&pinfo->net_dst));
tick_stat_node(st, st_str_ip_dst, 0, FALSE);
int dst_id = tick_stat_node(st, tmp_addr_str, st_node_ip_dst, TRUE);
int tmp_id;
static gchar tmp_str[128];
if (data->ttl == 0) {
switch (data->entry_type) {
case SD_ENTRY_STOP_OFFER_SERVICE:
stat_create_entry_summary_string(data, tmp_str, sizeof(tmp_str) - 1);
tmp_id = tick_stat_node(st, "Stop Offer Service", src_id, TRUE);
tick_stat_node(st, tmp_str, tmp_id, FALSE);
tmp_id = tick_stat_node(st, "Stop Offer Service", dst_id, TRUE);
tick_stat_node(st, tmp_str, tmp_id, FALSE);
break;
case SD_ENTRY_STOP_SUBSCRIBE_EVENTGROUP:
stat_create_entry_summary_string(data, tmp_str, sizeof(tmp_str) - 1);
tmp_id = tick_stat_node(st, "Stop Subscribe Eventgroup", src_id, TRUE);
tick_stat_node(st, tmp_str, tmp_id, FALSE);
tmp_id = tick_stat_node(st, "Stop Subscribe Eventgroup", dst_id, TRUE);
tick_stat_node(st, tmp_str, tmp_id, FALSE);
break;
case SD_ENTRY_SUBSCRIBE_EVENTGROUP_NACK:
stat_create_entry_summary_string(data, tmp_str, sizeof(tmp_str) - 1);
tmp_id = tick_stat_node(st, "Subscribe Eventgroup Nack", src_id, TRUE);
tick_stat_node(st, tmp_str, tmp_id, FALSE);
tmp_id = tick_stat_node(st, "Subscribe Eventgroup Nack", dst_id, TRUE);
tick_stat_node(st, tmp_str, tmp_id, FALSE);
break;
}
} else {
switch (data->entry_type) {
case SD_ENTRY_FIND_SERVICE:
stat_create_entry_summary_string(data, tmp_str, sizeof(tmp_str) - 1);
tmp_id = tick_stat_node(st, "Find Service", src_id, TRUE);
tick_stat_node(st, tmp_str, tmp_id, FALSE);
tmp_id = tick_stat_node(st, "Find Service", dst_id, TRUE);
tick_stat_node(st, tmp_str, tmp_id, FALSE);
break;
case SD_ENTRY_OFFER_SERVICE:
stat_create_entry_summary_string(data, tmp_str, sizeof(tmp_str) - 1);
tmp_id = tick_stat_node(st, "Offer Service", src_id, TRUE);
tick_stat_node(st, tmp_str, tmp_id, FALSE);
tmp_id = tick_stat_node(st, "Offer Service", dst_id, TRUE);
tick_stat_node(st, tmp_str, tmp_id, FALSE);
break;
case SD_ENTRY_SUBSCRIBE_EVENTGROUP:
stat_create_entry_summary_string(data, tmp_str, sizeof(tmp_str) - 1);
tmp_id = tick_stat_node(st, "Subscribe Eventgroup", src_id, TRUE);
tick_stat_node(st, tmp_str, tmp_id, FALSE);
tmp_id = tick_stat_node(st, "Subscribe Eventgroup", dst_id, TRUE);
tick_stat_node(st, tmp_str, tmp_id, FALSE);
break;
case SD_ENTRY_SUBSCRIBE_EVENTGROUP_ACK:
stat_create_entry_summary_string(data, tmp_str, sizeof(tmp_str) - 1);
tmp_id = tick_stat_node(st, "Subscribe Eventgroup Ack", src_id, TRUE);
tick_stat_node(st, tmp_str, tmp_id, FALSE);
tmp_id = tick_stat_node(st, "Subscribe Eventgroup Ack", dst_id, TRUE);
tick_stat_node(st, tmp_str, tmp_id, FALSE);
break;
}
}
return TAP_PACKET_REDRAW;
}
void
proto_register_someip_sd(void) {
module_t *someipsd_module;
expert_module_t *expert_module_someip_sd;
/* data fields */
static hf_register_info hf_sd[] = {
{ &hf_someip_sd_flags,
{ "Flags", "someipsd.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_rebootflag,
{ "Reboot Flag", "someipsd.flags.reboot",
FT_BOOLEAN, 8, TFS(&sd_reboot_flag), SOMEIP_SD_REBOOT_FLAG, NULL, HFILL }},
{ &hf_someip_sd_unicastflag,
{ "Unicast Flag", "someipsd.flags.unicast",
FT_BOOLEAN, 8, TFS(&sd_unicast_flag), SOMEIP_SD_UNICAST_FLAG, NULL, HFILL }},
{ &hf_someip_sd_explicitiniteventflag,
{ "Explicit Initial Events Flag", "someipsd.flags.exp_init_events",
FT_BOOLEAN, 8, TFS(&sd_eiec_flag), SOMEIP_SD_EXPL_INIT_EVENT_REQ_FLAG, NULL, HFILL }},
{ &hf_someip_sd_reserved,
{ "Reserved", "someipsd.reserved",
FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_length_entriesarray,
{ "Length of Entries Array", "someipsd.length_entriesarray",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entries,
{ "Entries Array", "someipsd.entries",
FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry,
{ "Entry", "someipsd.entry",
FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_type,
{ "Type", "someipsd.entry.type",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_index1,
{ "Index 1", "someipsd.entry.index1",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_index2,
{ "Index 2", "someipsd.entry.index2",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_numopt1,
{ "Number of Opts 1", "someipsd.entry.numopt1",
FT_UINT8, BASE_HEX, NULL, 0xf0, NULL, HFILL }},
{ &hf_someip_sd_entry_numopt2,
{ "Number of Opts 2", "someipsd.entry.numopt2",
FT_UINT8, BASE_HEX, NULL, 0x0f, NULL, HFILL }},
{ &hf_someip_sd_entry_opts_referenced,
{ "Options referenced", "someipsd.entry.optionsreferenced",
FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL }},
{ &hf_someip_sd_entry_serviceid,
{ "Service ID", "someipsd.entry.serviceid",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_servicename,
{ "Service Name", "someipsd.entry.servicename",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_instanceid,
{ "Instance ID", "someipsd.entry.instanceid",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_majorver,
{ "Major Version", "someipsd.entry.majorver",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_ttl,
{ "TTL", "someipsd.entry.ttl",
FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_minorver,
{ "Minor Version", "someipsd.entry.minorver",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_eventgroupid,
{ "Eventgroup ID", "someipsd.entry.eventgroupid",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_eventgroupname,
{ "Eventgroup Name", "someipsd.entry.eventgroupname",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_reserved,
{ "Reserved", "someipsd.entry.reserved",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_someip_sd_entry_counter,
{ "Counter", "someipsd.entry.counter",
FT_UINT8, BASE_HEX, NULL, SD_EVENTGROUP_ENTRY_COUNTER_MASK, NULL, HFILL } },
{ &hf_someip_sd_entry_reserved2,
{ "Reserved", "someipsd.entry.reserved2",
FT_UINT8, BASE_HEX, NULL, SD_EVENTGROUP_ENTRY_RES2_MASK, NULL, HFILL } },
{ &hf_someip_sd_entry_intial_event_flag,
{ "Initial Event Request", "someipsd.entry.initialevents",
FT_BOOLEAN, 8, NULL, SD_ENTRY_INIT_EVENT_REQ_MASK, NULL, HFILL } },
{ &hf_someip_sd_length_optionsarray,
{ "Length of Options Array", "someipsd.length_optionsarray",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_options,
{ "Options Array", "someipsd.options",
FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_option_type,
{ "Type", "someipsd.option.type",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_option_length,
{ "Length", "someipsd.option.length",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_option_reserved,
{ "Reserved", "someipsd.option.reserved",
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_option_ipv4,
{ "IPv4 Address", "someipsd.option.ipv4address",
FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_option_ipv6,
{ "IPv6 Address", "someipsd.option.ipv6address",
FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_option_port,
{ "Port", "someipsd.option.port",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_option_proto,
{ "Protocol", "someipsd.option.proto",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_option_reserved2,
{ "Reserved 2", "someipsd.option.reserved2",
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_someip_sd_option_data,
{ "Unknown Data", "someipsd.option.unknown_data",
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_someip_sd_option_config_string,
{ "Configuration String", "someipsd.option.config_string",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_someip_sd_option_config_string_element,
{ "Configuration String Element", "someipsd.option.config_string_element",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_someip_sd_option_lb_priority,
{ "Priority", "someipsd.option.priority",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_someip_sd_option_lb_weight,
{ "Weight", "someipsd.option.weight",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_someip_sd_entry_type_offerservice,
{ "Offer Service", "someipsd.entry.offerservice",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_type_stopofferservice,
{ "Stop Offer Service", "someipsd.entry.stopofferservice",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_type_findservice,
{ "Find Service", "someipsd.entry.findservice",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_type_subscribeeventgroup,
{ "Subscribe Eventgroup", "someipsd.entry.subscribeeventgroup",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_type_stopsubscribeeventgroup,
{ "Stop Subscribe Eventgroup", "someipsd.entry.stopsubscribeeventgroup",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_type_subscribeeventgroupack,
{ "Subscribe Eventgroup ACK", "someipsd.entry.subscribeeventgroupack",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sd_entry_type_subscribeeventgroupnack,
{ "Subscribe Eventgroup NACK", "someipsd.entry.subscribeeventgroupnack",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
};
static gint *ett_sd[] = {
&ett_someip_sd,
&ett_someip_sd_flags,
&ett_someip_sd_entries,
&ett_someip_sd_entry,
&ett_someip_sd_options,
&ett_someip_sd_option,
&ett_someip_sd_config_string,
};
static ei_register_info ei_sd[] = {
{ &ef_someipsd_message_truncated,{ "someipsd.message_truncated", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Truncated message!", EXPFILL } },
{ &ef_someipsd_entry_array_malformed,{ "someipsd.entry_array_malformed", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Entry Array length not multiple of 16 bytes!", EXPFILL } },
{ &ef_someipsd_entry_array_empty,{ "someipsd.entry_array_empty", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Empty Entry Array!", EXPFILL } },
{ &ef_someipsd_entry_unknown,{ "someipsd.entry_unknown", PI_MALFORMED, PI_WARN, "SOME/IP-SD Unknown Entry!", EXPFILL } },
{ &ef_someipsd_option_array_truncated,{ "someipsd.option_array_truncated", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Option Array truncated!", EXPFILL } },
{ &ef_someipsd_option_array_bytes_left,{ "someipsd.option_array_bytes_left", PI_MALFORMED, PI_WARN, "SOME/IP-SD Option Array bytes left after parsing options!", EXPFILL } },
{ &ef_someipsd_option_unknown,{ "someipsd.option_unknown", PI_MALFORMED, PI_WARN, "SOME/IP-SD Unknown Option!", EXPFILL } },
{ &ef_someipsd_option_wrong_length,{ "someipsd.option_wrong_length", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Option length is incorrect!", EXPFILL } },
{ &ef_someipsd_L4_protocol_unsupported,{ "someipsd.L4_protocol_unsupported", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Unsupported Layer 4 Protocol!", EXPFILL } },
{ &ef_someipsd_config_string_malformed,{ "someipsd.config_string_malformed", PI_MALFORMED, PI_ERROR, "SOME/IP-SD Configuration String malformed!", EXPFILL } },
};
/* Register Protocol, Fields, ETTs, Expert Info, Taps */
proto_someip_sd = proto_register_protocol(SOMEIP_SD_NAME_LONG, SOMEIP_SD_NAME, SOMEIP_SD_NAME_FILTER);
proto_register_field_array(proto_someip_sd, hf_sd, array_length(hf_sd));
proto_register_subtree_array(ett_sd, array_length(ett_sd));
expert_module_someip_sd = expert_register_protocol(proto_someip_sd);
expert_register_field_array(expert_module_someip_sd, ei_sd, array_length(ei_sd));
tap_someip_sd_entries = register_tap("someipsd_entries");
/* Register preferences */
someipsd_module = prefs_register_protocol(proto_someip_sd, &proto_reg_handoff_someip_sd);
range_convert_str(wmem_epan_scope(), &someip_ignore_ports_udp, "", 65535);
prefs_register_range_preference(someipsd_module, "ports.udp.ignore", "UDP Ports ignored",
"SOME/IP Ignore Port Ranges UDP. These ports are not automatically added by the SOME/IP-SD.",
&someip_ignore_ports_udp, 65535);
range_convert_str(wmem_epan_scope(), &someip_ignore_ports_tcp, "", 65535);
prefs_register_range_preference(someipsd_module, "ports.tcp.ignore", "TCP Ports ignored",
"SOME/IP Ignore Port Ranges TCP. These ports are not automatically added by the SOME/IP-SD.",
&someip_ignore_ports_tcp, 65535);
}
void
proto_reg_handoff_someip_sd(void) {
static gboolean initialized = FALSE;
static dissector_handle_t someip_sd_handle = NULL;
if (!initialized) {
someip_sd_handle = create_dissector_handle(dissect_someip_sd_pdu, proto_someip_sd);
dissector_add_uint("someip.messageid", SOMEIP_SD_MESSAGEID, someip_sd_handle);
stats_tree_register("someipsd_entries", "someipsd_entries", "SOME/IP-SD Entries", 0, someipsd_entries_stats_tree_packet, someipsd_entries_stats_tree_init, NULL);
initialized = TRUE;
}
/* nothing to do here right now */
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
|
C
|
wireshark/epan/dissectors/packet-someip.c
|
/* packet-someip.c
* SOME/IP dissector.
* By Dr. Lars Voelker <[email protected]> / <[email protected]>
* Copyright 2012-2023 Dr. Lars Voelker
* Copyright 2019 Ana Pantar
* Copyright 2019 Guenter Ebermann
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/expert.h>
#include <epan/to_str.h>
#include <epan/uat.h>
#include "packet-tcp.h"
#include <epan/reassemble.h>
#include <epan/addr_resolv.h>
#include <epan/stats_tree.h>
#include "packet-udp.h"
#include "packet-dtls.h"
#include "packet-someip.h"
#include "packet-tls.h"
/*
* Dissector for SOME/IP, SOME/IP-TP, and SOME/IP Payloads.
*
* See
* http://www.some-ip.com
*
*
* This dissector also supports the experimental WTLV or TLV extension,
* which is not part of the original SOME/IP.
* This add-on feature uses a so-called WireType, which is basically
* a type of a length field and an ID to each parameter. Since the
* WireType is not really a type, we should avoid TLV as name for this.
* Only use this, if you know what you are doing since this changes the
* serialization methodology of SOME/IP in a incompatible way and might
* break the dissection of your messages.
*/
#define SOMEIP_NAME "SOME/IP"
#define SOMEIP_NAME_LONG "SOME/IP Protocol"
#define SOMEIP_NAME_FILTER "someip"
#define SOMEIP_NAME_PREFIX "someip.payload"
#define SOMEIP_NAME_LONG_MULTIPLE "SOME/IP Protocol (Multiple Payloads)"
#define SOMEIP_NAME_LONG_BROKEN "SOME/IP: Incomplete headers!"
#define SOMEIP_NAME_LONG_TOO_SHORT "SOME/IP: Incomplete SOME/IP payload!"
/*** Configuration ***/
#define DATAFILE_SOMEIP_SERVICES "SOMEIP_service_identifiers"
#define DATAFILE_SOMEIP_METHODS "SOMEIP_method_event_identifiers"
#define DATAFILE_SOMEIP_EVENTGROUPS "SOMEIP_eventgroup_identifiers"
#define DATAFILE_SOMEIP_CLIENTS "SOMEIP_client_identifiers"
#define DATAFILE_SOMEIP_PARAMETERS "SOMEIP_parameter_list"
#define DATAFILE_SOMEIP_BASE_TYPES "SOMEIP_parameter_base_types"
#define DATAFILE_SOMEIP_ARRAYS "SOMEIP_parameter_arrays"
#define DATAFILE_SOMEIP_STRINGS "SOMEIP_parameter_strings"
#define DATAFILE_SOMEIP_TYPEDEFS "SOMEIP_parameter_typedefs"
#define DATAFILE_SOMEIP_STRUCTS "SOMEIP_parameter_structs"
#define DATAFILE_SOMEIP_UNIONS "SOMEIP_parameter_unions"
#define DATAFILE_SOMEIP_ENUMS "SOMEIP_parameter_enums"
#define SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_UNKNOWN 0
#define SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_BASE_TYPE 1
#define SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_STRING 2
#define SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_ARRAY 3
#define SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_STRUCT 4
#define SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_UNION 5
#define SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_TYPEDEF 6
#define SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_ENUM 7
/*** SOME/IP ***/
#define SOMEIP_HDR_LEN 16
#define SOMEIP_HDR_PART1_LEN 8
#define SOMEIP_HDR_PART2_LEN_INCL_TP 12
#define SOMEIP_TP_HDR_LEN 4
#define SOMEIP_PROTOCOL_VERSION 1
/* Message Types */
#define SOMEIP_MSGTYPE_REQUEST 0x00
#define SOMEIP_MSGTYPE_REQUEST_NO_RESPONSE 0x01
#define SOMEIP_MSGTYPE_NOTIFICATION 0x02
#define SOMEIP_MSGTYPE_RESPONSE 0x80
#define SOMEIP_MSGTYPE_ERROR 0x81
#define SOMEIP_MSGTYPE_ACK_MASK 0x40
#define SOMEIP_MSGTYPE_TP_MASK 0x20
#define SOMEIP_MSGTYPE_FLAGS_MASK 0x60
#define SOMEIP_MSGTYPE_NO_FLAGS_MASK 0x9f
#define SOMEIP_MSGTYPE_TP_STRING "SOME/IP-TP segment"
#define SOMEIP_MSGTYPE_ACK_STRING "ACK"
/* SOME/IP-TP */
#define SOMEIP_TP_OFFSET_MASK 0xfffffff0
#define SOMEIP_TP_OFFSET_MASK_FLAGS 0x0000000f
#define SOMEIP_TP_OFFSET_MASK_RESERVED 0x0000000e
#define SOMEIP_TP_OFFSET_MASK_MORE_SEGMENTS 0x00000001
/* Return Codes */
#define SOMEIP_RETCODE_OK 0x00
#define SOMEIP_RETCODE_NOT_OK 0x01
#define SOMEIP_RETCODE_UNKNOWN_SERVICE 0x02
#define SOMEIP_RETCODE_UNKNOWN_METHOD 0x03
#define SOMEIP_RETCODE_NOT_READY 0x04
#define SOMEIP_RETCODE_NOT_REACHABLE 0x05
#define SOMEIP_RETCODE_TIMEOUT 0x06
#define SOMEIP_RETCODE_WRONG_PROTO_VER 0x07
#define SOMEIP_RETCODE_WRONG_INTERFACE_VER 0x08
#define SOMEIP_RETCODE_MALFORMED_MSG 0x09
#define SOMEIP_RETCODE_WRONG_MESSAGE_TYPE 0x0a
/* SOME/IP WTLV (experimental "WTLV" extension) */
#define SOMEIP_WTLV_MASK_RES 0x8000
#define SOMEIP_WTLV_MASK_WIRE_TYPE 0x7000
#define SOMEIP_WTLV_MASK_DATA_ID 0x0fff
/* ID wireshark identifies the dissector by */
static int proto_someip = -1;
static dissector_handle_t someip_handle_udp = NULL;
static dissector_handle_t someip_handle_tcp = NULL;
static dissector_handle_t dtls_handle = NULL;
/* header field */
static int hf_someip_messageid = -1;
static int hf_someip_serviceid = -1;
static int hf_someip_servicename = -1;
static int hf_someip_methodid = -1;
static int hf_someip_methodname = -1;
static int hf_someip_length = -1;
static int hf_someip_clientid = -1;
static int hf_someip_clientname = -1;
static int hf_someip_sessionid = -1;
static int hf_someip_protover = -1;
static int hf_someip_interface_ver = -1;
static int hf_someip_messagetype = -1;
static int hf_someip_messagetype_ack_flag = -1;
static int hf_someip_messagetype_tp_flag = -1;
static int hf_someip_returncode = -1;
static int hf_someip_tp = -1;
static int hf_someip_tp_offset = -1;
static int hf_someip_tp_flags = -1;
static int hf_someip_tp_reserved = -1;
static int hf_someip_tp_more_segments = -1;
static int hf_someip_payload = -1;
/* protocol tree items */
static gint ett_someip = -1;
static gint ett_someip_msgtype = -1;
static gint ett_someip_tp = -1;
static gint ett_someip_tp_flags = -1;
/* dissector handling */
static dissector_table_t someip_dissector_table = NULL;
/* message reassembly for SOME/IP-TP */
static int hf_someip_tp_fragments = -1;
static int hf_someip_tp_fragment = -1;
static int hf_someip_tp_fragment_overlap = -1;
static int hf_someip_tp_fragment_overlap_conflicts = -1;
static int hf_someip_tp_fragment_multiple_tails = -1;
static int hf_someip_tp_fragment_too_long_fragment = -1;
static int hf_someip_tp_fragment_error = -1;
static int hf_someip_tp_fragment_count = -1;
static int hf_someip_tp_reassembled_in = -1;
static int hf_someip_tp_reassembled_length = -1;
static int hf_someip_tp_reassembled_data = -1;
static int hf_payload_unparsed = -1;
static int hf_payload_length_field_8bit = -1;
static int hf_payload_length_field_16bit = -1;
static int hf_payload_length_field_32bit = -1;
static int hf_payload_type_field_8bit = -1;
static int hf_payload_type_field_16bit = -1;
static int hf_payload_type_field_32bit = -1;
static int hf_payload_str_base = -1;
static int hf_payload_str_string = -1;
static int hf_payload_str_struct = -1;
static int hf_payload_str_array = -1;
static int hf_payload_str_union = -1;
static int hf_payload_wtlv_tag = -1;
static int hf_payload_wtlv_tag_res = -1;
static int hf_payload_wtlv_tag_wire_type = -1;
static int hf_payload_wtlv_tag_data_id = -1;
static hf_register_info* dynamic_hf_param = NULL;
static guint dynamic_hf_param_size = 0;
static hf_register_info* dynamic_hf_array = NULL;
static guint dynamic_hf_array_size = 0;
static hf_register_info* dynamic_hf_struct = NULL;
static guint dynamic_hf_struct_size = 0;
static hf_register_info* dynamic_hf_union = NULL;
static guint dynamic_hf_union_size = 0;
static gint ett_someip_tp_fragment = -1;
static gint ett_someip_tp_fragments = -1;
static gint ett_someip_payload = -1;
static gint ett_someip_string = -1;
static gint ett_someip_array = -1;
static gint ett_someip_array_dim = -1;
static gint ett_someip_struct = -1;
static gint ett_someip_union = -1;
static gint ett_someip_parameter = -1;
static gint ett_someip_wtlv_tag = -1;
static const fragment_items someip_tp_frag_items = {
&ett_someip_tp_fragment,
&ett_someip_tp_fragments,
&hf_someip_tp_fragments,
&hf_someip_tp_fragment,
&hf_someip_tp_fragment_overlap,
&hf_someip_tp_fragment_overlap_conflicts,
&hf_someip_tp_fragment_multiple_tails,
&hf_someip_tp_fragment_too_long_fragment,
&hf_someip_tp_fragment_error,
&hf_someip_tp_fragment_count,
&hf_someip_tp_reassembled_in,
&hf_someip_tp_reassembled_length,
&hf_someip_tp_reassembled_data,
"SOME/IP-TP Segments"
};
static gboolean someip_tp_reassemble = TRUE;
static gboolean someip_deserializer_activated = TRUE;
static gboolean someip_deserializer_wtlv_default = FALSE;
static gboolean someip_detect_dtls = FALSE;
/* SOME/IP Message Types */
static const value_string someip_msg_type[] = {
{SOMEIP_MSGTYPE_REQUEST, "Request"},
{SOMEIP_MSGTYPE_REQUEST_NO_RESPONSE, "Request no response"},
{SOMEIP_MSGTYPE_NOTIFICATION, "Notification"},
{SOMEIP_MSGTYPE_RESPONSE, "Response"},
{SOMEIP_MSGTYPE_ERROR, "Error"},
{SOMEIP_MSGTYPE_REQUEST | SOMEIP_MSGTYPE_ACK_MASK, "Request Ack"},
{SOMEIP_MSGTYPE_REQUEST_NO_RESPONSE | SOMEIP_MSGTYPE_ACK_MASK, "Request no response Ack"},
{SOMEIP_MSGTYPE_NOTIFICATION | SOMEIP_MSGTYPE_ACK_MASK, "Notification Ack"},
{SOMEIP_MSGTYPE_RESPONSE | SOMEIP_MSGTYPE_ACK_MASK, "Response Ack"},
{SOMEIP_MSGTYPE_ERROR | SOMEIP_MSGTYPE_ACK_MASK, "Error Ack"},
{0, NULL}
};
/* SOME/IP Return Code */
static const value_string someip_return_code[] = {
{SOMEIP_RETCODE_OK, "Ok"},
{SOMEIP_RETCODE_NOT_OK, "Not Ok"},
{SOMEIP_RETCODE_UNKNOWN_SERVICE, "Unknown Service"},
{SOMEIP_RETCODE_UNKNOWN_METHOD, "Unknown Method/Event"},
{SOMEIP_RETCODE_NOT_READY, "Not Ready"},
{SOMEIP_RETCODE_NOT_REACHABLE, "Not Reachable (internal)"},
{SOMEIP_RETCODE_TIMEOUT, "Timeout (internal)"},
{SOMEIP_RETCODE_WRONG_PROTO_VER, "Wrong Protocol Version"},
{SOMEIP_RETCODE_WRONG_INTERFACE_VER, "Wrong Interface Version"},
{SOMEIP_RETCODE_MALFORMED_MSG, "Malformed Message"},
{SOMEIP_RETCODE_WRONG_MESSAGE_TYPE, "Wrong Message Type"},
{0, NULL}
};
/*** expert info items ***/
static expert_field ef_someip_unknown_version = EI_INIT;
static expert_field ef_someip_message_truncated = EI_INIT;
static expert_field ef_someip_incomplete_headers = EI_INIT;
static expert_field ef_someip_payload_truncated = EI_INIT;
static expert_field ef_someip_payload_malformed = EI_INIT;
static expert_field ef_someip_payload_config_error = EI_INIT;
static expert_field ef_someip_payload_alignment_error = EI_INIT;
static expert_field ef_someip_payload_static_array_min_not_max = EI_INIT;
static expert_field ef_someip_payload_dyn_array_not_within_limit = EI_INIT;
/*** Data Structure for mapping IDs to Names (Services, Methods, ...) ***/
static GHashTable *data_someip_services = NULL;
static GHashTable *data_someip_methods = NULL;
static GHashTable *data_someip_eventgroups = NULL;
static GHashTable *data_someip_clients = NULL;
static GHashTable *data_someip_parameter_list = NULL;
static GHashTable *data_someip_parameter_base_type_list = NULL;
static GHashTable *data_someip_parameter_strings = NULL;
static GHashTable *data_someip_parameter_typedefs = NULL;
static GHashTable *data_someip_parameter_arrays = NULL;
static GHashTable *data_someip_parameter_structs = NULL;
static GHashTable *data_someip_parameter_unions = NULL;
static GHashTable *data_someip_parameter_enums = NULL;
/*** Taps ***/
static int tap_someip_messages = -1;
/*** Stats ***/
static const gchar *st_str_ip_src = "Source Addresses";
static const gchar *st_str_ip_dst = "Destination Addresses";
static int st_node_ip_src = -1;
static int st_node_ip_dst = -1;
/***********************************************
********* Preferences / Configuration *********
***********************************************/
typedef struct _someip_payload_parameter_item {
guint32 pos;
gchar *name;
guint32 data_type;
guint32 id_ref;
int *hf_id;
gchar *filter_string;
} someip_payload_parameter_item_t;
#define INIT_SOMEIP_PAYLOAD_PARAMETER_ITEM(NAME) \
(NAME)->pos = 0; \
(NAME)->name = NULL; \
(NAME)->data_type = 0; \
(NAME)->id_ref = 0; \
(NAME)->hf_id = NULL; \
(NAME)->filter_string = NULL;
typedef struct _someip_payload_parameter_base_type_list {
guint32 id;
gchar *name;
gchar *data_type;
gboolean big_endian;
guint32 bitlength_base_type;
guint32 bitlength_encoded_type;
} someip_payload_parameter_base_type_list_t;
#define INIT_COMMON_BASE_TYPE_LIST_ITEM(NAME) \
(NAME)->id = 0; \
(NAME)->name = NULL; \
(NAME)->data_type = NULL ; \
(NAME)->big_endian = TRUE; \
(NAME)->bitlength_base_type = 0; \
(NAME)->bitlength_encoded_type = 0;
typedef struct _someip_payload_parameter_string {
guint32 id;
gchar *name;
gchar *encoding;
gboolean dynamic_length;
guint32 max_length;
guint32 length_of_length; /* default: 32 */
gboolean big_endian;
guint32 pad_to;
} someip_payload_parameter_string_t;
#define INIT_SOMEIP_PAYLOAD_PARAMETER_STRING(NAME) \
(NAME)->id = 0; \
(NAME)->name = NULL; \
(NAME)->encoding = NULL; \
(NAME)->dynamic_length = FALSE; \
(NAME)->max_length = 0; \
(NAME)->length_of_length = 0; \
(NAME)->big_endian = TRUE; \
(NAME)->pad_to = 0;
typedef struct _someip_payload_parameter_typedef {
guint32 id;
gchar* name;
guint32 data_type;
guint32 id_ref;
} someip_payload_parameter_typedef_t;
#define INIT_SOMEIP_PAYLOAD_PARAMETER_TYPEDEF(NAME) \
(NAME)->id = 0; \
(NAME)->name = NULL; \
(NAME)->data_type = 0; \
(NAME)->id_ref = 0;
typedef struct _someip_payload_parameter_struct {
guint32 id;
gchar *struct_name;
guint32 length_of_length; /* default: 0 */
guint32 pad_to; /* default: 0 */
gboolean wtlv_encoding;
guint32 num_of_items;
/* array of items */
someip_payload_parameter_item_t *items;
} someip_payload_parameter_struct_t;
#define INIT_SOMEIP_PAYLOAD_PARAMETER_STRUCT(NAME) \
(NAME)->id = 0; \
(NAME)->struct_name = NULL; \
(NAME)->length_of_length = 0; \
(NAME)->pad_to = 0; \
(NAME)->wtlv_encoding = FALSE; \
(NAME)->num_of_items = 0;
typedef struct _someip_payload_parameter_enum_item {
guint64 value;
gchar *name;
} someip_payload_parameter_enum_item_t;
#define INIT_SOMEIP_PAYLOAD_PARAMETER_ENUM_ITEM(NAME) \
(NAME)->value = 0; \
(NAME)->name = NULL;
typedef struct _someip_payload_parameter_enum {
guint32 id;
gchar *name;
guint32 data_type;
guint32 id_ref;
guint32 num_of_items;
someip_payload_parameter_enum_item_t *items;
} someip_payload_parameter_enum_t;
#define INIT_SOMEIP_PAYLOAD_PARAMETER_ENUM(NAME) \
(NAME)->id = 0; \
(NAME)->name = NULL; \
(NAME)->data_type = 0; \
(NAME)->id_ref = 0; \
(NAME)->num_of_items = 0; \
(NAME)->items = NULL;
typedef struct _someip_parameter_union_item {
guint32 id;
gchar *name;
guint32 data_type;
guint32 id_ref;
int *hf_id;
gchar *filter_string;
} someip_parameter_union_item_t;
typedef struct _someip_parameter_union {
guint32 id;
gchar *name;
guint32 length_of_length; /* default: 32 */
guint32 length_of_type; /* default: 32 */
guint32 pad_to; /* default: 0 */
guint32 num_of_items;
someip_parameter_union_item_t *items;
} someip_parameter_union_t;
typedef struct _someip_parameter_union_uat {
guint32 id;
gchar *name;
guint32 length_of_length;
guint32 length_of_type;
guint32 pad_to;
guint32 num_of_items;
guint32 type_id;
gchar *type_name;
guint32 data_type;
guint32 id_ref;
gchar *filter_string;
} someip_parameter_union_uat_t;
typedef struct _someip_parameter_enum_uat {
guint32 id;
gchar *name;
guint32 data_type;
guint32 id_ref;
guint32 num_of_items;
guint32 value;
gchar *value_name;
} someip_parameter_enum_uat_t;
typedef struct _someip_parameter_array_dim {
guint32 num;
guint32 lower_limit;
guint32 upper_limit;
guint32 length_of_length;
guint32 pad_to;
} someip_parameter_array_dim_t;
typedef struct _someip_parameter_array {
guint32 id;
gchar *name;
guint32 data_type;
guint32 id_ref;
guint32 num_of_dims;
int *hf_id;
char *filter_string;
someip_parameter_array_dim_t *dims;
} someip_parameter_array_t;
typedef struct _someip_parameter_array_uat {
guint32 id;
gchar *name;
guint32 data_type;
guint32 id_ref;
guint32 num_of_dims;
gchar *filter_string;
guint32 num;
guint32 lower_limit;
guint32 upper_limit;
guint32 length_of_length;
guint32 pad_to;
} someip_parameter_array_uat_t;
typedef struct _someip_parameter_list {
guint32 service_id;
guint32 method_id;
guint32 version;
guint32 message_type;
gboolean wtlv_encoding;
guint32 num_of_items;
someip_payload_parameter_item_t *items;
} someip_parameter_list_t;
typedef struct _someip_parameter_list_uat {
guint32 service_id;
guint32 method_id;
guint32 version;
guint32 message_type;
gboolean wtlv_encoding;
guint32 num_of_params;
guint32 pos;
gchar *name;
guint32 data_type;
guint32 id_ref;
gchar *filter_string;
} someip_parameter_list_uat_t;
typedef struct _someip_parameter_struct_uat {
guint32 id;
gchar *struct_name;
guint32 length_of_length; /* default: 0 */
guint32 pad_to; /* default: 0 */
gboolean wtlv_encoding;
guint32 num_of_items;
guint32 pos;
gchar *name;
guint32 data_type;
guint32 id_ref;
gchar *filter_string;
} someip_parameter_struct_uat_t;
typedef someip_payload_parameter_base_type_list_t someip_parameter_base_type_list_uat_t;
typedef someip_payload_parameter_string_t someip_parameter_string_uat_t;
typedef someip_payload_parameter_typedef_t someip_parameter_typedef_uat_t;
typedef struct _generic_one_id_string {
guint id;
gchar *name;
} generic_one_id_string_t;
typedef struct _generic_two_id_string {
guint id;
guint id2;
gchar *name;
} generic_two_id_string_t;
static generic_one_id_string_t *someip_service_ident = NULL;
static guint someip_service_ident_num = 0;
static generic_two_id_string_t *someip_method_ident = NULL;
static guint someip_method_ident_num = 0;
static generic_two_id_string_t *someip_eventgroup_ident = NULL;
static guint someip_eventgroup_ident_num = 0;
static generic_two_id_string_t *someip_client_ident = NULL;
static guint someip_client_ident_num = 0;
static someip_parameter_list_uat_t *someip_parameter_list = NULL;
static guint someip_parameter_list_num = 0;
static someip_parameter_string_uat_t *someip_parameter_strings = NULL;
static guint someip_parameter_strings_num = 0;
static someip_parameter_typedef_uat_t *someip_parameter_typedefs = NULL;
static guint someip_parameter_typedefs_num = 0;
static someip_parameter_array_uat_t *someip_parameter_arrays = NULL;
static guint someip_parameter_arrays_num = 0;
static someip_parameter_struct_uat_t *someip_parameter_structs = NULL;
static guint someip_parameter_structs_num = 0;
static someip_parameter_union_uat_t *someip_parameter_unions = NULL;
static guint someip_parameter_unions_num = 0;
static someip_parameter_enum_uat_t *someip_parameter_enums = NULL;
static guint someip_parameter_enums_num = 0;
static someip_parameter_base_type_list_uat_t *someip_parameter_base_type_list = NULL;
static guint someip_parameter_base_type_list_num = 0;
void proto_register_someip(void);
void proto_reg_handoff_someip(void);
static void update_dynamic_hf_entries_someip_parameter_list(void);
static void update_dynamic_hf_entries_someip_parameter_arrays(void);
static void update_dynamic_hf_entries_someip_parameter_structs(void);
static void update_dynamic_hf_entries_someip_parameter_unions(void);
/* Segmentation support
* https://gitlab.com/wireshark/wireshark/-/issues/18880
*/
typedef struct _someip_segment_key {
address src_addr;
address dst_addr;
guint32 src_port;
guint32 dst_port;
someip_info_t info;
} someip_segment_key;
static guint
someip_segment_hash(gconstpointer k)
{
const someip_segment_key *key = (const someip_segment_key *)k;
guint hash_val;
hash_val = (key->info.service_id << 16 | key->info.method_id) ^
(key->info.client_id << 16 | key->info.session_id);
return hash_val;
}
static gint
someip_segment_equal(gconstpointer k1, gconstpointer k2)
{
const someip_segment_key *key1 = (someip_segment_key *)k1;
const someip_segment_key *key2 = (someip_segment_key *)k2;
return (key1->info.session_id == key2->info.session_id) &&
(key1->info.service_id == key2->info.service_id) &&
(key1->info.client_id == key2->info.client_id) &&
(key1->info.method_id == key2->info.method_id) &&
(key1->info.message_type == key2->info.message_type) &&
(key1->info.major_version == key2->info.major_version) &&
(addresses_equal(&key1->src_addr, &key2->src_addr)) &&
(addresses_equal(&key1->dst_addr, &key2->dst_addr)) &&
(key1->src_port == key2->src_port) &&
(key1->dst_port == key2->dst_port);
}
/*
* Create a fragment key for temporary use; it can point to non-
* persistent data, and so must only be used to look up and
* delete entries, not to add them.
*/
static gpointer
someip_segment_temporary_key(const packet_info *pinfo, const guint32 id _U_,
const void *data)
{
const someip_info_t *info = (const someip_info_t *)data;
someip_segment_key *key = g_slice_new(someip_segment_key);
/* Do a shallow copy of the addresses. */
copy_address_shallow(&key->src_addr, &pinfo->src);
copy_address_shallow(&key->dst_addr, &pinfo->dst);
key->src_port = pinfo->srcport;
key->dst_port = pinfo->destport;
memcpy(&key->info, info, sizeof(someip_info_t));
return (gpointer)key;
}
/*
* Create a fragment key for permanent use; it must point to persistent
* data, so that it can be used to add entries.
*/
static gpointer
someip_segment_persistent_key(const packet_info *pinfo,
const guint32 id _U_, const void *data)
{
const someip_info_t *info = (const someip_info_t *)data;
someip_segment_key *key = g_slice_new(someip_segment_key);
/* Do a deep copy of the addresses. */
copy_address(&key->src_addr, &pinfo->src);
copy_address(&key->dst_addr, &pinfo->dst);
key->src_port = pinfo->srcport;
key->dst_port = pinfo->destport;
memcpy(&key->info, info, sizeof(someip_info_t));
return (gpointer)key;
}
static void
someip_segment_free_temporary_key(gpointer ptr)
{
someip_segment_key *key = (someip_segment_key *)ptr;
if (key) {
g_slice_free(someip_segment_key, key);
}
}
static void
someip_segment_free_persistent_key(gpointer ptr)
{
someip_segment_key *key = (someip_segment_key *)ptr;
if (key) {
/* Free up the copies of the addresses from the old key. */
free_address(&key->src_addr);
free_address(&key->dst_addr);
g_slice_free(someip_segment_key, key);
}
}
static const reassembly_table_functions
someip_reassembly_table_functions = {
someip_segment_hash,
someip_segment_equal,
someip_segment_temporary_key,
someip_segment_persistent_key,
someip_segment_free_temporary_key,
someip_segment_free_persistent_key
};
static reassembly_table someip_tp_reassembly_table;
/* register a UDP SOME/IP port */
void
register_someip_port_udp(guint32 portnumber) {
dissector_add_uint("udp.port", portnumber, someip_handle_udp);
}
/* register a TCP SOME/IP port */
void
register_someip_port_tcp(guint32 portnumber) {
dissector_add_uint("tcp.port", portnumber, someip_handle_tcp);
}
/*** UAT Callbacks and Helpers ***/
static char*
check_filter_string(gchar *filter_string, guint32 id) {
char *err = NULL;
guchar c;
c = proto_check_field_name(filter_string);
if (c) {
if (c == '.') {
err = ws_strdup_printf("Filter String contains illegal chars '.' (ID: %i )", id);
} else if (g_ascii_isprint(c)) {
err = ws_strdup_printf("Filter String contains illegal chars '%c' (ID: %i)", c, id);
} else {
err = ws_strdup_printf("Filter String contains invalid byte \\%03o (ID: %i)", c, id);
}
}
return err;
}
static void
someip_free_key(gpointer key) {
wmem_free(wmem_epan_scope(), key);
}
static void
simple_free(gpointer data _U_) {
/* we need to free because of the g_strdup in post_update*/
g_free(data);
}
/* ID -> Name */
static void *
copy_generic_one_id_string_cb(void *n, const void *o, size_t size _U_) {
generic_one_id_string_t *new_rec = (generic_one_id_string_t *)n;
const generic_one_id_string_t *old_rec = (const generic_one_id_string_t *)o;
new_rec->name = g_strdup(old_rec->name);
new_rec->id = old_rec->id;
return new_rec;
}
static gboolean
update_generic_one_identifier_16bit(void *r, char **err) {
generic_one_id_string_t *rec = (generic_one_id_string_t *)r;
if (rec->id > 0xffff) {
*err = ws_strdup_printf("We currently only support 16 bit identifiers (ID: %i Name: %s)", rec->id, rec->name);
return FALSE;
}
if (rec->name == NULL || rec->name[0] == 0) {
*err = g_strdup("Name cannot be empty");
return FALSE;
}
return TRUE;
}
static void
free_generic_one_id_string_cb(void*r) {
generic_one_id_string_t *rec = (generic_one_id_string_t *)r;
/* freeing result of g_strdup */
g_free(rec->name);
rec->name = NULL;
}
static void
post_update_one_id_string_template_cb(generic_one_id_string_t *data, guint data_num, GHashTable *ht) {
guint i;
int *key = NULL;
for (i = 0; i < data_num; i++) {
key = wmem_new(wmem_epan_scope(), int);
*key = data[i].id;
g_hash_table_insert(ht, key, g_strdup(data[i].name));
}
}
/* ID/ID2 -> Name */
static void *
copy_generic_two_id_string_cb(void *n, const void *o, size_t size _U_) {
generic_two_id_string_t *new_rec = (generic_two_id_string_t *)n;
const generic_two_id_string_t *old_rec = (const generic_two_id_string_t *)o;
new_rec->name = g_strdup(old_rec->name);
new_rec->id = old_rec->id;
new_rec->id2 = old_rec->id2;
return new_rec;
}
static gboolean
update_generic_two_identifier_16bit(void *r, char **err) {
generic_two_id_string_t *rec = (generic_two_id_string_t *)r;
if ( rec->id > 0xffff ) {
*err = ws_strdup_printf("We currently only support 16 bit identifiers (ID: %i Name: %s)", rec->id, rec->name);
return FALSE;
}
if ( rec->id2 > 0xffff ) {
*err = ws_strdup_printf("We currently only support 16 bit identifiers (ID: %i ID2: %i Name: %s)", rec->id, rec->id2, rec->name);
return FALSE;
}
if (rec->name == NULL || rec->name[0] == 0) {
*err = g_strdup("Name cannot be empty");
return FALSE;
}
return TRUE;
}
static void
free_generic_two_id_string_cb(void*r) {
generic_two_id_string_t *rec = (generic_two_id_string_t *)r;
/* freeing result of g_strdup */
g_free(rec->name);
rec->name = NULL;
}
static void
post_update_generic_two_id_string_template_cb(generic_two_id_string_t *data, guint data_num, GHashTable *ht) {
guint i;
int *key = NULL;
guint tmp;
guint tmp2;
for (i = 0; i < data_num; i++) {
key = wmem_new(wmem_epan_scope(), int);
tmp = (data[i].id & 0xffff) << 16;
tmp2 = (data[i].id2 & 0xffff);
/* the hash table does not know about uint32, so we use int32 */
*key = (int)(tmp + tmp2);
g_hash_table_insert(ht, key, g_strdup(data[i].name));
}
}
char*
someip_lookup_service_name(guint16 serviceid) {
guint32 tmp = (guint32)serviceid;
if (data_someip_services == NULL) {
return NULL;
}
return (char *)g_hash_table_lookup(data_someip_services, &tmp);
}
static char*
someip_lookup_method_name(guint16 serviceid, guint16 methodid) {
guint32 tmp = (serviceid << 16) + methodid;
if (data_someip_methods == NULL) {
return NULL;
}
return (char *)g_hash_table_lookup(data_someip_methods, &tmp);
}
char*
someip_lookup_eventgroup_name(guint16 serviceid, guint16 eventgroupid) {
guint32 tmp = (serviceid << 16) + eventgroupid;
if (data_someip_eventgroups == NULL) {
return NULL;
}
return (char *)g_hash_table_lookup(data_someip_eventgroups, &tmp);
}
static char*
someip_lookup_client_name(guint16 serviceid, guint16 clientid) {
guint32 tmp = (serviceid << 16) + clientid;
if (data_someip_clients == NULL) {
return NULL;
}
return (char *)g_hash_table_lookup(data_someip_clients, &tmp);
}
/*** SOME/IP Services ***/
UAT_HEX_CB_DEF (someip_service_ident, id, generic_one_id_string_t)
UAT_CSTRING_CB_DEF (someip_service_ident, name, generic_one_id_string_t)
static void
reset_someip_service_cb(void) {
/* destroy old hash table, if it exists */
if (data_someip_services) {
g_hash_table_destroy(data_someip_services);
data_someip_services = NULL;
}
}
static void
post_update_someip_service_cb(void) {
reset_someip_service_cb();
/* create new hash table */
data_someip_services = g_hash_table_new_full(g_int_hash, g_int_equal, &someip_free_key, &simple_free);
post_update_one_id_string_template_cb(someip_service_ident, someip_service_ident_num, data_someip_services);
}
/*** SOME/IP Methods/Events/Fields ***/
UAT_HEX_CB_DEF (someip_method_ident, id, generic_two_id_string_t)
UAT_HEX_CB_DEF (someip_method_ident, id2, generic_two_id_string_t)
UAT_CSTRING_CB_DEF (someip_method_ident, name, generic_two_id_string_t)
static void
reset_someip_method_cb(void) {
/* destroy old hash table, if it exists */
if (data_someip_methods) {
g_hash_table_destroy(data_someip_methods);
data_someip_methods = NULL;
}
}
static void
post_update_someip_method_cb(void) {
reset_someip_method_cb();
/* create new hash table */
data_someip_methods = g_hash_table_new_full(g_int_hash, g_int_equal, &someip_free_key, &simple_free);
post_update_generic_two_id_string_template_cb(someip_method_ident, someip_method_ident_num, data_someip_methods);
}
/*** SOME/IP Eventgroups ***/
UAT_HEX_CB_DEF (someip_eventgroup_ident, id, generic_two_id_string_t)
UAT_HEX_CB_DEF (someip_eventgroup_ident, id2, generic_two_id_string_t)
UAT_CSTRING_CB_DEF (someip_eventgroup_ident, name, generic_two_id_string_t)
static void
reset_someip_eventgroup_cb(void) {
/* destroy old hash table, if it exists */
if (data_someip_eventgroups) {
g_hash_table_destroy(data_someip_eventgroups);
data_someip_eventgroups = NULL;
}
}
static void
post_update_someip_eventgroup_cb(void) {
reset_someip_eventgroup_cb();
/* create new hash table */
data_someip_eventgroups = g_hash_table_new_full(g_int_hash, g_int_equal, &someip_free_key, &simple_free);
post_update_generic_two_id_string_template_cb(someip_eventgroup_ident, someip_eventgroup_ident_num, data_someip_eventgroups);
}
/*** SOME/IP Clients ***/
UAT_HEX_CB_DEF(someip_client_ident, id, generic_two_id_string_t)
UAT_HEX_CB_DEF(someip_client_ident, id2, generic_two_id_string_t)
UAT_CSTRING_CB_DEF(someip_client_ident, name, generic_two_id_string_t)
static void
reset_someip_client_cb(void) {
/* destroy old hash table, if it exists */
if (data_someip_clients) {
g_hash_table_destroy(data_someip_clients);
data_someip_clients = NULL;
}
}
static void
post_update_someip_client_cb(void) {
reset_someip_client_cb();
/* create new hash table */
data_someip_clients = g_hash_table_new_full(g_int_hash, g_int_equal, &someip_free_key, &simple_free);
post_update_generic_two_id_string_template_cb(someip_client_ident, someip_client_ident_num, data_someip_clients);
}
static void
someip_payload_free_key(gpointer key) {
wmem_free(wmem_epan_scope(), key);
}
static gint64
someip_parameter_key(guint16 serviceid, guint16 methodid, guint8 version, guint8 msgtype) {
gint64 tmp1;
gint64 tmp2;
gint64 tmp3;
gint64 tmp4;
/* key:
Service-ID [16bit] | Method-ID [16bit] | Version [8bit] | Message-Type [8bit]
*/
tmp1 = (gint64)(serviceid & 0xffff);
tmp2 = (gint64)(methodid & 0xffff) << 16;
tmp3 = (gint64)(version & 0xff) << 32;
tmp4 = (gint64)(msgtype & 0xff) << 40;
return (gint64)(tmp1 + tmp2 + tmp3 + tmp4);
}
static someip_parameter_list_t*
get_parameter_config(guint16 serviceid, guint16 methodid, guint8 version, guint8 msgtype) {
gint64 *key = NULL;
someip_parameter_list_t *tmp = NULL;
if (data_someip_parameter_list == NULL) {
return NULL;
}
key = wmem_new(wmem_epan_scope(), gint64);
*key = someip_parameter_key(serviceid, methodid, version, msgtype);
tmp = (someip_parameter_list_t *)g_hash_table_lookup(data_someip_parameter_list, key);
wmem_free(wmem_epan_scope(), key);
return tmp;
}
static gpointer
get_generic_config(GHashTable *ht, gint64 id) {
if (ht == NULL) {
return NULL;
}
return (gpointer)g_hash_table_lookup(ht, &id);
}
static someip_payload_parameter_base_type_list_t*
get_base_type_config(guint32 id) {
return (someip_payload_parameter_base_type_list_t *)get_generic_config(data_someip_parameter_base_type_list, (gint64)id);
}
static someip_payload_parameter_string_t*
get_string_config(guint32 id) {
return (someip_payload_parameter_string_t *)get_generic_config(data_someip_parameter_strings, (gint64)id);
}
static someip_payload_parameter_typedef_t*
get_typedef_config(guint32 id) {
return (someip_payload_parameter_typedef_t *)get_generic_config(data_someip_parameter_typedefs, (gint64)id);
}
static someip_parameter_array_t*
get_array_config(guint32 id) {
return (someip_parameter_array_t *)get_generic_config(data_someip_parameter_arrays, (gint64)id);
}
static someip_payload_parameter_struct_t*
get_struct_config(guint32 id) {
return (someip_payload_parameter_struct_t *)get_generic_config(data_someip_parameter_structs, (gint64)id);
}
static someip_parameter_union_t*
get_union_config(guint32 id) {
return (someip_parameter_union_t *)get_generic_config(data_someip_parameter_unions, (gint64)id);
}
static someip_payload_parameter_enum_t*
get_enum_config(guint32 id) {
return (someip_payload_parameter_enum_t *)get_generic_config(data_someip_parameter_enums, (gint64)id);
}
UAT_HEX_CB_DEF(someip_parameter_list, service_id, someip_parameter_list_uat_t)
UAT_HEX_CB_DEF(someip_parameter_list, method_id, someip_parameter_list_uat_t)
UAT_DEC_CB_DEF(someip_parameter_list, version, someip_parameter_list_uat_t)
UAT_HEX_CB_DEF(someip_parameter_list, message_type, someip_parameter_list_uat_t)
UAT_BOOL_CB_DEF(someip_parameter_list, wtlv_encoding, someip_parameter_list_uat_t)
UAT_DEC_CB_DEF(someip_parameter_list, num_of_params, someip_parameter_list_uat_t)
UAT_DEC_CB_DEF(someip_parameter_list, pos, someip_parameter_list_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_list, name, someip_parameter_list_uat_t)
UAT_DEC_CB_DEF(someip_parameter_list, data_type, someip_parameter_list_uat_t)
UAT_HEX_CB_DEF(someip_parameter_list, id_ref, someip_parameter_list_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_list, filter_string, someip_parameter_list_uat_t)
static void *
copy_someip_parameter_list_cb(void *n, const void *o, size_t size _U_) {
someip_parameter_list_uat_t *new_rec = (someip_parameter_list_uat_t *)n;
const someip_parameter_list_uat_t *old_rec = (const someip_parameter_list_uat_t *)o;
if (old_rec->name) {
new_rec->name = g_strdup(old_rec->name);
} else {
new_rec->name = NULL;
}
if (old_rec->filter_string) {
new_rec->filter_string = g_strdup(old_rec->filter_string);
} else {
new_rec->filter_string = NULL;
}
new_rec->service_id = old_rec->service_id;
new_rec->method_id = old_rec->method_id;
new_rec->version = old_rec->version;
new_rec->message_type = old_rec->message_type;
new_rec->wtlv_encoding = old_rec->wtlv_encoding;
new_rec->num_of_params = old_rec->num_of_params;
new_rec->pos = old_rec->pos;
new_rec->data_type = old_rec->data_type;
new_rec->id_ref = old_rec->id_ref;
return new_rec;
}
static gboolean
update_someip_parameter_list(void *r, char **err) {
someip_parameter_list_uat_t *rec = (someip_parameter_list_uat_t *)r;
guchar c;
if (rec->service_id > 0xffff) {
*err = ws_strdup_printf("We currently only support 16 bit Service IDs (Service-ID: %i Name: %s)", rec->service_id, rec->name);
return FALSE;
}
if (rec->method_id > 0xffff) {
*err = ws_strdup_printf("We currently only support 16 bit Method IDs (Service-ID: %i Method-ID: %i Name: %s)", rec->service_id, rec->method_id, rec->name);
return FALSE;
}
if (rec->version > 0xff) {
*err = ws_strdup_printf("We currently only support 8 bit Version (Service-ID: %i Method-ID: %i Version: %d Name: %s)", rec->service_id, rec->method_id, rec->version, rec->name);
return FALSE;
}
if (rec->message_type > 0xff) {
*err = ws_strdup_printf("We currently only support 8 bit Message Type (Service-ID: %i Method-ID: %i Version: %d Message Type: %x Name: %s)", rec->service_id, rec->method_id, rec->version, rec->message_type, rec->name);
return FALSE;
}
if (rec->name == NULL || rec->name[0] == 0) {
*err = ws_strdup_printf("Name cannot be empty");
return FALSE;
}
if (rec->pos >= rec->num_of_params) {
*err = ws_strdup_printf("Position >= Number of Parameters");
return FALSE;
}
if (rec->filter_string == NULL || rec->filter_string[0] == 0) {
*err = ws_strdup_printf("Name cannot be empty");
return FALSE;
}
c = proto_check_field_name(rec->filter_string);
if (c) {
if (c == '.') {
*err = ws_strdup_printf("Filter String contains illegal chars '.' (Service-ID: %i Method-ID: %i)", rec->service_id, rec->method_id);
} else if (g_ascii_isprint(c)) {
*err = ws_strdup_printf("Filter String contains illegal chars '%c' (Service-ID: %i Method-ID: %i)", c, rec->service_id, rec->method_id);
} else {
*err = ws_strdup_printf("Filter String contains invalid byte \\%03o (Service-ID: %i Method-ID: %i)", c, rec->service_id, rec->method_id);
}
return FALSE;
}
return TRUE;
}
static void
free_someip_parameter_list_cb(void *r) {
someip_parameter_list_uat_t *rec = (someip_parameter_list_uat_t *)r;
if (rec->name) {
g_free(rec->name);
rec->name = NULL;
}
if (rec->filter_string) {
g_free(rec->filter_string);
rec->filter_string = NULL;
}
}
static void
free_someip_parameter_list(gpointer data) {
someip_parameter_list_t *list = (someip_parameter_list_t *)data;
if (list->items != NULL) {
wmem_free(wmem_epan_scope(), (void *)(list->items));
list->items = NULL;
}
wmem_free(wmem_epan_scope(), (void *)data);
}
static void
post_update_someip_parameter_list_read_in_data(someip_parameter_list_uat_t *data, guint data_num, GHashTable *ht) {
guint i = 0;
gint64 *key = NULL;
someip_parameter_list_t *list = NULL;
someip_payload_parameter_item_t *item = NULL;
someip_payload_parameter_item_t *items = NULL;
if (ht == NULL || data == NULL || data_num == 0) {
return;
}
for (i = 0; i < data_num; i++) {
/* the hash table does not know about uint64, so we use int64*/
key = wmem_new(wmem_epan_scope(), gint64);
*key = someip_parameter_key((guint16)data[i].service_id, (guint16)data[i].method_id, (guint8)data[i].version, (guint8)data[i].message_type);
list = (someip_parameter_list_t *)g_hash_table_lookup(ht, key);
if (list == NULL) {
list = wmem_new(wmem_epan_scope(), someip_parameter_list_t);
list->service_id = data[i].service_id;
list->method_id = data[i].method_id;
list->version = data[i].version;
list->message_type = data[i].message_type;
list->wtlv_encoding = data[i].wtlv_encoding;
list->num_of_items = data[i].num_of_params;
items = (someip_payload_parameter_item_t *)wmem_alloc0_array(wmem_epan_scope(), someip_payload_parameter_item_t, data[i].num_of_params);
list->items = items;
/* create new entry ... */
g_hash_table_insert(ht, key, list);
} else {
/* already present, deleting key */
wmem_free(wmem_epan_scope(), key);
}
/* and now we add to item array */
if (data[i].num_of_params == list->num_of_items && data[i].pos < list->num_of_items) {
item = &(list->items[data[i].pos]);
/* we do not care if we overwrite param */
item->name = data[i].name;
item->id_ref = data[i].id_ref;
item->pos = data[i].pos;
item->data_type = data[i].data_type;
item->filter_string = data[i].filter_string;
}
}
}
static void
reset_someip_parameter_list_cb(void) {
/* destroy old hash table, if it exists */
if (data_someip_parameter_list) {
g_hash_table_destroy(data_someip_parameter_list);
data_someip_parameter_list = NULL;
}
}
static void
post_update_someip_parameter_list_cb(void) {
reset_someip_parameter_list_cb();
data_someip_parameter_list = g_hash_table_new_full(g_int64_hash, g_int64_equal, &someip_payload_free_key, &free_someip_parameter_list);
post_update_someip_parameter_list_read_in_data(someip_parameter_list, someip_parameter_list_num, data_someip_parameter_list);
update_dynamic_hf_entries_someip_parameter_list();
}
UAT_HEX_CB_DEF(someip_parameter_enums, id, someip_parameter_enum_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_enums, name, someip_parameter_enum_uat_t)
UAT_DEC_CB_DEF(someip_parameter_enums, data_type, someip_parameter_enum_uat_t)
UAT_HEX_CB_DEF(someip_parameter_enums, id_ref, someip_parameter_enum_uat_t)
UAT_DEC_CB_DEF(someip_parameter_enums, num_of_items, someip_parameter_enum_uat_t)
UAT_HEX_CB_DEF(someip_parameter_enums, value, someip_parameter_enum_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_enums, value_name, someip_parameter_enum_uat_t)
static void *
copy_someip_parameter_enum_cb(void *n, const void *o, size_t size _U_) {
someip_parameter_enum_uat_t *new_rec = (someip_parameter_enum_uat_t *)n;
const someip_parameter_enum_uat_t *old_rec = (const someip_parameter_enum_uat_t *)o;
new_rec->id = old_rec->id;
if (old_rec->name) {
new_rec->name = g_strdup(old_rec->name);
} else {
new_rec->name = NULL;
}
new_rec->data_type = old_rec->data_type;
new_rec->id_ref = old_rec->id_ref;
new_rec->num_of_items = old_rec->num_of_items;
new_rec->value = old_rec->value;
if (old_rec->value_name) {
new_rec->value_name = g_strdup(old_rec->value_name);
} else {
new_rec->value_name = NULL;
}
return new_rec;
}
static gboolean
update_someip_parameter_enum(void *r, char **err) {
someip_parameter_enum_uat_t *rec = (someip_parameter_enum_uat_t *)r;
/* enum name is not used in a filter yet. */
if (rec->name == NULL || rec->name[0] == 0) {
*err = ws_strdup_printf("Name cannot be empty (ID: 0x%x)!", rec->id);
return FALSE;
}
if (rec->value_name == NULL || rec->value_name[0] == 0) {
*err = ws_strdup_printf("Value Name cannot be empty (ID: 0x%x)!", rec->id);
return FALSE;
}
if (rec->num_of_items == 0) {
*err = ws_strdup_printf("Number_of_Items = 0 (ID: 0x%x)!", rec->id);
return FALSE;
}
if (rec->data_type == SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_ENUM) {
*err = ws_strdup_printf("An enum cannot reference an enum (ID: 0x%x)!", rec->id);
return FALSE;
}
return TRUE;
}
static void
free_someip_parameter_enum_cb(void*r) {
someip_parameter_enum_uat_t *rec = (someip_parameter_enum_uat_t *)r;
if (rec->name) {
g_free(rec->name);
rec->name = NULL;
}
if (rec->value_name) {
g_free(rec->value_name);
rec->value_name = NULL;
}
}
static void
free_someip_parameter_enum(gpointer data) {
someip_payload_parameter_enum_t *list = (someip_payload_parameter_enum_t *)data;
if (list->items != NULL) {
wmem_free(wmem_epan_scope(), (void *)(list->items));
list->items = NULL;
}
wmem_free(wmem_epan_scope(), (void *)data);
}
static void
post_update_someip_parameter_enum_read_in_data(someip_parameter_enum_uat_t *data, guint data_num, GHashTable *ht) {
guint i = 0;
guint j = 0;
gint64 *key = NULL;
someip_payload_parameter_enum_t *list = NULL;
someip_payload_parameter_enum_item_t *item = NULL;
if (ht == NULL || data == NULL || data_num == 0) {
return;
}
for (i = 0; i < data_num; i++) {
key = wmem_new(wmem_epan_scope(), gint64);
*key = data[i].id;
list = (someip_payload_parameter_enum_t *)g_hash_table_lookup(ht, key);
if (list == NULL) {
list = wmem_new(wmem_epan_scope(), someip_payload_parameter_enum_t);
INIT_SOMEIP_PAYLOAD_PARAMETER_ENUM(list)
list->id = data[i].id;
list->name = data[i].name;
list->data_type = data[i].data_type;
list->id_ref = data[i].id_ref;
list->num_of_items = data[i].num_of_items;
list->items = (someip_payload_parameter_enum_item_t *)wmem_alloc0_array(wmem_epan_scope(), someip_payload_parameter_enum_item_t, list->num_of_items);
/* create new entry ... */
g_hash_table_insert(ht, key, list);
} else {
/* don't need it anymore */
wmem_free(wmem_epan_scope(), key);
}
/* and now we add to item array */
if (list->num_of_items > 0 && data[i].num_of_items == list->num_of_items) {
/* find first empty slot */
for (j = 0; j < list->num_of_items && list->items[j].name != NULL; j++);
if (j < list->num_of_items) {
item = &(list->items[j]);
INIT_SOMEIP_PAYLOAD_PARAMETER_ENUM_ITEM(item)
/* we do not care if we overwrite param */
item->value = data[i].value;
item->name = data[i].value_name;
}
}
}
}
static void
reset_someip_parameter_enum_cb(void) {
/* destroy old hash table, if it exists */
if (data_someip_parameter_enums) {
g_hash_table_destroy(data_someip_parameter_enums);
data_someip_parameter_enums = NULL;
}
}
static void
post_update_someip_parameter_enum_cb(void) {
reset_someip_parameter_enum_cb();
data_someip_parameter_enums = g_hash_table_new_full(g_int64_hash, g_int64_equal, &someip_payload_free_key, &free_someip_parameter_enum);
post_update_someip_parameter_enum_read_in_data(someip_parameter_enums, someip_parameter_enums_num, data_someip_parameter_enums);
}
UAT_HEX_CB_DEF(someip_parameter_arrays, id, someip_parameter_array_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_arrays, name, someip_parameter_array_uat_t)
UAT_DEC_CB_DEF(someip_parameter_arrays, data_type, someip_parameter_array_uat_t)
UAT_HEX_CB_DEF(someip_parameter_arrays, id_ref, someip_parameter_array_uat_t)
UAT_DEC_CB_DEF(someip_parameter_arrays, num_of_dims, someip_parameter_array_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_arrays, filter_string, someip_parameter_array_uat_t)
UAT_DEC_CB_DEF(someip_parameter_arrays, num, someip_parameter_array_uat_t)
UAT_DEC_CB_DEF(someip_parameter_arrays, lower_limit, someip_parameter_array_uat_t)
UAT_DEC_CB_DEF(someip_parameter_arrays, upper_limit, someip_parameter_array_uat_t)
UAT_DEC_CB_DEF(someip_parameter_arrays, length_of_length, someip_parameter_array_uat_t)
UAT_DEC_CB_DEF(someip_parameter_arrays, pad_to, someip_parameter_array_uat_t)
static void *
copy_someip_parameter_array_cb(void *n, const void *o, size_t size _U_) {
someip_parameter_array_uat_t *new_rec = (someip_parameter_array_uat_t *)n;
const someip_parameter_array_uat_t *old_rec = (const someip_parameter_array_uat_t *)o;
new_rec->id = old_rec->id;
if (old_rec->name) {
new_rec->name = g_strdup(old_rec->name);
} else {
new_rec->name = NULL;
}
new_rec->data_type = old_rec->data_type;
new_rec->id_ref = old_rec->id_ref;
new_rec->num_of_dims = old_rec->num_of_dims;
if (old_rec->filter_string) {
new_rec->filter_string = g_strdup(old_rec->filter_string);
} else {
new_rec->filter_string = NULL;
}
new_rec->num = old_rec->num;
new_rec->lower_limit = old_rec->lower_limit;
new_rec->upper_limit = old_rec->upper_limit;
new_rec->length_of_length = old_rec->length_of_length;
new_rec->pad_to = old_rec->pad_to;
return new_rec;
}
static gboolean
update_someip_parameter_array(void *r, char **err) {
someip_parameter_array_uat_t *rec = (someip_parameter_array_uat_t *)r;
char *tmp;
if (rec->name == NULL || rec->name[0] == 0) {
*err = ws_strdup_printf("Name cannot be empty (ID: 0x%x)!", rec->id);
return FALSE;
}
if (rec->num >= rec->num_of_dims) {
*err = ws_strdup_printf("Dimension >= Number of Dimensions (ID: 0x%x)!", rec->id);
return FALSE;
}
if (rec->filter_string == NULL || rec->filter_string[0] == 0) {
*err = ws_strdup_printf("Filter String cannot be empty (ID: 0x%x)!", rec->id);
return FALSE;
}
tmp = check_filter_string(rec->filter_string, rec->id);
if (tmp != NULL) {
*err = tmp;
return FALSE;
}
if (rec->data_type == SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_ARRAY && rec->id == rec->id_ref) {
*err = ws_strdup_printf("An array cannot include itself (ID: 0x%x)!", rec->id);
return FALSE;
}
return TRUE;
}
static void
free_someip_parameter_array_cb(void*r) {
someip_parameter_array_uat_t *rec = (someip_parameter_array_uat_t *)r;
if (rec->name) g_free(rec->name);
rec->name = NULL;
if (rec->filter_string) g_free(rec->filter_string);
rec->filter_string = NULL;
}
static void
free_someip_parameter_array(gpointer data) {
someip_parameter_array_t *list = (someip_parameter_array_t *)data;
if (list->dims != NULL) {
wmem_free(wmem_epan_scope(), (void *)(list->dims));
list->dims = NULL;
}
wmem_free(wmem_epan_scope(), (void *)data);
}
static void
post_update_someip_parameter_array_read_in_data(someip_parameter_array_uat_t *data, guint data_num, GHashTable *ht) {
guint i = 0;
gint64 *key = NULL;
someip_parameter_array_t *list = NULL;
someip_parameter_array_dim_t *item = NULL;
someip_parameter_array_dim_t *items = NULL;
if (ht == NULL || data == NULL || data_num == 0) {
return;
}
for (i = 0; i < data_num; i++) {
key = wmem_new(wmem_epan_scope(), gint64);
*key = data[i].id;
list = (someip_parameter_array_t *)g_hash_table_lookup(ht, key);
if (list == NULL) {
list = wmem_new(wmem_epan_scope(), someip_parameter_array_t);
list->id = data[i].id;
list->name = data[i].name;
list->data_type = data[i].data_type;
list->id_ref = data[i].id_ref;
list->num_of_dims = data[i].num_of_dims;
list->filter_string = data[i].filter_string;
items = (someip_parameter_array_dim_t *)wmem_alloc0_array(wmem_epan_scope(), someip_parameter_array_dim_t, data[i].num_of_dims);
list->dims = items;
/* create new entry ... */
g_hash_table_insert(ht, key, list);
}
/* and now we add to item array */
if (data[i].num_of_dims == list->num_of_dims && data[i].num < list->num_of_dims) {
item = &(list->dims[data[i].num]);
/* we do not care if we overwrite param */
item->num = data[i].num;
item->lower_limit = data[i].lower_limit;
item->upper_limit = data[i].upper_limit;
item->length_of_length = data[i].length_of_length;
item->pad_to = data[i].pad_to;
}
}
}
static void
post_update_someip_parameter_array_cb(void) {
/* destroy old hash table, if it exists */
if (data_someip_parameter_arrays) {
g_hash_table_destroy(data_someip_parameter_arrays);
data_someip_parameter_arrays = NULL;
}
data_someip_parameter_arrays = g_hash_table_new_full(g_int64_hash, g_int64_equal, &someip_payload_free_key, &free_someip_parameter_array);
post_update_someip_parameter_array_read_in_data(someip_parameter_arrays, someip_parameter_arrays_num, data_someip_parameter_arrays);
update_dynamic_hf_entries_someip_parameter_arrays();
}
static void
reset_someip_parameter_array_cb(void) {
/* destroy old hash table, if it exists */
if (data_someip_parameter_arrays) {
g_hash_table_destroy(data_someip_parameter_arrays);
data_someip_parameter_arrays = NULL;
}
}
UAT_HEX_CB_DEF(someip_parameter_structs, id, someip_parameter_struct_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_structs, struct_name, someip_parameter_struct_uat_t)
UAT_DEC_CB_DEF(someip_parameter_structs, length_of_length, someip_parameter_struct_uat_t)
UAT_DEC_CB_DEF(someip_parameter_structs, pad_to, someip_parameter_struct_uat_t)
UAT_BOOL_CB_DEF(someip_parameter_structs, wtlv_encoding, someip_parameter_struct_uat_t)
UAT_DEC_CB_DEF(someip_parameter_structs, num_of_items, someip_parameter_struct_uat_t)
UAT_DEC_CB_DEF(someip_parameter_structs, pos, someip_parameter_struct_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_structs, name, someip_parameter_struct_uat_t)
UAT_DEC_CB_DEF(someip_parameter_structs, data_type, someip_parameter_struct_uat_t)
UAT_HEX_CB_DEF(someip_parameter_structs, id_ref, someip_parameter_struct_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_structs, filter_string, someip_parameter_struct_uat_t)
static void *
copy_someip_parameter_struct_cb(void *n, const void *o, size_t size _U_) {
someip_parameter_struct_uat_t *new_rec = (someip_parameter_struct_uat_t *)n;
const someip_parameter_struct_uat_t *old_rec = (const someip_parameter_struct_uat_t *)o;
new_rec->id = old_rec->id;
if (old_rec->struct_name) {
new_rec->struct_name = g_strdup(old_rec->struct_name);
} else {
new_rec->struct_name = NULL;
}
new_rec->length_of_length = old_rec->length_of_length;
new_rec->pad_to = old_rec->pad_to;
new_rec->wtlv_encoding = old_rec->wtlv_encoding;
new_rec->num_of_items = old_rec->num_of_items;
new_rec->pos = old_rec->pos;
if (old_rec->name) {
new_rec->name = g_strdup(old_rec->name);
} else {
new_rec->name = NULL;
}
new_rec->data_type = old_rec->data_type;
new_rec->id_ref = old_rec->id_ref;
if (old_rec->filter_string) {
new_rec->filter_string = g_strdup(old_rec->filter_string);
} else {
new_rec->filter_string = NULL;
}
return new_rec;
}
static gboolean
update_someip_parameter_struct(void *r, char **err) {
someip_parameter_struct_uat_t *rec = (someip_parameter_struct_uat_t *)r;
char *tmp = NULL;
if (rec->struct_name == NULL || rec->struct_name[0] == 0) {
*err = ws_strdup_printf("Struct name cannot be empty (ID: 0x%x)!", rec->id);
return FALSE;
}
if (rec->filter_string == NULL || rec->filter_string[0] == 0) {
*err = ws_strdup_printf("Struct name cannot be empty (ID: 0x%x)!", rec->id);
return FALSE;
}
tmp = check_filter_string(rec->filter_string, rec->id);
if (tmp != NULL) {
*err = tmp;
return FALSE;
}
if (rec->name == NULL || rec->name[0] == 0) {
*err = ws_strdup_printf("Name cannot be empty (ID: 0x%x)!", rec->id);
return FALSE;
}
if (rec->pos >= rec->num_of_items) {
*err = ws_strdup_printf("Position >= Number of Parameters (ID: 0x%x)!", rec->id);
return FALSE;
}
if (rec->data_type == SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_STRUCT && rec->id == rec->id_ref) {
*err = ws_strdup_printf("A struct cannot include itself (ID: 0x%x)!", rec->id);
return FALSE;
}
return TRUE;
}
static void
free_someip_parameter_struct_cb(void *r) {
someip_parameter_struct_uat_t *rec = (someip_parameter_struct_uat_t *)r;
if (rec->struct_name) g_free(rec->struct_name);
rec->struct_name = NULL;
if (rec->name) g_free(rec->name);
rec->name = NULL;
if (rec->filter_string) g_free(rec->filter_string);
rec->filter_string = NULL;
}
static void
free_someip_parameter_struct(gpointer data) {
someip_payload_parameter_struct_t *list = (someip_payload_parameter_struct_t *)data;
if (list->items != NULL) {
wmem_free(wmem_epan_scope(), (void *)(list->items));
list->items = NULL;
}
wmem_free(wmem_epan_scope(), (void *)data);
}
static void
post_update_someip_parameter_struct_read_in_data(someip_parameter_struct_uat_t *data, guint data_num, GHashTable *ht) {
guint i = 0;
gint64 *key = NULL;
someip_payload_parameter_struct_t *list = NULL;
someip_payload_parameter_item_t *item = NULL;
someip_payload_parameter_item_t *items = NULL;
if (ht == NULL || data == NULL || data_num == 0) {
return;
}
for (i = 0; i < data_num; i++) {
key = wmem_new(wmem_epan_scope(), gint64);
*key = data[i].id;
list = (someip_payload_parameter_struct_t *)g_hash_table_lookup(ht, key);
if (list == NULL) {
list = wmem_new(wmem_epan_scope(), someip_payload_parameter_struct_t);
INIT_SOMEIP_PAYLOAD_PARAMETER_STRUCT(list)
list->id = data[i].id;
list->struct_name = data[i].struct_name;
list->length_of_length = data[i].length_of_length;
list->pad_to = data[i].pad_to;
list->wtlv_encoding = data[i].wtlv_encoding;
list->num_of_items = data[i].num_of_items;
items = (someip_payload_parameter_item_t *)wmem_alloc0_array(wmem_epan_scope(), someip_payload_parameter_item_t, data[i].num_of_items);
list->items = items;
/* create new entry ... */
g_hash_table_insert(ht, key, list);
}
/* and now we add to item array */
if (data[i].num_of_items == list->num_of_items && data[i].pos < list->num_of_items) {
item = &(list->items[data[i].pos]);
INIT_SOMEIP_PAYLOAD_PARAMETER_ITEM(item)
/* we do not care if we overwrite param */
item->name = data[i].name;
item->id_ref = data[i].id_ref;
item->pos = data[i].pos;
item->data_type = data[i].data_type;
item->filter_string = data[i].filter_string;
}
}
}
static void
post_update_someip_parameter_struct_cb(void) {
/* destroy old hash table, if it exists */
if (data_someip_parameter_structs) {
g_hash_table_destroy(data_someip_parameter_structs);
data_someip_parameter_structs = NULL;
}
data_someip_parameter_structs = g_hash_table_new_full(g_int64_hash, g_int64_equal, &someip_payload_free_key, &free_someip_parameter_struct);
post_update_someip_parameter_struct_read_in_data(someip_parameter_structs, someip_parameter_structs_num, data_someip_parameter_structs);
update_dynamic_hf_entries_someip_parameter_structs();
}
static void
reset_someip_parameter_struct_cb(void) {
/* destroy old hash table, if it exists */
if (data_someip_parameter_structs) {
g_hash_table_destroy(data_someip_parameter_structs);
data_someip_parameter_structs = NULL;
}
}
UAT_HEX_CB_DEF(someip_parameter_unions, id, someip_parameter_union_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_unions, name, someip_parameter_union_uat_t)
UAT_DEC_CB_DEF(someip_parameter_unions, length_of_length, someip_parameter_union_uat_t)
UAT_DEC_CB_DEF(someip_parameter_unions, length_of_type, someip_parameter_union_uat_t)
UAT_DEC_CB_DEF(someip_parameter_unions, pad_to, someip_parameter_union_uat_t)
UAT_DEC_CB_DEF(someip_parameter_unions, num_of_items, someip_parameter_union_uat_t)
UAT_DEC_CB_DEF(someip_parameter_unions, type_id, someip_parameter_union_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_unions, type_name, someip_parameter_union_uat_t)
UAT_DEC_CB_DEF(someip_parameter_unions, data_type, someip_parameter_union_uat_t)
UAT_HEX_CB_DEF(someip_parameter_unions, id_ref, someip_parameter_union_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_unions, filter_string, someip_parameter_union_uat_t)
static void *
copy_someip_parameter_union_cb(void *n, const void *o, size_t size _U_) {
someip_parameter_union_uat_t *new_rec = (someip_parameter_union_uat_t *)n;
const someip_parameter_union_uat_t *old_rec = (const someip_parameter_union_uat_t *)o;
new_rec->id = old_rec->id;
if (old_rec->name) {
new_rec->name = g_strdup(old_rec->name);
} else {
new_rec->name = NULL;
}
new_rec->length_of_length = old_rec->length_of_length;
new_rec->length_of_type = old_rec->length_of_type;
new_rec->pad_to = old_rec->pad_to;
new_rec->num_of_items = old_rec->num_of_items;
new_rec->type_id = old_rec->type_id;
if (old_rec->type_name) {
new_rec->type_name = g_strdup(old_rec->type_name);
} else {
new_rec->type_name = NULL;
}
new_rec->data_type = old_rec->data_type;
new_rec->id_ref = old_rec->id_ref;
if (old_rec->filter_string) {
new_rec->filter_string = g_strdup(old_rec->filter_string);
} else {
new_rec->filter_string = NULL;
}
return new_rec;
}
static gboolean
update_someip_parameter_union(void *r, char **err) {
someip_parameter_union_uat_t *rec = (someip_parameter_union_uat_t *)r;
gchar *tmp;
if (rec->name == NULL || rec->name[0] == 0) {
*err = ws_strdup_printf("Union name cannot be empty (ID: 0x%x)!", rec->id);
return FALSE;
}
tmp = check_filter_string(rec->filter_string, rec->id);
if (tmp != NULL) {
*err = tmp;
return FALSE;
}
if (rec->type_name == NULL || rec->type_name[0] == 0) {
*err = ws_strdup_printf("Type Name cannot be empty (ID: 0x%x)!", rec->id);
return FALSE;
}
if (rec->data_type == SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_UNION && rec->id == rec->id_ref) {
*err = ws_strdup_printf("A union cannot include itself (ID: 0x%x)!", rec->id);
return FALSE;
}
return TRUE;
}
static void
free_someip_parameter_union_cb(void*r) {
someip_parameter_union_uat_t *rec = (someip_parameter_union_uat_t *)r;
if (rec->name) {
g_free(rec->name);
rec->name = NULL;
}
if (rec->type_name) {
g_free(rec->type_name);
rec->type_name = NULL;
}
if (rec->filter_string) {
g_free(rec->filter_string);
rec->filter_string = NULL;
}
}
static void
free_someip_parameter_union(gpointer data) {
someip_parameter_union_t *list = (someip_parameter_union_t *)data;
if (list->items != NULL) {
wmem_free(wmem_epan_scope(), (void *)(list->items));
list->items = NULL;
}
wmem_free(wmem_epan_scope(), (void *)data);
}
static void
post_update_someip_parameter_union_read_in_data(someip_parameter_union_uat_t *data, guint data_num, GHashTable *ht) {
guint i = 0;
guint j = 0;
gint64 *key = NULL;
someip_parameter_union_t *list = NULL;
someip_parameter_union_item_t *item = NULL;
if (ht == NULL || data == NULL || data_num == 0) {
return;
}
for (i = 0; i < data_num; i++) {
key = wmem_new(wmem_epan_scope(), gint64);
*key = data[i].id;
list = (someip_parameter_union_t *)g_hash_table_lookup(ht, key);
if (list == NULL) {
list = wmem_new(wmem_epan_scope(), someip_parameter_union_t);
list->id = data[i].id;
list->name = data[i].name;
list->length_of_length = data[i].length_of_length;
list->length_of_type = data[i].length_of_type;
list->pad_to = data[i].pad_to;
list->num_of_items = data[i].num_of_items;
list->items = (someip_parameter_union_item_t *)wmem_alloc0_array(wmem_epan_scope(), someip_parameter_union_item_t, list->num_of_items);
/* create new entry ... */
g_hash_table_insert(ht, key, list);
} else {
/* don't need it anymore */
wmem_free(wmem_epan_scope(), key);
}
/* and now we add to item array */
if (data[i].num_of_items == list->num_of_items) {
/* find first empty slot */
for (j = 0; j < list->num_of_items && list->items[j].name != NULL; j++);
if (j < list->num_of_items) {
item = &(list->items[j]);
/* we do not care if we overwrite param */
item->id = data[i].type_id;
item->name = data[i].type_name;
item->data_type = data[i].data_type;
item->id_ref = data[i].id_ref;
item->filter_string = data[i].filter_string;
}
}
}
}
static void
reset_someip_parameter_union_cb(void) {
/* destroy old hash table, if it exists */
if (data_someip_parameter_unions) {
g_hash_table_destroy(data_someip_parameter_unions);
data_someip_parameter_unions = NULL;
}
}
static void
post_update_someip_parameter_union_cb(void) {
reset_someip_parameter_union_cb();
data_someip_parameter_unions = g_hash_table_new_full(g_int64_hash, g_int64_equal, &someip_payload_free_key, &free_someip_parameter_union);
post_update_someip_parameter_union_read_in_data(someip_parameter_unions, someip_parameter_unions_num, data_someip_parameter_unions);
update_dynamic_hf_entries_someip_parameter_unions();
}
UAT_HEX_CB_DEF(someip_parameter_base_type_list, id, someip_parameter_base_type_list_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_base_type_list, name, someip_parameter_base_type_list_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_base_type_list, data_type, someip_parameter_base_type_list_uat_t)
UAT_BOOL_CB_DEF(someip_parameter_base_type_list, big_endian, someip_parameter_base_type_list_uat_t)
UAT_DEC_CB_DEF(someip_parameter_base_type_list, bitlength_base_type, someip_parameter_base_type_list_uat_t)
UAT_DEC_CB_DEF(someip_parameter_base_type_list, bitlength_encoded_type, someip_parameter_base_type_list_uat_t)
static void *
copy_someip_parameter_base_type_list_cb(void *n, const void *o, size_t size _U_) {
someip_parameter_base_type_list_uat_t *new_rec = (someip_parameter_base_type_list_uat_t *)n;
const someip_parameter_base_type_list_uat_t *old_rec = (const someip_parameter_base_type_list_uat_t *)o;
if (old_rec->name) {
new_rec->name = g_strdup(old_rec->name);
} else {
new_rec->name = NULL;
}
if (old_rec->data_type) {
new_rec->data_type = g_strdup(old_rec->data_type);
} else {
new_rec->data_type = NULL;
}
new_rec->id = old_rec->id;
new_rec->big_endian = old_rec->big_endian;
new_rec->bitlength_base_type = old_rec->bitlength_base_type;
new_rec->bitlength_encoded_type = old_rec->bitlength_encoded_type;
return new_rec;
}
static gboolean
update_someip_parameter_base_type_list(void *r, char **err) {
someip_parameter_base_type_list_uat_t *rec = (someip_parameter_base_type_list_uat_t *)r;
if (rec->name == NULL || rec->name[0] == 0) {
*err = ws_strdup_printf("Name cannot be empty (ID: 0x%x)!", rec->id);
return FALSE;
}
if (rec->id > 0xffffffff) {
*err = ws_strdup_printf("We currently only support 32 bit IDs (%i) Name: %s", rec->id, rec->name);
return FALSE;
}
if (rec->bitlength_base_type != 8 && rec->bitlength_base_type != 16 && rec->bitlength_base_type != 32 && rec->bitlength_base_type != 64) {
*err = ws_strdup_printf("Bit length of base type may only be 8, 16, 32, or 64. Affected item: ID (%i) Name (%s).", rec->id, rec->name);
return FALSE;
}
/* As long as we check that rec->bitlength_base_type equals rec->bitlength_encoded_type, we do not have to check that bitlength_encoded_type is 8, 16, 32, or 64. */
if (rec->bitlength_base_type != rec->bitlength_encoded_type) {
*err = ws_strdup_printf("Bit length of encoded type must be equal to bit length of base type. Affected item: ID (%i) Name (%s). Shortened types supported by Signal-PDU dissector.", rec->id, rec->name);
return FALSE;
}
return TRUE;
}
static void
free_someip_parameter_base_type_list_cb(void*r) {
someip_parameter_base_type_list_uat_t *rec = (someip_parameter_base_type_list_uat_t *)r;
if (rec->name) {
g_free(rec->name);
rec->name = NULL;
}
if (rec->data_type) {
g_free(rec->data_type);
rec->data_type = NULL;
}
}
static void
reset_someip_parameter_base_type_list_cb(void) {
/* destroy old hash table, if it exists */
if (data_someip_parameter_base_type_list) {
g_hash_table_destroy(data_someip_parameter_base_type_list);
data_someip_parameter_base_type_list = NULL;
}
}
static void
post_update_someip_parameter_base_type_list_cb(void) {
guint i;
gint64 *key = NULL;
reset_someip_parameter_base_type_list_cb();
/* we don't need to free the data as long as we don't alloc it first */
data_someip_parameter_base_type_list = g_hash_table_new_full(g_int64_hash, g_int64_equal, &someip_payload_free_key, NULL);
if (data_someip_parameter_base_type_list == NULL || someip_parameter_base_type_list == NULL || someip_parameter_base_type_list_num == 0) {
return;
}
if (someip_parameter_base_type_list_num > 0) {
for (i = 0; i < someip_parameter_base_type_list_num; i++) {
key = wmem_new(wmem_epan_scope(), gint64);
*key = someip_parameter_base_type_list[i].id;
g_hash_table_insert(data_someip_parameter_base_type_list, key, &someip_parameter_base_type_list[i]);
}
}
}
UAT_HEX_CB_DEF(someip_parameter_strings, id, someip_parameter_string_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_strings, name, someip_parameter_string_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_strings, encoding, someip_parameter_string_uat_t)
UAT_BOOL_CB_DEF(someip_parameter_strings, dynamic_length, someip_parameter_string_uat_t)
UAT_DEC_CB_DEF(someip_parameter_strings, max_length, someip_parameter_string_uat_t)
UAT_DEC_CB_DEF(someip_parameter_strings, length_of_length, someip_parameter_string_uat_t)
UAT_BOOL_CB_DEF(someip_parameter_strings, big_endian, someip_parameter_string_uat_t)
UAT_DEC_CB_DEF(someip_parameter_strings, pad_to, someip_parameter_string_uat_t)
static void *
copy_someip_parameter_string_list_cb(void *n, const void *o, size_t size _U_) {
someip_parameter_string_uat_t *new_rec = (someip_parameter_string_uat_t *)n;
const someip_parameter_string_uat_t *old_rec = (const someip_parameter_string_uat_t *)o;
if (old_rec->name) {
new_rec->name = g_strdup(old_rec->name);
} else {
new_rec->name = NULL;
}
if (old_rec->encoding) {
new_rec->encoding = g_strdup(old_rec->encoding);
} else {
new_rec->encoding = NULL;
}
new_rec->id = old_rec->id;
new_rec->dynamic_length = old_rec->dynamic_length;
new_rec->max_length = old_rec->max_length;
new_rec->length_of_length = old_rec->length_of_length;
new_rec->big_endian = old_rec->big_endian;
new_rec->pad_to = old_rec->pad_to;
return new_rec;
}
static gboolean
update_someip_parameter_string_list(void *r, char **err) {
someip_parameter_string_uat_t *rec = (someip_parameter_string_uat_t *)r;
if (rec->name == NULL || rec->name[0] == 0) {
*err = ws_strdup_printf("Name cannot be empty (ID: 0x%x)!", rec->id);
return FALSE;
}
if (rec->id > 0xffffffff) {
*err = ws_strdup_printf("We currently only support 32 bit IDs (%i) Name: %s", rec->id, rec->name);
return FALSE;
}
if (rec->max_length > 0xffffffff) {
*err = ws_strdup_printf("We currently only support 32 bit max_length (%i) Name: %s", rec->max_length, rec->name);
return FALSE;
}
if (rec->length_of_length != 0 && rec->length_of_length != 8 && rec->length_of_length != 16 && rec->length_of_length != 32) {
*err = ws_strdup_printf("length_of_length can be only 0, 8, 16, or 32 but not %d (IDs: %i Name: %s)", rec->length_of_length, rec->id, rec->name);
return FALSE;
}
return TRUE;
}
static void
free_someip_parameter_string_list_cb(void*r) {
someip_parameter_string_uat_t *rec = (someip_parameter_string_uat_t *)r;
if (rec->name) {
g_free(rec->name);
rec->name = NULL;
}
if (rec->encoding) {
g_free(rec->encoding);
rec->encoding = NULL;
}
}
static void
reset_someip_parameter_string_list_cb(void) {
/* destroy old hash table, if it exists */
if (data_someip_parameter_strings) {
g_hash_table_destroy(data_someip_parameter_strings);
data_someip_parameter_strings = NULL;
}
}
static void
post_update_someip_parameter_string_list_cb(void) {
guint i;
gint64 *key = NULL;
/* destroy old hash table, if it exists */
if (data_someip_parameter_strings) {
g_hash_table_destroy(data_someip_parameter_strings);
data_someip_parameter_strings = NULL;
}
/* we don't need to free the data as long as we don't alloc it first */
data_someip_parameter_strings = g_hash_table_new_full(g_int64_hash, g_int64_equal, &someip_payload_free_key, NULL);
if (data_someip_parameter_strings == NULL || someip_parameter_strings == NULL || someip_parameter_strings_num == 0) {
return;
}
if (someip_parameter_strings_num > 0) {
for (i = 0; i < someip_parameter_strings_num; i++) {
key = wmem_new(wmem_epan_scope(), gint64);
*key = someip_parameter_strings[i].id;
g_hash_table_insert(data_someip_parameter_strings, key, &someip_parameter_strings[i]);
}
}
}
UAT_HEX_CB_DEF(someip_parameter_typedefs, id, someip_parameter_typedef_uat_t)
UAT_CSTRING_CB_DEF(someip_parameter_typedefs, name, someip_parameter_typedef_uat_t)
UAT_DEC_CB_DEF(someip_parameter_typedefs, data_type, someip_parameter_typedef_uat_t)
UAT_HEX_CB_DEF(someip_parameter_typedefs, id_ref, someip_parameter_typedef_uat_t)
static void *
copy_someip_parameter_typedef_list_cb(void *n, const void *o, size_t size _U_) {
someip_parameter_typedef_uat_t *new_rec = (someip_parameter_typedef_uat_t *)n;
const someip_parameter_typedef_uat_t *old_rec = (const someip_parameter_typedef_uat_t *)o;
if (old_rec->name) {
new_rec->name = g_strdup(old_rec->name);
} else {
new_rec->name = NULL;
}
new_rec->id = old_rec->id;
new_rec->data_type = old_rec->data_type;
new_rec->id_ref = old_rec->id_ref;
return new_rec;
}
static gboolean
update_someip_parameter_typedef_list(void *r, char **err) {
someip_parameter_typedef_uat_t *rec = (someip_parameter_typedef_uat_t *)r;
if (rec->id > 0xffffffff) {
*err = ws_strdup_printf("We currently only support 32 bit IDs (%i) Name: %s", rec->id, rec->name);
return FALSE;
}
if (rec->data_type == SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_TYPEDEF && rec->id == rec->id_ref) {
*err = ws_strdup_printf("A typedef cannot reference itself (ID: 0x%x)!", rec->id);
return FALSE;
}
return TRUE;
}
static void
free_someip_parameter_typedef_list_cb(void*r) {
someip_parameter_typedef_uat_t *rec = (someip_parameter_typedef_uat_t *)r;
if (rec->name) {
g_free(rec->name);
rec->name = NULL;
}
}
static void
reset_someip_parameter_typedef_list_cb(void) {
/* destroy old hash table, if it exists */
if (data_someip_parameter_typedefs) {
g_hash_table_destroy(data_someip_parameter_typedefs);
data_someip_parameter_typedefs = NULL;
}
}
static void
post_update_someip_parameter_typedef_list_cb(void) {
guint i;
gint64 *key = NULL;
reset_someip_parameter_typedef_list_cb();
/* we don't need to free the data as long as we don't alloc it first */
data_someip_parameter_typedefs = g_hash_table_new_full(g_int64_hash, g_int64_equal, &someip_payload_free_key, NULL);
if (data_someip_parameter_typedefs == NULL || someip_parameter_typedefs == NULL || someip_parameter_typedefs_num == 0) {
return;
}
if (someip_parameter_typedefs_num > 0) {
for (i = 0; i < someip_parameter_typedefs_num; i++) {
/* key: ID [32bit] */
key = wmem_new(wmem_epan_scope(), gint64);
*key = someip_parameter_typedefs[i].id;
g_hash_table_insert(data_someip_parameter_typedefs, key, &someip_parameter_typedefs[i]);
}
}
}
static void
deregister_dynamic_hf_data(hf_register_info **hf_array, guint *hf_size) {
if (*hf_array) {
/* Unregister all fields used before */
for (guint i = 0; i < *hf_size; i++) {
if ((*hf_array)[i].p_id != NULL) {
proto_deregister_field(proto_someip, *((*hf_array)[i].p_id));
g_free((*hf_array)[i].p_id);
(*hf_array)[i].p_id = NULL;
}
}
proto_add_deregistered_data(*hf_array);
*hf_array = NULL;
*hf_size = 0;
}
}
static void
allocate_dynamic_hf_data(hf_register_info **hf_array, guint *hf_size, guint new_size) {
*hf_array = g_new0(hf_register_info, new_size);
*hf_size = new_size;
}
typedef struct _param_return_attibutes_t {
enum ftenum type;
int display_base;
gchar *base_type_name;
} param_return_attributes_t;
static param_return_attributes_t
get_param_attributes(guint8 data_type, guint32 id_ref) {
gint count = 10;
param_return_attributes_t ret;
ret.type = FT_NONE;
ret.display_base = BASE_NONE;
ret.base_type_name = NULL;
/* we limit the number of typedef recursion to "count" */
while (data_type == SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_TYPEDEF && count > 0) {
someip_payload_parameter_typedef_t *tmp = get_typedef_config(id_ref);
/* this should not be a typedef since we don't support recursion of typedefs */
if (tmp != NULL) {
data_type = tmp->data_type;
id_ref = tmp->id_ref;
}
count--;
}
if (data_type == SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_ENUM) {
someip_payload_parameter_enum_t *tmp = get_enum_config(id_ref);
/* this can only be a base type ... */
if (tmp != NULL) {
data_type = tmp->data_type;
id_ref = tmp->id_ref;
}
}
if (data_type == SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_STRING) {
someip_payload_parameter_string_t *tmp = get_string_config(id_ref);
ret.type = FT_STRING;
ret.display_base = BASE_NONE;
if (tmp != NULL) {
ret.base_type_name = tmp->name;
}
return ret;
}
if (data_type == SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_BASE_TYPE) {
someip_payload_parameter_base_type_list_t *tmp = get_base_type_config(id_ref);
ret.display_base = BASE_DEC;
if (tmp != NULL) {
ret.base_type_name = tmp->name;
if (g_strcmp0(tmp->data_type, "uint8") == 0) {
ret.type = FT_UINT8;
} else if (g_strcmp0(tmp->data_type, "uint16") == 0) {
ret.type = FT_UINT16;
} else if (g_strcmp0(tmp->data_type, "uint24") == 0) {
ret.type = FT_UINT24;
} else if (g_strcmp0(tmp->data_type, "uint32") == 0) {
ret.type = FT_UINT32;
} else if (g_strcmp0(tmp->data_type, "uint40") == 0) {
ret.type = FT_UINT40;
} else if (g_strcmp0(tmp->data_type, "uint48") == 0) {
ret.type = FT_UINT48;
} else if (g_strcmp0(tmp->data_type, "uint56") == 0) {
ret.type = FT_UINT56;
} else if (g_strcmp0(tmp->data_type, "uint64") == 0) {
ret.type = FT_UINT64;
} else if (g_strcmp0(tmp->data_type, "int8") == 0) {
ret.type = FT_INT8;
} else if (g_strcmp0(tmp->data_type, "int16") == 0) {
ret.type = FT_INT16;
} else if (g_strcmp0(tmp->data_type, "int24") == 0) {
ret.type = FT_INT24;
} else if (g_strcmp0(tmp->data_type, "int32") == 0) {
ret.type = FT_INT32;
} else if (g_strcmp0(tmp->data_type, "int40") == 0) {
ret.type = FT_INT40;
} else if (g_strcmp0(tmp->data_type, "int48") == 0) {
ret.type = FT_INT48;
} else if (g_strcmp0(tmp->data_type, "int56") == 0) {
ret.type = FT_INT56;
} else if (g_strcmp0(tmp->data_type, "int64") == 0) {
ret.type = FT_INT64;
} else if (g_strcmp0(tmp->data_type, "float32") == 0) {
ret.type = FT_FLOAT;
ret.display_base = BASE_NONE;
} else if (g_strcmp0(tmp->data_type, "float64") == 0) {
ret.type = FT_DOUBLE;
ret.display_base = BASE_NONE;
} else {
ret.type = FT_NONE;
}
} else {
ret.type = FT_NONE;
}
}
/* all other types are handled or don't need a type! */
return ret;
}
static gint*
update_dynamic_hf_entry(hf_register_info *hf_array, int pos, guint32 data_type, guint id_ref, char *param_name, char *filter_string) {
param_return_attributes_t attribs;
gint *hf_id;
attribs = get_param_attributes(data_type, id_ref);
if (hf_array == NULL || attribs.type == FT_NONE) {
return NULL;
}
hf_id = g_new(gint, 1);
*hf_id = -1;
hf_array[pos].p_id = hf_id;
hf_array[pos].hfinfo.strings = NULL;
hf_array[pos].hfinfo.bitmask = 0;
hf_array[pos].hfinfo.blurb = NULL;
if (attribs.base_type_name == NULL) {
hf_array[pos].hfinfo.name = g_strdup(param_name);
} else {
hf_array[pos].hfinfo.name = ws_strdup_printf("%s [%s]", param_name, attribs.base_type_name);
}
hf_array[pos].hfinfo.abbrev = ws_strdup_printf("%s.%s", SOMEIP_NAME_PREFIX, filter_string);
hf_array[pos].hfinfo.type = attribs.type;
hf_array[pos].hfinfo.display = attribs.display_base;
HFILL_INIT(hf_array[pos]);
return hf_id;
}
static void
update_dynamic_param_hf_entry(gpointer key _U_, gpointer value, gpointer data) {
guint32 *pos = (guint32 *)data;
someip_parameter_list_t *list = (someip_parameter_list_t *)value;
guint i = 0;
for (i = 0; i < list->num_of_items ; i++) {
if (*pos >= dynamic_hf_param_size) {
return;
}
someip_payload_parameter_item_t *item = &(list->items[i]);
item->hf_id = update_dynamic_hf_entry(dynamic_hf_param, *pos, item->data_type, item->id_ref, item->name, item->filter_string);
if (item->hf_id != NULL) {
(*pos)++;
}
}
}
static void
update_dynamic_array_hf_entry(gpointer key _U_, gpointer value, gpointer data) {
guint32 *pos = (guint32 *)data;
someip_parameter_array_t *item = (someip_parameter_array_t *)value;
if (*pos >= dynamic_hf_array_size) {
return;
}
item->hf_id = update_dynamic_hf_entry(dynamic_hf_array, *pos, item->data_type, item->id_ref, item->name, item->filter_string);
if (item->hf_id != NULL) {
(*pos)++;
}
}
static void
update_dynamic_struct_hf_entry(gpointer key _U_, gpointer value, gpointer data) {
guint32 *pos = (guint32 *)data;
someip_payload_parameter_struct_t *list = (someip_payload_parameter_struct_t *)value;
guint i = 0;
for (i = 0; i < list->num_of_items; i++) {
if (*pos >= dynamic_hf_struct_size) {
return;
}
someip_payload_parameter_item_t *item = &(list->items[i]);
item->hf_id = update_dynamic_hf_entry(dynamic_hf_struct, *pos, item->data_type, item->id_ref, item->name, item->filter_string);
if (item->hf_id != NULL) {
(*pos)++;
}
}
}
static void
update_dynamic_union_hf_entry(gpointer key _U_, gpointer value, gpointer data) {
guint32 *pos = (guint32 *)data;
someip_parameter_union_t *list = (someip_parameter_union_t *)value;
guint i = 0;
for (i = 0; i < list->num_of_items; i++) {
if (*pos >= dynamic_hf_union_size) {
return;
}
someip_parameter_union_item_t *item = &(list->items[i]);
item->hf_id = update_dynamic_hf_entry(dynamic_hf_union, *pos, item->data_type, item->id_ref, item->name, item->filter_string);
if (item->hf_id != NULL) {
(*pos)++;
}
}
}
static void
update_dynamic_hf_entries_someip_parameter_list(void) {
if (data_someip_parameter_list != NULL) {
deregister_dynamic_hf_data(&dynamic_hf_param, &dynamic_hf_param_size);
allocate_dynamic_hf_data(&dynamic_hf_param, &dynamic_hf_param_size, someip_parameter_list_num);
guint32 pos = 0;
g_hash_table_foreach(data_someip_parameter_list, update_dynamic_param_hf_entry, &pos);
proto_register_field_array(proto_someip, dynamic_hf_param, pos);
}
}
static void
update_dynamic_hf_entries_someip_parameter_arrays(void) {
if (data_someip_parameter_arrays != NULL) {
deregister_dynamic_hf_data(&dynamic_hf_array, &dynamic_hf_array_size);
allocate_dynamic_hf_data(&dynamic_hf_array, &dynamic_hf_array_size, someip_parameter_arrays_num);
guint32 pos = 0;
g_hash_table_foreach(data_someip_parameter_arrays, update_dynamic_array_hf_entry, &pos);
proto_register_field_array(proto_someip, dynamic_hf_array, pos);
}
}
static void
update_dynamic_hf_entries_someip_parameter_structs(void) {
if (data_someip_parameter_structs != NULL) {
deregister_dynamic_hf_data(&dynamic_hf_struct, &dynamic_hf_struct_size);
allocate_dynamic_hf_data(&dynamic_hf_struct, &dynamic_hf_struct_size, someip_parameter_structs_num);
guint32 pos = 0;
g_hash_table_foreach(data_someip_parameter_structs, update_dynamic_struct_hf_entry, &pos);
proto_register_field_array(proto_someip, dynamic_hf_struct, pos);
}
}
static void
update_dynamic_hf_entries_someip_parameter_unions(void) {
if (data_someip_parameter_unions != NULL) {
deregister_dynamic_hf_data(&dynamic_hf_union, &dynamic_hf_union_size);
allocate_dynamic_hf_data(&dynamic_hf_union, &dynamic_hf_union_size, someip_parameter_unions_num);
guint32 pos = 0;
g_hash_table_foreach(data_someip_parameter_unions, update_dynamic_union_hf_entry, &pos);
proto_register_field_array(proto_someip, dynamic_hf_union, pos);
}
}
static void
expert_someip_payload_truncated(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, gint offset, gint length) {
proto_tree_add_expert(tree, pinfo, &ef_someip_payload_truncated, tvb, offset, length);
col_append_str(pinfo->cinfo, COL_INFO, " [SOME/IP Payload: Truncated payload!]");
}
static void
expert_someip_payload_malformed(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, gint offset, gint length) {
proto_tree_add_expert(tree, pinfo, &ef_someip_payload_malformed, tvb, offset, length);
col_append_str(pinfo->cinfo, COL_INFO, " [SOME/IP Payload: Malformed payload!]");
}
static void
expert_someip_payload_config_error(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, gint offset, gint length, const char *message) {
proto_tree_add_expert_format(tree, pinfo, &ef_someip_payload_config_error, tvb, offset, length, "SOME/IP Payload: %s", message);
col_append_str(pinfo->cinfo, COL_INFO, " [SOME/IP Payload: Config Error]");
}
/*******************************************
**************** Statistics ***************
*******************************************/
static void
someip_messages_stats_tree_init(stats_tree *st) {
st_node_ip_src = stats_tree_create_node(st, st_str_ip_src, 0, STAT_DT_INT, TRUE);
stat_node_set_flags(st, st_str_ip_src, 0, FALSE, ST_FLG_SORT_TOP);
st_node_ip_dst = stats_tree_create_node(st, st_str_ip_dst, 0, STAT_DT_INT, TRUE);
}
static tap_packet_status
someip_messages_stats_tree_packet(stats_tree *st, packet_info *pinfo, epan_dissect_t *edt _U_, const void *p, tap_flags_t flags _U_) {
static gchar tmp_srv_str[128];
static gchar tmp_meth_str[128];
static gchar tmp_addr_str[128];
int tmp;
DISSECTOR_ASSERT(p);
const someip_messages_tap_t *data = (const someip_messages_tap_t *)p;
snprintf(tmp_addr_str, sizeof(tmp_addr_str) - 1, "%s (%s)", address_to_str(pinfo->pool, &pinfo->net_src), address_to_name(&pinfo->net_src));
tick_stat_node(st, st_str_ip_src, 0, FALSE);
int src_id = tick_stat_node(st, tmp_addr_str, st_node_ip_src, TRUE);
snprintf(tmp_addr_str, sizeof(tmp_addr_str) - 1, "%s (%s)", address_to_str(pinfo->pool, &pinfo->net_dst), address_to_name(&pinfo->net_dst));
tick_stat_node(st, st_str_ip_dst, 0, FALSE);
int dst_id = tick_stat_node(st, tmp_addr_str, st_node_ip_dst, TRUE);
char *service_name = someip_lookup_service_name(data->service_id);
if (service_name == NULL) {
snprintf(tmp_srv_str, sizeof(tmp_srv_str) - 1, "Service 0x%04x", data->service_id);
} else {
snprintf(tmp_srv_str, sizeof(tmp_srv_str) - 1, "Service 0x%04x (%s)", data->service_id, service_name);
}
char *method_name = someip_lookup_method_name(data->service_id, data->method_id);
if (method_name == NULL) {
snprintf(tmp_meth_str, sizeof(tmp_meth_str) - 1, "Method 0x%04x %s", data->method_id,
val_to_str(data->message_type, someip_msg_type, "Message-Type: 0x%02x"));
} else {
snprintf(tmp_meth_str, sizeof(tmp_meth_str) - 1, "Method 0x%04x (%s) %s", data->method_id, method_name,
val_to_str(data->message_type, someip_msg_type, "Message-Type: 0x%02x"));
}
tmp = tick_stat_node(st, tmp_srv_str, src_id, TRUE);
tick_stat_node(st, tmp_meth_str, tmp, FALSE);
tmp = tick_stat_node(st, tmp_srv_str, dst_id, TRUE);
tick_stat_node(st, tmp_meth_str, tmp, FALSE);
return TAP_PACKET_REDRAW;
}
/*******************************************
******** SOME/IP Payload Dissector ********
*******************************************/
static int
dissect_someip_payload_parameter(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset, guint8 data_type, guint32 idref, gchar *name, int *hf_id_ptr, gint wtlv_offset);
static int
dissect_someip_payload_parameters(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset, someip_payload_parameter_item_t *items, guint32 num_of_items, gboolean wtlv);
/* add a flexible size length field, -1 for error*/
static gint64
dissect_someip_payload_length_field(tvbuff_t *tvb, packet_info *pinfo, proto_tree *subtree, gint offset, gint length_of_length_field) {
proto_item *ti;
guint32 tmp = 0;
switch (length_of_length_field) {
case 8:
ti = proto_tree_add_item_ret_uint(subtree, hf_payload_length_field_8bit, tvb, offset, length_of_length_field / 8, ENC_NA, &tmp);
proto_item_set_hidden(ti);
break;
case 16:
ti = proto_tree_add_item_ret_uint(subtree, hf_payload_length_field_16bit, tvb, offset, length_of_length_field / 8, ENC_BIG_ENDIAN, &tmp);
proto_item_set_hidden(ti);
break;
case 32:
ti = proto_tree_add_item_ret_uint(subtree, hf_payload_length_field_32bit, tvb, offset, length_of_length_field / 8, ENC_BIG_ENDIAN, &tmp);
proto_item_set_hidden(ti);
break;
default:
proto_tree_add_expert_format(subtree, pinfo, &ef_someip_payload_config_error, tvb, offset, 0,
"SOME/IP: Payload: length of length field does not make sense: %d bits", length_of_length_field);
col_append_str(pinfo->cinfo, COL_INFO, " [SOME/IP: Payload Config Error]");
return -1;
}
return (gint64)tmp;
}
/* add a flexible size type field */
static gint64
dissect_someip_payload_type_field(tvbuff_t *tvb, packet_info *pinfo, proto_tree *subtree, gint offset, gint length_of_type_field) {
proto_item *ti;
guint32 tmp = 0;
switch (length_of_type_field) {
case 8:
ti = proto_tree_add_item_ret_uint(subtree, hf_payload_type_field_8bit, tvb, offset, length_of_type_field / 8, ENC_NA, &tmp);
proto_item_set_hidden(ti);
break;
case 16:
ti = proto_tree_add_item_ret_uint(subtree, hf_payload_type_field_16bit, tvb, offset, length_of_type_field / 8, ENC_BIG_ENDIAN, &tmp);
proto_item_set_hidden(ti);
break;
case 32:
ti = proto_tree_add_item_ret_uint(subtree, hf_payload_type_field_32bit, tvb, offset, length_of_type_field / 8, ENC_BIG_ENDIAN, &tmp);
proto_item_set_hidden(ti);
break;
default:
proto_tree_add_expert_format(subtree, pinfo, &ef_someip_payload_config_error, tvb, offset, 0,
"SOME/IP: Payload: length of type field does not make sense: %d bits", length_of_type_field);
col_append_str(pinfo->cinfo, COL_INFO, " [SOME/IP: Payload Config Error]");
return -1;
}
return (gint64)tmp;
}
static guint32
dissect_someip_payload_add_wtlv_if_needed(tvbuff_t *tvb, packet_info *pinfo _U_, gint offset, proto_item *ti_root, proto_tree *parent_tree) {
static int * const tag_bitfield[] = {
&hf_payload_wtlv_tag_res,
&hf_payload_wtlv_tag_wire_type,
&hf_payload_wtlv_tag_data_id,
NULL
};
if (offset < 0) {
return 0;
}
proto_tree *tree = parent_tree;
if (tree == NULL) {
tree = proto_item_add_subtree(ti_root, ett_someip_parameter);
}
guint64 tagdata = 0;
proto_item *ti = proto_tree_add_bitmask_ret_uint64(tree, tvb, offset, hf_payload_wtlv_tag, ett_someip_wtlv_tag, tag_bitfield, ENC_BIG_ENDIAN, &tagdata);
proto_item_set_hidden(ti);
guint wiretype = (guint)((tagdata & SOMEIP_WTLV_MASK_WIRE_TYPE) >> 12);
switch (wiretype) {
case 5:
return 8;
case 6:
return 16;
case 7:
return 32;
default:
return 0;
}
}
static gint
dissect_someip_payload_base_type(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, gint offset, guint8 data_type, guint32 id, gchar *name, int *hf_id_ptr, gint wtlv_offset) {
someip_payload_parameter_base_type_list_t *base_type = NULL;
someip_payload_parameter_enum_t *enum_config = NULL;
guint32 basetype_id = 0;
guint32 enum_id = 0;
gint param_length = -1;
proto_item *ti = NULL;
guint64 value = 0;
guint32 value32 = 0;
gboolean value_set = FALSE;
guint32 i = 0;
gchar *value_name = NULL;
gboolean big_endian = TRUE;
int hf_id = -1;
if (hf_id_ptr != NULL) {
hf_id = *hf_id_ptr;
}
switch (data_type) {
case SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_BASE_TYPE:
basetype_id = id;
break;
case SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_ENUM:
enum_id = id;
enum_config = get_enum_config(enum_id);
if (enum_config == NULL) {
return 0;
}
basetype_id = enum_config->id_ref;
break;
default:
return 0;
}
base_type = get_base_type_config(basetype_id);
if (base_type == NULL) {
return 0;
}
big_endian = base_type->big_endian;
param_length = (gint)((base_type->bitlength_base_type) / 8);
if (param_length > tvb_captured_length_remaining(tvb, 0) - offset) {
return 0;
}
if (hf_id != -1) {
if (strncmp(base_type->data_type, "uint", 4) == 0) {
if (base_type->bitlength_base_type > 32) {
ti = proto_tree_add_item_ret_uint64(tree, hf_id, tvb, offset, param_length, big_endian ? ENC_BIG_ENDIAN : ENC_LITTLE_ENDIAN, &value);
} else {
ti = proto_tree_add_item_ret_uint(tree, hf_id, tvb, offset, param_length, big_endian ? ENC_BIG_ENDIAN : ENC_LITTLE_ENDIAN, &value32);
value = (guint64)value32;
}
value_set = TRUE;
} else {
ti = proto_tree_add_item(tree, hf_id, tvb, offset, param_length, big_endian ? ENC_BIG_ENDIAN : ENC_LITTLE_ENDIAN);
}
} else {
if (name == NULL) {
ti = proto_tree_add_string_format(tree, hf_payload_str_base, tvb, offset, param_length, base_type->name, "[%s]", base_type->name);
} else {
ti = proto_tree_add_string_format(tree, hf_payload_str_base, tvb, offset, param_length, base_type->name, "%s [%s]", name, base_type->name);
}
}
dissect_someip_payload_add_wtlv_if_needed(tvb, pinfo, wtlv_offset, ti, NULL);
if (enum_config != NULL && value_set == TRUE) {
for (i = 0; i < enum_config->num_of_items; i++) {
if (enum_config->items[i].value == value) {
value_name = enum_config->items[i].name;
break;
}
}
if (value_name != NULL) {
proto_item_append_text(ti, " (%s)", value_name);
}
}
return param_length;
}
static int
dissect_someip_payload_string(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset, guint32 id, gchar *name, int *hf_id_ptr, gint wtlv_offset) {
someip_payload_parameter_string_t *config = NULL;
guint8 *buf = NULL;
guint32 i = 0;
proto_item *ti = NULL;
proto_tree *subtree = NULL;
gint64 tmp = 0;
guint32 length = 0;
gint offset_orig = offset;
guint str_encoding = 0;
int hf_id = hf_payload_str_string;
if (hf_id_ptr != NULL) {
hf_id = *hf_id_ptr;
}
config = get_string_config(id);
if (config == NULL) {
return 0;
}
if (wtlv_offset >= 0) {
ti = proto_tree_add_string_format(tree, hf_id, tvb, wtlv_offset, 0, name, "%s [%s]", name, config->name);
} else {
ti = proto_tree_add_string_format(tree, hf_id, tvb, offset, 0, name, "%s [%s]", name, config->name);
}
subtree = proto_item_add_subtree(ti, ett_someip_string);
guint32 length_of_length = dissect_someip_payload_add_wtlv_if_needed(tvb, pinfo, wtlv_offset, ti, NULL);
/* WTLV length overrides configured length */
if (config->length_of_length == 0 && length_of_length == 0) {
length = config->max_length;
} else {
if (length_of_length == 0) {
length_of_length = config->length_of_length;
}
if (tvb_captured_length_remaining(tvb, offset) < (gint)(length_of_length >> 3)) {
expert_someip_payload_malformed(tree, pinfo, tvb, offset, 0);
return 0;
}
tmp = dissect_someip_payload_length_field(tvb, pinfo, subtree, offset, length_of_length);
if (tmp < 0) {
/* error */
return length_of_length / 8;
}
length = (guint32)tmp;
offset += length_of_length / 8;
}
if ((guint32)tvb_captured_length_remaining(tvb, offset) < length) {
expert_someip_payload_malformed(subtree, pinfo, tvb, offset, 0);
return 0;
}
if (strcmp(config->encoding, "utf-8") == 0) {
str_encoding = ENC_UTF_8 | ENC_NA;
} else if (strcmp(config->encoding, "utf-16") == 0) {
str_encoding = ENC_UTF_16 | (config->big_endian ? ENC_BIG_ENDIAN : ENC_LITTLE_ENDIAN);
} else {
str_encoding = ENC_ASCII | ENC_NA;
}
buf = tvb_get_string_enc(pinfo->pool, tvb, offset, length, str_encoding);
/* sanitizing buffer */
if (str_encoding & ENC_ASCII || str_encoding & ENC_UTF_8) {
for (i = 0; i < length; i++) {
if (buf[i] > 0x00 && buf[i] < 0x20) {
buf[i] = 0x20;
}
}
}
proto_item_append_text(ti, ": %s", buf);
offset += length;
proto_item_set_end(ti, tvb, offset);
return offset - offset_orig;
}
static int
dissect_someip_payload_struct(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset_orig, guint32 id, gchar *name, gint wtlv_offset) {
someip_payload_parameter_struct_t *config = NULL;
proto_tree *subtree = NULL;
proto_item *ti = NULL;
tvbuff_t *subtvb = tvb;
gint64 length = 0;
gint offset = offset_orig;
config = get_struct_config(id);
if (config == NULL || tree == NULL || tvb == NULL) {
return 0;
}
if (wtlv_offset >= 0) {
ti = proto_tree_add_string_format(tree, hf_payload_str_struct, tvb, wtlv_offset, 0, config->struct_name, "struct %s [%s]", name, config->struct_name);
} else {
ti = proto_tree_add_string_format(tree, hf_payload_str_struct, tvb, offset, 0, config->struct_name, "struct %s [%s]", name, config->struct_name);
}
subtree = proto_item_add_subtree(ti, ett_someip_struct);
guint32 length_of_length = dissect_someip_payload_add_wtlv_if_needed(tvb, pinfo, wtlv_offset, ti, subtree);
/* WTLV length overrides configured length */
if (length_of_length == 0) {
length_of_length = config->length_of_length;
}
if (tvb_captured_length_remaining(tvb, 0) < (gint)(length_of_length >> 3)) {
expert_someip_payload_malformed(tree, pinfo, tvb, offset, 0);
return 0;
};
if (length_of_length != 0) {
length = dissect_someip_payload_length_field(tvb, pinfo, subtree, offset, length_of_length);
if (length < 0) {
/* error */
return length_of_length / 8;
}
offset += length_of_length / 8;
int endpos = offset_orig + (length_of_length / 8) + (guint32)length;
proto_item_set_end(ti, tvb, endpos);
subtvb = tvb_new_subset_length_caplen(tvb, 0, endpos, endpos);
}
offset += dissect_someip_payload_parameters(subtvb, pinfo, subtree, offset, config->items, config->num_of_items, config->wtlv_encoding);
if (length_of_length == 0) {
proto_item_set_end(ti, tvb, offset);
return offset - offset_orig;
} else {
return (length_of_length / 8) + (guint32)length;
}
}
static int
dissect_someip_payload_typedef(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset, guint32 id, gchar *name _U_, int *hf_id, gint wtlv_offset) {
someip_payload_parameter_typedef_t *config = NULL;
config = get_typedef_config(id);
if (config == NULL) {
return 0;
}
/* we basically skip over the typedef for now */
return dissect_someip_payload_parameter(tvb, pinfo, tree, offset, (guint8)config->data_type, config->id_ref, config->name, hf_id, wtlv_offset);
}
/* returns bytes parsed, length needs to be gint to encode "non-existing" as -1 */
static int
dissect_someip_payload_array_dim_length(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset_orig, gint *length, gint *lower_limit, gint *upper_limit,
someip_parameter_array_t *config, gint current_dim, guint32 length_of_length) {
gint offset = offset_orig;
gint64 tmp = 0;
*lower_limit = config->dims[current_dim].lower_limit;
*upper_limit = config->dims[current_dim].upper_limit;
/* length needs to be -1, if we do not have a dynamic length array */
*length = -1;
if (length_of_length == 0) {
length_of_length = config->dims[current_dim].length_of_length;
}
if (length_of_length > 0) {
/* we are filling the length with number of bytes we found in the packet */
tmp = dissect_someip_payload_length_field(tvb, pinfo, tree, offset, length_of_length);
if (tmp < 0) {
/* leave *length = -1 */
return length_of_length/8;
}
*length = (gint32)tmp;
offset += length_of_length/8;
} else {
/* without a length field, the number of elements needs be fixed */
if (config->dims[current_dim].lower_limit != config->dims[current_dim].upper_limit) {
proto_tree_add_expert_format(tree, pinfo, &ef_someip_payload_static_array_min_not_max, tvb, offset_orig, 0,
"Static array config with Min!=Max (%d, %d)", config->dims[current_dim].lower_limit, config->dims[current_dim].upper_limit);
col_append_str(pinfo->cinfo, COL_INFO, " [SOME/IP Payload: Static array config with Min!=Max!]");
return 0;
}
}
return offset - offset_orig;
}
/* returns bytes parsed, length needs to be gint to encode "non-existing" as -1 */
static gint
dissect_someip_payload_array_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset_orig, gint length, gint lower_limit, gint upper_limit,
someip_parameter_array_t *config) {
tvbuff_t *subtvb = NULL;
guint32 offset = offset_orig;
guint32 bytes_parsed = 0;
guint32 ret = 0;
gint count = 0;
if (length != -1) {
if (length <= tvb_captured_length_remaining(tvb, offset)) {
subtvb = tvb_new_subset_length_caplen(tvb, offset, length, length);
/* created subtvb. so we set offset=0 */
offset = 0;
} else {
expert_someip_payload_truncated(tree, pinfo, tvb, offset, tvb_captured_length_remaining(tvb, offset));
return tvb_captured_length_remaining(tvb, offset);
}
} else {
subtvb = tvb;
}
while ((length == -1 && count < upper_limit) || ((gint)offset < length)) {
bytes_parsed = dissect_someip_payload_parameter(subtvb, pinfo, tree, offset, (guint8)config->data_type, config->id_ref, config->name, config->hf_id, -1);
if (bytes_parsed == 0) {
/* does this make sense? */
return 1;
}
offset += bytes_parsed;
count++;
}
if (count<lower_limit && count>upper_limit) {
proto_tree_add_expert_format(tree, pinfo, &ef_someip_payload_dyn_array_not_within_limit, tvb, offset_orig, length,
"Number of items (%d) outside limit %d-%d", count, lower_limit, upper_limit);
col_append_str(pinfo->cinfo, COL_INFO, " [SOME/IP Payload: Dynamic array does not stay between Min and Max values]");
}
if (length != -1) {
/* we created subtvb first and set offset to 0 */
ret = offset;
} else {
ret = offset - offset_orig;
}
return ret;
}
static gint
dissect_someip_payload_array_dim(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset_orig, gint length, gint lower_limit, gint upper_limit, someip_parameter_array_t *config, guint current_dim, gchar *name, guint32 length_of_length) {
proto_item *ti = NULL;
proto_tree *subtree = NULL;
gint sub_length = 0;
gint sub_lower_limit = 0;
gint sub_upper_limit = 0;
gint i = 0;
gint sub_offset = 0;
gint offset = offset_orig;
if (config->num_of_dims == current_dim + 1) {
/* only payload left. :) */
offset += dissect_someip_payload_array_payload(tvb, pinfo, tree, offset, length, lower_limit, upper_limit, config);
} else {
if (length != -1) {
while (offset < offset_orig + (gint)length) {
sub_offset = offset;
ti = proto_tree_add_string_format(tree, hf_payload_str_array, tvb, sub_offset, 0, name, "subarray (dim: %d, limit %d-%d)", current_dim + 1, sub_lower_limit, sub_upper_limit);
subtree = proto_item_add_subtree(ti, ett_someip_array_dim);
offset += dissect_someip_payload_array_dim_length(tvb, pinfo, subtree, offset, &sub_length, &sub_lower_limit, &sub_upper_limit, config, current_dim + 1, length_of_length);
if (tvb_captured_length_remaining(tvb, offset) < (gint)sub_length) {
expert_someip_payload_truncated(subtree, pinfo, tvb, offset, tvb_captured_length_remaining(tvb, offset));
return 0;
}
offset += dissect_someip_payload_array_dim(tvb, pinfo, subtree, offset, sub_length, sub_lower_limit, sub_upper_limit, config, current_dim + 1, name, length_of_length);
proto_item_set_end(ti, tvb, offset);
}
} else {
/* Multi-dim static array */
sub_lower_limit = config->dims[current_dim].lower_limit;
sub_upper_limit = config->dims[current_dim].upper_limit;
for (i = 0; i < upper_limit; i++) {
offset += dissect_someip_payload_array_dim(tvb, pinfo, tree, offset, -1, sub_lower_limit, sub_upper_limit, config, current_dim + 1, name, length_of_length);
}
}
}
return offset - offset_orig;
}
static int
dissect_someip_payload_array(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset_orig, guint32 id, gchar *name, gint wtlv_offset) {
someip_parameter_array_t *config = NULL;
proto_tree *subtree;
proto_item *ti = NULL;
gint offset = offset_orig;
gint length = 0;
gint size_of_length = 0;
gint lower_limit = 0;
gint upper_limit = 0;
config = get_array_config(id);
if (config == NULL) {
return 0;
}
if (config->num_of_dims == 0 || config->dims == NULL) {
expert_someip_payload_config_error(tree, pinfo, tvb, offset, 0, "Array config has not enough dimensions for this array!");
return 0;
}
ti = proto_tree_add_string_format(tree, hf_payload_str_array, tvb, offset, 0, config->name, "array %s", name);
subtree = proto_item_add_subtree(ti, ett_someip_array);
guint32 length_of_length = dissect_someip_payload_add_wtlv_if_needed(tvb, pinfo, wtlv_offset, ti, subtree);
offset += dissect_someip_payload_array_dim_length(tvb, pinfo, subtree, offset_orig, &length, &lower_limit, &upper_limit, config, 0, length_of_length);
size_of_length = offset - offset_orig;
if (length != -1) {
proto_item_append_text(ti, " (elements limit: %d-%d)", lower_limit, upper_limit);
} else {
proto_item_append_text(ti, " (elements limit: %d)", upper_limit);
}
offset += dissect_someip_payload_array_dim(tvb, pinfo, subtree, offset, length, lower_limit, upper_limit, config, 0, name, length_of_length);
proto_item_set_end(ti, tvb, offset);
if (length >= 0) {
/* length field present */
return size_of_length + length;
} else {
/* We have no length field, so we return what has been parsed! */
return offset - offset_orig;
}
}
static int
dissect_someip_payload_union(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset_orig, guint32 id, gchar *name, gint wtlv_offset) {
someip_parameter_union_t *config = NULL;
someip_parameter_union_item_t *item = NULL;
proto_item *ti = NULL;
proto_tree *subtree = NULL;
tvbuff_t *subtvb;
gint buf_length = -1;
gint64 tmp = 0;
guint32 length = 0;
guint32 type = 0;
guint32 i = 0;
gint offset = offset_orig;
config = get_union_config(id);
buf_length = tvb_captured_length_remaining(tvb, 0);
if (config == NULL) {
expert_someip_payload_config_error(tree, pinfo, tvb, offset, 0, "Union ID not configured");
return 0;
}
if (wtlv_offset >= 0) {
ti = proto_tree_add_string_format(tree, hf_payload_str_union, tvb, wtlv_offset, 0, name, "union %s [%s]", name, config->name);
} else {
ti = proto_tree_add_string_format(tree, hf_payload_str_union, tvb, offset_orig, 0, name, "union %s [%s]", name, config->name);
}
subtree = proto_item_add_subtree(ti, ett_someip_union);
guint32 length_of_length = dissect_someip_payload_add_wtlv_if_needed(tvb, pinfo, wtlv_offset, ti, subtree);
if (length_of_length == 0) {
length_of_length = config->length_of_length;
}
if ((length_of_length + config->length_of_type) / 8 > (guint)buf_length - offset) {
expert_someip_payload_truncated(tree, pinfo, tvb, offset, tvb_captured_length_remaining(tvb, offset));
return 0;
}
tmp = dissect_someip_payload_length_field(tvb, pinfo, subtree, offset_orig, length_of_length);
if (tmp == -1) {
return offset - offset_orig;
} else {
length = (guint32)tmp;
}
tmp = dissect_someip_payload_type_field(tvb, pinfo, subtree, offset_orig + length_of_length / 8, config->length_of_type);
if (tmp == -1) {
return offset - offset_orig;
} else {
type = (guint32)tmp;
}
offset += (length_of_length + config->length_of_type) / 8;
proto_item_set_end(ti, tvb, offset + length);
item = NULL;
for (i = 0; i < config->num_of_items; i++) {
if (config->items[i].id == type && config->items[i].name != NULL) {
item = &(config->items[i]);
}
}
if (item != NULL) {
subtvb = tvb_new_subset_length_caplen(tvb, offset, length, length);
dissect_someip_payload_parameter(subtvb, pinfo, subtree, 0, (guint8)item->data_type, item->id_ref, item->name, item->hf_id, -1);
} else {
expert_someip_payload_config_error(tree, pinfo, tvb, offset, 0, "Union type not configured");
}
return length + (config->length_of_type + length_of_length) / 8;
}
static int
dissect_someip_payload_parameter(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset, guint8 data_type, guint32 idref, gchar *name, int *hf_id_ptr, gint wtlv_offset) {
gint bytes_parsed = 0;
switch (data_type) {
case SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_TYPEDEF:
bytes_parsed = dissect_someip_payload_typedef(tvb, pinfo, tree, offset, idref, name, hf_id_ptr, wtlv_offset);
break;
case SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_BASE_TYPE:
case SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_ENUM:
bytes_parsed = dissect_someip_payload_base_type(tvb, pinfo, tree, offset, data_type, idref, name, hf_id_ptr, wtlv_offset);
break;
case SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_STRING:
bytes_parsed = dissect_someip_payload_string(tvb, pinfo, tree, offset, idref, name, hf_id_ptr, wtlv_offset);
break;
case SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_ARRAY:
bytes_parsed = dissect_someip_payload_array(tvb, pinfo, tree, offset, idref, name, wtlv_offset);
break;
case SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_STRUCT:
bytes_parsed = dissect_someip_payload_struct(tvb, pinfo, tree, offset, idref, name, wtlv_offset);
break;
case SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_UNION:
bytes_parsed = dissect_someip_payload_union(tvb, pinfo, tree, offset, idref, name, wtlv_offset);
break;
default:
proto_tree_add_expert_format(tree, pinfo, &ef_someip_payload_config_error, tvb, offset, 0,
"SOME/IP: Payload: item->data_type (0x%x) unknown/not implemented yet! name: %s, id_ref: 0x%x",
data_type, name, idref);
col_append_str(pinfo->cinfo, COL_INFO, " [SOME/IP: Payload Config Error]");
break;
}
return bytes_parsed;
}
/*
* returns <0 for errors
*/
static int dissect_someip_payload_peek_length_of_length(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, gint offset, gint length, someip_payload_parameter_item_t *item) {
if (item == NULL) {
return -1;
}
guint32 data_type = item->data_type;
guint32 id_ref = item->id_ref;
/* a config error could cause an endless loop, so we limit the number of indirections with loop_limit */
gint loop_limit = 255;
while (data_type == SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_TYPEDEF && loop_limit > 0) {
someip_payload_parameter_typedef_t *tmp = get_typedef_config(id_ref);
data_type = tmp->data_type;
id_ref = tmp->id_ref;
loop_limit--;
}
someip_payload_parameter_string_t *tmp_string_config;
someip_parameter_array_t *tmp_array_config;
someip_payload_parameter_struct_t *tmp_struct_config;
someip_parameter_union_t *tmp_union_config;
switch (data_type) {
case SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_STRING:
tmp_string_config = get_string_config(id_ref);
if (tmp_string_config == NULL) {
return -1;
}
return tmp_string_config->length_of_length;
break;
case SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_ARRAY:
tmp_array_config = get_array_config(id_ref);
if (tmp_array_config == NULL) {
return -1;
}
if (tmp_array_config->num_of_dims < 1 || tmp_array_config->dims == NULL) {
expert_someip_payload_config_error(tree, pinfo, tvb, offset, length, "array configuration does not support WTLV");
return -1;
}
return tmp_array_config->dims[0].length_of_length;
break;
case SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_STRUCT:
tmp_struct_config = get_struct_config(id_ref);
if (tmp_struct_config == NULL) {
return -1;
}
return tmp_struct_config->length_of_length;
break;
case SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_UNION:
tmp_union_config = get_union_config(id_ref);
if (tmp_union_config == NULL) {
return -1;
}
return tmp_union_config->length_of_length;
break;
case SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_TYPEDEF:
case SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_BASE_TYPE:
case SOMEIP_PAYLOAD_PARAMETER_DATA_TYPE_ENUM:
default:
/* This happends only if configuration or message are buggy. */
return -2;
}
}
static int
dissect_someip_payload_parameters(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset, someip_payload_parameter_item_t *items, guint32 num_of_items, gboolean wtlv) {
someip_payload_parameter_item_t *item;
gint offset_orig = offset;
if (items == NULL && !someip_deserializer_wtlv_default) {
return 0;
}
if (wtlv) {
while (tvb_captured_length_remaining(tvb, offset) >= 2) {
guint64 tagdata = tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN);
guint wiretype = (tagdata & SOMEIP_WTLV_MASK_WIRE_TYPE) >> 12;
guint param_id = tagdata & SOMEIP_WTLV_MASK_DATA_ID;
offset += 2;
if (param_id < num_of_items && items != NULL) {
item = &(items[param_id]);
} else {
item = NULL;
}
guint param_length = 0;
switch (wiretype) {
/* fixed length type with just 1, 2, 4, or 8 byte length */
case 0:
case 1:
case 2:
case 3:
param_length = 1 << wiretype;
break;
/* var length types like structs, strings, arrays, and unions */
case 4:
/* this type is deprecated and should not be used*/
switch (dissect_someip_payload_peek_length_of_length(tree, pinfo, tvb, offset - 2, 0, item)) {
case 8:
param_length = 1 + tvb_get_guint8(tvb, offset);
break;
case 16:
param_length = 2 + tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN);
break;
case 32:
param_length = 4 + tvb_get_guint32(tvb, offset, ENC_BIG_ENDIAN);
break;
default:
expert_someip_payload_config_error(tree, pinfo, tvb, offset - 2, 2, "WTLV type 4 but datatype has not an appropriate length field configured");
return 8 * (offset - offset_orig);
}
break;
case 5:
param_length = 1 + tvb_get_guint8(tvb, offset);
break;
case 6:
param_length = 2 + tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN);
break;
case 7:
param_length = 4 + tvb_get_guint32(tvb, offset, ENC_BIG_ENDIAN);
break;
default:
/* unsupported Wire Type!*/
expert_someip_payload_malformed(tree, pinfo, tvb, offset - 2, 2);
break;
}
tvbuff_t *subtvb = tvb_new_subset_length_caplen(tvb, offset - 2, param_length + 2, param_length + 2);
if (item != NULL) {
dissect_someip_payload_parameter(subtvb, pinfo, tree, 2, (guint8)item->data_type, item->id_ref, item->name, item->hf_id, 0);
} else {
proto_item *ti = proto_tree_add_item(tree, hf_payload_unparsed, subtvb, 2, param_length, ENC_NA);
dissect_someip_payload_add_wtlv_if_needed(tvb, pinfo, offset - 2, ti, NULL);
}
offset += param_length;
}
} else {
if (items == NULL) {
return 0;
}
guint32 i;
for (i = 0; i < num_of_items; i++) {
item = &(items[i]);
offset += dissect_someip_payload_parameter(tvb, pinfo, tree, offset, (guint8)item->data_type, item->id_ref, item->name, item->hf_id, -1);
}
}
return offset - offset_orig;
}
static void
dissect_someip_payload(tvbuff_t* tvb, packet_info* pinfo, proto_item *ti, guint16 serviceid, guint16 methodid, guint8 version, guint8 msgtype) {
someip_parameter_list_t* paramlist = NULL;
gint length = -1;
gint offset = 0;
proto_tree *tree = NULL;
/* TAP */
if (have_tap_listener(tap_someip_messages)) {
someip_messages_tap_t *data = wmem_alloc(pinfo->pool, sizeof(someip_messages_tap_t));
data->service_id = serviceid;
data->method_id = methodid;
data->interface_version = version;
data->message_type = msgtype;
tap_queue_packet(tap_someip_messages, pinfo, data);
}
length = tvb_captured_length_remaining(tvb, 0);
tree = proto_item_add_subtree(ti, ett_someip_payload);
paramlist = get_parameter_config(serviceid, methodid, version, msgtype);
if (paramlist == NULL) {
if (someip_deserializer_wtlv_default) {
offset += dissect_someip_payload_parameters(tvb, pinfo, tree, offset, NULL, 0, TRUE);
} else {
return;
}
} else {
offset += dissect_someip_payload_parameters(tvb, pinfo, tree, offset, paramlist->items, paramlist->num_of_items, paramlist->wtlv_encoding);
}
if (length > offset) {
proto_tree_add_item(tree, hf_payload_unparsed, tvb, offset, length - (offset), ENC_NA);
}
}
/***********************************
******** SOME/IP Dissector ********
***********************************/
static int
dissect_someip_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) {
guint32 offset = 0;
guint32 someip_messageid = 0;
guint32 someip_serviceid = 0;
guint32 someip_methodid = 0;
guint32 someip_clientid = 0;
guint32 someip_sessionid = 0;
guint32 someip_length = 0;
const gchar *service_description = NULL;
const gchar *method_description = NULL;
const gchar *client_description = NULL;
someip_info_t someip_data = SOMEIP_INFO_T_INIT;
guint32 someip_payload_length = 0;
tvbuff_t *subtvb = NULL;
proto_item *ti = NULL;
proto_item *ti_someip = NULL;
proto_tree *someip_tree = NULL;
proto_tree *msgtype_tree = NULL;
guint32 protocol_version = 0;
guint32 version = 0;
guint32 msgtype = 0;
gboolean msgtype_ack = FALSE;
gboolean msgtype_tp = FALSE;
guint32 retcode = 0;
int tmp = 0;
gint tvb_length = tvb_captured_length_remaining(tvb, offset);
static int * const someip_tp_flags[] = {
&hf_someip_tp_reserved,
&hf_someip_tp_more_segments,
NULL
};
col_set_str(pinfo->cinfo, COL_PROTOCOL, SOMEIP_NAME);
col_set_str(pinfo->cinfo, COL_INFO, SOMEIP_NAME_LONG);
ti_someip = proto_tree_add_item(tree, proto_someip, tvb, offset, -1, ENC_NA);
someip_tree = proto_item_add_subtree(ti_someip, ett_someip);
/* we should never get called with less than 8 bytes */
if (tvb_length < 8) {
return tvb_length;
}
/* Message ID = Service ID + Method ID*/
someip_messageid = tvb_get_ntohl(tvb, 0);
ti = proto_tree_add_uint_format_value(someip_tree, hf_someip_messageid, tvb, offset, 4, someip_messageid, "0x%08x", someip_messageid);
proto_item_set_hidden(ti);
/* Service ID */
ti = proto_tree_add_item_ret_uint(someip_tree, hf_someip_serviceid, tvb, offset, 2, ENC_BIG_ENDIAN, &someip_serviceid);
someip_data.service_id = someip_serviceid;
service_description = someip_lookup_service_name(someip_serviceid);
if (service_description != NULL) {
proto_item_append_text(ti, " (%s)", service_description);
ti = proto_tree_add_string(someip_tree, hf_someip_servicename, tvb, offset, 2, service_description);
proto_item_set_generated(ti);
proto_item_set_hidden(ti);
}
offset += 2;
/* Method ID */
ti = proto_tree_add_item_ret_uint(someip_tree, hf_someip_methodid, tvb, offset, 2, ENC_BIG_ENDIAN, &someip_methodid);
someip_data.method_id = someip_methodid;
method_description = someip_lookup_method_name(someip_serviceid, someip_methodid);
if (method_description != NULL) {
proto_item_append_text(ti, " (%s)", method_description);
ti = proto_tree_add_string(someip_tree, hf_someip_methodname , tvb, offset, 2, method_description);
proto_item_set_generated(ti);
proto_item_set_hidden(ti);
}
offset += 2;
/* Length */
proto_tree_add_item_ret_uint(someip_tree, hf_someip_length, tvb, offset, 4, ENC_BIG_ENDIAN, &someip_length);
offset += 4;
/* this checks if value of the header field */
if (someip_length < 8) {
expert_add_info_format(pinfo, ti_someip, &ef_someip_incomplete_headers, "%s", "SOME/IP length too short (<8 Bytes)!");
return tvb_length;
}
/* Add some additional info to the Protocol line and the Info Column*/
if (service_description == NULL) {
col_add_fstr(pinfo->cinfo, COL_INFO, "%s (Service ID: 0x%04x, Method ID: 0x%04x, Length: %i)",
SOMEIP_NAME_LONG, someip_serviceid, someip_methodid, someip_length);
} else if (method_description == NULL) {
col_add_fstr(pinfo->cinfo, COL_INFO, "%s (Service ID: 0x%04x (%s), Method ID: 0x%04x, Length: %i)",
SOMEIP_NAME_LONG, someip_serviceid, service_description, someip_methodid, someip_length);
} else {
col_add_fstr(pinfo->cinfo, COL_INFO, "%s (Service ID: 0x%04x (%s), Method ID: 0x%04x (%s), Length: %i)",
SOMEIP_NAME_LONG, someip_serviceid, service_description, someip_methodid, method_description, someip_length);
}
proto_item_append_text(ti_someip, " (Service ID: 0x%04x, Method ID: 0x%04x, Length: %i)", someip_serviceid, someip_methodid, someip_length);
/* check if we have bytes for the rest of the header */
if (tvb_length < 0 || offset + 8 > (guint32)tvb_length) {
expert_add_info_format(pinfo, ti_someip, &ef_someip_incomplete_headers, "%s", "SOME/IP not enough buffer bytes for header!");
return tvb_length;
}
/* Client ID */
ti = proto_tree_add_item_ret_uint(someip_tree, hf_someip_clientid, tvb, offset, 2, ENC_BIG_ENDIAN, &someip_clientid);
someip_data.client_id = someip_clientid;
client_description = someip_lookup_client_name(someip_serviceid, someip_clientid);
if (client_description != NULL) {
proto_item_append_text(ti, " (%s)", client_description);
ti = proto_tree_add_string(someip_tree, hf_someip_clientname, tvb, offset, 2, client_description);
proto_item_set_generated(ti);
proto_item_set_hidden(ti);
}
offset += 2;
/* Session ID */
proto_tree_add_item_ret_uint(someip_tree, hf_someip_sessionid, tvb, offset, 2, ENC_BIG_ENDIAN, &someip_sessionid);
someip_data.session_id = someip_sessionid;
offset += 2;
/* Protocol Version*/
ti = proto_tree_add_item_ret_uint(someip_tree, hf_someip_protover, tvb, offset, 1, ENC_BIG_ENDIAN, &protocol_version);
if (protocol_version!=SOMEIP_PROTOCOL_VERSION) {
expert_add_info(pinfo, ti, &ef_someip_unknown_version);
}
offset += 1;
/* Major Version of Service Interface */
proto_tree_add_item_ret_uint(someip_tree, hf_someip_interface_ver, tvb, offset, 1, ENC_BIG_ENDIAN, &version);
someip_data.major_version = version;
offset += 1;
/* Message Type */
ti = proto_tree_add_item_ret_uint(someip_tree, hf_someip_messagetype, tvb, offset, 1, ENC_BIG_ENDIAN, &msgtype);
someip_data.message_type = msgtype;
msgtype_tree = proto_item_add_subtree(ti, ett_someip_msgtype);
proto_tree_add_item_ret_boolean(msgtype_tree, hf_someip_messagetype_ack_flag, tvb, offset, 1, ENC_BIG_ENDIAN, &msgtype_ack);
proto_tree_add_item_ret_boolean(msgtype_tree, hf_someip_messagetype_tp_flag, tvb, offset, 1, ENC_BIG_ENDIAN, &msgtype_tp);
proto_item_append_text(ti, " (%s)", val_to_str_const((~SOMEIP_MSGTYPE_TP_MASK)&msgtype, someip_msg_type, "Unknown Message Type"));
if (msgtype_tp) {
proto_item_append_text(ti, " (%s)", SOMEIP_MSGTYPE_TP_STRING);
}
offset += 1;
/* Return Code */
ti = proto_tree_add_item_ret_uint(someip_tree, hf_someip_returncode, tvb, offset, 1, ENC_BIG_ENDIAN, &retcode);
proto_item_append_text(ti, " (%s)", val_to_str_const(retcode, someip_return_code, "Unknown Return Code"));
offset += 1;
/* lets figure out what we have for the rest */
if (((guint32)tvb_length >= (someip_length + 8)) ) {
someip_payload_length = someip_length - SOMEIP_HDR_PART1_LEN;
} else {
someip_payload_length = tvb_length - SOMEIP_HDR_LEN;
expert_add_info(pinfo, ti_someip, &ef_someip_message_truncated);
}
/* Is this a SOME/IP-TP segment? */
if (msgtype_tp) {
guint32 tp_offset = 0;
gboolean tp_more_segments = FALSE;
gboolean update_col_info = TRUE;
fragment_head *someip_tp_head = NULL;
proto_tree *tp_tree = NULL;
ti = proto_tree_add_item(someip_tree, hf_someip_tp, tvb, offset, someip_payload_length, ENC_NA);
tp_tree = proto_item_add_subtree(ti, ett_someip_tp);
tp_offset = (tvb_get_ntohl(tvb, offset) & SOMEIP_TP_OFFSET_MASK);
tp_more_segments = ((tvb_get_ntohl(tvb, offset) & SOMEIP_TP_OFFSET_MASK_MORE_SEGMENTS) != 0);
/* Why can I not mask an FT_UINT32 without it being shifted. :( . */
proto_tree_add_uint(tp_tree, hf_someip_tp_offset, tvb, offset, 4, tp_offset);
proto_tree_add_bitmask_with_flags(tp_tree, tvb, offset+3, hf_someip_tp_flags, ett_someip_tp_flags, someip_tp_flags, ENC_BIG_ENDIAN, BMT_NO_TFS | BMT_NO_INT);
offset += 4;
proto_tree_add_item(tp_tree, hf_someip_payload, tvb, offset, someip_payload_length - SOMEIP_TP_HDR_LEN, ENC_NA);
if (someip_tp_reassemble && tvb_bytes_exist(tvb, offset, someip_payload_length - SOMEIP_TP_HDR_LEN)) {
someip_tp_head = fragment_add_check(&someip_tp_reassembly_table, tvb, offset, pinfo, 0,
&someip_data, tp_offset, someip_payload_length - SOMEIP_TP_HDR_LEN, tp_more_segments);
subtvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled SOME/IP-TP Segment",
someip_tp_head, &someip_tp_frag_items, &update_col_info, someip_tree);
}
} else {
subtvb = tvb_new_subset_length_caplen(tvb, SOMEIP_HDR_LEN, someip_payload_length, someip_payload_length);
}
if (subtvb!=NULL) {
tvb_length = tvb_captured_length_remaining(subtvb, 0);
if (tvb_length > 0) {
tmp = dissector_try_uint_new(someip_dissector_table, someip_messageid, subtvb, pinfo, tree, FALSE, &someip_data);
/* if no subdissector was found, the generic payload dissector takes over. */
if (tmp==0) {
ti = proto_tree_add_item(someip_tree, hf_someip_payload, subtvb, 0, tvb_length, ENC_NA);
if (someip_deserializer_activated) {
dissect_someip_payload(subtvb, pinfo, ti, (guint16)someip_serviceid, (guint16)someip_methodid, (guint8)version, (guint8)(~SOMEIP_MSGTYPE_TP_MASK)&msgtype);
} else {
proto_tree* payload_dissection_disabled_info_sub_tree = proto_item_add_subtree(ti, ett_someip_payload);
proto_tree_add_text_internal(payload_dissection_disabled_info_sub_tree, subtvb, 0, tvb_length, "Dissection of payload is disabled. It can be enabled via protocol preferences.");
}
}
}
}
return SOMEIP_HDR_LEN + someip_payload_length;
}
static guint
get_someip_message_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_) {
return SOMEIP_HDR_PART1_LEN + (guint)tvb_get_ntohl(tvb, offset + 4);
}
static int
dissect_someip_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, SOMEIP_HDR_PART1_LEN, get_someip_message_len, dissect_someip_message, data);
return tvb_reported_length(tvb);
}
static gboolean
could_this_be_dtls(tvbuff_t *tvb) {
/* Headers compared
*
* Byte | SOME/IP | DTLS
* --------------------------------
* 00 | Service ID | Content Type
* 01 | Service ID | Version
* 02 | Method ID | Version
* 03 | Method ID | Epoch
* 04 | Length | Epoch
* 05 | Length | Sequence Counter
* 06 | Length | Sequence Counter
* 07 | Length | Sequence Counter
* 08 | Client ID | Sequence Counter
* 09 | Client ID | Sequence Counter
* 10 | Session ID | Sequence Counter
* 11 | Session ID | Length
* 12 | SOME/IP Ver | Length
* 13 | Iface Ver | ...
* 14 | Msg Type | ...
* 15 | Return Code | ...
* 16 | ... | ...
*/
gint length = tvb_captured_length_remaining(tvb, 0);
/* DTLS header is 13 bytes. */
if (length < 13) {
/* not sure what we have here ... */
return false;
}
guint8 dtls_content_type = tvb_get_guint8(tvb, 0);
guint16 dtls_version = tvb_get_guint16(tvb, 1, ENC_BIG_ENDIAN);
guint16 dtls_length = tvb_get_guint16(tvb, 11, ENC_BIG_ENDIAN);
gboolean dtls_possible = (20 <= dtls_content_type) && (dtls_content_type <= 63) &&
(0xfefc <= dtls_version) && (dtls_version <= 0xfeff) &&
((guint32)length == (guint32)dtls_length + 13);
if (dtls_possible && length < SOMEIP_HDR_LEN) {
return true;
}
guint32 someip_length = tvb_get_guint32(tvb, 4, ENC_BIG_ENDIAN);
guint8 someip_version = tvb_get_guint8(tvb, 12);
/* typically this is 1500 bytes or less on UDP but being conservative */
gboolean someip_possible = (someip_version == 1) && (8 <= someip_length) && (someip_length <= 65535) &&
((guint32)length == someip_length + 8);
return dtls_possible && !someip_possible;
}
static int
dissect_someip_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
if (someip_detect_dtls && could_this_be_dtls(tvb)) {
if (!PINFO_FD_VISITED(pinfo)) {
dissector_add_uint("dtls.port", (guint16)pinfo->destport, someip_handle_udp);
}
if (dtls_handle != 0) {
return call_dissector_with_data(dtls_handle, tvb, pinfo, tree, data);
}
}
return udp_dissect_pdus(tvb, pinfo, tree, SOMEIP_HDR_PART1_LEN, NULL, get_someip_message_len, dissect_someip_message, data);
}
static gboolean
test_someip(packet_info *pinfo _U_, tvbuff_t *tvb, int offset _U_, void *data _U_) {
if (tvb_captured_length(tvb) < SOMEIP_HDR_LEN) {
return FALSE;
}
if (tvb_get_guint32(tvb, 4, ENC_BIG_ENDIAN) < 8) {
return FALSE;
}
if ((tvb_get_guint8(tvb, 12)) != SOMEIP_PROTOCOL_VERSION) {
return FALSE;
}
if (!try_val_to_str((tvb_get_guint8(tvb, 14) & ~SOMEIP_MSGTYPE_TP_MASK), someip_msg_type)) {
return FALSE;
}
return TRUE;
}
static gboolean
dissect_some_ip_heur_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
if (test_someip(pinfo, tvb, 0, data)) {
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, SOMEIP_HDR_PART1_LEN, get_someip_message_len, dissect_someip_message, data);
return TRUE;
}
return FALSE;
}
static gboolean
dissect_some_ip_heur_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
return (udp_dissect_pdus(tvb, pinfo, tree, SOMEIP_HDR_PART1_LEN, test_someip, get_someip_message_len, dissect_someip_message, data) != 0);
}
void
proto_register_someip(void) {
module_t *someip_module;
expert_module_t *expert_module_someip;
uat_t *someip_service_uat;
uat_t *someip_method_uat;
uat_t *someip_eventgroup_uat;
uat_t *someip_client_uat;
uat_t *someip_parameter_base_type_list_uat;
uat_t *someip_parameter_strings_uat;
uat_t *someip_parameter_typedefs_uat;
uat_t *someip_parameter_list_uat;
uat_t *someip_parameter_arrays_uat;
uat_t *someip_parameter_structs_uat;
uat_t *someip_parameter_unions_uat;
uat_t *someip_parameter_enums_uat;
/* data fields */
static hf_register_info hf[] = {
{ &hf_someip_serviceid,
{ "Service ID", "someip.serviceid",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_servicename,
{ "Service Name", "someip.servicename",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_methodid,
{ "Method ID", "someip.methodid",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_methodname,
{ "Method Name", "someip.methodname",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_messageid,
{ "Message ID", "someip.messageid",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_length,
{ "Length", "someip.length",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_clientid,
{ "Client ID", "someip.clientid",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_clientname,
{ "Client Name", "someip.clientname",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_sessionid,
{ "Session ID", "someip.sessionid",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_protover,
{ "SOME/IP Version", "someip.protoversion",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_interface_ver,
{ "Interface Version", "someip.interfaceversion",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_messagetype,
{ "Message Type", "someip.messagetype",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_messagetype_ack_flag,
{ "Message Type Ack Flag", "someip.messagetype.ack",
FT_BOOLEAN, 8, NULL, SOMEIP_MSGTYPE_ACK_MASK, NULL, HFILL }},
{ &hf_someip_messagetype_tp_flag,
{ "Message Type TP Flag", "someip.messagetype.tp",
FT_BOOLEAN, 8, NULL, SOMEIP_MSGTYPE_TP_MASK, NULL, HFILL }},
{ &hf_someip_returncode,
{ "Return Code", "someip.returncode",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_payload,
{ "Payload", "someip.payload",
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_tp,
{ "SOME/IP-TP", "someip.tp",
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_tp_offset,
{ "Offset", "someip.tp.offset",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_someip_tp_flags,
{ "Flags", "someip.tp.flags",
FT_UINT32, BASE_HEX, NULL, SOMEIP_TP_OFFSET_MASK_FLAGS, NULL, HFILL }},
{ &hf_someip_tp_reserved,
{ "Reserved", "someip.tp.flags.reserved",
FT_UINT32, BASE_HEX, NULL, SOMEIP_TP_OFFSET_MASK_RESERVED, NULL, HFILL }},
{ &hf_someip_tp_more_segments,
{ "More Segments", "someip.tp.flags.more_segments",
FT_BOOLEAN, 32, NULL, SOMEIP_TP_OFFSET_MASK_MORE_SEGMENTS, NULL, HFILL }},
{&hf_someip_tp_fragments,
{"SOME/IP-TP segments", "someip.tp.fragments",
FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } },
{&hf_someip_tp_fragment,
{"SOME/IP-TP segment", "someip.tp.fragment",
FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL } },
{&hf_someip_tp_fragment_overlap,
{"SOME/IP-TP segment overlap", "someip.tp.fragment.overlap",
FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL } },
{&hf_someip_tp_fragment_overlap_conflicts,
{"SOME/IP-TP segment overlapping with conflicting data", "someip.tp.fragment.overlap.conflicts",
FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL } },
{&hf_someip_tp_fragment_multiple_tails,
{"SOME/IP-TP Message has multiple tail fragments", "someip.tp.fragment.multiple_tails",
FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL } },
{&hf_someip_tp_fragment_too_long_fragment,
{"SOME/IP-TP segment too long", "someip.tp.fragment.too_long_fragment",
FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL } },
{&hf_someip_tp_fragment_error,
{"SOME/IP-TP Message defragmentation error", "someip.tp.fragment.error",
FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL } },
{&hf_someip_tp_fragment_count,
{"SOME/IP-TP segment count", "someip.tp.fragment.count",
FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } },
{&hf_someip_tp_reassembled_in,
{"Reassembled in", "someip.tp.reassembled.in",
FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL } },
{&hf_someip_tp_reassembled_length,
{"Reassembled length", "someip.tp.reassembled.length",
FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } },
{&hf_someip_tp_reassembled_data,
{"Reassembled data", "someip.tp.reassembled.data",
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_payload_unparsed,
{ "Unparsed Payload", "someip.payload.unparsed",
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_payload_length_field_8bit,
{ "Length", "someip.payload.length",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_payload_length_field_16bit,
{ "Length", "someip.payload.length",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_payload_length_field_32bit,
{ "Length", "someip.payload.length",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_payload_type_field_8bit,
{ "Type", "someip.payload.type",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_payload_type_field_16bit,
{ "Type", "someip.payload.type",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_payload_type_field_32bit,
{ "Type", "someip.payload.type",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_payload_str_base, {
"(base)", "someip.payload.base",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_payload_str_string, {
"(string)", "someip.payload.string",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_payload_str_struct, {
"(struct)", "someip.payload.struct",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_payload_str_array, {
"(array)", "someip.payload.array",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_payload_str_union, {
"(array)", "someip.payload.union",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_payload_wtlv_tag, {
"WTLV-TAG", "someip.payload.wtlvtag",
FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_payload_wtlv_tag_res, {
"Reserved", "someip.payload.wtlvtag.res",
FT_UINT16, BASE_DEC, NULL, SOMEIP_WTLV_MASK_RES, NULL, HFILL } },
{ &hf_payload_wtlv_tag_wire_type, {
"Wire Type", "someip.payload.wtlvtag.wire_type",
FT_UINT16, BASE_DEC, NULL, SOMEIP_WTLV_MASK_WIRE_TYPE, NULL, HFILL } },
{ &hf_payload_wtlv_tag_data_id, {
"Data ID", "someip.payload.wtlvtag.data_id",
FT_UINT16, BASE_DEC, NULL, SOMEIP_WTLV_MASK_DATA_ID, NULL, HFILL } },
};
static gint *ett[] = {
&ett_someip,
&ett_someip_msgtype,
&ett_someip_tp,
&ett_someip_tp_flags,
&ett_someip_tp_fragment,
&ett_someip_tp_fragments,
&ett_someip_payload,
&ett_someip_string,
&ett_someip_array,
&ett_someip_array_dim,
&ett_someip_struct,
&ett_someip_union,
&ett_someip_parameter,
&ett_someip_wtlv_tag,
};
/* UATs for user_data fields */
static uat_field_t someip_service_uat_fields[] = {
UAT_FLD_HEX(someip_service_ident, id, "Service ID", "ID of the SOME/IP Service (16bit hex without leading 0x)"),
UAT_FLD_CSTRING(someip_service_ident, name, "Service Name", "Name of the SOME/IP Service (string)"),
UAT_END_FIELDS
};
static uat_field_t someip_method_uat_fields[] = {
UAT_FLD_HEX(someip_method_ident, id, "Service ID", "ID of the SOME/IP Service (16bit hex without leading 0x)"),
UAT_FLD_HEX(someip_method_ident, id2, "Methods ID", "ID of the SOME/IP Method/Event/Notifier (16bit hex without leading 0x)"),
UAT_FLD_CSTRING(someip_method_ident, name, "Method Name", "Name of the SOME/IP Method/Event/Notifier (string)"),
UAT_END_FIELDS
};
static uat_field_t someip_eventgroup_uat_fields[] = {
UAT_FLD_HEX(someip_eventgroup_ident, id, "Service ID", "ID of the SOME/IP Service (16bit hex without leading 0x)"),
UAT_FLD_HEX(someip_eventgroup_ident, id2, "Eventgroup ID", "ID of the SOME/IP Eventgroup (16bit hex without leading 0x)"),
UAT_FLD_CSTRING(someip_eventgroup_ident, name, "Eventgroup Name", "Name of the SOME/IP Service (string)"),
UAT_END_FIELDS
};
static uat_field_t someip_client_uat_fields[] = {
UAT_FLD_HEX(someip_client_ident, id, "Service ID", "ID of the SOME/IP Service (16bit hex without leading 0x)"),
UAT_FLD_HEX(someip_client_ident, id2, "Client ID", "ID of the SOME/IP Client (16bit hex without leading 0x)"),
UAT_FLD_CSTRING(someip_client_ident, name, "Client Name", "Name of the SOME/IP Client (string)"),
UAT_END_FIELDS
};
static uat_field_t someip_parameter_list_uat_fields[] = {
UAT_FLD_HEX(someip_parameter_list, service_id, "Service ID", "ID of the SOME/IP Service (16bit hex without leading 0x)"),
UAT_FLD_HEX(someip_parameter_list, method_id, "Method ID", "ID of the SOME/IP Method/Event/Notifier (16bit hex without leading 0x)"),
UAT_FLD_DEC(someip_parameter_list, version, "Version", "Version of the SOME/IP Service (8bit dec)"),
UAT_FLD_HEX(someip_parameter_list, message_type, "Message Type", "Message Type (8bit hex without leading 0x)"),
UAT_FLD_BOOL(someip_parameter_list, wtlv_encoding, "WTLV Extension?", "SOME/IP is extended by Wiretag-Length-Value encoding for this parameter list (not pure SOME/IP)"),
UAT_FLD_DEC(someip_parameter_list, num_of_params, "Number of Parameters", "Number of Parameters (16bit dec), needs to be larger than greatest Parameter Position/ID"),
UAT_FLD_DEC(someip_parameter_list, pos, "Parameter Position/ID", "Position or ID of parameter (16bit dec, starting with 0)"),
UAT_FLD_CSTRING(someip_parameter_list, name, "Parameter Name", "Name of parameter (string)"),
UAT_FLD_DEC(someip_parameter_list, data_type, "Parameter Type", "Type of parameter (1: base, 2: string, 3: array, 4: struct, 5: union, 6: typedef, 7: enum)"),
UAT_FLD_HEX(someip_parameter_list, id_ref, "ID Reference", "ID Reference (32bit hex)"),
UAT_FLD_CSTRING(someip_parameter_list, filter_string, "Filter String", "Unique filter string that will be prepended with someip.payload. (string)"),
UAT_END_FIELDS
};
static uat_field_t someip_parameter_array_uat_fields[] = {
UAT_FLD_HEX(someip_parameter_arrays, id, "ID", "ID of SOME/IP array (32bit hex without leading 0x)"),
UAT_FLD_CSTRING(someip_parameter_arrays, name, "Array Name", "Name of array"),
UAT_FLD_DEC(someip_parameter_arrays, data_type, "Parameter Type", "Type of parameter (1: base, 2: string, 3: array, 4: struct, 5: union, 6: typedef, 7: enum)"),
UAT_FLD_HEX(someip_parameter_arrays, id_ref, "ID Reference", "ID Reference (32bit hex)"),
UAT_FLD_DEC(someip_parameter_arrays, num_of_dims, "Number of Items", "Number of Dimensions (16bit dec)"),
UAT_FLD_CSTRING(someip_parameter_arrays, filter_string, "Filter String", "Unique filter string that will be prepended with someip.payload. (string)"),
UAT_FLD_DEC(someip_parameter_arrays, num, "Dimension", "Dimension (16bit dec, starting with 0)"),
UAT_FLD_DEC(someip_parameter_arrays, lower_limit, "Lower Limit", "Dimension (32bit dec)"),
UAT_FLD_DEC(someip_parameter_arrays, upper_limit, "Upper Limit", "Dimension (32bit dec)"),
UAT_FLD_DEC(someip_parameter_arrays, length_of_length, "Length of Length Field", "Length of the arrays length field in bits (8bit dec)"),
UAT_FLD_DEC(someip_parameter_arrays, pad_to, "Pad to", "Padding pads to reach alignment (8bit dec)"),
UAT_END_FIELDS
};
static uat_field_t someip_parameter_struct_uat_fields[] = {
UAT_FLD_HEX(someip_parameter_structs, id, "ID", "ID of SOME/IP struct (32bit hex without leading 0x)"),
UAT_FLD_CSTRING(someip_parameter_structs, struct_name, "Struct Name", "Name of struct"),
UAT_FLD_DEC(someip_parameter_structs, length_of_length, "Length of Length Field", "Length of the structs length field in bits (8bit dec)"),
UAT_FLD_DEC(someip_parameter_structs, pad_to, "Pad to", "Padding pads to reach alignment (8bit dec)"),
UAT_FLD_BOOL(someip_parameter_structs, wtlv_encoding, "WTLV Extension?", "SOME/IP is extended by Wiretag-Length-Value encoding for this struct (not pure SOME/IP)"),
UAT_FLD_DEC(someip_parameter_structs, num_of_items, "Number of Items", "Number of Items (16bit dec)"),
UAT_FLD_DEC(someip_parameter_structs, pos, "Parameter Position/ID", "Position or ID of parameter (16bit dec, starting with 0)"),
UAT_FLD_CSTRING(someip_parameter_structs, name, "Parameter Name", "Name of parameter (string)"),
UAT_FLD_DEC(someip_parameter_structs, data_type, "Parameter Type", "Type of parameter (1: base, 2: string, 3: array, 4: struct, 5: union, 6: typedef, 7: enum)"),
UAT_FLD_HEX(someip_parameter_structs, id_ref, "ID Reference", "ID Reference (32bit hex)"),
UAT_FLD_CSTRING(someip_parameter_structs, filter_string, "Filter String", "Unique filter string that will be prepended with someip.payload. (string)"),
UAT_END_FIELDS
};
static uat_field_t someip_parameter_union_uat_fields[] = {
UAT_FLD_HEX(someip_parameter_unions, id, "ID", "ID of SOME/IP union (32bit hex without leading 0x)"),
UAT_FLD_CSTRING(someip_parameter_unions, name, "Union Name", "Name of union"),
UAT_FLD_DEC(someip_parameter_unions, length_of_length, "Length of Length Field", "Length of the unions length field in bits (uint8 dec)"),
UAT_FLD_DEC(someip_parameter_unions, length_of_type, "Length of Type Field", "Length of the unions type field in bits (8bit dec)"),
UAT_FLD_DEC(someip_parameter_unions, pad_to, "Pad to", "Padding pads to reach alignment (8bit dec)"),
UAT_FLD_DEC(someip_parameter_unions, num_of_items, "Number of Items", "Number of Items (32bit dec)"),
UAT_FLD_DEC(someip_parameter_unions, type_id, "Type ID", "ID of Type (32bit dec, starting with 0)"),
UAT_FLD_CSTRING(someip_parameter_unions, type_name, "Type Name", "Name of Type (string)"),
UAT_FLD_DEC(someip_parameter_unions, data_type, "Data Type", "Type of payload (1: base, 2: string, 3: array, 4: struct, 5: union, 6: typedef, 7: enum)"),
UAT_FLD_HEX(someip_parameter_unions, id_ref, "ID Reference", "ID Reference (32bit hex)"),
UAT_FLD_CSTRING(someip_parameter_unions, filter_string, "Filter String", "Unique filter string that will be prepended with someip.payload. (string)"),
UAT_END_FIELDS
};
static uat_field_t someip_parameter_enum_uat_fields[] = {
UAT_FLD_HEX(someip_parameter_enums, id, "ID", "ID of SOME/IP enum (32bit hex without leading 0x)"),
UAT_FLD_CSTRING(someip_parameter_enums, name, "Name", "Name of Enumeration (string)"),
UAT_FLD_DEC(someip_parameter_enums, data_type, "Parameter Type", "Type of parameter (1: base, 2: string, 3: array, 4: struct, 5: union, 6: typedef, 7: enum)"),
UAT_FLD_HEX(someip_parameter_enums, id_ref, "ID Reference", "ID Reference (32bit hex)"),
UAT_FLD_DEC(someip_parameter_enums, num_of_items, "Number of Items", "Number of Items (32bit dec)"),
UAT_FLD_HEX(someip_parameter_enums, value, "Value", "Value (64bit uint hex)"),
UAT_FLD_CSTRING(someip_parameter_enums, value_name, "Value Name", "Name (string)"),
UAT_END_FIELDS
};
static uat_field_t someip_parameter_base_type_list_uat_fields[] = {
UAT_FLD_HEX(someip_parameter_base_type_list, id, "ID ", "ID (32bit hex)"),
UAT_FLD_CSTRING(someip_parameter_base_type_list, name, "Name", "Name of type (string)"),
UAT_FLD_CSTRING(someip_parameter_base_type_list, data_type, "Data Type", "Data type (string)"),
UAT_FLD_BOOL(someip_parameter_base_type_list, big_endian, "Big Endian", "Encoded Big Endian"),
UAT_FLD_DEC(someip_parameter_base_type_list, bitlength_base_type, "Bitlength base type", "Bitlength base type (uint32 dec)"),
UAT_FLD_DEC(someip_parameter_base_type_list, bitlength_encoded_type, "Bitlength enc. type", "Bitlength encoded type (uint32 dec)"),
UAT_END_FIELDS
};
static uat_field_t someip_parameter_string_list_uat_fields[] = {
UAT_FLD_HEX(someip_parameter_strings, id, "ID ", "ID (32bit hex)"),
UAT_FLD_CSTRING(someip_parameter_strings, name, "Name", "Name of string (string)"),
UAT_FLD_CSTRING(someip_parameter_strings, encoding, "Encoding", "String Encoding (ascii, utf-8, utf-16)"),
UAT_FLD_BOOL(someip_parameter_strings, dynamic_length, "Dynamic Length", "Dynamic length of string"),
UAT_FLD_DEC(someip_parameter_strings, max_length, "Max. Length", "Maximum length/Length (uint32 dec)"),
UAT_FLD_DEC(someip_parameter_strings, length_of_length, "Length of Len Field", "Length of the length field in bits (uint8 dec)"),
UAT_FLD_BOOL(someip_parameter_strings, big_endian, "Big Endian", "Encoded Big Endian"),
UAT_FLD_DEC(someip_parameter_strings, pad_to, "Pad to", "Padding pads to reach alignment (8bit dec)"),
UAT_END_FIELDS
};
static uat_field_t someip_parameter_typedef_list_uat_fields[] = {
UAT_FLD_HEX(someip_parameter_typedefs, id, "ID ", "ID (32bit hex)"),
UAT_FLD_CSTRING(someip_parameter_typedefs, name, "Name", "Name of typedef (string)"),
UAT_FLD_DEC(someip_parameter_typedefs, data_type, "Data Type", "Type referenced item (1: base, 2: string, 3: array, 4: struct, 5: union, 6: typedef, 7: enum)"),
UAT_FLD_HEX(someip_parameter_typedefs, id_ref, "ID Reference", "ID Reference (32bit hex)"),
UAT_END_FIELDS
};
static ei_register_info ei[] = {
{ &ef_someip_unknown_version,{ "someip.unknown_protocol_version",
PI_PROTOCOL, PI_WARN, "SOME/IP Unknown Protocol Version!", EXPFILL } },
{ &ef_someip_message_truncated,{ "someip.message_truncated",
PI_MALFORMED, PI_ERROR, "SOME/IP Truncated message!", EXPFILL } },
{ &ef_someip_incomplete_headers,{ "someip.incomplete_headers",
PI_MALFORMED, PI_ERROR, "SOME/IP Incomplete headers or some bytes left over!", EXPFILL } },
{ &ef_someip_payload_truncated, {"someip.payload.expert_truncated",
PI_MALFORMED, PI_ERROR, "SOME/IP Payload: Truncated payload!", EXPFILL} },
{ &ef_someip_payload_malformed, {"someip.payload.expert_malformed",
PI_MALFORMED, PI_ERROR, "SOME/IP Payload: Malformed payload!", EXPFILL} },
{ &ef_someip_payload_config_error, {"someip.payload.expert_config_error",
PI_MALFORMED, PI_ERROR, "SOME/IP Payload: Config Error!", EXPFILL} },
{ &ef_someip_payload_alignment_error, {"someip.payload.expert_alignment_error",
PI_MALFORMED, PI_ERROR, "SOME/IP Payload: SOME/IP datatype must be align to a byte!", EXPFILL} },
{ &ef_someip_payload_static_array_min_not_max, {"someip.payload.expert_static_array_min_max",
PI_MALFORMED, PI_ERROR, "SOME/IP Payload: Static array with min!=max!", EXPFILL} },
{ &ef_someip_payload_dyn_array_not_within_limit, {"someip.payload.expert_dyn_array_not_within_limit",
PI_MALFORMED, PI_WARN, "SOME/IP Payload: Dynamic array does not stay between Min and Max values!", EXPFILL} },
};
/* Register Protocol, Handles, Fields, ETTs, Expert Info, Dissector Table, Taps */
proto_someip = proto_register_protocol(SOMEIP_NAME_LONG, SOMEIP_NAME, SOMEIP_NAME_FILTER);
someip_handle_udp = register_dissector("someip_udp", dissect_someip_udp, proto_someip);
someip_handle_tcp = register_dissector("someip_tcp", dissect_someip_tcp, proto_someip);
proto_register_field_array(proto_someip, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_module_someip = expert_register_protocol(proto_someip);
expert_register_field_array(expert_module_someip, ei, array_length(ei));
someip_dissector_table = register_dissector_table("someip.messageid", "SOME/IP Message ID", proto_someip, FT_UINT32, BASE_HEX);
tap_someip_messages = register_tap("someip_messages");
/* init for SOME/IP-TP */
reassembly_table_init(&someip_tp_reassembly_table, &someip_reassembly_table_functions);
/* Register preferences */
someip_module = prefs_register_protocol(proto_someip, &proto_reg_handoff_someip);
/* UATs */
someip_service_uat = uat_new("SOME/IP Services",
sizeof(generic_one_id_string_t), /* record size */
DATAFILE_SOMEIP_SERVICES, /* filename */
TRUE, /* from profile */
(void **) &someip_service_ident, /* data_ptr */
&someip_service_ident_num, /* numitems_ptr */
UAT_AFFECTS_DISSECTION, /* but not fields */
NULL, /* help */
copy_generic_one_id_string_cb, /* copy callback */
update_generic_one_identifier_16bit, /* update callback */
free_generic_one_id_string_cb, /* free callback */
post_update_someip_service_cb, /* post update callback */
reset_someip_service_cb, /* reset callback */
someip_service_uat_fields /* UAT field definitions */
);
prefs_register_uat_preference(someip_module, "services", "SOME/IP Services",
"A table to define names of SOME/IP services", someip_service_uat);
someip_method_uat = uat_new("SOME/IP Methods/Events/Fields",
sizeof(generic_two_id_string_t), /* record size */
DATAFILE_SOMEIP_METHODS, /* filename */
TRUE, /* from profile */
(void **) &someip_method_ident, /* data_ptr */
&someip_method_ident_num, /* numitems_ptr */
UAT_AFFECTS_DISSECTION, /* but not fields */
NULL, /* help */
copy_generic_two_id_string_cb, /* copy callback */
update_generic_two_identifier_16bit, /* update callback */
free_generic_two_id_string_cb, /* free callback */
post_update_someip_method_cb, /* post update callback */
reset_someip_method_cb, /* reset callback */
someip_method_uat_fields /* UAT field definitions */
);
prefs_register_uat_preference(someip_module, "methods", "SOME/IP Methods",
"A table to define names of SOME/IP methods", someip_method_uat);
someip_eventgroup_uat = uat_new("SOME/IP Eventgroups",
sizeof(generic_two_id_string_t), /* record size */
DATAFILE_SOMEIP_EVENTGROUPS, /* filename */
TRUE, /* from profile */
(void **) &someip_eventgroup_ident, /* data_ptr */
&someip_eventgroup_ident_num, /* numitems_ptr */
UAT_AFFECTS_DISSECTION, /* but not fields */
NULL, /* help */
copy_generic_two_id_string_cb, /* copy callback */
update_generic_two_identifier_16bit, /* update callback */
free_generic_two_id_string_cb, /* free callback */
post_update_someip_eventgroup_cb, /* post update callback */
reset_someip_eventgroup_cb, /* reset callback */
someip_eventgroup_uat_fields /* UAT field definitions */
);
prefs_register_uat_preference(someip_module, "eventgroups", "SOME/IP Eventgroups",
"A table to define names of SOME/IP eventgroups", someip_eventgroup_uat);
someip_client_uat = uat_new("SOME/IP Clients",
sizeof(generic_two_id_string_t), /* record size */
DATAFILE_SOMEIP_CLIENTS, /* filename */
TRUE, /* from profile */
(void **)&someip_client_ident, /* data_ptr */
&someip_client_ident_num, /* numitems_ptr */
UAT_AFFECTS_DISSECTION, /* but not fields */
NULL, /* help */
copy_generic_two_id_string_cb, /* copy callback */
update_generic_two_identifier_16bit, /* update callback */
free_generic_two_id_string_cb, /* free callback */
post_update_someip_client_cb, /* post update callback */
reset_someip_client_cb, /* reset callback */
someip_client_uat_fields /* UAT field definitions */
);
prefs_register_uat_preference(someip_module, "clients", "SOME/IP Clients",
"A table to define names of SOME/IP clients", someip_client_uat);
someip_parameter_list_uat = uat_new("SOME/IP Parameter List",
sizeof(someip_parameter_list_uat_t), /* record size */
DATAFILE_SOMEIP_PARAMETERS, /* filename */
TRUE, /* from profile */
(void **)&someip_parameter_list, /* data_ptr */
&someip_parameter_list_num, /* numitems_ptr */
UAT_AFFECTS_DISSECTION | UAT_AFFECTS_FIELDS,
NULL, /* help */
copy_someip_parameter_list_cb, /* copy callback */
update_someip_parameter_list, /* update callback */
free_someip_parameter_list_cb, /* free callback */
post_update_someip_parameter_list_cb, /* post update callback */
reset_someip_parameter_list_cb, /* reset callback */
someip_parameter_list_uat_fields /* UAT field definitions */
);
prefs_register_bool_preference(someip_module, "reassemble_tp", "Reassemble SOME/IP-TP",
"Reassemble SOME/IP-TP segments", &someip_tp_reassemble);
prefs_register_bool_preference(someip_module, "payload_dissector_activated",
"Dissect Payload",
"Should the SOME/IP Dissector use the payload dissector?",
&someip_deserializer_activated);
prefs_register_bool_preference(someip_module, "detect_dtls_and_hand_off",
"Try to automatically detect DTLS",
"Should the SOME/IP Dissector automatically detect DTLS and hand off to it?",
&someip_detect_dtls);
prefs_register_bool_preference(someip_module, "payload_dissector_wtlv_default",
"Try WTLV payload dissection for unconfigured messages (not pure SOME/IP)",
"Should the SOME/IP Dissector use the payload dissector with the experimental WTLV encoding for unconfigured messages?",
&someip_deserializer_wtlv_default);
prefs_register_uat_preference(someip_module, "_someip_parameter_list", "SOME/IP Parameter List",
"A table to define names of SOME/IP parameters", someip_parameter_list_uat);
someip_parameter_arrays_uat = uat_new("SOME/IP Parameter Arrays",
sizeof(someip_parameter_array_uat_t), /* record size */
DATAFILE_SOMEIP_ARRAYS, /* filename */
TRUE, /* from profile */
(void **)&someip_parameter_arrays, /* data_ptr */
&someip_parameter_arrays_num, /* numitems_ptr */
UAT_AFFECTS_DISSECTION | UAT_AFFECTS_FIELDS,
NULL, /* help */
copy_someip_parameter_array_cb, /* copy callback */
update_someip_parameter_array, /* update callback */
free_someip_parameter_array_cb, /* free callback */
post_update_someip_parameter_array_cb, /* post update callback */
reset_someip_parameter_array_cb, /* reset callback */
someip_parameter_array_uat_fields /* UAT field definitions */
);
prefs_register_uat_preference(someip_module, "_someip_parameter_arrays", "SOME/IP Parameter Arrays",
"A table to define arrays used by SOME/IP", someip_parameter_arrays_uat);
someip_parameter_structs_uat = uat_new("SOME/IP Parameter Structs",
sizeof(someip_parameter_struct_uat_t), /* record size */
DATAFILE_SOMEIP_STRUCTS, /* filename */
TRUE, /* from profile */
(void **)&someip_parameter_structs, /* data_ptr */
&someip_parameter_structs_num, /* numitems_ptr */
UAT_AFFECTS_DISSECTION | UAT_AFFECTS_FIELDS,
NULL, /* help */
copy_someip_parameter_struct_cb, /* copy callback */
update_someip_parameter_struct, /* update callback */
free_someip_parameter_struct_cb, /* free callback */
post_update_someip_parameter_struct_cb, /* post update callback */
reset_someip_parameter_struct_cb, /* reset callback */
someip_parameter_struct_uat_fields /* UAT field definitions */
);
prefs_register_uat_preference(someip_module, "_someip_parameter_structs", "SOME/IP Parameter Structs",
"A table to define structs used by SOME/IP", someip_parameter_structs_uat);
someip_parameter_unions_uat = uat_new("SOME/IP Parameter Unions",
sizeof(someip_parameter_union_uat_t), /* record size */
DATAFILE_SOMEIP_UNIONS, /* filename */
TRUE, /* from profile */
(void **)&someip_parameter_unions, /* data_ptr */
&someip_parameter_unions_num, /* numitems_ptr */
UAT_AFFECTS_DISSECTION | UAT_AFFECTS_FIELDS,
NULL, /* help */
copy_someip_parameter_union_cb, /* copy callback */
update_someip_parameter_union, /* update callback */
free_someip_parameter_union_cb, /* free callback */
post_update_someip_parameter_union_cb, /* post update callback */
reset_someip_parameter_union_cb, /* reset callback */
someip_parameter_union_uat_fields /* UAT field definitions */
);
prefs_register_uat_preference(someip_module, "_someip_parameter_unions", "SOME/IP Parameter Unions",
"A table to define unions used by SOME/IP", someip_parameter_unions_uat);
someip_parameter_enums_uat = uat_new("SOME/IP Parameter Enums",
sizeof(someip_parameter_enum_uat_t), /* record size */
DATAFILE_SOMEIP_ENUMS, /* filename */
TRUE, /* from profile */
(void **)&someip_parameter_enums, /* data_ptr */
&someip_parameter_enums_num, /* numitems_ptr */
UAT_AFFECTS_DISSECTION, /* but not fields */
NULL, /* help */
copy_someip_parameter_enum_cb, /* copy callback */
update_someip_parameter_enum, /* update callback */
free_someip_parameter_enum_cb, /* free callback */
post_update_someip_parameter_enum_cb, /* post update callback */
reset_someip_parameter_enum_cb, /* reset callback */
someip_parameter_enum_uat_fields /* UAT field definitions */
);
prefs_register_uat_preference(someip_module, "_someip_parameter_enums", "SOME/IP Parameter Enums",
"A table to define enumerations used by SOME/IP", someip_parameter_enums_uat);
someip_parameter_base_type_list_uat = uat_new("SOME/IP Parameter Base Type List",
sizeof(someip_parameter_base_type_list_uat_t), /* record size */
DATAFILE_SOMEIP_BASE_TYPES, /* filename */
TRUE, /* from profile */
(void **)&someip_parameter_base_type_list, /* data_ptr */
&someip_parameter_base_type_list_num, /* numitems_ptr */
UAT_AFFECTS_DISSECTION, /* but not fields */
NULL, /* help */
copy_someip_parameter_base_type_list_cb, /* copy callback */
update_someip_parameter_base_type_list, /* update callback */
free_someip_parameter_base_type_list_cb, /* free callback */
post_update_someip_parameter_base_type_list_cb, /* post update callback */
reset_someip_parameter_base_type_list_cb, /* reset callback */
someip_parameter_base_type_list_uat_fields /* UAT field definitions */
);
prefs_register_uat_preference(someip_module, "_someip_parameter_base_type_list", "SOME/IP Parameter Base Type List",
"A table to define base types of SOME/IP parameters", someip_parameter_base_type_list_uat);
someip_parameter_strings_uat = uat_new("SOME/IP Parameter String List",
sizeof(someip_parameter_string_uat_t), /* record size */
DATAFILE_SOMEIP_STRINGS, /* filename */
TRUE, /* from profile */
(void **)&someip_parameter_strings, /* data_ptr */
&someip_parameter_strings_num, /* numitems_ptr */
UAT_AFFECTS_DISSECTION, /* but not fields */
NULL, /* help */
copy_someip_parameter_string_list_cb, /* copy callback */
update_someip_parameter_string_list, /* update callback */
free_someip_parameter_string_list_cb, /* free callback */
post_update_someip_parameter_string_list_cb, /* post update callback */
reset_someip_parameter_string_list_cb, /* reset callback */
someip_parameter_string_list_uat_fields /* UAT field definitions */
);
prefs_register_uat_preference(someip_module, "_someip_parameter_string_list", "SOME/IP Parameter String List",
"A table to define strings parameters", someip_parameter_strings_uat);
someip_parameter_typedefs_uat = uat_new("SOME/IP Parameter Typedef List",
sizeof(someip_parameter_typedef_uat_t), /* record size */
DATAFILE_SOMEIP_TYPEDEFS, /* filename */
TRUE, /* from profile */
(void **)&someip_parameter_typedefs, /* data_ptr */
&someip_parameter_typedefs_num, /* numitems_ptr */
UAT_AFFECTS_DISSECTION, /* but not fields */
NULL, /* help */
copy_someip_parameter_typedef_list_cb, /* copy callback */
update_someip_parameter_typedef_list, /* update callback */
free_someip_parameter_typedef_list_cb, /* free callback */
post_update_someip_parameter_typedef_list_cb, /* post update callback */
reset_someip_parameter_typedef_list_cb, /* reset callback */
someip_parameter_typedef_list_uat_fields /* UAT field definitions */
);
prefs_register_uat_preference(someip_module, "_someip_parameter_typedef_list", "SOME/IP Parameter Typedef List",
"A table to define typedefs", someip_parameter_typedefs_uat);
}
static void
clean_all_hashtables_with_empty_uat(void) {
/* On config change, we delete all hashtables which should have 0 entries! */
/* Usually this is already done in the post update cb of the uat.*/
/* Unfortunately, Wireshark does not call the post_update_cb on config errors. :( */
if (data_someip_services && someip_service_ident_num==0) {
g_hash_table_destroy(data_someip_services);
data_someip_services = NULL;
}
if (data_someip_methods && someip_method_ident_num==0) {
g_hash_table_destroy(data_someip_methods);
data_someip_methods = NULL;
}
if (data_someip_eventgroups && someip_eventgroup_ident_num==0) {
g_hash_table_destroy(data_someip_eventgroups);
data_someip_eventgroups = NULL;
}
if (data_someip_clients && someip_client_ident_num == 0) {
g_hash_table_destroy(data_someip_clients);
data_someip_clients = NULL;
}
if (data_someip_parameter_list && someip_parameter_list_num==0) {
g_hash_table_destroy(data_someip_parameter_list);
data_someip_parameter_list = NULL;
}
if (data_someip_parameter_arrays && someip_parameter_arrays_num==0) {
g_hash_table_destroy(data_someip_parameter_arrays);
data_someip_parameter_arrays = NULL;
}
if (data_someip_parameter_structs && someip_parameter_structs_num==0) {
g_hash_table_destroy(data_someip_parameter_structs);
data_someip_parameter_structs = NULL;
}
if (data_someip_parameter_unions && someip_parameter_unions_num==0) {
g_hash_table_destroy(data_someip_parameter_unions);
data_someip_parameter_unions = NULL;
}
if (data_someip_parameter_enums && someip_parameter_enums_num == 0) {
g_hash_table_destroy(data_someip_parameter_enums);
data_someip_parameter_enums = NULL;
}
if (data_someip_parameter_base_type_list && someip_parameter_base_type_list_num==0) {
g_hash_table_destroy(data_someip_parameter_base_type_list);
data_someip_parameter_base_type_list = NULL;
}
if (data_someip_parameter_strings && someip_parameter_strings_num==0) {
g_hash_table_destroy(data_someip_parameter_strings);
data_someip_parameter_strings = NULL;
}
if (data_someip_parameter_typedefs && someip_parameter_typedefs_num==0) {
g_hash_table_destroy(data_someip_parameter_typedefs);
data_someip_parameter_typedefs = NULL;
}
}
void
proto_reg_handoff_someip(void) {
static gboolean initialized = FALSE;
if (!initialized) {
/* add support for (D)TLS decode as */
dtls_dissector_add(0, someip_handle_udp);
ssl_dissector_add(0, someip_handle_tcp);
heur_dissector_add("udp", dissect_some_ip_heur_udp, "SOME/IP over UDP", "someip_udp_heur", proto_someip, HEURISTIC_DISABLE);
heur_dissector_add("tcp", dissect_some_ip_heur_tcp, "SOME/IP over TCP", "someip_tcp_heur", proto_someip, HEURISTIC_DISABLE);
stats_tree_register("someip_messages", "someip_messages", "SOME/IP Messages", 0, someip_messages_stats_tree_packet, someip_messages_stats_tree_init, NULL);
dissector_add_uint_range_with_preference("udp.port", "", someip_handle_udp);
dissector_add_uint_range_with_preference("tcp.port", "", someip_handle_tcp);
dtls_handle = find_dissector("dtls");
initialized = TRUE;
} else {
clean_all_hashtables_with_empty_uat();
}
update_dynamic_hf_entries_someip_parameter_list();
update_dynamic_hf_entries_someip_parameter_arrays();
update_dynamic_hf_entries_someip_parameter_structs();
update_dynamic_hf_entries_someip_parameter_unions();
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-someip.h
|
/* packet-someip.h
* Definitions for SOME/IP packet disassembly structures and routines
* By Dr. Lars Voelker <[email protected]> / <[email protected]>
* Copyright 2012-2022 Dr. Lars Voelker
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* used for SD to add ports dynamically */
void register_someip_port_udp(guint32 portnumber);
void register_someip_port_tcp(guint32 portnumber);
/* look up names for SD */
char* someip_lookup_service_name(guint16 serviceid);
char* someip_lookup_eventgroup_name(guint16 serviceid, guint16 eventgroupid);
typedef struct _someip_info
{
guint16 service_id;
guint16 method_id;
guint16 client_id;
guint16 session_id;
guint8 message_type;
guint8 major_version;
} someip_info_t;
#define SOMEIP_INFO_T_INIT { 0, 0, 0, 0, 0, 0 }
typedef struct _someip_messages_tap {
guint16 service_id;
guint16 method_id;
guint8 interface_version;
guint8 message_type;
} someip_messages_tap_t;
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
|
C
|
wireshark/epan/dissectors/packet-soupbintcp.c
|
/* packet-soupbintcp.c
* Routines for SoupBinTCP 3.0 protocol dissection
* Copyright 2013 David Arnold <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
* SoupBinTCP is a framing protocol published and used by NASDAQ to
* encapsulate both market data (ITCH) and order entry (OUCH)
* protocols. It is derived from the original SOUP protocol, which
* was ASCII-based, and relied on an EOL indicator as a message
* boundary.
*
* SoupBinTCP was introduced with OUCH-4.0 / ITCH-4.0 when those
* protocols also switched to using a binary representation for
* numerical values.
*
* The SOUP/SoupBinTCP protocols are also commonly used by other
* financial exchanges, although frequently they are more SOUP-like
* than exactly the same. This dissector doesn't attempt to support
* any other SOUP-like variants; I think it's probably better to have
* separate (if similar) dissectors for them.
*
* The only really complexity in the protocol is the message sequence
* numbering. See the comments below for an explanation of how it is
* handled.
*
* Specifications are available from NASDAQ's website, although the
* links to find them tend to move around over time. At the time of
* writing the correct URL is:
*
* http://www.nasdaqtrader.com/content/technicalsupport/specifications/dataproducts/soupbintcp.pdf
*
*/
#include "config.h"
#include <stdlib.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/proto_data.h>
#include <epan/expert.h>
#include <wsutil/strtoi.h>
/* For tcp_dissect_pdus() */
#include "packet-tcp.h"
void proto_register_soupbintcp(void);
void proto_reg_handoff_soupbintcp(void);
/** Session data stored in the conversation */
struct conv_data {
/** Next expected sequence number
*
* Set by the Login Accepted packet, and then updated for each
* subsequent Sequenced Data packet during dissection. */
guint next_seq;
};
/** Per-PDU data, stored in the frame's private data pointer */
struct pdu_data {
/** Sequence number for this PDU */
guint seq_num;
};
/** Packet names, indexed by message type code value */
static const value_string pkt_type_val[] = {
{ '+', "Debug Packet" },
{ 'A', "Login Accepted" },
{ 'H', "Server Heartbeat" },
{ 'J', "Login Rejected" },
{ 'L', "Login Request" },
{ 'O', "Logout Request" },
{ 'R', "Client Heartbeat" },
{ 'S', "Sequenced Data" },
{ 'U', "Unsequenced Data" },
{ 'Z', "End of Session" },
{ 0, NULL }
};
/** Login reject reasons, indexed by code value */
static const value_string reject_code_val[] = {
{ 'A', "Not authorized" },
{ 'S', "Session not available" },
{ 0, NULL }
};
/* Initialize the protocol and registered fields */
static int proto_soupbintcp = -1;
static dissector_handle_t soupbintcp_handle;
static heur_dissector_list_t heur_subdissector_list;
/* Preferences */
static gboolean soupbintcp_desegment = TRUE;
/* Initialize the subtree pointers */
static gint ett_soupbintcp = -1;
/* Header field formatting */
static int hf_soupbintcp_packet_length = -1;
static int hf_soupbintcp_packet_type = -1;
static int hf_soupbintcp_message = -1;
static int hf_soupbintcp_text = -1;
static int hf_soupbintcp_username = -1;
static int hf_soupbintcp_password = -1;
static int hf_soupbintcp_session = -1;
static int hf_soupbintcp_seq_num = -1;
static int hf_soupbintcp_next_seq_num = -1;
static int hf_soupbintcp_req_seq_num = -1;
static int hf_soupbintcp_reject_code = -1;
static expert_field ei_soupbintcp_next_seq_num_invalid = EI_INIT;
static expert_field ei_soupbintcp_req_seq_num_invalid = EI_INIT;
/** Dissector for SoupBinTCP messages */
static void
dissect_soupbintcp_common(
tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree)
{
struct conv_data *conv_data;
struct pdu_data *pdu_data;
const char *pkt_name;
gint32 seq_num;
gboolean seq_num_valid;
proto_item *ti;
proto_tree *soupbintcp_tree = NULL;
conversation_t *conv = NULL;
guint16 expected_len;
guint8 pkt_type;
gint offset = 0;
guint this_seq = 0, next_seq = 0, key;
heur_dtbl_entry_t *hdtbl_entry;
proto_item *pi;
/* Record the start of the packet to use as a sequence number key */
key = (guint)tvb_raw_offset(tvb);
/* Get the 16-bit big-endian SOUP packet length */
expected_len = tvb_get_ntohs(tvb, 0);
/* Get the 1-byte SOUP message type */
pkt_type = tvb_get_guint8(tvb, 2);
/* Since we use the packet name a few times, get and save that value */
pkt_name = val_to_str(pkt_type, pkt_type_val, "Unknown (%u)");
/* Set the protocol name in the summary display */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SoupBinTCP");
/* Set the packet name in the info column */
col_add_str(pinfo->cinfo, COL_INFO, pkt_name);
/* Sequence number tracking
*
* SOUP does not number packets from client to server (the server
* acknowledges all important messages, so the client should use
* the acks to figure out if the server received the message, and
* otherwise resend it).
*
* Packets from server to client are numbered, but it's implicit.
* The Login Accept packet contains the next sequence number that
* the server will send, and the client needs to count the
* Sequenced Data packets that it receives to know what their
* sequence numbers are.
*
* So, we grab the next sequence number from the Login Acceptance
* packet, and save it in a conversation_t we associate with the
* TCP session. Then, for each Sequenced Data packet we receive,
* the first time it's processed (when PINFO_FD_VISITED() is
* false), we write it into the PDU's frame's private data pointer
* and increment the saved sequence number (in the conversation_t).
*
* If the visited flag is true, then we've dissected this packet
* already, and so we can fetch the sequence number from the
* frame's private data area.
*
* In either case, if there's any problem, we report zero as the
* sequence number, and try to continue dissecting. */
/* If first dissection of Login Accept, save sequence number */
if (pkt_type == 'A' && !PINFO_FD_VISITED(pinfo)) {
ws_strtou32(tvb_get_string_enc(pinfo->pool, tvb, 13, 20, ENC_ASCII),
NULL, &next_seq);
/* Create new conversation for this session */
conv = conversation_new(pinfo->num,
&pinfo->src,
&pinfo->dst,
conversation_pt_to_conversation_type(pinfo->ptype),
pinfo->srcport,
pinfo->destport,
0);
/* Store starting sequence number for session's packets */
conv_data = wmem_new(wmem_file_scope(), struct conv_data);
conv_data->next_seq = next_seq;
conversation_add_proto_data(conv, proto_soupbintcp, conv_data);
}
/* Handle sequence numbering for a Sequenced Data packet */
if (pkt_type == 'S') {
if (!PINFO_FD_VISITED(pinfo)) {
/* Get next expected sequence number from conversation */
conv = find_conversation_pinfo(pinfo, 0);
if (!conv) {
this_seq = 0;
} else {
conv_data = (struct conv_data *)conversation_get_proto_data(conv,
proto_soupbintcp);
if (conv_data) {
this_seq = conv_data->next_seq++;
} else {
this_seq = 0;
}
pdu_data = wmem_new(wmem_file_scope(), struct pdu_data);
pdu_data->seq_num = this_seq;
p_add_proto_data(wmem_file_scope(), pinfo, proto_soupbintcp, key, pdu_data);
}
} else {
pdu_data = (struct pdu_data *)p_get_proto_data(wmem_file_scope(), pinfo, proto_soupbintcp, key);
if (pdu_data) {
this_seq = pdu_data->seq_num;
} else {
this_seq = 0;
}
}
col_append_fstr(pinfo->cinfo, COL_INFO, ", SeqNum = %u", this_seq);
}
if (tree) {
/* Create sub-tree for SoupBinTCP details */
ti = proto_tree_add_item(tree,
proto_soupbintcp,
tvb, 0, -1, ENC_NA);
soupbintcp_tree = proto_item_add_subtree(ti, ett_soupbintcp);
/* Append the packet name to the sub-tree item */
proto_item_append_text(ti, ", %s", pkt_name);
/* Length */
proto_tree_add_item(soupbintcp_tree,
hf_soupbintcp_packet_length,
tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* Type */
proto_tree_add_item(soupbintcp_tree,
hf_soupbintcp_packet_type,
tvb, offset, 1, ENC_ASCII|ENC_NA);
offset += 1;
switch (pkt_type) {
case '+': /* Debug Message */
proto_tree_add_item(soupbintcp_tree,
hf_soupbintcp_text,
tvb, offset, expected_len - 1, ENC_ASCII);
break;
case 'A': /* Login Accept */
proto_tree_add_item(soupbintcp_tree,
hf_soupbintcp_session,
tvb, offset, 10, ENC_ASCII);
offset += 10;
seq_num_valid = ws_strtoi32(tvb_get_string_enc(pinfo->pool,
tvb, offset, 20, ENC_ASCII), NULL, &seq_num);
pi = proto_tree_add_string_format_value(soupbintcp_tree,
hf_soupbintcp_next_seq_num,
tvb, offset, 20,
"X", "%d", seq_num);
if (!seq_num_valid)
expert_add_info(pinfo, pi, &ei_soupbintcp_next_seq_num_invalid);
break;
case 'J': /* Login Reject */
proto_tree_add_item(soupbintcp_tree,
hf_soupbintcp_reject_code,
tvb, offset, 1, ENC_ASCII|ENC_NA);
break;
case 'U': /* Unsequenced Data */
/* Display handled by sub-dissector */
break;
case 'S': /* Sequenced Data */
proto_item_append_text(ti, ", SeqNum=%u", this_seq);
proto_tree_add_string_format_value(soupbintcp_tree,
hf_soupbintcp_seq_num,
tvb, offset, 0,
"X",
"%u (Calculated)",
this_seq);
/* Display handled by sub-dissector */
break;
case 'L': /* Login Request */
proto_tree_add_item(soupbintcp_tree,
hf_soupbintcp_username,
tvb, offset, 6, ENC_ASCII);
offset += 6;
proto_tree_add_item(soupbintcp_tree,
hf_soupbintcp_password,
tvb, offset, 10, ENC_ASCII);
offset += 10;
proto_tree_add_item(soupbintcp_tree,
hf_soupbintcp_session,
tvb, offset, 10, ENC_ASCII);
offset += 10;
seq_num_valid = ws_strtoi32(tvb_get_string_enc(pinfo->pool,
tvb, offset, 20, ENC_ASCII), NULL, &seq_num);
pi = proto_tree_add_string_format_value(soupbintcp_tree,
hf_soupbintcp_req_seq_num,
tvb, offset, 20,
"X", "%d", seq_num);
if (!seq_num_valid)
expert_add_info(pinfo, pi, &ei_soupbintcp_req_seq_num_invalid);
break;
case 'H': /* Server Heartbeat */
break;
case 'O': /* Logout Request */
break;
case 'R': /* Client Heartbeat */
break;
case 'Z': /* End of Session */
break;
default:
/* Unknown */
proto_tree_add_item(tree,
hf_soupbintcp_message,
tvb, offset, -1, ENC_NA);
break;
}
}
/* Call sub-dissector for encapsulated data */
if (pkt_type == 'S' || pkt_type == 'U') {
tvbuff_t *sub_tvb;
/* Sub-dissector tvb starts at 3 (length (2) + pkt_type (1)) */
sub_tvb = tvb_new_subset_remaining(tvb, 3);
/* Otherwise, try heuristic dissectors */
if (dissector_try_heuristic(heur_subdissector_list,
sub_tvb,
pinfo,
tree,
&hdtbl_entry,
NULL)) {
return;
}
/* Otherwise, give up, and just print the bytes in hex */
if (tree) {
proto_tree_add_item(soupbintcp_tree,
hf_soupbintcp_message,
sub_tvb, 0, -1,
ENC_NA);
}
}
}
/** Return the size of the PDU in @p tvb, starting at @p offset */
static guint
get_soupbintcp_pdu_len(
packet_info *pinfo _U_,
tvbuff_t *tvb,
int offset,
void *data _U_)
{
/* Determine the length of the PDU using the SOUP header's 16-bit
big-endian length (at offset zero). We're guaranteed to get at
least two bytes here because we told tcp_dissect_pdus() that we
needed them. Add 2 to the retrieved value, because the SOUP
length doesn't include the length field itself. */
return (guint)tvb_get_ntohs(tvb, offset) + 2;
}
/** Dissect a possibly-reassembled TCP PDU */
static int
dissect_soupbintcp_tcp_pdu(
tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree,
void *data _U_)
{
dissect_soupbintcp_common(tvb, pinfo, tree);
return tvb_captured_length(tvb);
}
/** Dissect a TCP segment containing SoupBinTCP data */
static int
dissect_soupbintcp_tcp(
tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree,
void *data)
{
tcp_dissect_pdus(tvb, pinfo, tree,
soupbintcp_desegment, 2,
get_soupbintcp_pdu_len,
dissect_soupbintcp_tcp_pdu, data);
return tvb_captured_length(tvb);
}
void
proto_register_soupbintcp(void)
{
expert_module_t* expert_soupbinttcp;
static hf_register_info hf[] = {
{ &hf_soupbintcp_packet_length,
{ "Packet Length", "soupbintcp.packet_length",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Packet length, in bytes, NOT including these two bytes.",
HFILL }},
{ &hf_soupbintcp_packet_type,
{ "Packet Type", "soupbintcp.packet_type",
FT_CHAR, BASE_HEX, VALS(pkt_type_val), 0x0,
"Message type code",
HFILL }},
{ &hf_soupbintcp_reject_code,
{ "Login Reject Code", "soupbintcp.reject_code",
FT_CHAR, BASE_HEX, VALS(reject_code_val), 0x0,
"Login reject reason code",
HFILL }},
{ &hf_soupbintcp_message,
{ "Message", "soupbintcp.message",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Content of SoupBinTCP frame",
HFILL }},
{ &hf_soupbintcp_text,
{ "Debug Text", "soupbintcp.text",
FT_STRING, BASE_NONE, NULL, 0x0,
"Free-form, human-readable text",
HFILL }},
{ &hf_soupbintcp_username,
{ "User Name", "soupbintcp.username",
FT_STRING, BASE_NONE, NULL, 0x0,
"User's login name",
HFILL }},
{ &hf_soupbintcp_password,
{ "Password", "soupbintcp.password",
FT_STRING, BASE_NONE, NULL, 0x0,
"User's login password",
HFILL }},
{ &hf_soupbintcp_session,
{ "Session", "soupbintcp.session",
FT_STRING, BASE_NONE, NULL, 0x0,
"Session identifier, or send all spaces to log into the currently "
"active session",
HFILL }},
{ &hf_soupbintcp_seq_num,
{ "Sequence number", "soupbintcp.seq_num",
FT_STRING, BASE_NONE, NULL, 0x0,
"Calculated sequence number for this message",
HFILL }},
{ &hf_soupbintcp_next_seq_num,
{ "Next sequence number", "soupbintcp.next_seq_num",
FT_STRING, BASE_NONE, NULL, 0x0,
"Sequence number of next Sequenced Data message to be delivered",
HFILL }},
{ &hf_soupbintcp_req_seq_num,
{ "Requested sequence number", "soupbintcp.req_seq_num",
FT_STRING, BASE_NONE, NULL, 0x0,
"Request to begin (re)transmission of Sequenced Data at this "
"sequence number, or, if zero, to begin transmission with the "
"next message generated",
HFILL }}
};
static gint *ett[] = {
&ett_soupbintcp
};
static ei_register_info ei[] = {
{ &ei_soupbintcp_req_seq_num_invalid, { "soupbintcp.req_seq_num.invalid", PI_MALFORMED, PI_ERROR,
"Sequence number of next Sequenced Data message to be delivered is an invalid string", EXPFILL }},
{ &ei_soupbintcp_next_seq_num_invalid, { "soupbintcp.next_seq_num.invalid", PI_MALFORMED, PI_ERROR,
"Request to begin (re)transmission is an invalid string", EXPFILL }}
};
module_t *soupbintcp_module;
proto_soupbintcp = proto_register_protocol("SoupBinTCP", "SoupBinTCP", "soupbintcp");
proto_register_field_array(proto_soupbintcp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
soupbintcp_module = prefs_register_protocol(proto_soupbintcp, NULL);
prefs_register_bool_preference(
soupbintcp_module,
"desegment",
"Reassemble SoupBinTCP messages spanning multiple TCP segments",
"Whether the SoupBinTCP dissector should reassemble messages "
"spanning multiple TCP segments.",
&soupbintcp_desegment);
heur_subdissector_list = register_heur_dissector_list("soupbintcp", proto_soupbintcp);
expert_soupbinttcp = expert_register_protocol(proto_soupbintcp);
expert_register_field_array(expert_soupbinttcp, ei, array_length(ei));
}
void
proto_reg_handoff_soupbintcp(void)
{
soupbintcp_handle = create_dissector_handle(dissect_soupbintcp_tcp, proto_soupbintcp);
dissector_add_uint_range_with_preference("tcp.port", "", soupbintcp_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-sparkplug.c
|
/* packet-sparkplug.c
* Routines for Sparkplug dissection
* Copyright 2021 Graham Bloice <graham.bloice<at>trihedral.com>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/expert.h>
/*
* See
*
* https://cirrus-link.com/mqtt-sparkplug-tahu/
*
* and the specification is at
*
* https://www.eclipse.org/tahu/spec/Sparkplug%20Topic%20Namespace%20and%20State%20ManagementV2.2-with%20appendix%20B%20format%20-%20Eclipse.pdf
*
*/
/* Prototypes */
/* (Required to prevent [-Wmissing-prototypes] warnings */
void proto_reg_handoff_sparkplug(void);
void proto_register_sparkplug(void);
/* Initialize the protocol field */
static int proto_sparkplugb = -1;
/* Initialize the subtree pointers */
static gint ett_sparkplugb = -1;
static gint ett_sparkplugb_namespace = -1;
/* The handle to the protobuf dissector */
dissector_handle_t protobuf_handle = NULL;
/* The hf items */
static int hf_sparkplugb_namespace = -1;
static int hf_sparkplugb_groupid = -1;
static int hf_sparkplugb_messagetype = -1;
static int hf_sparkplugb_edgenodeid = -1;
static int hf_sparkplugb_deviceid = -1;
/* The expert info items */
static expert_field ei_sparkplugb_missing_groupid = EI_INIT;
static expert_field ei_sparkplugb_missing_messagetype = EI_INIT;
static expert_field ei_sparkplugb_missing_edgenodeid = EI_INIT;
static gboolean
dissect_sparkplugb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
proto_item *ti;
proto_tree *sparkplugb_tree, *namespace_tree;
gchar **topic_elements, **current_element;
char *topic = (char *)data;
/* Confirm the expected topic data is present */
if (topic == NULL)
return FALSE;
/* Parse the topic into the elements */
topic_elements = g_strsplit(topic, "/", 5);
/* Heuristic check that the first element of the topic is the SparkplugB namespace */
if (!topic_elements || (g_strcmp0("spBv1.0", topic_elements[0]) != 0)) {
g_strfreev(topic_elements);
return FALSE;
}
/* Make entries in Protocol column */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SparkplugB");
/* Adjust the info column */
col_clear(pinfo->cinfo, COL_INFO);
col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "SparkplugB");
/* create display subtree for the protocol */
ti = proto_tree_add_item(tree, proto_sparkplugb, tvb, 0, -1, ENC_NA);
sparkplugb_tree = proto_item_add_subtree(ti, ett_sparkplugb);
/* Add the elements parsed out from the topic string */
namespace_tree = proto_tree_add_subtree(sparkplugb_tree, tvb, 0, 0, ett_sparkplugb_namespace, &ti, "Topic Namespace");
proto_item_set_generated(ti);
current_element = topic_elements;
ti = proto_tree_add_string(namespace_tree, hf_sparkplugb_namespace, tvb, 0, 0, current_element[0]);
proto_item_set_generated(ti);
current_element += 1;
if (current_element[0]) {
ti = proto_tree_add_string(namespace_tree, hf_sparkplugb_groupid, tvb, 0, 0, current_element[0]);
proto_item_set_generated(ti);
}
else {
expert_add_info(pinfo, namespace_tree, &ei_sparkplugb_missing_groupid);
return FALSE;
}
/* Adjust the info colum text with the message type */
current_element += 1;
if (current_element[0]) {
col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, current_element[0]);
col_set_fence(pinfo->cinfo, COL_INFO);
ti = proto_tree_add_string(namespace_tree, hf_sparkplugb_messagetype, tvb, 0, 0, current_element[0]);
proto_item_set_generated(ti);
}
else {
expert_add_info(pinfo, namespace_tree, &ei_sparkplugb_missing_messagetype);
return FALSE;
}
current_element += 1;
if (current_element[0]) {
ti = proto_tree_add_string(namespace_tree, hf_sparkplugb_edgenodeid, tvb, 0, 0, current_element[0]);
proto_item_set_generated(ti);
}
else {
expert_add_info(pinfo, namespace_tree, &ei_sparkplugb_missing_edgenodeid);
return FALSE;
}
/* Device ID is optional */
current_element += 1;
if (current_element[0]) {
ti = proto_tree_add_string(namespace_tree, hf_sparkplugb_deviceid, tvb, 0, 0, current_element[0]);
proto_item_set_generated(ti);
}
g_strfreev(topic_elements);
/* Now handoff the Payload message to the protobuf dissector */
call_dissector_with_data(protobuf_handle, tvb, pinfo, sparkplugb_tree, "message,com.cirruslink.sparkplug.protobuf.Payload");
return TRUE;
}
void proto_register_sparkplug(void)
{
expert_module_t* expert_sparkplugb;
static gint *ett[] = {
&ett_sparkplugb,
&ett_sparkplugb_namespace
};
static hf_register_info hf[] = {
{&hf_sparkplugb_namespace, {"Namespace", "sparkplugb.namespace", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{&hf_sparkplugb_groupid, {"Group ID", "sparkplugb.groupid", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{&hf_sparkplugb_messagetype, {"Message Type", "sparkplugb.messagetype", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{&hf_sparkplugb_edgenodeid, {"Edge Node ID", "sparkplugb.edgenodeid", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{&hf_sparkplugb_deviceid, {"Device ID", "sparkplugb.deviceid", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}},
};
static ei_register_info ei[] = {
{ &ei_sparkplugb_missing_groupid, { "sparkplugb.missing_groupid", PI_MALFORMED, PI_ERROR, "Missing Group ID", EXPFILL }},
{ &ei_sparkplugb_missing_messagetype, { "sparkplugb.missing_messagetype", PI_MALFORMED, PI_ERROR, "Missing Message Type", EXPFILL }},
{ &ei_sparkplugb_missing_edgenodeid, { "sparkplugb.missing_edgenodeid", PI_MALFORMED, PI_ERROR, "Missing Edge Node ID", EXPFILL }},
};
/* Register the protocol name and description, fields and trees */
proto_sparkplugb = proto_register_protocol("SparkplugB", "SparkplugB", "sparkplugb");
register_dissector("sparkplugb", dissect_sparkplugb, proto_sparkplugb);
proto_register_field_array(proto_sparkplugb, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_sparkplugb = expert_register_protocol(proto_sparkplugb);
expert_register_field_array(expert_sparkplugb, ei, array_length(ei));
}
void proto_reg_handoff_sparkplug(void)
{
protobuf_handle = find_dissector_add_dependency("protobuf", proto_sparkplugb);
/* register as heuristic dissector with MQTT */
heur_dissector_add("mqtt.topic", dissect_sparkplugb, "SparkplugB over MQTT",
"sparkplugb_mqtt", proto_sparkplugb, HEURISTIC_ENABLE);
}
|
C
|
wireshark/epan/dissectors/packet-spdy.c
|
/* packet-spdy.c
* Routines for SPDY packet disassembly
* For now, the protocol spec can be found at
* http://dev.chromium.org/spdy/spdy-protocol
*
* Copyright 2010, Google Inc.
* Hasan Khalil <[email protected]>
* Chris Bentzel <[email protected]>
* Eric Shienbrood <[email protected]>
*
* Copyright 2013-2014
* Alexis La Goutte <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Originally based on packet-http.c
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/expert.h>
#include <epan/tap.h>
#include "packet-tcp.h"
#include "packet-tls.h"
#include "packet-media-type.h"
#ifdef HAVE_ZLIB
#define ZLIB_CONST
#include <zlib.h>
#endif
void proto_register_spdy(void);
void proto_reg_handoff_spdy(void);
#define MIN_SPDY_VERSION 3
#define SPDY_STREAM_ID_MASK 0x7FFFFFFF
/*
* Conversation data - used for assembling multi-data-frame
* entities and for decompressing request & reply header blocks.
*/
typedef struct _spdy_conv_t {
#ifdef HAVE_ZLIB
z_streamp rqst_decompressor;
z_streamp rply_decompressor;
uLong dictionary_id;
#endif
wmem_tree_t *streams;
} spdy_conv_t;
/* The types of SPDY frames */
#define SPDY_DATA 0
#define SPDY_SYN_STREAM 1
#define SPDY_SYN_REPLY 2
#define SPDY_RST_STREAM 3
#define SPDY_SETTINGS 4
#define SPDY_PING 6
#define SPDY_GOAWAY 7
#define SPDY_HEADERS 8
#define SPDY_WINDOW_UPDATE 9
#define SPDY_CREDENTIAL 10
#define SPDY_INVALID 11
#define SPDY_FLAG_FIN 0x01
#define SPDY_FLAG_UNIDIRECTIONAL 0x02
#define SPDY_FLAG_SETTINGS_CLEAR_SETTINGS 0x01
/* Flags for each setting in a SETTINGS frame. */
#define SPDY_FLAG_SETTINGS_PERSIST_VALUE 0x01
#define SPDY_FLAG_SETTINGS_PERSISTED 0x02
#define TCP_PORT_SPDY 6121
static const value_string frame_type_names[] = {
{ SPDY_DATA, "DATA" },
{ SPDY_SYN_STREAM, "SYN_STREAM" },
{ SPDY_SYN_REPLY, "SYN_REPLY" },
{ SPDY_RST_STREAM, "RST_STREAM" },
{ SPDY_SETTINGS, "SETTINGS" },
{ SPDY_PING, "PING" },
{ SPDY_GOAWAY, "GOAWAY" },
{ SPDY_HEADERS, "HEADERS" },
{ SPDY_WINDOW_UPDATE, "WINDOW_UPDATE" },
{ SPDY_CREDENTIAL, "CREDENTIAL" },
{ SPDY_INVALID, "INVALID" },
{ 0, NULL }
};
static const value_string rst_stream_status_names[] = {
{ 1, "PROTOCOL_ERROR" },
{ 2, "INVALID_STREAM" },
{ 3, "REFUSED_STREAM" },
{ 4, "UNSUPPORTED_VERSION" },
{ 5, "CANCEL" },
{ 6, "INTERNAL_ERROR" },
{ 7, "FLOW_CONTROL_ERROR" },
{ 8, "STREAM_IN_USE" },
{ 9, "STREAM_ALREADY_CLOSED" },
{ 10, "INVALID_CREDENTIALS" },
{ 11, "FRAME_TOO_LARGE" },
{ 12, "INVALID" },
{ 0, NULL }
};
static const value_string setting_id_names[] = {
{ 1, "UPLOAD_BANDWIDTH" },
{ 2, "DOWNLOAD_BANDWIDTH" },
{ 3, "ROUND_TRIP_TIME" },
{ 4, "MAX_CONCURRENT_STREAMS" },
{ 5, "CURRENT_CWND" },
{ 6, "DOWNLOAD_RETRANS_RATE" },
{ 7, "INITIAL_WINDOW_SIZE" },
{ 0, NULL }
};
static const value_string goaway_status_names[] = {
{ 0, "OK" },
{ 1, "PROTOCOL_ERROR" },
{ 11, "INTERNAL_ERROR" },
{ 0, NULL }
};
/*
* This structure will be tied to each SPDY frame and is used as an argument for
* dissect_spdy_*_payload() functions.
*/
typedef struct _spdy_control_frame_info_t {
gboolean control_bit;
guint16 version;
guint16 type;
guint8 flags;
guint32 length; /* Actually only 24 bits. */
} spdy_control_frame_info_t;
/*
* This structure will be tied to each SPDY header frame.
* Only applies to frames containing headers: SYN_STREAM, SYN_REPLY, HEADERS
* Note that there may be multiple SPDY frames in one packet.
*/
typedef struct _spdy_header_info_t {
guint32 stream_id;
guint8 *header_block;
guint header_block_len;
guint16 frame_type;
} spdy_header_info_t;
static wmem_list_t *header_info_list;
/*
* This structures keeps track of all the data frames
* associated with a stream, so that they can be
* reassembled into a single chunk.
*/
typedef struct _spdy_data_frame_t {
guint8 *data;
guint32 length;
guint32 framenum;
} spdy_data_frame_t;
typedef struct _spdy_stream_info_t {
media_container_type_t container_type;
gchar *content_type;
gchar *content_type_parameters;
gchar *content_encoding;
wmem_list_t *data_frames;
tvbuff_t *assembled_data;
guint num_data_frames;
} spdy_stream_info_t;
/* Handles for metadata population. */
static int spdy_tap = -1;
static int spdy_eo_tap = -1;
static int proto_spdy = -1;
static int hf_spdy_data = -1;
static int hf_spdy_control_bit = -1;
static int hf_spdy_version = -1;
static int hf_spdy_type = -1;
static int hf_spdy_flags = -1;
static int hf_spdy_flags_fin = -1;
static int hf_spdy_flags_unidirectional = -1;
static int hf_spdy_flags_clear_settings = -1;
static int hf_spdy_flags_persist_value = -1;
static int hf_spdy_flags_persisted = -1;
static int hf_spdy_length = -1;
static int hf_spdy_header_block = -1;
static int hf_spdy_header = -1;
static int hf_spdy_header_name = -1;
static int hf_spdy_header_value = -1;
static int hf_spdy_streamid = -1;
static int hf_spdy_associated_streamid = -1;
static int hf_spdy_priority = -1;
static int hf_spdy_unused = -1;
static int hf_spdy_slot = -1;
static int hf_spdy_num_headers = -1;
static int hf_spdy_rst_stream_status = -1;
static int hf_spdy_num_settings = -1;
static int hf_spdy_setting = -1;
static int hf_spdy_setting_id = -1;
static int hf_spdy_setting_value = -1;
static int hf_spdy_ping_id = -1;
static int hf_spdy_goaway_last_good_stream_id = -1;
static int hf_spdy_goaway_status = -1;
static int hf_spdy_window_update_delta = -1;
static gint ett_spdy = -1;
static gint ett_spdy_flags = -1;
static gint ett_spdy_header_block = -1;
static gint ett_spdy_header = -1;
static gint ett_spdy_setting = -1;
static gint ett_spdy_encoded_entity = -1;
static expert_field ei_spdy_inflation_failed = EI_INIT;
static expert_field ei_spdy_mal_frame_data = EI_INIT;
static expert_field ei_spdy_mal_setting_frame = EI_INIT;
static expert_field ei_spdy_invalid_rst_stream = EI_INIT;
static expert_field ei_spdy_invalid_go_away = EI_INIT;
static expert_field ei_spdy_invalid_frame_type = EI_INIT;
static expert_field ei_spdy_reassembly_info = EI_INIT;
static dissector_handle_t media_handle;
static dissector_handle_t spdy_handle;
static dissector_table_t media_type_subdissector_table;
static dissector_table_t port_subdissector_table;
static gboolean spdy_assemble_entity_bodies = TRUE;
/*
* Decompression of zlib encoded entities.
*/
#ifdef HAVE_ZLIB
static gboolean spdy_decompress_body = TRUE;
static gboolean spdy_decompress_headers = TRUE;
#else
static gboolean spdy_decompress_body = FALSE;
static gboolean spdy_decompress_headers = FALSE;
#endif
#ifdef HAVE_ZLIB
static const char spdy_dictionary[] = {
0x00, 0x00, 0x00, 0x07, 0x6f, 0x70, 0x74, 0x69, /* - - - - o p t i */
0x6f, 0x6e, 0x73, 0x00, 0x00, 0x00, 0x04, 0x68, /* o n s - - - - h */
0x65, 0x61, 0x64, 0x00, 0x00, 0x00, 0x04, 0x70, /* e a d - - - - p */
0x6f, 0x73, 0x74, 0x00, 0x00, 0x00, 0x03, 0x70, /* o s t - - - - p */
0x75, 0x74, 0x00, 0x00, 0x00, 0x06, 0x64, 0x65, /* u t - - - - d e */
0x6c, 0x65, 0x74, 0x65, 0x00, 0x00, 0x00, 0x05, /* l e t e - - - - */
0x74, 0x72, 0x61, 0x63, 0x65, 0x00, 0x00, 0x00, /* t r a c e - - - */
0x06, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x00, /* - a c c e p t - */
0x00, 0x00, 0x0e, 0x61, 0x63, 0x63, 0x65, 0x70, /* - - - a c c e p */
0x74, 0x2d, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65, /* t - c h a r s e */
0x74, 0x00, 0x00, 0x00, 0x0f, 0x61, 0x63, 0x63, /* t - - - - a c c */
0x65, 0x70, 0x74, 0x2d, 0x65, 0x6e, 0x63, 0x6f, /* e p t - e n c o */
0x64, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x0f, /* d i n g - - - - */
0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x6c, /* a c c e p t - l */
0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x00, /* a n g u a g e - */
0x00, 0x00, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x70, /* - - - a c c e p */
0x74, 0x2d, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x73, /* t - r a n g e s */
0x00, 0x00, 0x00, 0x03, 0x61, 0x67, 0x65, 0x00, /* - - - - a g e - */
0x00, 0x00, 0x05, 0x61, 0x6c, 0x6c, 0x6f, 0x77, /* - - - a l l o w */
0x00, 0x00, 0x00, 0x0d, 0x61, 0x75, 0x74, 0x68, /* - - - - a u t h */
0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, /* o r i z a t i o */
0x6e, 0x00, 0x00, 0x00, 0x0d, 0x63, 0x61, 0x63, /* n - - - - c a c */
0x68, 0x65, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, /* h e - c o n t r */
0x6f, 0x6c, 0x00, 0x00, 0x00, 0x0a, 0x63, 0x6f, /* o l - - - - c o */
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, /* n n e c t i o n */
0x00, 0x00, 0x00, 0x0c, 0x63, 0x6f, 0x6e, 0x74, /* - - - - c o n t */
0x65, 0x6e, 0x74, 0x2d, 0x62, 0x61, 0x73, 0x65, /* e n t - b a s e */
0x00, 0x00, 0x00, 0x10, 0x63, 0x6f, 0x6e, 0x74, /* - - - - c o n t */
0x65, 0x6e, 0x74, 0x2d, 0x65, 0x6e, 0x63, 0x6f, /* e n t - e n c o */
0x64, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x10, /* d i n g - - - - */
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, /* c o n t e n t - */
0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, /* l a n g u a g e */
0x00, 0x00, 0x00, 0x0e, 0x63, 0x6f, 0x6e, 0x74, /* - - - - c o n t */
0x65, 0x6e, 0x74, 0x2d, 0x6c, 0x65, 0x6e, 0x67, /* e n t - l e n g */
0x74, 0x68, 0x00, 0x00, 0x00, 0x10, 0x63, 0x6f, /* t h - - - - c o */
0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x6c, 0x6f, /* n t e n t - l o */
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, /* c a t i o n - - */
0x00, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, /* - - c o n t e n */
0x74, 0x2d, 0x6d, 0x64, 0x35, 0x00, 0x00, 0x00, /* t - m d 5 - - - */
0x0d, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, /* - c o n t e n t */
0x2d, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x00, /* - r a n g e - - */
0x00, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, /* - - c o n t e n */
0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x00, 0x00, /* t - t y p e - - */
0x00, 0x04, 0x64, 0x61, 0x74, 0x65, 0x00, 0x00, /* - - d a t e - - */
0x00, 0x04, 0x65, 0x74, 0x61, 0x67, 0x00, 0x00, /* - - e t a g - - */
0x00, 0x06, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, /* - - e x p e c t */
0x00, 0x00, 0x00, 0x07, 0x65, 0x78, 0x70, 0x69, /* - - - - e x p i */
0x72, 0x65, 0x73, 0x00, 0x00, 0x00, 0x04, 0x66, /* r e s - - - - f */
0x72, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x04, 0x68, /* r o m - - - - h */
0x6f, 0x73, 0x74, 0x00, 0x00, 0x00, 0x08, 0x69, /* o s t - - - - i */
0x66, 0x2d, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x00, /* f - m a t c h - */
0x00, 0x00, 0x11, 0x69, 0x66, 0x2d, 0x6d, 0x6f, /* - - - i f - m o */
0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x2d, 0x73, /* d i f i e d - s */
0x69, 0x6e, 0x63, 0x65, 0x00, 0x00, 0x00, 0x0d, /* i n c e - - - - */
0x69, 0x66, 0x2d, 0x6e, 0x6f, 0x6e, 0x65, 0x2d, /* i f - n o n e - */
0x6d, 0x61, 0x74, 0x63, 0x68, 0x00, 0x00, 0x00, /* m a t c h - - - */
0x08, 0x69, 0x66, 0x2d, 0x72, 0x61, 0x6e, 0x67, /* - i f - r a n g */
0x65, 0x00, 0x00, 0x00, 0x13, 0x69, 0x66, 0x2d, /* e - - - - i f - */
0x75, 0x6e, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, /* u n m o d i f i */
0x65, 0x64, 0x2d, 0x73, 0x69, 0x6e, 0x63, 0x65, /* e d - s i n c e */
0x00, 0x00, 0x00, 0x0d, 0x6c, 0x61, 0x73, 0x74, /* - - - - l a s t */
0x2d, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, /* - m o d i f i e */
0x64, 0x00, 0x00, 0x00, 0x08, 0x6c, 0x6f, 0x63, /* d - - - - l o c */
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, /* a t i o n - - - */
0x0c, 0x6d, 0x61, 0x78, 0x2d, 0x66, 0x6f, 0x72, /* - m a x - f o r */
0x77, 0x61, 0x72, 0x64, 0x73, 0x00, 0x00, 0x00, /* w a r d s - - - */
0x06, 0x70, 0x72, 0x61, 0x67, 0x6d, 0x61, 0x00, /* - p r a g m a - */
0x00, 0x00, 0x12, 0x70, 0x72, 0x6f, 0x78, 0x79, /* - - - p r o x y */
0x2d, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, /* - a u t h e n t */
0x69, 0x63, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00, /* i c a t e - - - */
0x13, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2d, 0x61, /* - p r o x y - a */
0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, /* u t h o r i z a */
0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x05, /* t i o n - - - - */
0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x00, 0x00, /* r a n g e - - - */
0x07, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, /* - r e f e r e r */
0x00, 0x00, 0x00, 0x0b, 0x72, 0x65, 0x74, 0x72, /* - - - - r e t r */
0x79, 0x2d, 0x61, 0x66, 0x74, 0x65, 0x72, 0x00, /* y - a f t e r - */
0x00, 0x00, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, /* - - - s e r v e */
0x72, 0x00, 0x00, 0x00, 0x02, 0x74, 0x65, 0x00, /* r - - - - t e - */
0x00, 0x00, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6c, /* - - - t r a i l */
0x65, 0x72, 0x00, 0x00, 0x00, 0x11, 0x74, 0x72, /* e r - - - - t r */
0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x2d, 0x65, /* a n s f e r - e */
0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x00, /* n c o d i n g - */
0x00, 0x00, 0x07, 0x75, 0x70, 0x67, 0x72, 0x61, /* - - - u p g r a */
0x64, 0x65, 0x00, 0x00, 0x00, 0x0a, 0x75, 0x73, /* d e - - - - u s */
0x65, 0x72, 0x2d, 0x61, 0x67, 0x65, 0x6e, 0x74, /* e r - a g e n t */
0x00, 0x00, 0x00, 0x04, 0x76, 0x61, 0x72, 0x79, /* - - - - v a r y */
0x00, 0x00, 0x00, 0x03, 0x76, 0x69, 0x61, 0x00, /* - - - - v i a - */
0x00, 0x00, 0x07, 0x77, 0x61, 0x72, 0x6e, 0x69, /* - - - w a r n i */
0x6e, 0x67, 0x00, 0x00, 0x00, 0x10, 0x77, 0x77, /* n g - - - - w w */
0x77, 0x2d, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, /* w - a u t h e n */
0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x00, 0x00, /* t i c a t e - - */
0x00, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, /* - - m e t h o d */
0x00, 0x00, 0x00, 0x03, 0x67, 0x65, 0x74, 0x00, /* - - - - g e t - */
0x00, 0x00, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, /* - - - s t a t u */
0x73, 0x00, 0x00, 0x00, 0x06, 0x32, 0x30, 0x30, /* s - - - - 2 0 0 */
0x20, 0x4f, 0x4b, 0x00, 0x00, 0x00, 0x07, 0x76, /* - O K - - - - v */
0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x00, /* e r s i o n - - */
0x00, 0x08, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, /* - - H T T P - 1 */
0x2e, 0x31, 0x00, 0x00, 0x00, 0x03, 0x75, 0x72, /* - 1 - - - - u r */
0x6c, 0x00, 0x00, 0x00, 0x06, 0x70, 0x75, 0x62, /* l - - - - p u b */
0x6c, 0x69, 0x63, 0x00, 0x00, 0x00, 0x0a, 0x73, /* l i c - - - - s */
0x65, 0x74, 0x2d, 0x63, 0x6f, 0x6f, 0x6b, 0x69, /* e t - c o o k i */
0x65, 0x00, 0x00, 0x00, 0x0a, 0x6b, 0x65, 0x65, /* e - - - - k e e */
0x70, 0x2d, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x00, /* p - a l i v e - */
0x00, 0x00, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69, /* - - - o r i g i */
0x6e, 0x31, 0x30, 0x30, 0x31, 0x30, 0x31, 0x32, /* n 1 0 0 1 0 1 2 */
0x30, 0x31, 0x32, 0x30, 0x32, 0x32, 0x30, 0x35, /* 0 1 2 0 2 2 0 5 */
0x32, 0x30, 0x36, 0x33, 0x30, 0x30, 0x33, 0x30, /* 2 0 6 3 0 0 3 0 */
0x32, 0x33, 0x30, 0x33, 0x33, 0x30, 0x34, 0x33, /* 2 3 0 3 3 0 4 3 */
0x30, 0x35, 0x33, 0x30, 0x36, 0x33, 0x30, 0x37, /* 0 5 3 0 6 3 0 7 */
0x34, 0x30, 0x32, 0x34, 0x30, 0x35, 0x34, 0x30, /* 4 0 2 4 0 5 4 0 */
0x36, 0x34, 0x30, 0x37, 0x34, 0x30, 0x38, 0x34, /* 6 4 0 7 4 0 8 4 */
0x30, 0x39, 0x34, 0x31, 0x30, 0x34, 0x31, 0x31, /* 0 9 4 1 0 4 1 1 */
0x34, 0x31, 0x32, 0x34, 0x31, 0x33, 0x34, 0x31, /* 4 1 2 4 1 3 4 1 */
0x34, 0x34, 0x31, 0x35, 0x34, 0x31, 0x36, 0x34, /* 4 4 1 5 4 1 6 4 */
0x31, 0x37, 0x35, 0x30, 0x32, 0x35, 0x30, 0x34, /* 1 7 5 0 2 5 0 4 */
0x35, 0x30, 0x35, 0x32, 0x30, 0x33, 0x20, 0x4e, /* 5 0 5 2 0 3 - N */
0x6f, 0x6e, 0x2d, 0x41, 0x75, 0x74, 0x68, 0x6f, /* o n - A u t h o */
0x72, 0x69, 0x74, 0x61, 0x74, 0x69, 0x76, 0x65, /* r i t a t i v e */
0x20, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, /* - I n f o r m a */
0x74, 0x69, 0x6f, 0x6e, 0x32, 0x30, 0x34, 0x20, /* t i o n 2 0 4 - */
0x4e, 0x6f, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x65, /* N o - C o n t e */
0x6e, 0x74, 0x33, 0x30, 0x31, 0x20, 0x4d, 0x6f, /* n t 3 0 1 - M o */
0x76, 0x65, 0x64, 0x20, 0x50, 0x65, 0x72, 0x6d, /* v e d - P e r m */
0x61, 0x6e, 0x65, 0x6e, 0x74, 0x6c, 0x79, 0x34, /* a n e n t l y 4 */
0x30, 0x30, 0x20, 0x42, 0x61, 0x64, 0x20, 0x52, /* 0 0 - B a d - R */
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x34, 0x30, /* e q u e s t 4 0 */
0x31, 0x20, 0x55, 0x6e, 0x61, 0x75, 0x74, 0x68, /* 1 - U n a u t h */
0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x34, 0x30, /* o r i z e d 4 0 */
0x33, 0x20, 0x46, 0x6f, 0x72, 0x62, 0x69, 0x64, /* 3 - F o r b i d */
0x64, 0x65, 0x6e, 0x34, 0x30, 0x34, 0x20, 0x4e, /* d e n 4 0 4 - N */
0x6f, 0x74, 0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64, /* o t - F o u n d */
0x35, 0x30, 0x30, 0x20, 0x49, 0x6e, 0x74, 0x65, /* 5 0 0 - I n t e */
0x72, 0x6e, 0x61, 0x6c, 0x20, 0x53, 0x65, 0x72, /* r n a l - S e r */
0x76, 0x65, 0x72, 0x20, 0x45, 0x72, 0x72, 0x6f, /* v e r - E r r o */
0x72, 0x35, 0x30, 0x31, 0x20, 0x4e, 0x6f, 0x74, /* r 5 0 1 - N o t */
0x20, 0x49, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, /* - I m p l e m e */
0x6e, 0x74, 0x65, 0x64, 0x35, 0x30, 0x33, 0x20, /* n t e d 5 0 3 - */
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x20, /* S e r v i c e - */
0x55, 0x6e, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, /* U n a v a i l a */
0x62, 0x6c, 0x65, 0x4a, 0x61, 0x6e, 0x20, 0x46, /* b l e J a n - F */
0x65, 0x62, 0x20, 0x4d, 0x61, 0x72, 0x20, 0x41, /* e b - M a r - A */
0x70, 0x72, 0x20, 0x4d, 0x61, 0x79, 0x20, 0x4a, /* p r - M a y - J */
0x75, 0x6e, 0x20, 0x4a, 0x75, 0x6c, 0x20, 0x41, /* u n - J u l - A */
0x75, 0x67, 0x20, 0x53, 0x65, 0x70, 0x74, 0x20, /* u g - S e p t - */
0x4f, 0x63, 0x74, 0x20, 0x4e, 0x6f, 0x76, 0x20, /* O c t - N o v - */
0x44, 0x65, 0x63, 0x20, 0x30, 0x30, 0x3a, 0x30, /* D e c - 0 0 - 0 */
0x30, 0x3a, 0x30, 0x30, 0x20, 0x4d, 0x6f, 0x6e, /* 0 - 0 0 - M o n */
0x2c, 0x20, 0x54, 0x75, 0x65, 0x2c, 0x20, 0x57, /* - - T u e - - W */
0x65, 0x64, 0x2c, 0x20, 0x54, 0x68, 0x75, 0x2c, /* e d - - T h u - */
0x20, 0x46, 0x72, 0x69, 0x2c, 0x20, 0x53, 0x61, /* - F r i - - S a */
0x74, 0x2c, 0x20, 0x53, 0x75, 0x6e, 0x2c, 0x20, /* t - - S u n - - */
0x47, 0x4d, 0x54, 0x63, 0x68, 0x75, 0x6e, 0x6b, /* G M T c h u n k */
0x65, 0x64, 0x2c, 0x74, 0x65, 0x78, 0x74, 0x2f, /* e d - t e x t - */
0x68, 0x74, 0x6d, 0x6c, 0x2c, 0x69, 0x6d, 0x61, /* h t m l - i m a */
0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0x2c, 0x69, /* g e - p n g - i */
0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x67, /* m a g e - j p g */
0x2c, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, /* - i m a g e - g */
0x69, 0x66, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69, /* i f - a p p l i */
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, /* c a t i o n - x */
0x6d, 0x6c, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69, /* m l - a p p l i */
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, /* c a t i o n - x */
0x68, 0x74, 0x6d, 0x6c, 0x2b, 0x78, 0x6d, 0x6c, /* h t m l - x m l */
0x2c, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, /* - t e x t - p l */
0x61, 0x69, 0x6e, 0x2c, 0x74, 0x65, 0x78, 0x74, /* a i n - t e x t */
0x2f, 0x6a, 0x61, 0x76, 0x61, 0x73, 0x63, 0x72, /* - j a v a s c r */
0x69, 0x70, 0x74, 0x2c, 0x70, 0x75, 0x62, 0x6c, /* i p t - p u b l */
0x69, 0x63, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, /* i c p r i v a t */
0x65, 0x6d, 0x61, 0x78, 0x2d, 0x61, 0x67, 0x65, /* e m a x - a g e */
0x3d, 0x67, 0x7a, 0x69, 0x70, 0x2c, 0x64, 0x65, /* - g z i p - d e */
0x66, 0x6c, 0x61, 0x74, 0x65, 0x2c, 0x73, 0x64, /* f l a t e - s d */
0x63, 0x68, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65, /* c h c h a r s e */
0x74, 0x3d, 0x75, 0x74, 0x66, 0x2d, 0x38, 0x63, /* t - u t f - 8 c */
0x68, 0x61, 0x72, 0x73, 0x65, 0x74, 0x3d, 0x69, /* h a r s e t - i */
0x73, 0x6f, 0x2d, 0x38, 0x38, 0x35, 0x39, 0x2d, /* s o - 8 8 5 9 - */
0x31, 0x2c, 0x75, 0x74, 0x66, 0x2d, 0x2c, 0x2a, /* 1 - u t f - - - */
0x2c, 0x65, 0x6e, 0x71, 0x3d, 0x30, 0x2e /* - e n q - 0 - */
};
/* callback function used at the end of file-scope to cleanup zlib's inflate
* streams to avoid memory leaks.
* XXX: can we be more aggressive and call this sooner for finished streams?
*/
static bool inflate_end_cb (wmem_allocator_t *allocator _U_,
wmem_cb_event_t event _U_, void *user_data) {
inflateEnd((z_streamp)user_data);
return FALSE;
}
#endif
/*
* Protocol initialization
*/
static void
spdy_init_protocol(void)
{
header_info_list = NULL;
}
/*
* Returns conversation data for a given packet. If conversation data can't be
* found, creates and returns new conversation data.
*/
static spdy_conv_t * get_or_create_spdy_conversation_data(packet_info *pinfo) {
conversation_t *conversation;
spdy_conv_t *conv_data;
#ifdef HAVE_ZLIB
int retcode;
#endif
conversation = find_or_create_conversation(pinfo);
/* Retrieve information from conversation */
conv_data = (spdy_conv_t *)conversation_get_proto_data(conversation, proto_spdy);
if (!conv_data) {
/* Set up the conversation structure itself */
conv_data = wmem_new0(wmem_file_scope(), spdy_conv_t);
conv_data->streams = NULL;
if (spdy_decompress_headers) {
#ifdef HAVE_ZLIB
conv_data->rqst_decompressor = wmem_new0(wmem_file_scope(), z_stream);
conv_data->rply_decompressor = wmem_new0(wmem_file_scope(), z_stream);
retcode = inflateInit(conv_data->rqst_decompressor);
if (retcode == Z_OK) {
wmem_register_callback(wmem_file_scope(), inflate_end_cb,
conv_data->rqst_decompressor);
retcode = inflateInit(conv_data->rply_decompressor);
if (retcode == Z_OK) {
wmem_register_callback(wmem_file_scope(), inflate_end_cb,
conv_data->rply_decompressor);
}
}
/* XXX - use wsutil/adler32.h? */
conv_data->dictionary_id = adler32(0L, Z_NULL, 0);
conv_data->dictionary_id = adler32(conv_data->dictionary_id,
spdy_dictionary,
(uInt)sizeof(spdy_dictionary));
#endif
}
conversation_add_proto_data(conversation, proto_spdy, conv_data);
}
return conv_data;
}
/*
* Retains state on a given stream.
*/
static void spdy_save_stream_info(spdy_conv_t *conv_data,
guint32 stream_id,
media_container_type_t container_type,
gchar *content_type,
gchar *content_type_params,
gchar *content_encoding) {
spdy_stream_info_t *si;
if (conv_data->streams == NULL) {
conv_data->streams = wmem_tree_new(wmem_file_scope());
}
si = wmem_new(wmem_file_scope(), spdy_stream_info_t);
si->container_type = container_type;
si->content_type = content_type;
si->content_type_parameters = content_type_params;
si->content_encoding = content_encoding;
si->data_frames = wmem_list_new(wmem_file_scope());
si->num_data_frames = 0;
si->assembled_data = NULL;
wmem_tree_insert32(conv_data->streams, stream_id, si);
}
/*
* Retrieves previously saved state on a given stream.
*/
static spdy_stream_info_t* spdy_get_stream_info(spdy_conv_t *conv_data,
guint32 stream_id)
{
if (conv_data->streams == NULL)
return NULL;
return (spdy_stream_info_t*)wmem_tree_lookup32(conv_data->streams, stream_id);
}
/*
* Adds a data chunk to a given SPDY conversation/stream.
*/
static void spdy_add_data_chunk(spdy_conv_t *conv_data,
guint32 stream_id,
guint32 frame,
guint8 *data,
guint32 length)
{
spdy_stream_info_t *si = spdy_get_stream_info(conv_data, stream_id);
if (si != NULL) {
spdy_data_frame_t *df = (spdy_data_frame_t *)wmem_new(wmem_file_scope(), spdy_data_frame_t);
df->data = data;
df->length = length;
df->framenum = frame;
wmem_list_append(si->data_frames, df);
++si->num_data_frames;
}
}
/*
* Increment the count of DATA frames found on a given stream.
*/
static void spdy_increment_data_chunk_count(spdy_conv_t *conv_data,
guint32 stream_id) {
spdy_stream_info_t *si = spdy_get_stream_info(conv_data, stream_id);
if (si != NULL) {
++si->num_data_frames;
}
}
/*
* Return the number of data frames saved so far for the specified stream.
*/
static guint spdy_get_num_data_frames(spdy_conv_t *conv_data,
guint32 stream_id) {
spdy_stream_info_t *si = spdy_get_stream_info(conv_data, stream_id);
return si == NULL ? 0 : si->num_data_frames;
}
/*
* Reassembles DATA frames for a given stream into one tvb.
*/
static spdy_stream_info_t* spdy_assemble_data_frames(spdy_conv_t *conv_data,
guint32 stream_id) {
spdy_stream_info_t *si = spdy_get_stream_info(conv_data, stream_id);
tvbuff_t *tvb;
if (si == NULL) {
return NULL;
}
/*
* Compute the total amount of data and concatenate the
* data chunks, if it hasn't already been done.
*/
if (si->assembled_data == NULL) {
spdy_data_frame_t *df;
guint8 *data;
guint32 datalen;
guint32 offset;
wmem_list_t *dflist = si->data_frames;
wmem_list_frame_t *frame;
if (wmem_list_count(dflist) == 0) {
return si;
}
datalen = 0;
/*
* It'd be nice to use a composite tvbuff here, but since
* only a real-data tvbuff can be the child of another
* tvb, we can't. It would be nice if this limitation
* could be fixed.
*/
frame = wmem_list_frame_next(wmem_list_head(dflist));
while (frame != NULL) {
df = (spdy_data_frame_t *)wmem_list_frame_data(frame);
datalen += df->length;
frame = wmem_list_frame_next(frame);
}
if (datalen != 0) {
data = (guint8 *)wmem_alloc(wmem_file_scope(), datalen);
dflist = si->data_frames;
offset = 0;
frame = wmem_list_frame_next(wmem_list_head(dflist));
while (frame != NULL) {
df = (spdy_data_frame_t *)wmem_list_frame_data(frame);
memcpy(data+offset, df->data, df->length);
offset += df->length;
frame = wmem_list_frame_next(frame);
}
tvb = tvb_new_real_data(data, datalen, datalen);
si->assembled_data = tvb;
}
}
return si;
}
/*
* Same as dissect_spdy_stream_id below, except with explicit field index.
*/
static void dissect_spdy_stream_id_field(tvbuff_t *tvb,
int offset,
packet_info *pinfo _U_,
proto_tree *frame_tree,
const int hfindex)
{
guint32 stream_id = tvb_get_ntohl(tvb, offset) & SPDY_STREAM_ID_MASK;
/* Add stream id to tree. */
proto_tree_add_item(frame_tree, hfindex, tvb, offset, 4, ENC_BIG_ENDIAN);
if (hfindex == hf_spdy_streamid) {
proto_item_append_text(frame_tree, ", Stream: %u", stream_id);
}
}
/*
* Adds flag details to proto tree.
*/
static void dissect_spdy_flags(tvbuff_t *tvb,
int offset,
proto_tree *frame_tree,
const spdy_control_frame_info_t *frame) {
proto_item *flags_ti;
proto_tree *flags_tree;
/* Create flags substree. */
flags_ti = proto_tree_add_item(frame_tree, hf_spdy_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
flags_tree = proto_item_add_subtree(flags_ti, ett_spdy_flags);
/* Add FIN flag for appropriate frames. */
if (frame->type == SPDY_DATA ||
frame->type == SPDY_SYN_STREAM ||
frame->type == SPDY_SYN_REPLY ||
frame->type == SPDY_HEADERS) {
/* Add FIN flag. */
proto_tree_add_item(flags_tree, hf_spdy_flags_fin, tvb, offset, 1, ENC_BIG_ENDIAN);
if (frame->flags & SPDY_FLAG_FIN) {
proto_item_append_text(frame_tree, " (FIN)");
proto_item_append_text(flags_ti, " (FIN)");
}
}
/* Add UNIDIRECTIONAL flag, only applicable for SYN_STREAM. */
if (frame->type == SPDY_SYN_STREAM) {
proto_tree_add_item(flags_tree, hf_spdy_flags_unidirectional, tvb,
offset, 1, ENC_BIG_ENDIAN);
if (frame->flags & SPDY_FLAG_UNIDIRECTIONAL) {
proto_item_append_text(flags_ti, " (UNIDIRECTIONAL)");
}
}
/* Add CLEAR_SETTINGS flag, only applicable for SETTINGS. */
if (frame->type == SPDY_SETTINGS) {
proto_tree_add_item(flags_tree, hf_spdy_flags_clear_settings, tvb,
offset, 1, ENC_BIG_ENDIAN);
if (frame->flags & SPDY_FLAG_SETTINGS_CLEAR_SETTINGS) {
proto_item_append_text(flags_ti, " (CLEAR)");
}
}
}
/*
* Performs DATA frame payload dissection.
*/
static int dissect_spdy_data_payload(tvbuff_t *tvb,
int offset,
packet_info *pinfo,
proto_tree *top_level_tree _U_,
proto_tree *spdy_tree,
proto_item *spdy_proto,
spdy_conv_t *conv_data,
guint32 stream_id,
const spdy_control_frame_info_t *frame)
{
dissector_handle_t handle;
guint num_data_frames;
gboolean dissected;
media_content_info_t content_info;
/* Add frame description. */
proto_item_append_text(spdy_proto, ", Stream: %d, Length: %d",
stream_id,
frame->length);
/* Add data. */
proto_tree_add_item(spdy_tree, hf_spdy_data, tvb, offset, frame->length, ENC_NA);
num_data_frames = spdy_get_num_data_frames(conv_data, stream_id);
if (frame->length != 0 || num_data_frames != 0) {
/*
* There's stuff left over; process it.
*/
tvbuff_t *next_tvb = NULL;
tvbuff_t *data_tvb = NULL;
spdy_stream_info_t *si = NULL;
guint8 *copied_data;
gboolean is_single_chunk = FALSE;
gboolean have_entire_body;
char *media_str = NULL;
/*
* Create a tvbuff for the payload.
*/
if (frame->length != 0) {
next_tvb = tvb_new_subset_length(tvb, offset, frame->length);
is_single_chunk = num_data_frames == 0 &&
(frame->flags & SPDY_FLAG_FIN) != 0;
if (!pinfo->fd->visited) {
if (!is_single_chunk) {
if (spdy_assemble_entity_bodies) {
copied_data = (guint8 *)tvb_memdup(wmem_file_scope(),next_tvb, 0, frame->length);
spdy_add_data_chunk(conv_data, stream_id, pinfo->num, copied_data, frame->length);
} else {
spdy_increment_data_chunk_count(conv_data, stream_id);
}
}
}
} else {
is_single_chunk = (num_data_frames == 1);
}
if (!(frame->flags & SPDY_FLAG_FIN)) {
col_set_fence(pinfo->cinfo, COL_INFO);
proto_item_append_text(spdy_proto, " (partial entity body)");
/* would like the proto item to say */
/* " (entity body fragment N of M)" */
goto body_dissected;
}
have_entire_body = is_single_chunk;
/*
* On seeing the last data frame in a stream, we can
* reassemble the frames into one data block.
*/
si = spdy_assemble_data_frames(conv_data, stream_id);
if (si == NULL) {
goto body_dissected;
}
data_tvb = si->assembled_data;
if (spdy_assemble_entity_bodies) {
have_entire_body = TRUE;
}
if (!have_entire_body) {
goto body_dissected;
}
if (data_tvb == NULL) {
if (next_tvb == NULL)
goto body_dissected;
data_tvb = next_tvb;
} else {
add_new_data_source(pinfo, data_tvb, "Assembled entity body");
}
if (have_entire_body && si->content_encoding != NULL &&
g_ascii_strcasecmp(si->content_encoding, "identity") != 0) {
/*
* We currently can't handle, for example, "compress";
* just handle them as data for now.
*
* After July 7, 2004 the LZW patent expires, so support
* might be added then. However, I don't think that
* anybody ever really implemented "compress", due to
* the aforementioned patent.
*/
tvbuff_t *uncomp_tvb = NULL;
proto_item *e_ti = NULL;
proto_tree *e_tree = NULL;
if (spdy_decompress_body &&
(g_ascii_strcasecmp(si->content_encoding, "gzip") == 0 ||
g_ascii_strcasecmp(si->content_encoding, "deflate") == 0)) {
uncomp_tvb = tvb_child_uncompress(tvb, data_tvb, 0,
tvb_reported_length(data_tvb));
}
/*
* Add the encoded entity to the protocol tree
*/
e_tree = proto_tree_add_subtree_format(spdy_tree, data_tvb,
0, tvb_reported_length(data_tvb), ett_spdy_encoded_entity, &e_ti,
"Content-encoded entity body (%s): %u bytes",
si->content_encoding,
tvb_reported_length(data_tvb));
if (si->num_data_frames > 1) {
wmem_list_t *dflist = si->data_frames;
wmem_list_frame_t *frame_item;
spdy_data_frame_t *df;
guint32 framenum = 0;
wmem_strbuf_t *str_frames = wmem_strbuf_new(pinfo->pool, "");
frame_item = wmem_list_frame_next(wmem_list_head(dflist));
while (frame_item != NULL) {
df = (spdy_data_frame_t *)wmem_list_frame_data(frame_item);
if (framenum != df->framenum) {
wmem_strbuf_append_printf(str_frames, " #%u", df->framenum);
framenum = df->framenum;
}
frame_item = wmem_list_frame_next(frame_item);
}
proto_tree_add_expert_format(e_tree, pinfo, &ei_spdy_reassembly_info, data_tvb, 0,
tvb_reported_length(data_tvb),
"Assembled from %d frames in packet(s)%s",
si->num_data_frames, wmem_strbuf_get_str(str_frames));
}
if (uncomp_tvb != NULL) {
/*
* Decompression worked
*/
/* XXX - Don't free this, since it's possible
* that the data was only partially
* decompressed, such as when desegmentation
* isn't enabled.
*
tvb_free(next_tvb);
*/
proto_item_append_text(e_ti, " -> %u bytes", tvb_reported_length(uncomp_tvb));
data_tvb = uncomp_tvb;
add_new_data_source(pinfo, data_tvb, "Uncompressed entity body");
} else {
if (spdy_decompress_body) {
proto_item_append_text(e_ti, " [Error: Decompression failed]");
}
call_data_dissector(data_tvb, pinfo, e_tree);
goto body_dissected;
}
}
/*
* Do subdissector checks.
*
* First, check whether some subdissector asked that they
* be called if something was on some particular port.
*/
if (have_entire_body && port_subdissector_table != NULL) {
handle = dissector_get_uint_handle(port_subdissector_table,
pinfo->match_uint);
} else {
handle = NULL;
}
if (handle == NULL && have_entire_body && si->content_type != NULL &&
media_type_subdissector_table != NULL) {
/*
* We didn't find any subdissector that
* registered for the port, and we have a
* Content-Type value. Is there any subdissector
* for that content type?
*/
if (si->content_type_parameters) {
media_str = wmem_strdup(pinfo->pool, si->content_type_parameters);
}
/*
* Calling the string handle for the media type
* dissector table will set pinfo->match_string
* to si->content_type for us.
*/
pinfo->match_string = si->content_type;
handle = dissector_get_string_handle(media_type_subdissector_table,
si->content_type);
}
content_info.type = si->container_type;
content_info.media_str = media_str;
content_info.data = NULL;
if (handle != NULL) {
/*
* We have a subdissector - call it.
*/
dissected = call_dissector_with_data(handle, data_tvb, pinfo, spdy_tree, &content_info);
} else {
dissected = FALSE;
}
if (!dissected && have_entire_body && si->content_type != NULL) {
/*
* Calling the default media handle if there is a content-type that
* wasn't handled above.
*/
call_dissector_with_data(media_handle, next_tvb, pinfo, spdy_tree, &content_info);
} else {
/* Call the default data dissector */
call_data_dissector(next_tvb, pinfo, spdy_tree);
}
body_dissected:
/*
* We've processed frame->length bytes worth of data
* (which may be no data at all); advance the
* offset past whatever data we've processed.
*/
;
}
return frame->length;
}
#ifdef HAVE_ZLIB
/*
* Performs header decompression.
*
* The returned buffer is automatically scoped to the lifetime of the capture
* (via wmem_memdup() with file scope).
*/
#define DECOMPRESS_BUFSIZE 16384
static guint8* spdy_decompress_header_block(tvbuff_t *tvb,
packet_info *pinfo,
z_streamp decomp,
uLong dictionary_id,
int offset,
guint32 length,
guint *uncomp_length) {
int retcode;
const guint8 *hptr = tvb_get_ptr(tvb, offset, length);
guint8 *uncomp_block = (guint8 *)wmem_alloc(pinfo->pool, DECOMPRESS_BUFSIZE);
#ifdef z_const
decomp->next_in = (z_const Bytef *)hptr;
#else
DIAG_OFF(cast-qual)
decomp->next_in = (Bytef *)hptr;
DIAG_ON(cast-qual)
#endif
decomp->avail_in = length;
decomp->next_out = uncomp_block;
decomp->avail_out = DECOMPRESS_BUFSIZE;
retcode = inflate(decomp, Z_SYNC_FLUSH);
if (retcode == Z_NEED_DICT) {
if (decomp->adler == dictionary_id) {
retcode = inflateSetDictionary(decomp,
spdy_dictionary,
sizeof(spdy_dictionary));
if (retcode == Z_OK) {
retcode = inflate(decomp, Z_SYNC_FLUSH);
}
}
}
/* Handle errors. */
if (retcode != Z_OK) {
return NULL;
}
/* Handle successful inflation. */
*uncomp_length = DECOMPRESS_BUFSIZE - decomp->avail_out;
return (guint8 *)wmem_memdup(wmem_file_scope(), uncomp_block, *uncomp_length);
}
#endif
/*
* Saves state on header data for a given stream.
*/
static spdy_header_info_t* spdy_save_header_block(packet_info *pinfo _U_,
guint32 stream_id,
guint16 frame_type,
guint8 *header,
guint length) {
spdy_header_info_t *header_info;
if (header_info_list == NULL)
header_info_list = wmem_list_new(wmem_file_scope());
header_info = wmem_new(wmem_file_scope(), spdy_header_info_t);
header_info->stream_id = stream_id;
header_info->header_block = header;
header_info->header_block_len = length;
header_info->frame_type = frame_type;
wmem_list_append(header_info_list, header_info);
return header_info;
}
/*
* Retrieves saved state for a given stream.
*/
static spdy_header_info_t* spdy_find_saved_header_block(packet_info *pinfo _U_,
guint32 stream_id,
guint16 frame_type) {
wmem_list_frame_t *frame;
if ((header_info_list == NULL) || (wmem_list_head(header_info_list) == NULL))
return NULL;
frame = wmem_list_frame_next(wmem_list_head(header_info_list));
while (frame != NULL) {
spdy_header_info_t *hi = (spdy_header_info_t *)wmem_list_frame_data(frame);
if (hi->stream_id == stream_id && hi->frame_type == frame_type)
return hi;
frame = wmem_list_frame_next(frame);
}
return NULL;
}
/*
* Given a content type string that may contain optional parameters,
* return the parameter string, if any, otherwise return NULL. This
* also has the side effect of null terminating the content type
* part of the original string.
*/
static gchar* spdy_parse_content_type(gchar *content_type) {
gchar *cp = content_type;
while (*cp != '\0' && *cp != ';' && !g_ascii_isspace(*cp)) {
*cp = g_ascii_tolower(*cp);
++cp;
}
if (*cp == '\0') {
cp = NULL;
}
if (cp != NULL) {
*cp++ = '\0';
while (*cp == ';' || g_ascii_isspace(*cp)) {
++cp;
}
if (*cp != '\0') {
return cp;
}
}
return NULL;
}
static int dissect_spdy_header_payload(
tvbuff_t *tvb,
int offset,
packet_info *pinfo,
proto_tree *frame_tree,
const spdy_control_frame_info_t *frame,
spdy_conv_t *conv_data) {
guint32 stream_id;
int header_block_length = frame->length;
int hdr_offset = 0;
tvbuff_t *header_tvb = NULL;
const gchar *hdr_method = NULL;
const gchar *hdr_path = NULL;
const gchar *hdr_version = NULL;
const gchar *hdr_host = NULL;
const gchar *hdr_scheme = NULL;
const gchar *hdr_status = NULL;
gchar *content_type = NULL;
gchar *content_encoding = NULL;
guint32 num_headers = 0;
proto_item *header_block_item;
proto_tree *header_block_tree;
/* Get stream id, which is present in all types of header frames. */
stream_id = tvb_get_ntohl(tvb, offset) & SPDY_STREAM_ID_MASK;
dissect_spdy_stream_id_field(tvb, offset, pinfo, frame_tree, hf_spdy_streamid);
offset += 4;
/* Get SYN_STREAM-only fields. */
if (frame->type == SPDY_SYN_STREAM) {
/* Get associated stream ID. */
dissect_spdy_stream_id_field(tvb, offset, pinfo, frame_tree, hf_spdy_associated_streamid);
offset += 4;
/* Get priority */
proto_tree_add_item(frame_tree, hf_spdy_priority, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(frame_tree, hf_spdy_unused, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(frame_tree, hf_spdy_slot, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
}
/* Get our header block length. */
switch (frame->type) {
case SPDY_SYN_STREAM:
header_block_length -= 10;
break;
case SPDY_SYN_REPLY:
case SPDY_HEADERS:
header_block_length -= 4;
break;
default:
/* Unhandled case. This should never happen. */
DISSECTOR_ASSERT_NOT_REACHED();
}
/* Add the header block. */
header_block_item = proto_tree_add_item(frame_tree,
hf_spdy_header_block,
tvb,
offset,
header_block_length,
ENC_NA);
header_block_tree = proto_item_add_subtree(header_block_item,
ett_spdy_header_block);
/* Decompress header block as necessary. */
if (!spdy_decompress_headers) {
header_tvb = tvb;
hdr_offset = offset;
} else {
spdy_header_info_t *header_info;
/* First attempt to find previously decompressed data.
* This will not work correctly for lower-level frames that contain more
* than one SPDY frame of the same type. We assume this to never be the
* case, though. */
header_info = spdy_find_saved_header_block(pinfo,
stream_id,
frame->type);
/* Generate decompressed data and store it, since none was found. */
if (header_info == NULL) {
guint8 *uncomp_ptr = NULL;
guint uncomp_length = 0;
#ifdef HAVE_ZLIB
z_streamp decomp;
/* Get our decompressor. */
if (stream_id % 2 == 0) {
/* Even streams are server-initiated and should never get a
* client-initiated header block. Use reply decompressor. */
decomp = conv_data->rply_decompressor;
} else if (frame->type == SPDY_HEADERS) {
/* Odd streams are client-initiated, but may have HEADERS from either
* side. Currently, no known clients send HEADERS so we assume they are
* all from the server. */
decomp = conv_data->rply_decompressor;
} else if (frame->type == SPDY_SYN_STREAM) {
decomp = conv_data->rqst_decompressor;
} else if (frame->type == SPDY_SYN_REPLY) {
decomp = conv_data->rply_decompressor;
} else {
/* Unhandled case. This should never happen. */
DISSECTOR_ASSERT_NOT_REACHED();
}
/* Decompress. */
uncomp_ptr = spdy_decompress_header_block(tvb,
pinfo,
decomp,
conv_data->dictionary_id,
offset,
header_block_length,
&uncomp_length);
/* Catch decompression failures. */
if (uncomp_ptr == NULL) {
expert_add_info(pinfo, frame_tree, &ei_spdy_inflation_failed);
proto_item_append_text(frame_tree, " [Error: Header decompression failed]");
return -1;
}
#endif
/* Store decompressed data. */
header_info = spdy_save_header_block(pinfo, stream_id, frame->type, uncomp_ptr, uncomp_length);
}
/* Create a tvb containing the uncompressed data. */
header_tvb = tvb_new_child_real_data(tvb, header_info->header_block,
header_info->header_block_len,
header_info->header_block_len);
add_new_data_source(pinfo, header_tvb, "Uncompressed headers");
hdr_offset = 0;
}
/* Get header block details. */
if (header_tvb == NULL || !spdy_decompress_headers) {
num_headers = 0;
} else {
num_headers = tvb_get_ntohl(header_tvb, hdr_offset);
/*ti = */ proto_tree_add_item(header_block_tree,
hf_spdy_num_headers,
header_tvb,
hdr_offset,
4,
ENC_BIG_ENDIAN);
}
hdr_offset += 4;
/* Process headers. */
while (num_headers--) {
gchar *header_name;
const gchar *header_value;
proto_tree *header_tree;
proto_item *header;
int header_name_offset;
int header_value_offset;
int header_name_length;
int header_value_length;
/* Get header name details. */
if (tvb_reported_length_remaining(header_tvb, hdr_offset) < 4) {
expert_add_info_format(pinfo, frame_tree, &ei_spdy_mal_frame_data,
"Not enough frame data for header name size.");
break;
}
header_name_offset = hdr_offset;
header_name_length = tvb_get_ntohl(header_tvb, hdr_offset);
hdr_offset += 4;
if (tvb_reported_length_remaining(header_tvb, hdr_offset) < header_name_length) {
expert_add_info_format(pinfo, frame_tree, &ei_spdy_mal_frame_data,
"Not enough frame data for header name.");
break;
}
header_name = (gchar *)tvb_get_string_enc(pinfo->pool, header_tvb,
hdr_offset,
header_name_length, ENC_ASCII|ENC_NA);
hdr_offset += header_name_length;
/* Get header value details. */
if (tvb_reported_length_remaining(header_tvb, hdr_offset) < 4) {
expert_add_info_format(pinfo, frame_tree, &ei_spdy_mal_frame_data,
"Not enough frame data for header value size.");
break;
}
header_value_offset = hdr_offset;
header_value_length = tvb_get_ntohl(header_tvb, hdr_offset);
hdr_offset += 4;
if (tvb_reported_length_remaining(header_tvb, hdr_offset) < header_value_length) {
expert_add_info_format(pinfo, frame_tree, &ei_spdy_mal_frame_data,
"Not enough frame data for header value.");
break;
}
header_value = (gchar *)tvb_get_string_enc(pinfo->pool,header_tvb,
hdr_offset,
header_value_length, ENC_ASCII|ENC_NA);
hdr_offset += header_value_length;
/* Populate tree with header name/value details. */
if (frame_tree) {
/* Add 'Header' subtree with description. */
header = proto_tree_add_item(frame_tree,
hf_spdy_header,
header_tvb,
header_name_offset,
hdr_offset - header_name_offset,
ENC_NA);
proto_item_append_text(header, ": %s: %s", header_name, header_value);
header_tree = proto_item_add_subtree(header, ett_spdy_header);
/* Add header name. */
proto_tree_add_item(header_tree, hf_spdy_header_name, header_tvb,
header_name_offset, 4, ENC_ASCII|ENC_BIG_ENDIAN);
/* Add header value. */
proto_tree_add_item(header_tree, hf_spdy_header_value, header_tvb,
header_value_offset, 4, ENC_ASCII|ENC_BIG_ENDIAN);
}
/*
* TODO(ers) check that the header name contains only legal characters.
*/
/* TODO(hkhalil): Make sure that prohibited headers aren't sent. */
if (g_strcmp0(header_name, ":method") == 0) {
hdr_method = header_value;
} else if (g_strcmp0(header_name, ":path") == 0) {
hdr_path = header_value;
} else if (g_strcmp0(header_name, ":version") == 0) {
hdr_version = header_value;
} else if (g_strcmp0(header_name, ":host") == 0) {
hdr_host = header_value;
} else if (g_strcmp0(header_name, ":scheme") == 0) {
hdr_scheme = header_value;
} else if (g_strcmp0(header_name, ":status") == 0) {
hdr_status = header_value;
} else if (g_strcmp0(header_name, "content-type") == 0) {
content_type = wmem_strdup(wmem_file_scope(), header_value);
} else if (g_strcmp0(header_name, "content-encoding") == 0) {
content_encoding = wmem_strdup(wmem_file_scope(), header_value);
}
}
/* Set Info column. */
if (hdr_version != NULL) {
if (hdr_status == NULL) {
proto_item_append_text(frame_tree, ", Request: %s %s://%s%s %s",
hdr_method, hdr_scheme, hdr_host, hdr_path, hdr_version);
} else {
proto_item_append_text(frame_tree, ", Response: %s %s",
hdr_status, hdr_version);
}
}
/*
* If we expect data on this stream, we need to remember the content
* type and content encoding.
*/
if (content_type != NULL && !pinfo->fd->visited) {
gchar *content_type_params = spdy_parse_content_type(content_type);
spdy_save_stream_info(conv_data, stream_id,
(hdr_status == NULL) ? MEDIA_CONTAINER_HTTP_REQUEST : MEDIA_CONTAINER_HTTP_RESPONSE,
content_type, content_type_params, content_encoding);
}
return frame->length;
}
static int dissect_spdy_rst_stream_payload(
tvbuff_t *tvb,
int offset,
packet_info *pinfo,
proto_tree *frame_tree,
const spdy_control_frame_info_t *frame) {
guint32 rst_status;
proto_item *ti;
const char* str;
/* Get stream ID and add to info column and tree. */
dissect_spdy_stream_id_field(tvb, offset, pinfo, frame_tree, hf_spdy_streamid);
offset += 4;
/* Get status. */
ti = proto_tree_add_item(frame_tree, hf_spdy_rst_stream_status, tvb, offset, 4, ENC_BIG_ENDIAN);
rst_status = tvb_get_ntohl(tvb, offset);
if (try_val_to_str(rst_status, rst_stream_status_names) == NULL) {
/* Handle boundary conditions. */
expert_add_info_format(pinfo, ti, &ei_spdy_invalid_rst_stream,
"Invalid status code for RST_STREAM: %u", rst_status);
}
str = val_to_str(rst_status, rst_stream_status_names, "Unknown (%d)");
proto_item_append_text(frame_tree, ", Status: %s", str);
return frame->length;
}
static int dissect_spdy_settings_payload(
tvbuff_t *tvb,
int offset,
packet_info *pinfo,
proto_tree *frame_tree,
const spdy_control_frame_info_t *frame) {
guint32 num_entries;
proto_item *ti, *ti_setting;
proto_tree *setting_tree;
proto_tree *flags_tree;
/* Make sure that we have enough room for our number of entries field. */
if (frame->length < 4) {
expert_add_info(pinfo, frame_tree, &ei_spdy_mal_setting_frame);
return -1;
}
/* Get number of entries, and make sure we have enough room for them. */
num_entries = tvb_get_ntohl(tvb, offset);
if (frame->length < num_entries * 8) {
expert_add_info_format(pinfo, frame_tree, &ei_spdy_mal_setting_frame,
"SETTINGS frame too small [num_entries=%d]", num_entries);
return -1;
}
proto_tree_add_item(frame_tree, hf_spdy_num_settings, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
/* Dissect each entry. */
while (num_entries > 0) {
const gchar *setting_id_str;
guint32 setting_value;
/* Create key/value pair subtree. */
ti_setting = proto_tree_add_item(frame_tree, hf_spdy_setting, tvb, offset, 8, ENC_NA);
setting_tree = proto_item_add_subtree(ti_setting, ett_spdy_setting);
/* Set flags. */
if (setting_tree) {
ti = proto_tree_add_item(setting_tree, hf_spdy_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
/* TODO(hkhalil): Prettier output for flags sub-tree description. */
flags_tree = proto_item_add_subtree(ti, ett_spdy_flags);
proto_tree_add_item(flags_tree, hf_spdy_flags_persist_value, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(flags_tree, hf_spdy_flags_persisted, tvb, offset, 1, ENC_BIG_ENDIAN);
}
offset += 1;
/* Set ID. */
setting_id_str = val_to_str(tvb_get_ntoh24(tvb, offset), setting_id_names, "Unknown(%d)");
proto_tree_add_item(setting_tree, hf_spdy_setting_id, tvb, offset, 3, ENC_BIG_ENDIAN);
offset += 3;
/* Set Value. */
setting_value = tvb_get_ntohl(tvb, offset);
proto_tree_add_item(setting_tree, hf_spdy_setting_value, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_item_append_text(ti_setting, ", %s: %u", setting_id_str, setting_value);
proto_item_append_text(frame_tree, ", %s: %u", setting_id_str, setting_value);
offset += 4;
/* Increment. */
--num_entries;
}
return frame->length;
}
static int dissect_spdy_ping_payload(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
proto_tree *frame_tree, const spdy_control_frame_info_t *frame)
{
/* Get ping ID. */
guint32 ping_id = tvb_get_ntohl(tvb, offset);
/* Add proto item for ping ID. */
proto_tree_add_item(frame_tree, hf_spdy_ping_id, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_item_append_text(frame_tree, ", ID: %u", ping_id);
return frame->length;
}
static int dissect_spdy_goaway_payload(tvbuff_t *tvb,
int offset,
packet_info *pinfo,
proto_tree *frame_tree,
const spdy_control_frame_info_t *frame) {
guint32 goaway_status;
proto_item* ti;
/* Get last good stream ID and add to info column and tree. */
dissect_spdy_stream_id_field(tvb, offset, pinfo, frame_tree, hf_spdy_goaway_last_good_stream_id);
offset += 4;
/* Add proto item for goaway_status. */
ti = proto_tree_add_item(frame_tree, hf_spdy_goaway_status, tvb, offset, 4, ENC_BIG_ENDIAN);
goaway_status = tvb_get_ntohl(tvb, offset);
if (try_val_to_str(goaway_status, goaway_status_names) == NULL) {
/* Handle boundary conditions. */
expert_add_info_format(pinfo, ti, &ei_spdy_invalid_go_away,
"Invalid status code for GOAWAY: %u", goaway_status);
}
/* Add status to info column. */
proto_item_append_text(frame_tree, " Status=%s)",
val_to_str(goaway_status, rst_stream_status_names, "Unknown (%d)"));
return frame->length;
}
static int dissect_spdy_window_update_payload(
tvbuff_t *tvb,
int offset,
packet_info *pinfo,
proto_tree *frame_tree,
const spdy_control_frame_info_t *frame)
{
guint32 window_update_delta;
/* Get stream ID. */
dissect_spdy_stream_id_field(tvb, offset, pinfo, frame_tree, hf_spdy_streamid);
offset += 4;
/* Get window update delta. */
window_update_delta = tvb_get_ntohl(tvb, offset) & 0x7FFFFFFF;
/* Add proto item for window update delta. */
proto_tree_add_item(frame_tree, hf_spdy_window_update_delta, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_item_append_text(frame_tree, ", Delta: %u", window_update_delta);
return frame->length;
}
/*
* Performs SPDY frame dissection.
*/
static int dissect_spdy_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
guint8 control_bit;
spdy_control_frame_info_t frame;
guint32 stream_id = 0;
const gchar *frame_type_name;
proto_tree *spdy_tree;
proto_item *spdy_item, *type_item = NULL;
int offset = 0;
spdy_conv_t *conv_data;
conv_data = get_or_create_spdy_conversation_data(pinfo);
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SPDY");
/* Create frame root. */
spdy_item = proto_tree_add_item(tree, proto_spdy, tvb, offset, -1, ENC_NA);
spdy_tree = proto_item_add_subtree(spdy_item, ett_spdy);
/* Add control bit. */
control_bit = tvb_get_guint8(tvb, offset) & 0x80;
proto_tree_add_item(spdy_tree, hf_spdy_control_bit, tvb, offset, 2, ENC_NA);
/* Process first four bytes of frame, formatted depending on control bit. */
if (control_bit) {
/* Add version. */
frame.version = tvb_get_ntohs(tvb, offset) & 0x7FFF;
proto_tree_add_item(spdy_tree, hf_spdy_version, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* Add control frame type. */
type_item = proto_tree_add_item(spdy_tree, hf_spdy_type, tvb, offset, 2, ENC_BIG_ENDIAN);
frame.type = tvb_get_ntohs(tvb, offset);
if (frame.type >= SPDY_INVALID) {
expert_add_info_format(pinfo, type_item, &ei_spdy_invalid_frame_type,
"Invalid SPDY control frame type: %d", frame.type);
return -1;
}
offset += 2;
} else {
frame.type = SPDY_DATA;
frame.version = 0; /* Version doesn't apply to DATA. */
/* Add stream ID. */
stream_id = tvb_get_ntohl(tvb, offset) & SPDY_STREAM_ID_MASK;
proto_tree_add_item(spdy_tree, hf_spdy_streamid, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
/* Add frame info. */
frame_type_name = val_to_str(frame.type, frame_type_names, "Unknown(%d)");
col_append_sep_str(pinfo->cinfo, COL_INFO, ", ", frame_type_name);
proto_item_append_text(spdy_tree, ": %s", frame_type_name);
/* Add flags. */
frame.flags = tvb_get_guint8(tvb, offset);
if (spdy_tree) {
dissect_spdy_flags(tvb, offset, spdy_tree, &frame);
}
offset += 1;
/* Add length. */
frame.length = tvb_get_ntoh24(tvb, offset);
proto_item_set_len(spdy_item, frame.length + 8);
proto_tree_add_item(spdy_tree, hf_spdy_length, tvb, offset, 3, ENC_BIG_ENDIAN);
offset += 3;
/*
* Make sure there's as much data as the frame header says there is.
*/
if ((guint)tvb_reported_length_remaining(tvb, offset) < frame.length) {
expert_add_info_format(pinfo, tree, &ei_spdy_mal_frame_data,
"Not enough frame data: %d vs. %d",
frame.length, tvb_reported_length_remaining(tvb, offset));
return -1;
}
/* Dissect DATA payload as necessary. */
if (!control_bit) {
return offset + dissect_spdy_data_payload(tvb, offset, pinfo, tree, spdy_tree,
spdy_item, conv_data, stream_id, &frame);
}
/* Abort here if the version is too low. */
if (frame.version < MIN_SPDY_VERSION) {
proto_item_append_text(spdy_item, " [Unsupported Version]");
return frame.length + 8;
}
switch (frame.type) {
case SPDY_SYN_STREAM:
case SPDY_SYN_REPLY:
case SPDY_HEADERS:
dissect_spdy_header_payload(tvb, offset, pinfo, spdy_tree, &frame, conv_data);
break;
case SPDY_RST_STREAM:
dissect_spdy_rst_stream_payload(tvb, offset, pinfo, spdy_tree, &frame);
break;
case SPDY_SETTINGS:
dissect_spdy_settings_payload(tvb, offset, pinfo, spdy_tree, &frame);
break;
case SPDY_PING:
dissect_spdy_ping_payload(tvb, offset, pinfo, spdy_tree, &frame);
break;
case SPDY_GOAWAY:
dissect_spdy_goaway_payload(tvb, offset, pinfo, spdy_tree, &frame);
break;
case SPDY_WINDOW_UPDATE:
dissect_spdy_window_update_payload(tvb, offset, pinfo, spdy_tree, &frame);
break;
case SPDY_CREDENTIAL:
/* TODO(hkhalil): Show something meaningful. */
break;
default:
expert_add_info_format(pinfo, type_item, &ei_spdy_invalid_frame_type,
"Unhandled SPDY frame type: %d", frame.type);
break;
}
/*
* OK, we've set the Protocol and Info columns for the
* first SPDY message; set a fence so that subsequent
* SPDY messages don't overwrite the Info column.
*/
col_set_fence(pinfo->cinfo, COL_INFO);
/* Assume that we've consumed the whole frame. */
return 8 + frame.length;
}
static guint get_spdy_message_len(packet_info *pinfo _U_, tvbuff_t *tvb,
int offset, void *data _U_)
{
return (guint)tvb_get_ntoh24(tvb, offset + 5) + 8;
}
/*
* Wrapper for dissect_spdy_frame, sets fencing and desegments as necessary.
*/
static int dissect_spdy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
col_clear(pinfo->cinfo, COL_INFO);
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 8, get_spdy_message_len, dissect_spdy_frame, data);
return tvb_captured_length(tvb);
}
/*
* Looks for SPDY frame at tvb start.
* If not enough data for either, requests more via desegment struct.
*/
static gboolean dissect_spdy_heur(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree,
void *data _U_)
{
/*
* The first byte of a SPDY frame must be either 0 or
* 0x80. If it's not, assume that this is not SPDY.
* (In theory, a data frame could have a stream ID
* >= 2^24, in which case it won't have 0 for a first
* byte, but this is a pretty reliable heuristic for
* now.)
*/
guint8 first_byte = tvb_get_guint8(tvb, 0);
if (first_byte != 0x80 && first_byte != 0x0) {
return FALSE;
}
/* Attempt dissection. */
if (dissect_spdy(tvb, pinfo, tree, NULL) != 0) {
return TRUE;
}
return FALSE;
}
/*
* Performs plugin registration.
*/
void proto_register_spdy(void)
{
static hf_register_info hf[] = {
{ &hf_spdy_data,
{ "Data", "spdy.data",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL
}
},
{ &hf_spdy_control_bit,
{ "Control frame", "spdy.control_bit",
FT_BOOLEAN, 16, TFS(&tfs_yes_no), 0x8000,
"TRUE if SPDY control frame", HFILL
}
},
{ &hf_spdy_version,
{ "Version", "spdy.version",
FT_UINT16, BASE_DEC, NULL, 0x7FFF,
NULL, HFILL
}
},
{ &hf_spdy_type,
{ "Type", "spdy.type",
FT_UINT16, BASE_DEC,
VALS(frame_type_names), 0x0,
NULL, HFILL
}
},
{ &hf_spdy_flags,
{ "Flags", "spdy.flags",
FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL
}
},
{ &hf_spdy_flags_fin,
{ "FIN", "spdy.flags.fin",
FT_BOOLEAN, 8,
TFS(&tfs_set_notset), SPDY_FLAG_FIN,
NULL, HFILL
}
},
{ &hf_spdy_flags_unidirectional,
{ "Unidirectional", "spdy.flags.unidirectional",
FT_BOOLEAN, 8,
TFS(&tfs_set_notset), SPDY_FLAG_UNIDIRECTIONAL,
NULL, HFILL
}
},
{ &hf_spdy_flags_clear_settings,
{ "Persist Value", "spdy.flags.clear_settings",
FT_BOOLEAN, 8,
TFS(&tfs_set_notset), SPDY_FLAG_SETTINGS_CLEAR_SETTINGS,
NULL, HFILL
}
},
{ &hf_spdy_flags_persist_value,
{ "Persist Value", "spdy.flags.persist_value",
FT_BOOLEAN, 8,
TFS(&tfs_set_notset), SPDY_FLAG_SETTINGS_PERSIST_VALUE,
NULL, HFILL
}
},
{ &hf_spdy_flags_persisted,
{ "Persisted", "spdy.flags.persisted",
FT_BOOLEAN, 8,
TFS(&tfs_set_notset), SPDY_FLAG_SETTINGS_PERSISTED,
NULL, HFILL
}
},
{ &hf_spdy_length,
{ "Length", "spdy.length",
FT_UINT24, BASE_DEC, NULL, 0x0,
NULL, HFILL
}
},
{ &hf_spdy_header_block,
{ "Header block", "spdy.header_block",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL
}
},
{ &hf_spdy_header,
{ "Header", "spdy.header",
FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL
}
},
{ &hf_spdy_header_name,
{ "Name", "spdy.header.name",
FT_UINT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL
}
},
{ &hf_spdy_header_value,
{ "Value", "spdy.header.value",
FT_UINT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL
}
},
{ &hf_spdy_streamid,
{ "Stream ID", "spdy.streamid",
FT_UINT32, BASE_DEC, NULL, SPDY_STREAM_ID_MASK,
NULL, HFILL
}
},
{ &hf_spdy_associated_streamid,
{ "Associated Stream ID", "spdy.associated.streamid",
FT_UINT32, BASE_DEC, NULL, SPDY_STREAM_ID_MASK,
NULL, HFILL
}
},
{ &hf_spdy_priority,
{ "Priority", "spdy.priority",
FT_UINT16, BASE_DEC, NULL, 0xE000,
NULL, HFILL
}
},
{ &hf_spdy_unused,
{ "Unused", "spdy.unused",
FT_UINT16, BASE_HEX, NULL, 0x1F00,
"Reserved for future use", HFILL
}
},
{ &hf_spdy_slot,
{ "Slot", "spdy.slot",
FT_UINT16, BASE_DEC, NULL, 0x00FF,
"Specifying the index in the server's CREDENTIAL vector of the client certificate to be used for this request", HFILL
}
},
{ &hf_spdy_num_headers,
{ "Number of headers", "spdy.numheaders",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL
}
},
{ &hf_spdy_rst_stream_status,
{ "Reset Status", "spdy.rst_stream_status",
FT_UINT32, BASE_DEC, VALS(rst_stream_status_names), 0x0,
NULL, HFILL
}
},
{ &hf_spdy_num_settings,
{ "Number of Settings", "spdy.num_settings",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL
}
},
{ &hf_spdy_setting,
{ "Setting", "spdy.setting",
FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL
}
},
{ &hf_spdy_setting_id,
{ "ID", "spdy.setting.id",
FT_UINT24, BASE_DEC, VALS(setting_id_names), 0x0,
NULL, HFILL
}
},
{ &hf_spdy_setting_value,
{ "Value", "spdy.setting.value",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL
}
},
{ &hf_spdy_ping_id,
{ "Ping ID", "spdy.ping_id",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL
}
},
{ &hf_spdy_goaway_last_good_stream_id,
{ "Last Good Stream ID", "spdy.goaway_last_good_stream_id",
FT_UINT32, BASE_DEC, NULL, SPDY_STREAM_ID_MASK,
NULL, HFILL
}
},
{ &hf_spdy_goaway_status,
{ "Go Away Status", "spdy.goaway_status",
FT_UINT32, BASE_DEC, VALS(goaway_status_names), 0x0,
NULL, HFILL
}
},
{ &hf_spdy_window_update_delta,
{ "Window Update Delta", "spdy.window_update_delta",
FT_UINT32, BASE_DEC, NULL, 0x7FFFFFFF,
NULL, HFILL
}
},
};
static gint *ett[] = {
&ett_spdy,
&ett_spdy_flags,
&ett_spdy_header_block,
&ett_spdy_header,
&ett_spdy_setting,
&ett_spdy_encoded_entity,
};
static ei_register_info ei[] = {
{ &ei_spdy_inflation_failed, { "spdy.inflation_failed", PI_UNDECODED, PI_ERROR, "Inflation failed. Aborting.", EXPFILL }},
{ &ei_spdy_mal_frame_data, { "spdy.malformed.frame_data", PI_MALFORMED, PI_ERROR, "Not enough frame data", EXPFILL }},
{ &ei_spdy_mal_setting_frame, { "spdy.malformed.setting_frame", PI_MALFORMED, PI_ERROR, "SETTINGS frame too small for number of entries field.", EXPFILL }},
{ &ei_spdy_invalid_rst_stream, { "spdy.rst_stream.invalid", PI_PROTOCOL, PI_WARN, "Invalid status code for RST_STREAM", EXPFILL }},
{ &ei_spdy_invalid_go_away, { "spdy.goaway.invalid", PI_PROTOCOL, PI_WARN, "Invalid status code for GOAWAY", EXPFILL }},
{ &ei_spdy_invalid_frame_type, { "spdy.type.invalid", PI_PROTOCOL, PI_WARN, "Invalid SPDY frame type", EXPFILL }},
{ &ei_spdy_reassembly_info, { "spdy.reassembly_info", PI_REASSEMBLE, PI_CHAT, "Assembled from frames in packet(s)", EXPFILL }},
};
module_t *spdy_module;
expert_module_t* expert_spdy;
proto_spdy = proto_register_protocol("SPDY", "SPDY", "spdy");
proto_register_field_array(proto_spdy, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_spdy = expert_register_protocol(proto_spdy);
expert_register_field_array(expert_spdy, ei, array_length(ei));
spdy_handle = register_dissector("spdy", dissect_spdy, proto_spdy);
spdy_module = prefs_register_protocol(proto_spdy, NULL);
prefs_register_bool_preference(spdy_module, "assemble_data_frames",
"Assemble SPDY bodies that consist of multiple DATA frames",
"Whether the SPDY dissector should reassemble multiple "
"data frames into an entity body.",
&spdy_assemble_entity_bodies);
prefs_register_bool_preference(spdy_module, "decompress_headers",
"Uncompress SPDY headers",
"Whether to uncompress SPDY headers.",
&spdy_decompress_headers);
prefs_register_bool_preference(spdy_module, "decompress_body",
"Uncompress entity bodies",
"Whether to uncompress entity bodies that are compressed "
"using \"Content-Encoding: \"",
&spdy_decompress_body);
register_init_routine(&spdy_init_protocol);
/*
* Register for tapping
*/
spdy_tap = register_tap("spdy"); /* SPDY statistics tap */
spdy_eo_tap = register_tap("spdy_eo"); /* SPDY Export Object tap */
}
void proto_reg_handoff_spdy(void) {
dissector_add_uint_with_preference("tcp.port", TCP_PORT_SPDY, spdy_handle);
/* Use "0" to avoid overwriting HTTPS port and still offer support over TLS */
ssl_dissector_add(0, spdy_handle);
dissector_add_string("http.upgrade", "spdy", spdy_handle);
media_handle = find_dissector_add_dependency("media", proto_spdy);
port_subdissector_table = find_dissector_table("http.port");
media_type_subdissector_table = find_dissector_table("media_type");
/* Weak heuristic, so disabled by default */
heur_dissector_add("tcp", dissect_spdy_heur, "SPDY over TCP", "spdy_tcp", proto_spdy, HEURISTIC_DISABLE);
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
|
C
|
wireshark/epan/dissectors/packet-spice.c
|
/* packet-spice.c
* Routines for Spice protocol dissection
* Copyright 2011, Yaniv Kaul <[email protected]>
* Copyright 2013, Jonathon Jongsma <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* This code is based on the protocol specification:
* https://www.spice-space.org/spice-protocol.html
* and the source - git://cgit.freedesktop.org/spice/spice-protocol
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/conversation.h>
#include <epan/expert.h>
#include <epan/proto_data.h>
/* NOTE:
* packet-spice.h is auto-generated from a Spice protocol definition by a tool
* included in the spice-common repository
* (https://gitlab.freedesktop.org/spice/spice-common)
* To re-generate this file, run the following command from the root of the
* spice-common tree:
* python ./spice_codegen.py --generate-wireshark-dissector \
* spice.proto packet-spice.h
*/
#if WS_IS_AT_LEAST_GNUC_VERSION(6,0)
DIAG_OFF(unused-const-variable)
#endif
#include "packet-spice.h"
#if WS_IS_AT_LEAST_GNUC_VERSION(6,0)
DIAG_ON(unused-const-variable)
#endif
void proto_register_spice(void);
void proto_reg_handoff_spice(void);
#define SPICE_MAGIC 0x52454451 /* = "REDQ" */
#define SPICE_VERSION_MAJOR_1 1
#define SPICE_VERSION_MINOR_0 0
#define SPICE_VERSION_MAJOR_UNSTABLE 0xfffe
#define SPICE_VERSION_MINOR_UNSTABLE 0xffff
#define SPICE_TICKET_PUBKEY_BYTES 162
#define SPICE_ALIGN(a, size) (((a) + ((size) - 1)) & ~((size) - 1))
typedef enum {
SPICE_LINK_CLIENT,
SPICE_LINK_SERVER,
SPICE_TICKET_CLIENT,
SPICE_TICKET_SERVER,
SPICE_CLIENT_AUTH_SELECT,
SPICE_SASL_INIT_FROM_SERVER,
SPICE_SASL_START_TO_SERVER,
SPICE_SASL_START_FROM_SERVER,
SPICE_SASL_START_FROM_SERVER_CONT,
SPICE_SASL_STEP_TO_SERVER,
SPICE_SASL_STEP_FROM_SERVER,
SPICE_SASL_STEP_FROM_SERVER_CONT,
SPICE_SASL_DATA,
SPICE_DATA
} spice_session_state_e;
static const value_string state_name_vs[] = {
{ SPICE_LINK_CLIENT, "Client link message" },
{ SPICE_LINK_SERVER, "Server link message" },
{ SPICE_TICKET_CLIENT, "Client ticket" },
{ SPICE_TICKET_SERVER, "Server ticket" },
{ SPICE_CLIENT_AUTH_SELECT, "Client authentication method selection" },
{ SPICE_SASL_INIT_FROM_SERVER, "SASL supported authentication mechanisms (init from server)" },
{ SPICE_SASL_START_TO_SERVER, "SASL authentication (start to server)" },
{ SPICE_SASL_START_FROM_SERVER, "SASL authentication (start from server)" },
{ SPICE_SASL_START_FROM_SERVER_CONT, "SASL authentication - result from server" },
{ SPICE_SASL_STEP_TO_SERVER, "SASL authentication from client (step to server)" },
{ SPICE_SASL_STEP_FROM_SERVER, "SASL authentication (step from server)" },
{ SPICE_SASL_STEP_FROM_SERVER_CONT, "SASL authentication - result from server" },
{ SPICE_SASL_DATA, "SASL wrapped Spice message" },
{ SPICE_DATA, "" }, /* Intentionally "blank" to help col_append_sep_str() logic */
{ 0, NULL }
};
static dissector_handle_t spice_handle;
#define SPICE_CHANNEL_NONE 0
#define SPICE_FIRST_AVAIL_MESSAGE 101
#define sizeof_SpiceLinkHeader 16
#define sizeof_SpiceDataHeader 18
#define sizeof_SpiceMiniDataHeader 6
static const value_string playback_mode_vals[] = {
{ SPICE_AUDIO_DATA_MODE_INVALID, "INVALID" },
{ SPICE_AUDIO_DATA_MODE_RAW, "RAW" },
{ SPICE_AUDIO_DATA_MODE_CELT_0_5_1, "CELT_0_5_1" },
{ 0, NULL }
};
/* main channel */
enum {
SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE,
SPICE_MAIN_CAP_VM_NAME_UUID,
SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS,
SPICE_MAIN_CAP_SEAMLESS_MIGRATE
};
enum
{
SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE_MASK = (1 << SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE),
SPICE_MAIN_CAP_VM_NAME_UUID_MASK = (1 << SPICE_MAIN_CAP_VM_NAME_UUID),
SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS_MASK = (1 << SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS),
SPICE_MAIN_CAP_SEAMLESS_MIGRATE_MASK = (1 << SPICE_MAIN_CAP_SEAMLESS_MIGRATE)
};
enum {
VD_AGENT_MOUSE_STATE = 1,
VD_AGENT_MONITORS_CONFIG,
VD_AGENT_REPLY,
VD_AGENT_CLIPBOARD,
VD_AGENT_DISPLAY_CONFIG,
VD_AGENT_ANNOUNCE_CAPABILITIES,
VD_AGENT_CLIPBOARD_GRAB,
VD_AGENT_CLIPBOARD_REQUEST,
VD_AGENT_CLIPBOARD_RELEASE,
VD_AGENT_FILE_XFER_START,
VD_AGENT_FILE_XFER_STATUS,
VD_AGENT_FILE_XFER_DATA,
VD_AGENT_CLIENT_DISCONNECTED,
VD_AGENT_END_MESSAGE
};
static const value_string agent_message_type_vs[] = {
{ VD_AGENT_MOUSE_STATE, "VD_AGENT_MOUSE_STATE" },
{ VD_AGENT_MONITORS_CONFIG, "VD_AGENT_MONITORS_CONFIG" },
{ VD_AGENT_REPLY, "VD_AGENT_REPLY" },
{ VD_AGENT_CLIPBOARD, "VD_AGENT_CLIPBOARD" },
{ VD_AGENT_DISPLAY_CONFIG, "VD_AGENT_DISPLAY_CONFIG" },
{ VD_AGENT_ANNOUNCE_CAPABILITIES, "VD_AGENT_ANNOUNCE_CAPABILITIES" },
{ VD_AGENT_CLIPBOARD_GRAB, "VD_AGENT_CLIPBOARD_GRAB" },
{ VD_AGENT_CLIPBOARD_REQUEST, "VD_AGENT_CLIPBOARD_REQUEST" },
{ VD_AGENT_CLIPBOARD_RELEASE, "VD_AGENT_CLIPBOARD_RELEASE" },
{ VD_AGENT_FILE_XFER_START, "VD_AGENT_FILE_XFER_START" },
{ VD_AGENT_FILE_XFER_STATUS, "VD_AGENT_FILE_XFER_STATUS" },
{ VD_AGENT_FILE_XFER_DATA, "VD_AGENT_FILE_XFER_DATA" },
{ VD_AGENT_CLIENT_DISCONNECTED, "VD_AGENT_CLIENT_DISCONNECTED" },
{ VD_AGENT_END_MESSAGE, "VD_AGENT_END_MESSAGE" },
{ 0, NULL }
};
enum {
VD_AGENT_CLIPBOARD_NONE,
VD_AGENT_CLIPBOARD_UTF8_TEXT,
VD_AGENT_CLIPBOARD_IMAGE_PNG,
VD_AGENT_CLIPBOARD_IMAGE_BMP,
VD_AGENT_CLIPBOARD_IMAGE_TIFF,
VD_AGENT_CLIPBOARD_IMAGE_JPG
};
static const value_string agent_clipboard_type[] = {
{ VD_AGENT_CLIPBOARD_NONE, "NONE" },
{ VD_AGENT_CLIPBOARD_UTF8_TEXT, "UTF8_TEXT" },
{ VD_AGENT_CLIPBOARD_IMAGE_PNG, "IMAGE_PNG" },
{ VD_AGENT_CLIPBOARD_IMAGE_BMP, "IMAGE_BMP" },
{ VD_AGENT_CLIPBOARD_IMAGE_TIFF,"IMAGE_TIFF" },
{ VD_AGENT_CLIPBOARD_IMAGE_JPG, "IMAGE_JPG" },
{ 0, NULL }
};
enum {
VD_AGENT_CAP_MOUSE_STATE = (1 << 0),
VD_AGENT_CAP_MONITORS_CONFIG = (1 << 1),
VD_AGENT_CAP_REPLY = (1 << 2),
VD_AGENT_CAP_CLIPBOARD = (1 << 3),
VD_AGENT_CAP_DISPLAY_CONFIG = (1 << 4),
VD_AGENT_CAP_CLIPBOARD_BY_DEMAND = (1 << 5),
VD_AGENT_CAP_CLIPBOARD_SELECTION = (1 << 6),
VD_AGENT_CAP_SPARSE_MONITORS_CONFIG = (1 << 7),
VD_AGENT_CAP_GUEST_LINEEND_LF = (1 << 8),
VD_AGENT_CAP_GUEST_LINEEND_CRLF = (1 << 9)
};
#if 0
static const value_string vd_agent_cap_vs[] = {
{ VD_AGENT_CAP_MOUSE_STATE, "VD_AGENT_CAP_MOUSE_STATE" },
{ VD_AGENT_CAP_MONITORS_CONFIG, "VD_AGENT_CAP_MONITORS_CONFIG" },
{ VD_AGENT_CAP_REPLY, "VD_AGENT_CAP_REPLY" },
{ VD_AGENT_CAP_CLIPBOARD, "VD_AGENT_CAP_CLIPBOARD" },
{ VD_AGENT_CAP_DISPLAY_CONFIG, "VD_AGENT_CAP_DISPLAY_CONFIG" },
{ VD_AGENT_CAP_CLIPBOARD_BY_DEMAND, "VD_AGENT_CAP_CLIPBOARD_BY_DEMAND" },
{ VD_AGENT_CAP_CLIPBOARD_SELECTION, "VD_AGENT_CAP_CLIPBOARD_SELECTION" },
{ VD_AGENT_CAP_SPARSE_MONITORS_CONFIG, "VD_AGENT_CAP_SPARSE_MONITORS_CONFIG" },
{ VD_AGENT_CAP_GUEST_LINEEND_LF, "VD_AGENT_CAP_GUEST_LINEEND_LF" },
{ VD_AGENT_CAP_GUEST_LINEEND_CRLF, "VD_AGENT_CAP_GUEST_LINEEND_CRLF" },
{ 0, NULL }
};
#endif
enum {
VD_AGENT_CONFIG_MONITORS_FLAG_USE_POS = (1 << 0)
};
#if 0
static const value_string vd_agent_monitors_config_flag_vs[] = {
{ VD_AGENT_CONFIG_MONITORS_FLAG_USE_POS, "VD_AGENT_CONFIG_MONITORS_FLAG_USE_POS"},
{ 0, NULL }
};
#endif
enum {
VD_AGENT_SUCCESS = 1,
VD_AGENT_ERROR
};
static const value_string vd_agent_reply_error_vs[] = {
{ VD_AGENT_SUCCESS, "SUCCESS"},
{ VD_AGENT_ERROR, "ERROR"},
{ 0, NULL }
};
/* playback channel capabilities */
enum {
SPICE_PLAYBACK_CAP_CELT_0_5_1,
SPICE_PLAYBACK_CAP_VOLUME,
SPICE_PLAYBACK_CAP_LATENCY,
SPICE_PLAYBACK_CAP_OPUS,
/* Number of bits to display for capabilities of the playback channel. */
PLAYBACK_CAP_NBITS
};
enum {
SPICE_PLAYBACK_CAP_CELT_0_5_1_MASK = (1 << SPICE_PLAYBACK_CAP_CELT_0_5_1),
SPICE_PLAYBACK_CAP_VOLUME_MASK = (1 << SPICE_PLAYBACK_CAP_VOLUME),
SPICE_PLAYBACK_CAP_LATENCY_MASK = (1 << SPICE_PLAYBACK_CAP_LATENCY),
SPICE_PLAYBACK_CAP_OPUS_MASK = (1 << SPICE_PLAYBACK_CAP_OPUS),
};
/* record channel capabilities */
enum {
SPICE_RECORD_CAP_CELT_0_5_1,
SPICE_RECORD_CAP_VOLUME,
SPICE_RECORD_CAP_OPUS,
/* Number of bits to display for capabilities of the record channel. */
RECORD_CAP_NBITS
};
enum {
SPICE_RECORD_CAP_CELT_0_5_1_MASK = (1 << SPICE_RECORD_CAP_CELT_0_5_1),
SPICE_RECORD_CAP_VOLUME_MASK = (1 << SPICE_RECORD_CAP_VOLUME),
SPICE_RECORD_CAP_OPUS_MASK = (1 << SPICE_RECORD_CAP_OPUS),
};
/* display channel */
enum {
SPICE_DISPLAY_CAP_SIZED_STREAM,
SPICE_DISPLAY_CAP_MONITORS_CONFIG,
SPICE_DISPLAY_CAP_COMPOSITE,
SPICE_DISPLAY_CAP_A8_SURFACE,
SPICE_DISPLAY_CAP_STREAM_REPORT,
SPICE_DISPLAY_CAP_LZ4_COMPRESSION,
SPICE_DISPLAY_CAP_PREF_COMPRESSION,
SPICE_DISPLAY_CAP_GL_SCANOUT,
SPICE_DISPLAY_CAP_MULTI_CODEC,
SPICE_DISPLAY_CAP_CODEC_MJPEG,
SPICE_DISPLAY_CAP_CODEC_VP8,
SPICE_DISPLAY_CAP_CODEC_H264,
SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE,
SPICE_DISPLAY_CAP_CODEC_VP9,
SPICE_DISPLAY_CAP_CODEC_H265,
/* Number of bits to display for capabilities of the display channel. */
DISPLAY_CAP_NBITS
};
enum {
SPICE_DISPLAY_CAP_SIZED_STREAM_MASK = (1 << SPICE_DISPLAY_CAP_SIZED_STREAM),
SPICE_DISPLAY_CAP_MONITORS_CONFIG_MASK = (1 << SPICE_DISPLAY_CAP_MONITORS_CONFIG),
SPICE_DISPLAY_CAP_COMPOSITE_MASK = (1 << SPICE_DISPLAY_CAP_COMPOSITE),
SPICE_DISPLAY_CAP_A8_SURFACE_MASK = (1 << SPICE_DISPLAY_CAP_A8_SURFACE),
SPICE_DISPLAY_CAP_STREAM_REPORT_MASK = (1 << SPICE_DISPLAY_CAP_STREAM_REPORT),
SPICE_DISPLAY_CAP_LZ4_COMPRESSION_MASK = (1 << SPICE_DISPLAY_CAP_LZ4_COMPRESSION),
SPICE_DISPLAY_CAP_PREF_COMPRESSION_MASK = (1 << SPICE_DISPLAY_CAP_PREF_COMPRESSION),
SPICE_DISPLAY_CAP_GL_SCANOUT_MASK = (1 << SPICE_DISPLAY_CAP_GL_SCANOUT),
SPICE_DISPLAY_CAP_MULTI_CODEC_MASK = (1 << SPICE_DISPLAY_CAP_MULTI_CODEC),
SPICE_DISPLAY_CAP_CODEC_MJPEG_MASK = (1 << SPICE_DISPLAY_CAP_CODEC_MJPEG),
SPICE_DISPLAY_CAP_CODEC_VP8_MASK = (1 << SPICE_DISPLAY_CAP_CODEC_VP8),
SPICE_DISPLAY_CAP_CODEC_H264_MASK = (1 << SPICE_DISPLAY_CAP_CODEC_H264),
SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE_MASK = (1 << SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE),
SPICE_DISPLAY_CAP_CODEC_VP9_MASK = (1 << SPICE_DISPLAY_CAP_CODEC_VP9),
SPICE_DISPLAY_CAP_CODEC_H265_MASK = (1 << SPICE_DISPLAY_CAP_CODEC_H265)
};
/* display channel */
#define sizeof_RedcDisplayInit 14
/* cursor channel */
static const value_string cursor_visible_vs[] = {
{ 1, "Visible" },
{ 0, "Invisible" },
{ 0, NULL }
};
typedef struct {
guint64 unique;
guint8 type;
guint16 width;
guint16 height;
guint16 hot_spot_x;
guint16 hot_spot_y;
} CursorHeader;
#define sizeof_CursorHeader 17
static const value_string spice_agent_vs[] = {
{ 0, "Disconnected" },
{ 1, "Connected" },
{ 0, NULL }
};
/* This structure will be tied to each conversation. */
typedef struct {
guint32 connection_id;
guint32 num_channel_caps;
guint32 destport;
guint32 client_auth;
guint32 server_auth;
guint32 auth_selected;
spice_session_state_e next_state;
guint16 playback_mode;
guint8 channel_type;
guint8 channel_id;
gboolean client_mini_header;
gboolean server_mini_header;
} spice_conversation_t;
typedef struct {
spice_session_state_e state;
} spice_packet_t;
typedef struct {
gint32 left;
gint32 top;
gint32 right;
gint32 bottom;
} SpiceRect;
#define sizeof_SpiceRect 16
typedef struct {
guint8 type;
} Clip;
#define sizeof_Clip 1 /* This is correct only if the type is none. If it is RECTS, this is followed by: */
typedef struct {
guint32 num_rects; /* this is followed by RECT rects[num_rects] */
} ClipRects;
typedef struct {
guint32 surface_id;
SpiceRect bounding_box;
Clip clip;
} DisplayBase;
#define sizeof_DisplayBase 21 /* size without a rect list in the Clip */
typedef struct {
gint32 x;
gint32 y;
} point32_t;
typedef struct {
gint16 x;
gint16 y;
} point16_t;
#define sizeof_Mask 13
#define sizeof_ImageDescriptor 18
enum {
QUIC_IMAGE_TYPE_INVALID,
QUIC_IMAGE_TYPE_GRAY,
QUIC_IMAGE_TYPE_RGB16,
QUIC_IMAGE_TYPE_RGB24,
QUIC_IMAGE_TYPE_RGB32,
QUIC_IMAGE_TYPE_RGBA
};
static const value_string quic_type_vs[] = {
{ QUIC_IMAGE_TYPE_INVALID, "INVALID" },
{ QUIC_IMAGE_TYPE_GRAY, "GRAY" },
{ QUIC_IMAGE_TYPE_RGB16, "RGB16" },
{ QUIC_IMAGE_TYPE_RGB24, "RGB24" },
{ QUIC_IMAGE_TYPE_RGB32, "RGB32" },
{ QUIC_IMAGE_TYPE_RGBA, "RGBA" },
{ 0, NULL }
};
enum {
LZ_IMAGE_TYPE_INVALID,
LZ_IMAGE_TYPE_PLT1_LE,
LZ_IMAGE_TYPE_PLT1_BE,
LZ_IMAGE_TYPE_PLT4_LE,
LZ_IMAGE_TYPE_PLT4_BE,
LZ_IMAGE_TYPE_PLT8,
LZ_IMAGE_TYPE_RGB16,
LZ_IMAGE_TYPE_RGB24,
LZ_IMAGE_TYPE_RGB32,
LZ_IMAGE_TYPE_RGBA,
LZ_IMAGE_TYPE_XXXA
};
static const value_string LzImage_type_vs[] = {
{ LZ_IMAGE_TYPE_INVALID, "INVALID" },
{ LZ_IMAGE_TYPE_PLT1_LE, "PLT1_LE" },
{ LZ_IMAGE_TYPE_PLT1_BE, "PLT1_BE" },
{ LZ_IMAGE_TYPE_PLT4_LE, "PLT4_LE" },
{ LZ_IMAGE_TYPE_PLT4_BE, "PLT4_BE" },
{ LZ_IMAGE_TYPE_PLT8, "PLT8" },
{ LZ_IMAGE_TYPE_RGB16, "RGB16" },
{ LZ_IMAGE_TYPE_RGB24, "RGB24" },
{ LZ_IMAGE_TYPE_RGB32, "RGB32" },
{ LZ_IMAGE_TYPE_RGBA, "RGBA" },
{ LZ_IMAGE_TYPE_XXXA, "RGB JPEG (w/ Alpha LZ)" },
{ 0, NULL }
};
#define sizeof_SpiceHead 28
enum {
SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION,
SPICE_COMMON_CAP_AUTH_SPICE,
SPICE_COMMON_CAP_AUTH_SASL,
SPICE_COMMON_CAP_MINI_HEADER
};
enum {
SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION_MASK = (1 << SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION),
SPICE_COMMON_CAP_AUTH_SPICE_MASK = (1 << SPICE_COMMON_CAP_AUTH_SPICE),
SPICE_COMMON_CAP_AUTH_SASL_MASK = (1 << SPICE_COMMON_CAP_AUTH_SASL),
SPICE_COMMON_CAP_MINI_HEADER_MASK = (1 << SPICE_COMMON_CAP_MINI_HEADER)
};
static const value_string spice_auth_select_vs[] = {
{ SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION, "Auth Selection" },
{ SPICE_COMMON_CAP_AUTH_SPICE, "Spice" },
{ SPICE_COMMON_CAP_AUTH_SASL, "SASL" },
{ SPICE_COMMON_CAP_MINI_HEADER, "Mini header" },
{ 0, NULL }
};
static const value_string spice_sasl_auth_result_vs[] = {
{ 0, "CONTINUE" },
{ 1, "DONE" },
{ 0, NULL }
};
#define GET_PDU_FROM_OFFSET(OFFSET) if (avail < pdu_len) { \
pinfo->desegment_offset = OFFSET; \
pinfo->desegment_len = pdu_len - avail; \
return avail; \
}
static gint ett_spice = -1;
static gint ett_link_client = -1;
static gint ett_link_server = -1;
static gint ett_link_caps = -1;
static gint ett_data = -1;
static gint ett_message = -1;
static gint ett_ticket_client = -1;
static gint ett_auth_select_client = -1;
static gint ett_ticket_server = -1;
static gint ett_playback = -1;
static gint ett_display_client = -1;
static gint ett_display_server = -1;
static gint ett_common_server_message = -1;
static gint ett_common_client_message = -1;
static gint ett_point = -1;
static gint ett_point16 = -1;
static gint ett_cursor = -1;
static gint ett_spice_main = -1;
static gint ett_rect = -1;
static gint ett_DisplayBase = -1;
static gint ett_Clip = -1;
static gint ett_Mask = -1;
static gint ett_imagedesc = -1;
static gint ett_imageQuic = -1;
static gint ett_GLZ_RGB = -1;
static gint ett_LZ_RGB = -1;
static gint ett_LZ_PLT = -1;
static gint ett_ZLIB_GLZ = -1;
static gint ett_Uncomp_tree = -1;
static gint ett_LZ_JPEG = -1;
static gint ett_JPEG = -1;
static gint ett_cursor_header = -1;
static gint ett_RedCursor = -1;
static gint ett_pattern = -1;
static gint ett_brush = -1;
static gint ett_Pixmap = -1;
static gint ett_SpiceHead = -1;
static gint ett_inputs_client = -1;
static gint ett_rectlist = -1;
static gint ett_inputs_server = -1;
static gint ett_record_client = -1;
static gint ett_record_server = -1;
static gint ett_main_client = -1;
static gint ett_spice_agent = -1;
static gint ett_cap_tree = -1;
static int proto_spice = -1;
static int hf_spice_magic = -1;
static int hf_major_version = -1;
static int hf_minor_version = -1;
static int hf_message_size = -1;
static int hf_message_type = -1;
static int hf_conn_id = -1;
static int hf_channel_type = -1;
static int hf_channel_id = -1;
static int hf_num_common_caps = -1;
static int hf_num_channel_caps = -1;
static int hf_caps_offset = -1;
static int hf_error_code = -1;
static int hf_data = -1;
static int hf_serial = -1;
static int hf_data_size = -1;
static int hf_data_sublist = -1;
static int hf_link_client = -1;
static int hf_link_server = -1;
static int hf_ticket_client = -1;
static int hf_auth_select_client = -1;
static int hf_ticket_server = -1;
static int hf_main_num_channels = -1;
static int hf_main_cap_semi_migrate = -1;
static int hf_main_cap_vm_name_uuid = -1;
static int hf_main_cap_agent_connected_tokens = -1;
static int hf_main_cap_seamless_migrate = -1;
static int hf_inputs_cap = -1;
static int hf_cursor_cap = -1;
static int hf_common_cap_auth_select = -1;
static int hf_common_cap_auth_spice = -1;
static int hf_common_cap_auth_sasl = -1;
static int hf_common_cap_mini_header = -1;
static int hf_audio_timestamp = -1;
static int hf_audio_mode = -1;
static int hf_audio_channels = -1;
static int hf_audio_format = -1;
static int hf_audio_frequency = -1;
static int hf_audio_volume = -1;
static int hf_audio_mute = -1;
static int hf_audio_latency = -1;
static int hf_red_set_ack_generation = -1;
static int hf_red_set_ack_window = -1;
static int hf_Clip_type = -1;
static int hf_Mask_flag = -1;
static int hf_display_rop_descriptor = -1;
static int hf_display_scale_mode = -1;
static int hf_display_stream_id = -1;
static int hf_display_stream_report_unique_id = -1;
static int hf_display_stream_report_max_window_size = -1;
static int hf_display_stream_report_timeout = -1;
static int hf_display_stream_width = -1;
static int hf_display_stream_height = -1;
static int hf_display_stream_src_width = -1;
static int hf_display_stream_src_height = -1;
static int hf_display_stream_data_size = -1;
static int hf_display_stream_codec_type = -1;
static int hf_display_stream_stamp = -1;
static int hf_display_stream_flags = -1;
static int hf_red_ping_id = -1;
static int hf_red_timestamp = -1;
static int hf_spice_display_mode_width = -1;
static int hf_spice_display_mode_height = -1;
static int hf_spice_display_mode_depth = -1;
static int hf_image_desc_id = -1;
static int hf_image_desc_type = -1;
static int hf_image_desc_flags = -1;
static int hf_image_desc_width = -1;
static int hf_image_desc_height = -1;
static int hf_quic_width = -1;
static int hf_quic_height = -1;
static int hf_quic_major_version = -1;
static int hf_quic_minor_version = -1;
static int hf_quic_type = -1;
static int hf_LZ_width = -1;
static int hf_LZ_height = -1;
static int hf_LZ_major_version = -1;
static int hf_LZ_minor_version = -1;
static int hf_LZ_PLT_type = -1;
static int hf_LZ_RGB_type = -1;
static int hf_LZ_stride = -1;
static int hf_LZ_RGB_dict_id = -1;
static int hf_cursor_trail_len = -1;
static int hf_cursor_trail_freq = -1;
static int hf_cursor_trail_visible = -1;
static int hf_cursor_unique = -1;
static int hf_cursor_type = -1;
static int hf_cursor_width = -1;
static int hf_cursor_height = -1;
static int hf_cursor_hotspot_x = -1;
static int hf_cursor_hotspot_y = -1;
static int hf_cursor_flags = -1;
static int hf_cursor_id = -1;
static int hf_spice_display_init_cache_id = -1;
static int hf_spice_display_init_cache_size = -1;
static int hf_spice_display_init_glz_dict_id = -1;
static int hf_spice_display_init_dict_window_size = -1;
static int hf_brush_type = -1;
static int hf_brush_rgb = -1;
static int hf_pixmap_width = -1;
static int hf_pixmap_height = -1;
static int hf_pixmap_stride = -1;
static int hf_pixmap_address = -1;
static int hf_pixmap_format = -1;
static int hf_pixmap_flags = -1;
static int hf_keyboard_modifiers = -1;
static int hf_keyboard_modifier_scroll_lock = -1;
static int hf_keyboard_modifier_num_lock = -1;
static int hf_keyboard_modifier_caps_lock = -1;
static int hf_keyboard_code = -1;
static int hf_rectlist_size = -1;
static int hf_migrate_dest_port = -1;
static int hf_migrate_dest_sport = -1;
static int hf_migrate_src_mig_version = -1;
static int hf_session_id = -1;
static int hf_display_channels_hint = -1;
static int hf_supported_mouse_modes = -1;
static int hf_current_mouse_mode = -1;
static int hf_supported_mouse_modes_flags = -1;
static int hf_supported_mouse_modes_flag_client = -1;
static int hf_supported_mouse_modes_flag_server = -1;
static int hf_current_mouse_mode_flags = -1;
static int hf_agent_connected = -1;
static int hf_agent_tokens = -1;
static int hf_agent_protocol = -1;
static int hf_agent_type = -1;
static int hf_agent_opaque = -1;
static int hf_agent_size = -1;
static int hf_agent_token = -1;
static int hf_agent_clipboard_selection = -1;
static int hf_agent_clipboard_type = -1;
static int hf_agent_num_monitors = -1;
static int hf_agent_monitor_height = -1;
static int hf_agent_monitor_width = -1;
static int hf_agent_monitor_depth = -1;
static int hf_agent_monitor_x = -1;
static int hf_agent_monitor_y = -1;
static int hf_multi_media_time = -1;
static int hf_ram_hint = -1;
static int hf_button_state = -1;
static int hf_mouse_display_id = -1;
static int hf_display_text_fore_mode = -1;
static int hf_display_text_back_mode = -1;
static int hf_display_surface_id = -1;
static int hf_display_surface_width = -1;
static int hf_display_surface_height = -1;
static int hf_display_surface_format = -1;
static int hf_display_surface_flags = -1;
static int hf_main_client_agent_tokens = -1;
static int hf_tranparent_src_color = -1;
static int hf_tranparent_true_color = -1;
static int hf_spice_sasl_auth_result = -1;
static int hf_playback_cap_celt_0_5_1 = -1;
static int hf_playback_cap_volume = -1;
static int hf_playback_cap_latency = -1;
static int hf_playback_cap_opus = -1;
static int hf_record_cap_celt = -1;
static int hf_record_cap_volume = -1;
static int hf_record_cap_opus = -1;
static int hf_display_cap_sized_stream = -1;
static int hf_display_cap_monitors_config = -1;
static int hf_display_cap_composite = -1;
static int hf_display_cap_a8_surface = -1;
static int hf_display_cap_stream_report = -1;
static int hf_display_cap_lz4_compression = -1;
static int hf_display_cap_pref_compression = -1;
static int hf_display_cap_gl_scanout = -1;
static int hf_display_cap_multi_codec = -1;
static int hf_display_cap_codec_mjpeg = -1;
static int hf_display_cap_codec_vp8 = -1;
static int hf_display_cap_codec_h264 = -1;
static int hf_display_cap_pref_video_codec_type = -1;
static int hf_display_cap_codec_vp9 = -1;
static int hf_display_cap_codec_h265 = -1;
static int hf_main_uuid = -1;
static int hf_main_name = -1;
static int hf_main_name_len = -1;
static int hf_display_monitor_config_count = -1;
static int hf_display_monitor_config_max_allowed = -1;
static int hf_display_head_id = -1;
static int hf_display_head_surface_id = -1;
static int hf_display_head_width = -1;
static int hf_display_head_height = -1;
static int hf_display_head_x = -1;
static int hf_display_head_y = -1;
static int hf_display_head_flags = -1;
static int hf_zlib_uncompress_size = -1;
static int hf_zlib_compress_size = -1;
static int hf_rect_left = -1;
static int hf_rect_top = -1;
static int hf_rect_right = -1;
static int hf_rect_bottom = -1;
static int hf_point32_x = -1;
static int hf_point32_y = -1;
static int hf_point16_x = -1;
static int hf_point16_y = -1;
static int hf_severity = -1;
static int hf_visibility = -1;
static int hf_notify_code = -1;
static int hf_notify_message_len = -1;
static int hf_notify_message = -1;
static int hf_num_glyphs = -1;
static int hf_port_opened = -1;
static int hf_port_event = -1;
static int hf_raw_data = -1;
static int hf_display_inval_list_count = -1;
static int hf_resource_type = -1;
static int hf_resource_id = -1;
static int hf_ref_image = -1;
static int hf_ref_string = -1;
static int hf_vd_agent_caps_request = -1;
static int hf_vd_agent_cap_mouse_state = -1;
static int hf_vd_agent_cap_monitors_config = -1;
static int hf_vd_agent_cap_reply = -1;
static int hf_vd_agent_cap_clipboard = -1;
static int hf_vd_agent_cap_display_config = -1;
static int hf_vd_agent_cap_clipboard_by_demand = -1;
static int hf_vd_agent_cap_clipboard_selection = -1;
static int hf_vd_agent_cap_sparse_monitors_config = -1;
static int hf_vd_agent_cap_guest_lineend_lf = -1;
static int hf_vd_agent_cap_guest_lineend_crlf = -1;
static int hf_vd_agent_monitors_config_flag_use_pos = -1;
static int hf_vd_agent_reply_type = -1;
static int hf_vd_agent_reply_error = -1;
/* Generated from convert_proto_tree_add_text.pl */
static int hf_spice_supported_authentication_mechanisms_list = -1;
static int hf_spice_selected_client_out_mechanism = -1;
static int hf_spice_scale_mode = -1;
static int hf_spice_supported_authentication_mechanisms_list_length = -1;
static int hf_spice_rop3 = -1;
static int hf_spice_x509_subjectpublickeyinfo = -1;
static int hf_spice_glz_rgb_image_size = -1;
static int hf_spice_vd_agent_display_config_message = -1;
static int hf_spice_stream_data = -1;
static int hf_spice_client_out_mechanism_length = -1;
static int hf_spice_vd_agent_clipboard_message = -1;
static int hf_spice_image_from_cache = -1;
static int hf_spice_lz_rgb_compressed_image_data = -1;
static int hf_spice_unknown_bytes = -1;
static int hf_spice_sasl_data = -1;
static int hf_spice_name_length = -1;
static int hf_spice_zlib_stream = -1;
static int hf_spice_lz_plt_image_size = -1;
static int hf_spice_reserved = -1;
static int hf_spice_sasl_authentication_data = -1;
static int hf_spice_image_from_cache_lossless = -1;
static int hf_spice_quic_magic = -1;
static int hf_spice_surface_id = -1;
static int hf_spice_ping_data = -1;
static int hf_spice_display_mark_message = -1;
static int hf_spice_pixmap_pixels = -1;
static int hf_spice_vd_agent_clipboard_release_message = -1;
static int hf_spice_clientout_list = -1;
static int hf_spice_server_inputs_mouse_motion_ack_message = -1;
static int hf_spice_cursor_data = -1;
static int hf_spice_clientout_length = -1;
static int hf_spice_lz_magic = -1;
static int hf_spice_lz_rgb_image_size = -1;
static int hf_spice_lz_plt_data = -1;
static int hf_spice_glyph_flags = -1;
static int hf_spice_palette_offset = -1;
#if 0
static int hf_spice_lz_jpeg_image_size = -1;
#endif
static int hf_spice_palette = -1;
static int hf_spice_selected_authentication_mechanism_length = -1;
static int hf_spice_display_reset_message = -1;
static int hf_spice_topdown_flag = -1;
static int hf_spice_quic_image_size = -1;
static int hf_spice_sasl_message_length = -1;
static int hf_spice_selected_authentication_mechanism = -1;
static int hf_spice_lz_plt_flag = -1;
static int hf_spice_quic_compressed_image_data = -1;
static expert_field ei_spice_decompress_error = EI_INIT;
static expert_field ei_spice_unknown_message = EI_INIT;
static expert_field ei_spice_not_dissected = EI_INIT;
static expert_field ei_spice_auth_unknown = EI_INIT;
static expert_field ei_spice_sasl_auth_result = EI_INIT;
static expert_field ei_spice_expected_from_client = EI_INIT;
/* Generated from convert_proto_tree_add_text.pl */
static expert_field ei_spice_brush_type = EI_INIT;
static expert_field ei_spice_unknown_image_type = EI_INIT;
static expert_field ei_spice_Mask_flag = EI_INIT;
static expert_field ei_spice_Mask_point = EI_INIT;
static expert_field ei_spice_common_cap_unknown = EI_INIT;
static expert_field ei_spice_unknown_channel = EI_INIT;
static dissector_handle_t jpeg_handle;
static guint32
dissect_SpiceHead(tvbuff_t *tvb, proto_tree *tree, guint32 offset, const guint16 num)
{
proto_tree *SpiceHead_tree;
SpiceHead_tree = proto_tree_add_subtree_format(tree, tvb, offset, sizeof_SpiceHead,
ett_SpiceHead, NULL, "Display Head #%u", num);
proto_tree_add_item(SpiceHead_tree, hf_display_head_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(SpiceHead_tree, hf_display_head_surface_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(SpiceHead_tree, hf_display_head_width, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(SpiceHead_tree, hf_display_head_height, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(SpiceHead_tree, hf_display_head_x, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(SpiceHead_tree, hf_display_head_y, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(SpiceHead_tree, hf_display_head_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
return offset;
}
#define sizeof_AgentMonitorConfig 20
static guint32
dissect_AgentMonitorConfig(tvbuff_t *tvb, proto_tree *tree, guint32 offset, const guint16 num)
{
proto_tree *subtree;
subtree = proto_tree_add_subtree_format(tree, tvb, offset, sizeof_AgentMonitorConfig,
ett_SpiceHead, NULL, "Monitor Config #%u", num);
proto_tree_add_item(subtree, hf_agent_monitor_height, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_agent_monitor_width, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_agent_monitor_depth, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_agent_monitor_x, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_agent_monitor_y, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
return offset;
}
/* returns the pixmap size in bytes */
static guint32
dissect_Pixmap(tvbuff_t *tvb, proto_tree *tree, guint32 offset)
{
proto_item *ti;
proto_tree *Pixmap_tree;
guint32 PixmapSize;
guint32 strides, height, palette_ptr;
Pixmap_tree = proto_tree_add_subtree(tree, tvb, offset, 0, ett_Pixmap, &ti, "Pixmap"); /* size is fixed later */
proto_tree_add_item(Pixmap_tree, hf_pixmap_format, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(Pixmap_tree, hf_pixmap_flags, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(Pixmap_tree, hf_pixmap_width, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
height = tvb_get_letohl(tvb, offset);
proto_tree_add_item(Pixmap_tree, hf_pixmap_height, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
strides = tvb_get_letohl(tvb, offset);
proto_tree_add_item(Pixmap_tree, hf_pixmap_stride, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
palette_ptr = tvb_get_letohl(tvb, offset);
proto_tree_add_item(Pixmap_tree, hf_pixmap_address, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
PixmapSize = height * strides;
proto_item_set_len(ti, 18 + PixmapSize);
proto_tree_add_bytes_format(Pixmap_tree, hf_spice_pixmap_pixels, tvb, offset, PixmapSize, NULL,
"Pixmap pixels (%d bytes)", PixmapSize);
offset += PixmapSize;
/* FIXME: compute palette size */
proto_tree_add_bytes_format(Pixmap_tree, hf_spice_palette, tvb, offset, 0, NULL, "Palette (offset from message start - %u)", palette_ptr);
/*TODO: complete pixmap dissection */
return PixmapSize + 18;
}
/* returns the type of cursor */
static guint8
dissect_CursorHeader(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint16 *width, guint16 *height)
{
const guint8 type = tvb_get_guint8(tvb, offset + 8);
*width = tvb_get_letohs(tvb, offset + 8 + 1);
*height = tvb_get_letohs(tvb, offset + 8 + 1 + 2);
if (tree) {
proto_tree *CursorHeader_tree;
CursorHeader_tree = proto_tree_add_subtree(tree, tvb, offset, sizeof_CursorHeader, ett_cursor_header, NULL, "Cursor Header");
proto_tree_add_item(CursorHeader_tree, hf_cursor_unique, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(CursorHeader_tree, hf_cursor_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(CursorHeader_tree, hf_cursor_width, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(CursorHeader_tree, hf_cursor_height, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(CursorHeader_tree, hf_cursor_hotspot_x, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(CursorHeader_tree, hf_cursor_hotspot_y, tvb, offset, 2, ENC_LITTLE_ENDIAN);
}
return type;
}
/* returns the size of RedCursor */
static guint32
dissect_RedCursor(tvbuff_t *tvb, proto_tree *tree, guint32 offset)
{
proto_item *ti;
proto_tree *RedCursor_tree;
guint8 type;
guint16 height, width;
guint32 init_offset = offset;
const guint16 flags = tvb_get_letohs(tvb, offset);
guint32 data_size = 0;
RedCursor_tree = proto_tree_add_subtree(tree, tvb, offset, 2, ett_RedCursor, &ti, "RedCursor"); /* FIXME - fix size if flag is not NONE */
proto_tree_add_item(RedCursor_tree, hf_cursor_flags, tvb, offset, 2, ENC_LITTLE_ENDIAN);
if (flags == SPICE_CURSOR_FLAGS_NONE) {
return 2;
}
offset += 2;
type = dissect_CursorHeader(tvb, RedCursor_tree, offset, &width, &height);
offset += (int)sizeof_CursorHeader;
if (((width == 0) || (height == 0)) || (flags == SPICE_CURSOR_FLAGS_FROM_CACHE)) {
proto_item_set_len(ti, offset - init_offset);
return (offset - init_offset);
}
switch (type) {
case SPICE_CURSOR_TYPE_ALPHA:
data_size = (width << 2) * height;
break;
case SPICE_CURSOR_TYPE_MONO:
data_size = (SPICE_ALIGN(width, 8) >> 2) * height;
break;
/* TODO: fix all size calculations for below cursor types, using SPICE_ALIGN */
case SPICE_CURSOR_TYPE_COLOR4:
case SPICE_CURSOR_TYPE_COLOR8:
case SPICE_CURSOR_TYPE_COLOR16:
case SPICE_CURSOR_TYPE_COLOR24:
case SPICE_CURSOR_TYPE_COLOR32:
break;
default:
data_size = 0;
break;
}
if (data_size != 0) {
proto_tree_add_item(RedCursor_tree, hf_spice_cursor_data, tvb, offset, data_size, ENC_NA);
} else {
proto_tree_add_item(RedCursor_tree, hf_spice_cursor_data, tvb, offset, -1, ENC_NA);
}
offset += data_size;
return (offset - init_offset);
}
/* returns the image type, needed for later */
static guint8
dissect_ImageDescriptor(tvbuff_t *tvb, proto_tree *tree, guint32 offset)
{
const guint8 type = tvb_get_guint8(tvb, offset + 8);
if (tree) {
proto_tree *ImageDescriptor_tree;
ImageDescriptor_tree = proto_tree_add_subtree(tree, tvb, offset, sizeof_ImageDescriptor, ett_imagedesc, NULL, "Image Descriptor");
proto_tree_add_item(ImageDescriptor_tree, hf_image_desc_id, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(ImageDescriptor_tree, hf_image_desc_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(ImageDescriptor_tree, hf_image_desc_flags, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(ImageDescriptor_tree, hf_image_desc_width, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(ImageDescriptor_tree, hf_image_desc_height, tvb, offset, 4, ENC_LITTLE_ENDIAN);
}
return type;
}
static guint32
dissect_ImageQuic(tvbuff_t *tvb, proto_tree *tree, guint32 offset)
{
const guint32 QuicSize = tvb_get_letohl(tvb, offset);
if (tree) {
proto_tree *ImageQuic_tree;
ImageQuic_tree = proto_tree_add_subtree(tree, tvb, offset, QuicSize + 4, ett_imageQuic, NULL, "QUIC Image");
proto_tree_add_uint(ImageQuic_tree, hf_spice_quic_image_size, tvb, offset, 4, QuicSize);
offset += 4;
proto_tree_add_item(ImageQuic_tree, hf_spice_quic_magic, tvb, offset, 4, ENC_ASCII);
offset += 4;
proto_tree_add_item(ImageQuic_tree, hf_quic_major_version, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(ImageQuic_tree, hf_quic_minor_version, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(ImageQuic_tree, hf_quic_type, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(ImageQuic_tree, hf_quic_width, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(ImageQuic_tree, hf_quic_height, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_bytes_format(ImageQuic_tree, hf_spice_quic_compressed_image_data, tvb, offset, QuicSize - 20, NULL, "QUIC compressed image data (%u bytes)", QuicSize);
}
return QuicSize + 4;
}
static guint32
dissect_ImageLZ_common_header(tvbuff_t *tvb, proto_tree *tree, const guint32 offset)
{
proto_tree_add_item(tree, hf_spice_lz_magic, tvb, offset, 4, ENC_ASCII);
proto_tree_add_item(tree, hf_LZ_major_version, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_LZ_minor_version, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
return 8;
}
static guint32
dissect_ImageLZ_common(tvbuff_t *tvb, proto_tree *tree, guint32 offset, const gboolean IsLZ, const guint32 size)
{
guint8 type;
guint32 end_offset = offset + size;
offset += dissect_ImageLZ_common_header(tvb, tree, offset);
if (IsLZ)
offset +=3; /* alignment in LZ? Does not exist in GLZ?*/
proto_tree_add_item(tree, hf_LZ_RGB_type, tvb, offset, 1, ENC_NA);
type = tvb_get_guint8(tvb, offset);
offset += 1;
switch (type & 0xf) { /* 0xf is the MASK */
case LZ_IMAGE_TYPE_RGB16:
case LZ_IMAGE_TYPE_RGB24:
case LZ_IMAGE_TYPE_RGB32:
proto_tree_add_item(tree, hf_LZ_width, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_LZ_height, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_LZ_stride, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_LZ_RGB_dict_id, tvb, offset, 8, ENC_BIG_ENDIAN);
offset += 8;
proto_tree_add_bytes_format(tree, hf_spice_lz_rgb_compressed_image_data, tvb, offset, end_offset - offset, NULL, "LZ_RGB compressed image data (%u bytes)", end_offset - offset);
break;
case LZ_IMAGE_TYPE_RGBA:
offset += 2;
break;
case LZ_IMAGE_TYPE_XXXA:
proto_tree_add_item(tree, hf_LZ_width, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_LZ_height, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_LZ_stride, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_spice_topdown_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_spice_unknown_bytes, tvb, offset, 12, ENC_NA);
offset += 8;
break;
default:
proto_tree_add_item(tree, hf_LZ_width, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_LZ_height, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_LZ_stride, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_LZ_RGB_dict_id, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_bytes_format(tree, hf_spice_lz_rgb_compressed_image_data, tvb, offset, end_offset - offset, NULL, "LZ_RGB compressed image data (%u bytes)", end_offset - offset);
break;
}
return offset;
}
#if 0
static guint32
dissect_ImageLZ_JPEG(tvbuff_t *tvb, proto_tree *tree, guint32 offset)
{
proto_tree *LZ_JPEG_tree;
const guint32 LZ_JPEGSize = tvb_get_letohl(tvb, offset);
LZ_JPEG_tree = proto_tree_add_subtree(tree, tvb, offset, LZ_JPEGSize + 4, ett_LZ_JPEG, NULL, "LZ_JPEG Image");
proto_tree_add_uint(LZ_JPEG_tree, hf_spice_lz_jpeg_image_size, tvb, offset, 4, LZ_JPEGSize);
offset += 4;
offset += dissect_ImageLZ_common_header(tvb, LZ_JPEG_tree, offset);
return offset;
}
#endif
static guint32
dissect_ImageGLZ_RGB(tvbuff_t *tvb, proto_tree *tree, guint32 offset, const guint32 size)
{
proto_tree *GLZ_RGB_tree;
guint32 GLZ_RGBSize;
if (size == 0) { /* if no size was passed to us, need to fetch it. Otherwise, we already have it from the callee */
GLZ_RGBSize = tvb_get_letohl(tvb, offset);
GLZ_RGB_tree = proto_tree_add_subtree(tree, tvb, offset, GLZ_RGBSize + 4, ett_GLZ_RGB, NULL, "GLZ_RGB Image");
proto_tree_add_uint(GLZ_RGB_tree, hf_spice_glz_rgb_image_size, tvb, offset, 4, GLZ_RGBSize);
offset += 4;
} else {
GLZ_RGBSize = size;
GLZ_RGB_tree = proto_tree_add_subtree(tree, tvb, offset, GLZ_RGBSize, ett_GLZ_RGB, NULL, "GLZ_RGB Image");
}
dissect_ImageLZ_common(tvb, GLZ_RGB_tree, offset, FALSE, GLZ_RGBSize);
return GLZ_RGBSize + 4;
}
static guint32
dissect_ImageLZ_RGB(tvbuff_t *tvb, proto_tree *tree, guint32 offset)
{
proto_tree *LZ_RGB_tree;
const guint32 LZ_RGBSize = tvb_get_letohl(tvb, offset);
LZ_RGB_tree = proto_tree_add_subtree(tree, tvb, offset, LZ_RGBSize + 4, ett_LZ_RGB, NULL, "LZ_RGB Image");
proto_tree_add_uint(LZ_RGB_tree, hf_spice_lz_rgb_image_size, tvb, offset, 4, LZ_RGBSize);
offset += 4;
dissect_ImageLZ_common(tvb, LZ_RGB_tree, offset, TRUE, LZ_RGBSize);
return LZ_RGBSize + 4;
}
static guint32
dissect_ImageLZ_PLT(tvbuff_t *tvb, proto_tree *tree, guint32 offset)
{
proto_tree *LZ_PLT_tree;
guint32 LZ_PLTSize, pal_size;
const guint32 current_offset = offset;
LZ_PLTSize = tvb_get_letohl(tvb, offset + 1); /* for some reason, it reports two extra bytes */
LZ_PLT_tree = proto_tree_add_subtree(tree, tvb, offset, (LZ_PLTSize - 2)+ 1 + 4 + 4 + 8 + 4 + 4 + 4 + 4 + 4, ett_LZ_PLT, NULL, "LZ_PLT Image");
proto_tree_add_item(LZ_PLT_tree, hf_spice_lz_plt_flag, tvb, offset, 1, ENC_NA); /* TODO: dissect */
offset += 1;
proto_tree_add_uint_format_value(LZ_PLT_tree, hf_spice_lz_plt_image_size, tvb, offset, 4, LZ_PLTSize, "%u bytes (2 extra bytes?)", LZ_PLTSize);
offset += 4;
proto_tree_add_item_ret_uint(LZ_PLT_tree, hf_spice_palette_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN, &pal_size); /* TODO: not sure it's correct */
offset += 4;
dissect_ImageLZ_common_header(tvb, LZ_PLT_tree, offset);
offset += 8;
proto_tree_add_item(LZ_PLT_tree, hf_LZ_PLT_type, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(LZ_PLT_tree, hf_LZ_width, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(LZ_PLT_tree, hf_LZ_height, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(LZ_PLT_tree, hf_LZ_stride, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(LZ_PLT_tree, hf_spice_topdown_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_bytes_format(LZ_PLT_tree, hf_spice_lz_plt_data, tvb, offset, (LZ_PLTSize - 2), NULL, "LZ_PLT data (%u bytes)", (LZ_PLTSize - 2));
offset += (LZ_PLTSize - 2);
/* TODO:
* proto_tree_add_bytes_format(LZ_PLT_tree, tvb, offset, pal_size, "palette (%u bytes)" , pal_size);
* offset += pal_size;
*/
return offset - current_offset;
}
static guint32
dissect_ImageJPEG_Alpha(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset)
{
proto_tree *JPEG_tree;
tvbuff_t *jpeg_tvb;
guint32 JPEG_Size, Data_Size;
/*TODO: const guint8 flags = tvb_get_guint8(tvb, offset); dissect and present */
offset += 1;
JPEG_Size = tvb_get_letohl(tvb, offset);
offset += 4;
Data_Size = tvb_get_letohl(tvb, offset);
offset += 4;
JPEG_tree = proto_tree_add_subtree_format(tree, tvb, offset - 9, Data_Size + 9,
ett_JPEG, NULL, "RGB JPEG Image, Alpha channel (%u bytes)", Data_Size);
jpeg_tvb = tvb_new_subset_length(tvb, offset, JPEG_Size);
call_dissector(jpeg_handle, jpeg_tvb, pinfo, JPEG_tree);
offset += JPEG_Size;
dissect_ImageLZ_common(tvb, tree, offset, TRUE, JPEG_Size);
return Data_Size + 9;
}
static guint32
dissect_ImageJPEG(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, const guint32 offset)
{
proto_tree *JPEG_tree;
tvbuff_t *jpeg_tvb;
const guint32 JPEG_Size = tvb_get_letohl(tvb, offset);
JPEG_tree = proto_tree_add_subtree_format(tree, tvb, offset, JPEG_Size + 4, ett_JPEG, NULL, "JPEG Image (%u bytes)", JPEG_Size);
jpeg_tvb = tvb_new_subset_length(tvb, offset + 4, JPEG_Size);
call_dissector(jpeg_handle, jpeg_tvb, pinfo, JPEG_tree);
return JPEG_Size + 4;
}
#ifdef HAVE_ZLIB
static void
dissect_ImageZLIB_GLZ_stream(tvbuff_t *tvb, proto_tree *ZLIB_GLZ_tree, packet_info *pinfo,
guint32 offset, guint32 ZLIB_GLZSize, guint32 ZLIB_uncompSize)
{
proto_item *ti;
proto_tree *Uncomp_tree;
tvbuff_t *uncompressed_tvb;
Uncomp_tree = proto_tree_add_subtree_format(ZLIB_GLZ_tree, tvb, offset, ZLIB_GLZSize, ett_Uncomp_tree, &ti, "ZLIB stream (%u bytes)", ZLIB_GLZSize);
uncompressed_tvb = tvb_child_uncompress(tvb, tvb, offset, ZLIB_GLZSize);
if (uncompressed_tvb != NULL) {
add_new_data_source(pinfo, uncompressed_tvb, "Uncompressed GLZ stream");
dissect_ImageGLZ_RGB(uncompressed_tvb, Uncomp_tree, 0, ZLIB_uncompSize);
} else {
expert_add_info(pinfo, ti, &ei_spice_decompress_error);
}
}
#else
static void
dissect_ImageZLIB_GLZ_stream(tvbuff_t *tvb, proto_tree *ZLIB_GLZ_tree, packet_info *pinfo _U_,
guint32 offset, guint32 ZLIB_GLZSize, guint32 ZLIB_uncompSize _U_)
{
proto_tree_add_bytes_format(ZLIB_GLZ_tree, hf_spice_zlib_stream, tvb, offset, ZLIB_GLZSize, NULL, "ZLIB stream (%u bytes)", ZLIB_GLZSize);
}
#endif
static guint32
dissect_ImageZLIB_GLZ(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset)
{
proto_tree *ZLIB_GLZ_tree;
guint32 ZLIB_GLZSize, ZLIB_uncompSize;
ZLIB_uncompSize = tvb_get_letohl(tvb, offset);
ZLIB_GLZSize = tvb_get_letohl(tvb, offset + 4); /* compressed size */
if (tree) {
ZLIB_GLZ_tree = proto_tree_add_subtree(tree, tvb, offset, ZLIB_GLZSize + 8, ett_ZLIB_GLZ, NULL, "ZLIB over GLZ Image");
proto_tree_add_item(ZLIB_GLZ_tree, hf_zlib_uncompress_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(ZLIB_GLZ_tree, hf_zlib_compress_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
dissect_ImageZLIB_GLZ_stream(tvb, ZLIB_GLZ_tree, pinfo, offset, ZLIB_GLZSize, ZLIB_uncompSize);
}
return ZLIB_GLZSize + 8;
}
/* returns the size of an image, not offset */
static guint32
dissect_Image(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset)
{
guint32 ImageSize = 0;
const guint8 type = dissect_ImageDescriptor(tvb, tree, offset);
offset += (int)sizeof_ImageDescriptor;
switch (type) {
case SPICE_IMAGE_TYPE_BITMAP:
ImageSize = dissect_Pixmap(tvb, tree, offset);
break;
case SPICE_IMAGE_TYPE_QUIC:
ImageSize = dissect_ImageQuic(tvb, tree, offset);
break;
case SPICE_IMAGE_TYPE_LZ_PLT:
ImageSize = dissect_ImageLZ_PLT(tvb, tree, offset);
break;
case SPICE_IMAGE_TYPE_LZ_RGB:
ImageSize = dissect_ImageLZ_RGB(tvb, tree, offset);
break;
case SPICE_IMAGE_TYPE_GLZ_RGB:
ImageSize = dissect_ImageGLZ_RGB(tvb, tree, offset, 0);
break;
case SPICE_IMAGE_TYPE_FROM_CACHE:
proto_tree_add_item(tree, hf_spice_image_from_cache, tvb, offset, 0, ENC_NA);
break;
case SPICE_IMAGE_TYPE_SURFACE:
ImageSize = 4; /* surface ID */
proto_tree_add_item(tree, hf_spice_surface_id, tvb, offset, ImageSize, ENC_LITTLE_ENDIAN);
break;
case SPICE_IMAGE_TYPE_JPEG:
ImageSize = dissect_ImageJPEG(tvb, tree, pinfo, offset);
break;
case SPICE_IMAGE_TYPE_FROM_CACHE_LOSSLESS:
proto_tree_add_item(tree, hf_spice_image_from_cache_lossless, tvb, offset, 0, ENC_NA);
break;
case SPICE_IMAGE_TYPE_ZLIB_GLZ_RGB:
ImageSize = dissect_ImageZLIB_GLZ(tvb, tree, pinfo, offset);
break;
case SPICE_IMAGE_TYPE_JPEG_ALPHA:
ImageSize = dissect_ImageJPEG_Alpha(tvb, tree, pinfo, offset);
break;
default:
proto_tree_add_expert(tree, pinfo, &ei_spice_unknown_image_type, tvb, offset, -1);
}
return sizeof_ImageDescriptor + ImageSize;
}
static SpiceRect
dissect_SpiceRect(tvbuff_t *tvb, proto_tree *tree, const guint32 offset, const gint32 id)
{
proto_tree *rect_tree;
SpiceRect rect;
rect.left = tvb_get_letohl(tvb, offset);
rect.top = tvb_get_letohl(tvb, offset + 4);
rect.right = tvb_get_letohl(tvb, offset + 8);
rect.bottom = tvb_get_letohl(tvb, offset + 12);
if (tree) {
if (id != -1) {
rect_tree = proto_tree_add_subtree_format(tree, tvb, offset, sizeof_SpiceRect, ett_rect, NULL,
"RECT %u: (%u-%u, %u-%u)", id, rect.left, rect.top, rect.right, rect.bottom);
} else { /* single rectangle */
rect_tree = proto_tree_add_subtree_format(tree, tvb, offset, sizeof_SpiceRect, ett_rect, NULL,
"RECT: (%u-%u, %u-%u)", rect.left, rect.top, rect.right, rect.bottom);
}
proto_tree_add_item(rect_tree, hf_rect_left, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(rect_tree, hf_rect_top, tvb, offset + 4, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(rect_tree, hf_rect_right, tvb, offset + 8, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(rect_tree, hf_rect_bottom, tvb, offset + 12, 4, ENC_LITTLE_ENDIAN);
}
return rect;
}
static guint32
rect_is_empty(const SpiceRect r)
{
return r.top == r.bottom || r.left == r.right;
}
static guint32
dissect_RectList(tvbuff_t *tvb, proto_tree *tree, guint32 offset)
{
proto_tree *rectlist_tree;
guint32 i;
const guint32 rectlist_size = tvb_get_letohl(tvb, offset);
if (tree) {
rectlist_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 + (rectlist_size * sizeof_SpiceRect),
ett_rectlist, NULL, "RectList (%d rects)", rectlist_size);
proto_tree_add_item(rectlist_tree, hf_rectlist_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
for (i = 0; i < rectlist_size; i++ ) {
dissect_SpiceRect(tvb, rectlist_tree, offset, i);
offset += (int)sizeof_SpiceRect;
}
}
return (4 + (rectlist_size * sizeof_SpiceRect));
}
/* returns clip type */
static guint8
dissect_Clip(tvbuff_t *tvb, proto_tree *tree, const guint32 offset)
{
proto_tree *Clip_tree;
const guint8 type = tvb_get_guint8(tvb, offset);
if (tree) {
Clip_tree = proto_tree_add_subtree(tree, tvb, offset, 1, ett_Clip, NULL, "SpiceClip");
proto_tree_add_item(Clip_tree, hf_Clip_type, tvb, offset, sizeof_Clip, ENC_LITTLE_ENDIAN);
}
return type;
}
static proto_item*
dissect_POINT32(tvbuff_t *tvb, proto_tree *tree, const guint32 offset)
{
proto_tree *point_tree;
proto_item *ret_item;
point32_t point;
point.x = tvb_get_letohil(tvb, offset);
point.y = tvb_get_letohil(tvb, offset + 4);
point_tree = proto_tree_add_subtree_format(tree, tvb, offset, sizeof(point32_t), ett_point, &ret_item, "POINT (%d, %d)", point.x, point.y);
proto_tree_add_item(point_tree, hf_point32_x, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(point_tree, hf_point32_y, tvb, offset + 4, 4, ENC_LITTLE_ENDIAN);
return ret_item;
}
static point16_t
dissect_POINT16(tvbuff_t *tvb, proto_tree *tree, const guint32 offset)
{
proto_tree *point16_tree;
point16_t point16;
point16.x = tvb_get_letohis(tvb, offset);
point16.y = tvb_get_letohis(tvb, offset + 2);
if (tree) {
point16_tree = proto_tree_add_subtree_format(tree, tvb, offset, sizeof(point16_t), ett_point16, NULL, "POINT16 (%d, %d)", point16.x, point16.y);
proto_tree_add_item(point16_tree, hf_point16_x, tvb, offset, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(point16_tree, hf_point16_y, tvb, offset + 2, 2, ENC_LITTLE_ENDIAN);
}
return point16;
}
static guint32
dissect_Mask(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, guint32 offset)
{
proto_item *ti, *mask_item, *point_item;
proto_tree *Mask_tree;
guint32 bitmap;
Mask_tree = proto_tree_add_subtree(tree, tvb, offset, sizeof_Mask, ett_Mask, &ti, "Mask");
mask_item = proto_tree_add_item(Mask_tree, hf_Mask_flag, tvb, offset, 1, ENC_NA);
offset += 1;
point_item = dissect_POINT32(tvb, Mask_tree, offset);
offset += (int)sizeof(point32_t);
bitmap = tvb_get_letohl(tvb, offset);
proto_tree_add_item(Mask_tree, hf_ref_image, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
if (bitmap != 0) {
proto_item_set_len(ti, sizeof_Mask + sizeof_ImageDescriptor);
dissect_ImageDescriptor(tvb, Mask_tree, offset);
return sizeof_Mask + sizeof_ImageDescriptor;
}
expert_add_info(pinfo, mask_item, &ei_spice_Mask_flag);
expert_add_info(pinfo, point_item, &ei_spice_Mask_point);
return sizeof_Mask;
}
/* returns brush size */
static guint32
dissect_Brush(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, guint32 offset)
{
proto_tree *brush_tree;
proto_item *ti;
const guint8 type = tvb_get_guint8(tvb, offset);
ti = proto_tree_add_item(tree, hf_brush_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
switch (type) {
case SPICE_BRUSH_TYPE_SOLID:
proto_item_set_len(ti, 5);
brush_tree = proto_item_add_subtree(ti, ett_brush);
offset += 1;
proto_tree_add_item(brush_tree, hf_brush_rgb, tvb, offset, 4, ENC_LITTLE_ENDIAN);
return 5;
case SPICE_BRUSH_TYPE_PATTERN:
proto_item_set_len(ti, 17);
brush_tree = proto_item_add_subtree(ti, ett_brush);
proto_tree_add_item(brush_tree, hf_brush_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* FIXME: this is supposed to be the offset to the image to be used as the pattern. */
/* For now the hack is that callers check if the returned size was not 5 (therefore SOLID, */
/* it's a pattern and later on dissect the image. That's bad. Really. */
proto_tree_add_item(brush_tree, hf_ref_image, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
dissect_POINT32(tvb, brush_tree, offset);
return (1 + 4 + 8);
case SPICE_BRUSH_TYPE_NONE:
return 1;
default:
expert_add_info(pinfo, ti, &ei_spice_brush_type);
return 0;
}
return 0;
}
static guint32
dissect_DisplayBase(tvbuff_t *tvb, proto_tree *tree, guint32 offset)
{
proto_item *ti;
proto_tree *DisplayBase_tree;
SpiceRect rect;
guint8 clip_type;
guint32 clip_size = 0;
DisplayBase_tree = proto_tree_add_subtree(tree, tvb, offset, sizeof_DisplayBase, ett_DisplayBase, &ti, "SpiceMsgDisplayBase");
proto_tree_add_item(DisplayBase_tree, hf_display_surface_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
rect = dissect_SpiceRect(tvb, DisplayBase_tree, offset, -1);
proto_item_append_text(ti, " - SpiceRect box (%u-%u, %u-%u)",rect.left, rect.top, rect.right, rect.bottom);
offset += (int)sizeof_SpiceRect;
clip_type = dissect_Clip(tvb, DisplayBase_tree, offset);
offset += (int)sizeof_Clip;
if (clip_type == SPICE_CLIP_TYPE_RECTS) {
clip_size = dissect_RectList(tvb, DisplayBase_tree, offset);
proto_item_set_len(ti, sizeof_DisplayBase + clip_size);
return sizeof_DisplayBase + clip_size;
}
return sizeof_DisplayBase;
}
#define sizeof_ResourceId 9
static guint32
dissect_SpiceResourceId(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint16 count)
{
proto_tree *resource_tree;
resource_tree = proto_tree_add_subtree_format(tree, tvb, offset, sizeof_ResourceId,
ett_cursor_header, NULL, "Resource #%d", count);
proto_tree_add_item(resource_tree, hf_resource_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
proto_tree_add_item(resource_tree, hf_resource_id, tvb, offset, 8, ENC_LITTLE_ENDIAN);
return sizeof_ResourceId;
}
static const gchar* get_message_type_string(const guint16 message_type, const spice_conversation_t *spice_info,
const gboolean client_message)
{
if (message_type < SPICE_FIRST_AVAIL_MESSAGE) { /* this is a common message */
if (client_message) {
return val_to_str_const(message_type, spice_msgc_vs, "Unknown client message");
} else {
return val_to_str_const(message_type, spice_msg_vs, "Unknown server message");
}
}
switch (spice_info->channel_type) {
case SPICE_CHANNEL_MAIN:
if (client_message) {
return val_to_str_const(message_type, spice_msgc_main_vs, "Unknown main channel client message");
} else {
return val_to_str_const(message_type, spice_msg_main_vs, "Unknown main channel server message");
}
break;
case SPICE_CHANNEL_DISPLAY:
if (client_message) {
return val_to_str_const(message_type, spice_msgc_display_vs, "Unknown display channel client message");
} else {
return val_to_str_const(message_type, spice_msg_display_vs, "Unknown display channel server message");
}
break;
case SPICE_CHANNEL_INPUTS:
if (client_message) {
return val_to_str_const(message_type, spice_msgc_inputs_vs, "Unknown inputs channel client message");
} else {
return val_to_str_const(message_type, spice_msg_inputs_vs, "Unknown inputs channel server message");
}
break;
case SPICE_CHANNEL_CURSOR:
if (client_message) {
return val_to_str_const(message_type, NULL, "Unknown cursor channel client message");
} else {
return val_to_str_const(message_type, spice_msg_cursor_vs, "Unknown cursor channel server message");
}
break;
case SPICE_CHANNEL_PLAYBACK:
return val_to_str_const(message_type, spice_msg_playback_vs, "Unknown playback channel server message");
break;
case SPICE_CHANNEL_RECORD:
if (client_message) {
return val_to_str_const(message_type, spice_msgc_record_vs, "Unknown record channel client message");
} else {
return val_to_str_const(message_type, spice_msg_record_vs, "Unknown record channel server message");
}
break;
case SPICE_CHANNEL_TUNNEL:
if (client_message) {
return val_to_str_const(message_type, spice_msgc_tunnel_vs, "Unknown tunnel channel client message");
} else {
return val_to_str_const(message_type, spice_msg_tunnel_vs, "Unknown tunnel channel server message");
}
break;
case SPICE_CHANNEL_SMARTCARD:
if (client_message) {
return val_to_str_const(message_type, spice_msgc_smartcard_vs, "Unknown smartcard channel client message");
} else {
return val_to_str_const(message_type, spice_msg_smartcard_vs, "Unknown smartcard channel server message");
}
break;
case SPICE_CHANNEL_USBREDIR:
if (client_message) {
const value_string *values = NULL;
if (message_type < SPICE_MSG_END_SPICEVMC)
values = spice_msg_spicevmc_vs;
return val_to_str_const(message_type, values, "Unknown usbredir channel client message");
} else {
const value_string *values = NULL;
if (message_type < SPICE_MSGC_END_SPICEVMC)
values = spice_msgc_spicevmc_vs;
return val_to_str_const(message_type, values, "Unknown usbredir channel server message");
}
break;
default:
break;
}
return "Unknown message";
}
static void
dissect_spice_mini_data_header(tvbuff_t *tvb, proto_tree *tree, const spice_conversation_t *spice_info,
const gboolean client_message, const guint16 message_type, guint32 offset)
{
proto_tree* subtree;
if (tree) {
subtree = proto_tree_add_subtree_format(tree, tvb, offset, 2, ett_common_client_message, NULL,
"Message type: %s (%d)", get_message_type_string(message_type, spice_info, client_message), message_type);
proto_tree_add_item(subtree, hf_message_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_data_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
}
}
static void
dissect_spice_data_header(tvbuff_t *tvb, proto_tree *tree, const spice_conversation_t *spice_info,
const gboolean client_message, const guint16 message_type, proto_item** msgtype_item, guint32 *sublist_size, guint32 offset)
{
proto_tree* subtree;
*sublist_size = tvb_get_letohl(tvb, offset + 14);
if (tree) {
proto_tree_add_item(tree, hf_serial, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
subtree = proto_tree_add_subtree_format(tree, tvb, offset, 2, ett_common_client_message, NULL,
"Message type: %s (%d)", get_message_type_string(message_type, spice_info, client_message), message_type);
*msgtype_item = proto_tree_add_item(subtree, hf_message_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_data_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_data_sublist, tvb, offset, 4, ENC_LITTLE_ENDIAN);
}
}
static guint32
dissect_spice_common_client_messages(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const guint16 message_type, proto_item* msgtype_item, guint32 offset)
{
switch (message_type) {
case SPICE_MSGC_ACK_SYNC:
proto_tree_add_item(tree, hf_red_set_ack_generation, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case SPICE_MSGC_ACK:
break;
case SPICE_MSGC_PONG:
proto_tree_add_item(tree, hf_red_ping_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_red_timestamp, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
break;
/*
case SPICE_MSGC_MIGRATE_FLUSH_MARK:
case SPICE_MSGC_MIGRATE_DATA:
case SPICE_MSGC_DISCONNECTING:
*/
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown common client message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_common_server_messages(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const guint16 message_type, proto_item* msgtype_item,
guint32 offset, const guint32 total_message_size)
{
guint32 message_len;
switch (message_type) {
/*
case SPICE_MSG_MIGRATE:
case SPICE_MSG_MIGRATE_DATA:
case SPICE_MSG_WAIT_FOR_CHANNELS:
case SPICE_MSG_DISCONNECTING:
*/
case SPICE_MSG_SET_ACK:
proto_tree_add_item(tree, hf_red_set_ack_generation, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_red_set_ack_window, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case SPICE_MSG_PING:
proto_tree_add_item(tree, hf_red_ping_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_red_timestamp, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
if (total_message_size > 12) {
proto_tree_add_bytes_format(tree, hf_spice_ping_data, tvb, offset, total_message_size - 12,
NULL, "PING DATA (%d bytes)", total_message_size - 12);
offset += (total_message_size - 12);
}
break;
case SPICE_MSG_NOTIFY:
proto_tree_add_item(tree, hf_red_timestamp, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(tree, hf_severity, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_visibility, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/*TODO: based on severity, dissect the error code */
proto_tree_add_item(tree, hf_notify_code, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
message_len = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_notify_message_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_notify_message, tvb, offset, message_len + 1, ENC_ASCII);
offset += (message_len + 1);
break;
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown common server message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_record_client(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const guint16 message_type, proto_item* msgtype_item, guint32 offset)
{
proto_tree *record_tree;
switch (message_type) {
case SPICE_MSGC_RECORD_MODE:
record_tree = proto_tree_add_subtree(tree, tvb, offset, 8, ett_record_client, NULL, "Client RECORD_MODE message"); /* size is incorrect, fixed later */
proto_tree_add_item(record_tree, hf_audio_timestamp, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(record_tree, hf_audio_mode, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* TODO - mode dependent, there may be more data here */
break;
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown record client message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_display_client(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const guint16 message_type, proto_item* msgtype_item, guint32 offset)
{
switch (message_type) {
case SPICE_MSGC_DISPLAY_INIT:
proto_tree_add_item(tree, hf_spice_display_init_cache_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(tree, hf_spice_display_init_cache_size, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(tree, hf_spice_display_init_glz_dict_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(tree, hf_spice_display_init_dict_window_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown display client message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_display_server(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, const guint16 message_type, proto_item* msgtype_item, guint32 offset)
{
guint32 data_size, displayBaseLen;
guint8 clip_type;
guint16 count, i;
SpiceRect r;
tvbuff_t *jpeg_tvb;
switch (message_type) {
case SPICE_MSG_DISPLAY_MODE:
proto_tree_add_item(tree, hf_spice_display_mode_width, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_spice_display_mode_height, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_spice_display_mode_depth, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case SPICE_MSG_DISPLAY_MARK:
proto_tree_add_item(tree, hf_spice_display_mark_message, tvb, offset, 0, ENC_NA);
break;
case SPICE_MSG_DISPLAY_RESET:
proto_tree_add_item(tree, hf_spice_display_reset_message, tvb, offset, 0, ENC_NA);
break;
case SPICE_MSG_DISPLAY_INVAL_LIST:
proto_tree_add_item(tree, hf_display_inval_list_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
count = tvb_get_letohs(tvb, offset);
offset += 2;
for (i = 0; i < count; i++) {
offset += dissect_SpiceResourceId(tvb, tree, offset, i + 1);
}
break;
case SPICE_MSG_DISPLAY_DRAW_ALPHA_BLEND:
displayBaseLen = dissect_DisplayBase(tvb, tree, offset);
offset += displayBaseLen;
/* TODO: Flag 1 byte, Alpha 1 byte dissection*/
offset += 2;
proto_tree_add_item(tree, hf_ref_image, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
dissect_SpiceRect(tvb, tree, offset, -1);
offset += (int)sizeof_SpiceRect;
data_size = dissect_Image(tvb, tree, pinfo, offset);
offset += data_size;
break;
case SPICE_MSG_DISPLAY_DRAW_BLACKNESS:
displayBaseLen = dissect_DisplayBase(tvb, tree, offset);
offset += displayBaseLen;
offset += dissect_Mask(tvb, pinfo, tree, offset);
break;
case SPICE_MSG_DISPLAY_COPY_BITS:
displayBaseLen = dissect_DisplayBase(tvb, tree, offset);
offset += displayBaseLen;
dissect_POINT32(tvb, tree, offset);
offset += (int)sizeof(point32_t);
break;
case SPICE_MSG_DISPLAY_DRAW_WHITENESS:
displayBaseLen = dissect_DisplayBase(tvb, tree, offset);
offset += displayBaseLen;
offset += dissect_Mask(tvb, pinfo, tree, offset);
break;
case SPICE_MSG_DISPLAY_DRAW_INVERS:
displayBaseLen = dissect_DisplayBase(tvb, tree, offset);
offset += displayBaseLen;
offset += dissect_Mask(tvb, pinfo, tree, offset);
break;
case SPICE_MSG_DISPLAY_DRAW_FILL:
displayBaseLen = dissect_DisplayBase(tvb, tree, offset);
offset += displayBaseLen;
data_size = dissect_Brush(tvb, pinfo, tree, offset);
offset += data_size;
proto_tree_add_item(tree, hf_display_rop_descriptor, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
offset += dissect_Mask(tvb, pinfo, tree, offset);
if (data_size != 5) { /* if it's not a SOLID brush, it's a PATTERN, dissect its image descriptor */
offset += dissect_Image(tvb, tree, pinfo, offset);
}
break;
case SPICE_MSG_DISPLAY_DRAW_TRANSPARENT:
displayBaseLen = dissect_DisplayBase(tvb, tree, offset);
offset += displayBaseLen;
proto_tree_add_item(tree, hf_ref_image, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* source area */
dissect_SpiceRect(tvb, tree, offset, -1);
offset += (int)sizeof_SpiceRect;
proto_tree_add_item(tree, hf_tranparent_src_color, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_tranparent_true_color, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
data_size = dissect_Image(tvb, tree, pinfo, offset);
offset += data_size;
break;
case SPICE_MSG_DISPLAY_DRAW_BLEND:
case SPICE_MSG_DISPLAY_DRAW_COPY:
displayBaseLen = dissect_DisplayBase(tvb, tree, offset);
offset += displayBaseLen;
/* SpiceImage *src_bitmap */
proto_tree_add_item(tree, hf_ref_image, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* source area */
dissect_SpiceRect(tvb, tree, offset, -1);
offset += (int)sizeof_SpiceRect;
proto_tree_add_item(tree, hf_display_rop_descriptor, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_display_scale_mode, tvb, offset, 1, ENC_NA);
offset += 1;
offset += dissect_Mask(tvb, pinfo, tree, offset);
data_size = dissect_Image(tvb, tree, pinfo, offset);
offset += data_size;
break;
case SPICE_MSG_DISPLAY_DRAW_ROP3:
displayBaseLen = dissect_DisplayBase(tvb, tree, offset);
offset += displayBaseLen;
/* SpiceImage *src_bitmap */
proto_tree_add_item(tree, hf_ref_image, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* source area */
dissect_SpiceRect(tvb, tree, offset, -1);
offset += (int)sizeof_SpiceRect;
data_size = dissect_Brush(tvb, pinfo, tree, offset);
offset += data_size;
proto_tree_add_item(tree, hf_spice_rop3, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_spice_scale_mode, tvb, offset, 1, ENC_NA);
offset += 1;
offset += dissect_Mask(tvb, pinfo, tree, offset);
/*FIXME - need to understand what the rest of the message contains. */
data_size = dissect_Image(tvb, tree, pinfo, offset);
offset += data_size;
break;
case SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES:
break;
case SPICE_MSG_DISPLAY_DRAW_TEXT:
displayBaseLen = dissect_DisplayBase(tvb, tree, offset);
offset += displayBaseLen;
proto_tree_add_item(tree, hf_ref_string, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
r = dissect_SpiceRect(tvb, tree, offset, -1);
offset += (int)sizeof_SpiceRect;
if (!rect_is_empty(r)) {
data_size = dissect_Brush(tvb, pinfo, tree, offset);
offset += data_size;
}
proto_tree_add_item(tree, hf_display_text_fore_mode, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_display_text_back_mode, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_num_glyphs, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_spice_glyph_flags, tvb, offset, 2, ENC_BIG_ENDIAN);
/*TODO finish dissecting glyph list */
break;
case SPICE_MSG_DISPLAY_DRAW_STROKE:
displayBaseLen = dissect_DisplayBase(tvb, tree, offset);
offset += displayBaseLen;
/*TODO: complete and correct dissection */
break;
case SPICE_MSG_DISPLAY_STREAM_CLIP:
proto_tree_add_item(tree, hf_display_stream_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
clip_type = dissect_Clip(tvb, tree, offset);
offset += (int)sizeof_Clip;
if (clip_type == SPICE_CLIP_TYPE_RECTS) {
offset += dissect_RectList(tvb, tree, offset);
}
break;
case SPICE_MSG_DISPLAY_STREAM_CREATE:
proto_tree_add_item(tree, hf_display_surface_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_display_stream_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_display_stream_flags, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(tree, hf_display_stream_codec_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(tree, hf_display_stream_stamp, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(tree, hf_display_stream_width, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_display_stream_height, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_display_stream_src_width, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_display_stream_src_height, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
dissect_SpiceRect(tvb, tree, offset, -1);
offset += (int)sizeof_SpiceRect;
clip_type = dissect_Clip(tvb, tree, offset);
offset += (int)sizeof_Clip;
if (clip_type == SPICE_CLIP_TYPE_RECTS) {
offset += dissect_RectList(tvb, tree, offset);
}
break;
case SPICE_MSG_DISPLAY_STREAM_DATA:
data_size = tvb_get_letohl(tvb, offset + 8);
proto_tree_add_item(tree, hf_display_stream_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_multi_media_time, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_display_stream_data_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_bytes_format(tree, hf_spice_stream_data, tvb, offset, data_size, NULL, "Stream data");
jpeg_tvb = tvb_new_subset_length(tvb, offset, data_size);
call_dissector(jpeg_handle, jpeg_tvb, pinfo, tree);
offset += data_size;
break;
case SPICE_MSG_DISPLAY_STREAM_DESTROY:
proto_tree_add_item(tree, hf_display_stream_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case SPICE_MSG_DISPLAY_STREAM_DATA_SIZED:
proto_tree_add_item(tree, hf_display_stream_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_multi_media_time, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_display_stream_width, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_display_stream_height, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
dissect_SpiceRect(tvb, tree, offset, -1);
offset += (int)sizeof_SpiceRect;
proto_tree_add_item(tree, hf_display_stream_data_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL:
break;
case SPICE_MSG_DISPLAY_SURFACE_CREATE:
proto_tree_add_item(tree, hf_display_surface_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_display_surface_width, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_display_surface_height, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_display_surface_format, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_display_surface_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case SPICE_MSG_DISPLAY_SURFACE_DESTROY:
proto_tree_add_item(tree, hf_display_surface_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case SPICE_MSG_DISPLAY_MONITORS_CONFIG:
proto_tree_add_item(tree, hf_display_monitor_config_count, tvb, offset, 2, ENC_LITTLE_ENDIAN);
count = tvb_get_letohs(tvb, offset);
offset += 2;
proto_tree_add_item(tree, hf_display_monitor_config_max_allowed, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
for (i = 0; i < count; i++) {
offset = dissect_SpiceHead(tvb, tree, offset, i);
}
break;
case SPICE_MSG_DISPLAY_DRAW_COMPOSITE:
break;
case SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT:
proto_tree_add_item(tree, hf_display_stream_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_display_stream_report_unique_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_display_stream_report_max_window_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_display_stream_report_timeout, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown display server message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_playback_server(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const guint16 message_type, proto_item* msgtype_item,
guint32 message_size, spice_conversation_t *spice_info, guint32 offset)
{
guint8 num_channels, i;
proto_tree* subtree;
switch (message_type) {
case SPICE_MSG_PLAYBACK_DATA:
proto_tree_add_item(tree, hf_audio_timestamp, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_raw_data, tvb, offset, message_size - 4, ENC_NA);
offset += (message_size - 4);
break;
case SPICE_MSG_PLAYBACK_MODE:
proto_tree_add_item(tree, hf_audio_timestamp, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
spice_info->playback_mode = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_audio_mode, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* TODO - mode dependent, there may be more data here */
break;
case SPICE_MSG_PLAYBACK_START:
proto_tree_add_item(tree, hf_audio_channels, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_audio_format, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_audio_frequency, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_audio_timestamp, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case SPICE_MSG_PLAYBACK_STOP:
break;
case SPICE_MSG_PLAYBACK_VOLUME:
num_channels = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_audio_channels, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
subtree = proto_tree_add_subtree(tree, tvb, offset, 2 * num_channels, ett_record_server, NULL, "Channel volume array");
for (i = 0; i < num_channels; i++) {
proto_tree_add_item(subtree, hf_audio_volume, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
}
break;
case SPICE_MSG_PLAYBACK_MUTE:
proto_tree_add_item(tree, hf_audio_mute, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
break;
case SPICE_MSG_PLAYBACK_LATENCY:
proto_tree_add_item(tree, hf_audio_latency, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown playback server message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_cursor_server(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const guint16 message_type, proto_item* msgtype_item, guint32 offset)
{
guint32 RedCursorSize;
switch (message_type) {
case SPICE_MSG_CURSOR_INIT:
dissect_POINT16(tvb, tree, offset);
offset += (int)sizeof(point16_t);
proto_tree_add_item(tree, hf_cursor_trail_len, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_cursor_trail_freq, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_cursor_trail_visible, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
RedCursorSize = dissect_RedCursor(tvb, tree, offset);
offset += RedCursorSize;
break;
case SPICE_MSG_CURSOR_RESET:
break;
case SPICE_MSG_CURSOR_SET:
dissect_POINT16(tvb, tree, offset);
offset += (int)sizeof(point16_t);
offset +=1; /*TODO flags */
RedCursorSize = dissect_RedCursor(tvb, tree, offset);
offset += RedCursorSize;
break;
case SPICE_MSG_CURSOR_MOVE:
dissect_POINT16(tvb, tree, offset);
offset += (int)sizeof(point16_t);
break;
case SPICE_MSG_CURSOR_HIDE:
break;
case SPICE_MSG_CURSOR_TRAIL:
proto_tree_add_item(tree, hf_cursor_trail_len, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_cursor_trail_freq, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
break;
case SPICE_MSG_CURSOR_INVAL_ONE:
proto_tree_add_item(tree, hf_cursor_id, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
break;
case SPICE_MSG_CURSOR_INVAL_ALL:
break;
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown cursor server message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_record_server(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const guint16 message_type, proto_item* msgtype_item, guint32 offset)
{
guint8 num_channels, i;
proto_tree* subtree;
switch (message_type) {
case SPICE_MSG_RECORD_STOP:
break;
case SPICE_MSG_RECORD_VOLUME:
num_channels = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_audio_channels, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
subtree = proto_tree_add_subtree(tree, tvb, offset, 2 * num_channels, ett_record_server, NULL, "Volume Array");
for (i = 0; i < num_channels; i++) {
proto_tree_add_item(subtree, hf_audio_volume, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
}
break;
case SPICE_MSG_RECORD_MUTE:
proto_tree_add_item(tree, hf_audio_mute, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
break;
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown record server message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_agent_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const guint32 message_type, proto_item* msgtype_item, guint32 message_len, guint32 offset)
{
proto_tree *agent_tree;
guint32 n_monitors = 0, i;
switch (message_type) {
case VD_AGENT_MOUSE_STATE:
dissect_POINT32(tvb, tree, offset);
offset += (int)sizeof(point32_t);
proto_tree_add_item(tree, hf_button_state, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_mouse_display_id, tvb, offset, 1, ENC_NA);
offset += 1;
break;
case VD_AGENT_MONITORS_CONFIG:
n_monitors = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_agent_num_monitors, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_vd_agent_monitors_config_flag_use_pos, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
for (i = 0; i < n_monitors; i++) {
offset = dissect_AgentMonitorConfig(tvb, tree, offset, i);
}
break;
case VD_AGENT_REPLY:
proto_tree_add_item(tree, hf_vd_agent_reply_type, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_vd_agent_reply_error, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case VD_AGENT_CLIPBOARD:
/*ti = */proto_tree_add_item(tree, hf_spice_vd_agent_clipboard_message, tvb, offset, message_len, ENC_NA);
/* TODO: display string
agent_tree = proto_item_add_subtree(ti, ett_spice_agent);
*/
offset += message_len;
break;
case VD_AGENT_DISPLAY_CONFIG:
proto_tree_add_item(tree, hf_spice_vd_agent_display_config_message, tvb, offset, 4, ENC_NA);
offset += 4;
break;
case VD_AGENT_ANNOUNCE_CAPABILITIES:
proto_tree_add_item(tree, hf_vd_agent_caps_request, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_vd_agent_cap_mouse_state, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_vd_agent_cap_monitors_config, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_vd_agent_cap_reply, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_vd_agent_cap_clipboard, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_vd_agent_cap_display_config, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_vd_agent_cap_clipboard_by_demand, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_vd_agent_cap_clipboard_selection, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_vd_agent_cap_sparse_monitors_config, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_vd_agent_cap_guest_lineend_lf, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_vd_agent_cap_guest_lineend_crlf, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case VD_AGENT_CLIPBOARD_GRAB:
agent_tree = proto_tree_add_subtree(tree, tvb, offset, 4, ett_spice_agent, NULL, "VD_AGENT_CLIPBOARD_GRAB message");
proto_tree_add_item(agent_tree, hf_agent_clipboard_selection, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(agent_tree, hf_spice_reserved, tvb, offset, 3, ENC_NA);
offset += 3;
break;
case VD_AGENT_CLIPBOARD_REQUEST:
agent_tree = proto_tree_add_subtree(tree, tvb, offset, 8, ett_spice_agent, NULL, "VD_AGENT_CLIPBOARD_REQUEST message");
proto_tree_add_item(agent_tree, hf_agent_clipboard_selection, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(agent_tree, hf_spice_reserved, tvb, offset, 3, ENC_NA);
offset += 3;
proto_tree_add_item(agent_tree, hf_agent_clipboard_type, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case VD_AGENT_CLIPBOARD_RELEASE:
proto_tree_add_item(tree, hf_spice_vd_agent_clipboard_release_message, tvb, offset, 0, ENC_NA);
break;
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown agent message (%u) - cannot dissect", message_type);
break;
}
return offset;
}
/* note that the size property is necessary here because the protocol uses
* uint32 in the INIT message, and flags16 in the MOUSE_MODE message
*/
static guint32
dissect_supported_mouse_modes(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint32 size)
{
proto_item* ti;
proto_tree *sub_tree;
int hf = hf_supported_mouse_modes;
if (size == 2)
hf = hf_supported_mouse_modes_flags;
ti = proto_tree_add_item(tree, hf, tvb, offset, size, ENC_LITTLE_ENDIAN);
sub_tree = proto_item_add_subtree(ti, ett_main_client);
proto_tree_add_item(sub_tree, hf_supported_mouse_modes_flag_client, tvb, offset, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(sub_tree, hf_supported_mouse_modes_flag_server, tvb, offset, 2, ENC_LITTLE_ENDIAN);
return offset + size;
}
static guint32
dissect_spice_main_server(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const guint16 message_type, proto_item* msgtype_item, guint32 offset)
{
guint32 num_channels, i, agent_msg_type, agent_msg_len, name_len, data_size;
proto_tree *subtree = NULL;
switch (message_type) {
case SPICE_MSG_MAIN_MIGRATE_BEGIN:
case SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST:
case SPICE_MSG_MAIN_MIGRATE_BEGIN_SEAMLESS:
proto_tree_add_item(tree, hf_migrate_dest_port, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_migrate_dest_sport, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
data_size = tvb_get_letohl(tvb, offset);
offset += 4;
proto_tree_add_item(tree, hf_raw_data, tvb, offset, data_size, ENC_NA);
offset += data_size;
data_size = tvb_get_letohl(tvb, offset);
offset += 4;
proto_tree_add_item(tree, hf_raw_data, tvb, offset, data_size, ENC_NA);
offset += data_size;
if (message_type == SPICE_MSG_MAIN_MIGRATE_BEGIN_SEAMLESS) {
proto_tree_add_item(tree, hf_migrate_src_mig_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
break;
case SPICE_MSG_MAIN_MIGRATE_CANCEL:
break;
case SPICE_MSG_MAIN_INIT:
proto_tree_add_item(tree, hf_session_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_display_channels_hint, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
dissect_supported_mouse_modes(tvb, tree, offset, 4);
offset += 4;
proto_tree_add_item(tree, hf_current_mouse_mode, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_agent_connected, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_agent_tokens, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_multi_media_time, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_ram_hint, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case SPICE_MSG_MAIN_CHANNELS_LIST:
num_channels = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_main_num_channels, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
subtree = proto_tree_add_subtree(tree, tvb, offset, 2 * num_channels, ett_main_client, NULL, "Channel Array");
for (i = 0; i < num_channels; i++ ) {
proto_tree *subsubtree;
subsubtree = proto_tree_add_subtree_format(subtree, tvb, offset, 2, ett_main_client, NULL, "channels[%u]: %s", i,
val_to_str_const(tvb_get_guint8(tvb, offset), channel_types_vs, "Unknown"));
proto_tree_add_item(subsubtree, hf_channel_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(subsubtree, hf_channel_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
}
break;
case SPICE_MSG_MAIN_MOUSE_MODE:
dissect_supported_mouse_modes(tvb, tree, offset, 2);
offset += 2;
proto_tree_add_item(tree, hf_current_mouse_mode_flags, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
break;
case SPICE_MSG_MAIN_MULTI_MEDIA_TIME:
proto_tree_add_item(tree, hf_multi_media_time, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case SPICE_MSG_MAIN_AGENT_DISCONNECTED:
proto_tree_add_item(tree, hf_error_code, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case SPICE_MSG_MAIN_AGENT_DATA:
proto_tree_add_item(tree, hf_agent_protocol, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_agent_type, tvb, offset, 4, ENC_LITTLE_ENDIAN);
agent_msg_type = tvb_get_letohl(tvb, offset);
offset += 4;
proto_tree_add_item(tree, hf_agent_opaque, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(tree, hf_agent_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
agent_msg_len = tvb_get_letohl(tvb, offset);
offset += 4;
offset = dissect_spice_agent_message(tvb, pinfo, tree, agent_msg_type, msgtype_item, agent_msg_len, offset);
break;
case SPICE_MSG_MAIN_AGENT_TOKEN:
case SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS:
proto_tree_add_item(tree, hf_agent_token, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case SPICE_MSG_MAIN_NAME:
name_len = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_main_name_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_main_name, tvb, offset, name_len, ENC_ASCII);
offset += name_len;
break;
case SPICE_MSG_MAIN_UUID:
proto_tree_add_item(tree, hf_main_uuid, tvb, offset, 16, ENC_BIG_ENDIAN);
offset += 16;
break;
case SPICE_MSG_MAIN_MIGRATE_END:
break;
case SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_ACK:
break;
case SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_NACK:
break;
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown main server message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_main_client(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const guint16 message_type, proto_item* msgtype_item, guint32 offset)
{
proto_tree *main_tree;
guint32 agent_msg_type, agent_msg_len;
switch (message_type) {
case SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST:
proto_tree_add_item(tree, hf_current_mouse_mode_flags, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
break;
case SPICE_MSGC_MAIN_ATTACH_CHANNELS:
break;
case SPICE_MSGC_MAIN_AGENT_START:
main_tree = proto_tree_add_subtree(tree, tvb, offset, 4, ett_main_client, NULL, "Client AGENT_START message");
proto_tree_add_item(main_tree, hf_main_client_agent_tokens, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case SPICE_MSGC_MAIN_AGENT_DATA:
main_tree = proto_tree_add_subtree(tree, tvb, offset, 24, ett_main_client, NULL, "Client AGENT_DATA message");
proto_tree_add_item(main_tree, hf_agent_protocol, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(main_tree, hf_agent_type, tvb, offset, 4, ENC_LITTLE_ENDIAN);
agent_msg_type = tvb_get_letohl(tvb, offset);
offset += 4;
proto_tree_add_item(main_tree, hf_agent_opaque, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item(main_tree, hf_agent_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
agent_msg_len = tvb_get_letohl(tvb, offset);
offset += 4;
offset = dissect_spice_agent_message(tvb, pinfo, main_tree, agent_msg_type, msgtype_item, agent_msg_len, offset);
break;
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown main client message - cannot dissect");
break;
}
return offset;
}
static int
dissect_spice_keyboard_modifiers(tvbuff_t *tvb, proto_tree *tree, guint32 offset)
{
proto_item *ti;
proto_tree *subtree;
ti = proto_tree_add_item(tree, hf_keyboard_modifiers, tvb, offset, 2, ENC_LITTLE_ENDIAN);
subtree = proto_item_add_subtree(ti, ett_link_caps);
proto_tree_add_item(subtree, hf_keyboard_modifier_scroll_lock, tvb, offset, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(subtree, hf_keyboard_modifier_num_lock, tvb, offset, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(subtree, hf_keyboard_modifier_caps_lock, tvb, offset, 2, ENC_LITTLE_ENDIAN);
return 2;
}
static guint32
dissect_spice_inputs_client(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const guint16 message_type, proto_item* msgtype_item, guint32 offset)
{
proto_tree *inputs_tree;
switch (message_type) {
case SPICE_MSGC_INPUTS_KEY_DOWN:
inputs_tree = proto_tree_add_subtree(tree, tvb, offset, 4, ett_inputs_client, NULL, "Client KEY_DOWN message");
proto_tree_add_item(inputs_tree, hf_keyboard_code, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case SPICE_MSGC_INPUTS_KEY_UP:
inputs_tree = proto_tree_add_subtree(tree, tvb, offset, 4, ett_inputs_client, NULL, "Client KEY_UP message");
proto_tree_add_item(inputs_tree, hf_keyboard_code, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
break;
case SPICE_MSGC_INPUTS_KEY_MODIFIERS:
offset += dissect_spice_keyboard_modifiers(tvb, tree, offset);
break;
case SPICE_MSGC_INPUTS_MOUSE_POSITION:
inputs_tree = proto_tree_add_subtree(tree, tvb, offset, sizeof(point32_t) + 3, ett_inputs_client, NULL, "Client MOUSE_POSITION message");
dissect_POINT32(tvb, inputs_tree, offset);
offset += (int)sizeof(point32_t);
proto_tree_add_item(inputs_tree, hf_button_state, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(inputs_tree, hf_mouse_display_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
break;
case SPICE_MSGC_INPUTS_MOUSE_MOTION:
inputs_tree = proto_tree_add_subtree(tree, tvb, offset, sizeof(point32_t) + 2, ett_inputs_client, NULL, "Client MOUSE_MOTION message");
dissect_POINT32(tvb, inputs_tree, offset);
offset += (int)sizeof(point32_t);
proto_tree_add_item(inputs_tree, hf_button_state, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
break;
case SPICE_MSGC_INPUTS_MOUSE_PRESS:
inputs_tree = proto_tree_add_subtree(tree, tvb, offset, 3, ett_inputs_client, NULL, "Client MOUSE_PRESS message");
proto_tree_add_item(inputs_tree, hf_button_state, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(inputs_tree, hf_mouse_display_id, tvb, offset, 1, ENC_NA);
offset += 1;
break;
case SPICE_MSGC_INPUTS_MOUSE_RELEASE:
inputs_tree = proto_tree_add_subtree(tree, tvb, offset, 3, ett_inputs_client, NULL, "Client MOUSE_RELEASE message");
proto_tree_add_item(inputs_tree, hf_button_state, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(inputs_tree, hf_mouse_display_id, tvb, offset, 1, ENC_NA);
offset += 1;
break;
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown inputs client message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_inputs_server(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const guint16 message_type, proto_item* msgtype_item, guint32 offset)
{
switch (message_type) {
case SPICE_MSG_INPUTS_INIT:
offset += dissect_spice_keyboard_modifiers(tvb, tree, offset);
break;
case SPICE_MSG_INPUTS_KEY_MODIFIERS:
offset += dissect_spice_keyboard_modifiers(tvb, tree, offset);
break;
case SPICE_MSG_INPUTS_MOUSE_MOTION_ACK:
proto_tree_add_item(tree, hf_spice_server_inputs_mouse_motion_ack_message, tvb, offset, 0, ENC_NA);
break;
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown inputs server message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_tunnel_client(packet_info *pinfo, const guint16 message_type, proto_item* msgtype_item, guint32 offset)
{
/* TODO: Not implemented yet */
switch (message_type) {
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_tunnel_server(packet_info *pinfo, const guint16 message_type, proto_item* msgtype_item, guint32 offset)
{
/* TODO: Not implemented yet */
switch (message_type) {
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_smartcard_client(packet_info *pinfo, const guint16 message_type, proto_item* msgtype_item, guint32 offset)
{
/* TODO: Not implemented yet */
switch (message_type) {
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_smartcard_server(packet_info *pinfo, const guint16 message_type, proto_item* msgtype_item, guint32 offset)
{
/* TODO: Not implemented yet */
switch (message_type) {
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_usbredir_client(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const guint16 message_type, proto_item* msgtype_item, guint32 message_size, guint32 offset)
{
switch (message_type) {
case SPICE_MSGC_SPICEVMC_DATA:
proto_tree_add_item(tree, hf_raw_data, tvb, offset, message_size, ENC_NA);
offset += message_size;
break;
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_usbredir_server(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const guint16 message_type, proto_item* msgtype_item, guint32 message_size, guint32 offset)
{
switch (message_type) {
case SPICE_MSG_SPICEVMC_DATA:
proto_tree_add_item(tree, hf_raw_data, tvb, offset, message_size, ENC_NA);
offset += message_size;
break;
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_port_client(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const guint16 message_type, proto_item* msgtype_item, guint32 message_size, guint32 offset)
{
switch (message_type) {
case SPICE_MSGC_SPICEVMC_DATA:
proto_tree_add_item(tree, hf_raw_data, tvb, offset, message_size, ENC_NA);
offset += message_size;
break;
case SPICE_MSGC_PORT_EVENT:
proto_tree_add_item(tree, hf_port_event, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
break;
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_port_server(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const guint16 message_type, proto_item* msgtype_item, guint32 message_size, guint32 offset)
{
switch (message_type) {
case SPICE_MSG_SPICEVMC_DATA:
proto_tree_add_item(tree, hf_raw_data, tvb, offset, message_size, ENC_NA);
offset += message_size;
break;
case SPICE_MSG_PORT_INIT:
{
guint32 size = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_spice_name_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_main_name, tvb, offset, size, ENC_ASCII);
offset += size;
proto_tree_add_item(tree, hf_port_opened, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
}
break;
case SPICE_MSG_PORT_EVENT:
proto_tree_add_item(tree, hf_port_event, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
break;
default:
expert_add_info_format(pinfo, msgtype_item, &ei_spice_unknown_message, "Unknown message - cannot dissect");
break;
}
return offset;
}
static guint32
dissect_spice_data_server_pdu(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, spice_conversation_t *spice_info, guint32 offset, const guint32 total_message_size)
{
proto_item *ti = NULL, *msg_ti=NULL, *msgtype_ti=NULL;
proto_tree *data_header_tree, *message_tree;
guint16 message_type;
guint32 message_size, sublist_size, old_offset;
guint32 header_size;
if (spice_info->client_mini_header && spice_info->server_mini_header) {
header_size = sizeof_SpiceMiniDataHeader;
message_type = tvb_get_letohs(tvb, offset);
message_size = tvb_get_letohl(tvb, offset +2);
message_tree = proto_tree_add_subtree_format(tree, tvb, offset, 0,
ett_message, &msg_ti, "%s (%d bytes)",
get_message_type_string(message_type, spice_info, FALSE),
message_size + header_size);
ti = proto_tree_add_item(message_tree, hf_data, tvb, offset, header_size, ENC_NA);
data_header_tree = proto_item_add_subtree(ti, ett_data);
dissect_spice_mini_data_header(tvb, data_header_tree, spice_info, FALSE, message_type, offset);
proto_item_set_len(msg_ti, message_size + header_size);
} else {
header_size = sizeof_SpiceDataHeader;
message_type = tvb_get_letohs(tvb, offset + 8);
message_size = tvb_get_letohl(tvb, offset + 10);
message_tree = proto_tree_add_subtree_format(tree, tvb, offset, 0,
ett_message, &msg_ti, "%s (%d bytes)",
get_message_type_string(message_type, spice_info, FALSE),
message_size + header_size);
ti = proto_tree_add_item(message_tree, hf_data, tvb, offset, header_size, ENC_NA);
data_header_tree = proto_item_add_subtree(ti, ett_data);
dissect_spice_data_header(tvb, data_header_tree, spice_info, FALSE, message_type, &msgtype_ti, &sublist_size, offset);
}
proto_item_set_len(msg_ti, message_size + header_size);
offset += header_size;
old_offset = offset;
col_append_sep_str(pinfo->cinfo, COL_INFO, ", ", get_message_type_string(message_type, spice_info, FALSE));
if (message_type < SPICE_FIRST_AVAIL_MESSAGE) { /* this is a common message */
offset = dissect_spice_common_server_messages(tvb, pinfo, message_tree, message_type, msgtype_ti, offset, total_message_size - header_size);
return offset;
}
switch (spice_info->channel_type) {
case SPICE_CHANNEL_PLAYBACK:
offset = dissect_spice_playback_server(tvb, pinfo, message_tree, message_type, msgtype_ti, message_size, spice_info, offset);
break;
case SPICE_CHANNEL_RECORD:
offset = dissect_spice_record_server(tvb, pinfo, message_tree, message_type, msgtype_ti, offset);
break;
case SPICE_CHANNEL_MAIN:
offset = dissect_spice_main_server(tvb, pinfo, message_tree, message_type, msgtype_ti, offset);
break;
case SPICE_CHANNEL_CURSOR:
offset = dissect_spice_cursor_server(tvb, pinfo, message_tree, message_type, msgtype_ti, offset);
break;
case SPICE_CHANNEL_DISPLAY:
offset = dissect_spice_display_server(tvb, message_tree, pinfo, message_type, msgtype_ti, offset);
break;
case SPICE_CHANNEL_INPUTS:
offset = dissect_spice_inputs_server(tvb, pinfo, message_tree, message_type, msgtype_ti, offset);
break;
case SPICE_CHANNEL_TUNNEL:
offset = dissect_spice_tunnel_server(pinfo, message_type, msgtype_ti, offset);
break;
case SPICE_CHANNEL_SMARTCARD:
offset = dissect_spice_smartcard_server(pinfo, message_type, msgtype_ti, offset);
break;
case SPICE_CHANNEL_USBREDIR:
offset = dissect_spice_usbredir_server(tvb, pinfo, message_tree, message_type, msgtype_ti, message_size, offset);
break;
case SPICE_CHANNEL_PORT:
offset = dissect_spice_port_server(tvb, pinfo, message_tree, message_type, msgtype_ti, message_size, offset);
break;
default:
expert_add_info_format(pinfo, msgtype_ti, &ei_spice_unknown_message, "Unknown server PDU - cannot dissect");
}
if ((offset - old_offset) != message_size) {
proto_tree_add_expert_format(tree, pinfo, &ei_spice_not_dissected, tvb, offset, -1,
"message type %s (%u) not fully dissected", get_message_type_string(message_type, spice_info, FALSE), message_type);
offset = old_offset + message_size;
}
return offset;
}
static guint32
dissect_spice_data_client_pdu(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, spice_conversation_t *spice_info, guint32 offset)
{
proto_item *ti = NULL, *msgtype_ti = NULL;
proto_tree *data_header_tree;
guint16 message_type;
guint32 message_size = 0, sublist_size;
guint32 header_size;
if (spice_info->client_mini_header && spice_info->server_mini_header) {
header_size = sizeof_SpiceMiniDataHeader;
ti = proto_tree_add_item(tree, hf_data, tvb, offset, header_size, ENC_NA);
data_header_tree = proto_item_add_subtree(ti, ett_data);
message_type = tvb_get_letohs(tvb, offset);
message_size = tvb_get_letohl(tvb, offset + 2);
dissect_spice_mini_data_header(tvb, data_header_tree, spice_info, TRUE, message_type, offset);
} else {
header_size = sizeof_SpiceDataHeader;
ti = proto_tree_add_item(tree, hf_data, tvb, offset, header_size, ENC_NA);
data_header_tree = proto_item_add_subtree(ti, ett_data);
message_type = tvb_get_letohs(tvb, offset + 8);
message_size = tvb_get_letohl(tvb, offset + 10);
dissect_spice_data_header(tvb, data_header_tree, spice_info, TRUE, message_type, &msgtype_ti, &sublist_size, offset);
}
col_append_sep_str(pinfo->cinfo, COL_INFO, ", ", get_message_type_string(message_type, spice_info, TRUE));
offset += header_size;
/* TODO: deal with sub-messages list first. As implementation does not uses sub-messages list yet, */
/* it cannot be implemented in the dissector yet. */
if (message_type < SPICE_FIRST_AVAIL_MESSAGE) { /* this is a common message */
return dissect_spice_common_client_messages(tvb, pinfo, tree, message_type, msgtype_ti, offset);
}
switch (spice_info->channel_type) {
case SPICE_CHANNEL_PLAYBACK:
break;
case SPICE_CHANNEL_RECORD:
offset = dissect_spice_record_client(tvb, pinfo, tree, message_type, msgtype_ti, offset);
break;
case SPICE_CHANNEL_MAIN:
offset = dissect_spice_main_client(tvb, pinfo, tree, message_type, msgtype_ti, offset);
break;
case SPICE_CHANNEL_DISPLAY:
offset = dissect_spice_display_client(tvb, pinfo, tree, message_type, msgtype_ti, offset);
break;
case SPICE_CHANNEL_INPUTS:
offset = dissect_spice_inputs_client(tvb, pinfo, tree, message_type, msgtype_ti, offset);
break;
case SPICE_CHANNEL_TUNNEL:
offset = dissect_spice_tunnel_client(pinfo, message_type, msgtype_ti, offset);
break;
case SPICE_CHANNEL_SMARTCARD:
offset = dissect_spice_smartcard_client(pinfo, message_type, msgtype_ti, offset);
break;
case SPICE_CHANNEL_USBREDIR:
offset = dissect_spice_usbredir_client(tvb, pinfo, tree, message_type, msgtype_ti, message_size, offset);
break;
case SPICE_CHANNEL_PORT:
offset = dissect_spice_port_client(tvb, pinfo, tree, message_type, msgtype_ti, message_size, offset);
break;
default:
expert_add_info_format(pinfo, msgtype_ti, &ei_spice_unknown_message, "Unknown client PDU - cannot dissect");
break;
}
return offset;
}
static void
dissect_spice_link_common_header(tvbuff_t *tvb, proto_tree *tree)
{
if (tree) {
/* dissect common header */
proto_tree_add_item(tree, hf_spice_magic, tvb, 0, 4, ENC_ASCII);
proto_tree_add_item(tree, hf_major_version, tvb, 4, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_minor_version, tvb, 8, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_message_size, tvb, 12, 4, ENC_LITTLE_ENDIAN);
}
}
static void
dissect_spice_common_capabilities(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, guint32 offset, const guint caps_len, spice_conversation_t *spice_info, gboolean is_client)
{
/* TODO: save common and per-channel capabilities in spice_info ? */
guint i;
guint32 val;
static int * const caps[] = {
&hf_common_cap_auth_select,
&hf_common_cap_auth_spice,
&hf_common_cap_auth_sasl,
&hf_common_cap_mini_header,
NULL
};
for(i = 0; i < caps_len; i++) {
val = tvb_get_letohl(tvb, offset);
switch (i) {
case 0:
if (is_client) {
spice_info->client_auth = val;
} else {
spice_info->server_auth = val;
}
proto_tree_add_bitmask_list(tree, tvb, offset, 4, caps, ENC_LITTLE_ENDIAN);
if (val & SPICE_COMMON_CAP_MINI_HEADER_MASK) {
if (is_client) {
spice_info->client_mini_header = TRUE;
} else {
spice_info->server_mini_header = TRUE;
}
}
offset += 4;
break;
default:
proto_tree_add_expert(tree, pinfo, &ei_spice_common_cap_unknown, tvb, offset, 4);
offset += 4;
break;
}
}
}
static void
dissect_spice_link_capabilities(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, guint32 offset, const guint caps_len, const spice_conversation_t *spice_info)
{
/* TODO: save common and per-channel capabilities in spice_info ? */
guint i;
for(i = 0; i < caps_len; i++) {
switch (spice_info->channel_type) {
case SPICE_CHANNEL_PLAYBACK:
{
int * const playback_cap[] = {
&hf_playback_cap_celt_0_5_1,
&hf_playback_cap_volume,
&hf_playback_cap_latency,
&hf_playback_cap_opus,
NULL
};
if (i != 0)
return;
proto_tree_add_bitmask_list(tree, tvb, offset, 4, playback_cap, ENC_LITTLE_ENDIAN);
}
break;
case SPICE_CHANNEL_MAIN:
{
int * const main_cap[] = {
&hf_main_cap_semi_migrate,
&hf_main_cap_vm_name_uuid, /*Note: only relevant for client. TODO: dissect only for client */
&hf_main_cap_agent_connected_tokens,
&hf_main_cap_seamless_migrate,
NULL
};
if (i != 0)
return;
proto_tree_add_bitmask_list(tree, tvb, offset, 4, main_cap, ENC_LITTLE_ENDIAN);
}
break;
case SPICE_CHANNEL_DISPLAY:
{
int * const display_cap[] = {
&hf_display_cap_sized_stream,
&hf_display_cap_monitors_config,
&hf_display_cap_composite,
&hf_display_cap_a8_surface,
&hf_display_cap_stream_report,
&hf_display_cap_lz4_compression,
&hf_display_cap_pref_compression,
&hf_display_cap_gl_scanout,
&hf_display_cap_multi_codec,
&hf_display_cap_codec_mjpeg,
&hf_display_cap_codec_vp8,
&hf_display_cap_codec_h264,
&hf_display_cap_pref_video_codec_type,
&hf_display_cap_codec_vp9,
&hf_display_cap_codec_h265,
NULL
};
if (i != 0)
return;
proto_tree_add_bitmask_list(tree, tvb, offset, 4, display_cap, ENC_LITTLE_ENDIAN);
}
break;
case SPICE_CHANNEL_INPUTS:
proto_tree_add_item(tree, hf_inputs_cap, tvb, offset, 4, ENC_LITTLE_ENDIAN);
break;
case SPICE_CHANNEL_CURSOR:
proto_tree_add_item(tree, hf_cursor_cap, tvb, offset, 4, ENC_LITTLE_ENDIAN);
break;
case SPICE_CHANNEL_RECORD:
{
int * const record_cap[] = {
&hf_record_cap_celt,
&hf_record_cap_volume,
&hf_record_cap_opus,
NULL
};
if (i != 0)
return;
proto_tree_add_bitmask_list(tree, tvb, offset, 4, record_cap, ENC_LITTLE_ENDIAN);
}
break;
default:
proto_tree_add_expert(tree, pinfo, &ei_spice_unknown_channel, tvb, offset, -1);
return;
}
offset += 4;
}
}
static void
dissect_spice_link_client_pdu(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, spice_conversation_t *spice_info)
{
guint32 offset;
guint32 common_caps_len, channel_caps_len;
proto_item *ti = NULL;
proto_tree *link_header_tree = NULL;
proto_tree *caps_tree = NULL;
if (tree) {
ti = proto_tree_add_item(tree, hf_link_client, tvb, 0, sizeof_SpiceLinkHeader, ENC_NA);
link_header_tree = proto_item_add_subtree(ti, ett_link_client);
dissect_spice_link_common_header(tvb, link_header_tree);
}
offset = sizeof_SpiceLinkHeader;
if (spice_info->channel_type == SPICE_CHANNEL_NONE) {
spice_info->channel_type = tvb_get_guint8(tvb, offset + 4);
}
common_caps_len = tvb_get_letohl(tvb, offset + 6);
channel_caps_len = tvb_get_letohl(tvb, offset + 10);
proto_tree_add_item(tree, hf_conn_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_channel_type, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_channel_id, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_num_common_caps, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_num_channel_caps, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_caps_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
if (common_caps_len > 0) {
caps_tree = proto_tree_add_subtree_format(tree, tvb, offset, common_caps_len * 4,
ett_link_caps, NULL, "Client Common Capabilities (%d bytes)",
common_caps_len * 4); /* caps_len multiplied by 4 as length is in UINT32 units */
dissect_spice_common_capabilities(tvb, pinfo, caps_tree, offset, common_caps_len, spice_info, TRUE);
offset += (common_caps_len * 4);
}
if (channel_caps_len > 0) {
caps_tree = proto_tree_add_subtree_format(tree, tvb, offset, channel_caps_len * 4,
ett_link_caps, NULL, "Client Channel-specific Capabilities (%d bytes)",
channel_caps_len * 4); /* caps_len multiplied by 4 as length is in UINT32 units */
dissect_spice_link_capabilities(tvb, pinfo, caps_tree, offset, channel_caps_len, spice_info);
}
}
static void
dissect_spice_link_server_pdu(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, spice_conversation_t *spice_info)
{
guint32 offset;
guint32 common_caps_len, channel_caps_len;
proto_item *ti = NULL;
proto_tree *link_tree = NULL;
proto_tree *caps_tree = NULL;
if (tree) {
ti = proto_tree_add_item(tree, hf_link_server, tvb, 0, sizeof_SpiceLinkHeader, ENC_NA);
link_tree = proto_item_add_subtree(ti, ett_link_server);
dissect_spice_link_common_header(tvb, link_tree);
}
offset = sizeof_SpiceLinkHeader;
if (tree) {
proto_tree_add_item(tree, hf_error_code, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_bytes_format(tree, hf_spice_x509_subjectpublickeyinfo, tvb, offset + 4, SPICE_TICKET_PUBKEY_BYTES, NULL, "X.509 SubjectPublicKeyInfo (ASN.1)");
proto_tree_add_item(tree, hf_num_common_caps, tvb, offset + 4 + SPICE_TICKET_PUBKEY_BYTES, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_num_channel_caps, tvb, offset + 8 + SPICE_TICKET_PUBKEY_BYTES, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_caps_offset, tvb, offset + 12 + SPICE_TICKET_PUBKEY_BYTES, 4, ENC_LITTLE_ENDIAN);
}
common_caps_len = tvb_get_letohl(tvb, offset + 4 + SPICE_TICKET_PUBKEY_BYTES);
channel_caps_len = tvb_get_letohl(tvb, offset + 8 + SPICE_TICKET_PUBKEY_BYTES);
offset += (int)sizeof_SpiceLinkHeader + SPICE_TICKET_PUBKEY_BYTES;
if (common_caps_len > 0) {
caps_tree = proto_tree_add_subtree_format(tree, tvb, offset, common_caps_len * 4,
ett_link_caps, NULL, "Common Capabilities (%d bytes)",
common_caps_len * 4); /* caps_len multiplied by 4 as length is in UINT32 units */
dissect_spice_common_capabilities(tvb, pinfo, caps_tree, offset, common_caps_len, spice_info, FALSE);
offset += (common_caps_len * 4);
}
if (channel_caps_len > 0) {
caps_tree = proto_tree_add_subtree_format(tree, tvb, offset, channel_caps_len * 4,
ett_link_caps, NULL, "Channel Capabilities (%d bytes)",
channel_caps_len * 4); /* caps_len multiplied by 4 as length is in UINT32 units */
dissect_spice_link_capabilities(tvb, pinfo, caps_tree, offset, channel_caps_len, spice_info);
}
}
static int
dissect_spice(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
conversation_t *conversation;
spice_conversation_t *spice_info;
spice_packet_t *per_packet_info;
guint32 avail;
guint32 pdu_len = 0;
guint32 offset;
proto_item *ti, *auth_item;
proto_tree *spice_tree;
gboolean client_sasl_list = FALSE;
guint8 sasl_auth_result;
conversation = find_or_create_conversation(pinfo);
spice_info = (spice_conversation_t*)conversation_get_proto_data(conversation, proto_spice);
if (!spice_info) {
spice_info = wmem_new0(wmem_file_scope(), spice_conversation_t);
spice_info->destport = pinfo->destport;
spice_info->channel_type = SPICE_CHANNEL_NONE;
spice_info->next_state = SPICE_LINK_CLIENT;
spice_info->client_auth = 0;
spice_info->server_auth = 0;
spice_info->playback_mode = SPICE_AUDIO_DATA_MODE_INVALID;
spice_info->client_mini_header = FALSE;
spice_info->server_mini_header = FALSE;
conversation_add_proto_data(conversation, proto_spice, spice_info);
conversation_set_dissector(conversation, spice_handle);
}
per_packet_info = (spice_packet_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_spice, 0);
if (!per_packet_info) {
per_packet_info = wmem_new(wmem_file_scope(), spice_packet_t);
per_packet_info->state = spice_info->next_state;
p_add_proto_data(wmem_file_scope(), pinfo, proto_spice, 0, per_packet_info);
}
col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "Spice %s", val_to_str_const(spice_info->channel_type,channel_types_vs, "Unknown"));
col_clear(pinfo->cinfo, COL_INFO);
col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(per_packet_info->state, state_name_vs, ""));
ti = proto_tree_add_item(tree, proto_spice, tvb, 0, -1, ENC_NA);
spice_tree = proto_item_add_subtree(ti, ett_spice);
switch (per_packet_info->state) {
case SPICE_LINK_CLIENT:
avail = tvb_reported_length(tvb);
pdu_len = sizeof_SpiceLinkHeader;
GET_PDU_FROM_OFFSET(0)
pdu_len = tvb_get_letohl(tvb, 12) + sizeof_SpiceLinkHeader;
GET_PDU_FROM_OFFSET(0)
proto_item_set_len(ti, pdu_len);
dissect_spice_link_client_pdu(tvb, pinfo, spice_tree, spice_info);
col_add_fstr(pinfo->cinfo, COL_PROTOCOL,
"Spice %s", val_to_str_const(spice_info->channel_type,channel_types_vs, "Unknown"));
spice_info->next_state = SPICE_LINK_SERVER;
return pdu_len;
break;
case SPICE_LINK_SERVER:
avail = tvb_reported_length(tvb);
pdu_len = sizeof_SpiceLinkHeader;
GET_PDU_FROM_OFFSET(0)
pdu_len = tvb_get_letohl(tvb, 12) + sizeof_SpiceLinkHeader;
GET_PDU_FROM_OFFSET(0)
proto_item_set_len(ti, pdu_len);
dissect_spice_link_server_pdu(tvb, pinfo, spice_tree, spice_info);
if (!(spice_info->server_auth & SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION_MASK) ||
!(spice_info->client_auth & SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION_MASK)) {
/* Server or clients support spice ticket auth only */
spice_info->next_state = SPICE_TICKET_CLIENT;
} else { /* Protocol selection between client and server */
spice_info->next_state = SPICE_CLIENT_AUTH_SELECT;
}
return pdu_len;
break;
case SPICE_CLIENT_AUTH_SELECT:
if (spice_info->destport != pinfo->destport) { /* ignore anything from the server, wait for data from client */
expert_add_info(pinfo, ti, &ei_spice_expected_from_client);
break;
}
avail = tvb_reported_length(tvb);
pdu_len = 4;
GET_PDU_FROM_OFFSET(0)
proto_item_set_len(ti, 4);
auth_item = proto_tree_add_item(spice_tree, hf_auth_select_client, tvb, 0, 4, ENC_LITTLE_ENDIAN);
spice_info->auth_selected = tvb_get_letohl(tvb, 0);
switch (spice_info->auth_selected) {
case SPICE_COMMON_CAP_AUTH_SPICE:
spice_info->next_state = SPICE_TICKET_CLIENT;
break;
case SPICE_COMMON_CAP_AUTH_SASL:
spice_info->next_state = SPICE_SASL_INIT_FROM_SERVER;
break;
default:
expert_add_info(pinfo, auth_item, &ei_spice_auth_unknown);
break;
}
return 4;
break;
case SPICE_SASL_INIT_FROM_SERVER:
offset = 0;
avail = tvb_reported_length_remaining(tvb, offset);
pdu_len = 4;
GET_PDU_FROM_OFFSET(offset)
pdu_len = tvb_get_letohl(tvb, offset); /* the length of the following messages */
proto_item_set_len(ti, 4);
proto_tree_add_item(spice_tree, hf_spice_sasl_message_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
pdu_len += 4;
GET_PDU_FROM_OFFSET(offset)
proto_item_set_len(ti, pdu_len);
proto_tree_add_uint(spice_tree, hf_spice_supported_authentication_mechanisms_list_length, tvb, offset, 4, pdu_len - 4);
offset += 4;
proto_tree_add_item(spice_tree, hf_spice_supported_authentication_mechanisms_list, tvb, offset, pdu_len - 4, ENC_NA|ENC_ASCII);
offset += (pdu_len - 4);
spice_info->next_state = SPICE_SASL_START_TO_SERVER;
return offset;
case SPICE_SASL_START_TO_SERVER:
offset = 0;
while (offset < tvb_reported_length(tvb)) {
avail = tvb_reported_length_remaining(tvb, offset);
pdu_len = 4;
GET_PDU_FROM_OFFSET(offset)
pdu_len = tvb_get_letohl(tvb, offset); /* the length of the following messages */
proto_item_set_len(ti, 4);
proto_tree_add_item(spice_tree, hf_spice_sasl_message_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
if (pdu_len == 0) {
/* meaning, empty PDU - assuming the client_out_list, which may be empty*/
spice_info->next_state = SPICE_SASL_START_FROM_SERVER;
pdu_len = 4; /* only the size field.*/
offset += pdu_len;
} else {
pdu_len += 4;
GET_PDU_FROM_OFFSET(offset)
proto_item_set_len(ti, pdu_len);
if (client_sasl_list == FALSE) {
client_sasl_list = TRUE;
col_set_str(pinfo->cinfo, COL_INFO, "Client selected SASL authentication mechanism (start to server)");
proto_tree_add_uint(spice_tree, hf_spice_selected_authentication_mechanism_length, tvb, offset, 4, pdu_len - 4);
offset += 4;
proto_tree_add_item(spice_tree, hf_spice_selected_authentication_mechanism, tvb, offset, pdu_len - 4, ENC_NA|ENC_ASCII);
} else {
/* this is the client out list, ending the start from client message */
col_set_str(pinfo->cinfo, COL_INFO, "Client out mechanism (start to server)");
proto_tree_add_uint(spice_tree, hf_spice_client_out_mechanism_length, tvb, offset, 4, pdu_len - 4);
offset += 4;
proto_tree_add_item(spice_tree, hf_spice_selected_client_out_mechanism, tvb, offset, pdu_len - 4, ENC_NA|ENC_ASCII);
spice_info->next_state = SPICE_SASL_START_FROM_SERVER;
}
offset += (pdu_len - 4);
}
}
return pdu_len;
break;
case SPICE_SASL_START_FROM_SERVER:
case SPICE_SASL_STEP_FROM_SERVER:
offset = 0;
while (offset < tvb_reported_length(tvb)) {
avail = tvb_reported_length_remaining(tvb, offset);
pdu_len = 4;
GET_PDU_FROM_OFFSET(offset)
pdu_len = tvb_get_letohl(tvb, offset); /* the length of the following messages */
proto_item_set_len(ti, 4 + pdu_len);
proto_tree_add_item(spice_tree, hf_spice_sasl_message_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
if (pdu_len == 0) { /* meaning, empty PDU */
offset += 4; /* only the size field.*/
} else {
pdu_len += 4;
GET_PDU_FROM_OFFSET(offset)
offset += 4;
proto_tree_add_item(spice_tree, hf_spice_sasl_authentication_data, tvb, offset, pdu_len - 4, ENC_ASCII);
offset += (pdu_len - 4);
}
}
if (per_packet_info->state == SPICE_SASL_START_FROM_SERVER) {
spice_info->next_state = SPICE_SASL_START_FROM_SERVER_CONT;
} else {
spice_info->next_state = SPICE_SASL_STEP_FROM_SERVER_CONT;
}
return pdu_len;
break;
case SPICE_SASL_START_FROM_SERVER_CONT:
case SPICE_SASL_STEP_FROM_SERVER_CONT:
offset = 0;
avail = tvb_reported_length_remaining(tvb, offset);
if (avail >= 1) {
proto_item_set_len(ti, 1);
sasl_auth_result = tvb_get_guint8(tvb, offset);
proto_tree_add_item(spice_tree, hf_spice_sasl_auth_result, tvb, offset, 1, ENC_NA);
if (per_packet_info->state == SPICE_SASL_START_FROM_SERVER_CONT) {
/* if we are in the sasl start, and can continue */
if (sasl_auth_result == 0) { /* 0 = continue */
spice_info->next_state = SPICE_SASL_STEP_TO_SERVER;
} else {
expert_add_info_format(pinfo, ti, &ei_spice_sasl_auth_result, "SPICE_SASL_START_FROM_SERVER_CONT and sasl_auth_result is %d",
sasl_auth_result);
}
} else { /* SPICE_SASL_STEP_FROM_SERVER_CONT state. */
spice_info->next_state = SPICE_TICKET_SERVER;
}
}
return 1;
break;
case SPICE_SASL_STEP_TO_SERVER:
offset = 0;
while (offset < tvb_reported_length(tvb)) {
avail = tvb_reported_length_remaining(tvb, offset);
pdu_len = 4;
GET_PDU_FROM_OFFSET(offset)
pdu_len = tvb_get_letohl(tvb, offset); /* the length of the following messages */
proto_item_set_len(ti, 4);
proto_tree_add_item(spice_tree, hf_spice_sasl_message_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
if (pdu_len == 0) {
/* meaning, empty PDU - assuming the client_out_list, which may be empty*/
col_set_str(pinfo->cinfo, COL_INFO, "SASL authentication from client (step to server)");
spice_info->next_state = SPICE_SASL_STEP_FROM_SERVER;
pdu_len = 4; /* only the size field.*/
offset += pdu_len;
} else {
pdu_len += 4;
GET_PDU_FROM_OFFSET(offset)
proto_item_set_len(ti, pdu_len);
col_set_str(pinfo->cinfo, COL_INFO, "Clientout (step to server)");
proto_tree_add_uint(spice_tree, hf_spice_clientout_length, tvb, offset, 4, pdu_len - 4);
offset += 4;
proto_tree_add_item(spice_tree, hf_spice_clientout_list, tvb, offset, pdu_len - 4, ENC_NA|ENC_ASCII);
spice_info->next_state = SPICE_SASL_STEP_FROM_SERVER;
offset += (pdu_len - 4);
}
}
return pdu_len;
break;
case SPICE_SASL_DATA:
offset = 0;
while (offset < tvb_reported_length(tvb)) {
avail = tvb_reported_length_remaining(tvb, offset);
pdu_len = 4;
GET_PDU_FROM_OFFSET(offset)
pdu_len = tvb_get_ntohl(tvb, offset); /* the length of the following messages */
proto_item_set_len(ti, pdu_len);
proto_tree_add_item(spice_tree, hf_spice_sasl_message_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
if (pdu_len == 0) { /* meaning, empty PDU */
return 4; /* only the size field.*/
} else {
pdu_len += 4;
}
GET_PDU_FROM_OFFSET(offset)
proto_item_set_len(ti, pdu_len);
col_add_fstr(pinfo->cinfo, COL_PROTOCOL,
"Spice %s (SASL wrapped)", val_to_str_const(spice_info->channel_type,channel_types_vs, "Unknown"));
offset += 4;
proto_tree_add_bytes_format(spice_tree, hf_spice_sasl_data, tvb, offset, pdu_len - 4, NULL, "SASL data (%u bytes)", pdu_len - 4);
offset += (pdu_len - 4);
}
return pdu_len;
break;
case SPICE_DATA:
offset = 0;
while (offset < tvb_reported_length(tvb)) {
avail = tvb_reported_length_remaining(tvb, offset);
if (spice_info->client_mini_header && spice_info->server_mini_header) {
pdu_len = sizeof_SpiceMiniDataHeader;
GET_PDU_FROM_OFFSET(offset)
pdu_len = tvb_get_letohl(tvb, offset + 2);
pdu_len += sizeof_SpiceMiniDataHeader;
} else {
pdu_len = sizeof_SpiceDataHeader;
GET_PDU_FROM_OFFSET(offset)
/* if there are no sub-messages, get the usual message body size. */
/* Note that we do not dissect properly yet sub-messages - but they */
/* are not used in the protcol either */
pdu_len = tvb_get_letohl(tvb, offset + 10);
pdu_len += sizeof_SpiceDataHeader; /* +sizeof_SpiceDataHeader since you need to exclude the SPICE */
/* data header, which is sizeof_SpiceDataHeader (18) bytes long) */
}
GET_PDU_FROM_OFFSET(offset)
proto_item_set_len(ti, pdu_len);
if (spice_info->destport == pinfo->destport) { /* client to server traffic */
offset = dissect_spice_data_client_pdu(tvb, spice_tree, pinfo, spice_info, offset);
} else { /* server to client traffic */
offset = dissect_spice_data_server_pdu(tvb, spice_tree, pinfo, spice_info, offset, pdu_len);
}
}
return offset;
break;
case SPICE_TICKET_CLIENT:
if (spice_info->destport != pinfo->destport) /* ignore anything from the server, wait for ticket from client */
break;
avail = tvb_reported_length(tvb);
pdu_len = 128;
GET_PDU_FROM_OFFSET(0)
proto_item_set_len(ti, 128);
proto_tree_add_item(spice_tree, hf_ticket_client, tvb, 0, 128, ENC_NA);
spice_info->next_state = SPICE_TICKET_SERVER;
return 128;
break;
case SPICE_TICKET_SERVER:
if (spice_info->destport != pinfo->srcport) /* ignore anything from the client, wait for ticket from server */
break;
avail = tvb_reported_length(tvb);
pdu_len = 4;
GET_PDU_FROM_OFFSET(0)
proto_item_set_len(ti, 4);
proto_tree_add_item(spice_tree, hf_ticket_server, tvb, 0, 4, ENC_LITTLE_ENDIAN);
if (spice_info->auth_selected == SPICE_COMMON_CAP_AUTH_SASL) {
spice_info->next_state = SPICE_SASL_DATA;
} else {
spice_info->next_state = SPICE_DATA;
}
return pdu_len;
break;
default:
break;
}
return 0;
}
static gboolean
test_spice_protocol(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
if ((tvb_reported_length(tvb) >= 4) && (tvb_get_ntohl(tvb, 0) == SPICE_MAGIC)) {
dissect_spice(tvb, pinfo, tree, data);
return TRUE;
}
return FALSE;
}
/* Register the protocol with Wireshark */
void
proto_register_spice(void)
{
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_link_client,
{ "Link client header", "spice.link_client",
FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_link_server,
{ "Link server header", "spice.link_server",
FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_spice_magic,
{ "SPICE MAGIC", "spice.magic",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_major_version,
{ "Protocol major version", "spice.major_version",
FT_INT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_minor_version,
{ "Protocol minor version", "spice.minor_version",
FT_INT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_message_size,
{ "Message size", "spice.message_size",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_message_type,
{ "Message type", "spice.message_type",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_conn_id,
{ "Session ID", "spice.conn_id",
FT_UINT32, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_channel_type,
{ "Channel type", "spice.channel_type",
FT_UINT8, BASE_DEC, VALS(channel_types_vs), 0x0,
NULL, HFILL }
},
{ &hf_channel_id,
{ "Channel ID", "spice.channel_id",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_num_common_caps,
{ "Number of common capabilities", "spice.num_common_caps",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_num_channel_caps,
{ "Number of channel capabilities", "spice.num_channel_caps",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_caps_offset,
{ "Capabilities offset (bytes)", "spice.caps_offset",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_error_code,
{ "spice ERROR", "spice.error_code",
FT_UINT32, BASE_DEC, VALS(spice_link_err_vs), 0x0,
NULL, HFILL }
},
{ &hf_serial,
{ "Message serial number", "spice.serial",
FT_UINT64, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_data,
{ "Message header", "spice.message_header",
FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_data_size,
{ "Message body size (bytes)", "spice.message_size",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_data_sublist,
{ "Sub-list offset (bytes)", "spice.message_sublist",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_ticket_client,
{ "Ticket - client", "spice.ticket_client",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_ticket_server,
{ "Link result", "spice.ticket_server",
FT_UINT32, BASE_DEC, VALS(spice_link_err_vs), 0x0,
NULL, HFILL }
},
{ &hf_auth_select_client,
{ "Authentication selected by client", "spice.auth_select_client",
FT_UINT32, BASE_DEC, VALS(spice_auth_select_vs), 0x0,
NULL, HFILL }
},
{ &hf_common_cap_auth_select,
{ "Auth Selection", "spice.common_cap_auth_select",
FT_BOOLEAN, 4, TFS(&tfs_set_notset), SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION_MASK,
NULL, HFILL }
},
{ &hf_common_cap_auth_spice,
{ "Auth Spice", "spice.common_cap_auth_spice",
FT_BOOLEAN, 4, TFS(&tfs_set_notset), SPICE_COMMON_CAP_AUTH_SPICE_MASK,
NULL, HFILL }
},
{ &hf_common_cap_auth_sasl,
{ "Auth SASL", "spice.common_cap_auth_sasl",
FT_BOOLEAN, 4, TFS(&tfs_set_notset), SPICE_COMMON_CAP_AUTH_SASL_MASK,
NULL, HFILL }
},
{ &hf_common_cap_mini_header,
{ "Mini Header", "spice.common_cap_mini_header",
FT_BOOLEAN, 4, TFS(&tfs_set_notset), SPICE_COMMON_CAP_MINI_HEADER_MASK,
NULL, HFILL }
},
{ &hf_playback_cap_celt_0_5_1,
{ "CELT 0.5.1 playback channel support", "spice.playback_cap_celt_0_5_1",
FT_BOOLEAN, PLAYBACK_CAP_NBITS, TFS(&tfs_set_notset), SPICE_PLAYBACK_CAP_CELT_0_5_1_MASK,
NULL, HFILL }
},
{ &hf_playback_cap_volume,
{ "Volume playback channel support", "spice.playback_cap_volume",
FT_BOOLEAN, PLAYBACK_CAP_NBITS, TFS(&tfs_set_notset), SPICE_PLAYBACK_CAP_VOLUME_MASK,
NULL, HFILL }
},
{ &hf_playback_cap_latency,
{ "Latency playback channel support", "spice.playback_cap_latency",
FT_BOOLEAN, PLAYBACK_CAP_NBITS, TFS(&tfs_set_notset), SPICE_PLAYBACK_CAP_LATENCY_MASK,
NULL, HFILL }
},
{ &hf_playback_cap_opus,
{ "OPUS playback channel support", "spice.playback_cap_opus",
FT_BOOLEAN, PLAYBACK_CAP_NBITS, TFS(&tfs_set_notset), SPICE_PLAYBACK_CAP_OPUS_MASK,
NULL, HFILL }
},
{ &hf_record_cap_celt,
{ "CELT 0.5.1 record channel support", "spice.record_cap_celt",
FT_BOOLEAN, RECORD_CAP_NBITS, TFS(&tfs_set_notset), SPICE_RECORD_CAP_CELT_0_5_1_MASK,
NULL, HFILL }
},
{ &hf_record_cap_volume,
{ "Volume record channel support", "spice.record_cap_volume",
FT_BOOLEAN, RECORD_CAP_NBITS, TFS(&tfs_set_notset), SPICE_RECORD_CAP_VOLUME_MASK,
NULL, HFILL }
},
{ &hf_record_cap_opus,
{ "Opus record channel support", "spice.record_cap_opus",
FT_BOOLEAN, RECORD_CAP_NBITS, TFS(&tfs_set_notset), SPICE_RECORD_CAP_OPUS_MASK,
NULL, HFILL }
},
{ &hf_display_cap_sized_stream,
{ "Sized stream display channel support", "spice.display_cap_sized_stream",
FT_BOOLEAN, DISPLAY_CAP_NBITS, TFS(&tfs_set_notset), SPICE_DISPLAY_CAP_SIZED_STREAM_MASK,
NULL, HFILL }
},
{ &hf_display_cap_monitors_config,
{ "Monitors configuration display channel support", "spice.display_cap_monitors_config",
FT_BOOLEAN, DISPLAY_CAP_NBITS, TFS(&tfs_set_notset), SPICE_DISPLAY_CAP_MONITORS_CONFIG_MASK,
NULL, HFILL }
},
{ &hf_display_cap_composite,
{ "Composite capability display channel support", "spice.display_cap_composite",
FT_BOOLEAN, DISPLAY_CAP_NBITS, TFS(&tfs_set_notset), SPICE_DISPLAY_CAP_COMPOSITE_MASK,
NULL, HFILL }
},
{ &hf_display_cap_a8_surface,
{ "A8 bitmap display channel support", "spice.display_cap_a8_surface",
FT_BOOLEAN, DISPLAY_CAP_NBITS, TFS(&tfs_set_notset), SPICE_DISPLAY_CAP_A8_SURFACE_MASK,
NULL, HFILL }
},
{ &hf_display_cap_stream_report,
{ "Stream Report display channel support", "spice.display_cap_stream_report",
FT_BOOLEAN, DISPLAY_CAP_NBITS, TFS(&tfs_set_notset), SPICE_DISPLAY_CAP_STREAM_REPORT_MASK,
NULL, HFILL }
},
{ &hf_display_cap_lz4_compression,
{ "LZ4 Compression display channel support", "spice.display_cap_lz4_compression",
FT_BOOLEAN, DISPLAY_CAP_NBITS, TFS(&tfs_set_notset), SPICE_DISPLAY_CAP_LZ4_COMPRESSION_MASK,
NULL, HFILL }
},
{ &hf_display_cap_pref_compression,
{ "Pref Compression display channel support", "spice.display_cap_pref_compression",
FT_BOOLEAN, DISPLAY_CAP_NBITS, TFS(&tfs_set_notset), SPICE_DISPLAY_CAP_PREF_COMPRESSION_MASK,
NULL, HFILL }
},
{ &hf_display_cap_gl_scanout,
{ "GL Scanout display channel support", "spice.display_cap_gl_scanout",
FT_BOOLEAN, DISPLAY_CAP_NBITS, TFS(&tfs_set_notset), SPICE_DISPLAY_CAP_GL_SCANOUT_MASK,
NULL, HFILL }
},
{ &hf_display_cap_multi_codec,
{ "Multi-codec display channel support", "spice.display_cap_multi_codec",
FT_BOOLEAN, DISPLAY_CAP_NBITS, TFS(&tfs_set_notset), SPICE_DISPLAY_CAP_MULTI_CODEC_MASK,
NULL, HFILL }
},
{ &hf_display_cap_codec_mjpeg,
{ "MJPEG codec display channel support", "spice.display_cap_codec_mjpeg",
FT_BOOLEAN, DISPLAY_CAP_NBITS, TFS(&tfs_set_notset), SPICE_DISPLAY_CAP_CODEC_MJPEG_MASK,
NULL, HFILL }
},
{ &hf_display_cap_codec_vp8,
{ "VP8 codec display channel support", "spice.display_cap_codec_vp8",
FT_BOOLEAN, DISPLAY_CAP_NBITS, TFS(&tfs_set_notset), SPICE_DISPLAY_CAP_CODEC_VP8_MASK,
NULL, HFILL }
},
{ &hf_display_cap_codec_h264,
{ "H264 codec display channel support", "spice.display_cap_codec_h264",
FT_BOOLEAN, DISPLAY_CAP_NBITS, TFS(&tfs_set_notset), SPICE_DISPLAY_CAP_CODEC_H264_MASK,
NULL, HFILL }
},
{ &hf_display_cap_pref_video_codec_type,
{ "Preferred Video Codec Type display channel support", "spice.display_cap_pref_video_codec_type",
FT_BOOLEAN, DISPLAY_CAP_NBITS, TFS(&tfs_set_notset), SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE_MASK,
NULL, HFILL }
},
{ &hf_display_cap_codec_vp9,
{ "VP9 codec display channel support", "spice.display_cap_codec_vp9",
FT_BOOLEAN, DISPLAY_CAP_NBITS, TFS(&tfs_set_notset), SPICE_DISPLAY_CAP_CODEC_VP9_MASK,
NULL, HFILL }
},
{ &hf_display_cap_codec_h265,
{ "H265 codec display channel support", "spice.display_cap_codec_h265",
FT_BOOLEAN, DISPLAY_CAP_NBITS, TFS(&tfs_set_notset), SPICE_DISPLAY_CAP_CODEC_H265_MASK,
NULL, HFILL }
},
{ &hf_cursor_cap,
{ "Cursor channel capability", "spice.cursor_cap",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_inputs_cap,
{ "Inputs channel capability", "spice.inputs_cap",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_main_num_channels,
{ "Number of Channels", "spice.main_num_channels",
FT_UINT32, 4, NULL, 0x0,
NULL, HFILL }
},
{ &hf_main_cap_semi_migrate,
{ "Semi-seamless migration capability", "spice.main_cap_semi_migrate",
FT_BOOLEAN, 4, TFS(&tfs_set_notset), SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE_MASK,
NULL, HFILL }
},
{ &hf_main_cap_vm_name_uuid,
{ "VM name and UUID messages capability", "spice.main_cap_vm_name_uuid",
FT_BOOLEAN, 4, TFS(&tfs_set_notset), SPICE_MAIN_CAP_VM_NAME_UUID_MASK,
NULL, HFILL }
},
{ &hf_main_cap_agent_connected_tokens,
{ "Agent connected tokens capability", "spice.main_cap_agent_connected_tokens",
FT_BOOLEAN, 4, TFS(&tfs_set_notset), SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS_MASK,
NULL, HFILL }
},
{ &hf_main_cap_seamless_migrate,
{ "Seamless migration capability", "spice.main_cap_seamless_migrate",
FT_BOOLEAN, 4, TFS(&tfs_set_notset), SPICE_MAIN_CAP_SEAMLESS_MIGRATE_MASK,
NULL, HFILL }
},
{ &hf_audio_timestamp,
{ "Timestamp", "spice.audio_timestamp",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_audio_mode,
{ "Mode", "spice.audio_mode",
FT_UINT16, BASE_DEC, VALS(playback_mode_vals), 0x0,
NULL, HFILL }
},
{ &hf_audio_channels,
{ "Channels", "spice.audio_channels",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_audio_format,
{ "Format", "spice.audio_format",
FT_UINT16, BASE_DEC, VALS(spice_audio_fmt_vs), 0x0,
NULL, HFILL }
},
{ &hf_audio_frequency,
{ "Frequency", "spice.audio_frequency",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_audio_volume,
{ "Volume", "spice.audio_volume",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_audio_mute,
{ "Mute", "spice.audio_mute",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_audio_latency,
{ "Latency (ms)", "spice.audio_latency",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_red_set_ack_generation,
{ "Set ACK generation", "spice.red_set_ack_generation",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_red_set_ack_window,
{ "Set ACK window (messages)", "spice.red_set_ack_window",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_Clip_type,
{ "Clip type", "spice.clip_type",
FT_UINT8, BASE_DEC, VALS(spice_clip_type_vs), 0x0,
NULL, HFILL }
},
{ &hf_Mask_flag,
{ "Mask flag", "spice.mask_flag",
FT_UINT8, BASE_DEC, VALS(spice_mask_flags_vs), 0x0,
NULL, HFILL }
},
{ &hf_display_rop_descriptor,
{ "ROP descriptor", "spice.display_rop_descriptor",
FT_UINT16, BASE_HEX, VALS(spice_ropd_vs), 0x0,
NULL, HFILL }
},
{ &hf_display_scale_mode,
{ "Scale mode", "spice.scale_mode",
FT_UINT8, BASE_DEC, VALS(spice_image_scale_mode_vs), 0x0,
NULL, HFILL }
},
{ &hf_red_ping_id,
{ "Ping ID", "spice.ping_id",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_red_timestamp,
{ "timestamp", "spice.timestamp",
FT_UINT64, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_spice_display_mode_width,
{ "Display Width", "spice.display_width",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_spice_display_mode_height,
{ "Display Height", "spice.display_height",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_spice_display_mode_depth,
{ "Color depth", "spice.display_depth",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_image_desc_id,
{ "Image ID", "spice.image_id",
FT_UINT64, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_image_desc_type,
{ "Image type", "spice.image_type",
FT_UINT8, BASE_DEC, VALS(spice_image_type_vs), 0x0,
NULL, HFILL }
},
{ &hf_image_desc_flags,
{ "Flags", "spice.image_flags",
FT_UINT8, BASE_HEX, VALS(spice_image_flags_vs), 0x0,
NULL, HFILL }
},
{ &hf_image_desc_width,
{ "Width", "spice.image_width",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_image_desc_height,
{ "Height", "spice.image_height",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_width,
{ "Width", "spice.quic_width",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_type,
{ "QUIC image type", "spice.quic_type",
FT_UINT32, BASE_DEC, VALS(quic_type_vs), 0x0,
NULL, HFILL }
},
{ &hf_quic_height,
{ "Height", "spice.quic_height",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_major_version,
{ "QUIC major version", "spice.quic_major_version",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_minor_version,
{ "QUIC minor version", "spice.quic_minor_version",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_LZ_width,
{ "Width", "spice.LZ_width",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_LZ_height,
{ "Height", "spice.LZ_height",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_LZ_RGB_type,
{ "Image type", "spice.LZ_RGB_type",
FT_UINT8, BASE_DEC, VALS(LzImage_type_vs), 0xf,
NULL, HFILL }
},
{ &hf_LZ_major_version,
{ "LZ major version", "spice.LZ_major_version",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_LZ_minor_version,
{ "LZ minor version", "spice.LZ_minor_version",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_LZ_stride,
{ "Stride", "spice.LZ_stride",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_LZ_RGB_dict_id,
{ "LZ RGB Dictionary ID", "spice.LZ_RGB_dict_id",
FT_UINT64, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_cursor_trail_len,
{ "Cursor trail length", "spice.cursor_trail_len",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_cursor_trail_freq,
{ "Cursor trail frequency", "spice.cursor_trail_freq",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_cursor_trail_visible,
{ "Cursor trail visibility", "spice.cursor_trail_visible",
FT_UINT8, BASE_DEC, VALS(cursor_visible_vs), 0x0,
NULL, HFILL }
},
{ &hf_cursor_unique,
{ "Cursor unique ID", "spice.cursor_unique",
FT_UINT64, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_cursor_type,
{ "Cursor type", "spice.cursor_type",
FT_UINT8, BASE_HEX, VALS(spice_cursor_type_vs), 0x0,
NULL, HFILL }
},
{ &hf_cursor_width,
{ "Cursor width", "spice.cursor_width",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_cursor_height,
{ "Cursor height", "spice.cursor_height",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_cursor_hotspot_x,
{ "Cursor hotspot X", "spice.cursor_hotspot_x",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_cursor_hotspot_y,
{ "Cursor hotspot Y", "spice.cursor_hotspot_y",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_cursor_flags, /*FIXME - those are flags */
{ "Cursor flags", "spice.cursor_flags",
FT_UINT16, BASE_HEX, VALS(spice_cursor_flags_vs), 0x0,
NULL, HFILL }
},
{ &hf_cursor_id,
{ "Cursor ID", "spice.cursor_id",
FT_UINT64, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_spice_display_init_cache_id,
{ "Cache ID", "spice.display_init_cache_id",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_spice_display_init_cache_size,
{ "Cache size (pixels)", "spice.display_init_cache_size",
FT_UINT64, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_spice_display_init_glz_dict_id,
{ "GLZ Dictionary ID", "spice.display_init_glz_dict_id",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_spice_display_init_dict_window_size,
{ "Dictionary window size", "spice.display_init_dict_window_size",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_brush_type,
{ "Brush type", "spice.brush_type",
FT_UINT8, BASE_DEC, VALS(spice_brush_type_vs), 0x0,
NULL, HFILL }
},
{ &hf_brush_rgb,
{ "Brush color", "spice.brush_rgb",
FT_UINT32, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_pixmap_width,
{ "Pixmap width", "spice.pixmap_width",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_pixmap_height,
{ "Pixmap height", "spice.pixmap_height",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_pixmap_stride,
{ "Pixmap stride", "spice.pixmap_stride",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_pixmap_address,
{ "Pixmap palette pointer", "spice.pixmap_palette_address",
FT_UINT32, BASE_HEX_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_pixmap_format,
{ "Pixmap format", "spice.pixmap_format",
FT_UINT8, BASE_DEC, VALS(spice_bitmap_fmt_vs), 0x0,
NULL, HFILL }
},
{ &hf_pixmap_flags,
{ "Pixmap flags", "spice.pixmap_flags",
FT_UINT8, BASE_HEX, VALS(spice_bitmap_flags_vs), 0x0,
NULL, HFILL }
},
{ &hf_keyboard_modifiers,
{ "Keyboard modifiers", "spice.keyboard_modifiers",
FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_keyboard_modifier_scroll_lock,
{ "Scroll Lock", "spice.keyboard_modifier_scroll_lock",
FT_BOOLEAN, 16, TFS(&tfs_set_notset), SPICE_KEYBOARD_MODIFIER_FLAGS_SCROLL_LOCK,
NULL, HFILL }
},
{ &hf_keyboard_modifier_num_lock,
{ "Num Lock", "spice.keyboard_modifier_num_lock",
FT_BOOLEAN, 16, TFS(&tfs_set_notset), SPICE_KEYBOARD_MODIFIER_FLAGS_NUM_LOCK,
NULL, HFILL }
},
{ &hf_keyboard_modifier_caps_lock,
{ "Caps Lock", "spice.keyboard_modifier_caps_lock",
FT_BOOLEAN, 16, TFS(&tfs_set_notset), SPICE_KEYBOARD_MODIFIER_FLAGS_CAPS_LOCK,
NULL, HFILL }
},
{ &hf_keyboard_code,
{ "Key scan code", "spice.keyboard_key_code",
FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_rectlist_size,
{ "RectList size", "spice.rectlist_size",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_migrate_dest_port,
{ "Migrate Dest Port", "spice.migrate_dest_port",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_migrate_dest_sport,
{ "Migrate Dest Secure Port", "spice.migrate_dest_sport",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_migrate_src_mig_version,
{ "Migrate Source Migration Version", "spice.migrate_src_version",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_session_id,
{ "Session ID", "spice.main_session_id",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_channels_hint,
{ "Number of display channels", "spice.display_channels_hint",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_supported_mouse_modes,
{ "Supported mouse modes", "spice.supported_mouse_modes",
FT_UINT32, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_supported_mouse_modes_flags,
{ "Supported mouse modes", "spice.supported_mouse_modes_flags",
FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_current_mouse_mode,
{ "Current mouse mode", "spice.current_mouse_mode",
FT_UINT32, BASE_HEX, VALS(spice_mouse_mode_vs), 0x0,
NULL, HFILL }
},
{ &hf_supported_mouse_modes_flag_client,
{ "Client mode", "spice.supported_mouse_modes_flag_client",
FT_BOOLEAN, 2, TFS(&tfs_set_notset), SPICE_MOUSE_MODE_CLIENT,
NULL, HFILL }
},
{ &hf_supported_mouse_modes_flag_server,
{ "Server mode", "spice.supported_mouse_modes_flags_server",
FT_BOOLEAN, 2, TFS(&tfs_set_notset), SPICE_MOUSE_MODE_SERVER,
NULL, HFILL }
},
{ &hf_current_mouse_mode_flags,
{ "Current mouse mode", "spice.current_mouse_mode_flags",
FT_UINT16, BASE_HEX, VALS(spice_mouse_mode_vs), 0x0,
NULL, HFILL }
},
{ &hf_agent_connected,
{ "Agent", "spice.agent",
FT_UINT32, BASE_DEC, VALS(spice_agent_vs), 0x0,
NULL, HFILL }
},
{ &hf_agent_tokens,
{ "Agent tokens", "spice.agent_tokens",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_multi_media_time,
{ "Current server multimedia time", "spice.multimedia_time",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_ram_hint,
{ "RAM hint", "spice.ram_hint",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_button_state, /*FIXME - bitmask */
{ "Mouse button state", "spice.button_state",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_mouse_display_id,
{ "Mouse display ID", "spice.mouse_display_id",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_text_fore_mode,
{ "Text foreground mode", "spice.draw_text_fore_mode",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_text_back_mode,
{ "Text background mode", "spice.draw_text_back_mode",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_monitor_config_count,
{ "Monitor count", "spice.monitor_config_count",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_monitor_config_max_allowed,
{ "Max.allowed monitors", "spice.monitor_config_max_allowed",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_stream_id,
{ "Stream ID", "spice.display_stream_id",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_stream_report_unique_id,
{ "Unique ID", "spice.display_stream_report_unique_id",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_stream_report_max_window_size,
{ "Max window size", "spice.display_stream_report_max_window_size",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_stream_report_timeout,
{ "Timeout (ms)", "spice.display_stream_report_timeout",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_stream_flags,
{ "Stream flags", "spice.display_stream_flags",
FT_UINT8, BASE_DEC, VALS(spice_stream_flags_vs), 0x0,
NULL, HFILL }
},
{ &hf_display_stream_codec_type,
{ "Stream codec type", "spice.display_stream_codec_type",
FT_UINT32, BASE_DEC, VALS(spice_video_codec_type_vs), 0x0,
NULL, HFILL }
},
{ &hf_display_stream_stamp,
{ "Stream stamp", "spice.display_stream_stamp",
FT_UINT64, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_stream_data_size,
{ "Stream data size", "spice.display_stream_data_size",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_stream_width,
{ "Stream width", "spice.stream_width",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_stream_height,
{ "Stream height", "spice.stream_height",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_stream_src_width,
{ "Stream source width", "spice.stream_src_width",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_stream_src_height,
{ "Stream source height", "spice.stream_src_height",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_surface_id,
{ "Surface ID", "spice.surface_id",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_surface_width,
{ "Surface width", "spice.surface_width",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_surface_height,
{ "Surface height", "spice.surface_height",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_surface_format,
{ "Surface format", "spice.surface_format",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_surface_flags,
{ "Surface flags", "spice.surface_flags",
FT_UINT32, BASE_DEC, VALS(spice_surface_flags_vs), 0x0,
NULL, HFILL }
},
{ &hf_tranparent_src_color,
{ "Transparent source color", "spice.display_transparent_src_color",
FT_UINT32, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_tranparent_true_color,
{ "Transparent true color", "spice.display_transparent_true_color",
FT_UINT32, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_main_client_agent_tokens,
{ "Agent tokens", "spice.main_agent_tokens",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_agent_protocol,
{ "Agent Protocol version", "spice.main_agent_protocol",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_agent_type,
{ "Agent message type", "spice.agent_message_type",
FT_UINT32, BASE_DEC, VALS(agent_message_type_vs), 0x0,
NULL, HFILL }
},
{ &hf_agent_opaque,
{ "Agent Opaque", "spice.main_agent_opaque",
FT_UINT64, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_agent_size,
{ "Agent message size", "spice.main_agent_size",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_agent_token,
{ "Agent token", "spice.main_agent_token",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_agent_clipboard_selection,
{ "Agent clipboard selection", "spice.main_agent_clipboard_selection",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_agent_clipboard_type,
{ "Agent clipboard type", "spice.main_agent_clipboard_type",
FT_UINT32, BASE_DEC, VALS(agent_clipboard_type), 0x0,
NULL, HFILL }
},
{ &hf_LZ_PLT_type,
{ "LZ_PLT image type", "spice.LZ_PLT_type",
FT_UINT32, BASE_DEC, VALS(LzImage_type_vs), 0x0,
NULL, HFILL }
},
{ &hf_spice_sasl_auth_result,
{ "Authentication result", "spice.sasl_auth_result",
FT_UINT8, BASE_DEC, VALS(spice_sasl_auth_result_vs), 0x0,
NULL, HFILL }
},
{ &hf_main_uuid,
{ "UUID", "spice.main_uuid",
FT_GUID, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_main_name_len,
{ "Name length", "spice.main_name_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_main_name,
{ "Name", "spice.main_name",
FT_STRINGZ, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_head_id,
{ "Head ID", "spice.display_head_id",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_head_surface_id,
{ "Head surface ID", "spice.display_head_surface_id",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_head_width,
{ "Head width", "spice.display_head_width",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_head_height,
{ "Head height", "spice.display_head_height",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_head_x,
{ "Head X coordinate", "spice.display_head_x",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_head_y,
{ "Head Y coordinate", "spice.display_head_y",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_head_flags,
{ "Head flags", "spice.display_head_flags",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_zlib_uncompress_size,
{ "ZLIB stream uncompressed size", "spice.zlib_uncompress_size",
FT_UINT32, BASE_DEC|BASE_UNIT_STRING, &units_byte_bytes, 0x0,
NULL, HFILL }
},
{ &hf_zlib_compress_size,
{ "ZLIB stream compressed size", "spice.zlib_compress_size",
FT_UINT32, BASE_DEC|BASE_UNIT_STRING, &units_byte_bytes, 0x0,
NULL, HFILL }
},
{ &hf_rect_left,
{ "left", "spice.rect.left",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_rect_top,
{ "top", "spice.rect.top",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_rect_right,
{ "right", "spice.rect.right",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_rect_bottom,
{ "bottom", "spice.rect.bottom",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_point32_x,
{ "x", "spice.point32.x",
FT_INT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_point32_y,
{ "y", "spice.point32.y",
FT_INT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_point16_x,
{ "x", "spice.point16.x",
FT_INT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_point16_y,
{ "y", "spice.point16.y",
FT_INT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_severity,
{ "Severity", "spice.notify_severity",
FT_UINT32, BASE_DEC, VALS(spice_notify_severity_vs), 0x0,
NULL, HFILL }
},
{ &hf_visibility,
{ "Visibility", "spice.notify_visibility",
FT_UINT32, BASE_DEC, VALS(spice_notify_visibility_vs), 0x0,
NULL, HFILL }
},
{ &hf_notify_code,
{ "error/warn/info code", "spice.notify_code",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_notify_message_len,
{ "Message length", "spice.notify_message_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_notify_message,
{ "Message", "spice.notify_message",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_num_glyphs,
{ "Number of glyphs", "spice.num_glyphs",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_port_opened,
{ "Opened", "spice.port_opened",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_port_event,
{ "Event", "spice.port_event",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_raw_data,
{ "data", "spice.data",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_display_inval_list_count,
{ "count", "spice.display_inval_list_count",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_resource_type,
{ "Type", "spice.resource_type",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_resource_id,
{ "id", "spice.resource_id",
FT_UINT64, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_ref_image,
{ "Image address", "spice.ref_image",
FT_UINT32, BASE_HEX_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_ref_string,
{ "String address", "spice.ref_string",
FT_UINT32, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_agent_num_monitors,
{ "Number of monitors", "spice.agent_num_monitors",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_agent_monitor_height,
{ "Height", "spice.agent_monitor_height",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_agent_monitor_width,
{ "Width", "spice.agent_monitor_width",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_agent_monitor_depth,
{ "Depth", "spice.agent_monitor_depth",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_agent_monitor_x,
{ "x", "spice.agent_monitor_x",
FT_INT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_agent_monitor_y,
{ "y", "spice.agent_monitor_y",
FT_INT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_vd_agent_caps_request,
{ "Request", "spice.vd_agent_caps_request",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_vd_agent_cap_mouse_state,
{ "Mouse State", "spice.vd_agent_cap_mouse_state",
FT_BOOLEAN, 32, TFS(&tfs_set_notset), VD_AGENT_CAP_MOUSE_STATE,
NULL, HFILL }
},
{ &hf_vd_agent_cap_monitors_config,
{ "Monitors config", "spice.vd_agent_cap_monitors_config",
FT_BOOLEAN, 32, TFS(&tfs_set_notset), VD_AGENT_CAP_MONITORS_CONFIG,
NULL, HFILL }
},
{ &hf_vd_agent_cap_reply,
{ "Reply", "spice.vd_agent_cap_reply",
FT_BOOLEAN, 32, TFS(&tfs_set_notset), VD_AGENT_CAP_REPLY,
NULL, HFILL }
},
{ &hf_vd_agent_cap_clipboard,
{ "Clipboard", "spice.vd_agent_cap_clipboard",
FT_BOOLEAN, 32, TFS(&tfs_set_notset), VD_AGENT_CAP_CLIPBOARD,
NULL, HFILL }
},
{ &hf_vd_agent_cap_display_config,
{ "Display config", "spice.vd_agent_cap_display_config",
FT_BOOLEAN, 32, TFS(&tfs_set_notset), VD_AGENT_CAP_DISPLAY_CONFIG,
NULL, HFILL }
},
{ &hf_vd_agent_cap_clipboard_by_demand,
{ "Clipboard by demand", "spice.vd_agent_cap_clipboard_by_demand",
FT_BOOLEAN, 32, TFS(&tfs_set_notset), VD_AGENT_CAP_CLIPBOARD_BY_DEMAND,
NULL, HFILL }
},
{ &hf_vd_agent_cap_clipboard_selection,
{ "Clipboard selection", "spice.vd_agent_cap_clipboard_selection",
FT_BOOLEAN, 32, TFS(&tfs_set_notset), VD_AGENT_CAP_CLIPBOARD_SELECTION,
NULL, HFILL }
},
{ &hf_vd_agent_cap_sparse_monitors_config,
{ "Sparse monitors config", "spice.vd_agent_cap_sparse_monitors_config",
FT_BOOLEAN, 32, TFS(&tfs_set_notset), VD_AGENT_CAP_SPARSE_MONITORS_CONFIG,
NULL, HFILL }
},
{ &hf_vd_agent_cap_guest_lineend_lf,
{ "Guest line-end LF", "spice.vd_agent_cap_guest_lineend_lf",
FT_BOOLEAN, 32, TFS(&tfs_set_notset), VD_AGENT_CAP_GUEST_LINEEND_LF,
NULL, HFILL }
},
{ &hf_vd_agent_cap_guest_lineend_crlf,
{ "Guest line-end CRLF", "spice.vd_agent_cap_guest_lineend_crlf",
FT_BOOLEAN, 32, TFS(&tfs_set_notset), VD_AGENT_CAP_GUEST_LINEEND_CRLF,
NULL, HFILL }
},
{ &hf_vd_agent_monitors_config_flag_use_pos,
{ "Use position", "spice.vd_agent_monitors_config_flag_use_pos",
FT_BOOLEAN, 32, TFS(&tfs_set_notset), VD_AGENT_CONFIG_MONITORS_FLAG_USE_POS,
NULL, HFILL }
},
{ &hf_vd_agent_reply_type,
{ "Type", "spice.vd_agent_reply_type",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_vd_agent_reply_error,
{ "Error", "spice.vd_agent_reply_error",
FT_UINT32, BASE_DEC, VALS(vd_agent_reply_error_vs), 0x0,
NULL, HFILL }
},
/* Generated from convert_proto_tree_add_text.pl */
{ &hf_spice_pixmap_pixels, { "Pixmap pixels", "spice.pixmap_pixels", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_palette, { "Palette", "spice.palette", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_cursor_data, { "Cursor data", "spice.cursor_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_quic_image_size, { "QUIC image size", "spice.quic_image_size", FT_UINT32, BASE_DEC|BASE_UNIT_STRING, &units_byte_bytes, 0x0, NULL, HFILL }},
{ &hf_spice_quic_magic, { "QUIC magic", "spice.quic_magic", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_quic_compressed_image_data, { "QUIC compressed image data", "spice.quic_compressed_image_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_lz_magic, { "LZ magic", "spice.lz_magic", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_lz_rgb_compressed_image_data, { "LZ_RGB compressed image data", "spice.lz_rgb_compressed_image_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_topdown_flag, { "Topdown flag", "spice.topdown_flag", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_unknown_bytes, { "Unknown bytes", "spice.unknown_bytes", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
#if 0
{ &hf_spice_lz_jpeg_image_size, { "LZ JPEG image size", "spice.lz_jpeg_image_size", FT_UINT32, BASE_DEC|BASE_UNIT_STRING, &units_byte_bytes, 0x0, NULL, HFILL }},
#endif
{ &hf_spice_glz_rgb_image_size, { "GLZ RGB image size", "spice.glz_rgb_image_size", FT_UINT32, BASE_DEC|BASE_UNIT_STRING, &units_byte_bytes, 0x0, NULL, HFILL }},
{ &hf_spice_lz_rgb_image_size, { "LZ RGB image size", "spice.lz_rgb_image_size", FT_UINT32, BASE_DEC|BASE_UNIT_STRING, &units_byte_bytes, 0x0, NULL, HFILL }},
{ &hf_spice_lz_plt_flag, { "LZ_PLT Flag", "spice.lz_plt_flag", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_lz_plt_image_size, { "LZ PLT image size", "spice.lz_plt_image_size", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_palette_offset, { "palette offset", "spice.palette_offset", FT_UINT32, BASE_DEC|BASE_UNIT_STRING, &units_byte_bytes, 0x0, NULL, HFILL }},
{ &hf_spice_lz_plt_data, { "LZ_PLT data", "spice.lz_plt_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_zlib_stream, { "ZLIB stream", "spice.zlib_stream", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_image_from_cache, { "Image from Cache", "spice.image_from_cache", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_surface_id, { "Surface ID", "spice.surface_id", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_image_from_cache_lossless, { "Image from Cache - lossless", "spice.image_from_cache_lossless", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_ping_data, { "PING DATA", "spice.ping_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_display_mark_message, { "DISPLAY_MARK message", "spice.display_mark_message", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_display_reset_message, { "DISPLAY_RESET message", "spice.display_reset_message", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_rop3, { "ROP3", "spice.rop3", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_scale_mode, { "scale mode", "spice.scale_mode", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_glyph_flags, { "Glyph flags", "spice.glyph_flags", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_stream_data, { "Stream data", "spice.stream_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_vd_agent_clipboard_message, { "VD_AGENT_CLIPBOARD message", "spice.vd_agent_clipboard_message", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_vd_agent_display_config_message, { "VD_AGENT_DISPLAY_CONFIG message", "spice.vd_agent_display_config_message", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_reserved, { "Reserved", "spice.reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_vd_agent_clipboard_release_message, { "VD_AGENT_CLIPBOARD_RELEASE message", "spice.vd_agent_clipboard_release_message", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_server_inputs_mouse_motion_ack_message, { "Server INPUTS_MOUSE_MOTION_ACK message", "spice.server_inputs_mouse_motion_ack_message", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_name_length, { "Name length (bytes)", "spice.name_length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_x509_subjectpublickeyinfo, { "X.509 SubjectPublicKeyInfo (ASN.1)", "spice.x509_subjectpublickeyinfo", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_sasl_message_length, { "SASL message length", "spice.sasl_message_length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_supported_authentication_mechanisms_list_length, { "Supported authentication mechanisms list length", "spice.supported_authentication_mechanisms_list_length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_supported_authentication_mechanisms_list, { "Supported authentication mechanisms list", "spice.supported_authentication_mechanisms_list", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_selected_authentication_mechanism_length, { "Selected authentication mechanism length", "spice.selected_authentication_mechanism_length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_selected_authentication_mechanism, { "Selected authentication mechanism", "spice.selected_authentication_mechanism", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_client_out_mechanism_length, { "Client out mechanism length", "spice.client_out_mechanism_length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_selected_client_out_mechanism, { "Selected client out mechanism", "spice.selected_client_out_mechanism", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_sasl_authentication_data, { "SASL authentication data", "spice.sasl_authentication_data", FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_clientout_length, { "clientout length", "spice.clientout_length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_clientout_list, { "clientout list", "spice.clientout_list", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_spice_sasl_data, { "SASL data", "spice.sasl_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
};
/* Setup protocol subtree arrays */
static gint *ett[] = {
&ett_spice,
&ett_link_client,
&ett_link_server,
&ett_link_caps,
&ett_ticket_client,
&ett_auth_select_client,
&ett_ticket_server,
&ett_data,
&ett_message,
&ett_playback,
&ett_common_server_message,
&ett_common_client_message,
&ett_display_client,
&ett_display_server,
&ett_point,
&ett_point16,
&ett_rect,
&ett_DisplayBase,
&ett_Clip,
&ett_Mask,
&ett_imagedesc,
&ett_imageQuic,
&ett_GLZ_RGB,
&ett_LZ_RGB,
&ett_ZLIB_GLZ,
&ett_Uncomp_tree,
&ett_LZ_JPEG,
&ett_LZ_PLT,
&ett_JPEG,
&ett_cursor_header,
&ett_RedCursor,
&ett_cursor,
&ett_spice_main,
&ett_brush,
&ett_pattern,
&ett_Pixmap,
&ett_SpiceHead,
&ett_inputs_client,
&ett_rectlist,
&ett_inputs_server,
&ett_record_client,
&ett_record_server,
&ett_main_client,
&ett_spice_agent,
&ett_cap_tree
};
static ei_register_info ei[] = {
{ &ei_spice_decompress_error, { "spice.decompress_error", PI_PROTOCOL, PI_WARN, "Error: Unable to decompress content", EXPFILL }},
{ &ei_spice_unknown_message, { "spice.unknown_message", PI_UNDECODED, PI_WARN, "Unknown message - cannot dissect", EXPFILL }},
{ &ei_spice_not_dissected, { "spice.not_dissected", PI_UNDECODED, PI_WARN, "Message not dissected", EXPFILL }},
{ &ei_spice_auth_unknown, { "spice.auth_unknown", PI_PROTOCOL, PI_WARN, "Unknown authentication selected", EXPFILL }},
{ &ei_spice_sasl_auth_result, { "spice.sasl_auth_result.expert", PI_PROTOCOL, PI_WARN, "Bad sasl_auth_result", EXPFILL }},
{ &ei_spice_expected_from_client, { "spice.expected_from_client", PI_PROTOCOL, PI_WARN, "SPICE_CLIENT_AUTH_SELECT: packet from server - expected from client", EXPFILL }},
/* Generated from convert_proto_tree_add_text.pl */
{ &ei_spice_unknown_image_type, { "spice.unknown_image_type", PI_UNDECODED, PI_WARN, "Unknown image type - cannot dissect", EXPFILL }},
{ &ei_spice_brush_type, { "spice.brush_type.invalid", PI_PROTOCOL, PI_WARN, "Invalid Brush type", EXPFILL }},
{ &ei_spice_Mask_flag, { "spice.mask_flag.irrelevant", PI_PROTOCOL, PI_NOTE, "value irrelevant as bitmap address is 0", EXPFILL }},
{ &ei_spice_Mask_point, { "spice.mask_point.irrelevant", PI_PROTOCOL, PI_NOTE, "value irrelevant as bitmap address is 0", EXPFILL }},
{ &ei_spice_unknown_channel, { "spice.unknown_channel", PI_UNDECODED, PI_WARN, "Unknown channel - cannot dissect", EXPFILL }},
{ &ei_spice_common_cap_unknown, { "spice.common_cap.unknown", PI_PROTOCOL, PI_WARN, "Unknown common capability", EXPFILL }},
};
expert_module_t* expert_spice;
/* Register the protocol name and description */
proto_spice = proto_register_protocol("Spice protocol", "Spice", "spice");
/* Required function calls to register the header fields and subtrees */
proto_register_field_array(proto_spice, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_spice = expert_register_protocol(proto_spice);
expert_register_field_array(expert_spice, ei, array_length(ei));
}
void
proto_reg_handoff_spice(void)
{
spice_handle = create_dissector_handle(dissect_spice, proto_spice);
dissector_add_for_decode_as_with_preference("tcp.port", spice_handle);
heur_dissector_add("tcp", test_spice_protocol, "Spice over TCP", "spice_tcp", proto_spice, HEURISTIC_ENABLE);
jpeg_handle = find_dissector_add_dependency("image-jfif", proto_spice);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-spice.h
|
/* this is a file autogenerated by spice_codegen.py */
/*
* Copyright (C) 2013 Red Hat, Inc.
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#ifndef _H_SPICE_ENUMS
#define _H_SPICE_ENUMS
typedef enum SpiceLinkErr {
SPICE_LINK_ERR_OK,
SPICE_LINK_ERR_ERROR,
SPICE_LINK_ERR_INVALID_MAGIC,
SPICE_LINK_ERR_INVALID_DATA,
SPICE_LINK_ERR_VERSION_MISMATCH,
SPICE_LINK_ERR_NEED_SECURED,
SPICE_LINK_ERR_NEED_UNSECURED,
SPICE_LINK_ERR_PERMISSION_DENIED,
SPICE_LINK_ERR_BAD_CONNECTION_ID,
SPICE_LINK_ERR_CHANNEL_NOT_AVAILABLE,
SPICE_LINK_ERR_ENUM_END
} SpiceLinkErr;
static const value_string spice_link_err_vs[] = {
{ SPICE_LINK_ERR_OK, "OK" },
{ SPICE_LINK_ERR_ERROR, "ERROR" },
{ SPICE_LINK_ERR_INVALID_MAGIC, "INVALID_MAGIC" },
{ SPICE_LINK_ERR_INVALID_DATA, "INVALID_DATA" },
{ SPICE_LINK_ERR_VERSION_MISMATCH, "VERSION_MISMATCH" },
{ SPICE_LINK_ERR_NEED_SECURED, "NEED_SECURED" },
{ SPICE_LINK_ERR_NEED_UNSECURED, "NEED_UNSECURED" },
{ SPICE_LINK_ERR_PERMISSION_DENIED, "PERMISSION_DENIED" },
{ SPICE_LINK_ERR_BAD_CONNECTION_ID, "BAD_CONNECTION_ID" },
{ SPICE_LINK_ERR_CHANNEL_NOT_AVAILABLE, "CHANNEL_NOT_AVAILABLE" },
{ 0, NULL } };
typedef enum SpiceWarnCode {
SPICE_WARN_GENERAL,
SPICE_WARN_CODE_ENUM_END
} SpiceWarnCode;
static const value_string spice_warn_code_vs[] = {
{ SPICE_WARN_GENERAL, "WARN_GENERAL" },
{ 0, NULL } };
typedef enum SpiceInfoCode {
SPICE_INFO_GENERAL,
SPICE_INFO_CODE_ENUM_END
} SpiceInfoCode;
static const value_string spice_info_code_vs[] = {
{ SPICE_INFO_GENERAL, "INFO_GENERAL" },
{ 0, NULL } };
typedef enum SpiceMigrateFlags {
SPICE_MIGRATE_NEED_FLUSH = (1 << 0),
SPICE_MIGRATE_NEED_DATA_TRANSFER = (1 << 1),
SPICE_MIGRATE_FLAGS_MASK = 0x3
} SpiceMigrateFlags;
static const value_string spice_migrate_flags_vs[] = {
{ SPICE_MIGRATE_NEED_FLUSH, "NEED_FLUSH" },
{ SPICE_MIGRATE_NEED_DATA_TRANSFER, "NEED_DATA_TRANSFER" },
{ 0, NULL } };
typedef enum SpiceCompositeFlags {
SPICE_COMPOSITE_OP0 = (1 << 0),
SPICE_COMPOSITE_OP1 = (1 << 1),
SPICE_COMPOSITE_OP2 = (1 << 2),
SPICE_COMPOSITE_OP3 = (1 << 3),
SPICE_COMPOSITE_OP4 = (1 << 4),
SPICE_COMPOSITE_OP5 = (1 << 5),
SPICE_COMPOSITE_OP6 = (1 << 6),
SPICE_COMPOSITE_OP7 = (1 << 7),
SPICE_COMPOSITE_SRC_FILTER0 = (1 << 8),
SPICE_COMPOSITE_SRC_FILTER1 = (1 << 9),
SPICE_COMPOSITE_SRC_FILTER2 = (1 << 10),
SPICE_COMPOSITE_MASK_FILTER0 = (1 << 11),
SPICE_COMPOSITE_MASK_FITLER1 = (1 << 12),
SPICE_COMPOSITE_MASK_FILTER2 = (1 << 13),
SPICE_COMPOSITE_SRC_REPEAT0 = (1 << 14),
SPICE_COMPOSITE_SRC_REPEAT1 = (1 << 15),
SPICE_COMPOSITE_MASK_REPEAT0 = (1 << 16),
SPICE_COMPOSITE_MASK_REPEAT1 = (1 << 17),
SPICE_COMPOSITE_COMPONENT_ALPHA = (1 << 18),
SPICE_COMPOSITE_HAS_MASK = (1 << 19),
SPICE_COMPOSITE_HAS_SRC_TRANSFORM = (1 << 20),
SPICE_COMPOSITE_HAS_MASK_TRANSFORM = (1 << 21),
SPICE_COMPOSITE_SOURCE_OPAQUE = (1 << 22),
SPICE_COMPOSITE_MASK_OPAQUE = (1 << 23),
SPICE_COMPOSITE_DEST_OPAQUE = (1 << 24),
SPICE_COMPOSITE_FLAGS_MASK = 0x1ffffff
} SpiceCompositeFlags;
static const value_string spice_composite_flags_vs[] = {
{ SPICE_COMPOSITE_OP0, "OP0" },
{ SPICE_COMPOSITE_OP1, "OP1" },
{ SPICE_COMPOSITE_OP2, "OP2" },
{ SPICE_COMPOSITE_OP3, "OP3" },
{ SPICE_COMPOSITE_OP4, "OP4" },
{ SPICE_COMPOSITE_OP5, "OP5" },
{ SPICE_COMPOSITE_OP6, "OP6" },
{ SPICE_COMPOSITE_OP7, "OP7" },
{ SPICE_COMPOSITE_SRC_FILTER0, "SRC_FILTER0" },
{ SPICE_COMPOSITE_SRC_FILTER1, "SRC_FILTER1" },
{ SPICE_COMPOSITE_SRC_FILTER2, "SRC_FILTER2" },
{ SPICE_COMPOSITE_MASK_FILTER0, "MASK_FILTER0" },
{ SPICE_COMPOSITE_MASK_FITLER1, "MASK_FITLER1" },
{ SPICE_COMPOSITE_MASK_FILTER2, "MASK_FILTER2" },
{ SPICE_COMPOSITE_SRC_REPEAT0, "SRC_REPEAT0" },
{ SPICE_COMPOSITE_SRC_REPEAT1, "SRC_REPEAT1" },
{ SPICE_COMPOSITE_MASK_REPEAT0, "MASK_REPEAT0" },
{ SPICE_COMPOSITE_MASK_REPEAT1, "MASK_REPEAT1" },
{ SPICE_COMPOSITE_COMPONENT_ALPHA, "COMPONENT_ALPHA" },
{ SPICE_COMPOSITE_HAS_MASK, "HAS_MASK" },
{ SPICE_COMPOSITE_HAS_SRC_TRANSFORM, "HAS_SRC_TRANSFORM" },
{ SPICE_COMPOSITE_HAS_MASK_TRANSFORM, "HAS_MASK_TRANSFORM" },
{ SPICE_COMPOSITE_SOURCE_OPAQUE, "SOURCE_OPAQUE" },
{ SPICE_COMPOSITE_MASK_OPAQUE, "MASK_OPAQUE" },
{ SPICE_COMPOSITE_DEST_OPAQUE, "DEST_OPAQUE" },
{ 0, NULL } };
typedef enum SpiceNotifySeverity {
SPICE_NOTIFY_SEVERITY_INFO,
SPICE_NOTIFY_SEVERITY_WARN,
SPICE_NOTIFY_SEVERITY_ERROR,
SPICE_NOTIFY_SEVERITY_ENUM_END
} SpiceNotifySeverity;
static const value_string spice_notify_severity_vs[] = {
{ SPICE_NOTIFY_SEVERITY_INFO, "INFO" },
{ SPICE_NOTIFY_SEVERITY_WARN, "WARN" },
{ SPICE_NOTIFY_SEVERITY_ERROR, "ERROR" },
{ 0, NULL } };
typedef enum SpiceNotifyVisibility {
SPICE_NOTIFY_VISIBILITY_LOW,
SPICE_NOTIFY_VISIBILITY_MEDIUM,
SPICE_NOTIFY_VISIBILITY_HIGH,
SPICE_NOTIFY_VISIBILITY_ENUM_END
} SpiceNotifyVisibility;
static const value_string spice_notify_visibility_vs[] = {
{ SPICE_NOTIFY_VISIBILITY_LOW, "LOW" },
{ SPICE_NOTIFY_VISIBILITY_MEDIUM, "MEDIUM" },
{ SPICE_NOTIFY_VISIBILITY_HIGH, "HIGH" },
{ 0, NULL } };
typedef enum SpiceMouseMode {
SPICE_MOUSE_MODE_SERVER = (1 << 0),
SPICE_MOUSE_MODE_CLIENT = (1 << 1),
SPICE_MOUSE_MODE_MASK = 0x3
} SpiceMouseMode;
static const value_string spice_mouse_mode_vs[] = {
{ SPICE_MOUSE_MODE_SERVER, "SERVER" },
{ SPICE_MOUSE_MODE_CLIENT, "CLIENT" },
{ 0, NULL } };
typedef enum SpicePubkeyType {
SPICE_PUBKEY_TYPE_INVALID,
SPICE_PUBKEY_TYPE_RSA,
SPICE_PUBKEY_TYPE_RSA2,
SPICE_PUBKEY_TYPE_DSA,
SPICE_PUBKEY_TYPE_DSA1,
SPICE_PUBKEY_TYPE_DSA2,
SPICE_PUBKEY_TYPE_DSA3,
SPICE_PUBKEY_TYPE_DSA4,
SPICE_PUBKEY_TYPE_DH,
SPICE_PUBKEY_TYPE_EC,
SPICE_PUBKEY_TYPE_ENUM_END
} SpicePubkeyType;
static const value_string spice_pubkey_type_vs[] = {
{ SPICE_PUBKEY_TYPE_INVALID, "INVALID" },
{ SPICE_PUBKEY_TYPE_RSA, "RSA" },
{ SPICE_PUBKEY_TYPE_RSA2, "RSA2" },
{ SPICE_PUBKEY_TYPE_DSA, "DSA" },
{ SPICE_PUBKEY_TYPE_DSA1, "DSA1" },
{ SPICE_PUBKEY_TYPE_DSA2, "DSA2" },
{ SPICE_PUBKEY_TYPE_DSA3, "DSA3" },
{ SPICE_PUBKEY_TYPE_DSA4, "DSA4" },
{ SPICE_PUBKEY_TYPE_DH, "DH" },
{ SPICE_PUBKEY_TYPE_EC, "EC" },
{ 0, NULL } };
typedef enum SpiceDataCompressionType {
SPICE_DATA_COMPRESSION_TYPE_NONE,
SPICE_DATA_COMPRESSION_TYPE_LZ4,
SPICE_DATA_COMPRESSION_TYPE_ENUM_END
} SpiceDataCompressionType;
static const value_string spice_data_compression_type_vs[] = {
{ SPICE_DATA_COMPRESSION_TYPE_NONE, "NONE" },
{ SPICE_DATA_COMPRESSION_TYPE_LZ4, "LZ4" },
{ 0, NULL } };
typedef enum SpiceClipType {
SPICE_CLIP_TYPE_NONE,
SPICE_CLIP_TYPE_RECTS,
SPICE_CLIP_TYPE_ENUM_END
} SpiceClipType;
static const value_string spice_clip_type_vs[] = {
{ SPICE_CLIP_TYPE_NONE, "NONE" },
{ SPICE_CLIP_TYPE_RECTS, "RECTS" },
{ 0, NULL } };
typedef enum SpicePathFlags {
SPICE_PATH_BEGIN = (1 << 0),
SPICE_PATH_END = (1 << 1),
SPICE_PATH_CLOSE = (1 << 3),
SPICE_PATH_BEZIER = (1 << 4),
SPICE_PATH_FLAGS_MASK = 0x1b
} SpicePathFlags;
static const value_string spice_path_flags_vs[] = {
{ SPICE_PATH_BEGIN, "BEGIN" },
{ SPICE_PATH_END, "END" },
{ SPICE_PATH_CLOSE, "CLOSE" },
{ SPICE_PATH_BEZIER, "BEZIER" },
{ 0, NULL } };
typedef enum SpiceVideoCodecType {
SPICE_VIDEO_CODEC_TYPE_MJPEG = 1,
SPICE_VIDEO_CODEC_TYPE_VP8,
SPICE_VIDEO_CODEC_TYPE_H264,
SPICE_VIDEO_CODEC_TYPE_VP9,
SPICE_VIDEO_CODEC_TYPE_H265,
SPICE_VIDEO_CODEC_TYPE_ENUM_END
} SpiceVideoCodecType;
static const value_string spice_video_codec_type_vs[] = {
{ SPICE_VIDEO_CODEC_TYPE_MJPEG, "MJPEG" },
{ SPICE_VIDEO_CODEC_TYPE_VP8, "VP8" },
{ SPICE_VIDEO_CODEC_TYPE_H264, "H264" },
{ SPICE_VIDEO_CODEC_TYPE_VP9, "VP9" },
{ SPICE_VIDEO_CODEC_TYPE_H265, "H265" },
{ 0, NULL } };
typedef enum SpiceStreamFlags {
SPICE_STREAM_FLAGS_TOP_DOWN = (1 << 0),
SPICE_STREAM_FLAGS_MASK = 0x1
} SpiceStreamFlags;
static const value_string spice_stream_flags_vs[] = {
{ SPICE_STREAM_FLAGS_TOP_DOWN, "TOP_DOWN" },
{ 0, NULL } };
typedef enum SpiceBrushType {
SPICE_BRUSH_TYPE_NONE,
SPICE_BRUSH_TYPE_SOLID,
SPICE_BRUSH_TYPE_PATTERN,
SPICE_BRUSH_TYPE_ENUM_END
} SpiceBrushType;
static const value_string spice_brush_type_vs[] = {
{ SPICE_BRUSH_TYPE_NONE, "NONE" },
{ SPICE_BRUSH_TYPE_SOLID, "SOLID" },
{ SPICE_BRUSH_TYPE_PATTERN, "PATTERN" },
{ 0, NULL } };
typedef enum SpiceMaskFlags {
SPICE_MASK_FLAGS_INVERS = (1 << 0),
SPICE_MASK_FLAGS_MASK = 0x1
} SpiceMaskFlags;
static const value_string spice_mask_flags_vs[] = {
{ SPICE_MASK_FLAGS_INVERS, "INVERS" },
{ 0, NULL } };
typedef enum SpiceImageType {
SPICE_IMAGE_TYPE_BITMAP,
SPICE_IMAGE_TYPE_QUIC,
SPICE_IMAGE_TYPE_RESERVED,
SPICE_IMAGE_TYPE_LZ_PLT = 100,
SPICE_IMAGE_TYPE_LZ_RGB,
SPICE_IMAGE_TYPE_GLZ_RGB,
SPICE_IMAGE_TYPE_FROM_CACHE,
SPICE_IMAGE_TYPE_SURFACE,
SPICE_IMAGE_TYPE_JPEG,
SPICE_IMAGE_TYPE_FROM_CACHE_LOSSLESS,
SPICE_IMAGE_TYPE_ZLIB_GLZ_RGB,
SPICE_IMAGE_TYPE_JPEG_ALPHA,
SPICE_IMAGE_TYPE_LZ4,
SPICE_IMAGE_TYPE_ENUM_END
} SpiceImageType;
static const value_string spice_image_type_vs[] = {
{ SPICE_IMAGE_TYPE_BITMAP, "BITMAP" },
{ SPICE_IMAGE_TYPE_QUIC, "QUIC" },
{ SPICE_IMAGE_TYPE_RESERVED, "RESERVED" },
{ SPICE_IMAGE_TYPE_LZ_PLT, "LZ_PLT" },
{ SPICE_IMAGE_TYPE_LZ_RGB, "LZ_RGB" },
{ SPICE_IMAGE_TYPE_GLZ_RGB, "GLZ_RGB" },
{ SPICE_IMAGE_TYPE_FROM_CACHE, "FROM_CACHE" },
{ SPICE_IMAGE_TYPE_SURFACE, "SURFACE" },
{ SPICE_IMAGE_TYPE_JPEG, "JPEG" },
{ SPICE_IMAGE_TYPE_FROM_CACHE_LOSSLESS, "FROM_CACHE_LOSSLESS" },
{ SPICE_IMAGE_TYPE_ZLIB_GLZ_RGB, "ZLIB_GLZ_RGB" },
{ SPICE_IMAGE_TYPE_JPEG_ALPHA, "JPEG_ALPHA" },
{ SPICE_IMAGE_TYPE_LZ4, "LZ4" },
{ 0, NULL } };
typedef enum SpiceImageCompression {
SPICE_IMAGE_COMPRESSION_INVALID,
SPICE_IMAGE_COMPRESSION_OFF,
SPICE_IMAGE_COMPRESSION_AUTO_GLZ,
SPICE_IMAGE_COMPRESSION_AUTO_LZ,
SPICE_IMAGE_COMPRESSION_QUIC,
SPICE_IMAGE_COMPRESSION_GLZ,
SPICE_IMAGE_COMPRESSION_LZ,
SPICE_IMAGE_COMPRESSION_LZ4,
SPICE_IMAGE_COMPRESSION_ENUM_END
} SpiceImageCompression;
static const value_string spice_image_compression_vs[] = {
{ SPICE_IMAGE_COMPRESSION_INVALID, "INVALID" },
{ SPICE_IMAGE_COMPRESSION_OFF, "OFF" },
{ SPICE_IMAGE_COMPRESSION_AUTO_GLZ, "AUTO_GLZ" },
{ SPICE_IMAGE_COMPRESSION_AUTO_LZ, "AUTO_LZ" },
{ SPICE_IMAGE_COMPRESSION_QUIC, "QUIC" },
{ SPICE_IMAGE_COMPRESSION_GLZ, "GLZ" },
{ SPICE_IMAGE_COMPRESSION_LZ, "LZ" },
{ SPICE_IMAGE_COMPRESSION_LZ4, "LZ4" },
{ 0, NULL } };
typedef enum SpiceImageFlags {
SPICE_IMAGE_FLAGS_CACHE_ME = (1 << 0),
SPICE_IMAGE_FLAGS_HIGH_BITS_SET = (1 << 1),
SPICE_IMAGE_FLAGS_CACHE_REPLACE_ME = (1 << 2),
SPICE_IMAGE_FLAGS_MASK = 0x7
} SpiceImageFlags;
static const value_string spice_image_flags_vs[] = {
{ SPICE_IMAGE_FLAGS_CACHE_ME, "CACHE_ME" },
{ SPICE_IMAGE_FLAGS_HIGH_BITS_SET, "HIGH_BITS_SET" },
{ SPICE_IMAGE_FLAGS_CACHE_REPLACE_ME, "CACHE_REPLACE_ME" },
{ 0, NULL } };
typedef enum SpiceBitmapFmt {
SPICE_BITMAP_FMT_INVALID,
SPICE_BITMAP_FMT_1BIT_LE,
SPICE_BITMAP_FMT_1BIT_BE,
SPICE_BITMAP_FMT_4BIT_LE,
SPICE_BITMAP_FMT_4BIT_BE,
SPICE_BITMAP_FMT_8BIT,
SPICE_BITMAP_FMT_16BIT,
SPICE_BITMAP_FMT_24BIT,
SPICE_BITMAP_FMT_32BIT,
SPICE_BITMAP_FMT_RGBA,
SPICE_BITMAP_FMT_8BIT_A,
SPICE_BITMAP_FMT_ENUM_END
} SpiceBitmapFmt;
static const value_string spice_bitmap_fmt_vs[] = {
{ SPICE_BITMAP_FMT_INVALID, "INVALID" },
{ SPICE_BITMAP_FMT_1BIT_LE, "1BIT_LE" },
{ SPICE_BITMAP_FMT_1BIT_BE, "1BIT_BE" },
{ SPICE_BITMAP_FMT_4BIT_LE, "4BIT_LE" },
{ SPICE_BITMAP_FMT_4BIT_BE, "4BIT_BE" },
{ SPICE_BITMAP_FMT_8BIT, "8BIT" },
{ SPICE_BITMAP_FMT_16BIT, "16BIT" },
{ SPICE_BITMAP_FMT_24BIT, "24BIT" },
{ SPICE_BITMAP_FMT_32BIT, "32BIT" },
{ SPICE_BITMAP_FMT_RGBA, "RGBA" },
{ SPICE_BITMAP_FMT_8BIT_A, "8BIT_A" },
{ 0, NULL } };
typedef enum SpiceBitmapFlags {
SPICE_BITMAP_FLAGS_PAL_CACHE_ME = (1 << 0),
SPICE_BITMAP_FLAGS_PAL_FROM_CACHE = (1 << 1),
SPICE_BITMAP_FLAGS_TOP_DOWN = (1 << 2),
SPICE_BITMAP_FLAGS_MASK = 0x7
} SpiceBitmapFlags;
static const value_string spice_bitmap_flags_vs[] = {
{ SPICE_BITMAP_FLAGS_PAL_CACHE_ME, "PAL_CACHE_ME" },
{ SPICE_BITMAP_FLAGS_PAL_FROM_CACHE, "PAL_FROM_CACHE" },
{ SPICE_BITMAP_FLAGS_TOP_DOWN, "TOP_DOWN" },
{ 0, NULL } };
typedef enum SpiceJpegAlphaFlags {
SPICE_JPEG_ALPHA_FLAGS_TOP_DOWN = (1 << 0),
SPICE_JPEG_ALPHA_FLAGS_MASK = 0x1
} SpiceJpegAlphaFlags;
static const value_string spice_jpeg_alpha_flags_vs[] = {
{ SPICE_JPEG_ALPHA_FLAGS_TOP_DOWN, "TOP_DOWN" },
{ 0, NULL } };
typedef enum SpiceImageScaleMode {
SPICE_IMAGE_SCALE_MODE_INTERPOLATE,
SPICE_IMAGE_SCALE_MODE_NEAREST,
SPICE_IMAGE_SCALE_MODE_ENUM_END
} SpiceImageScaleMode;
static const value_string spice_image_scale_mode_vs[] = {
{ SPICE_IMAGE_SCALE_MODE_INTERPOLATE, "INTERPOLATE" },
{ SPICE_IMAGE_SCALE_MODE_NEAREST, "NEAREST" },
{ 0, NULL } };
typedef enum SpiceRopd {
SPICE_ROPD_INVERS_SRC = (1 << 0),
SPICE_ROPD_INVERS_BRUSH = (1 << 1),
SPICE_ROPD_INVERS_DEST = (1 << 2),
SPICE_ROPD_OP_PUT = (1 << 3),
SPICE_ROPD_OP_OR = (1 << 4),
SPICE_ROPD_OP_AND = (1 << 5),
SPICE_ROPD_OP_XOR = (1 << 6),
SPICE_ROPD_OP_BLACKNESS = (1 << 7),
SPICE_ROPD_OP_WHITENESS = (1 << 8),
SPICE_ROPD_OP_INVERS = (1 << 9),
SPICE_ROPD_INVERS_RES = (1 << 10),
SPICE_ROPD_MASK = 0x7ff
} SpiceRopd;
static const value_string spice_ropd_vs[] = {
{ SPICE_ROPD_INVERS_SRC, "INVERS_SRC" },
{ SPICE_ROPD_INVERS_BRUSH, "INVERS_BRUSH" },
{ SPICE_ROPD_INVERS_DEST, "INVERS_DEST" },
{ SPICE_ROPD_OP_PUT, "OP_PUT" },
{ SPICE_ROPD_OP_OR, "OP_OR" },
{ SPICE_ROPD_OP_AND, "OP_AND" },
{ SPICE_ROPD_OP_XOR, "OP_XOR" },
{ SPICE_ROPD_OP_BLACKNESS, "OP_BLACKNESS" },
{ SPICE_ROPD_OP_WHITENESS, "OP_WHITENESS" },
{ SPICE_ROPD_OP_INVERS, "OP_INVERS" },
{ SPICE_ROPD_INVERS_RES, "INVERS_RES" },
{ 0, NULL } };
typedef enum SpiceLineFlags {
SPICE_LINE_FLAGS_START_WITH_GAP = (1 << 2),
SPICE_LINE_FLAGS_STYLED = (1 << 3),
SPICE_LINE_FLAGS_MASK = 0xc
} SpiceLineFlags;
static const value_string spice_line_flags_vs[] = {
{ SPICE_LINE_FLAGS_START_WITH_GAP, "START_WITH_GAP" },
{ SPICE_LINE_FLAGS_STYLED, "STYLED" },
{ 0, NULL } };
typedef enum SpiceStringFlags {
SPICE_STRING_FLAGS_RASTER_A1 = (1 << 0),
SPICE_STRING_FLAGS_RASTER_A4 = (1 << 1),
SPICE_STRING_FLAGS_RASTER_A8 = (1 << 2),
SPICE_STRING_FLAGS_RASTER_TOP_DOWN = (1 << 3),
SPICE_STRING_FLAGS_MASK = 0xf
} SpiceStringFlags;
static const value_string spice_string_flags_vs[] = {
{ SPICE_STRING_FLAGS_RASTER_A1, "RASTER_A1" },
{ SPICE_STRING_FLAGS_RASTER_A4, "RASTER_A4" },
{ SPICE_STRING_FLAGS_RASTER_A8, "RASTER_A8" },
{ SPICE_STRING_FLAGS_RASTER_TOP_DOWN, "RASTER_TOP_DOWN" },
{ 0, NULL } };
typedef enum SpiceSurfaceFlags {
SPICE_SURFACE_FLAGS_PRIMARY = (1 << 0),
SPICE_SURFACE_FLAGS_STREAMING_MODE = (1 << 1),
SPICE_SURFACE_FLAGS_MASK = 0x3
} SpiceSurfaceFlags;
static const value_string spice_surface_flags_vs[] = {
{ SPICE_SURFACE_FLAGS_PRIMARY, "PRIMARY" },
{ SPICE_SURFACE_FLAGS_STREAMING_MODE, "STREAMING_MODE" },
{ 0, NULL } };
typedef enum SpiceSurfaceFmt {
SPICE_SURFACE_FMT_INVALID,
SPICE_SURFACE_FMT_1_A,
SPICE_SURFACE_FMT_8_A = 8,
SPICE_SURFACE_FMT_16_555 = 16,
SPICE_SURFACE_FMT_32_xRGB = 32,
SPICE_SURFACE_FMT_16_565 = 80,
SPICE_SURFACE_FMT_32_ARGB = 96,
SPICE_SURFACE_FMT_ENUM_END
} SpiceSurfaceFmt;
static const value_string spice_surface_fmt_vs[] = {
{ SPICE_SURFACE_FMT_INVALID, "INVALID" },
{ SPICE_SURFACE_FMT_1_A, "1_A" },
{ SPICE_SURFACE_FMT_8_A, "8_A" },
{ SPICE_SURFACE_FMT_16_555, "16_555" },
{ SPICE_SURFACE_FMT_32_xRGB, "32_xRGB" },
{ SPICE_SURFACE_FMT_16_565, "16_565" },
{ SPICE_SURFACE_FMT_32_ARGB, "32_ARGB" },
{ 0, NULL } };
typedef enum SpiceAlphaFlags {
SPICE_ALPHA_FLAGS_DEST_HAS_ALPHA = (1 << 0),
SPICE_ALPHA_FLAGS_SRC_SURFACE_HAS_ALPHA = (1 << 1),
SPICE_ALPHA_FLAGS_MASK = 0x3
} SpiceAlphaFlags;
static const value_string spice_alpha_flags_vs[] = {
{ SPICE_ALPHA_FLAGS_DEST_HAS_ALPHA, "DEST_HAS_ALPHA" },
{ SPICE_ALPHA_FLAGS_SRC_SURFACE_HAS_ALPHA, "SRC_SURFACE_HAS_ALPHA" },
{ 0, NULL } };
typedef enum SpiceResourceType {
SPICE_RES_TYPE_INVALID,
SPICE_RES_TYPE_PIXMAP,
SPICE_RESOURCE_TYPE_ENUM_END
} SpiceResourceType;
static const value_string spice_resource_type_vs[] = {
{ SPICE_RES_TYPE_INVALID, "INVALID" },
{ SPICE_RES_TYPE_PIXMAP, "PIXMAP" },
{ 0, NULL } };
typedef enum SpiceGlScanoutFlags {
SPICE_GL_SCANOUT_FLAGS_Y0TOP = (1 << 0),
SPICE_GL_SCANOUT_FLAGS_MASK = 0x1
} SpiceGlScanoutFlags;
static const value_string spice_gl_scanout_flags_vs[] = {
{ SPICE_GL_SCANOUT_FLAGS_Y0TOP, "Y0TOP" },
{ 0, NULL } };
typedef enum SpiceKeyboardModifierFlags {
SPICE_KEYBOARD_MODIFIER_FLAGS_SCROLL_LOCK = (1 << 0),
SPICE_KEYBOARD_MODIFIER_FLAGS_NUM_LOCK = (1 << 1),
SPICE_KEYBOARD_MODIFIER_FLAGS_CAPS_LOCK = (1 << 2),
SPICE_KEYBOARD_MODIFIER_FLAGS_MASK = 0x7
} SpiceKeyboardModifierFlags;
static const value_string spice_keyboard_modifier_flags_vs[] = {
{ SPICE_KEYBOARD_MODIFIER_FLAGS_SCROLL_LOCK, "SCROLL_LOCK" },
{ SPICE_KEYBOARD_MODIFIER_FLAGS_NUM_LOCK, "NUM_LOCK" },
{ SPICE_KEYBOARD_MODIFIER_FLAGS_CAPS_LOCK, "CAPS_LOCK" },
{ 0, NULL } };
typedef enum SpiceMouseButton {
SPICE_MOUSE_BUTTON_INVALID,
SPICE_MOUSE_BUTTON_LEFT,
SPICE_MOUSE_BUTTON_MIDDLE,
SPICE_MOUSE_BUTTON_RIGHT,
SPICE_MOUSE_BUTTON_UP,
SPICE_MOUSE_BUTTON_DOWN,
SPICE_MOUSE_BUTTON_ENUM_END
} SpiceMouseButton;
static const value_string spice_mouse_button_vs[] = {
{ SPICE_MOUSE_BUTTON_INVALID, "INVALID" },
{ SPICE_MOUSE_BUTTON_LEFT, "LEFT" },
{ SPICE_MOUSE_BUTTON_MIDDLE, "MIDDLE" },
{ SPICE_MOUSE_BUTTON_RIGHT, "RIGHT" },
{ SPICE_MOUSE_BUTTON_UP, "UP" },
{ SPICE_MOUSE_BUTTON_DOWN, "DOWN" },
{ 0, NULL } };
typedef enum SpiceMouseButtonMask {
SPICE_MOUSE_BUTTON_MASK_LEFT = (1 << 0),
SPICE_MOUSE_BUTTON_MASK_MIDDLE = (1 << 1),
SPICE_MOUSE_BUTTON_MASK_RIGHT = (1 << 2),
SPICE_MOUSE_BUTTON_MASK_MASK = 0x7
} SpiceMouseButtonMask;
static const value_string spice_mouse_button_mask_vs[] = {
{ SPICE_MOUSE_BUTTON_MASK_LEFT, "LEFT" },
{ SPICE_MOUSE_BUTTON_MASK_MIDDLE, "MIDDLE" },
{ SPICE_MOUSE_BUTTON_MASK_RIGHT, "RIGHT" },
{ 0, NULL } };
typedef enum SpiceCursorType {
SPICE_CURSOR_TYPE_ALPHA,
SPICE_CURSOR_TYPE_MONO,
SPICE_CURSOR_TYPE_COLOR4,
SPICE_CURSOR_TYPE_COLOR8,
SPICE_CURSOR_TYPE_COLOR16,
SPICE_CURSOR_TYPE_COLOR24,
SPICE_CURSOR_TYPE_COLOR32,
SPICE_CURSOR_TYPE_ENUM_END
} SpiceCursorType;
static const value_string spice_cursor_type_vs[] = {
{ SPICE_CURSOR_TYPE_ALPHA, "ALPHA" },
{ SPICE_CURSOR_TYPE_MONO, "MONO" },
{ SPICE_CURSOR_TYPE_COLOR4, "COLOR4" },
{ SPICE_CURSOR_TYPE_COLOR8, "COLOR8" },
{ SPICE_CURSOR_TYPE_COLOR16, "COLOR16" },
{ SPICE_CURSOR_TYPE_COLOR24, "COLOR24" },
{ SPICE_CURSOR_TYPE_COLOR32, "COLOR32" },
{ 0, NULL } };
typedef enum SpiceCursorFlags {
SPICE_CURSOR_FLAGS_NONE = (1 << 0),
SPICE_CURSOR_FLAGS_CACHE_ME = (1 << 1),
SPICE_CURSOR_FLAGS_FROM_CACHE = (1 << 2),
SPICE_CURSOR_FLAGS_MASK = 0x7
} SpiceCursorFlags;
static const value_string spice_cursor_flags_vs[] = {
{ SPICE_CURSOR_FLAGS_NONE, "NONE" },
{ SPICE_CURSOR_FLAGS_CACHE_ME, "CACHE_ME" },
{ SPICE_CURSOR_FLAGS_FROM_CACHE, "FROM_CACHE" },
{ 0, NULL } };
typedef enum SpiceAudioDataMode {
SPICE_AUDIO_DATA_MODE_INVALID,
SPICE_AUDIO_DATA_MODE_RAW,
SPICE_AUDIO_DATA_MODE_CELT_0_5_1,
SPICE_AUDIO_DATA_MODE_OPUS,
SPICE_AUDIO_DATA_MODE_ENUM_END
} SpiceAudioDataMode;
static const value_string spice_audio_data_mode_vs[] = {
{ SPICE_AUDIO_DATA_MODE_INVALID, "INVALID" },
{ SPICE_AUDIO_DATA_MODE_RAW, "RAW" },
{ SPICE_AUDIO_DATA_MODE_CELT_0_5_1, "CELT_0_5_1" },
{ SPICE_AUDIO_DATA_MODE_OPUS, "OPUS" },
{ 0, NULL } };
typedef enum SpiceAudioFmt {
SPICE_AUDIO_FMT_INVALID,
SPICE_AUDIO_FMT_S16,
SPICE_AUDIO_FMT_ENUM_END
} SpiceAudioFmt;
static const value_string spice_audio_fmt_vs[] = {
{ SPICE_AUDIO_FMT_INVALID, "INVALID" },
{ SPICE_AUDIO_FMT_S16, "S16" },
{ 0, NULL } };
typedef enum SpiceTunnelServiceType {
SPICE_TUNNEL_SERVICE_TYPE_INVALID,
SPICE_TUNNEL_SERVICE_TYPE_GENERIC,
SPICE_TUNNEL_SERVICE_TYPE_IPP,
SPICE_TUNNEL_SERVICE_TYPE_ENUM_END
} SpiceTunnelServiceType;
static const value_string spice_tunnel_service_type_vs[] = {
{ SPICE_TUNNEL_SERVICE_TYPE_INVALID, "INVALID" },
{ SPICE_TUNNEL_SERVICE_TYPE_GENERIC, "GENERIC" },
{ SPICE_TUNNEL_SERVICE_TYPE_IPP, "IPP" },
{ 0, NULL } };
typedef enum SpiceTunnelIpType {
SPICE_TUNNEL_IP_TYPE_INVALID,
SPICE_TUNNEL_IP_TYPE_IPv4,
SPICE_TUNNEL_IP_TYPE_ENUM_END
} SpiceTunnelIpType;
static const value_string spice_tunnel_ip_type_vs[] = {
{ SPICE_TUNNEL_IP_TYPE_INVALID, "INVALID" },
{ SPICE_TUNNEL_IP_TYPE_IPv4, "IPv4" },
{ 0, NULL } };
typedef enum SpiceVscMessageType {
SPICE_VSC_MESSAGE_TYPE_Init = 1,
SPICE_VSC_MESSAGE_TYPE_Error,
SPICE_VSC_MESSAGE_TYPE_ReaderAdd,
SPICE_VSC_MESSAGE_TYPE_ReaderRemove,
SPICE_VSC_MESSAGE_TYPE_ATR,
SPICE_VSC_MESSAGE_TYPE_CardRemove,
SPICE_VSC_MESSAGE_TYPE_APDU,
SPICE_VSC_MESSAGE_TYPE_Flush,
SPICE_VSC_MESSAGE_TYPE_FlushComplete,
SPICE_VSC_MESSAGE_TYPE_ENUM_END
} SpiceVscMessageType;
static const value_string spice_vsc_message_type_vs[] = {
{ SPICE_VSC_MESSAGE_TYPE_Init, "Init" },
{ SPICE_VSC_MESSAGE_TYPE_Error, "Error" },
{ SPICE_VSC_MESSAGE_TYPE_ReaderAdd, "ReaderAdd" },
{ SPICE_VSC_MESSAGE_TYPE_ReaderRemove, "ReaderRemove" },
{ SPICE_VSC_MESSAGE_TYPE_ATR, "ATR" },
{ SPICE_VSC_MESSAGE_TYPE_CardRemove, "CardRemove" },
{ SPICE_VSC_MESSAGE_TYPE_APDU, "APDU" },
{ SPICE_VSC_MESSAGE_TYPE_Flush, "Flush" },
{ SPICE_VSC_MESSAGE_TYPE_FlushComplete, "FlushComplete" },
{ 0, NULL } };
enum {
SPICE_CHANNEL_MAIN = 1,
SPICE_CHANNEL_DISPLAY,
SPICE_CHANNEL_INPUTS,
SPICE_CHANNEL_CURSOR,
SPICE_CHANNEL_PLAYBACK,
SPICE_CHANNEL_RECORD,
SPICE_CHANNEL_TUNNEL,
SPICE_CHANNEL_SMARTCARD,
SPICE_CHANNEL_USBREDIR,
SPICE_CHANNEL_PORT,
SPICE_CHANNEL_WEBDAV,
SPICE_END_CHANNEL
};
static const value_string channel_types_vs[] = {
{ SPICE_CHANNEL_MAIN, "MAIN" },
{ SPICE_CHANNEL_DISPLAY, "DISPLAY" },
{ SPICE_CHANNEL_INPUTS, "INPUTS" },
{ SPICE_CHANNEL_CURSOR, "CURSOR" },
{ SPICE_CHANNEL_PLAYBACK, "PLAYBACK" },
{ SPICE_CHANNEL_RECORD, "RECORD" },
{ SPICE_CHANNEL_TUNNEL, "TUNNEL" },
{ SPICE_CHANNEL_SMARTCARD, "SMARTCARD" },
{ SPICE_CHANNEL_USBREDIR, "USBREDIR" },
{ SPICE_CHANNEL_PORT, "PORT" },
{ SPICE_CHANNEL_WEBDAV, "WEBDAV" },
{ 0, NULL }
};
enum {
SPICE_MSG_MIGRATE = 1,
SPICE_MSG_MIGRATE_DATA,
SPICE_MSG_SET_ACK,
SPICE_MSG_PING,
SPICE_MSG_WAIT_FOR_CHANNELS,
SPICE_MSG_DISCONNECTING,
SPICE_MSG_NOTIFY,
SPICE_MSG_LIST,
SPICE_MSG_BASE_LAST = 100,
};
static const value_string spice_msg_vs[] = {
{ SPICE_MSG_MIGRATE, "Server MIGRATE" },
{ SPICE_MSG_MIGRATE_DATA, "Server MIGRATE_DATA" },
{ SPICE_MSG_SET_ACK, "Server SET_ACK" },
{ SPICE_MSG_PING, "Server PING" },
{ SPICE_MSG_WAIT_FOR_CHANNELS, "Server WAIT_FOR_CHANNELS" },
{ SPICE_MSG_DISCONNECTING, "Server DISCONNECTING" },
{ SPICE_MSG_NOTIFY, "Server NOTIFY" },
{ SPICE_MSG_LIST, "Server LIST" },
{ SPICE_MSG_BASE_LAST, "Server BASE_LAST" },
{ 0, NULL }
};
enum {
SPICE_MSGC_ACK_SYNC = 1,
SPICE_MSGC_ACK,
SPICE_MSGC_PONG,
SPICE_MSGC_MIGRATE_FLUSH_MARK,
SPICE_MSGC_MIGRATE_DATA,
SPICE_MSGC_DISCONNECTING,
};
static const value_string spice_msgc_vs[] = {
{ SPICE_MSGC_ACK_SYNC, "Client ACK_SYNC" },
{ SPICE_MSGC_ACK, "Client ACK" },
{ SPICE_MSGC_PONG, "Client PONG" },
{ SPICE_MSGC_MIGRATE_FLUSH_MARK, "Client MIGRATE_FLUSH_MARK" },
{ SPICE_MSGC_MIGRATE_DATA, "Client MIGRATE_DATA" },
{ SPICE_MSGC_DISCONNECTING, "Client DISCONNECTING" },
{ 0, NULL }
};
enum {
SPICE_MSG_MAIN_MIGRATE_BEGIN = 101,
SPICE_MSG_MAIN_MIGRATE_CANCEL,
SPICE_MSG_MAIN_INIT,
SPICE_MSG_MAIN_CHANNELS_LIST,
SPICE_MSG_MAIN_MOUSE_MODE,
SPICE_MSG_MAIN_MULTI_MEDIA_TIME,
SPICE_MSG_MAIN_AGENT_CONNECTED,
SPICE_MSG_MAIN_AGENT_DISCONNECTED,
SPICE_MSG_MAIN_AGENT_DATA,
SPICE_MSG_MAIN_AGENT_TOKEN,
SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST,
SPICE_MSG_MAIN_MIGRATE_END,
SPICE_MSG_MAIN_NAME,
SPICE_MSG_MAIN_UUID,
SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS,
SPICE_MSG_MAIN_MIGRATE_BEGIN_SEAMLESS,
SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_ACK,
SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_NACK,
SPICE_MSG_END_MAIN
};
static const value_string spice_msg_main_vs[] = {
{ SPICE_MSG_MAIN_MIGRATE_BEGIN, "Server MIGRATE_BEGIN" },
{ SPICE_MSG_MAIN_MIGRATE_CANCEL, "Server MIGRATE_CANCEL" },
{ SPICE_MSG_MAIN_INIT, "Server INIT" },
{ SPICE_MSG_MAIN_CHANNELS_LIST, "Server CHANNELS_LIST" },
{ SPICE_MSG_MAIN_MOUSE_MODE, "Server MOUSE_MODE" },
{ SPICE_MSG_MAIN_MULTI_MEDIA_TIME, "Server MULTI_MEDIA_TIME" },
{ SPICE_MSG_MAIN_AGENT_CONNECTED, "Server AGENT_CONNECTED" },
{ SPICE_MSG_MAIN_AGENT_DISCONNECTED, "Server AGENT_DISCONNECTED" },
{ SPICE_MSG_MAIN_AGENT_DATA, "Server AGENT_DATA" },
{ SPICE_MSG_MAIN_AGENT_TOKEN, "Server AGENT_TOKEN" },
{ SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST, "Server MIGRATE_SWITCH_HOST" },
{ SPICE_MSG_MAIN_MIGRATE_END, "Server MIGRATE_END" },
{ SPICE_MSG_MAIN_NAME, "Server NAME" },
{ SPICE_MSG_MAIN_UUID, "Server UUID" },
{ SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS, "Server AGENT_CONNECTED_TOKENS" },
{ SPICE_MSG_MAIN_MIGRATE_BEGIN_SEAMLESS, "Server MIGRATE_BEGIN_SEAMLESS" },
{ SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_ACK, "Server MIGRATE_DST_SEAMLESS_ACK" },
{ SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_NACK, "Server MIGRATE_DST_SEAMLESS_NACK" },
{ 0, NULL }
};
enum {
SPICE_MSGC_MAIN_CLIENT_INFO = 101,
SPICE_MSGC_MAIN_MIGRATE_CONNECTED,
SPICE_MSGC_MAIN_MIGRATE_CONNECT_ERROR,
SPICE_MSGC_MAIN_ATTACH_CHANNELS,
SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST,
SPICE_MSGC_MAIN_AGENT_START,
SPICE_MSGC_MAIN_AGENT_DATA,
SPICE_MSGC_MAIN_AGENT_TOKEN,
SPICE_MSGC_MAIN_MIGRATE_END,
SPICE_MSGC_MAIN_MIGRATE_DST_DO_SEAMLESS,
SPICE_MSGC_MAIN_MIGRATE_CONNECTED_SEAMLESS,
SPICE_MSGC_END_MAIN
};
static const value_string spice_msgc_main_vs[] = {
{ SPICE_MSGC_MAIN_CLIENT_INFO, "Client CLIENT_INFO" },
{ SPICE_MSGC_MAIN_MIGRATE_CONNECTED, "Client MIGRATE_CONNECTED" },
{ SPICE_MSGC_MAIN_MIGRATE_CONNECT_ERROR, "Client MIGRATE_CONNECT_ERROR" },
{ SPICE_MSGC_MAIN_ATTACH_CHANNELS, "Client ATTACH_CHANNELS" },
{ SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST, "Client MOUSE_MODE_REQUEST" },
{ SPICE_MSGC_MAIN_AGENT_START, "Client AGENT_START" },
{ SPICE_MSGC_MAIN_AGENT_DATA, "Client AGENT_DATA" },
{ SPICE_MSGC_MAIN_AGENT_TOKEN, "Client AGENT_TOKEN" },
{ SPICE_MSGC_MAIN_MIGRATE_END, "Client MIGRATE_END" },
{ SPICE_MSGC_MAIN_MIGRATE_DST_DO_SEAMLESS, "Client MIGRATE_DST_DO_SEAMLESS" },
{ SPICE_MSGC_MAIN_MIGRATE_CONNECTED_SEAMLESS, "Client MIGRATE_CONNECTED_SEAMLESS" },
{ 0, NULL }
};
enum {
SPICE_MSG_DISPLAY_MODE = 101,
SPICE_MSG_DISPLAY_MARK,
SPICE_MSG_DISPLAY_RESET,
SPICE_MSG_DISPLAY_COPY_BITS,
SPICE_MSG_DISPLAY_INVAL_LIST,
SPICE_MSG_DISPLAY_INVAL_ALL_PIXMAPS,
SPICE_MSG_DISPLAY_INVAL_PALETTE,
SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES,
SPICE_MSG_DISPLAY_STREAM_CREATE = 122,
SPICE_MSG_DISPLAY_STREAM_DATA,
SPICE_MSG_DISPLAY_STREAM_CLIP,
SPICE_MSG_DISPLAY_STREAM_DESTROY,
SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL,
SPICE_MSG_DISPLAY_DRAW_FILL = 302,
SPICE_MSG_DISPLAY_DRAW_OPAQUE,
SPICE_MSG_DISPLAY_DRAW_COPY,
SPICE_MSG_DISPLAY_DRAW_BLEND,
SPICE_MSG_DISPLAY_DRAW_BLACKNESS,
SPICE_MSG_DISPLAY_DRAW_WHITENESS,
SPICE_MSG_DISPLAY_DRAW_INVERS,
SPICE_MSG_DISPLAY_DRAW_ROP3,
SPICE_MSG_DISPLAY_DRAW_STROKE,
SPICE_MSG_DISPLAY_DRAW_TEXT,
SPICE_MSG_DISPLAY_DRAW_TRANSPARENT,
SPICE_MSG_DISPLAY_DRAW_ALPHA_BLEND,
SPICE_MSG_DISPLAY_SURFACE_CREATE,
SPICE_MSG_DISPLAY_SURFACE_DESTROY,
SPICE_MSG_DISPLAY_STREAM_DATA_SIZED,
SPICE_MSG_DISPLAY_MONITORS_CONFIG,
SPICE_MSG_DISPLAY_DRAW_COMPOSITE,
SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT,
SPICE_MSG_DISPLAY_GL_SCANOUT_UNIX,
SPICE_MSG_DISPLAY_GL_DRAW,
SPICE_MSG_END_DISPLAY
};
static const value_string spice_msg_display_vs[] = {
{ SPICE_MSG_DISPLAY_MODE, "Server MODE" },
{ SPICE_MSG_DISPLAY_MARK, "Server MARK" },
{ SPICE_MSG_DISPLAY_RESET, "Server RESET" },
{ SPICE_MSG_DISPLAY_COPY_BITS, "Server COPY_BITS" },
{ SPICE_MSG_DISPLAY_INVAL_LIST, "Server INVAL_LIST" },
{ SPICE_MSG_DISPLAY_INVAL_ALL_PIXMAPS, "Server INVAL_ALL_PIXMAPS" },
{ SPICE_MSG_DISPLAY_INVAL_PALETTE, "Server INVAL_PALETTE" },
{ SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES, "Server INVAL_ALL_PALETTES" },
{ SPICE_MSG_DISPLAY_STREAM_CREATE, "Server STREAM_CREATE" },
{ SPICE_MSG_DISPLAY_STREAM_DATA, "Server STREAM_DATA" },
{ SPICE_MSG_DISPLAY_STREAM_CLIP, "Server STREAM_CLIP" },
{ SPICE_MSG_DISPLAY_STREAM_DESTROY, "Server STREAM_DESTROY" },
{ SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL, "Server STREAM_DESTROY_ALL" },
{ SPICE_MSG_DISPLAY_DRAW_FILL, "Server DRAW_FILL" },
{ SPICE_MSG_DISPLAY_DRAW_OPAQUE, "Server DRAW_OPAQUE" },
{ SPICE_MSG_DISPLAY_DRAW_COPY, "Server DRAW_COPY" },
{ SPICE_MSG_DISPLAY_DRAW_BLEND, "Server DRAW_BLEND" },
{ SPICE_MSG_DISPLAY_DRAW_BLACKNESS, "Server DRAW_BLACKNESS" },
{ SPICE_MSG_DISPLAY_DRAW_WHITENESS, "Server DRAW_WHITENESS" },
{ SPICE_MSG_DISPLAY_DRAW_INVERS, "Server DRAW_INVERS" },
{ SPICE_MSG_DISPLAY_DRAW_ROP3, "Server DRAW_ROP3" },
{ SPICE_MSG_DISPLAY_DRAW_STROKE, "Server DRAW_STROKE" },
{ SPICE_MSG_DISPLAY_DRAW_TEXT, "Server DRAW_TEXT" },
{ SPICE_MSG_DISPLAY_DRAW_TRANSPARENT, "Server DRAW_TRANSPARENT" },
{ SPICE_MSG_DISPLAY_DRAW_ALPHA_BLEND, "Server DRAW_ALPHA_BLEND" },
{ SPICE_MSG_DISPLAY_SURFACE_CREATE, "Server SURFACE_CREATE" },
{ SPICE_MSG_DISPLAY_SURFACE_DESTROY, "Server SURFACE_DESTROY" },
{ SPICE_MSG_DISPLAY_STREAM_DATA_SIZED, "Server STREAM_DATA_SIZED" },
{ SPICE_MSG_DISPLAY_MONITORS_CONFIG, "Server MONITORS_CONFIG" },
{ SPICE_MSG_DISPLAY_DRAW_COMPOSITE, "Server DRAW_COMPOSITE" },
{ SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT, "Server STREAM_ACTIVATE_REPORT" },
{ SPICE_MSG_DISPLAY_GL_SCANOUT_UNIX, "Server GL_SCANOUT_UNIX" },
{ SPICE_MSG_DISPLAY_GL_DRAW, "Server GL_DRAW" },
{ 0, NULL }
};
enum {
SPICE_MSGC_DISPLAY_INIT = 101,
SPICE_MSGC_DISPLAY_STREAM_REPORT,
SPICE_MSGC_DISPLAY_PREFERRED_COMPRESSION,
SPICE_MSGC_DISPLAY_GL_DRAW_DONE,
SPICE_MSGC_DISPLAY_PREFERRED_VIDEO_CODEC_TYPE,
SPICE_MSGC_END_DISPLAY
};
static const value_string spice_msgc_display_vs[] = {
{ SPICE_MSGC_DISPLAY_INIT, "Client INIT" },
{ SPICE_MSGC_DISPLAY_STREAM_REPORT, "Client STREAM_REPORT" },
{ SPICE_MSGC_DISPLAY_PREFERRED_COMPRESSION, "Client PREFERRED_COMPRESSION" },
{ SPICE_MSGC_DISPLAY_GL_DRAW_DONE, "Client GL_DRAW_DONE" },
{ SPICE_MSGC_DISPLAY_PREFERRED_VIDEO_CODEC_TYPE, "Client PREFERRED_VIDEO_CODEC_TYPE" },
{ 0, NULL }
};
enum {
SPICE_MSG_INPUTS_INIT = 101,
SPICE_MSG_INPUTS_KEY_MODIFIERS,
SPICE_MSG_INPUTS_MOUSE_MOTION_ACK = 111,
SPICE_MSG_END_INPUTS
};
static const value_string spice_msg_inputs_vs[] = {
{ SPICE_MSG_INPUTS_INIT, "Server INIT" },
{ SPICE_MSG_INPUTS_KEY_MODIFIERS, "Server KEY_MODIFIERS" },
{ SPICE_MSG_INPUTS_MOUSE_MOTION_ACK, "Server MOUSE_MOTION_ACK" },
{ 0, NULL }
};
enum {
SPICE_MSGC_INPUTS_KEY_DOWN = 101,
SPICE_MSGC_INPUTS_KEY_UP,
SPICE_MSGC_INPUTS_KEY_MODIFIERS,
SPICE_MSGC_INPUTS_KEY_SCANCODE,
SPICE_MSGC_INPUTS_MOUSE_MOTION = 111,
SPICE_MSGC_INPUTS_MOUSE_POSITION,
SPICE_MSGC_INPUTS_MOUSE_PRESS,
SPICE_MSGC_INPUTS_MOUSE_RELEASE,
SPICE_MSGC_END_INPUTS
};
static const value_string spice_msgc_inputs_vs[] = {
{ SPICE_MSGC_INPUTS_KEY_DOWN, "Client KEY_DOWN" },
{ SPICE_MSGC_INPUTS_KEY_UP, "Client KEY_UP" },
{ SPICE_MSGC_INPUTS_KEY_MODIFIERS, "Client KEY_MODIFIERS" },
{ SPICE_MSGC_INPUTS_KEY_SCANCODE, "Client KEY_SCANCODE" },
{ SPICE_MSGC_INPUTS_MOUSE_MOTION, "Client MOUSE_MOTION" },
{ SPICE_MSGC_INPUTS_MOUSE_POSITION, "Client MOUSE_POSITION" },
{ SPICE_MSGC_INPUTS_MOUSE_PRESS, "Client MOUSE_PRESS" },
{ SPICE_MSGC_INPUTS_MOUSE_RELEASE, "Client MOUSE_RELEASE" },
{ 0, NULL }
};
enum {
SPICE_MSG_CURSOR_INIT = 101,
SPICE_MSG_CURSOR_RESET,
SPICE_MSG_CURSOR_SET,
SPICE_MSG_CURSOR_MOVE,
SPICE_MSG_CURSOR_HIDE,
SPICE_MSG_CURSOR_TRAIL,
SPICE_MSG_CURSOR_INVAL_ONE,
SPICE_MSG_CURSOR_INVAL_ALL,
SPICE_MSG_END_CURSOR
};
static const value_string spice_msg_cursor_vs[] = {
{ SPICE_MSG_CURSOR_INIT, "Server INIT" },
{ SPICE_MSG_CURSOR_RESET, "Server RESET" },
{ SPICE_MSG_CURSOR_SET, "Server SET" },
{ SPICE_MSG_CURSOR_MOVE, "Server MOVE" },
{ SPICE_MSG_CURSOR_HIDE, "Server HIDE" },
{ SPICE_MSG_CURSOR_TRAIL, "Server TRAIL" },
{ SPICE_MSG_CURSOR_INVAL_ONE, "Server INVAL_ONE" },
{ SPICE_MSG_CURSOR_INVAL_ALL, "Server INVAL_ALL" },
{ 0, NULL }
};
enum {
SPICE_MSG_PLAYBACK_DATA = 101,
SPICE_MSG_PLAYBACK_MODE,
SPICE_MSG_PLAYBACK_START,
SPICE_MSG_PLAYBACK_STOP,
SPICE_MSG_PLAYBACK_VOLUME,
SPICE_MSG_PLAYBACK_MUTE,
SPICE_MSG_PLAYBACK_LATENCY,
SPICE_MSG_END_PLAYBACK
};
static const value_string spice_msg_playback_vs[] = {
{ SPICE_MSG_PLAYBACK_DATA, "Server DATA" },
{ SPICE_MSG_PLAYBACK_MODE, "Server MODE" },
{ SPICE_MSG_PLAYBACK_START, "Server START" },
{ SPICE_MSG_PLAYBACK_STOP, "Server STOP" },
{ SPICE_MSG_PLAYBACK_VOLUME, "Server VOLUME" },
{ SPICE_MSG_PLAYBACK_MUTE, "Server MUTE" },
{ SPICE_MSG_PLAYBACK_LATENCY, "Server LATENCY" },
{ 0, NULL }
};
enum {
SPICE_MSG_RECORD_START = 101,
SPICE_MSG_RECORD_STOP,
SPICE_MSG_RECORD_VOLUME,
SPICE_MSG_RECORD_MUTE,
SPICE_MSG_END_RECORD
};
static const value_string spice_msg_record_vs[] = {
{ SPICE_MSG_RECORD_START, "Server START" },
{ SPICE_MSG_RECORD_STOP, "Server STOP" },
{ SPICE_MSG_RECORD_VOLUME, "Server VOLUME" },
{ SPICE_MSG_RECORD_MUTE, "Server MUTE" },
{ 0, NULL }
};
enum {
SPICE_MSGC_RECORD_DATA = 101,
SPICE_MSGC_RECORD_MODE,
SPICE_MSGC_RECORD_START_MARK,
SPICE_MSGC_END_RECORD
};
static const value_string spice_msgc_record_vs[] = {
{ SPICE_MSGC_RECORD_DATA, "Client DATA" },
{ SPICE_MSGC_RECORD_MODE, "Client MODE" },
{ SPICE_MSGC_RECORD_START_MARK, "Client START_MARK" },
{ 0, NULL }
};
enum {
SPICE_MSG_TUNNEL_INIT = 101,
SPICE_MSG_TUNNEL_SERVICE_IP_MAP,
SPICE_MSG_TUNNEL_SOCKET_OPEN,
SPICE_MSG_TUNNEL_SOCKET_FIN,
SPICE_MSG_TUNNEL_SOCKET_CLOSE,
SPICE_MSG_TUNNEL_SOCKET_DATA,
SPICE_MSG_TUNNEL_SOCKET_CLOSED_ACK,
SPICE_MSG_TUNNEL_SOCKET_TOKEN,
SPICE_MSG_END_TUNNEL
};
static const value_string spice_msg_tunnel_vs[] = {
{ SPICE_MSG_TUNNEL_INIT, "Server INIT" },
{ SPICE_MSG_TUNNEL_SERVICE_IP_MAP, "Server SERVICE_IP_MAP" },
{ SPICE_MSG_TUNNEL_SOCKET_OPEN, "Server SOCKET_OPEN" },
{ SPICE_MSG_TUNNEL_SOCKET_FIN, "Server SOCKET_FIN" },
{ SPICE_MSG_TUNNEL_SOCKET_CLOSE, "Server SOCKET_CLOSE" },
{ SPICE_MSG_TUNNEL_SOCKET_DATA, "Server SOCKET_DATA" },
{ SPICE_MSG_TUNNEL_SOCKET_CLOSED_ACK, "Server SOCKET_CLOSED_ACK" },
{ SPICE_MSG_TUNNEL_SOCKET_TOKEN, "Server SOCKET_TOKEN" },
{ 0, NULL }
};
enum {
SPICE_MSGC_TUNNEL_SERVICE_ADD = 101,
SPICE_MSGC_TUNNEL_SERVICE_REMOVE,
SPICE_MSGC_TUNNEL_SOCKET_OPEN_ACK,
SPICE_MSGC_TUNNEL_SOCKET_OPEN_NACK,
SPICE_MSGC_TUNNEL_SOCKET_FIN,
SPICE_MSGC_TUNNEL_SOCKET_CLOSED,
SPICE_MSGC_TUNNEL_SOCKET_CLOSED_ACK,
SPICE_MSGC_TUNNEL_SOCKET_DATA,
SPICE_MSGC_TUNNEL_SOCKET_TOKEN,
SPICE_MSGC_END_TUNNEL
};
static const value_string spice_msgc_tunnel_vs[] = {
{ SPICE_MSGC_TUNNEL_SERVICE_ADD, "Client SERVICE_ADD" },
{ SPICE_MSGC_TUNNEL_SERVICE_REMOVE, "Client SERVICE_REMOVE" },
{ SPICE_MSGC_TUNNEL_SOCKET_OPEN_ACK, "Client SOCKET_OPEN_ACK" },
{ SPICE_MSGC_TUNNEL_SOCKET_OPEN_NACK, "Client SOCKET_OPEN_NACK" },
{ SPICE_MSGC_TUNNEL_SOCKET_FIN, "Client SOCKET_FIN" },
{ SPICE_MSGC_TUNNEL_SOCKET_CLOSED, "Client SOCKET_CLOSED" },
{ SPICE_MSGC_TUNNEL_SOCKET_CLOSED_ACK, "Client SOCKET_CLOSED_ACK" },
{ SPICE_MSGC_TUNNEL_SOCKET_DATA, "Client SOCKET_DATA" },
{ SPICE_MSGC_TUNNEL_SOCKET_TOKEN, "Client SOCKET_TOKEN" },
{ 0, NULL }
};
enum {
SPICE_MSG_SMARTCARD_DATA = 101,
SPICE_MSG_END_SMARTCARD
};
static const value_string spice_msg_smartcard_vs[] = {
{ SPICE_MSG_SMARTCARD_DATA, "Server DATA" },
{ 0, NULL }
};
enum {
SPICE_MSGC_SMARTCARD_HEADER = 101,
SPICE_MSGC_END_SMARTCARD
};
static const value_string spice_msgc_smartcard_vs[] = {
{ SPICE_MSGC_SMARTCARD_HEADER, "Client HEADER" },
{ 0, NULL }
};
enum {
SPICE_MSG_SPICEVMC_DATA = 101,
SPICE_MSG_SPICEVMC_COMPRESSED_DATA,
SPICE_MSG_END_SPICEVMC
};
static const value_string spice_msg_spicevmc_vs[] = {
{ SPICE_MSG_SPICEVMC_DATA, "Server DATA" },
{ SPICE_MSG_SPICEVMC_COMPRESSED_DATA, "Server COMPRESSED_DATA" },
{ 0, NULL }
};
enum {
SPICE_MSGC_SPICEVMC_DATA = 101,
SPICE_MSGC_SPICEVMC_COMPRESSED_DATA,
SPICE_MSGC_END_SPICEVMC
};
static const value_string spice_msgc_spicevmc_vs[] = {
{ SPICE_MSGC_SPICEVMC_DATA, "Client DATA" },
{ SPICE_MSGC_SPICEVMC_COMPRESSED_DATA, "Client COMPRESSED_DATA" },
{ 0, NULL }
};
enum {
SPICE_MSG_PORT_INIT = 201,
SPICE_MSG_PORT_EVENT,
SPICE_MSG_END_PORT
};
static const value_string spice_msg_port_vs[] = {
{ SPICE_MSG_PORT_INIT, "Server INIT" },
{ SPICE_MSG_PORT_EVENT, "Server EVENT" },
{ 0, NULL }
};
enum {
SPICE_MSGC_PORT_EVENT = 201,
SPICE_MSGC_END_PORT
};
static const value_string spice_msgc_port_vs[] = {
{ SPICE_MSGC_PORT_EVENT, "Client EVENT" },
{ 0, NULL }
};
#endif /* _H_SPICE_ENUMS */
|
C
|
wireshark/epan/dissectors/packet-spnego.c
|
/* Do not modify this file. Changes will be overwritten. */
/* Generated automatically by the ASN.1 to Wireshark dissector compiler */
/* packet-spnego.c */
/* asn2wrs.py -b -L -p spnego -c ./spnego.cnf -s ./packet-spnego-template -D . -O ../.. spnego.asn */
/* packet-spnego-template.c
* Routines for the simple and protected GSS-API negotiation mechanism
* as described in RFC 2478.
* Copyright 2002, Tim Potter <[email protected]>
* Copyright 2002, Richard Sharpe <[email protected]>
* Copyright 2003, Richard Sharpe <[email protected]>
* Copyright 2005, Ronnie Sahlberg (krb decryption)
* Copyright 2005, Anders Broman (converted to asn2wrs generated dissector)
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* The heimdal code for decryption of GSSAPI wrappers using heimdal comes from
Heimdal 1.6 and has been modified for wireshark's requirements.
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/expert.h>
#include <epan/asn1.h>
#include <epan/conversation.h>
#include <epan/proto_data.h>
#include <wsutil/wsgcrypt.h>
#include "packet-gssapi.h"
#include "packet-kerberos.h"
#include "packet-ber.h"
#define PNAME "Simple Protected Negotiation"
#define PSNAME "SPNEGO"
#define PFNAME "spnego"
void proto_register_spnego(void);
void proto_reg_handoff_spnego(void);
static dissector_handle_t spnego_wrap_handle;
/* Initialize the protocol and registered fields */
static int proto_spnego = -1;
static int proto_spnego_krb5 = -1;
static int hf_spnego_wraptoken = -1;
static int hf_spnego_krb5_oid;
static int hf_spnego_krb5 = -1;
static int hf_spnego_krb5_tok_id = -1;
static int hf_spnego_krb5_sgn_alg = -1;
static int hf_spnego_krb5_seal_alg = -1;
static int hf_spnego_krb5_snd_seq = -1;
static int hf_spnego_krb5_sgn_cksum = -1;
static int hf_spnego_krb5_confounder = -1;
static int hf_spnego_krb5_filler = -1;
static int hf_spnego_krb5_cfx_flags = -1;
static int hf_spnego_krb5_cfx_flags_01 = -1;
static int hf_spnego_krb5_cfx_flags_02 = -1;
static int hf_spnego_krb5_cfx_flags_04 = -1;
static int hf_spnego_krb5_cfx_ec = -1;
static int hf_spnego_krb5_cfx_rrc = -1;
static int hf_spnego_krb5_cfx_seq = -1;
static int hf_spnego_negTokenInit = -1; /* T_negTokenInit */
static int hf_spnego_negTokenTarg = -1; /* NegTokenTarg */
static int hf_spnego_MechTypeList_item = -1; /* MechType */
static int hf_spnego_mechTypes = -1; /* MechTypeList */
static int hf_spnego_reqFlags = -1; /* ContextFlags */
static int hf_spnego_mechToken = -1; /* T_mechToken */
static int hf_spnego_mechListMIC = -1; /* OCTET_STRING */
static int hf_spnego_hintName = -1; /* GeneralString */
static int hf_spnego_hintAddress = -1; /* OCTET_STRING */
static int hf_spnego_mechToken_01 = -1; /* OCTET_STRING */
static int hf_spnego_negHints = -1; /* NegHints */
static int hf_spnego_negResult = -1; /* T_negResult */
static int hf_spnego_supportedMech = -1; /* T_supportedMech */
static int hf_spnego_responseToken = -1; /* T_responseToken */
static int hf_spnego_mechListMIC_01 = -1; /* T_mechListMIC */
static int hf_spnego_thisMech = -1; /* MechType */
static int hf_spnego_innerContextToken = -1; /* InnerContextToken */
/* named bits */
static int hf_spnego_ContextFlags_delegFlag = -1;
static int hf_spnego_ContextFlags_mutualFlag = -1;
static int hf_spnego_ContextFlags_replayFlag = -1;
static int hf_spnego_ContextFlags_sequenceFlag = -1;
static int hf_spnego_ContextFlags_anonFlag = -1;
static int hf_spnego_ContextFlags_confFlag = -1;
static int hf_spnego_ContextFlags_integFlag = -1;
/* Global variables */
static const char *MechType_oid;
gssapi_oid_value *next_level_value;
gboolean saw_mechanism = FALSE;
/* Initialize the subtree pointers */
static gint ett_spnego = -1;
static gint ett_spnego_wraptoken = -1;
static gint ett_spnego_krb5 = -1;
static gint ett_spnego_krb5_cfx_flags = -1;
static gint ett_spnego_NegotiationToken = -1;
static gint ett_spnego_MechTypeList = -1;
static gint ett_spnego_NegTokenInit = -1;
static gint ett_spnego_NegHints = -1;
static gint ett_spnego_NegTokenInit2 = -1;
static gint ett_spnego_ContextFlags = -1;
static gint ett_spnego_NegTokenTarg = -1;
static gint ett_spnego_InitialContextToken_U = -1;
static expert_field ei_spnego_decrypted_keytype = EI_INIT;
static expert_field ei_spnego_unknown_header = EI_INIT;
static dissector_handle_t spnego_handle;
static dissector_handle_t spnego_krb5_handle;
static dissector_handle_t spnego_krb5_wrap_handle;
/*
* Unfortunately, we have to have forward declarations of these,
* as the code generated by asn2wrs includes a call before the
* definition.
*/
static int dissect_spnego_NegTokenInit(bool implicit_tag, tvbuff_t *tvb,
int offset, asn1_ctx_t *actx _U_,
proto_tree *tree, int hf_index);
static int dissect_spnego_NegTokenInit2(bool implicit_tag, tvbuff_t *tvb,
int offset, asn1_ctx_t *actx _U_,
proto_tree *tree, int hf_index);
static int
dissect_spnego_MechType(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
gssapi_oid_value *value;
offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &MechType_oid);
value = gssapi_lookup_oid_str(MechType_oid);
/*
* Tell our caller the first mechanism we see, so that if
* this is a negTokenInit with a mechToken, it can interpret
* the mechToken according to the first mechType. (There
* might not have been any indication of the mechType
* in prior frames, so we can't necessarily use the
* mechanism from the conversation; i.e., a negTokenInit
* can contain the initial security token for the desired
* mechanism of the initiator - that's the first mechanism
* in the list.)
*/
if (!saw_mechanism) {
if (value)
next_level_value = value;
saw_mechanism = TRUE;
}
return offset;
}
static const ber_sequence_t MechTypeList_sequence_of[1] = {
{ &hf_spnego_MechTypeList_item, BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_spnego_MechType },
};
static int
dissect_spnego_MechTypeList(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
conversation_t *conversation;
saw_mechanism = FALSE;
offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
MechTypeList_sequence_of, hf_index, ett_spnego_MechTypeList);
/*
* If we saw a mechType we need to store it in case the negTokenTarg
* does not provide a supportedMech.
*/
if(saw_mechanism){
conversation = find_or_create_conversation(actx->pinfo);
conversation_add_proto_data(conversation, proto_spnego, next_level_value);
}
return offset;
}
static int * const ContextFlags_bits[] = {
&hf_spnego_ContextFlags_delegFlag,
&hf_spnego_ContextFlags_mutualFlag,
&hf_spnego_ContextFlags_replayFlag,
&hf_spnego_ContextFlags_sequenceFlag,
&hf_spnego_ContextFlags_anonFlag,
&hf_spnego_ContextFlags_confFlag,
&hf_spnego_ContextFlags_integFlag,
NULL
};
static int
dissect_spnego_ContextFlags(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_bitstring(implicit_tag, actx, tree, tvb, offset,
ContextFlags_bits, 7, hf_index, ett_spnego_ContextFlags,
NULL);
return offset;
}
static int
dissect_spnego_T_mechToken(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
tvbuff_t *mechToken_tvb = NULL;
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
&mechToken_tvb);
/*
* Now, we should be able to dispatch, if we've gotten a tvbuff for
* the token and we have information on how to dissect its contents.
*/
if (mechToken_tvb && next_level_value)
call_dissector(next_level_value->handle, mechToken_tvb, actx->pinfo, tree);
return offset;
}
static int
dissect_spnego_OCTET_STRING(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static const ber_sequence_t NegTokenInit_sequence[] = {
{ &hf_spnego_mechTypes , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL, dissect_spnego_MechTypeList },
{ &hf_spnego_reqFlags , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL, dissect_spnego_ContextFlags },
{ &hf_spnego_mechToken , BER_CLASS_CON, 2, BER_FLAGS_OPTIONAL, dissect_spnego_T_mechToken },
{ &hf_spnego_mechListMIC , BER_CLASS_CON, 3, BER_FLAGS_OPTIONAL, dissect_spnego_OCTET_STRING },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_spnego_NegTokenInit(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
NegTokenInit_sequence, hf_index, ett_spnego_NegTokenInit);
return offset;
}
static int
dissect_spnego_T_negTokenInit(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
bool is_response = actx->pinfo->ptype == PT_TCP &&
actx->pinfo->srcport < 1024;
/*
* We decode as negTokenInit2 or negTokenInit depending on whether or not
* we are in a response or a request. That is essentially what MS-SPNG
* says.
*/
if (is_response) {
return dissect_spnego_NegTokenInit2(implicit_tag, tvb, offset,
actx, tree, hf_index);
} else {
return dissect_spnego_NegTokenInit(implicit_tag, tvb, offset,
actx, tree, hf_index);
}
return offset;
}
static const value_string spnego_T_negResult_vals[] = {
{ 0, "accept-completed" },
{ 1, "accept-incomplete" },
{ 2, "reject" },
{ 0, NULL }
};
static int
dissect_spnego_T_negResult(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static int
dissect_spnego_T_supportedMech(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
conversation_t *conversation;
saw_mechanism = FALSE;
offset = dissect_spnego_MechType(implicit_tag, tvb, offset, actx, tree, hf_index);
/*
* If we saw an explicit mechType we store this in the conversation so that
* it will override any mechType we might have picked up from the
* negTokenInit.
*/
if(saw_mechanism){
conversation = find_or_create_conversation(actx->pinfo);
conversation_add_proto_data(conversation, proto_spnego, next_level_value);
}
return offset;
}
static int
dissect_spnego_T_responseToken(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
tvbuff_t *responseToken_tvb;
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
&responseToken_tvb);
/*
* Now, we should be able to dispatch, if we've gotten a tvbuff for
* the token and we have information on how to dissect its contents.
* However, we should make sure that there is something in the
* response token ...
*/
if (responseToken_tvb && (tvb_reported_length(responseToken_tvb) > 0) ){
gssapi_oid_value *value=next_level_value;
if(value){
call_dissector(value->handle, responseToken_tvb, actx->pinfo, tree);
}
}
return offset;
}
static int
dissect_spnego_T_mechListMIC(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
tvbuff_t *mechListMIC_tvb;
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
&mechListMIC_tvb);
/*
* Now, we should be able to dispatch, if we've gotten a tvbuff for
* the token and we have information on how to dissect its contents.
* However, we should make sure that there is something in the
* response token ...
*/
if (mechListMIC_tvb && (tvb_reported_length(mechListMIC_tvb) > 0) ){
gssapi_oid_value *value=next_level_value;
if(value){
call_dissector(value->handle, mechListMIC_tvb, actx->pinfo, tree);
}
}
return offset;
}
static const ber_sequence_t NegTokenTarg_sequence[] = {
{ &hf_spnego_negResult , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL, dissect_spnego_T_negResult },
{ &hf_spnego_supportedMech, BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL, dissect_spnego_T_supportedMech },
{ &hf_spnego_responseToken, BER_CLASS_CON, 2, BER_FLAGS_OPTIONAL, dissect_spnego_T_responseToken },
{ &hf_spnego_mechListMIC_01, BER_CLASS_CON, 3, BER_FLAGS_OPTIONAL, dissect_spnego_T_mechListMIC },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_spnego_NegTokenTarg(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
NegTokenTarg_sequence, hf_index, ett_spnego_NegTokenTarg);
return offset;
}
static const ber_choice_t NegotiationToken_choice[] = {
{ 0, &hf_spnego_negTokenInit , BER_CLASS_CON, 0, 0, dissect_spnego_T_negTokenInit },
{ 1, &hf_spnego_negTokenTarg , BER_CLASS_CON, 1, 0, dissect_spnego_NegTokenTarg },
{ 0, NULL, 0, 0, 0, NULL }
};
static int
dissect_spnego_NegotiationToken(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_choice(actx, tree, tvb, offset,
NegotiationToken_choice, hf_index, ett_spnego_NegotiationToken,
NULL);
return offset;
}
static int
dissect_spnego_GeneralString(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_GeneralString,
actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static const ber_sequence_t NegHints_sequence[] = {
{ &hf_spnego_hintName , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL, dissect_spnego_GeneralString },
{ &hf_spnego_hintAddress , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL, dissect_spnego_OCTET_STRING },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_spnego_NegHints(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
NegHints_sequence, hf_index, ett_spnego_NegHints);
return offset;
}
static const ber_sequence_t NegTokenInit2_sequence[] = {
{ &hf_spnego_mechTypes , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL, dissect_spnego_MechTypeList },
{ &hf_spnego_reqFlags , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL, dissect_spnego_ContextFlags },
{ &hf_spnego_mechToken_01 , BER_CLASS_CON, 2, BER_FLAGS_OPTIONAL, dissect_spnego_OCTET_STRING },
{ &hf_spnego_negHints , BER_CLASS_CON, 3, BER_FLAGS_OPTIONAL, dissect_spnego_NegHints },
{ &hf_spnego_mechListMIC , BER_CLASS_CON, 4, BER_FLAGS_OPTIONAL, dissect_spnego_OCTET_STRING },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_spnego_NegTokenInit2(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
NegTokenInit2_sequence, hf_index, ett_spnego_NegTokenInit2);
return offset;
}
static int
dissect_spnego_InnerContextToken(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
gssapi_oid_value *next_level_value_lcl;
proto_item *item;
proto_tree *subtree;
tvbuff_t *token_tvb;
int len;
/*
* XXX - what should we do if this OID doesn't match the value
* attached to the frame or conversation? (That would be
* bogus, but that's not impossible - some broken implementation
* might negotiate some security mechanism but put the OID
* for some other security mechanism in GSS_Wrap tokens.)
* Does it matter?
*/
next_level_value_lcl = gssapi_lookup_oid_str(MechType_oid);
/*
* Now dissect the GSS_Wrap token; it's assumed to be in the
* rest of the tvbuff.
*/
item = proto_tree_add_item(tree, hf_spnego_wraptoken, tvb, offset, -1, ENC_NA);
subtree = proto_item_add_subtree(item, ett_spnego_wraptoken);
/*
* Now, we should be able to dispatch after creating a new TVB.
* The subdissector must return the length of the part of the
* token it dissected, so we can return the length of the part
* we (and it) dissected.
*/
token_tvb = tvb_new_subset_remaining(tvb, offset);
if (next_level_value_lcl && next_level_value_lcl->wrap_handle) {
len = call_dissector(next_level_value_lcl->wrap_handle, token_tvb, actx->pinfo,
subtree);
if (len == 0)
offset = tvb_reported_length(tvb);
else
offset = offset + len;
} else
offset = tvb_reported_length(tvb);
return offset;
}
static const ber_sequence_t InitialContextToken_U_sequence[] = {
{ &hf_spnego_thisMech , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_spnego_MechType },
{ &hf_spnego_innerContextToken, BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_spnego_InnerContextToken },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_spnego_InitialContextToken_U(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
InitialContextToken_U_sequence, hf_index, ett_spnego_InitialContextToken_U);
return offset;
}
static int
dissect_spnego_InitialContextToken(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
hf_index, BER_CLASS_APP, 0, TRUE, dissect_spnego_InitialContextToken_U);
return offset;
}
/*
* This is the SPNEGO KRB5 dissector. It is not true KRB5, but some ASN.1
* wrapped blob with an OID, USHORT token ID, and a Ticket, that is also
* ASN.1 wrapped by the looks of it. It conforms to RFC1964.
*/
#define KRB_TOKEN_AP_REQ 0x0001
#define KRB_TOKEN_AP_REP 0x0002
#define KRB_TOKEN_AP_ERR 0x0003
#define KRB_TOKEN_GETMIC 0x0101
#define KRB_TOKEN_WRAP 0x0102
#define KRB_TOKEN_DELETE_SEC_CONTEXT 0x0201
#define KRB_TOKEN_TGT_REQ 0x0004
#define KRB_TOKEN_TGT_REP 0x0104
#define KRB_TOKEN_CFX_GETMIC 0x0404
#define KRB_TOKEN_CFX_WRAP 0x0405
static const value_string spnego_krb5_tok_id_vals[] = {
{ KRB_TOKEN_AP_REQ, "KRB5_AP_REQ"},
{ KRB_TOKEN_AP_REP, "KRB5_AP_REP"},
{ KRB_TOKEN_AP_ERR, "KRB5_ERROR"},
{ KRB_TOKEN_GETMIC, "KRB5_GSS_GetMIC" },
{ KRB_TOKEN_WRAP, "KRB5_GSS_Wrap" },
{ KRB_TOKEN_DELETE_SEC_CONTEXT, "KRB5_GSS_Delete_sec_context" },
{ KRB_TOKEN_TGT_REQ, "KERB_TGT_REQUEST" },
{ KRB_TOKEN_TGT_REP, "KERB_TGT_REPLY" },
{ KRB_TOKEN_CFX_GETMIC, "KRB_TOKEN_CFX_GetMic" },
{ KRB_TOKEN_CFX_WRAP, "KRB_TOKEN_CFX_WRAP" },
{ 0, NULL}
};
#define KRB_SGN_ALG_DES_MAC_MD5 0x0000
#define KRB_SGN_ALG_MD2_5 0x0001
#define KRB_SGN_ALG_DES_MAC 0x0002
#define KRB_SGN_ALG_HMAC 0x0011
static const value_string spnego_krb5_sgn_alg_vals[] = {
{ KRB_SGN_ALG_DES_MAC_MD5, "DES MAC MD5"},
{ KRB_SGN_ALG_MD2_5, "MD2.5"},
{ KRB_SGN_ALG_DES_MAC, "DES MAC"},
{ KRB_SGN_ALG_HMAC, "HMAC"},
{ 0, NULL}
};
#define KRB_SEAL_ALG_DES_CBC 0x0000
#define KRB_SEAL_ALG_RC4 0x0010
#define KRB_SEAL_ALG_NONE 0xffff
static const value_string spnego_krb5_seal_alg_vals[] = {
{ KRB_SEAL_ALG_DES_CBC, "DES CBC"},
{ KRB_SEAL_ALG_RC4, "RC4"},
{ KRB_SEAL_ALG_NONE, "None"},
{ 0, NULL}
};
/*
* XXX - is this for SPNEGO or just GSS-API?
* RFC 1964 is "The Kerberos Version 5 GSS-API Mechanism"; presumably one
* can directly designate Kerberos V5 as a mechanism in GSS-API, rather
* than designating SPNEGO as the mechanism, offering Kerberos V5, and
* getting it accepted.
*/
static int
dissect_spnego_krb5_getmic_base(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int
dissect_spnego_krb5_wrap_base(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint16 token_id, gssapi_encrypt_info_t* gssapi_encrypt);
static int
dissect_spnego_krb5_cfx_getmic_base(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int
dissect_spnego_krb5_cfx_wrap_base(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint16 token_id, gssapi_encrypt_info_t* gssapi_encrypt);
static int
dissect_spnego_krb5(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
proto_item *item;
proto_tree *subtree;
int offset = 0;
guint16 token_id;
const char *oid;
tvbuff_t *krb5_tvb;
gint8 ber_class;
bool pc, ind = 0;
gint32 tag;
guint32 len;
gssapi_encrypt_info_t* encrypt_info = (gssapi_encrypt_info_t*)data;
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
item = proto_tree_add_item(tree, hf_spnego_krb5, tvb, offset, -1, ENC_NA);
subtree = proto_item_add_subtree(item, ett_spnego_krb5);
/*
* The KRB5 blob conforms to RFC1964:
* [APPLICATION 0] {
* OID,
* USHORT (0x0001 == AP-REQ, 0x0002 == AP-REP, 0x0003 == ERROR),
* OCTET STRING }
*
* However, for some protocols, the KRB5 blob starts at the SHORT
* and has no DER encoded header etc.
*
* It appears that for some other protocols the KRB5 blob is just
* a Kerberos message, with no [APPLICATION 0] header, no OID,
* and no USHORT.
*
* So:
*
* If we see an [APPLICATION 0] HEADER, we show the OID and
* the USHORT, and then dissect the rest as a Kerberos message.
*
* If we see an [APPLICATION 14] or [APPLICATION 15] header,
* we assume it's an AP-REQ or AP-REP message, and dissect
* it all as a Kerberos message.
*
* Otherwise, we show the USHORT, and then dissect the rest
* as a Kerberos message.
*/
/*
* Get the first header ...
*/
get_ber_identifier(tvb, offset, &ber_class, &pc, &tag);
if (ber_class == BER_CLASS_APP && pc) {
/*
* [APPLICATION <tag>]
*/
offset = dissect_ber_identifier(pinfo, subtree, tvb, offset, &ber_class, &pc, &tag);
offset = dissect_ber_length(pinfo, subtree, tvb, offset, &len, &ind);
switch (tag) {
case 0:
/*
* [APPLICATION 0]
*/
/* Next, the OID */
offset=dissect_ber_object_identifier_str(FALSE, &asn1_ctx, subtree, tvb, offset, hf_spnego_krb5_oid, &oid);
token_id = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(subtree, hf_spnego_krb5_tok_id, tvb, offset, 2, token_id);
offset += 2;
break;
case 14: /* [APPLICATION 14] */
case 15: /* [APPLICATION 15] */
/*
* No token ID - just dissect as a Kerberos message and
* return.
*/
dissect_kerberos_main(tvb, pinfo, subtree, FALSE, NULL);
return tvb_captured_length(tvb);
default:
proto_tree_add_expert_format(subtree, pinfo, &ei_spnego_unknown_header, tvb, offset, 0,
"Unknown header (class=%d, pc=%d, tag=%d)", ber_class, pc, tag);
goto done;
}
} else {
/* Next, the token ID ... */
token_id = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(subtree, hf_spnego_krb5_tok_id, tvb, offset, 2, token_id);
offset += 2;
}
switch (token_id) {
case KRB_TOKEN_TGT_REQ:
offset = dissect_kerberos_TGT_REQ(FALSE, tvb, offset, &asn1_ctx, subtree, -1);
break;
case KRB_TOKEN_TGT_REP:
offset = dissect_kerberos_TGT_REP(FALSE, tvb, offset, &asn1_ctx, subtree, -1);
break;
case KRB_TOKEN_AP_REQ:
case KRB_TOKEN_AP_REP:
case KRB_TOKEN_AP_ERR:
krb5_tvb = tvb_new_subset_remaining(tvb, offset);
offset += dissect_kerberos_main(krb5_tvb, pinfo, subtree, FALSE, NULL);
break;
case KRB_TOKEN_GETMIC:
offset = dissect_spnego_krb5_getmic_base(tvb, offset, pinfo, subtree);
break;
case KRB_TOKEN_WRAP:
offset = dissect_spnego_krb5_wrap_base(tvb, offset, pinfo, subtree, token_id, encrypt_info);
break;
case KRB_TOKEN_DELETE_SEC_CONTEXT:
break;
case KRB_TOKEN_CFX_GETMIC:
offset = dissect_spnego_krb5_cfx_getmic_base(tvb, offset, pinfo, subtree);
break;
case KRB_TOKEN_CFX_WRAP:
offset = dissect_spnego_krb5_cfx_wrap_base(tvb, offset, pinfo, subtree, token_id, encrypt_info);
break;
default:
break;
}
done:
proto_item_set_len(item, offset);
return tvb_captured_length(tvb);
}
#ifdef HAVE_KERBEROS
#ifndef KEYTYPE_ARCFOUR_56
# define KEYTYPE_ARCFOUR_56 24
#endif
#ifndef KEYTYPE_ARCFOUR_HMAC
# define KEYTYPE_ARCFOUR_HMAC 23
#endif
/* XXX - We should probably do a configure-time check for this instead */
#ifndef KRB5_KU_USAGE_SEAL
# define KRB5_KU_USAGE_SEAL 22
#endif
static int
arcfour_mic_key(const guint8 *key_data, size_t key_size, int key_type,
const guint8 *cksum_data, size_t cksum_size,
guint8 *key6_data)
{
guint8 k5_data[HASH_MD5_LENGTH];
guint8 T[4] = { 0 };
if (key_type == KEYTYPE_ARCFOUR_56) {
guint8 L40[14] = "fortybits";
memcpy(L40 + 10, T, sizeof(T));
if (ws_hmac_buffer(GCRY_MD_MD5, k5_data, L40, 14, key_data, key_size)) {
return 0;
}
memset(&k5_data[7], 0xAB, 9);
} else {
if (ws_hmac_buffer(GCRY_MD_MD5, k5_data, T, 4, key_data, key_size)) {
return 0;
}
}
if (ws_hmac_buffer(GCRY_MD_MD5, key6_data, cksum_data, cksum_size, k5_data, HASH_MD5_LENGTH)) {
return 0;
}
return 0;
}
static int
usage2arcfour(int usage)
{
switch (usage) {
case 3: /*KRB5_KU_AS_REP_ENC_PART 3 */
case 9: /*KRB5_KU_TGS_REP_ENC_PART_SUB_KEY 9 */
return 8;
case 22: /*KRB5_KU_USAGE_SEAL 22 */
return 13;
case 23: /*KRB5_KU_USAGE_SIGN 23 */
return 15;
case 24: /*KRB5_KU_USAGE_SEQ 24 */
return 0;
default :
return 0;
}
}
static int
arcfour_mic_cksum(guint8 *key_data, int key_length,
unsigned int usage,
guint8 sgn_cksum[8],
const guint8 *v1, size_t l1,
const guint8 *v2, size_t l2,
const guint8 *v3, size_t l3)
{
static const guint8 signature[] = "signaturekey";
guint8 ksign_c[HASH_MD5_LENGTH];
guint8 t[4];
guint8 digest[HASH_MD5_LENGTH];
int rc4_usage;
guint8 cksum[HASH_MD5_LENGTH];
gcry_md_hd_t md5_handle;
rc4_usage=usage2arcfour(usage);
if (ws_hmac_buffer(GCRY_MD_MD5, ksign_c, signature, sizeof(signature), key_data, key_length)) {
return 0;
}
if (gcry_md_open(&md5_handle, GCRY_MD_MD5, 0)) {
return 0;
}
t[0] = (rc4_usage >> 0) & 0xFF;
t[1] = (rc4_usage >> 8) & 0xFF;
t[2] = (rc4_usage >> 16) & 0xFF;
t[3] = (rc4_usage >> 24) & 0xFF;
gcry_md_write(md5_handle, t, 4);
gcry_md_write(md5_handle, v1, l1);
gcry_md_write(md5_handle, v2, l2);
gcry_md_write(md5_handle, v3, l3);
memcpy(digest, gcry_md_read(md5_handle, 0), HASH_MD5_LENGTH);
gcry_md_close(md5_handle);
if (ws_hmac_buffer(GCRY_MD_MD5, cksum, digest, HASH_MD5_LENGTH, ksign_c, HASH_MD5_LENGTH)) {
return 0;
}
memcpy(sgn_cksum, cksum, 8);
return 0;
}
/*
* Verify padding of a gss wrapped message and return its length.
*/
static int
gssapi_verify_pad(guint8 *wrapped_data, int wrapped_length,
int datalen,
int *padlen)
{
guint8 *pad;
int padlength;
int i;
pad = wrapped_data + wrapped_length - 1;
padlength = *pad;
if (padlength > datalen)
return 1;
for (i = padlength; i > 0 && *pad == padlength; i--, pad--);
if (i != 0)
return 2;
*padlen = padlength;
return 0;
}
static int
decrypt_arcfour(gssapi_encrypt_info_t* gssapi_encrypt, guint8 *input_message_buffer, guint8 *output_message_buffer,
guint8 *key_value, int key_size, int key_type)
{
guint8 Klocaldata[16];
int ret;
int datalen;
guint8 k6_data[16];
guint32 SND_SEQ[2];
guint8 Confounder[8];
guint8 cksum_data[8];
int cmp;
int conf_flag;
int padlen = 0;
gcry_cipher_hd_t rc4_handle;
int i;
datalen = tvb_captured_length(gssapi_encrypt->gssapi_encrypted_tvb);
if(tvb_get_ntohs(gssapi_encrypt->gssapi_wrap_tvb, 4)==0x1000){
conf_flag=1;
} else if (tvb_get_ntohs(gssapi_encrypt->gssapi_wrap_tvb, 4)==0xffff){
conf_flag=0;
} else {
return -3;
}
if(tvb_get_ntohs(gssapi_encrypt->gssapi_wrap_tvb, 6)!=0xffff){
return -4;
}
ret = arcfour_mic_key(key_value, key_size, key_type,
tvb_get_ptr(gssapi_encrypt->gssapi_wrap_tvb, 16, 8),
8, /* SGN_CKSUM */
k6_data);
if (ret) {
return -5;
}
tvb_memcpy(gssapi_encrypt->gssapi_wrap_tvb, SND_SEQ, 8, 8);
if (gcry_cipher_open (&rc4_handle, GCRY_CIPHER_ARCFOUR, GCRY_CIPHER_MODE_STREAM, 0)) {
return -12;
}
if (gcry_cipher_setkey(rc4_handle, k6_data, sizeof(k6_data))) {
gcry_cipher_close(rc4_handle);
return -13;
}
gcry_cipher_decrypt(rc4_handle, (guint8 *)SND_SEQ, 8, NULL, 0);
gcry_cipher_close(rc4_handle);
memset(k6_data, 0, sizeof(k6_data));
if (SND_SEQ[1] != 0xFFFFFFFF && SND_SEQ[1] != 0x00000000) {
return -6;
}
for (i = 0; i < 16; i++)
Klocaldata[i] = ((guint8 *)key_value)[i] ^ 0xF0;
ret = arcfour_mic_key(Klocaldata,sizeof(Klocaldata),key_type,
(const guint8 *)SND_SEQ, 4,
k6_data);
memset(Klocaldata, 0, sizeof(Klocaldata));
if (ret) {
return -7;
}
if(conf_flag) {
tvb_memcpy(gssapi_encrypt->gssapi_wrap_tvb, Confounder, 24, 8);
if (gcry_cipher_open (&rc4_handle, GCRY_CIPHER_ARCFOUR, GCRY_CIPHER_MODE_STREAM, 0)) {
return -14;
}
if (gcry_cipher_setkey(rc4_handle, k6_data, sizeof(k6_data))) {
gcry_cipher_close(rc4_handle);
return -15;
}
gcry_cipher_decrypt(rc4_handle, Confounder, 8, NULL, 0);
gcry_cipher_decrypt(rc4_handle, output_message_buffer, datalen, input_message_buffer, datalen);
gcry_cipher_close(rc4_handle);
} else {
tvb_memcpy(gssapi_encrypt->gssapi_wrap_tvb, Confounder, 24, 8);
memcpy(output_message_buffer, input_message_buffer, datalen);
}
memset(k6_data, 0, sizeof(k6_data));
/* only normal (i.e. non DCE style wrapping use padding ? */
if(gssapi_encrypt->decrypt_gssapi_tvb==DECRYPT_GSSAPI_NORMAL){
ret = gssapi_verify_pad(output_message_buffer,datalen,datalen, &padlen);
if (ret) {
return -9;
}
datalen -= padlen;
}
/* don't know what the checksum looks like for dce style gssapi */
if(gssapi_encrypt->decrypt_gssapi_tvb==DECRYPT_GSSAPI_NORMAL){
ret = arcfour_mic_cksum(key_value, key_size, KRB5_KU_USAGE_SEAL,
cksum_data,
tvb_get_ptr(gssapi_encrypt->gssapi_wrap_tvb, 0, 8), 8,
Confounder, sizeof(Confounder), output_message_buffer,
datalen + padlen);
if (ret) {
return -10;
}
cmp = tvb_memeql(gssapi_encrypt->gssapi_wrap_tvb, 16, cksum_data, 8); /* SGN_CKSUM */
if (cmp) {
return -11;
}
}
return datalen;
}
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
static void
decrypt_gssapi_krb_arcfour_wrap(proto_tree *tree _U_, packet_info *pinfo, tvbuff_t *tvb, int keytype, gssapi_encrypt_info_t* gssapi_encrypt)
{
int ret;
enc_key_t *ek;
int length;
const guint8 *original_data;
guint8 *cryptocopy=NULL; /* workaround for pre-0.6.1 heimdal bug */
guint8 *output_message_buffer;
length=tvb_captured_length(gssapi_encrypt->gssapi_encrypted_tvb);
original_data=tvb_get_ptr(gssapi_encrypt->gssapi_encrypted_tvb, 0, length);
/* don't do anything if we are not attempting to decrypt data */
/*
if(!krb_decrypt){
return;
}
*/
/* XXX we should only do this for first time, then store somewhere */
/* XXX We also need to re-read the keytab when the preference changes */
cryptocopy=(guint8 *)wmem_alloc(pinfo->pool, length);
output_message_buffer=(guint8 *)wmem_alloc(pinfo->pool, length);
for(ek=enc_key_list;ek;ek=ek->next){
/* shortcircuit and bail out if enctypes are not matching */
if(ek->keytype!=keytype){
continue;
}
/* pre-0.6.1 versions of Heimdal would sometimes change
the cryptotext data even when the decryption failed.
This would obviously not work since we iterate over the
keys. So just give it a copy of the crypto data instead.
This has been seen for RC4-HMAC blobs.
*/
memcpy(cryptocopy, original_data, length);
ret=decrypt_arcfour(gssapi_encrypt,
cryptocopy,
output_message_buffer,
ek->keyvalue,
ek->keylength,
ek->keytype);
if (ret >= 0) {
expert_add_info_format(pinfo, NULL, &ei_spnego_decrypted_keytype,
"Decrypted keytype %d in frame %u using %s",
ek->keytype, pinfo->num, ek->key_origin);
gssapi_encrypt->gssapi_decrypted_tvb=tvb_new_child_real_data(tvb, output_message_buffer, ret, ret);
add_new_data_source(pinfo, gssapi_encrypt->gssapi_decrypted_tvb, "Decrypted GSS-Krb5");
return;
}
}
}
/* borrowed from heimdal */
static int
rrc_rotate(guint8 *data, int len, guint16 rrc, int unrotate)
{
guint8 *tmp, buf[256];
size_t left;
if (len == 0)
return 0;
rrc %= len;
if (rrc == 0)
return 0;
left = len - rrc;
if (rrc <= sizeof(buf)) {
tmp = buf;
} else {
tmp = (guint8 *)g_malloc(rrc);
if (tmp == NULL)
return -1;
}
if (unrotate) {
memcpy(tmp, data, rrc);
memmove(data, data + rrc, left);
memcpy(data + left, tmp, rrc);
} else {
memcpy(tmp, data + left, rrc);
memmove(data + rrc, data, left);
memcpy(data, tmp, rrc);
}
if (rrc > sizeof(buf))
g_free(tmp);
return 0;
}
static void
decrypt_gssapi_krb_cfx_wrap(proto_tree *tree,
packet_info *pinfo,
tvbuff_t *checksum_tvb,
gssapi_encrypt_info_t* gssapi_encrypt,
guint16 ec _U_,
guint16 rrc,
int keytype,
unsigned int usage)
{
guint8 *rotated;
guint8 *output;
int datalen;
tvbuff_t *next_tvb;
/* don't do anything if we are not attempting to decrypt data */
if(!krb_decrypt){
return;
}
if (gssapi_encrypt->decrypt_gssapi_tvb==DECRYPT_GSSAPI_DCE) {
tvbuff_t *out_tvb = NULL;
out_tvb = decrypt_krb5_krb_cfx_dce(tree, pinfo, usage, keytype,
gssapi_encrypt->gssapi_header_tvb,
gssapi_encrypt->gssapi_encrypted_tvb,
gssapi_encrypt->gssapi_trailer_tvb,
checksum_tvb);
if (out_tvb) {
gssapi_encrypt->gssapi_decrypted_tvb = out_tvb;
add_new_data_source(pinfo, gssapi_encrypt->gssapi_decrypted_tvb, "Decrypted GSS-Krb5 CFX DCE");
}
return;
}
datalen = tvb_captured_length(checksum_tvb) + tvb_captured_length(gssapi_encrypt->gssapi_encrypted_tvb);
rotated = (guint8 *)wmem_alloc(pinfo->pool, datalen);
tvb_memcpy(checksum_tvb, rotated, 0, tvb_captured_length(checksum_tvb));
tvb_memcpy(gssapi_encrypt->gssapi_encrypted_tvb, rotated + tvb_captured_length(checksum_tvb),
0, tvb_captured_length(gssapi_encrypt->gssapi_encrypted_tvb));
rrc_rotate(rotated, datalen, rrc, TRUE);
next_tvb=tvb_new_child_real_data(gssapi_encrypt->gssapi_encrypted_tvb, rotated,
datalen, datalen);
add_new_data_source(pinfo, next_tvb, "GSSAPI CFX");
output = decrypt_krb5_data(tree, pinfo, usage, next_tvb, keytype, &datalen);
if (output) {
guint8 *outdata;
outdata = (guint8 *)wmem_memdup(pinfo->pool, output, tvb_captured_length(gssapi_encrypt->gssapi_encrypted_tvb));
gssapi_encrypt->gssapi_decrypted_tvb=tvb_new_child_real_data(gssapi_encrypt->gssapi_encrypted_tvb,
outdata,
tvb_captured_length(gssapi_encrypt->gssapi_encrypted_tvb),
tvb_captured_length(gssapi_encrypt->gssapi_encrypted_tvb));
add_new_data_source(pinfo, gssapi_encrypt->gssapi_decrypted_tvb, "Decrypted GSS-Krb5");
}
}
#endif /* HAVE_HEIMDAL_KERBEROS || HAVE_MIT_KERBEROS */
#endif
/*
* This is for GSSAPI Wrap tokens ...
*/
static int
dissect_spnego_krb5_wrap_base(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint16 token_id, gssapi_encrypt_info_t* gssapi_encrypt)
{
guint16 sgn_alg, seal_alg;
#ifdef HAVE_KERBEROS
int start_offset=offset;
#else
(void) pinfo;
(void) token_id;
#endif
/*
* The KRB5 blob conforms to RFC1964:
* USHORT (0x0102 == GSS_Wrap)
* and so on }
*/
/* Now, the sign and seal algorithms ... */
sgn_alg = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_spnego_krb5_sgn_alg, tvb, offset, 2, sgn_alg);
offset += 2;
seal_alg = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_spnego_krb5_seal_alg, tvb, offset, 2, seal_alg);
offset += 2;
/* Skip the filler */
offset += 2;
/* Encrypted sequence number */
proto_tree_add_item(tree, hf_spnego_krb5_snd_seq, tvb, offset, 8, ENC_NA);
offset += 8;
/* Checksum of plaintext padded data */
proto_tree_add_item(tree, hf_spnego_krb5_sgn_cksum, tvb, offset, 8, ENC_NA);
offset += 8;
/*
* At least according to draft-brezak-win2k-krb-rc4-hmac-04,
* if the signing algorithm is KRB_SGN_ALG_HMAC, there's an
* extra 8 bytes of "Random confounder" after the checksum.
* It certainly confounds code expecting all Kerberos 5
* GSS_Wrap() tokens to look the same....
*/
if ((sgn_alg == KRB_SGN_ALG_HMAC) ||
/* there also seems to be a confounder for DES MAC MD5 - certainly seen when using with
SASL with LDAP between a Java client and Active Directory. If this breaks other things
we may need to make this an option. gal 17/2/06 */
(sgn_alg == KRB_SGN_ALG_DES_MAC_MD5)) {
proto_tree_add_item(tree, hf_spnego_krb5_confounder, tvb, offset, 8, ENC_NA);
offset += 8;
}
/* Is the data encrypted? */
if (gssapi_encrypt != NULL)
gssapi_encrypt->gssapi_data_encrypted=(seal_alg!=KRB_SEAL_ALG_NONE);
#ifdef HAVE_KERBEROS
#define GSS_ARCFOUR_WRAP_TOKEN_SIZE 32
if(gssapi_encrypt && gssapi_encrypt->decrypt_gssapi_tvb){
/* if the caller did not provide a tvb, then we just use
whatever is left of our current tvb.
*/
if(!gssapi_encrypt->gssapi_encrypted_tvb){
int len;
len=tvb_reported_length_remaining(tvb,offset);
if(len>tvb_captured_length_remaining(tvb, offset)){
/* no point in trying to decrypt,
we don't have the full pdu.
*/
return offset;
}
gssapi_encrypt->gssapi_encrypted_tvb = tvb_new_subset_length(
tvb, offset, len);
}
/* if this is KRB5 wrapped rc4-hmac */
if((token_id==KRB_TOKEN_WRAP)
&&(sgn_alg==KRB_SGN_ALG_HMAC)
&&(seal_alg==KRB_SEAL_ALG_RC4)){
/* do we need to create a tvb for the wrapper
as well ?
*/
if(!gssapi_encrypt->gssapi_wrap_tvb){
gssapi_encrypt->gssapi_wrap_tvb = tvb_new_subset_length(
tvb, start_offset-2,
GSS_ARCFOUR_WRAP_TOKEN_SIZE);
}
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
decrypt_gssapi_krb_arcfour_wrap(tree,
pinfo,
tvb,
KEYTYPE_ARCFOUR_HMAC,
gssapi_encrypt);
#endif /* HAVE_HEIMDAL_KERBEROS || HAVE_MIT_KERBEROS */
}
}
#endif
/*
* Return the offset past the checksum, so that we know where
* the data we're wrapped around starts. Also, set the length
* of our top-level item to that offset, so it doesn't cover
* the data we're wrapped around.
*
* Note that for DCERPC the GSSAPI blobs comes after the data it wraps,
* not before.
*/
return offset;
}
/*
* XXX - This is for GSSAPI GetMIC tokens ...
*/
static int
dissect_spnego_krb5_getmic_base(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
{
guint16 sgn_alg;
/*
* The KRB5 blob conforms to RFC1964:
* USHORT (0x0101 == GSS_GetMIC)
* and so on }
*/
/* Now, the sign algorithm ... */
sgn_alg = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(tree, hf_spnego_krb5_sgn_alg, tvb, offset, 2, sgn_alg);
offset += 2;
/* Skip the filler */
offset += 4;
/* Encrypted sequence number */
proto_tree_add_item(tree, hf_spnego_krb5_snd_seq, tvb, offset, 8, ENC_NA);
offset += 8;
/* Checksum of plaintext padded data */
proto_tree_add_item(tree, hf_spnego_krb5_sgn_cksum, tvb, offset, 8, ENC_NA);
offset += 8;
/*
* At least according to draft-brezak-win2k-krb-rc4-hmac-04,
* if the signing algorithm is KRB_SGN_ALG_HMAC, there's an
* extra 8 bytes of "Random confounder" after the checksum.
* It certainly confounds code expecting all Kerberos 5
* GSS_Wrap() tokens to look the same....
*
* The exception is DNS/TSIG where there is no such confounder
* so we need to test here if there are more bytes in our tvb or not.
* -- ronnie
*/
if (tvb_reported_length_remaining(tvb, offset)) {
if (sgn_alg == KRB_SGN_ALG_HMAC) {
proto_tree_add_item(tree, hf_spnego_krb5_confounder, tvb, offset, 8, ENC_NA);
offset += 8;
}
}
/*
* Return the offset past the checksum, so that we know where
* the data we're wrapped around starts. Also, set the length
* of our top-level item to that offset, so it doesn't cover
* the data we're wrapped around.
*/
return offset;
}
static int
dissect_spnego_krb5_cfx_flags(tvbuff_t *tvb, int offset,
proto_tree *spnego_krb5_tree,
guint8 cfx_flags _U_)
{
static int * const flags[] = {
&hf_spnego_krb5_cfx_flags_04,
&hf_spnego_krb5_cfx_flags_02,
&hf_spnego_krb5_cfx_flags_01,
NULL
};
proto_tree_add_bitmask(spnego_krb5_tree, tvb, offset, hf_spnego_krb5_cfx_flags, ett_spnego_krb5_cfx_flags, flags, ENC_NA);
return (offset + 1);
}
/*
* This is for GSSAPI CFX Wrap tokens ...
*/
static int
dissect_spnego_krb5_cfx_wrap_base(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint16 token_id _U_, gssapi_encrypt_info_t* gssapi_encrypt)
{
guint8 flags;
guint16 ec;
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
guint16 rrc;
#else
(void) pinfo;
#endif
int checksum_size;
int start_offset=offset;
/*
* The KRB5 blob conforms to RFC4121:
* USHORT (0x0504)
* and so on }
*/
/* Now, the sign and seal algorithms ... */
flags = tvb_get_guint8(tvb, offset);
offset = dissect_spnego_krb5_cfx_flags(tvb, offset, tree, flags);
if (gssapi_encrypt != NULL)
gssapi_encrypt->gssapi_data_encrypted=(flags & 2);
/* Skip the filler */
proto_tree_add_item(tree, hf_spnego_krb5_filler, tvb, offset, 1, ENC_NA);
offset += 1;
/* EC */
ec = tvb_get_ntohs(tvb, offset);
proto_tree_add_item(tree, hf_spnego_krb5_cfx_ec, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* RRC */
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
rrc = tvb_get_ntohs(tvb, offset);
#endif
proto_tree_add_item(tree, hf_spnego_krb5_cfx_rrc, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* sequence number */
proto_tree_add_item(tree, hf_spnego_krb5_cfx_seq, tvb, offset, 8, ENC_BIG_ENDIAN);
offset += 8;
if (gssapi_encrypt == NULL) /* Probably shoudn't happen, but just protect ourselves */
return offset;
/* Checksum of plaintext padded data */
if (gssapi_encrypt->gssapi_data_encrypted) {
checksum_size = 44 + ec;
proto_tree_add_item(tree, hf_spnego_krb5_sgn_cksum, tvb, offset, checksum_size, ENC_NA);
offset += checksum_size;
} else {
int returned_offset;
int inner_token_len = 0;
/*
* We know we have a wrap token, but we have to let the proto
* above us decode that, so hand it back in gssapi_wrap_tvb
* and put the checksum in the tree.
*/
checksum_size = ec;
inner_token_len = tvb_reported_length_remaining(tvb, offset);
if (inner_token_len > ec) {
inner_token_len -= ec;
}
/*
* We handle only the two common cases for now
* (rrc == 0 and rrc == ec)
*/
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
if (rrc == ec) {
proto_tree_add_item(tree, hf_spnego_krb5_sgn_cksum, tvb, offset, checksum_size, ENC_NA);
offset += checksum_size;
}
#endif
returned_offset = offset;
gssapi_encrypt->gssapi_wrap_tvb = tvb_new_subset_length(tvb, offset,
inner_token_len);
offset += inner_token_len;
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
if (rrc == 0)
#endif
{
proto_tree_add_item(tree, hf_spnego_krb5_sgn_cksum, tvb, offset, checksum_size, ENC_NA);
}
/*
* Return an offset that puts our caller before the inner
* token. This is better than before, but we still see the
* checksum included in the LDAP query at times.
*/
return returned_offset;
}
if(gssapi_encrypt->decrypt_gssapi_tvb){
/* if the caller did not provide a tvb, then we just use
whatever is left of our current tvb.
*/
if(!gssapi_encrypt->gssapi_encrypted_tvb){
int len;
len=tvb_reported_length_remaining(tvb,offset);
if(len>tvb_captured_length_remaining(tvb, offset)){
/* no point in trying to decrypt,
we don't have the full pdu.
*/
return offset;
}
gssapi_encrypt->gssapi_encrypted_tvb = tvb_new_subset_length_caplen(
tvb, offset, len, len);
}
if (gssapi_encrypt->gssapi_data_encrypted) {
/* do we need to create a tvb for the wrapper
as well ?
*/
if(!gssapi_encrypt->gssapi_wrap_tvb){
gssapi_encrypt->gssapi_wrap_tvb = tvb_new_subset_length(
tvb, start_offset-2,
offset - (start_offset-2));
}
}
}
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
{
tvbuff_t *checksum_tvb = tvb_new_subset_length(tvb, 16, checksum_size);
if (gssapi_encrypt->gssapi_data_encrypted) {
if(gssapi_encrypt->gssapi_encrypted_tvb){
decrypt_gssapi_krb_cfx_wrap(tree,
pinfo,
checksum_tvb,
gssapi_encrypt,
ec,
rrc,
-1,
(flags & 0x0001)?
KRB5_KU_USAGE_ACCEPTOR_SEAL:
KRB5_KU_USAGE_INITIATOR_SEAL);
}
}
}
#endif /* HAVE_HEIMDAL_KERBEROS || HAVE_MIT_KERBEROS */
/*
* Return the offset past the checksum, so that we know where
* the data we're wrapped around starts. Also, set the length
* of our top-level item to that offset, so it doesn't cover
* the data we're wrapped around.
*
* Note that for DCERPC the GSSAPI blobs comes after the data it wraps,
* not before.
*/
return offset;
}
/*
* XXX - This is for GSSAPI CFX GetMIC tokens ...
*/
static int
dissect_spnego_krb5_cfx_getmic_base(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
{
guint8 flags;
int checksum_size;
/*
* The KRB5 blob conforms to RFC4121:
* USHORT (0x0404 == GSS_GetMIC)
* and so on }
*/
flags = tvb_get_guint8(tvb, offset);
offset = dissect_spnego_krb5_cfx_flags(tvb, offset, tree, flags);
/* Skip the filler */
proto_tree_add_item(tree, hf_spnego_krb5_filler, tvb, offset, 5, ENC_NA);
offset += 5;
/* sequence number */
proto_tree_add_item(tree, hf_spnego_krb5_cfx_seq, tvb, offset, 8, ENC_BIG_ENDIAN);
offset += 8;
/* Checksum of plaintext padded data */
checksum_size = tvb_captured_length_remaining(tvb, offset);
proto_tree_add_item(tree, hf_spnego_krb5_sgn_cksum, tvb, offset, checksum_size, ENC_NA);
offset += checksum_size;
/*
* Return the offset past the checksum, so that we know where
* the data we're wrapped around starts. Also, set the length
* of our top-level item to that offset, so it doesn't cover
* the data we're wrapped around.
*/
return offset;
}
/*
* XXX - is this for SPNEGO or just GSS-API?
* RFC 1964 is "The Kerberos Version 5 GSS-API Mechanism"; presumably one
* can directly designate Kerberos V5 as a mechanism in GSS-API, rather
* than designating SPNEGO as the mechanism, offering Kerberos V5, and
* getting it accepted.
*/
static int
dissect_spnego_krb5_wrap(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data)
{
proto_item *item;
proto_tree *subtree;
int offset = 0;
guint16 token_id;
gssapi_encrypt_info_t* encrypt_info = (gssapi_encrypt_info_t*)data;
item = proto_tree_add_item(tree, hf_spnego_krb5, tvb, 0, -1, ENC_NA);
subtree = proto_item_add_subtree(item, ett_spnego_krb5);
/*
* The KRB5 blob conforms to RFC1964:
* USHORT (0x0102 == GSS_Wrap)
* and so on }
*/
/* First, the token ID ... */
token_id = tvb_get_letohs(tvb, offset);
proto_tree_add_uint(subtree, hf_spnego_krb5_tok_id, tvb, offset, 2, token_id);
offset += 2;
switch (token_id) {
case KRB_TOKEN_GETMIC:
offset = dissect_spnego_krb5_getmic_base(tvb, offset, pinfo, subtree);
break;
case KRB_TOKEN_WRAP:
offset = dissect_spnego_krb5_wrap_base(tvb, offset, pinfo, subtree, token_id, encrypt_info);
break;
case KRB_TOKEN_CFX_GETMIC:
offset = dissect_spnego_krb5_cfx_getmic_base(tvb, offset, pinfo, subtree);
break;
case KRB_TOKEN_CFX_WRAP:
offset = dissect_spnego_krb5_cfx_wrap_base(tvb, offset, pinfo, subtree, token_id, encrypt_info);
break;
default:
break;
}
/*
* Return the offset past the checksum, so that we know where
* the data we're wrapped around starts. Also, set the length
* of our top-level item to that offset, so it doesn't cover
* the data we're wrapped around.
*/
proto_item_set_len(item, offset);
return offset;
}
/* Spnego stuff from here */
static int
dissect_spnego_wrap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
proto_item *item;
proto_tree *subtree;
int offset = 0;
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
MechType_oid = NULL;
/*
* We need this later, so lets get it now ...
* It has to be per-frame as there can be more than one GSS-API
* negotiation in a conversation.
*/
item = proto_tree_add_item(tree, proto_spnego, tvb, offset, -1, ENC_NA);
subtree = proto_item_add_subtree(item, ett_spnego);
/*
* The TVB contains a [0] header and a sequence that consists of an
* object ID and a blob containing the data ...
* XXX - is this RFC 2743's "Mechanism-Independent Token Format",
* with the "optional" "use in non-initial tokens" being chosen.
* ASN1 code addet to spnego.asn to handle this.
*/
offset = dissect_spnego_InitialContextToken(FALSE, tvb, offset, &asn1_ctx , subtree, -1);
return offset;
}
static int
dissect_spnego(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_)
{
proto_item *item;
proto_tree *subtree;
int offset = 0;
conversation_t *conversation;
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
/*
* We need this later, so lets get it now ...
* It has to be per-frame as there can be more than one GSS-API
* negotiation in a conversation.
*/
next_level_value = (gssapi_oid_value *)p_get_proto_data(wmem_file_scope(), pinfo, proto_spnego, 0);
if (!next_level_value && !pinfo->fd->visited) {
/*
* No handle attached to this frame, but it's the first
* pass, so it'd be attached to the conversation.
* If we have a conversation, try to get the handle,
* and if we get one, attach it to the frame.
*/
conversation = find_conversation_pinfo(pinfo, 0);
if (conversation) {
next_level_value = (gssapi_oid_value *)conversation_get_proto_data(conversation, proto_spnego);
if (next_level_value)
p_add_proto_data(wmem_file_scope(), pinfo, proto_spnego, 0, next_level_value);
}
}
item = proto_tree_add_item(parent_tree, proto_spnego, tvb, offset, -1, ENC_NA);
subtree = proto_item_add_subtree(item, ett_spnego);
/*
* The TVB contains a [0] header and a sequence that consists of an
* object ID and a blob containing the data ...
* Actually, it contains, according to RFC2478:
* NegotiationToken ::= CHOICE {
* negTokenInit [0] NegTokenInit,
* negTokenTarg [1] NegTokenTarg }
* NegTokenInit ::= SEQUENCE {
* mechTypes [0] MechTypeList OPTIONAL,
* reqFlags [1] ContextFlags OPTIONAL,
* mechToken [2] OCTET STRING OPTIONAL,
* mechListMIC [3] OCTET STRING OPTIONAL }
* NegTokenTarg ::= SEQUENCE {
* negResult [0] ENUMERATED {
* accept_completed (0),
* accept_incomplete (1),
* reject (2) } OPTIONAL,
* supportedMech [1] MechType OPTIONAL,
* responseToken [2] OCTET STRING OPTIONAL,
* mechListMIC [3] OCTET STRING OPTIONAL }
*
* Windows typically includes mechTypes and mechListMic ('NONE'
* in the case of NTLMSSP only).
* It seems to duplicate the responseToken into the mechListMic field
* as well. Naughty, naughty.
*
*/
dissect_spnego_NegotiationToken(FALSE, tvb, offset, &asn1_ctx, subtree, -1);
return tvb_captured_length(tvb);
}
/*--- proto_register_spnego -------------------------------------------*/
void proto_register_spnego(void) {
/* List of fields */
static hf_register_info hf[] = {
{ &hf_spnego_wraptoken,
{ "wrapToken", "spnego.wraptoken",
FT_NONE, BASE_NONE, NULL, 0x0, "SPNEGO wrapToken",
HFILL}},
{ &hf_spnego_krb5,
{ "krb5_blob", "spnego.krb5.blob", FT_BYTES,
BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_spnego_krb5_oid,
{ "KRB5 OID", "spnego.krb5_oid", FT_STRING,
BASE_NONE, NULL, 0, NULL, HFILL }},
{ &hf_spnego_krb5_tok_id,
{ "krb5_tok_id", "spnego.krb5.tok_id", FT_UINT16, BASE_HEX,
VALS(spnego_krb5_tok_id_vals), 0, "KRB5 Token Id", HFILL}},
{ &hf_spnego_krb5_sgn_alg,
{ "krb5_sgn_alg", "spnego.krb5.sgn_alg", FT_UINT16, BASE_HEX,
VALS(spnego_krb5_sgn_alg_vals), 0, "KRB5 Signing Algorithm", HFILL}},
{ &hf_spnego_krb5_seal_alg,
{ "krb5_seal_alg", "spnego.krb5.seal_alg", FT_UINT16, BASE_HEX,
VALS(spnego_krb5_seal_alg_vals), 0, "KRB5 Sealing Algorithm", HFILL}},
{ &hf_spnego_krb5_snd_seq,
{ "krb5_snd_seq", "spnego.krb5.snd_seq", FT_BYTES, BASE_NONE,
NULL, 0, "KRB5 Encrypted Sequence Number", HFILL}},
{ &hf_spnego_krb5_sgn_cksum,
{ "krb5_sgn_cksum", "spnego.krb5.sgn_cksum", FT_BYTES, BASE_NONE,
NULL, 0, "KRB5 Data Checksum", HFILL}},
{ &hf_spnego_krb5_confounder,
{ "krb5_confounder", "spnego.krb5.confounder", FT_BYTES, BASE_NONE,
NULL, 0, "KRB5 Confounder", HFILL}},
{ &hf_spnego_krb5_filler,
{ "krb5_filler", "spnego.krb5.filler", FT_BYTES, BASE_NONE,
NULL, 0, "KRB5 Filler", HFILL}},
{ &hf_spnego_krb5_cfx_flags,
{ "krb5_cfx_flags", "spnego.krb5.cfx_flags", FT_UINT8, BASE_HEX,
NULL, 0, "KRB5 CFX Flags", HFILL}},
{ &hf_spnego_krb5_cfx_flags_01,
{ "SendByAcceptor", "spnego.krb5.send_by_acceptor", FT_BOOLEAN, 8,
TFS (&tfs_set_notset), 0x01, NULL, HFILL}},
{ &hf_spnego_krb5_cfx_flags_02,
{ "Sealed", "spnego.krb5.sealed", FT_BOOLEAN, 8,
TFS (&tfs_set_notset), 0x02, NULL, HFILL}},
{ &hf_spnego_krb5_cfx_flags_04,
{ "AcceptorSubkey", "spnego.krb5.acceptor_subkey", FT_BOOLEAN, 8,
TFS (&tfs_set_notset), 0x04, NULL, HFILL}},
{ &hf_spnego_krb5_cfx_ec,
{ "krb5_cfx_ec", "spnego.krb5.cfx_ec", FT_UINT16, BASE_DEC,
NULL, 0, "KRB5 CFX Extra Count", HFILL}},
{ &hf_spnego_krb5_cfx_rrc,
{ "krb5_cfx_rrc", "spnego.krb5.cfx_rrc", FT_UINT16, BASE_DEC,
NULL, 0, "KRB5 CFX Right Rotation Count", HFILL}},
{ &hf_spnego_krb5_cfx_seq,
{ "krb5_cfx_seq", "spnego.krb5.cfx_seq", FT_UINT64, BASE_DEC,
NULL, 0, "KRB5 Sequence Number", HFILL}},
{ &hf_spnego_negTokenInit,
{ "negTokenInit", "spnego.negTokenInit_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_spnego_negTokenTarg,
{ "negTokenTarg", "spnego.negTokenTarg_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_spnego_MechTypeList_item,
{ "MechType", "spnego.MechType",
FT_OID, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_spnego_mechTypes,
{ "mechTypes", "spnego.mechTypes",
FT_UINT32, BASE_DEC, NULL, 0,
"MechTypeList", HFILL }},
{ &hf_spnego_reqFlags,
{ "reqFlags", "spnego.reqFlags",
FT_BYTES, BASE_NONE, NULL, 0,
"ContextFlags", HFILL }},
{ &hf_spnego_mechToken,
{ "mechToken", "spnego.mechToken",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_spnego_mechListMIC,
{ "mechListMIC", "spnego.mechListMIC",
FT_BYTES, BASE_NONE, NULL, 0,
"OCTET_STRING", HFILL }},
{ &hf_spnego_hintName,
{ "hintName", "spnego.hintName",
FT_STRING, BASE_NONE, NULL, 0,
"GeneralString", HFILL }},
{ &hf_spnego_hintAddress,
{ "hintAddress", "spnego.hintAddress",
FT_BYTES, BASE_NONE, NULL, 0,
"OCTET_STRING", HFILL }},
{ &hf_spnego_mechToken_01,
{ "mechToken", "spnego.mechToken",
FT_BYTES, BASE_NONE, NULL, 0,
"OCTET_STRING", HFILL }},
{ &hf_spnego_negHints,
{ "negHints", "spnego.negHints_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_spnego_negResult,
{ "negResult", "spnego.negResult",
FT_UINT32, BASE_DEC, VALS(spnego_T_negResult_vals), 0,
NULL, HFILL }},
{ &hf_spnego_supportedMech,
{ "supportedMech", "spnego.supportedMech",
FT_OID, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_spnego_responseToken,
{ "responseToken", "spnego.responseToken",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_spnego_mechListMIC_01,
{ "mechListMIC", "spnego.mechListMIC",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_spnego_thisMech,
{ "thisMech", "spnego.thisMech",
FT_OID, BASE_NONE, NULL, 0,
"MechType", HFILL }},
{ &hf_spnego_innerContextToken,
{ "innerContextToken", "spnego.innerContextToken_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_spnego_ContextFlags_delegFlag,
{ "delegFlag", "spnego.ContextFlags.delegFlag",
FT_BOOLEAN, 8, NULL, 0x80,
NULL, HFILL }},
{ &hf_spnego_ContextFlags_mutualFlag,
{ "mutualFlag", "spnego.ContextFlags.mutualFlag",
FT_BOOLEAN, 8, NULL, 0x40,
NULL, HFILL }},
{ &hf_spnego_ContextFlags_replayFlag,
{ "replayFlag", "spnego.ContextFlags.replayFlag",
FT_BOOLEAN, 8, NULL, 0x20,
NULL, HFILL }},
{ &hf_spnego_ContextFlags_sequenceFlag,
{ "sequenceFlag", "spnego.ContextFlags.sequenceFlag",
FT_BOOLEAN, 8, NULL, 0x10,
NULL, HFILL }},
{ &hf_spnego_ContextFlags_anonFlag,
{ "anonFlag", "spnego.ContextFlags.anonFlag",
FT_BOOLEAN, 8, NULL, 0x08,
NULL, HFILL }},
{ &hf_spnego_ContextFlags_confFlag,
{ "confFlag", "spnego.ContextFlags.confFlag",
FT_BOOLEAN, 8, NULL, 0x04,
NULL, HFILL }},
{ &hf_spnego_ContextFlags_integFlag,
{ "integFlag", "spnego.ContextFlags.integFlag",
FT_BOOLEAN, 8, NULL, 0x02,
NULL, HFILL }},
};
/* List of subtrees */
static gint *ett[] = {
&ett_spnego,
&ett_spnego_wraptoken,
&ett_spnego_krb5,
&ett_spnego_krb5_cfx_flags,
&ett_spnego_NegotiationToken,
&ett_spnego_MechTypeList,
&ett_spnego_NegTokenInit,
&ett_spnego_NegHints,
&ett_spnego_NegTokenInit2,
&ett_spnego_ContextFlags,
&ett_spnego_NegTokenTarg,
&ett_spnego_InitialContextToken_U,
};
static ei_register_info ei[] = {
{ &ei_spnego_decrypted_keytype, { "spnego.decrypted_keytype", PI_SECURITY, PI_CHAT, "Decrypted keytype", EXPFILL }},
{ &ei_spnego_unknown_header, { "spnego.unknown_header", PI_PROTOCOL, PI_WARN, "Unknown header", EXPFILL }},
};
expert_module_t* expert_spnego;
/* Register protocol */
proto_spnego = proto_register_protocol(PNAME, PSNAME, PFNAME);
spnego_handle = register_dissector("spnego", dissect_spnego, proto_spnego);
spnego_wrap_handle = register_dissector("spnego-wrap", dissect_spnego_wrap, proto_spnego);
proto_spnego_krb5 = proto_register_protocol("SPNEGO-KRB5", "SPNEGO-KRB5", "spnego-krb5");
spnego_krb5_handle = register_dissector("spnego-krb5", dissect_spnego_krb5, proto_spnego_krb5);
spnego_krb5_wrap_handle = register_dissector("spnego-krb5-wrap", dissect_spnego_krb5_wrap, proto_spnego_krb5);
/* Register fields and subtrees */
proto_register_field_array(proto_spnego, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_spnego = expert_register_protocol(proto_spnego);
expert_register_field_array(expert_spnego, ei, array_length(ei));
}
/*--- proto_reg_handoff_spnego ---------------------------------------*/
void proto_reg_handoff_spnego(void) {
/* Register protocol with GSS-API module */
gssapi_init_oid("1.3.6.1.5.5.2", proto_spnego, ett_spnego,
spnego_handle, spnego_wrap_handle,
"SPNEGO - Simple Protected Negotiation");
/* Register both the one MS created and the real one */
/*
* Thanks to Jean-Baptiste Marchand and Richard B Ward, the
* mystery of the MS KRB5 OID is cleared up. It was due to a library
* that did not handle OID components greater than 16 bits, and was
* fixed in Win2K SP2 as well as WinXP.
* See the archive of <[email protected]> for the thread topic
* SPNEGO implementation issues. 3-Dec-2002.
*/
gssapi_init_oid("1.2.840.48018.1.2.2", proto_spnego_krb5, ett_spnego_krb5,
spnego_krb5_handle, spnego_krb5_wrap_handle,
"MS KRB5 - Microsoft Kerberos 5");
gssapi_init_oid("1.2.840.113554.1.2.2", proto_spnego_krb5, ett_spnego_krb5,
spnego_krb5_handle, spnego_krb5_wrap_handle,
"KRB5 - Kerberos 5");
gssapi_init_oid("1.2.840.113554.1.2.2.3", proto_spnego_krb5, ett_spnego_krb5,
spnego_krb5_handle, spnego_krb5_wrap_handle,
"KRB5 - Kerberos 5 - User to User");
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|
C
|
wireshark/epan/dissectors/packet-spp.c
|
/* packet-spp.c
* Routines for XNS SPP
* Based on the Netware SPX dissector by Gilbert Ramirez <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include "packet-idp.h"
void proto_register_spp(void);
void proto_reg_handoff_spp(void);
static dissector_handle_t spp_handle;
static int proto_spp = -1;
static int hf_spp_connection_control = -1;
static int hf_spp_connection_control_sys = -1;
static int hf_spp_connection_control_send_ack = -1;
static int hf_spp_connection_control_attn = -1;
static int hf_spp_connection_control_eom = -1;
static int hf_spp_datastream_type = -1;
static int hf_spp_src_id = -1;
static int hf_spp_dst_id = -1;
static int hf_spp_seq_nr = -1;
static int hf_spp_ack_nr = -1;
static int hf_spp_all_nr = -1;
/* static int hf_spp_rexmt_frame = -1; */
static gint ett_spp = -1;
static gint ett_spp_connctrl = -1;
static dissector_table_t spp_socket_dissector_table;
/*
* See
*
* "Internet Transport Protocols", XSIS 028112, December 1981
*
* if you can find it; this is based on the headers in the BSD XNS
* implementation.
*/
#define SPP_SYS_PACKET 0x80
#define SPP_SEND_ACK 0x40
#define SPP_ATTN 0x20
#define SPP_EOM 0x10
static const char*
spp_conn_ctrl(guint8 ctrl)
{
static const value_string conn_vals[] = {
{ 0x00, "Data, No Ack Required" },
{ SPP_EOM, "End-of-Message" },
{ SPP_ATTN, "Attention" },
{ SPP_SEND_ACK, "Acknowledgment Required"},
{ SPP_SEND_ACK|SPP_EOM, "Send Ack: End Message"},
{ SPP_SYS_PACKET, "System Packet"},
{ SPP_SYS_PACKET|SPP_SEND_ACK, "System Packet: Send Ack"},
{ 0x00, NULL }
};
return val_to_str_const((ctrl & 0xf0), conn_vals, "Unknown");
}
static const char*
spp_datastream(guint8 type)
{
switch (type) {
case 0xfe:
return "End-of-Connection";
case 0xff:
return "End-of-Connection Acknowledgment";
default:
return NULL;
}
}
#define SPP_HEADER_LEN 12
/*
* XXX - do reassembly, using the EOM flag. (Then do that in the Netware
* SPX implementation, too.)
*
* XXX - hand off to subdissectors based on the socket number.
*/
static int
dissect_spp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
proto_tree *spp_tree;
proto_item *ti;
tvbuff_t *next_tvb;
guint8 conn_ctrl;
guint8 datastream_type;
const char *datastream_type_string;
guint16 spp_seq;
const char *spp_msg_string;
guint16 low_socket, high_socket;
static int * const ctrl[] = {
&hf_spp_connection_control_sys,
&hf_spp_connection_control_send_ack,
&hf_spp_connection_control_attn,
&hf_spp_connection_control_eom,
NULL
};
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SPP");
col_set_str(pinfo->cinfo, COL_INFO, "SPP");
ti = proto_tree_add_item(tree, proto_spp, tvb, 0, SPP_HEADER_LEN, ENC_NA);
spp_tree = proto_item_add_subtree(ti, ett_spp);
conn_ctrl = tvb_get_guint8(tvb, 0);
spp_msg_string = spp_conn_ctrl(conn_ctrl);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", spp_msg_string);
proto_tree_add_bitmask_with_flags(spp_tree, tvb, 0, hf_spp_connection_control, ett_spp_connctrl,
ctrl, ENC_NA, BMT_NO_FALSE);
datastream_type = tvb_get_guint8(tvb, 1);
datastream_type_string = spp_datastream(datastream_type);
if (datastream_type_string != NULL) {
col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)", datastream_type_string);
}
if (tree) {
if (datastream_type_string != NULL) {
proto_tree_add_uint_format_value(spp_tree, hf_spp_datastream_type, tvb,
1, 1, datastream_type,
"%s (0x%02X)",
datastream_type_string,
datastream_type);
} else {
proto_tree_add_uint(spp_tree, hf_spp_datastream_type, tvb,
1, 1, datastream_type);
}
proto_tree_add_item(spp_tree, hf_spp_src_id, tvb, 2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(spp_tree, hf_spp_dst_id, tvb, 4, 2, ENC_BIG_ENDIAN);
}
spp_seq = tvb_get_ntohs(tvb, 6);
if (tree) {
proto_tree_add_uint(spp_tree, hf_spp_seq_nr, tvb, 6, 2, spp_seq);
proto_tree_add_item(spp_tree, hf_spp_ack_nr, tvb, 8, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(spp_tree, hf_spp_all_nr, tvb, 10, 2, ENC_BIG_ENDIAN);
}
if (tvb_reported_length_remaining(tvb, SPP_HEADER_LEN) > 0) {
if (pinfo->srcport > pinfo->destport) {
low_socket = pinfo->destport;
high_socket = pinfo->srcport;
} else {
low_socket = pinfo->srcport;
high_socket = pinfo->destport;
}
next_tvb = tvb_new_subset_remaining(tvb, SPP_HEADER_LEN);
if (dissector_try_uint(spp_socket_dissector_table, low_socket,
next_tvb, pinfo, tree))
return tvb_captured_length(tvb);
if (dissector_try_uint(spp_socket_dissector_table, high_socket,
next_tvb, pinfo, tree))
return tvb_captured_length(tvb);
call_data_dissector(next_tvb, pinfo, tree);
}
return tvb_captured_length(tvb);
}
void
proto_register_spp(void)
{
static hf_register_info hf_spp[] = {
{ &hf_spp_connection_control,
{ "Connection Control", "spp.ctl",
FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_spp_connection_control_sys,
{ "System Packet", "spp.ctl.sys",
FT_BOOLEAN, 8, NULL, SPP_SYS_PACKET,
NULL, HFILL }},
{ &hf_spp_connection_control_send_ack,
{ "Send Ack", "spp.ctl.send_ack",
FT_BOOLEAN, 8, NULL, SPP_SEND_ACK,
NULL, HFILL }},
{ &hf_spp_connection_control_attn,
{ "Attention", "spp.ctl.attn",
FT_BOOLEAN, 8, NULL, SPP_ATTN,
NULL, HFILL }},
{ &hf_spp_connection_control_eom,
{ "End of Message", "spp.ctl.eom",
FT_BOOLEAN, 8, NULL, SPP_EOM,
NULL, HFILL }},
{ &hf_spp_datastream_type,
{ "Datastream Type", "spp.type",
FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_spp_src_id,
{ "Source Connection ID", "spp.src",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_spp_dst_id,
{ "Destination Connection ID", "spp.dst",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_spp_seq_nr,
{ "Sequence Number", "spp.seq",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_spp_ack_nr,
{ "Acknowledgment Number", "spp.ack",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_spp_all_nr,
{ "Allocation Number", "spp.alloc",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
#if 0
{ &hf_spp_rexmt_frame,
{ "Retransmitted Frame Number", "spp.rexmt_frame",
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
#endif
};
static gint *ett[] = {
&ett_spp,
&ett_spp_connctrl,
};
proto_spp = proto_register_protocol("Sequenced Packet Protocol",
"SPP", "spp");
proto_register_field_array(proto_spp, hf_spp, array_length(hf_spp));
proto_register_subtree_array(ett, array_length(ett));
spp_handle = register_dissector("spp", dissect_spp, proto_spp);
spp_socket_dissector_table = register_dissector_table("spp.socket",
"SPP socket", proto_spp, FT_UINT16, BASE_HEX);
}
void
proto_reg_handoff_spp(void)
{
dissector_add_uint("idp.packet_type", IDP_PACKET_TYPE_SPP, spp_handle);
}
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-spray.c
|
/* packet-spray.c
* 2001 Ronnie Sahlberg <See AUTHORS for email>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include "packet-rpc.h"
void proto_register_spray(void);
void proto_reg_handoff_spray(void);
static int proto_spray = -1;
static int hf_spray_procedure_v1 = -1;
static int hf_spray_sprayarr = -1;
static int hf_spray_counter = -1;
static int hf_spray_clock = -1;
static int hf_spray_sec = -1;
static int hf_spray_usec = -1;
static gint ett_spray = -1;
static gint ett_spray_clock = -1;
#define PACKET_SPRAY_H
#define SPRAYPROC_NULL 0
#define SPRAYPROC_SPRAY 1
#define SPRAYPROC_GET 2
#define SPRAYPROC_CLEAR 3
#define SPRAY_PROGRAM 100012
static int
dissect_get_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
proto_item* lock_item = NULL;
proto_tree* lock_tree = NULL;
int offset = 0;
offset = dissect_rpc_uint32(tvb, tree,
hf_spray_counter, offset);
lock_item = proto_tree_add_item(tree, hf_spray_clock, tvb,
offset, -1, ENC_NA);
lock_tree = proto_item_add_subtree(lock_item, ett_spray_clock);
offset = dissect_rpc_uint32(tvb, lock_tree,
hf_spray_sec, offset);
offset = dissect_rpc_uint32(tvb, lock_tree,
hf_spray_usec, offset);
return offset;
}
static int
dissect_spray_call(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
return dissect_rpc_data(tvb, tree, hf_spray_sprayarr, 0);
}
/* proc number, "proc name", dissect_request, dissect_reply */
static const vsff spray1_proc[] = {
{ SPRAYPROC_NULL, "NULL",
dissect_rpc_void, dissect_rpc_void },
{ SPRAYPROC_SPRAY, "SPRAY",
dissect_spray_call, dissect_rpc_void },
{ SPRAYPROC_GET, "GET",
dissect_rpc_void, dissect_get_reply },
{ SPRAYPROC_CLEAR, "CLEAR",
dissect_rpc_void, dissect_rpc_void },
{ 0, NULL, NULL, NULL }
};
static const value_string spray1_proc_vals[] = {
{ SPRAYPROC_NULL, "NULL" },
{ SPRAYPROC_SPRAY, "SPRAY" },
{ SPRAYPROC_GET, "GET" },
{ SPRAYPROC_CLEAR, "CLEAR" },
{ 0, NULL }
};
static const rpc_prog_vers_info spray_vers_info[] = {
{ 1, spray1_proc, &hf_spray_procedure_v1 },
};
void
proto_register_spray(void)
{
static hf_register_info hf[] = {
{ &hf_spray_procedure_v1, {
"V1 Procedure", "spray.procedure_v1", FT_UINT32, BASE_DEC,
VALS(spray1_proc_vals), 0, NULL, HFILL }},
{ &hf_spray_sprayarr, {
"Data", "spray.sprayarr", FT_BYTES, BASE_NONE,
NULL, 0, "Sprayarr data", HFILL }},
{ &hf_spray_counter, {
"counter", "spray.counter", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_spray_clock, {
"clock", "spray.clock", FT_NONE, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_spray_sec, {
"sec", "spray.sec", FT_UINT32, BASE_DEC,
NULL, 0, "Seconds", HFILL }},
{ &hf_spray_usec, {
"usec", "spray.usec", FT_UINT32, BASE_DEC,
NULL, 0, "Microseconds", HFILL }}
};
static gint *ett[] = {
&ett_spray,
&ett_spray_clock,
};
proto_spray = proto_register_protocol("SPRAY", "SPRAY", "spray");
proto_register_field_array(proto_spray, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_spray(void)
{
/* Register the protocol as RPC */
rpc_init_prog(proto_spray, SPRAY_PROGRAM, ett_spray,
G_N_ELEMENTS(spray_vers_info), spray_vers_info);
}
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-sprt.c
|
/* packet-sprt.h
*
* Routines for SPRT dissection
* SPRT = Simple Packet Relay Transport
*
* Written by Jamison Adcock <[email protected]>
* for Sparta Inc., dba Cobham Analytic Solutions
* This code is largely based on the RTP parsing code
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* TODO:
* - work on conversations
*
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/conversation.h>
#include <epan/expert.h>
#include "packet-sprt.h"
void proto_register_sprt(void);
void proto_reg_handoff_sprt(void);
/* for some "range_string"s, there's only one value in the range */
#define SPRT_VALUE_RANGE(a) a,a
/* TODO - conversation states */
#define SPRT_STATE_XXX_TODO 0
#define SPRT_CONV_MAX_SETUP_METHOD_SIZE 12
/* is DLCI field present in I_OCTET message? See "DLCI enabled" in CONNECT message */
typedef enum {
DLCI_UNKNOWN,
DLCI_PRESENT,
DLCI_ABSENT
} i_octet_dlci_status_t;
/* Keep conversation info for one side of an SPRT conversation
* TODO - this needs to be bidirectional
*/
struct _sprt_conversation_info
{
gchar method[SPRT_CONV_MAX_SETUP_METHOD_SIZE + 1];
gboolean stream_started;
guint32 frame_number; /* the frame where this conversation is started */
/* sequence numbers for each channel: */
guint32 seqnum[4];
/* are we using the DLCI field in I_OCTET messages? See CONNECT message ("DLCI enabled") */
i_octet_dlci_status_t i_octet_dlci_status;
guint32 connect_frame_number; /* the CONNECT frame that tells us if the DLCI is enabled */
/* TODO - maintain state */
};
/* SPRT Message IDs: */
#define SPRT_MODEM_RELAY_MSG_ID_NULL 0
#define SPRT_MODEM_RELAY_MSG_ID_INIT 1
#define SPRT_MODEM_RELAY_MSG_ID_XID_XCHG 2
#define SPRT_MODEM_RELAY_MSG_ID_JM_INFO 3
#define SPRT_MODEM_RELAY_MSG_ID_START_JM 4
#define SPRT_MODEM_RELAY_MSG_ID_CONNECT 5
#define SPRT_MODEM_RELAY_MSG_ID_BREAK 6
#define SPRT_MODEM_RELAY_MSG_ID_BREAK_ACK 7
#define SPRT_MODEM_RELAY_MSG_ID_MR_EVENT 8
#define SPRT_MODEM_RELAY_MSG_ID_CLEARDOWN 9
#define SPRT_MODEM_RELAY_MSG_ID_PROF_XCHG 10
/* 11 -15 Reserved */
#define SPRT_MODEM_RELAY_MSG_ID_RESERVED1_START 11
#define SPRT_MODEM_RELAY_MSG_ID_RESERVED1_END 15
/* Data */
#define SPRT_MODEM_RELAY_MSG_ID_I_RAW_OCTET 16
#define SPRT_MODEM_RELAY_MSG_ID_I_RAW_BIT 17
#define SPRT_MODEM_RELAY_MSG_ID_I_OCTET 18
#define SPRT_MODEM_RELAY_MSG_ID_I_CHAR_STAT 19
#define SPRT_MODEM_RELAY_MSG_ID_I_CHAR_DYN 20
#define SPRT_MODEM_RELAY_MSG_ID_I_FRAME 21
#define SPRT_MODEM_RELAY_MSG_ID_I_OCTET_CS 22
#define SPRT_MODEM_RELAY_MSG_ID_I_CHAR_STAT_CS 23
#define SPRT_MODEM_RELAY_MSG_ID_I_CHAR_DYN_CS 24
/* 25 - 99 Reserved */
#define SPRT_MODEM_RELAY_MSG_ID_RESERVED2_START 25
#define SPRT_MODEM_RELAY_MSG_ID_RESERVED2_END 99
/* 100 - 127 Vendor-specific */
#define SPRT_MODEM_RELAY_MSG_ID_VENDOR_START 100
#define SPRT_MODEM_RELAY_MSG_ID_VENDOR_END 127
/* error correcting protocol in XID_XCHG message: */
#define SPRT_ECP_NO_LINK_LAYER_PROTO 0
#define SPRT_ECP_V42_LAPM 1
#define SPRT_ECP_ANNEX_AV42_1996 2
/* 3 - 25 Reserved for ITU-T */
#define SPRT_ECP_RESERVED_START 3
#define SPRT_ECP_RESERVED_END 25
/* category ID used in JM_INFO message: */
#define SPRT_JM_INFO_CAT_ID_CALL_FUNCT 0x8
#define SPRT_JM_INFO_CAT_ID_MOD_MODES 0xA
#define SPRT_JM_INFO_CAT_ID_PROTOCOLS 0x5
#define SPRT_JM_INFO_CAT_ID_PSTN_ACCESS 0xB
#define SPRT_JM_INFO_CAT_ID_PCM_MODEM_AVAIL 0xE
#define SPRT_JM_INFO_CAT_ID_CATEGORY_EXTENSION 0x0
#define SPRT_JMINFO_TBC_CALL_FUNCT_PSTN_MULTIMEDIA_TERM 0x4
#define SPRT_JMINFO_TBC_CALL_FUNCT_TEXTPHONE_ITU_T_REC_V18 0x2
#define SPRT_JMINFO_TBC_CALL_FUNCT_VIDEOTEXT_ITU_T_REC_T101 0x6
#define SPRT_JMINFO_TBC_CALL_FUNCT_TRANS_FAX_ITU_T_REC_T30 0x1
#define SPRT_JMINFO_TBC_CALL_FUNCT_RECV_FAX_ITU_T_REC_T30 0x5
#define SPRT_JMINFO_TBC_CALL_FUNCT_DATA_V_SERIES_MODEM_REC 0x3
#define SPRT_JMINFO_TBC_PROTOCOL_LAPM_ITU_T_REC_V42 0x4
/* selected modulations in CONNECT message: */
#define SPRT_SELMOD_NULL 0
#define SPRT_SELMOD_V92 1
#define SPRT_SELMOD_V91 2
#define SPRT_SELMOD_V90 3
#define SPRT_SELMOD_V34 4
#define SPRT_SELMOD_V32_BIS 5
#define SPRT_SELMOD_V32 6
#define SPRT_SELMOD_V22_BIS 7
#define SPRT_SELMOD_V22 8
#define SPRT_SELMOD_V17 9
#define SPRT_SELMOD_V29 10
#define SPRT_SELMOD_V27_TER 11
#define SPRT_SELMOD_V26_TER 12
#define SPRT_SELMOD_V26_BIS 13
#define SPRT_SELMOD_V23 14
#define SPRT_SELMOD_V21 15
#define SPRT_SELMOD_BELL_212 16
#define SPRT_SELMOD_BELL_103 17
/* 18 - 30 Vendor-specific modulations */
#define SPRT_SELMOD_VENDOR_START 18
#define SPRT_SELMOD_VENDOR_END 30
/* 31 - 63 Reserved for ITU-T */
#define SPRT_SELMOD_RESERVED_START 31
#define SPRT_SELMOD_RESERVED_END 63
/* Compression direction in CONNECT message: */
#define SPRT_COMPR_DIR_NO_COMPRESSION 0
#define SPRT_COMPR_DIR_TRANSMIT 1
#define SPRT_COMPR_DIR_RECEIVE 2
#define SPRT_COMPR_DIR_BIDIRECTIONAL 3
/* Selected compression modes in CONNECT message: */
#define SPRT_SELECTED_COMPR_NONE 0
#define SPRT_SELECTED_COMPR_V42_BIS 1
#define SPRT_SELECTED_COMPR_V44 2
#define SPRT_SELECTED_COMPR_MNP5 3
/* 4 - 15 Reserved by ITU-T */
#define SPRT_SELECTED_COMPR_RESERVED_START 4
#define SPRT_SELECTED_COMPR_RESERVED_END 15
/* Selected error correction modes in CONNECT message: */
#define SPRT_SELECTED_ERR_CORR_V14_OR_NONE 0
#define SPRT_SELECTED_ERR_CORR_V42_LAPM 1
#define SPRT_SELECTED_ERR_CORR_ANNEX_AV42 2
/* 3 - 15 Reserved for ITU-T */
#define SPRT_SELECTED_ERR_CORR_RESERVED_START 3
#define SPRT_SELECTED_ERR_CORR_RESERVED_END 15
/* Break source protocol in BREAK message: */
#define SPRT_BREAK_SRC_PROTO_V42_LAPM 0
#define SPRT_BREAK_SRC_PROTO_ANNEX_AV42_1996 1
#define SPRT_BREAK_SRC_PROTO_V14 2
/* 3 - 15 Reserved for ITU-T */
#define SPRT_BREAK_SRC_PROTO_RESERVED_START 3
#define SPRT_BREAK_SRC_PROTO_RESERVED_END 15
#define SPRT_BREAK_TYPE_NOT_APPLICABLE 0
#define SPRT_BREAK_TYPE_DESTRUCTIVE_AND_EXPEDITED 1
#define SPRT_BREAK_TYPE_NONDESTRUCTIVE_AND_EXPEDITED 2
#define SPRT_BREAK_TYPE_NONDESTRUCTIVE_AND_NONEXPEDITED 3
/* 4 - 15 Reserved for ITU-T */
#define SPRT_BREAK_TYPE_RESERVED_START 4
#define SPRT_BREAK_TYPE_RESERVED_END 15
/* Modem relay info in MR_EVENT messages: */
#define SPRT_MREVT_EVENT_ID_NULL 0
#define SPRT_MREVT_EVENT_ID_RATE_RENEGOTIATION 1
#define SPRT_MREVT_EVENT_ID_RETRAIN 2
#define SPRT_MREVT_EVENT_ID_PHYSUP 3
/* 4 - 255 Reserved for ITU-T */
#define SPRT_MREVT_EVENT_ID_RESERVED_START 4
#define SPRT_MREVT_EVENT_ID_RESERVED_END 255
#define SPRT_MREVT_REASON_CODE_NULL 0
#define SPRT_MREVT_REASON_CODE_INIT 1
#define SPRT_MREVT_REASON_CODE_RESPONDING 2
/* 3 - 255 Undefined */
#define SPRT_MREVT_REASON_CODE_RESERVED_START 3
#define SPRT_MREVT_REASON_CODE_RESERVED_END 255
#define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_NULL 0
#define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_600 1
#define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_1200 2
#define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_1600 3
#define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_2400 4
#define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_2743 5
#define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_3000 6
#define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_3200 7
#define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_3429 8
#define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_8000 9
/* 10 - 254 Reserved for ITU-T */
#define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_RESERVED_START 10
#define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_RESERVED_END 254
#define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_UNSPECIFIED 255
/* Cleardown reason codes: */
#define SPRT_CLEARDOWN_RIC_UNKNOWN 0
#define SPRT_CLEARDOWN_RIC_PHYSICAL_LAYER_RELEASE 1
#define SPRT_CLEARDOWN_RIC_LINK_LAYER_DISCONNECT 2
#define SPRT_CLEARDOWN_RIC_DATA_COMPRESSION_DISCONNECT 3
#define SPRT_CLEARDOWN_RIC_ABORT 4
#define SPRT_CLEARDOWN_RIC_ON_HOOK 5
#define SPRT_CLEARDOWN_RIC_NETWORK_LAYER_TERMINATION 6
#define SPRT_CLEARDOWN_RIC_ADMINISTRATIVE 7
/* PROF_XCHG messages (XID profile exchange for MR1): */
#define SPRT_PROF_XCHG_SUPPORT_NO 0
#define SPRT_PROF_XCHG_SUPPORT_YES 1
#define SPRT_PROF_XCHG_SUPPORT_UNKNOWN 2
/* DLCI field in I_OCTET: */
#define SPRT_PAYLOAD_DLCI1_DTE2DTE 0
#define SPRT_PAYLOAD_DLCI1_RESERVED_START 1
#define SPRT_PAYLOAD_DLCI1_RESERVED_END 31
#define SPRT_PAYLOAD_DLCI1_NOT_RESERVED_START 32
#define SPRT_PAYLOAD_DLCI1_NOT_RESERVED_END 62
#define SPRT_PAYLOAD_DLCI1_CTRLFN2CTRLFN 63
#define SPRT_PAYLOAD_DLCI2_START 0
#define SPRT_PAYLOAD_DLCI2_END 127
/* Payload fields for I_CHAR_STAT_CS, etc.: */
/* # of data bits */
#define SPRT_PAYLOAD_D_0 0
#define SPRT_PAYLOAD_D_1 1
#define SPRT_PAYLOAD_D_2 2
#define SPRT_PAYLOAD_D_3 3
/* parity */
#define SPRT_PAYLOAD_P_0 0
#define SPRT_PAYLOAD_P_1 1
#define SPRT_PAYLOAD_P_2 2
#define SPRT_PAYLOAD_P_3 3
#define SPRT_PAYLOAD_P_4 4
#define SPRT_PAYLOAD_P_5 5
#define SPRT_PAYLOAD_P_6 6
#define SPRT_PAYLOAD_P_7 7
/* # of stop bits */
#define SPRT_PAYLOAD_S_0 0
#define SPRT_PAYLOAD_S_1 1
#define SPRT_PAYLOAD_S_2 2
#define SPRT_PAYLOAD_S_3 3
/* data frame state */
#define SPRT_PAYLOAD_FR_0 0
#define SPRT_PAYLOAD_FR_1 1
#define SPRT_PAYLOAD_FR_2 2
#define SPRT_PAYLOAD_FR_3 3
/* Initialize the protocol & registered fields */
static int proto_sprt = -1;
static int hf_sprt_setup = -1;
static int hf_sprt_setup_frame = -1;
static int hf_sprt_setup_method = -1;
static int hf_sprt_header_extension_bit = -1;
static int hf_sprt_subsession_id = -1;
static int hf_sprt_reserved_bit = -1;
static int hf_sprt_payload_type = -1;
static int hf_sprt_transport_channel_id = -1;
static int hf_sprt_sequence_number = -1;
static int hf_sprt_number_of_ack_fields = -1;
static int hf_sprt_base_sequence_number = -1;
static int hf_sprt_ack_field_items = -1;
static int hf_sprt_transport_channel_item = -1;
static int hf_sprt_sequence_item = -1;
static int hf_sprt_payload_length = -1;
static int hf_sprt_payload_no_data = -1;
static int hf_sprt_payload_reserved_bit = -1;
static int hf_sprt_payload_message_id = -1;
static int hf_sprt_payload_data = -1; /* stuff after msgid */
/* INIT msg: */
static int hf_sprt_payload_msg_init_all_fields = -1;
static int hf_sprt_payload_msg_init_necrxch = -1;
static int hf_sprt_payload_msg_init_ecrxch = -1;
static int hf_sprt_payload_msg_init_xid_prof_exch = -1;
static int hf_sprt_payload_msg_init_assym_data_types = -1;
static int hf_sprt_payload_msg_init_opt_moip_types_i_raw_bit = -1;
static int hf_sprt_payload_msg_init_opt_moip_types_i_frame = -1;
static int hf_sprt_payload_msg_init_opt_moip_types_i_char_stat = -1;
static int hf_sprt_payload_msg_init_opt_moip_types_i_char_dyn = -1;
static int hf_sprt_payload_msg_init_opt_moip_types_i_octet_cs = -1;
static int hf_sprt_payload_msg_init_opt_moip_types_i_char_stat_cs = -1;
static int hf_sprt_payload_msg_init_opt_moip_types_i_char_dyn_cs = -1;
static int hf_sprt_payload_msg_init_opt_moip_types_reserved = -1;
/* XID_XCHG message: */
static int hf_sprt_payload_msg_xidxchg_ecp = -1;
static int hf_sprt_payload_msg_xidxchg_xidlr1_v42bis = -1;
static int hf_sprt_payload_msg_xidxchg_xidlr1_v44 = -1;
static int hf_sprt_payload_msg_xidxchg_xidlr1_mnp5 = -1;
static int hf_sprt_payload_msg_xidxchg_xidlr1_reserved = -1;
static int hf_sprt_payload_msg_xidxchg_xidlr2_v42bis_compr_req = -1;
static int hf_sprt_payload_msg_xidxchg_xidlr3and4_v42bis_num_codewords = -1;
static int hf_sprt_payload_msg_xidxchg_xidlr5_v42bis_max_strlen = -1;
static int hf_sprt_payload_msg_xidxchg_xidlr6_v44_capability = -1;
static int hf_sprt_payload_msg_xidxchg_xidlr7_v44_compr_req = -1;
static int hf_sprt_payload_msg_xidxchg_xidlr8and9_v44_num_codewords_trans = -1;
static int hf_sprt_payload_msg_xidxchg_xidlr10and11_v44_num_codewords_recv = -1;
static int hf_sprt_payload_msg_xidxchg_xidlr12_v44_max_strlen_trans = -1;
static int hf_sprt_payload_msg_xidxchg_xidlr13_v44_max_strlen_recv = -1;
static int hf_sprt_payload_msg_xidxchg_xidlr14and15_v44_history_len_trans = -1;
static int hf_sprt_payload_msg_xidxchg_xidlr16and17_v44_history_len_recv = -1;
/* V.8 JM_INFO msg: */
static int hf_sprt_payload_msg_jminfo_category_data = -1;
static int hf_sprt_payload_msg_jminfo_category_id = -1;
static int hf_sprt_payload_msg_jminfo_category_ext_info = -1;
static int hf_sprt_payload_msg_jminfo_unk_category_info = -1;
static int hf_sprt_payload_msg_jminfo_category_leftover_bits = -1;
static int hf_sprt_payload_msg_jminfo_call_function = -1;
static int hf_sprt_payload_msg_jminfo_mod_v34_duplex = -1;
static int hf_sprt_payload_msg_jminfo_mod_v34_half_duplex = -1;
static int hf_sprt_payload_msg_jminfo_mod_v32bis_v32 = -1;
static int hf_sprt_payload_msg_jminfo_mod_v22bis_v22 = -1;
static int hf_sprt_payload_msg_jminfo_mod_v17 = -1;
static int hf_sprt_payload_msg_jminfo_mod_v29_half_duplex = -1;
static int hf_sprt_payload_msg_jminfo_mod_v27ter = -1;
static int hf_sprt_payload_msg_jminfo_mod_v26ter = -1;
static int hf_sprt_payload_msg_jminfo_mod_v26bis = -1;
static int hf_sprt_payload_msg_jminfo_mod_v23_duplex = -1;
static int hf_sprt_payload_msg_jminfo_mod_v23_half_duplex = -1;
static int hf_sprt_payload_msg_jminfo_mod_v21 = -1;
static int hf_sprt_payload_msg_jminfo_protocols = -1;
static int hf_sprt_payload_msg_jminfo_pstn_access_call_dce_cell = -1;
static int hf_sprt_payload_msg_jminfo_pstn_access_answ_dce_cell = -1;
static int hf_sprt_payload_msg_jminfo_pstn_access_dce_on_digital_net = -1;
static int hf_sprt_payload_msg_jminfo_pcm_modem_avail_v90_v92_analog = -1;
static int hf_sprt_payload_msg_jminfo_pcm_modem_avail_v90_v92_digital = -1;
static int hf_sprt_payload_msg_jminfo_pcm_modem_avail_v91 = -1;
/* CONNECT msg: */
static int hf_sprt_payload_msg_connect_selmod = -1;
static int hf_sprt_payload_msg_connect_compr_dir = -1;
static int hf_sprt_payload_msg_connect_selected_compr = -1;
static int hf_sprt_payload_msg_connect_selected_err_corr = -1;
static int hf_sprt_payload_msg_connect_tdsr = -1;
static int hf_sprt_payload_msg_connect_rdsr = -1;
static int hf_sprt_payload_msg_connect_dlci_enabled = -1;
static int hf_sprt_payload_msg_connect_avail_data_types = -1;
static int hf_sprt_payload_msg_connect_adt_octet_no_format_no_dlci = -1;
static int hf_sprt_payload_msg_connect_adt_i_raw_bit = -1;
static int hf_sprt_payload_msg_connect_adt_i_frame = -1;
static int hf_sprt_payload_msg_connect_adt_i_char_stat = -1;
static int hf_sprt_payload_msg_connect_adt_i_char_dyn = -1;
static int hf_sprt_payload_msg_connect_adt_i_octet_cs = -1;
static int hf_sprt_payload_msg_connect_adt_i_char_stat_cs = -1;
static int hf_sprt_payload_msg_connect_adt_i_char_dyn_cs = -1;
static int hf_sprt_payload_msg_connect_adt_reserved = -1;
static int hf_sprt_payload_msg_connect_compr_trans_dict_sz = -1;
static int hf_sprt_payload_msg_connect_compr_recv_dict_sz = -1;
static int hf_sprt_payload_msg_connect_compr_trans_str_len = -1;
static int hf_sprt_payload_msg_connect_compr_recv_str_len = -1;
static int hf_sprt_payload_msg_connect_compr_trans_hist_sz = -1;
static int hf_sprt_payload_msg_connect_compr_recv_hist_sz = -1;
/* BREAK msg: */
static int hf_sprt_payload_msg_break_source_proto = -1;
static int hf_sprt_payload_msg_break_type = -1;
static int hf_sprt_payload_msg_break_length = -1;
/* MR_EVENT msg: */
static int hf_sprt_payload_msg_mr_event_id = -1;
static int hf_sprt_payload_msg_mr_evt_reason_code = -1;
static int hf_sprt_payload_msg_mr_evt_selmod = -1;
static int hf_sprt_payload_msg_mr_evt_txsen = -1;
static int hf_sprt_payload_msg_mr_evt_rxsen = -1;
static int hf_sprt_payload_msg_mr_evt_tdsr = -1;
static int hf_sprt_payload_msg_mr_evt_rdsr = -1;
static int hf_sprt_payload_msg_mr_evt_txsr = -1;
static int hf_sprt_payload_msg_mr_evt_rxsr = -1;
/* CLEARDOWN msg: */
static int hf_sprt_payload_msg_cleardown_reason_code = -1;
static int hf_sprt_payload_msg_cleardown_vendor_tag = -1;
static int hf_sprt_payload_msg_cleardown_vendor_info = -1;
/* PROF_XCHG msg: */
static int hf_sprt_payload_msg_profxchg_v42_lapm = -1;
static int hf_sprt_payload_msg_profxchg_annex_av42 = -1;
static int hf_sprt_payload_msg_profxchg_v44_compr = -1;
static int hf_sprt_payload_msg_profxchg_v42bis_compr = -1;
static int hf_sprt_payload_msg_profxchg_mnp5_compr = -1;
static int hf_sprt_payload_msg_profxchg_reserved = -1;
static int hf_sprt_payload_msg_profxchg_xidlr2_v42bis_compr_req = -1;
static int hf_sprt_payload_msg_profxchg_xidlr3and4_v42bis_num_codewords = -1;
static int hf_sprt_payload_msg_profxchg_xidlr5_v42bis_max_strlen = -1;
static int hf_sprt_payload_msg_profxchg_xidlr6_v44_capability = -1;
static int hf_sprt_payload_msg_profxchg_xidlr7_v44_compr_req = -1;
static int hf_sprt_payload_msg_profxchg_xidlr8and9_v44_num_codewords_trans = -1;
static int hf_sprt_payload_msg_profxchg_xidlr10and11_v44_num_codewords_recv = -1;
static int hf_sprt_payload_msg_profxchg_xidlr12_v44_max_strlen_trans = -1;
static int hf_sprt_payload_msg_profxchg_xidlr13_v44_max_strlen_recv = -1;
static int hf_sprt_payload_msg_profxchg_xidlr14and15_v44_history_len_trans = -1;
static int hf_sprt_payload_msg_profxchg_xidlr16and17_v44_history_len_recv = -1;
/* I_OCTET */
static int hf_sprt_payload_i_octet_no_dlci = -1;
static int hf_sprt_payload_i_octet_dlci_presence_unknown = -1;
static int hf_sprt_payload_i_octet_dlci1 = -1;
static int hf_sprt_payload_i_octet_cr = -1;
static int hf_sprt_payload_i_octet_ea = -1;
static int hf_sprt_payload_i_octet_dlci2 = -1;
static int hf_sprt_payload_i_octet_dlci_setup_by_connect_frame = -1;
/* I_OCTET_CS, I_CHAR_STAT_CS, I_CHAR_DYN_CS msgs: */
static int hf_sprt_payload_data_cs = -1;
static int hf_sprt_payload_data_reserved_bit = -1;
static int hf_sprt_payload_data_num_data_bits = -1;
static int hf_sprt_payload_data_parity_type = -1;
static int hf_sprt_payload_num_stop_bits = -1;
static int hf_sprt_payload_frame_reserved_bits = -1;
static int hf_sprt_payload_frame_state = -1;
static int hf_sprt_payload_rawoctet_n_field_present = -1;
static int hf_sprt_payload_rawoctet_l = -1;
static int hf_sprt_payload_rawoctet_n = -1;
static int hf_sprt_payload_rawbit_included_fields_l = -1;
static int hf_sprt_payload_rawbit_included_fields_lp = -1;
static int hf_sprt_payload_rawbit_included_fields_lpn = -1;
static int hf_sprt_payload_rawbit_len_a = -1;
static int hf_sprt_payload_rawbit_len_b = -1;
static int hf_sprt_payload_rawbit_len_c = -1;
static int hf_sprt_payload_rawbit_p = -1;
static int hf_sprt_payload_rawbit_n = -1;
/* Preferences */
static gboolean global_sprt_show_setup_info = TRUE; /* show how this SPRT stream got started */
static gboolean global_sprt_show_dlci_info = TRUE; /* show DLCI in I_OCTET messages, including setup frame (if we can) */
/* dissector handle */
static dissector_handle_t sprt_handle;
/* initialize the subtree pointers */
static gint ett_sprt = -1;
static gint ett_sprt_setup = -1;
static gint ett_sprt_ack_fields = -1;
static gint ett_payload = -1;
static gint ett_init_msg_all_fields = -1;
static gint ett_jminfo_msg_cat_data = -1;
static gint ett_connect_msg_adt = -1;
static expert_field ei_sprt_sequence_number_0 = EI_INIT;
/* value strings & range strings */
static const value_string sprt_transport_channel_characteristics[] = {
{ 0, "Unreliable, unsequenced" },
{ 1, "Reliable, sequenced" },
{ 2, "Expedited, reliable, sequenced" },
{ 3, "Unreliable, sequenced" },
{ 0, NULL}
};
static const range_string sprt_modem_relay_msg_id_name[] = {
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_NULL), "NULL reserved for ITU-T" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_INIT), "INIT" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_XID_XCHG), "XID_XCHG" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_JM_INFO), "JM_INFO" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_START_JM), "START_JM" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_CONNECT), "CONNECT" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_BREAK), "BREAK" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_BREAK_ACK), "BREAK_ACK" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_MR_EVENT), "MR_EVENT" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_CLEARDOWN), "CLEARDOWN" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_PROF_XCHG), "PROF_XCHG" },
{ SPRT_MODEM_RELAY_MSG_ID_RESERVED1_START, SPRT_MODEM_RELAY_MSG_ID_RESERVED1_END, "Reserved for ITU-T" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_RAW_OCTET), "I_RAW-OCTET" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_RAW_BIT), "I_RAW-BIT" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_OCTET), "I_OCTET" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_CHAR_STAT), "I_CHAR-STAT" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_CHAR_DYN), "I_CHAR-DYN" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_FRAME), "I_FRAME" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_OCTET_CS), "I_OCTET-CS" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_CHAR_STAT_CS), "I_CHAR-STAT-CS" },
{ SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_CHAR_DYN_CS), "I_CHAR-DYN-CS" },
{ SPRT_MODEM_RELAY_MSG_ID_RESERVED2_START, SPRT_MODEM_RELAY_MSG_ID_RESERVED2_END, "Reserved for ITU-T" },
{ SPRT_MODEM_RELAY_MSG_ID_VENDOR_START, SPRT_MODEM_RELAY_MSG_ID_VENDOR_END, "Vendor-specific message" },
{ 0, 0, NULL }
};
static const range_string sprt_ecp_name[] = {
{ SPRT_VALUE_RANGE(SPRT_ECP_NO_LINK_LAYER_PROTO), "No link layer protocol" },
{ SPRT_VALUE_RANGE(SPRT_ECP_V42_LAPM), "V.42/LAPM" },
{ SPRT_VALUE_RANGE(SPRT_ECP_ANNEX_AV42_1996), "Annex A/V.42(1996)" },
{ SPRT_ECP_RESERVED_START, SPRT_ECP_RESERVED_END, "Reserved for ITU-T" },
{ 0, 0, NULL }
};
static const value_string sprt_jm_info_cat_id_name[] = {
{ SPRT_JM_INFO_CAT_ID_CALL_FUNCT, "Call function" },
{ SPRT_JM_INFO_CAT_ID_MOD_MODES, "Modulation modes" },
{ SPRT_JM_INFO_CAT_ID_PROTOCOLS, "Protocols" },
{ SPRT_JM_INFO_CAT_ID_PSTN_ACCESS, "PSTN access" },
{ SPRT_JM_INFO_CAT_ID_PCM_MODEM_AVAIL, "PCM modem availability" },
{ SPRT_JM_INFO_CAT_ID_CATEGORY_EXTENSION, "Extension of current category" },
{ 0, NULL }
};
static const value_string sprt_jminfo_tbc_call_funct_name[] = {
{ SPRT_JMINFO_TBC_CALL_FUNCT_PSTN_MULTIMEDIA_TERM, "PSTN Multimedia terminal (ITU-T Rec. H.324)" },
{ SPRT_JMINFO_TBC_CALL_FUNCT_TEXTPHONE_ITU_T_REC_V18, "Textphone (ITU-T Rec. V.18)" },
{ SPRT_JMINFO_TBC_CALL_FUNCT_VIDEOTEXT_ITU_T_REC_T101, "Videotext (ITU-T Rec. T.101)" },
{ SPRT_JMINFO_TBC_CALL_FUNCT_TRANS_FAX_ITU_T_REC_T30, "Transmit facsimile from call terminal (ITU-T Rec. T.30)" },
{ SPRT_JMINFO_TBC_CALL_FUNCT_RECV_FAX_ITU_T_REC_T30, "Receive facsimile at call terminal (ITU-T Rec. T.30)" },
{ SPRT_JMINFO_TBC_CALL_FUNCT_DATA_V_SERIES_MODEM_REC, "Data (V-series modem Recommendations)" },
{ 0, NULL }
};
static const range_string sprt_jminfo_tbc_protocol_name[] = {
{ SPRT_VALUE_RANGE(SPRT_JMINFO_TBC_PROTOCOL_LAPM_ITU_T_REC_V42), "LAPM protocol according to ITU-T Rec. V.42" },
{ 0, 0, NULL }
};
static const range_string sprt_selmod_name[] = {
{ SPRT_VALUE_RANGE(SPRT_SELMOD_NULL), "NULL" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_V92), "V.92" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_V91), "V.91" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_V90), "V.90" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_V34), "V.34" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_V32_BIS), "V.32bis" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_V32), "V.32" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_V22_BIS), "V.22bis" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_V22), "V.22" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_V17), "V.17" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_V29), "V.29" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_V27_TER), "V.27ter" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_V26_TER), "V.26ter" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_V26_BIS), "V.26bis" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_V23), "V.23" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_V21), "V.21" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_BELL_212), "Bell 212" },
{ SPRT_VALUE_RANGE(SPRT_SELMOD_BELL_103), "Bell 103" },
{ SPRT_SELMOD_VENDOR_START, SPRT_SELMOD_VENDOR_END, "Vendor-specific modulation" },
{ SPRT_SELMOD_RESERVED_START, SPRT_SELMOD_RESERVED_END, "Reserved for ITU-T" },
{ 0, 0, NULL }
};
static const value_string sprt_comp_direction[] = {
{ SPRT_COMPR_DIR_NO_COMPRESSION, "None" },
{ SPRT_COMPR_DIR_TRANSMIT, "Transmit" },
{ SPRT_COMPR_DIR_RECEIVE, "Receive" },
{ SPRT_COMPR_DIR_BIDIRECTIONAL, "Bidirectional" },
{ 0, NULL }
};
static const range_string sprt_selected_compr_name[] = {
{ SPRT_VALUE_RANGE(SPRT_SELECTED_COMPR_NONE), "None" },
{ SPRT_VALUE_RANGE(SPRT_SELECTED_COMPR_V42_BIS), "V.42bis" },
{ SPRT_VALUE_RANGE(SPRT_SELECTED_COMPR_V44), "V.44" },
{ SPRT_VALUE_RANGE(SPRT_SELECTED_COMPR_MNP5), "MNP5" },
{ SPRT_SELECTED_COMPR_RESERVED_START, SPRT_SELECTED_COMPR_RESERVED_END, "Reserved by ITU-T" },
{ 0, 0, NULL }
};
static const range_string sprt_selected_err_corr_name[] = {
{ SPRT_VALUE_RANGE(SPRT_SELECTED_ERR_CORR_V14_OR_NONE), "V.14 or no error correction protocol" },
{ SPRT_VALUE_RANGE(SPRT_SELECTED_ERR_CORR_V42_LAPM), "V.42/LAPM" },
{ SPRT_VALUE_RANGE(SPRT_SELECTED_ERR_CORR_ANNEX_AV42), "Annex A/V.42" },
{ SPRT_SELECTED_ERR_CORR_RESERVED_START, SPRT_SELECTED_ERR_CORR_RESERVED_END, "Reserved for ITU-T" },
{ 0, 0, NULL }
};
static const range_string sprt_break_src_proto_name[] = {
{ SPRT_VALUE_RANGE(SPRT_BREAK_SRC_PROTO_V42_LAPM), "V.42/LAPM" },
{ SPRT_VALUE_RANGE(SPRT_BREAK_SRC_PROTO_ANNEX_AV42_1996), "Annex A/V.42(1996)" },
{ SPRT_VALUE_RANGE(SPRT_BREAK_SRC_PROTO_V14), "V.14" },
{ SPRT_BREAK_SRC_PROTO_RESERVED_START, SPRT_BREAK_SRC_PROTO_RESERVED_END, "Reserved for ITU-T" },
{ 0, 0, NULL }
};
static const range_string sprt_break_type_name[] = {
{ SPRT_VALUE_RANGE(SPRT_BREAK_TYPE_NOT_APPLICABLE), "Not applicable" },
{ SPRT_VALUE_RANGE(SPRT_BREAK_TYPE_DESTRUCTIVE_AND_EXPEDITED), "Destructive and expedited" },
{ SPRT_VALUE_RANGE(SPRT_BREAK_TYPE_NONDESTRUCTIVE_AND_EXPEDITED), "Non-destructive and expedited" },
{ SPRT_VALUE_RANGE(SPRT_BREAK_TYPE_NONDESTRUCTIVE_AND_NONEXPEDITED), "Non-destructive and non-expedited" },
{ SPRT_BREAK_TYPE_RESERVED_START, SPRT_BREAK_TYPE_RESERVED_END, "Reserved for ITU-T" },
{ 0, 0, NULL }
};
static const range_string sprt_mrevent_id_name[] = {
{ SPRT_VALUE_RANGE(SPRT_MREVT_EVENT_ID_NULL), "NULL" },
{ SPRT_VALUE_RANGE(SPRT_MREVT_EVENT_ID_RATE_RENEGOTIATION), "Rate renegotiation" },
{ SPRT_VALUE_RANGE(SPRT_MREVT_EVENT_ID_RETRAIN), "Retrain" },
{ SPRT_VALUE_RANGE(SPRT_MREVT_EVENT_ID_PHYSUP), "Physical layer ready" }, /* reason code should be 0 */
{ SPRT_MREVT_EVENT_ID_RESERVED_START, SPRT_MREVT_EVENT_ID_RESERVED_END, "Reserved for ITU-T" },
{ 0, 0, NULL }
};
static const range_string sprt_mrevent_reason_code_name[] = {
{ SPRT_VALUE_RANGE(SPRT_MREVT_REASON_CODE_NULL), "Null/not applicable" }, /* for eventid = PHYSUP */
{ SPRT_VALUE_RANGE(SPRT_MREVT_REASON_CODE_INIT), "Initiation" },
{ SPRT_VALUE_RANGE(SPRT_MREVT_REASON_CODE_RESPONDING), "Responding" },
{ SPRT_MREVT_REASON_CODE_RESERVED_START, SPRT_MREVT_REASON_CODE_RESERVED_END, "Reserved for ITU-T" },
{ 0, 0, NULL }
};
static const range_string sprt_mrevent_phys_layer_symbol_rate[] = {
{ SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_NULL), "Null/not applicable" },
{ SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_600), "600" },
{ SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_1200), "1200" },
{ SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_1600), "1600" },
{ SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_2400), "2400" },
{ SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_2743), "2743" },
{ SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_3000), "3000" },
{ SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_3200), "3200" },
{ SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_3429), "3249" },
{ SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_8000), "8000" },
{ SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_RESERVED_START, SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_RESERVED_END, "Reserved for ITU-T" },
{ SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_UNSPECIFIED), "Unspecified" },
{ 0, 0, NULL }
};
static const value_string sprt_cleardown_reason[] = {
{ SPRT_CLEARDOWN_RIC_UNKNOWN, "Unknown/unspecified" },
{ SPRT_CLEARDOWN_RIC_PHYSICAL_LAYER_RELEASE, "Physical layer release" },
{ SPRT_CLEARDOWN_RIC_LINK_LAYER_DISCONNECT, "Link layer disconnect" },
{ SPRT_CLEARDOWN_RIC_DATA_COMPRESSION_DISCONNECT, "Data compression disconnect" },
{ SPRT_CLEARDOWN_RIC_ABORT, "Abort" },
{ SPRT_CLEARDOWN_RIC_ON_HOOK, "On hook" },
{ SPRT_CLEARDOWN_RIC_NETWORK_LAYER_TERMINATION, "Network layer termination" },
{ SPRT_CLEARDOWN_RIC_ADMINISTRATIVE, "Administrative" },
{ 0, NULL }
};
static const value_string sprt_prof_xchg_support[] = {
{ SPRT_PROF_XCHG_SUPPORT_NO, "No" },
{ SPRT_PROF_XCHG_SUPPORT_YES, "Yes" },
{ SPRT_PROF_XCHG_SUPPORT_UNKNOWN, "Unknown" },
{ 0, NULL }
};
static const range_string sprt_payload_dlci1[] = {
{ SPRT_VALUE_RANGE(SPRT_PAYLOAD_DLCI1_DTE2DTE), "DTE-to-DTE (V.24 interfaces) data" },
{ SPRT_PAYLOAD_DLCI1_RESERVED_START, SPRT_PAYLOAD_DLCI1_RESERVED_END, "Reserved for ITU-T" },
{ SPRT_PAYLOAD_DLCI1_NOT_RESERVED_START, SPRT_PAYLOAD_DLCI1_NOT_RESERVED_END, "Not reserved for ITU-T" },
{ SPRT_VALUE_RANGE(SPRT_PAYLOAD_DLCI1_CTRLFN2CTRLFN), "Control-function to control-function information" },
{ 0, 0, NULL }
};
static const true_false_string sprt_payload_ea_bit = {
"Last octet of address field", "Another octet of address field follows"
};
static const range_string sprt_payload_dlci2[] = {
{ SPRT_PAYLOAD_DLCI2_START, SPRT_PAYLOAD_DLCI2_END, "Reserved by ITU-T for further study" },
{ 0, 0, NULL }
};
static const value_string sprt_payload_data_bits[] = {
{ SPRT_PAYLOAD_D_0, "5 bits" },
{ SPRT_PAYLOAD_D_1, "6 bits" },
{ SPRT_PAYLOAD_D_2, "7 bits" },
{ SPRT_PAYLOAD_D_3, "8 bits" },
{ 0, NULL }
};
static const value_string sprt_payload_parity[] = {
{ SPRT_PAYLOAD_P_0, "Unknown" },
{ SPRT_PAYLOAD_P_1, "None" },
{ SPRT_PAYLOAD_P_2, "Even parity" },
{ SPRT_PAYLOAD_P_3, "Odd parity" },
{ SPRT_PAYLOAD_P_4, "Space parity" },
{ SPRT_PAYLOAD_P_5, "Mark parity" },
{ SPRT_PAYLOAD_P_6, "Reserved" },
{ SPRT_PAYLOAD_P_7, "Reserved" },
{ 0, NULL }
};
static const value_string sprt_payload_stop_bits[] = {
{ SPRT_PAYLOAD_S_0, "1 stop bit" },
{ SPRT_PAYLOAD_S_1, "2 stop bits" },
{ SPRT_PAYLOAD_S_2, "Reserved" },
{ SPRT_PAYLOAD_S_3, "Reserved" },
{ 0, NULL }
};
static const value_string sprt_payload_frame_state[] = {
{ SPRT_PAYLOAD_FR_0, "Data frame without termination" },
{ SPRT_PAYLOAD_FR_1, "Data frame with termination" },
{ SPRT_PAYLOAD_FR_2, "Data frame with abort termination" },
{ SPRT_PAYLOAD_FR_3, "Undefined" },
{ 0, NULL }
};
/* look for a conversation & return the associated data */
static struct _sprt_conversation_info* find_sprt_conversation_data(packet_info *pinfo)
{
conversation_t *p_conv = NULL;
struct _sprt_conversation_info *p_conv_data = NULL;
/* Use existing packet info if available */
p_conv = find_conversation_pinfo(pinfo, NO_ADDR_B|NO_PORT_B);
if (p_conv)
{
p_conv_data = (struct _sprt_conversation_info*)conversation_get_proto_data(p_conv, proto_sprt);
}
return p_conv_data;
}
/* set up SPRT conversation */
void sprt_add_address(packet_info *pinfo,
address *addr, int port,
int other_port,
const gchar *setup_method,
guint32 setup_frame_number)
{
address null_addr;
conversation_t* p_conv;
struct _sprt_conversation_info *p_conv_data = NULL;
/*
* If this isn't the first time this packet has been processed,
* we've already done this work, so we don't need to do it
* again.
*/
if (pinfo->fd->visited)
{
return;
}
clear_address(&null_addr);
/*
* Check if the ip address and port combination is not
* already registered as a conversation.
*/
p_conv = find_conversation(setup_frame_number, addr, &null_addr, CONVERSATION_UDP, port, other_port,
NO_ADDR_B | (!other_port ? NO_PORT_B : 0));
/*
* If not, create a new conversation.
*/
if (!p_conv || p_conv->setup_frame != setup_frame_number) {
p_conv = conversation_new(setup_frame_number, addr, &null_addr, CONVERSATION_UDP,
(guint32)port, (guint32)other_port,
NO_ADDR2 | (!other_port ? NO_PORT2 : 0));
}
/* Set dissector */
conversation_set_dissector(p_conv, sprt_handle);
/*
* Check if the conversation has data associated with it.
*/
p_conv_data = (struct _sprt_conversation_info *)conversation_get_proto_data(p_conv, proto_sprt);
/*
* If not, add a new data item.
*/
if (!p_conv_data) {
/* Create conversation data */
p_conv_data = wmem_new(wmem_file_scope(), struct _sprt_conversation_info);
p_conv_data->stream_started = FALSE;
p_conv_data->seqnum[0] = 0;
p_conv_data->seqnum[1] = 0;
p_conv_data->seqnum[2] = 0;
p_conv_data->seqnum[3] = 0;
p_conv_data->i_octet_dlci_status = DLCI_UNKNOWN;
p_conv_data->connect_frame_number = 0;
conversation_add_proto_data(p_conv, proto_sprt, p_conv_data);
}
/* Update the conversation data. */
(void) g_strlcpy(p_conv_data->method, setup_method, SPRT_CONV_MAX_SETUP_METHOD_SIZE);
p_conv_data->frame_number = setup_frame_number;
}
/* Display setup info */
static void show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
struct _sprt_conversation_info *p_conv_data;
proto_tree *sprt_setup_tree;
proto_item *ti;
/* look up the conversation & get the data */
p_conv_data = find_sprt_conversation_data(pinfo);
if (!p_conv_data)
{
proto_tree_add_string_format(tree, hf_sprt_setup, tvb, 0, 0, "", "No setup info found");
return;
}
/* Create setup info subtree with summary info. */
ti = proto_tree_add_string_format(tree, hf_sprt_setup, tvb, 0, 0,
"",
"Stream setup by %s (frame %u)",
p_conv_data->method,
p_conv_data->frame_number);
proto_item_set_generated(ti);
sprt_setup_tree = proto_item_add_subtree(ti, ett_sprt_setup);
if (sprt_setup_tree)
{
/* Add details into subtree */
proto_item* item = proto_tree_add_uint(sprt_setup_tree, hf_sprt_setup_frame,
tvb, 0, 0, p_conv_data->frame_number);
proto_item_set_generated(item);
item = proto_tree_add_string(sprt_setup_tree, hf_sprt_setup_method,
tvb, 0, 0, p_conv_data->method);
proto_item_set_generated(item);
}
}
/* code to actually dissect the packet payload data */
static int
dissect_sprt_data(tvbuff_t *tvb,
packet_info *pinfo,
struct _sprt_conversation_info *p_conv_data,
proto_tree *sprt_tree,
unsigned int offset,
guint payload_length)
{
proto_item *ti;
proto_tree *sprt_payload_tree, *field_subtree;
guint8 octet, payload_msgid, category_id;
guint8 selcompr, mr_event_id;
guint16 word, category_count;
if (payload_length > 0)
{
ti = proto_tree_add_uint(sprt_tree, hf_sprt_payload_length, tvb, offset, 1, payload_length);
proto_item_set_len(ti, payload_length);
sprt_payload_tree = proto_item_add_subtree(ti, ett_payload);
payload_msgid = tvb_get_guint8(tvb, offset) & 0x7F;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_reserved_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_message_id, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
payload_length--;
/* what kind of message is this? */
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s(%d)",
rval_to_str_const(payload_msgid, sprt_modem_relay_msg_id_name, "Unknown"),
payload_msgid);
/* now parse payload stuff after ext. bit & msgid */
switch(payload_msgid)
{
case SPRT_MODEM_RELAY_MSG_ID_INIT:
/* make subtree */
ti = proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_init_all_fields, tvb, offset, 2, ENC_BIG_ENDIAN);
field_subtree = proto_item_add_subtree(ti, ett_init_msg_all_fields);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_necrxch, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_ecrxch, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_xid_prof_exch, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_assym_data_types, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_opt_moip_types_i_raw_bit, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_opt_moip_types_i_frame, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_opt_moip_types_i_char_stat, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_opt_moip_types_i_char_dyn, tvb, offset, 2, ENC_BIG_ENDIAN);
/* from V.150.1 amendment 2 (5-2006): */
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_opt_moip_types_i_octet_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_opt_moip_types_i_char_stat_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_opt_moip_types_i_char_dyn_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_opt_moip_types_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
break;
case SPRT_MODEM_RELAY_MSG_ID_XID_XCHG:
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_ecp, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr1_v42bis, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr1_v44, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr1_mnp5, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr1_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr2_v42bis_compr_req, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr3and4_v42bis_num_codewords, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr5_v42bis_max_strlen, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr6_v44_capability, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr7_v44_compr_req, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr8and9_v44_num_codewords_trans, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr10and11_v44_num_codewords_recv, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr12_v44_max_strlen_trans, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr13_v44_max_strlen_recv, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr14and15_v44_history_len_trans, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr16and17_v44_history_len_recv, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
break;
case SPRT_MODEM_RELAY_MSG_ID_JM_INFO:
category_count = 1;
do /* there may be multiple categories */
{
word = tvb_get_ntohs(tvb, offset);
category_id = (word >> 12);
ti = proto_tree_add_uint_format_value(sprt_payload_tree, hf_sprt_payload_msg_jminfo_category_data, tvb, offset, 2, word,
"Item #%d: %s (0x%04x)", category_count, val_to_str_const(category_id, sprt_jm_info_cat_id_name, "Unknown"), category_id);
category_count++;
field_subtree = proto_item_add_subtree(ti, ett_jminfo_msg_cat_data);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_category_id, tvb, offset, 2, ENC_BIG_ENDIAN);
switch(category_id)
{
case SPRT_JM_INFO_CAT_ID_CALL_FUNCT: /* 0x8 */
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_call_function, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_category_leftover_bits, tvb, offset, 2, ENC_BIG_ENDIAN);
break;
case SPRT_JM_INFO_CAT_ID_MOD_MODES: /* 0xA */
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v34_duplex, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v34_half_duplex, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v32bis_v32, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v22bis_v22, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v17, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v29_half_duplex, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v27ter, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v26ter, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v26bis, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v23_duplex, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v23_half_duplex, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v21, tvb, offset, 2, ENC_BIG_ENDIAN);
break;
case SPRT_JM_INFO_CAT_ID_PROTOCOLS: /* 0x5 */
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_protocols, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_category_leftover_bits, tvb, offset, 2, ENC_BIG_ENDIAN);
break;
case SPRT_JM_INFO_CAT_ID_PSTN_ACCESS: /* 0xB */
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_pstn_access_call_dce_cell, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_pstn_access_answ_dce_cell, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_pstn_access_dce_on_digital_net, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_category_leftover_bits, tvb, offset, 2, ENC_BIG_ENDIAN);
break;
case SPRT_JM_INFO_CAT_ID_PCM_MODEM_AVAIL: /* 0xE */
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_pcm_modem_avail_v90_v92_analog, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_pcm_modem_avail_v90_v92_digital, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_pcm_modem_avail_v91, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_category_leftover_bits, tvb, offset, 2, ENC_BIG_ENDIAN);
break;
case SPRT_JM_INFO_CAT_ID_CATEGORY_EXTENSION: /* 0x0 */
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_category_ext_info, tvb, offset, 2, ENC_BIG_ENDIAN);
break;
default: /* unknown category ID */
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_unk_category_info, tvb, offset, 2, ENC_BIG_ENDIAN);
break;
}
offset += 2;
} while (tvb_reported_length_remaining(tvb, offset) >= 2);
break;
case SPRT_MODEM_RELAY_MSG_ID_START_JM:
/* No additional content */
break;
case SPRT_MODEM_RELAY_MSG_ID_CONNECT: /***/
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_selmod, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_compr_dir, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
selcompr = (tvb_get_guint8(tvb, offset) & 0xF0) >> 4;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_selected_compr, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_selected_err_corr, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_tdsr, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_rdsr, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
word = tvb_get_ntohs(tvb, offset);
/* is DLCI enabled (used w/I_OCTET messages)? */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_dlci_enabled, tvb, offset, 2, ENC_BIG_ENDIAN);
/* have we previously seen a CONNECT msg in this conversation (i.e., do we know if DLCI is used w/I_OCTET?) */
if (p_conv_data->connect_frame_number == 0)
{
p_conv_data->connect_frame_number = pinfo->num;
if (word & 0x8000)
{
p_conv_data->i_octet_dlci_status = DLCI_PRESENT;
} else {
p_conv_data->i_octet_dlci_status = DLCI_ABSENT;
}
}
/* do subtree for available data types */
ti = proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_avail_data_types, tvb, offset, 2, ENC_BIG_ENDIAN);
field_subtree = proto_item_add_subtree(ti, ett_connect_msg_adt);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_octet_no_format_no_dlci, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_i_raw_bit, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_i_frame, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_i_char_stat, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_i_char_dyn, tvb, offset, 2, ENC_BIG_ENDIAN);
/* from V.150.1 amendment 2 (5-2006): */
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_i_octet_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_i_char_stat_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_i_char_dyn_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
if (selcompr != SPRT_SELECTED_COMPR_NONE &&
selcompr != SPRT_SELECTED_COMPR_MNP5)
{
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_compr_trans_dict_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_compr_recv_dict_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_compr_trans_str_len, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_compr_recv_str_len, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
}
if (selcompr != SPRT_SELECTED_COMPR_NONE &&
selcompr != SPRT_SELECTED_COMPR_MNP5 &&
selcompr != SPRT_SELECTED_COMPR_V42_BIS)
{
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_compr_trans_hist_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_compr_recv_hist_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
}
break;
case SPRT_MODEM_RELAY_MSG_ID_BREAK: /* no additional info */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_break_source_proto, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_break_type, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_break_length, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
break;
case SPRT_MODEM_RELAY_MSG_ID_BREAK_ACK:
/* No additional content */
break;
case SPRT_MODEM_RELAY_MSG_ID_MR_EVENT:
mr_event_id = tvb_get_guint8(tvb, offset);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_event_id, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_evt_reason_code, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
if (mr_event_id == SPRT_MREVT_EVENT_ID_PHYSUP)
{
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_evt_selmod, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_evt_txsen, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_evt_rxsen, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_evt_tdsr, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_evt_rdsr, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* The next two fields are "optional"
* they should only appear w/PHYSUP (MR_EVENT id = 3) messages, when TxSR and RxSR are true
*/
if (tvb_reported_length_remaining(tvb, offset) >= 2)
{
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_evt_txsr, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_evt_rxsr, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
}
}
break;
case SPRT_MODEM_RELAY_MSG_ID_CLEARDOWN:
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_cleardown_reason_code, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_cleardown_vendor_tag, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_cleardown_vendor_info, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
break;
case SPRT_MODEM_RELAY_MSG_ID_PROF_XCHG:
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_v42_lapm, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_annex_av42, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_v44_compr, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_v42bis_compr, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_mnp5_compr, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr2_v42bis_compr_req, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr3and4_v42bis_num_codewords, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr5_v42bis_max_strlen, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr6_v44_capability, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr7_v44_compr_req, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr8and9_v44_num_codewords_trans, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr10and11_v44_num_codewords_recv, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr12_v44_max_strlen_trans, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr13_v44_max_strlen_recv, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr14and15_v44_history_len_trans, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr16and17_v44_history_len_recv, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
break;
case SPRT_MODEM_RELAY_MSG_ID_I_RAW_OCTET: /* data */
octet = tvb_get_guint8(tvb, offset);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawoctet_n_field_present, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawoctet_l, tvb, offset, 1, ENC_BIG_ENDIAN);
if (octet & 0x80) /* is N field present? */
{
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawoctet_n, tvb, offset, 1, ENC_BIG_ENDIAN);
}
offset++;
payload_length--;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
break;
case SPRT_MODEM_RELAY_MSG_ID_I_RAW_BIT: /* data */
/*
* L, P, N fields need to be parsed
*/
switch((tvb_get_guint8(tvb, offset) & 0xC0) >> 6)
{
case 0x0: /* 00: get L (6 bits) */
/* display leading "00" bits, followed by L */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_included_fields_l, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_len_a, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
payload_length--;
break;
case 0x1: /* 01: get L (3 bits) & P (3 bits) */
/* display leading "01" bits, followed by L,P */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_included_fields_lp, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_len_b, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_p, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
payload_length--;
break;
default: /* 10, 11: get L (4 bits), P (3 bits), N (8 bits) */
/* display leading "1" bit, followed by L,P,N */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_included_fields_lpn, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_len_c, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_p, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
payload_length--;
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_n, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
payload_length--;
break;
}
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
break;
case SPRT_MODEM_RELAY_MSG_ID_I_OCTET: /* data */
if (global_sprt_show_dlci_info)
{
/* DLCI field may be 0, 1, or 2 bytes, depending on CONNECT message (see "DLCI enabled")...
* or UNKNOWN if we don't see the CONNECT message
*/
switch(p_conv_data->i_octet_dlci_status)
{
case DLCI_PRESENT:
octet = tvb_get_guint8(tvb, offset);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_i_octet_dlci1, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_i_octet_cr, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_i_octet_ea, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
payload_length--;
/* check address extension... if ea bit == 0, then DLCI has another octet (see ITU-T V42 spec for more info) */
if (!(octet & 0x01))
{
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_i_octet_dlci2, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_i_octet_ea, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
payload_length--;
}
ti = proto_tree_add_uint(sprt_payload_tree, hf_sprt_payload_i_octet_dlci_setup_by_connect_frame, tvb, 0, 0, p_conv_data->connect_frame_number);
proto_item_set_generated(ti);
break;
case DLCI_ABSENT:
ti = proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_i_octet_no_dlci, tvb, 0, 0, ENC_NA);
proto_item_set_generated(ti);
ti = proto_tree_add_uint(sprt_payload_tree, hf_sprt_payload_i_octet_dlci_setup_by_connect_frame, tvb, 0, 0, p_conv_data->connect_frame_number);
proto_item_set_generated(ti);
break;
case DLCI_UNKNOWN: /* e.g., we didn't see the CONNECT msg so we don't know if there is a DLCI */
default:
ti = proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_i_octet_dlci_presence_unknown, tvb, 0, 0, ENC_NA);
proto_item_set_generated(ti);
break;
}
}
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
break;
case SPRT_MODEM_RELAY_MSG_ID_I_CHAR_STAT: /* data */
/* r: 1-bit reserved */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_reserved_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
/* D: 2-bit field indicating # of data bits */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_num_data_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
/* P: 3-bit field for parity type */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_parity_type, tvb, offset, 1, ENC_BIG_ENDIAN);
/* S: 2-bit field indicating # of stop bits */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_num_stop_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
payload_length--;
/* octets */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
break;
case SPRT_MODEM_RELAY_MSG_ID_I_CHAR_DYN: /* data */
/* r: 1-bit reserved */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_reserved_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
/* D: 2-bit field indicating # of data bits */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_num_data_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
/* P: 3-bit field for parity type */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_parity_type, tvb, offset, 1, ENC_BIG_ENDIAN);
/* S: 2-bit field indicating # of stop bits */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_num_stop_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
payload_length--;
/* octets */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
break;
case SPRT_MODEM_RELAY_MSG_ID_I_FRAME: /* data */
/* R: 6 reserved bits */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_frame_reserved_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
/* Fr: data frame state */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_frame_state, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
payload_length--;
/* octets */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
break;
case SPRT_MODEM_RELAY_MSG_ID_I_OCTET_CS: /* data */
/* CS: 2-byte character sequence number */
/* TODO - does this msg type ever have a DLCI? */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
payload_length -= 2;
/* octets */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
break;
case SPRT_MODEM_RELAY_MSG_ID_I_CHAR_STAT_CS: /* data */
/* r: 1-bit reserved */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_reserved_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
/* D: 2-bit field indicating # of data bits */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_num_data_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
/* P: 3-bit field for parity type */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_parity_type, tvb, offset, 1, ENC_BIG_ENDIAN);
/* S: 2-bit field indicating # of stop bits */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_num_stop_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
payload_length--;
/* CS: 2-byte character sequence number */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
payload_length -= 2;
/* octets */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
break;
case SPRT_MODEM_RELAY_MSG_ID_I_CHAR_DYN_CS: /* data */
/* r: 1-bit reserved */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_reserved_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
/* D: 2-bit field indicating # of data bits */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_num_data_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
/* P: 3-bit field for parity type */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_parity_type, tvb, offset, 1, ENC_BIG_ENDIAN);
/* S: 2-bit field indicating # of stop bits */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_num_stop_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
payload_length--;
/* CS: 2-byte character sequence number */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
payload_length -= 2;
/* octets */
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
break;
default:
proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
break;
}
} else {
proto_tree_add_item(sprt_tree, hf_sprt_payload_no_data, tvb, offset, 0, ENC_NA);
col_append_str(pinfo->cinfo, COL_INFO, ", No Payload");
}
return offset;
}
static int
dissect_sprt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
/* Set up structures needed to add the protocol subtree and manage it */
proto_item *ti;
proto_tree *sprt_tree = NULL;
proto_tree *sprt_ack_field_tree;
guint16 word1;
unsigned int offset = 0;
guint payload_length;
struct _sprt_conversation_info *p_conv_data = NULL;
int i;
guint16 tc;
guint16 seqnum; /* 0 if TC = 0 or if no payload */
guint16 noa;
/* ack fields */
/*guint16 tcn;*/
/*guint16 sqn;*/
/* Make entries in Protocol column and Info column on summary display */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SPRT");
col_clear(pinfo->cinfo, COL_INFO);
if (tree)
{
/* create the trees */
ti = proto_tree_add_item(tree, proto_sprt, tvb, 0, -1, ENC_NA);
sprt_tree = proto_item_add_subtree(ti, ett_sprt);
/* show conversation setup info */
if (global_sprt_show_setup_info)
{
show_setup_info(tvb, pinfo, sprt_tree);
}
}
/*SPRT header packet format
+------+-------+-------+-------+-------+-------+---------+-------+
|0 |1 |2 |3 |4 |5 |6 |7 |
+------+-------+-------+-------+-------+-------+---------+-------+
| X | SSID |
+----------------------------------------------------------------+
| R | PT |
+--------------+-------------------------------------------------+
| TC | Sequence Number |
+--------------+-------------------------------------------------+
| Sequence Number |
+----------------------------------------------------------------+
| NOA | Base Sequence Number |
+--------------+-------------------------------------------------+
| Base Sequence Number |
+----------------------------------------------------------------+
| TCN | SQN |
+--------------+-------------------------------------------------+
| SQN |
+----------------------------------------------------------------+
| TCN | SQN |
+--------------+-------------------------------------------------+
| SQN |
+----------------------------------------------------------------+
| TCN | SQN |
+--------------+-------------------------------------------------+
| SQN |
+----------------------------------------------------------------+
*/
/* Get fields needed for further dissection */
word1 = tvb_get_ntohs(tvb, offset + 2);
tc = (word1 & 0xC000) >> 14;
seqnum = word1 & 0x3FFF;
noa = (tvb_get_ntohs(tvb, offset + 4) & 0xC000) >> 14;
/* Get conversation data, or create it if not found */
p_conv_data = find_sprt_conversation_data(pinfo);
if (!p_conv_data)
{
sprt_add_address(pinfo,
&pinfo->src, pinfo->srcport,
0,
"SPRT stream",
pinfo->num);
p_conv_data = find_sprt_conversation_data(pinfo);
}
proto_tree_add_item(sprt_tree, hf_sprt_header_extension_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_tree, hf_sprt_subsession_id, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_tree, hf_sprt_reserved_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_tree, hf_sprt_payload_type, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sprt_tree, hf_sprt_transport_channel_id, tvb, offset, 2, ENC_BIG_ENDIAN);
ti = proto_tree_add_item(sprt_tree, hf_sprt_sequence_number, tvb, offset, 2, ENC_BIG_ENDIAN);
if (tc == 0 && seqnum != 0)
expert_add_info(pinfo, ti, &ei_sprt_sequence_number_0);
p_conv_data->seqnum[tc] = seqnum; /* keep track of seqnum values */
offset+=2;
proto_tree_add_item(sprt_tree, hf_sprt_number_of_ack_fields, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_tree, hf_sprt_base_sequence_number, tvb, offset, 2, ENC_BIG_ENDIAN);
offset+=2;
if (noa) /* parse ack fields? There can be 0 - 3 */
{
ti = proto_tree_add_item(sprt_tree, hf_sprt_ack_field_items, tvb, offset, 2, ENC_BIG_ENDIAN);
sprt_ack_field_tree = proto_item_add_subtree(ti, ett_sprt_ack_fields);
for(i = 0; i < noa; i++)
{
proto_tree_add_item(sprt_ack_field_tree, hf_sprt_transport_channel_item, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sprt_ack_field_tree, hf_sprt_sequence_item, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
}
}
/* put details in the info column */
col_append_fstr(pinfo->cinfo, COL_INFO, "TC=%u", tc);
if (tc != 0)
col_append_fstr(pinfo->cinfo, COL_INFO, ", Seq=%u", seqnum);
/* dissect the payload, if any */
payload_length = tvb_captured_length(tvb) - (6 + noa * 2); /* total sprt length - header stuff */
dissect_sprt_data(tvb, pinfo, p_conv_data, sprt_tree, offset, payload_length);
if (noa)
col_append_str(pinfo->cinfo, COL_INFO, " (ACK fields present)");
return tvb_captured_length(tvb);
}
/* heuristic dissector */
static gboolean
dissect_sprt_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
guint8 octet, extension_bit, reserved_bit, payload_type;
guint16 word, tc, seqnum;
unsigned int offset = 0;
/* This is a heuristic dissector, which means we get all the UDP
* traffic not sent to a known dissector and not claimed by
* a heuristic dissector called before us!
*/
if (tvb_captured_length(tvb) < 6)
return FALSE; /* packet is waay to short */
/* Get the fields in the first two octets */
extension_bit = tvb_get_guint8(tvb, offset) & 0x7F;
if (extension_bit != 0) /* must be 0 */
return FALSE;
octet = tvb_get_guint8(tvb, offset + 1);
reserved_bit = octet & 80;
payload_type = octet & 0x7F;
if (reserved_bit != 0) /* must be 0 */
return FALSE;
if (payload_type < 96 || payload_type > 128) /* value within RTP dynamic payload type range */
return FALSE;
word = tvb_get_ntohs(tvb, offset + 2);
tc = word >> 14;
seqnum = word & 0x3F;
if ((tc == 0 || tc == 3) && (seqnum != 0)) /* seqnum only applies if tc is 1 or 2 */
return FALSE;
dissect_sprt(tvb, pinfo, tree, NULL);
return TRUE;
}
/* register the protocol with Wireshark */
void
proto_register_sprt(void)
{
module_t *sprt_module;
expert_module_t* expert_sprt;
static hf_register_info hf[] =
{
/* set up fields */
{
&hf_sprt_setup,
{
"Stream setup",
"sprt.setup",
FT_STRING,
BASE_NONE,
NULL,
0x0,
"Stream setup, method and frame number", HFILL
}
},
{
&hf_sprt_setup_frame,
{
"Setup frame",
"sprt.setup-frame",
FT_FRAMENUM,
BASE_NONE,
NULL,
0x0,
"Frame that set up this stream", HFILL
}
},
{
&hf_sprt_setup_method,
{
"Setup Method",
"sprt.setup-method",
FT_STRING,
BASE_NONE,
NULL,
0x0,
"Method used to set up this stream", HFILL
}
},
/* SPRT header fields: */
{
&hf_sprt_header_extension_bit,
{
"Header extension bit",
"sprt.x",
FT_BOOLEAN,
8,
TFS(&tfs_set_notset),
0x80,
NULL, HFILL
}
},
{
&hf_sprt_subsession_id,
{
"Sub session ID",
"sprt.ssid",
FT_UINT8,
BASE_DEC,
NULL,
0x7F,
NULL, HFILL
}
},
{
&hf_sprt_reserved_bit,
{
"Reserved bit",
"sprt.reserved",
FT_BOOLEAN,
8,
TFS(&tfs_set_notset),
0x80,
NULL, HFILL
}
},
{
&hf_sprt_payload_type,
{
"Payload type",
"sprt.pt",
FT_UINT8,
BASE_DEC,
NULL,
0x7F,
NULL, HFILL
}
},
{
&hf_sprt_transport_channel_id,
{
"Transport channel ID",
"sprt.tc",
FT_UINT16,
BASE_DEC,
VALS(sprt_transport_channel_characteristics),
0xC000,
NULL, HFILL
}
},
{
&hf_sprt_sequence_number,
{
"Sequence number",
"sprt.seq",
FT_UINT16,
BASE_DEC,
NULL,
0x3FFF,
NULL, HFILL
}
},
{
&hf_sprt_number_of_ack_fields,
{
"Number of ACK fields",
"sprt.noa",
FT_UINT16,
BASE_DEC,
NULL,
0xC000,
NULL, HFILL
}
},
{
&hf_sprt_base_sequence_number,
{
"Base sequence number",
"sprt.bsqn",
FT_UINT16,
BASE_DEC,
NULL,
0x3FFF,
NULL, HFILL
}
},
/* ACK fields, if any: */
{
&hf_sprt_ack_field_items, /* 0 to 3 items (TCN + SQN) */
{
"ACK fields",
"sprt.ack.field",
FT_UINT16,
BASE_DEC,
NULL,
0xC000,
NULL, HFILL
}
},
{
&hf_sprt_transport_channel_item,
{
"Transport control channel",
"sprt.tcn",
FT_UINT16,
BASE_DEC,
NULL,
0xC000,
NULL, HFILL
}
},
{
&hf_sprt_sequence_item,
{
"Sequence number",
"sprt.sqn",
FT_UINT16,
BASE_DEC,
NULL,
0x3FFF,
NULL, HFILL
}
},
/* SPRT payload, if any: */
{
&hf_sprt_payload_length,
{
"Payload (in bytes)",
"sprt.payload.length",
FT_UINT32,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_no_data,
{
"No payload",
"sprt.payload",
FT_NONE,
BASE_NONE,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_reserved_bit,
{
"Reserved bit",
"sprt.payload.reserved_bit",
FT_BOOLEAN,
8,
TFS(&tfs_set_notset),
0x80,
NULL, HFILL
}
},
{
&hf_sprt_payload_message_id,
{
"Payload message ID",
"sprt.payload.msgid",
FT_UINT8,
BASE_DEC | BASE_RANGE_STRING,
RVALS(sprt_modem_relay_msg_id_name),
0x7F,
NULL, HFILL
}
},
/* SPRT payload fields, if any (depend on payload msgid): */
/* INIT message */
{
&hf_sprt_payload_msg_init_all_fields,
{
"Init message fields",
"sprt.payload.msg_init.all_fields",
FT_UINT16,
BASE_HEX,
NULL,
0xFFFF, /* 0x0 */
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_init_necrxch,
{
"NECRxCH",
"sprt.payload.msg_init.NECRxCH",
FT_BOOLEAN,
16,
NULL,
0x8000,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_init_ecrxch,
{
"ECRxCH",
"sprt.payload.msg_init.ECRxCH",
FT_BOOLEAN,
16,
NULL,
0x4000,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_init_xid_prof_exch,
{
"XID profile exchange",
"sprt.payload.msg_init.XID_profile_exch",
FT_BOOLEAN,
16,
TFS(&tfs_supported_not_supported),
0x2000,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_init_assym_data_types,
{
"Asymmetrical data types",
"sprt.payload.msg_init.assym_data_types",
FT_BOOLEAN,
16,
TFS(&tfs_supported_not_supported),
0x1000,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_init_opt_moip_types_i_raw_bit,
{
"I_RAW-BIT",
"sprt.payload.msg_init.opt_moip_types_i_raw_bit",
FT_BOOLEAN,
16,
TFS(&tfs_supported_not_supported),
0x0800,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_init_opt_moip_types_i_frame,
{
"I_FRAME",
"sprt.payload.msg_init.opt_moip_types_i_frame",
FT_BOOLEAN,
16,
TFS(&tfs_supported_not_supported),
0x0400,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_init_opt_moip_types_i_char_stat,
{
"I_CHAR-STAT",
"sprt.payload.msg_init.opt_moip_types_i_char_stat",
FT_BOOLEAN,
16,
TFS(&tfs_supported_not_supported),
0x0200,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_init_opt_moip_types_i_char_dyn,
{
"I_CHAR-DYN",
"sprt.payload.msg_init.opt_moip_types_i_char_dyn",
FT_BOOLEAN,
16,
TFS(&tfs_supported_not_supported),
0x0100,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_init_opt_moip_types_i_octet_cs,
{
"I_OCTET-CS",
"sprt.payload.msg_init.opt_moip_types_i_octet_cs",
FT_BOOLEAN,
16,
TFS(&tfs_supported_not_supported),
0x0080,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_init_opt_moip_types_i_char_stat_cs,
{
"I_CHAR-STAT-CS",
"sprt.payload.msg_init.opt_moip_types_i_char_stat_cs",
FT_BOOLEAN,
16,
TFS(&tfs_supported_not_supported),
0x0040,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_init_opt_moip_types_i_char_dyn_cs,
{
"I_CHAR-DYN-CS",
"sprt.payload.msg_init.opt_moip_types_i_char_dyn_cs",
FT_BOOLEAN,
16,
TFS(&tfs_supported_not_supported),
0x0020,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_init_opt_moip_types_reserved,
{
"Reserved for ITU-T",
"sprt.payload.msg_init.opt_moip_types_reserved",
FT_UINT16,
BASE_HEX,
NULL,
0x001F,
NULL, HFILL
}
},
/* XID_XCHG message */
{
&hf_sprt_payload_msg_xidxchg_ecp,
{
"Error correcting protocol",
"sprt.payload.msg_xidxchg.ecp",
FT_UINT8,
BASE_DEC | BASE_RANGE_STRING,
RVALS(sprt_ecp_name),
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_xidxchg_xidlr1_v42bis,
{
"V.42 bis",
"sprt.payload.msg_xidxchg.xidlr1_v42bis",
FT_BOOLEAN,
8,
TFS(&tfs_supported_not_supported),
0x80,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_xidxchg_xidlr1_v44,
{
"V.44",
"sprt.payload.msg_xidxchg.xidlr1_v44",
FT_BOOLEAN,
8,
TFS(&tfs_supported_not_supported),
0x40,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_xidxchg_xidlr1_mnp5,
{
"MNP5",
"sprt.payload.msg_xidxchg.xidlr1_mnp5",
FT_BOOLEAN,
8,
TFS(&tfs_supported_not_supported),
0x20,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_xidxchg_xidlr1_reserved,
{
"Reserved for ITU-T",
"sprt.payload.msg_xidxchg.xidlr1_reserved",
FT_UINT8,
BASE_HEX,
NULL,
0x1F,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_xidxchg_xidlr2_v42bis_compr_req,
{
"V.42bis data compression request",
"sprt.payload.msg_xidxchg.xidlr2_v42bis_compr_req",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_xidxchg_xidlr3and4_v42bis_num_codewords,
{
"V.42bis number of codewords",
"sprt.payload.msg_xidxchg.xidlr3and4_v42bis_num_codewords",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_xidxchg_xidlr5_v42bis_max_strlen,
{
"V.42bis maximum string length",
"sprt.payload.msg_xidxchg.xidlr5_v42bis_max_strlen",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_xidxchg_xidlr6_v44_capability,
{
"V.44 capability",
"sprt.payload.msg_xidxchg.xidlr6_v44_capability",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_xidxchg_xidlr7_v44_compr_req,
{
"V.44 data compression request",
"sprt.payload.msg_xidxchg.xidlr7_v44_compr_req",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_xidxchg_xidlr8and9_v44_num_codewords_trans,
{
"V.44 number of codewords in transmit direction",
"sprt.payload.msg_xidxchg.xidlr8and9_v44_num_codewords_trans",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_xidxchg_xidlr10and11_v44_num_codewords_recv,
{
"V.44 number of codewords in receive direction",
"sprt.payload.msg_xidxchg.xidlr10and11_v44_num_codewords_recv",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_xidxchg_xidlr12_v44_max_strlen_trans,
{
"V.44 maximum string length in transmit direction",
"sprt.payload.msg_xidxchg.xidlr12_v44_max_strlen_trans",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_xidxchg_xidlr13_v44_max_strlen_recv,
{
"V.44 maximum string length in receive direction",
"sprt.payload.msg_xidxchg.xidlr13_v44_max_strlen_recv",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_xidxchg_xidlr14and15_v44_history_len_trans,
{
"V.44 length of history in transmit direction",
"sprt.payload.msg_xidxchg.xidlr14and15_v44_history_len_trans",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_xidxchg_xidlr16and17_v44_history_len_recv,
{
"V.44 length of history in receive direction",
"sprt.payload.msg_xidxchg.xidlr16and17_v44_history_len_recv",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
/* JM_INFO message */
{
&hf_sprt_payload_msg_jminfo_category_data,
{
"Category data",
"sprt.payload.msg_jminfo.category_data",
FT_UINT16,
BASE_DEC,
NULL,
0xFFFF,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_category_id,
{
"Category ID",
"sprt.payload.msg_jminfo.category_id",
FT_UINT16,
BASE_HEX,
VALS(sprt_jm_info_cat_id_name),
0xF000,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_category_ext_info,
{
"Unrecognized category data",
"sprt.payload.msg_jminfo.category_ext_info",
FT_UINT16,
BASE_DEC,
NULL,
0x0FFF,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_unk_category_info,
{
"Category extension data",
"sprt.payload.msg_jminfo.unk_category_info",
FT_UINT16,
BASE_DEC,
NULL,
0x0FFF,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_category_leftover_bits,
{
"Leftover bits", /* "Category info leftover bits", */
"sprt.payload.msg_jminfo.category_leftover_bits",
FT_UINT16,
BASE_HEX,
NULL,
0x01FF,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_call_function,
{
"Call function",
"sprt.payload.msg_jminfo.call_function",
FT_UINT16,
BASE_DEC,
VALS(sprt_jminfo_tbc_call_funct_name),
0x0E00,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_mod_v34_duplex,
{
"V.34 duplex",
"sprt.payload.msg_jminfo.mod_v34_duplex",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0800,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_mod_v34_half_duplex,
{
"V.34 half-duplex",
"sprt.payload.msg_jminfo.mod_v34_half_duplex",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0400,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_mod_v32bis_v32,
{
"V.32bis/V.32",
"sprt.payload.msg_jminfo.mod_v32bis_v32",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0200,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_mod_v22bis_v22,
{
"V.22bis/V.22",
"sprt.payload.msg_jminfo.mod_v22bis_v22",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0100,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_mod_v17,
{
"V.17",
"sprt.payload.msg_jminfo.mod_v17",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0080,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_mod_v29_half_duplex,
{
"V.29 half-duplex",
"sprt.payload.msg_jminfo.mod_v29_half_duplex",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0040,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_mod_v27ter,
{
"V.27ter",
"sprt.payload.msg_jminfo.mod_v27ter",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0020,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_mod_v26ter,
{
"V.26ter",
"sprt.payload.msg_jminfo.mod_v26ter",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0010,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_mod_v26bis,
{
"V.26bis",
"sprt.payload.msg_jminfo.mod_v26bis",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0008,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_mod_v23_duplex,
{
"V.23 duplex",
"sprt.payload.msg_jminfo.mod_v23_duplex",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0004,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_mod_v23_half_duplex,
{
"V.23 half-duplex",
"sprt.payload.msg_jminfo.mod_v23_half_duplex",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0002,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_mod_v21,
{
"V.21",
"sprt.payload.msg_jminfo.mod_v21",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0001,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_protocols,
{
"Protocols",
"sprt.payload.msg_jminfo.protocols",
FT_UINT16,
BASE_DEC | BASE_RANGE_STRING,
RVALS(sprt_jminfo_tbc_protocol_name),
0x0E00,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_pstn_access_call_dce_cell,
{
"Call DCE is on a cellular connection",
"sprt.payload.msg_jminfo.pstn_access_call_dce_cell",
FT_BOOLEAN,
16,
NULL,
0x0800,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_pstn_access_answ_dce_cell,
{
"Answer DCE is on a cellular connection",
"sprt.payload.msg_jminfo.pstn_access_answ_dce_cell",
FT_BOOLEAN,
16,
NULL,
0x0400,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_pstn_access_dce_on_digital_net,
{
"DCE is on a digital network connection",
"sprt.payload.msg_jminfo.pstn_access_dce_on_digital_net",
FT_BOOLEAN,
16,
NULL,
0x0200,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_pcm_modem_avail_v90_v92_analog,
{
"V.90 or V.92 analog modem availability",
"sprt.payload.msg_jminfo.pcm_modem_avail_v90_v92_analog",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0800,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_pcm_modem_avail_v90_v92_digital,
{
"V.90 or V.92 digital modem availability",
"sprt.payload.msg_jminfo.pcm_modem_avail_v90_v92_digital",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0400,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_jminfo_pcm_modem_avail_v91,
{
"V.91 modem availability",
"sprt.payload.msg_jminfo.pcm_modem_avail_v91",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0200,
NULL, HFILL
}
},
/* START_JM message has no additional fields */
/* CONNECT message */
{
&hf_sprt_payload_msg_connect_selmod,
{
"Selected modulation",
"sprt.payload.msg_connect.selmod",
FT_UINT8,
BASE_DEC | BASE_RANGE_STRING,
RVALS(sprt_selmod_name),
0xFC,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_compr_dir,
{
"Compression direction",
"sprt.payload.msg_connect.compr_dir",
FT_UINT8,
BASE_DEC,
VALS(sprt_comp_direction),
0x03,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_selected_compr,
{
"Selected compression",
"sprt.payload.msg_connect.selected_compr",
FT_UINT8,
BASE_DEC | BASE_RANGE_STRING,
RVALS(sprt_selected_compr_name),
0xF0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_selected_err_corr,
{
"Selected error correction",
"sprt.payload.msg_connect.selected_err_corr",
FT_UINT8,
BASE_DEC | BASE_RANGE_STRING,
RVALS(sprt_selected_err_corr_name),
0x0F,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_tdsr,
{
"Transmit data signalling rate (bits/sec)",
"sprt.payload.msg_connect.tdsr",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_rdsr,
{
"Receive data signalling rate (bits/sec)",
"sprt.payload.msg_connect.rdsr",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_dlci_enabled,
{
"DLCI",
"sprt.payload.msg_connect.dlci_enabled",
FT_BOOLEAN,
16,
TFS(&tfs_enabled_disabled),
0x8000,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_avail_data_types,
{
"Available data types",
"sprt.payload.msg_connect.avail_data_types",
FT_UINT16,
BASE_HEX,
NULL,
0x7FFF,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_adt_octet_no_format_no_dlci,
{
"Octet w/o formatting with no DLCI",
"sprt.payload.msg_connect.adt_octet_no_format_no_dlci",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x4000,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_adt_i_raw_bit,
{
"I_RAW-BIT",
"sprt.payload.msg_connect.adt_i_raw_bit",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x2000,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_adt_i_frame,
{
"I_FRAME",
"sprt.payload.msg_connect.adt_i_frame",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x1000,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_adt_i_char_stat,
{
"I_CHAR-STAT",
"sprt.payload.msg_connect.adt_i_char_stat",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0800,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_adt_i_char_dyn,
{
"I_CHAR-DYN",
"sprt.payload.msg_connect.adt_i_char_dyn",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0400,
NULL, HFILL
}
},
{ /* from V.150.1 amendment 2 (5-2006): */
&hf_sprt_payload_msg_connect_adt_i_octet_cs,
{
"I_OCTET-CS",
"sprt.payload.msg_connect.adt_i_octet_cs",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0200,
NULL, HFILL
}
},
{ /* from V.150.1 amendment 2 (5-2006): */
&hf_sprt_payload_msg_connect_adt_i_char_stat_cs,
{
"I_CHAR-STAT-CS",
"sprt.payload.msg_connect.adt_i_char_stat_cs",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0100,
NULL, HFILL
}
},
{ /* from V.150.1 amendment 2 (5-2006): */
&hf_sprt_payload_msg_connect_adt_i_char_dyn_cs,
{
"I_CHAR-DYN-CS",
"sprt.payload.msg_connect.adt_i_char_dyn_cs",
FT_BOOLEAN,
16,
TFS(&tfs_available_not_available),
0x0080,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_adt_reserved,
{
"Reserved for ITU-T",
"sprt.payload.msg_connect.adt_reserved",
FT_UINT16,
BASE_HEX,
NULL,
0x007F,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_compr_trans_dict_sz,
{
"Compression transmit dictionary size",
"sprt.payload.msg_connect.compr_trans_dict_sz",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_compr_recv_dict_sz,
{
"Compression receive dictionary size",
"sprt.payload.msg_connect.compr_recv_dict_sz",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_compr_trans_str_len,
{
"Compression transmit string length",
"sprt.payload.msg_connect.compr_trans_str_len",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_compr_recv_str_len,
{
"Compression receive string length",
"sprt.payload.msg_connect.compr_recv_str_len",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_compr_trans_hist_sz,
{
"Compression transmit history size",
"sprt.payload.msg_connect.compr_trans_hist_sz",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_connect_compr_recv_hist_sz,
{
"Compression receive history size",
"sprt.payload.msg_connect.compr_recv_hist_sz",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
/* BREAK message */
{
&hf_sprt_payload_msg_break_source_proto,
{
"Break source protocol",
"sprt.payload.msg_break.source_proto",
FT_UINT8,
BASE_DEC | BASE_RANGE_STRING,
RVALS(sprt_break_src_proto_name),
0xF0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_break_type,
{
"Break type",
"sprt.payload.msg_break.type",
FT_UINT8,
BASE_DEC | BASE_RANGE_STRING,
RVALS(sprt_break_type_name),
0x0F,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_break_length,
{
"Break length (x10 msec)",
"sprt.payload.msg_break.length",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
/* BREAK_ACK message has no additional fields */
/* MR_EVENT message */
{
&hf_sprt_payload_msg_mr_event_id,
{
"Modem relay event ID",
"sprt.payload.msg_mr_event.id",
FT_UINT8,
BASE_DEC | BASE_RANGE_STRING,
RVALS(sprt_mrevent_id_name),
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_mr_evt_reason_code,
{
"Reason code",
"sprt.payload.msg_mr_event.reason_code",
FT_UINT8,
BASE_DEC | BASE_RANGE_STRING,
RVALS(sprt_mrevent_reason_code_name),
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_mr_evt_selmod,
{
"Selected modulation",
"sprt.payload.msg_mr_event.selmod",
FT_UINT8,
BASE_DEC | BASE_RANGE_STRING,
RVALS(sprt_selmod_name),
0xFC,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_mr_evt_txsen,
{
"TxSEN",
"sprt.payload.msg_mr_event.txsen",
FT_BOOLEAN,
8,
TFS(&tfs_enabled_disabled),
0x02,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_mr_evt_rxsen,
{
"RxSEN",
"sprt.payload.msg_mr_event.rxsen",
FT_BOOLEAN,
8,
TFS(&tfs_enabled_disabled),
0x01,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_mr_evt_tdsr,
{
"Transmit data signalling rate (bits/sec)",
"sprt.payload.msg_mr_event.tdsr",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_mr_evt_rdsr,
{
"Receive data signalling rate (bits/sec)",
"sprt.payload.msg_mr_event.rdsr",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_mr_evt_txsr,
{
"Physical layer transmitter symbol rate (TxSR)",
"sprt.payload.msg_mr_event.txsr",
FT_UINT8,
BASE_DEC | BASE_RANGE_STRING,
RVALS(sprt_mrevent_phys_layer_symbol_rate),
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_mr_evt_rxsr,
{
"Physical layer receiver symbol rate (RxSR)",
"sprt.payload.msg_mr_event.rxsr",
FT_UINT8,
BASE_DEC | BASE_RANGE_STRING,
RVALS(sprt_mrevent_phys_layer_symbol_rate),
0x0,
NULL, HFILL
}
},
/* CLEARDOWN message */
{
&hf_sprt_payload_msg_cleardown_reason_code,
{
"Reason code",
"sprt.payload.msg_cleardown.reason_code",
FT_UINT8,
BASE_DEC,
VALS(sprt_cleardown_reason),
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_cleardown_vendor_tag,
{
"Vendor tag",
"sprt.payload.msg_cleardown.vendor_tag",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_cleardown_vendor_info,
{
"Vendor info",
"sprt.payload.msg_cleardown.vendor_info",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
/* PROF_XCHG message */
{
&hf_sprt_payload_msg_profxchg_v42_lapm,
{
"V.42/LAPM protocol support",
"sprt.payload.msg_profxchg.v42_lapm",
FT_UINT8,
BASE_DEC,
VALS(sprt_prof_xchg_support),
0xC0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_profxchg_annex_av42,
{
"Annex A/V.42(1996) protocol support",
"sprt.payload.msg_profxchg.annex_av42",
FT_UINT8,
BASE_DEC,
VALS(sprt_prof_xchg_support),
0x30,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_profxchg_v44_compr,
{
"V.44 compression support",
"sprt.payload.msg_profxchg.v44_compr",
FT_UINT8,
BASE_DEC,
VALS(sprt_prof_xchg_support),
0x0C,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_profxchg_v42bis_compr,
{
"V.42bis compression support",
"sprt.payload.msg_profxchg.v42bis_compr",
FT_UINT8,
BASE_DEC,
VALS(sprt_prof_xchg_support),
0x03,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_profxchg_mnp5_compr,
{
"MNP5 compression support",
"sprt.payload.msg_profxchg.mnp5_compr",
FT_UINT8,
BASE_DEC,
VALS(sprt_prof_xchg_support),
0xC0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_profxchg_reserved,
{
"Reserved for ITU-T",
"sprt.payload.msg_profxchg.reserved",
FT_UINT8,
BASE_HEX,
NULL,
0x3F,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_profxchg_xidlr2_v42bis_compr_req,
{
"V.42bis data compression request",
"sprt.payload.msg_profxchg.xidlr2_v42bis_compr_req",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_profxchg_xidlr3and4_v42bis_num_codewords,
{
"V.42bis number of codewords",
"sprt.payload.msg_profxchg.xidlr3and4_v42bis_num_codewords",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_profxchg_xidlr5_v42bis_max_strlen,
{
"V.42bis maximum string length",
"sprt.payload.msg_profxchg.xidlr5_v42bis_max_strlen",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_profxchg_xidlr6_v44_capability,
{
"V.44 capability",
"sprt.payload.msg_profxchg.xidlr6_v44_capability",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_profxchg_xidlr7_v44_compr_req,
{
"V.44 data compression request",
"sprt.payload.msg_profxchg.xidlr7_v44_compr_req",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_profxchg_xidlr8and9_v44_num_codewords_trans,
{
"V.44 number of codewords in transmit direction",
"sprt.payload.msg_profxchg.xidlr8and9_v44_num_codewords_trans",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_profxchg_xidlr10and11_v44_num_codewords_recv,
{
"V.44 number of codewords in receive direction",
"sprt.payload.msg_profxchg.xidlr10and11_v44_num_codewords_recv",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_profxchg_xidlr12_v44_max_strlen_trans,
{
"V.44 maximum string length in transmit direction",
"sprt.payload.msg_profxchg.xidlr12_v44_max_strlen_trans",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_profxchg_xidlr13_v44_max_strlen_recv,
{
"V.44 maximum string length in receive direction",
"sprt.payload.msg_profxchg.xidlr13_v44_max_strlen_recv",
FT_UINT8,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_profxchg_xidlr14and15_v44_history_len_trans,
{
"V.44 length of history in transmit direction",
"sprt.payload.msg_profxchg.xidlr14and15_v44_history_len_trans",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_msg_profxchg_xidlr16and17_v44_history_len_recv,
{
"V.44 length of history in receive direction",
"sprt.payload.msg_profxchg.xidlr16and17_v44_history_len_recv",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
/* User data messages... */
/* I_OCTET message: need to use DLCI field (8 or 16 bits) if indicated by CONNECT message */
{
&hf_sprt_payload_i_octet_no_dlci,
{
"No DLCI field",
"sprt.payload.i_octet_no_dlci",
FT_NONE,
BASE_NONE,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_i_octet_dlci_presence_unknown,
{
"Not known if DLCI field is present",
"sprt.payload.i_octet_dlci_presence_unknown",
FT_NONE,
BASE_NONE,
NULL,
0x0,
NULL, HFILL
}
},
{
&hf_sprt_payload_i_octet_dlci1,
{
"DLCI #1",
"sprt.payload.i_octet_dlci1",
FT_UINT8,
BASE_DEC | BASE_RANGE_STRING,
RVALS(sprt_payload_dlci1),
0xFC,
NULL, HFILL
}
},
{
&hf_sprt_payload_i_octet_cr,
{
"Command/response bit",
"sprt.payload.i_octet_cr",
FT_BOOLEAN,
8,
NULL,
0x02,
NULL, HFILL
}
},
{
&hf_sprt_payload_i_octet_ea,
{
"Address field extension bit",
"sprt.payload.i_octet_ea",
FT_BOOLEAN,
8,
TFS(&sprt_payload_ea_bit),
0x01,
NULL, HFILL
}
},
{
&hf_sprt_payload_i_octet_dlci2,
{
"DLCI #2",
"sprt.payload.i_octet_dlci2",
FT_UINT8,
BASE_DEC | BASE_RANGE_STRING,
RVALS(sprt_payload_dlci2),
0xFE,
NULL, HFILL
}
},
{
&hf_sprt_payload_i_octet_dlci_setup_by_connect_frame,
{
"DLCI setup by CONNECT message at frame",
"sprt.payload.i_octet_dlci_setup_by_connect_frame",
FT_FRAMENUM,
BASE_NONE,
NULL,
0x0,
NULL, HFILL
}
},
/* fields for I_RAW_OCTET message (L; L,N) */
{
&hf_sprt_payload_rawoctet_n_field_present,
{
"N field",
"sprt.payload.rawoctet_n_field_present",
FT_BOOLEAN,
8,
TFS(&tfs_present_absent),
0x80,
NULL, HFILL
}
},
{
&hf_sprt_payload_rawoctet_l,
{
"L: # of octets in segment minus one",
"sprt.payload.rawoctet_l",
FT_UINT8,
BASE_DEC,
NULL,
0x7F,
NULL, HFILL
}
},
{
&hf_sprt_payload_rawoctet_n,
{
"N: # of times octets appear in data minus 2",
"sprt.payload.rawoctet_n",
FT_UINT8,
BASE_DEC,
NULL,
0xFF,
NULL, HFILL
}
},
/* fields for I_RAW_BIT (L; L,P; L,P,N) */
{
&hf_sprt_payload_rawbit_included_fields_l,
{
"Include field L only",
"sprt.payload.rawbit_included_fields_l",
FT_UINT8,
BASE_DEC,
NULL,
0xC0, /* top two bits: 00 */
NULL, HFILL
}
},
{
&hf_sprt_payload_rawbit_included_fields_lp,
{
"Include fields L, P",
"sprt.payload.rawbit_field_format_lp",
FT_UINT8,
BASE_DEC,
NULL,
0xC0, /* top two bits: 01 */
NULL, HFILL
}
},
{
&hf_sprt_payload_rawbit_included_fields_lpn,
{
"Include fields L, P, N",
"sprt.payload.rawbit_included_fields_lpn",
FT_UINT8,
BASE_DEC,
NULL,
0x80, /* top bit: 1 */
NULL, HFILL
}
},
{
&hf_sprt_payload_rawbit_len_a,
{
"L: # of octets in segment",
"sprt.payload.rawbit_len_a",
FT_UINT8,
BASE_DEC,
NULL,
0x3F, /* six bits */
NULL, HFILL
}
},
{
&hf_sprt_payload_rawbit_len_b,
{
"L: # of octets in segment",
"sprt.payload.rawbit_len_b",
FT_UINT8,
BASE_DEC,
NULL,
0x38, /* three bits */
NULL, HFILL
}
},
{
&hf_sprt_payload_rawbit_len_c,
{
"L: # of octets in segment",
"sprt.payload.rawbit_len_c",
FT_UINT8,
BASE_DEC,
NULL,
0x78, /* four bits */
NULL, HFILL
}
},
{
&hf_sprt_payload_rawbit_p,
{
"P: # of low-order bits in last octet that are not in segment",
"sprt.payload.rawbit_p",
FT_UINT8,
BASE_DEC,
NULL,
0x7, /* three bits */
NULL, HFILL
}
},
{
&hf_sprt_payload_rawbit_n,
{
"N: # of times octets appear in data minus 2",
"sprt.payload.rawbit_n",
FT_UINT8,
BASE_DEC,
NULL,
0xFF, /* eight bits */
NULL, HFILL
}
},
/* fields in I_CHAR_STAT & I_CHAR_DYN messages */
{
&hf_sprt_payload_data_reserved_bit,
{
"Reserved bit",
"sprt.payload.reserved_bit",
FT_BOOLEAN,
8,
TFS(&tfs_set_notset),
0x80,
NULL, HFILL
}
},
{
&hf_sprt_payload_data_num_data_bits,
{
"D: Number of data bits",
"sprt.payload.num_data_bits",
FT_UINT8,
BASE_DEC,
VALS(sprt_payload_data_bits),
0x60,
NULL, HFILL
}
},
{
&hf_sprt_payload_data_parity_type,
{
"P: Parity type",
"sprt.payload.parity_type",
FT_UINT8,
BASE_DEC,
VALS(sprt_payload_parity),
0x1C,
NULL, HFILL
}
},
{
&hf_sprt_payload_num_stop_bits,
{
"S: Number stop bits",
"sprt.payload.num_stop_bits",
FT_UINT8,
BASE_DEC,
VALS(sprt_payload_stop_bits),
0x03,
NULL, HFILL
}
},
/* sequence field in I_OCTET_CS, I_CHAR_STAT_CS, & I_CHAR_DYN_CS messages */
{
&hf_sprt_payload_data_cs,
{
"Character sequence number",
"sprt.payload.cs",
FT_UINT16,
BASE_DEC,
NULL,
0x0,
NULL, HFILL
}
},
/* fields for I_FRAME: */
{
&hf_sprt_payload_frame_reserved_bits,
{
"Reserved bits",
"sprt.payload.frame_reserved_bits",
FT_UINT8,
BASE_HEX,
NULL,
0xFC,
NULL, HFILL
}
},
{
&hf_sprt_payload_frame_state,
{
"Frame state",
"sprt.payload.frame_state",
FT_UINT8,
BASE_DEC,
VALS(sprt_payload_frame_state),
0x03,
NULL, HFILL
}
},
/* just dump remaining payload data: */
{
&hf_sprt_payload_data,
{
"Payload data",
"sprt.payload.data",
FT_BYTES,
BASE_NONE,
NULL,
0x0,
NULL, HFILL
}
},
}; /* hf_register_info hf[] */
/* setup protocol subtree array */
static gint *ett[] = {
&ett_sprt,
&ett_sprt_setup,
&ett_sprt_ack_fields,
&ett_payload,
&ett_init_msg_all_fields,
&ett_jminfo_msg_cat_data,
&ett_connect_msg_adt
};
static ei_register_info ei[] = {
{ &ei_sprt_sequence_number_0, { "sprt.sequence_number_0", PI_PROTOCOL, PI_WARN, "Should be 0 for transport channel 0", EXPFILL }},
};
/* register protocol name & description */
proto_sprt = proto_register_protocol("Simple Packet Relay Transport", "SPRT", "sprt");
/* required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_sprt, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_sprt = expert_register_protocol(proto_sprt);
expert_register_field_array(expert_sprt, ei, array_length(ei));
/* register the dissector */
sprt_handle = register_dissector("sprt", dissect_sprt, proto_sprt);
sprt_module = prefs_register_protocol(proto_sprt, NULL);
/* preferences */
prefs_register_bool_preference(sprt_module, "show_setup_info",
"Show stream setup information",
"Where available, show which protocol and frame caused "
"this SPRT stream to be created",
&global_sprt_show_setup_info);
prefs_register_bool_preference(sprt_module, "show_dlci_info",
"Show DLCI in I_OCTET messages",
"Show the DLCI field in I_OCTET messages as well as the frame that "
"enabled/disabled the DLCI",
&global_sprt_show_dlci_info);
}
void
proto_reg_handoff_sprt(void)
{
dissector_add_for_decode_as_with_preference("udp.port", sprt_handle);
heur_dissector_add( "udp", dissect_sprt_heur, "SPRT over UDP", "sprt_udp", proto_sprt, HEURISTIC_ENABLE);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-sprt.h
|
/* packet-sprt.h
*
* Routines for SPRT dissection
* SPRT = Simple Packet Relay Transport
*
* Written by Jamison Adcock <[email protected]>
* for Sparta Inc., dba Cobham Analytic Solutions
* This code is largely based on the RTP parsing code
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef _PACKET_SPRT_H
#define _PACKET_SPRT_H
void sprt_add_address(packet_info *pinfo,
address *addr,
int port,
int other_port,
const gchar *setup_method,
guint32 setup_frame_number);
#endif /* _PACKET_SPRT_H */
|
C
|
wireshark/epan/dissectors/packet-srp.c
|
/* packet-srp.c
* Routines for H.324/SRP dissection
* 2004 Richard van der Hoff <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/crc16-tvb.h>
void proto_register_srp(void);
void proto_register_ccsrl(void);
void proto_reg_handoff_srp(void);
/* Wireshark ID of the protocols */
static int proto_srp = -1;
static int proto_ccsrl = -1;
/* The following hf_* variables are used to hold the Wireshark IDs of
* our header fields; they are filled out when we call
* proto_register_field_array() in proto_register_srp()
*/
static int hf_srp_header = -1;
static int hf_srp_seqno = -1;
static int hf_srp_crc = -1;
static int hf_srp_crc_bad = -1;
static int hf_ccsrl_ls = -1;
/* These are the ids of the subtrees that we may be creating */
static gint ett_srp = -1;
static gint ett_ccsrl = -1;
static dissector_handle_t ccsrl_handle;
static dissector_handle_t h245dg_handle;
/*****************************************************************************/
#define SRP_SRP_COMMAND 249
#define SRP_SRP_RESPONSE 251
#define SRP_NSRP_RESPONSE 247
/* WNSRP definitions */
#define WNSRP_COMMAND_HEADER 241
#define WNSRP_RESPONSE_HEADER 243
static const value_string srp_frame_types[] = {
{SRP_SRP_COMMAND, "SRP command"},
{SRP_SRP_RESPONSE, "SRP response"},
{SRP_NSRP_RESPONSE, "NSRP response"},
{WNSRP_COMMAND_HEADER, "WNSRP command"},
{WNSRP_RESPONSE_HEADER, "WNSRP response"},
{0,NULL}
};
static const value_string ccsrl_ls_vals[] = {
{0xFF, "Yes"},
{0x00, "No"},
{0,NULL}
};
/*****************************************************************************/
static int dissect_ccsrl(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_)
{
proto_item *ccsrl_item;
proto_tree *ccsrl_tree=NULL;
guint8 lastseg = tvb_get_guint8(tvb,0);
tvbuff_t *next_tvb;
/* add the 'ccsrl' tree to the main tree */
if (tree) {
ccsrl_item = proto_tree_add_item (tree, proto_ccsrl, tvb, 0, -1, ENC_NA);
ccsrl_tree = proto_item_add_subtree (ccsrl_item, ett_ccsrl);
proto_tree_add_uint(ccsrl_tree,hf_ccsrl_ls,tvb,0,1,lastseg);
}
/* XXX add support for reassembly of fragments */
/* XXX currently, we always dissect as H245. It's not necessarily
that though.
*/
next_tvb = tvb_new_subset_remaining(tvb, 1);
call_dissector( h245dg_handle, next_tvb, pinfo, ccsrl_tree );
return tvb_captured_length(tvb);
}
static void dissect_srp_command(tvbuff_t * tvb, packet_info * pinfo, proto_tree * srp_tree)
{
tvbuff_t *next_tvb;
guint payload_len;
if( srp_tree )
proto_tree_add_item(srp_tree,hf_srp_seqno,tvb,1,1,ENC_BIG_ENDIAN);
payload_len = tvb_reported_length_remaining(tvb,4);
next_tvb = tvb_new_subset_length(tvb, 2, payload_len);
/* XXX currently, we always dissect as CCSRL. It's only that in
* H324/Annex C though.
*/
call_dissector(ccsrl_handle, next_tvb, pinfo, srp_tree );
}
static int dissect_srp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data _U_)
{
proto_item *srp_item = NULL;
proto_tree *srp_tree = NULL;
proto_item *hidden_item;
guint8 header = tvb_get_guint8(tvb,0);
/* add the 'srp' tree to the main tree */
if (tree) {
srp_item = proto_tree_add_item (tree, proto_srp, tvb, 0, -1, ENC_NA);
srp_tree = proto_item_add_subtree (srp_item, ett_srp);
proto_tree_add_uint(srp_tree,hf_srp_header,tvb,0,1,header);
}
switch( header ) {
case SRP_SRP_COMMAND:
case WNSRP_COMMAND_HEADER:
dissect_srp_command(tvb,pinfo,srp_tree);
break;
case SRP_SRP_RESPONSE:
break;
case SRP_NSRP_RESPONSE:
case WNSRP_RESPONSE_HEADER:
if( srp_tree )
proto_tree_add_item(srp_tree,hf_srp_seqno,tvb,1,1,ENC_BIG_ENDIAN);
break;
default:
break;
}
if( srp_tree ) {
guint16 crc, calc_crc;
guint crc_offset = tvb_reported_length(tvb)-2;
crc = tvb_get_letohs(tvb,-2);
/* crc includes the header */
calc_crc = crc16_ccitt_tvb(tvb,crc_offset);
if( crc == calc_crc ) {
proto_tree_add_uint_format_value(srp_tree, hf_srp_crc, tvb,
crc_offset, 2, crc,
"0x%04x (correct)", crc);
} else {
hidden_item = proto_tree_add_boolean(srp_tree, hf_srp_crc_bad, tvb,
crc_offset, 2, TRUE);
proto_item_set_hidden(hidden_item);
proto_tree_add_uint_format_value(srp_tree, hf_srp_crc, tvb,
crc_offset, 2, crc,
"0x%04x (incorrect, should be 0x%04x)",
crc,
calc_crc);
}
}
return tvb_captured_length(tvb);
}
void proto_register_ccsrl (void)
{
static hf_register_info hf[] = {
{ &hf_ccsrl_ls,
{ "Last Segment","ccsrl.ls",FT_UINT8, BASE_HEX, VALS(ccsrl_ls_vals), 0x0,
"Last segment indicator", HFILL}},
};
static gint *ett[] = {
&ett_ccsrl,
};
proto_ccsrl = proto_register_protocol ("H.324/CCSRL", "CCSRL", "ccsrl");
proto_register_field_array (proto_ccsrl, hf, array_length (hf));
proto_register_subtree_array (ett, array_length (ett));
register_dissector("ccsrl", dissect_ccsrl, proto_ccsrl);
}
void proto_register_srp (void)
{
static hf_register_info hf[] = {
{&hf_srp_header,
{ "Header", "srp.header", FT_UINT8, BASE_DEC, VALS(srp_frame_types), 0x0,
"SRP header octet", HFILL }},
{&hf_srp_seqno,
{ "Sequence Number", "srp.seqno", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{&hf_srp_crc,
{ "CRC", "srp.crc", FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_srp_crc_bad,
{ "Bad CRC","srp.crc_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
};
static gint *ett[] = {
&ett_srp,
};
proto_srp = proto_register_protocol ("H.324/SRP", "SRP", "srp");
proto_register_field_array (proto_srp, hf, array_length (hf));
proto_register_subtree_array (ett, array_length (ett));
register_dissector("srp", dissect_srp, proto_srp);
/* register our init routine to be called at the start of a capture,
to clear out our hash tables etc */
/* register_init_routine(&srp_init_protocol); */
}
void proto_reg_handoff_srp(void) {
ccsrl_handle = find_dissector_add_dependency("ccsrl", proto_srp);
h245dg_handle = find_dissector_add_dependency("h245dg", proto_srp);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-srt.c
|
/* packet-srt.c
* Routines for Secure Reliable Transport Protocol dissection
* Copyright (c) 2018 Haivision Systems Inc. <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
* SRT is an open source video transport protocol and technology stack
* that optimizes streaming performance across unpredictable networks
* with secure streams and easy firewall traversal, bringing the best
* quality live video over the worst networks.
*
* Internet draft:
* https://datatracker.ietf.org/doc/html/draft-sharabayko-srt-01
*
* Open-source implementation:
* https://github.com/Haivision/srt
*/
#include <config.h>
#include <epan/packet.h>
#include <epan/expert.h>
#include <epan/conversation.h>
#include <wsutil/str_util.h>
#include <wsutil/inet_addr.h>
/* Prototypes */
void proto_reg_handoff_srt(void);
void proto_register_srt(void);
/* Initialize the protocol */
static int proto_srt = -1;
static int hf_srt_iscontrol = -1;
static int hf_srt_type = -1;
static int hf_srt_exttype = -1;
static int hf_srt_exttype_none = -1;
static int hf_srt_seqno = -1;
static int hf_srt_ack_seqno = -1;
static int hf_srt_ackno = -1;
static int hf_srt_msgno = -1;
static int hf_srt_msgno_pb = -1;
static int hf_srt_msgno_inorder = -1;
static int hf_srt_msgno_enctypes = -1;
static int hf_srt_msgno_rexmit = -1;
static int hf_srt_timestamp = -1;
static int hf_srt_id = -1;
static int hf_srt_addinfo = -1;
static int hf_srt_rtt = -1;
static int hf_srt_rttvar = -1;
static int hf_srt_bufavail = -1;
static int hf_srt_rate = -1;
static int hf_srt_bandwidth = -1;
static int hf_srt_rcvrate = -1;
/* SRT Handshake */
static int hf_srt_handshake_version = -1;
static int hf_srt_handshake_type_v4 = -1;
static int hf_srt_handshake_enc_field_v5 = -1;
static int hf_srt_handshake_ext_field_v5 = -1;
static int hf_srt_handshake_ext_field_v5_flag_hsreq = -1;
static int hf_srt_handshake_ext_field_v5_flag_kmreq = -1;
static int hf_srt_handshake_ext_field_v5_flag_config = -1;
static int hf_srt_handshake_isn = -1;
static int hf_srt_handshake_mtu = -1;
static int hf_srt_handshake_flow_window = -1;
static int hf_srt_handshake_reqtype = -1;
static int hf_srt_handshake_failure_type = -1;
static int hf_srt_handshake_id = -1;
static int hf_srt_handshake_cookie = -1;
static int hf_srt_handshake_peerip = -1;
/* SRT Handshake Extension */
static int hf_srt_handshake_ext_version = -1;
static int hf_srt_handshake_ext_flags = -1;
static int hf_srt_handshake_ext_flag_tsbpd_snd = -1;
static int hf_srt_handshake_ext_flag_tsbpd_rcv = -1;
static int hf_srt_handshake_ext_flag_haicrypt = -1;
static int hf_srt_handshake_ext_flag_tlpkt_drop = -1;
static int hf_srt_handshake_ext_flag_nak_report = -1;
static int hf_srt_handshake_ext_flag_rexmit = -1;
static int hf_srt_handshake_ext_flag_stream = -1;
static int hf_srt_srths_blocktype = -1;
static int hf_srt_srths_blocklen = -1;
static int hf_srt_srths_agent_latency = -1; // TSBPD delay
static int hf_srt_srths_peer_latency = -1; // TSBPD delay
static int hf_srt_srtkm_msg = -1;
static int hf_srt_srtkm_error = -1;
static int hf_srt_srths_sid = -1;
static int hf_srt_srths_congestcontrol = -1;
static gint ett_srt = -1;
static gint ett_srt_handshake_ext_flags = -1;
static gint ett_srt_handshake_ext_field_flags = -1;
static expert_field ei_srt_nak_seqno = EI_INIT;
static expert_field ei_srt_hs_ext_hsreq_len = EI_INIT;
static expert_field ei_srt_hs_ext_type = EI_INIT;
static dissector_handle_t srt_udp_handle;
/* This defines the firstmost bit of the packet, so it can stay this way. */
#define SRT_TYPE_DATA 0
#define SRT_TYPE_CONTROL 1
#define SRT_CONTROL_MASK (~0x80000000)
#define SRT_LOSS_SEQUENCE_FIRST 0x80000000
#define SRT_LOSS_SEQUENCE_MASK (~SRT_LOSS_SEQUENCE_FIRST)
enum UDTSockType
{
SRT_UNDEFINED = 0, /* initial trap representation */
SRT_STREAM = 1,
SRT_DGRAM = 2,
SRT_MAGIC_CODE = 0x4A17
};
/* Handshake Extended Field Flags */
#define SRT_OPT_FIELD_LEN 32
#define SRT_OPT_TSBPDSND (1 << 0)
#define SRT_OPT_TSBPDRCV (1 << 1)
#define SRT_OPT_HAICRYPT (1 << 2)
#define SRT_OPT_TLPKTDROP (1 << 3)
#define SRT_OPT_NAKREPORT (1 << 4)
#define SRT_OPT_REXMITFLG (1 << 5)
#define SRT_OPT_STREAM (1 << 6)
/* Extended Handshake Flags */
#define SRT_HS_V5_EXT_FIELD_LEN 16
#define SRT_HS_V5_EXT_FIELD_HSREQ (1 << 0)
#define SRT_HS_V5_EXT_FIELD_KMREQ (1 << 1)
#define SRT_HS_V5_EXT_FIELD_CONFIG (1 << 2)
#define SRT_HS_V5_EXT_FIELD_MAGIC SRT_MAGIC_CODE
/* Message number field and single bit flags */
#define SRT_MSGNO_FF_FIRST_B (2 << (32-2))
#define SRT_MSGNO_FF_LAST_B (1 << (32-2))
#define SRT_MSGNO_FF_MASK (SRT_MSGNO_FF_FIRST_B | SRT_MSGNO_FF_LAST_B)
enum PacketBoundary
{
PB_SUBSEQUENT = 0,
/* 01: last packet of a message */
PB_LAST = 1,
/* 10: first packet of a message */
PB_FIRST = 2,
/* 11: solo message packet */
PB_SOLO = 3,
};
#define SRT_MSGNO_INORDER (1 << (32-3)) /* 0x20000000 */
#define SRT_MSGNO_ENCTYPE (3 << (32-5)) /* 0x18000000 */
#define SRT_MSGNO_EK_NONE 0
#define SRT_MSGNO_EK_EVEN 1
#define SRT_MSGNO_EK_ODD 2
#define SRT_MSGNO_REXMIT (1 << (32-6)) /* 0x04000000 */
/* Rest of the bits are for message sequence number */
#define SRT_MSGNO_MSGNO_MASK 0x03ffffff
/* The message types used by UDT protocol. This is a part of UDT
* protocol and should never be changed.
*/
enum UDTMessageType
{
UMSG_HANDSHAKE = 0, // Connection Handshake. Control: see @a CHandShake.
UMSG_KEEPALIVE = 1, // Keep-alive.
UMSG_ACK = 2, // Acknowledgement. Control: past-the-end sequence number up to which packets have been received.
UMSG_LOSSREPORT = 3, // Negative Acknowledgement (NACK). Control: Loss list.
UMSG_CGWARNING = 4, // Congestion warning.
UMSG_SHUTDOWN = 5, // Shutdown.
UMSG_ACKACK = 6, // Acknowledgement of Acknowledgement. Add info: The ACK sequence number
UMSG_DROPREQ = 7, // Message Drop Request. Add info: Message ID. Control Info: (first, last) number of the message.
UMSG_PEERERROR = 8, // Signal from the Peer side. Add info: Error code.
/* ... add extra code types here */
UMSG_END_OF_TYPES,
UMSG_EXT = 0x7FFF // For the use of user-defined control packets.
};
// Adapted constants
#define SRT_CMD_HSREQ 1
#define SRT_CMD_HSRSP 2
#define SRT_CMD_KMREQ 3
#define SRT_CMD_KMRSP 4
#define SRT_CMD_SID 5
#define SRT_CMD_CONGESTCTRL 6
enum SrtDataStruct
{
SRT_HS_VERSION = 0,
SRT_HS_FLAGS,
SRT_HS_EXTRAS,
// Keep it always last
SRT_HS__SIZE
};
enum UDTRequestType
{
URQ_AGREEMENT = -2,
URQ_CONCLUSION = -1,
URQ_WAVEAHAND = 0,
URQ_INDUCTION = 1,
URQ_FAILURE_TYPES = 1000
};
enum SRT_KM_STATE
{
SRT_KM_S_UNSECURED = 0, ///< No encryption
SRT_KM_S_SECURING = 1, ///< Stream encrypted, exchanging Keying Material
SRT_KM_S_SECURED = 2, ///< Stream encrypted, keying Material exchanged, decrypting ok.
SRT_KM_S_NOSECRET = 3, ///< Stream encrypted and no secret to decrypt Keying Material
SRT_KM_S_BADSECRET = 4 ///< Stream encrypted and wrong secret, cannot decrypt Keying Material
};
static const value_string srt_ctrlmsg_types[] = {
{UMSG_HANDSHAKE, "UMSG_HANDSHAKE"},
{UMSG_KEEPALIVE, "UMSG_KEEPALIVE"},
{UMSG_ACK, "UMSG_ACK"},
{UMSG_LOSSREPORT, "UMSG_LOSSREPORT"},
{UMSG_CGWARNING, "UMSG_CGWARNING"},
{UMSG_SHUTDOWN, "UMSG_SHUTDOWN"},
{UMSG_ACKACK, "UMSG_ACKACK"},
{UMSG_DROPREQ, "UMSG_DROPREQ"},
{UMSG_PEERERROR, "UMSG_PEERERROR"},
{UMSG_EXT, "UMSG_EXT"},
{0, NULL},
};
static const value_string srt_ctrlmsg_exttypes[] = {
{SRT_CMD_HSREQ, "SRT_CMD_HSREQ"},
{SRT_CMD_HSRSP, "SRT_CMD_HSRSP"},
{SRT_CMD_KMREQ, "SRT_CMD_KMREQ"},
{SRT_CMD_KMRSP, "SRT_CMD_KMRSP"},
{SRT_CMD_SID, "SRT_CMD_SID"},
{SRT_CMD_CONGESTCTRL, "SRT_CMD_CONGESTCTRL"},
{ 0, NULL },
};
static const value_string srt_hsv4_socket_types[] = {
{SRT_STREAM, "SRT_STREAM"},
{SRT_DGRAM, "SRT_DGRAM"},
{0, NULL},
};
static const value_string srt_handshake_enc_field[] = {
{0, "PBKEYLEN not advertised"},
{2, "AES-128" },
{3, "AES-192" },
{4, "AES-256" },
{0, NULL},
};
static const true_false_string srt_packet_types = {
"CONTROL", /* 1 */
"DATA" /* 0 */
};
static const value_string srt_pb_types[] = {
{PB_SUBSEQUENT, "PB_SUBSEQUENT"},
{PB_LAST, "PB_LAST"},
{PB_FIRST, "PB_FIRST"},
{PB_SOLO, "PB_SOLO"},
{0, NULL},
};
static const value_string srt_msgno_enctypes[] = {
{SRT_MSGNO_EK_NONE, "Not encrypted"},
{SRT_MSGNO_EK_EVEN, "Encrypted ith even key"},
{SRT_MSGNO_EK_ODD, "Encrypted with odd key"},
{0, NULL},
};
static const true_false_string srt_msgno_rexmit = {
"Retransmitted", /* 1 */
"Original" /* 0 */
};
static const value_string srt_hs_request_types[] = {
{URQ_INDUCTION, "URQ_INDUCTION (c/l invocation)"},
{URQ_CONCLUSION, "URQ_CONCLUSION"},
{URQ_WAVEAHAND, "URQ_WAVEAHAND (rendezvous invocation)"},
{URQ_AGREEMENT, "URQ_AGREEMENT (rendezvous finalization)"},
{0, NULL}
};
static const value_string srt_enc_kmstate[] = {
{SRT_KM_S_UNSECURED, "UNSECURED"},
{SRT_KM_S_SECURING, "SECURING"},
{SRT_KM_S_SECURED, "SECURED"},
{SRT_KM_S_NOSECRET, "NOSECRET"},
{SRT_KM_S_BADSECRET, "BADSECRET"},
{0, NULL},
};
/*
* XXX To be added later to extract correct IPv4/IPv6 address from 16 bytes of data
* static void srt_tree_add_ipaddr( proto_tree *tree, const int hf, tvbuff_t *tvb, gint offset)
* {
*
* }
*/
#define IP_BUFFER_SIZE 64
static void srt_format_ip_address(gchar* dest, size_t dest_size, const gchar* ptr)
{
/* Initial IPv4 check.
* The address is considered IPv4 if:
* byte[0] and byte[3] != 0
* bytes[4...16] == 0
*/
ws_in4_addr ia4;
ws_in6_addr ia6;
guint32* p;
int i, j;
if (ptr[0] != 0 && ptr[3] != 0)
{
for (i = 4; i < 16; ++i)
{
if ( ptr[i] == 0 )
continue;
/* This is not an IP4 */
p = (guint32*) &ia6;
for (j = 0; j < 4; ++j)
p[j] = g_ntohl(((guint32*)ptr)[j]);
ws_inet_ntop6(&ia6, dest, (guint) dest_size);
return;
}
}
// There's one small problem: the contents of the handshake
// goes in LITTLE ENDIAN. That's an initial problem of UDT.
// The address must be inverted.
// Here's IPv4, so invert only one l.
ia4 = g_ntohl(*((const guint32*)ptr));
ws_inet_ntop4(&ia4, dest, (guint) dest_size);
return;
}
static void srt_format_hs_ext_hsreq(proto_tree* tree, tvbuff_t* tvb, int baseoff)
{
proto_item* pi;
guint32 version = 0;
pi = proto_tree_add_item_ret_uint(tree, hf_srt_handshake_ext_version, tvb, baseoff, 4, ENC_BIG_ENDIAN, &version);
const int vminor = (version >> 8) & 0xff;
const int vmajor = (version >> 16) & 0xff;
const int vpatch = version & 0xff;
proto_item_append_text(pi, " (%d.%d.%d)", vmajor, vminor, vpatch);
static int * const ext_hs_flags[] = {
&hf_srt_handshake_ext_flag_tsbpd_snd,
&hf_srt_handshake_ext_flag_tsbpd_rcv,
&hf_srt_handshake_ext_flag_haicrypt,
&hf_srt_handshake_ext_flag_tlpkt_drop,
&hf_srt_handshake_ext_flag_nak_report,
&hf_srt_handshake_ext_flag_rexmit,
&hf_srt_handshake_ext_flag_stream,
NULL
};
proto_tree_add_bitmask_with_flags(tree, tvb, baseoff + 4, hf_srt_handshake_ext_flags,
ett_srt_handshake_ext_flags, ext_hs_flags, ENC_NA, BMT_NO_APPEND);
proto_tree_add_item(tree, hf_srt_srths_peer_latency, tvb, baseoff+8, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srt_srths_agent_latency, tvb, baseoff+10, 2, ENC_BIG_ENDIAN);
}
static void srt_format_kmx(proto_tree* tree, tvbuff_t* tvb, int baseoff, int blocklen)
{
if (blocklen == 4)
{
// Error report. Format as KMX state.
proto_tree_add_item(tree, hf_srt_srtkm_error, tvb, baseoff, 4, ENC_NA);
}
else
{
proto_tree_add_item(tree, hf_srt_srtkm_msg, tvb, baseoff, blocklen, ENC_NA);
}
}
// Wireshark dissector doesn't have a possibility to format enum-collected flags.
static void dissect_srt_hs_ext_field(proto_tree* tree,
tvbuff_t* tvb, int baseoff)
{
static const gint ext_field_len = 2;
const int bits = tvb_get_ntohs(tvb, baseoff);
if (bits == SRT_HS_V5_EXT_FIELD_MAGIC)
{
proto_item* pi = proto_tree_add_item(tree, hf_srt_handshake_ext_field_v5,
tvb, baseoff, ext_field_len, ENC_BIG_ENDIAN);
proto_item_append_text(pi, ": HSv5 MAGIC");
return;
}
static int * const ext_hs_ext_field_flags[] = {
&hf_srt_handshake_ext_field_v5_flag_hsreq,
&hf_srt_handshake_ext_field_v5_flag_kmreq,
&hf_srt_handshake_ext_field_v5_flag_config,
NULL
};
proto_tree_add_bitmask_with_flags(tree, tvb, baseoff, hf_srt_handshake_ext_field_v5,
ett_srt_handshake_ext_field_flags, ext_hs_ext_field_flags, ENC_NA, BMT_NO_APPEND);
return;
}
/*
* UTF-8 string packed as 32 bit little endian words (what?!)
* https://datatracker.ietf.org/doc/html/draft-sharabayko-srt-01#section-3.2.1.3
*
* THe spec says
*
* The actual size is determined by the Extension Length field,
* which defines the length in four byte blocks. If the actual
* payload is less than the declared length, the remaining bytes
* are set to zeros.
*
* The content is stored as 32-bit little endian words.
*
* This means that the octets of the string are in the rather peculiar
* order:
*
* octet 3
* octet 2
* octet 1
* octet 0
* octet 8
* octet 7
* octet 6
* octet 5
*
* and so on, with null padding (not null termination).
*/
static void format_text_reorder_32(proto_tree* tree, tvbuff_t* tvb, int hfinfo, int baseoff, int blocklen)
{
wmem_strbuf_t *sid = wmem_strbuf_create(wmem_packet_scope());
for (int ii = 0; ii < blocklen; ii += 4)
{
//
// Yes, this is fetching the 32-bit word as big-endian
// rather than little-endian.
//
// However, it's then taking the low-order byte of the
// result as the first octet, followed by the byte above
// that, followed by the byte above that, followed by
// the high-order byte.
//
// This is equivalent t fetching the 32-bit word as little-endian
// and then taking the high-order byte of the result as the
// first octet, etc.
//
// And both of those implement what's described above.
//
// No, I have no idea why they chose this representation for
// strings.
//
const guint32 u = tvb_get_ntohl(tvb, baseoff + ii);
wmem_strbuf_append_c(sid, 0xFF & (u >> 0));
wmem_strbuf_append_c(sid, 0xFF & (u >> 8));
wmem_strbuf_append_c(sid, 0xFF & (u >> 16));
wmem_strbuf_append_c(sid, 0xFF & (u >> 24));
}
if (!wmem_strbuf_utf8_validate(sid, NULL))
wmem_strbuf_utf8_make_valid(sid);
proto_tree_add_string(tree, hfinfo, tvb,
baseoff, blocklen, wmem_strbuf_get_str(sid));
}
/* Code to actually dissect the packets
*
*/
static void
dissect_srt_control_packet(tvbuff_t *tvb, packet_info* pinfo,
proto_tree *tree, proto_item *srt_item)
{
guint32 type = 0;
guint32 exttype = 0;
proto_tree_add_item_ret_uint(tree, hf_srt_type, tvb, 0, 2,
ENC_BIG_ENDIAN, &type);
if ( type != UMSG_EXT )
proto_tree_add_item(tree, hf_srt_exttype_none, tvb, 2, 2,
ENC_BIG_ENDIAN);
else
proto_tree_add_item_ret_uint(tree, hf_srt_exttype, tvb, 2, 2,
ENC_BIG_ENDIAN, &exttype);
switch (type)
{
case UMSG_EXT:
col_add_fstr(pinfo->cinfo, COL_INFO, "Control/ext: %s socket: 0x%x",
val_to_str(exttype, srt_ctrlmsg_exttypes,
"Unknown SRT Control Type (0x%x)"),
tvb_get_ntohl(tvb, 12));
break;
case UMSG_ACK:
col_add_fstr(pinfo->cinfo, COL_INFO, "Control: UMSG_ACK %d ackseq: %d socket: 0x%x",
tvb_get_ntohl(tvb, 4),
tvb_get_ntohl(tvb, 16),
tvb_get_ntohl(tvb, 12));
break;
case UMSG_ACKACK:
col_add_fstr(pinfo->cinfo, COL_INFO, "Control: UMSG_ACKACK %d socket: 0x%x",
tvb_get_ntohl(tvb, 4),
tvb_get_ntohl(tvb, 12));
break;
default:
col_add_fstr(pinfo->cinfo, COL_INFO, "Control: %s socket: 0x%x",
val_to_str(type, srt_ctrlmsg_types,
"Unknown UDT Control Type (%x)"),
tvb_get_ntohl(tvb, 12));
break;
}
switch (type)
{
case UMSG_ACK:
case UMSG_ACKACK:
proto_tree_add_item(tree, hf_srt_ackno, tvb, 4, 4,
ENC_BIG_ENDIAN);
break;
case UMSG_DROPREQ:
proto_tree_add_item(tree, hf_srt_msgno, tvb, 4, 4,
ENC_BIG_ENDIAN);
break;
default:
proto_tree_add_item(tree, hf_srt_addinfo, tvb, 4, 4,
ENC_BIG_ENDIAN);
break;
}
proto_tree_add_item(tree, hf_srt_timestamp, tvb, 8, 4,
ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srt_id, tvb, 12, 4,
ENC_BIG_ENDIAN);
switch (type)
{
case UMSG_HANDSHAKE:
{
char ipbuf[IP_BUFFER_SIZE];
const int version = tvb_get_ntohl(tvb, 16);
const int final_length = tvb_reported_length(tvb);
int baselen = 64;
int handshake_reqtype;
/* This contains the handshake version (currently 4 or 5) */
proto_tree_add_item(tree, hf_srt_handshake_version, tvb,
16, 4, ENC_BIG_ENDIAN);
/* Version 4 embraces both HSv4 listener URQ_INDUCTION response
* and HSv5 caller URQ_INDUCTION request. In both these cases the
* value is interpreted as socket type (UDT legacy). With version 5
* the first message is the listener's URQ_INDUCTION response, where
* the layout in the type is already the MAGIC in the lower block,
* and ENC FLAGS in the upper block. The next caller's URQ_CONCLUSION
* will have SRT HS Extension block flags in the lower block.
*/
if (version == 4)
{
proto_tree_add_item(tree, hf_srt_handshake_type_v4, tvb,
20, 4, ENC_BIG_ENDIAN);
}
else
{
/* Both the PBKEYLEN-ad and magic are used in HSv5 induction. */
proto_tree_add_item(tree, hf_srt_handshake_enc_field_v5, tvb,
20, 2, ENC_BIG_ENDIAN);
dissect_srt_hs_ext_field(tree, tvb, 22); /* 2 bytes */
}
proto_tree_add_item(tree, hf_srt_handshake_isn, tvb,
24, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srt_handshake_mtu, tvb,
28, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srt_handshake_flow_window, tvb,
32, 4, ENC_BIG_ENDIAN);
handshake_reqtype = tvb_get_ntohl(tvb, 36);
if (handshake_reqtype < URQ_FAILURE_TYPES)
{
proto_tree_add_item(tree, hf_srt_handshake_reqtype, tvb,
36, 4, ENC_BIG_ENDIAN);
}
else
{
int error_code = handshake_reqtype - URQ_FAILURE_TYPES;
proto_tree_add_uint_format_value(tree, hf_srt_handshake_failure_type, tvb, 36, 4, handshake_reqtype,
"%d (%s)", error_code,
error_code < 1000 ? "SRT internal" :
error_code < 2000 ? "SRT predefined" : "user-defined");
}
proto_tree_add_item(tree, hf_srt_handshake_id, tvb,
40, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srt_handshake_cookie, tvb,
44, 4, ENC_BIG_ENDIAN);
srt_format_ip_address(ipbuf, sizeof ipbuf, (const gchar *)tvb_memdup(wmem_packet_scope(), tvb, 48, 16));
proto_tree_add_string(tree, hf_srt_handshake_peerip, tvb,
48, 16, ipbuf);
if (final_length > baselen)
{
/* Extract SRT handshake extension blocks
* and increase baselen accordingly.
*/
int begin = baselen;
for (;;)
{
const guint16 blockid = tvb_get_ntohs(tvb, begin);
const guint16 blocklen = tvb_get_ntohs(tvb, begin + 2);
proto_tree_add_item(tree, hf_srt_srths_blocktype, tvb,
begin, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srt_srths_blocklen, tvb,
begin+2, 2, ENC_BIG_ENDIAN);
// Shift to the payload
begin += 4;
switch (blockid)
{
case SRT_CMD_HSREQ:
case SRT_CMD_HSRSP:
if (blocklen == 3)
{
srt_format_hs_ext_hsreq(tree, tvb, begin);
}
else
{
/* blocklen should be 3, that corresponds to (3 * 4) = 12 bytes.
* Otherwise the format is unknown.*/
proto_tree_add_expert_format(tree, pinfo, &ei_srt_hs_ext_hsreq_len,
tvb, begin, 4 * blocklen, "Actual length is %u",
blocklen);
}
break;
case SRT_CMD_KMREQ:
case SRT_CMD_KMRSP:
// Rely on the extracted blocklen
srt_format_kmx(tree, tvb, begin, blocklen*4);
break;
case SRT_CMD_SID:
format_text_reorder_32(tree, tvb, hf_srt_srths_sid, begin, 4 * blocklen);
break;
case SRT_CMD_CONGESTCTRL:
format_text_reorder_32(tree, tvb, hf_srt_srths_congestcontrol, begin, 4 * blocklen);
break;
default:
proto_tree_add_expert_format(tree, pinfo, &ei_srt_hs_ext_type,
tvb, begin, 4 * blocklen, "Ext Type value is %u",
blockid);
break;
}
/* Move the index pointer past the block and repeat. */
begin += blocklen * 4;
/* OK, once one block is done, interrupt the loop. */
if (begin >= final_length)
break;
}
baselen = begin;
}
proto_item_set_len(srt_item, baselen);
}
break;
case UMSG_ACK:
{
guint len = tvb_reported_length(tvb);
proto_tree_add_item(tree, hf_srt_ack_seqno, tvb, 4 * 4, 4,
ENC_BIG_ENDIAN);
// Check for "Lite ACK" (size 4)
if (len <= (4 + 1) * 4)
{
proto_item_set_len(srt_item, (4 + 1) * 4);
}
else
{
proto_tree_add_item(tree, hf_srt_rtt, tvb, (4+1)*4, 4,
ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srt_rttvar, tvb, (4+2)*4, 4,
ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srt_bufavail, tvb, (4+3)*4, 4,
ENC_BIG_ENDIAN);
/* if not a light ack, decode the rate and link capacity */
if (len > (4 + 4) * 4)
{
proto_tree_add_item(tree, hf_srt_rate, tvb, (4 + 4) * 4, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srt_bandwidth, tvb, (4 + 5) * 4, 4, ENC_BIG_ENDIAN);
// SRT Extra data. This can be version dependent, so
// test the length for each field.
if (len > (4 + 6) * 4)
{
proto_tree_add_item(tree, hf_srt_rcvrate, tvb, (4 + 6) * 4, 4, ENC_BIG_ENDIAN);
len = (4 + 7) * 4;
}
proto_item_set_len(srt_item, (gint) len);
}
else
{
proto_item_set_len(srt_item, (4 + 4) * 4);
}
}
}
break;
case UMSG_DROPREQ:
{
guint len = tvb_reported_length(tvb);
if (len > (4 + 0) * 4)
{
guint lo = tvb_get_ntohl(tvb, (4 + 0) * 4);
guint hi = tvb_get_ntohl(tvb, (4 + 1) * 4);
proto_tree_add_expert_format(tree, pinfo, &ei_srt_nak_seqno,
tvb, 16, 8, "Drop sequence range: %u-%u",
lo, hi);
proto_item_set_len(srt_item, (gint) len);
}
}
break;
case UMSG_LOSSREPORT:
{
guint len = tvb_reported_length(tvb);
guint pos;
guint32 val;
guint prev = 0;
for (pos = 16; pos < len; pos += 4)
{
val = tvb_get_ntohl(tvb, pos);
if (val & SRT_LOSS_SEQUENCE_FIRST) {
// Remember this as a beginning range
prev = val;
continue;
}
// We have either a single value, or end-range here.
if (prev & SRT_LOSS_SEQUENCE_FIRST) {
// Was a range. Display as range and clear the state.
proto_tree_add_expert_format(tree, pinfo, &ei_srt_nak_seqno,
tvb, pos-4, 8, "Loss sequence range: %u-%u",
(prev & SRT_LOSS_SEQUENCE_MASK), val);
prev = 0;
} else {
// No from, so this is a freestanding loss value
proto_tree_add_expert_format(tree, pinfo, &ei_srt_nak_seqno,
tvb, pos, 4, "Loss sequence: %u", val);
}
}
// Report possible errors
if (prev)
{
proto_tree_add_expert_format(tree, pinfo, &ei_srt_nak_seqno,
tvb, pos-4, 4, "ERROR: loss sequence range begin only: %u (%x)",
val & SRT_LOSS_SEQUENCE_MASK, val);
}
proto_item_set_len(srt_item, len);
}
break;
case UMSG_EXT:
switch (exttype)
{
case SRT_CMD_HSREQ:
case SRT_CMD_HSRSP:
srt_format_hs_ext_hsreq(tree, tvb, 16);
break;
case SRT_CMD_KMREQ:
case SRT_CMD_KMRSP:
{
// This relies on value of HCRYPT_MSG_KM_MAX_SZ resulting from this above.
// Too strongly dependent on devel API, so using explicit 104.
int plen = tvb_reported_length(tvb) - 16;
if (plen > 104)
plen = 104;
srt_format_kmx(tree, tvb, 16, plen);
}
break;
default:
break;
}
break;
default:
// All other types have kinda "extra padding"
proto_tree_add_item(tree, hf_srt_addinfo, tvb, 16, 4, ENC_BIG_ENDIAN);
break;
}
}
/* Code to actually dissect the packets
*
* @return the amount of data this dissector was able to dissect
*/
static int
dissect_srt_udp(tvbuff_t *tvb, packet_info* pinfo, proto_tree *parent_tree,
void *data _U_)
{
/* Other misc. local variables. */
gboolean is_control = 0;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SRT");
col_clear (pinfo->cinfo, COL_INFO);
proto_item *srt_item = proto_tree_add_item(parent_tree, proto_srt, tvb,
0 /*start*/, -1 /*length*/, ENC_NA);
proto_tree *tree = proto_item_add_subtree(srt_item, ett_srt);
proto_tree_add_item_ret_boolean(tree, hf_srt_iscontrol, tvb, 0, 4, ENC_BIG_ENDIAN, &is_control);
if (is_control)
{
dissect_srt_control_packet(tvb, pinfo, tree, srt_item);
}
else
{
/* otherwise, a data packet */
tvbuff_t *next_tvb;
col_add_fstr(pinfo->cinfo, COL_INFO,
"DATA: seqno: %u msgno: %u socket: 0x%x",
tvb_get_ntohl(tvb, 0),
tvb_get_ntohl(tvb, 4) & SRT_MSGNO_MSGNO_MASK,
tvb_get_ntohl(tvb, 12));
if (tree)
{
// Sequence number
proto_tree_add_item(tree, hf_srt_seqno, tvb, 0, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srt_msgno_pb, tvb, 4, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srt_msgno_inorder, tvb, 4, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srt_msgno_enctypes, tvb, 4, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srt_msgno_rexmit, tvb, 4, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srt_msgno, tvb, 4, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srt_timestamp, tvb, 8, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srt_id, tvb, 12, 4, ENC_BIG_ENDIAN);
}
next_tvb = tvb_new_subset_remaining(tvb, 16);
call_data_dissector(next_tvb, pinfo, tree);
}
return tvb_reported_length(tvb);
}
static gboolean
dissect_srt_heur_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
conversation_t *conv;
/* Must have at least 24 captured bytes for heuristic check */
if (tvb_captured_length(tvb) < 24)
return FALSE;
/* detect handshake control packet */
if (tvb_get_ntohl(tvb, 0) != (0x80000000 | UMSG_HANDSHAKE))
return FALSE;
/* must be version 4 or 5*/
const guint32 version = tvb_get_ntohl(tvb, 16);
if (version != 4 && version != 5)
return FALSE;
/* SRT: must be DGRAM. STREAM is not supported in SRT */
if (version == 4 && tvb_get_ntohl(tvb, 20) != SRT_DGRAM)
return FALSE;
conv = find_or_create_conversation(pinfo);
conversation_set_dissector(conv, srt_udp_handle);
dissect_srt_udp(tvb, pinfo, tree, data);
return TRUE;
}
/* Register the protocol with Wireshark.
*
* This format is required because a script is used to build the C function that
* calls all the protocol registration.
*/
void proto_register_srt(void)
{
expert_module_t *expert_srt;
/* Setup list of header fields See Section 1.5 of README.dissector for
* details. */
static hf_register_info hf[] = {
{&hf_srt_iscontrol, {
"Content", "srt.iscontrol",
FT_BOOLEAN, 32,
TFS(&srt_packet_types), 0x80000000, NULL, HFILL }},
{&hf_srt_type, {
"Msg Type", "srt.type",
FT_UINT16, BASE_HEX,
VALS(srt_ctrlmsg_types), 0x7fff, NULL, HFILL}},
{&hf_srt_exttype, {
"Extended type", "srt.exttype",
FT_UINT16, BASE_HEX,
VALS(srt_ctrlmsg_exttypes), 0, NULL, HFILL}},
{&hf_srt_exttype_none, {
"(no extended type)", "srt.exttype_none",
FT_UINT16, BASE_HEX,
NULL, 0, NULL, HFILL}},
{&hf_srt_seqno, {
"Sequence Number", "srt.seqno",
FT_UINT32, BASE_DEC,
NULL, SRT_CONTROL_MASK, NULL, HFILL}},
{&hf_srt_addinfo, {
"(Unused)", "srt.addinfo",
FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL}},
{&hf_srt_msgno, {
"Message Number", "srt.msgno",
FT_UINT32, BASE_DEC,
NULL, SRT_MSGNO_MSGNO_MASK, NULL, HFILL}},
{&hf_srt_msgno_pb, {
"Packet Boundary", "srt.pb",
FT_UINT32, BASE_DEC,
VALS(srt_pb_types), SRT_MSGNO_FF_MASK, NULL, HFILL}},
{&hf_srt_msgno_inorder, {
"In-Order Indicator", "srt.msg.order",
FT_UINT32, BASE_DEC,
NULL, SRT_MSGNO_INORDER, NULL, HFILL}},
{&hf_srt_msgno_enctypes, {
"Encryption Status", "srt.msg.enc",
FT_UINT32, BASE_DEC,
VALS(srt_msgno_enctypes), SRT_MSGNO_ENCTYPE, NULL, HFILL }},
{&hf_srt_msgno_rexmit, {
"Sent as", "srt.msg.rexmit",
FT_BOOLEAN, 32,
TFS(&srt_msgno_rexmit), SRT_MSGNO_REXMIT, NULL, HFILL }},
{&hf_srt_timestamp, {
"Time Stamp", "srt.timestamp",
FT_UINT32, BASE_DEC_HEX,
NULL, 0, NULL, HFILL}},
{&hf_srt_id, {
"Destination Socket ID", "srt.id",
FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL}},
{&hf_srt_ack_seqno, {
"ACKD_RCVLASTACK", "srt.ack_seqno",
FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL}},
{&hf_srt_ackno, {
"Ack Number", "srt.ackno",
FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL}},
{&hf_srt_rtt, {
"ACKD_RTT", "srt.rtt",
FT_UINT32, BASE_DEC | BASE_UNIT_STRING,
&units_microseconds, 0, NULL, HFILL}},
{&hf_srt_rttvar, {
"ACKD_RTTVAR", "srt.rttvar",
FT_UINT32, BASE_DEC | BASE_UNIT_STRING,
&units_microseconds, 0, NULL, HFILL}},
{&hf_srt_bufavail, {
"ACKD_BUFFERLEFT", "srt.bufavail",
FT_UINT32, BASE_DEC | BASE_UNIT_STRING,
&units_pkts, 0, NULL, HFILL}},
{&hf_srt_rate, {
"ACKD_RCVSPEED", "srt.rate",
FT_UINT32, BASE_DEC | BASE_UNIT_STRING,
&units_pkts_per_sec, 0, NULL, HFILL}},
{&hf_srt_bandwidth, {
"ACKD_BANDWIDTH", "srt.bw",
FT_UINT32, BASE_DEC | BASE_UNIT_STRING,
&units_pkts_per_sec, 0, NULL, HFILL}},
{&hf_srt_rcvrate, {
"ACKD_RCVRATE", "srt.rcvrate",
FT_UINT32, BASE_DEC | BASE_UNIT_STRING,
&units_byte_bytespsecond, 0, NULL, HFILL}},
{&hf_srt_handshake_version, {
"Handshake Version", "srt.hs.version",
FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL}},
{&hf_srt_handshake_type_v4, {
"(Legacy) Socket type", "srt.hs.socktype",
FT_UINT32, BASE_DEC,
VALS(srt_hsv4_socket_types), 0, NULL,
HFILL}},
{&hf_srt_handshake_enc_field_v5, {
"Encryption Field", "srt.hs.encfield",
FT_UINT16, BASE_HEX,
VALS(srt_handshake_enc_field), 0, NULL,
HFILL}},
{&hf_srt_handshake_ext_field_v5, {
"Extended Field", "srt.hs.extfield",
FT_UINT16, BASE_HEX,
NULL, 0, NULL,
HFILL}},
{&hf_srt_handshake_ext_field_v5_flag_hsreq, {
"HS_EXT_FIELD_HSREQ", "srt.hs.extfield.hsreq",
FT_BOOLEAN, SRT_HS_V5_EXT_FIELD_LEN, TFS(&tfs_set_notset),
SRT_HS_V5_EXT_FIELD_HSREQ,
"Handshake request",
HFILL}},
{&hf_srt_handshake_ext_field_v5_flag_kmreq, {
"HS_EXT_FIELD_KMREQ", "srt.hs.extfield.kmreq",
FT_BOOLEAN, SRT_HS_V5_EXT_FIELD_LEN, TFS(&tfs_set_notset),
SRT_HS_V5_EXT_FIELD_KMREQ,
"KM request",
HFILL}},
{&hf_srt_handshake_ext_field_v5_flag_config, {
"HS_EXT_FIELD_CONFIG", "srt.hs.extfield.config",
FT_BOOLEAN, SRT_HS_V5_EXT_FIELD_LEN, TFS(&tfs_set_notset),
SRT_HS_V5_EXT_FIELD_CONFIG,
"Handshake has configuration",
HFILL}},
{&hf_srt_handshake_isn, {
"Initial Sequence Number", "srt.hs.isn",
FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL}},
{&hf_srt_handshake_mtu, {
"MTU", "srt.hs.mtu",
FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL}},
{&hf_srt_handshake_flow_window, {
"Flow Window", "srt.hs.flow_window",
FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL}},
{&hf_srt_handshake_reqtype, {
"Handshake Type", "srt.hs.reqtype",
FT_INT32, BASE_DEC,
VALS(srt_hs_request_types), 0, NULL, HFILL}},
{&hf_srt_handshake_failure_type, {
"Handshake FAULURE code", "srt.hs.reqtype",
FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL}},
{&hf_srt_handshake_id, {
"Socket ID", "srt.hs.id",
FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL}},
{&hf_srt_handshake_cookie, {
"SYN Cookie", "srt.hs.cookie",
FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL}},
{&hf_srt_handshake_peerip, {
/* FT_STRINGZ is used because the value
* is formatted to a temporary buffer first */
"Peer IP Address", "srt.hs.peerip",
FT_STRINGZ, BASE_NONE,
NULL, 0, NULL, HFILL}},
{&hf_srt_handshake_ext_version, {
"SRT Version", "srt.hs.version",
FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL}},
{&hf_srt_handshake_ext_flags, {
/* This uses custom format by appending the flag format string,
* while the value in hex is still printed. */
"SRT Flags", "srt.hs.srtflags",
FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL}},
{&hf_srt_handshake_ext_flag_tsbpd_snd, {
"TSBPDSND", "srt.hs.srtflags.tsbpd_snd",
FT_BOOLEAN, SRT_OPT_FIELD_LEN, TFS(&tfs_set_notset),
SRT_OPT_TSBPDSND,
"The party will be sending in TSBPD (Time Stamp Based Packet Delivery) mode",
HFILL}},
{&hf_srt_handshake_ext_flag_tsbpd_rcv, {
"TSBPDRCV", "srt.hs.srtflags.tsbpd_rcv",
FT_BOOLEAN, SRT_OPT_FIELD_LEN, TFS(&tfs_set_notset),
SRT_OPT_TSBPDRCV,
"The party expects to receive in TSBPD (Time Stamp Based Packet Delivery) mode",
HFILL}},
{&hf_srt_handshake_ext_flag_haicrypt, {
"HAICRYPT", "srt.hs.srtflags.haicrypt",
FT_BOOLEAN, SRT_OPT_FIELD_LEN, TFS(&tfs_set_notset),
SRT_OPT_HAICRYPT,
"The party includes haicrypt (legacy flag)",
HFILL}},
{&hf_srt_handshake_ext_flag_tlpkt_drop, {
"TLPKTDROP", "srt.hs.srtflags.tlpkt_drop",
FT_BOOLEAN, SRT_OPT_FIELD_LEN, TFS(&tfs_set_notset),
SRT_OPT_TLPKTDROP,
"The party will do the Too-Late Packet Drop",
HFILL}},
{&hf_srt_handshake_ext_flag_nak_report, {
"NAKREPORT", "srt.hs.srtflags.nak_report",
FT_BOOLEAN, SRT_OPT_FIELD_LEN, TFS(&tfs_set_notset),
SRT_OPT_NAKREPORT,
"The party will do periodic NAK reporting",
HFILL}},
{&hf_srt_handshake_ext_flag_rexmit, {
"REXMITFLG", "srt.hs.srtflags.rexmit",
FT_BOOLEAN, SRT_OPT_FIELD_LEN, TFS(&tfs_set_notset),
SRT_OPT_REXMITFLG,
"The party uses the REXMIT flag",
HFILL}},
{&hf_srt_handshake_ext_flag_stream, {
"STREAM", "srt.hs.srtflags.stream",
FT_BOOLEAN, SRT_OPT_FIELD_LEN, TFS(&tfs_set_notset),
SRT_OPT_STREAM,
"The party uses stream type transmission",
HFILL}},
{&hf_srt_srths_blocktype, {
"SRT HS Extension type", "srt.hs.blocktype",
FT_UINT16, BASE_HEX,
VALS(srt_ctrlmsg_exttypes), 0, NULL, HFILL}},
{&hf_srt_srths_blocklen, {
"SRT HS Extension size (4-byte blocks)", "srt.hs.blocklen",
FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL}},
{&hf_srt_srths_agent_latency, {
"Latency", "srt.hs.agent_latency",
FT_UINT16, BASE_DEC | BASE_UNIT_STRING,
&units_milliseconds, 0, NULL, HFILL}},
{&hf_srt_srths_peer_latency, {
"Peer Latency", "srt.hs.peer_latency",
FT_UINT16, BASE_DEC | BASE_UNIT_STRING,
&units_milliseconds, 0, NULL, HFILL}},
{&hf_srt_srtkm_msg, {
"KMX Message (or KM State if 4 bytes)", "srt.km.msg",
FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL}},
{&hf_srt_srtkm_error, {
"KM State", "srt.km.error",
FT_UINT32, BASE_DEC,
VALS(srt_enc_kmstate), 0, NULL, HFILL}},
{&hf_srt_srths_sid, {
"Stream ID", "srt.hs.sid",
FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL}},
{&hf_srt_srths_congestcontrol, {
"Congestion Control Type", "srt.hs.congestctrl",
FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL}}
};
static gint *ett[] = {
&ett_srt,
&ett_srt_handshake_ext_flags,
&ett_srt_handshake_ext_field_flags
};
static ei_register_info ei[] = {
{ &ei_srt_nak_seqno,
{ "srt.nak_seqno", PI_SEQUENCE, PI_NOTE,
"Missing Sequence Number(s)", EXPFILL }},
{ &ei_srt_hs_ext_hsreq_len,
{ "srt.hs.ext.hsreq", PI_PROTOCOL, PI_WARN,
"Unknown HS Ext HSREQ length", EXPFILL }},
{ &ei_srt_hs_ext_type,
{ "srt.hs.ext.type", PI_PROTOCOL, PI_WARN,
"Unknown HS Ext Type", EXPFILL }},
};
proto_srt = proto_register_protocol("SRT Protocol", "SRT", "srt");
proto_register_field_array(proto_srt, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_srt = expert_register_protocol(proto_srt);
expert_register_field_array(expert_srt, ei, array_length(ei));
register_dissector("srt", dissect_srt_udp, proto_srt);
}
void proto_reg_handoff_srt(void)
{
srt_udp_handle = create_dissector_handle(dissect_srt_udp, proto_srt);
/* register as heuristic dissector for UDP */
heur_dissector_add("udp", dissect_srt_heur_udp, "SRT over UDP",
"srt_udp", proto_srt, HEURISTIC_ENABLE);
/* Add a handle to the list of handles that *could* be used with this
table. That list is used by the "Decode As"/"-d" code in the UI. */
dissector_add_for_decode_as("udp.port", srt_udp_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-srvloc.c
|
/* packet-srvloc.c
* Routines for SRVLOC (Service Location Protocol) packet dissection
* Copyright 1999, James Coe <[email protected]>
* Copyright 2002, Brad Hards
* Updated for TCP segments by Greg Morris <[email protected]>
* Copyright 2003, Greg Morris
*
* NOTE: This is Alpha software not all features have been verified yet.
* In particular I have not had an opportunity to see how it
* responds to SRVLOC over TCP.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Service Location Protocol is RFC 2165
* Service Location Protocol Version 2 is RFC 2608
* - partial support by Brad Hards <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <stdlib.h> /* for strtoul() */
#include <epan/packet.h>
#include <epan/prefs.h>
#include "packet-tcp.h"
#include <epan/expert.h>
void proto_register_srvloc(void);
void proto_reg_handoff_srvloc(void);
static gboolean srvloc_desegment = TRUE;
static int proto_srvloc = -1;
static int hf_srvloc_version = -1;
static int hf_srvloc_function = -1;
static int hf_srvloc_pktlen = -1;
static int hf_srvloc_xid = -1;
static int hf_srvloc_langtaglen = -1;
static int hf_srvloc_langtag = -1;
static int hf_srvloc_nextextoff = -1;
static int hf_srvloc_flags_v1 = -1;
static int hf_srvloc_flags_v1_overflow = -1;
static int hf_srvloc_flags_v1_monolingual = -1;
static int hf_srvloc_flags_v1_url_auth = -1;
static int hf_srvloc_flags_v1_attribute_auth = -1;
static int hf_srvloc_flags_v1_fresh = -1;
static int hf_srvloc_error = -1;
static int hf_srvloc_flags_v2 = -1;
static int hf_srvloc_flags_v2_overflow = -1;
static int hf_srvloc_flags_v2_fresh = -1;
static int hf_srvloc_flags_v2_reqmulti = -1;
static int hf_srvloc_error_v2 = -1;
static int hf_srvloc_daadvert_timestamp = -1;
static int hf_srvloc_daadvert_urllen = -1;
static int hf_srvloc_daadvert_url = -1;
static int hf_srvloc_daadvert_scopelistlen = -1;
static int hf_srvloc_daadvert_scopelist = -1;
static int hf_srvloc_daadvert_attrlistlen = -1;
static int hf_srvloc_daadvert_attrlist = -1;
static int hf_srvloc_daadvert_slpspilen = -1;
static int hf_srvloc_daadvert_slpspi = -1;
static int hf_srvloc_daadvert_authcount = -1;
static int hf_srvloc_srvreq_prlistlen = -1;
static int hf_srvloc_srvreq_prlist = -1;
static int hf_srvloc_srvreq_srvtypelen = -1;
static int hf_srvloc_srvreq_srvtypelist = -1;
static int hf_srvloc_srvreq_scopelistlen = -1;
static int hf_srvloc_srvreq_scopelist = -1;
static int hf_srvloc_srvreq_predicatelen = -1;
static int hf_srvloc_srvreq_predicate = -1;
static int hf_srvloc_srvreq_slpspilen = -1;
static int hf_srvloc_srvreq_slpspi = -1;
static int hf_srvloc_srvrply_urlcount = -1;
static int hf_srvloc_srvreg_attrlistlen = -1;
static int hf_srvloc_srvreg_attrlist = -1;
static int hf_srvloc_srvreg_attrauthcount = -1;
static int hf_srvloc_srvreg_srvtypelen = -1;
static int hf_srvloc_srvreg_srvtype = -1;
static int hf_srvloc_srvreg_scopelistlen = -1;
static int hf_srvloc_srvreg_scopelist = -1;
static int hf_srvloc_srvdereg_scopelistlen = -1;
static int hf_srvloc_srvdereg_scopelist = -1;
static int hf_srvloc_srvdereg_taglistlen = -1;
static int hf_srvloc_srvdereg_taglist = -1;
static int hf_srvloc_attrreq_prlistlen = -1;
static int hf_srvloc_attrreq_prlist = -1;
static int hf_srvloc_attrreq_urllen = -1;
static int hf_srvloc_attrreq_url = -1;
static int hf_srvloc_attrreq_scopelistlen = -1;
static int hf_srvloc_attrreq_scopelist = -1;
static int hf_srvloc_attrreq_attrlistlen = -1;
static int hf_srvloc_attrreq_attrlist = -1;
static int hf_srvloc_attrreq_taglistlen = -1;
static int hf_srvloc_attrreq_taglist = -1;
static int hf_srvloc_attrreq_slpspilen = -1;
static int hf_srvloc_attrreq_slpspi = -1;
static int hf_srvloc_attrrply_attrlistlen = -1;
static int hf_srvloc_attrrply_attrlist = -1;
static int hf_srvloc_attrrply_attrauthcount = -1;
static int hf_srvloc_srvtypereq_prlistlen = -1;
static int hf_srvloc_srvtypereq_prlist = -1;
static int hf_srvloc_srvtypereq_nameauthlistlen = -1;
static int hf_srvloc_srvtypereq_nameauthlistlenall = -1;
static int hf_srvloc_srvtypereq_nameauthlist = -1;
static int hf_srvloc_srvtypereq_scopelistlen = -1;
static int hf_srvloc_srvtypereq_scopelist = -1;
static int hf_srvloc_srvtyperply_srvtypelen = -1;
static int hf_srvloc_srvtyperply_srvtype = -1;
static int hf_srvloc_srvtyperply_srvtypelistlen = -1;
static int hf_srvloc_srvtyperply_srvtypelist = -1;
static int hf_srvloc_saadvert_urllen = -1;
static int hf_srvloc_saadvert_url = -1;
static int hf_srvloc_saadvert_scopelistlen = -1;
static int hf_srvloc_saadvert_scopelist = -1;
static int hf_srvloc_saadvert_attrlistlen = -1;
static int hf_srvloc_saadvert_attrlist = -1;
static int hf_srvloc_saadvert_authcount = -1;
static int hf_srvloc_authblkv2_bsd = -1;
static int hf_srvloc_authblkv2_len = -1;
static int hf_srvloc_authblkv2_timestamp = -1;
static int hf_srvloc_authblkv2_slpspilen = -1;
static int hf_srvloc_authblkv2_slpspi = -1;
static int hf_srvloc_url_reserved = -1;
static int hf_srvloc_url_lifetime = -1;
static int hf_srvloc_url_urllen = -1;
static int hf_srvloc_url_url = -1;
static int hf_srvloc_url_numauths = -1;
static int hf_srvloc_add_ref_ip = -1;
static int hf_srvloc_srvrply_svcname = -1;
/* Generated from convert_proto_tree_add_text.pl */
static int hf_srvloc_timestamp = -1;
static int hf_srvloc_authentication_block = -1;
static int hf_srvloc_transaction_id = -1;
static int hf_srvloc_block_structure_descriptor = -1;
static int hf_srvloc_communication_type = -1;
static int hf_srvloc_language = -1;
static int hf_srvloc_socket = -1;
static int hf_srvloc_encoding = -1;
static int hf_srvloc_node = -1;
static int hf_srvloc_item = -1;
static int hf_srvloc_service_type = -1;
static int hf_srvloc_network = -1;
static int hf_srvloc_service_type_count = -1;
static int hf_srvloc_dialect = -1;
static int hf_srvloc_authenticator_length = -1;
static int hf_srvloc_protocol = -1;
static int hf_srvloc_port = -1;
static gint ett_srvloc = -1;
static gint ett_srvloc_attr = -1;
static gint ett_srvloc_flags = -1;
static expert_field ei_srvloc_error = EI_INIT;
static expert_field ei_srvloc_error_v2 = EI_INIT;
static expert_field ei_srvloc_function_unknown = EI_INIT;
static expert_field ei_srvloc_malformed = EI_INIT;
static const true_false_string tfs_srvloc_flags_overflow = {
"Message will not fit in datagram",
"Message will fit in a datagram"
};
static const true_false_string tfs_srvloc_flags_v1_monolingual = {
"Only responses in specified language will be accepted",
"Responses in any language will be accepted"
};
static const true_false_string tfs_srvloc_flags_v1_url_auth = {
"URL Authentication Block is present",
"URL Authentication Block is absent"
};
static const true_false_string tfs_srvloc_flags_v1_attribute_auth = {
"Attribute Authentication Block is present",
"Attribute Authentication Block is absent"
};
static const true_false_string tfs_srvloc_flags_fresh = {
"New Service Registration",
"Not a new Service Registration"
};
static const true_false_string tfs_srvloc_flags_v2_reqmulti = {
"Multicast (or broadcast) request",
"Not multicast or broadcast"
};
#define TCP_PORT_SRVLOC 427
#define UDP_PORT_SRVLOC 427
/* Define function types */
#define SRVREQ 1
#define SRVRPLY 2
#define SRVREG 3
#define SRVDEREG 4
#define SRVACK 5
#define ATTRRQST 6
#define ATTRRPLY 7
#define DAADVERT 8
#define SRVTYPERQST 9
#define SRVTYPERPLY 10
#define SAADVERT 11 /* SLPv2, section 8 */
/* Create protocol header structure */
/* bradh: looks like never used. */
/* bradh: comment it out for now since it doesn't work for v2
struct srvloc_hdr {
guint8 version;
guint8 function;
guint16 length;
guint8 flags;
guint8 dialect;
guchar language[2];
guint16 encoding;
guint16 xid;
};
*/
/* List to resolve function numbers to names */
static const value_string srvloc_functions[] = {
{ SRVREQ, "Service Request" },
{ SRVRPLY, "Service Reply" },
{ SRVREG, "Service Registration" },
{ SRVDEREG, "Service Deregister" },
{ SRVACK, "Service Acknowledge" },
{ ATTRRQST, "Attribute Request" },
{ ATTRRPLY, "Attribute Reply" },
{ DAADVERT, "DA Advertisement" },
{ SRVTYPERQST, "Service Type Request" },
{ SRVTYPERPLY, "Service Type Reply" },
{ SAADVERT, "SA Advertisement" }, /* v2 only */
{ 0, NULL }
};
/* List to resolve flag values to names */
/* Define flag masks */
#define FLAG_O 0x80
#define FLAG_M 0x40
#define FLAG_U 0x20
#define FLAG_A 0x10
#define FLAG_F 0x08
/* it all changes for Version 2 */
#define FLAG_O_V2 0x8000
#define FLAG_F_V2 0x4000
#define FLAG_R_V2 0x2000
/* Define Error Codes - Version 1*/
#define SUCCESS 0
#define LANG_NOT_SPTD 1
#define PROT_PARSE_ERR 2
#define INVLD_REG 3
#define SCOPE_NOT_SPTD 4
#define CHRSET_NOT_UND 5
#define AUTH_ABSENT 6
#define AUTH_FAILED 7
/* List to resolve error codes to names */
static const value_string srvloc_errs[] = {
{ SUCCESS, "No Error" },
{ LANG_NOT_SPTD, "Language not supported" },
{ PROT_PARSE_ERR, "Protocol parse error" },
{ INVLD_REG, "Invalid registration" },
{ SCOPE_NOT_SPTD, "Scope not supported" },
{ CHRSET_NOT_UND, "Character set not understood" },
{ AUTH_ABSENT, "Authentication absent" },
{ AUTH_FAILED, "Authentication failed" },
{ 0, NULL }
};
/* Define Error Codes for Version 2 */
#define LANGUAGE_NOT_SUPPORTED 1
#define PARSE_ERROR 2
#define INVALID_REGISTRATION 3
#define SCOPE_NOT_SUPPORTED 4
#define AUTHENTICATION_UNKNOWN 5
#define AUTHENTICATION_ABSENT 6
#define AUTHENTICATION_FAILED 7
#define VER_NOT_SUPPORTED 9
#define INTERNAL_ERROR 10
#define DA_BUSY_NOW 11
#define OPTION_NOT_UNDERSTOOD 12
#define INVALID_UPDATE 13
#define MSG_NOT_SUPPORTED 14
#define REFRESH_REJECTED 15
static const value_string srvloc_errs_v2[] = {
{ SUCCESS, "No Error" },
{ LANGUAGE_NOT_SUPPORTED, "No data in the requested language" },
{ PARSE_ERROR, "The message fails to obey SLP syntax." },
{ INVALID_REGISTRATION, "The SrvReg has problems" },
{ SCOPE_NOT_SUPPORTED, "Scope list not supported" },
{ AUTHENTICATION_UNKNOWN, "Unsupported SLP SPI." },
{ AUTHENTICATION_ABSENT, "URL and ATTR authentication not provided"},
{ AUTHENTICATION_FAILED, "Authentication error"},
{ VER_NOT_SUPPORTED, "Unsupported version number in message header" },
{ INTERNAL_ERROR, "The DA (or SA) is too sick to respond" },
{ DA_BUSY_NOW, "UA or SA SHOULD retry" },
{ OPTION_NOT_UNDERSTOOD, "Unknown option from the mandatory range"},
{ INVALID_UPDATE, "Invalid SrvReg" },
{ MSG_NOT_SUPPORTED, "No support for AttrRqst or SrvTypeRqst" },
{ REFRESH_REJECTED, "SrvReg sent too soon"},
{ 0, NULL }
};
/*
* Character encodings.
* This is a small subset of what's in
*
* http://www.iana.org/assignments/character-sets
*
* XXX - we should do something useful with this, i.e. properly
* handle strings based on the character set they're in.
*
* XXX - what does "properly handle strings" mean? How do we know
* what character set the terminal can handle (for tty-based code)
* or the GUI can handle (for GUI code)?
*
* XXX - the Wireshark core really should be what does all the
* character set handling for strings, and it should be stuck with
* the task of figuring out how to properly handle them.
*/
#define CHARSET_ASCII 3
#define CHARSET_ISO_10646_UTF_1 27
#define CHARSET_ISO_646_BASIC 28
#define CHARSET_ISO_646_IRV 30
#define CHARSET_ISO_8859_1 4
#define CHARSET_ISO_10646_UCS_2 1000 /* a/k/a Unicode */
#define CHARSET_UTF_7 1012
#define CHARSET_UTF_8 106
static const value_string charsets[] = {
{ CHARSET_ASCII, "US-ASCII" },
{ CHARSET_ISO_10646_UTF_1, "ISO 10646 UTF-1" },
{ CHARSET_ISO_646_BASIC, "ISO 646 basic:1983" },
{ CHARSET_ISO_646_IRV, "ISO 646 IRV:1983" },
{ CHARSET_ISO_8859_1, "ISO 8859-1" },
{ CHARSET_ISO_10646_UCS_2, "Unicode" },
{ CHARSET_UTF_7, "UTF-7" },
{ CHARSET_UTF_8, "UTF-8" },
{ 0, NULL }
};
static int
dissect_authblk(tvbuff_t *tvb, int offset, proto_tree *tree)
{
guint16 length;
proto_tree_add_item(tree, hf_srvloc_timestamp, tvb, offset, 8, ENC_TIME_NTP|ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srvloc_block_structure_descriptor, tvb, offset + 8, 2, ENC_BIG_ENDIAN);
length = tvb_get_ntohs(tvb, offset + 10);
proto_tree_add_item(tree, hf_srvloc_authenticator_length, tvb, offset + 10, 2, ENC_BIG_ENDIAN);
offset += 12;
proto_tree_add_item(tree, hf_srvloc_authentication_block, tvb, offset, length, ENC_NA|ENC_ASCII);
offset += length;
return offset;
}
/* SLPv2 version - Needs to be fixed to match RFC2608 sect 9.2*/
static int
dissect_authblk_v2(tvbuff_t *tvb, int offset, proto_tree *tree)
{
guint16 length;
proto_tree_add_item(tree, hf_srvloc_authblkv2_bsd, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srvloc_authblkv2_len, tvb, offset+2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_srvloc_authblkv2_timestamp, tvb, offset+4, 4, ENC_TIME_SECS|ENC_BIG_ENDIAN);
length = tvb_get_ntohs(tvb, offset + 8);
proto_tree_add_uint(tree, hf_srvloc_authblkv2_slpspilen, tvb, offset + 8, 2, length);
offset += 10;
proto_tree_add_item(tree, hf_srvloc_authblkv2_slpspi, tvb, offset, length, ENC_ASCII);
offset += length;
/* add code in here to handle Structured Authentication Block */
return offset;
}
static int
dissect_attrauthblk_v2(tvbuff_t *tvb _U_, int offset, proto_tree *tree _U_)
{
/* add code in here to handle attribute authentication */
return offset;
}
static void
add_v1_string(proto_tree *tree, int hf, tvbuff_t *tvb, int offset, int length,
guint16 encoding)
{
switch (encoding) {
case CHARSET_ISO_10646_UCS_2:
proto_tree_add_item(tree, hf, tvb, offset, length, ENC_UCS_2|ENC_BIG_ENDIAN);
break;
default:
/* XXX - need to support all the CHARSET_ values */
proto_tree_add_item(tree, hf, tvb, offset, length, ENC_ASCII|ENC_NA);
break;
}
}
/*
* XXX - is this trying to guess the byte order?
*
* http://www.iana.org/assignments/character-sets
*
* says of ISO-10646-UCS-2, which has the code 1000 (this routine is used
* with CHARSET_ISO_10646_UCS_2, which is #defined to be 1000):
*
* this needs to specify network byte order: the standard
* does not specify (it is a 16-bit integer space)
*
* Does that mean that in SRVLOC, ISO-10646-UCS-2 is always big-endian?
* If so, can we just use "tvb_get_string_enc()" and be
* done with it?
*
* XXX - this is also used with CHARSET_UTF_8. Is that a cut-and-pasteo?
*/
static const guint8*
unicode_to_bytes(tvbuff_t *tvb, int offset, int length, gboolean endianness)
{
const guint8 *ascii_text = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII);
int i, j = 0;
guint8 c_char, c_char1;
guint8 *byte_array;
/* XXX - Is this the correct behavior? */
if (length < 1)
return "";
if (endianness) {
byte_array = (guint8 *)wmem_alloc(wmem_packet_scope(), length*2 + 1);
for (i = length; i > 0; i--) {
c_char = ascii_text[i];
if (c_char != 0) {
if (i == 0)
break;
i--;
c_char1 = ascii_text[i];
if (c_char1 == 0) {
if (i == 0)
break;
i--;
c_char1 = ascii_text[i];
}
byte_array[j] = c_char1;
j++;
byte_array[j] = c_char;
j++;
}
}
}
else
{
byte_array = (guint8 *)wmem_alloc(wmem_packet_scope(), length + 1);
for (i = 0; i < length; i++) {
c_char = ascii_text[i];
if (c_char != 0) {
byte_array[j] = c_char;
j++;
}
}
}
byte_array[j]=0;
return byte_array;
}
/*
* Format of x-x-x-xxxxxxxx. Each of these entries represents the service binding to UDP, TCP, or IPX.
* The first digit is the protocol family: 2 for TCP/UPD, 6 for IPX.
* The second digit is the socket type: 1 for socket stream (TCP), 2 for datagram (UDP and IPX).
* The third is the protocol: 6 for TCP, 17 for UDP, and 1000 for IPX.
* Last is the IP address, in hex, of the interface that is registered (or, in the case of IPX, an IPX network number).
*
* OpenSLP supports multiple attribute replies so we need to parse the attribute name and then decode accordingly.
* We currently only parse the (non-utf8) attributes:
* svcname
* svcaddr
*/
static const value_string srvloc_svc[] = {
{ 50, "TCP/UDP" },
{ 54, "IPX" },
{ 0, NULL }
};
static const value_string srvloc_ss[] = {
{ 49, "Socket" },
{ 50, "Datagram" },
{ 0, NULL }
};
static const value_string srvloc_prot[] = {
{ 54, "TCP" },
{ 17, "UDP" },
{ 1000, "IPX" },
{ 0, NULL }
};
static void
attr_list(proto_tree *tree, packet_info* pinfo, int hf, tvbuff_t *tvb, int offset, int length,
guint16 encoding)
{
const char *attr_type;
int i, svc, type_len, foffset=offset;
guint32 prot;
const guint8 *byte_value;
proto_tree *srvloc_tree;
proto_item *ti;
char *tmp;
switch (encoding) {
case CHARSET_ISO_10646_UCS_2:
while (offset+2<length) {
offset += 2;
/* If the length passed is longer then the actual payload then this must be an incomplete packet. */
if (tvb_reported_length_remaining(tvb, 4)<length) {
proto_tree_add_expert(tree, pinfo, &ei_srvloc_malformed, tvb, offset, -1);
break;
}
/* Parse the attribute name */
tmp = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length-offset, ENC_UCS_2|ENC_BIG_ENDIAN);
type_len = (int)strcspn(tmp, "=");
attr_type = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, type_len*2, ENC_UCS_2|ENC_BIG_ENDIAN);
proto_tree_add_string(tree, hf, tvb, offset, type_len*2, attr_type);
offset += (type_len*2)+2;
if (strcmp(attr_type, "svcname-ws")==0) {
/* This is the attribute svcname */
tmp = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length-offset, ENC_UCS_2|ENC_BIG_ENDIAN);
type_len = (int)strcspn(tmp, ")");
add_v1_string(tree, hf_srvloc_srvrply_svcname, tvb, offset, type_len*2, encoding);
offset += (type_len*2)+4;
attr_type = "";
} else if (strcmp(attr_type, "svcaddr-ws")==0) {
/* This is the attribute svcaddr */
i=1;
for (foffset = offset; foffset<length; foffset += 2) {
srvloc_tree = proto_tree_add_subtree_format(tree, tvb, foffset, -1, ett_srvloc_attr, NULL, "Item %d", i);
svc = tvb_get_guint8(tvb, foffset+1);
proto_tree_add_item(srvloc_tree, hf_srvloc_service_type, tvb, foffset+1, 1, ENC_NA);
proto_tree_add_item(srvloc_tree, hf_srvloc_communication_type, tvb, foffset+5, 1, ENC_NA);
foffset += 9;
if (svc == 50) {
if (tvb_get_guint8(tvb, foffset)==54) { /* TCP */
proto_tree_add_item(srvloc_tree, hf_srvloc_protocol, tvb, foffset, 1, ENC_NA);
foffset += 2;
}
else
{
byte_value = unicode_to_bytes(tvb, foffset, 4, FALSE); /* UDP */
prot = (guint32)strtoul(byte_value, NULL, 10);
proto_tree_add_uint(srvloc_tree, hf_srvloc_protocol, tvb, foffset, 4, prot);
foffset += 4;
}
}
else
{
byte_value = unicode_to_bytes(tvb, foffset, 8, FALSE); /* IPX */
prot = (guint32)strtoul(byte_value, NULL, 10);
ti = proto_tree_add_uint(srvloc_tree, hf_srvloc_protocol, tvb, foffset, 4, prot);
proto_item_set_len(ti, 8);
foffset += 8;
}
if (svc == 50) {
byte_value = unicode_to_bytes(tvb, foffset, 16, TRUE); /* IP Address */
prot = (guint32)strtoul(byte_value, NULL, 16);
proto_tree_add_ipv4(srvloc_tree, hf_srvloc_add_ref_ip, tvb, foffset+2, 16, prot);
byte_value = unicode_to_bytes(tvb, foffset+18, 8, FALSE); /* Port */
prot = (guint32)strtoul(byte_value, NULL, 16);
ti = proto_tree_add_uint(srvloc_tree, hf_srvloc_port, tvb, foffset+18, 4, prot);
proto_item_set_len(ti, 8);
}
else
{
byte_value = unicode_to_bytes(tvb, foffset+2, 16, FALSE); /* IPX Network Address */
prot = (guint32)strtoul(byte_value, NULL, 16);
ti = proto_tree_add_uint(srvloc_tree, hf_srvloc_network, tvb, foffset+2, 4, prot);
proto_item_set_len(ti, 16);
byte_value = unicode_to_bytes(tvb, foffset+18, 24, FALSE); /* IPX Node Address */
prot = (guint32)strtoul(byte_value, NULL, 16);
ti = proto_tree_add_uint(srvloc_tree, hf_srvloc_node, tvb, foffset+18, 4, prot);
proto_item_set_len(ti, 24);
byte_value = unicode_to_bytes(tvb, foffset+42, 8, FALSE); /* Socket */
prot = (guint32)strtoul(byte_value, NULL, 16);
ti = proto_tree_add_uint(srvloc_tree, hf_srvloc_socket, tvb, foffset+42, 4, prot);
proto_item_set_len(ti, 8);
}
i++;
foffset += 57;
}
offset = foffset;
attr_type = "";
}
/* If there are no more supported attributes available then abort dissection */
if (strcmp(attr_type, "svcaddr-ws")!=0 && strcmp(attr_type, "svcname-ws")!=0 && strcmp(attr_type, "")!=0) {
break;
}
}
break;
case CHARSET_UTF_8:
type_len = (int)strcspn(tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII), "=");
attr_type = unicode_to_bytes(tvb, offset+1, type_len-1, FALSE);
proto_tree_add_string(tree, hf, tvb, offset+1, type_len-1, attr_type);
i=1;
for (foffset = offset + (type_len); foffset<length; foffset++) {
srvloc_tree = proto_tree_add_subtree_format(tree, tvb, foffset, -1, ett_srvloc_attr, NULL, "Item %d", i);
svc = tvb_get_guint8(tvb, foffset+1);
proto_tree_add_item(srvloc_tree, hf_srvloc_service_type, tvb, foffset+1, 1, ENC_NA);
proto_tree_add_item(srvloc_tree, hf_srvloc_communication_type, tvb, foffset+3, 1, ENC_NA);
foffset += 5;
if (svc == 50) {
if (tvb_get_guint8(tvb, foffset)==54) { /* TCP */
proto_tree_add_item(srvloc_tree, hf_srvloc_protocol, tvb, foffset, 1, ENC_NA);
foffset += 1;
}
else
{
/* UDP */
byte_value = unicode_to_bytes(tvb, foffset, 2, FALSE); /* UDP */
prot = (guint32)strtoul(byte_value, NULL, 10);
proto_tree_add_uint(srvloc_tree, hf_srvloc_protocol, tvb, foffset, 2, prot);
foffset += 2;
}
}
else
{
byte_value = unicode_to_bytes(tvb, foffset, 4, FALSE); /* IPX */
prot = (guint32)strtoul(byte_value, NULL, 10);
proto_tree_add_uint(srvloc_tree, hf_srvloc_protocol, tvb, foffset, 4, prot);
foffset += 4;
}
if (svc == 50) {
byte_value = unicode_to_bytes(tvb, foffset, 8, TRUE); /* IP Address */
prot = (guint32)strtoul(byte_value, NULL, 16);
proto_tree_add_ipv4(srvloc_tree, hf_srvloc_add_ref_ip, tvb, foffset+1, 8, prot);
byte_value = unicode_to_bytes(tvb, foffset+9, 4, FALSE); /* Port */
prot = (guint32)strtoul(byte_value, NULL, 16);
proto_tree_add_uint(srvloc_tree, hf_srvloc_port, tvb, foffset+9, 4, prot);
}
else
{
byte_value = unicode_to_bytes(tvb, foffset+1, 8, FALSE); /* IPX Network Address */
prot = (guint32)strtoul(byte_value, NULL, 16);
ti = proto_tree_add_uint(srvloc_tree, hf_srvloc_network, tvb, foffset+1, 4, prot);
proto_item_set_len(ti, 8);
byte_value = unicode_to_bytes(tvb, foffset+9, 12, FALSE); /* IPX Node Address */
prot = (guint32)strtoul(byte_value, NULL, 16);
ti = proto_tree_add_uint(srvloc_tree, hf_srvloc_node, tvb, foffset+9, 4, prot);
proto_item_set_len(ti, 12);
byte_value = unicode_to_bytes(tvb, foffset+21, 4, FALSE); /* Socket */
prot = (guint32)strtoul(byte_value, NULL, 16);
proto_tree_add_uint(srvloc_tree, hf_srvloc_socket, tvb, foffset+21, 4, prot);
}
i++;
foffset += 28;
}
break;
default:
/* XXX - need to handle specific encodings */
proto_tree_add_item(tree, hf, tvb, offset, length, ENC_ASCII|ENC_NA);
break;
}
}
static void
attr_list2(proto_tree *tree, int hf, tvbuff_t *tvb, int offset, int length, guint16 encoding _U_)
{
guint8 *start;
guint8 c;
guint32 x;
guint32 cnt;
proto_item *ti;
proto_tree *attr_tree;
/* if we were to decode:
* For slp, these 9 characters: (),\!<=>~ and 0x00-1F, 0x7f are reserved and must be escaped in the form \HH
*/
/* create a sub tree for attributes */
/* XXX - is this always ASCII, or what? */
ti = proto_tree_add_item(tree, hf, tvb, offset, length, ENC_ASCII|ENC_NA);
attr_tree = proto_item_add_subtree(ti, ett_srvloc_attr);
/* this will ensure there is a terminating null */
start = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII);
cnt = 0;
x = 0;
c = start[x];
while (c) {
if (c == ',') {
cnt++; /* Attribute count */
start[x] = 0;
proto_tree_add_string_format(attr_tree, hf_srvloc_item, tvb, offset, x, start, "Item %d: %s", cnt, start);
offset += x+1;
start += x+1;
/* reset string length */
x = 0;
c = start[x];
} else {
/* increment and get next */
x++;
c = start[x];
}
}
/* display anything remaining */
if (x) {
cnt++;
proto_tree_add_string_format(attr_tree, hf_srvloc_item, tvb, offset, x, start, "Item %d: %s", cnt, start);
}
}
static int
dissect_url_entry_v1(tvbuff_t *tvb, int offset, proto_tree *tree,
guint16 encoding, guint16 flags)
{
guint16 url_len;
proto_tree_add_item(tree, hf_srvloc_url_lifetime, tvb, offset, 2,
ENC_BIG_ENDIAN);
offset += 2;
url_len = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(tree, hf_srvloc_url_urllen, tvb, offset, 2,
url_len);
offset += 2;
add_v1_string(tree, hf_srvloc_url_url, tvb, offset, url_len, encoding);
offset += url_len;
if ( (flags & FLAG_U) == FLAG_U )
offset = dissect_authblk(tvb, offset, tree);
return offset;
}
static int
dissect_url_entry_v2(tvbuff_t *tvb, int offset, proto_tree *tree)
{
guint8 reserved;
guint16 url_len;
guint8 num_auths;
reserved = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_srvloc_url_reserved, tvb, offset, 1,
reserved);
offset += 1;
proto_tree_add_item(tree, hf_srvloc_url_lifetime, tvb, offset, 2,
ENC_BIG_ENDIAN);
offset += 2;
url_len = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(tree, hf_srvloc_url_urllen, tvb, offset, 2,
url_len);
offset += 2;
proto_tree_add_item(tree, hf_srvloc_url_url, tvb, offset, url_len, ENC_ASCII);
offset += url_len;
num_auths = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_srvloc_url_numauths, tvb, offset, 1,
num_auths);
offset += 1;
while (num_auths > 0) {
offset = dissect_authblk_v2(tvb, offset, tree);
num_auths--;
}
return offset;
}
/* Packet dissection routine called by tcp & udp when port 427 detected */
static int
dissect_srvloc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
int offset = 0;
proto_item *ti;
proto_tree *srvloc_tree;
guint8 version;
guint8 function;
guint16 encoding;
guint32 length; /* three bytes needed for v2 */
guint16 flags; /* two byes needed for v2 */
guint32 count;
guint32 next_ext_off; /* three bytes, v2 only */
guint16 lang_tag_len;
proto_item *expert_item;
guint16 expert_status;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SRVLOC");
col_clear(pinfo->cinfo, COL_INFO);
version = tvb_get_guint8(tvb, offset);
function = tvb_get_guint8(tvb, offset + 1);
col_add_str(pinfo->cinfo, COL_INFO,
val_to_str(function, srvloc_functions, "Unknown Function (%u)"));
ti = proto_tree_add_item(tree, proto_srvloc, tvb, offset, -1, ENC_NA);
srvloc_tree = proto_item_add_subtree(ti, ett_srvloc);
proto_tree_add_uint(srvloc_tree, hf_srvloc_version, tvb, offset, 1,
version);
proto_tree_add_uint(srvloc_tree, hf_srvloc_function, tvb, offset + 1, 1,
function);
if (version < 2) {
static int * const v1_flags[] = {
&hf_srvloc_flags_v1_overflow,
&hf_srvloc_flags_v1_monolingual,
&hf_srvloc_flags_v1_url_auth,
&hf_srvloc_flags_v1_attribute_auth,
&hf_srvloc_flags_v1_fresh,
NULL
};
length = tvb_get_ntohs(tvb, offset + 2);
proto_tree_add_uint(srvloc_tree, hf_srvloc_pktlen, tvb, offset + 2, 2,
length);
flags = tvb_get_guint8(tvb, offset + 4);
proto_tree_add_bitmask(srvloc_tree, tvb, offset + 4, hf_srvloc_flags_v1, ett_srvloc_flags, v1_flags, ENC_NA);
proto_tree_add_item(srvloc_tree, hf_srvloc_dialect, tvb, offset + 5, 1, ENC_NA);
proto_tree_add_item(srvloc_tree, hf_srvloc_language, tvb, offset + 6, 2, ENC_NA|ENC_ASCII);
encoding = tvb_get_ntohs(tvb, offset + 8);
proto_tree_add_item(srvloc_tree, hf_srvloc_encoding, tvb, offset + 8, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(srvloc_tree, hf_srvloc_transaction_id, tvb, offset + 10, 2, ENC_BIG_ENDIAN);
/* added echo of XID to info column by Greg Morris 0ct 14, 2005 */
col_append_fstr(pinfo->cinfo, COL_INFO, ", V1 Transaction ID - %u", tvb_get_ntohs(tvb, offset + 10));
offset += 12;
switch (function) {
case SRVREQ:
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvreq_prlistlen, tvb, offset, 2, length);
offset += 2;
add_v1_string(srvloc_tree, hf_srvloc_srvreq_prlist, tvb, offset, length, encoding);
offset += length;
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvreq_predicatelen, tvb, offset, 2, length);
offset += 2;
add_v1_string(srvloc_tree, hf_srvloc_srvreq_predicate, tvb, offset, length, encoding);
offset += length;
break;
case SRVRPLY:
expert_item = proto_tree_add_item(srvloc_tree, hf_srvloc_error, tvb, offset, 2, ENC_BIG_ENDIAN);
expert_status = tvb_get_ntohs(tvb, offset);
if (expert_status!=0) {
expert_add_info_format(pinfo, expert_item, &ei_srvloc_error, "Error: %s", val_to_str(expert_status, srvloc_errs, "Unknown SRVLOC Error (0x%02x)"));
}
offset += 2;
count = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvrply_urlcount, tvb, offset, 2, count);
offset += 2;
while (count > 0) {
offset = dissect_url_entry_v1(tvb, offset, srvloc_tree,
encoding, flags);
count--;
}
break;
case SRVREG:
offset = dissect_url_entry_v1(tvb, offset, srvloc_tree, encoding,
flags);
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvreg_attrlistlen, tvb, offset, 2, length);
offset += 2;
add_v1_string(srvloc_tree, hf_srvloc_srvreg_attrlist, tvb, offset, length, encoding);
offset += length;
if ( (flags & FLAG_A) == FLAG_A )
offset = dissect_authblk(tvb, offset, srvloc_tree);
break;
case SRVDEREG:
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(tree, hf_srvloc_url_urllen, tvb, offset, 2, length);
offset += 2;
add_v1_string(tree, hf_srvloc_url_url, tvb, offset, length, encoding);
offset += length;
if ( (flags & FLAG_U) == FLAG_U )
offset = dissect_authblk(tvb, offset, srvloc_tree);
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvdereg_taglistlen, tvb, offset, 2, length);
offset += 2;
add_v1_string(srvloc_tree, hf_srvloc_srvdereg_taglist, tvb, offset, length, encoding);
offset += length;
/*
* XXX - this was there before, but RFC 2165 doesn't speak
* of there being an attribute authentication block in
* a Service Deregister message. Is that a post-RFC-2165
* addition?
*/
if ( (flags & FLAG_A) == FLAG_A )
offset = dissect_authblk(tvb, offset, srvloc_tree);
break;
case SRVACK:
expert_item = proto_tree_add_item(srvloc_tree, hf_srvloc_error, tvb, offset, 2, ENC_BIG_ENDIAN);
expert_status = tvb_get_ntohs(tvb, offset);
if (expert_status!=0) {
expert_add_info_format(pinfo, expert_item, &ei_srvloc_error, "Error: %s", val_to_str(expert_status, srvloc_errs, "Unknown SRVLOC Error (0x%02x)"));
}
offset += 2;
break;
case ATTRRQST:
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_attrreq_prlistlen, tvb, offset, 2, length);
offset += 2;
add_v1_string(srvloc_tree, hf_srvloc_attrreq_prlist, tvb, offset, length, encoding);
offset += length;
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_attrreq_urllen, tvb, offset, 2, length);
offset += 2;
add_v1_string(srvloc_tree, hf_srvloc_attrreq_url, tvb, offset, length, encoding);
offset += length;
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_attrreq_scopelistlen, tvb, offset, 2, length);
offset += 2;
add_v1_string(srvloc_tree, hf_srvloc_attrreq_scopelist, tvb, offset, length, encoding);
offset += length;
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_attrreq_attrlistlen, tvb, offset, 2, length);
offset += 2;
add_v1_string(srvloc_tree, hf_srvloc_attrreq_attrlist, tvb, offset, length, encoding);
offset += length;
break;
case ATTRRPLY:
expert_item = proto_tree_add_item(srvloc_tree, hf_srvloc_error_v2, tvb, offset, 2, ENC_BIG_ENDIAN);
expert_status = tvb_get_ntohs(tvb, offset);
if (expert_status!=0) {
expert_add_info_format(pinfo, expert_item, &ei_srvloc_error, "Error: %s", val_to_str(expert_status, srvloc_errs_v2, "Unknown SRVLOC Error (0x%02x)"));
}
offset += 2;
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_attrrply_attrlistlen, tvb, offset, 2, length);
if (length > 0) {
offset += 2;
attr_list(srvloc_tree, pinfo, hf_srvloc_attrrply_attrlist, tvb, offset, length, encoding);
offset += length;
if ( (flags & FLAG_A) == FLAG_A )
offset = dissect_authblk(tvb, offset, srvloc_tree);
}
break;
case DAADVERT:
expert_item = proto_tree_add_item(srvloc_tree, hf_srvloc_error, tvb, offset, 2, ENC_BIG_ENDIAN);
expert_status = tvb_get_ntohs(tvb, offset);
if (expert_status!=0) {
expert_add_info_format(pinfo, expert_item, &ei_srvloc_error, "Error: %s", val_to_str(expert_status, srvloc_errs, "Unknown SRVLOC Error (0x%02x)"));
}
offset += 2;
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_daadvert_urllen, tvb, offset, 2, length);
offset += 2;
add_v1_string(srvloc_tree, hf_srvloc_daadvert_url, tvb, offset, length, encoding);
offset += length;
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_daadvert_scopelistlen, tvb, offset, 2, length);
offset += 2;
add_v1_string(srvloc_tree, hf_srvloc_daadvert_scopelist, tvb, offset, length, encoding);
offset += length;
break;
case SRVTYPERQST:
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtypereq_prlistlen, tvb, offset, 2, length);
offset += 2;
add_v1_string(srvloc_tree, hf_srvloc_srvtypereq_prlist, tvb, offset, length, encoding);
offset += length;
length = tvb_get_ntohs(tvb, offset);
/* Updated by Greg Morris on 1-30-04 */
if (0xFFFF == length) {
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtypereq_nameauthlistlenall, tvb, offset, 2, length);
offset += 2;
}
else
{
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtypereq_nameauthlistlen, tvb, offset, 2, length);
offset += 2;
add_v1_string(srvloc_tree, hf_srvloc_srvtypereq_nameauthlist, tvb, offset, length, encoding);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtypereq_scopelistlen, tvb, offset, 2, length);
offset += 2;
add_v1_string(srvloc_tree, hf_srvloc_srvtypereq_scopelist, tvb, offset, length, encoding);
offset += length;
break;
case SRVTYPERPLY:
expert_item = proto_tree_add_item(srvloc_tree, hf_srvloc_error, tvb, offset, 2, ENC_BIG_ENDIAN);
expert_status = tvb_get_ntohs(tvb, offset);
if (expert_status!=0) {
expert_add_info_format(pinfo, expert_item, &ei_srvloc_error, "Error: %s", val_to_str(expert_status, srvloc_errs, "Unknown SRVLOC Error (0x%02x)"));
}
offset += 2;
count = tvb_get_ntohs(tvb, offset);
proto_tree_add_item(srvloc_tree, hf_srvloc_service_type_count, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
while (count > 0) {
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtyperply_srvtypelen, tvb, offset, 2, length);
offset += 2;
add_v1_string(srvloc_tree, hf_srvloc_srvtyperply_srvtype, tvb, offset, length, encoding);
offset += length;
count--;
}
break;
default:
proto_tree_add_expert_format(srvloc_tree, pinfo, &ei_srvloc_function_unknown,
tvb, offset, -1, "Unknown Function Type: %d", function);
}
}
else { /* Version 2 */
static int * const v2_flags[] = {
&hf_srvloc_flags_v2_overflow,
&hf_srvloc_flags_v2_fresh,
&hf_srvloc_flags_v2_reqmulti,
NULL
};
proto_tree_add_item_ret_uint(srvloc_tree, hf_srvloc_pktlen, tvb, offset + 2, 3, ENC_BIG_ENDIAN, &length);
proto_tree_add_bitmask(srvloc_tree, tvb, offset + 5, hf_srvloc_flags_v2, ett_srvloc_flags, v2_flags, ENC_BIG_ENDIAN);
proto_tree_add_item_ret_uint(srvloc_tree, hf_srvloc_nextextoff, tvb, offset + 7, 3,
ENC_BIG_ENDIAN, &next_ext_off);
proto_tree_add_item(srvloc_tree, hf_srvloc_xid, tvb, offset + 10, 2, ENC_BIG_ENDIAN);
col_append_fstr(pinfo->cinfo, COL_INFO, ", V2 XID - %u", tvb_get_ntohs(tvb, offset + 10));
lang_tag_len = tvb_get_ntohs(tvb, offset + 12);
proto_tree_add_uint(srvloc_tree, hf_srvloc_langtaglen, tvb, offset + 12, 2, lang_tag_len);
proto_tree_add_item(srvloc_tree, hf_srvloc_langtag, tvb, offset + 14, lang_tag_len, ENC_ASCII);
offset += 14+lang_tag_len;
switch (function) {
case SRVREQ: /* RFC2608 8.1 */
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvreq_prlistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_srvreq_prlist, tvb, offset, length, ENC_ASCII);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvreq_srvtypelen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_srvreq_srvtypelist, tvb, offset, length, ENC_ASCII);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvreq_scopelistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_srvreq_scopelist, tvb, offset, length, ENC_ASCII);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvreq_predicatelen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_srvreq_predicate, tvb, offset, length, ENC_ASCII);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvreq_slpspilen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_srvreq_slpspi, tvb, offset, length, ENC_ASCII);
offset += length;
}
break;
case SRVRPLY: /* RFC2608 8.2 */
expert_item = proto_tree_add_item(srvloc_tree, hf_srvloc_error_v2, tvb, offset, 2, ENC_BIG_ENDIAN);
expert_status = tvb_get_ntohs(tvb, offset);
if (expert_status!=0) {
expert_add_info_format(pinfo, expert_item, &ei_srvloc_error_v2, "Error: %s", val_to_str(expert_status, srvloc_errs_v2, "Unknown SRVLOC Error (0x%02x)"));
}
offset += 2;
count = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvrply_urlcount, tvb, offset, 2, count);
offset += 2;
while (count > 0) {
offset = dissect_url_entry_v2(tvb, offset, srvloc_tree);
count--;
}
break;
case SRVREG: /* RFC2608 8.3 */
offset = dissect_url_entry_v2(tvb, offset, srvloc_tree);
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvreg_srvtypelen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_srvreg_srvtype, tvb, offset, length, ENC_ASCII);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvreg_scopelistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_srvreg_scopelist, tvb, offset, length, ENC_ASCII);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvreg_attrlistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
attr_list2(srvloc_tree, hf_srvloc_srvreg_attrlist, tvb, offset, length, CHARSET_UTF_8);
offset += length;
}
count = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvreg_attrauthcount, tvb, offset, 1, count);
offset += 1;
while (count > 0) {
offset = dissect_attrauthblk_v2(tvb, offset, srvloc_tree);
count--;
}
break;
case SRVDEREG: /* RFC2608 10.6 */
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvdereg_scopelistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_srvdereg_scopelist, tvb, offset, length, ENC_ASCII);
offset += length;
}
offset = dissect_url_entry_v2(tvb, offset, srvloc_tree);
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvdereg_taglistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_srvdereg_taglist, tvb, offset, length, ENC_ASCII);
offset += length;
}
break;
case SRVACK: /* RFC2608 8.4 */
expert_item = proto_tree_add_item(srvloc_tree, hf_srvloc_error_v2, tvb, offset, 2, ENC_BIG_ENDIAN);
expert_status = tvb_get_ntohs(tvb, offset);
if (expert_status!=0) {
expert_add_info_format(pinfo, expert_item, &ei_srvloc_error_v2, "Error: %s", val_to_str(expert_status, srvloc_errs_v2, "Unknown SRVLOC Error (0x%02x)"));
}
offset += 2;
break;
case ATTRRQST: /* RFC2608 10.3*/
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_attrreq_prlistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_attrreq_prlist, tvb, offset, length, ENC_ASCII);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_attrreq_urllen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_attrreq_url, tvb, offset, length, ENC_ASCII);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_attrreq_scopelistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_attrreq_scopelist, tvb, offset, length, ENC_ASCII);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_attrreq_taglistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_attrreq_taglist, tvb, offset, length, ENC_ASCII);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_attrreq_slpspilen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_attrreq_slpspi, tvb, offset, length, ENC_ASCII);
offset += length;
}
break;
case ATTRRPLY: /* RFC2608 10.4 */
expert_item = proto_tree_add_item(srvloc_tree, hf_srvloc_error_v2, tvb, offset, 2, ENC_BIG_ENDIAN);
expert_status = tvb_get_ntohs(tvb, offset);
if (expert_status!=0) {
expert_add_info_format(pinfo, expert_item, &ei_srvloc_error_v2, "Error: %s", val_to_str(expert_status, srvloc_errs_v2, "Unknown SRVLOC Error (0x%02x)"));
}
offset += 2;
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_attrrply_attrlistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
attr_list2(srvloc_tree, hf_srvloc_attrrply_attrlist, tvb, offset, length, CHARSET_UTF_8);
offset += length;
}
count = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_attrrply_attrauthcount, tvb, offset, 1, count);
offset += 1;
while (count > 0) {
offset = dissect_attrauthblk_v2(tvb, offset, srvloc_tree);
count--;
}
break;
case DAADVERT: /* RCC 2608 8.5 */
expert_item = proto_tree_add_item(srvloc_tree, hf_srvloc_error_v2, tvb, offset, 2, ENC_BIG_ENDIAN);
expert_status = tvb_get_ntohs(tvb, offset);
if (expert_status!=0) {
expert_add_info_format(pinfo, expert_item, &ei_srvloc_error_v2, "Error: %s", val_to_str(expert_status, srvloc_errs_v2, "Unknown SRVLOC Error (0x%02x)"));
}
offset += 2;
proto_tree_add_item(srvloc_tree, hf_srvloc_daadvert_timestamp, tvb, offset, 4,
ENC_TIME_SECS|ENC_BIG_ENDIAN);
offset += 4;
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_daadvert_urllen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_daadvert_url, tvb, offset, length, ENC_ASCII);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_daadvert_scopelistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_daadvert_scopelist, tvb, offset, length, ENC_ASCII);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_daadvert_attrlistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_daadvert_attrlist, tvb, offset, length, ENC_ASCII);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_daadvert_slpspilen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_daadvert_slpspi, tvb, offset, length, ENC_ASCII);
offset += length;
}
count = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_daadvert_authcount, tvb, offset, 1, count);
offset += 1;
while (count > 0) {
offset = dissect_authblk_v2(tvb, offset, srvloc_tree);
count--;
}
break;
case SRVTYPERQST: /* RFC2608 10.1 */
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtypereq_prlistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_srvtypereq_prlist, tvb, offset, length, ENC_ASCII);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
if (0xFFFF == length) {
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtypereq_nameauthlistlenall, tvb, offset, 2, length);
offset += 2;
} else {
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtypereq_nameauthlistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_srvtypereq_nameauthlist, tvb, offset, length, ENC_ASCII);
offset += length;
}
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtypereq_scopelistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_srvtypereq_scopelist, tvb, offset, length, ENC_ASCII);
offset += length;
}
break;
case SRVTYPERPLY: /* rfc2608 10.2 */
expert_item = proto_tree_add_item(srvloc_tree, hf_srvloc_error_v2, tvb, offset, 2, ENC_BIG_ENDIAN);
expert_status = tvb_get_ntohs(tvb, offset);
if (expert_status!=0) {
expert_add_info_format(pinfo, expert_item, &ei_srvloc_error_v2, "Error: %s", val_to_str(expert_status, srvloc_errs_v2, "Unknown SRVLOC Error (0x%02x)"));
}
offset += 2;
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_srvtyperply_srvtypelistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_srvtyperply_srvtypelist, tvb, offset, length, ENC_ASCII);
offset += length;
}
break;
case SAADVERT: /* rfc2608 10.2 */
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_saadvert_urllen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_saadvert_url, tvb, offset, length, ENC_ASCII);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_saadvert_scopelistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_saadvert_scopelist, tvb, offset, length, ENC_ASCII);
offset += length;
}
length = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_saadvert_attrlistlen, tvb, offset, 2, length);
offset += 2;
if (length) {
proto_tree_add_item(srvloc_tree, hf_srvloc_saadvert_attrlist, tvb, offset, length, ENC_ASCII);
offset += length;
}
count = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(srvloc_tree, hf_srvloc_saadvert_authcount, tvb, offset, 1, length);
offset += 1;
while (count > 0) {
offset = dissect_authblk_v2(tvb, offset, srvloc_tree);
count--;
}
break;
default:
proto_tree_add_expert_format(srvloc_tree, pinfo, &ei_srvloc_function_unknown,
tvb, offset, -1, "Unknown Function Type: %d", function);
}
}
return offset;
}
static guint
get_srvloc_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
{
/*
* Get the length of the SRVLOC packet.
* It starts at offset+2, but it's 2 bytes in SLPv1 and 3 bytes
* in SLPv2.
*/
if (tvb_get_guint8(tvb, offset) == 2)
return tvb_get_ntoh24(tvb, offset + 2);
else
return tvb_get_ntohs(tvb, offset + 2);
}
static int
dissect_srvloc_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
/*
* XXX - in SLPv1, the fixed length need only be 4, as the length
* is 2 bytes long; however, it must be 5 for SLPv2, as the length
* is 3 bytes long, and there's probably no harm in asking for 5
* bytes, as even SLPv1 packets start with a 12-byte header,
* and if the packet has a length that's 4 or less, it's bogus,
* and we can't handle a length < 4 anyway.
*/
tcp_dissect_pdus(tvb, pinfo, tree, srvloc_desegment, 5, get_srvloc_pdu_len,
dissect_srvloc, data);
return tvb_captured_length(tvb);
}
/* Register protocol with Wireshark. */
void
proto_register_srvloc(void)
{
static hf_register_info hf[] = {
/* Helper functions for the Version 1 Header*/
{&hf_srvloc_error,
{"Error Code", "srvloc.err",
FT_UINT16, BASE_DEC, VALS(srvloc_errs), 0x0,
NULL, HFILL }
},
/* Helper function for the Version 2 Header */
{&hf_srvloc_error_v2,
{"Error Code", "srvloc.errv2",
FT_UINT16, BASE_DEC, VALS(srvloc_errs_v2), 0x0,
NULL, HFILL }
},
{&hf_srvloc_xid,
{"XID", "srvloc.xid",
FT_UINT24, BASE_DEC, NULL, 0x0,
"Transaction ID", HFILL }
},
{&hf_srvloc_langtag,
{"Lang Tag", "srvloc.langtag",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{&hf_srvloc_langtaglen,
{"Lang Tag Len", "srvloc.langtaglen",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{&hf_srvloc_nextextoff,
{"Next Extension Offset", "srvloc.nextextoff",
FT_UINT24, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
/* Helper functions for URL and URL Entry parsing - both versions */
{&hf_srvloc_url_reserved,
{"Reserved", "srvloc.url.reserved",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{&hf_srvloc_url_lifetime,
{"URL lifetime", "srvloc.url.lifetime",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{&hf_srvloc_url_urllen,
{"URL Length", "srvloc.url.urllen",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{&hf_srvloc_url_url,
{"URL", "srvloc.url.url",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{&hf_srvloc_url_numauths,
{"Num Auths", "srvloc.url.numauths",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
/* Helper functions for the common header fields */
{&hf_srvloc_function,
{"Function", "srvloc.function",
FT_UINT8, BASE_DEC, VALS(srvloc_functions), 0x0,
NULL, HFILL }
},
{&hf_srvloc_pktlen,
{"Packet Length", "srvloc.pktlen",
FT_UINT24, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_srvloc_version,
{ "Version", "srvloc.version",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{&hf_srvloc_flags_v1,
{"Flags", "srvloc.flags_v1",
FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_srvloc_flags_v1_overflow,
{ "Overflow", "srvloc.flags_v1.overflow", FT_BOOLEAN, 8,
TFS(&tfs_srvloc_flags_overflow), FLAG_O, "Can whole packet fit into a datagram?", HFILL }},
{ &hf_srvloc_flags_v1_monolingual,
{ "Monolingual", "srvloc.flags_v1.monolingual", FT_BOOLEAN, 8,
TFS(&tfs_srvloc_flags_v1_monolingual), FLAG_M, "Can whole packet fit into a datagram?", HFILL }},
{ &hf_srvloc_flags_v1_url_auth,
{ "URL Authentication", "srvloc.flags_v1.url_auth", FT_BOOLEAN, 8,
TFS(&tfs_srvloc_flags_v1_url_auth), FLAG_U, "Can whole packet fit into a datagram?", HFILL }},
{ &hf_srvloc_flags_v1_attribute_auth,
{ "Attribute Authentication", "srvloc.flags_v1.attribute_auth", FT_BOOLEAN, 8,
TFS(&tfs_srvloc_flags_v1_attribute_auth), FLAG_A, "Can whole packet fit into a datagram?", HFILL }},
{ &hf_srvloc_flags_v1_fresh,
{ "Fresh Registration", "srvloc.flags_v1.fresh", FT_BOOLEAN, 8,
TFS(&tfs_srvloc_flags_fresh), FLAG_F, "Is this a new registration?", HFILL }},
{&hf_srvloc_flags_v2,
{"Flags", "srvloc.flags_v2",
FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_srvloc_flags_v2_overflow,
{ "Overflow", "srvloc.flags_v2.overflow", FT_BOOLEAN, 16,
TFS(&tfs_srvloc_flags_overflow), FLAG_O_V2, "Can whole packet fit into a datagram?", HFILL }},
{ &hf_srvloc_flags_v2_fresh,
{ "Fresh Registration", "srvloc.flags_v2.fresh", FT_BOOLEAN, 16,
TFS(&tfs_srvloc_flags_fresh), FLAG_F_V2, "Is this a new registration?", HFILL }},
{ &hf_srvloc_flags_v2_reqmulti,
{ "Multicast requested", "srvloc.flags_v2.reqmulti", FT_BOOLEAN, 16,
TFS(&tfs_srvloc_flags_v2_reqmulti), FLAG_R_V2, "Do we want multicast?", HFILL }},
/* collection of helper functions for dissect_authblk_v2 */
{ &hf_srvloc_authblkv2_bsd,
{ "BSD", "srvloc.authblkv2_bsd", FT_UINT16, BASE_HEX, NULL, 0x0,
"Block Structure Descriptor", HFILL}
},
{ &hf_srvloc_authblkv2_len,
{ "Length", "srvloc.authblkv2_len", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of Authentication Block", HFILL}
},
{ &hf_srvloc_authblkv2_timestamp,
{ "Timestamp", "srvloc.authblkv2.timestamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "Timestamp on Authentication Block", HFILL }
},
{ &hf_srvloc_authblkv2_slpspilen,
{ "SLP SPI Length", "srvloc.authblkv2.slpspilen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of the SLP SPI", HFILL}
},
{ &hf_srvloc_authblkv2_slpspi,
{ "SLP SPI", "srvloc.authblkv2.slpspi", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
/* collection of helper functions for Service Request */
{ &hf_srvloc_srvreq_prlistlen,
{ "Previous Response List Length", "srvloc.srvreq.prlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of Previous Response List", HFILL}
},
{ &hf_srvloc_srvreq_prlist,
{ "Previous Response List", "srvloc.srvreq.prlist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_srvreq_srvtypelen,
{ "Service Type Length", "srvloc.srvreq.srvtypelen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of Service Type List", HFILL}
},
{ &hf_srvloc_srvreq_srvtypelist,
{ "Service Type List", "srvloc.srvreq.srvtypelist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_srvreq_scopelistlen,
{ "Scope List Length", "srvloc.srvreq.scopelistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of the Scope List", HFILL}
},
{ &hf_srvloc_srvreq_scopelist,
{ "Scope List", "srvloc.srvreq.scopelist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_srvreq_predicatelen,
{ "Predicate Length", "srvloc.srvreq.predicatelen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of the Predicate", HFILL}
},
{ &hf_srvloc_srvreq_predicate,
{ "Predicate", "srvloc.srvreq.predicate", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_srvreq_slpspilen,
{ "SLP SPI Length", "srvloc.srvreq.slpspilen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of the SLP SPI", HFILL}
},
{ &hf_srvloc_srvreq_slpspi,
{ "SLP SPI", "srvloc.srvreq.slpspi", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
/* Helper function for Service Request */
{ &hf_srvloc_srvrply_urlcount,
{ "Number of URLs", "srvloc.srvreq.urlcount", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
/* Helper functions for Service Registration */
{ &hf_srvloc_srvreg_srvtypelen,
{ "Service Type Length", "srvloc.srvreq.srvtypelen", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_srvreg_srvtype,
{ "Service Type", "srvloc.srvreq.srvtype", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_srvreg_scopelistlen,
{ "Scope List Length", "srvloc.srvreq.scopelistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_srvreg_scopelist,
{ "Scope List", "srvloc.srvreq.scopelist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_srvreg_attrlistlen,
{ "Attribute List Length", "srvloc.srvreq.attrlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_srvreg_attrlist,
{ "Attribute List", "srvloc.srvreq.attrlist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_srvreg_attrauthcount,
{ "Attr Auths", "srvloc.srvreq.attrauthcount", FT_UINT8, BASE_DEC, NULL, 0x0,
"Number of Attribute Authentication Blocks", HFILL}
},
/* Helper functions for Service Deregistration */
{ &hf_srvloc_srvdereg_scopelistlen,
{ "Scope List Length", "srvloc.srvdereq.scopelistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_srvdereg_scopelist,
{ "Scope List", "srvloc.srvdereq.scopelist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_srvdereg_taglistlen,
{ "Tag List Length", "srvloc.srvdereq.taglistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_srvdereg_taglist,
{ "Tag List", "srvloc.srvdereq.taglist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
/* collection of helper functions for Attribute Request */
{ &hf_srvloc_attrreq_prlistlen,
{ "Previous Response List Length", "srvloc.attrreq.prlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of Previous Response List", HFILL}
},
{ &hf_srvloc_attrreq_prlist,
{ "Previous Response List", "srvloc.attrreq.prlist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_attrreq_urllen,
{ "URL Length", "srvloc.attrreq.urllen", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_attrreq_url,
{ "Service URL", "srvloc.attrreq.url", FT_STRING, BASE_NONE, NULL, 0x0,
"URL of service", HFILL}
},
{ &hf_srvloc_attrreq_scopelistlen,
{ "Scope List Length", "srvloc.attrreq.scopelistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of the Scope List", HFILL}
},
{ &hf_srvloc_attrreq_scopelist,
{ "Scope List", "srvloc.attrreq.scopelist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_attrreq_attrlistlen,
{ "Attribute List Length", "srvloc.attrreq.attrlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_attrreq_attrlist,
{ "Attribute List", "srvloc.attrreq.attrlist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_attrreq_taglistlen,
{ "Tag List Length", "srvloc.attrreq.taglistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_attrreq_taglist,
{ "Tag List", "srvloc.attrreq.taglist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_attrreq_slpspilen,
{ "SLP SPI Length", "srvloc.attrreq.slpspilen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of the SLP SPI", HFILL}
},
{ &hf_srvloc_attrreq_slpspi,
{ "SLP SPI", "srvloc.attrreq.slpspi", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
/* collection of helper functions for Attribute Reply */
{ &hf_srvloc_attrrply_attrlistlen,
{ "Attribute List Length", "srvloc.attrrply.attrlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of Attribute List", HFILL}
},
{ &hf_srvloc_attrrply_attrlist,
{ "Attribute List", "srvloc.attrrply.attrlist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_attrrply_attrauthcount,
{ "Attr Auths", "srvloc.srvreq.attrauthcount", FT_UINT8, BASE_DEC, NULL, 0x0,
"Number of Attribute Authentication Blocks", HFILL}
},
/* collection of helper functions for DA Advertisement */
{ &hf_srvloc_daadvert_timestamp,
{ "DAADVERT Timestamp", "srvloc.daadvert.timestamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0, "Timestamp on DA Advert", HFILL }
},
{ &hf_srvloc_daadvert_urllen,
{ "URL Length", "srvloc.daadvert.urllen", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_daadvert_url,
{ "URL", "srvloc.daadvert.url", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_daadvert_scopelistlen,
{ "Scope List Length", "srvloc.daadvert.scopelistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of the Scope List", HFILL}
},
{ &hf_srvloc_daadvert_scopelist,
{ "Scope List", "srvloc.daadvert.scopelist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_daadvert_attrlistlen,
{ "Attribute List Length", "srvloc.daadvert.attrlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_daadvert_attrlist,
{ "Attribute List", "srvloc.daadvert.attrlist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_daadvert_slpspilen,
{ "SLP SPI Length", "srvloc.daadvert.slpspilen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of the SLP SPI", HFILL}
},
{ &hf_srvloc_daadvert_slpspi,
{ "SLP SPI", "srvloc.daadvert.slpspi", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_daadvert_authcount,
{ "Auths", "srvloc.daadvert.authcount", FT_UINT8, BASE_DEC, NULL, 0x0,
"Number of Authentication Blocks", HFILL}
},
/* collection of helper functions for Service Type Request */
{ &hf_srvloc_srvtypereq_prlistlen,
{ "Previous Response List Length", "srvloc.srvtypereq.prlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of Previous Response List", HFILL}
},
{ &hf_srvloc_srvtypereq_prlist,
{ "Previous Response List", "srvloc.srvtypereq.prlist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_srvtypereq_nameauthlistlen,
{ "Naming Authority List Length", "srvloc.srvtypereq.nameauthlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of the Naming Authority List", HFILL}
},
{ &hf_srvloc_srvtypereq_nameauthlistlenall,
{ "Naming Authority List Length (All Naming Authorities)", "srvloc.srvtypereq.nameauthlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of the Naming Authority List", HFILL}
},
{ &hf_srvloc_srvtypereq_nameauthlist,
{ "Naming Authority List", "srvloc.srvtypereq.nameauthlist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_srvtypereq_scopelistlen,
{ "Scope List Length", "srvloc.srvtypereq.scopelistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of the Scope List", HFILL}
},
{ &hf_srvloc_srvtypereq_scopelist,
{ "Scope List", "srvloc.srvtypereq.scopelist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
/* collection of helper functions for Service Type Replies */
{ &hf_srvloc_srvtyperply_srvtypelen,
{ "Service Type Length", "srvloc.srvtypereq.srvtypelen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of the Service Type", HFILL}
},
{ &hf_srvloc_srvtyperply_srvtype,
{ "Service Type", "srvloc.srvtyperply.srvtype", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_srvtyperply_srvtypelistlen,
{ "Service Type List Length", "srvloc.srvtypereq.srvtypelistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of the Service Type List", HFILL}
},
{ &hf_srvloc_srvtyperply_srvtypelist,
{ "Service Type List", "srvloc.srvtyperply.srvtypelist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
/* collection of helper functions for SA Advertisement */
{ &hf_srvloc_saadvert_urllen,
{ "URL Length", "srvloc.saadvert.urllen", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_saadvert_url,
{ "URL", "srvloc.saadvert.url", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_saadvert_scopelistlen,
{ "Scope List Length", "srvloc.saadvert.scopelistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
"Length of the Scope List", HFILL}
},
{ &hf_srvloc_saadvert_scopelist,
{ "Scope List", "srvloc.saadvert.scopelist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_saadvert_attrlistlen,
{ "Attribute List Length", "srvloc.saadvert.attrlistlen", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_saadvert_attrlist,
{ "Attribute List", "srvloc.saadvert.attrlist", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
{ &hf_srvloc_saadvert_authcount,
{ "Auths", "srvloc.saadvert.authcount", FT_UINT8, BASE_DEC, NULL, 0x0,
"Number of Authentication Blocks", HFILL}
},
{ &hf_srvloc_add_ref_ip,
{ "IP Address", "srvloc.list.ipaddr", FT_IPv4, BASE_NONE, NULL, 0x0,
"IP Address of SLP server", HFILL}
},
{ &hf_srvloc_srvrply_svcname,
{ "Service Name Value", "srvloc.srvrply.svcname", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL}
},
/* Generated from convert_proto_tree_add_text.pl */
{ &hf_srvloc_timestamp, { "Timestamp", "srvloc.timestamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0, NULL, HFILL }},
{ &hf_srvloc_block_structure_descriptor, { "Block Structure Descriptor", "srvloc.block_structure_descriptor", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_srvloc_authenticator_length, { "Authenticator length", "srvloc.authenticator_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_srvloc_authentication_block, { "Authentication block", "srvloc.authentication_block", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_srvloc_service_type, { "Service Type", "srvloc.service_type", FT_UINT8, BASE_DEC, VALS(srvloc_svc), 0x0, NULL, HFILL }},
{ &hf_srvloc_communication_type, { "Communication Type", "srvloc.communication_type", FT_UINT8, BASE_DEC, VALS(srvloc_ss), 0x0, NULL, HFILL }},
{ &hf_srvloc_protocol, { "Protocol", "srvloc.protocol", FT_UINT32, BASE_DEC, VALS(srvloc_prot), 0x0, NULL, HFILL }},
{ &hf_srvloc_port, { "Port", "srvloc.port", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_srvloc_network, { "Network", "srvloc.network", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_srvloc_node, { "Node", "srvloc.node", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_srvloc_socket, { "Socket", "srvloc.socket", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_srvloc_item, { "Item", "srvloc.item", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_srvloc_dialect, { "Dialect", "srvloc.dialect", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_srvloc_language, { "Language", "srvloc.language", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_srvloc_encoding, { "Encoding", "srvloc.encoding", FT_UINT16, BASE_DEC, VALS(charsets), 0x0, NULL, HFILL }},
{ &hf_srvloc_transaction_id, { "Transaction ID", "srvloc.transaction_id", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_srvloc_service_type_count, { "Service Type Count", "srvloc.service_type_count", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
};
static gint *ett[] = {
&ett_srvloc,
&ett_srvloc_attr,
&ett_srvloc_flags,
};
static ei_register_info ei[] = {
{ &ei_srvloc_error, { "srvloc.err.expert", PI_RESPONSE_CODE, PI_ERROR, "Error", EXPFILL }},
{ &ei_srvloc_error_v2, { "srvloc.errv2.expert", PI_RESPONSE_CODE, PI_ERROR, "Error", EXPFILL }},
{ &ei_srvloc_function_unknown, { "srvloc.function.unknown", PI_RESPONSE_CODE, PI_ERROR, "Unknown Function Type", EXPFILL }},
{ &ei_srvloc_malformed, { "srvloc.malformed", PI_MALFORMED, PI_ERROR, "Too much data to pass inside this protocol. Resubmit request using a streaming protocol like TCP. "
"Protocol dissection is aborted due to packet overflow. See overflow flag.", EXPFILL }},
};
module_t *srvloc_module;
expert_module_t* expert_srvloc;
proto_srvloc = proto_register_protocol("Service Location Protocol",
"SRVLOC", "srvloc");
proto_register_field_array(proto_srvloc, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_srvloc = expert_register_protocol(proto_srvloc);
expert_register_field_array(expert_srvloc, ei, array_length(ei));
srvloc_module = prefs_register_protocol(proto_srvloc, NULL);
prefs_register_bool_preference(srvloc_module, "desegment_tcp",
"Reassemble SRVLOC messages spanning multiple TCP segments",
"Whether the SRVLOC dissector should reassemble messages spanning multiple TCP segments. "
"To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
&srvloc_desegment);
}
void
proto_reg_handoff_srvloc(void)
{
dissector_handle_t srvloc_handle, srvloc_tcp_handle;
srvloc_handle = create_dissector_handle(dissect_srvloc, proto_srvloc);
dissector_add_uint_with_preference("udp.port", UDP_PORT_SRVLOC, srvloc_handle);
srvloc_tcp_handle = create_dissector_handle(dissect_srvloc_tcp,
proto_srvloc);
dissector_add_uint_with_preference("tcp.port", TCP_PORT_SRVLOC, srvloc_tcp_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-sscf-nni.c
|
/* packet-sscf-nni.c
* Routines for SSCF-NNI (Q.2140) frame disassembly
* Jeff Morriss <jeff.morriss.ws [AT] gmail.com>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998
*
* Copied from packet-sscop.c
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
void proto_register_sscf(void);
void proto_reg_handoff_sscf(void);
static int proto_sscf = -1;
static gint ett_sscf = -1;
static dissector_handle_t mtp3_handle;
#define SSCF_PDU_LENGTH 4
#define SSCF_STATUS_OFFSET 3
#define SSCF_STATUS_LENGTH 1
#define SSCF_SPARE_OFFSET 0
#define SSCF_SPARE_LENGTH 3
static int hf_status = -1;
static int hf_spare = -1;
#define SSCF_STATUS_OOS 0x01
#define SSCF_STATUS_PO 0x02
#define SSCF_STATUS_IS 0x03
#define SSCF_STATUS_NORMAL 0x04
#define SSCF_STATUS_EMERGENCY 0x05
#define SSCF_STATUS_ALIGNMENT_NOT_SUCCESSFUL 0x7
#define SSCF_STATUS_MANAGEMENT_INITIATED 0x08
#define SSCF_STATUS_PROTOCOL_ERROR 0x09
#define SSCF_STATUS_PROVING_NOT_SUCCESSFUL 0x0a
static const value_string sscf_status_vals[] = {
{ SSCF_STATUS_OOS, "Out of Service" },
{ SSCF_STATUS_PO, "Processor Outage" },
{ SSCF_STATUS_IS, "In Service" },
{ SSCF_STATUS_NORMAL, "Normal" },
{ SSCF_STATUS_EMERGENCY, "Emergency" },
{ SSCF_STATUS_ALIGNMENT_NOT_SUCCESSFUL, "Alignment Not Successful" },
{ SSCF_STATUS_MANAGEMENT_INITIATED, "Management Initiated" },
{ SSCF_STATUS_PROTOCOL_ERROR, "Protocol Error" },
{ SSCF_STATUS_PROVING_NOT_SUCCESSFUL, "Proving Not Successful" },
{ 0, NULL }
};
static int
dissect_sscf_nni(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
guint reported_length;
proto_item *sscf_item = NULL;
proto_tree *sscf_tree = NULL;
guint8 sscf_status;
reported_length = tvb_reported_length(tvb); /* frame length */
if (tree) {
sscf_item = proto_tree_add_item(tree, proto_sscf, tvb, 0, -1, ENC_NA);
sscf_tree = proto_item_add_subtree(sscf_item, ett_sscf);
}
if (reported_length > SSCF_PDU_LENGTH)
{
call_dissector(mtp3_handle, tvb, pinfo, tree);
} else {
sscf_status = tvb_get_guint8(tvb, SSCF_STATUS_OFFSET);
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SSCF-NNI");
col_add_fstr(pinfo->cinfo, COL_INFO, "STATUS (%s) ",
val_to_str_const(sscf_status, sscf_status_vals, "Unknown"));
proto_tree_add_item(sscf_tree, hf_status, tvb, SSCF_STATUS_OFFSET,
SSCF_STATUS_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(sscf_tree, hf_spare, tvb, SSCF_SPARE_OFFSET,
SSCF_SPARE_LENGTH, ENC_BIG_ENDIAN);
}
return tvb_captured_length(tvb);
}
void
proto_register_sscf(void)
{
static hf_register_info hf[] =
{ { &hf_status, { "Status", "sscf-nni.status", FT_UINT8, BASE_HEX,
VALS(sscf_status_vals), 0x0, NULL, HFILL} },
{ &hf_spare, { "Spare", "sscf-nni.spare", FT_UINT24, BASE_HEX,
NULL, 0x0, NULL, HFILL} }
};
static gint *ett[] = {
&ett_sscf,
};
proto_sscf = proto_register_protocol("SSCF-NNI", "SSCF-NNI", "sscf-nni");
proto_register_field_array(proto_sscf, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_dissector("sscf-nni", dissect_sscf_nni, proto_sscf);
}
void
proto_reg_handoff_sscf(void)
{
mtp3_handle = find_dissector_add_dependency("mtp3", proto_sscf);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|
C
|
wireshark/epan/dissectors/packet-sscop.c
|
/* packet-sscop.c
* Routines for SSCOP (Q.2110, Q.SAAL) frame disassembly
* Guy Harris <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998
*
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/proto_data.h>
#include <wiretap/wtap.h>
#include "packet-sscop.h"
void proto_register_sscop(void);
void proto_reg_handoff_sscop(void);
int proto_sscop = -1;
static int hf_sscop_type = -1;
static int hf_sscop_sq = -1;
static int hf_sscop_mr = -1;
static int hf_sscop_s = -1;
static int hf_sscop_ps = -1;
static int hf_sscop_r = -1;
static int hf_sscop_stat_s = -1;
static int hf_sscop_pad_length = -1;
static int hf_sscop_source = -1;
/* static int hf_sscop_stat_count = -1; */
static gint ett_sscop = -1;
static gint ett_stat = -1;
static dissector_handle_t q2931_handle;
static dissector_handle_t data_handle;
static dissector_handle_t sscf_nni_handle;
static dissector_handle_t alcap_handle;
static dissector_handle_t nbap_handle;
static dissector_handle_t sscop_handle;
static const enum_val_t sscop_payload_dissector_options[] = {
{ "data", "Data (no further dissection)", DATA_DISSECTOR },
{ "Q.2931", "Q.2931", Q2931_DISSECTOR },
{ "SSCF-NNI", "SSCF-NNI (MTP3-b)", SSCF_NNI_DISSECTOR },
{ "ALCAP", "ALCAP", ALCAP_DISSECTOR },
{ "NBAP", "NBAP", NBAP_DISSECTOR },
{ NULL, NULL, 0 }
};
static guint sscop_payload_dissector = Q2931_DISSECTOR;
static dissector_handle_t default_handle;
static sscop_info_t sscop_info;
/*
* See
*
* http://web.archive.org/web/20150408122122/http://www.protocols.com/pbook/atmsig.htm
*
* for some information on SSCOP, although, alas, not the actual PDU
* type values - those I got from the FreeBSD 3.2 ATM code.
*/
/*
* SSCOP PDU types.
*/
#define SSCOP_TYPE_MASK 0x0f
#define SSCOP_BGN 0x01 /* Begin */
#define SSCOP_BGAK 0x02 /* Begin Acknowledge */
#define SSCOP_END 0x03 /* End */
#define SSCOP_ENDAK 0x04 /* End Acknowledge */
#define SSCOP_RS 0x05 /* Resynchronization */
#define SSCOP_RSAK 0x06 /* Resynchronization Acknowledge */
#define SSCOP_BGREJ 0x07 /* Begin Reject */
#define SSCOP_SD 0x08 /* Sequenced Data */
#if 0
#define SSCOP_SDP 0x09 /* Sequenced Data with Poll */
#endif
#define SSCOP_ER 0x09 /* Error Recovery */
#define SSCOP_POLL 0x0a /* Status Request */
#define SSCOP_STAT 0x0b /* Solicited Status Response */
#define SSCOP_USTAT 0x0c /* Unsolicited Status Response */
#define SSCOP_UD 0x0d /* Unnumbered Data */
#define SSCOP_MD 0x0e /* Management Data */
#define SSCOP_ERAK 0x0f /* Error Acknowledge */
#define SSCOP_S 0x10 /* Source bit in End PDU */
/*
* XXX - how to distinguish SDP from ER?
*/
static const value_string sscop_type_vals[] = {
{ SSCOP_BGN, "Begin" },
{ SSCOP_BGAK, "Begin Acknowledge" },
{ SSCOP_END, "End" },
{ SSCOP_ENDAK, "End Acknowledge" },
{ SSCOP_RS, "Resynchronization" },
{ SSCOP_RSAK, "Resynchronization Acknowledge" },
{ SSCOP_BGREJ, "Begin Reject" },
{ SSCOP_SD, "Sequenced Data" },
#if 0
{ SSCOP_SDP, "Sequenced Data with Poll" },
#endif
{ SSCOP_ER, "Error Recovery" },
{ SSCOP_POLL, "Status Request" },
{ SSCOP_STAT, "Solicited Status Response" },
{ SSCOP_USTAT, "Unsolicited Status Response" },
{ SSCOP_UD, "Unnumbered Data" },
{ SSCOP_MD, "Management Data" },
{ SSCOP_ERAK, "Error Acknowledge" },
{ 0, NULL }
};
static value_string_ext sscop_type_vals_ext = VALUE_STRING_EXT_INIT(sscop_type_vals);
/*
* The SSCOP "header" is a trailer, so the "offsets" are computed based
* on the length of the packet.
*/
/*
* PDU type.
*/
#define SSCOP_PDU_TYPE (reported_length - 4) /* single byte */
/*
* Begin PDU, Begin Acknowledge PDU (no N(SQ) in it), Resynchronization
* PDU, Resynchronization Acknowledge PDU (no N(SQ) in it in Q.SAAL),
* Error Recovery PDU, Error Recovery Acknoledge PDU (no N(SQ) in it).
*/
#define SSCOP_N_SQ (reported_length - 5) /* One byte */
#define SSCOP_N_MR (reported_length - 4) /* lower 3 bytes thereof */
/*
* Sequenced Data PDU (no N(PS) in it), Sequenced Data with Poll PDU,
* Poll PDU.
*/
#define SSCOP_N_PS (reported_length - 8) /* lower 3 bytes thereof */
#define SSCOP_N_S (reported_length - 4) /* lower 3 bytes thereof */
/*
* Solicited Status PDU, Unsolicited Status PDU (no N(PS) in it).
*/
#define SSCOP_SS_N_PS (reported_length - 12) /* lower 3 bytes thereof */
#define SSCOP_SS_N_MR (reported_length - 8) /* lower 3 bytes thereof */
#define SSCOP_SS_N_R (reported_length - 4) /* lower 3 bytes thereof */
static void dissect_stat_list(proto_tree *tree, tvbuff_t *tvb,guint h) {
gint n,i;
if ((n = (tvb_reported_length(tvb))/4 - h)) {
tree = proto_tree_add_subtree(tree,tvb,0,n*4,ett_stat,NULL,"SD List");
for (i = 0; i < n; i++) {
proto_tree_add_item(tree, hf_sscop_stat_s, tvb, i*4 + 1,3,ENC_BIG_ENDIAN);
}
}
}
extern void
dissect_sscop_and_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, dissector_handle_t payload_handle)
{
guint reported_length;
proto_item *ti;
proto_tree *sscop_tree = NULL;
guint8 sscop_pdu_type;
int pdu_len;
int pad_len;
tvbuff_t *next_tvb;
reported_length = tvb_reported_length(tvb); /* frame length */
sscop_pdu_type = tvb_get_guint8(tvb, SSCOP_PDU_TYPE);
sscop_info.type = sscop_pdu_type & SSCOP_TYPE_MASK;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SSCOP");
col_add_str(pinfo->cinfo, COL_INFO, val_to_str_ext(sscop_info.type, &sscop_type_vals_ext,
"Unknown PDU type (0x%02x)"));
/*
* Find the length of the PDU and, if there's any payload and
* padding, the length of the padding.
*/
switch (sscop_info.type) {
case SSCOP_SD:
pad_len = (sscop_pdu_type >> 6) & 0x03;
pdu_len = 4;
break;
case SSCOP_BGN:
case SSCOP_BGAK:
case SSCOP_BGREJ:
case SSCOP_END:
case SSCOP_RS:
#if 0
case SSCOP_SDP:
#endif
pad_len = (sscop_pdu_type >> 6) & 0x03;
sscop_info.payload_len = pdu_len = 8;
break;
case SSCOP_UD:
pad_len = (sscop_pdu_type >> 6) & 0x03;
sscop_info.payload_len = pdu_len = 4;
break;
default:
pad_len = 0;
pdu_len = reported_length; /* No payload, just SSCOP */
sscop_info.payload_len = 0;
break;
}
if (tree) {
ti = proto_tree_add_protocol_format(tree, proto_sscop, tvb,
reported_length - pdu_len,
pdu_len, "SSCOP");
sscop_tree = proto_item_add_subtree(ti, ett_sscop);
proto_tree_add_item(sscop_tree, hf_sscop_type, tvb, SSCOP_PDU_TYPE, 1,ENC_BIG_ENDIAN);
switch (sscop_info.type) {
case SSCOP_BGN:
case SSCOP_RS:
case SSCOP_ER:
proto_tree_add_item(sscop_tree, hf_sscop_sq, tvb, SSCOP_N_SQ, 1,ENC_BIG_ENDIAN);
proto_tree_add_item(sscop_tree, hf_sscop_mr, tvb, SSCOP_N_MR + 1, 3, ENC_BIG_ENDIAN);
break;
case SSCOP_END:
proto_tree_add_string(sscop_tree, hf_sscop_source, tvb, SSCOP_PDU_TYPE, 1,
(sscop_pdu_type & SSCOP_S) ? "SSCOP" : "User");
break;
case SSCOP_BGAK:
case SSCOP_RSAK:
proto_tree_add_item(sscop_tree, hf_sscop_mr, tvb, SSCOP_N_MR + 1, 3, ENC_BIG_ENDIAN);
break;
case SSCOP_ERAK:
proto_tree_add_item(sscop_tree, hf_sscop_mr, tvb, SSCOP_N_MR + 1, 3, ENC_BIG_ENDIAN);
break;
case SSCOP_SD:
proto_tree_add_item(sscop_tree, hf_sscop_s, tvb, SSCOP_N_S + 1, 3, ENC_BIG_ENDIAN);
break;
#if 0
case SSCOP_SDP:
#endif
case SSCOP_POLL:
proto_tree_add_item(sscop_tree, hf_sscop_ps, tvb, SSCOP_N_PS + 1, 3,ENC_BIG_ENDIAN);
proto_tree_add_item(sscop_tree, hf_sscop_s, tvb, SSCOP_N_S + 1, 3,ENC_BIG_ENDIAN);
break;
case SSCOP_STAT:
proto_tree_add_item(sscop_tree, hf_sscop_ps, tvb, SSCOP_SS_N_PS + 1, 3,ENC_BIG_ENDIAN);
proto_tree_add_item(sscop_tree, hf_sscop_mr, tvb, SSCOP_SS_N_MR + 1, 3, ENC_BIG_ENDIAN);
proto_tree_add_item(sscop_tree, hf_sscop_r, tvb, SSCOP_SS_N_R + 1, 3,ENC_BIG_ENDIAN);
dissect_stat_list(sscop_tree,tvb,3);
break;
case SSCOP_USTAT:
proto_tree_add_item(sscop_tree, hf_sscop_mr, tvb, SSCOP_SS_N_MR + 1, 3, ENC_BIG_ENDIAN);
proto_tree_add_item(sscop_tree, hf_sscop_r, tvb, SSCOP_SS_N_R + 1, 3,ENC_BIG_ENDIAN);
dissect_stat_list(sscop_tree,tvb,2);
break;
}
}
/*
* Dissect the payload, if any.
*
* XXX - what about a Management Data PDU?
*/
switch (sscop_info.type) {
case SSCOP_SD:
case SSCOP_UD:
case SSCOP_BGN:
case SSCOP_BGAK:
case SSCOP_BGREJ:
case SSCOP_END:
case SSCOP_RS:
#if 0
case SSCOP_SDP:
#endif
if (tree) {
proto_tree_add_uint(sscop_tree, hf_sscop_pad_length, tvb, SSCOP_PDU_TYPE, 1, pad_len);
}
/*
* Compute length of data in PDU - subtract the trailer length
* and the pad length from the reported length.
*/
reported_length -= (pdu_len + pad_len);
if (reported_length != 0) {
/*
* We know that we have all of the payload, because we know we have
* at least 4 bytes of data after the payload, i.e. the SSCOP trailer.
* Therefore, we know that the captured length of the payload is
* equal to the length of the payload.
*/
next_tvb = tvb_new_subset_length(tvb, 0, reported_length);
if (sscop_info.type == SSCOP_SD)
{
call_dissector(payload_handle, next_tvb, pinfo, tree);
}
break;
}
}
}
static int dissect_sscop(tvbuff_t* tvb, packet_info* pinfo,proto_tree* tree, void* data _U_)
{
struct _sscop_payload_info *p_sscop_info;
dissector_handle_t subdissector;
/* Look for packet info for subdissector information */
p_sscop_info = (struct _sscop_payload_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_sscop, 0);
if ( p_sscop_info
&& ( subdissector = p_sscop_info->subdissector )
&& ( subdissector == data_handle
|| subdissector == q2931_handle
|| subdissector == sscf_nni_handle
|| subdissector == alcap_handle
|| subdissector == nbap_handle) )
dissect_sscop_and_payload(tvb,pinfo,tree,subdissector);
else
dissect_sscop_and_payload(tvb,pinfo,tree,default_handle);
return tvb_captured_length(tvb);
}
/* Make sure handles for various protocols are initialized */
static void initialize_handles_once(void) {
static gboolean initialized = FALSE;
if (!initialized) {
q2931_handle = find_dissector("q2931");
data_handle = find_dissector("data");
sscf_nni_handle = find_dissector("sscf-nni");
alcap_handle = find_dissector("alcap");
nbap_handle = find_dissector("nbap");
initialized = TRUE;
}
}
gboolean sscop_allowed_subdissector(dissector_handle_t handle)
{
initialize_handles_once();
if (handle == q2931_handle || handle == data_handle
|| handle == sscf_nni_handle || handle == alcap_handle
|| handle == nbap_handle)
return TRUE;
return FALSE;
}
void
proto_reg_handoff_sscop(void)
{
static gboolean prefs_initialized = FALSE;
if (!prefs_initialized) {
initialize_handles_once();
dissector_add_uint_range_with_preference("udp.port", "", sscop_handle);
dissector_add_uint("atm.aal5.type", TRAF_SSCOP, sscop_handle);
prefs_initialized = TRUE;
}
switch(sscop_payload_dissector) {
case DATA_DISSECTOR: default_handle = data_handle; break;
case Q2931_DISSECTOR: default_handle = q2931_handle; break;
case SSCF_NNI_DISSECTOR: default_handle = sscf_nni_handle; break;
case ALCAP_DISSECTOR: default_handle = alcap_handle; break;
case NBAP_DISSECTOR: default_handle = nbap_handle; break;
}
}
void
proto_register_sscop(void)
{
static hf_register_info hf[] = {
{ &hf_sscop_type, { "PDU Type", "sscop.type", FT_UINT8, BASE_HEX|BASE_EXT_STRING, &sscop_type_vals_ext, SSCOP_TYPE_MASK, NULL, HFILL }},
{ &hf_sscop_sq, { "N(SQ)", "sscop.sq", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sscop_mr, { "N(MR)", "sscop.mr", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sscop_s, { "N(S)", "sscop.s", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sscop_ps, { "N(PS)", "sscop.ps", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sscop_r, { "N(R)", "sscop.r", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sscop_stat_s, { "N(S)", "sscop.stat.s", FT_UINT24, BASE_DEC, NULL, 0x0,NULL, HFILL }},
{ &hf_sscop_pad_length, { "Pad length", "sscop.pad_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sscop_source, { "Source", "sscop.source", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
#if 0
{ &hf_sscop_stat_count, { "Number of NACKed pdus", "sscop.stat.count", FT_UINT32, BASE_DEC, NULL, 0x0,NULL, HFILL }}
#endif
};
static gint *ett[] = {
&ett_sscop,
&ett_stat
};
module_t *sscop_module;
proto_sscop = proto_register_protocol("SSCOP", "SSCOP", "sscop");
proto_register_field_array(proto_sscop, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
sscop_handle = register_dissector("sscop", dissect_sscop, proto_sscop);
sscop_module = prefs_register_protocol(proto_sscop, proto_reg_handoff_sscop);
prefs_register_enum_preference(sscop_module, "payload",
"SSCOP payload protocol",
"SSCOP payload (dissector to call on SSCOP payload)",
(gint *)&sscop_payload_dissector,
sscop_payload_dissector_options, FALSE);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-sscop.h
|
/* packet-sscop.h
* definitions for SSCOP (Q.2110, Q.SAAL) frame disassembly
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998
*
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
typedef struct _sscop_info_t {
guint8 type;
guint32 payload_len;
} sscop_info_t;
typedef struct _sscop_payload_info {
dissector_handle_t subdissector;
} sscop_payload_info;
typedef enum {
DATA_DISSECTOR = 1,
Q2931_DISSECTOR = 2,
SSCF_NNI_DISSECTOR = 3,
ALCAP_DISSECTOR = 4,
NBAP_DISSECTOR = 5
} Dissector_Option;
extern gboolean sscop_allowed_subdissector(dissector_handle_t handle);
extern void dissect_sscop_and_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, dissector_handle_t handle);
|
C
|
wireshark/epan/dissectors/packet-ssh.c
|
/* packet-ssh.c
* Routines for ssh packet dissection
*
* Huagang XIE <[email protected]>
* Kees Cook <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Copied from packet-mysql.c
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
*
* Note: support SSH v1 and v2 now.
*
*/
/* SSH version 2 is defined in:
*
* RFC 4250: The Secure Shell (SSH) Protocol Assigned Numbers
* RFC 4251: The Secure Shell (SSH) Protocol Architecture
* RFC 4252: The Secure Shell (SSH) Authentication Protocol
* RFC 4253: The Secure Shell (SSH) Transport Layer Protocol
* RFC 4254: The Secure Shell (SSH) Connection Protocol
*
* SSH versions under 2 were never officially standardized.
*
* Diffie-Hellman Group Exchange is defined in:
*
* RFC 4419: Diffie-Hellman Group Exchange for
* the Secure Shell (SSH) Transport Layer Protocol
*/
/* "SSH" prefixes are for version 2, whereas "SSH1" is for version 1 */
#include "config.h"
/* Start with WIRESHARK_LOG_DOMAINS=packet-ssh and WIRESHARK_LOG_LEVEL=debug to see messages. */
#define WS_LOG_DOMAIN "packet-ssh"
// Define this to get hex dumps more similar to what you get in openssh. If not defined, dumps look more like what you get with other dissectors.
#define OPENSSH_STYLE
#include <errno.h>
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/sctpppids.h>
#include <epan/prefs.h>
#include <epan/expert.h>
#include <epan/proto_data.h>
#include <wsutil/strtoi.h>
#include <wsutil/to_str.h>
#include <wsutil/file_util.h>
#include <wsutil/filesystem.h>
#include <wsutil/wsgcrypt.h>
#include <wsutil/curve25519.h>
#include <wsutil/pint.h>
#include <wsutil/wslog.h>
#include <epan/secrets.h>
#include <wiretap/secrets-types.h>
#if defined(HAVE_LIBGNUTLS)
#include <gnutls/abstract.h>
#endif
#include "packet-tcp.h"
void proto_register_ssh(void);
void proto_reg_handoff_ssh(void);
/* SSH Version 1 definition , from openssh ssh1.h */
#define SSH1_MSG_NONE 0 /* no message */
#define SSH1_MSG_DISCONNECT 1 /* cause (string) */
#define SSH1_SMSG_PUBLIC_KEY 2 /* ck,msk,srvk,hostk */
#define SSH1_CMSG_SESSION_KEY 3 /* key (BIGNUM) */
#define SSH1_CMSG_USER 4 /* user (string) */
#define SSH_VERSION_UNKNOWN 0
#define SSH_VERSION_1 1
#define SSH_VERSION_2 2
/* proto data */
typedef struct {
guint8 *data;
guint length;
} ssh_bignum;
#define SSH_KEX_CURVE25519 0x00010000
#define SSH_KEX_DH_GEX 0x00020000
#define SSH_KEX_DH_GROUP1 0x00030001
#define SSH_KEX_DH_GROUP14 0x00030014
#define SSH_KEX_DH_GROUP16 0x00030016
#define SSH_KEX_DH_GROUP18 0x00030018
#define SSH_KEX_HASH_SHA1 1
#define SSH_KEX_HASH_SHA256 2
#define SSH_KEX_HASH_SHA512 4
#define DIGEST_MAX_SIZE 48
typedef struct _ssh_message_info_t {
guint32 sequence_number;
guint32 offset;
guchar *plain_data; /**< Decrypted data. */
guint data_len; /**< Length of decrypted data. */
gint id; /**< Identifies the exact message within a frame
(there can be multiple records in a frame). */
struct _ssh_message_info_t* next;
guint8 calc_mac[DIGEST_MAX_SIZE];
} ssh_message_info_t;
typedef struct {
gboolean from_server;
ssh_message_info_t * messages;
} ssh_packet_info_t;
typedef struct _ssh_channel_info_t {
guint client_channel_number;
guint server_channel_number;
dissector_handle_t subdissector_handle;
struct _ssh_channel_info_t* next;
} ssh_channel_info_t;
struct ssh_peer_data {
guint counter;
guint32 frame_version_start;
guint32 frame_version_end;
guint32 frame_key_start;
guint32 frame_key_end;
int frame_key_end_offset;
gchar* kex_proposal;
/* For all subsequent proposals,
[0] is client-to-server and [1] is server-to-client. */
#define CLIENT_TO_SERVER_PROPOSAL 0
#define SERVER_TO_CLIENT_PROPOSAL 1
gchar* mac_proposals[2];
gchar* mac;
gint mac_length;
gchar* enc_proposals[2];
gchar* enc;
gchar* comp_proposals[2];
gchar* comp;
gint length_is_plaintext;
// see libgcrypt source, gcrypt.h:gcry_cipher_algos
guint cipher_id;
guint mac_id;
// chacha20 needs two cipher handles
gcry_cipher_hd_t cipher, cipher_2;
guint sequence_number;
guint32 seq_num_kex_init;
// union ??? -- begin
guint32 seq_num_gex_req;
guint32 seq_num_gex_grp;
guint32 seq_num_gex_ini;
guint32 seq_num_gex_rep;
// --
guint32 seq_num_ecdh_ini;
guint32 seq_num_ecdh_rep;
// --
guint32 seq_num_dh_ini;
guint32 seq_num_dh_rep;
// union ??? -- end
guint32 seq_num_new_key;
ssh_bignum *bn_cookie;
guint8 iv[12];
guint8 hmac_iv[DIGEST_MAX_SIZE];
guint hmac_iv_len;
struct ssh_flow_data * global_data;
};
struct ssh_flow_data {
guint version;
gchar* kex;
int (*kex_specific_dissector)(guint8 msg_code, tvbuff_t *tvb,
packet_info *pinfo, int offset, proto_tree *tree,
struct ssh_flow_data *global_data, guint *seq_num);
/* [0] is client's, [1] is server's */
#define CLIENT_PEER_DATA 0
#define SERVER_PEER_DATA 1
struct ssh_peer_data peer_data[2];
gchar *session_id;
guint session_id_length;
ssh_bignum *kex_e;
ssh_bignum *kex_f;
ssh_bignum *kex_gex_p; // Group modulo
ssh_bignum *kex_gex_g; // Group generator
ssh_bignum *secret;
wmem_array_t *kex_client_version;
wmem_array_t *kex_server_version;
wmem_array_t *kex_client_key_exchange_init;
wmem_array_t *kex_server_key_exchange_init;
wmem_array_t *kex_server_host_key_blob;
wmem_array_t *kex_gex_bits_min;
wmem_array_t *kex_gex_bits_req;
wmem_array_t *kex_gex_bits_max;
wmem_array_t *kex_shared_secret;
gboolean do_decrypt;
ssh_bignum new_keys[6];
ssh_channel_info_t *channel_info;
};
typedef struct {
gchar *type;
ssh_bignum *key_material;
} ssh_key_map_entry_t;
static GHashTable * ssh_master_key_map = NULL;
static int proto_ssh = -1;
/* Version exchange */
static int hf_ssh_protocol = -1;
/* Framing */
static int hf_ssh_packet_length = -1;
static int hf_ssh_packet_length_encrypted = -1;
static int hf_ssh_padding_length = -1;
static int hf_ssh_payload = -1;
static int hf_ssh_encrypted_packet = -1;
static int hf_ssh_padding_string = -1;
static int hf_ssh_mac_string = -1;
static int hf_ssh_mac_status = -1;
static int hf_ssh_seq_num = -1;
static int hf_ssh_direction = -1;
/* Message codes */
static int hf_ssh_msg_code = -1;
static int hf_ssh2_msg_code = -1;
static int hf_ssh2_kex_dh_msg_code = -1;
static int hf_ssh2_kex_dh_gex_msg_code = -1;
static int hf_ssh2_kex_ecdh_msg_code = -1;
/* Algorithm negotiation */
static int hf_ssh_cookie = -1;
static int hf_ssh_kex_algorithms = -1;
static int hf_ssh_server_host_key_algorithms = -1;
static int hf_ssh_encryption_algorithms_client_to_server = -1;
static int hf_ssh_encryption_algorithms_server_to_client = -1;
static int hf_ssh_mac_algorithms_client_to_server = -1;
static int hf_ssh_mac_algorithms_server_to_client = -1;
static int hf_ssh_compression_algorithms_client_to_server = -1;
static int hf_ssh_compression_algorithms_server_to_client = -1;
static int hf_ssh_languages_client_to_server = -1;
static int hf_ssh_languages_server_to_client = -1;
static int hf_ssh_kex_algorithms_length = -1;
static int hf_ssh_server_host_key_algorithms_length = -1;
static int hf_ssh_encryption_algorithms_client_to_server_length = -1;
static int hf_ssh_encryption_algorithms_server_to_client_length = -1;
static int hf_ssh_mac_algorithms_client_to_server_length = -1;
static int hf_ssh_mac_algorithms_server_to_client_length = -1;
static int hf_ssh_compression_algorithms_client_to_server_length = -1;
static int hf_ssh_compression_algorithms_server_to_client_length = -1;
static int hf_ssh_languages_client_to_server_length = -1;
static int hf_ssh_languages_server_to_client_length = -1;
static int hf_ssh_first_kex_packet_follows = -1;
static int hf_ssh_kex_reserved = -1;
static int hf_ssh_kex_hassh_algo = -1;
static int hf_ssh_kex_hassh = -1;
static int hf_ssh_kex_hasshserver_algo = -1;
static int hf_ssh_kex_hasshserver = -1;
/* Key exchange common elements */
static int hf_ssh_hostkey_length = -1;
static int hf_ssh_hostkey_type_length = -1;
static int hf_ssh_hostkey_type = -1;
static int hf_ssh_hostkey_data = -1;
static int hf_ssh_hostkey_rsa_n = -1;
static int hf_ssh_hostkey_rsa_e = -1;
static int hf_ssh_hostkey_dsa_p = -1;
static int hf_ssh_hostkey_dsa_q = -1;
static int hf_ssh_hostkey_dsa_g = -1;
static int hf_ssh_hostkey_dsa_y = -1;
static int hf_ssh_hostkey_ecdsa_curve_id = -1;
static int hf_ssh_hostkey_ecdsa_curve_id_length = -1;
static int hf_ssh_hostkey_ecdsa_q = -1;
static int hf_ssh_hostkey_ecdsa_q_length = -1;
static int hf_ssh_hostkey_eddsa_key = -1;
static int hf_ssh_hostkey_eddsa_key_length = -1;
static int hf_ssh_hostsig_length = -1;
static int hf_ssh_hostsig_type_length = -1;
static int hf_ssh_hostsig_type = -1;
static int hf_ssh_hostsig_rsa = -1;
static int hf_ssh_hostsig_dsa = -1;
static int hf_ssh_hostsig_data = -1;
/* Key exchange: Diffie-Hellman */
static int hf_ssh_dh_e = -1;
static int hf_ssh_dh_f = -1;
/* Key exchange: Diffie-Hellman Group Exchange */
static int hf_ssh_dh_gex_min = -1;
static int hf_ssh_dh_gex_nbits = -1;
static int hf_ssh_dh_gex_max = -1;
static int hf_ssh_dh_gex_p = -1;
static int hf_ssh_dh_gex_g = -1;
/* Key exchange: Elliptic Curve Diffie-Hellman */
static int hf_ssh_ecdh_q_c = -1;
static int hf_ssh_ecdh_q_c_length = -1;
static int hf_ssh_ecdh_q_s = -1;
static int hf_ssh_ecdh_q_s_length = -1;
/* Miscellaneous */
static int hf_ssh_mpint_length = -1;
static int hf_ssh_ignore_data_length = -1;
static int hf_ssh_ignore_data = -1;
static int hf_ssh_debug_always_display = -1;
static int hf_ssh_debug_message_length = -1;
static int hf_ssh_debug_message = -1;
static int hf_ssh_service_name_length = -1;
static int hf_ssh_service_name = -1;
static int hf_ssh_userauth_user_name_length = -1;
static int hf_ssh_userauth_user_name = -1;
static int hf_ssh_userauth_change_password = -1;
static int hf_ssh_userauth_service_name_length = -1;
static int hf_ssh_userauth_service_name = -1;
static int hf_ssh_userauth_method_name_length = -1;
static int hf_ssh_userauth_method_name = -1;
static int hf_ssh_userauth_have_signature = -1;
static int hf_ssh_userauth_password_length = -1;
static int hf_ssh_userauth_password = -1;
static int hf_ssh_userauth_new_password_length = -1;
static int hf_ssh_userauth_new_password = -1;
static int hf_ssh_auth_failure_list_length = -1;
static int hf_ssh_auth_failure_list = -1;
static int hf_ssh_userauth_partial_success = -1;
static int hf_ssh_userauth_pka_name_len = -1;
static int hf_ssh_userauth_pka_name = -1;
static int hf_ssh_pk_blob_name_length = -1;
static int hf_ssh_pk_blob_name = -1;
static int hf_ssh_blob_length = -1;
static int hf_ssh_signature_length = -1;
static int hf_ssh_pk_sig_blob_name_length = -1;
static int hf_ssh_pk_sig_blob_name = -1;
static int hf_ssh_connection_type_name_len = -1;
static int hf_ssh_connection_type_name = -1;
static int hf_ssh_connection_sender_channel = -1;
static int hf_ssh_connection_recipient_channel = -1;
static int hf_ssh_connection_initial_window = -1;
static int hf_ssh_connection_maximum_packet_size = -1;
static int hf_ssh_global_request_name_len = -1;
static int hf_ssh_global_request_name = -1;
static int hf_ssh_global_request_want_reply = -1;
static int hf_ssh_global_request_hostkeys_array_len = -1;
static int hf_ssh_channel_request_name_len = -1;
static int hf_ssh_channel_request_name = -1;
static int hf_ssh_channel_request_want_reply = -1;
static int hf_ssh_subsystem_name_len = -1;
static int hf_ssh_subsystem_name = -1;
static int hf_ssh_channel_window_adjust = -1;
static int hf_ssh_channel_data_len = -1;
static int hf_ssh_exit_status = -1;
static int hf_ssh_disconnect_reason = -1;
static int hf_ssh_disconnect_description_length = -1;
static int hf_ssh_disconnect_description = -1;
static int hf_ssh_lang_tag_length = -1;
static int hf_ssh_lang_tag = -1;
static int hf_ssh_blob_p = -1;
static int hf_ssh_blob_e = -1;
static int hf_ssh_pk_sig_s_length = -1;
static int hf_ssh_pk_sig_s = -1;
static gint ett_ssh = -1;
static gint ett_key_exchange = -1;
static gint ett_key_exchange_host_key = -1;
static gint ett_key_exchange_host_sig = -1;
static gint ett_userauth_pk_blob = -1;
static gint ett_userauth_pk_signautre = -1;
static gint ett_key_init = -1;
static gint ett_ssh1 = -1;
static gint ett_ssh2 = -1;
static expert_field ei_ssh_packet_length = EI_INIT;
static expert_field ei_ssh_packet_decode = EI_INIT;
static expert_field ei_ssh_invalid_keylen = EI_INIT;
static expert_field ei_ssh_mac_bad = EI_INIT;
static gboolean ssh_desegment = TRUE;
static dissector_handle_t ssh_handle;
static dissector_handle_t sftp_handle=NULL;
static const char *pref_keylog_file;
static FILE *ssh_keylog_file;
#define SSH_DECRYPT_DEBUG
#ifdef SSH_DECRYPT_DEBUG
static const gchar *ssh_debug_file_name = NULL;
#endif
// 29418/tcp: Gerrit Code Review
#define TCP_RANGE_SSH "22,29418"
#define SCTP_PORT_SSH 22
/* Message Numbers (from RFC 4250) (1-255) */
/* Transport layer protocol: generic (1-19) */
#define SSH_MSG_DISCONNECT 1
#define SSH_MSG_IGNORE 2
#define SSH_MSG_UNIMPLEMENTED 3
#define SSH_MSG_DEBUG 4
#define SSH_MSG_SERVICE_REQUEST 5
#define SSH_MSG_SERVICE_ACCEPT 6
/* Transport layer protocol: Algorithm negotiation (20-29) */
#define SSH_MSG_KEXINIT 20
#define SSH_MSG_NEWKEYS 21
/* Transport layer: Key exchange method specific (reusable) (30-49) */
#define SSH_MSG_KEXDH_INIT 30
#define SSH_MSG_KEXDH_REPLY 31
#define SSH_MSG_KEX_DH_GEX_REQUEST_OLD 30
#define SSH_MSG_KEX_DH_GEX_GROUP 31
#define SSH_MSG_KEX_DH_GEX_INIT 32
#define SSH_MSG_KEX_DH_GEX_REPLY 33
#define SSH_MSG_KEX_DH_GEX_REQUEST 34
#define SSH_MSG_KEX_ECDH_INIT 30
#define SSH_MSG_KEX_ECDH_REPLY 31
/* User authentication protocol: generic (50-59) */
#define SSH_MSG_USERAUTH_REQUEST 50
#define SSH_MSG_USERAUTH_FAILURE 51
#define SSH_MSG_USERAUTH_SUCCESS 52
#define SSH_MSG_USERAUTH_BANNER 53
/* User authentication protocol: method specific (reusable) (50-79) */
#define SSH_MSG_USERAUTH_PK_OK 60
/* Connection protocol: generic (80-89) */
#define SSH_MSG_GLOBAL_REQUEST 80
#define SSH_MSG_REQUEST_SUCCESS 81
#define SSH_MSG_REQUEST_FAILURE 82
/* Connection protocol: channel related messages (90-127) */
#define SSH_MSG_CHANNEL_OPEN 90
#define SSH_MSG_CHANNEL_OPEN_CONFIRMATION 91
#define SSH_MSG_CHANNEL_OPEN_FAILURE 92
#define SSH_MSG_CHANNEL_WINDOW_ADJUST 93
#define SSH_MSG_CHANNEL_DATA 94
#define SSH_MSG_CHANNEL_EXTENDED_DATA 95
#define SSH_MSG_CHANNEL_EOF 96
#define SSH_MSG_CHANNEL_CLOSE 97
#define SSH_MSG_CHANNEL_REQUEST 98
#define SSH_MSG_CHANNEL_SUCCESS 99
#define SSH_MSG_CHANNEL_FAILURE 100
/* 128-191 reserved for client protocols */
/* 192-255 local extensions */
#define CIPHER_AES128_CTR 0x00010001
#define CIPHER_AES192_CTR 0x00010003
#define CIPHER_AES256_CTR 0x00010004
#define CIPHER_AES128_CBC 0x00020001
#define CIPHER_AES192_CBC 0x00020002
#define CIPHER_AES256_CBC 0x00020004
#define CIPHER_AES128_GCM 0x00040001
//#define CIPHER_AES192_GCM 0x00040002 -- does not exist
#define CIPHER_AES256_GCM 0x00040004
#define CIPHER_MAC_SHA2_256 0x00020001
static const value_string ssh_direction_vals[] = {
{ CLIENT_TO_SERVER_PROPOSAL, "client-to-server" },
{ SERVER_TO_CLIENT_PROPOSAL, "server-to-client" },
{ 0, NULL }
};
static const value_string ssh2_msg_vals[] = {
{ SSH_MSG_DISCONNECT, "Disconnect" },
{ SSH_MSG_IGNORE, "Ignore" },
{ SSH_MSG_UNIMPLEMENTED, "Unimplemented" },
{ SSH_MSG_DEBUG, "Debug" },
{ SSH_MSG_SERVICE_REQUEST, "Service Request" },
{ SSH_MSG_SERVICE_ACCEPT, "Service Accept" },
{ SSH_MSG_KEXINIT, "Key Exchange Init" },
{ SSH_MSG_NEWKEYS, "New Keys" },
{ SSH_MSG_USERAUTH_REQUEST, "User Authentication Request" },
{ SSH_MSG_USERAUTH_FAILURE, "User Authentication Failure" },
{ SSH_MSG_USERAUTH_SUCCESS, "User Authentication Success" },
{ SSH_MSG_USERAUTH_BANNER, "User Authentication Banner" },
{ SSH_MSG_GLOBAL_REQUEST, "Global Request" },
{ SSH_MSG_REQUEST_SUCCESS, "Request Success" },
{ SSH_MSG_REQUEST_FAILURE, "Request Failure" },
{ SSH_MSG_CHANNEL_OPEN, "Channel Open" },
{ SSH_MSG_CHANNEL_OPEN_CONFIRMATION, "Channel Open Confirmation" },
{ SSH_MSG_CHANNEL_OPEN_FAILURE, "Channel Open Failure" },
{ SSH_MSG_CHANNEL_WINDOW_ADJUST, "Window Adjust" },
{ SSH_MSG_CHANNEL_DATA, "Channel Data" },
{ SSH_MSG_CHANNEL_EXTENDED_DATA, "Channel Extended Data" },
{ SSH_MSG_CHANNEL_EOF, "Channel EOF" },
{ SSH_MSG_CHANNEL_CLOSE, "Channel Close" },
{ SSH_MSG_CHANNEL_REQUEST, "Channel Request" },
{ SSH_MSG_CHANNEL_SUCCESS, "Channel Success" },
{ SSH_MSG_CHANNEL_FAILURE, "Channel Failure" },
{ SSH_MSG_USERAUTH_PK_OK, "Public Key algorithm accepted" },
{ 0, NULL }
};
static const value_string ssh2_kex_dh_msg_vals[] = {
{ SSH_MSG_KEXDH_INIT, "Diffie-Hellman Key Exchange Init" },
{ SSH_MSG_KEXDH_REPLY, "Diffie-Hellman Key Exchange Reply" },
{ 0, NULL }
};
static const value_string ssh2_kex_dh_gex_msg_vals[] = {
{ SSH_MSG_KEX_DH_GEX_REQUEST_OLD, "Diffie-Hellman Group Exchange Request (Old)" },
{ SSH_MSG_KEX_DH_GEX_GROUP, "Diffie-Hellman Group Exchange Group" },
{ SSH_MSG_KEX_DH_GEX_INIT, "Diffie-Hellman Group Exchange Init" },
{ SSH_MSG_KEX_DH_GEX_REPLY, "Diffie-Hellman Group Exchange Reply" },
{ SSH_MSG_KEX_DH_GEX_REQUEST, "Diffie-Hellman Group Exchange Request" },
{ 0, NULL }
};
static const value_string ssh2_kex_ecdh_msg_vals[] = {
{ SSH_MSG_KEX_ECDH_INIT, "Elliptic Curve Diffie-Hellman Key Exchange Init" },
{ SSH_MSG_KEX_ECDH_REPLY, "Elliptic Curve Diffie-Hellman Key Exchange Reply" },
{ 0, NULL }
};
static const value_string ssh1_msg_vals[] = {
{SSH1_MSG_NONE, "No Message"},
{SSH1_MSG_DISCONNECT, "Disconnect"},
{SSH1_SMSG_PUBLIC_KEY, "Public Key"},
{SSH1_CMSG_SESSION_KEY, "Session Key"},
{SSH1_CMSG_USER, "User"},
{0, NULL}
};
static int ssh_dissect_key_init(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree,
int is_response,
struct ssh_flow_data *global_data);
static int ssh_dissect_proposal(tvbuff_t *tvb, int offset, proto_tree *tree,
int hf_index_length, int hf_index_value, char **store);
static int ssh_dissect_ssh1(tvbuff_t *tvb, packet_info *pinfo,
struct ssh_flow_data *global_data,
int offset, proto_tree *tree, int is_response,
gboolean *need_desegmentation);
static int ssh_dissect_ssh2(tvbuff_t *tvb, packet_info *pinfo,
struct ssh_flow_data *global_data,
int offset, proto_tree *tree, int is_response,
gboolean *need_desegmentation);
static int ssh_dissect_key_exchange(tvbuff_t *tvb, packet_info *pinfo,
struct ssh_flow_data *global_data,
int offset, proto_tree *tree, int is_response,
gboolean *need_desegmentation);
static int ssh_dissect_kex_dh(guint8 msg_code, tvbuff_t *tvb,
packet_info *pinfo, int offset, proto_tree *tree,
struct ssh_flow_data *global_data, guint *seq_num);
static int ssh_dissect_kex_dh_gex(guint8 msg_code, tvbuff_t *tvb,
packet_info *pinfo, int offset, proto_tree *tree,
struct ssh_flow_data *global_data, guint *seq_num);
static int ssh_dissect_kex_ecdh(guint8 msg_code, tvbuff_t *tvb,
packet_info *pinfo, int offset, proto_tree *tree,
struct ssh_flow_data *global_data, guint *seq_num);
static int ssh_dissect_protocol(tvbuff_t *tvb, packet_info *pinfo,
struct ssh_flow_data *global_data,
int offset, proto_tree *tree, int is_response, guint *version,
gboolean *need_desegmentation);
static int ssh_try_dissect_encrypted_packet(tvbuff_t *tvb, packet_info *pinfo,
struct ssh_peer_data *peer_data, int offset, proto_tree *tree);
static int ssh_dissect_encrypted_packet(tvbuff_t *tvb, packet_info *pinfo,
struct ssh_peer_data *peer_data,
int offset, proto_tree *tree);
static void ssh_choose_algo(gchar *client, gchar *server, gchar **result);
static void ssh_set_mac_length(struct ssh_peer_data *peer_data);
static void ssh_set_kex_specific_dissector(struct ssh_flow_data *global_data);
static void ssh_keylog_read_file(void);
static void ssh_keylog_process_line(const char *line);
static void ssh_keylog_process_lines(const guint8 *data, guint datalen);
static void ssh_keylog_reset(void);
static ssh_bignum *ssh_kex_make_bignum(const guint8 *data, guint length);
static gboolean ssh_read_e(tvbuff_t *tvb, int offset,
struct ssh_flow_data *global_data);
static gboolean ssh_read_f(tvbuff_t *tvb, int offset,
struct ssh_flow_data *global_data);
#ifdef SSH_DECRYPTION_SUPPORTED
static ssh_bignum * ssh_read_mpint(tvbuff_t *tvb, int offset);
#endif
static void ssh_keylog_hash_write_secret(struct ssh_flow_data *global_data);
static ssh_bignum *ssh_kex_shared_secret(gint kex_type, ssh_bignum *pub, ssh_bignum *priv, ssh_bignum *modulo);
static void ssh_hash_buffer_put_string(wmem_array_t *buffer, const gchar *string,
guint len);
static void ssh_hash_buffer_put_uint32(wmem_array_t *buffer, guint val);
static gchar *ssh_string(const gchar *string, guint len);
static void ssh_derive_symmetric_keys(ssh_bignum *shared_secret,
gchar *exchange_hash, guint hash_length,
struct ssh_flow_data *global_data);
static void ssh_derive_symmetric_key(ssh_bignum *shared_secret,
gchar *exchange_hash, guint hash_length, gchar id,
ssh_bignum *result_key, struct ssh_flow_data *global_data, guint we_need);
static void ssh_choose_enc_mac(struct ssh_flow_data *global_data);
static void ssh_decryption_set_cipher_id(struct ssh_peer_data *peer);
static void ssh_decryption_setup_cipher(struct ssh_peer_data *peer,
ssh_bignum *iv, ssh_bignum *key);
static void ssh_decryption_set_mac_id(struct ssh_peer_data *peer);
static void ssh_decryption_setup_mac(struct ssh_peer_data *peer,
ssh_bignum *iv);
static void ssh_increment_message_number(packet_info *pinfo,
struct ssh_flow_data *global_data, gboolean is_response);
static guint ssh_decrypt_packet(tvbuff_t *tvb, packet_info *pinfo,
struct ssh_peer_data *peer_data, int offset, proto_tree *tree);
static gboolean ssh_decrypt_chacha20(gcry_cipher_hd_t hd, guint32 seqnr,
guint32 counter, const guchar *ctext, guint ctext_len,
guchar *plain, guint plain_len);
static proto_item * ssh_tree_add_mac(proto_tree *tree, tvbuff_t *tvb, const guint offset, const guint mac_len,
const int hf_mac, const int hf_mac_status, struct expert_field* bad_checksum_expert,
packet_info *pinfo, const guint8 * calc_mac, const guint flags);
static int ssh_dissect_decrypted_packet(tvbuff_t *tvb, packet_info *pinfo,
struct ssh_peer_data *peer_data, proto_tree *tree,
gchar *plaintext, guint plaintext_len);
static int ssh_dissect_transport_generic(tvbuff_t *packet_tvb, packet_info *pinfo,
int offset, proto_item *msg_type_tree, guint msg_code);
static int ssh_dissect_userauth_generic(tvbuff_t *packet_tvb, packet_info *pinfo,
int offset, proto_item *msg_type_tree, guint msg_code);
static int ssh_dissect_userauth_specific(tvbuff_t *packet_tvb, packet_info *pinfo,
int offset, proto_item *msg_type_tree, guint msg_code);
static int ssh_dissect_connection_specific(tvbuff_t *packet_tvb, packet_info *pinfo,
struct ssh_peer_data *peer_data, int offset, proto_item *msg_type_tree,
guint msg_code);
static int ssh_dissect_connection_generic(tvbuff_t *packet_tvb, packet_info *pinfo,
int offset, proto_item *msg_type_tree, guint msg_code);
static int ssh_dissect_public_key_blob(tvbuff_t *packet_tvb, packet_info *pinfo,
int offset, proto_item *msg_type_tree);
static int ssh_dissect_public_key_signature(tvbuff_t *packet_tvb, packet_info *pinfo,
int offset, proto_item *msg_type_tree);
static dissector_handle_t get_subdissector_for_channel(struct ssh_peer_data *peer_data, guint uiNumChannel);
static void set_subdissector_for_channel(struct ssh_peer_data *peer_data, guint uiNumChannel, guint8* subsystem_name);
#define SSH_DEBUG_USE_STDERR "-"
#ifdef SSH_DECRYPT_DEBUG
static void
ssh_debug_printf(const gchar* fmt,...) G_GNUC_PRINTF(1,2);
static void
ssh_print_data(const gchar* name, const guchar* data, size_t len);
static void
ssh_set_debug(const gchar* name);
static void
ssh_debug_flush(void);
#else
/* No debug: nullify debug operation*/
static inline void G_GNUC_PRINTF(1,2)
ssh_debug_printf(const gchar* fmt _U_,...)
{
}
#define ssh_print_data(a, b, c)
#define ssh_print_string(a, b)
#define ssh_set_debug(name)
#define ssh_debug_flush()
#endif /* SSH_DECRYPT_DEBUG */
static int
dissect_ssh(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
proto_tree *ssh_tree;
proto_item *ti;
conversation_t *conversation;
int last_offset, offset = 0;
gboolean is_response = (pinfo->destport != pinfo->match_uint),
need_desegmentation;
guint version;
struct ssh_flow_data *global_data = NULL;
struct ssh_peer_data *peer_data;
ssh_debug_printf("\ndissect_ssh enter frame #%u (%s)\n", pinfo->num, (pinfo->fd->visited)?"already visited":"first time");
conversation = find_or_create_conversation(pinfo);
global_data = (struct ssh_flow_data *)conversation_get_proto_data(conversation, proto_ssh);
if (!global_data) {
global_data = wmem_new0(wmem_file_scope(), struct ssh_flow_data);
global_data->version = SSH_VERSION_UNKNOWN;
global_data->kex_specific_dissector = ssh_dissect_kex_dh;
global_data->peer_data[CLIENT_PEER_DATA].mac_length = -1;
global_data->peer_data[SERVER_PEER_DATA].mac_length = -1;
global_data->peer_data[CLIENT_PEER_DATA].sequence_number = 0;
global_data->peer_data[SERVER_PEER_DATA].sequence_number = 0;
global_data->peer_data[CLIENT_PEER_DATA].seq_num_kex_init = 0;
global_data->peer_data[SERVER_PEER_DATA].seq_num_kex_init = 0;
global_data->peer_data[CLIENT_PEER_DATA].seq_num_gex_req = 0;
global_data->peer_data[SERVER_PEER_DATA].seq_num_gex_req = 0;
global_data->peer_data[CLIENT_PEER_DATA].seq_num_gex_grp = 0;
global_data->peer_data[SERVER_PEER_DATA].seq_num_gex_grp = 0;
global_data->peer_data[CLIENT_PEER_DATA].seq_num_gex_ini = 0;
global_data->peer_data[SERVER_PEER_DATA].seq_num_gex_ini = 0;
global_data->peer_data[CLIENT_PEER_DATA].seq_num_gex_rep = 0;
global_data->peer_data[SERVER_PEER_DATA].seq_num_gex_rep = 0;
global_data->peer_data[CLIENT_PEER_DATA].seq_num_ecdh_ini = 0;
global_data->peer_data[SERVER_PEER_DATA].seq_num_ecdh_ini = 0;
global_data->peer_data[CLIENT_PEER_DATA].seq_num_ecdh_rep = 0;
global_data->peer_data[SERVER_PEER_DATA].seq_num_ecdh_rep = 0;
global_data->peer_data[CLIENT_PEER_DATA].seq_num_dh_ini = 0;
global_data->peer_data[SERVER_PEER_DATA].seq_num_dh_ini = 0;
global_data->peer_data[CLIENT_PEER_DATA].seq_num_dh_rep = 0;
global_data->peer_data[SERVER_PEER_DATA].seq_num_dh_rep = 0;
global_data->peer_data[CLIENT_PEER_DATA].seq_num_new_key = 0;
global_data->peer_data[SERVER_PEER_DATA].seq_num_new_key = 0;
global_data->peer_data[CLIENT_PEER_DATA].bn_cookie = NULL;
global_data->peer_data[SERVER_PEER_DATA].bn_cookie = NULL;
global_data->peer_data[CLIENT_PEER_DATA].global_data = global_data;
global_data->peer_data[SERVER_PEER_DATA].global_data = global_data;
global_data->channel_info = NULL;
global_data->kex_client_version = wmem_array_new(wmem_file_scope(), 1);
global_data->kex_server_version = wmem_array_new(wmem_file_scope(), 1);
global_data->kex_client_key_exchange_init = wmem_array_new(wmem_file_scope(), 1);
global_data->kex_server_key_exchange_init = wmem_array_new(wmem_file_scope(), 1);
global_data->kex_server_host_key_blob = wmem_array_new(wmem_file_scope(), 1);
global_data->kex_gex_bits_min = wmem_array_new(wmem_file_scope(), 1);
global_data->kex_gex_bits_req = wmem_array_new(wmem_file_scope(), 1);
global_data->kex_gex_bits_max = wmem_array_new(wmem_file_scope(), 1);
global_data->kex_shared_secret = wmem_array_new(wmem_file_scope(), 1);
global_data->do_decrypt = TRUE;
conversation_add_proto_data(conversation, proto_ssh, global_data);
}
peer_data = &global_data->peer_data[is_response];
ti = proto_tree_add_item(tree, proto_ssh, tvb, offset, -1, ENC_NA);
ssh_tree = proto_item_add_subtree(ti, ett_ssh);
version = global_data->version;
switch(version) {
case SSH_VERSION_UNKNOWN:
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SSH");
break;
case SSH_VERSION_1:
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SSHv1");
break;
case SSH_VERSION_2:
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SSHv2");
break;
}
col_clear(pinfo->cinfo, COL_INFO);
while(tvb_reported_length_remaining(tvb, offset)> 0) {
gboolean after_version_start = (peer_data->frame_version_start == 0 ||
pinfo->num >= peer_data->frame_version_start);
gboolean before_version_end = (peer_data->frame_version_end == 0 ||
pinfo->num <= peer_data->frame_version_end);
need_desegmentation = FALSE;
last_offset = offset;
peer_data->counter++;
if (after_version_start && before_version_end &&
(tvb_strncaseeql(tvb, offset, "SSH-", 4) == 0)) {
if (peer_data->frame_version_start == 0)
peer_data->frame_version_start = pinfo->num;
offset = ssh_dissect_protocol(tvb, pinfo,
global_data,
offset, ssh_tree, is_response,
&version, &need_desegmentation);
if (!need_desegmentation) {
peer_data->frame_version_end = pinfo->num;
global_data->version = version;
}
} else {
switch(version) {
case SSH_VERSION_UNKNOWN:
offset = ssh_try_dissect_encrypted_packet(tvb, pinfo,
&global_data->peer_data[is_response], offset, ssh_tree);
break;
case SSH_VERSION_1:
offset = ssh_dissect_ssh1(tvb, pinfo, global_data,
offset, ssh_tree, is_response,
&need_desegmentation);
break;
case SSH_VERSION_2:
offset = ssh_dissect_ssh2(tvb, pinfo, global_data,
offset, ssh_tree, is_response,
&need_desegmentation);
break;
}
}
if (need_desegmentation)
return tvb_captured_length(tvb);
if (offset <= last_offset) {
/* XXX - add an expert info in the function
that decrements offset */
break;
}
}
col_prepend_fstr(pinfo->cinfo, COL_INFO, "%s: ", is_response ? "Server" : "Client");
ti = proto_tree_add_boolean_format_value(ssh_tree, hf_ssh_direction, tvb, 0, 0, is_response, "%s",
try_val_to_str(is_response, ssh_direction_vals));
proto_item_set_generated(ti);
ssh_debug_flush();
return tvb_captured_length(tvb);
}
static int
ssh_dissect_ssh2(tvbuff_t *tvb, packet_info *pinfo,
struct ssh_flow_data *global_data,
int offset, proto_tree *tree, int is_response,
gboolean *need_desegmentation)
{
proto_item *ssh2_tree = NULL;
gint remain_length;
struct ssh_peer_data *peer_data = &global_data->peer_data[is_response];
remain_length = tvb_captured_length_remaining(tvb, offset);
while(remain_length>0){
int last_offset = offset;
if (tree) {
wmem_strbuf_t *title = wmem_strbuf_new(wmem_packet_scope(), "SSH Version 2");
if (peer_data->enc || peer_data->mac || peer_data->comp) {
wmem_strbuf_append_printf(title, " (");
if (peer_data->enc)
wmem_strbuf_append_printf(title, "encryption:%s%s",
peer_data->enc,
peer_data->mac || peer_data->comp
? " " : "");
if (peer_data->mac)
wmem_strbuf_append_printf(title, "mac:%s%s",
peer_data->mac,
peer_data->comp ? " " : "");
if (peer_data->comp)
wmem_strbuf_append_printf(title, "compression:%s",
peer_data->comp);
wmem_strbuf_append_printf(title, ")");
}
ssh2_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_ssh2, NULL, wmem_strbuf_get_str(title));
}
ws_noisy("....ssh_dissect_ssh2[%c]: frame_key_start=%d, pinfo->num=%d, frame_key_end=%d, offset=%d, frame_key_end_offset=%d ", is_response==SERVER_PEER_DATA?'S':'C', peer_data->frame_key_start, pinfo->num, peer_data->frame_key_end, offset, peer_data->frame_key_end_offset);
if ((peer_data->frame_key_start == 0) ||
((peer_data->frame_key_start <= pinfo->num) &&
((peer_data->frame_key_end == 0) || (pinfo->num < peer_data->frame_key_end) ||
((pinfo->num == peer_data->frame_key_end) && (offset < peer_data->frame_key_end_offset))))) {
offset = ssh_dissect_key_exchange(tvb, pinfo, global_data,
offset, ssh2_tree, is_response,
need_desegmentation);
if (!*need_desegmentation) {
ssh_increment_message_number(pinfo, global_data, is_response);
}else{
break;
}
} else {
if(!*need_desegmentation){
offset = ssh_try_dissect_encrypted_packet(tvb, pinfo,
&global_data->peer_data[is_response], offset, ssh2_tree);
}else{
break;
}
}
if (ssh2_tree) {
proto_item_set_len(ssh2_tree, offset - last_offset);
}
remain_length = tvb_captured_length_remaining(tvb, offset);
}
return offset;
}
static int
ssh_dissect_ssh1(tvbuff_t *tvb, packet_info *pinfo,
struct ssh_flow_data *global_data,
int offset, proto_tree *tree, int is_response,
gboolean *need_desegmentation)
{
guint plen, padding_length, len;
guint8 msg_code;
guint remain_length;
proto_item *ssh1_tree;
struct ssh_peer_data *peer_data = &global_data->peer_data[is_response];
ssh1_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_ssh1, NULL, "SSH Version 1");
/*
* We use "tvb_ensure_captured_length_remaining()" to make sure there
* actually *is* data remaining.
*
* This means we're guaranteed that "remain_length" is positive.
*/
remain_length = tvb_ensure_captured_length_remaining(tvb, offset);
/*
* Can we do reassembly?
*/
if (ssh_desegment && pinfo->can_desegment) {
/*
* Yes - would an SSH header starting at this offset be split
* across segment boundaries?
*/
if (remain_length < 4) {
/*
* Yes. Tell the TCP dissector where the data for
* this message starts in the data it handed us and
* that we need "some more data." Don't tell it
* exactly how many bytes we need because if/when we
* ask for even more (after the header) that will
* break reassembly.
*/
pinfo->desegment_offset = offset;
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
*need_desegmentation = TRUE;
return offset;
}
}
plen = tvb_get_ntohl(tvb, offset) ;
padding_length = 8 - plen%8;
if (ssh_desegment && pinfo->can_desegment) {
if (plen+4+padding_length > remain_length) {
pinfo->desegment_offset = offset;
pinfo->desegment_len = plen+padding_length - remain_length;
*need_desegmentation = TRUE;
return offset;
}
}
if (plen >= 0xffff) {
if (ssh1_tree && plen > 0) {
proto_tree_add_uint_format(ssh1_tree, hf_ssh_packet_length, tvb,
offset, 4, plen, "Overly large length %x", plen);
}
plen = remain_length-4-padding_length;
} else {
if (ssh1_tree && plen > 0) {
proto_tree_add_uint(ssh1_tree, hf_ssh_packet_length, tvb,
offset, 4, plen);
}
}
offset+=4;
/* padding length */
proto_tree_add_uint(ssh1_tree, hf_ssh_padding_length, tvb,
offset, padding_length, padding_length);
offset += padding_length;
/* msg_code */
if ((peer_data->frame_key_start == 0) ||
((peer_data->frame_key_start >= pinfo->num) && (pinfo->num <= peer_data->frame_key_end))) {
msg_code = tvb_get_guint8(tvb, offset);
proto_tree_add_item(ssh1_tree, hf_ssh_msg_code, tvb, offset, 1, ENC_BIG_ENDIAN);
col_append_sep_str(pinfo->cinfo, COL_INFO, NULL,
val_to_str(msg_code, ssh1_msg_vals, "Unknown (%u)"));
offset += 1;
len = plen -1;
if (!pinfo->fd->visited) {
if (peer_data->frame_key_start == 0)
peer_data->frame_key_start = pinfo->num;
peer_data->frame_key_end = pinfo->num;
}
} else {
len = plen;
col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "Encrypted packet (len=%d)", len);
}
/* payload */
if (ssh1_tree) {
proto_tree_add_item(ssh1_tree, hf_ssh_payload,
tvb, offset, len, ENC_NA);
}
offset += len;
return offset;
}
static int
ssh_tree_add_mpint(tvbuff_t *tvb, int offset, proto_tree *tree,
int hf_ssh_mpint_selection)
{
guint len = tvb_get_ntohl(tvb, offset);
proto_tree_add_uint(tree, hf_ssh_mpint_length, tvb,
offset, 4, len);
offset+=4;
proto_tree_add_item(tree, hf_ssh_mpint_selection,
tvb, offset, len, ENC_NA);
return 4+len;
}
static int
ssh_tree_add_string(tvbuff_t *tvb, int offset, proto_tree *tree,
int hf_ssh_string, int hf_ssh_string_length)
{
guint len = tvb_get_ntohl(tvb, offset);
proto_tree_add_uint(tree, hf_ssh_string_length, tvb,
offset, 4, len);
offset+=4;
proto_tree_add_item(tree, hf_ssh_string,
tvb, offset, len, ENC_NA);
return 4+len;
}
static guint
ssh_tree_add_hostkey(tvbuff_t *tvb, int offset, proto_tree *parent_tree,
const char *tree_name, int ett_idx,
struct ssh_flow_data *global_data)
{
proto_tree *tree = NULL;
int last_offset;
int remaining_len;
guint key_len, type_len;
char* key_type;
gchar *tree_title;
last_offset = offset;
key_len = tvb_get_ntohl(tvb, offset);
offset += 4;
/* Read the key type before creating the tree so we can append it as info. */
type_len = tvb_get_ntohl(tvb, offset);
offset += 4;
key_type = (char *) tvb_get_string_enc(wmem_packet_scope(), tvb, offset, type_len, ENC_ASCII|ENC_NA);
tree_title = wmem_strdup_printf(wmem_packet_scope(), "%s (type: %s)", tree_name, key_type);
tree = proto_tree_add_subtree(parent_tree, tvb, last_offset, key_len + 4, ett_idx, NULL,
tree_title);
proto_tree_add_uint(tree, hf_ssh_hostkey_length, tvb, last_offset, 4, key_len);
// server host key (K_S / Q)
gchar *data = (gchar *)tvb_memdup(wmem_packet_scope(), tvb, last_offset + 4, key_len);
ssh_hash_buffer_put_string(global_data->kex_server_host_key_blob, data, key_len);
last_offset += 4;
proto_tree_add_uint(tree, hf_ssh_hostkey_type_length, tvb, last_offset, 4, type_len);
proto_tree_add_string(tree, hf_ssh_hostkey_type, tvb, offset, type_len, key_type);
offset += type_len;
if (0 == strcmp(key_type, "ssh-rsa")) {
offset += ssh_tree_add_mpint(tvb, offset, tree, hf_ssh_hostkey_rsa_e);
ssh_tree_add_mpint(tvb, offset, tree, hf_ssh_hostkey_rsa_n);
} else if (0 == strcmp(key_type, "ssh-dss")) {
offset += ssh_tree_add_mpint(tvb, offset, tree, hf_ssh_hostkey_dsa_p);
offset += ssh_tree_add_mpint(tvb, offset, tree, hf_ssh_hostkey_dsa_q);
offset += ssh_tree_add_mpint(tvb, offset, tree, hf_ssh_hostkey_dsa_g);
ssh_tree_add_mpint(tvb, offset, tree, hf_ssh_hostkey_dsa_y);
} else if (g_str_has_prefix(key_type, "ecdsa-sha2-")) {
offset += ssh_tree_add_string(tvb, offset, tree,
hf_ssh_hostkey_ecdsa_curve_id, hf_ssh_hostkey_ecdsa_curve_id_length);
ssh_tree_add_string(tvb, offset, tree,
hf_ssh_hostkey_ecdsa_q, hf_ssh_hostkey_ecdsa_q_length);
} else if (g_str_has_prefix(key_type, "ssh-ed")) {
ssh_tree_add_string(tvb, offset, tree,
hf_ssh_hostkey_eddsa_key, hf_ssh_hostkey_eddsa_key_length);
} else {
remaining_len = key_len - (type_len + 4);
proto_tree_add_item(tree, hf_ssh_hostkey_data, tvb, offset, remaining_len, ENC_NA);
}
return 4+key_len;
}
static guint
ssh_tree_add_hostsignature(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *parent_tree,
const char *tree_name, int ett_idx,
struct ssh_flow_data *global_data)
{
(void)global_data;
proto_tree *tree = NULL;
proto_item* ti = NULL;
int last_offset;
int offset0 = offset;
int remaining_len;
guint sig_len, type_len;
guint8* sig_type;
gchar *tree_title;
last_offset = offset;
sig_len = tvb_get_ntohl(tvb, offset);
offset += 4;
/* Read the signature type before creating the tree so we can append it as info. */
type_len = tvb_get_ntohl(tvb, offset);
offset += 4;
sig_type = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, type_len, ENC_ASCII|ENC_NA);
tree_title = wmem_strdup_printf(wmem_packet_scope(), "%s (type: %s)", tree_name, sig_type);
tree = proto_tree_add_subtree(parent_tree, tvb, last_offset, sig_len + 4, ett_idx, NULL,
tree_title);
ti = proto_tree_add_uint(tree, hf_ssh_hostsig_length, tvb, last_offset, 4, sig_len);
last_offset += 4;
proto_tree_add_uint(tree, hf_ssh_hostsig_type_length, tvb, last_offset, 4, type_len);
proto_tree_add_string(tree, hf_ssh_hostsig_type, tvb, offset, type_len, sig_type);
offset += type_len;
if (0 == strcmp(sig_type, "ssh-rsa")) {
offset += ssh_tree_add_mpint(tvb, offset, tree, hf_ssh_hostsig_rsa);
} else if (0 == strcmp(sig_type, "ssh-dss")) {
offset += ssh_tree_add_mpint(tvb, offset, tree, hf_ssh_hostsig_dsa);
} else if (g_str_has_prefix(sig_type, "ecdsa-sha2-")) {
// offset += ssh_tree_add_string(tvb, offset, tree,
// hf_ssh_hostkey_ecdsa_curve_id, hf_ssh_hostkey_ecdsa_curve_id_length);
// ssh_tree_add_string(tvb, offset, tree,
// hf_ssh_hostkey_ecdsa_q, hf_ssh_hostkey_ecdsa_q_length);
} else if (g_str_has_prefix(sig_type, "ssh-ed")) {
// ssh_tree_add_string(tvb, offset, tree,
// hf_ssh_hostkey_eddsa_key, hf_ssh_hostkey_eddsa_key_length);
} else {
remaining_len = sig_len - (type_len + 4);
proto_tree_add_item(tree, hf_ssh_hostsig_data, tvb, offset, remaining_len, ENC_NA);
}
if(offset-offset0!=(int)(4+sig_len)){
expert_add_info_format(pinfo, ti, &ei_ssh_packet_decode, "Decoded %d bytes, but packet length is %d bytes", offset-offset0, sig_len);
}
return 4+sig_len;
}
static int
ssh_dissect_key_exchange(tvbuff_t *tvb, packet_info *pinfo,
struct ssh_flow_data *global_data,
int offset, proto_tree *tree, int is_response,
gboolean *need_desegmentation)
{
guint plen, len;
guint8 padding_length;
guint remain_length;
int last_offset = offset;
guint msg_code;
guint seq_num = 0;
proto_item *ti;
proto_item *key_ex_tree = NULL;
const gchar *key_ex_title = "Key Exchange";
struct ssh_peer_data *peer_data = &global_data->peer_data[is_response];
/*
* We use "tvb_ensure_captured_length_remaining()" to make sure there
* actually *is* data remaining.
*
* This means we're guaranteed that "remain_length" is positive.
*/
remain_length = tvb_ensure_captured_length_remaining(tvb, offset);
/*
* Can we do reassembly?
*/
if (ssh_desegment && pinfo->can_desegment) {
/*
* Yes - would an SSH header starting at this offset
* be split across segment boundaries?
*/
if (remain_length < 4) {
/*
* Yes. Tell the TCP dissector where the data for
* this message starts in the data it handed us and
* that we need "some more data." Don't tell it
* exactly how many bytes we need because if/when we
* ask for even more (after the header) that will
* break reassembly.
*/
pinfo->desegment_offset = offset;
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
*need_desegmentation = TRUE;
return offset;
}
}
plen = tvb_get_ntohl(tvb, offset) ;
if (ssh_desegment && pinfo->can_desegment) {
if (plen +4 > remain_length) {
pinfo->desegment_offset = offset;
pinfo->desegment_len = plen+4 - remain_length;
*need_desegmentation = TRUE;
return offset;
}
}
/*
* Need to check plen > 0x80000000 here
*/
ti = proto_tree_add_uint(tree, hf_ssh_packet_length, tvb,
offset, 4, plen);
if (plen >= 0xffff) {
expert_add_info_format(pinfo, ti, &ei_ssh_packet_length, "Overly large number %d", plen);
plen = remain_length-4;
}
offset+=4;
/* padding length */
padding_length = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_ssh_padding_length, tvb, offset, 1, padding_length);
offset += 1;
if (global_data->kex)
key_ex_title = wmem_strdup_printf(wmem_packet_scope(), "%s (method:%s)", key_ex_title, global_data->kex);
key_ex_tree = proto_tree_add_subtree(tree, tvb, offset, plen-1, ett_key_exchange, NULL, key_ex_title);
/* msg_code */
msg_code = tvb_get_guint8(tvb, offset);
if (msg_code >= 30 && msg_code < 40) {
offset = global_data->kex_specific_dissector(msg_code, tvb, pinfo,
offset, key_ex_tree, global_data, &seq_num);
} else {
proto_tree_add_item(key_ex_tree, hf_ssh2_msg_code, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
col_append_sep_str(pinfo->cinfo, COL_INFO, NULL,
val_to_str(msg_code, ssh2_msg_vals, "Unknown (%u)"));
/* 16 bytes cookie */
switch(msg_code)
{
case SSH_MSG_KEXINIT:
offset = ssh_dissect_key_init(tvb, pinfo, offset, key_ex_tree, is_response, global_data);
if ((peer_data->frame_key_start == 0) || (peer_data->frame_key_start == pinfo->num)) {
if (!PINFO_FD_VISITED(pinfo)) {
peer_data->frame_key_start = pinfo->num;
if(global_data->peer_data[is_response].seq_num_kex_init == 0){
global_data->peer_data[is_response].seq_num_kex_init = global_data->peer_data[is_response].sequence_number;
global_data->peer_data[is_response].sequence_number++;
ssh_debug_printf("%s->sequence_number{SSH_MSG_KEXINIT=%d}++ > %d\n", is_response?"server":"client", global_data->peer_data[is_response].seq_num_kex_init, global_data->peer_data[is_response].sequence_number);
}
}
}
seq_num = global_data->peer_data[is_response].seq_num_kex_init;
break;
case SSH_MSG_NEWKEYS:
if (peer_data->frame_key_end == 0) {
peer_data->frame_key_end = pinfo->num;
peer_data->frame_key_end_offset = offset;
if(global_data->peer_data[is_response].seq_num_new_key == 0){
global_data->peer_data[is_response].seq_num_new_key = global_data->peer_data[is_response].sequence_number;
global_data->peer_data[is_response].sequence_number++;
ssh_debug_printf("%s->sequence_number{SSH_MSG_NEWKEYS=%d}++ > %d\n", is_response?"server":"client", global_data->peer_data[is_response].seq_num_new_key, global_data->peer_data[is_response].sequence_number);
}
// the client sent SSH_MSG_NEWKEYS
if (!is_response) {
ssh_debug_printf("Activating new keys for CLIENT => SERVER\n");
ssh_decryption_setup_cipher(&global_data->peer_data[CLIENT_PEER_DATA], &global_data->new_keys[0], &global_data->new_keys[2]);
ssh_decryption_setup_mac(&global_data->peer_data[CLIENT_PEER_DATA], &global_data->new_keys[4]);
}else{
ssh_debug_printf("Activating new keys for SERVER => CLIENT\n");
ssh_decryption_setup_cipher(&global_data->peer_data[SERVER_PEER_DATA], &global_data->new_keys[1], &global_data->new_keys[3]);
ssh_decryption_setup_mac(&global_data->peer_data[SERVER_PEER_DATA], &global_data->new_keys[5]);
}
}
seq_num = global_data->peer_data[is_response].seq_num_new_key;
break;
}
}
len = plen+4-padding_length-(offset-last_offset);
if (len > 0) {
proto_tree_add_item(key_ex_tree, hf_ssh_payload, tvb, offset, len, ENC_NA);
}
offset += len;
/* padding */
proto_tree_add_item(tree, hf_ssh_padding_string, tvb, offset, padding_length, ENC_NA);
offset+= padding_length;
proto_tree_add_uint(tree, hf_ssh_seq_num, tvb, offset, 0, seq_num);
return offset;
}
static int ssh_dissect_kex_dh(guint8 msg_code, tvbuff_t *tvb,
packet_info *pinfo, int offset, proto_tree *tree,
struct ssh_flow_data *global_data, guint *seq_num)
{
*seq_num = 0;
proto_tree_add_item(tree, hf_ssh2_kex_dh_msg_code, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
col_append_sep_str(pinfo->cinfo, COL_INFO, NULL,
val_to_str(msg_code, ssh2_kex_dh_msg_vals, "Unknown (%u)"));
switch (msg_code) {
case SSH_MSG_KEXDH_INIT:
// e (client ephemeral key public part)
if (!ssh_read_e(tvb, offset, global_data)) {
proto_tree_add_expert_format(tree, pinfo, &ei_ssh_invalid_keylen, tvb, offset, 2,
"Invalid key length: %u", tvb_get_ntohl(tvb, offset));
}
offset += ssh_tree_add_mpint(tvb, offset, tree, hf_ssh_dh_e);
if(global_data->peer_data[CLIENT_PEER_DATA].seq_num_dh_ini == 0){
global_data->peer_data[CLIENT_PEER_DATA].sequence_number++;
global_data->peer_data[CLIENT_PEER_DATA].seq_num_dh_ini = global_data->peer_data[CLIENT_PEER_DATA].sequence_number;
ssh_debug_printf("%s->sequence_number{SSH_MSG_KEXDH_INIT}++ > %d\n", CLIENT_PEER_DATA?"serveur":"client", global_data->peer_data[CLIENT_PEER_DATA].sequence_number);
}
*seq_num = global_data->peer_data[CLIENT_PEER_DATA].seq_num_dh_ini;
break;
case SSH_MSG_KEXDH_REPLY:
offset += ssh_tree_add_hostkey(tvb, offset, tree, "KEX host key",
ett_key_exchange_host_key, global_data);
// f (server ephemeral key public part), K_S (host key)
if (!ssh_read_f(tvb, offset, global_data)) {
proto_tree_add_expert_format(tree, pinfo, &ei_ssh_invalid_keylen, tvb, offset, 2,
"Invalid key length: %u", tvb_get_ntohl(tvb, offset));
}
ssh_choose_enc_mac(global_data);
ssh_keylog_hash_write_secret(global_data);
offset += ssh_tree_add_mpint(tvb, offset, tree, hf_ssh_dh_f);
offset += ssh_tree_add_hostsignature(tvb, pinfo, offset, tree, "KEX host signature",
ett_key_exchange_host_sig, global_data);
if(global_data->peer_data[SERVER_PEER_DATA].seq_num_dh_rep == 0){
global_data->peer_data[SERVER_PEER_DATA].sequence_number++;
global_data->peer_data[SERVER_PEER_DATA].seq_num_dh_rep = global_data->peer_data[SERVER_PEER_DATA].sequence_number;
ssh_debug_printf("%s->sequence_number{SSH_MSG_KEXDH_REPLY}++ > %d\n", SERVER_PEER_DATA?"serveur":"client", global_data->peer_data[SERVER_PEER_DATA].sequence_number);
}
*seq_num = global_data->peer_data[SERVER_PEER_DATA].seq_num_dh_rep;
break;
}
return offset;
}
static int ssh_dissect_kex_dh_gex(guint8 msg_code, tvbuff_t *tvb,
packet_info *pinfo, int offset, proto_tree *tree,
struct ssh_flow_data *global_data, guint *seq_num)
{
*seq_num = 0;
proto_tree_add_item(tree, hf_ssh2_kex_dh_gex_msg_code, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
col_append_sep_str(pinfo->cinfo, COL_INFO, NULL,
val_to_str(msg_code, ssh2_kex_dh_gex_msg_vals, "Unknown (%u)"));
switch (msg_code) {
case SSH_MSG_KEX_DH_GEX_REQUEST_OLD:
proto_tree_add_item(tree, hf_ssh_dh_gex_nbits, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
break;
case SSH_MSG_KEX_DH_GEX_GROUP:
#ifdef SSH_DECRYPTION_SUPPORTED
// p (Group modulo)
global_data->kex_gex_p = ssh_read_mpint(tvb, offset);
#endif
offset += ssh_tree_add_mpint(tvb, offset, tree, hf_ssh_dh_gex_p);
#ifdef SSH_DECRYPTION_SUPPORTED
// g (Group generator)
global_data->kex_gex_g = ssh_read_mpint(tvb, offset);
#endif
offset += ssh_tree_add_mpint(tvb, offset, tree, hf_ssh_dh_gex_g);
if(global_data->peer_data[SERVER_PEER_DATA].seq_num_gex_grp == 0){
global_data->peer_data[SERVER_PEER_DATA].sequence_number++;
global_data->peer_data[SERVER_PEER_DATA].seq_num_gex_grp = global_data->peer_data[SERVER_PEER_DATA].sequence_number;
ssh_debug_printf("%s->sequence_number{SSH_MSG_KEX_DH_GEX_GROUP}++ > %d\n", SERVER_PEER_DATA?"serveur":"client", global_data->peer_data[SERVER_PEER_DATA].sequence_number);
}
*seq_num = global_data->peer_data[SERVER_PEER_DATA].seq_num_gex_grp;
break;
case SSH_MSG_KEX_DH_GEX_INIT:
#ifdef SSH_DECRYPTION_SUPPORTED
// e (Client public key)
if (!ssh_read_e(tvb, offset, global_data)) {
proto_tree_add_expert_format(tree, pinfo, &ei_ssh_invalid_keylen, tvb, offset, 2,
"Invalid key length: %u", tvb_get_ntohl(tvb, offset));
}
#endif
offset += ssh_tree_add_mpint(tvb, offset, tree, hf_ssh_dh_e);
if(global_data->peer_data[CLIENT_PEER_DATA].seq_num_gex_ini == 0){
global_data->peer_data[CLIENT_PEER_DATA].sequence_number++;
global_data->peer_data[CLIENT_PEER_DATA].seq_num_gex_ini = global_data->peer_data[CLIENT_PEER_DATA].sequence_number;
ssh_debug_printf("%s->sequence_number{SSH_MSG_KEX_DH_GEX_INIT}++ > %d\n", CLIENT_PEER_DATA?"serveur":"client", global_data->peer_data[CLIENT_PEER_DATA].sequence_number);
}
*seq_num = global_data->peer_data[CLIENT_PEER_DATA].seq_num_gex_ini;
break;
case SSH_MSG_KEX_DH_GEX_REPLY:
offset += ssh_tree_add_hostkey(tvb, offset, tree, "KEX host key",
ett_key_exchange_host_key, global_data);
#ifdef SSH_DECRYPTION_SUPPORTED
if (!PINFO_FD_VISITED(pinfo)) {
ssh_read_f(tvb, offset, global_data);
// f (server ephemeral key public part), K_S (host key)
ssh_keylog_hash_write_secret(global_data);
}
ssh_choose_enc_mac(global_data);
ssh_keylog_hash_write_secret(global_data);
#endif
offset += ssh_tree_add_mpint(tvb, offset, tree, hf_ssh_dh_f);
offset += ssh_tree_add_hostsignature(tvb, pinfo, offset, tree, "KEX host signature",
ett_key_exchange_host_sig, global_data);
if(global_data->peer_data[SERVER_PEER_DATA].seq_num_gex_rep == 0){
global_data->peer_data[SERVER_PEER_DATA].sequence_number++;
global_data->peer_data[SERVER_PEER_DATA].seq_num_gex_rep = global_data->peer_data[SERVER_PEER_DATA].sequence_number;
ssh_debug_printf("%s->sequence_number{SSH_MSG_KEX_DH_GEX_REPLY}++ > %d\n", SERVER_PEER_DATA?"serveur":"client", global_data->peer_data[SERVER_PEER_DATA].sequence_number);
}
*seq_num = global_data->peer_data[SERVER_PEER_DATA].seq_num_gex_rep;
break;
case SSH_MSG_KEX_DH_GEX_REQUEST:{
if (!PINFO_FD_VISITED(pinfo)) {
ssh_hash_buffer_put_uint32(global_data->kex_gex_bits_min, tvb_get_ntohl(tvb, offset));
}
proto_tree_add_item(tree, hf_ssh_dh_gex_min, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
if (!PINFO_FD_VISITED(pinfo)) {
ssh_hash_buffer_put_uint32(global_data->kex_gex_bits_req, tvb_get_ntohl(tvb, offset));
}
proto_tree_add_item(tree, hf_ssh_dh_gex_nbits, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
if (!PINFO_FD_VISITED(pinfo)) {
ssh_hash_buffer_put_uint32(global_data->kex_gex_bits_max, tvb_get_ntohl(tvb, offset));
}
proto_tree_add_item(tree, hf_ssh_dh_gex_max, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
if(global_data->peer_data[CLIENT_PEER_DATA].seq_num_gex_req == 0){
global_data->peer_data[CLIENT_PEER_DATA].sequence_number++;
global_data->peer_data[CLIENT_PEER_DATA].seq_num_gex_req = global_data->peer_data[CLIENT_PEER_DATA].sequence_number;
ssh_debug_printf("%s->sequence_number{SSH_MSG_KEX_DH_GEX_REQUEST}++ > %d\n", CLIENT_PEER_DATA?"serveur":"client", global_data->peer_data[CLIENT_PEER_DATA].sequence_number);
}
*seq_num = global_data->peer_data[CLIENT_PEER_DATA].seq_num_gex_req;
break;
}
}
return offset;
}
static int
ssh_dissect_kex_ecdh(guint8 msg_code, tvbuff_t *tvb,
packet_info *pinfo, int offset, proto_tree *tree,
struct ssh_flow_data *global_data, guint *seq_num)
{
proto_tree_add_item(tree, hf_ssh2_kex_ecdh_msg_code, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
col_append_sep_str(pinfo->cinfo, COL_INFO, NULL,
val_to_str(msg_code, ssh2_kex_ecdh_msg_vals, "Unknown (%u)"));
switch (msg_code) {
case SSH_MSG_KEX_ECDH_INIT:
if (!ssh_read_e(tvb, offset, global_data)) {
proto_tree_add_expert_format(tree, pinfo, &ei_ssh_invalid_keylen, tvb, offset, 2,
"Invalid key length: %u", tvb_get_ntohl(tvb, offset));
}
if (!PINFO_FD_VISITED(pinfo)) {
if(global_data->peer_data[CLIENT_PEER_DATA].seq_num_ecdh_ini == 0){
global_data->peer_data[CLIENT_PEER_DATA].seq_num_ecdh_ini = global_data->peer_data[CLIENT_PEER_DATA].sequence_number;
global_data->peer_data[CLIENT_PEER_DATA].sequence_number++;
ssh_debug_printf("%s->sequence_number{SSH_MSG_KEX_ECDH_INIT=%d}++ > %d\n", CLIENT_PEER_DATA?"server":"client", global_data->peer_data[CLIENT_PEER_DATA].seq_num_ecdh_ini, global_data->peer_data[CLIENT_PEER_DATA].sequence_number);
}
}
*seq_num = global_data->peer_data[CLIENT_PEER_DATA].seq_num_ecdh_ini;
offset += ssh_tree_add_string(tvb, offset, tree, hf_ssh_ecdh_q_c, hf_ssh_ecdh_q_c_length);
break;
case SSH_MSG_KEX_ECDH_REPLY:
offset += ssh_tree_add_hostkey(tvb, offset, tree, "KEX host key",
ett_key_exchange_host_key, global_data);
if (!ssh_read_f(tvb, offset, global_data)){
proto_tree_add_expert_format(tree, pinfo, &ei_ssh_invalid_keylen, tvb, offset, 2,
"Invalid key length: %u", tvb_get_ntohl(tvb, offset));
}
ssh_choose_enc_mac(global_data);
ssh_keylog_hash_write_secret(global_data);
if(global_data->peer_data[SERVER_PEER_DATA].seq_num_ecdh_rep == 0){
global_data->peer_data[SERVER_PEER_DATA].seq_num_ecdh_rep = global_data->peer_data[SERVER_PEER_DATA].sequence_number;
global_data->peer_data[SERVER_PEER_DATA].sequence_number++;
ssh_debug_printf("%s->sequence_number{SSH_MSG_KEX_ECDH_REPLY=%d}++ > %d\n", SERVER_PEER_DATA?"server":"client", global_data->peer_data[SERVER_PEER_DATA].seq_num_ecdh_rep, global_data->peer_data[SERVER_PEER_DATA].sequence_number);
}
*seq_num = global_data->peer_data[SERVER_PEER_DATA].seq_num_ecdh_rep;
offset += ssh_tree_add_string(tvb, offset, tree, hf_ssh_ecdh_q_s, hf_ssh_ecdh_q_s_length);
offset += ssh_tree_add_hostsignature(tvb, pinfo, offset, tree, "KEX host signature",
ett_key_exchange_host_sig, global_data);
break;
}
return offset;
}
static int
ssh_try_dissect_encrypted_packet(tvbuff_t *tvb, packet_info *pinfo,
struct ssh_peer_data *peer_data, int offset, proto_tree *tree)
{
gboolean can_decrypt = peer_data->cipher != NULL;
if (can_decrypt) {
return ssh_decrypt_packet(tvb, pinfo, peer_data, offset, tree);
}
return ssh_dissect_encrypted_packet(tvb, pinfo, peer_data, offset, tree);
}
static int
ssh_dissect_encrypted_packet(tvbuff_t *tvb, packet_info *pinfo,
struct ssh_peer_data *peer_data,
int offset, proto_tree *tree)
{
gint len;
guint plen;
len = tvb_reported_length_remaining(tvb, offset);
col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "Encrypted packet (len=%d)", len);
if (tree) {
gint encrypted_len = len;
if (len > 4 && peer_data->length_is_plaintext) {
plen = tvb_get_ntohl(tvb, offset) ;
proto_tree_add_uint(tree, hf_ssh_packet_length, tvb, offset, 4, plen);
encrypted_len -= 4;
}
else if (len > 4) {
proto_tree_add_item(tree, hf_ssh_packet_length_encrypted, tvb, offset, 4, ENC_NA);
encrypted_len -= 4;
}
if (peer_data->mac_length>0)
encrypted_len -= peer_data->mac_length;
proto_tree_add_item(tree, hf_ssh_encrypted_packet,
tvb, offset+4, encrypted_len, ENC_NA);
if (peer_data->mac_length>0)
proto_tree_add_item(tree, hf_ssh_mac_string,
tvb, offset+4+encrypted_len,
peer_data->mac_length, ENC_NA);
}
offset += len;
return offset;
}
static int
ssh_dissect_protocol(tvbuff_t *tvb, packet_info *pinfo,
struct ssh_flow_data *global_data,
int offset, proto_tree *tree, int is_response, guint * version,
gboolean *need_desegmentation)
{
guint remain_length;
gint linelen, protolen;
/*
* If the first packet do not contain the banner,
* it is dump in the middle of a flow or not a ssh at all
*/
if (tvb_strncaseeql(tvb, offset, "SSH-", 4) != 0) {
offset = ssh_dissect_encrypted_packet(tvb, pinfo,
&global_data->peer_data[is_response], offset, tree);
return offset;
}
if (!is_response) {
if (tvb_strncaseeql(tvb, offset, "SSH-2.", 6) == 0) {
*(version) = SSH_VERSION_2;
} else if (tvb_strncaseeql(tvb, offset, "SSH-1.99-", 9) == 0) {
*(version) = SSH_VERSION_2;
} else if (tvb_strncaseeql(tvb, offset, "SSH-1.", 6) == 0) {
*(version) = SSH_VERSION_1;
}
}
/*
* We use "tvb_ensure_captured_length_remaining()" to make sure there
* actually *is* data remaining.
*
* This means we're guaranteed that "remain_length" is positive.
*/
remain_length = tvb_ensure_captured_length_remaining(tvb, offset);
/*linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
*/
linelen = tvb_find_guint8(tvb, offset, -1, '\n');
if (ssh_desegment && pinfo->can_desegment) {
if (linelen == -1 || remain_length < (guint)linelen-offset) {
pinfo->desegment_offset = offset;
pinfo->desegment_len = linelen-remain_length;
*need_desegmentation = TRUE;
return offset;
}
}
if (linelen == -1) {
/* XXX - reassemble across segment boundaries? */
linelen = remain_length;
protolen = linelen;
} else {
linelen = linelen - offset + 1;
if (linelen > 1 && tvb_get_guint8(tvb, offset + linelen - 2) == '\r')
protolen = linelen - 2;
else
protolen = linelen - 1;
}
col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "Protocol (%s)",
tvb_format_text(pinfo->pool, tvb, offset, protolen));
// V_C / V_S (client and server identification strings) RFC4253 4.2
// format: SSH-protoversion-softwareversion SP comments [CR LF not incl.]
if (!PINFO_FD_VISITED(pinfo)) {
gchar *data = (gchar *)tvb_memdup(wmem_packet_scope(), tvb, offset, protolen);
if(!is_response){
ssh_hash_buffer_put_string(global_data->kex_client_version, data, protolen);
}else{
ssh_hash_buffer_put_string(global_data->kex_server_version, data, protolen);
}
}
proto_tree_add_item(tree, hf_ssh_protocol,
tvb, offset, protolen, ENC_ASCII);
offset += linelen;
return offset;
}
static void
ssh_set_mac_length(struct ssh_peer_data *peer_data)
{
char *size_str;
guint32 size = 0;
char *mac_name = peer_data->mac;
char *strip;
if (!mac_name)
return;
/* wmem_strdup() never returns NULL */
mac_name = wmem_strdup(NULL, (const gchar *)mac_name);
/* strip trailing "[email protected]" or "@openssh.com" */
strip = strstr(mac_name, "[email protected]");
if (strip) {
peer_data->length_is_plaintext = 1;
*strip = '\0';
}
else {
strip = strstr(mac_name, "@openssh.com");
if (strip) *strip = '\0';
}
size_str = g_strrstr(mac_name, "-");
if (size_str && ws_strtou32(size_str + 1, NULL, &size) && size > 0 && size % 8 == 0) {
peer_data->mac_length = size / 8;
}
else if (strcmp(mac_name, "hmac-sha1") == 0) {
peer_data->mac_length = 20;
}
else if (strcmp(mac_name, "hmac-md5") == 0) {
peer_data->mac_length = 16;
}
else if (strcmp(mac_name, "hmac-ripemd160") == 0) {
peer_data->mac_length = 20;
}
else if (strcmp(mac_name, "none") == 0) {
peer_data->mac_length = 0;
}
wmem_free(NULL, mac_name);
}
static void ssh_set_kex_specific_dissector(struct ssh_flow_data *global_data)
{
const char *kex_name = global_data->kex;
if (!kex_name) return;
if (strcmp(kex_name, "diffie-hellman-group-exchange-sha1") == 0 ||
strcmp(kex_name, "diffie-hellman-group-exchange-sha256") == 0)
{
global_data->kex_specific_dissector = ssh_dissect_kex_dh_gex;
}
else if (g_str_has_prefix(kex_name, "ecdh-sha2-") ||
strcmp(kex_name, "[email protected]") == 0 ||
strcmp(kex_name, "curve25519-sha256") == 0 ||
strcmp(kex_name, "curve448-sha512") == 0)
{
global_data->kex_specific_dissector = ssh_dissect_kex_ecdh;
}
else if (strcmp(kex_name, "diffie-hellman-group14-sha256") == 0 ||
strcmp(kex_name, "diffie-hellman-group16-sha512") == 0 ||
strcmp(kex_name, "diffie-hellman-group18-sha512") == 0 ||
strcmp(kex_name, "diffie-hellman-group1-sha1") == 0 ||
strcmp(kex_name, "diffie-hellman-group14-sha1") == 0)
{
global_data->kex_specific_dissector = ssh_dissect_kex_dh;
}
}
static gint
ssh_gslist_compare_strings(gconstpointer a, gconstpointer b)
{
if (a == NULL && b == NULL)
return 0;
if (a == NULL)
return -1;
if (b == NULL)
return 1;
return strcmp((const char*)a, (const char*)b);
}
/* expects that *result is NULL */
static void
ssh_choose_algo(gchar *client, gchar *server, gchar **result)
{
gchar **server_strings = NULL;
gchar **client_strings = NULL;
gchar **step;
GSList *server_list = NULL;
if (!client || !server || !result || *result)
return;
server_strings = g_strsplit(server, ",", 0);
for (step = server_strings; *step; step++) {
server_list = g_slist_append(server_list, *step);
}
client_strings = g_strsplit(client, ",", 0);
for (step = client_strings; *step; step++) {
GSList *agreed;
if ((agreed = g_slist_find_custom(server_list, *step, ssh_gslist_compare_strings))) {
*result = wmem_strdup(wmem_file_scope(), (const gchar *)agreed->data);
break;
}
}
g_strfreev(client_strings);
g_slist_free(server_list);
g_strfreev(server_strings);
}
static int
ssh_dissect_key_init(tvbuff_t *tvb, packet_info *pinfo, int offset,
proto_tree *tree, int is_response, struct ssh_flow_data *global_data)
{
int start_offset = offset;
int payload_length;
wmem_strbuf_t *hassh_algo;
gchar *hassh;
proto_item *tf, *ti;
proto_tree *key_init_tree;
struct ssh_peer_data *peer_data = &global_data->peer_data[is_response];
key_init_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_key_init, &tf, "Algorithms");
if (!PINFO_FD_VISITED(pinfo)) {
peer_data->bn_cookie = ssh_kex_make_bignum(tvb_get_ptr(tvb, offset, 16), 16);
}
proto_tree_add_item(key_init_tree, hf_ssh_cookie,
tvb, offset, 16, ENC_NA);
offset += 16;
offset = ssh_dissect_proposal(tvb, offset, key_init_tree,
hf_ssh_kex_algorithms_length, hf_ssh_kex_algorithms,
&peer_data->kex_proposal);
offset = ssh_dissect_proposal(tvb, offset, key_init_tree,
hf_ssh_server_host_key_algorithms_length,
hf_ssh_server_host_key_algorithms, NULL);
offset = ssh_dissect_proposal(tvb, offset, key_init_tree,
hf_ssh_encryption_algorithms_client_to_server_length,
hf_ssh_encryption_algorithms_client_to_server,
&peer_data->enc_proposals[CLIENT_TO_SERVER_PROPOSAL]);
offset = ssh_dissect_proposal(tvb, offset, key_init_tree,
hf_ssh_encryption_algorithms_server_to_client_length,
hf_ssh_encryption_algorithms_server_to_client,
&peer_data->enc_proposals[SERVER_TO_CLIENT_PROPOSAL]);
offset = ssh_dissect_proposal(tvb, offset, key_init_tree,
hf_ssh_mac_algorithms_client_to_server_length,
hf_ssh_mac_algorithms_client_to_server,
&peer_data->mac_proposals[CLIENT_TO_SERVER_PROPOSAL]);
offset = ssh_dissect_proposal(tvb, offset, key_init_tree,
hf_ssh_mac_algorithms_server_to_client_length,
hf_ssh_mac_algorithms_server_to_client,
&peer_data->mac_proposals[SERVER_TO_CLIENT_PROPOSAL]);
offset = ssh_dissect_proposal(tvb, offset, key_init_tree,
hf_ssh_compression_algorithms_client_to_server_length,
hf_ssh_compression_algorithms_client_to_server,
&peer_data->comp_proposals[CLIENT_TO_SERVER_PROPOSAL]);
offset = ssh_dissect_proposal(tvb, offset, key_init_tree,
hf_ssh_compression_algorithms_server_to_client_length,
hf_ssh_compression_algorithms_server_to_client,
&peer_data->comp_proposals[SERVER_TO_CLIENT_PROPOSAL]);
offset = ssh_dissect_proposal(tvb, offset, key_init_tree,
hf_ssh_languages_client_to_server_length,
hf_ssh_languages_client_to_server, NULL);
offset = ssh_dissect_proposal(tvb, offset, key_init_tree,
hf_ssh_languages_server_to_client_length,
hf_ssh_languages_server_to_client, NULL);
proto_tree_add_item(key_init_tree, hf_ssh_first_kex_packet_follows,
tvb, offset, 1, ENC_BIG_ENDIAN);
offset+=1;
proto_tree_add_item(key_init_tree, hf_ssh_kex_reserved,
tvb, offset, 4, ENC_NA);
offset+=4;
hassh_algo = wmem_strbuf_new(wmem_packet_scope(), "");
if(!is_response) {
wmem_strbuf_append_printf(hassh_algo, "%s;%s;%s;%s", peer_data->kex_proposal, peer_data->enc_proposals[CLIENT_TO_SERVER_PROPOSAL],
peer_data->mac_proposals[CLIENT_TO_SERVER_PROPOSAL], peer_data->comp_proposals[CLIENT_TO_SERVER_PROPOSAL]);
hassh = g_compute_checksum_for_string(G_CHECKSUM_MD5, wmem_strbuf_get_str(hassh_algo), wmem_strbuf_get_len(hassh_algo));
ti = proto_tree_add_string(key_init_tree, hf_ssh_kex_hassh_algo, tvb, offset, 0, wmem_strbuf_get_str(hassh_algo));
proto_item_set_generated(ti);
ti = proto_tree_add_string(key_init_tree, hf_ssh_kex_hassh, tvb, offset, 0, hassh);
proto_item_set_generated(ti);
g_free(hassh);
} else {
wmem_strbuf_append_printf(hassh_algo, "%s;%s;%s;%s", peer_data->kex_proposal, peer_data->enc_proposals[SERVER_TO_CLIENT_PROPOSAL],
peer_data->mac_proposals[SERVER_TO_CLIENT_PROPOSAL], peer_data->comp_proposals[SERVER_TO_CLIENT_PROPOSAL]);
hassh = g_compute_checksum_for_string(G_CHECKSUM_MD5, wmem_strbuf_get_str(hassh_algo), wmem_strbuf_get_len(hassh_algo));
ti = proto_tree_add_string(key_init_tree, hf_ssh_kex_hasshserver_algo, tvb, offset, 0, wmem_strbuf_get_str(hassh_algo));
proto_item_set_generated(ti);
ti = proto_tree_add_string(key_init_tree, hf_ssh_kex_hasshserver, tvb, offset, 0, hassh);
proto_item_set_generated(ti);
g_free(hassh);
}
if (global_data->peer_data[CLIENT_PEER_DATA].kex_proposal &&
global_data->peer_data[SERVER_PEER_DATA].kex_proposal &&
!global_data->kex)
{
/* Note: we're ignoring first_kex_packet_follows. */
ssh_choose_algo(
global_data->peer_data[CLIENT_PEER_DATA].kex_proposal,
global_data->peer_data[SERVER_PEER_DATA].kex_proposal,
&global_data->kex);
ssh_set_kex_specific_dissector(global_data);
}
payload_length = offset - start_offset;
if (tf != NULL) {
proto_item_set_len(tf, payload_length);
}
// I_C / I_S (client and server SSH_MSG_KEXINIT payload) RFC4253 4.2
if (!PINFO_FD_VISITED(pinfo)) {
gchar *data = (gchar *)wmem_alloc(wmem_packet_scope(), payload_length + 1);
tvb_memcpy(tvb, data + 1, start_offset, payload_length);
data[0] = SSH_MSG_KEXINIT;
if(is_response){
ssh_hash_buffer_put_string(global_data->kex_server_key_exchange_init, data, payload_length + 1);
}else{
ssh_hash_buffer_put_string(global_data->kex_client_key_exchange_init, data, payload_length + 1);
}
}
return offset;
}
static int
ssh_dissect_proposal(tvbuff_t *tvb, int offset, proto_tree *tree,
int hf_index_length, int hf_index_value, char **store)
{
guint32 len = tvb_get_ntohl(tvb, offset);
proto_tree_add_uint(tree, hf_index_length, tvb, offset, 4, len);
offset += 4;
proto_tree_add_item(tree, hf_index_value, tvb, offset, len,
ENC_ASCII);
if (store)
*store = (char *) tvb_get_string_enc(wmem_file_scope(), tvb, offset, len, ENC_ASCII);
offset += len;
return offset;
}
static void
ssh_keylog_read_file(void)
{
if (!pref_keylog_file || !*pref_keylog_file) {
ws_debug("no keylog file preference set");
return;
}
if (ssh_keylog_file && file_needs_reopen(ws_fileno(ssh_keylog_file),
pref_keylog_file)) {
ssh_keylog_reset();
g_hash_table_remove_all(ssh_master_key_map);
}
if (!ssh_keylog_file) {
ssh_keylog_file = ws_fopen(pref_keylog_file, "r");
if (!ssh_keylog_file) {
ws_debug("ssh: failed to open key log file %s: %s",
pref_keylog_file, g_strerror(errno));
return;
}
}
/* File format: each line follows the format "<cookie> <type> <key>".
* <cookie> is the hex-encoded (client or server) 16 bytes cookie
* (32 characters) found in the SSH_MSG_KEXINIT of the endpoint whose
* private random is disclosed.
* <type> is either SHARED_SECRET or PRIVATE_KEY depending on the
* type of key provided. PRIVAT_KEY is only supported for DH,
* DH group exchange, and ECDH (including Curve25519) key exchanges.
* <key> is the private random number that is used to generate the DH
* negotiation (length depends on algorithm). In RFC4253 it is called
* x for the client and y for the server.
* For openssh and DH group exchange, it can be retrieved using
* DH_get0_key(kex->dh, NULL, &server_random)
* for groupN in file kexdh.c function kex_dh_compute_key
* for custom group in file kexgexs.c function input_kex_dh_gex_init
* For openssh and curve25519, it can be found in function kex_c25519_enc
* in variable server_key. One may also provide the shared secret
* directly if <type> is set to SHARED_SECRET.
*
* Example:
* 90d886612f9c35903db5bb30d11f23c2 PRIVATE_KEY DEF830C22F6C927E31972FFB20B46C96D0A5F2D5E7BE5A3A8804D6BFC431619ED10AF589EEDFF4750DEA00EFD7AFDB814B6F3528729692B1F2482041521AE9DC
*/
for (;;) {
char buf[512];
buf[0] = 0;
if (!fgets(buf, sizeof(buf), ssh_keylog_file)) {
if (ferror(ssh_keylog_file)) {
ws_debug("Error while reading %s, closing it.", pref_keylog_file);
ssh_keylog_reset();
g_hash_table_remove_all(ssh_master_key_map);
}
break;
}
size_t len = strlen(buf);
while(len>0 && (buf[len-1]=='\r' || buf[len-1]=='\n')){len-=1;buf[len]=0;}
ssh_keylog_process_line(buf);
}
}
static void
ssh_keylog_process_lines(const guint8 *data, guint datalen)
{
const char *next_line = (const char *)data;
const char *line_end = next_line + datalen;
while (next_line && next_line < line_end) {
const char *line = next_line;
next_line = (const char *)memchr(line, '\n', line_end - line);
gssize linelen;
if (next_line) {
linelen = next_line - line;
next_line++; /* drop LF */
} else {
linelen = (gssize)(line_end - line);
}
if (linelen > 0 && line[linelen - 1] == '\r') {
linelen--; /* drop CR */
}
ssh_debug_printf(" checking keylog line: %.*s\n", (int)linelen, line);
gchar * strippedline = g_strndup(line, linelen);
ssh_keylog_process_line(strippedline);
g_free(strippedline);
}
}
static void
ssh_keylog_process_line(const char *line)
{
ws_noisy("ssh: process line: %s", line);
gchar **split = g_strsplit(line, " ", 3);
gchar *cookie, *type, *key;
size_t cookie_len, key_len;
if (g_strv_length(split) == 3) {
// New format: [hex-encoded cookie] [key type] [hex-encoded key material]
cookie = split[0];
type = split[1];
key = split[2];
} else if (g_strv_length(split) == 2) {
// Old format: [hex-encoded cookie] [hex-encoded private key]
ws_debug("ssh keylog: detected old keylog format without explicit key type");
type = "PRIVATE_KEY";
cookie = split[0];
key = split[1];
} else {
ws_debug("ssh keylog: invalid format");
g_strfreev(split);
return;
}
key_len = strlen(key);
cookie_len = strlen(cookie);
if(key_len & 1){
ws_debug("ssh keylog: invalid format (key could at least be even!)");
g_strfreev(split);
return;
}
if(cookie_len & 1){
ws_debug("ssh keylog: invalid format (cookie could at least be even!)");
g_strfreev(split);
return;
}
ssh_bignum * bn_cookie = ssh_kex_make_bignum(NULL, (guint)(cookie_len/2));
ssh_bignum * bn_priv = ssh_kex_make_bignum(NULL, (guint)(key_len/2));
guint8 c;
for (size_t i = 0; i < key_len/2; i ++) {
gchar v0 = key[i * 2];
gint8 h0 = (v0>='0' && v0<='9')?v0-'0':(v0>='a' && v0<='f')?v0-'a'+10:(v0>='A' && v0<='F')?v0-'A'+10:-1;
gchar v1 = key[i * 2 + 1];
gint8 h1 = (v1>='0' && v1<='9')?v1-'0':(v1>='a' && v1<='f')?v1-'a'+10:(v1>='A' && v1<='F')?v1-'A'+10:-1;
if (h0==-1 || h1==-1) {
ws_debug("ssh: can't process key, invalid hex number: %c%c", v0, v1);
g_strfreev(split);
return;
}
c = (h0 << 4) | h1;
bn_priv->data[i] = c;
}
for (size_t i = 0; i < cookie_len/2; i ++) {
gchar v0 = cookie[i * 2];
gint8 h0 = (v0>='0' && v0<='9')?v0-'0':(v0>='a' && v0<='f')?v0-'a'+10:(v0>='A' && v0<='F')?v0-'A'+10:-1;
gchar v1 = cookie[i * 2 + 1];
gint8 h1 = (v1>='0' && v1<='9')?v1-'0':(v1>='a' && v1<='f')?v1-'a'+10:(v1>='A' && v1<='F')?v1-'A'+10:-1;
if (h0==-1 || h1==-1) {
ws_debug("ssh: can't process cookie, invalid hex number: %c%c", v0, v1);
g_strfreev(split);
return;
}
c = (h0 << 4) | h1;
bn_cookie->data[i] = c;
}
ssh_bignum * bn_priv_ht = g_new(ssh_bignum, 1);
bn_priv_ht->length = bn_priv->length;
bn_priv_ht->data = (guint8 *) g_memdup2(bn_priv->data, bn_priv->length);
ssh_bignum * bn_cookie_ht = g_new(ssh_bignum, 1);
bn_cookie_ht->length = bn_cookie->length;
bn_cookie_ht->data = (guint8 *) g_memdup2(bn_cookie->data, bn_cookie->length);
gchar * type_ht = (gchar *) g_memdup2(type, strlen(type) + 1);
ssh_key_map_entry_t * entry_ht = g_new(ssh_key_map_entry_t, 1);
entry_ht->type = type_ht;
entry_ht->key_material = bn_priv_ht;
g_hash_table_insert(ssh_master_key_map, bn_cookie_ht, entry_ht);
g_strfreev(split);
}
static void
ssh_keylog_reset(void)
{
if (ssh_keylog_file) {
fclose(ssh_keylog_file);
ssh_keylog_file = NULL;
}
}
static guint
ssh_kex_type(gchar *type)
{
if (type) {
if (g_str_has_prefix(type, "curve25519")) {
return SSH_KEX_CURVE25519;
}else if (g_str_has_prefix(type, "diffie-hellman-group-exchange")) {
return SSH_KEX_DH_GEX;
}else if (g_str_has_prefix(type, "diffie-hellman-group14")) {
return SSH_KEX_DH_GROUP14;
}else if (g_str_has_prefix(type, "diffie-hellman-group16")) {
return SSH_KEX_DH_GROUP16;
}else if (g_str_has_prefix(type, "diffie-hellman-group18")) {
return SSH_KEX_DH_GROUP18;
}else if (g_str_has_prefix(type, "diffie-hellman-group1")) {
return SSH_KEX_DH_GROUP1;
}
}
return 0;
}
static guint
ssh_kex_hash_type(gchar *type_string)
{
if (type_string && g_str_has_suffix(type_string, "sha1")) {
return SSH_KEX_HASH_SHA1;
}else if (type_string && g_str_has_suffix(type_string, "sha256")) {
return SSH_KEX_HASH_SHA256;
}else if (type_string && g_str_has_suffix(type_string, "sha512")) {
return SSH_KEX_HASH_SHA512;
} else {
ws_debug("hash type %s not supported", type_string);
return 0;
}
}
static ssh_bignum *
ssh_kex_make_bignum(const guint8 *data, guint length)
{
// 512 bytes (4096 bits) is the maximum bignum size we're supporting
// Actually we need 513 bytes, to make provision for signed values
// Diffie-Hellman group 18 has 8192 bits
if (length == 0 || length > 1025) {
return NULL;
}
ssh_bignum *bn = wmem_new0(wmem_file_scope(), ssh_bignum);
bn->data = (guint8 *)wmem_alloc0(wmem_file_scope(), length);
if (data) {
memcpy(bn->data, data, length);
}
bn->length = length;
return bn;
}
static gboolean
ssh_read_e(tvbuff_t *tvb, int offset, struct ssh_flow_data *global_data)
{
// store the client's public part (e) for later usage
guint32 length = tvb_get_ntohl(tvb, offset);
global_data->kex_e = ssh_kex_make_bignum(NULL, length);
if (!global_data->kex_e) {
return false;
}
tvb_memcpy(tvb, global_data->kex_e->data, offset + 4, length);
return true;
}
static gboolean
ssh_read_f(tvbuff_t *tvb, int offset, struct ssh_flow_data *global_data)
{
// store the server's public part (f) for later usage
guint32 length = tvb_get_ntohl(tvb, offset);
global_data->kex_f = ssh_kex_make_bignum(NULL, length);
if (!global_data->kex_f) {
return false;
}
tvb_memcpy(tvb, global_data->kex_f->data, offset + 4, length);
return true;
}
#ifdef SSH_DECRYPTION_SUPPORTED
static ssh_bignum *
ssh_read_mpint(tvbuff_t *tvb, int offset)
{
// store the DH group modulo (p) for later usage
int length = tvb_get_ntohl(tvb, offset);
ssh_bignum * bn = ssh_kex_make_bignum(NULL, length);
if (!bn) {
ws_debug("invalid bignum length %u", length);
return NULL;
}
tvb_memcpy(tvb, bn->data, offset + 4, length);
return bn;
}
#endif //def SSH_DECRYPTION_SUPPORTED
static void
ssh_keylog_hash_write_secret(struct ssh_flow_data *global_data)
{
/*
* This computation is defined differently for each key exchange method:
* https://tools.ietf.org/html/rfc4253#page-23
* https://tools.ietf.org/html/rfc5656#page-8
* https://tools.ietf.org/html/rfc4419#page-4
* All key exchange methods:
* https://www.iana.org/assignments/ssh-parameters/ssh-parameters.xhtml#ssh-parameters-16
*/
gcry_md_hd_t hd;
ssh_key_map_entry_t *entry;
ssh_bignum *secret = NULL;
int length;
gboolean client_cookie = FALSE;
ssh_keylog_read_file();
guint kex_type = ssh_kex_type(global_data->kex);
guint kex_hash_type = ssh_kex_hash_type(global_data->kex);
entry = (ssh_key_map_entry_t *)g_hash_table_lookup(ssh_master_key_map, global_data->peer_data[SERVER_PEER_DATA].bn_cookie);
if (!entry) {
entry = (ssh_key_map_entry_t *)g_hash_table_lookup(ssh_master_key_map, global_data->peer_data[CLIENT_PEER_DATA].bn_cookie);
client_cookie = TRUE;
}
if (!entry) {
ws_debug("ssh decryption: no entry in keylog file for this session");
global_data->do_decrypt = FALSE;
return;
}
if (!strcmp(entry->type, "PRIVATE_KEY")) {
if (client_cookie) {
secret = ssh_kex_shared_secret(kex_type, global_data->kex_f, entry->key_material, global_data->kex_gex_p);
} else {
secret = ssh_kex_shared_secret(kex_type, global_data->kex_e, entry->key_material, global_data->kex_gex_p);
}
} else if (!strcmp(entry->type, "SHARED_SECRET")) {
secret = ssh_kex_make_bignum(entry->key_material->data, entry->key_material->length);
} else {
ws_debug("ssh decryption: unknown key type in keylog file");
global_data->do_decrypt = FALSE;
return;
}
if (!secret) {
ws_debug("ssh decryption: no key material for this session");
global_data->do_decrypt = FALSE;
return;
}
// shared secret data needs to be written as an mpint, and we need it later
if (secret->data[0] & 0x80) { // Stored in Big endian
length = secret->length + 1;
gchar *tmp = (gchar *)wmem_alloc0(wmem_packet_scope(), length);
memcpy(tmp + 1, secret->data, secret->length);
tmp[0] = 0;
secret->data = tmp;
secret->length = length;
}
ssh_hash_buffer_put_string(global_data->kex_shared_secret, secret->data, secret->length);
wmem_array_t * kex_gex_p = wmem_array_new(wmem_packet_scope(), 1);
if(global_data->kex_gex_p){ssh_hash_buffer_put_string(kex_gex_p, global_data->kex_gex_p->data, global_data->kex_gex_p->length);}
wmem_array_t * kex_gex_g = wmem_array_new(wmem_packet_scope(), 1);
if(global_data->kex_gex_g){ssh_hash_buffer_put_string(kex_gex_g, global_data->kex_gex_g->data, global_data->kex_gex_g->length);}
wmem_array_t * kex_e = wmem_array_new(wmem_packet_scope(), 1);
if(global_data->kex_e){ssh_hash_buffer_put_string(kex_e, global_data->kex_e->data, global_data->kex_e->length);}
wmem_array_t * kex_f = wmem_array_new(wmem_packet_scope(), 1);
if(global_data->kex_f){ssh_hash_buffer_put_string(kex_f, global_data->kex_f->data, global_data->kex_f->length);}
wmem_array_t * kex_hash_buffer = wmem_array_new(wmem_packet_scope(), 1);
ssh_print_data("client_version", (const guchar *)wmem_array_get_raw(global_data->kex_client_version), wmem_array_get_count(global_data->kex_client_version));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(global_data->kex_client_version), wmem_array_get_count(global_data->kex_client_version));
ssh_print_data("server_version", (const guchar *)wmem_array_get_raw(global_data->kex_server_version), wmem_array_get_count(global_data->kex_server_version));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(global_data->kex_server_version), wmem_array_get_count(global_data->kex_server_version));
ssh_print_data("client_key_exchange_init", (const guchar *)wmem_array_get_raw(global_data->kex_client_key_exchange_init), wmem_array_get_count(global_data->kex_client_key_exchange_init));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(global_data->kex_client_key_exchange_init), wmem_array_get_count(global_data->kex_client_key_exchange_init));
ssh_print_data("server_key_exchange_init", (const guchar *)wmem_array_get_raw(global_data->kex_server_key_exchange_init), wmem_array_get_count(global_data->kex_server_key_exchange_init));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(global_data->kex_server_key_exchange_init), wmem_array_get_count(global_data->kex_server_key_exchange_init));
ssh_print_data("kex_server_host_key_blob", (const guchar *)wmem_array_get_raw(global_data->kex_server_host_key_blob), wmem_array_get_count(global_data->kex_server_host_key_blob));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(global_data->kex_server_host_key_blob), wmem_array_get_count(global_data->kex_server_host_key_blob));
if(kex_type==SSH_KEX_DH_GEX){
ssh_print_data("kex_gex_bits_min", (const guchar *)wmem_array_get_raw(global_data->kex_gex_bits_min), wmem_array_get_count(global_data->kex_gex_bits_min));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(global_data->kex_gex_bits_min), wmem_array_get_count(global_data->kex_gex_bits_min));
ssh_print_data("kex_gex_bits_req", (const guchar *)wmem_array_get_raw(global_data->kex_gex_bits_req), wmem_array_get_count(global_data->kex_gex_bits_req));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(global_data->kex_gex_bits_req), wmem_array_get_count(global_data->kex_gex_bits_req));
ssh_print_data("kex_gex_bits_max", (const guchar *)wmem_array_get_raw(global_data->kex_gex_bits_max), wmem_array_get_count(global_data->kex_gex_bits_max));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(global_data->kex_gex_bits_max), wmem_array_get_count(global_data->kex_gex_bits_max));
ssh_print_data("key modulo (p)", (const guchar *)wmem_array_get_raw(kex_gex_p), wmem_array_get_count(kex_gex_p));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(kex_gex_p), wmem_array_get_count(kex_gex_p));
ssh_print_data("key base (g)", (const guchar *)wmem_array_get_raw(kex_gex_g), wmem_array_get_count(kex_gex_g));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(kex_gex_g), wmem_array_get_count(kex_gex_g));
ssh_print_data("key client (e)", (const guchar *)wmem_array_get_raw(kex_e), wmem_array_get_count(kex_e));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(kex_e), wmem_array_get_count(kex_e));
ssh_print_data("key server (f)", (const guchar *)wmem_array_get_raw(kex_f), wmem_array_get_count(kex_f));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(kex_f), wmem_array_get_count(kex_f));
}
if(kex_type==SSH_KEX_DH_GROUP1 || kex_type==SSH_KEX_DH_GROUP14 || kex_type==SSH_KEX_DH_GROUP16 || kex_type==SSH_KEX_DH_GROUP18){
ssh_print_data("key client (e)", (const guchar *)wmem_array_get_raw(kex_e), wmem_array_get_count(kex_e));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(kex_e), wmem_array_get_count(kex_e));
ssh_print_data("key server (f)", (const guchar *)wmem_array_get_raw(kex_f), wmem_array_get_count(kex_f));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(kex_f), wmem_array_get_count(kex_f));
}
if(kex_type==SSH_KEX_CURVE25519){
ssh_print_data("key client (Q_C)", (const guchar *)wmem_array_get_raw(kex_e), wmem_array_get_count(kex_e));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(kex_e), wmem_array_get_count(kex_e));
ssh_print_data("key server (Q_S)", (const guchar *)wmem_array_get_raw(kex_f), wmem_array_get_count(kex_f));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(kex_f), wmem_array_get_count(kex_f));
}
ssh_print_data("shared secret", (const guchar *)wmem_array_get_raw(global_data->kex_shared_secret), wmem_array_get_count(global_data->kex_shared_secret));
wmem_array_append(kex_hash_buffer, wmem_array_get_raw(global_data->kex_shared_secret), wmem_array_get_count(global_data->kex_shared_secret));
ssh_print_data("exchange", (const guchar *)wmem_array_get_raw(kex_hash_buffer), wmem_array_get_count(kex_hash_buffer));
guint hash_len = 32;
if(kex_hash_type==SSH_KEX_HASH_SHA1) {
gcry_md_open(&hd, GCRY_MD_SHA1, 0);
hash_len = 20;
} else if(kex_hash_type==SSH_KEX_HASH_SHA256) {
gcry_md_open(&hd, GCRY_MD_SHA256, 0);
hash_len = 32;
} else if(kex_hash_type==SSH_KEX_HASH_SHA512) {
gcry_md_open(&hd, GCRY_MD_SHA512, 0);
hash_len = 64;
} else {
ws_debug("kex_hash_type type %d not supported", kex_hash_type);
return;
}
gchar *exchange_hash = (gchar *)wmem_alloc0(wmem_file_scope(), hash_len);
gcry_md_write(hd, wmem_array_get_raw(kex_hash_buffer), wmem_array_get_count(kex_hash_buffer));
memcpy(exchange_hash, gcry_md_read(hd, 0), hash_len);
gcry_md_close(hd);
ssh_print_data("hash", exchange_hash, hash_len);
global_data->secret = secret;
ssh_derive_symmetric_keys(secret, exchange_hash, hash_len, global_data);
}
// the purpose of this function is to deal with all different kex methods
static ssh_bignum *
ssh_kex_shared_secret(gint kex_type, ssh_bignum *pub, ssh_bignum *priv, ssh_bignum *modulo)
{
DISSECTOR_ASSERT(pub != NULL);
DISSECTOR_ASSERT(priv != NULL);
ssh_bignum *secret = ssh_kex_make_bignum(NULL, pub->length);
if (!secret) {
ws_debug("invalid key length %u", pub->length);
return NULL;
}
if(kex_type==SSH_KEX_DH_GEX){
gcry_mpi_t b = NULL;
gcry_mpi_scan(&b, GCRYMPI_FMT_USG, pub->data, pub->length, NULL);
gcry_mpi_t d = NULL, e = NULL, m = NULL;
size_t result_len = 0;
d = gcry_mpi_new(pub->length*8);
gcry_mpi_scan(&e, GCRYMPI_FMT_USG, priv->data, priv->length, NULL);
gcry_mpi_scan(&m, GCRYMPI_FMT_USG, modulo->data, modulo->length, NULL);
gcry_mpi_powm(d, b, e, m); // gcry_mpi_powm(d, b, e, m) => d = b^e % m
gcry_mpi_print(GCRYMPI_FMT_USG, secret->data, secret->length, &result_len, d);
secret->length = (guint)result_len; // Should not be larger than what fits in a 32-bit unsigned integer...
gcry_mpi_release(d);
gcry_mpi_release(b);
gcry_mpi_release(e);
gcry_mpi_release(m);
}else if(kex_type==SSH_KEX_DH_GROUP1 || kex_type==SSH_KEX_DH_GROUP14 || kex_type==SSH_KEX_DH_GROUP16 || kex_type==SSH_KEX_DH_GROUP18){
gcry_mpi_t m = NULL;
if(kex_type==SSH_KEX_DH_GROUP1){
static const guint8 p[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34,
0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74,
0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD,
0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37,
0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6,
0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED,
0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6,
0x49, 0x28, 0x66, 0x51, 0xEC, 0xE6, 0x53, 0x81, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
gcry_mpi_scan(&m, GCRYMPI_FMT_USG, p, sizeof(p), NULL);
}else if(kex_type==SSH_KEX_DH_GROUP14){
//p:FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF
static const guint8 p[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34,
0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74,
0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD,
0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37,
0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6,
0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED,
0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6,
0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05,
0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F,
0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB,
0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04,
0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B,
0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, 0xEC, 0x07, 0xA2, 0x8F,
0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18,
0x39, 0x95, 0x49, 0x7C, 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10,
0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAC, 0xAA, 0x68, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
gcry_mpi_scan(&m, GCRYMPI_FMT_USG, p, sizeof(p), NULL);
}else if(kex_type==SSH_KEX_DH_GROUP16){
//p:FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D788719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA993B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199FFFFFFFFFFFFFFFF
static const guint8 p[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34,
0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74,
0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD,
0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37,
0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6,
0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED,
0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6,
0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05,
0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F,
0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB,
0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04,
0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B,
0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, 0xEC, 0x07, 0xA2, 0x8F,
0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18,
0x39, 0x95, 0x49, 0x7C, 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10,
0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, 0xAD, 0x33, 0x17, 0x0D, 0x04, 0x50, 0x7A, 0x33,
0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A,
0x8A, 0xEA, 0x71, 0x57, 0x5D, 0x06, 0x0C, 0x7D, 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7,
0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, 0x1E, 0x8C, 0x94, 0xE0, 0x4A, 0x25, 0x61, 0x9D,
0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64,
0xD8, 0x76, 0x02, 0x73, 0x3E, 0xC8, 0x6A, 0x64, 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C,
0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, 0x77, 0x09, 0x88, 0xC0, 0xBA, 0xD9, 0x46, 0xE2,
0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E,
0x4B, 0x82, 0xD1, 0x20, 0xA9, 0x21, 0x08, 0x01, 0x1A, 0x72, 0x3C, 0x12, 0xA7, 0x87, 0xE6, 0xD7,
0x88, 0x71, 0x9A, 0x10, 0xBD, 0xBA, 0x5B, 0x26, 0x99, 0xC3, 0x27, 0x18, 0x6A, 0xF4, 0xE2, 0x3C,
0x1A, 0x94, 0x68, 0x34, 0xB6, 0x15, 0x0B, 0xDA, 0x25, 0x83, 0xE9, 0xCA, 0x2A, 0xD4, 0x4C, 0xE8,
0xDB, 0xBB, 0xC2, 0xDB, 0x04, 0xDE, 0x8E, 0xF9, 0x2E, 0x8E, 0xFC, 0x14, 0x1F, 0xBE, 0xCA, 0xA6,
0x28, 0x7C, 0x59, 0x47, 0x4E, 0x6B, 0xC0, 0x5D, 0x99, 0xB2, 0x96, 0x4F, 0xA0, 0x90, 0xC3, 0xA2,
0x23, 0x3B, 0xA1, 0x86, 0x51, 0x5B, 0xE7, 0xED, 0x1F, 0x61, 0x29, 0x70, 0xCE, 0xE2, 0xD7, 0xAF,
0xB8, 0x1B, 0xDD, 0x76, 0x21, 0x70, 0x48, 0x1C, 0xD0, 0x06, 0x91, 0x27, 0xD5, 0xB0, 0x5A, 0xA9,
0x93, 0xB4, 0xEA, 0x98, 0x8D, 0x8F, 0xDD, 0xC1, 0x86, 0xFF, 0xB7, 0xDC, 0x90, 0xA6, 0xC0, 0x8F,
0x4D, 0xF4, 0x35, 0xC9, 0x34, 0x06, 0x31, 0x99, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
gcry_mpi_scan(&m, GCRYMPI_FMT_USG, p, sizeof(p), NULL);
}else if(kex_type==SSH_KEX_DH_GROUP18){
//p:FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D788719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA993B4EA988D8FDDC186FFB7DC90A6C08F4DF435C93402849236C3FAB4D27C7026C1D4DCB2602646DEC9751E763DBA37BDF8FF9406AD9E530EE5DB382F413001AEB06A53ED9027D831179727B0865A8918DA3EDBEBCF9B14ED44CE6CBACED4BB1BDB7F1447E6CC254B332051512BD7AF426FB8F401378CD2BF5983CA01C64B92ECF032EA15D1721D03F482D7CE6E74FEF6D55E702F46980C82B5A84031900B1C9E59E7C97FBEC7E8F323A97A7E36CC88BE0F1D45B7FF585AC54BD407B22B4154AACC8F6D7EBF48E1D814CC5ED20F8037E0A79715EEF29BE32806A1D58BB7C5DA76F550AA3D8A1FBFF0EB19CCB1A313D55CDA56C9EC2EF29632387FE8D76E3C0468043E8F663F4860EE12BF2D5B0B7474D6E694F91E6DBE115974A3926F12FEE5E438777CB6A932DF8CD8BEC4D073B931BA3BC832B68D9DD300741FA7BF8AFC47ED2576F6936BA424663AAB639C5AE4F5683423B4742BF1C978238F16CBE39D652DE3FDB8BEFC848AD922222E04A4037C0713EB57A81A23F0C73473FC646CEA306B4BCBC8862F8385DDFA9D4B7FA2C087E879683303ED5BDD3A062B3CF5B3A278A66D2A13F83F44F82DDF310EE074AB6A364597E899A0255DC164F31CC50846851DF9AB48195DED7EA1B1D510BD7EE74D73FAF36BC31ECFA268359046F4EB879F924009438B481C6CD7889A002ED5EE382BC9190DA6FC026E479558E4475677E9AA9E3050E2765694DFC81F56E880B96E7160C980DD98EDD3DFFFFFFFFFFFFFFFFF
static const guint8 p[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34,
0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74,
0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD,
0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37,
0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6,
0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED,
0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6,
0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05,
0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F,
0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB,
0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04,
0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B,
0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, 0xEC, 0x07, 0xA2, 0x8F,
0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18,
0x39, 0x95, 0x49, 0x7C, 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10,
0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, 0xAD, 0x33, 0x17, 0x0D, 0x04, 0x50, 0x7A, 0x33,
0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, 0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A,
0x8A, 0xEA, 0x71, 0x57, 0x5D, 0x06, 0x0C, 0x7D, 0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7,
0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, 0x1E, 0x8C, 0x94, 0xE0, 0x4A, 0x25, 0x61, 0x9D,
0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, 0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64,
0xD8, 0x76, 0x02, 0x73, 0x3E, 0xC8, 0x6A, 0x64, 0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C,
0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, 0x77, 0x09, 0x88, 0xC0, 0xBA, 0xD9, 0x46, 0xE2,
0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, 0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E,
0x4B, 0x82, 0xD1, 0x20, 0xA9, 0x21, 0x08, 0x01, 0x1A, 0x72, 0x3C, 0x12, 0xA7, 0x87, 0xE6, 0xD7,
0x88, 0x71, 0x9A, 0x10, 0xBD, 0xBA, 0x5B, 0x26, 0x99, 0xC3, 0x27, 0x18, 0x6A, 0xF4, 0xE2, 0x3C,
0x1A, 0x94, 0x68, 0x34, 0xB6, 0x15, 0x0B, 0xDA, 0x25, 0x83, 0xE9, 0xCA, 0x2A, 0xD4, 0x4C, 0xE8,
0xDB, 0xBB, 0xC2, 0xDB, 0x04, 0xDE, 0x8E, 0xF9, 0x2E, 0x8E, 0xFC, 0x14, 0x1F, 0xBE, 0xCA, 0xA6,
0x28, 0x7C, 0x59, 0x47, 0x4E, 0x6B, 0xC0, 0x5D, 0x99, 0xB2, 0x96, 0x4F, 0xA0, 0x90, 0xC3, 0xA2,
0x23, 0x3B, 0xA1, 0x86, 0x51, 0x5B, 0xE7, 0xED, 0x1F, 0x61, 0x29, 0x70, 0xCE, 0xE2, 0xD7, 0xAF,
0xB8, 0x1B, 0xDD, 0x76, 0x21, 0x70, 0x48, 0x1C, 0xD0, 0x06, 0x91, 0x27, 0xD5, 0xB0, 0x5A, 0xA9,
0x93, 0xB4, 0xEA, 0x98, 0x8D, 0x8F, 0xDD, 0xC1, 0x86, 0xFF, 0xB7, 0xDC, 0x90, 0xA6, 0xC0, 0x8F,
0x4D, 0xF4, 0x35, 0xC9, 0x34, 0x02, 0x84, 0x92, 0x36, 0xC3, 0xFA, 0xB4, 0xD2, 0x7C, 0x70, 0x26,
0xC1, 0xD4, 0xDC, 0xB2, 0x60, 0x26, 0x46, 0xDE, 0xC9, 0x75, 0x1E, 0x76, 0x3D, 0xBA, 0x37, 0xBD,
0xF8, 0xFF, 0x94, 0x06, 0xAD, 0x9E, 0x53, 0x0E, 0xE5, 0xDB, 0x38, 0x2F, 0x41, 0x30, 0x01, 0xAE,
0xB0, 0x6A, 0x53, 0xED, 0x90, 0x27, 0xD8, 0x31, 0x17, 0x97, 0x27, 0xB0, 0x86, 0x5A, 0x89, 0x18,
0xDA, 0x3E, 0xDB, 0xEB, 0xCF, 0x9B, 0x14, 0xED, 0x44, 0xCE, 0x6C, 0xBA, 0xCE, 0xD4, 0xBB, 0x1B,
0xDB, 0x7F, 0x14, 0x47, 0xE6, 0xCC, 0x25, 0x4B, 0x33, 0x20, 0x51, 0x51, 0x2B, 0xD7, 0xAF, 0x42,
0x6F, 0xB8, 0xF4, 0x01, 0x37, 0x8C, 0xD2, 0xBF, 0x59, 0x83, 0xCA, 0x01, 0xC6, 0x4B, 0x92, 0xEC,
0xF0, 0x32, 0xEA, 0x15, 0xD1, 0x72, 0x1D, 0x03, 0xF4, 0x82, 0xD7, 0xCE, 0x6E, 0x74, 0xFE, 0xF6,
0xD5, 0x5E, 0x70, 0x2F, 0x46, 0x98, 0x0C, 0x82, 0xB5, 0xA8, 0x40, 0x31, 0x90, 0x0B, 0x1C, 0x9E,
0x59, 0xE7, 0xC9, 0x7F, 0xBE, 0xC7, 0xE8, 0xF3, 0x23, 0xA9, 0x7A, 0x7E, 0x36, 0xCC, 0x88, 0xBE,
0x0F, 0x1D, 0x45, 0xB7, 0xFF, 0x58, 0x5A, 0xC5, 0x4B, 0xD4, 0x07, 0xB2, 0x2B, 0x41, 0x54, 0xAA,
0xCC, 0x8F, 0x6D, 0x7E, 0xBF, 0x48, 0xE1, 0xD8, 0x14, 0xCC, 0x5E, 0xD2, 0x0F, 0x80, 0x37, 0xE0,
0xA7, 0x97, 0x15, 0xEE, 0xF2, 0x9B, 0xE3, 0x28, 0x06, 0xA1, 0xD5, 0x8B, 0xB7, 0xC5, 0xDA, 0x76,
0xF5, 0x50, 0xAA, 0x3D, 0x8A, 0x1F, 0xBF, 0xF0, 0xEB, 0x19, 0xCC, 0xB1, 0xA3, 0x13, 0xD5, 0x5C,
0xDA, 0x56, 0xC9, 0xEC, 0x2E, 0xF2, 0x96, 0x32, 0x38, 0x7F, 0xE8, 0xD7, 0x6E, 0x3C, 0x04, 0x68,
0x04, 0x3E, 0x8F, 0x66, 0x3F, 0x48, 0x60, 0xEE, 0x12, 0xBF, 0x2D, 0x5B, 0x0B, 0x74, 0x74, 0xD6,
0xE6, 0x94, 0xF9, 0x1E, 0x6D, 0xBE, 0x11, 0x59, 0x74, 0xA3, 0x92, 0x6F, 0x12, 0xFE, 0xE5, 0xE4,
0x38, 0x77, 0x7C, 0xB6, 0xA9, 0x32, 0xDF, 0x8C, 0xD8, 0xBE, 0xC4, 0xD0, 0x73, 0xB9, 0x31, 0xBA,
0x3B, 0xC8, 0x32, 0xB6, 0x8D, 0x9D, 0xD3, 0x00, 0x74, 0x1F, 0xA7, 0xBF, 0x8A, 0xFC, 0x47, 0xED,
0x25, 0x76, 0xF6, 0x93, 0x6B, 0xA4, 0x24, 0x66, 0x3A, 0xAB, 0x63, 0x9C, 0x5A, 0xE4, 0xF5, 0x68,
0x34, 0x23, 0xB4, 0x74, 0x2B, 0xF1, 0xC9, 0x78, 0x23, 0x8F, 0x16, 0xCB, 0xE3, 0x9D, 0x65, 0x2D,
0xE3, 0xFD, 0xB8, 0xBE, 0xFC, 0x84, 0x8A, 0xD9, 0x22, 0x22, 0x2E, 0x04, 0xA4, 0x03, 0x7C, 0x07,
0x13, 0xEB, 0x57, 0xA8, 0x1A, 0x23, 0xF0, 0xC7, 0x34, 0x73, 0xFC, 0x64, 0x6C, 0xEA, 0x30, 0x6B,
0x4B, 0xCB, 0xC8, 0x86, 0x2F, 0x83, 0x85, 0xDD, 0xFA, 0x9D, 0x4B, 0x7F, 0xA2, 0xC0, 0x87, 0xE8,
0x79, 0x68, 0x33, 0x03, 0xED, 0x5B, 0xDD, 0x3A, 0x06, 0x2B, 0x3C, 0xF5, 0xB3, 0xA2, 0x78, 0xA6,
0x6D, 0x2A, 0x13, 0xF8, 0x3F, 0x44, 0xF8, 0x2D, 0xDF, 0x31, 0x0E, 0xE0, 0x74, 0xAB, 0x6A, 0x36,
0x45, 0x97, 0xE8, 0x99, 0xA0, 0x25, 0x5D, 0xC1, 0x64, 0xF3, 0x1C, 0xC5, 0x08, 0x46, 0x85, 0x1D,
0xF9, 0xAB, 0x48, 0x19, 0x5D, 0xED, 0x7E, 0xA1, 0xB1, 0xD5, 0x10, 0xBD, 0x7E, 0xE7, 0x4D, 0x73,
0xFA, 0xF3, 0x6B, 0xC3, 0x1E, 0xCF, 0xA2, 0x68, 0x35, 0x90, 0x46, 0xF4, 0xEB, 0x87, 0x9F, 0x92,
0x40, 0x09, 0x43, 0x8B, 0x48, 0x1C, 0x6C, 0xD7, 0x88, 0x9A, 0x00, 0x2E, 0xD5, 0xEE, 0x38, 0x2B,
0xC9, 0x19, 0x0D, 0xA6, 0xFC, 0x02, 0x6E, 0x47, 0x95, 0x58, 0xE4, 0x47, 0x56, 0x77, 0xE9, 0xAA,
0x9E, 0x30, 0x50, 0xE2, 0x76, 0x56, 0x94, 0xDF, 0xC8, 0x1F, 0x56, 0xE8, 0x80, 0xB9, 0x6E, 0x71,
0x60, 0xC9, 0x80, 0xDD, 0x98, 0xED, 0xD3, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,};
gcry_mpi_scan(&m, GCRYMPI_FMT_USG, p, sizeof(p), NULL);
}
gcry_mpi_t b = NULL;
gcry_mpi_scan(&b, GCRYMPI_FMT_USG, pub->data, pub->length, NULL);
gcry_mpi_t d = NULL, e = NULL;
size_t result_len = 0;
d = gcry_mpi_new(pub->length*8);
gcry_mpi_scan(&e, GCRYMPI_FMT_USG, priv->data, priv->length, NULL);
gcry_mpi_powm(d, b, e, m); // gcry_mpi_powm(d, b, e, m) => d = b^e % m
gcry_mpi_print(GCRYMPI_FMT_USG, secret->data, secret->length, &result_len, d);
secret->length = (guint)result_len; // Should not be larger than what fits in a 32-bit unsigned integer...
gcry_mpi_release(d);
gcry_mpi_release(b);
gcry_mpi_release(e);
gcry_mpi_release(m);
}else if(kex_type==SSH_KEX_CURVE25519){
if (crypto_scalarmult_curve25519(secret->data, priv->data, pub->data)) {
ws_debug("curve25519: can't compute shared secret");
return NULL;
}
} else {
ws_debug("kex_type type %d not supported", kex_type);
return 0;
}
return secret;
}
static gchar *
ssh_string(const gchar *string, guint length)
{
gchar *ssh_string = (gchar *)wmem_alloc(wmem_packet_scope(), length + 4);
ssh_string[0] = (length >> 24) & 0xff;
ssh_string[1] = (length >> 16) & 0xff;
ssh_string[2] = (length >> 8) & 0xff;
ssh_string[3] = length & 0xff;
memcpy(ssh_string + 4, string, length);
return ssh_string;
}
static void
ssh_hash_buffer_put_string(wmem_array_t *buffer, const gchar *string,
guint length)
{
if (!buffer) {
return;
}
gchar *string_with_length = ssh_string(string, length);
wmem_array_append(buffer, string_with_length, length + 4);
}
static void
ssh_hash_buffer_put_uint32(wmem_array_t *buffer, guint val)
{
if (!buffer) {
return;
}
gchar buf[4];
buf[0] = (val >> 24); buf[1] = (val >> 16); buf[2] = (val >> 8); buf[3] = (val >> 0);
wmem_array_append(buffer, buf, 4);
}
static void ssh_derive_symmetric_keys(ssh_bignum *secret, gchar *exchange_hash,
guint hash_length, struct ssh_flow_data *global_data)
{
if (!global_data->session_id) {
global_data->session_id = exchange_hash;
global_data->session_id_length = hash_length;
}
unsigned int we_need = 0;
for(int peer_cnt=0;peer_cnt<2;peer_cnt++){
struct ssh_peer_data * peer_data = &global_data->peer_data[peer_cnt];
// required size of key depends on cipher used. chacha20 wants 64 bytes
guint need = 0;
if (GCRY_CIPHER_CHACHA20 == peer_data->cipher_id) {
need = 64;
} else if (CIPHER_AES128_CBC == peer_data->cipher_id || CIPHER_AES128_CTR == peer_data->cipher_id || CIPHER_AES128_GCM == peer_data->cipher_id) {
need = 16;
} else if (CIPHER_AES192_CBC == peer_data->cipher_id || CIPHER_AES192_CTR == peer_data->cipher_id) {
need = 24;
} else if (CIPHER_AES256_CBC == peer_data->cipher_id || CIPHER_AES256_CTR == peer_data->cipher_id || CIPHER_AES256_GCM == peer_data->cipher_id) {
need = 32;
} else {
ssh_debug_printf("ssh: cipher (%d) is unknown or not set\n", peer_data->cipher_id);
ssh_debug_flush();
}
if(peer_data->mac_id == CIPHER_MAC_SHA2_256){
need = 32;
}else{
ssh_debug_printf("ssh: MAC (%d) is unknown or not set\n", peer_data->mac_id);
ssh_debug_flush();
}
if (we_need<need) {
we_need = need;
}
}
for (int i = 0; i < 6; i ++) {
ssh_derive_symmetric_key(secret, exchange_hash, hash_length,
'A' + i, &global_data->new_keys[i], global_data, we_need);
if(i==0){ ssh_print_data("Initial IV client to server", global_data->new_keys[i].data, global_data->new_keys[i].length);
}else if(i==1){ ssh_print_data("Initial IV server to client", global_data->new_keys[i].data, global_data->new_keys[i].length);
}else if(i==2){ ssh_print_data("Encryption key client to server", global_data->new_keys[i].data, global_data->new_keys[i].length);
}else if(i==3){ ssh_print_data("Encryption key server to client", global_data->new_keys[i].data, global_data->new_keys[i].length);
}else if(i==4){ ssh_print_data("Integrity key client to server", global_data->new_keys[i].data, global_data->new_keys[i].length);
}else if(i==5){ ssh_print_data("Integrity key server to client", global_data->new_keys[i].data, global_data->new_keys[i].length);
}
}
}
static void ssh_derive_symmetric_key(ssh_bignum *secret, gchar *exchange_hash,
guint hash_length, gchar id, ssh_bignum *result_key,
struct ssh_flow_data *global_data, guint we_need)
{
gcry_md_hd_t hd;
guint kex_hash_type = ssh_kex_hash_type(global_data->kex);
int algo = GCRY_MD_SHA256;
if(kex_hash_type==SSH_KEX_HASH_SHA1){
algo = GCRY_MD_SHA1;
}else if(kex_hash_type==SSH_KEX_HASH_SHA256){
algo = GCRY_MD_SHA256;
}else if(kex_hash_type==SSH_KEX_HASH_SHA512){
algo = GCRY_MD_SHA512;
}
guint len = gcry_md_get_algo_dlen(algo);
result_key->data = (guchar *)wmem_alloc(wmem_file_scope(), we_need);
gchar *secret_with_length = ssh_string(secret->data, secret->length);
if (gcry_md_open(&hd, algo, 0) == 0) {
gcry_md_write(hd, secret_with_length, secret->length + 4);
gcry_md_write(hd, exchange_hash, hash_length);
gcry_md_putc(hd, id);
gcry_md_write(hd, global_data->session_id, hash_length);
guint add_length = MIN(len, we_need);
memcpy(result_key->data, gcry_md_read(hd, 0), add_length);
gcry_md_close(hd);
}
// expand key
for (guint have = len; have < we_need; have += len) {
if (gcry_md_open(&hd, algo, 0) == 0) {
gcry_md_write(hd, secret_with_length, secret->length + 4);
gcry_md_write(hd, exchange_hash, hash_length);
gcry_md_write(hd, result_key->data+have-len, len);
guint add_length = MIN(len, we_need - have);
memcpy(result_key->data+have, gcry_md_read(hd, 0), add_length);
gcry_md_close(hd);
}
}
result_key->length = we_need;
}
static void
ssh_choose_enc_mac(struct ssh_flow_data *global_data)
{
for(int peer_cnt=0;peer_cnt<2;peer_cnt++){
struct ssh_peer_data * peer_data = &global_data->peer_data[peer_cnt];
ssh_choose_algo(global_data->peer_data[CLIENT_PEER_DATA].enc_proposals[peer_cnt],
global_data->peer_data[SERVER_PEER_DATA].enc_proposals[peer_cnt],
&peer_data->enc);
/* some ciphers have their own MAC so the "negotiated" one is meaningless */
if(peer_data->enc && (0 == strcmp(peer_data->enc, "[email protected]") ||
0 == strcmp(peer_data->enc, "[email protected]"))) {
peer_data->mac = wmem_strdup(wmem_file_scope(), (const gchar *)"<implicit>");
peer_data->mac_length = 16;
peer_data->length_is_plaintext = 1;
}
else if(peer_data->enc && 0 == strcmp(peer_data->enc, "[email protected]")) {
peer_data->mac = wmem_strdup(wmem_file_scope(), (const gchar *)"<implicit>");
peer_data->mac_length = 16;
}
else {
ssh_choose_algo(global_data->peer_data[CLIENT_PEER_DATA].mac_proposals[peer_cnt],
global_data->peer_data[SERVER_PEER_DATA].mac_proposals[peer_cnt],
&peer_data->mac);
ssh_set_mac_length(peer_data);
}
ssh_choose_algo(global_data->peer_data[CLIENT_PEER_DATA].comp_proposals[peer_cnt],
global_data->peer_data[SERVER_PEER_DATA].comp_proposals[peer_cnt],
&peer_data->comp);
}
ssh_decryption_set_cipher_id(&global_data->peer_data[CLIENT_PEER_DATA]);
ssh_decryption_set_mac_id(&global_data->peer_data[CLIENT_PEER_DATA]);
ssh_decryption_set_cipher_id(&global_data->peer_data[SERVER_PEER_DATA]);
ssh_decryption_set_mac_id(&global_data->peer_data[SERVER_PEER_DATA]);
}
static void
ssh_decryption_set_cipher_id(struct ssh_peer_data *peer)
{
gchar *cipher_name = peer->enc;
if (!cipher_name) {
peer->cipher = NULL;
ws_debug("ERROR: cipher_name is NULL");
} else if (0 == strcmp(cipher_name, "[email protected]")) {
peer->cipher_id = GCRY_CIPHER_CHACHA20;
} else if (0 == strcmp(cipher_name, "[email protected]")) {
peer->cipher_id = CIPHER_AES128_GCM;
} else if (0 == strcmp(cipher_name, "aes128-gcm")) {
peer->cipher_id = CIPHER_AES128_GCM;
} else if (0 == strcmp(cipher_name, "[email protected]")) {
peer->cipher_id = CIPHER_AES256_GCM;
} else if (0 == strcmp(cipher_name, "aes256-gcm")) {
peer->cipher_id = CIPHER_AES256_GCM;
} else if (0 == strcmp(cipher_name, "aes128-cbc")) {
peer->cipher_id = CIPHER_AES128_CBC;
} else if (0 == strcmp(cipher_name, "aes192-cbc")) {
peer->cipher_id = CIPHER_AES192_CBC;
} else if (0 == strcmp(cipher_name, "aes256-cbc")) {
peer->cipher_id = CIPHER_AES256_CBC;
} else if (0 == strcmp(cipher_name, "aes128-ctr")) {
peer->cipher_id = CIPHER_AES128_CTR;
} else if (0 == strcmp(cipher_name, "aes192-ctr")) {
peer->cipher_id = CIPHER_AES192_CTR;
} else if (0 == strcmp(cipher_name, "aes256-ctr")) {
peer->cipher_id = CIPHER_AES256_CTR;
} else {
peer->cipher = NULL;
ws_debug("decryption not supported: %s", cipher_name);
}
}
static void
ssh_decryption_set_mac_id(struct ssh_peer_data *peer)
{
gchar *mac_name = peer->mac;
if (!mac_name) {
peer->mac = NULL;
ws_debug("ERROR: mac_name is NULL");
} else if (0 == strcmp(mac_name, "hmac-sha2-256")) {
peer->mac_id = CIPHER_MAC_SHA2_256;
} else {
peer->mac = NULL;
ws_debug("decryption MAC not supported: %s", mac_name);
}
}
static void
ssh_decryption_setup_cipher(struct ssh_peer_data *peer_data,
ssh_bignum *iv, ssh_bignum *key)
{
gcry_error_t err;
gcry_cipher_hd_t *hd1, *hd2;
hd1 = &peer_data->cipher;
hd2 = &peer_data->cipher_2;
if (GCRY_CIPHER_CHACHA20 == peer_data->cipher_id) {
if (gcry_cipher_open(hd1, GCRY_CIPHER_CHACHA20, GCRY_CIPHER_MODE_STREAM, 0) ||
gcry_cipher_open(hd2, GCRY_CIPHER_CHACHA20, GCRY_CIPHER_MODE_STREAM, 0)) {
gcry_cipher_close(*hd1);
gcry_cipher_close(*hd2);
ws_debug("ssh: can't open chacha20 cipher handles");
return;
}
gchar k1[32];
gchar k2[32];
if(key->data){
memcpy(k1, key->data, 32);
memcpy(k2, key->data + 32, 32);
}else{
memset(k1, 0, 32);
memset(k2, 0, 32);
}
ssh_debug_printf("ssh: cipher is chacha20\n");
ssh_print_data("key 1", k1, 32);
ssh_print_data("key 2", k2, 32);
if ((err = gcry_cipher_setkey(*hd1, k1, 32))) {
gcry_cipher_close(*hd1);
ws_debug("ssh: can't set chacha20 cipher key %s", gcry_strerror(err));
return;
}
if ((err = gcry_cipher_setkey(*hd2, k2, 32))) {
gcry_cipher_close(*hd1);
gcry_cipher_close(*hd2);
ws_debug("ssh: can't set chacha20 cipher key %s", gcry_strerror(err));
return;
}
} else if (CIPHER_AES128_CBC == peer_data->cipher_id || CIPHER_AES192_CBC == peer_data->cipher_id || CIPHER_AES256_CBC == peer_data->cipher_id) {
gint iKeyLen = CIPHER_AES128_CBC == peer_data->cipher_id?16:CIPHER_AES192_CBC == peer_data->cipher_id?24:32;
if (gcry_cipher_open(hd1, CIPHER_AES128_CBC == peer_data->cipher_id?GCRY_CIPHER_AES128:CIPHER_AES192_CBC == peer_data->cipher_id?GCRY_CIPHER_AES192:GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CBC, GCRY_CIPHER_CBC_CTS)) {
gcry_cipher_close(*hd1);
ws_debug("ssh: can't open aes%d cipher handle", iKeyLen*8);
return;
}
gchar k1[32], iv1[16];
if(key->data){
memcpy(k1, key->data, iKeyLen);
}else{
memset(k1, 0, iKeyLen);
}
if(iv->data){
memcpy(iv1, iv->data, 16);
}else{
memset(iv1, 0, 16);
}
ssh_debug_printf("ssh: cipher is aes%d-cbc\n", iKeyLen*8);
ssh_print_data("key", k1, iKeyLen);
ssh_print_data("iv", iv1, 16);
if ((err = gcry_cipher_setkey(*hd1, k1, iKeyLen))) {
gcry_cipher_close(*hd1);
ws_debug("ssh: can't set aes%d cipher key", iKeyLen*8);
ws_debug("libgcrypt: %d %s %s", gcry_err_code(err), gcry_strsource(err), gcry_strerror(err));
return;
}
if ((err = gcry_cipher_setiv(*hd1, iv1, 16))) {
gcry_cipher_close(*hd1);
ws_debug("ssh: can't set aes%d cipher iv", iKeyLen*8);
ws_debug("libgcrypt: %d %s %s", gcry_err_code(err), gcry_strsource(err), gcry_strerror(err));
return;
}
} else if (CIPHER_AES128_CTR == peer_data->cipher_id || CIPHER_AES192_CTR == peer_data->cipher_id || CIPHER_AES256_CTR == peer_data->cipher_id) {
gint iKeyLen = CIPHER_AES128_CTR == peer_data->cipher_id?16:CIPHER_AES192_CTR == peer_data->cipher_id?24:32;
if (gcry_cipher_open(hd1, CIPHER_AES128_CTR == peer_data->cipher_id?GCRY_CIPHER_AES128:CIPHER_AES192_CTR == peer_data->cipher_id?GCRY_CIPHER_AES192:GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CTR, 0)) {
gcry_cipher_close(*hd1);
ws_debug("ssh: can't open aes%d cipher handle", iKeyLen*8);
return;
}
gchar k1[32], iv1[16];
if(key->data){
memcpy(k1, key->data, iKeyLen);
}else{
memset(k1, 0, iKeyLen);
}
if(iv->data){
memcpy(iv1, iv->data, 16);
}else{
memset(iv1, 0, 16);
}
ssh_debug_printf("ssh: cipher is aes%d-ctr\n", iKeyLen*8);
ssh_print_data("key", k1, iKeyLen);
ssh_print_data("iv", iv1, 16);
if ((err = gcry_cipher_setkey(*hd1, k1, iKeyLen))) {
gcry_cipher_close(*hd1);
ws_debug("ssh: can't set aes%d cipher key", iKeyLen*8);
ws_debug("libgcrypt: %d %s %s", gcry_err_code(err), gcry_strsource(err), gcry_strerror(err));
return;
}
if ((err = gcry_cipher_setctr(*hd1, iv1, 16))) {
gcry_cipher_close(*hd1);
ws_debug("ssh: can't set aes%d cipher iv", iKeyLen*8);
ws_debug("libgcrypt: %d %s %s", gcry_err_code(err), gcry_strsource(err), gcry_strerror(err));
return;
}
} else if (CIPHER_AES128_GCM == peer_data->cipher_id || CIPHER_AES256_GCM == peer_data->cipher_id) {
gint iKeyLen = CIPHER_AES128_GCM == peer_data->cipher_id?16:32;
if (gcry_cipher_open(hd1, CIPHER_AES128_GCM == peer_data->cipher_id?GCRY_CIPHER_AES128:GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_GCM, 0)) {
gcry_cipher_close(*hd1);
ws_debug("ssh: can't open aes%d cipher handle", iKeyLen*8);
return;
}
gchar k1[32], iv2[12];
if(key->data){
memcpy(k1, key->data, iKeyLen);
}else{
memset(k1, 0, iKeyLen);
}
if(iv->data){
memcpy(peer_data->iv, iv->data, 12);
}else{
memset(iv2, 0, 12);
}
ssh_debug_printf("ssh: cipher is aes%d-gcm\n", iKeyLen*8);
ssh_print_data("key", k1, iKeyLen);
ssh_print_data("iv", peer_data->iv, 12);
if ((err = gcry_cipher_setkey(*hd1, k1, iKeyLen))) {
gcry_cipher_close(*hd1);
ws_debug("ssh: can't set aes%d cipher key", iKeyLen*8);
ws_debug("libgcrypt: %d %s %s", gcry_err_code(err), gcry_strsource(err), gcry_strerror(err));
return;
}
} else {
ssh_debug_printf("ssh: cipher (%d) is unknown or not set\n", peer_data->cipher_id);
}
}
static void
ssh_decryption_setup_mac(struct ssh_peer_data *peer_data,
ssh_bignum *iv)
{
if(peer_data->mac_id == CIPHER_MAC_SHA2_256){
if(iv->data){
memcpy(peer_data->hmac_iv, iv->data, 32);
}else{
memset(peer_data->hmac_iv, 0, 32);
}
peer_data->hmac_iv_len = 32;
ssh_debug_printf("ssh: mac is hmac-sha2-256\n");
ssh_print_data("iv", peer_data->hmac_iv, peer_data->hmac_iv_len);
}else{
ws_debug("ssh: unsupported MAC");
}
}
/* libgcrypt wrappers for HMAC/message digest operations {{{ */
/* hmac abstraction layer */
#define SSH_HMAC gcry_md_hd_t
static inline gint
ssh_hmac_init(SSH_HMAC* md, const void * key, gint len, gint algo)
{
gcry_error_t err;
const char *err_str, *err_src;
err = gcry_md_open(md,algo, GCRY_MD_FLAG_HMAC);
if (err != 0) {
err_str = gcry_strerror(err);
err_src = gcry_strsource(err);
ssh_debug_printf("ssh_hmac_init(): gcry_md_open failed %s/%s", err_str, err_src);
return -1;
}
gcry_md_setkey (*(md), key, len);
return 0;
}
static inline void
ssh_hmac_update(SSH_HMAC* md, const void* data, gint len)
{
gcry_md_write(*(md), data, len);
}
static inline void
ssh_hmac_final(SSH_HMAC* md, guchar* data, guint* datalen)
{
gint algo;
guint len;
algo = gcry_md_get_algo (*(md));
len = gcry_md_get_algo_dlen(algo);
DISSECTOR_ASSERT(len <= *datalen);
memcpy(data, gcry_md_read(*(md), algo), len);
*datalen = len;
}
static inline void
ssh_hmac_cleanup(SSH_HMAC* md)
{
gcry_md_close(*(md));
}
/* libgcrypt wrappers for HMAC/message digest operations }}} */
/* Decryption integrity check {{{ */
static gint
ssh_get_digest_by_id(guint mac_id)
{
if(mac_id==CIPHER_MAC_SHA2_256){
return GCRY_MD_SHA256;
}
return -1;
}
static void
ssh_calc_mac(struct ssh_peer_data *peer_data, guint32 seqnr, guint8* data, guint32 datalen, guint8* calc_mac)
{
SSH_HMAC hm;
gint md;
guint32 len;
guint8 buf[DIGEST_MAX_SIZE];
md=ssh_get_digest_by_id(peer_data->mac_id);
// ssl_debug_printf("ssh_check_mac mac type:%s md %d\n",
// ssl_cipher_suite_dig(decoder->cipher_suite)->name, md);
memset(calc_mac, 0, DIGEST_MAX_SIZE);
if (ssh_hmac_init(&hm, peer_data->hmac_iv, peer_data->hmac_iv_len,md) != 0)
return;
/* hash sequence number */
phton32(buf, seqnr);
ssh_print_data("Mac IV", peer_data->hmac_iv, peer_data->hmac_iv_len);
ssh_print_data("Mac seq", buf, 4);
ssh_print_data("Mac data", data, datalen);
ssh_hmac_update(&hm,buf,4);
ssh_hmac_update(&hm,data,datalen);
/* get digest and digest len*/
len = sizeof(buf);
ssh_hmac_final(&hm,buf,&len);
ssh_hmac_cleanup(&hm);
ssh_print_data("Mac", buf, len);
memcpy(calc_mac, buf, len);
return;
}
/* Decryption integrity check }}} */
static void
ssh_increment_message_number(packet_info *pinfo, struct ssh_flow_data *global_data,
gboolean is_response)
{
if (!PINFO_FD_VISITED(pinfo)) {
ssh_packet_info_t * packet = (ssh_packet_info_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_ssh, 0);
if(!packet){
packet = wmem_new0(wmem_file_scope(), ssh_packet_info_t);
packet->from_server = is_response;
packet->messages = NULL;
p_add_proto_data(wmem_file_scope(), pinfo, proto_ssh, 0, packet);
}
(void)global_data;
}
}
static guint
ssh_decrypt_packet(tvbuff_t *tvb, packet_info *pinfo,
struct ssh_peer_data *peer_data, int offset, proto_tree *tree)
{
gboolean is_response = (pinfo->destport != pinfo->match_uint);
ssh_packet_info_t *packet = (ssh_packet_info_t *)p_get_proto_data(
wmem_file_scope(), pinfo, proto_ssh, 0);
if(!packet){
packet = wmem_new0(wmem_file_scope(), ssh_packet_info_t);
packet->from_server = is_response;
packet->messages = NULL;
p_add_proto_data(wmem_file_scope(), pinfo, proto_ssh, 0, packet);
}
gint record_id = tvb_raw_offset(tvb)+offset;
ssh_message_info_t *message = NULL;
ssh_message_info_t **pmessage = &packet->messages;
while(*pmessage){
// ws_debug("looking for message %d now %d", record_id, (*pmessage)->id);
if ((*pmessage)->id == record_id) {
message = *pmessage;
break;
}
pmessage = &(*pmessage)->next;
}
if(!message){
message = wmem_new(wmem_file_scope(), ssh_message_info_t);
message->plain_data = NULL;
message->data_len = 0;
message->id = record_id;
message->next = NULL;
message->sequence_number = peer_data->sequence_number;
peer_data->sequence_number++;
ssh_debug_printf("%s->sequence_number++ > %d\n", is_response?"server":"client", peer_data->sequence_number);
*pmessage = message;
}
guint message_length = 0, seqnr;
gchar *plain = NULL, *mac;
guint mac_len;
seqnr = message->sequence_number;
if (GCRY_CIPHER_CHACHA20 == peer_data->cipher_id) {
const gchar *ctext = (const gchar *)tvb_get_ptr(tvb, offset, 4);
guint8 plain_length_buf[4];
if (!ssh_decrypt_chacha20(peer_data->cipher_2, seqnr, 0, ctext, 4,
plain_length_buf, 4)) {
ws_debug("ERROR: could not decrypt packet len");
return tvb_captured_length(tvb);
}
message_length = pntoh32(plain_length_buf);
ssh_debug_printf("chachapoly_crypt seqnr=%d [%u]\n", seqnr, message_length);
ssh_debug_printf("%s plain for seq = %d len = %u\n", is_response?"s2c":"c2s", seqnr, message_length);
if(message_length>32768){
ws_debug("ssh: unreasonable message length %u", message_length);
return tvb_captured_length(tvb);
}
plain = (gchar *)wmem_alloc0(pinfo->pool, message_length+4);
plain[0] = plain_length_buf[0]; plain[1] = plain_length_buf[1]; plain[2] = plain_length_buf[2]; plain[3] = plain_length_buf[3];
const gchar *ctext2 = (const gchar *)tvb_get_ptr(tvb, offset+4,
message_length);
if (!ssh_decrypt_chacha20(peer_data->cipher, seqnr, 1, ctext2,
message_length, plain+4, message_length)) {
ws_debug("ERROR: could not decrypt packet payload");
return tvb_captured_length(tvb);
}
mac_len = 16;
mac = (gchar *)tvb_get_ptr(tvb, offset + 4 + message_length, mac_len);
gchar poly_key[32], iv[16];
memset(poly_key, 0, 32);
memset(iv, 0, 8);
phton64(iv+8, (guint64)seqnr);
gcry_cipher_setiv(peer_data->cipher, iv, mac_len);
gcry_cipher_encrypt(peer_data->cipher, poly_key, 32, poly_key, 32);
gcry_mac_hd_t mac_hd;
gcry_mac_open(&mac_hd, GCRY_MAC_POLY1305, 0, NULL);
gcry_mac_setkey(mac_hd, poly_key, 32);
gcry_mac_write(mac_hd, ctext, 4);
gcry_mac_write(mac_hd, ctext2, message_length);
if (gcry_mac_verify(mac_hd, mac, mac_len)) {
ws_debug("ssh: MAC does not match");
}
size_t buflen = DIGEST_MAX_SIZE;
gcry_mac_read(mac_hd, message->calc_mac, &buflen);
message->plain_data = plain;
message->data_len = message_length + 4;
// ssh_print_data(is_response?"s2c encrypted":"c2s encrypted", ctext2, message_length+4+mac_len);
ssh_debug_printf("%s plain text seq=%d", is_response?"s2c":"c2s",seqnr);
ssh_print_data("", plain, message_length+4);
} else if (CIPHER_AES128_GCM == peer_data->cipher_id || CIPHER_AES256_GCM == peer_data->cipher_id) {
mac_len = peer_data->mac_length;
const gchar *plain_buf = (const gchar *)tvb_get_ptr(tvb, offset, 4);
message_length = pntoh32(plain_buf);
guint remaining = tvb_reported_length_remaining(tvb, offset);
ssh_debug_printf("length: %d, remaining: %d\n", message_length, remaining);
if(message->plain_data && message->data_len){
}else{
const gchar *ctl = (const gchar *)tvb_get_ptr(tvb, offset,
message_length+4);
const gchar *ctext = ctl + 4;
plain = (gchar *)wmem_alloc(wmem_file_scope(), message_length+4);
plain[0] = message_length >> 24; plain[1] = message_length >> 16; plain[2] = message_length >> 8; plain[3] = message_length >> 0;
gcry_error_t err;
/* gcry_cipher_setiv(peer_data->cipher, iv, 12); */
if ((err = gcry_cipher_setiv(peer_data->cipher, peer_data->iv, 12))) {
gcry_cipher_close(peer_data->cipher);
// TODO: temporary work-around as long as a Windows python bug is triggered by automated tests
#ifndef _WIN32
ws_debug("ssh: can't set aes128 cipher iv");
ws_debug("libgcrypt: %d %s %s", gcry_err_code(err), gcry_strsource(err), gcry_strerror(err));
#endif //ndef _WIN32
return offset;
}
int idx = 12;
do{
idx -= 1;
peer_data->iv[idx] += 1;
}while(idx>4 && peer_data->iv[idx]==0);
if ((err = gcry_cipher_authenticate(peer_data->cipher, plain, 4))) {
// TODO: temporary work-around as long as a Windows python bug is triggered by automated tests
#ifndef _WIN32
ws_debug("can't authenticate using aes128-gcm: %s\n", gpg_strerror(err));
#endif //ndef _WIN32
return offset;
}
guint offs = 0;
if(remaining>message_length+4){remaining=message_length;}
while(offs<remaining){
if (gcry_cipher_decrypt(peer_data->cipher, plain+4+offs, 16,
ctext+offs, 16))
{
// TODO: temporary work-around as long as a Windows python bug is triggered by automated tests
#ifndef _WIN32
ws_debug("can\'t decrypt aes128");
#endif //ndef _WIN32
return offset;
}
offs += 16;
}
if (gcry_cipher_gettag (peer_data->cipher, message->calc_mac, 16)) {
// TODO: temporary work-around as long as a Windows python bug is triggered by automated tests
#ifndef _WIN32
ws_debug ("aes128-gcm, gcry_cipher_gettag() failed\n");
#endif //ndef _WIN32
return offset;
}
if ((err = gcry_cipher_reset(peer_data->cipher))) {
// TODO: temporary work-around as long as a Windows python bug is triggered by automated tests
#ifndef _WIN32
ws_debug("aes-gcm, gcry_cipher_reset failed: %s\n", gpg_strerror (err));
#endif //ndef _WIN32
return offset;
}
message->plain_data = plain;
message->data_len = message_length + 4;
// ssh_print_data(is_response?"s2c encrypted":"c2s encrypted", ctl, message_length+4+mac_len);
ssh_debug_printf("%s plain text seq=%d", is_response?"s2c":"c2s",seqnr);
ssh_print_data("", plain, message_length+4);
}
plain = message->plain_data;
message_length = message->data_len - 4;
} else if (CIPHER_AES128_CBC == peer_data->cipher_id || CIPHER_AES128_CTR == peer_data->cipher_id ||
CIPHER_AES192_CBC == peer_data->cipher_id || CIPHER_AES192_CTR == peer_data->cipher_id ||
CIPHER_AES256_CBC == peer_data->cipher_id || CIPHER_AES256_CTR == peer_data->cipher_id) {
mac_len = peer_data->mac_length;
message_length = tvb_reported_length_remaining(tvb, offset) - 4 - mac_len;
if(message->plain_data && message->data_len){
}else{
// TODO: see how to handle fragmentation...
// const gchar *ctext = NULL;
ws_noisy("Getting raw bytes of length %d", tvb_reported_length_remaining(tvb, offset));
const gchar *cypher_buf0 = (const gchar *)tvb_get_ptr(tvb, offset, tvb_reported_length_remaining(tvb, offset));
gchar plain0[16];
if (gcry_cipher_decrypt(peer_data->cipher, plain0, 16, cypher_buf0, 16))
{
ws_debug("can\'t decrypt aes128");
return offset;
}
// ctext = cypher_buf0;
guint message_length_decrypted = pntoh32(plain0);
guint remaining = tvb_reported_length_remaining(tvb, offset);
if(message_length_decrypted>32768){
ws_debug("ssh: unreasonable message length %u/%u", message_length_decrypted, message_length);
return tvb_captured_length(tvb);
}else{
message_length = message_length_decrypted;
message->plain_data = (gchar *)wmem_alloc(wmem_file_scope(), message_length+4);
memcpy(message->plain_data, plain0, 16);
plain = message->plain_data;
guint offs = 16;
if(remaining>message_length+4){remaining=message_length+4;}
while(offs<remaining){
gchar *ct = (gchar *)tvb_get_ptr(tvb, offset+offs, 16);
if (gcry_cipher_decrypt(peer_data->cipher, plain+offs, 16, ct, 16))
{
ws_debug("can\'t decrypt aes128");
return offset;
}
offs += 16;
}
if(message_length_decrypted>remaining){
// Need desegmentation
ws_noisy(" need_desegmentation: offset = %d, reported_length_remaining = %d\n",
offset, tvb_reported_length_remaining(tvb, offset));
/* Make data available to ssh_follow_tap_listener */
return tvb_captured_length(tvb);
}
// ssh_print_data(is_response?"s2c encrypted":"c2s encrypted", ctext, message_length+4+mac_len);
ssh_debug_printf("%s plain text seq=%d", is_response?"s2c":"c2s",seqnr);
ssh_print_data("", plain, message_length+4);
// TODO: process fragments
message->plain_data = plain;
message->data_len = message_length + 4;
ssh_calc_mac(peer_data, message->sequence_number, message->plain_data, message->data_len, message->calc_mac);
}
}
plain = message->plain_data;
message_length = message->data_len - 4;
mac = (gchar *)tvb_get_ptr(tvb, offset + 4 + message_length, mac_len);
if(!memcmp(mac, message->calc_mac, mac_len)){ws_noisy("MAC OK");}else{ws_debug("MAC ERR");}
}
if(plain){
ssh_dissect_decrypted_packet(tvb, pinfo, peer_data, tree, plain, message_length+4);
ssh_tree_add_mac(tree, tvb, offset + 4 + message_length, mac_len, hf_ssh_mac_string, hf_ssh_mac_status, &ei_ssh_mac_bad, pinfo, message->calc_mac,
PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
proto_tree_add_uint(tree, hf_ssh_seq_num, tvb, offset + 4 + message_length, mac_len, message->sequence_number);
}
offset += message_length + peer_data->mac_length + 4;
return offset;
}
proto_item *
ssh_tree_add_mac(proto_tree *tree, tvbuff_t *tvb, const guint offset, const guint mac_len,
const int hf_mac, const int hf_mac_status, struct expert_field* bad_checksum_expert,
packet_info *pinfo, const guint8 * calc_mac, const guint flags)
{
// header_field_info *hfinfo = proto_registrar_get_nth(hf_checksum);
proto_item* ti = NULL;
proto_item* ti2;
gboolean incorrect_mac = TRUE;
gchar *mac;
// DISSECTOR_ASSERT_HINT(hfinfo != NULL, "Not passed hfi!");
/*
if (flags & PROTO_CHECKSUM_NOT_PRESENT) {
ti = proto_tree_add_uint_format_value(tree, hf_checksum, tvb, offset, len, 0, "[missing]");
proto_item_set_generated(ti);
if (hf_checksum_status != -1) {
ti2 = proto_tree_add_uint(tree, hf_checksum_status, tvb, offset, len, PROTO_CHECKSUM_E_NOT_PRESENT);
proto_item_set_generated(ti2);
}
return ti;
}
*/
mac = (gchar *)tvb_get_ptr(tvb, offset, mac_len);
if (flags & PROTO_CHECKSUM_GENERATED) {
// ti = proto_tree_add_uint(tree, hf_checksum, tvb, offset, len, computed_checksum);
// proto_item_set_generated(ti);
} else {
ti = proto_tree_add_item(tree, hf_mac, tvb, offset, mac_len, ENC_NA);
if (flags & PROTO_CHECKSUM_VERIFY) {
if (flags & (PROTO_CHECKSUM_IN_CKSUM|PROTO_CHECKSUM_ZERO)) {
if (!memcmp(mac, calc_mac, mac_len)) {
proto_item_append_text(ti, " [correct]");
if (hf_mac_status != -1) {
ti2 = proto_tree_add_uint(tree, hf_mac_status, tvb, offset, 0, PROTO_CHECKSUM_E_GOOD);
proto_item_set_generated(ti2);
}
incorrect_mac = FALSE;
} else if (flags & PROTO_CHECKSUM_IN_CKSUM) {
// computed_checksum = in_cksum_shouldbe(checksum, computed_checksum);
}
} else {
if (!memcmp(mac, calc_mac, mac_len)) {
proto_item_append_text(ti, " [correct]");
if (hf_mac_status != -1) {
ti2 = proto_tree_add_uint(tree, hf_mac_status, tvb, offset, 0, PROTO_CHECKSUM_E_GOOD);
proto_item_set_generated(ti2);
}
incorrect_mac = FALSE;
}
}
if (incorrect_mac) {
if (hf_mac_status != -1) {
ti2 = proto_tree_add_uint(tree, hf_mac_status, tvb, offset, 0, PROTO_CHECKSUM_E_BAD);
proto_item_set_generated(ti2);
}
if (flags & PROTO_CHECKSUM_ZERO) {
proto_item_append_text(ti, " [incorrect]");
if (bad_checksum_expert != NULL)
expert_add_info_format(pinfo, ti, bad_checksum_expert, "%s", expert_get_summary(bad_checksum_expert));
} else {
gchar *data = (gchar *)wmem_alloc(wmem_packet_scope(), mac_len*2 + 1);
*bytes_to_hexstr(data, calc_mac, mac_len) = 0;
proto_item_append_text(ti, " incorrect, computed %s", data);
if (bad_checksum_expert != NULL)
expert_add_info_format(pinfo, ti, bad_checksum_expert, "%s", expert_get_summary(bad_checksum_expert));
}
}
} else {
if (hf_mac_status != -1) {
proto_item_append_text(ti, " [unverified]");
ti2 = proto_tree_add_uint(tree, hf_mac_status, tvb, offset, 0, PROTO_CHECKSUM_E_UNVERIFIED);
proto_item_set_generated(ti2);
}
}
}
return ti;
}
static gboolean
ssh_decrypt_chacha20(gcry_cipher_hd_t hd,
guint32 seqnr, guint32 counter, const guchar *ctext, guint ctext_len,
guchar *plain, guint plain_len)
{
guchar seq[8];
guchar iv[16];
phton64(seq, (guint64)seqnr);
// chacha20 uses a different cipher handle for the packet payload & length
// the payload uses a block counter
if (counter) {
guchar ctr[8] = {1,0,0,0,0,0,0,0};
memcpy(iv, ctr, 8);
memcpy(iv+8, seq, 8);
}
return ((!counter && gcry_cipher_setiv(hd, seq, 8) == 0) ||
(counter && gcry_cipher_setiv(hd, iv, 16) == 0)) &&
gcry_cipher_decrypt(hd, plain, plain_len, ctext, ctext_len) == 0;
}
static int
ssh_dissect_decrypted_packet(tvbuff_t *tvb, packet_info *pinfo,
struct ssh_peer_data *peer_data, proto_tree *tree,
gchar *plaintext, guint plaintext_len)
{
int offset = 0; // TODO:
int dissected_len = 0;
col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "Encrypted packet (plaintext_len=%d)", plaintext_len);
tvbuff_t *packet_tvb = tvb_new_child_real_data(tvb, plaintext, plaintext_len, plaintext_len);
add_new_data_source(pinfo, packet_tvb, "Decrypted Packet");
guint plen, len;
guint8 padding_length;
guint remain_length;
int last_offset=offset;
guint msg_code;
proto_item *ti;
proto_item *msg_type_tree = NULL;
/*
* We use "tvb_ensure_captured_length_remaining()" to make sure there
* actually *is* data remaining.
*
* This means we're guaranteed that "remain_length" is positive.
*/
remain_length = tvb_ensure_captured_length_remaining(packet_tvb, offset);
/*
* Can we do reassembly?
*/
if (ssh_desegment && pinfo->can_desegment) {
/*
* Yes - would an SSH header starting at this offset
* be split across segment boundaries?
*/
if (remain_length < 4) {
/*
* Yes. Tell the TCP dissector where the data for
* this message starts in the data it handed us and
* that we need "some more data." Don't tell it
* exactly how many bytes we need because if/when we
* ask for even more (after the header) that will
* break reassembly.
*/
pinfo->desegment_offset = offset;
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
return offset;
}
}
plen = tvb_get_ntohl(packet_tvb, offset) ;
if (ssh_desegment && pinfo->can_desegment) {
if (plen +4 > remain_length) {
pinfo->desegment_offset = offset;
pinfo->desegment_len = plen+4 - remain_length;
return offset;
}
}
/*
* Need to check plen > 0x80000000 here
*/
ti = proto_tree_add_uint(tree, hf_ssh_packet_length, packet_tvb,
offset, 4, plen);
if (plen >= 0xffff) {
expert_add_info_format(pinfo, ti, &ei_ssh_packet_length, "Overly large number %d", plen);
plen = remain_length-4;
}
offset+=4;
/* padding length */
padding_length = tvb_get_guint8(packet_tvb, offset);
proto_tree_add_uint(tree, hf_ssh_padding_length, packet_tvb, offset, 1, padding_length);
offset += 1;
/* msg_code */
msg_code = tvb_get_guint8(packet_tvb, offset);
/* Transport layer protocol */
/* Generic (1-19) */
if(msg_code >= 1 && msg_code <= 19) {
col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, val_to_str(msg_code, ssh2_msg_vals, "Unknown (%u)"));
msg_type_tree = proto_tree_add_subtree(tree, packet_tvb, offset, plen-1, ett_key_exchange, NULL, "Message: Transport (generic)");
proto_tree_add_item(msg_type_tree, hf_ssh2_msg_code, packet_tvb, offset, 1, ENC_BIG_ENDIAN);
offset+=1;
dissected_len = ssh_dissect_transport_generic(packet_tvb, pinfo, offset, msg_type_tree, msg_code) - offset;
// offset = ssh_dissect_transport_generic(packet_tvb, pinfo, global_data, offset, msg_type_tree, is_response, msg_code);
}
/* Algorithm negotiation (20-29) */
else if(msg_code >=20 && msg_code <= 29) {
msg_type_tree = proto_tree_add_subtree(tree, packet_tvb, offset, plen-1, ett_key_exchange, NULL, "Message: Transport (algorithm negotiation)");
//TODO: See if the complete dissector should be refactored to always got through here first offset = ssh_dissect_transport_algorithm_negotiation(packet_tvb, pinfo, global_data, offset, msg_type_tree, is_response, msg_code);
}
/* Key exchange method specific (reusable) (30-49) */
else if (msg_code >=30 && msg_code <= 49) {
msg_type_tree = proto_tree_add_subtree(tree, packet_tvb, offset, plen-1, ett_key_exchange, NULL, "Message: Transport (key exchange method specific)");
//TODO: See if the complete dissector should be refactored to always got through here first offset = global_data->kex_specific_dissector(msg_code, packet_tvb, pinfo, offset, msg_type_tree);
}
/* User authentication protocol */
/* Generic (50-59) */
else if (msg_code >= 50 && msg_code <= 59) {
col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, val_to_str(msg_code, ssh2_msg_vals, "Unknown (%u)"));
msg_type_tree = proto_tree_add_subtree(tree, packet_tvb, offset, plen-1, ett_key_exchange, NULL, "Message: User Authentication (generic)");
proto_tree_add_item(msg_type_tree, hf_ssh2_msg_code, packet_tvb, offset, 1, ENC_BIG_ENDIAN);
dissected_len = ssh_dissect_userauth_generic(packet_tvb, pinfo, offset+1, msg_type_tree, msg_code) - offset;
// TODO: offset = ssh_dissect_userauth_generic(packet_tvb, pinfo, global_data, offset, msg_type_tree, is_response, msg_code);
}
/* User authentication method specific (reusable) (60-79) */
else if (msg_code >= 60 && msg_code <= 79) {
col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, val_to_str(msg_code, ssh2_msg_vals, "Unknown (%u)"));
msg_type_tree = proto_tree_add_subtree(tree, packet_tvb, offset, plen-1, ett_key_exchange, NULL, "Message: User Authentication: (method specific)");
proto_tree_add_item(msg_type_tree, hf_ssh2_msg_code, packet_tvb, offset, 1, ENC_BIG_ENDIAN);
// TODO: offset = ssh_dissect_userauth_specific(packet_tvb, pinfo, global_data, offset, msg_type_tree, is_response, msg_code);
dissected_len = ssh_dissect_userauth_specific(packet_tvb, pinfo, offset+1, msg_type_tree, msg_code) - offset;
}
/* Connection protocol */
/* Generic (80-89) */
else if (msg_code >= 80 && msg_code <= 89) {
col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, val_to_str(msg_code, ssh2_msg_vals, "Unknown (%u)"));
msg_type_tree = proto_tree_add_subtree(tree, packet_tvb, offset, plen-1, ett_key_exchange, NULL, "Message: Connection (generic)");
proto_tree_add_item(msg_type_tree, hf_ssh2_msg_code, packet_tvb, offset, 1, ENC_BIG_ENDIAN);
// TODO: offset = ssh_dissect_connection_generic(packet_tvb, pinfo, global_data, offset, msg_type_tree, is_response, msg_code);
dissected_len = ssh_dissect_connection_generic(packet_tvb, pinfo, offset+1, msg_type_tree, msg_code) - offset;
}
/* Channel related messages (90-127) */
else if (msg_code >= 90 && msg_code <= 127) {
col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, val_to_str(msg_code, ssh2_msg_vals, "Unknown (%u)"));
msg_type_tree = proto_tree_add_subtree(tree, packet_tvb, offset, plen-1, ett_key_exchange, NULL, "Message: Connection: (channel related message)");
proto_tree_add_item(msg_type_tree, hf_ssh2_msg_code, packet_tvb, offset, 1, ENC_BIG_ENDIAN);
// TODO: offset = ssh_dissect_connection_channel(packet_tvb, pinfo, global_data, offset, msg_type_tree, is_response, msg_code);
dissected_len = ssh_dissect_connection_specific(packet_tvb, pinfo, peer_data, offset+1, msg_type_tree, msg_code) - offset;
}
/* Reserved for client protocols (128-191) */
else if (msg_code >= 128 && msg_code <= 191) {
col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, val_to_str(msg_code, ssh2_msg_vals, "Unknown (%u)"));
msg_type_tree = proto_tree_add_subtree(tree, packet_tvb, offset, plen-1, ett_key_exchange, NULL, "Message: Client protocol");
proto_tree_add_item(msg_type_tree, hf_ssh2_msg_code, packet_tvb, offset, 1, ENC_BIG_ENDIAN);
offset+=1;
// TODO: offset = ssh_dissect_client(packet_tvb, pinfo, global_data, offset, msg_type_tree, is_response, msg_code);
}
/* Local extensions (192-255) */
else if (msg_code >= 192 && msg_code <= 255) {
col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, val_to_str(msg_code, ssh2_msg_vals, "Unknown (%u)"));
msg_type_tree = proto_tree_add_subtree(tree, packet_tvb, offset, plen-1, ett_key_exchange, NULL, "Message: Local extension");
proto_tree_add_item(msg_type_tree, hf_ssh2_msg_code, packet_tvb, offset, 1, ENC_BIG_ENDIAN);
offset+=1;
// TODO: offset = ssh_dissect_local_extention(packet_tvb, pinfo, global_data, offset, msg_type_tree, is_response, msg_code);
}
len = plen+4-padding_length-(offset-last_offset);
if (len > 0) {
proto_tree_add_item(msg_type_tree, hf_ssh_payload, packet_tvb, offset, len, ENC_NA);
}
if(dissected_len!=(int)len){
// expert_add_info_format(pinfo, ti, &ei_ssh_packet_decode, "Decoded %d bytes, but packet length is %d bytes", dissected_len, len);
expert_add_info_format(pinfo, ti, &ei_ssh_packet_decode, "Decoded %d bytes, but packet length is %d bytes [%d]", dissected_len, len, msg_code);
}
offset +=len;
/* padding */
proto_tree_add_item(tree, hf_ssh_padding_string, packet_tvb, offset, padding_length, ENC_NA);
offset+= padding_length;
return offset;
}
static int
ssh_dissect_transport_generic(tvbuff_t *packet_tvb, packet_info *pinfo,
int offset, proto_item *msg_type_tree, guint msg_code)
{
(void)pinfo;
if(msg_code==SSH_MSG_DISCONNECT){
proto_tree_add_item(msg_type_tree, hf_ssh_disconnect_reason, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
guint nlen;
nlen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_disconnect_description_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_disconnect_description, packet_tvb, offset, nlen, ENC_ASCII);
offset += nlen;
nlen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_lang_tag_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_lang_tag, packet_tvb, offset, nlen, ENC_ASCII);
offset += nlen;
}else if(msg_code==SSH_MSG_IGNORE){
offset += ssh_tree_add_string(packet_tvb, offset, msg_type_tree, hf_ssh_ignore_data, hf_ssh_ignore_data_length);
}else if(msg_code==SSH_MSG_DEBUG){
guint slen;
proto_tree_add_item(msg_type_tree, hf_ssh_debug_always_display, packet_tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_debug_message_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_debug_message, packet_tvb, offset, slen, ENC_UTF_8);
offset += slen;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_lang_tag_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_lang_tag, packet_tvb, offset, slen, ENC_ASCII);
offset += slen;
}else if(msg_code==SSH_MSG_SERVICE_REQUEST){
guint nlen;
nlen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_service_name_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_service_name, packet_tvb, offset, nlen, ENC_ASCII);
offset += nlen;
}else if(msg_code==SSH_MSG_SERVICE_ACCEPT){
guint nlen;
nlen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_service_name_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_service_name, packet_tvb, offset, nlen, ENC_ASCII);
offset += nlen;
}
return offset;
}
static int
ssh_dissect_userauth_generic(tvbuff_t *packet_tvb, packet_info *pinfo,
int offset, proto_item *msg_type_tree, guint msg_code)
{
if(msg_code==SSH_MSG_USERAUTH_REQUEST){
guint slen;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_user_name_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_user_name, packet_tvb, offset, slen, ENC_ASCII);
offset += slen;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_service_name_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_service_name, packet_tvb, offset, slen, ENC_ASCII);
offset += slen;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_method_name_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_method_name, packet_tvb, offset, slen, ENC_ASCII);
guint8* key_type;
key_type = tvb_get_string_enc(wmem_packet_scope(), packet_tvb, offset, slen, ENC_ASCII|ENC_NA);
offset += slen;
if (0 == strcmp(key_type, "none")) {
}else if (0 == strcmp(key_type, "publickey")) {
guint8 bHaveSignature = tvb_get_guint8(packet_tvb, offset);
int dissected_len = 0;
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_have_signature, packet_tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_pka_name_len, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_pka_name, packet_tvb, offset, slen, ENC_ASCII);
offset += slen;
proto_item *blob_tree = NULL;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_blob_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
blob_tree = proto_tree_add_subtree(msg_type_tree, packet_tvb, offset, slen, ett_userauth_pk_blob, NULL, "Public key blob");
// proto_tree_add_item(blob_tree, hf_ssh2_msg_code, packet_tvb, offset, 1, ENC_BIG_ENDIAN);
dissected_len = ssh_dissect_public_key_blob(packet_tvb, pinfo, offset, blob_tree) - offset;
if(dissected_len!=(int)slen){
expert_add_info_format(pinfo, blob_tree, &ei_ssh_packet_decode, "Decoded %d bytes, but packet length is %d bytes", dissected_len, slen);
}
offset += slen;
if(bHaveSignature){
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_signature_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_item *signature_tree = NULL;
signature_tree = proto_tree_add_subtree(msg_type_tree, packet_tvb, offset, slen, ett_userauth_pk_signautre, NULL, "Public key signature");
dissected_len = ssh_dissect_public_key_signature(packet_tvb, pinfo, offset, signature_tree) - offset;
if(dissected_len!=(int)slen){
expert_add_info_format(pinfo, signature_tree, &ei_ssh_packet_decode, "Decoded %d bytes, but packet length is %d bytes", dissected_len, slen);
}
offset += slen;
}
}else if (0 == strcmp(key_type, "password")) {
guint8 bChangePassword = tvb_get_guint8(packet_tvb, offset);
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_change_password, packet_tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_password_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_password, packet_tvb, offset, slen, ENC_ASCII);
offset += slen;
if(bChangePassword){
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_new_password_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_new_password, packet_tvb, offset, slen, ENC_ASCII);
offset += slen;
}
}else{
}
}else if(msg_code==SSH_MSG_USERAUTH_FAILURE){
guint slen;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_auth_failure_list_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_auth_failure_list, packet_tvb, offset, slen, ENC_ASCII);
offset += slen;
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_partial_success, packet_tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
}
return offset;
}
static int
ssh_dissect_userauth_specific(tvbuff_t *packet_tvb, packet_info *pinfo,
int offset, proto_item *msg_type_tree, guint msg_code)
{
if(msg_code==SSH_MSG_USERAUTH_PK_OK){
proto_item *ti;
int dissected_len = 0;
guint slen;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_pka_name_len, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_userauth_pka_name, packet_tvb, offset, slen, ENC_ASCII);
offset += slen;
proto_item *blob_tree = NULL;
slen = tvb_get_ntohl(packet_tvb, offset) ;
ti = proto_tree_add_item(msg_type_tree, hf_ssh_blob_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
blob_tree = proto_tree_add_subtree(msg_type_tree, packet_tvb, offset, slen, ett_userauth_pk_blob, NULL, "Public key blob");
dissected_len = ssh_dissect_public_key_blob(packet_tvb, pinfo, offset, blob_tree) - offset;
if(dissected_len!=(int)slen){
expert_add_info_format(pinfo, ti, &ei_ssh_packet_decode, "Decoded %d bytes, but packet length is %d bytes", dissected_len, slen);
}
offset += slen;
}
return offset;
}
static int
ssh_dissect_connection_specific(tvbuff_t *packet_tvb, packet_info *pinfo,
struct ssh_peer_data *peer_data, int offset, proto_item *msg_type_tree,
guint msg_code)
{
if(msg_code==SSH_MSG_CHANNEL_OPEN){
guint slen;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_connection_type_name_len, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_connection_type_name, packet_tvb, offset, slen, ENC_UTF_8);
offset += slen;
proto_tree_add_item(msg_type_tree, hf_ssh_connection_sender_channel, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_connection_initial_window, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_connection_maximum_packet_size, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}else if(msg_code==SSH_MSG_CHANNEL_OPEN_CONFIRMATION){
proto_tree_add_item(msg_type_tree, hf_ssh_connection_recipient_channel, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_connection_sender_channel, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_connection_initial_window, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_connection_maximum_packet_size, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}else if(msg_code==SSH_MSG_CHANNEL_WINDOW_ADJUST){
proto_tree_add_item(msg_type_tree, hf_ssh_connection_recipient_channel, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_channel_window_adjust, packet_tvb, offset, 4, ENC_BIG_ENDIAN); // TODO: maintain count of transfered bytes and window size
offset += 4;
}else if(msg_code==SSH_MSG_CHANNEL_DATA){
guint uiNumChannel;
uiNumChannel = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_connection_recipient_channel, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
// TODO: process according to the type of channel
guint slen;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_channel_data_len, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
tvbuff_t *next_tvb = tvb_new_subset_remaining(packet_tvb, offset);
dissector_handle_t subdissector_handle = get_subdissector_for_channel(peer_data, uiNumChannel);
if(subdissector_handle){
call_dissector(subdissector_handle, next_tvb, pinfo, msg_type_tree);
}
offset += slen;
}else if(msg_code==SSH_MSG_CHANNEL_EOF){
proto_tree_add_item(msg_type_tree, hf_ssh_connection_recipient_channel, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}else if(msg_code==SSH_MSG_CHANNEL_CLOSE){
proto_tree_add_item(msg_type_tree, hf_ssh_connection_recipient_channel, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}else if(msg_code==SSH_MSG_CHANNEL_REQUEST){
guint uiNumChannel;
uiNumChannel = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_connection_recipient_channel, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
guint8* request_name;
guint slen;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_channel_request_name_len, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
request_name = tvb_get_string_enc(wmem_packet_scope(), packet_tvb, offset, slen, ENC_ASCII|ENC_NA);
proto_tree_add_item(msg_type_tree, hf_ssh_channel_request_name, packet_tvb, offset, slen, ENC_UTF_8);
offset += slen;
proto_tree_add_item(msg_type_tree, hf_ssh_channel_request_want_reply, packet_tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
if (0 == strcmp(request_name, "subsystem")) {
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_subsystem_name_len, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
guint8* subsystem_name = tvb_get_string_enc(wmem_packet_scope(), packet_tvb, offset, slen, ENC_ASCII|ENC_NA);
set_subdissector_for_channel(peer_data, uiNumChannel, subsystem_name);
proto_tree_add_item(msg_type_tree, hf_ssh_subsystem_name, packet_tvb, offset, slen, ENC_UTF_8);
offset += slen;
}else if (0 == strcmp(request_name, "exit-status")) {
proto_tree_add_item(msg_type_tree, hf_ssh_exit_status, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
}else if(msg_code==SSH_MSG_CHANNEL_SUCCESS){
proto_tree_add_item(msg_type_tree, hf_ssh_connection_recipient_channel, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
return offset;
}
static dissector_handle_t
get_subdissector_for_channel(struct ssh_peer_data *peer_data, guint uiNumChannel)
{
ssh_channel_info_t *ci = peer_data->global_data->channel_info;
while(ci){
guint channel_number = &peer_data->global_data->peer_data[SERVER_PEER_DATA]==peer_data?ci->client_channel_number:ci->server_channel_number;
if(channel_number==uiNumChannel){return ci->subdissector_handle;}
ci = ci->next;
}
ws_debug("Error lookin up channel %d", uiNumChannel);
return NULL;
}
static void
set_subdissector_for_channel(struct ssh_peer_data *peer_data, guint uiNumChannel, guint8* subsystem_name)
{
ssh_channel_info_t *ci = NULL;
ssh_channel_info_t **pci = &peer_data->global_data->channel_info;
int is_server = &peer_data->global_data->peer_data[SERVER_PEER_DATA]==peer_data;
while(*pci){
guint channel_number = is_server?(*pci)->client_channel_number:(*pci)->server_channel_number;
if (channel_number == uiNumChannel) {
ci = *pci;
break;
}
pci = &(*pci)->next;
}
if(!ci){
ci = wmem_new(wmem_file_scope(), ssh_channel_info_t);
*pci = ci;
}
if(0 == strcmp(subsystem_name, "sftp")) {
ci->subdissector_handle = sftp_handle;
} else {
ci->subdissector_handle = NULL;
}
}
static int
ssh_dissect_connection_generic(tvbuff_t *packet_tvb, packet_info *pinfo,
int offset, proto_item *msg_type_tree, guint msg_code)
{
(void)pinfo;
if(msg_code==SSH_MSG_GLOBAL_REQUEST){
guint8* request_name;
guint slen;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_global_request_name_len, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
request_name = tvb_get_string_enc(wmem_packet_scope(), packet_tvb, offset, slen, ENC_ASCII|ENC_NA);
proto_tree_add_item(msg_type_tree, hf_ssh_global_request_name, packet_tvb, offset, slen, ENC_ASCII);
offset += slen;
proto_tree_add_item(msg_type_tree, hf_ssh_global_request_want_reply, packet_tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
if (0 == strcmp(request_name, "[email protected]")) {
guint alen;
proto_item *ti;
int dissected_len = 0;
alen = tvb_get_ntohl(packet_tvb, offset) ;
ti = proto_tree_add_item(msg_type_tree, hf_ssh_global_request_hostkeys_array_len, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_item *blob_tree = NULL;
blob_tree = proto_tree_add_subtree(msg_type_tree, packet_tvb, offset, alen, ett_userauth_pk_blob, NULL, "Public key blob");
dissected_len = ssh_dissect_public_key_blob(packet_tvb, pinfo, offset, blob_tree) - offset;
if(dissected_len!=(int)alen){
expert_add_info_format(pinfo, ti, &ei_ssh_packet_decode, "Decoded %d bytes, but packet length is %d bytes", dissected_len, alen);
}
offset += alen;
}
}
return offset;
}
static int
ssh_dissect_public_key_blob(tvbuff_t *packet_tvb, packet_info *pinfo,
int offset, proto_item *msg_type_tree)
{
(void)pinfo;
guint slen;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_pk_blob_name_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_pk_blob_name, packet_tvb, offset, slen, ENC_ASCII);
offset += slen;
offset += ssh_tree_add_mpint(packet_tvb, offset, msg_type_tree, hf_ssh_blob_e);
offset += ssh_tree_add_mpint(packet_tvb, offset, msg_type_tree, hf_ssh_blob_p);
return offset;
}
static int
ssh_dissect_public_key_signature(tvbuff_t *packet_tvb, packet_info *pinfo,
int offset, proto_item *msg_type_tree)
{
(void)pinfo;
guint slen;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_pk_sig_blob_name_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_pk_sig_blob_name, packet_tvb, offset, slen, ENC_ASCII);
offset += slen;
slen = tvb_get_ntohl(packet_tvb, offset) ;
proto_tree_add_item(msg_type_tree, hf_ssh_pk_sig_s_length, packet_tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(msg_type_tree, hf_ssh_pk_sig_s, packet_tvb, offset, slen, ENC_NA);
offset += slen;
return offset;
}
#ifdef SSH_DECRYPT_DEBUG /* {{{ */
static FILE* ssh_debug_file=NULL;
static void
ssh_prefs_apply_cb(void)
{
ssh_set_debug(ssh_debug_file_name);
}
static void
ssh_set_debug(const gchar* name)
{
static gint debug_file_must_be_closed;
gint use_stderr;
use_stderr = name?(strcmp(name, SSH_DEBUG_USE_STDERR) == 0):0;
if (debug_file_must_be_closed)
fclose(ssh_debug_file);
if (use_stderr)
ssh_debug_file = stderr;
else if (!name || (strcmp(name, "") ==0))
ssh_debug_file = NULL;
else
ssh_debug_file = ws_fopen(name, "w");
if (!use_stderr && ssh_debug_file)
debug_file_must_be_closed = 1;
else
debug_file_must_be_closed = 0;
ssh_debug_printf("Wireshark SSH debug log \n\n");
#ifdef HAVE_LIBGNUTLS
ssh_debug_printf("GnuTLS version: %s\n", gnutls_check_version(NULL));
#endif
ssh_debug_printf("Libgcrypt version: %s\n", gcry_check_version(NULL));
ssh_debug_printf("\n");
}
static void
ssh_debug_flush(void)
{
if (ssh_debug_file)
fflush(ssh_debug_file);
}
static void
ssh_debug_printf(const gchar* fmt, ...)
{
va_list ap;
if (!ssh_debug_file)
return;
va_start(ap, fmt);
vfprintf(ssh_debug_file, fmt, ap);
va_end(ap);
}
static void
ssh_print_data(const gchar* name, const guchar* data, size_t len)
{
size_t i, j, k;
if (!ssh_debug_file)
return;
#ifdef OPENSSH_STYLE
fprintf(ssh_debug_file,"%s[%d]\n",name, (int) len);
#else
fprintf(ssh_debug_file,"%s[%d]:\n",name, (int) len);
#endif
for (i=0; i<len; i+=16) {
#ifdef OPENSSH_STYLE
fprintf(ssh_debug_file,"%04u: ", (unsigned int)i);
#else
fprintf(ssh_debug_file,"| ");
#endif
for (j=i, k=0; k<16 && j<len; ++j, ++k)
fprintf(ssh_debug_file,"%.2x ",data[j]);
for (; k<16; ++k)
fprintf(ssh_debug_file," ");
#ifdef OPENSSH_STYLE
fputc(' ', ssh_debug_file);
#else
fputc('|', ssh_debug_file);
#endif
for (j=i, k=0; k<16 && j<len; ++j, ++k) {
guchar c = data[j];
if (!g_ascii_isprint(c) || (c=='\t')) c = '.';
fputc(c, ssh_debug_file);
}
#ifdef OPENSSH_STYLE
fprintf(ssh_debug_file,"\n");
#else
for (; k<16; ++k)
fputc(' ', ssh_debug_file);
fprintf(ssh_debug_file,"|\n");
#endif
}
}
#endif /* SSH_DECRYPT_DEBUG }}} */
static void
ssh_secrets_block_callback(const void *secrets, guint size)
{
ssh_keylog_process_lines((const guint8 *)secrets, size);
}
/* Functions for SSH random hashtables. {{{ */
static gint
ssh_equal (gconstpointer v, gconstpointer v2)
{
if (v == NULL || v2 == NULL) {
return 0;
}
const ssh_bignum *val1;
const ssh_bignum *val2;
val1 = (const ssh_bignum *)v;
val2 = (const ssh_bignum *)v2;
if (val1->length == val2->length &&
!memcmp(val1->data, val2->data, val2->length)) {
return 1;
}
return 0;
}
static guint
ssh_hash (gconstpointer v)
{
guint l,hash;
const ssh_bignum* id;
const guint* cur;
if (v == NULL) {
return 0;
}
hash = 0;
id = (const ssh_bignum*) v;
/* id and id->data are mallocated in ssh_save_master_key(). As such 'data'
* should be aligned for any kind of access (for example as a guint as
* is done below). The intermediate void* cast is to prevent "cast
* increases required alignment of target type" warnings on CPUs (such
* as SPARCs) that do not allow misaligned memory accesses.
*/
cur = (const guint*)(void*) id->data;
for (l=4; (l < id->length); l+=4, cur++)
hash = hash ^ (*cur);
return hash;
}
static void
ssh_free_glib_allocated_bignum(gpointer data)
{
ssh_bignum * bignum;
if (data == NULL) {
return;
}
bignum = (ssh_bignum *) data;
g_free(bignum->data);
g_free(bignum);
}
static void
ssh_free_glib_allocated_entry(gpointer data)
{
ssh_key_map_entry_t * entry;
if (data == NULL) {
return;
}
entry = (ssh_key_map_entry_t *) data;
g_free(entry->type);
ssh_free_glib_allocated_bignum(entry->key_material);
g_free(entry);
}
/* Functions for SSH random hashtables. }}} */
static void
ssh_shutdown(void) {
g_hash_table_destroy(ssh_master_key_map);
}
void
proto_register_ssh(void)
{
static hf_register_info hf[] = {
{ &hf_ssh_protocol,
{ "Protocol", "ssh.protocol",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_packet_length,
{ "Packet Length", "ssh.packet_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_packet_length_encrypted,
{ "Packet Length (encrypted)", "ssh.packet_length_encrypted",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_padding_length,
{ "Padding Length", "ssh.padding_length",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_payload,
{ "Payload", "ssh.payload",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_encrypted_packet,
{ "Encrypted Packet", "ssh.encrypted_packet",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_padding_string,
{ "Padding String", "ssh.padding_string",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_seq_num,
{ "Sequence number", "ssh.seq_num",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_mac_string,
{ "MAC", "ssh.mac",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Message authentication code", HFILL }},
{ &hf_ssh_mac_status,
{ "MAC Status", "ssh.mac.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
NULL, HFILL }},
{ &hf_ssh_direction,
{ "Direction", "ssh.direction",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"Message direction", HFILL }},
{ &hf_ssh_msg_code,
{ "Message Code", "ssh.message_code",
FT_UINT8, BASE_DEC, VALS(ssh1_msg_vals), 0x0,
NULL, HFILL }},
{ &hf_ssh2_msg_code,
{ "Message Code", "ssh.message_code",
FT_UINT8, BASE_DEC, VALS(ssh2_msg_vals), 0x0,
NULL, HFILL }},
{ &hf_ssh2_kex_dh_msg_code,
{ "Message Code", "ssh.message_code",
FT_UINT8, BASE_DEC, VALS(ssh2_kex_dh_msg_vals), 0x0,
NULL, HFILL }},
{ &hf_ssh2_kex_dh_gex_msg_code,
{ "Message Code", "ssh.message_code",
FT_UINT8, BASE_DEC, VALS(ssh2_kex_dh_gex_msg_vals), 0x0,
NULL, HFILL }},
{ &hf_ssh2_kex_ecdh_msg_code,
{ "Message Code", "ssh.message_code",
FT_UINT8, BASE_DEC, VALS(ssh2_kex_ecdh_msg_vals), 0x0,
NULL, HFILL }},
{ &hf_ssh_cookie,
{ "Cookie", "ssh.cookie",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_kex_algorithms,
{ "kex_algorithms string", "ssh.kex_algorithms",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_server_host_key_algorithms,
{ "server_host_key_algorithms string", "ssh.server_host_key_algorithms",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_encryption_algorithms_client_to_server,
{ "encryption_algorithms_client_to_server string", "ssh.encryption_algorithms_client_to_server",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_encryption_algorithms_server_to_client,
{ "encryption_algorithms_server_to_client string", "ssh.encryption_algorithms_server_to_client",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_mac_algorithms_client_to_server,
{ "mac_algorithms_client_to_server string", "ssh.mac_algorithms_client_to_server",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_mac_algorithms_server_to_client,
{ "mac_algorithms_server_to_client string", "ssh.mac_algorithms_server_to_client",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_compression_algorithms_client_to_server,
{ "compression_algorithms_client_to_server string", "ssh.compression_algorithms_client_to_server",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_compression_algorithms_server_to_client,
{ "compression_algorithms_server_to_client string", "ssh.compression_algorithms_server_to_client",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_languages_client_to_server,
{ "languages_client_to_server string", "ssh.languages_client_to_server",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_languages_server_to_client,
{ "languages_server_to_client string", "ssh.languages_server_to_client",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_kex_algorithms_length,
{ "kex_algorithms length", "ssh.kex_algorithms_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_server_host_key_algorithms_length,
{ "server_host_key_algorithms length", "ssh.server_host_key_algorithms_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_encryption_algorithms_client_to_server_length,
{ "encryption_algorithms_client_to_server length", "ssh.encryption_algorithms_client_to_server_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_encryption_algorithms_server_to_client_length,
{ "encryption_algorithms_server_to_client length", "ssh.encryption_algorithms_server_to_client_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_mac_algorithms_client_to_server_length,
{ "mac_algorithms_client_to_server length", "ssh.mac_algorithms_client_to_server_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_mac_algorithms_server_to_client_length,
{ "mac_algorithms_server_to_client length", "ssh.mac_algorithms_server_to_client_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_compression_algorithms_client_to_server_length,
{ "compression_algorithms_client_to_server length", "ssh.compression_algorithms_client_to_server_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_compression_algorithms_server_to_client_length,
{ "compression_algorithms_server_to_client length", "ssh.compression_algorithms_server_to_client_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_languages_client_to_server_length,
{ "languages_client_to_server length", "ssh.languages_client_to_server_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_languages_server_to_client_length,
{ "languages_server_to_client length", "ssh.languages_server_to_client_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_first_kex_packet_follows,
{ "First KEX Packet Follows", "ssh.first_kex_packet_follows",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_kex_reserved,
{ "Reserved", "ssh.kex.reserved",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_kex_hassh_algo,
{ "hasshAlgorithms", "ssh.kex.hassh_algorithms",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_kex_hassh,
{ "hassh", "ssh.kex.hassh",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_kex_hasshserver_algo,
{ "hasshServerAlgorithms", "ssh.kex.hasshserver_algorithms",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_kex_hasshserver,
{ "hasshServer", "ssh.kex.hasshserver",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostkey_length,
{ "Host key length", "ssh.host_key.length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostkey_type_length,
{ "Host key type length", "ssh.host_key.type_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostkey_type,
{ "Host key type", "ssh.host_key.type",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostkey_data,
{ "Host key data", "ssh.host_key.data",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostkey_rsa_n,
{ "RSA modulus (N)", "ssh.host_key.rsa.n",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostkey_rsa_e,
{ "RSA public exponent (e)", "ssh.host_key.rsa.e",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostkey_dsa_p,
{ "DSA prime modulus (p)", "ssh.host_key.dsa.p",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostkey_dsa_q,
{ "DSA prime divisor (q)", "ssh.host_key.dsa.q",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostkey_dsa_g,
{ "DSA subgroup generator (g)", "ssh.host_key.dsa.g",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostkey_dsa_y,
{ "DSA public key (y)", "ssh.host_key.dsa.y",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostkey_ecdsa_curve_id,
{ "ECDSA elliptic curve identifier", "ssh.host_key.ecdsa.id",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostkey_ecdsa_curve_id_length,
{ "ECDSA elliptic curve identifier length", "ssh.host_key.ecdsa.id_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostkey_ecdsa_q,
{ "ECDSA public key (Q)", "ssh.host_key.ecdsa.q",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostkey_ecdsa_q_length,
{ "ECDSA public key length", "ssh.host_key.ecdsa.q_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostkey_eddsa_key,
{ "EdDSA public key", "ssh.host_key.eddsa.key",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostkey_eddsa_key_length,
{ "EdDSA public key length", "ssh.host_key.eddsa.key_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostsig_length,
{ "Host signature length", "ssh.host_sig.length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostsig_type_length,
{ "Host signature type length", "ssh.host_sig.type_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostsig_type,
{ "Host signature type", "ssh.host_sig.type",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostsig_data,
{ "Host signature data", "ssh.host_sig.data",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostsig_rsa,
{ "RSA signature", "ssh.host_sig.rsa",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_hostsig_dsa,
{ "DSA signature", "ssh.host_sig.dsa",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_dh_e,
{ "DH client e", "ssh.dh.e",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_dh_f,
{ "DH server f", "ssh.dh.f",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_dh_gex_min,
{ "DH GEX Min", "ssh.dh_gex.min",
FT_UINT32, BASE_DEC, NULL, 0x0,
"Minimal acceptable group size", HFILL }},
{ &hf_ssh_dh_gex_nbits,
{ "DH GEX Number of Bits", "ssh.dh_gex.nbits",
FT_UINT32, BASE_DEC, NULL, 0x0,
"Preferred group size", HFILL }},
{ &hf_ssh_dh_gex_max,
{ "DH GEX Max", "ssh.dh_gex.max",
FT_UINT32, BASE_DEC, NULL, 0x0,
"Maximal acceptable group size", HFILL }},
{ &hf_ssh_dh_gex_p,
{ "DH GEX modulus (P)", "ssh.dh_gex.p",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_dh_gex_g,
{ "DH GEX base (G)", "ssh.dh_gex.g",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_ecdh_q_c,
{ "ECDH client's ephemeral public key (Q_C)", "ssh.ecdh.q_c",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_ecdh_q_c_length,
{ "ECDH client's ephemeral public key length", "ssh.ecdh.q_c_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_ecdh_q_s,
{ "ECDH server's ephemeral public key (Q_S)", "ssh.ecdh.q_s",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_ecdh_q_s_length,
{ "ECDH server's ephemeral public key length", "ssh.ecdh.q_s_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_mpint_length,
{ "Multi Precision Integer Length", "ssh.mpint_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_ignore_data_length,
{ "Debug message length", "ssh.ignore_data_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_ignore_data,
{ "Ignore data", "ssh.ignore_data",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_debug_always_display,
{ "Always Display", "ssh.debug_always_display",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_debug_message_length,
{ "Debug message length", "ssh.debug_name_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_debug_message,
{ "Debug message", "ssh.debug_name",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_service_name_length,
{ "Service Name length", "ssh.service_name_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_service_name,
{ "Service Name", "ssh.service_name",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_disconnect_reason,
{ "Disconnect reason", "ssh.disconnect_reason",
FT_UINT32, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_disconnect_description_length,
{ "Disconnect description length", "ssh.disconnect_description_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_disconnect_description,
{ "Disconnect description", "ssh.disconnect_description",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_lang_tag_length,
{ "Language tag length", "ssh.lang_tag_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_lang_tag,
{ "Language tag", "ssh.lang_tag",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_userauth_user_name_length,
{ "User Name length", "ssh.userauth_user_name_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_userauth_user_name,
{ "User Name", "ssh.userauth_user_name",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_userauth_change_password,
{ "Change password", "ssh.userauth.change_password",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_userauth_service_name_length,
{ "Service Name length", "ssh.userauth_service_name_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_userauth_service_name,
{ "Service Name", "ssh.userauth_service_name",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_userauth_method_name_length,
{ "Method Name length", "ssh.userauth_method_name_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_userauth_method_name,
{ "Method Name", "ssh.userauth_method_name",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_userauth_have_signature,
{ "Have signature", "ssh.userauth.have_signature",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_userauth_password_length,
{ "Password length", "ssh.userauth_password_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_userauth_password,
{ "Password", "ssh.userauth_password",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_userauth_new_password_length,
{ "New password length", "ssh.userauth_new_password_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_userauth_new_password,
{ "New password", "ssh.userauth_new_password",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_auth_failure_list_length,
{ "Authentications that can continue list len", "ssh.auth_failure_cont_list_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_auth_failure_list,
{ "Authentications that can continue list", "ssh.auth_failure_cont_list",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_userauth_partial_success,
{ "Partial success", "ssh.userauth.partial_success",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_userauth_pka_name_len,
{ "Public key algorithm name length", "ssh.userauth_pka_name_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_userauth_pka_name,
{ "Public key algorithm name", "ssh.userauth_pka_name",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_pk_blob_name_length,
{ "Public key blob algorithm name length", "ssh.pk_blob_name_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_pk_blob_name,
{ "Public key blob algorithm name", "ssh.pk_blob_name",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_blob_length,
{ "Public key blob length", "ssh.pk_blob_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_blob_p,
{ "ssh-rsa modulus (n)", "ssh.blob.ssh-rsa.n",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_blob_e,
{ "ssh-rsa public exponent (e)", "ssh.blob.ssh-rsa.e",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_signature_length,
{ "Public key signature blob length", "ssh.pk_sig_blob_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_pk_sig_blob_name_length,
{ "Public key signature blob algorithm name length", "ssh.pk_sig_blob_name_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_pk_sig_blob_name,
{ "Public key signature blob algorithm name", "ssh.pk_sig_blob_name",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_pk_sig_s_length,
{ "ssh-rsa signature length", "ssh.sig.ssh-rsa.length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_pk_sig_s,
{ "ssh-rsa signature (s)", "ssh.sig.ssh-rsa.s",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_connection_type_name_len,
{ "Channel type name length", "ssh.connection_type_name_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_connection_type_name,
{ "Channel type name", "ssh.connection_type_name",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_connection_sender_channel,
{ "Sender channel", "ssh.connection_sender_channel",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_connection_recipient_channel,
{ "Recipient channel", "ssh.connection_recipient_channel",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_connection_initial_window,
{ "Initial window size", "ssh.connection_initial_window_size",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_connection_maximum_packet_size,
{ "Maximum packet size", "ssh.userauth_maximum_packet_size",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_global_request_name_len,
{ "Global request name length", "ssh.global_request_name_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_global_request_name,
{ "Global request name", "ssh.global_request_name",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_global_request_want_reply,
{ "Global request want reply", "ssh.global_request_want_reply",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_global_request_hostkeys_array_len,
{ "Host keys array length", "ssh.global_request_hostkeys",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_channel_request_name_len,
{ "Channel request name length", "ssh.global_request_name_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_channel_request_name,
{ "Channel request name", "ssh.global_request_name",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_channel_request_want_reply,
{ "Channel request want reply", "ssh.channel_request_want_reply",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_subsystem_name_len,
{ "Subsystem name length", "ssh.subsystem_name_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_subsystem_name,
{ "Subsystem name", "ssh.subsystem_name",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_exit_status,
{ "Exit status", "ssh.exit_status",
FT_UINT32, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_channel_window_adjust,
{ "Bytes to add", "ssh.channel_window_adjust",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_ssh_channel_data_len,
{ "Data length", "ssh.channel_data_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
};
static gint *ett[] = {
&ett_ssh,
&ett_key_exchange,
&ett_key_exchange_host_key,
&ett_key_exchange_host_sig,
&ett_userauth_pk_blob,
&ett_userauth_pk_signautre,
&ett_ssh1,
&ett_ssh2,
&ett_key_init
};
static ei_register_info ei[] = {
{ &ei_ssh_packet_length, { "ssh.packet_length.error", PI_PROTOCOL, PI_WARN, "Overly large number", EXPFILL }},
{ &ei_ssh_packet_decode, { "ssh.packet_decode.error", PI_PROTOCOL, PI_WARN, "Packet decoded length not equal to packet length", EXPFILL }},
{ &ei_ssh_invalid_keylen, { "ssh.key_length.error", PI_PROTOCOL, PI_ERROR, "Invalid key length", EXPFILL }},
{ &ei_ssh_mac_bad, { "ssh.mac_bad.expert", PI_CHECKSUM, PI_ERROR, "Bad MAC", EXPFILL }},
};
module_t *ssh_module;
expert_module_t *expert_ssh;
proto_ssh = proto_register_protocol("SSH Protocol", "SSH", "ssh");
proto_register_field_array(proto_ssh, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_ssh = expert_register_protocol(proto_ssh);
expert_register_field_array(expert_ssh, ei, array_length(ei));
#ifdef SSH_DECRYPT_DEBUG
ssh_module = prefs_register_protocol(proto_ssh, ssh_prefs_apply_cb);
#else
ssh_module = prefs_register_protocol(proto_ssh, NULL);
#endif
prefs_register_bool_preference(ssh_module, "desegment_buffers",
"Reassemble SSH buffers spanning multiple TCP segments",
"Whether the SSH dissector should reassemble SSH buffers spanning multiple TCP segments. "
"To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
&ssh_desegment);
ssh_master_key_map = g_hash_table_new_full(ssh_hash, ssh_equal, ssh_free_glib_allocated_bignum, ssh_free_glib_allocated_entry);
prefs_register_filename_preference(ssh_module, "keylog_file", "Key log filename",
"The path to the file which contains a list of key exchange secrets in the following format:\n"
"\"<hex-encoded-cookie> <PRIVATE_KEY|SHARED_SECRET> <hex-encoded-key>\" (without quotes or leading spaces).\n",
&pref_keylog_file, FALSE);
prefs_register_filename_preference(ssh_module, "debug_file", "SSH debug file",
"Redirect SSH debug to the file specified. Leave empty to disable debugging "
"or use \"" SSH_DEBUG_USE_STDERR "\" to redirect output to stderr.",
&ssh_debug_file_name, TRUE);
secrets_register_type(SECRETS_TYPE_SSH, ssh_secrets_block_callback);
ssh_handle = register_dissector("ssh", dissect_ssh, proto_ssh);
register_shutdown_routine(ssh_shutdown);
}
void
proto_reg_handoff_ssh(void)
{
#ifdef SSH_DECRYPT_DEBUG
ssh_set_debug(ssh_debug_file_name);
#endif
dissector_add_uint_range_with_preference("tcp.port", TCP_RANGE_SSH, ssh_handle);
dissector_add_uint("sctp.port", SCTP_PORT_SSH, ssh_handle);
dissector_add_uint("sctp.ppi", SSH_PAYLOAD_PROTOCOL_ID, ssh_handle);
sftp_handle = find_dissector("sftp");
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-sstp.c
|
/* packet-sstp.c
* routines for sstp packet dissasembly
* - MS-SSTP:
*
* https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-sstp
*
* Created as part of a semester project at the University of Applied Sciences Hagenberg
* (https://www.fh-ooe.at/en/hagenberg-campus/)
*
* Copyright (c) 2013:
* Hofer Manuel ([email protected])
* Nemeth Franz
* Scheipner Alexander
* Stiftinger Thomas
* Werner Sebastian
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include "packet-tcp.h"
void proto_register_sstp(void);
void proto_reg_handoff_sstp(void);
#define SSTP_BITMASK_MAJORVERSION 0xF0
#define SSTP_BITMASK_MINORVERSION 0x0F
#define SSTP_BITMASK_CONTROLFLAG 0x01
#define SSTP_BITMASK_LENGTH_RESERVED 0xF000
#define SSTP_BITMASK_LENGTH_LENGTH 0x0FFF
#define SSTP_CERT_HASH_PROTOCOL_SHA1 0x01
#define SSTP_CERT_HASH_PROTOCOL_SHA256 0x02
#define SSTP_ENCAPSULATED_PPP 0x0001
/* bytewise offsets inside the paket buffer */
#define SSTP_OFFSET_ATTRIBUTES 8
#define SSTP_OFFSET_DATA 4
#define SSTP_OFFSET_RESERVED 1
#define SSTP_OFFSET_ISCONTROL 1
#define SSTP_OFFSET_LENGTH 2
#define SSTP_OFFSET_MAJORVERSION 0
#define SSTP_OFFSET_MINORVERSION 0
#define SSTP_OFFSET_MSGTYPE 4
#define SSTP_OFFSET_NUMATTRIB 6
/* fieldsize in byte */
#define SSTP_FSIZE_ATTRIBUTE 4
#define SSTP_FSIZE_ATTRIB_ID 1
#define SSTP_FSIZE_ATTRIB_LENGTH 2
#define SSTP_FSIZE_ATTRIB_RESERVED 1
#define SSTP_FSIZE_CERT_HASH_SHA1 20
#define SSTP_FSIZE_CERT_HASH_SHA256 32
#define SSTP_FSIZE_COMPOUND_MAC_SHA1 20
#define SSTP_FSIZE_COMPOUND_MAC_SHA256 32
#define SSTP_FSIZE_ENCAPSULATED_PROTOCOL 2
#define SSTP_FSIZE_HASH_PROTOCOL 1
#define SSTP_FSIZE_HASH_PROTOCOL_BITMASK 1
#define SSTP_FSIZE_ISCONTROL 1
#define SSTP_FSIZE_LENGTH 2
#define SSTP_FSIZE_MAJORVERSION 1
#define SSTP_FSIZE_MINORVERSION 1
#define SSTP_FSIZE_MSGTYPE 2
#define SSTP_FSIZE_NONCE 32
#define SSTP_FSIZE_NUMATTRIB 2
#define SSTP_FSIZE_PADDING_SHA1 12
#define SSTP_FSIZE_RESERVED 1
#define SSTP_FSIZE_RESERVED2 3
#define SSTP_FSIZE_STATUS 4
/* Message types */
#define SSTP_MSG_CALL_ABORT 0x005
#define SSTP_MSG_CALL_CONNECTED 0x004
#define SSTP_MSG_CALL_CONNECT_ACK 0x002
#define SSTP_MSG_CALL_CONNECT_NAK 0x003
#define SSTP_MSG_CALL_CONNECT_REQUEST 0x001
#define SSTP_MSG_CALL_DISCONNECT 0x006
#define SSTP_MSG_CALL_DISCONNECT_ACK 0x007
#define SSTP_MSG_ECHO_REQUEST 0x008
#define SSTP_MSG_ECHO_RESPONSE 0x009
/* Attribute Types */
#define SSTP_ATTRIB_CRYPTO_BINDING 3
#define SSTP_ATTRIB_CRYPTO_BINDING_REQ 4
#define SSTP_ATTRIB_ENCAPSULATED_PROTOCOL_ID 1
#define SSTP_ATTRIB_NO_ERROR 0
#define SSTP_ATTRIB_STATUS_INFO 2
/* Status Types */
#define SSTP_ATTRIB_STATUS_ATTRIB_NOT_SUPPORTED_IN_MSG 0x000009
#define SSTP_ATTRIB_STATUS_DUPLICATE_ATTRIBUTE 0x000001
#define SSTP_ATTRIB_STATUS_INVALID_ATTRIB_VALUE_LENGTH 0x000003
#define SSTP_ATTRIB_STATUS_INVALID_FRAME_RECEIVED 0x000007
#define SSTP_ATTRIB_STATUS_NEGOTIATION_TIMEOUT 0x000008
#define SSTP_ATTRIB_STATUS_NO_ERROR 0x000000
#define SSTP_ATTRIB_STATUS_REQUIRED_ATTRIBUTE_MISSING 0x00000a
#define SSTP_ATTRIB_STATUS_RETRY_COUNT_EXCEEDED 0x000006
#define SSTP_ATTRIB_STATUS_STATUS_INFO_NOT_SUPPORTED_IN_MSG 0x00000b
#define SSTP_ATTRIB_STATUS_UNACCEPTED_FRAME_RECEIVED 0x000005
#define SSTP_ATTRIB_STATUS_UNRECOGNIZED_ATTRIBUTE 0x000002
#define SSTP_ATTRIB_STATUS_VALUE_NOT_SUPPORTED 0x000004
static dissector_handle_t ppp_hdlc_handle = NULL;
static gint ett_sstp = -1;
static gint ett_sstp_attribute = -1;
static gint ett_sstp_version = -1;
static gint hf_sstp_attrib_id = -1;
static gint hf_sstp_attrib_length = -1;
static gint hf_sstp_attrib_length_reserved = -1;
static gint hf_sstp_attrib_reserved = -1;
static gint hf_sstp_attrib_value = -1;
static gint hf_sstp_cert_hash = -1;
static gint hf_sstp_compound_mac = -1;
static gint hf_sstp_control_flag = -1;
static gint hf_sstp_data_unknown = -1;
static gint hf_sstp_ecapsulated_protocol = -1;
static gint hf_sstp_hash_protocol = -1;
static gint hf_sstp_length = -1;
static gint hf_sstp_major = -1;
static gint hf_sstp_messagetype = -1;
static gint hf_sstp_minor = -1;
static gint hf_sstp_nonce = -1;
static gint hf_sstp_numattrib = -1;
static gint hf_sstp_padding = -1;
static gint hf_sstp_reserved = -1;
static gint hf_sstp_status = -1;
static gint proto_sstp = -1;
static const value_string sstp_messagetypes[] = {
{SSTP_MSG_CALL_CONNECT_REQUEST, "SSTP_MSG_CALL_CONNECT_REQUEST"},
{SSTP_MSG_CALL_CONNECT_ACK, "SSTP_MSG_CALL_CONNECT_ACK"},
{SSTP_MSG_CALL_CONNECT_NAK, "SSTP_MSG_CALL_CONNECT_NAK"},
{SSTP_MSG_CALL_CONNECTED, "SSTP_MSG_CALL_CONNECTED"},
{SSTP_MSG_CALL_ABORT, "SSTP_MSG_CALL_ABORT"},
{SSTP_MSG_CALL_DISCONNECT, "SSTP_MSG_CALL_DISCONNECT"},
{SSTP_MSG_CALL_DISCONNECT_ACK, "SSTP_MSG_CALL_DISCONNECT_ACK"},
{SSTP_MSG_ECHO_REQUEST, "SSTP_MSG_ECHO_REQUEST"},
{SSTP_MSG_ECHO_RESPONSE, "SSTP_MSG_ECHO_RESPONSE"},
{0, NULL}
};
static const value_string sstp_attributes[] = {
{SSTP_ATTRIB_NO_ERROR, "SSTP_ATTRIB_NO_ERROR"},
{SSTP_ATTRIB_ENCAPSULATED_PROTOCOL_ID, "SSTP_ATTRIB_ENCAPSULATED_PROTOCOL_ID"},
{SSTP_ATTRIB_STATUS_INFO, "SSTP_ATTRIB_STATUS_INFO"},
{SSTP_ATTRIB_CRYPTO_BINDING, "SSTP_ATTRIB_CRYPTO_BINDING"},
{SSTP_ATTRIB_CRYPTO_BINDING_REQ, "SSTP_ATTRIB_CRYPTO_BINDING_REQ"},
{0, NULL}
};
static const value_string encapsulated_protocols[] = {
{SSTP_ENCAPSULATED_PPP, "PPP"},
{0, NULL}
};
static const value_string hash_protocols[] = {
{SSTP_CERT_HASH_PROTOCOL_SHA1, "SHA1"},
{SSTP_CERT_HASH_PROTOCOL_SHA256, "SHA256"},
{0, NULL}
};
static const value_string attrib_status[] = {
{SSTP_ATTRIB_STATUS_NO_ERROR, "SSTP_ATTRIB_STATUS_NO_ERROR"},
{SSTP_ATTRIB_STATUS_DUPLICATE_ATTRIBUTE, "SSTP_ATTRIB_STATUS_DUPLICATE_ATTRIBUTE"},
{SSTP_ATTRIB_STATUS_UNRECOGNIZED_ATTRIBUTE, "SSTP_ATTRIB_STATUS_UNRECOGNIZED_ATTRIBUTE"},
{SSTP_ATTRIB_STATUS_INVALID_ATTRIB_VALUE_LENGTH , "SSTP_ATTRIB_STATUS_INVALID_ATTRIB_VALUE_LENGTH"},
{SSTP_ATTRIB_STATUS_VALUE_NOT_SUPPORTED, "SSTP_ATTRIB_STATUS_VALUE_NOT_SUPPORTED"},
{SSTP_ATTRIB_STATUS_UNACCEPTED_FRAME_RECEIVED, "SSTP_ATTRIB_STATUS_UNACCEPTED_FRAME_RECEIVED"},
{SSTP_ATTRIB_STATUS_RETRY_COUNT_EXCEEDED, "SSTP_ATTRIB_STATUS_RETRY_COUNT_EXCEEDED"},
{SSTP_ATTRIB_STATUS_INVALID_FRAME_RECEIVED, "SSTP_ATTRIB_STATUS_INVALID_FRAME_RECEIVED"},
{SSTP_ATTRIB_STATUS_NEGOTIATION_TIMEOUT, "SSTP_ATTRIB_STATUS_NEGOTIATION_TIMEOUT"},
{SSTP_ATTRIB_STATUS_ATTRIB_NOT_SUPPORTED_IN_MSG, "SSTP_ATTRIB_STATUS_ATTRIB_NOT_SUPPORTED_IN_MSG"},
{SSTP_ATTRIB_STATUS_REQUIRED_ATTRIBUTE_MISSING, "SSTP_ATTRIB_STATUS_REQUIRED_ATTRIBUTE_MISSING"},
{SSTP_ATTRIB_STATUS_STATUS_INFO_NOT_SUPPORTED_IN_MSG, "SSTP_ATTRIB_STATUS_STATUS_INFO_NOT_SUPPORTED_IN_MSG"},
{0, NULL}
};
static int
dissect_sstp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
guint16 sstp_control_flag;
guint32 offset = 0;
guint8 sstp_major;
guint8 sstp_minor;
proto_item *ti;
proto_tree *sstp_tree;
proto_tree *sstp_tree_attribute;
proto_tree *sstp_tree_version;
guint16 sstp_numattrib;
tvbuff_t *tvb_next;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SSTP");
/* Clear out stuff in the info column */
col_clear(pinfo->cinfo, COL_INFO);
ti = proto_tree_add_item(tree, proto_sstp, tvb, 0, -1, ENC_NA);
sstp_tree = proto_item_add_subtree(ti, ett_sstp);
sstp_control_flag = tvb_get_guint8(tvb, SSTP_OFFSET_ISCONTROL) & SSTP_BITMASK_CONTROLFLAG;
sstp_minor = (tvb_get_guint8(tvb, SSTP_OFFSET_MINORVERSION) & SSTP_BITMASK_MINORVERSION); /* leftmost 4 bit */
sstp_major = (tvb_get_guint8(tvb, SSTP_OFFSET_MAJORVERSION) >> 4); /* rightmost 4 bit */
col_append_fstr(pinfo->cinfo, COL_INFO, "SSTP-%u.%u ", sstp_major, sstp_minor);
sstp_tree_version = proto_tree_add_subtree_format(sstp_tree, tvb, offset, SSTP_FSIZE_MAJORVERSION, ett_sstp_version,
NULL, "Version %d.%d", sstp_major, sstp_minor);
proto_tree_add_item(sstp_tree_version, hf_sstp_major, tvb, SSTP_OFFSET_MAJORVERSION, SSTP_FSIZE_MAJORVERSION, ENC_BIG_ENDIAN);
proto_tree_add_item(sstp_tree_version, hf_sstp_minor, tvb, SSTP_OFFSET_MINORVERSION, SSTP_FSIZE_MINORVERSION, ENC_BIG_ENDIAN);
proto_tree_add_item(sstp_tree, hf_sstp_reserved, tvb, SSTP_OFFSET_RESERVED, SSTP_FSIZE_RESERVED, ENC_NA);
proto_tree_add_item(sstp_tree, hf_sstp_control_flag, tvb, SSTP_OFFSET_ISCONTROL, SSTP_FSIZE_ISCONTROL, ENC_BIG_ENDIAN);
proto_tree_add_item(sstp_tree, hf_sstp_length, tvb, SSTP_OFFSET_LENGTH, SSTP_FSIZE_LENGTH, ENC_BIG_ENDIAN);
/* check wether we got a control or data packet */
if (sstp_control_flag) {
guint16 sstp_messagetype = tvb_get_guint16(tvb, SSTP_OFFSET_MSGTYPE, ENC_BIG_ENDIAN);
col_append_fstr(pinfo->cinfo, COL_INFO, "Type: CONTROL, %s; ", val_to_str_const(sstp_messagetype, sstp_messagetypes, "Unknown Messagetype"));
proto_tree_add_item(sstp_tree, hf_sstp_messagetype, tvb, SSTP_OFFSET_MSGTYPE, SSTP_FSIZE_MSGTYPE, ENC_BIG_ENDIAN);
proto_tree_add_item(sstp_tree, hf_sstp_numattrib, tvb, SSTP_OFFSET_NUMATTRIB, SSTP_FSIZE_NUMATTRIB, ENC_BIG_ENDIAN);
sstp_numattrib = tvb_get_ntohs(tvb, SSTP_OFFSET_NUMATTRIB);
/* display attributes */
if (sstp_numattrib > 0) {
guint16 attrib_length = 0;
guint8 attrib_id = 0;
guint8 hashproto = 0;
offset = SSTP_OFFSET_ATTRIBUTES;
for(;sstp_numattrib > 0; sstp_numattrib--) {
/* read attribute id and create subtree for attribute */
attrib_id = tvb_get_guint8(tvb, offset+1);
sstp_tree_attribute = proto_tree_add_subtree_format(sstp_tree, tvb, offset, SSTP_FSIZE_ATTRIB_RESERVED, ett_sstp_attribute,
NULL, "Attribute %s", val_to_str_const(attrib_id, sstp_attributes, "Unknown Attribute"));
proto_tree_add_item(sstp_tree_attribute, hf_sstp_attrib_reserved, tvb, offset, SSTP_FSIZE_ATTRIB_RESERVED, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sstp_tree_attribute, hf_sstp_attrib_id, tvb, offset, SSTP_FSIZE_ATTRIB_ID, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(sstp_tree_attribute, hf_sstp_attrib_length_reserved, tvb, offset, SSTP_FSIZE_ATTRIB_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(sstp_tree_attribute, hf_sstp_attrib_length, tvb, offset, SSTP_FSIZE_ATTRIB_LENGTH, ENC_BIG_ENDIAN);
/* get length of attribute value */
attrib_length = (tvb_get_ntohs(tvb, offset) & SSTP_BITMASK_LENGTH_LENGTH);
/* if this attribute follows the specification, length should at least be 4 */
if (attrib_length >= 4) {
/* length field also contains the previously processed 4 bytes */
attrib_length -= 4;
}
offset += 2;
/* attributes that need special treatment... */
switch(attrib_id) {
case SSTP_ATTRIB_ENCAPSULATED_PROTOCOL_ID:
proto_tree_add_item(sstp_tree_attribute, hf_sstp_ecapsulated_protocol, tvb, offset, SSTP_FSIZE_ENCAPSULATED_PROTOCOL, ENC_BIG_ENDIAN);
offset += SSTP_FSIZE_ENCAPSULATED_PROTOCOL;
break;
case SSTP_ATTRIB_STATUS_INFO:
proto_tree_add_item(sstp_tree_attribute, hf_sstp_reserved, tvb, offset, SSTP_FSIZE_RESERVED2, ENC_NA);
offset += SSTP_FSIZE_RESERVED2;
attrib_length -= SSTP_FSIZE_RESERVED2;
proto_tree_add_item(sstp_tree_attribute, hf_sstp_attrib_id, tvb, offset, SSTP_FSIZE_ATTRIB_ID, ENC_BIG_ENDIAN);
offset += SSTP_FSIZE_ATTRIB_ID;
attrib_length -= SSTP_FSIZE_ATTRIB_ID;
proto_tree_add_item(sstp_tree_attribute, hf_sstp_status, tvb, offset, SSTP_FSIZE_STATUS, ENC_BIG_ENDIAN);
offset += SSTP_FSIZE_STATUS;
attrib_length -= SSTP_FSIZE_STATUS;
proto_tree_add_item(sstp_tree_attribute, hf_sstp_attrib_value, tvb, offset, attrib_length, ENC_NA);
offset += attrib_length;
break;
case SSTP_ATTRIB_CRYPTO_BINDING:
proto_tree_add_item(sstp_tree_attribute, hf_sstp_reserved, tvb, offset, SSTP_FSIZE_RESERVED2, ENC_NA);
offset += SSTP_FSIZE_RESERVED2;
proto_tree_add_item(sstp_tree_attribute, hf_sstp_hash_protocol, tvb, offset, SSTP_FSIZE_HASH_PROTOCOL, ENC_BIG_ENDIAN);
hashproto = tvb_get_guint8(tvb, offset);
offset += SSTP_FSIZE_HASH_PROTOCOL;
proto_tree_add_item(sstp_tree_attribute, hf_sstp_nonce, tvb, offset, SSTP_FSIZE_NONCE, ENC_NA);
offset += SSTP_FSIZE_NONCE;
if (hashproto == SSTP_CERT_HASH_PROTOCOL_SHA1) {
proto_tree_add_item(sstp_tree_attribute, hf_sstp_cert_hash, tvb, offset, SSTP_FSIZE_CERT_HASH_SHA1, ENC_NA);
offset += SSTP_FSIZE_CERT_HASH_SHA1;
proto_tree_add_item(sstp_tree_attribute, hf_sstp_padding, tvb, offset, SSTP_FSIZE_PADDING_SHA1, ENC_NA);
offset += SSTP_FSIZE_PADDING_SHA1;
proto_tree_add_item(sstp_tree_attribute, hf_sstp_compound_mac, tvb, offset, SSTP_FSIZE_COMPOUND_MAC_SHA1, ENC_NA);
offset += SSTP_FSIZE_COMPOUND_MAC_SHA1;
proto_tree_add_item(sstp_tree_attribute, hf_sstp_padding, tvb, offset, SSTP_FSIZE_PADDING_SHA1, ENC_NA);
offset += SSTP_FSIZE_PADDING_SHA1;
}
if (hashproto == SSTP_CERT_HASH_PROTOCOL_SHA256) {
proto_tree_add_item(sstp_tree_attribute, hf_sstp_cert_hash, tvb, offset, SSTP_FSIZE_CERT_HASH_SHA256, ENC_NA);
offset += SSTP_FSIZE_CERT_HASH_SHA256;
}
break;
case SSTP_ATTRIB_CRYPTO_BINDING_REQ:
proto_tree_add_item(sstp_tree_attribute, hf_sstp_reserved, tvb, offset, SSTP_FSIZE_RESERVED2, ENC_NA);
offset += SSTP_FSIZE_RESERVED2;
proto_tree_add_item(sstp_tree_attribute, hf_sstp_hash_protocol, tvb, offset, SSTP_FSIZE_HASH_PROTOCOL, ENC_BIG_ENDIAN);
offset += SSTP_FSIZE_HASH_PROTOCOL;
proto_tree_add_item(sstp_tree_attribute, hf_sstp_nonce, tvb, offset, SSTP_FSIZE_NONCE, ENC_NA);
offset += SSTP_FSIZE_NONCE;
break;
}
}
}
/* While testing with different dumps, i noticed data in the buffer i couldnt find any documentation about */
if (tvb_reported_length_remaining(tvb, offset) > 0) {
proto_tree_add_item(sstp_tree, hf_sstp_data_unknown, tvb, offset, -1, ENC_NA);
}
} else {
col_append_fstr(pinfo->cinfo, COL_INFO, "Type: DATA; ");
/* our work here is done, since sstp encapsulates ppp, we hand the remaining buffer
over to the ppp dissector for further analysis */
tvb_next = tvb_new_subset_remaining(tvb, SSTP_OFFSET_DATA);
call_dissector(ppp_hdlc_handle, tvb_next, pinfo, tree);
}
return tvb_captured_length(tvb);
}
static guint
get_sstp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
{
return tvb_get_ntohs(tvb, offset+SSTP_OFFSET_LENGTH);
}
static int
dissect_sstp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, SSTP_OFFSET_LENGTH+SSTP_FSIZE_LENGTH, get_sstp_pdu_len, dissect_sstp_pdu, data);
return tvb_captured_length(tvb);
}
void
proto_register_sstp(void)
{
/* Setting up header data structure */
static hf_register_info hf[] = {
/* sstp minor version (4 Bit) */
{ &hf_sstp_major,
{ "Major Version", "sstp.majorversion",
FT_UINT8, BASE_DEC,
NULL, SSTP_BITMASK_MAJORVERSION,
NULL, HFILL }
},
/* sstp major version (4 Bit) */
{ &hf_sstp_minor,
{ "Minor Version", "sstp.minorversion",
FT_UINT8, BASE_DEC,
NULL, SSTP_BITMASK_MINORVERSION,
NULL, HFILL }
},
/* Several Reserved Fields with different size */
{ &hf_sstp_reserved,
{ "Reserved", "sstp.reserved",
FT_BYTES, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
/* C (1 Bit, set to 1 if control packet, 0 means data packet) */
{ &hf_sstp_control_flag,
{ "Control Packet", "sstp.iscontrol",
FT_BOOLEAN, 8,
NULL, SSTP_BITMASK_CONTROLFLAG,
NULL, HFILL }
},
/* Length Packet (16 Bit) */
{ &hf_sstp_length,
{ "Length-Packet", "sstp.length",
FT_UINT16, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
/* Message Type (16 Bit) */
{ &hf_sstp_messagetype,
{ "Message Type", "sstp.messagetype",
FT_UINT16, BASE_HEX,
VALS(sstp_messagetypes), 0x0,
NULL, HFILL }
},
/* Number of Attributes (16 Bit) */
{ &hf_sstp_numattrib,
{ "Number of Attributes", "sstp.numattrib",
FT_UINT16, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
/* Fields for Attributes */
/* Attribute Reserved Field (8 Bit) */
{ &hf_sstp_attrib_reserved,
{ "Reserved", "sstp.attribreserved",
FT_UINT8, BASE_HEX,
NULL, 0x0,
NULL, HFILL }
},
/* Attribute ID (8 Bit) */
{ &hf_sstp_attrib_id,
{ "ID", "sstp.attribid",
FT_UINT8, BASE_DEC,
VALS(sstp_attributes), 0x0,
NULL, HFILL }
},
/* Attribute Length Reserved (4 Bit reserved for future use inside the 16 bit length field) */
{ &hf_sstp_attrib_length_reserved,
{ "Reserved", "sstp.attriblengthreserved",
FT_UINT16, BASE_HEX,
NULL, SSTP_BITMASK_LENGTH_RESERVED,
NULL, HFILL }
},
/* Attribute Length Actual Length (12 Bit) */
{ &hf_sstp_attrib_length,
{ "Length", "sstp.attriblength",
FT_UINT16, BASE_DEC,
NULL, SSTP_BITMASK_LENGTH_LENGTH,
NULL, HFILL }
},
/* Undocumented Data in SSTP_MSG_CALL_CONNECT_REQUEST
see also MS-SSTP section 2.2.9 "Call Connect Request Message
(SSTP_MSG_CALL_CONNECT_REQUEST)":
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-sstp/e73ced14-7bef-407b-a85b-a6f624324dd1
*/
{ &hf_sstp_data_unknown,
{ "Unknown Data", "sstp.dataunknown",
FT_BYTES, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
/* Hash Protocol (8 Bit) */
{ &hf_sstp_hash_protocol,
{ "Hash Protocol", "sstp.hash",
FT_UINT8, BASE_HEX,
VALS(hash_protocols), 0x0,
NULL, HFILL }
},
/* Nonce (256 Bit) */
{ &hf_sstp_nonce,
{ "Nonce", "sstp.nonce",
FT_BYTES, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
/* Cert Hash (20 Bytes if SHA1 is used, 32 Bytes with SHA256) */
{ &hf_sstp_cert_hash,
{ "Cert Hash", "sstp.cert_hash",
FT_BYTES, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
/* Cert Padding (0 Bytes if SHA256 is used, 12 Bytes with SHA1) */
{ &hf_sstp_padding,
{ "Padding", "sstp.padding",
FT_BYTES, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
/* Compound MAC (20 Bytes if SHA1 is used, 32 Bytes with SHA1) */
{ &hf_sstp_compound_mac,
{ "Compound Mac", "sstp.compoundmac",
FT_BYTES, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
/* Encapsulated Protocol (2 Bytes) */
{ &hf_sstp_ecapsulated_protocol,
{ "Encapsulated Protocol", "sstp.encapsulatedprotocol",
FT_UINT16, BASE_HEX,
VALS(encapsulated_protocols), 0x0,
NULL, HFILL }
},
/* Attribute Status (4 Bytes) */
{ &hf_sstp_status,
{ "Status", "sstp.status",
FT_UINT32, BASE_HEX,
VALS(attrib_status), 0x0,
NULL, HFILL }
},
/* Attribute Value (Variable Length) */
{ &hf_sstp_attrib_value,
{ "Attribute Value", "sstp.attribvalue",
FT_BYTES, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
}
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_sstp,
&ett_sstp_attribute,
&ett_sstp_version
};
proto_sstp = proto_register_protocol("Secure Socket Tunneling Protocol", "SSTP", "sstp");
register_dissector("sstp", dissect_sstp, proto_sstp);
proto_register_field_array(proto_sstp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_sstp(void)
{
ppp_hdlc_handle = find_dissector_add_dependency("ppp_hdlc", proto_sstp);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|
C
|
wireshark/epan/dissectors/packet-ssyncp.c
|
/* packet-ssyncp.c
* Routines for dissecting mosh's State Synchronization Protocol
* Copyright 2020 Google LLC
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
* State Synchronization Protocol is the protocol used by mosh:
* <https://mosh.org/mosh-paper-draft.pdf>
*
* The protocol name is abbreviated as SSyncP to avoid conflict with the
* "Scripting Service Protocol".
*
* The protocol is based on UDP, with a plaintext header followed by an
* encrypted payload. For now we just support decrypting a single connection at
* a time, using the MOSH_KEY dumped from the environment variables
* (`cat /proc/$pid/environ | tr '\0' '\n' | grep MOSH_KEY` on Linux).
* Note that to display the embedded protobuf properly, you'll have to add
* src/protobufs/ from mosh's source code to the ProtoBuf search path.
* For now we stop decoding after reaching the first level of protobufs; in
* them, a second layer of protobufs is sometimes embedded (e.g. for
* transmitting screen contents and such). Implementing that is left as an
* exercise for the reader.
*/
#include <config.h>
#include <epan/packet.h> /* Should be first Wireshark include (other than config.h) */
#include <epan/conversation.h>
#include <epan/wmem_scopes.h>
#include <epan/proto_data.h>
#include <epan/prefs.h>
#include <epan/expert.h>
#include <wsutil/report_message.h>
#include <wsutil/wsgcrypt.h>
void proto_reg_handoff_ssyncp(void);
void proto_register_ssyncp(void);
static int proto_ssyncp = -1;
static int hf_ssyncp_direction = -1;
static int hf_ssyncp_seq = -1;
static int hf_ssyncp_encrypted = -1;
static int hf_ssyncp_seq_delta = -1;
static int hf_ssyncp_timestamp = -1;
static int hf_ssyncp_timestamp_reply = -1;
static int hf_ssyncp_frag_seq = -1;
static int hf_ssyncp_frag_final = -1;
static int hf_ssyncp_frag_idx = -1;
static int hf_ssyncp_rtt_to_server = -1;
static int hf_ssyncp_rtt_to_client = -1;
/* Initialize the subtree pointers */
static gint ett_ssyncp = -1;
static gint ett_ssyncp_decrypted = -1;
static expert_field ei_ssyncp_fragmented = EI_INIT;
static expert_field ei_ssyncp_bad_key = EI_INIT;
static const char *pref_ssyncp_key;
static char ssyncp_raw_aes_key[16];
static gboolean have_ssyncp_key;
static dissector_handle_t dissector_protobuf;
typedef struct _ssyncp_conv_info_t {
/* last sequence numbers per direction */
guint64 last_seq[2];
/* for each direction, have we seen any traffic yet? */
gboolean seen_packet[2];
guint16 clock_offset[2];
gboolean clock_seen[2];
} ssyncp_conv_info_t;
typedef struct _ssyncp_packet_info_t {
gboolean first_packet;
gint64 seq_delta;
gboolean have_rtt_estimate;
gint16 rtt_estimate;
} ssyncp_packet_info_t;
#define SSYNCP_IV_PAD 4
#define SSYNCP_SEQ_LEN 8
#define SSYNCP_DATAGRAM_HEADER_LEN (SSYNCP_SEQ_LEN + 2 + 2) /* 64-bit IV and two 16-bit timestamps */
#define SSYNCP_TRANSPORT_HEADER_LEN (8 + 2)
#define SSYNCP_AUTHTAG_LEN 16 /* 128-bit auth tag */
/*
* We only match on 60001, which mosh uses for its first connection.
* If there are more connections in the range 60002-61000, the user will have to
* mark those as ssyncp traffic manually - we'd have too many false positives
* otherwise.
*/
#define SSYNCP_UDP_PORT 60001
static int
dissect_ssyncp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data _U_)
{
/* Check that we have at least a datagram plus an OCB auth tag. */
if (tvb_reported_length(tvb) < SSYNCP_DATAGRAM_HEADER_LEN + SSYNCP_TRANSPORT_HEADER_LEN + SSYNCP_AUTHTAG_LEN)
return 0;
guint64 direction_and_seq = tvb_get_guint64(tvb, 0, ENC_BIG_ENDIAN);
guint direction = direction_and_seq >> 63;
guint64 seq = direction_and_seq & ~(1ULL << 63);
/* Heuristic: The 63-bit sequence number starts from zero and increments
* from there. Even if you send 1000 packets per second over 10 years, you
* won't reach 2^35. So check that the sequence number is not outrageously
* high.
*/
if (seq > (1ULL << 35))
return 0;
/* On the first pass, track the previous sequence numbers per direction,
* compute deltas between sequence numbers, and save those deltas.
* On subsequent passes, use the computed deltas.
*/
ssyncp_packet_info_t *ssyncp_pinfo;
ssyncp_conv_info_t *ssyncp_info = NULL;
if (pinfo->fd->visited) {
ssyncp_pinfo = (ssyncp_packet_info_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_ssyncp, 0);
} else {
conversation_t *conversation = find_or_create_conversation(pinfo);
ssyncp_info = (ssyncp_conv_info_t *)conversation_get_proto_data(conversation, proto_ssyncp);
if (!ssyncp_info) {
ssyncp_info = wmem_new(wmem_file_scope(), ssyncp_conv_info_t);
conversation_add_proto_data(conversation, proto_ssyncp, ssyncp_info);
ssyncp_info->seen_packet[0] = FALSE;
ssyncp_info->seen_packet[1] = FALSE;
ssyncp_info->clock_seen[0] = FALSE;
ssyncp_info->clock_seen[1] = FALSE;
}
ssyncp_pinfo = wmem_new(wmem_file_scope(), ssyncp_packet_info_t);
ssyncp_pinfo->first_packet = !ssyncp_info->seen_packet[direction];
if (ssyncp_pinfo->first_packet) {
ssyncp_info->seen_packet[direction] = TRUE;
} else {
ssyncp_pinfo->seq_delta = seq - ssyncp_info->last_seq[direction];
}
ssyncp_pinfo->have_rtt_estimate = FALSE;
p_add_proto_data(wmem_file_scope(), pinfo, proto_ssyncp, 0, ssyncp_pinfo);
ssyncp_info->last_seq[direction] = seq;
}
/*** COLUMN DATA ***/
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ssyncp");
col_clear(pinfo->cinfo, COL_INFO);
char *direction_str = direction ? "Server->Client" : "Client->Server";
col_set_str(pinfo->cinfo, COL_INFO, direction_str);
/*** PROTOCOL TREE ***/
/* create display subtree for the protocol */
proto_item *ti = proto_tree_add_item(tree, proto_ssyncp, tvb, 0, -1, ENC_NA);
proto_tree *ssyncp_tree = proto_item_add_subtree(ti, ett_ssyncp);
/* Add an item to the subtree, see section 1.5 of README.dissector for more
* information. */
proto_tree_add_item(ssyncp_tree, hf_ssyncp_direction, tvb,
0, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ssyncp_tree, hf_ssyncp_seq, tvb,
0, 8, ENC_BIG_ENDIAN);
#ifdef GCRY_OCB_BLOCK_LEN
proto_item *encrypted_item =
#endif
proto_tree_add_item(ssyncp_tree, hf_ssyncp_encrypted,
tvb, 8, -1, ENC_NA);
if (!ssyncp_pinfo->first_packet) {
proto_item *delta_item =
proto_tree_add_int64(ssyncp_tree, hf_ssyncp_seq_delta, tvb, 0, 0,
ssyncp_pinfo->seq_delta);
proto_item_set_generated(delta_item);
}
unsigned char *decrypted = NULL;
guint decrypted_len = 0;
/* avoid build failure on ancient libgcrypt without OCB support */
#ifdef GCRY_OCB_BLOCK_LEN
if (have_ssyncp_key) {
gcry_error_t gcry_err;
/* try to decrypt the rest of the packet */
gcry_cipher_hd_t gcry_hd;
gcry_err = gcry_cipher_open(&gcry_hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_OCB, 0);
if (gcry_err_code(gcry_err)) {
/* this shouldn't happen (even if the packet is garbage) */
report_failure("ssyncp: unable to initialize cipher???");
return tvb_captured_length(tvb);
}
gcry_err = gcry_cipher_setkey(gcry_hd, ssyncp_raw_aes_key, sizeof(ssyncp_raw_aes_key));
if (gcry_err_code(gcry_err)) {
/* this shouldn't happen (even if the packet is garbage) */
report_failure("ssyncp: unable to set key???");
gcry_cipher_close(gcry_hd);
return tvb_captured_length(tvb);
}
char nonce[SSYNCP_IV_PAD + SSYNCP_SEQ_LEN];
memset(nonce, 0, SSYNCP_IV_PAD);
tvb_memcpy(tvb, nonce + SSYNCP_IV_PAD, 0, SSYNCP_SEQ_LEN);
gcry_err = gcry_cipher_setiv(gcry_hd, nonce, sizeof(nonce));
if (gcry_err_code(gcry_err)) {
/* this shouldn't happen (even if the packet is garbage) */
report_failure("ssyncp: unable to set iv???");
gcry_cipher_close(gcry_hd);
return tvb_captured_length(tvb);
}
decrypted_len = tvb_captured_length(tvb) - SSYNCP_SEQ_LEN - SSYNCP_AUTHTAG_LEN;
decrypted = (unsigned char *)tvb_memdup(pinfo->pool, tvb,
SSYNCP_SEQ_LEN, decrypted_len);
gcry_cipher_final(gcry_hd);
gcry_err = gcry_cipher_decrypt(gcry_hd, decrypted, decrypted_len, NULL, 0);
if (gcry_err_code(gcry_err)) {
/* this shouldn't happen (even if the packet is garbage) */
report_failure("ssyncp: unable to decrypt???");
gcry_cipher_close(gcry_hd);
return tvb_captured_length(tvb);
}
gcry_err = gcry_cipher_checktag(gcry_hd,
tvb_get_ptr(tvb, SSYNCP_SEQ_LEN+decrypted_len, SSYNCP_AUTHTAG_LEN),
SSYNCP_AUTHTAG_LEN);
if (gcry_err_code(gcry_err) && gcry_err_code(gcry_err) != GPG_ERR_CHECKSUM) {
/* this shouldn't happen (even if the packet is garbage) */
report_failure("ssyncp: unable to check auth tag???");
gcry_cipher_close(gcry_hd);
return tvb_captured_length(tvb);
}
if (gcry_err_code(gcry_err)) {
/* if the tag is wrong, the key was wrong and the decrypted data is useless */
decrypted = NULL;
expert_add_info(pinfo, encrypted_item, &ei_ssyncp_bad_key);
}
gcry_cipher_close(gcry_hd);
}
#endif
if (decrypted) {
tvbuff_t *decrypted_tvb = tvb_new_child_real_data(tvb, decrypted, decrypted_len, decrypted_len);
add_new_data_source(pinfo, decrypted_tvb, "Decrypted data");
if (!pinfo->fd->visited) {
guint16 our_clock16 = ((guint64)pinfo->abs_ts.secs * 1000 + pinfo->abs_ts.nsecs / 1000000) & 0xffff;
guint16 sender_ts = tvb_get_guint16(decrypted_tvb, 0, ENC_BIG_ENDIAN);
guint16 reply_ts = tvb_get_guint16(decrypted_tvb, 2, ENC_BIG_ENDIAN);
ssyncp_info->clock_offset[direction] = sender_ts - our_clock16;
ssyncp_info->clock_seen[direction] = TRUE;
if (reply_ts != 0xffff && ssyncp_info->clock_seen[1-direction]) {
guint16 projected_send_time_our_clock = reply_ts - ssyncp_info->clock_offset[1-direction];
ssyncp_pinfo->rtt_estimate = our_clock16 - projected_send_time_our_clock;
ssyncp_pinfo->have_rtt_estimate = TRUE;
}
}
proto_tree *dec_tree = proto_tree_add_subtree(ssyncp_tree, decrypted_tvb,
0, -1, ett_ssyncp_decrypted, NULL, "Decrypted data");
proto_tree_add_item(dec_tree, hf_ssyncp_timestamp, decrypted_tvb,
0, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(dec_tree, hf_ssyncp_timestamp_reply, decrypted_tvb,
2, 2, ENC_BIG_ENDIAN);
if (ssyncp_pinfo->have_rtt_estimate) {
int rtt_id = direction ? hf_ssyncp_rtt_to_server : hf_ssyncp_rtt_to_client;
proto_item *rtt_item = proto_tree_add_int(dec_tree, rtt_id, decrypted_tvb, 2, 2, ssyncp_pinfo->rtt_estimate);
proto_item_set_generated(rtt_item);
}
proto_tree_add_item(dec_tree, hf_ssyncp_frag_seq, decrypted_tvb,
4, 8, ENC_BIG_ENDIAN);
proto_tree_add_item(dec_tree, hf_ssyncp_frag_final, decrypted_tvb,
12, 2, ENC_BIG_ENDIAN);
proto_item *frag_idx_item = proto_tree_add_item(dec_tree,
hf_ssyncp_frag_idx, decrypted_tvb, 12, 2, ENC_BIG_ENDIAN);
/* TODO actually handle fragmentation; for now just bail out on fragmentation */
if (tvb_get_guint16(decrypted_tvb, 12, ENC_BIG_ENDIAN) != 0x8000) {
expert_add_info(pinfo, frag_idx_item, &ei_ssyncp_fragmented);
return tvb_captured_length(tvb);
}
tvbuff_t *inflated_tvb = tvb_child_uncompress(decrypted_tvb, decrypted_tvb, 14, decrypted_len - 14);
if (inflated_tvb == NULL)
return tvb_captured_length(tvb);
add_new_data_source(pinfo, inflated_tvb, "Inflated data");
if (dissector_protobuf) {
call_dissector_with_data(dissector_protobuf, inflated_tvb, pinfo,
dec_tree, "message,TransportBuffers.Instruction");
}
}
return tvb_captured_length(tvb);
}
/* Register the protocol with Wireshark.
*
* This format is required because a script is used to build the C function that
* calls all the protocol registration.
*/
void
proto_register_ssyncp(void)
{
static const true_false_string direction_name = {
"Server->Client",
"Client->Server"
};
/* Setup list of header fields See Section 1.5 of README.dissector for
* details. */
static hf_register_info hf[] = {
{ &hf_ssyncp_direction,
{ "Direction", "ssyncp.direction",
FT_BOOLEAN, 8, TFS(&direction_name), 0x80,
"Direction of packet", HFILL }
},
{ &hf_ssyncp_seq,
{ "Sequence number", "ssyncp.seq",
FT_UINT64, BASE_HEX, NULL, 0x7fffffffffffffff,
"Monotonically incrementing packet sequence number", HFILL }
},
{ &hf_ssyncp_encrypted,
{ "Encrypted data", "ssyncp.enc_data",
FT_BYTES, BASE_NONE, NULL, 0,
"Encrypted RTT estimation fields and Transport Layer payload, encrypted with AES-128-OCB",
HFILL }
},
{ &hf_ssyncp_seq_delta,
{ "Sequence number delta", "ssyncp.seq_delta",
FT_INT64, BASE_DEC, NULL, 0,
"Delta from last sequence number; 1 is normal, 0 is duplicated packet, <0 is reordering, >1 is reordering or packet loss", HFILL }
},
{ &hf_ssyncp_timestamp,
{ "Truncated timestamp", "ssyncp.timestamp",
FT_UINT16, BASE_HEX, NULL, 0,
"Low 16 bits of sender's time in milliseconds", HFILL }
},
{ &hf_ssyncp_timestamp_reply,
{ "Last timestamp received", "ssyncp.timestamp_reply",
FT_UINT16, BASE_HEX, NULL, 0,
"Low 16 bits of timestamp of last received packet plus time since it was received (for RTT estimation)", HFILL }
},
{ &hf_ssyncp_frag_seq,
{ "Fragment ID", "ssyncp.frag_seq",
FT_UINT64, BASE_HEX, NULL, 0,
"Transport-level sequence number, used for fragment reassembly", HFILL }
},
{ &hf_ssyncp_frag_final,
{ "Final fragment", "ssyncp.frag_final",
FT_BOOLEAN, 16, NULL, 0x8000,
"Is this the last fragment?", HFILL }
},
{ &hf_ssyncp_frag_idx,
{ "Fragment Index", "ssyncp.frag_idx",
FT_UINT16, BASE_HEX, NULL, 0x7fff,
"Index of this fragment in the list of fragments of the transport-level message", HFILL }
},
{ &hf_ssyncp_rtt_to_server,
{ "RTT estimate to server (in ms)", "ssyncp.rtt_est_to_server",
FT_INT16, BASE_DEC, NULL, 0,
"Estimated round trip time from point of capture to server", HFILL }
},
{ &hf_ssyncp_rtt_to_client,
{ "RTT estimate to client (in ms)", "ssyncp.rtt_est_to_client",
FT_INT16, BASE_DEC, NULL, 0,
"Estimated round trip time from point of capture to client", HFILL }
}
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_ssyncp,
&ett_ssyncp_decrypted
};
/* Setup protocol expert items */
static ei_register_info ei[] = {
{ &ei_ssyncp_fragmented,
{ "ssyncp.fragmented", PI_REASSEMBLE, PI_WARN,
"SSYNCP-level fragmentation, dissector can't handle that", EXPFILL }
},
{ &ei_ssyncp_bad_key,
{ "ssyncp.badkey", PI_DECRYPTION, PI_WARN,
"Encrypted data could not be decrypted with the provided key", EXPFILL }
}
};
/* Register the protocol name and description */
proto_ssyncp = proto_register_protocol("State Synchronization Protocol", "SSyncP", "ssyncp");
/* Required function calls to register the header fields and subtrees */
proto_register_field_array(proto_ssyncp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_module_t *expert_ssyncp = expert_register_protocol(proto_ssyncp);
expert_register_field_array(expert_ssyncp, ei, array_length(ei));
module_t *ssyncp_module = prefs_register_protocol(proto_ssyncp, proto_reg_handoff_ssyncp);
prefs_register_string_preference(ssyncp_module, "key",
"ssyncp MOSH_KEY",
"MOSH_KEY AES key (from mosh-{client,server} environment variable)",
&pref_ssyncp_key);
}
void
proto_reg_handoff_ssyncp(void)
{
static dissector_handle_t ssyncp_handle;
static gboolean initialized = FALSE;
if (!initialized) {
ssyncp_handle = create_dissector_handle(dissect_ssyncp, proto_ssyncp);
dissector_add_uint("udp.port", SSYNCP_UDP_PORT, ssyncp_handle);
dissector_protobuf = find_dissector("protobuf");
if (dissector_protobuf == NULL) {
report_failure("unable to find protobuf dissector");
}
initialized = TRUE;
}
have_ssyncp_key = FALSE;
if (strlen(pref_ssyncp_key) != 0) {
if (strlen(pref_ssyncp_key) != 22) {
report_failure("ssyncp: invalid key, must be 22 characters long");
return;
}
char base64_key[25];
memcpy(base64_key, pref_ssyncp_key, 22);
memcpy(base64_key+22, "==\0", 3);
gsize out_len;
if (g_base64_decode_inplace(base64_key, &out_len) == NULL || out_len != sizeof(ssyncp_raw_aes_key)) {
report_failure("ssyncp: invalid key, base64 decoding (with \"==\" appended) failed");
return;
}
memcpy(ssyncp_raw_aes_key, base64_key, sizeof(ssyncp_raw_aes_key));
have_ssyncp_key = TRUE;
}
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-stanag4607.c
|
/* packet-stanag4607.c
* Routines for STANAG 4607 dissection
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <math.h>
#include <epan/packet.h>
#include <epan/expert.h>
#include <wiretap/stanag4607.h>
void proto_register_stanag4607(void);
void proto_reg_handoff_stanag4607(void);
static int proto_stanag4607 = -1;
static int hf_4607_version = -1;
static int hf_4607_packet_size = -1;
static int hf_4607_nationality = -1;
static int hf_4607_sec_class = -1;
static int hf_4607_sec_system = -1;
static int hf_4607_sec_code = -1;
static int hf_4607_exercise_indicator = -1;
static int hf_4607_platform_id = -1;
static int hf_4607_mission_id = -1;
static int hf_4607_job_id = -1;
static int hf_4607_segment_type = -1;
static int hf_4607_segment_size = -1;
/* Mission Segment */
static int hf_4607_mission_plan = -1;
static int hf_4607_mission_flight_plan = -1;
static int hf_4607_mission_platform = -1;
static int hf_4607_mission_platform_config = -1;
static int hf_4607_mission_time_year = -1;
static int hf_4607_mission_time_month = -1;
static int hf_4607_mission_time_day = -1;
/* Dwell Segment */
static int hf_4607_dwell_mask = -1;
static int hf_4607_dwell_revisit_index = -1;
static int hf_4607_dwell_dwell_index = -1;
static int hf_4607_dwell_last_dwell = -1;
static int hf_4607_dwell_count = -1;
static int hf_4607_dwell_time = -1;
static int hf_4607_dwell_sensor_lat = -1;
static int hf_4607_dwell_sensor_lon = -1;
static int hf_4607_dwell_sensor_alt = -1;
static int hf_4607_dwell_scale_lat = -1;
static int hf_4607_dwell_scale_lon = -1;
static int hf_4607_dwell_unc_along = -1;
static int hf_4607_dwell_unc_cross = -1;
static int hf_4607_dwell_unc_alt = -1;
static int hf_4607_dwell_track = -1;
static int hf_4607_dwell_speed = -1;
static int hf_4607_dwell_vert_velocity = -1;
static int hf_4607_dwell_track_unc = -1;
static int hf_4607_dwell_speed_unc = -1;
static int hf_4607_dwell_vv_unc = -1;
static int hf_4607_dwell_plat_heading = -1;
static int hf_4607_dwell_plat_pitch = -1;
static int hf_4607_dwell_plat_roll = -1;
static int hf_4607_dwell_da_lat = -1;
static int hf_4607_dwell_da_lon = -1;
static int hf_4607_dwell_da_range = -1;
static int hf_4607_dwell_da_angle = -1;
static int hf_4607_dwell_sensor_heading = -1;
static int hf_4607_dwell_sensor_pitch = -1;
static int hf_4607_dwell_sensor_roll = -1;
static int hf_4607_dwell_mdv = -1;
/* Target Report */
static int hf_4607_dwell_report_index = -1;
static int hf_4607_dwell_report_lat = -1;
static int hf_4607_dwell_report_lon = -1;
static int hf_4607_dwell_report_delta_lat = -1;
static int hf_4607_dwell_report_delta_lon = -1;
static int hf_4607_dwell_report_height = -1;
static int hf_4607_dwell_report_radial = -1;
static int hf_4607_dwell_report_wrap = -1;
static int hf_4607_dwell_report_snr = -1;
static int hf_4607_dwell_report_class = -1;
static int hf_4607_dwell_report_prob = -1;
static int hf_4607_dwell_report_unc_slant = -1;
static int hf_4607_dwell_report_unc_cross = -1;
static int hf_4607_dwell_report_unc_height = -1;
static int hf_4607_dwell_report_unc_radial = -1;
static int hf_4607_dwell_report_tag_app = -1;
static int hf_4607_dwell_report_tag_entity = -1;
static int hf_4607_dwell_report_section = -1;
/* Job Definition Segment */
static int hf_4607_jobdef_job_id = -1;
static int hf_4607_jobdef_sensor_type = -1;
static int hf_4607_jobdef_sensor_model = -1;
static int hf_4607_jobdef_filter = -1;
static int hf_4607_jobdef_priority = -1;
static int hf_4607_jobdef_ba_lat_a = -1;
static int hf_4607_jobdef_ba_lon_a = -1;
static int hf_4607_jobdef_ba_lat_b = -1;
static int hf_4607_jobdef_ba_lon_b = -1;
static int hf_4607_jobdef_ba_lat_c = -1;
static int hf_4607_jobdef_ba_lon_c = -1;
static int hf_4607_jobdef_ba_lat_d = -1;
static int hf_4607_jobdef_ba_lon_d = -1;
static int hf_4607_jobdef_radar_mode = -1;
static int hf_4607_jobdef_revisit_interval = -1;
static int hf_4607_jobdef_unc_along = -1;
static int hf_4607_jobdef_unc_cross = -1;
static int hf_4607_jobdef_unc_alt = -1;
static int hf_4607_jobdef_unc_heading = -1;
static int hf_4607_jobdef_unc_speed = -1;
static int hf_4607_jobdef_sense_slant = -1;
static int hf_4607_jobdef_sense_cross = -1;
static int hf_4607_jobdef_sense_vlos = -1;
static int hf_4607_jobdef_sense_mdv = -1;
static int hf_4607_jobdef_sense_prob = -1;
static int hf_4607_jobdef_sense_alarm = -1;
static int hf_4607_jobdef_terrain_model = -1;
static int hf_4607_jobdef_geoid_model = -1;
/* Platform Location Segment */
static int hf_4607_platloc_time = -1;
static int hf_4607_platloc_latitude = -1;
static int hf_4607_platloc_longitude = -1;
static int hf_4607_platloc_altitude = -1;
static int hf_4607_platloc_track = -1;
static int hf_4607_platloc_speed = -1;
static int hf_4607_platloc_vertical_velocity = -1;
/* Subtree pointers */
static gint ett_4607_hdr = -1;
static gint ett_4607_seg = -1;
static gint ett_4607_rpt = -1;
/* Error pointers */
static expert_field ei_bad_length = EI_INIT;
static expert_field ei_too_short = EI_INIT;
static expert_field ei_bad_packet_size = EI_INIT;
static dissector_handle_t stanag4607_handle;
static const value_string stanag4607_class_vals[] = {
{ 1, "TOP SECRET" },
{ 2, "SECRET" },
{ 3, "CONFIDENTIAL" },
{ 4, "RESTRICTED" },
{ 5, "UNCLASSIFIED" },
{ 0, NULL }
};
static const value_string stanag4607_exind_vals[] = {
{ 0, "Operation, Real Data" },
{ 1, "Operation, Simulated Data" },
{ 2, "Operation, Synthesized Data" },
{ 128, "Exercise, Real Data" },
{ 129, "Exercise, Simulated Data" },
{ 130, "Exercise, Synthesized Data" },
{ 0, NULL }
};
#define MISSION_SEGMENT 1
#define DWELL_SEGMENT 2
#define JOB_DEFINITION_SEGMENT 5
#define PLATFORM_LOCATION_SEGMENT 13
static const value_string stanag4607_segment_vals[] = {
{ 1, "Mission Segment" },
{ 2, "Dwell Segment" },
{ 3, "HRR Segment" },
{ 5, "Job Definition Segment" },
{ 6, "Free Text Segment" },
{ 7, "Low Reflectivity Index Segment" },
{ 8, "Group Segment" },
{ 9, "Attached Target Segment" },
{ 10, "Test and Status Segment" },
{ 11, "System-Specific Segment" },
{ 12, "Processing History Segment" },
{ 13, "Platform Location Segment" },
{ 101, "Job Request Segment" },
{ 102, "Job Acknowledgment Segment" },
{ 0, NULL }
};
static const value_string stanag4607_sensor_vals[] = {
{ 0, "Unidentified" },
{ 1, "Other" },
{ 2, "HiSAR" },
{ 3, "ASTOR" },
{ 4, "Rotary Wing Radar" },
{ 5, "Global Hawk Sensor" },
{ 6, "HORIZON" },
{ 7, "APY-3" },
{ 8, "APY-6" },
{ 9, "APY-8 (Lynx I)" },
{ 10, "RADARSAT2" },
{ 11, "ASARS-2A" },
{ 12, "TESAR" },
{ 13, "MP-RTIP" },
{ 14, "APG-77" },
{ 15, "APG-79" },
{ 16, "APG-81" },
{ 17, "APY-6v1" },
{ 18, "SPY-I (Lynx II)" },
{ 19, "SIDM" },
{ 20, "LIMIT" },
{ 21, "TCAR (AGS A321)" },
{ 22, "LSRS Sensor" },
{ 23, "UGS Single Sensor" },
{ 24, "UGS Cluster Sensor" },
{ 25, "IMASTER GMTI" },
{ 26, "AN/ZPY-1 (STARLite)" },
{ 27, "VADER" },
{ 255, "No Statement" },
{ 0, NULL }
};
static const value_string stanag4607_radar_mode_vals[] = {
{ 0, "Unspecified Mode" },
{ 1, "MTI (Moving Target Indicator)" },
{ 2, "HRR (High Range Resolution)" },
{ 3, "UHRR (Ultra High Range Resolution)" },
{ 4, "HUR (High Update Rate)" },
{ 5, "FTI" },
/* TODO: and many many more ... */
{ 0, NULL }
};
static const value_string stanag4607_terrain_vals[] = {
{ 0, "None Specified" },
{ 1, "DTED0 (Digital Terrain Elevation Data, Level 0)" },
{ 2, "DTED1 (Digital Terrain Elevation Data, Level 1)" },
{ 3, "DTED2 (Digital Terrain Elevation Data, Level 2)" },
{ 4, "DTED3 (Digital Terrain Elevation Data, Level 3)" },
{ 5, "DTED4 (Digital Terrain Elevation Data, Level 4)" },
{ 6, "DTED5 (Digital Terrain Elevation Data, Level 5)" },
{ 7, "SRTM1 (Shuttle Radar Topography Mission, Level 1)" },
{ 8, "SRTM2 (Shuttle Radar Topography Mission, Level 2)" },
{ 9, "DGM50 M745 (Digitales Gelandemodell 1:50 000)" },
{ 10, "DGM250 (Digitales Gelandemodell 1:250 000)" },
{ 11, "ITHD (Interferometric Terrain Data Height)" },
{ 12, "STHD (Stereometric Terrain Data Height)" },
{ 13, "SEDRIS (SEDRIS Reference Model ISO/IEC 18026)" },
{ 0, NULL }
};
static const value_string stanag4607_geoid_vals[] = {
{ 0, "None Specified" },
{ 1, "EGM96 (Earth Gravitional Model, Version 1996)" },
{ 2, "GEO96 (Geoid Gravitional Model, Version 1996)" },
{ 3, "Flat Earth" },
{ 0, NULL }
};
static const value_string stanag4607_target_vals[] = {
{ 0, "No Information, Live Target" },
{ 1, "Tracked Vehicle, Live Target" },
{ 2, "Wheeled Vehicle, Live Target" },
{ 3, "Rotary Wing Aircraft, Live Target" },
{ 4, "Fixed Wing Aircraft, Live Target" },
{ 5, "Stationary Rotator, Live Target" },
{ 6, "Maritime, Live Target" },
{ 7, "Beacon, Live Target" },
{ 8, "Amphibious, Live Target" },
{ 9, "Person, Live Target" },
{ 10, "Vehicle, Live Target" },
{ 11, "Animal, Live Target" },
{ 12, "Large Multiple-Return, Live Land Target" },
{ 13, "Large Multiple-Return, Live Maritime Target" },
{ 126, "Other, Live Target" },
{ 127, "Unknown, Live Target" },
{ 128, "No Information, Simulated Target" },
{ 129, "Tracked Vehicle, Simulated Target" },
{ 130, "Wheeled Vehicle, Simulated Target" },
{ 131, "Rotary Wing Aircraft, Simulated Target" },
{ 132, "Fixed Wing Aircraft, Simulated Target" },
{ 133, "Stationary Rotator, Simulated Target" },
{ 134, "Maritime, Simulated Target" },
{ 135, "Beacon, Simulated Target" },
{ 136, "Amphibious, Simulated Target" },
{ 137, "Person, Simulated Target" },
{ 138, "Vehicle, Simulated Target" },
{ 139, "Animal, Simulated Target" },
{ 140, "Large Multiple-Return, Simulated Land Target" },
{ 141, "Large Multiple-Return, Simulated Maritime Target" },
{ 143, "Tagging Device" },
{ 254, "Other, Simulated Target" },
{ 255, "Unknown, Simulated Target" },
{ 0, NULL }
};
static const value_string stanag4607_platform_vals[] = {
{ 0, "Unidentified" },
{ 1, "ACS" },
{ 2, "ARL-M" },
{ 3, "Sentinel" },
{ 4, "Rotary Wing Radar" },
{ 5, "Global Hawk-Navy" },
{ 6, "HORIZON" },
{ 7, "E-8 (Joint STARS)" },
{ 8, "P-3C" },
{ 9, "Predator" },
{ 10, "RADARSAT2" },
{ 11, "U-2" },
{ 12, "E-10" },
{ 13, "UGS - Single" },
{ 14, "UGS - Cluster" },
{ 15, "Ground Based" },
{ 16, "UAV-Army" },
{ 17, "UAV-Marines" },
{ 18, "UAV-Navy" },
{ 19, "UAV-Air Force" },
{ 20, "Global Hawk-Air Force" },
{ 21, "Global Hawk-Australia" },
{ 22, "Global Hawk-Germany" },
{ 23, "Paul Revere" },
{ 24, "Mariner UAV" },
{ 25, "BAC-111" },
{ 26, "Coyote" },
{ 27, "King Air" },
{ 28, "LIMIT" },
{ 29, "NRL NP-3B" },
{ 30, "SOSTAR-X" },
{ 31, "WatchKeeper" },
{ 32, "Alliance Ground Surveillance (AGS) (A321)" },
{ 33, "Stryker" },
{ 34, "AGS (HALE UAV)" },
{ 35, "SIDM" },
{ 36, "Reaper" },
{ 37, "Warrior A" },
{ 38, "Warrior" },
{ 39, "Twin Otter" },
{ 255, "Other" },
{ 0, NULL }
};
static void
prt_sa32(gchar *buff, guint32 val)
{
double deg, min, sec;
double x = (double) ((gint32) val);
x /= (double) (1UL<<30);
x *= 45.0;
deg = floor(x);
min = floor(60.0 * (x - deg));
sec = 60.0 * (60.0 * (x - deg) - min);
/* checkAPI.pl doesn't like the unicode degree symbol, I don't know what to do... */
snprintf(buff, ITEM_LABEL_LENGTH, "%.8f degrees (%.0f %.0f\' %.2f\")", x, deg, min, sec);
}
static void
prt_ba32(gchar *buff, guint32 val)
{
double deg, min, sec;
double x = (double) val;
x /= (double) (1UL<<30);
x *= 90.0;
deg = floor(x);
min = floor(60.0 * (x - deg));
sec = 60.0 * (60.0 * (x - deg) - min);
/* checkAPI.pl doesn't like the unicode degree symbol, I don't know what to do... */
snprintf(buff, ITEM_LABEL_LENGTH, "%.8f degrees (%.0f %.0f\' %.2f\")", x, deg, min, sec);
}
static void
prt_sa16(gchar *buff, guint32 val)
{
double x = (double) ((gint32) val);
x /= (double) (1<<14);
x *= 90.0;
snprintf(buff, ITEM_LABEL_LENGTH, "%.3f degrees", x);
}
static void
prt_ba16(gchar *buff, guint32 val)
{
double x = (double) val;
x /= (double) (1<<14);
x *= 90.0;
snprintf(buff, ITEM_LABEL_LENGTH, "%.3f degrees", x);
}
static void
prt_ba16_none(gchar *buff, guint32 val)
{
double x = (double) val;
x /= (double) (1<<14);
x *= 90.0;
if (val <= 65536)
snprintf(buff, ITEM_LABEL_LENGTH, "No Statement");
else
snprintf(buff, ITEM_LABEL_LENGTH, "%.3f degrees", x);
}
static void
prt_kilo(gchar *buff, guint32 val)
{
double x = (double) ((gint32) val);
x /= 128.0;
snprintf(buff, ITEM_LABEL_LENGTH, "%.2f kilometers", x);
}
static void
prt_meters(gchar *buff, guint32 val)
{
double x = (double) ((gint32) val);
snprintf(buff, ITEM_LABEL_LENGTH, "%.0f meters", x);
}
static void
prt_decimeters(gchar *buff, guint32 val)
{
double x = (double) ((gint32) val);
x /= 10.0;
snprintf(buff, ITEM_LABEL_LENGTH, "%.1f meters", x);
}
static void
prt_centimeters(gchar *buff, guint32 val)
{
double x = (double) ((gint32) val);
x /= 100.0;
snprintf(buff, ITEM_LABEL_LENGTH, "%.2f meters", x);
}
static void
prt_speed(gchar *buff, guint32 val)
{
double x = (double) val;
x /= 1000.0;
snprintf(buff, ITEM_LABEL_LENGTH, "%.3f meters/second", x);
}
static void
prt_speed_centi(gchar *buff, guint32 val)
{
double x = (double) ((gint32) val);
x /= 100.0;
snprintf(buff, ITEM_LABEL_LENGTH, "%.2f meters/second", x);
}
static void
prt_speed_deci(gchar *buff, guint32 val)
{
/* Usually 8-bit, signed */
double x = (double) ((gint32) val);
x /= 10.0;
snprintf(buff, ITEM_LABEL_LENGTH, "%.1f meters/second", x);
}
static void
prt_millisec(gchar *buff, guint32 val)
{
double x = (double) val;
x /= 1000.0;
snprintf(buff, ITEM_LABEL_LENGTH, "%.3f seconds", x);
}
static void
prt_none8(gchar *buff, guint32 val)
{
if (0xff == val)
snprintf(buff, ITEM_LABEL_LENGTH, "No Statement");
else
snprintf(buff, ITEM_LABEL_LENGTH, "%d", val);
}
static void
prt_none16(gchar *buff, guint32 val)
{
if (0xffff == val)
snprintf(buff, ITEM_LABEL_LENGTH, "No Statement");
else
snprintf(buff, ITEM_LABEL_LENGTH, "%d", val);
}
static gint
dissect_mission(tvbuff_t *tvb, proto_tree *seg_tree, gint offset)
{
proto_tree_add_item(seg_tree, hf_4607_mission_plan, tvb, offset, 12, ENC_ASCII);
offset += 12;
proto_tree_add_item(seg_tree, hf_4607_mission_flight_plan, tvb, offset, 12, ENC_ASCII);
offset += 12;
proto_tree_add_item(seg_tree, hf_4607_mission_platform, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(seg_tree, hf_4607_mission_platform_config, tvb, offset, 10, ENC_ASCII);
offset += 10;
proto_tree_add_item(seg_tree, hf_4607_mission_time_year, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_mission_time_month, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(seg_tree, hf_4607_mission_time_day, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
return offset;
}
/* Dwell Segment Existence Mask */
/* The Dxx fields are NOT bit locations! They are the field numbers
* as specified in Table 2-4 Dwell Segment. These field numbers DO NOT
* count bit locations in the existence mask (even though they come
* close to this). The m and n values of the m*8+n offset below are
* given in Figure 2-1 titled "Dwell Segment Existence Mask Mapping."
*/
#define SET(MASK,OFF) (((MASK)>>(OFF)) & G_GINT64_CONSTANT(1))
#define D10 6*8+7
#define D12 6*8+5
#define D15 6*8+2
#define D18 5*8+7
#define D21 5*8+4
#define D24 5*8+1
#define D28 4*8+5
#define D31 4*8+2
#define D32_1 4*8+1
#define D32_2 4*8+0
#define D32_6 3*8+4
#define D32_7 3*8+3
#define D32_9 3*8+1
#define D32_10 3*8+0
#define D32_11 2*8+7
#define D32_12 2*8+6
#define D32_16 2*8+2
#define D32_18 2*8+0
/* Target Report */
static gint
dissect_target(tvbuff_t *tvb, proto_tree *seg_tree, gint offset, guint64 mask)
{
proto_item *rpt_item = NULL;
proto_tree *rpt_tree = seg_tree;
if (SET(mask, D32_1)) {
rpt_item = proto_tree_add_item(rpt_tree, hf_4607_dwell_report_index, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
rpt_tree = proto_item_add_subtree(rpt_item, ett_4607_rpt);
}
if (SET(mask, D32_2)) {
rpt_item = proto_tree_add_item(rpt_tree, hf_4607_dwell_report_lat, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(rpt_tree, hf_4607_dwell_report_lon, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
} else {
rpt_item = proto_tree_add_item(rpt_tree, hf_4607_dwell_report_delta_lat, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(rpt_tree, hf_4607_dwell_report_delta_lon, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
}
/* If the report index wasn't set, then no subtree yet */
if (rpt_item && rpt_tree == seg_tree) {
rpt_tree = proto_item_add_subtree(rpt_item, ett_4607_rpt);
}
if (SET(mask, D32_6)) {
proto_tree_add_item(rpt_tree, hf_4607_dwell_report_height, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
}
if (SET(mask, D32_7)) {
proto_tree_add_item(rpt_tree, hf_4607_dwell_report_radial, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(rpt_tree, hf_4607_dwell_report_wrap, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
}
if (SET(mask, D32_9)) {
proto_tree_add_item(rpt_tree, hf_4607_dwell_report_snr, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
}
if (SET(mask, D32_10)) {
proto_tree_add_item(rpt_tree, hf_4607_dwell_report_class, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
}
if (SET(mask, D32_11)) {
proto_tree_add_item(rpt_tree, hf_4607_dwell_report_prob, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
}
if (SET(mask, D32_12)) {
proto_tree_add_item(rpt_tree, hf_4607_dwell_report_unc_slant, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(rpt_tree, hf_4607_dwell_report_unc_cross, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(rpt_tree, hf_4607_dwell_report_unc_height, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(rpt_tree, hf_4607_dwell_report_unc_radial, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
}
if (SET(mask, D32_16)) {
proto_tree_add_item(rpt_tree, hf_4607_dwell_report_tag_app, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(rpt_tree, hf_4607_dwell_report_tag_entity, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
if (SET(mask, D32_18)) {
proto_tree_add_item(rpt_tree, hf_4607_dwell_report_section, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
}
return offset;
}
/* Dwell Segment */
static gint
dissect_dwell(tvbuff_t *tvb, proto_tree *seg_tree, gint offset)
{
guint64 mask;
guint32 count;
mask = tvb_get_ntoh64(tvb, offset);
proto_tree_add_item(seg_tree, hf_4607_dwell_mask, tvb, offset, 8, ENC_BIG_ENDIAN);
offset += 8;
proto_tree_add_item(seg_tree, hf_4607_dwell_revisit_index, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_dwell_dwell_index, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_dwell_last_dwell, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
/* count of target reports */
count = tvb_get_ntohs(tvb, offset);
proto_tree_add_item(seg_tree, hf_4607_dwell_count, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_dwell_time, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_dwell_sensor_lat, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_dwell_sensor_lon, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_dwell_sensor_alt, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
if (SET(mask, D10)) {
proto_tree_add_item(seg_tree, hf_4607_dwell_scale_lat, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_dwell_scale_lon, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
if (SET(mask, D12)) {
proto_tree_add_item(seg_tree, hf_4607_dwell_unc_along, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_dwell_unc_cross, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_dwell_unc_alt, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
}
if (SET(mask, D15)) {
proto_tree_add_item(seg_tree, hf_4607_dwell_track, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_dwell_speed, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_dwell_vert_velocity, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
}
if (SET(mask, D18)) {
proto_tree_add_item(seg_tree, hf_4607_dwell_track_unc, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(seg_tree, hf_4607_dwell_speed_unc, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_dwell_vv_unc, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
}
if (SET(mask, D21)) {
proto_tree_add_item(seg_tree, hf_4607_dwell_plat_heading, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_dwell_plat_pitch, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_dwell_plat_roll, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
}
/* Mandatory Dwell Area */
proto_tree_add_item(seg_tree, hf_4607_dwell_da_lat, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_dwell_da_lon, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_dwell_da_range, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_dwell_da_angle, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
if (SET(mask, D28)) {
proto_tree_add_item(seg_tree, hf_4607_dwell_sensor_heading, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_dwell_sensor_pitch, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_dwell_sensor_roll, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
}
if (SET(mask, D31)) {
proto_tree_add_item(seg_tree, hf_4607_dwell_mdv, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
}
while (count--) {
offset = dissect_target(tvb, seg_tree, offset, mask);
}
return offset;
}
/* Job Definition */
static gint
dissect_jobdef(tvbuff_t *tvb, proto_tree *seg_tree, gint offset)
{
proto_tree_add_item(seg_tree, hf_4607_jobdef_job_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_jobdef_sensor_type, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(seg_tree, hf_4607_jobdef_sensor_model, tvb, offset, 6, ENC_ASCII);
offset += 6;
proto_tree_add_item(seg_tree, hf_4607_jobdef_filter, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(seg_tree, hf_4607_jobdef_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(seg_tree, hf_4607_jobdef_ba_lat_a, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_jobdef_ba_lon_a, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_jobdef_ba_lat_b, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_jobdef_ba_lon_b, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_jobdef_ba_lat_c, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_jobdef_ba_lon_c, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_jobdef_ba_lat_d, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_jobdef_ba_lon_d, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_jobdef_radar_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(seg_tree, hf_4607_jobdef_revisit_interval, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_jobdef_unc_along, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_jobdef_unc_cross, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_jobdef_unc_alt, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_jobdef_unc_heading, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(seg_tree, hf_4607_jobdef_unc_speed, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_jobdef_sense_slant, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_jobdef_sense_cross, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_jobdef_sense_vlos, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_jobdef_sense_mdv, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(seg_tree, hf_4607_jobdef_sense_prob, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(seg_tree, hf_4607_jobdef_sense_alarm, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(seg_tree, hf_4607_jobdef_terrain_model, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(seg_tree, hf_4607_jobdef_geoid_model, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
return offset;
}
static gint
dissect_platform_location(tvbuff_t *tvb, proto_tree *seg_tree, gint offset)
{
proto_tree_add_item(seg_tree, hf_4607_platloc_time, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_platloc_latitude, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_platloc_longitude, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_platloc_altitude, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_platloc_track, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(seg_tree, hf_4607_platloc_speed, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(seg_tree, hf_4607_platloc_vertical_velocity, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
return offset;
}
/* 32 == packet header, 5 == segment type and length */
#define STANAG4607_MIN_LENGTH (32+5)
#define MINIMUM_SEGMENT_SIZE 14
#define MISSION_SEGMENT_SIZE 44
#define JOB_DEFINITION_SEGMENT_SIZE 73
#define PLATFORM_LOCATION_SEGMENT_SIZE 28
/* Provide a basic sanity check on segment sizes; the fixed-length
* ones should be what they claim to be.
*/
#define CHK_SIZE(SEG_TYPE) \
if (SEG_TYPE##_SIZE != seg_size) { \
col_append_str(pinfo->cinfo, COL_INFO, ", Error: Invalid segment size "); \
expert_add_info(pinfo, pi, &ei_bad_length); \
}
static int
dissect_stanag4607(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
guint32 offset = 0;
gint8 first_segment;
guint32 pkt_size = 0;
proto_item *ti = NULL;
proto_tree *hdr_tree = NULL;
proto_item *seg_type = NULL;
proto_tree *seg_tree = NULL;
guint8 seg_id = 0;
/* Basic length check */
if (tvb_captured_length(tvb) < STANAG4607_MIN_LENGTH)
return 0;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "S4607");
/* Clear out stuff in the info column */
col_clear(pinfo->cinfo, COL_INFO);
/* Put type of first segment in the info column */
first_segment = tvb_get_guint8(tvb, 32);
col_add_str(pinfo->cinfo, COL_INFO,
val_to_str(first_segment, stanag4607_segment_vals, "Unknown (0x%02x)"));
/* Put the timestamp, if available in the time column */
if (PLATFORM_LOCATION_SEGMENT == first_segment) {
guint32 millisecs;
nstime_t ts;
millisecs = tvb_get_ntohl(tvb, 37);
ts.secs = millisecs / 1000;
ts.nsecs = (int)((millisecs - 1000 * ts.secs) * 1000000);
col_set_time(pinfo->cinfo, COL_REL_TIME, &ts, "s4607.ploc.time");
}
/* The generic packet header */
if (tree) {
ti = proto_tree_add_item(tree, proto_stanag4607, tvb, 0, -1, ENC_NA);
hdr_tree = proto_item_add_subtree(ti, ett_4607_hdr);
proto_tree_add_item(hdr_tree, hf_4607_version, tvb, 0, 2, ENC_ASCII);
ti = proto_tree_add_item(hdr_tree, hf_4607_packet_size, tvb, 2, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(hdr_tree, hf_4607_nationality, tvb, 6, 2, ENC_ASCII);
proto_tree_add_item(hdr_tree, hf_4607_sec_class, tvb, 8, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(hdr_tree, hf_4607_sec_system, tvb, 9, 2, ENC_ASCII);
proto_tree_add_item(hdr_tree, hf_4607_sec_code, tvb, 11, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(hdr_tree, hf_4607_exercise_indicator, tvb, 13, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(hdr_tree, hf_4607_platform_id, tvb, 14, 10, ENC_ASCII);
proto_tree_add_item(hdr_tree, hf_4607_mission_id, tvb, 24, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(hdr_tree, hf_4607_job_id, tvb, 28, 4, ENC_BIG_ENDIAN);
}
offset = 32;
pkt_size = tvb_get_ntohl(tvb, 2);
/* Ruh ro. These should be equal... */
if (tvb_reported_length(tvb) != pkt_size) {
expert_add_info(pinfo, ti, &ei_bad_packet_size);
pkt_size = tvb_reported_length(tvb);
}
/* Loop over all segments in the packet */
while (offset < pkt_size) {
guint32 seg_size = 0;
guint32 saved_offset = offset;
proto_item * pi;
/* Segment header */
seg_type = proto_tree_add_item(hdr_tree, hf_4607_segment_type, tvb, offset, 1, ENC_BIG_ENDIAN);
seg_id = tvb_get_guint8(tvb, offset);
offset += 1;
seg_tree = proto_item_add_subtree(seg_type, ett_4607_seg);
pi = proto_tree_add_item(seg_tree, hf_4607_segment_size, tvb, offset, 4, ENC_BIG_ENDIAN);
seg_size = tvb_get_ntohl(tvb, offset);
offset += 4;
if (seg_size < MINIMUM_SEGMENT_SIZE) {
seg_size = MINIMUM_SEGMENT_SIZE;
col_append_str(pinfo->cinfo, COL_INFO, ", Error: Invalid segment size ");
expert_add_info(pinfo, pi, &ei_too_short);
}
switch (seg_id) {
case MISSION_SEGMENT:
CHK_SIZE(MISSION_SEGMENT);
offset = dissect_mission(tvb, seg_tree, offset);
break;
case DWELL_SEGMENT:
offset = dissect_dwell(tvb, seg_tree, offset);
break;
case JOB_DEFINITION_SEGMENT:
CHK_SIZE(JOB_DEFINITION_SEGMENT);
offset = dissect_jobdef(tvb, seg_tree, offset);
break;
case PLATFORM_LOCATION_SEGMENT:
CHK_SIZE(PLATFORM_LOCATION_SEGMENT);
offset = dissect_platform_location(tvb, seg_tree, offset);
break;
default:
offset += seg_size - 5;
break;
}
if (offset < saved_offset) {
/* overflow */
break;
}
}
return tvb_captured_length(tvb);
}
void
proto_register_stanag4607(void)
{
static hf_register_info hf[] = {
/* ========================================== */
/* Packet header */
{ &hf_4607_version,
{ "Version ID", "s4607.version",
FT_STRING, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_packet_size,
{ "Packet Size", "s4607.size",
FT_UINT32, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_nationality,
{ "Nationality", "s4607.nationality",
FT_STRING, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_sec_class,
{ "Security Classification", "s4607.sec.class",
FT_UINT8, BASE_DEC,
VALS(stanag4607_class_vals), 0x0,
NULL, HFILL }
},
{ &hf_4607_sec_system,
{ "Security System", "s4607.sec.system",
FT_STRING, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_sec_code,
{ "Security Codes", "s4607.sec.codes",
FT_UINT16, BASE_HEX,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_exercise_indicator,
{ "Exercise Indicator", "s4607.exind",
FT_UINT8, BASE_DEC,
VALS(stanag4607_exind_vals), 0x0,
NULL, HFILL }
},
{ &hf_4607_platform_id,
{ "Platform ID", "s4607.platform",
FT_STRING, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_mission_id,
{ "Mission ID", "s4607.mission",
FT_UINT32, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_job_id,
{ "Job ID", "s4607.job",
FT_UINT32, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
/* ========================================== */
/* Segment header */
{ &hf_4607_segment_type,
{ "Segment Type", "s4607.seg.type",
FT_UINT8, BASE_DEC,
VALS(stanag4607_segment_vals), 0x0,
NULL, HFILL }
},
{ &hf_4607_segment_size,
{ "Segment Size", "s4607.seg.size",
FT_UINT32, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
/* ========================================== */
/* Dwell Segment */
{ &hf_4607_dwell_mask,
{ "Existence Mask", "s4607.dwell.mask",
FT_UINT64, BASE_HEX,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_revisit_index,
{ "Revisit Index", "s4607.dwell.revisit",
FT_UINT16, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_dwell_index,
{ "Dwell Index", "s4607.dwell.dwell",
FT_UINT16, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_last_dwell,
{ "Last Dwell of Revisit", "s4607.dwell.last",
FT_UINT8, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_count,
{ "Target Report Count", "s4607.dwell.count",
FT_UINT16, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_time,
{ "Dwell Time", "s4607.dwell.time",
FT_UINT32, BASE_CUSTOM,
CF_FUNC(prt_millisec), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_sensor_lat,
{ "Sensor Position Latitude", "s4607.dwell.sensor.lat",
FT_INT32, BASE_CUSTOM,
CF_FUNC(prt_sa32), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_sensor_lon,
{ "Sensor Position Longitude", "s4607.dwell.sensor.lon",
FT_UINT32, BASE_CUSTOM,
CF_FUNC(prt_ba32), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_sensor_alt,
{ "Sensor Position Altitude", "s4607.dwell.sensor.alt",
FT_INT32, BASE_CUSTOM,
CF_FUNC(prt_centimeters), 0x0,
NULL, HFILL }
},
/* D10 */
{ &hf_4607_dwell_scale_lat,
{ "Scale Factor, Latitude", "s4607.dwell.scale.lat",
FT_INT32, BASE_CUSTOM,
CF_FUNC(prt_sa32), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_scale_lon,
{ "Scale Factor, Longitude", "s4607.dwell.scale.lon",
FT_UINT32, BASE_CUSTOM,
CF_FUNC(prt_ba32), 0x0,
NULL, HFILL }
},
/* D12 */
{ &hf_4607_dwell_unc_along,
{ "Sensor Position Uncertainty Along Track", "s4607.dwell.unc.along",
FT_UINT32, BASE_CUSTOM,
CF_FUNC(prt_centimeters), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_unc_cross,
{ "Sensor Position Uncertainty Cross Track", "s4607.dwell.unc.cross",
FT_UINT32, BASE_CUSTOM,
CF_FUNC(prt_centimeters), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_unc_alt,
{ "Sensor Position Uncertainty Altitude", "s4607.dwell.unc.alt",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_centimeters), 0x0,
NULL, HFILL }
},
/* D15 */
{ &hf_4607_dwell_track,
{ "Sensor Track", "s4607.dwell.track",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_ba16), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_speed,
{ "Sensor Speed", "s4607.dwell.speed",
FT_UINT32, BASE_CUSTOM,
CF_FUNC(prt_speed), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_vert_velocity,
{ "Sensor Vertical Velocity", "s4607.dwell.vvel",
FT_INT8, BASE_CUSTOM,
CF_FUNC(prt_speed_deci), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_track_unc,
{ "Sensor Track Uncertainty", "s4607.dwell.track.unc",
FT_UINT8, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_speed_unc,
{ "Sensor Speed Uncertainty", "s4607.dwell.speed.unc",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_speed), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_vv_unc,
{ "Sensor Vertical Velocity Uncertainty", "s4607.dwell.vvel.unc",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_speed_centi), 0x0,
NULL, HFILL }
},
/* D21 */
{ &hf_4607_dwell_plat_heading,
{ "Platform Orientation Heading", "s4607.dwell.plat.heading",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_ba16), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_plat_pitch,
{ "Platform Orientation Pitch", "s4607.dwell.plat.pitch",
FT_INT16, BASE_CUSTOM,
CF_FUNC(prt_sa16), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_plat_roll,
{ "Platform Orientation Roll (Bank Angle)", "s4607.dwell.plat.roll",
FT_INT16, BASE_CUSTOM,
CF_FUNC(prt_sa16), 0x0,
NULL, HFILL }
},
/* D24 */
{ &hf_4607_dwell_da_lat,
{ "Dwell Area Center Latitude", "s4607.dwell.da.lat",
FT_INT32, BASE_CUSTOM,
CF_FUNC(prt_sa32), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_da_lon,
{ "Dwell Area Center Longitude", "s4607.dwell.da.lon",
FT_UINT32, BASE_CUSTOM,
CF_FUNC(prt_ba32), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_da_range,
{ "Dwell Area Range Half Extent", "s4607.dwell.da.range",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_kilo), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_da_angle,
{ "Dwell Area Dwell Angle Half Extent", "s4607.dwell.da.angle",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_ba16), 0x0,
NULL, HFILL }
},
/* D28 */
{ &hf_4607_dwell_sensor_heading,
{ "Sensor Orientation Heading", "s4607.dwell.sensor.heading",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_ba16), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_sensor_pitch,
{ "Sensor Orientation Pitch", "s4607.dwell.sensor.pitch",
FT_INT16, BASE_CUSTOM,
CF_FUNC(prt_sa16), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_sensor_roll,
{ "Sensor Orientation Roll (Bank Angle)", "s4607.dwell.sensor.roll",
FT_INT16, BASE_CUSTOM,
CF_FUNC(prt_sa16), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_mdv,
{ "Minimum Detectable Velocity (MDV)", "s4607.dwell.mdv",
FT_UINT8, BASE_CUSTOM,
CF_FUNC(prt_speed_deci), 0x0,
NULL, HFILL }
},
/* ========================================== */
/* Target Report */
{ &hf_4607_dwell_report_index,
{ "MTI Report Index", "s4607.dwell.rpt.idx",
FT_UINT16, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
/* D32.2 */
{ &hf_4607_dwell_report_lat,
{ "Target Location Hi-Res Latitude", "s4607.dwell.rpt.lat",
FT_INT32, BASE_CUSTOM,
CF_FUNC(prt_sa32), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_report_lon,
{ "Target Location Hi-Res Longitude", "s4607.dwell.rpt.lon",
FT_UINT32, BASE_CUSTOM,
CF_FUNC(prt_ba32), 0x0,
NULL, HFILL }
},
/* D32.4 */
{ &hf_4607_dwell_report_delta_lat,
{ "Target Location Delta Latitude", "s4607.dwell.rpt.delta.lat",
FT_INT16, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_report_delta_lon,
{ "Target Location Delta Longitude", "s4607.dwell.rpt.delta.lon",
FT_INT16, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
/* D32.6 */
{ &hf_4607_dwell_report_height,
{ "Target Location Geodetic Height", "s4607.dwell.rpt.height",
FT_INT16, BASE_CUSTOM,
CF_FUNC(prt_meters), 0x0,
NULL, HFILL }
},
/* D32.7 */
{ &hf_4607_dwell_report_radial,
{ "Target Velocity Line of Sight Component", "s4607.dwell.rpt.radial",
FT_INT16, BASE_CUSTOM,
CF_FUNC(prt_speed_centi), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_report_wrap,
{ "Target Wrap Velocity", "s4607.dwell.rpt.wrap",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_speed_centi), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_report_snr,
{ "Target SNR", "s4607.dwell.rpt.snr",
FT_INT8, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_report_class,
{ "Target Classification", "s4607.dwell.rpt.class",
FT_UINT8, BASE_DEC,
VALS(stanag4607_target_vals), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_report_prob,
{ "Target Class Probability", "s4607.dwell.rpt.prob",
FT_UINT8, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
/* D32.12 */
{ &hf_4607_dwell_report_unc_slant,
{ "Target Measurement Uncertainty Slant Range", "s4607.dwell.rpt.unc.slant",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_centimeters), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_report_unc_cross,
{ "Target Measurement Uncertainty Cross Range", "s4607.dwell.rpt.unc.cross",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_decimeters), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_report_unc_height,
{ "Target Measurement Uncertainty Height", "s4607.dwell.rpt.unc.height",
FT_UINT8, BASE_CUSTOM,
CF_FUNC(prt_meters), 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_report_unc_radial,
{ "Target Measurement Uncertainty Radial Velocity", "s4607.dwell.rpt.unc.radial",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_speed_centi), 0x0,
NULL, HFILL }
},
/* D32.16 */
{ &hf_4607_dwell_report_tag_app,
{ "Truth Tag Application", "s4607.dwell.rpt.tag.app",
FT_UINT8, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_report_tag_entity,
{ "Truth Tag Entity", "s4607.dwell.rpt.tag.entity",
FT_UINT32, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_dwell_report_section,
{ "Radar Cross Section", "s4607.dwell.rpt.section",
FT_INT8, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
/* ========================================== */
/* Job Definition Segment */
{ &hf_4607_jobdef_job_id,
{ "Job ID", "s4607.job.id",
FT_UINT32, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_sensor_type,
{ "Sensor Type", "s4607.job.type",
FT_UINT8, BASE_DEC,
VALS(stanag4607_sensor_vals), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_sensor_model,
{ "Sensor Model", "s4607.job.model",
FT_STRING, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_filter,
{ "Target Filtering Flag", "s4607.job.filter",
FT_UINT8, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_priority,
{ "Radar Priority", "s4607.job.priority",
FT_UINT8, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_ba_lat_a,
{ "Bounding Area Point A Latitude", "s4607.job.ba.lat.a",
FT_INT32, BASE_CUSTOM,
CF_FUNC(prt_sa32), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_ba_lon_a,
{ "Bounding Area Point A Longitude", "s4607.job.ba.lon.a",
FT_UINT32, BASE_CUSTOM,
CF_FUNC(prt_ba32), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_ba_lat_b,
{ "Bounding Area Point B Latitude", "s4607.job.ba.lat.b",
FT_INT32, BASE_CUSTOM,
CF_FUNC(prt_sa32), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_ba_lon_b,
{ "Bounding Area Point B Longitude", "s4607.job.ba.lon.b",
FT_UINT32, BASE_CUSTOM,
CF_FUNC(prt_ba32), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_ba_lat_c,
{ "Bounding Area Point C Latitude", "s4607.job.ba.lat.c",
FT_INT32, BASE_CUSTOM,
CF_FUNC(prt_sa32), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_ba_lon_c,
{ "Bounding Area Point C Longitude", "s4607.job.ba.lon.c",
FT_UINT32, BASE_CUSTOM,
CF_FUNC(prt_ba32), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_ba_lat_d,
{ "Bounding Area Point D Latitude", "s4607.job.ba.lat.d",
FT_INT32, BASE_CUSTOM,
CF_FUNC(prt_sa32), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_ba_lon_d,
{ "Bounding Area Point D Longitude", "s4607.job.ba.lon.d",
FT_UINT32, BASE_CUSTOM,
CF_FUNC(prt_ba32), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_radar_mode,
{ "Radar Mode", "s4607.job.mode",
FT_UINT8, BASE_DEC,
VALS(stanag4607_radar_mode_vals), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_revisit_interval,
{ "Nominal Revisit Interval", "s4607.job.revisit",
FT_UINT16, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_unc_along,
{ "Nominal Sensor Position Uncertainty Along Track", "s4607.job.unc.track",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_none16), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_unc_cross,
{ "Nominal Sensor Position Uncertainty Cross Track", "s4607.job.unc.cross",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_none16), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_unc_alt,
{ "Nominal Sensor Position Uncertainty Altitude", "s4607.job.unc.alt",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_none16), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_unc_heading,
{ "Nominal Sensor Position Uncertainty Track Heading", "s4607.job.unc.heading",
FT_UINT8, BASE_CUSTOM,
CF_FUNC(prt_none8), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_unc_speed,
{ "Nominal Sensor Position Uncertainty Speed", "s4607.job.unc.speed",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_none16), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_sense_slant,
{ "Nominal Sensor Slant Range Standard Deviation", "s4607.job.sense.slant",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_none16), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_sense_cross,
{ "Nominal Sensor Cross Range Standard Deviation", "s4607.job.sense.cross",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_ba16_none), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_sense_vlos,
{ "Nominal Sensor Velocity Line-Of-Sight Std. Dev", "s4607.job.sense.vlos",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_none16), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_sense_mdv,
{ "Nominal Sensor Minimum Detectable Velocity (MDV)", "s4607.job.sense.mdv",
FT_UINT8, BASE_CUSTOM,
CF_FUNC(prt_none8), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_sense_prob,
{ "Nominal Sensor Detection Probability", "s4607.job.sense.prob",
FT_UINT8, BASE_CUSTOM,
CF_FUNC(prt_none8), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_sense_alarm,
{ "Nominal Sensor False Alarm Density", "s4607.job.sense.alarm",
FT_UINT8, BASE_CUSTOM,
CF_FUNC(prt_none8), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_terrain_model,
{ "Terrain Elevation Model Used", "s4607.job.terrain",
FT_UINT8, BASE_DEC,
VALS(stanag4607_terrain_vals), 0x0,
NULL, HFILL }
},
{ &hf_4607_jobdef_geoid_model,
{ "Geoid Model Used", "s4607.job.geoid",
FT_UINT8, BASE_DEC,
VALS(stanag4607_geoid_vals), 0x0,
NULL, HFILL }
},
/* ========================================== */
/* Mission segment */
{ &hf_4607_mission_plan,
{ "Mission Plan", "s4607.mission.plan",
FT_STRING, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_mission_flight_plan,
{ "Mission Flight Plan", "s4607.mission.flight",
FT_STRING, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_mission_platform,
{ "Mission Platform Type", "s4607.mission.platform",
FT_UINT8, BASE_DEC,
VALS(stanag4607_platform_vals), 0x0,
NULL, HFILL }
},
{ &hf_4607_mission_platform_config,
{ "Mission Platform Configuration", "s4607.mission.config",
FT_STRING, BASE_NONE,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_mission_time_year,
{ "Mission Reference Time Year", "s4607.mission.year",
FT_UINT16, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_mission_time_month,
{ "Mission Reference Time Month", "s4607.mission.month",
FT_UINT8, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_4607_mission_time_day,
{ "Mission Reference Time Day", "s4607.mission.day",
FT_UINT8, BASE_DEC,
NULL, 0x0,
NULL, HFILL }
},
/* ========================================== */
{ &hf_4607_platloc_time,
{ "Platform Location Time", "s4607.ploc.time",
FT_UINT32, BASE_CUSTOM,
CF_FUNC(prt_millisec), 0x0,
NULL, HFILL }
},
{ &hf_4607_platloc_latitude,
{ "Platform Position Latitude", "s4607.ploc.lat",
FT_INT32, BASE_CUSTOM,
CF_FUNC(prt_sa32), 0x0,
NULL, HFILL }
},
{ &hf_4607_platloc_longitude,
{ "Platform Position Longitude", "s4607.ploc.lon",
FT_UINT32, BASE_CUSTOM,
CF_FUNC(prt_ba32), 0x0,
NULL, HFILL }
},
{ &hf_4607_platloc_altitude,
{ "Platform Position Altitude", "s4607.ploc.alt",
FT_INT32, BASE_CUSTOM,
CF_FUNC(prt_centimeters), 0x0,
NULL, HFILL }
},
{ &hf_4607_platloc_track,
{ "Platform Track", "s4607.ploc.track",
FT_UINT16, BASE_CUSTOM,
CF_FUNC(prt_ba16), 0x0,
NULL, HFILL }
},
{ &hf_4607_platloc_speed,
{ "Platform Speed", "s4607.ploc.speed",
FT_UINT32, BASE_CUSTOM,
CF_FUNC(prt_speed), 0x0,
NULL, HFILL }
},
{ &hf_4607_platloc_vertical_velocity,
{ "Platform Vertical Velocity", "s4607.ploc.velocity",
FT_INT8, BASE_CUSTOM,
CF_FUNC(prt_speed_deci), 0x0,
NULL, HFILL }
},
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_4607_hdr,
&ett_4607_seg,
&ett_4607_rpt,
};
static ei_register_info ei[] = {
{ &ei_too_short,
{ "s4607.segment_too_short", PI_MALFORMED, PI_ERROR,
"Segment size too small", EXPFILL }},
{ &ei_bad_length,
{ "s4607.segment_bad_length", PI_MALFORMED, PI_ERROR,
"Bad segment size", EXPFILL }},
{ &ei_bad_packet_size,
{ "s4607.bad_packet_size", PI_MALFORMED, PI_ERROR,
"Bad packet size field", EXPFILL }}
};
expert_module_t* expert_4607;
proto_stanag4607 = proto_register_protocol (
"STANAG 4607 (GMTI Format)", /* name */
"STANAG 4607", /* short name */
"s4607" /* abbrev */
);
proto_register_field_array(proto_stanag4607, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_4607 = expert_register_protocol(proto_stanag4607);
expert_register_field_array(expert_4607, ei, array_length(ei));
stanag4607_handle = register_dissector("stanag4607", dissect_stanag4607, proto_stanag4607);
/* prefs_register_protocol(proto_stanag4607, proto_reg_handoff_stanag4607); */
}
void
proto_reg_handoff_stanag4607(void)
{
dissector_add_uint("wtap_encap", WTAP_ENCAP_STANAG_4607, stanag4607_handle);
}
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-starteam.c
|
/* packet-starteam.c
* Routines for Borland StarTeam packet dissection
*
* metatech <metatech[AT]flashmail.com>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* StarTeam in a nutshell
*
* StarTeam is a Software Change & Configuration Management Tool (like CVS)
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#include "packet-tcp.h"
void proto_register_starteam(void);
void proto_reg_handoff_starteam(void);
static int proto_starteam = -1;
static int hf_starteam_mdh_session_tag = -1;
static int hf_starteam_mdh_ctimestamp = -1;
static int hf_starteam_mdh_flags = -1;
static int hf_starteam_mdh_keyid = -1;
static int hf_starteam_mdh_reserved = -1;
static int hf_starteam_ph_signature = -1;
static int hf_starteam_ph_packet_size = -1;
static int hf_starteam_ph_data_size = -1;
static int hf_starteam_ph_data_flags = -1;
static int hf_starteam_id_revision_level = -1;
static int hf_starteam_id_client = -1;
static int hf_starteam_id_connect = -1;
static int hf_starteam_id_component = -1;
static int hf_starteam_id_command = -1;
static int hf_starteam_id_command_time = -1;
static int hf_starteam_id_command_userid = -1;
static int hf_starteam_data_data = -1;
static gint ett_starteam = -1;
static gint ett_starteam_mdh = -1;
static gint ett_starteam_ph = -1;
static gint ett_starteam_id = -1;
static gint ett_starteam_data = -1;
static dissector_handle_t starteam_tcp_handle;
static gboolean starteam_desegment = TRUE;
#define STARTEAM_MAGIC 0x416C616E /* "Alan" */
#define STARTEAM_SRVR_CMD_GET_SESSION_TAG 1
#define STARTEAM_SRVR_CMD_GET_REQUIRED_ENCRYPTION_LEVEL 2
#define STARTEAM_SRVR_CMD_GET_SERVER_PARAMS 3
#define STARTEAM_SRVR_CMD_SERVER_CONNECT 4
#define STARTEAM_SRVR_CMD_SERVER_RECONNECT 5
#define STARTEAM_SRVR_CMD_BEGIN_LOGIN 10
#define STARTEAM_SRVR_CMD_KEY_EXCHANGE_PHASE0 11
#define STARTEAM_SRVR_CMD_KEY_EXCHANGE_PHASE12 12
#define STARTEAM_SRVR_CMD_KEY_EXCHANGE_PHASE3 13
#define STARTEAM_SRVR_CMD_SERVER_LOGIN 14
#define STARTEAM_SRVR_CMD_GET_PROJECT_LIST 1001
#define STARTEAM_SRVR_CMD_GET_PROJECT_VIEWS 1002
#define STARTEAM_SRVR_CMD_PROJECT_LOGIN 1011
#define STARTEAM_SRVR_CMD_PROJECT_LOGOUT 1013
#define STARTEAM_PROJ_CMD_LIST_SET_READ 1014
#define STARTEAM_PROJ_CMD_LIST_ADD_ATTACHMENT 1015
#define STARTEAM_PROJ_CMD_LIST_GET_ATTACHMENT 1016
#define STARTEAM_PROJ_CMD_LIST_REMOVE_ATTACHMENT 1017
#define STARTEAM_PROJ_CMD_MAIL_LIST_ITEMS 1018
#define STARTEAM_PROJ_CMD_LIST_ANY_NEWITEMS 1020
#define STARTEAM_PROJ_CMD_LIST_GET_NEWITEMS 1021
/* #define STARTEAM_SRVR_CMD_RELEASE_CLIENT 1021 XXX: ?? */
#define STARTEAM_SRVR_CMD_UPDATE_SERVER_INFO 1022
#define STARTEAM_SRVR_CMD_GET_USAGE_DATA 1023
#define STARTEAM_SRVR_CMD_GET_LICENSE_INFO 1024
#define STARTEAM_PROJ_CMD_FILTER_ADD 1030
#define STARTEAM_PROJ_CMD_FILTER_MODIFY 1031
#define STARTEAM_PROJ_CMD_FILTER_GET 1032
#define STARTEAM_PROJ_CMD_FILTER_GET_LIST 1033
#define STARTEAM_PROJ_CMD_FILTER_DELETE 1034
#define STARTEAM_PROJ_CMD_QUERY_ADD 1035
#define STARTEAM_PROJ_CMD_QUERY_MODIFY 1036
#define STARTEAM_PROJ_CMD_QUERY_GET 1037
#define STARTEAM_PROJ_CMD_QUERY_GET_LIST 1038
#define STARTEAM_PROJ_CMD_QUERY_DELETE 1039
#define STARTEAM_PROJ_GET_FILTER_CLASS_ID 1040
#define STARTEAM_PROJ_GET_QUERY_CLASS_ID 1041
#define STARTEAM_SRVR_CMD_PROJECT_CREATE 1051
#define STARTEAM_SRVR_CMD_PROJECT_OPEN 1052
#define STARTEAM_SRVR_CMD_PROJECT_CLOSE 1053
#define STARTEAM_PROJ_CMD_CATALOG_LOADALL 1151
#define STARTEAM_PROJ_CMD_CATALOG_LOADSET 1152
#define STARTEAM_PROJ_CMD_CATALOG_LOADREGISTEREDCLASSES 1154
#define STARTEAM_PROJ_CMD_REFRESH_CLASS_INFO 1160
#define STARTEAM_PROJ_CMD_ADD_CUSTOM_FIELD_CLASS_INFO 1161
#define STARTEAM_PROJ_CMD_MODIFY_FIELD_CLASS_INFO 1162
#define STARTEAM_PROJ_CMD_ADD_CUSTOM_FIELD_CLASS_INFO_EX 1163
#define STARTEAM_PROJ_CMD_GET_FOLDER_ITEMS 2001
/* #define STARTEAM_SRVR_CMD_GET_USERS_AND_GROUPS 2001 XXX: ?? */
#define STARTEAM_PROJ_CMD_REFRESH_ITEMS 2002
#define STARTEAM_PROJ_CMD_GET_ITEM 2003
/* #define STARTEAM_SRVR_CMD_GET_EMAIL_USERS 2003 XXX: ?? */
#define STARTEAM_PROJ_CMD_UPDATE_ITEM 2004
#define STARTEAM_PROJ_CMD_DELETE_ITEM 2005
#define STARTEAM_PROJ_CMD_SET_ITEM_LOCK 2006
#define STARTEAM_PROJ_CMD_DELETE_TREE_ITEM 2007
#define STARTEAM_PROJ_CMD_GET_ITEM_HISTORY 2010
#define STARTEAM_SRVR_CMD_GET_USER_PERSONAL_INFO 2011
#define STARTEAM_SRVR_CMD_SET_USER_PERSONAL_INFO 2012
#define STARTEAM_SRVR_CMD_SET_USER_PASSWORD 2013
#define STARTEAM_PROJ_CMD_MOVE_ITEMS 2020
#define STARTEAM_PROJ_CMD_MOVE_TREE_ITEMS 2021
/* #define STARTEAM_SRVR_CMD_GET_GROUP_INFO 2021 XXX: ?? */
#define STARTEAM_PROJ_CMD_SHARE_ITEMS 2022
/* #define STARTEAM_SRVR_CMD_ADD_EDIT_GROUP_INFO 2022 XXX: ?? */
#define STARTEAM_PROJ_CMD_SHARE_TREE_ITEMS 2023
/* #define STARTEAM_SRVR_CMD_DROP_GROUP 2023 XXX: ?? */
#define STARTEAM_SRVR_CMD_GET_USER_INFO 2024
#define STARTEAM_SRVR_CMD_ADD_EDIT_USER_INFO 2025
#define STARTEAM_SRVR_CMD_DROP_USER 2026
#define STARTEAM_SRVR_CMD_GET_MIN_PASSWORD_LENGTH 2027
#define STARTEAM_SRVR_CMD_USER_ADMIN_OPERATION 2028
#define STARTEAM_SRVR_CMD_ACCESS_CHECK 2029
#define STARTEAM_PROJ_CMD_GET_COMMON_ANCESTOR_ITEM 2030
/* #define STARTEAM_SRVR_CMD_ACCESS_TEST 2030 XXX: ?? */
#define STARTEAM_PROJ_CMD_UPDATE_REVISION_COMMENT 2031
/* #define STARTEAM_SRVR_CMD_GET_MAIN_LOG_LAST64K 2031 XXX: ?? */
#define STARTEAM_SRVR_CMD_GET_SERVER_CONFIG 2032
#define STARTEAM_SRVR_CMD_SET_SERVER_CONFIG 2033
#define STARTEAM_SRVR_CMD_GET_SERVER_ACL 2034
#define STARTEAM_SRVR_CMD_DROP_SERVER_ACL 2035
#define STARTEAM_SRVR_CMD_SET_SERVER_ACL 2036
#define STARTEAM_SRVR_CMD_GET_SYSTEM_POLICY 2037
#define STARTEAM_SRVR_CMD_SET_SYSTEM_POLICY 2038
#define STARTEAM_SRVR_CMD_GET_SECURITY_LOG 2039
#define STARTEAM_SRVR_CMD_GET_SERVER_COMMAND_STATS 2040
#define STARTEAM_SRVR_CMD_SET_SERVER_COMMAND_MODE 2041
#define STARTEAM_SRVR_CMD_SHUTDOWN 2042
#define STARTEAM_SRVR_CMD_RESTART 2043
#define STARTEAM_SRVR_CMD_GET_SERVER_COMMAND_MODE 2045
#define STARTEAM_SRVR_CMD_GET_LOG 2046
#define STARTEAM_SRVR_CMD_GET_COMPONENT_LIST 2050
#define STARTEAM_SRVR_CMD_GET_GROUP_MEMBERS 2060
#define STARTEAM_PROJ_CMD_GET_ITEMS_VERSIONS 5001
#define STARTEAM_SRVR_CMD_VALIDATE_VSS_INI_PATH 9034
#define STARTEAM_SRVR_CMD_VALIDATE_PVCS_CFG_PATH 9035
#define STARTEAM_SRVR_CMD_GET_VSS_PROJECT_TREE 9036
#define STARTEAM_SRVR_CMD_GET_ALL_PVCS_ARCHIVES 9037
#define STARTEAM_SRVR_CMD_INITIALIZE_FOREIGN_ACCESS 9038
#define STARTEAM_SRVR_CMD_SET_FOREIGN_PROJECT_PW 9039
#define STARTEAM_PROJ_CMD_PING 10001
#define STARTEAM_PROJ_CMD_SET_LOCALE 10005
#define STARTEAM_PROJ_CMD_GET_CONTAINER_ACL 10011
#define STARTEAM_PROJ_CMD_SET_CONTAINER_ACL 10012
#define STARTEAM_PROJ_CMD_GET_CONTAINER_LEVEL_ACL 10013
#define STARTEAM_PROJ_CMD_SET_CONTAINER_LEVEL_ACL 10014
#define STARTEAM_PROJ_CMD_GET_OBJECT_ACL 10015
#define STARTEAM_PROJ_CMD_SET_OBJECT_ACL 10016
#define STARTEAM_PROJ_CMD_ITEM_ACCESS_CHECK 10017
#define STARTEAM_PROJ_CMD_ITEM_ACCESS_TEST 10018
#define STARTEAM_PROJ_CMD_GET_OWNER 10019
#define STARTEAM_PROJ_CMD_ACQUIRE_OWNERSHIP 10020
#define STARTEAM_PROJ_CMD_GET_FOLDERS 10021
#define STARTEAM_PROJ_CMD_ADD_FOLDERS 10023
#define STARTEAM_PROJ_CMD_DELETE_FOLDER 10024
#define STARTEAM_PROJ_CMD_MOVE_FOLDER 10025
#define STARTEAM_PROJ_CMD_SHARE_FOLDER 10026
#define STARTEAM_PROJ_CMD_CONTAINER_ACCESS_CHECK 10031
#define STARTEAM_PROJ_CMD_CONTAINER_ACCESS_TEST 10032
#define STARTEAM_PROJ_CMD_GET_OBJECT2_ACL 10035
#define STARTEAM_PROJ_CMD_SET_OBJECT2_ACL 10036
#define STARTEAM_PROJ_CMD_OBJECT_ACCESS_CHECK 10037
#define STARTEAM_PROJ_CMD_OBJECT_ACCESS_TEST 10038
#define STARTEAM_PROJ_CMD_GET_OBJECT_OWNER 10039
#define STARTEAM_PROJ_CMD_ACQUIRE_OBJECT_OWNERSHIP 10040
#define STARTEAM_PROJ_CMD_GET_FOLDER_PROPERTIES 10053
#define STARTEAM_PROJ_CMD_SET_FOLDER_PROPERTIES 10054
#define STARTEAM_PROJ_CMD_GET_ITEM_PROPERTIES 10060
#define STARTEAM_PROJ_CMD_SET_ITEM_PROPERTIES 10061
#define STARTEAM_PROJ_CMD_GET_ITEM_REFERENCES 10062
#define STARTEAM_PROJ_CMD_GET_ITEM_REFERENCE 10063
#define STARTEAM_PROJ_CMD_GET_ITEM_REVISIONS 10065
#define STARTEAM_PROJ_CMD_DELETE_PROJECT 10083
#define STARTEAM_PROJ_CMD_GET_PROJECT_PROPERTIES 10085
#define STARTEAM_PROJ_CMD_SET_PROJECT_PROPERTIES 10086
#define STARTEAM_PROJ_CMD_GET_VIEW_INFO 10090
#define STARTEAM_PROJ_CMD_ADD_VIEW 10091
#define STARTEAM_PROJ_CMD_GET_VIEWS 10092
#define STARTEAM_PROJ_CMD_GET_VIEW_PROPERTIES 10093
#define STARTEAM_PROJ_CMD_SET_VIEW_PROPERTIES 10094
#define STARTEAM_PROJ_CMD_DELETE_VIEW 10095
#define STARTEAM_PROJ_CMD_SWITCH_VIEW 10098
#define STARTEAM_PROJ_CMD_SWITCH_VIEW_CONFIG 10099
#define STARTEAM_PROJ_CMD_GET_FOLDER_PATH 10100
#define STARTEAM_FILE_CMD_CHECKOUT 10104
#define STARTEAM_FILE_CMD_GET_SYNC_INFO 10111
#define STARTEAM_FILE_CMD_DELETE_SYNC_INFO 10112
#define STARTEAM_FILE_CMD_GET_PATH_IDS 10117
#define STARTEAM_FILE_CMD_SYNC_UPDATE_ALL_INFO 10119
#define STARTEAM_FILE_CMD_RESYNC_FILE 10121
#define STARTEAM_FILE_CMD_CONVERT_ARCHIVE 10122
#define STARTEAM_FILE_CMD_ARCHIVE_CONVERSION 10123
#define STARTEAM_FILE_CMD_READ_PVCS_ARCHIVES 10130
#define STARTEAM_FILE_CMD_ADD_PVCS_ARCHIVES 10131
#define STARTEAM_FILE_CMD_ADD_PVCS_BRANCHES 10132
#define STARTEAM_FILE_CMD_FINISH_NEW_PVCS_PROJECT 10133
#define STARTEAM_FILE_CMD_GET_NUMBER_VSS_ARCHIVES 10134
#define STARTEAM_FILE_CMD_READ_VSS_ARCHIVES 10135
#define STARTEAM_FILE_CMD_ADD_VSS_ARCHIVE_TO_FOLDER 10136
#define STARTEAM_FILE_CMD_FINISH_NEW_VSS_PROJECT 10137
#define STARTEAM_FILE_CMD_REFRESH_FOREIGN_FOLDER 10138
#define STARTEAM_FILE_CMD_START_GO_NATIVE 10139
#define STARTEAM_FILE_CMD_GET_PROJECT_TYPE 10141
#define STARTEAM_FILE_CMD_SET_FOREIGN_PROJECT_PW 10142
#define STARTEAM_FILE_CMD_INTERNAL_NESTED_COMMAND 10143
#define STARTEAM_PROJ_CMD_LABEL_GET_INFO 10201
#define STARTEAM_PROJ_CMD_LABEL_GET_PROPERTIES 10202
#define STARTEAM_PROJ_CMD_LABEL_SET_PROPERTIES 10203
#define STARTEAM_PROJ_CMD_LABEL_CREATE 10205
#define STARTEAM_PROJ_CMD_LABEL_DELETE 10206
#define STARTEAM_PROJ_CMD_LABEL_ATTACH 10207
#define STARTEAM_PROJ_CMD_LABEL_MOVE 10208
#define STARTEAM_PROJ_CMD_LABEL_DETACH 10209
#define STARTEAM_PROJ_CMD_LABEL_GET_INFO_EX 10221
#define STARTEAM_PROJ_CMD_LABEL_CREATE_EX 10222
#define STARTEAM_PROJ_CMD_LABEL_ATTACH_EX 10223
#define STARTEAM_PROJ_CMD_LABEL_ATTACH_ITEMS 10224
#define STARTEAM_PROJ_CMD_LABEL_DETACH_EX 10225
#define STARTEAM_PROJ_CMD_LABEL_DETACH_ITEMS 10226
#define STARTEAM_PROJ_CMD_LABEL_GETITEMIDS 10229
#define STARTEAM_PROJ_CMD_LINK_GET_INFO 10300
#define STARTEAM_PROJ_CMD_LINK_CREATE 10301
#define STARTEAM_PROJ_CMD_LINK_DELETE 10302
#define STARTEAM_PROJ_CMD_LINK_UPDATE_PROPERTIES 10310
#define STARTEAM_PROJ_CMD_LINK_UPDATE_PINS 10311
#define STARTEAM_PROJ_CMD_PROMOTION_GET 10400
#define STARTEAM_PROJ_CMD_PROMOTION_SET 10401
#define STARTEAM_TASK_CMD_GET_WORKRECS 10402
#define STARTEAM_TASK_CMD_ADD_WORKREC 10403
#define STARTEAM_TASK_CMD_UPDATE_WORKREC 10404
#define STARTEAM_TASK_CMD_DELETE_WORKREC 10405
#define STARTEAM_TASK_CMD_DELETE_TASK_PREDECESSOR 10408
#define STARTEAM_TASK_CMD_GET_TASK_DEPENDENCIES 10409
#define STARTEAM_TASK_CMD_ADD_TASK_PREDECESSOR 10410
#define STARTEAM_TASK_CMD_UPDATE_TASK_PREDECESSOR 10411
#define STARTEAM_PROJ_CMD_VIEW_COMPARE_GET_FOLDER_DETAILS 20070
#define STARTEAM_PROJ_CMD_VIEW_COMPARE_RELATE_ITEMS 20071
#define STARTEAM_TEXT_MDH "Message Data Header"
#define STARTEAM_TEXT_PH "Packet Header"
#define STARTEAM_TEXT_ID "ID"
#define STARTEAM_TEXT_DATA "Data"
static const value_string starteam_opcode_vals[] = {
{ STARTEAM_SRVR_CMD_GET_SESSION_TAG, "SRVR_CMD_GET_SESSION_TAG" },
{ STARTEAM_SRVR_CMD_GET_REQUIRED_ENCRYPTION_LEVEL, "SRVR_CMD_GET_REQUIRED_ENCRYPTION_LEVEL" },
{ STARTEAM_SRVR_CMD_GET_SERVER_PARAMS, "SRVR_CMD_GET_SERVER_PARAMS" },
{ STARTEAM_SRVR_CMD_SERVER_CONNECT, "SRVR_CMD_SERVER_CONNECT" },
{ STARTEAM_SRVR_CMD_SERVER_RECONNECT, "SRVR_CMD_SERVER_RECONNECT" },
{ STARTEAM_SRVR_CMD_BEGIN_LOGIN, "SRVR_CMD_BEGIN_LOGIN" },
{ STARTEAM_SRVR_CMD_KEY_EXCHANGE_PHASE0, "SRVR_CMD_KEY_EXCHANGE_PHASE0" },
{ STARTEAM_SRVR_CMD_KEY_EXCHANGE_PHASE12, "SRVR_CMD_KEY_EXCHANGE_PHASE12" },
{ STARTEAM_SRVR_CMD_KEY_EXCHANGE_PHASE3, "SRVR_CMD_KEY_EXCHANGE_PHASE3" },
{ STARTEAM_SRVR_CMD_SERVER_LOGIN, "SRVR_CMD_SERVER_LOGIN" },
{ STARTEAM_SRVR_CMD_GET_PROJECT_LIST, "SRVR_CMD_GET_PROJECT_LIST" },
{ STARTEAM_SRVR_CMD_GET_PROJECT_VIEWS, "SRVR_CMD_GET_PROJECT_VIEWS" },
{ STARTEAM_SRVR_CMD_PROJECT_LOGIN, "SRVR_CMD_PROJECT_LOGIN" },
{ STARTEAM_SRVR_CMD_PROJECT_LOGOUT, "SRVR_CMD_PROJECT_LOGOUT" },
{ STARTEAM_PROJ_CMD_LIST_SET_READ, "PROJ_CMD_LIST_SET_READ" },
{ STARTEAM_PROJ_CMD_LIST_ADD_ATTACHMENT, "PROJ_CMD_LIST_ADD_ATTACHMENT" },
{ STARTEAM_PROJ_CMD_LIST_GET_ATTACHMENT, "PROJ_CMD_LIST_GET_ATTACHMENT" },
{ STARTEAM_PROJ_CMD_LIST_REMOVE_ATTACHMENT, "PROJ_CMD_LIST_REMOVE_ATTACHMENT" },
{ STARTEAM_PROJ_CMD_MAIL_LIST_ITEMS, "PROJ_CMD_MAIL_LIST_ITEMS" },
{ STARTEAM_PROJ_CMD_LIST_ANY_NEWITEMS, "PROJ_CMD_LIST_ANY_NEWITEMS" },
{ STARTEAM_PROJ_CMD_LIST_GET_NEWITEMS, "PROJ_CMD_LIST_GET_NEWITEMS" },
/* { STARTEAM_SRVR_CMD_RELEASE_CLIENT, "SRVR_CMD_RELEASE_CLIENT" }, */
{ STARTEAM_SRVR_CMD_UPDATE_SERVER_INFO, "SRVR_CMD_UPDATE_SERVER_INFO" },
{ STARTEAM_SRVR_CMD_GET_USAGE_DATA, "SRVR_CMD_GET_USAGE_DATA" },
{ STARTEAM_SRVR_CMD_GET_LICENSE_INFO, "SRVR_CMD_GET_LICENSE_INFO" },
{ STARTEAM_PROJ_CMD_FILTER_ADD, "PROJ_CMD_FILTER_ADD" },
{ STARTEAM_PROJ_CMD_FILTER_MODIFY, "PROJ_CMD_FILTER_MODIFY" },
{ STARTEAM_PROJ_CMD_FILTER_GET, "PROJ_CMD_FILTER_GET" },
{ STARTEAM_PROJ_CMD_FILTER_GET_LIST, "PROJ_CMD_FILTER_GET_LIST" },
{ STARTEAM_PROJ_CMD_FILTER_DELETE, "PROJ_CMD_FILTER_DELETE" },
{ STARTEAM_PROJ_CMD_QUERY_ADD, "PROJ_CMD_QUERY_ADD" },
{ STARTEAM_PROJ_CMD_QUERY_MODIFY, "PROJ_CMD_QUERY_MODIFY" },
{ STARTEAM_PROJ_CMD_QUERY_GET, "PROJ_CMD_QUERY_GET" },
{ STARTEAM_PROJ_CMD_QUERY_GET_LIST, "PROJ_CMD_QUERY_GET_LIST" },
{ STARTEAM_PROJ_CMD_QUERY_DELETE, "PROJ_CMD_QUERY_DELETE" },
{ STARTEAM_PROJ_GET_FILTER_CLASS_ID, "PROJ_GET_FILTER_CLASS_ID" },
{ STARTEAM_PROJ_GET_QUERY_CLASS_ID, "PROJ_GET_QUERY_CLASS_ID" },
{ STARTEAM_SRVR_CMD_PROJECT_CREATE, "SRVR_CMD_PROJECT_CREATE" },
{ STARTEAM_SRVR_CMD_PROJECT_OPEN, "SRVR_CMD_PROJECT_OPEN" },
{ STARTEAM_SRVR_CMD_PROJECT_CLOSE, "SRVR_CMD_PROJECT_CLOSE" },
{ STARTEAM_PROJ_CMD_CATALOG_LOADALL, "PROJ_CMD_CATALOG_LOADALL" },
{ STARTEAM_PROJ_CMD_CATALOG_LOADSET, "PROJ_CMD_CATALOG_LOADSET" },
{ STARTEAM_PROJ_CMD_CATALOG_LOADREGISTEREDCLASSES, "PROJ_CMD_CATALOG_LOADREGISTEREDCLASSES" },
{ STARTEAM_PROJ_CMD_REFRESH_CLASS_INFO, "PROJ_CMD_REFRESH_CLASS_INFO" },
{ STARTEAM_PROJ_CMD_ADD_CUSTOM_FIELD_CLASS_INFO, "PROJ_CMD_ADD_CUSTOM_FIELD_CLASS_INFO" },
{ STARTEAM_PROJ_CMD_MODIFY_FIELD_CLASS_INFO, "PROJ_CMD_MODIFY_FIELD_CLASS_INFO" },
{ STARTEAM_PROJ_CMD_ADD_CUSTOM_FIELD_CLASS_INFO_EX, "PROJ_CMD_ADD_CUSTOM_FIELD_CLASS_INFO_EX" },
{ STARTEAM_PROJ_CMD_GET_FOLDER_ITEMS, "PROJ_CMD_GET_FOLDER_ITEMS" },
/* { STARTEAM_SRVR_CMD_GET_USERS_AND_GROUPS, "SRVR_CMD_GET_USERS_AND_GROUPS" }, */
{ STARTEAM_PROJ_CMD_REFRESH_ITEMS, "PROJ_CMD_REFRESH_ITEMS" },
{ STARTEAM_PROJ_CMD_GET_ITEM, "PROJ_CMD_GET_ITEM" },
/* { STARTEAM_SRVR_CMD_GET_EMAIL_USERS, "SRVR_CMD_GET_EMAIL_USERS" }, */
{ STARTEAM_PROJ_CMD_UPDATE_ITEM, "PROJ_CMD_UPDATE_ITEM" },
{ STARTEAM_PROJ_CMD_DELETE_ITEM, "PROJ_CMD_DELETE_ITEM" },
{ STARTEAM_PROJ_CMD_SET_ITEM_LOCK, "PROJ_CMD_SET_ITEM_LOCK" },
{ STARTEAM_PROJ_CMD_DELETE_TREE_ITEM, "PROJ_CMD_DELETE_TREE_ITEM" },
{ STARTEAM_PROJ_CMD_GET_ITEM_HISTORY, "PROJ_CMD_GET_ITEM_HISTORY" },
{ STARTEAM_SRVR_CMD_GET_USER_PERSONAL_INFO, "SRVR_CMD_GET_USER_PERSONAL_INFO" },
{ STARTEAM_SRVR_CMD_SET_USER_PERSONAL_INFO, "SRVR_CMD_SET_USER_PERSONAL_INFO" },
{ STARTEAM_SRVR_CMD_SET_USER_PASSWORD, "SRVR_CMD_SET_USER_PASSWORD" },
{ STARTEAM_PROJ_CMD_MOVE_ITEMS, "PROJ_CMD_MOVE_ITEMS" },
{ STARTEAM_PROJ_CMD_MOVE_TREE_ITEMS, "PROJ_CMD_MOVE_TREE_ITEMS" },
/* { STARTEAM_SRVR_CMD_GET_GROUP_INFO, "SRVR_CMD_GET_GROUP_INFO" }, */
{ STARTEAM_PROJ_CMD_SHARE_ITEMS, "PROJ_CMD_SHARE_ITEMS" },
/* { STARTEAM_SRVR_CMD_ADD_EDIT_GROUP_INFO, "SRVR_CMD_ADD_EDIT_GROUP_INFO" }, */
{ STARTEAM_PROJ_CMD_SHARE_TREE_ITEMS, "PROJ_CMD_SHARE_TREE_ITEMS" },
/* { STARTEAM_SRVR_CMD_DROP_GROUP, "SRVR_CMD_DROP_GROUP" }, */
{ STARTEAM_SRVR_CMD_GET_USER_INFO, "SRVR_CMD_GET_USER_INFO" },
{ STARTEAM_SRVR_CMD_ADD_EDIT_USER_INFO, "SRVR_CMD_ADD_EDIT_USER_INFO" },
{ STARTEAM_SRVR_CMD_DROP_USER, "SRVR_CMD_DROP_USER" },
{ STARTEAM_SRVR_CMD_GET_MIN_PASSWORD_LENGTH, "SRVR_CMD_GET_MIN_PASSWORD_LENGTH" },
{ STARTEAM_SRVR_CMD_USER_ADMIN_OPERATION, "SRVR_CMD_USER_ADMIN_OPERATION" },
{ STARTEAM_SRVR_CMD_ACCESS_CHECK, "SRVR_CMD_ACCESS_CHECK" },
{ STARTEAM_PROJ_CMD_GET_COMMON_ANCESTOR_ITEM, "PROJ_CMD_GET_COMMON_ANCESTOR_ITEM" },
/* { STARTEAM_SRVR_CMD_ACCESS_TEST, "SRVR_CMD_ACCESS_TEST" }, */
{ STARTEAM_PROJ_CMD_UPDATE_REVISION_COMMENT, "PROJ_CMD_UPDATE_REVISION_COMMENT" },
/* { STARTEAM_SRVR_CMD_GET_MAIN_LOG_LAST64K, "SRVR_CMD_GET_MAIN_LOG_LAST64K" }, */
{ STARTEAM_SRVR_CMD_GET_SERVER_CONFIG, "SRVR_CMD_GET_SERVER_CONFIG" },
{ STARTEAM_SRVR_CMD_SET_SERVER_CONFIG, "SRVR_CMD_SET_SERVER_CONFIG" },
{ STARTEAM_SRVR_CMD_GET_SERVER_ACL, "SRVR_CMD_GET_SERVER_ACL" },
{ STARTEAM_SRVR_CMD_DROP_SERVER_ACL, "SRVR_CMD_DROP_SERVER_ACL" },
{ STARTEAM_SRVR_CMD_SET_SERVER_ACL, "SRVR_CMD_SET_SERVER_ACL" },
{ STARTEAM_SRVR_CMD_GET_SYSTEM_POLICY, "SRVR_CMD_GET_SYSTEM_POLICY" },
{ STARTEAM_SRVR_CMD_SET_SYSTEM_POLICY, "SRVR_CMD_SET_SYSTEM_POLICY" },
{ STARTEAM_SRVR_CMD_GET_SECURITY_LOG, "SRVR_CMD_GET_SECURITY_LOG" },
{ STARTEAM_SRVR_CMD_GET_SERVER_COMMAND_STATS, "SRVR_CMD_GET_SERVER_COMMAND_STATS" },
{ STARTEAM_SRVR_CMD_SET_SERVER_COMMAND_MODE, "SRVR_CMD_SET_SERVER_COMMAND_MODE" },
{ STARTEAM_SRVR_CMD_SHUTDOWN, "SRVR_CMD_SHUTDOWN" },
{ STARTEAM_SRVR_CMD_RESTART, "SRVR_CMD_RESTART" },
{ STARTEAM_SRVR_CMD_GET_SERVER_COMMAND_MODE, "SRVR_CMD_GET_SERVER_COMMAND_MODE" },
{ STARTEAM_SRVR_CMD_GET_LOG, "SRVR_CMD_GET_LOG" },
{ STARTEAM_SRVR_CMD_GET_COMPONENT_LIST, "SRVR_CMD_GET_COMPONENT_LIST" },
{ STARTEAM_SRVR_CMD_GET_GROUP_MEMBERS, "SRVR_CMD_GET_GROUP_MEMBERS" },
{ STARTEAM_PROJ_CMD_GET_ITEMS_VERSIONS, "PROJ_CMD_GET_ITEMS_VERSIONS" },
{ STARTEAM_SRVR_CMD_VALIDATE_VSS_INI_PATH, "SRVR_CMD_VALIDATE_VSS_INI_PATH" },
{ STARTEAM_SRVR_CMD_VALIDATE_PVCS_CFG_PATH, "SRVR_CMD_VALIDATE_PVCS_CFG_PATH" },
{ STARTEAM_SRVR_CMD_GET_VSS_PROJECT_TREE, "SRVR_CMD_GET_VSS_PROJECT_TREE" },
{ STARTEAM_SRVR_CMD_GET_ALL_PVCS_ARCHIVES, "SRVR_CMD_GET_ALL_PVCS_ARCHIVES" },
{ STARTEAM_SRVR_CMD_INITIALIZE_FOREIGN_ACCESS, "SRVR_CMD_INITIALIZE_FOREIGN_ACCESS" },
{ STARTEAM_SRVR_CMD_SET_FOREIGN_PROJECT_PW, "SRVR_CMD_SET_FOREIGN_PROJECT_PW" },
{ STARTEAM_PROJ_CMD_PING, "PROJ_CMD_PING" },
{ STARTEAM_PROJ_CMD_SET_LOCALE, "PROJ_CMD_SET_LOCALE" },
{ STARTEAM_PROJ_CMD_GET_CONTAINER_ACL, "PROJ_CMD_GET_CONTAINER_ACL" },
{ STARTEAM_PROJ_CMD_SET_CONTAINER_ACL, "PROJ_CMD_SET_CONTAINER_ACL" },
{ STARTEAM_PROJ_CMD_GET_CONTAINER_LEVEL_ACL, "PROJ_CMD_GET_CONTAINER_LEVEL_ACL" },
{ STARTEAM_PROJ_CMD_SET_CONTAINER_LEVEL_ACL, "PROJ_CMD_SET_CONTAINER_LEVEL_ACL" },
{ STARTEAM_PROJ_CMD_GET_OBJECT_ACL, "PROJ_CMD_GET_OBJECT_ACL" },
{ STARTEAM_PROJ_CMD_SET_OBJECT_ACL, "PROJ_CMD_SET_OBJECT_ACL" },
{ STARTEAM_PROJ_CMD_ITEM_ACCESS_CHECK, "PROJ_CMD_ITEM_ACCESS_CHECK" },
{ STARTEAM_PROJ_CMD_ITEM_ACCESS_TEST, "PROJ_CMD_ITEM_ACCESS_TEST" },
{ STARTEAM_PROJ_CMD_GET_OWNER, "PROJ_CMD_GET_OWNER" },
{ STARTEAM_PROJ_CMD_ACQUIRE_OWNERSHIP, "PROJ_CMD_ACQUIRE_OWNERSHIP" },
{ STARTEAM_PROJ_CMD_GET_FOLDERS, "PROJ_CMD_GET_FOLDERS" },
{ STARTEAM_PROJ_CMD_ADD_FOLDERS, "PROJ_CMD_ADD_FOLDERS" },
{ STARTEAM_PROJ_CMD_DELETE_FOLDER, "PROJ_CMD_DELETE_FOLDER" },
{ STARTEAM_PROJ_CMD_MOVE_FOLDER, "PROJ_CMD_MOVE_FOLDER" },
{ STARTEAM_PROJ_CMD_SHARE_FOLDER, "PROJ_CMD_SHARE_FOLDER" },
{ STARTEAM_PROJ_CMD_CONTAINER_ACCESS_CHECK, "PROJ_CMD_CONTAINER_ACCESS_CHECK" },
{ STARTEAM_PROJ_CMD_CONTAINER_ACCESS_TEST, "PROJ_CMD_CONTAINER_ACCESS_TEST" },
{ STARTEAM_PROJ_CMD_GET_OBJECT2_ACL, "PROJ_CMD_GET_OBJECT2_ACL" },
{ STARTEAM_PROJ_CMD_SET_OBJECT2_ACL, "PROJ_CMD_SET_OBJECT2_ACL" },
{ STARTEAM_PROJ_CMD_OBJECT_ACCESS_CHECK, "PROJ_CMD_OBJECT_ACCESS_CHECK" },
{ STARTEAM_PROJ_CMD_OBJECT_ACCESS_TEST, "PROJ_CMD_OBJECT_ACCESS_TEST" },
{ STARTEAM_PROJ_CMD_GET_OBJECT_OWNER, "PROJ_CMD_GET_OBJECT_OWNER" },
{ STARTEAM_PROJ_CMD_ACQUIRE_OBJECT_OWNERSHIP, "PROJ_CMD_ACQUIRE_OBJECT_OWNERSHIP" },
{ STARTEAM_PROJ_CMD_GET_FOLDER_PROPERTIES, "PROJ_CMD_GET_FOLDER_PROPERTIES" },
{ STARTEAM_PROJ_CMD_SET_FOLDER_PROPERTIES, "PROJ_CMD_SET_FOLDER_PROPERTIES" },
{ STARTEAM_PROJ_CMD_GET_ITEM_PROPERTIES, "PROJ_CMD_GET_ITEM_PROPERTIES" },
{ STARTEAM_PROJ_CMD_SET_ITEM_PROPERTIES, "PROJ_CMD_SET_ITEM_PROPERTIES" },
{ STARTEAM_PROJ_CMD_GET_ITEM_REFERENCES, "PROJ_CMD_GET_ITEM_REFERENCES" },
{ STARTEAM_PROJ_CMD_GET_ITEM_REFERENCE, "PROJ_CMD_GET_ITEM_REFERENCE" },
{ STARTEAM_PROJ_CMD_GET_ITEM_REVISIONS, "PROJ_CMD_GET_ITEM_REVISIONS" },
{ STARTEAM_PROJ_CMD_DELETE_PROJECT, "PROJ_CMD_DELETE_PROJECT" },
{ STARTEAM_PROJ_CMD_GET_PROJECT_PROPERTIES, "PROJ_CMD_GET_PROJECT_PROPERTIES" },
{ STARTEAM_PROJ_CMD_SET_PROJECT_PROPERTIES, "PROJ_CMD_SET_PROJECT_PROPERTIES" },
{ STARTEAM_PROJ_CMD_GET_VIEW_INFO, "PROJ_CMD_GET_VIEW_INFO" },
{ STARTEAM_PROJ_CMD_ADD_VIEW, "PROJ_CMD_ADD_VIEW" },
{ STARTEAM_PROJ_CMD_GET_VIEWS, "PROJ_CMD_GET_VIEWS" },
{ STARTEAM_PROJ_CMD_GET_VIEW_PROPERTIES, "PROJ_CMD_GET_VIEW_PROPERTIES" },
{ STARTEAM_PROJ_CMD_SET_VIEW_PROPERTIES, "PROJ_CMD_SET_VIEW_PROPERTIES" },
{ STARTEAM_PROJ_CMD_DELETE_VIEW, "PROJ_CMD_DELETE_VIEW" },
{ STARTEAM_PROJ_CMD_SWITCH_VIEW, "PROJ_CMD_SWITCH_VIEW" },
{ STARTEAM_PROJ_CMD_SWITCH_VIEW_CONFIG, "PROJ_CMD_SWITCH_VIEW_CONFIG" },
{ STARTEAM_PROJ_CMD_GET_FOLDER_PATH, "PROJ_CMD_GET_FOLDER_PATH" },
{ STARTEAM_FILE_CMD_CHECKOUT, "FILE_CMD_CHECKOUT" },
{ STARTEAM_FILE_CMD_GET_SYNC_INFO, "FILE_CMD_GET_SYNC_INFO" },
{ STARTEAM_FILE_CMD_DELETE_SYNC_INFO, "FILE_CMD_DELETE_SYNC_INFO" },
{ STARTEAM_FILE_CMD_GET_PATH_IDS, "FILE_CMD_GET_PATH_IDS" },
{ STARTEAM_FILE_CMD_SYNC_UPDATE_ALL_INFO, "FILE_CMD_SYNC_UPDATE_ALL_INFO" },
{ STARTEAM_FILE_CMD_RESYNC_FILE, "FILE_CMD_RESYNC_FILE" },
{ STARTEAM_FILE_CMD_CONVERT_ARCHIVE, "FILE_CMD_CONVERT_ARCHIVE" },
{ STARTEAM_FILE_CMD_ARCHIVE_CONVERSION, "FILE_CMD_ARCHIVE_CONVERSION" },
{ STARTEAM_FILE_CMD_READ_PVCS_ARCHIVES, "FILE_CMD_READ_PVCS_ARCHIVES" },
{ STARTEAM_FILE_CMD_ADD_PVCS_ARCHIVES, "FILE_CMD_ADD_PVCS_ARCHIVES" },
{ STARTEAM_FILE_CMD_ADD_PVCS_BRANCHES, "FILE_CMD_ADD_PVCS_BRANCHES" },
{ STARTEAM_FILE_CMD_FINISH_NEW_PVCS_PROJECT, "FILE_CMD_FINISH_NEW_PVCS_PROJECT" },
{ STARTEAM_FILE_CMD_GET_NUMBER_VSS_ARCHIVES, "FILE_CMD_GET_NUMBER_VSS_ARCHIVES" },
{ STARTEAM_FILE_CMD_READ_VSS_ARCHIVES, "FILE_CMD_READ_VSS_ARCHIVES" },
{ STARTEAM_FILE_CMD_ADD_VSS_ARCHIVE_TO_FOLDER, "FILE_CMD_ADD_VSS_ARCHIVE_TO_FOLDER" },
{ STARTEAM_FILE_CMD_FINISH_NEW_VSS_PROJECT, "FILE_CMD_FINISH_NEW_VSS_PROJECT" },
{ STARTEAM_FILE_CMD_REFRESH_FOREIGN_FOLDER, "FILE_CMD_REFRESH_FOREIGN_FOLDER" },
{ STARTEAM_FILE_CMD_START_GO_NATIVE, "FILE_CMD_START_GO_NATIVE" },
{ STARTEAM_FILE_CMD_GET_PROJECT_TYPE, "FILE_CMD_GET_PROJECT_TYPE" },
{ STARTEAM_FILE_CMD_SET_FOREIGN_PROJECT_PW, "FILE_CMD_SET_FOREIGN_PROJECT_PW" },
{ STARTEAM_FILE_CMD_INTERNAL_NESTED_COMMAND, "FILE_CMD_INTERNAL_NESTED_COMMAND" },
{ STARTEAM_PROJ_CMD_LABEL_GET_INFO, "PROJ_CMD_LABEL_GET_INFO" },
{ STARTEAM_PROJ_CMD_LABEL_GET_PROPERTIES, "PROJ_CMD_LABEL_GET_PROPERTIES" },
{ STARTEAM_PROJ_CMD_LABEL_SET_PROPERTIES, "PROJ_CMD_LABEL_SET_PROPERTIES" },
{ STARTEAM_PROJ_CMD_LABEL_CREATE, "PROJ_CMD_LABEL_CREATE" },
{ STARTEAM_PROJ_CMD_LABEL_DELETE, "PROJ_CMD_LABEL_DELETE" },
{ STARTEAM_PROJ_CMD_LABEL_ATTACH, "PROJ_CMD_LABEL_ATTACH" },
{ STARTEAM_PROJ_CMD_LABEL_MOVE, "PROJ_CMD_LABEL_MOVE" },
{ STARTEAM_PROJ_CMD_LABEL_DETACH, "PROJ_CMD_LABEL_DETACH" },
{ STARTEAM_PROJ_CMD_LABEL_GET_INFO_EX, "PROJ_CMD_LABEL_GET_INFO_EX" },
{ STARTEAM_PROJ_CMD_LABEL_CREATE_EX, "PROJ_CMD_LABEL_CREATE_EX" },
{ STARTEAM_PROJ_CMD_LABEL_ATTACH_EX, "PROJ_CMD_LABEL_ATTACH_EX" },
{ STARTEAM_PROJ_CMD_LABEL_ATTACH_ITEMS, "PROJ_CMD_LABEL_ATTACH_ITEMS" },
{ STARTEAM_PROJ_CMD_LABEL_DETACH_EX, "PROJ_CMD_LABEL_DETACH_EX" },
{ STARTEAM_PROJ_CMD_LABEL_DETACH_ITEMS, "PROJ_CMD_LABEL_DETACH_ITEMS" },
{ STARTEAM_PROJ_CMD_LABEL_GETITEMIDS, "PROJ_CMD_LABEL_GETITEMIDS" },
{ STARTEAM_PROJ_CMD_LINK_GET_INFO, "PROJ_CMD_LINK_GET_INFO" },
{ STARTEAM_PROJ_CMD_LINK_CREATE, "PROJ_CMD_LINK_CREATE" },
{ STARTEAM_PROJ_CMD_LINK_DELETE, "PROJ_CMD_LINK_DELETE" },
{ STARTEAM_PROJ_CMD_LINK_UPDATE_PROPERTIES, "PROJ_CMD_LINK_UPDATE_PROPERTIES" },
{ STARTEAM_PROJ_CMD_LINK_UPDATE_PINS, "PROJ_CMD_LINK_UPDATE_PINS" },
{ STARTEAM_PROJ_CMD_PROMOTION_GET, "PROJ_CMD_PROMOTION_GET" },
{ STARTEAM_PROJ_CMD_PROMOTION_SET, "PROJ_CMD_PROMOTION_SET" },
{ STARTEAM_TASK_CMD_GET_WORKRECS, "TASK_CMD_GET_WORKRECS" },
{ STARTEAM_TASK_CMD_ADD_WORKREC, "TASK_CMD_ADD_WORKREC" },
{ STARTEAM_TASK_CMD_UPDATE_WORKREC, "TASK_CMD_UPDATE_WORKREC" },
{ STARTEAM_TASK_CMD_DELETE_WORKREC, "TASK_CMD_DELETE_WORKREC" },
{ STARTEAM_TASK_CMD_DELETE_TASK_PREDECESSOR, "TASK_CMD_DELETE_TASK_PREDECESSOR" },
{ STARTEAM_TASK_CMD_GET_TASK_DEPENDENCIES, "TASK_CMD_GET_TASK_DEPENDENCIES" },
{ STARTEAM_TASK_CMD_ADD_TASK_PREDECESSOR, "TASK_CMD_ADD_TASK_PREDECESSOR" },
{ STARTEAM_TASK_CMD_UPDATE_TASK_PREDECESSOR, "TASK_CMD_UPDATE_TASK_PREDECESSOR" },
{ STARTEAM_PROJ_CMD_VIEW_COMPARE_GET_FOLDER_DETAILS, "PROJ_CMD_VIEW_COMPARE_GET_FOLDER_DETAILS" },
{ STARTEAM_PROJ_CMD_VIEW_COMPARE_RELATE_ITEMS, "PROJ_CMD_VIEW_COMPARE_RELATE_ITEMS" },
{ 0, NULL }
};
static value_string_ext starteam_opcode_vals_ext = VALUE_STRING_EXT_INIT(starteam_opcode_vals);
static gint iPreviousFrameNumber = -1;
static void
starteam_init(void)
{
iPreviousFrameNumber = -1;
}
static int
dissect_starteam(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
gint offset = 0;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "StarTeam");
/* This is a trick to know whether this is the first PDU in this packet or not */
if(iPreviousFrameNumber != (gint) pinfo->num){
col_clear(pinfo->cinfo, COL_INFO);
} else {
col_append_str(pinfo->cinfo, COL_INFO, " | ");
}
iPreviousFrameNumber = pinfo->num;
if(tvb_captured_length(tvb) >= 16){
guint32 iCommand = 0;
gboolean bRequest = FALSE;
if(tvb_get_ntohl(tvb, offset + 0) == STARTEAM_MAGIC){
/* This packet is a response */
bRequest = FALSE;
col_append_fstr(pinfo->cinfo, COL_INFO, "Reply: %d bytes", tvb_reported_length(tvb));
} else if(tvb_captured_length_remaining(tvb, offset) >= 28 && tvb_get_ntohl(tvb, offset + 20) == STARTEAM_MAGIC){
/* This packet is a request */
bRequest = TRUE;
if(tvb_captured_length_remaining(tvb, offset) >= 66){
iCommand = tvb_get_letohl(tvb, offset + 62);
}
col_append_str(pinfo->cinfo, COL_INFO,
val_to_str_ext(iCommand, &starteam_opcode_vals_ext, "Unknown (0x%02x)"));
}
if(tree){
proto_tree *starteam_tree;
proto_tree *starteamroot_tree;
proto_item *ti;
ti = proto_tree_add_item(tree, proto_starteam, tvb, offset, -1, ENC_NA);
if (bRequest) proto_item_append_text(ti, " (%s)",
val_to_str_ext(iCommand, &starteam_opcode_vals_ext, "Unknown (0x%02x)"));
starteamroot_tree = proto_item_add_subtree(ti, ett_starteam);
if(bRequest){
if(tvb_reported_length_remaining(tvb, offset) >= 20){
starteam_tree = proto_tree_add_subtree(starteamroot_tree, tvb, offset, 20, ett_starteam_mdh, NULL, STARTEAM_TEXT_MDH);
proto_tree_add_item(starteam_tree, hf_starteam_mdh_session_tag, tvb, offset + 0, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(starteam_tree, hf_starteam_mdh_ctimestamp, tvb, offset + 4, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(starteam_tree, hf_starteam_mdh_flags, tvb, offset + 8, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(starteam_tree, hf_starteam_mdh_keyid, tvb, offset + 12, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(starteam_tree, hf_starteam_mdh_reserved, tvb, offset + 16, 4, ENC_LITTLE_ENDIAN);
offset += 20;
}
}
if(tvb_reported_length_remaining(tvb, offset) >= 16){
starteam_tree = proto_tree_add_subtree(starteamroot_tree, tvb, offset, 16, ett_starteam_ph, NULL, STARTEAM_TEXT_PH);
proto_tree_add_item(starteam_tree, hf_starteam_ph_signature, tvb, offset + 0, 4, ENC_ASCII);
proto_tree_add_item(starteam_tree, hf_starteam_ph_packet_size, tvb, offset + 4, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(starteam_tree, hf_starteam_ph_data_size, tvb, offset + 8, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(starteam_tree, hf_starteam_ph_data_flags, tvb, offset + 12, 4, ENC_LITTLE_ENDIAN);
offset += 16;
if(bRequest){
if(tvb_reported_length_remaining(tvb, offset) >= 38){
starteam_tree = proto_tree_add_subtree(starteamroot_tree, tvb, offset, 38, ett_starteam_id, NULL, STARTEAM_TEXT_ID);
proto_tree_add_item(starteam_tree, hf_starteam_id_revision_level, tvb, offset + 0, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(starteam_tree, hf_starteam_id_client, tvb, offset + 2, 16, ENC_ASCII);
proto_tree_add_item(starteam_tree, hf_starteam_id_connect, tvb, offset + 18, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(starteam_tree, hf_starteam_id_component, tvb, offset + 22, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(starteam_tree, hf_starteam_id_command, tvb, offset + 26, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(starteam_tree, hf_starteam_id_command_time, tvb, offset + 30, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(starteam_tree, hf_starteam_id_command_userid, tvb, offset + 34, 4, ENC_LITTLE_ENDIAN);
offset += 38;
}
}
if(tvb_reported_length_remaining(tvb, offset) > 0){
starteam_tree = proto_tree_add_subtree(starteamroot_tree, tvb, offset, -1, ett_starteam_data, NULL, STARTEAM_TEXT_DATA);
proto_tree_add_item(starteam_tree, hf_starteam_data_data, tvb, offset, -1, ENC_ASCII);
}
}
}
}
return tvb_captured_length(tvb);
}
static guint
get_starteam_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb,
int offset, void *data _U_)
{
guint32 iPDULength = 0;
if(tvb_captured_length_remaining(tvb, offset) >= 8 && tvb_get_ntohl(tvb, offset + 0) == STARTEAM_MAGIC){
/* Response */
iPDULength = tvb_get_letohl(tvb, offset + 4) + 16;
} else if(tvb_captured_length_remaining(tvb, offset) >= 28 && tvb_get_ntohl(tvb, offset + 20) == STARTEAM_MAGIC){
/* Request */
iPDULength = tvb_get_letohl(tvb, offset + 24) + 36;
}
return iPDULength;
}
static int
dissect_starteam_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
tcp_dissect_pdus(tvb, pinfo, tree, starteam_desegment, 8, get_starteam_pdu_len, dissect_starteam, data);
return tvb_captured_length(tvb);
}
static gboolean
dissect_starteam_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
if(tvb_captured_length(tvb) >= 32){
gint iOffsetLengths = -1;
if(tvb_get_ntohl(tvb, 0) == STARTEAM_MAGIC){
iOffsetLengths = 4;
} else if(tvb_get_ntohl(tvb, 20) == STARTEAM_MAGIC){
iOffsetLengths = 24;
}
if(iOffsetLengths != -1){
guint32 iLengthPacket;
guint32 iLengthData;
iLengthPacket = tvb_get_letohl(tvb, iOffsetLengths);
iLengthData = tvb_get_letohl(tvb, iOffsetLengths + 4);
if(iLengthPacket == iLengthData){
/* Register this dissector for this conversation */
conversation_t *conversation = NULL;
conversation = find_or_create_conversation(pinfo);
conversation_set_dissector(conversation, starteam_tcp_handle);
/* Dissect the packet */
dissect_starteam(tvb, pinfo, tree, data);
return TRUE;
}
}
}
return FALSE;
}
void
proto_register_starteam(void)
{
static hf_register_info hf[] = {
{ &hf_starteam_mdh_session_tag,
{ "Session tag", "starteam.mdh.stag", FT_UINT32, BASE_DEC, NULL, 0x0, "MDH session tag", HFILL }},
{ &hf_starteam_mdh_ctimestamp,
{ "Client timestamp", "starteam.mdh.ctimestamp", FT_UINT32, BASE_DEC, NULL, 0x0, "MDH client timestamp", HFILL }},
{ &hf_starteam_mdh_flags,
{ "Flags", "starteam.mdh.flags", FT_UINT32, BASE_HEX, NULL, 0x0, "MDH flags", HFILL }},
{ &hf_starteam_mdh_keyid,
{ "Key ID", "starteam.mdh.keyid", FT_UINT32, BASE_HEX, NULL, 0x0, "MDH key ID", HFILL }},
{ &hf_starteam_mdh_reserved,
{ "Reserved", "starteam.mdh.reserved", FT_UINT32, BASE_HEX, NULL, 0x0, "MDH reserved", HFILL }},
{ &hf_starteam_ph_signature,
{ "Signature", "starteam.ph.signature", FT_STRINGZ, BASE_NONE, NULL, 0x0, "PH signature", HFILL }},
{ &hf_starteam_ph_packet_size,
{ "Packet size", "starteam.ph.psize", FT_UINT32, BASE_DEC, NULL, 0x0, "PH packet size", HFILL }},
{ &hf_starteam_ph_data_size,
{ "Data size", "starteam.ph.dsize", FT_UINT32, BASE_DEC, NULL, 0x0, "PH data size", HFILL }},
{ &hf_starteam_ph_data_flags,
{ "Flags", "starteam.ph.flags", FT_UINT32, BASE_HEX, NULL, 0x0, "PH flags", HFILL }},
{ &hf_starteam_id_revision_level,
{ "Revision level", "starteam.id.level", FT_UINT16, BASE_DEC, NULL, 0x0, "ID revision level", HFILL }},
{ &hf_starteam_id_client,
{ "Client ID", "starteam.id.client", FT_STRINGZ, BASE_NONE, NULL, 0x0, "ID client ID", HFILL }},
{ &hf_starteam_id_connect,
{ "Connect ID", "starteam.id.connect", FT_UINT32, BASE_HEX, NULL, 0x0, "ID connect ID", HFILL }},
{ &hf_starteam_id_component,
{ "Component ID", "starteam.id.component", FT_UINT32, BASE_DEC, NULL, 0x0, "ID component ID", HFILL }},
{ &hf_starteam_id_command,
{ "Command ID", "starteam.id.command", FT_UINT32, BASE_DEC|BASE_EXT_STRING, &starteam_opcode_vals_ext, 0x0, "ID command ID", HFILL }},
{ &hf_starteam_id_command_time,
{ "Command time", "starteam.id.commandtime", FT_UINT32, BASE_HEX, NULL, 0x0, "ID command time", HFILL }},
{ &hf_starteam_id_command_userid,
{ "Command user ID", "starteam.id.commanduserid", FT_UINT32, BASE_HEX, NULL, 0x0, "ID command user ID", HFILL }},
{ &hf_starteam_data_data,
{ "Data", "starteam.data", FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }}
};
static gint *ett[] = {
&ett_starteam,
&ett_starteam_mdh,
&ett_starteam_ph,
&ett_starteam_id,
&ett_starteam_data
};
module_t *starteam_module;
proto_starteam = proto_register_protocol("StarTeam", "StarTeam", "starteam");
proto_register_field_array(proto_starteam, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
starteam_module = prefs_register_protocol(proto_starteam, NULL);
prefs_register_bool_preference(starteam_module, "desegment",
"Reassemble StarTeam messages spanning multiple TCP segments",
"Whether the StarTeam dissector should reassemble messages spanning multiple TCP segments."
" To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
&starteam_desegment);
register_init_routine(&starteam_init);
}
void
proto_reg_handoff_starteam(void)
{
heur_dissector_add("tcp", dissect_starteam_heur, "StarTeam over TCP", "starteam_tcp", proto_starteam, HEURISTIC_ENABLE);
starteam_tcp_handle = create_dissector_handle(dissect_starteam_tcp, proto_starteam);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|
C
|
wireshark/epan/dissectors/packet-stat-notify.c
|
/* packet-stat.c
* Routines for async NSM stat callback dissection
* 2001 Ronnie Sahlberg <See AUTHORS for email>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include "packet-rpc.h"
#include "packet-stat-notify.h"
void proto_register_statnotify(void);
void proto_reg_handoff_statnotify(void);
static int proto_statnotify = -1;
static int hf_statnotify_procedure_v1 = -1;
static int hf_statnotify_name = -1;
static int hf_statnotify_state = -1;
static int hf_statnotify_priv = -1;
static gint ett_statnotify = -1;
static int
dissect_statnotify_mon(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
int offset = 0;
offset = dissect_rpc_string(tvb,tree,hf_statnotify_name,offset,NULL);
offset = dissect_rpc_uint32(tvb,tree,hf_statnotify_state,offset);
proto_tree_add_item(tree,hf_statnotify_priv,tvb,offset,16,ENC_NA);
offset += 16;
return offset;
}
/* proc number, "proc name", dissect_request, dissect_reply */
static const vsff statnotify1_proc[] = {
{ 0, "NULL",
dissect_rpc_void, dissect_rpc_void },
{ STATNOTIFYPROC_MON, "MON-CALLBACK",
dissect_statnotify_mon, dissect_rpc_void },
{ 0, NULL, NULL, NULL }
};
static const value_string statnotify1_proc_vals[] = {
{ 0, "NULL" },
{ STATNOTIFYPROC_MON, "MON-CALLBACK" },
{ 0, NULL }
};
/* end of stat-notify version 1 */
static const rpc_prog_vers_info statnotify_vers_info[] = {
{ 1, statnotify1_proc, &hf_statnotify_procedure_v1 },
};
void
proto_register_statnotify(void)
{
static hf_register_info hf[] = {
{ &hf_statnotify_procedure_v1, {
"V1 Procedure", "statnotify.procedure_v1", FT_UINT32, BASE_DEC,
VALS(statnotify1_proc_vals), 0, NULL, HFILL }},
{ &hf_statnotify_name, {
"Name", "statnotify.name", FT_STRING, BASE_NONE,
NULL, 0, "Name of client that changed", HFILL }},
{ &hf_statnotify_state, {
"State", "statnotify.state", FT_UINT32, BASE_DEC,
NULL, 0, "New state of client that changed", HFILL }},
{ &hf_statnotify_priv, {
"Priv", "statnotify.priv", FT_BYTES, BASE_NONE,
NULL, 0, "Client supplied opaque data", HFILL }},
};
static gint *ett[] = {
&ett_statnotify,
};
proto_statnotify = proto_register_protocol("Network Status Monitor CallBack Protocol", "STAT-CB", "statnotify");
proto_register_field_array(proto_statnotify, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_statnotify(void)
{
/* Register the protocol as RPC */
rpc_init_prog(proto_statnotify, STATNOTIFY_PROGRAM, ett_statnotify,
G_N_ELEMENTS(statnotify_vers_info), statnotify_vers_info);
}
/*
* Editor modelines - https://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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-stat-notify.h
|
/* packet-stat-notify.h
* Async callback to notify NSM servers of changes in client status
* 2001 Ronnie Sahlberg <See AUTHORS for email>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef PACKET_STAT_NOTIFY_H
#define PACKET_STAT_NOTIFY_H
#define STATNOTIFY_PROGRAM 200048
#define STATNOTIFYPROC_NULL 0
#define STATNOTIFYPROC_MON 1
#endif
|
C
|
wireshark/epan/dissectors/packet-stat.c
|
/* packet-stat.c
* Routines for stat dissection
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Copied from packet-smb.c
*
* 2001 Ronnie Sahlberg <See AUTHORS for email>
* Added the dissectors for STAT protocol
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include "packet-rpc.h"
#include "packet-stat.h"
void proto_register_stat(void);
void proto_reg_handoff_stat(void);
static const value_string stat1_proc_vals[] = {
{ 0, "NULL" },
{ STATPROC_STAT, "STAT" },
{ STATPROC_MON, "MON" },
{ STATPROC_UNMON, "UNMON" },
{ STATPROC_UNMON_ALL, "UNMON_ALL" },
{ STATPROC_SIMU_CRASH, "SIMU_CRASH" },
{ STATPROC_NOTIFY, "NOTIFY" },
{ 0, NULL }
};
static const value_string stat_res[] =
{
{ 0, "STAT_SUCC" },
{ 1, "STAT_FAIL" },
{ 0, NULL }
};
static int proto_stat = -1;
static int hf_stat_mon = -1;
static int hf_stat_mon_id_name = -1;
static int hf_stat_mon_name = -1;
static int hf_stat_my_id = -1;
static int hf_stat_my_id_hostname = -1;
static int hf_stat_my_id_proc = -1;
static int hf_stat_my_id_prog = -1;
static int hf_stat_my_id_vers = -1;
static int hf_stat_priv = -1;
static int hf_stat_procedure_v1 = -1;
static int hf_stat_stat_chge = -1;
static int hf_stat_stat_res = -1;
static int hf_stat_stat_res_res = -1;
static int hf_stat_stat_res_state = -1;
static int hf_stat_state = -1;
static gint ett_stat = -1;
static gint ett_stat_stat_res = -1;
static gint ett_stat_mon = -1;
static gint ett_stat_my_id = -1;
static gint ett_stat_stat_chge = -1;
#define STAT_SUCC 0
#define STAT_FAIL 1
/* Calculate length (including padding) of my_id structure.
* First read the length of the string and round it upwards to nearest
* multiple of 4, then add 16 (4*uint32)
*/
static int
my_id_len(tvbuff_t *tvb, int offset)
{
int len;
len = tvb_get_ntohl(tvb, offset);
if(len&0x03)
len = (len&0xfc)+4;
len += 16;
return len;
}
/* Calculate length (including padding) of my_id structure.
* First read the length of the string and round it upwards to nearest
* multiple of 4, then add 4 (string len) and size of my_id struct.
*/
static int
mon_id_len(tvbuff_t *tvb, int offset)
{
int len;
len = tvb_get_ntohl(tvb, offset);
if(len&0x03){
len = (len&0xfc)+4;
}
len += 4;
return len+my_id_len(tvb,offset+len);
}
static int
dissect_stat_stat(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
{
return dissect_rpc_string(tvb,tree,hf_stat_mon_name,0,NULL);
}
static int
dissect_stat_stat_res(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
{
proto_item *sub_item;
proto_tree *sub_tree;
gint32 res;
int offset = 0;
sub_item = proto_tree_add_item(tree, hf_stat_stat_res, tvb,
offset, -1, ENC_NA);
sub_tree = proto_item_add_subtree(sub_item, ett_stat_stat_res);
res = tvb_get_ntohl(tvb, offset);
offset = dissect_rpc_uint32(tvb,sub_tree,hf_stat_stat_res_res,offset);
if (res==STAT_SUCC) {
offset = dissect_rpc_uint32(tvb,sub_tree,hf_stat_stat_res_state,offset);
} else {
offset += 4;
}
return offset;
}
static int
dissect_stat_my_id(tvbuff_t *tvb, int offset, proto_tree *tree)
{
proto_item *sub_item;
proto_tree *sub_tree;
sub_item = proto_tree_add_item(tree, hf_stat_my_id, tvb,
offset, my_id_len(tvb,offset), ENC_NA);
sub_tree = proto_item_add_subtree(sub_item, ett_stat_my_id);
offset = dissect_rpc_string(tvb,sub_tree,hf_stat_my_id_hostname,offset,NULL);
offset = dissect_rpc_uint32(tvb,sub_tree,hf_stat_my_id_prog,offset);
offset = dissect_rpc_uint32(tvb,sub_tree,hf_stat_my_id_vers,offset);
offset = dissect_rpc_uint32(tvb,sub_tree,hf_stat_my_id_proc,offset);
return offset;
}
static int
dissect_stat_mon_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
{
proto_item *sub_item;
proto_tree *sub_tree;
int offset = 0;
sub_item = proto_tree_add_item(tree, hf_stat_mon, tvb,
offset, mon_id_len(tvb,offset), ENC_NA);
sub_tree = proto_item_add_subtree(sub_item, ett_stat_mon);
offset = dissect_rpc_string(tvb,sub_tree,hf_stat_mon_id_name,offset,NULL);
offset = dissect_stat_my_id(tvb,offset,sub_tree);
return offset;
}
static int
dissect_stat_priv(tvbuff_t *tvb, int offset, proto_tree *tree)
{
proto_tree_add_item(tree, hf_stat_priv, tvb, offset, 16, ENC_NA);
offset += 16;
return offset;
}
static int
dissect_stat_mon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
int offset = dissect_stat_mon_id(tvb,pinfo,tree,data);
offset = dissect_stat_priv(tvb,offset,tree);
return offset;
}
static int
dissect_stat_state(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
{
return dissect_rpc_uint32(tvb,tree,hf_stat_state,0);
}
static int
dissect_stat_notify(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
{
proto_item *sub_item;
proto_tree *sub_tree;
int offset = 0;
int start_offset = offset;
sub_item = proto_tree_add_item(tree, hf_stat_stat_chge, tvb,
offset, -1, ENC_NA);
sub_tree = proto_item_add_subtree(sub_item, ett_stat_stat_chge);
offset = dissect_rpc_string(tvb,sub_tree,hf_stat_mon_id_name,offset,NULL);
offset = dissect_rpc_uint32(tvb,tree,hf_stat_state,offset);
if(sub_item)
proto_item_set_len(sub_item, offset - start_offset);
return offset;
}
static int
dissect_stat_umon_all(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
{
return dissect_stat_my_id(tvb,0,tree);
}
/* proc number, "proc name", dissect_request, dissect_reply */
static const vsff stat1_proc[] = {
{ 0, "NULL",
dissect_rpc_void, dissect_rpc_void },
{ STATPROC_STAT, "STAT",
dissect_stat_stat, dissect_stat_stat_res },
{ STATPROC_MON, "MON",
dissect_stat_mon, dissect_stat_stat_res },
{ STATPROC_UNMON, "UNMON",
dissect_stat_mon_id, dissect_stat_state },
{ STATPROC_UNMON_ALL, "UNMON_ALL",
dissect_stat_umon_all, dissect_stat_state },
{ STATPROC_SIMU_CRASH, "SIMU_CRASH",
dissect_rpc_void, dissect_rpc_void },
{ STATPROC_NOTIFY, "NOTIFY",
dissect_stat_notify, dissect_rpc_void },
{ 0, NULL, NULL, NULL }
};
/* end of stat version 1 */
static const rpc_prog_vers_info stat_vers_info[] = {
{ 1, stat1_proc, &hf_stat_procedure_v1 },
};
void
proto_register_stat(void)
{
static hf_register_info hf[] = {
{ &hf_stat_procedure_v1,
{ "V1 Procedure", "stat.procedure_v1",
FT_UINT32, BASE_DEC, VALS(stat1_proc_vals), 0,
NULL, HFILL }
},
{ &hf_stat_mon_name,
{ "Name", "stat.name",
FT_STRING, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_stat_stat_res,
{ "Status Result", "stat.stat_res",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_stat_stat_res_res,
{ "Result", "stat.stat_res.res",
FT_UINT32, BASE_DEC, VALS(stat_res), 0,
NULL, HFILL }
},
{ &hf_stat_stat_res_state,
{ "State", "stat.stat_res.state",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_stat_state,
{ "State", "stat.state",
FT_UINT32, BASE_DEC, NULL, 0,
"State of local NSM", HFILL }
},
{ &hf_stat_mon,
{ "Monitor", "stat.mon",
FT_NONE, BASE_NONE, NULL, 0,
"Monitor Host", HFILL }
},
{ &hf_stat_mon_id_name,
{ "Monitor ID Name", "stat.mon_id.name",
FT_STRING, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_stat_my_id,
{ "My ID", "stat.my_id",
FT_NONE, BASE_NONE, NULL, 0,
"My_ID structure", HFILL }
},
{ &hf_stat_my_id_hostname,
{ "Hostname", "stat.my_id.hostname",
FT_STRING, BASE_NONE, NULL, 0,
"My_ID Host to callback", HFILL }
},
{ &hf_stat_my_id_prog,
{ "Program", "stat.my_id.prog",
FT_UINT32, BASE_DEC, NULL, 0,
"My_ID Program to callback", HFILL }
},
{ &hf_stat_my_id_vers,
{ "Version", "stat.my_id.vers",
FT_UINT32, BASE_DEC, NULL, 0,
"My_ID Version of callback", HFILL }
},
{ &hf_stat_my_id_proc,
{ "Procedure", "stat.my_id.proc",
FT_UINT32, BASE_DEC, NULL, 0,
"My_ID Procedure to callback", HFILL }
},
{ &hf_stat_priv,
{ "Priv", "stat.priv",
FT_BYTES, BASE_NONE, NULL, 0,
"Private client supplied opaque data", HFILL }
},
{ &hf_stat_stat_chge,
{ "Status Change", "stat.stat_chge",
FT_NONE, BASE_NONE, NULL, 0,
"Status Change structure", HFILL }
},
};
static gint *ett[] = {
&ett_stat,
&ett_stat_stat_res,
&ett_stat_mon,
&ett_stat_my_id,
&ett_stat_stat_chge,
};
proto_stat = proto_register_protocol("Network Status Monitor Protocol", "STAT", "stat");
proto_register_field_array(proto_stat, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_stat(void)
{
/* Register the protocol as RPC */
rpc_init_prog(proto_stat, STAT_PROGRAM, ett_stat,
G_N_ELEMENTS(stat_vers_info), stat_vers_info);
}
/*
* Editor modelines - https://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:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-stat.h
|
/* packet-stat.h
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef PACKET_STAT_H
#define PACKET_STAT_H
#define STAT_PROGRAM 100024
#define STATPROC_NULL 0
#define STATPROC_STAT 1
#define STATPROC_MON 2
#define STATPROC_UNMON 3
#define STATPROC_UNMON_ALL 4
#define STATPROC_SIMU_CRASH 5
#define STATPROC_NOTIFY 6
#endif
|
C
|
wireshark/epan/dissectors/packet-stcsig.c
|
/* packet-stcsig.c
* Routines for dissecting Spirent Test Center Signatures
* Copyright 2018 Joerg Mayer (see AUTHORS file)
* Based on disassembly of Spirent's modified version of Wireshark 1.10.3
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* The logic is based on the dissassembly of libwireshark.dll which was
* part of wireshark-win64-1.10.3-spirent-2.exe, distributed by Spirent
* to customers of their Spirent Test Center.
* As the installer displays the normal GPLv2+ license the choice was
* made to go with dissassembly instead of finding out who to ask for
* the source code.
*
* Please report errors or missing features when compared to the original.
*/
/* TODO:
* - Find out the meaning of the unknown trailer (perhaps some fcs or
* some prbseq related stuff?)
* - Find out meaning of prbseq
* - Is there a (fixed) structure in the csp field?
* - Validate the timestamp decoding: The seconds value is identical to
* Spirent's stcsig dissector, the ns value differs significantly
* - Find out what the TSLR really stands for - currently just a guess
*/
#include "config.h"
#include <epan/packet.h>
#include <tfs.h>
void proto_register_stcsig(void);
void proto_reg_handoff_stcsig(void);
#define PROTO_SHORT_NAME "STCSIG"
#define PROTO_LONG_NAME "Spirent Test Center Signature"
static int proto_stcsig = -1;
static int hf_stcsig_csp = -1;
static int hf_stcsig_iv = -1;
static int hf_stcsig_prbseq = -1;
static int hf_stcsig_rawdata = -1;
static int hf_stcsig_seqnum_complement = -1;
static int hf_stcsig_seqnum_edm = -1;
static int hf_stcsig_seqnum_sm = -1;
static int hf_stcsig_streamid = -1;
static int hf_stcsig_streamindex = -1;
static int hf_stcsig_streamtype = -1;
static int hf_stcsig_timestamp = -1;
static int hf_stcsig_tslr = -1;
static int hf_stcsig_unknown = -1;
static gint ett_stcsig = -1;
static gint ett_stcsig_streamid = -1;
static const true_false_string tfs_end_start = { "EndOfFrame", "StartOfFrame" };
static const true_false_string tfs_hard_soft = { "Hard", "Soft" };
/*
* For the last 20 bytes of the data section to be a Spirent Signature
* the fist byte (offset 0) plus the 11th byte (offset 10) of the deocded
* signature must add up to 255
*/
static gboolean
is_signature(tvbuff_t *tvb, gint sigoffset)
{
/*
* How to generate the table below:
*
* static guint8 runit = 1;
* for(int k=0; k<256; k++) {
* obfuscation_value = k;
* for(int i=1; i<=10; i++) {
* obfuscation_value = deobfuscate_this[obfuscation_value];
* }
* printf("0x%02x, ", obfuscation_value);
* if (k%8 == 7) printf("\n");
* }
*/
static const guint8 deobfuscate_offset_10[256] = {
0x00, 0x86, 0x0d, 0x8b, 0x9d, 0x1b, 0x90, 0x16,
0xbc, 0x3a, 0xb1, 0x37, 0x21, 0xa7, 0x2c, 0xaa,
0x78, 0xfe, 0x75, 0xf3, 0xe5, 0x63, 0xe8, 0x6e,
0xc4, 0x42, 0xc9, 0x4f, 0x59, 0xdf, 0x54, 0xd2,
0xf1, 0x77, 0xfc, 0x7a, 0x6c, 0xea, 0x61, 0xe7,
0x4d, 0xcb, 0x40, 0xc6, 0xd0, 0x56, 0xdd, 0x5b,
0x89, 0x0f, 0x84, 0x02, 0x14, 0x92, 0x19, 0x9f,
0x35, 0xb3, 0x38, 0xbe, 0xa8, 0x2e, 0xa5, 0x23,
0xe2, 0x64, 0xef, 0x69, 0x7f, 0xf9, 0x72, 0xf4,
0x5e, 0xd8, 0x53, 0xd5, 0xc3, 0x45, 0xce, 0x48,
0x9a, 0x1c, 0x97, 0x11, 0x07, 0x81, 0x0a, 0x8c,
0x26, 0xa0, 0x2b, 0xad, 0xbb, 0x3d, 0xb6, 0x30,
0x13, 0x95, 0x1e, 0x98, 0x8e, 0x08, 0x83, 0x05,
0xaf, 0x29, 0xa2, 0x24, 0x32, 0xb4, 0x3f, 0xb9,
0x6b, 0xed, 0x66, 0xe0, 0xf6, 0x70, 0xfb, 0x7d,
0xd7, 0x51, 0xda, 0x5c, 0x4a, 0xcc, 0x47, 0xc1,
0x43, 0xc5, 0x4e, 0xc8, 0xde, 0x58, 0xd3, 0x55,
0xff, 0x79, 0xf2, 0x74, 0x62, 0xe4, 0x6f, 0xe9,
0x3b, 0xbd, 0x36, 0xb0, 0xa6, 0x20, 0xab, 0x2d,
0x87, 0x01, 0x8a, 0x0c, 0x1a, 0x9c, 0x17, 0x91,
0xb2, 0x34, 0xbf, 0x39, 0x2f, 0xa9, 0x22, 0xa4,
0x0e, 0x88, 0x03, 0x85, 0x93, 0x15, 0x9e, 0x18,
0xca, 0x4c, 0xc7, 0x41, 0x57, 0xd1, 0x5a, 0xdc,
0x76, 0xf0, 0x7b, 0xfd, 0xeb, 0x6d, 0xe6, 0x60,
0xa1, 0x27, 0xac, 0x2a, 0x3c, 0xba, 0x31, 0xb7,
0x1d, 0x9b, 0x10, 0x96, 0x80, 0x06, 0x8d, 0x0b,
0xd9, 0x5f, 0xd4, 0x52, 0x44, 0xc2, 0x49, 0xcf,
0x65, 0xe3, 0x68, 0xee, 0xf8, 0x7e, 0xf5, 0x73,
0x50, 0xd6, 0x5d, 0xdb, 0xcd, 0x4b, 0xc0, 0x46,
0xec, 0x6a, 0xe1, 0x67, 0x71, 0xf7, 0x7c, 0xfa,
0x28, 0xae, 0x25, 0xa3, 0xb5, 0x33, 0xb8, 0x3e,
0x94, 0x12, 0x99, 0x1f, 0x09, 0x8f, 0x04, 0x82
};
guint8 byte0;
guint8 byte10;
/* Byte 0 also is the initialization vector for the obfuscation of offsets 1 - 15 */
byte0 = tvb_get_guint8(tvb, sigoffset);
byte10 = tvb_get_guint8(tvb, sigoffset + 10);
if (byte0 + (byte10 ^ deobfuscate_offset_10[byte0]) == 255) {
return TRUE;
} else {
return FALSE;
}
}
static void
decode_signature(guint8* decode_buffer)
{
static const guint8 deobfuscate_this[256] = {
0x00, 0x71, 0xe3, 0x92, 0xb6, 0xc7, 0x55, 0x24,
0x1c, 0x6d, 0xff, 0x8e, 0xaa, 0xdb, 0x49, 0x38,
0x39, 0x48, 0xda, 0xab, 0x8f, 0xfe, 0x6c, 0x1d,
0x25, 0x54, 0xc6, 0xb7, 0x93, 0xe2, 0x70, 0x01,
0x72, 0x03, 0x91, 0xe0, 0xc4, 0xb5, 0x27, 0x56,
0x6e, 0x1f, 0x8d, 0xfc, 0xd8, 0xa9, 0x3b, 0x4a,
0x4b, 0x3a, 0xa8, 0xd9, 0xfd, 0x8c, 0x1e, 0x6f,
0x57, 0x26, 0xb4, 0xc5, 0xe1, 0x90, 0x02, 0x73,
0xe4, 0x95, 0x07, 0x76, 0x52, 0x23, 0xb1, 0xc0,
0xf8, 0x89, 0x1b, 0x6a, 0x4e, 0x3f, 0xad, 0xdc,
0xdd, 0xac, 0x3e, 0x4f, 0x6b, 0x1a, 0x88, 0xf9,
0xc1, 0xb0, 0x22, 0x53, 0x77, 0x06, 0x94, 0xe5,
0x96, 0xe7, 0x75, 0x04, 0x20, 0x51, 0xc3, 0xb2,
0x8a, 0xfb, 0x69, 0x18, 0x3c, 0x4d, 0xdf, 0xae,
0xaf, 0xde, 0x4c, 0x3d, 0x19, 0x68, 0xfa, 0x8b,
0xb3, 0xc2, 0x50, 0x21, 0x05, 0x74, 0xe6, 0x97,
0xb8, 0xc9, 0x5b, 0x2a, 0x0e, 0x7f, 0xed, 0x9c,
0xa4, 0xd5, 0x47, 0x36, 0x12, 0x63, 0xf1, 0x80,
0x81, 0xf0, 0x62, 0x13, 0x37, 0x46, 0xd4, 0xa5,
0x9d, 0xec, 0x7e, 0x0f, 0x2b, 0x5a, 0xc8, 0xb9,
0xca, 0xbb, 0x29, 0x58, 0x7c, 0x0d, 0x9f, 0xee,
0xd6, 0xa7, 0x35, 0x44, 0x60, 0x11, 0x83, 0xf2,
0xf3, 0x82, 0x10, 0x61, 0x45, 0x34, 0xa6, 0xd7,
0xef, 0x9e, 0x0c, 0x7d, 0x59, 0x28, 0xba, 0xcb,
0x5c, 0x2d, 0xbf, 0xce, 0xea, 0x9b, 0x09, 0x78,
0x40, 0x31, 0xa3, 0xd2, 0xf6, 0x87, 0x15, 0x64,
0x65, 0x14, 0x86, 0xf7, 0xd3, 0xa2, 0x30, 0x41,
0x79, 0x08, 0x9a, 0xeb, 0xcf, 0xbe, 0x2c, 0x5d,
0x2e, 0x5f, 0xcd, 0xbc, 0x98, 0xe9, 0x7b, 0x0a,
0x32, 0x43, 0xd1, 0xa0, 0x84, 0xf5, 0x67, 0x16,
0x17, 0x66, 0xf4, 0x85, 0xa1, 0xd0, 0x42, 0x33,
0x0b, 0x7a, 0xe8, 0x99, 0xbd, 0xcc, 0x5e, 0x2f
};
guint8 obfuscation_value;
obfuscation_value = decode_buffer[0];
for(int i=1; i<16; i++) {
obfuscation_value = deobfuscate_this[obfuscation_value];
decode_buffer[i] ^= obfuscation_value;
}
/* decode_buffer[16...19] is unobfuscated */
}
static int
dissect_stcsig(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
gint bytes, length;
gint sig_offset;
tvbuff_t *stcsig_tvb;
proto_item *ti;
proto_tree *stcsig_tree;
proto_tree *stcsig_streamid_tree;
guint8 *real_stcsig;
guint64 timestamp_2_5_ns;
nstime_t timestamp;
length = tvb_captured_length(tvb);
if (length >= 21 && tvb_get_guint8(tvb, length - 21) == 0 && is_signature(tvb, length - 20)) {
bytes = 20;
} else if (length >= 25 && tvb_get_guint8(tvb, length - 25) == 0 && is_signature(tvb, length - 24)) {
/* Sigsize + 4 bytes FCS */
bytes = 24;
} else if (length >= 29 && tvb_get_guint8(tvb, length - 29) == 0 && is_signature(tvb, length - 28)) {
/* Sigsize + 8 bytes FCS, i.e. FibreChannel */
bytes = 28;
} else if (length >= 20 && is_signature(tvb, length - 20)) {
bytes = 20;
} else if (length >= 24 && is_signature(tvb, length - 24)) {
/* Sigsize + 4 bytes FCS */
bytes = 24;
} else if (length >= 28 && is_signature(tvb, length - 28)) {
/* Sigsize + 8 bytes FCS, i.e. FibreChannel */
bytes = 28;
} else {
return 0;
}
sig_offset = length - bytes;
#if 0
/* Maybe make this a preference */
col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_SHORT_NAME);
col_set_str(pinfo->cinfo, COL_INFO, PROTO_LONG_NAME);
#endif
real_stcsig = (guint8 *)tvb_memdup(pinfo->pool, tvb, sig_offset, 20);
decode_signature(real_stcsig);
stcsig_tvb = tvb_new_child_real_data(tvb, real_stcsig, 20, 20);
add_new_data_source(pinfo, stcsig_tvb, PROTO_LONG_NAME);
ti = proto_tree_add_item(tree, proto_stcsig, tvb, sig_offset, 20, ENC_NA);
stcsig_tree = proto_item_add_subtree(ti, ett_stcsig);
proto_tree_add_item(stcsig_tree, hf_stcsig_rawdata, tvb, sig_offset, 20, ENC_NA);
proto_tree_add_item(stcsig_tree, hf_stcsig_iv, stcsig_tvb, 0, 1, ENC_NA);
ti = proto_tree_add_item(stcsig_tree, hf_stcsig_streamid, stcsig_tvb, 1, 4, ENC_BIG_ENDIAN);
stcsig_streamid_tree = proto_item_add_subtree(ti, ett_stcsig_streamid);
/* This subtree is mostly an optical hierachy, auto expand it */
tree_expanded_set(ett_stcsig_streamid, TRUE);
proto_tree_add_item(stcsig_streamid_tree, hf_stcsig_csp, stcsig_tvb, 1, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(stcsig_streamid_tree, hf_stcsig_streamtype, stcsig_tvb, 3, 1, ENC_NA);
proto_tree_add_item(stcsig_streamid_tree, hf_stcsig_streamindex, stcsig_tvb, 3, 2, ENC_BIG_ENDIAN);
if (tvb_get_ntohs(stcsig_tvb, 5) + tvb_get_ntohs(stcsig_tvb, 7) == 0xffff) {
proto_tree_add_item(stcsig_tree, hf_stcsig_seqnum_complement, stcsig_tvb, 5, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(stcsig_tree, hf_stcsig_seqnum_edm, stcsig_tvb, 7, 4, ENC_BIG_ENDIAN);
} else {
proto_tree_add_item(stcsig_tree, hf_stcsig_seqnum_sm, stcsig_tvb, 5, 6, ENC_BIG_ENDIAN);
}
timestamp_2_5_ns = (guint64)(tvb_get_guint8(stcsig_tvb, 15) & 0xfc) << 30;
timestamp_2_5_ns |= tvb_get_ntohl(stcsig_tvb, 11);
timestamp.secs = (time_t)(timestamp_2_5_ns / 400000000L);
timestamp.nsecs = (int)(timestamp_2_5_ns % 400000000L);
proto_tree_add_time(stcsig_tree, hf_stcsig_timestamp, stcsig_tvb, 11, 5, ×tamp);
proto_tree_add_item(stcsig_tree, hf_stcsig_prbseq, stcsig_tvb, 15, 1, ENC_NA);
proto_tree_add_item(stcsig_tree, hf_stcsig_tslr, stcsig_tvb, 15, 1, ENC_NA);
proto_tree_add_item(stcsig_tree, hf_stcsig_unknown, stcsig_tvb, 16, 4, ENC_NA);
/* Ignored for post-dissectors but required by function type */
return length;
}
void
proto_register_stcsig(void)
{
static hf_register_info hf[] = {
{ &hf_stcsig_rawdata,
{ "Raw Data", "stcsig.rawdata",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_stcsig_iv,
{ "IV", "stcsig.iv",
FT_UINT8, BASE_HEX, NULL, 0x0,
"Deobfuscation Initialization Vector and Complement of Sequence Low Byte", HFILL }
},
{ &hf_stcsig_streamid,
{ "StreamID", "stcsig.streamid",
FT_INT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_stcsig_csp,
{ "ChassisSlotPort", "stcsig.csp",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_stcsig_seqnum_complement,
{ "Complement (EDM)", "stcsig.complement",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Complement of high bytes of Sequence Number", HFILL }
},
{ &hf_stcsig_seqnum_edm,
{ "Sequence Number (EDM)", "stcsig.seqnum",
FT_UINT32, BASE_DEC, NULL, 0x0,
"Sequence Number (Enhanced Detection Mode)", HFILL }
},
{ &hf_stcsig_seqnum_sm,
{ "Sequence Number (SM)", "stcsig.seqnum.sm",
FT_UINT48, BASE_DEC, NULL, 0x0,
"Sequence Number (Sequence Mode)", HFILL }
},
{ &hf_stcsig_streamindex,
{ "Stream Index", "stcsig.streamindex",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_stcsig_timestamp,
{ "Timestamp", "stcsig.timestamp",
FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_stcsig_prbseq,
{ "Pseudo-Random Binary Sequence", "stcsig.prbseq",
FT_BOOLEAN, 8, TFS(&tfs_true_false), 0x02,
NULL, HFILL }
},
{ &hf_stcsig_tslr,
{ "TSLR", "stcsig.tslr",
FT_BOOLEAN, 8, TFS(&tfs_end_start), 0x01,
"Time Stamp Location Reference", HFILL }
},
{ &hf_stcsig_streamtype,
{ "StreamType", "stcsig.streamtype",
FT_BOOLEAN, 8, TFS(&tfs_hard_soft), 0x80,
NULL, HFILL }
},
{ &hf_stcsig_unknown,
{ "Unknown", "stcsig.unknown",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Unknown Trailer (not obfuscated)", HFILL }
},
};
static gint *ett[] = {
&ett_stcsig,
&ett_stcsig_streamid
};
dissector_handle_t stcsig_handle;
proto_stcsig = proto_register_protocol(PROTO_LONG_NAME, PROTO_SHORT_NAME, "stcsig");
register_dissector("stcsig", dissect_stcsig, proto_stcsig);
proto_register_field_array(proto_stcsig, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
stcsig_handle = register_dissector(PROTO_SHORT_NAME, dissect_stcsig, proto_stcsig);
register_postdissector(stcsig_handle);
/* STCSIG is a rarely used case, disable it by default for performance reasons. */
proto_disable_by_default(proto_stcsig);
}
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-steam-ihs-discovery.c
|
/* packet-steam_ihs_discovery.c
* Routines for Steam In-Home Streaming Discovery Protocol dissection
* Copyright 2017, Jan Holthuis <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* Steam In-Home Streaming Discovery Protocol detects servers and negotiates
* connections to stream video games over the networks. It is used by
* Valve Software's Steam Client and Steam Link devices.
*
* Further Information:
* https://codingrange.com/blog/steam-in-home-streaming-discovery-protocol
* https://codingrange.com/blog/steam-in-home-streaming-control-protocol
*/
#include <config.h>
#include <epan/packet.h> /* Should be first Wireshark include (other than config.h) */
#include <epan/expert.h> /* Include only as needed */
#include <epan/prefs.h> /* Include only as needed */
/* Prototypes */
/* (Required to prevent [-Wmissing-prototypes] warnings */
void proto_reg_handoff_steam_ihs_discovery(void);
void proto_register_steam_ihs_discovery(void);
static int proto_steam_ihs_discovery = -1;
static int hf_steam_ihs_discovery_signature = -1;
static int hf_steam_ihs_discovery_header_length = -1;
static int hf_steam_ihs_discovery_header_clientid = -1;
static int hf_steam_ihs_discovery_header_msgtype = -1;
static int hf_steam_ihs_discovery_header_instanceid = -1;
static int hf_steam_ihs_discovery_body_length = -1;
static int hf_steam_ihs_discovery_body_discovery_seqnum = -1;
static int hf_steam_ihs_discovery_body_discovery_clientids = -1;
static int hf_steam_ihs_discovery_body_status_version = -1;
static int hf_steam_ihs_discovery_body_status_minversion = -1;
static int hf_steam_ihs_discovery_body_status_connectport = -1;
static int hf_steam_ihs_discovery_body_status_hostname = -1;
static int hf_steam_ihs_discovery_body_status_enabledservices = -1;
static int hf_steam_ihs_discovery_body_status_ostype = -1;
static int hf_steam_ihs_discovery_body_status_is64bit = -1;
static int hf_steam_ihs_discovery_body_status_euniverse = -1;
static int hf_steam_ihs_discovery_body_status_timestamp = -1;
static int hf_steam_ihs_discovery_body_status_screenlocked = -1;
static int hf_steam_ihs_discovery_body_status_gamesrunning = -1;
static int hf_steam_ihs_discovery_body_status_macaddresses = -1;
static int hf_steam_ihs_discovery_body_status_user_steamid = -1;
static int hf_steam_ihs_discovery_body_status_user_authkeyid = -1;
static int hf_steam_ihs_discovery_body_authrequest_devicetoken = -1;
static int hf_steam_ihs_discovery_body_authrequest_devicename = -1;
static int hf_steam_ihs_discovery_body_authrequest_encryptedrequest = -1;
static int hf_steam_ihs_discovery_body_authresponse_authresult = -1;
static int hf_steam_ihs_discovery_body_streamingrequest_requestid = -1;
static int hf_steam_ihs_discovery_body_streamingrequest_maximumresolutionx = -1;
static int hf_steam_ihs_discovery_body_streamingrequest_maximumresolutiony = -1;
static int hf_steam_ihs_discovery_body_streamingrequest_audiochannelcount = -1;
static int hf_steam_ihs_discovery_body_streamingrequest_deviceversion = -1;
static int hf_steam_ihs_discovery_body_streamingrequest_streamdesktop = -1;
static int hf_steam_ihs_discovery_body_streamingrequest_devicetoken = -1;
static int hf_steam_ihs_discovery_body_streamingrequest_pin = -1;
static int hf_steam_ihs_discovery_body_streamingrequest_enablevideostreaming = -1;
static int hf_steam_ihs_discovery_body_streamingrequest_enableaudiostreaming = -1;
static int hf_steam_ihs_discovery_body_streamingrequest_enableinputstreaming = -1;
static int hf_steam_ihs_discovery_body_streamingcancelrequest_requestid = -1;
static int hf_steam_ihs_discovery_body_streamingresponse_requestid = -1;
static int hf_steam_ihs_discovery_body_streamingresponse_result = -1;
static int hf_steam_ihs_discovery_body_streamingresponse_port = -1;
static int hf_steam_ihs_discovery_body_streamingresponse_encryptedsessionkey = -1;
static int hf_steam_ihs_discovery_body_streamingresponse_virtualherelicenseddevicecount = -1;
static int hf_steam_ihs_discovery_body_proofrequest_challenge = -1;
static int hf_steam_ihs_discovery_body_proofresponse_response = -1;
static int hf_steam_ihs_discovery_unknown_data = -1;
static int hf_steam_ihs_discovery_unknown_number = -1;
static const val64_string hf_steam_ihs_discovery_header_msgtype_strings[] = {
{ 0, "Client Discovery" },
{ 1, "Client Status" },
{ 2, "Client Offline" },
{ 3, "Device Authorization Request" },
{ 4, "Device Authorization Response" },
{ 5, "Device Streaming Request" },
{ 6, "Device Streaming Response" },
{ 7, "Device Proof Request" },
{ 8, "Device Proof Response" },
{ 9, "Device Authorization Cancel Request" },
{ 10, "Device Streaming Cancel Request" },
{ 0, NULL }
};
static const val64_string hf_steam_ihs_discovery_body_authresponse_authresult_strings[] = {
{ 0, "Success" },
{ 1, "Denied" },
{ 2, "Not Logged In" },
{ 3, "Offline" },
{ 4, "Busy" },
{ 5, "In Progress" },
{ 6, "TimedOut" },
{ 7, "Failed" },
{ 8, "Canceled" },
{ 0, NULL }
};
static const val64_string hf_steam_ihs_discovery_body_streamingresponse_result_strings[] = {
{ 0, "Success" },
{ 1, "Unauthorized" },
{ 2, "Screen Locked" },
{ 3, "Failed" },
{ 4, "Busy" },
{ 5, "In Progress" },
{ 6, "Canceled" },
{ 7, "Drivers Not Installed" },
{ 8, "Disabled" },
{ 9, "Broadcasting Active" },
{ 10, "VR Active" },
{ 11, "PIN Required" },
{ 0, NULL }
};
static expert_field ei_steam_ihs_discovery_unknown_data = EI_INIT;
static expert_field ei_steam_ihs_discovery_unknown_number = EI_INIT;
static expert_field ei_steam_ihs_discovery_unknown_lengthdelimited = EI_INIT;
static expert_field ei_steam_ihs_discovery_invalid_wiretype = EI_INIT;
static expert_field ei_steam_ihs_discovery_invalid_length = EI_INIT;
#define STEAM_IHS_DISCOVERY_UDP_PORT 27036
/* Initialize the subtree pointers */
static gint ett_steam_ihs_discovery = -1;
static gint ett_steam_ihs_discovery_body_status_user = -1;
#define STEAM_IHS_DISCOVERY_MIN_LENGTH 12
#define STEAM_IHS_DISCOVERY_SIGNATURE_LENGTH 8
#define STEAM_IHS_DISCOVERY_SIGNATURE_VALUE 0xFFFFFFFF214C5FA0
/* Helper functions and structs for reading Protocol Buffers.
*
* Detailed information about protobuf message encoding can be found at:
* https://developers.google.com/protocol-buffers/docs/encoding#structure
*/
#define PROTOBUF_WIRETYPE_VARINT 0
#define PROTOBUF_WIRETYPE_64BIT 1
#define PROTOBUF_WIRETYPE_LENGTHDELIMITED 2
#define PROTOBUF_WIRETYPE_32BIT 5
static const char * const protobuf_wiretype_names[] = {"VarInt", "64-bit", "Length-delimited", "Start group", "End group", "32-bit"};
static const char protobuf_wiretype_name_unknown[] = "Unknown";
static const char* protobuf_get_wiretype_name(guint8 wire_type) {
if (wire_type <= 5) {
return protobuf_wiretype_names[wire_type];
}
return protobuf_wiretype_name_unknown;
}
static gint64
get_varint64(tvbuff_t *tvb, gint offset, gint bytes_left, gint* len)
{
guint8 b;
gint64 result = 0;
*len = 0;
while ((*len) < bytes_left) {
b = tvb_get_guint8(tvb, offset+(*len));
result |= ((gint64)b & 0x7f) << ((*len)*7);
(*len)++;
if ((b & 0x80) == 0) {
break;
}
}
return result;
}
typedef struct {
tvbuff_t *tvb;
gint offset;
gint bytes_left;
} protobuf_desc_t;
typedef struct {
guint64 value;
guint64 field_number;
guint8 wire_type;
} protobuf_tag_t;
static void
protobuf_seek_forward(protobuf_desc_t* pb, gint len)
{
pb->offset += len;
pb->bytes_left -= len;
}
static gint
protobuf_iter_next(protobuf_desc_t* pb, protobuf_tag_t* tag)
{
gint len;
if (pb->bytes_left <= 0) {
return 0;
}
tag->value = get_varint64(pb->tvb, pb->offset, pb->bytes_left, &len);
tag->field_number = tag->value >> 3;
tag->wire_type = tag->value & 0x7;
protobuf_seek_forward(pb, len);
return pb->bytes_left;
}
static gint
protobuf_dissect_unknown_field(protobuf_desc_t *pb, protobuf_tag_t *tag, packet_info *pinfo, proto_tree *tree, proto_item** tiptr)
{
gint len;
gint64 value;
proto_item* ti;
switch(tag->wire_type) {
case PROTOBUF_WIRETYPE_VARINT:
value = get_varint64(pb->tvb, pb->offset, pb->bytes_left, &len);
ti = proto_tree_add_uint64(tree, hf_steam_ihs_discovery_unknown_number, pb->tvb,
pb->offset, len, (guint64)value);
expert_add_info_format(pinfo, ti, &ei_steam_ihs_discovery_unknown_number, "Unknown numeric protobuf field (wire type %d = %s)", tag->wire_type, protobuf_get_wiretype_name(tag->wire_type));
break;
case PROTOBUF_WIRETYPE_64BIT:
len = 8;
ti = proto_tree_add_item(tree, hf_steam_ihs_discovery_unknown_number, pb->tvb, pb->offset+len, len, ENC_LITTLE_ENDIAN);
expert_add_info_format(pinfo, ti, &ei_steam_ihs_discovery_unknown_number, "Unknown numeric protobuf field (wire type %d = %s)", tag->wire_type, protobuf_get_wiretype_name(tag->wire_type));
break;
case PROTOBUF_WIRETYPE_LENGTHDELIMITED:
value = get_varint64(pb->tvb, pb->offset, pb->bytes_left, &len);
if((guint64)value > (guint64)(pb->bytes_left-len)) {
ti = proto_tree_add_item(tree, hf_steam_ihs_discovery_unknown_data, pb->tvb, pb->offset+len, pb->bytes_left-len, ENC_NA);
expert_add_info_format(pinfo, ti, &ei_steam_ihs_discovery_invalid_length, "Length-delimited field %"PRIu64" has length prefix %"PRIu64", but buffer is only %d bytes long.", tag->field_number, (guint64)value, (pb->bytes_left-len));
len = pb->bytes_left;
} else {
ti = proto_tree_add_item(tree, hf_steam_ihs_discovery_unknown_data, pb->tvb, pb->offset+len, (gint)value, ENC_NA);
len += (gint)value;
}
expert_add_info(pinfo, ti, &ei_steam_ihs_discovery_unknown_lengthdelimited);
break;
case PROTOBUF_WIRETYPE_32BIT:
len = 4;
ti = proto_tree_add_item(tree, hf_steam_ihs_discovery_unknown_number, pb->tvb, pb->offset+len, len, ENC_LITTLE_ENDIAN);
expert_add_info_format(pinfo, ti, &ei_steam_ihs_discovery_unknown_number, "Unknown numeric protobuf field (wire type %d = %s)", tag->wire_type, protobuf_get_wiretype_name(tag->wire_type));
break;
default:
len = pb->bytes_left;
ti = proto_tree_add_item(tree, hf_steam_ihs_discovery_unknown_data, pb->tvb, pb->offset, len, ENC_NA);
expert_add_info(pinfo, ti, &ei_steam_ihs_discovery_unknown_data);
break;
}
if(tiptr != NULL) {
*tiptr = ti;
}
return len;
}
static gint
protobuf_verify_wiretype(protobuf_desc_t *pb, protobuf_tag_t *tag, packet_info *pinfo, proto_tree *tree, guint8 expected_wire_type)
{
gint len;
gint64 len_prefix;
proto_item *ti = NULL;
if(expected_wire_type == tag->wire_type) {
if(expected_wire_type == PROTOBUF_WIRETYPE_LENGTHDELIMITED) {
len_prefix = get_varint64(pb->tvb, pb->offset, pb->bytes_left, &len);
if(len_prefix < 0 || len_prefix > G_MAXINT) {
ti = proto_tree_add_item(tree, hf_steam_ihs_discovery_unknown_data, pb->tvb, pb->offset+len, pb->bytes_left-len, ENC_NA);
expert_add_info_format(pinfo, ti, &ei_steam_ihs_discovery_invalid_length, "Length-delimited field %"PRIu64" has length prefix %"PRId64" outside valid range (0 <= x <= G_MAXINT).", tag->field_number, len_prefix);
return pb->bytes_left;
} else if(((gint)len_prefix) > (pb->bytes_left-len)) {
ti = proto_tree_add_item(tree, hf_steam_ihs_discovery_unknown_data, pb->tvb, pb->offset+len, pb->bytes_left-len, ENC_NA);
expert_add_info_format(pinfo, ti, &ei_steam_ihs_discovery_invalid_length, "Length-delimited field %"PRIu64" has length prefix %"PRId64", but buffer is only %d bytes long.", tag->field_number, len_prefix, (pb->bytes_left-len));
return pb->bytes_left;
}
}
return 0;
}
len = protobuf_dissect_unknown_field(pb, tag, pinfo, tree, &ti);
expert_add_info_format(pinfo, ti, &ei_steam_ihs_discovery_invalid_wiretype, "Expected wiretype %d (%s) for field %"PRIu64", but got %d (%s) instead.", expected_wire_type, protobuf_get_wiretype_name(expected_wire_type), tag->field_number, tag->wire_type, protobuf_get_wiretype_name(tag->wire_type));
return len;
}
/* The actual protocol-specific stuff */
#define STEAMDISCOVER_FN_HEADER_CLIENTID 1
#define STEAMDISCOVER_FN_HEADER_MSGTYPE 2
#define STEAMDISCOVER_FN_HEADER_INSTANCEID 3
#define STEAMDISCOVER_FN_DISCOVERY_SEQNUM 1
#define STEAMDISCOVER_FN_DISCOVERY_CLIENTIDS 2
#define STEAMDISCOVER_FN_STATUS_VERSION 1
#define STEAMDISCOVER_FN_STATUS_MINVERSION 2
#define STEAMDISCOVER_FN_STATUS_CONNECTPORT 3
#define STEAMDISCOVER_FN_STATUS_HOSTNAME 4
#define STEAMDISCOVER_FN_STATUS_ENABLEDSERVICES 6
#define STEAMDISCOVER_FN_STATUS_OSTYPE 7
#define STEAMDISCOVER_FN_STATUS_IS64BIT 8
#define STEAMDISCOVER_FN_STATUS_USERS 9
#define STEAMDISCOVER_FN_STATUS_EUNIVERSE 11
#define STEAMDISCOVER_FN_STATUS_TIMESTAMP 12
#define STEAMDISCOVER_FN_STATUS_SCREENLOCKED 13
#define STEAMDISCOVER_FN_STATUS_GAMESRUNNING 14
#define STEAMDISCOVER_FN_STATUS_MACADDRESSES 15
#define STEAMDISCOVER_FN_STATUS_USER_STEAMID 1
#define STEAMDISCOVER_FN_STATUS_USER_AUTHKEYID 2
#define STEAMDISCOVER_FN_AUTHREQUEST_DEVICETOKEN 1
#define STEAMDISCOVER_FN_AUTHREQUEST_DEVICENAME 2
#define STEAMDISCOVER_FN_AUTHREQUEST_ENCRYPTEDREQUEST 3
#define STEAMDISCOVER_FN_AUTHRESPONSE_AUTHRESULT 1
#define STEAMDISCOVER_FN_STREAMINGREQUEST_REQUESTID 1
#define STEAMDISCOVER_FN_STREAMINGREQUEST_MAXIMUMRESOLUTIONX 2
#define STEAMDISCOVER_FN_STREAMINGREQUEST_MAXIMUMRESOLUTIONY 3
#define STEAMDISCOVER_FN_STREAMINGREQUEST_AUDIOCHANNELCOUNT 4
#define STEAMDISCOVER_FN_STREAMINGREQUEST_DEVICEVERSION 5
#define STEAMDISCOVER_FN_STREAMINGREQUEST_STREAMDESKTOP 6
#define STEAMDISCOVER_FN_STREAMINGREQUEST_DEVICETOKEN 7
#define STEAMDISCOVER_FN_STREAMINGREQUEST_PIN 8
#define STEAMDISCOVER_FN_STREAMINGREQUEST_ENABLEVIDEOSTREAMING 9
#define STEAMDISCOVER_FN_STREAMINGREQUEST_ENABLEAUDIOSTREAMING 10
#define STEAMDISCOVER_FN_STREAMINGREQUEST_ENABLEINPUTSTREAMING 11
#define STEAMDISCOVER_FN_STREAMINGCANCELREQUEST_REQUESTID 1
#define STEAMDISCOVER_FN_STREAMINGRESPONSE_REQUESTID 1
#define STEAMDISCOVER_FN_STREAMINGRESPONSE_RESULT 2
#define STEAMDISCOVER_FN_STREAMINGRESPONSE_PORT 3
#define STEAMDISCOVER_FN_STREAMINGRESPONSE_ENCRYPTEDSESSIONKEY 4
#define STEAMDISCOVER_FN_STREAMINGRESPONSE_VIRTUALHERELICENSEDDEVICECOUNT 5
#define STEAMDISCOVER_FN_PROOFREQUEST_CHALLENGE 1
#define STEAMDISCOVER_FN_PROOFRESPONSE_RESPONSE 1
#define STEAMDISCOVER_MSGTYPE_CLIENTBROADCASTMSGDISCOVERY 0
#define STEAMDISCOVER_MSGTYPE_CLIENTBROADCASTMSGSTATUS 1
#define STEAMDISCOVER_MSGTYPE_CLIENTBROADCASTMSGOFFLINE 2
#define STEAMDISCOVER_MSGTYPE_DEVICEAUTHORIZATIONREQUEST 3
#define STEAMDISCOVER_MSGTYPE_DEVICEAUTHORIZATIONRESPONSE 4
#define STEAMDISCOVER_MSGTYPE_DEVICESTREAMINGREQUEST 5
#define STEAMDISCOVER_MSGTYPE_DEVICESTREAMINGRESPONSE 6
#define STEAMDISCOVER_MSGTYPE_DEVICEPROOFREQUEST 7
#define STEAMDISCOVER_MSGTYPE_DEVICEPROOFRESPONSE 8
#define STEAMDISCOVER_MSGTYPE_DEVICEAUTHORIZATIONCANCELREQUEST 9
#define STEAMDISCOVER_MSGTYPE_DEVICESTREAMINGCANCELREQUEST 10
#define STEAMDISCOVER_MSGTYPES_MAX 10
#define STEAMDISCOVER_ENSURE_WIRETYPE(X) if((len = protobuf_verify_wiretype(&pb, &tag, pinfo, tree, X))) break;
/* Dissect the header section of a packet. The header is a
* CMsgRemoteClientBroadcastHeader protobuf message.
*
* enum ERemoteClientBroadcastMsg {
* k_ERemoteClientBroadcastMsgDiscovery = 0;
* k_ERemoteClientBroadcastMsgStatus = 1;
* k_ERemoteClientBroadcastMsgOffline = 2;
* k_ERemoteDeviceAuthorizationRequest = 3;
* k_ERemoteDeviceAuthorizationResponse = 4;
* k_ERemoteDeviceStreamingRequest = 5;
* k_ERemoteDeviceStreamingResponse = 6;
* k_ERemoteDeviceProofRequest = 7;
* k_ERemoteDeviceProofResponse = 8;
* k_ERemoteDeviceAuthorizationCancelRequest = 9;
* k_ERemoteDeviceStreamingCancelRequest = 10;
* }
*
* message CMsgRemoteClientBroadcastHeader {
* optional uint64 client_id = 1;
* optional ERemoteClientBroadcastMsg msg_type = 2;
* optional uint64 instance_id = 3;
* }
*/
static gint64
steamdiscover_dissect_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gint offset, gint bytes_left)
{
gint len;
gint64 value;
gint64 msg_type = -1;
protobuf_desc_t pb = { tvb, offset, bytes_left };
protobuf_tag_t tag = { 0, 0, 0 };
while (protobuf_iter_next(&pb, &tag)) {
switch(tag.field_number) {
case STEAMDISCOVER_FN_HEADER_CLIENTID:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_uint64(tree, hf_steam_ihs_discovery_header_clientid, pb.tvb,
pb.offset, len, (guint64)value);
break;
case STEAMDISCOVER_FN_HEADER_MSGTYPE:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
msg_type = value;
proto_tree_add_uint64(tree, hf_steam_ihs_discovery_header_msgtype, pb.tvb,
pb.offset, len, (guint64)value);
break;
case STEAMDISCOVER_FN_HEADER_INSTANCEID:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_uint64(tree, hf_steam_ihs_discovery_header_instanceid, pb.tvb,
pb.offset, len, (guint64)value);
break;
default:
len = protobuf_dissect_unknown_field(&pb, &tag, pinfo, tree, NULL);
break;
}
protobuf_seek_forward(&pb, len);
}
return msg_type;
}
/* Dissect a CMsgRemoteClientBroadcastDiscovery protobuf message body.
*
* message CMsgRemoteClientBroadcastDiscovery {
* optional uint32 seq_num = 1;
* repeated uint64 client_ids = 2;
* }
*/
static void
steamdiscover_dissect_body_discovery(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gint offset, gint bytes_left)
{
gint len;
gint64 value;
protobuf_desc_t pb = { tvb, offset, bytes_left };
protobuf_tag_t tag = { 0, 0, 0 };
while (protobuf_iter_next(&pb, &tag)) {
switch(tag.field_number) {
case STEAMDISCOVER_FN_DISCOVERY_SEQNUM:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_uint(tree, hf_steam_ihs_discovery_body_discovery_seqnum, pb.tvb,
pb.offset, len, (guint32)value);
col_append_fstr(pinfo->cinfo, COL_INFO, " Seq=%"PRIu32, (guint32)value);
break;
case STEAMDISCOVER_FN_DISCOVERY_CLIENTIDS:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_uint64(tree, hf_steam_ihs_discovery_body_discovery_clientids, pb.tvb,
pb.offset, len, value);
break;
default:
len = protobuf_dissect_unknown_field(&pb, &tag, pinfo, tree, NULL);
break;
}
protobuf_seek_forward(&pb, len);
}
}
/* Dissect a CMsgRemoteClientBroadcastStatus protobuf message body.
*
* message CMsgRemoteClientBroadcastStatus {
* message User {
* optional fixed64 steamid = 1;
* optional uint32 auth_key_id = 2;
* }
* optional int32 version = 1;
* optional int32 min_version = 2;
* optional uint32 connect_port = 3;
* optional string hostname = 4;
* optional uint32 enabled_services = 6;
* optional int32 ostype = 7 [default = 0];
* optional bool is64bit = 8 [default = false];
* repeated CMsgRemoteClientBroadcastStatus.User users = 9;
* optional int32 euniverse = 11;
* optional uint32 timestamp = 12;
* optional bool screen_locked = 13;
* optional bool games_running = 14;
* repeated string mac_addresses = 15;
* optional uint32 download_lan_peer_group = 16;
* optional bool broadcasting_active = 17;
* optional bool vr_active = 18;
* }
*/
static void
steamdiscover_dissect_body_status(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gint offset, gint bytes_left)
{
gint64 value;
gint len;
gint len2;
protobuf_desc_t pb = { tvb, offset, bytes_left };
protobuf_desc_t pb2 = { tvb, 0, 0 };
protobuf_tag_t tag = { 0, 0, 0 };
guint8 *hostname;
nstime_t timestamp;
proto_tree *user_tree;
proto_item *user_it;
while (protobuf_iter_next(&pb, &tag)) {
switch(tag.field_number) {
case STEAMDISCOVER_FN_STATUS_VERSION:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_int(tree, hf_steam_ihs_discovery_body_status_version, pb.tvb,
pb.offset, len, (gint32)value);
break;
case STEAMDISCOVER_FN_STATUS_MINVERSION:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_int(tree, hf_steam_ihs_discovery_body_status_minversion, pb.tvb,
pb.offset, len, (gint32)value);
break;
case STEAMDISCOVER_FN_STATUS_CONNECTPORT:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_uint(tree, hf_steam_ihs_discovery_body_status_connectport, pb.tvb,
pb.offset, len, (guint32)value);
break;
case STEAMDISCOVER_FN_STATUS_HOSTNAME:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_LENGTHDELIMITED);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_item(tree, hf_steam_ihs_discovery_body_status_hostname, pb.tvb,
pb.offset+len, (gint)value, ENC_UTF_8);
hostname = tvb_get_string_enc(pinfo->pool, pb.tvb, pb.offset+len, (gint)value, ENC_UTF_8);
if(hostname && strlen(hostname)) {
col_add_fstr(pinfo->cinfo, COL_INFO, "%s from %s", hf_steam_ihs_discovery_header_msgtype_strings[STEAMDISCOVER_MSGTYPE_CLIENTBROADCASTMSGSTATUS].strptr, hostname);
}
len += (gint)value;
break;
case STEAMDISCOVER_FN_STATUS_ENABLEDSERVICES:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_uint(tree, hf_steam_ihs_discovery_body_status_enabledservices, pb.tvb,
pb.offset, len, (guint32)value);
break;
case STEAMDISCOVER_FN_STATUS_OSTYPE:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_int(tree, hf_steam_ihs_discovery_body_status_ostype, pb.tvb,
pb.offset, len, (gint32)value);
break;
case STEAMDISCOVER_FN_STATUS_IS64BIT:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_boolean(tree, hf_steam_ihs_discovery_body_status_is64bit, pb.tvb,
pb.offset, len, (gint32)value);
break;
case STEAMDISCOVER_FN_STATUS_USERS:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_LENGTHDELIMITED);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
pb2.offset = pb.offset+len;
pb2.bytes_left = (gint)value;
len += (gint)value;
user_tree = proto_tree_add_subtree(tree, pb.tvb, pb.offset, len, ett_steam_ihs_discovery_body_status_user, &user_it, "User");
while (protobuf_iter_next(&pb2, &tag)) {
switch(tag.field_number) {
case STEAMDISCOVER_FN_STATUS_USER_STEAMID:
if((len2 = protobuf_verify_wiretype(&pb2, &tag, pinfo, user_tree, PROTOBUF_WIRETYPE_64BIT))) break;
len2 = 8;
value = tvb_get_letoh64(pb2.tvb, pb2.offset);
proto_tree_add_uint64(user_tree, hf_steam_ihs_discovery_body_status_user_steamid, pb2.tvb,
pb2.offset, len2, (guint64)value);
proto_item_append_text(user_it, ", Steam ID: %"PRIu64, (guint64)value);
break;
case STEAMDISCOVER_FN_STATUS_USER_AUTHKEYID:
if((len2 = protobuf_verify_wiretype(&pb2, &tag, pinfo, user_tree, PROTOBUF_WIRETYPE_VARINT))) break;
value = get_varint64(pb2.tvb, pb2.offset, pb2.bytes_left, &len2);
proto_tree_add_uint(user_tree, hf_steam_ihs_discovery_body_status_user_authkeyid, pb2.tvb,
pb2.offset, len2, (guint32)value);
proto_item_append_text(user_it, ", Auth Key ID: %"PRIu32, (guint32)value);
break;
default:
len2 = protobuf_dissect_unknown_field(&pb2, &tag, pinfo, tree, NULL);
break;
}
protobuf_seek_forward(&pb2, len2);
}
break;
case STEAMDISCOVER_FN_STATUS_EUNIVERSE:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_int(tree, hf_steam_ihs_discovery_body_status_euniverse, pb.tvb,
pb.offset, len, (gint32)value);
break;
case STEAMDISCOVER_FN_STATUS_TIMESTAMP:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
timestamp.secs = (time_t)get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
timestamp.nsecs = 0;
proto_tree_add_time(tree, hf_steam_ihs_discovery_body_status_timestamp, pb.tvb,
pb.offset, len, ×tamp);
break;
case STEAMDISCOVER_FN_STATUS_SCREENLOCKED:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_boolean(tree, hf_steam_ihs_discovery_body_status_screenlocked, pb.tvb,
pb.offset, len, (gint32)value);
break;
case STEAMDISCOVER_FN_STATUS_GAMESRUNNING:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_boolean(tree, hf_steam_ihs_discovery_body_status_gamesrunning, pb.tvb,
pb.offset, len, (gint32)value);
break;
case STEAMDISCOVER_FN_STATUS_MACADDRESSES:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_LENGTHDELIMITED);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_item(tree, hf_steam_ihs_discovery_body_status_macaddresses, pb.tvb,
pb.offset+len, (gint)value, ENC_UTF_8);
len += (gint)value;
break;
default:
len = protobuf_dissect_unknown_field(&pb, &tag, pinfo, tree, NULL);
break;
}
protobuf_seek_forward(&pb, len);
}
}
/* Dissect a CMsgRemoteDeviceAuthorizationRequest protobuf message body.
*
* message CMsgRemoteDeviceAuthorizationRequest {
* message CKeyEscrow_Ticket {
* optional bytes password = 1;
* optional uint64 identifier = 2;
* optional bytes payload = 3;
* optional uint32 timestamp = 4;
* optional CMsgRemoteDeviceAuthorizationRequest.EKeyEscrowUsage usage = 5;
* optional string device_name = 6;
* optional string device_model = 7;
* optional string device_serial = 8;
* optional uint32 device_provisioning_id = 9;
* }
* enum EKeyEscrowUsage {
* k_EKeyEscrowUsageStreamingDevice = 0;
* }
* required bytes device_token = 1;
* optional string device_name = 2;
* required bytes encrypted_request = 3;
* }
*/
static void
steamdiscover_dissect_body_authrequest(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gint offset, gint bytes_left)
{
guint len;
gint64 value;
protobuf_desc_t pb = { tvb, offset, bytes_left };
protobuf_tag_t tag = { 0, 0, 0 };
guint8* devicename;
while (protobuf_iter_next(&pb, &tag)) {
switch(tag.field_number) {
case STEAMDISCOVER_FN_AUTHREQUEST_DEVICETOKEN:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_LENGTHDELIMITED);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_item(tree, hf_steam_ihs_discovery_body_authrequest_devicetoken, pb.tvb,
pb.offset+len, (gint)value, ENC_NA);
len += (gint)value;
break;
case STEAMDISCOVER_FN_AUTHREQUEST_DEVICENAME:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_LENGTHDELIMITED);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_item(tree, hf_steam_ihs_discovery_body_authrequest_devicename, pb.tvb,
pb.offset+len, (gint)value, ENC_UTF_8);
devicename = tvb_get_string_enc(pinfo->pool, pb.tvb, pb.offset+len, (gint)value, ENC_UTF_8);
if (devicename && strlen(devicename)) {
col_append_fstr(pinfo->cinfo, COL_INFO, " from %s", devicename);
}
len += (gint)value;
break;
case STEAMDISCOVER_FN_AUTHREQUEST_ENCRYPTEDREQUEST:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_LENGTHDELIMITED);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_item(tree, hf_steam_ihs_discovery_body_authrequest_encryptedrequest, pb.tvb,
pb.offset+len, (gint)value, ENC_NA);
len += (gint)value;
break;
default:
len = protobuf_dissect_unknown_field(&pb, &tag, pinfo, tree, NULL);
break;
}
protobuf_seek_forward(&pb, len);
}
}
/* Dissect a CMsgRemoteDeviceAuthorizationResponse protobuf message body.
*
* message CMsgRemoteDeviceAuthorizationResponse {
* required ERemoteDeviceAuthorizationResult result = 1;
* }
*/
static void
steamdiscover_dissect_body_authresponse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gint offset, gint bytes_left)
{
gint len;
gint64 value;
protobuf_desc_t pb = { tvb, offset, bytes_left };
protobuf_tag_t tag = { 0, 0, 0 };
while (protobuf_iter_next(&pb, &tag)) {
switch(tag.field_number) {
case STEAMDISCOVER_FN_AUTHRESPONSE_AUTHRESULT:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_uint64(tree, hf_steam_ihs_discovery_body_authresponse_authresult, pb.tvb,
pb.offset, len, (guint64)value);
col_add_fstr(pinfo->cinfo, COL_INFO, "%s Result=%"PRIu64"(%s)", hf_steam_ihs_discovery_header_msgtype_strings[STEAMDISCOVER_MSGTYPE_DEVICEAUTHORIZATIONRESPONSE].strptr,
(guint64)value, val64_to_str_const((guint64)value, hf_steam_ihs_discovery_body_authresponse_authresult_strings, "Unknown"));
break;
default:
len = protobuf_dissect_unknown_field(&pb, &tag, pinfo, tree, NULL);
break;
}
protobuf_seek_forward(&pb, len);
}
}
/* Dissect a CMsgRemoteDeviceStreamingRequest protobuf message body.
*
* message CMsgRemoteDeviceStreamingRequest {
* required uint32 request_id = 1;
* optional int32 maximum_resolution_x = 2;
* optional int32 maximum_resolution_y = 3;
* optional int32 audio_channel_count = 4 [default = 2];
* optional string device_version = 5;
* optional bool stream_desktop = 6;
* optional bytes device_token = 7;
* optional bytes pin = 8;
* optional bool enable_video_streaming = 9 [default = true];
* optional bool enable_audio_streaming = 10 [default = true];
* optional bool enable_input_streaming = 11 [default = true];
* }
*/
static void
steamdiscover_dissect_body_streamingrequest(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gint offset, gint bytes_left)
{
gint len;
gint64 value;
protobuf_desc_t pb = { tvb, offset, bytes_left };
protobuf_tag_t tag = { 0, 0, 0 };
while (protobuf_iter_next(&pb, &tag)) {
switch(tag.field_number) {
case STEAMDISCOVER_FN_STREAMINGREQUEST_REQUESTID:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_uint(tree, hf_steam_ihs_discovery_body_streamingrequest_requestid, pb.tvb,
pb.offset, len, (guint32)value);
col_add_fstr(pinfo->cinfo, COL_INFO, "%s ID=%08x", hf_steam_ihs_discovery_header_msgtype_strings[STEAMDISCOVER_MSGTYPE_DEVICESTREAMINGREQUEST].strptr, (guint32)value);
break;
case STEAMDISCOVER_FN_STREAMINGREQUEST_MAXIMUMRESOLUTIONX:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_int(tree, hf_steam_ihs_discovery_body_streamingrequest_maximumresolutionx, pb.tvb,
pb.offset, len, (gint32)value);
break;
case STEAMDISCOVER_FN_STREAMINGREQUEST_MAXIMUMRESOLUTIONY:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_int(tree, hf_steam_ihs_discovery_body_streamingrequest_maximumresolutiony, pb.tvb,
pb.offset, len, (gint32)value);
break;
case STEAMDISCOVER_FN_STREAMINGREQUEST_AUDIOCHANNELCOUNT:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_int(tree, hf_steam_ihs_discovery_body_streamingrequest_audiochannelcount, pb.tvb,
pb.offset, len, (gint32)value);
break;
case STEAMDISCOVER_FN_STREAMINGREQUEST_DEVICEVERSION:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_LENGTHDELIMITED);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_item(tree, hf_steam_ihs_discovery_body_streamingrequest_deviceversion, pb.tvb, pb.offset+len, (gint)value, ENC_UTF_8);
len += (gint)value;
break;
case STEAMDISCOVER_FN_STREAMINGREQUEST_STREAMDESKTOP:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_boolean(tree, hf_steam_ihs_discovery_body_streamingrequest_streamdesktop, pb.tvb,
pb.offset, len, (gint32)value);
break;
case STEAMDISCOVER_FN_STREAMINGREQUEST_DEVICETOKEN:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_LENGTHDELIMITED);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_item(tree, hf_steam_ihs_discovery_body_streamingrequest_devicetoken, pb.tvb, pb.offset+len, (gint)value, ENC_NA);
len += (gint)value;
break;
case STEAMDISCOVER_FN_STREAMINGREQUEST_PIN:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_LENGTHDELIMITED);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_item(tree, hf_steam_ihs_discovery_body_streamingrequest_pin, pb.tvb, pb.offset+len, (gint)value, ENC_NA);
len += (gint)value;
break;
case STEAMDISCOVER_FN_STREAMINGREQUEST_ENABLEVIDEOSTREAMING:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_boolean(tree, hf_steam_ihs_discovery_body_streamingrequest_enablevideostreaming, pb.tvb,
pb.offset, len, (gint32)value);
break;
case STEAMDISCOVER_FN_STREAMINGREQUEST_ENABLEAUDIOSTREAMING:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_boolean(tree, hf_steam_ihs_discovery_body_streamingrequest_enableaudiostreaming, pb.tvb,
pb.offset, len, (gint32)value);
break;
case STEAMDISCOVER_FN_STREAMINGREQUEST_ENABLEINPUTSTREAMING:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_boolean(tree, hf_steam_ihs_discovery_body_streamingrequest_enableinputstreaming, pb.tvb,
pb.offset, len, (gint32)value);
break;
default:
len = protobuf_dissect_unknown_field(&pb, &tag, pinfo, tree, NULL);
break;
}
protobuf_seek_forward(&pb, len);
}
}
/* Dissect a CMsgRemoteDeviceStreamingCancelRequest protobuf message body.
*
* message CMsgRemoteDeviceStreamingCancelRequest {
* required uint32 request_id = 1;
* }
*/
static void
steamdiscover_dissect_body_streamingcancelrequest(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gint offset, gint bytes_left)
{
guint len;
gint64 value;
protobuf_desc_t pb = { tvb, offset, bytes_left };
protobuf_tag_t tag = { 0, 0, 0 };
while (protobuf_iter_next(&pb, &tag)) {
switch(tag.field_number) {
case STEAMDISCOVER_FN_STREAMINGCANCELREQUEST_REQUESTID:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_uint(tree, hf_steam_ihs_discovery_body_streamingcancelrequest_requestid, pb.tvb,
pb.offset, len, (guint32)value);
col_add_fstr(pinfo->cinfo, COL_INFO, "%s, ID=%08x", hf_steam_ihs_discovery_header_msgtype_strings[STEAMDISCOVER_MSGTYPE_DEVICESTREAMINGCANCELREQUEST].strptr, (guint32)value);
break;
default:
len = protobuf_dissect_unknown_field(&pb, &tag, pinfo, tree, NULL);
break;
}
protobuf_seek_forward(&pb, len);
}
}
/* Dissect a CMsgRemoteDeviceStreamingResponse protobuf message body.
*
* enum ERemoteDeviceStreamingResult {
* k_ERemoteDeviceStreamingSuccess = 0;
* k_ERemoteDeviceStreamingUnauthorized = 1;
* k_ERemoteDeviceStreamingScreenLocked = 2;
* k_ERemoteDeviceStreamingFailed = 3;
* k_ERemoteDeviceStreamingBusy = 4;
* k_ERemoteDeviceStreamingInProgress = 5;
* k_ERemoteDeviceStreamingCanceled = 6;
* k_ERemoteDeviceStreamingDriversNotInstalled = 7;
* k_ERemoteDeviceStreamingDisabled = 8;
* k_ERemoteDeviceStreamingBroadcastingActive = 9;
* k_ERemoteDeviceStreamingVRActive = 10;
* k_ERemoteDeviceStreamingPINRequired = 11;
* }
*
* message CMsgRemoteDeviceStreamingResponse {
* required uint32 request_id = 1;
* required ERemoteDeviceStreamingResult result = 2;
* optional uint32 port = 3;
* optional bytes encrypted_session_key = 4;
* optional int32 virtualhere_licensed_device_count_OBSOLETE = 5;
* }
*/
static void
steamdiscover_dissect_body_streamingresponse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gint offset, gint bytes_left)
{
guint len;
gint64 value;
protobuf_desc_t pb = { tvb, offset, bytes_left };
protobuf_tag_t tag = { 0, 0, 0 };
while (protobuf_iter_next(&pb, &tag)) {
switch(tag.field_number) {
case STEAMDISCOVER_FN_STREAMINGRESPONSE_REQUESTID:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_uint(tree, hf_steam_ihs_discovery_body_streamingresponse_requestid, pb.tvb,
pb.offset, len, (guint32)value);
col_append_fstr(pinfo->cinfo, COL_INFO, " ID=%08x", (guint32)value);
break;
case STEAMDISCOVER_FN_STREAMINGRESPONSE_RESULT:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_uint64(tree, hf_steam_ihs_discovery_body_streamingresponse_result, pb.tvb,
pb.offset, len, (guint64)value);
col_append_fstr(pinfo->cinfo, COL_INFO, " Result=%"PRIu64"(%s)", (guint64)value, val64_to_str_const((guint64)value, hf_steam_ihs_discovery_body_streamingresponse_result_strings, "Unknown"));
break;
case STEAMDISCOVER_FN_STREAMINGRESPONSE_PORT:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_uint(tree, hf_steam_ihs_discovery_body_streamingresponse_port, pb.tvb,
pb.offset, len, (guint32)value);
col_append_fstr(pinfo->cinfo, COL_INFO, " Port=%"PRIu32, (guint32)value);
break;
case STEAMDISCOVER_FN_STREAMINGRESPONSE_ENCRYPTEDSESSIONKEY:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_LENGTHDELIMITED);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_item(tree, hf_steam_ihs_discovery_body_streamingresponse_encryptedsessionkey, pb.tvb, pb.offset+len, (gint)value, ENC_NA);
len += (gint)value;
break;
case STEAMDISCOVER_FN_STREAMINGRESPONSE_VIRTUALHERELICENSEDDEVICECOUNT:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_VARINT);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_int(tree, hf_steam_ihs_discovery_body_streamingresponse_virtualherelicenseddevicecount, pb.tvb,
pb.offset, len, (gint32)value);
break;
default:
len = protobuf_dissect_unknown_field(&pb, &tag, pinfo, tree, NULL);
break;
}
protobuf_seek_forward(&pb, len);
}
}
/* Dissect a CMsgRemoteDeviceProofRequest protobuf message body.
*
* message CMsgRemoteDeviceProofRequest {
* required bytes challenge = 1;
* }
*/
static void
steamdiscover_dissect_body_proofrequest(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gint offset, gint bytes_left)
{
gint len;
gint64 value;
protobuf_desc_t pb = { tvb, offset, bytes_left };
protobuf_tag_t tag = { 0, 0, 0 };
while (protobuf_iter_next(&pb, &tag)) {
switch(tag.field_number) {
case STEAMDISCOVER_FN_PROOFREQUEST_CHALLENGE:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_LENGTHDELIMITED);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_item(tree, hf_steam_ihs_discovery_body_proofrequest_challenge, pb.tvb, pb.offset+len, (gint)value, ENC_NA);
len += (gint)value;
break;
default:
len = protobuf_dissect_unknown_field(&pb, &tag, pinfo, tree, NULL);
break;
}
protobuf_seek_forward(&pb, len);
}
}
/* Dissect a CMsgRemoteDeviceProofResponse protobuf message body.
*
* message CMsgRemoteDeviceProofResponse {
* required bytes response = 1;
* }
*/
static void
steamdiscover_dissect_body_proofresponse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gint offset, gint bytes_left)
{
gint len;
gint64 value;
protobuf_desc_t pb = { tvb, offset, bytes_left };
protobuf_tag_t tag = { 0, 0, 0 };
while (protobuf_iter_next(&pb, &tag)) {
switch(tag.field_number) {
case STEAMDISCOVER_FN_PROOFRESPONSE_RESPONSE:
STEAMDISCOVER_ENSURE_WIRETYPE(PROTOBUF_WIRETYPE_LENGTHDELIMITED);
value = get_varint64(pb.tvb, pb.offset, pb.bytes_left, &len);
proto_tree_add_item(tree, hf_steam_ihs_discovery_body_proofresponse_response, pb.tvb, pb.offset+len, (gint)value, ENC_NA);
len += (gint)value;
break;
default:
len = protobuf_dissect_unknown_field(&pb, &tag, pinfo, tree, NULL);
break;
}
protobuf_seek_forward(&pb, len);
}
}
static void
steamdiscover_dissect_body_unknown(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gint offset, gint bytes_left)
{
gint len;
protobuf_desc_t pb = { tvb, offset, bytes_left };
protobuf_tag_t tag = { 0, 0, 0 };
while (protobuf_iter_next(&pb, &tag)) {
len = protobuf_dissect_unknown_field(&pb, &tag, pinfo, tree, NULL);
protobuf_seek_forward(&pb, len);
}
}
/* Code to actually dissect the packets */
static int
dissect_steam_ihs_discovery(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data _U_)
{
/* Set up structures needed to add the protocol subtree and manage it */
proto_item *ti;
proto_tree *steam_ihs_discovery_tree;
/* Other misc. local variables. */
gint offset = 0;
gint header_length = 0;
gint body_length = 0;
gint total_length = 0;
gint64 msg_type;
/* Check that the packet is long enough for it to belong to us. */
if (tvb_reported_length(tvb) < STEAM_IHS_DISCOVERY_MIN_LENGTH)
return 0;
if (tvb_captured_length(tvb) < STEAM_IHS_DISCOVERY_MIN_LENGTH)
return 0;
/* Check if packet starts with the 8 byte signature value. */
if (tvb_get_ntoh64(tvb, 0) != STEAM_IHS_DISCOVERY_SIGNATURE_VALUE)
return 0;
/* Parse header and body lengths.
*
* A packet looks like this:
* 1. Signature Value (8 bytes)
* 2. Header length (4 bytes)
* 3. Header
* 4. Body length (4 bytes)
* 6. Body
* */
header_length = tvb_get_letohl(tvb, STEAM_IHS_DISCOVERY_SIGNATURE_LENGTH);
body_length = tvb_get_letohl(tvb, STEAM_IHS_DISCOVERY_SIGNATURE_LENGTH + 4 + header_length);
total_length = STEAM_IHS_DISCOVERY_SIGNATURE_LENGTH + 4 + header_length + 4 + body_length;
/* Check if expected and captured packet length are equal. */
if (tvb_reported_length(tvb) != (guint)total_length)
return 0;
if (tvb_captured_length(tvb) != (guint)total_length)
return 0;
/* Set the Protocol column to the constant string of steam_ihs_discovery */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "STEAMDISCOVER");
col_clear(pinfo->cinfo, COL_INFO);
/* create display subtree for the protocol */
ti = proto_tree_add_item(tree, proto_steam_ihs_discovery, tvb, 0, -1, ENC_NA);
steam_ihs_discovery_tree = proto_item_add_subtree(ti, ett_steam_ihs_discovery);
proto_tree_add_item(steam_ihs_discovery_tree, hf_steam_ihs_discovery_signature, tvb,
offset, STEAM_IHS_DISCOVERY_SIGNATURE_LENGTH, ENC_LITTLE_ENDIAN);
offset += STEAM_IHS_DISCOVERY_SIGNATURE_LENGTH;
proto_tree_add_item(steam_ihs_discovery_tree, hf_steam_ihs_discovery_header_length, tvb,
offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
msg_type = steamdiscover_dissect_header(tvb, pinfo, steam_ihs_discovery_tree, offset, header_length);
if ((0 <= msg_type) && (msg_type <= STEAMDISCOVER_MSGTYPES_MAX)) {
col_set_str(pinfo->cinfo, COL_INFO, hf_steam_ihs_discovery_header_msgtype_strings[msg_type].strptr);
} else {
col_set_str(pinfo->cinfo, COL_INFO, "Unknown Message");
}
offset += header_length;
proto_tree_add_item(steam_ihs_discovery_tree, hf_steam_ihs_discovery_body_length, tvb,
offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
switch(msg_type)
{
case STEAMDISCOVER_MSGTYPE_CLIENTBROADCASTMSGDISCOVERY:
steamdiscover_dissect_body_discovery(tvb, pinfo, steam_ihs_discovery_tree, offset, body_length);
break;
case STEAMDISCOVER_MSGTYPE_CLIENTBROADCASTMSGSTATUS:
steamdiscover_dissect_body_status(tvb, pinfo, steam_ihs_discovery_tree, offset, body_length);
break;
case STEAMDISCOVER_MSGTYPE_CLIENTBROADCASTMSGOFFLINE:
/* Message seems to have no body */
break;
case STEAMDISCOVER_MSGTYPE_DEVICEAUTHORIZATIONREQUEST:
steamdiscover_dissect_body_authrequest(tvb, pinfo, steam_ihs_discovery_tree, offset, body_length);
break;
case STEAMDISCOVER_MSGTYPE_DEVICEAUTHORIZATIONCANCELREQUEST:
/* Message seems to have no body */
break;
case STEAMDISCOVER_MSGTYPE_DEVICEAUTHORIZATIONRESPONSE:
steamdiscover_dissect_body_authresponse(tvb, pinfo, steam_ihs_discovery_tree, offset, body_length);
break;
case STEAMDISCOVER_MSGTYPE_DEVICESTREAMINGREQUEST:
steamdiscover_dissect_body_streamingrequest(tvb, pinfo, steam_ihs_discovery_tree, offset, body_length);
break;
case STEAMDISCOVER_MSGTYPE_DEVICESTREAMINGCANCELREQUEST:
steamdiscover_dissect_body_streamingcancelrequest(tvb, pinfo, steam_ihs_discovery_tree, offset, body_length);
break;
case STEAMDISCOVER_MSGTYPE_DEVICESTREAMINGRESPONSE:
steamdiscover_dissect_body_streamingresponse(tvb, pinfo, steam_ihs_discovery_tree, offset, body_length);
break;
case STEAMDISCOVER_MSGTYPE_DEVICEPROOFREQUEST:
steamdiscover_dissect_body_proofrequest(tvb, pinfo, steam_ihs_discovery_tree, offset, body_length);
break;
case STEAMDISCOVER_MSGTYPE_DEVICEPROOFRESPONSE:
steamdiscover_dissect_body_proofresponse(tvb, pinfo, steam_ihs_discovery_tree, offset, body_length);
break;
default:
steamdiscover_dissect_body_unknown(tvb, pinfo, steam_ihs_discovery_tree, offset, body_length);
break;
}
return tvb_captured_length(tvb);
}
/* Register the protocol with Wireshark. */
void
proto_register_steam_ihs_discovery(void)
{
expert_module_t *expert_steam_ihs_discovery;
static hf_register_info hf[] = {
/* Non-protobuf header fields */
{ &hf_steam_ihs_discovery_signature,
{ "Signature", "steam_ihs_discovery.signature",
FT_UINT64, BASE_HEX, NULL, 0,
"Every packet of the Steam In-Home Streaming Discovery Protocol begins with this signature.", HFILL }
},
{ &hf_steam_ihs_discovery_header_length,
{ "Header Length", "steam_ihs_discovery.header_length",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_length,
{ "Body Length", "steam_ihs_discovery.body_length",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_unknown_data,
{ "Unknown Data", "steam_ihs_discovery.unknown_data",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_unknown_number,
{ "Unknown Number", "steam_ihs_discovery.unknown_number",
FT_UINT64, BASE_DEC_HEX, NULL, 0,
NULL, HFILL }
},
/* CMsgRemoteClientBroadcastHeader */
{ &hf_steam_ihs_discovery_header_clientid,
{ "Client ID", "steam_ihs_discovery.header_client_id",
FT_UINT64, BASE_DEC_HEX, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_header_msgtype,
{ "Message Type", "steam_ihs_discovery.header_msg_type",
FT_UINT64, BASE_DEC|BASE_VAL64_STRING, VALS64(hf_steam_ihs_discovery_header_msgtype_strings), 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_header_instanceid,
{ "Instance ID", "steam_ihs_discovery.header_instance_id",
FT_UINT64, BASE_DEC_HEX, NULL, 0,
NULL, HFILL }
},
/* CMsgRemoteClientBroadcastDiscovery message */
{ &hf_steam_ihs_discovery_body_discovery_seqnum,
{ "Sequence Number", "steam_ihs_discovery.body_discovery_seqnum",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_discovery_clientids,
{ "Client IDs", "steam_ihs_discovery.body_discovery_clientids",
FT_UINT64, BASE_HEX, NULL, 0,
NULL, HFILL }
},
/* CMsgRemoteClientBroadcastStatus message */
{ &hf_steam_ihs_discovery_body_status_version,
{ "Version", "steam_ihs_discovery.body_status_version",
FT_INT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_status_minversion,
{ "Minimum Version", "steam_ihs_discovery.body_status_minversion",
FT_INT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_status_connectport,
{ "Connect Port", "steam_ihs_discovery.body_status_connectport",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_status_hostname,
{ "Hostname", "steam_ihs_discovery.body_status_hostname",
FT_STRING, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_status_enabledservices,
{ "Enabled Services", "steam_ihs_discovery.body_status_enabledservices",
FT_UINT32, BASE_HEX, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_status_ostype,
{ "OS Type", "steam_ihs_discovery.body_status_ostype",
FT_INT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_status_is64bit,
{ "Is 64 Bit", "steam_ihs_discovery.body_status_is64bit",
FT_BOOLEAN, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_status_euniverse,
{ "EUniverse", "steam_ihs_discovery.body_status_euniverse",
FT_INT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_status_timestamp,
{ "Timestamp", "steam_ihs_discovery.body_status_timestamp",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_status_screenlocked,
{ "Screen Locked", "steam_ihs_discovery.body_status_screenlocked",
FT_BOOLEAN, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_status_gamesrunning,
{ "Games Running", "steam_ihs_discovery.body_status_gamesrunning",
FT_BOOLEAN, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_status_macaddresses,
{ "MAC Addresses", "steam_ihs_discovery.body_status_macaddresses",
FT_STRING, BASE_NONE, NULL, 0,
NULL, HFILL }
},
/* CMsgRemoteClientBroadcastStatus.User */
{ &hf_steam_ihs_discovery_body_status_user_steamid,
{ "Steam ID", "steam_ihs_discovery.body_status_user_steamid",
FT_UINT64, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_status_user_authkeyid,
{ "Auth Key ID", "steam_ihs_discovery.body_status_user_authkeyid",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
/* CMsgRemoteDeviceAuthorizationRequest */
{ &hf_steam_ihs_discovery_body_authrequest_devicetoken,
{ "Device Token", "steam_ihs_discovery.body_authrequest_devicetoken",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_authrequest_devicename,
{ "Device Name", "steam_ihs_discovery.body_authrequest_devicename",
FT_STRING, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_authrequest_encryptedrequest,
{ "Encrypted Request", "steam_ihs_discovery.body_authrequest_encryptedrequest",
FT_BYTES, BASE_NO_DISPLAY_VALUE, NULL, 0,
NULL, HFILL }
},
/* CMsgRemoteDeviceAuthorizationResponse */
{ &hf_steam_ihs_discovery_body_authresponse_authresult,
{ "Result", "steam_ihs_discovery.body_authresponse_authresult",
FT_UINT64, BASE_DEC|BASE_VAL64_STRING, VALS64(hf_steam_ihs_discovery_body_authresponse_authresult_strings), 0,
NULL, HFILL }
},
/* CMsgRemoteDeviceStreamingRequest */
{ &hf_steam_ihs_discovery_body_streamingrequest_requestid,
{ "Request ID", "steam_ihs_discovery.body_streamingrequest_requestid",
FT_UINT32, BASE_HEX, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_streamingrequest_maximumresolutionx,
{ "Maximum Resolution X", "steam_ihs_discovery.body_streamingrequest_maximumresolutionx",
FT_INT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_streamingrequest_maximumresolutiony,
{ "Maximum Resolution Y", "steam_ihs_discovery.body_streamingrequest_maximumresolutiony",
FT_INT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_streamingrequest_audiochannelcount,
{ "Audio Channel Count", "steam_ihs_discovery.body_streamingrequest_audiochannelcount",
FT_INT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_streamingrequest_deviceversion,
{ "Device Version", "steam_ihs_discovery.body_streamingrequest_deviceversion",
FT_STRING, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_streamingrequest_streamdesktop,
{ "Stream Desktop", "steam_ihs_discovery.body_streamingrequest_streamdesktop",
FT_BOOLEAN, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_streamingrequest_devicetoken,
{ "Device Token", "steam_ihs_discovery.body_streamingrequest_devicetoken",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_streamingrequest_pin,
{ "PIN", "steam_ihs_discovery.body_streamingrequest_pin",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_streamingrequest_enablevideostreaming,
{ "Enable Video Streaming", "steam_ihs_discovery.body_streamingrequest_enablevideostreaming",
FT_BOOLEAN, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_streamingrequest_enableaudiostreaming,
{ "Enable Audio Streaming", "steam_ihs_discovery.body_streamingrequest_enableaudiostreaming",
FT_BOOLEAN, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_streamingrequest_enableinputstreaming,
{ "Enable Input Streaming", "steam_ihs_discovery.body_streamingrequest_enableinputstreaming",
FT_BOOLEAN, BASE_NONE, NULL, 0,
NULL, HFILL }
},
/* CMsgRemoteDeviceStreamingCancelRequest */
{ &hf_steam_ihs_discovery_body_streamingcancelrequest_requestid,
{ "Request ID", "steam_ihs_discovery.body_streamingcancelrequest_requestid",
FT_UINT32, BASE_HEX, NULL, 0,
NULL, HFILL }
},
/* CMsgRemoteDeviceStreamingResponse */
{ &hf_steam_ihs_discovery_body_streamingresponse_requestid,
{ "Request ID", "steam_ihs_discovery.body_streamingresponse_requestid",
FT_UINT32, BASE_HEX, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_streamingresponse_result,
{ "Result", "steam_ihs_discovery.body_streamingresponse_result",
FT_UINT64, BASE_DEC|BASE_VAL64_STRING, VALS64(hf_steam_ihs_discovery_body_streamingresponse_result_strings), 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_streamingresponse_port,
{ "Port", "steam_ihs_discovery.body_streamingresponse_port",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_streamingresponse_encryptedsessionkey,
{ "Encrypted Session Key", "steam_ihs_discovery.body_streamingresponse_encryptedsessionkey",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_steam_ihs_discovery_body_streamingresponse_virtualherelicenseddevicecount,
{ "VirtualHere Licensed Device Count", "steam_ihs_discovery.body_streamingresponse_virtualherelicenseddevicecount",
FT_INT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
/* CMsgRemoteDeviceProofRequest */
{ &hf_steam_ihs_discovery_body_proofrequest_challenge,
{ "Challenge", "steam_ihs_discovery.body_proofrequest_challenge",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }
},
/* CMsgRemoteDeviceProofResponse */
{ &hf_steam_ihs_discovery_body_proofresponse_response,
{ "Response", "steam_ihs_discovery.body_proofresponse_response",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }
}
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_steam_ihs_discovery,
&ett_steam_ihs_discovery_body_status_user
};
/* Setup protocol expert items */
static ei_register_info ei[] = {
{ &ei_steam_ihs_discovery_unknown_data,
{ "steam_ihs_discovery.unknowndata", PI_UNDECODED, PI_WARN,
"Unknown data section", EXPFILL }
},
{ &ei_steam_ihs_discovery_unknown_number,
{ "steam_ihs_discovery.unknownnumber", PI_UNDECODED, PI_WARN,
"Unknown numeric protobuf field", EXPFILL }
},
{ &ei_steam_ihs_discovery_unknown_lengthdelimited,
{ "steam_ihs_discovery.unknownlengthdelimited", PI_UNDECODED, PI_WARN,
"Unknown length-delimited protobuf field", EXPFILL }
},
{ &ei_steam_ihs_discovery_invalid_wiretype,
{ "steam_ihs_discovery.invalid_wiretype", PI_MALFORMED, PI_ERROR,
"Unexpected wire type", EXPFILL }
},
{ &ei_steam_ihs_discovery_invalid_length,
{ "steam_ihs_discovery.invalid_length", PI_MALFORMED, PI_ERROR,
"Length-delimited field has invalid length", EXPFILL }
}
};
/* Register the protocol name and description */
proto_steam_ihs_discovery = proto_register_protocol("Steam In-Home Streaming Discovery Protocol",
"Steam IHS Discovery", "steam_ihs_discovery");
/* Required function calls to register the header fields and subtrees */
proto_register_field_array(proto_steam_ihs_discovery, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
/* Required function calls to register expert items */
expert_steam_ihs_discovery = expert_register_protocol(proto_steam_ihs_discovery);
expert_register_field_array(expert_steam_ihs_discovery, ei, array_length(ei));
/* Register a preferences module - handled by Decode As. */
/* steam_ihs_discovery_module = prefs_register_protocol(proto_steam_ihs_discovery, NULL); */
}
void
proto_reg_handoff_steam_ihs_discovery(void)
{
static dissector_handle_t steam_ihs_discovery_handle;
steam_ihs_discovery_handle = create_dissector_handle(dissect_steam_ihs_discovery, proto_steam_ihs_discovery);
dissector_add_uint_with_preference("udp.port", STEAM_IHS_DISCOVERY_UDP_PORT, steam_ihs_discovery_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-stt.c
|
/* packet-stt.c
*
* Routines for Stateless Transport Tunneling (STT) packet dissection
* Remi Vichery <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Protocol ref:
* https://tools.ietf.org/html/draft-davie-stt-07
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/expert.h>
#include <epan/in_cksum.h>
#include <epan/ipproto.h>
#include <epan/prefs.h>
#include <epan/reassemble.h>
#include <epan/to_str.h>
#include "packet-ip.h"
static gboolean pref_reassemble = TRUE;
static gboolean pref_check_checksum = FALSE;
/* IANA ref:
* https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
*/
#define TCP_PORT_STT 7471
/* Length of entire overloaded TCP header. */
#define STT_TCP_HDR_LEN 20
/* Sum of STT header field sizes plus trailing padding. */
#define STT_HEADER_SIZE 18
#define STT_TCP_OFF_DPORT 2
#define STT_TCP_OFF_PKT_LEN 4
#define STT_TCP_OFF_SEG_OFF 6
#define STT_TCP_OFF_PKT_ID 8
#define STT_PCP_MASK 0xE000
#define STT_V_MASK 0x1000
#define STT_VLANID_MASK 0x0FFF
#define FLAG_OFFLOAD_MASK 0x02
void proto_register_stt(void);
void proto_reg_handoff_stt(void);
static int proto_stt = -1;
static int hf_stt_stream_id = -1;
static int hf_stt_dport = -1;
static int hf_stt_pkt_len = -1;
static int hf_stt_seg_off = -1;
static int hf_stt_pkt_id = -1;
static int hf_stt_checksum = -1;
static int hf_stt_checksum_status = -1;
static int hf_stt_tcp_data = -1;
static int hf_stt_tcp_data_offset = -1;
static int hf_stt_tcp_flags = -1;
static int hf_stt_tcp_rsvd = -1;
static int hf_stt_tcp_ns = -1;
static int hf_stt_tcp_cwr = -1;
static int hf_stt_tcp_ece = -1;
static int hf_stt_tcp_urg = -1;
static int hf_stt_tcp_ack = -1;
static int hf_stt_tcp_psh = -1;
static int hf_stt_tcp_rst = -1;
static int hf_stt_tcp_syn = -1;
static int hf_stt_tcp_fin = -1;
static int hf_stt_tcp_window = -1;
static int hf_stt_tcp_urg_ptr = -1;
static int hf_stt_version = -1;
static int hf_stt_flags = -1;
static int hf_stt_flag_rsvd = -1;
static int hf_stt_flag_tcp = -1;
static int hf_stt_flag_ipv4 = -1;
static int hf_stt_flag_partial = -1;
static int hf_stt_flag_verified = -1;
static int hf_stt_l4_offset = -1;
static int hf_stt_reserved_8 = -1;
static int hf_stt_mss = -1;
static int hf_stt_vlan = -1;
static int hf_stt_pcp = -1;
static int hf_stt_v = -1;
static int hf_stt_vlan_id= -1;
static int hf_stt_context_id = -1;
static int hf_stt_padding = -1;
static int hf_segments = -1;
static int hf_segment = -1;
static int hf_segment_overlap = -1;
static int hf_segment_overlap_conflict = -1;
static int hf_segment_multiple_tails = -1;
static int hf_segment_too_long_fragment = -1;
static int hf_segment_error = -1;
static int hf_segment_count = -1;
static int hf_reassembled_in = -1;
static int hf_reassembled_length = -1;
static int ett_stt = -1;
static int ett_stt_tcp_data = -1;
static int ett_stt_tcp_flags = -1;
static int ett_stt_flgs = -1;
static int ett_stt_vlan = -1;
static int ett_segment = -1;
static int ett_segments = -1;
static reassembly_table stt_reassembly_table;
static expert_field ei_stt_ver_unknown = EI_INIT;
static expert_field ei_stt_checksum_bad = EI_INIT;
static expert_field ei_stt_data_offset_bad = EI_INIT;
static expert_field ei_stt_l4_offset = EI_INIT;
static expert_field ei_stt_mss = EI_INIT;
static dissector_handle_t eth_handle;
/* From Table G-2 of IEEE standard 802.1Q-2005 */
static const value_string pri_vals[] = {
{ 1, "Background" },
{ 0, "Best Effort (default)" },
{ 2, "Excellent Effort" },
{ 3, "Critical Applications" },
{ 4, "Video, < 100ms latency and jitter" },
{ 5, "Voice, < 10ms latency and jitter" },
{ 6, "Internetwork Control" },
{ 7, "Network Control" },
{ 0, NULL }
};
static const fragment_items frag_items = {
&ett_segment,
&ett_segments,
&hf_segments,
&hf_segment,
&hf_segment_overlap,
&hf_segment_overlap_conflict,
&hf_segment_multiple_tails,
&hf_segment_too_long_fragment,
&hf_segment_error,
&hf_segment_count,
&hf_reassembled_in,
&hf_reassembled_length,
NULL, /* Reassembled data */
"STT segments"
};
static tvbuff_t *
handle_segment(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
guint32 pkt_id, guint16 pkt_len, guint16 seg_off)
{
fragment_head *frags;
int offset;
guint32 frag_data_len;
gboolean more_frags;
/* Skip fake TCP header after the first segment. */
if (seg_off == 0) {
offset = 0;
} else {
offset = STT_TCP_HDR_LEN;
/* We saved the TCP header on the first packet (only), which skews the
* segment offset. */
seg_off += STT_TCP_HDR_LEN;
}
frag_data_len = tvb_reported_length_remaining(tvb, offset);
more_frags = seg_off + frag_data_len < pkt_len;
frags = fragment_add_check(&stt_reassembly_table, tvb, offset, pinfo,
pkt_id, NULL, seg_off, frag_data_len,
more_frags);
/* Update reassembly fields in UI if reassembly is complete. */
if (frags) {
return process_reassembled_data(tvb, offset, pinfo, "Reassembled STT",
frags, &frag_items, NULL, tree);
}
return NULL;
}
static void
dissect_stt_checksum(tvbuff_t *tvb, packet_info *pinfo, proto_tree *stt_tree)
{
gboolean can_checksum = !pinfo->fragmented &&
tvb_bytes_exist(tvb, 0, tvb_reported_length(tvb));
if (can_checksum && pref_check_checksum) {
vec_t cksum_vec[4];
guint32 phdr[2];
/* Set up the fields of the pseudo-header. */
SET_CKSUM_VEC_PTR(cksum_vec[0], (const guint8 *)pinfo->src.data,
pinfo->src.len);
SET_CKSUM_VEC_PTR(cksum_vec[1], (const guint8 *)pinfo->dst.data,
pinfo->dst.len);
switch (pinfo->src.type) {
case AT_IPv4:
phdr[0] = g_htonl((IP_PROTO_TCP<<16) + tvb_reported_length(tvb));
SET_CKSUM_VEC_PTR(cksum_vec[2], (const guint8 *)phdr, 4);
break;
case AT_IPv6:
phdr[0] = g_htonl(tvb_reported_length(tvb));
phdr[1] = g_htonl(IP_PROTO_TCP);
SET_CKSUM_VEC_PTR(cksum_vec[2], (const guint8 *)phdr, 8);
break;
default:
/* STT runs only atop IPv4 and IPv6.... */
DISSECTOR_ASSERT_NOT_REACHED();
break;
}
SET_CKSUM_VEC_TVB(cksum_vec[3], tvb, 0, tvb_reported_length(tvb));
proto_tree_add_checksum(stt_tree, tvb, 16, hf_stt_checksum, hf_stt_checksum_status, &ei_stt_checksum_bad, pinfo,
in_cksum(cksum_vec, 4), ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
} else {
proto_tree_add_checksum(stt_tree, tvb, 16, hf_stt_checksum, hf_stt_checksum_status, &ei_stt_checksum_bad, pinfo,
0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
}
static int
dissect_tcp_flags(proto_tree *tree, tvbuff_t *tvb, int offset)
{
static int * const flags[] = {
&hf_stt_tcp_rsvd,
&hf_stt_tcp_ns,
&hf_stt_tcp_cwr,
&hf_stt_tcp_ece,
&hf_stt_tcp_urg,
&hf_stt_tcp_ack,
&hf_stt_tcp_psh,
&hf_stt_tcp_rst,
&hf_stt_tcp_syn,
&hf_stt_tcp_fin,
NULL
};
proto_tree_add_bitmask(tree, tvb, offset, hf_stt_tcp_flags,
ett_stt_tcp_flags, flags, ENC_BIG_ENDIAN);
offset += 2;
return offset;
}
static void
dissect_tcp_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *stt_tree)
{
int offset = 0;
proto_tree *tcp_tree;
proto_item *tcp_item, *data_offset_item;
int data_offset;
proto_tree_add_item(stt_tree, hf_stt_stream_id, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(stt_tree, hf_stt_dport, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(stt_tree, hf_stt_pkt_len, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(stt_tree, hf_stt_seg_off, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(stt_tree, hf_stt_pkt_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
tcp_item = proto_tree_add_item(stt_tree, hf_stt_tcp_data, tvb, offset,
8, ENC_NA);
tcp_tree = proto_item_add_subtree(tcp_item, ett_stt_tcp_data);
proto_item_set_text(tcp_item, "TCP Data");
data_offset = hi_nibble(tvb_get_guint8(tvb, offset)) * 4;
data_offset_item = proto_tree_add_uint(tcp_tree,
hf_stt_tcp_data_offset,
tvb, offset, 1,
data_offset);
if (data_offset != STT_TCP_HDR_LEN) {
expert_add_info(pinfo, data_offset_item, &ei_stt_data_offset_bad);
}
offset = dissect_tcp_flags(tcp_tree, tvb, offset);
proto_tree_add_item(tcp_tree, hf_stt_tcp_window, tvb, offset, 2,
ENC_BIG_ENDIAN);
offset += 2;
dissect_stt_checksum(tvb, pinfo, stt_tree);
offset += 2;
proto_tree_add_item(tcp_tree, hf_stt_tcp_urg_ptr, tvb, offset, 2,
ENC_BIG_ENDIAN);
}
static int
dissect_stt_flags(proto_tree *tree, tvbuff_t *tvb, int offset)
{
static int * const flags[] = {
&hf_stt_flag_rsvd,
&hf_stt_flag_tcp,
&hf_stt_flag_ipv4,
&hf_stt_flag_partial,
&hf_stt_flag_verified,
NULL
};
proto_tree_add_bitmask(tree, tvb, offset, hf_stt_flags,
ett_stt_flgs, flags, ENC_BIG_ENDIAN);
offset += 1;
return offset;
}
static void
dissect_stt_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *stt_tree,
proto_item *stt_item)
{
proto_tree *vlan_tree;
proto_item *ver_item, *l4_offset_item, *vlan_item, *mss_item;
guint8 flags;
guint32 version, l4_offset, mss, attributes;
guint64 context_id;
int offset = STT_TCP_HDR_LEN;
/*
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Version | Flags | L4 Offset | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Max. Segment Size | PCP |V| VLAN ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+ Context ID (64 bits) +
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Padding | Data |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
| |
*/
/* Protocol version */
ver_item = proto_tree_add_item_ret_uint(stt_tree, hf_stt_version, tvb,
offset, 1, ENC_BIG_ENDIAN, &version);
if (version != 0) {
expert_add_info_format(pinfo, ver_item, &ei_stt_ver_unknown,
"Unknown version %u", version);
col_add_fstr(pinfo->cinfo, COL_INFO, "Unknown STT version %u", version);
}
offset++;
/* Flags */
flags = tvb_get_guint8(tvb, offset);
offset = dissect_stt_flags(stt_tree, tvb, offset);
/* Layer 4 offset */
l4_offset_item = proto_tree_add_item_ret_uint(stt_tree, hf_stt_l4_offset,
tvb, offset, 1,
ENC_BIG_ENDIAN, &l4_offset);
/* Display an error if offset is != 0 when offloading is not in use */
if ( !(flags & FLAG_OFFLOAD_MASK) && (l4_offset != 0) ) {
expert_add_info_format(pinfo, l4_offset_item, &ei_stt_l4_offset, "Incorrect offset, should be equal to zero");
}
/* Display an error if offset equals 0 when there is offloading */
if ( (flags & FLAG_OFFLOAD_MASK) && (l4_offset == 0) ) {
expert_add_info_format(pinfo, l4_offset_item, &ei_stt_l4_offset, "Incorrect offset, should be greater than zero");
}
offset ++;
/* Reserved field (1 byte). MUST be 0 on transmission,
ignored on receipt. */
proto_tree_add_item(stt_tree, hf_stt_reserved_8, tvb, offset, 1,
ENC_BIG_ENDIAN);
offset ++;
/* Maximum Segment Size. MUST be 0 if segmentation offload
is not in use. */
mss_item = proto_tree_add_item_ret_uint(stt_tree, hf_stt_mss, tvb,
offset, 2, ENC_BIG_ENDIAN, &mss);
/* Display an error if MSS is != 0 when offloading is not in use */
if ( !(flags & FLAG_OFFLOAD_MASK) && (mss != 0) ) {
expert_add_info_format(pinfo, mss_item, &ei_stt_mss, "Incorrect max segment size, should be equal to zero");
}
offset += 2;
/* Tag Control Information like header. If V flag is set, it
indicates the presence of a valid VLAN ID in the following field
and valid PCP in the preceding field. */
vlan_item = proto_tree_add_item_ret_uint(stt_tree, hf_stt_vlan, tvb, offset,
2, ENC_BIG_ENDIAN, &attributes);
vlan_tree = proto_item_add_subtree(vlan_item, ett_stt_vlan);
proto_item_set_text(vlan_item, "VLAN Priority %u, ID %u",
(attributes >> 13), (attributes & STT_VLANID_MASK));
proto_tree_add_item(vlan_tree, hf_stt_pcp, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(vlan_tree, hf_stt_v, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(vlan_tree, hf_stt_vlan_id, tvb, offset, 2, ENC_BIG_ENDIAN);
if (attributes & STT_V_MASK) {
/* Display priority code point and VLAN ID when V flag is set */
proto_item_append_text(stt_item, ", Priority: %u, VLAN ID: %u",
attributes >> 13,
attributes & STT_VLANID_MASK);
}
/* Show if any part of this is set to aid debugging bad implementations. */
if (attributes == 0) {
proto_item_set_hidden(vlan_item);
}
offset += 2;
/* Context ID */
context_id = tvb_get_ntoh64(tvb, offset);
proto_tree_add_item(stt_tree, hf_stt_context_id, tvb, offset, 8, ENC_BIG_ENDIAN);
proto_item_append_text(stt_item, ", Context ID: 0x%" PRIx64,
context_id);
offset += 8;
/* Padding */
proto_tree_add_item(stt_tree, hf_stt_padding, tvb, offset,
2, ENC_BIG_ENDIAN);
}
static void
dissect_stt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *stt_item;
proto_tree *stt_tree;
tvbuff_t *next_tvb;
guint16 seg_off, pkt_len, rx_bytes;
guint8 sub_off;
gboolean frag_save, is_seg;
/* Make entry in Protocol column on summary display. */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "STT");
col_clear(pinfo->cinfo, COL_INFO);
stt_item = proto_tree_add_item(tree, proto_stt, tvb, 0,
STT_TCP_HDR_LEN, ENC_NA);
stt_tree = proto_item_add_subtree(stt_item, ett_stt);
dissect_tcp_tree(tvb, pinfo, stt_tree);
frag_save = pinfo->fragmented;
seg_off = tvb_get_ntohs(tvb, STT_TCP_OFF_SEG_OFF);
pkt_len = tvb_get_ntohs(tvb, STT_TCP_OFF_PKT_LEN);
rx_bytes = tvb_reported_length_remaining(tvb, STT_TCP_HDR_LEN);
is_seg = pkt_len > rx_bytes;
if (is_seg) {
guint32 pkt_id = tvb_get_ntohl(tvb, STT_TCP_OFF_PKT_ID);
pinfo->fragmented = TRUE;
col_add_fstr(pinfo->cinfo, COL_INFO,
"STT Segment (ID: 0x%x Len: %hu, Off: %hu)",
pkt_id, pkt_len, seg_off);
/* Reassemble segments unless the user has disabled reassembly. */
if (pref_reassemble && tvb_bytes_exist(tvb, 0, rx_bytes)) {
tvbuff_t *reasm_tvb;
reasm_tvb = handle_segment(tvb, pinfo, stt_tree, pkt_id,
pkt_len, seg_off);
if (reasm_tvb) {
tvb = reasm_tvb;
pinfo->fragmented = frag_save;
is_seg = FALSE;
}
} else if (seg_off == 0) {
/* If we're not reassembling, move ahead as if we have the
* whole frame. */
is_seg = FALSE;
}
}
/* Only full packets have a STT header (following the fake TCP header). */
if (!is_seg) {
sub_off = STT_TCP_HDR_LEN + STT_HEADER_SIZE;
dissect_stt_tree(tvb, pinfo, stt_tree, stt_item);
} else {
sub_off = STT_TCP_HDR_LEN;
}
if (seg_off == 0) {
proto_item_set_len(stt_item, sub_off);
}
next_tvb = tvb_new_subset_remaining(tvb, sub_off);
/* Only dissect inner frame if not segmented or if we aren't
doing reassembly. */
if (!is_seg) {
call_dissector(eth_handle, next_tvb, pinfo, tree);
} else {
call_data_dissector(next_tvb, pinfo, tree);
}
pinfo->fragmented = frag_save;
}
static gboolean
dissect_stt_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *iph)
{
/* Make sure we at least have a TCP header */
if (ws_ip_protocol(iph) != IP_PROTO_TCP ||
tvb_captured_length(tvb) < STT_TCP_HDR_LEN) {
return FALSE;
}
/* Check the TCP destination port */
if (tvb_get_ntohs(tvb, STT_TCP_OFF_DPORT) != TCP_PORT_STT) {
return FALSE;
}
dissect_stt(tvb, pinfo, tree);
return TRUE;
}
/* Register STT with Wireshark */
void
proto_register_stt(void)
{
expert_module_t* expert_stt;
module_t *stt_prefs;
static hf_register_info hf[] = {
/* Overloaded fake TCP header fields. */
{ &hf_stt_stream_id,
{ "Stream ID", "stt.stream_id",
FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL
},
},
{ &hf_stt_dport,
{ "Destination Port", "stt.dport",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL
},
},
{ &hf_stt_pkt_len,
{ "Packet Length", "stt.pkt_len",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL
},
},
{ &hf_stt_seg_off,
{ "Segment Offset", "stt.seg_off",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL
},
},
{ &hf_stt_pkt_id,
{ "Packet ID", "stt.pkt_id",
FT_UINT32, BASE_HEX, NULL, 0x0,
NULL, HFILL
},
},
{ &hf_stt_tcp_data,
{ "TCP Data", "stt.tcp",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL,
},
},
{ &hf_stt_tcp_data_offset,
{ "Data Offset", "stt.tcp.data_offset",
FT_UINT8, BASE_DEC|BASE_UNIT_STRING, &units_byte_bytes, 0x0,
NULL, HFILL,
},
},
{ &hf_stt_tcp_flags,
{ "Flags", "stt.tcp.flags",
FT_UINT16, BASE_HEX, NULL, 0x0FFF,
NULL, HFILL,
},
},
{ &hf_stt_tcp_rsvd,
{ "Reserved", "stt.tcp.flags.rsvd",
FT_BOOLEAN, 12, NULL, 0xE00,
NULL, HFILL,
},
},
{ &hf_stt_tcp_ns,
{ "Nonce", "stt.tcp.flags.ns",
FT_BOOLEAN, 12, NULL, 0x100,
NULL, HFILL,
},
},
{ &hf_stt_tcp_cwr,
{ "Congestion Window Reduced (CWR)", "stt.tcp.flags.cwr",
FT_BOOLEAN, 12, NULL, 0x080,
NULL, HFILL,
},
},
{ &hf_stt_tcp_ece,
{ "ECN-Echo", "stt.tcp.flags.ece",
FT_BOOLEAN, 12, NULL, 0x040,
NULL, HFILL,
},
},
{ &hf_stt_tcp_urg,
{ "Urgent", "stt.tcp.flags.urg",
FT_BOOLEAN, 12, NULL, 0x020,
NULL, HFILL,
},
},
{ &hf_stt_tcp_ack,
{ "Acknowledgement", "stt.tcp.flags.ack",
FT_BOOLEAN, 12, NULL, 0x010,
NULL, HFILL,
},
},
{ &hf_stt_tcp_psh,
{ "Push", "stt.tcp.flags.psh",
FT_BOOLEAN, 12, NULL, 0x008,
NULL, HFILL,
},
},
{ &hf_stt_tcp_rst,
{ "Reset", "stt.tcp.flags.rst",
FT_BOOLEAN, 12, NULL, 0x004,
NULL, HFILL,
},
},
{ &hf_stt_tcp_syn,
{ "Syn", "stt.tcp.flags.syn",
FT_BOOLEAN, 12, NULL, 0x002,
NULL, HFILL,
},
},
{ &hf_stt_tcp_fin,
{ "Fin", "stt.tcp.flags.fin",
FT_BOOLEAN, 12, NULL, 0x001,
NULL, HFILL,
},
},
{ &hf_stt_tcp_window,
{ "Window", "stt.tcp.window",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL,
},
},
{ &hf_stt_tcp_urg_ptr,
{ "Urgent Pointer", "stt.tcp.urg_ptr",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL,
},
},
/* STT header fields. */
{ &hf_stt_version,
{ "Version", "stt.version",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL
},
},
{ &hf_stt_flags,
{ "Flags", "stt.flags",
FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL,
},
},
{ &hf_stt_flag_rsvd,
{ "Reserved", "stt.flags.rsvd",
FT_BOOLEAN, 8, NULL, 0xF0,
NULL, HFILL,
},
},
{ &hf_stt_flag_tcp,
{ "TCP payload", "stt.flags.tcp",
FT_BOOLEAN, 8, NULL, 0x08,
NULL, HFILL,
},
},
{ &hf_stt_flag_ipv4,
{ "IPv4 packet", "stt.flags.ipv4",
FT_BOOLEAN, 8, NULL, 0x04,
NULL, HFILL,
},
},
{ &hf_stt_flag_partial,
{ "Checksum partial", "stt.flags.csum_partial",
FT_BOOLEAN, 8, NULL, 0x02,
NULL, HFILL,
},
},
{ &hf_stt_flag_verified,
{ "Checksum verified", "stt.flags.csum_verified",
FT_BOOLEAN, 8, NULL, 0x01,
NULL, HFILL,
},
},
{ &hf_stt_l4_offset,
{ "L4 Offset", "stt.l4offset",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL,
},
},
{ &hf_stt_reserved_8,
{ "Reserved", "stt.reserved",
FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL,
},
},
{ &hf_stt_mss,
{ "Max Segment Size", "stt.mss",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL,
},
},
{ &hf_stt_vlan,
{ "VLAN", "stt.vlan",
FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL,
},
},
{ &hf_stt_pcp,
{ "PCP", "stt.vlan.pcp",
FT_UINT16, BASE_DEC, VALS(pri_vals), STT_PCP_MASK,
NULL, HFILL,
},
},
{ &hf_stt_v,
{ "V flag", "stt.vlan.v",
FT_UINT16, BASE_DEC, NULL, STT_V_MASK,
NULL, HFILL,
},
},
{ &hf_stt_vlan_id,
{ "VLAN ID", "stt.vlan.id",
FT_UINT16, BASE_DEC, NULL, STT_VLANID_MASK,
NULL, HFILL,
},
},
{ &hf_stt_context_id,
{ "Context ID", "stt.context_id",
FT_UINT64, BASE_HEX, NULL, 0x0,
NULL, HFILL,
},
},
{ &hf_stt_padding,
{ "Padding", "stt.padding",
FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL,
},
},
/* Checksum validation fields */
{ &hf_stt_checksum,
{ "Checksum", "stt.checksum",
FT_UINT16, BASE_HEX, NULL, 0x0,
"Details at: https://www.wireshark.org/docs/wsug_html_chunked/ChAdvChecksums.html", HFILL
},
},
{ &hf_stt_checksum_status,
{ "Checksum Status", "stt.checksum.status",
FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
NULL, HFILL
},
},
/* Segment reassembly information. */
{ &hf_segment_overlap,
{ "Segment overlap", "stt.segment.overlap",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"Segment overlaps with other segments", HFILL
},
},
{ &hf_segment_overlap_conflict,
{ "Conflicting data in segment overlap", "stt.segment.overlap.conflict",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"Overlapping segments contained conflicting data", HFILL
},
},
{ &hf_segment_multiple_tails,
{ "Multiple tail segments found", "stt.segment.multipletails",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"Several tails were found when reassembling the packet", HFILL
},
},
{ &hf_segment_too_long_fragment,
{ "Segment too long", "stt.segment.toolongfragment",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"Segment contained data past end of the packet", HFILL
},
},
{ &hf_segment_error,
{ "Reassembling error", "stt.segment.error",
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
"Reassembling error due to illegal segments", HFILL
},
},
{ &hf_segment_count,
{ "Segment count", "stt.segment.count",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL
},
},
{ &hf_segment,
{ "STT Segment", "stt.segment",
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
NULL, HFILL
},
},
{ &hf_segments,
{ "Reassembled STT Segments", "stt.segments",
FT_NONE, BASE_NONE, NULL, 0x0,
"STT Segments", HFILL
},
},
{ &hf_reassembled_in,
{ "Reassembled PDU in frame", "stt.reassembled_in",
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
"The STT packet is reassembled in this frame", HFILL
},
},
{ &hf_reassembled_length,
{ "Reassembled STT length", "stt.reassembled.length",
FT_UINT32, BASE_DEC, NULL, 0x0,
"The total length of the reassembled payload", HFILL
},
},
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_stt,
&ett_stt_tcp_data,
&ett_stt_tcp_flags,
&ett_stt_flgs,
&ett_stt_vlan,
&ett_segment,
&ett_segments
};
static ei_register_info ei[] = {
{ &ei_stt_checksum_bad,
{ "stt.checksum_bad.expert", PI_CHECKSUM,
PI_ERROR, "Bad checksum", EXPFILL
}
},
{ &ei_stt_data_offset_bad,
{ "stt.data_offset_bad.expert", PI_PROTOCOL,
PI_WARN, "TCP Data Offset should be 20 bytes", EXPFILL
}
},
{ &ei_stt_ver_unknown,
{ "stt.version_unknown.expert", PI_PROTOCOL,
PI_WARN, "Unknown version", EXPFILL
}
},
{ &ei_stt_l4_offset,
{ "stt.l4offset_bad.expert", PI_PROTOCOL,
PI_WARN, "Bad L4 Offset", EXPFILL
}
},
{ &ei_stt_mss,
{ "stt.mss_bad.expert", PI_PROTOCOL,
PI_WARN, "Bad MSS", EXPFILL
}
},
};
/* Register the protocol name and description */
proto_stt = proto_register_protocol("Stateless Transport Tunneling",
"STT", "stt");
expert_stt = expert_register_protocol(proto_stt);
expert_register_field_array(expert_stt, ei, array_length(ei));
/* Required function calls to register the header fields and
subtrees used */
proto_register_field_array(proto_stt, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
stt_prefs = prefs_register_protocol(proto_stt, NULL);
prefs_register_bool_preference(stt_prefs, "reassemble",
"Reassemble segmented STT packets",
"Reassembles greater than MTU sized STT packets broken into segments on transmit",
&pref_reassemble);
prefs_register_bool_preference(stt_prefs, "check_checksum",
"Validate the STT checksum if possible",
"Whether to validate the STT checksum or not.",
&pref_check_checksum);
reassembly_table_register(&stt_reassembly_table,
&addresses_reassembly_table_functions);
}
void
proto_reg_handoff_stt(void)
{
/*
* The I-D doesn't explicity indicate that the FCS isn't present
* in the tunneled Ethernet frames, but it is missing from the
* captures attached to bug 10282.
*/
eth_handle = find_dissector_add_dependency("eth_withoutfcs", proto_stt);
heur_dissector_add("ip", dissect_stt_heur, "Stateless Transport Tunneling over IP", "stt_ip", proto_stt, HEURISTIC_ENABLE);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-stun.c
|
/* packet-stun.c
* Routines for Session Traversal Utilities for NAT (STUN) dissection
* Copyright 2003, Shiang-Ming Huang <[email protected]>
* Copyright 2006, Marc Petit-Huguenin <[email protected]>
* Copyright 2007-2008, 8x8 Inc. <[email protected]>
* Copyright 2008, Gael Breard <[email protected]>
* Copyright 2013, Media5 Corporation, David Bergeron <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Please refer to the following specs for protocol detail:
* - RFC 3489 (Addition of deprecated attributes for diagnostics purpose)
* STUN - Simple Traversal of User Datagram Protocol (UDP)
* Through Network Address Translators (NATs) (superseeded by RFC 5389)
* - RFC 5389, formerly draft-ietf-behave-rfc3489bis-18
* Session Traversal Utilities for NAT (STUN) (superseeded by RFC 8489)
* - RFC 8489 Session Traversal Utilities for NAT (STUN)
* - RFC 5780, formerly draft-ietf-behave-nat-behavior-discovery-08
* NAT Behavior Discovery Using Session Traversal Utilities for NAT (STUN)
* - RFC 5766, formerly draft-ietf-behave-turn-16
* Traversal Using Relays around NAT (TURN) (superseeded by RFC 8656)
* - RFC 8656 Traversal Using Relays around NAT (TURN)
* - RFC 6062 Traversal Using Relays around NAT (TURN) Extensions for TCP Allocations
* - RFC 6156, formerly draft-ietf-behave-turn-ipv6-11
* Traversal Using Relays around NAT (TURN) Extension for IPv6
* - RFC 5245, formerly draft-ietf-mmusic-ice-19
* Interactive Connectivity Establishment (ICE)
* - RFC 6544 TCP Candidates with Interactive Connectivity Establishment (ICE)
*
* Iana registered values:
* https://www.iana.org/assignments/stun-parameters/stun-parameters.xhtml
*
* From MS
* MS-TURN: Traversal Using Relay NAT (TURN) Extensions https://docs.microsoft.com/en-us/openspecs/office_protocols/ms-turn
* MS-TURNBWM: Traversal using Relay NAT (TURN) Bandwidth Management Extensions https://docs.microsoft.com/en-us/openspecs/office_protocols/ms-turnbwm
* MS-ICE: Interactive Connectivity Establishment (ICE) Extensions https://docs.microsoft.com/en-us/openspecs/office_protocols/ms-ice
* MS-ICE2: Interactive Connectivity Establishment ICE Extensions 2.0 https://docs.microsoft.com/en-us/openspecs/office_protocols/ms-ice2
* MS-ICE2BWN: Interactive Connectivity Establishment (ICE) 2.0 Bandwidth Management Extensions https://docs.microsoft.com/en-us/openspecs/office_protocols/ms-ice2bwm
*/
/* TODO
* Add information about different versions to table as we find it
* Add/Implement missing attributes
* Add/Implement missing message classes/methods
* Add missing error codes
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/expert.h>
#include <epan/to_str.h>
#include <epan/crc32-tvb.h>
#include <wsutil/ws_roundup.h>
#include "packet-tcp.h"
void proto_register_stun(void);
void proto_reg_handoff_stun(void);
/* Dissection relevant differences between STUN/TURN specification documents
*
* Aspect | MS-TURN 18.0 | RFC 3489 | RFC 5389 | RFC 8489 (*1) |
* ===============================================================================================
* Message | 0b00+14-bit | 16-bit | 0b00+14-bit, type= | |
* Type | No class or method | No class or method | class+method | |
* | 0x0115: Data Ind | | Method: 0x000-0xFFF| Method: 0x000-0x0FF|
* -----------------------------------------------------------------------------------------------
* Transac- | 128 bits, seen | 128 bits | 32 bit Magic + | |
* tion ID | with MAGIC as well | | 96 bit Trans ID | |
* -----------------------------------------------------------------------------------------------
* Padding | No Attribute Pad | No Attribute Pad | Pad to 32 bits | |
* | | | Att. Len excl. Pad | |
* | | | Msg. Len incl. Pad | |
* | | | -> MLen & 3 == 0 | |
* | | | Pad value: any | Pad value: MBZ |
* -----------------------------------------------------------------------------------------------
* (XOR-) | Write: Any value | Write: Any value | Write: MBZ | |
* MAP-ADDR | Read : Ignored | Read : Ignored | Read : Ignored | |
* 1st byte | | | | |
* -----------------------------------------------------------------------------------------------
* Username | Opaque | Opaque | UTF-8 String | |
* -----------------------------------------------------------------------------------------------
* Password | Opaque | Deprecated | Deprecated | |
* -----------------------------------------------------------------------------------------------
* NONCE & | 0x0014 | 0x0015 (*2) | 0x0015 | |
* REALM | 0x0015 | 0x0014 | 0x0014 | |
* -----------------------------------------------------------------------------------------------
* TURN | RFC 5766/8656 or | N/A | RFC 5766: | RFC 8656: |
* Channels | Multiplexed TURN | | 0x4000-0x7FFF used | 0x4000-0x4FFF used |
* | Channels (0xFF10) | | 0x8000-0xFFFF res. | 0x5000-0xFFFF res. |
* | | | Reserved MUST NOT | Reserved MUST be |
* | | | be rejected | dropped (collision)|
* -----------------------------------------------------------------------------------------------
* *1: Only where different from RFC 5389
* *2: NONCE & REALM were first defined in Internet-Drafts after RFC 3489 was
* published. Early drafts, up to draft-ietf-behave-rfc3489bis-02 and
* draft-rosenberg-midcom-turn-08, used 0x0014 for NONCE and 0x0015 for REALM.
* The attribute numbers were swapped in draft-ietf-behave-rfc3489bis-03 (when
* moved from the TURN spec to the STUN spec), the same version that added the
* fixed 32-bit magic. Since this dissector only handles packets with the magic
* (others are rejected and processed by the classicstun dissector instead),
* the swapped values are used for RFC 3489 mode here.
*/
enum {
NET_VER_AUTO,
NET_VER_MS_TURN,
NET_VER_3489,
NET_VER_5389
};
/* Auto-tuning. Default: NET_VER_5389; NET_VER_MS_TURN if MAGIC_COOKIE is found */
/* NET_VER_3489 is only useful for packets that conform specifically to
* draft-ietf-behave-rfc3849bis-03; i.e. that have the 32 bit magic so that they
* are not handled by classicstun instead, have the current (swapped) NONE and
* REALM attribute numbers, but do not have the attribute padding that was
* introduced in draft-ietf-behave-rfc3849bis-04.
*/
static gint stun_network_version = NET_VER_5389;
static const enum_val_t stun_network_version_vals[] = {
{ "Auto", "Auto", NET_VER_AUTO},
{ "MS-TURN", "MS-TURN", NET_VER_MS_TURN },
{ "RFC3489 and earlier", "RFC3489 and earlier", NET_VER_3489},
{ "RFC5389 and later", "RFC5389 and later", NET_VER_5389 },
{ NULL, NULL, 0 }
};
static const value_string network_versions_vals[] = {
{NET_VER_MS_TURN, "MS-TURN"},
{NET_VER_3489, "RFC-3489 and earlier"},
{NET_VER_5389, "RFC-5389/8489"},
{0, NULL}
};
/* heuristic subdissectors */
static heur_dissector_list_t heur_subdissector_list;
/* stun dissector handles */
static dissector_handle_t data_handle;
static dissector_handle_t stun_tcp_handle;
static dissector_handle_t stun_udp_handle;
/* Initialize the protocol and registered fields */
static int proto_stun = -1;
static int hf_stun_channel = -1;
static int hf_stun_tcp_frame_length = -1;
static int hf_stun_type = -1;
static int hf_stun_type_class = -1;
static int hf_stun_type_method = -1;
static int hf_stun_type_method_assignment = -1;
static int hf_stun_length = -1;
static int hf_stun_cookie = -1;
static int hf_stun_id = -1;
static int hf_stun_attributes = -1;
static int hf_stun_response_in = -1;
static int hf_stun_response_to = -1;
static int hf_stun_time = -1;
static int hf_stun_duplicate = -1;
static int hf_stun_attr = -1;
static int hf_stun_att_type = -1; /* STUN attribute fields */
static int hf_stun_att_length = -1;
static int hf_stun_att_family = -1;
static int hf_stun_att_type_comprehension = -1;
static int hf_stun_att_type_assignment = -1;
static int hf_stun_att_ipv4 = -1;
static int hf_stun_att_ipv6 = -1;
static int hf_stun_att_port = -1;
static int hf_stun_att_username = -1;
static int hf_stun_att_username_opaque = -1;
static int hf_stun_att_password = -1;
static int hf_stun_att_padding = -1;
static int hf_stun_att_hmac = -1;
static int hf_stun_att_crc32 = -1;
static int hf_stun_att_crc32_status = -1;
static int hf_stun_att_error_class = -1;
static int hf_stun_att_error_number = -1;
static int hf_stun_att_error_reason = -1;
static int hf_stun_att_realm = -1;
static int hf_stun_att_nonce = -1;
static int hf_stun_att_unknown = -1;
static int hf_stun_att_xor_ipv4 = -1;
static int hf_stun_att_xor_ipv6 = -1;
static int hf_stun_att_xor_port = -1;
static int hf_stun_att_icmp_type = -1;
static int hf_stun_att_icmp_code = -1;
static int hf_stun_att_ms_turn_unknown_8006 = -1;
static int hf_stun_att_software = -1;
static int hf_stun_att_priority = -1;
static int hf_stun_att_tie_breaker = -1;
static int hf_stun_att_change_ip = -1;
static int hf_stun_att_change_port = -1;
static int hf_stun_att_cache_timeout = -1;
static int hf_stun_att_token = -1;
static int hf_stun_att_pw_alg = -1;
static int hf_stun_att_pw_alg_param_len = -1;
static int hf_stun_att_pw_alg_param_data = -1;
static int hf_stun_att_reserve_next = -1;
static int hf_stun_att_reserved = -1;
static int hf_stun_att_value = -1;
static int hf_stun_att_transp = -1;
static int hf_stun_att_magic_cookie = -1;
static int hf_stun_att_bandwidth = -1;
static int hf_stun_att_lifetime = -1;
static int hf_stun_att_channelnum = -1;
static int hf_stun_att_ms_version = -1;
static int hf_stun_att_ms_version_ice = -1;
static int hf_stun_att_ms_connection_id = -1;
static int hf_stun_att_ms_sequence_number = -1;
static int hf_stun_att_ms_stream_type = -1;
static int hf_stun_att_ms_service_quality = -1;
static int hf_stun_att_ms_foundation = -1;
static int hf_stun_att_ms_multiplexed_turn_session_id = -1;
static int hf_stun_att_ms_turn_session_id = -1;
static int hf_stun_att_bandwidth_acm_type = -1;
static int hf_stun_att_bandwidth_rsv_id = -1;
static int hf_stun_att_bandwidth_rsv_amount_misb = -1;
static int hf_stun_att_bandwidth_rsv_amount_masb = -1;
static int hf_stun_att_bandwidth_rsv_amount_mirb = -1;
static int hf_stun_att_bandwidth_rsv_amount_marb = -1;
static int hf_stun_att_address_rp_a = -1;
static int hf_stun_att_address_rp_b = -1;
static int hf_stun_att_address_rp_rsv1 = -1;
static int hf_stun_att_address_rp_rsv2 = -1;
static int hf_stun_att_address_rp_masb = -1;
static int hf_stun_att_address_rp_marb = -1;
static int hf_stun_att_sip_dialog_id = -1;
static int hf_stun_att_sip_call_id = -1;
static int hf_stun_att_lp_peer_location = -1;
static int hf_stun_att_lp_self_location = -1;
static int hf_stun_att_lp_federation = -1;
static int hf_stun_att_google_network_id = -1;
static int hf_stun_att_google_network_cost = -1;
static int hf_stun_network_version = -1;
/* Expert items */
static expert_field ei_stun_short_packet = EI_INIT;
static expert_field ei_stun_wrong_msglen = EI_INIT;
static expert_field ei_stun_long_attribute = EI_INIT;
static expert_field ei_stun_unknown_attribute = EI_INIT;
static expert_field ei_stun_fingerprint_bad = EI_INIT;
/* Structure containing transaction specific information */
typedef struct _stun_transaction_t {
guint32 req_frame;
guint32 rep_frame;
nstime_t req_time;
} stun_transaction_t;
/* Structure containing conversation specific information */
typedef struct _stun_conv_info_t {
wmem_tree_t *transaction_pdus;
} stun_conv_info_t;
/* STUN versions RFC5389 and newer split off the leading 32 bits of the
* transaction ID into a magic cookie (called message cookie in this
* dissector to avoid confusion with the MAGIC_COOKIE attribute) and
* shortens the real transaction ID to 96 bits.
* This allows to differentiate between the legacy version of RFC3489
* and all newer versions.
*/
#define MESSAGE_COOKIE 0x2112A442
#define TURN_MAGIC_COOKIE 0x72C64BC6
/* Message classes (2 bit) */
#define REQUEST 0
#define INDICATION 1
#define SUCCESS_RESPONSE 2
#define ERROR_RESPONSE 3
/* Methods */
/* 0x000-0x07F IETF Review */
#define BINDING 0x0001 /* RFC8489 */
#define SHARED_SECRET 0x0002 /* RFC3489 */
#define ALLOCATE 0x0003 /* RFC8489 */
#define REFRESH 0x0004 /* RFC8489 */
/* 0x0005 is Unassigned.
* 0x1115 was used for DATA_INDICATION in draft-rosenberg-midcom-turn-08,
* but this did not fit the later class+indication scheme (it would
* indicate an error response, which it is not) and was unassigned and
* replaced with 0x0007 before RFC5389. The MS-TURN specification lists
* it, however, and some MS-TURN captures use it.
*/
#define SEND 0x0006 /* RFC8656 */
#define DATA_IND 0x0007 /* RFC8656 */
#define CREATE_PERMISSION 0x0008 /* RFC8656 */
#define CHANNELBIND 0x0009 /* RFC8656 */
/* TCP specific */
#define CONNECT 0x000a /* RFC6062 */
#define CONNECTION_BIND 0x000b /* RFC6062 */
#define CONNECTION_ATTEMPT 0x000c /* RFC6062 */
#define GOOG_PING 0x0080 /* Google undocumented */
/* 0x080-0x0FF Expert Review */
/* 0x100-0xFFF Reserved (for DTLS-SRTP multiplexing collision avoidance,
* see RFC7983. Cannot be made available for assignment without IETF Review.)
*/
/* Attribute Types */
/* 0x0000-0x3FFF IETF Review comprehension-required range */
#define MAPPED_ADDRESS 0x0001 /* RFC8489, MS-TURN */
#define RESPONSE_ADDRESS 0x0002 /* Deprecated, RFC3489 */
#define CHANGE_REQUEST 0x0003 /* Deprecated, RFC3489 */
#define SOURCE_ADDRESS 0x0004 /* Deprecated, RFC3489 */
#define CHANGED_ADDRESS 0x0005 /* Deprecated, RFC3489 */
#define USERNAME 0x0006 /* RFC8489, MS-TURN */
#define PASSWORD 0x0007 /* Deprecated, RFC3489 */
#define MESSAGE_INTEGRITY 0x0008 /* RFC8489, MS-TURN */
#define ERROR_CODE 0x0009 /* RFC8489, MS-TURN */
#define UNKNOWN_ATTRIBUTES 0x000a /* RFC8489, MS-TURN */
#define REFLECTED_FROM 0x000b /* Deprecated, RFC3489 */
#define CHANNEL_NUMBER 0x000c /* RFC8656 */
#define LIFETIME 0x000d /* RFC8656, MS-TURN */
#define MS_ALTERNATE_SERVER 0x000e /* MS-TURN */
/* 0x000f reserved collision */
#define MAGIC_COOKIE 0x000f /* MS-TURN */
/* 0x0010 fix reference */
#define BANDWIDTH 0x0010 /* MS-TURN */
/* 0x0011 reserved collision */
#define DESTINATION_ADDRESS 0x0011 /* MS-TURN */
#define XOR_PEER_ADDRESS 0x0012 /* RFC8656, MS-TURN */
#define DATA 0x0013 /* RFC8656, MS-TURN */
/* Note: REALM and NONCE have swapped attribute numbers in MS-TURN */
#define REALM 0x0014 /* RFC8489, MS-TURN uses 0x0015 */
#define NONCE 0x0015 /* RFC8489, MS-TURN uses 0x0014 */
#define XOR_RELAYED_ADDRESS 0x0016 /* RFC8656 */
#define REQUESTED_ADDRESS_FAMILY 0x0017 /* RFC8656, MS-TURN */
#define EVEN_PORT 0x0018 /* RFC8656 */
#define REQUESTED_TRANSPORT 0x0019 /* RFC8656 */
#define DONT_FRAGMENT 0x001a /* RFC8656 */
#define ACCESS_TOKEN 0x001b /* RFC7635 */
#define MESSAGE_INTEGRITY_SHA256 0x001c /* RFC8489 */
#define PASSWORD_ALGORITHM 0x001d /* RFC8489 */
#define USERHASH 0x001e /* RFC8489 */
/* 0x001f Reserved */
#define XOR_MAPPED_ADDRESS 0x0020 /* RFC8489 */
/* 0x0021 add deprecated TIMER-VAL */
#define RESERVATION_TOKEN 0x0022 /* RFC8656 */
/* 0x0023 Reserved */
#define PRIORITY 0x0024 /* RFC8445 */
#define USE_CANDIDATE 0x0025 /* RFC8445 */
#define PADDING 0x0026 /* RFC5780 */
/* 0x0027 collision RESPONSE-PORT RFC5780 */
#define XOR_RESPONSE_TARGET 0x0027 /* draft-ietf-behave-nat-behavior-discovery-03 */
/* 0x0028 Reserved collision */
#define XOR_REFLECTED_FROM 0x0028 /* draft-ietf-behave-nat-behavior-discovery-03 */
/* 0x0029 Reserved */
#define CONNECTION_ID 0x002a /* rfc6062 */
/* 0x002b-0x002f unassigned */
/* 0x0030 collision reserved */
#define LEGACY_ICMP 0x0030 /* Moved from TURN to 0x8004 */
/* 0x0031-0x3fff Unassigned */
/* 0x4000-0x7FFF Expert Review comprehension-required range */
/* 0x4000-0x7fff Unassigned */
/* 0x8000-0xBFFF IETF Review comprehension-optional range */
#define ADDITIONAL_ADDRESS_FAMILY 0x8000 /* RFC8656 */
#define ADDRESS_ERROR_CODE 0x8001 /* RFC8656 */
#define PASSWORD_ALGORITHMS 0x8002 /* RFC8489 */
#define ALTERNATE_DOMAIN 0x8003 /* RFC8489 */
#define ICMP 0x8004 /* RFC8656 */
/* Unknown attribute in MS-TURN packets */
#define MS_TURN_UNKNOWN_8006 0x8006
/* 0x8005-0x8021 Unassigned collision */
#define MS_VERSION 0x8008 /* MS-TURN */
/* collision */
#define MS_XOR_MAPPED_ADDRESS 0x8020 /* MS-TURN */
#define SOFTWARE 0x8022 /* RFC8489 */
#define ALTERNATE_SERVER 0x8023 /* RFC8489 */
/* 0x8024 Reserved */
#define TRANSACTION_TRANSMIT_COUNTER 0x8025 /* RFC7982 */
/* 0x8026 Reserved */
#define CACHE_TIMEOUT 0x8027 /* RFC5780 */
#define FINGERPRINT 0x8028 /* RFC8489 */
#define ICE_CONTROLLED 0x8029 /* RFC8445 */
#define ICE_CONTROLLING 0x802a /* RFC8445 */
#define RESPONSE_ORIGIN 0x802b /* RFC5780 */
#define OTHER_ADDRESS 0x802c /* RFC5780 */
#define ECN_CHECK_STUN 0x802d /* RFC6679 */
#define THIRD_PARTY_AUTHORIZATION 0x802e /* RFC7635 */
/* 0x802f Unassigned */
#define MOBILITY_TICKET 0x8030 /* RFC8016 */
/* 0x8031-0xBFFF Unassigned collision */
#define MS_ALTERNATE_HOST_NAME 0x8032 /* MS-TURN */
#define MS_APP_ID 0x8037 /* MS-TURN */
#define MS_SECURE_TAG 0x8039 /* MS-TURN */
#define MS_SEQUENCE_NUMBER 0x8050 /* MS-TURN */
#define MS_CANDIDATE_IDENTIFIER 0x8054 /* MS-ICE2 */
#define MS_SERVICE_QUALITY 0x8055 /* MS-TURN */
#define BANDWIDTH_ACM 0x8056 /* MS-TURNBWM */
#define BANDWIDTH_RSV_ID 0x8057 /* MS-TURNBWM */
#define BANDWIDTH_RSV_AMOUNT 0x8058 /* MS-TURNBWM */
#define REMOTE_SITE_ADDR 0x8059 /* MS-TURNBWM */
#define REMOTE_RELAY_SITE 0x805A /* MS-TURNBWM */
#define LOCAL_SITE_ADDR 0x805B /* MS-TURNBWM */
#define LOCAL_RELAY_SITE 0x805C /* MS-TURNBWM */
#define REMOTE_SITE_ADDR_RP 0x805D /* MS-TURNBWM */
#define REMOTE_RELAY_SITE_RP 0x805E /* MS-TURNBWM */
#define LOCAL_SITE_ADDR_RP 0x805F /* MS-TURNBWM */
#define LOCAL_RELAY_SITE_RP 0x8060 /* MS-TURNBWM */
#define SIP_DIALOG_ID 0x8061 /* MS-TURNBWM */
#define SIP_CALL_ID 0x8062 /* MS-TURNBWM */
#define LOCATION_PROFILE 0x8068 /* MS-TURNBWM */
#define MS_IMPLEMENTATION_VER 0x8070 /* MS-ICE2 */
#define MS_ALT_MAPPED_ADDRESS 0x8090 /* MS-TURN */
#define MS_MULTIPLEXED_TURN_SESSION_ID 0x8095 /* MS_TURN */
/* 0xC000-0xFFFF Expert Review comprehension-optional range */
#define CISCO_STUN_FLOWDATA 0xc000 /* Cisco undocumented */
#define ENF_FLOW_DESCRIPTION 0xc001 /* Cisco undocumented */
#define ENF_NETWORK_STATUS 0xc002 /* Cisco undocumented */
/* 0xc003-0xc056 Unassigned */
/* https://webrtc.googlesource.com/src/+/refs/heads/master/api/transport/stun.h */
#define GOOG_NETWORK_INFO 0xc057
#define GOOG_LAST_ICE_CHECK_RECEIVED 0xc058
#define GOOG_MISC_INFO 0xc059
/* Various IANA-registered but undocumented Google attributes follow */
#define GOOG_OBSOLETE_1 0xc05a
#define GOOG_CONNECTION_ID 0xc05b
#define GOOG_DELTA 0xc05c
#define GOOG_DELTA_ACK 0xc05d
/* 0xc05e-0xc05f Unassigned */
#define GOOG_MESSAGE_INTEGRITY_32 0xc060
/* 0xc061-0xff03 Unassigned */
/* https://webrtc.googlesource.com/src/+/refs/heads/master/p2p/base/turn_port.cc */
#define GOOG_MULTI_MAPPING 0xff04
#define GOOG_LOGGING_ID 0xff05
/* 0xff06-0xffff Unassigned */
#define MS_MULTIPLEX_TURN 0xFF10
/* Initialize the subtree pointers */
static gint ett_stun = -1;
static gint ett_stun_type = -1;
static gint ett_stun_att_all= -1;
static gint ett_stun_att = -1;
static gint ett_stun_att_type = -1;
#define UDP_PORT_STUN 3478
#define TCP_PORT_STUN 3478
#define STUN_HDR_LEN 20 /* STUN message header length */
#define ATTR_HDR_LEN 4 /* STUN attribute header length */
#define CHANNEL_DATA_HDR_LEN 4 /* TURN CHANNEL-DATA Message hdr length */
#define MIN_HDR_LEN 4
#define TCP_FRAME_COOKIE_LEN 10 /* min length for cookie with TCP framing */
static const value_string transportnames[] = {
{ 17, "UDP" },
{ 6, "TCP" },
{ 0, NULL }
};
static const value_string classes[] = {
{REQUEST , "Request"},
{INDICATION , "Indication"},
{SUCCESS_RESPONSE, "Success Response"},
{ERROR_RESPONSE , "Error Response"},
{0x00 , NULL}
};
static const value_string methods[] = {
{BINDING , "Binding"},
{SHARED_SECRET , "SharedSecret"},
{ALLOCATE , "Allocate"},
{REFRESH , "Refresh"},
{SEND , "Send"},
{DATA_IND , "Data"},
{CREATE_PERMISSION , "CreatePermission"},
{CHANNELBIND , "Channel-Bind"},
{CONNECT , "Connect"},
{CONNECTION_BIND , "ConnectionBind"},
{CONNECTION_ATTEMPT, "ConnectionAttempt"},
{GOOG_PING , "GooglePing"},
{0x00 , NULL}
};
static const value_string attributes[] = {
/* 0x0000-0x3FFF IETF Review comprehension-required range */
{MAPPED_ADDRESS , "MAPPED-ADDRESS"},
{RESPONSE_ADDRESS , "RESPONSE_ADDRESS"},
{CHANGE_REQUEST , "CHANGE_REQUEST"},
{SOURCE_ADDRESS , "SOURCE_ADDRESS"},
{CHANGED_ADDRESS , "CHANGED_ADDRESS"},
{USERNAME , "USERNAME"},
{PASSWORD , "PASSWORD"},
{MESSAGE_INTEGRITY , "MESSAGE-INTEGRITY"},
{ERROR_CODE , "ERROR-CODE"},
{UNKNOWN_ATTRIBUTES , "UNKNOWN-ATTRIBUTES"},
{REFLECTED_FROM , "REFLECTED-FROM"},
{CHANNEL_NUMBER , "CHANNEL-NUMBER"},
{LIFETIME , "LIFETIME"},
{MS_ALTERNATE_SERVER , "MS-ALTERNATE-SERVER"},
{MAGIC_COOKIE , "MAGIC-COOKIE"},
{BANDWIDTH , "BANDWIDTH"},
{DESTINATION_ADDRESS , "DESTINATION-ADDRESS"},
{XOR_PEER_ADDRESS , "XOR-PEER-ADDRESS"},
{DATA , "DATA"},
{REALM , "REALM"},
{NONCE , "NONCE"},
{XOR_RELAYED_ADDRESS , "XOR-RELAYED-ADDRESS"},
{REQUESTED_ADDRESS_FAMILY, "REQUESTED-ADDRESS-FAMILY"},
{EVEN_PORT , "EVEN-PORT"},
{REQUESTED_TRANSPORT , "REQUESTED-TRANSPORT"},
{DONT_FRAGMENT , "DONT-FRAGMENT"},
{ACCESS_TOKEN , "ACCESS-TOKEN"},
{MESSAGE_INTEGRITY_SHA256, "MESSAGE-INTEGRITY-SHA256"},
{PASSWORD_ALGORITHM , "PASSWORD-ALGORITHM"},
{USERHASH , "USERHASH"},
{XOR_MAPPED_ADDRESS , "XOR-MAPPED-ADDRESS"},
{RESERVATION_TOKEN , "RESERVATION-TOKEN"},
{PRIORITY , "PRIORITY"},
{USE_CANDIDATE , "USE-CANDIDATE"},
{PADDING , "PADDING"},
{XOR_RESPONSE_TARGET , "XOR-RESPONSE-TARGET"},
{XOR_REFLECTED_FROM , "XOR-REFELECTED-FROM"},
{CONNECTION_ID , "CONNECTION-ID"},
{LEGACY_ICMP , "LEGACY-ICMP"},
/* 0x4000-0x7FFF Expert Review comprehension-required range */
/* 0x8000-0xBFFF IETF Review comprehension-optional range */
{ADDITIONAL_ADDRESS_FAMILY, "ADDITIONAL-ADDRESS-FAMILY"},
{ADDRESS_ERROR_CODE , "ADDRESS-ERROR-CODE"},
{PASSWORD_ALGORITHMS , "PASSWORD-ALGORITHMS"},
{ALTERNATE_DOMAIN , "ALTERNATE-DOMAIN"},
{ICMP , "ICMP"},
{MS_TURN_UNKNOWN_8006 , "MS-TURN UNKNOWN 8006"},
{MS_VERSION , "MS-VERSION"},
{MS_XOR_MAPPED_ADDRESS , "XOR-MAPPED-ADDRESS"},
{SOFTWARE , "SOFTWARE"},
{ALTERNATE_SERVER , "ALTERNATE-SERVER"},
{TRANSACTION_TRANSMIT_COUNTER, "TRANSACTION-TRANSMIT-COUNTER"},
{CACHE_TIMEOUT , "CACHE-TIMEOUT"},
{FINGERPRINT , "FINGERPRINT"},
{ICE_CONTROLLED , "ICE-CONTROLLED"},
{ICE_CONTROLLING , "ICE-CONTROLLING"},
{RESPONSE_ORIGIN , "RESPONSE-ORIGIN"},
{OTHER_ADDRESS , "OTHER-ADDRESS"},
{ECN_CHECK_STUN , "ECN-CHECK-STUN"},
{THIRD_PARTY_AUTHORIZATION, "THIRD-PARTY-AUTHORIZATION"},
{MOBILITY_TICKET , "MOBILITY-TICKET"},
{MS_ALTERNATE_HOST_NAME, "MS-ALTERNATE-HOST-NAME"},
{MS_APP_ID , "MS-APP-ID"},
{MS_SECURE_TAG , "MS-SECURE-TAG"},
{MS_SEQUENCE_NUMBER , "MS-SEQUENCE-NUMBER"},
{MS_CANDIDATE_IDENTIFIER, "MS-CANDIDATE-IDENTIFIER"},
{MS_SERVICE_QUALITY , "MS-SERVICE-QUALITY"},
{BANDWIDTH_ACM , "Bandwidth Admission Control Message"},
{BANDWIDTH_RSV_ID , "Bandwidth Reservation Identifier"},
{BANDWIDTH_RSV_AMOUNT , "Bandwidth Reservation Amount"},
{REMOTE_SITE_ADDR , "Remote Site Address"},
{REMOTE_RELAY_SITE , "Remote Relay Site Address"},
{LOCAL_SITE_ADDR , "Local Site Address"},
{LOCAL_RELAY_SITE , "Local Relay Site Address"},
{REMOTE_SITE_ADDR_RP , "Remote Site Address Response"},
{REMOTE_RELAY_SITE_RP , "Remote Relay Site Address Response"},
{LOCAL_SITE_ADDR_RP , "Local Site Address Response"},
{LOCAL_RELAY_SITE_RP , "Local Relay Site Address Response"},
{SIP_DIALOG_ID , "SIP Dialog Identifier"},
{SIP_CALL_ID , "SIP Call Identifier"},
{LOCATION_PROFILE , "Location Profile"},
{MS_IMPLEMENTATION_VER , "MS-IMPLEMENTATION-VERSION"},
{MS_ALT_MAPPED_ADDRESS , "MS-ALT-MAPPED-ADDRESS"},
{MS_MULTIPLEXED_TURN_SESSION_ID, "MS-MULTIPLEXED-TURN-SESSION-ID"},
/* 0xC000-0xFFFF Expert Review comprehension-optional range */
{CISCO_STUN_FLOWDATA , "CISCO-STUN-FLOWDATA"},
{ENF_FLOW_DESCRIPTION , "ENF-FLOW-DESCRIPTION"},
{ENF_NETWORK_STATUS , "ENF-NETWORK-STATUS"},
{GOOG_NETWORK_INFO , "GOOG-NETWORK-INFO"},
{GOOG_LAST_ICE_CHECK_RECEIVED, "GOOG-LAST-ICE-CHECK-RECEIVED"},
{GOOG_MISC_INFO , "GOOG-MISC-INFO"},
{GOOG_OBSOLETE_1 , "GOOG-OBSOLETE-1"},
{GOOG_CONNECTION_ID , "GOOG-CONNECTION-ID"},
{GOOG_DELTA , "GOOG-DELTA"},
{GOOG_DELTA_ACK , "GOOG-DELTA-ACK"},
{GOOG_MESSAGE_INTEGRITY_32, "GOOG-MESSAGE_INTEGRITY-32"},
{GOOG_MULTI_MAPPING , "GOOG-MULTI-MAPPING"},
{GOOG_LOGGING_ID , "GOOG-LOGGING-ID"},
{0x00 , NULL}
};
static value_string_ext attributes_ext = VALUE_STRING_EXT_INIT(attributes);
static const value_string assignments[] = {
{0x0000, "IETF Review"},
{0x0001, "Designated Expert"},
{0x00, NULL}
};
static const value_string comprehensions[] = {
{0x0000, "Required"},
{0x0001, "Optional"},
{0x00 , NULL}
};
static const value_string attributes_reserve_next[] = {
{0, "No reservation"},
{1, "Reserve next port number"},
{0x00, NULL}
};
static const value_string attributes_family[] = {
{0x0001, "IPv4"},
{0x0002, "IPv6"},
{0x00, NULL}
};
/* https://www.iana.org/assignments/stun-parameters/stun-parameters.xhtml#stun-parameters-6 (2020-08-05)*/
static const value_string error_code[] = {
{274, "Disable Candidate"}, /* MS-ICE2BWN */
{275, "Disable Candidate Pair"}, /* MS-ICE2BWN */
{300, "Try Alternate"}, /* RFC8489 */
{400, "Bad Request"}, /* RFC8489 */
{401, "Unauthenticated"}, /* RFC8489, RFC3489+MS-TURN: Unauthorized */
{403, "Forbidden"}, /* RFC8656 */
{405, "Mobility Forbidden"}, /* RFC8016 */
{420, "Unknown Attribute"}, /* RFC8489 */
{430, "Stale Credentials (legacy)"}, /* RFC3489 */
{431, "Integrity Check Failure (legacy)"}, /* RFC3489 */
{432, "Missing Username (legacy)"}, /* RFC3489 */
{433, "Use TLS (legacy)"}, /* RFC3489 */
{434, "Missing Realm (legacy)"}, /* MS-TURN */
{435, "Missing Nonce (legacy)"}, /* MS-TURN */
{436, "Unknown User (legacy)"}, /* MS-TURN */
{437, "Allocation Mismatch"}, /* RFC8656 */
{438, "Stale Nonce"}, /* RFC8489 */
{439, "Wrong Credentials (legacy)"}, /* turn-07 */
{440, "Address Family not Supported"}, /* RFC8656 */
{441, "Wrong Credentials"}, /* RFC8656 */
{442, "Unsupported Transport Protocol"}, /* RFC8656 */
{443, "Peer Address Family Mismatch"}, /* RFC8656 */
{446, "Connection Already Exists"}, /* RFC6062 */
{447, "Connection Timeout or Failure"}, /* RFC6062 */
{481, "Connection does not exist (legacy)"}, /* nat-behavior-discovery-03 */
{486, "Allocation Quota Reached"}, /* RFC8656 */
{487, "Role Conflict"}, /* RFC8445 */
{500, "Server Error"}, /* RFC8489 */
{503, "Service Unavailable (legacy)"}, /* nat-behavior-discovery-03 */
{507, "Insufficient Bandwidth Capacity (legacy)"}, /* turn-07 */
{508, "Insufficient Port Capacity"}, /* RFC8656 */
{600, "Global Failure"}, /* RFC8656 */
{0x00, NULL}
};
static value_string_ext error_code_ext = VALUE_STRING_EXT_INIT(error_code);
static const value_string ms_version_vals[] = {
{0x00000001, "ICE"},
{0x00000002, "MS-ICE2"},
{0x00000003, "MS-ICE2 with SHA256"},
{0x00000004, "MS-ICE2 with SHA256 and IPv6"},
{0x00000005, "MULTIPLEXED TURN over UDP only"},
{0x00000006, "MULTIPLEXED TURN over UDP and TCP"},
{0x00, NULL}
};
static const range_string ms_version_ice_rvals[] = {
{0x00000000, 0x00000002, "Supports only RFC3489bis-02 message formats"},
{0x00000003, 0xFFFFFFFF, "Supports RFC5389 message formats"},
{0x00, 0x00, NULL}
};
static const value_string ms_stream_type_vals[] = {
{0x0001, "Audio"},
{0x0002, "Video"},
{0x0003, "Supplemental Video"},
{0x0004, "Data"},
{0x00, NULL}
};
static const value_string ms_service_quality_vals[] = {
{0x0000, "Best effort delivery"},
{0x0001, "Reliable delivery"},
{0x00, NULL}
};
static const value_string bandwidth_acm_type_vals[] = {
{0x0000, "Reservation Check"},
{0x0001, "Reservation Commit"},
{0x0002, "Reservation Update"},
{0x00, NULL}
};
static const value_string location_vals[] = {
{0x00, "Unknown"},
{0x01, "Internet"},
{0x02, "Intranet"},
{0x00, NULL}
};
static const value_string federation_vals[] = {
{0x00, "No Federation"},
{0x01, "Enterprise Federation"},
{0x02, "Public Cloud Federation"},
{0x00, NULL}
};
static const value_string password_algorithm_vals[] = {
{0x0000, "Reserved"},
{0x0001, "MD5"},
{0x0002, "SHA-256"},
{0x0000, NULL}
};
/* https://webrtc.googlesource.com/src/+/refs/heads/master/rtc_base/network_constants.h */
static const value_string google_network_cost_vals[] = {
{0, "Min"},
{10, "Low"},
{50, "Unknown"},
{250, "Cellular5G"},
{500, "Cellular4G"},
{900, "Cellular"},
{910, "Cellular3G"},
{980, "Cellular2G"},
{999, "Max"},
{0, NULL}
};
static guint
get_stun_message_len(packet_info *pinfo _U_, tvbuff_t *tvb,
int offset, void *data _U_)
{
guint16 type;
guint length;
guint captured_length = tvb_captured_length(tvb);
if ((captured_length >= TCP_FRAME_COOKIE_LEN) &&
(tvb_get_ntohl(tvb, 6) == MESSAGE_COOKIE)) {
/*
* The magic cookie is off by two, so this appears to be
* RFC 4571 framing, as per RFC 6544; use the length
* field from that framing, rather than the STUN/TURN
* ChannelData length field.
*/
return (tvb_get_ntohs(tvb, offset) + 2);
}
type = tvb_get_ntohs(tvb, offset);
length = tvb_get_ntohs(tvb, offset+2);
if (type & 0xC000)
{
/* two first bits not NULL => should be a channel-data message */
/* Note: For TCP the message is padded to a 4 byte boundary */
return (length + CHANNEL_DATA_HDR_LEN +3) & ~0x3;
}
else
{
/* Normal STUN message */
return length + STUN_HDR_LEN;
}
}
/*
* XXX: why is this done in this file by the STUN dissector? Why don't we
* re-use the packet-turnchannel.c's dissect_turnchannel_message() function?
*/
static int
dissect_stun_message_channel_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 msg_type, guint msg_length)
{
tvbuff_t *next_tvb;
heur_dtbl_entry_t *hdtbl_entry;
gint offset = CHANNEL_DATA_HDR_LEN;
/* XXX: a TURN ChannelData message is not actually a STUN message. */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "STUN");
col_set_str(pinfo->cinfo, COL_INFO, "ChannelData TURN Message");
if (tree) {
proto_item *ti;
proto_tree *stun_tree;
ti = proto_tree_add_item(
tree, proto_stun, tvb, 0,
CHANNEL_DATA_HDR_LEN,
ENC_NA);
proto_item_append_text(ti, ", TURN ChannelData Message");
stun_tree = proto_item_add_subtree(ti, ett_stun);
proto_tree_add_item(stun_tree, hf_stun_channel, tvb, 0, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(stun_tree, hf_stun_length, tvb, 2, 2, ENC_BIG_ENDIAN);
/* MS-TURN Multiplexed TURN Channel */
if (msg_type == MS_MULTIPLEX_TURN && msg_length >= 8) {
proto_tree_add_item(stun_tree, hf_stun_att_ms_turn_session_id, tvb, 4, 8, ENC_NA);
}
}
if (msg_type == MS_MULTIPLEX_TURN && msg_length >= 8) {
msg_length -= 8;
offset += 8;
}
next_tvb = tvb_new_subset_length(tvb, offset, msg_length);
if (!dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, tree, &hdtbl_entry, NULL)) {
call_dissector_only(data_handle, next_tvb, pinfo, tree, NULL);
}
return tvb_reported_length(tvb);
}
static int
dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean heur_check, gboolean is_udp)
{
guint captured_length;
guint16 msg_type;
guint msg_length;
proto_item *ti;
proto_tree *stun_tree;
proto_tree *stun_type_tree;
proto_tree *att_all_tree;
proto_tree *att_type_tree;
proto_tree *att_tree = NULL;
guint16 msg_type_method;
guint16 msg_type_class;
const char *msg_class_str;
const char *msg_method_str;
guint16 att_type, att_type_display;
guint16 att_length, att_length_pad, clear_port;
guint32 clear_ip[4];
address addr;
guint i;
guint offset;
guint magic_cookie_first_word;
guint tcp_framing_offset;
conversation_t *conversation=NULL;
stun_conv_info_t *stun_info;
stun_transaction_t *stun_trans;
wmem_tree_key_t transaction_id_key[2];
guint32 transaction_id[3];
heur_dtbl_entry_t *hdtbl_entry;
guint reported_length;
gboolean is_turn = FALSE;
gboolean found_turn_attributes = FALSE;
int network_version; /* STUN flavour of the current message */
/*
* Check if the frame is really meant for us.
*/
/* First, make sure we have enough data to do the check. */
captured_length = tvb_captured_length(tvb);
if (captured_length < MIN_HDR_LEN)
return 0;
reported_length = tvb_reported_length(tvb);
tcp_framing_offset = 0;
if ((!is_udp) && (captured_length >= TCP_FRAME_COOKIE_LEN) &&
(tvb_get_ntohl(tvb, 6) == MESSAGE_COOKIE)) {
/*
* The magic cookie is off by two, so this appears to be
* RFC 4571 framing, as per RFC 6544; the STUN/TURN
* ChannelData header begins after the 2-octet
* RFC 4571 length field.
*/
tcp_framing_offset = 2;
}
msg_type = tvb_get_ntohs(tvb, tcp_framing_offset + 0);
msg_length = tvb_get_ntohs(tvb, tcp_framing_offset + 2);
/* TURN ChannelData message ? */
if (msg_type & 0xC000) {
/* two first bits not NULL => should be a channel-data message */
/*
* If the packet is being dissected through heuristics, we never match
* TURN ChannelData because the heuristics are otherwise rather weak.
* Instead we have to have seen another STUN message type on the same
* 5-tuple, and then set that conversation for non-heuristic STUN
* dissection.
*/
if (heur_check)
return 0;
/* RFC 5764 defined a demultiplexing scheme to allow STUN to co-exist
* on the same 5-tuple as DTLS-SRTP (and ZRTP) by rejecting previously
* reserved channel numbers and method types, implicitly restricting
* channel numbers to 0x4000-0x7FFF. RFC 5766 did not incorporate this
* restriction, instead indicating that reserved numbers MUST NOT be
* dropped.
* RFCs 7983, 8489, and 8656 reconciled this and formally indicated
* that channel numbers in the reserved range MUST be dropped, while
* further restricting the channel numbers to 0x4000-0x4FFF.
* Reject the range 0x8000-0xFFFF, except for the special
* MS-TURN multiplex channel number, since no implementation has
* used any other value in that range.
*/
if (msg_type & 0x8000 && msg_type != MS_MULTIPLEX_TURN) {
/* XXX: If this packet is not being dissected through heuristics,
* then the range 0x8000-0xBFFF is quite likely to be RTP/RTCP,
* and according to RFC 7983 should be forwarded to the RTP
* dissector. However, similar to TURN ChannelData, the heuristics
* for RTP are fairly weak and turned off by default over UDP.
* It would be nice to be able to ensure that for this packet
* the RTP over UDP heuristic dissector is called while still
* rejecting the packet and removing STUN from the list of layers.
*/
return 0;
}
/* note that padding is only mandatory over streaming
protocols */
if (is_udp) {
if (reported_length != msg_length + CHANNEL_DATA_HDR_LEN &&
reported_length != ((msg_length + CHANNEL_DATA_HDR_LEN + 3) & ~0x3))
return 0;
} else { /* TCP */
if (reported_length != ((msg_length + CHANNEL_DATA_HDR_LEN + 3) & ~0x3))
return 0;
}
/* XXX: why don't we invoke the turnchannel dissector instead? */
return dissect_stun_message_channel_data(tvb, pinfo, tree, msg_type, msg_length);
}
/* Normal STUN message */
if (captured_length < STUN_HDR_LEN)
return 0;
msg_type_class = ((msg_type & 0x0010) >> 4) | ((msg_type & 0x0100) >> 7) ;
msg_type_method = (msg_type & 0x000F) | ((msg_type & 0x00E0) >> 1) | ((msg_type & 0x3E00) >> 2);
if (msg_type_method > 0xFF) {
/* "Reserved for DTLS-SRTP multiplexing collision avoidance, see RFC
* 7983. Cannot be made available for assignment without IETF Review."
* Even though not reserved until RFC 7983, these have never been
* assigned or used, including by MS-TURN.
*/
return 0;
}
/* Check if it is really a STUN message - reject messages without the
* RFC 5389 Magic and let the classicstun dissector handle those.
*/
if ( tvb_get_ntohl(tvb, tcp_framing_offset + 4) != MESSAGE_COOKIE)
return 0;
/* check if payload enough */
if (reported_length != (msg_length + STUN_HDR_LEN + tcp_framing_offset))
return 0;
/* The message seems to be a valid STUN message! */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "STUN");
/* Create the transaction key which may be used
to track the conversation */
transaction_id[0] = tvb_get_ntohl(tvb, tcp_framing_offset + 8);
transaction_id[1] = tvb_get_ntohl(tvb, tcp_framing_offset + 12);
transaction_id[2] = tvb_get_ntohl(tvb, tcp_framing_offset + 16);
transaction_id_key[0].length = 3;
transaction_id_key[0].key = transaction_id;
transaction_id_key[1].length = 0;
transaction_id_key[1].key = NULL;
switch (msg_type_method) {
/* if it's a TURN method, remember that */
case ALLOCATE:
case REFRESH:
case SEND:
case DATA_IND:
case CREATE_PERMISSION:
case CHANNELBIND:
case CONNECT:
case CONNECTION_BIND:
case CONNECTION_ATTEMPT:
is_turn = TRUE;
break;
}
conversation = find_or_create_conversation(pinfo);
/*
* Do we already have a state structure for this conv
*/
stun_info = (stun_conv_info_t *)conversation_get_proto_data(conversation, proto_stun);
if (!stun_info) {
/* No. Attach that information to the conversation, and add
* it to the list of information structures.
*/
stun_info = wmem_new(wmem_file_scope(), stun_conv_info_t);
stun_info->transaction_pdus=wmem_tree_new(wmem_file_scope());
conversation_add_proto_data(conversation, proto_stun, stun_info);
}
if (!pinfo->fd->visited) {
if ((stun_trans = (stun_transaction_t *)
wmem_tree_lookup32_array(stun_info->transaction_pdus,
transaction_id_key)) == NULL) {
transaction_id_key[0].length = 3;
transaction_id_key[0].key = transaction_id;
transaction_id_key[1].length = 0;
transaction_id_key[1].key = NULL;
stun_trans=wmem_new(wmem_file_scope(), stun_transaction_t);
stun_trans->req_frame=0;
stun_trans->rep_frame=0;
stun_trans->req_time=pinfo->abs_ts;
wmem_tree_insert32_array(stun_info->transaction_pdus,
transaction_id_key,
(void *)stun_trans);
}
if (msg_type_class == REQUEST) {
/* This is a request */
if (stun_trans->req_frame == 0) {
stun_trans->req_frame=pinfo->num;
}
} else {
/* This is a catch-all for all non-request messages */
if (stun_trans->rep_frame == 0) {
stun_trans->rep_frame=pinfo->num;
}
}
} else {
stun_trans=(stun_transaction_t *)wmem_tree_lookup32_array(stun_info->transaction_pdus,
transaction_id_key);
}
if (!stun_trans) {
/* create a "fake" pana_trans structure */
stun_trans=wmem_new(pinfo->pool, stun_transaction_t);
stun_trans->req_frame=0;
stun_trans->rep_frame=0;
stun_trans->req_time=pinfo->abs_ts;
}
msg_class_str = val_to_str_const(msg_type_class, classes, "Unknown");
msg_method_str = val_to_str_const(msg_type_method, methods, "Unknown");
col_add_lstr(pinfo->cinfo, COL_INFO,
msg_method_str,
" ",
msg_class_str,
COL_ADD_LSTR_TERMINATOR);
offset = 0;
ti = proto_tree_add_item(tree, proto_stun, tvb, offset, -1, ENC_NA);
stun_tree = proto_item_add_subtree(ti, ett_stun);
if (msg_type_class == REQUEST) {
if (stun_trans->req_frame != pinfo->num) {
proto_item *it;
it=proto_tree_add_uint(stun_tree, hf_stun_duplicate,
tvb, offset, 0,
stun_trans->req_frame);
proto_item_set_generated(it);
}
if (stun_trans->rep_frame) {
proto_item *it;
it=proto_tree_add_uint(stun_tree, hf_stun_response_in,
tvb, offset, 0,
stun_trans->rep_frame);
proto_item_set_generated(it);
}
}
else {
/* Retransmission control */
if (stun_trans->rep_frame != pinfo->num) {
proto_item *it;
it=proto_tree_add_uint(stun_tree, hf_stun_duplicate,
tvb, offset, 0,
stun_trans->rep_frame);
proto_item_set_generated(it);
}
if (msg_type_class == SUCCESS_RESPONSE || msg_type_class == ERROR_RESPONSE) {
/* This is a response */
if (stun_trans->req_frame) {
proto_item *it;
nstime_t ns;
it=proto_tree_add_uint(stun_tree, hf_stun_response_to, tvb,
offset, 0,
stun_trans->req_frame);
proto_item_set_generated(it);
nstime_delta(&ns, &pinfo->abs_ts, &stun_trans->req_time);
it=proto_tree_add_time(stun_tree, hf_stun_time, tvb,
offset, 0, &ns);
proto_item_set_generated(it);
}
}
}
if (tcp_framing_offset) {
proto_tree_add_item(stun_tree, hf_stun_tcp_frame_length, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
}
ti = proto_tree_add_uint_format_value(stun_tree, hf_stun_type, tvb, offset, 2,
msg_type, "0x%04x (%s %s)", msg_type, msg_method_str, msg_class_str);
stun_type_tree = proto_item_add_subtree(ti, ett_stun_type);
ti = proto_tree_add_uint(stun_type_tree, hf_stun_type_class, tvb, offset, 2, msg_type);
proto_item_append_text(ti, " %s (%d)", msg_class_str, msg_type_class);
ti = proto_tree_add_uint(stun_type_tree, hf_stun_type_method, tvb, offset, 2, msg_type);
proto_item_append_text(ti, " %s (0x%03x)", msg_method_str, msg_type_method);
proto_tree_add_uint(stun_type_tree, hf_stun_type_method_assignment, tvb, offset, 2, msg_type);
offset += 2;
proto_tree_add_item(stun_tree, hf_stun_length, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(stun_tree, hf_stun_cookie, tvb, offset, 4, ENC_NA);
offset += 4;
proto_tree_add_item(stun_tree, hf_stun_id, tvb, offset, 12, ENC_NA);
offset += 12;
/* Remember this (in host order) so we can show clear xor'd addresses */
magic_cookie_first_word = tvb_get_ntohl(tvb, tcp_framing_offset + 4);
network_version = stun_network_version != NET_VER_AUTO ? stun_network_version : NET_VER_5389;
if (msg_length != 0) {
const gchar *attribute_name_str;
/* According to [MS-TURN] section 2.2.2.8: "This attribute MUST be the
first attribute following the TURN message header in all TURN messages" */
if (stun_network_version == NET_VER_AUTO &&
offset < (STUN_HDR_LEN + msg_length) &&
tvb_get_ntohs(tvb, offset) == MAGIC_COOKIE) {
network_version = NET_VER_MS_TURN;
}
ti = proto_tree_add_uint(stun_tree, hf_stun_network_version, tvb, offset, 0, network_version);
proto_item_set_generated(ti);
/* Starting with RFC 5389 msg_length MUST be multiple of 4 bytes */
if ((network_version >= NET_VER_5389 && msg_length & 3) != 0)
stun_tree = proto_tree_add_expert(stun_tree, pinfo, &ei_stun_wrong_msglen, tvb, offset-18, 2);
ti = proto_tree_add_item(stun_tree, hf_stun_attributes, tvb, offset, msg_length, ENC_NA);
att_all_tree = proto_item_add_subtree(ti, ett_stun_att_all);
while (offset < (STUN_HDR_LEN + msg_length)) {
att_type = tvb_get_ntohs(tvb, offset); /* Attribute type field in attribute header */
att_length = tvb_get_ntohs(tvb, offset+2); /* Attribute length field in attribute header */
if (network_version >= NET_VER_5389)
att_length_pad = WS_ROUNDUP_4(att_length); /* Attribute length including padding */
else
att_length_pad = att_length;
att_type_display = att_type;
/* Early drafts and MS-TURN use swapped numbers to later versions */
if ((network_version < NET_VER_3489) && (att_type == 0x0014 || att_type == 0x0015)) {
att_type_display ^= 1;
}
attribute_name_str = try_val_to_str_ext(att_type_display, &attributes_ext);
if (attribute_name_str){
ti = proto_tree_add_uint_format(att_all_tree, hf_stun_attr,
tvb, offset, ATTR_HDR_LEN+att_length_pad,
att_type, "%s", attribute_name_str);
att_tree = proto_item_add_subtree(ti, ett_stun_att);
ti = proto_tree_add_uint_format_value(att_tree, hf_stun_att_type, tvb,
offset, 2, att_type, "%s", attribute_name_str);
att_type_tree = proto_item_add_subtree(ti, ett_stun_att_type);
proto_tree_add_uint(att_type_tree, hf_stun_att_type_comprehension, tvb, offset, 2, att_type);
proto_tree_add_uint(att_type_tree, hf_stun_att_type_assignment, tvb, offset, 2, att_type);
if ((offset+ATTR_HDR_LEN+att_length_pad) > (STUN_HDR_LEN+msg_length+tcp_framing_offset)) {
proto_tree_add_uint_format_value(att_tree,
hf_stun_att_length, tvb, offset+2, 2,
att_length_pad,
"%u (bogus, goes past the end of the message)",
att_length_pad);
break;
}
} else {
att_tree = proto_tree_add_expert_format(att_all_tree, pinfo, &ei_stun_unknown_attribute, tvb,
offset, 2, "Unknown attribute 0x%04x", att_type);
}
offset += 2;
proto_tree_add_uint(att_tree, hf_stun_att_length, tvb,
offset, 2, att_length);
offset += 2;
/* Zero out address */
clear_address(&addr);
switch (att_type_display) {
/* Deprecated STUN RFC3489 attributes */
case RESPONSE_ADDRESS:
case SOURCE_ADDRESS:
case CHANGED_ADDRESS:
case REFLECTED_FROM:
case DESTINATION_ADDRESS:
if (att_length < 1)
break;
proto_tree_add_item(att_tree, hf_stun_att_reserved, tvb, offset, 1, ENC_NA);
if (att_length < 2)
break;
proto_tree_add_item(att_tree, hf_stun_att_family, tvb, offset+1, 1, ENC_BIG_ENDIAN);
if (att_length < 4)
break;
proto_tree_add_item(att_tree, hf_stun_att_port, tvb, offset+2, 2, ENC_BIG_ENDIAN);
switch (tvb_get_guint8(tvb, offset+1))
{
case 1:
if (att_length < 8)
break;
proto_tree_add_item(att_tree, hf_stun_att_ipv4, tvb, offset+4, 4, ENC_BIG_ENDIAN);
proto_item_append_text(att_tree, " (Deprecated): %s:%d", tvb_ip_to_str(pinfo->pool, tvb, offset+4),tvb_get_ntohs(tvb,offset+2));
break;
case 2:
if (att_length < 20)
break;
proto_tree_add_item(att_tree, hf_stun_att_ipv6, tvb, offset+4, 16, ENC_NA);
break;
}
break;
/* Deprecated STUN RFC3489 attributes */
case PASSWORD:
{
proto_tree_add_item(att_tree, hf_stun_att_password, tvb, offset, att_length, ENC_NA);
}
break;
case MAPPED_ADDRESS:
case ALTERNATE_SERVER:
case RESPONSE_ORIGIN:
case OTHER_ADDRESS:
case MS_ALT_MAPPED_ADDRESS:
case MS_ALTERNATE_SERVER:
{
const gchar *addr_str = NULL;
guint16 att_port;
if (att_length < 1)
break;
proto_tree_add_item(att_tree, hf_stun_att_reserved, tvb, offset, 1, ENC_NA);
if (att_length < 2)
break;
proto_tree_add_item(att_tree, hf_stun_att_family, tvb, offset+1, 1, ENC_BIG_ENDIAN);
if (att_length < 4)
break;
proto_tree_add_item(att_tree, hf_stun_att_port, tvb, offset+2, 2, ENC_BIG_ENDIAN);
att_port = tvb_get_ntohs(tvb, offset + 2);
switch (tvb_get_guint8(tvb, offset+1)) {
case 1:
if (att_length < 8)
break;
addr_str = tvb_ip_to_str(pinfo->pool, tvb, offset + 4);
proto_tree_add_item(att_tree, hf_stun_att_ipv4, tvb, offset+4, 4, ENC_BIG_ENDIAN);
break;
case 2:
if (att_length < 20)
break;
addr_str = tvb_ip6_to_str(pinfo->pool, tvb, offset + 4);
proto_tree_add_item(att_tree, hf_stun_att_ipv6, tvb, offset+4, 16, ENC_NA);
break;
}
if (addr_str != NULL) {
proto_item_append_text(att_tree, ": %s:%d", addr_str, att_port);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s: %s:%d",
attribute_name_str, addr_str, att_port);
}
break;
}
case CHANGE_REQUEST:
{
gboolean change_ip, change_port;
if (att_length < 4)
break;
proto_tree_add_item_ret_boolean(att_tree, hf_stun_att_change_ip, tvb, offset, 4, ENC_BIG_ENDIAN, &change_ip);
proto_tree_add_item_ret_boolean(att_tree, hf_stun_att_change_port, tvb, offset, 4, ENC_BIG_ENDIAN, &change_port);
if (change_ip && change_port) {
col_append_str(pinfo->cinfo, COL_INFO, ", Change IP and Port");
} else if (change_ip) {
col_append_str(pinfo->cinfo, COL_INFO, ", Change IP");
} else if (change_port) {
col_append_str(pinfo->cinfo, COL_INFO, ", Change Port");
}
break;
}
case USERNAME:
{
if (network_version > NET_VER_3489) {
const guint8 *user_name_str;
proto_tree_add_item_ret_string(att_tree, hf_stun_att_username, tvb, offset, att_length, ENC_UTF_8|ENC_NA, pinfo->pool, &user_name_str);
proto_item_append_text(att_tree, ": %s", user_name_str);
col_append_fstr( pinfo->cinfo, COL_INFO, " user: %s", user_name_str);
} else {
proto_tree_add_item(att_tree, hf_stun_att_username_opaque, tvb, offset, att_length, ENC_NA);
}
break;
}
case MESSAGE_INTEGRITY:
if (att_length < 20)
break;
proto_tree_add_item(att_tree, hf_stun_att_hmac, tvb, offset, att_length, ENC_NA);
break;
case ERROR_CODE:
if (att_length < 2)
break;
proto_tree_add_item(att_tree, hf_stun_att_reserved, tvb, offset, 2, ENC_NA);
if (att_length < 3)
break;
proto_tree_add_item(att_tree, hf_stun_att_error_class, tvb, offset+2, 1, ENC_BIG_ENDIAN);
if (att_length < 4)
break;
proto_tree_add_item(att_tree, hf_stun_att_error_number, tvb, offset+3, 1, ENC_BIG_ENDIAN);
{
int human_error_num = tvb_get_guint8(tvb, offset+2) * 100 + tvb_get_guint8(tvb, offset+3);
const gchar *error_str = val_to_str_ext_const(human_error_num, &error_code_ext, "*Unknown error code*");
proto_item_append_text(
att_tree,
" %d (%s)",
human_error_num, /* human readable error code */
error_str
);
col_append_fstr(
pinfo->cinfo, COL_INFO,
" error-code: %d (%s)",
human_error_num,
error_str
);
}
if (att_length < 5)
break;
{
const guint8 *error_reas_str;
proto_tree_add_item_ret_string(att_tree, hf_stun_att_error_reason, tvb, offset + 4, att_length - 4, ENC_UTF_8 | ENC_NA, pinfo->pool, &error_reas_str);
proto_item_append_text(att_tree, ": %s", error_reas_str);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", error_reas_str);
}
break;
case UNKNOWN_ATTRIBUTES:
for (i = 0; i < att_length; i += 2)
proto_tree_add_item(att_tree, hf_stun_att_unknown, tvb, offset+i, 2, ENC_BIG_ENDIAN);
break;
case REALM:
{
const guint8 *realm_str;
proto_tree_add_item_ret_string(att_tree, hf_stun_att_realm, tvb, offset, att_length, ENC_UTF_8|ENC_NA, pinfo->pool, &realm_str);
proto_item_append_text(att_tree, ": %s", realm_str);
col_append_fstr(pinfo->cinfo, COL_INFO, " realm: %s", realm_str);
break;
}
case NONCE:
{
const guint8 *nonce_str;
proto_tree_add_item_ret_string(att_tree, hf_stun_att_nonce, tvb, offset, att_length, ENC_UTF_8|ENC_NA, pinfo->pool, &nonce_str);
proto_item_append_text(att_tree, ": %s", nonce_str);
col_append_str(pinfo->cinfo, COL_INFO, " with nonce");
break;
}
case PASSWORD_ALGORITHM:
case PASSWORD_ALGORITHMS:
{
guint alg, alg_param_len, alg_param_len_pad;
guint remaining = att_length;
while (remaining > 0) {
guint loopoffset = offset + att_length - remaining;
if (remaining < 4) {
proto_tree_add_expert_format(att_tree, pinfo, &ei_stun_short_packet, tvb,
loopoffset, remaining, "Too few bytes left for TLV header (%d < 4)", remaining);
break;
}
proto_tree_add_item_ret_uint(att_tree, hf_stun_att_pw_alg, tvb, loopoffset, 2, ENC_BIG_ENDIAN, &alg);
proto_tree_add_item_ret_uint(att_tree, hf_stun_att_pw_alg_param_len, tvb, loopoffset+2, 2, ENC_BIG_ENDIAN, &alg_param_len);
if (alg_param_len > 0) {
if (alg_param_len+4 >= remaining)
proto_tree_add_item(att_tree, hf_stun_att_pw_alg_param_data, tvb, loopoffset+4, alg_param_len, ENC_NA);
else {
proto_tree_add_expert_format(att_tree, pinfo, &ei_stun_short_packet, tvb,
loopoffset, remaining, "Too few bytes left for parameter data (%u < %u)", remaining-4, alg_param_len);
break;
}
}
/* Hopefully, in case MS-TURN ever gets PASSWORD-ALGORITHM(S) support they will add it with padding */
alg_param_len_pad = WS_ROUNDUP_4(alg_param_len);
if (alg_param_len < alg_param_len_pad)
proto_tree_add_uint(att_tree, hf_stun_att_padding, tvb, loopoffset+alg_param_len, alg_param_len_pad-alg_param_len, alg_param_len_pad-alg_param_len);
remaining -= (alg_param_len_pad + 4);
if ((att_type_display == PASSWORD_ALGORITHM) && (remaining > 0)) {
proto_tree_add_expert_format(att_tree, pinfo, &ei_stun_long_attribute, tvb,
loopoffset, remaining, " (PASSWORD-ALGORITHM)");
/* Continue anyway */
}
}
break;
}
case XOR_PEER_ADDRESS:
case XOR_RELAYED_ADDRESS:
found_turn_attributes = TRUE;
/* Fallthrough */
case XOR_MAPPED_ADDRESS:
case XOR_RESPONSE_TARGET:
case XOR_REFLECTED_FROM:
case MS_XOR_MAPPED_ADDRESS:
case REMOTE_SITE_ADDR:
case REMOTE_RELAY_SITE:
case LOCAL_SITE_ADDR:
case LOCAL_RELAY_SITE:
if (att_length < 1)
break;
proto_tree_add_item(att_tree, hf_stun_att_reserved, tvb, offset, 1, ENC_NA);
if (att_length < 2)
break;
proto_tree_add_item(att_tree, hf_stun_att_family, tvb, offset+1, 1, ENC_BIG_ENDIAN);
if (att_length < 4)
break;
proto_tree_add_item(att_tree, hf_stun_att_xor_port, tvb, offset+2, 2, ENC_NA);
/* Show the port 'in the clear'
XOR (host order) transid with (host order) xor-port.
Add host-order port into tree. */
clear_port = tvb_get_ntohs(tvb, offset+2) ^ (magic_cookie_first_word >> 16);
ti = proto_tree_add_uint(att_tree, hf_stun_att_port, tvb, offset+2, 2, clear_port);
proto_item_set_generated(ti);
if (att_length < 8)
break;
switch (tvb_get_guint8(tvb, offset+1)) {
case 1:
proto_tree_add_item(att_tree, hf_stun_att_xor_ipv4, tvb, offset+4, 4, ENC_NA);
/* Show the address 'in the clear'.
XOR (host order) transid with (host order) xor-address.
Add in network order tree. */
clear_ip[0] = tvb_get_ipv4(tvb, offset+4) ^ g_htonl(magic_cookie_first_word);
ti = proto_tree_add_ipv4(att_tree, hf_stun_att_ipv4, tvb, offset+4, 4, clear_ip[0]);
proto_item_set_generated(ti);
set_address(&addr, AT_IPv4, 4, clear_ip);
break;
case 2:
if (att_length < 20)
break;
proto_tree_add_item(att_tree, hf_stun_att_xor_ipv6, tvb, offset+4, 16, ENC_NA);
tvb_get_ipv6(tvb, offset+4, (ws_in6_addr *)clear_ip);
clear_ip[0] ^= g_htonl(magic_cookie_first_word);
clear_ip[1] ^= g_htonl(transaction_id[0]);
clear_ip[2] ^= g_htonl(transaction_id[1]);
clear_ip[3] ^= g_htonl(transaction_id[2]);
ti = proto_tree_add_ipv6(att_tree, hf_stun_att_ipv6, tvb, offset+4, 16,
(const ws_in6_addr *)clear_ip);
proto_item_set_generated(ti);
set_address(&addr, AT_IPv6, 16, &clear_ip);
break;
default:
clear_address(&addr);
break;
}
if (addr.type != AT_NONE) {
const gchar *ipstr = address_to_str(pinfo->pool, &addr);
proto_item_append_text(att_tree, ": %s:%d", ipstr, clear_port);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s: %s:%d",
attribute_name_str, ipstr, clear_port);
}
break;
case REQUESTED_ADDRESS_FAMILY:
if (att_length < 1)
break;
proto_tree_add_item(att_tree, hf_stun_att_family, tvb, offset, 1, ENC_BIG_ENDIAN);
if (att_length < 4)
break;
proto_tree_add_item(att_tree, hf_stun_att_reserved, tvb, offset+1, 3, ENC_NA);
break;
case EVEN_PORT:
if (att_length < 1)
break;
proto_tree_add_item(att_tree, hf_stun_att_reserve_next, tvb, offset, 1, ENC_BIG_ENDIAN);
found_turn_attributes = TRUE;
break;
case RESERVATION_TOKEN:
if (att_length < 8)
break;
proto_tree_add_item(att_tree, hf_stun_att_token, tvb, offset, 8, ENC_NA);
found_turn_attributes = TRUE;
break;
case PRIORITY:
if (att_length < 4)
break;
proto_tree_add_item(att_tree, hf_stun_att_priority, tvb, offset, 4, ENC_BIG_ENDIAN);
break;
case PADDING:
proto_tree_add_uint(att_tree, hf_stun_att_padding, tvb, offset, att_length, att_length);
break;
case LEGACY_ICMP:
case ICMP:
if (att_length < 4)
break;
proto_tree_add_item(att_tree, hf_stun_att_icmp_type, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(att_tree, hf_stun_att_icmp_code, tvb, offset+1, 1, ENC_BIG_ENDIAN);
break;
case MS_TURN_UNKNOWN_8006:
proto_tree_add_item(att_tree, hf_stun_att_ms_turn_unknown_8006, tvb, offset, att_length, ENC_NA);
break;
case SOFTWARE:
proto_tree_add_item(att_tree, hf_stun_att_software, tvb, offset, att_length, ENC_UTF_8);
break;
case CACHE_TIMEOUT:
if (att_length < 4)
break;
proto_tree_add_item(att_tree, hf_stun_att_cache_timeout, tvb, offset, 4, ENC_BIG_ENDIAN);
break;
case FINGERPRINT:
if (att_length < 4)
break;
proto_tree_add_checksum(att_tree, tvb, offset, hf_stun_att_crc32, hf_stun_att_crc32_status, &ei_stun_fingerprint_bad, pinfo, crc32_ccitt_tvb_offset(tvb, tcp_framing_offset, offset-4-tcp_framing_offset) ^ 0x5354554e, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
break;
case ICE_CONTROLLED:
case ICE_CONTROLLING:
if (att_length < 8)
break;
proto_tree_add_item(att_tree, hf_stun_att_tie_breaker, tvb, offset, 8, ENC_NA);
break;
case DATA:
if (att_length > 0) {
tvbuff_t *next_tvb;
proto_tree_add_item(att_tree, hf_stun_att_value, tvb, offset, att_length, ENC_NA);
next_tvb = tvb_new_subset_length(tvb, offset, att_length);
if (!dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, att_tree, &hdtbl_entry, NULL)) {
call_dissector_only(data_handle, next_tvb, pinfo, att_tree, NULL);
}
}
found_turn_attributes = TRUE;
break;
case REQUESTED_TRANSPORT:
if (att_length < 1)
break;
proto_tree_add_item(att_tree, hf_stun_att_transp, tvb, offset, 1, ENC_BIG_ENDIAN);
if (att_length < 4)
break;
{
guint8 protoCode = tvb_get_guint8(tvb, offset);
const gchar *protoCode_str = val_to_str(protoCode, transportnames, "Unknown (0x%8x)");
proto_item_append_text(att_tree, ": %s", protoCode_str);
col_append_fstr(
pinfo->cinfo, COL_INFO,
" %s",
protoCode_str
);
}
proto_tree_add_item(att_tree, hf_stun_att_reserved, tvb, offset+1, 3, ENC_NA);
found_turn_attributes = TRUE;
break;
case CHANNEL_NUMBER:
if (att_length < 4)
break;
proto_tree_add_item(att_tree, hf_stun_att_channelnum, tvb, offset, 2, ENC_BIG_ENDIAN);
{
guint16 chan = tvb_get_ntohs(tvb, offset);
proto_item_append_text(att_tree, ": 0x%x", chan);
col_append_fstr(
pinfo->cinfo, COL_INFO,
" ChannelNumber=0x%x",
chan
);
}
proto_tree_add_item(att_tree, hf_stun_att_reserved, tvb, offset+2, 2, ENC_NA);
found_turn_attributes = TRUE;
break;
case MAGIC_COOKIE:
if (att_length < 4)
break;
proto_tree_add_item(att_tree, hf_stun_att_magic_cookie, tvb, offset, 4, ENC_BIG_ENDIAN);
break;
case BANDWIDTH:
if (att_length < 4)
break;
proto_tree_add_item(att_tree, hf_stun_att_bandwidth, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_item_append_text(att_tree, " %d", tvb_get_ntohl(tvb, offset));
col_append_fstr(
pinfo->cinfo, COL_INFO,
" bandwidth: %d",
tvb_get_ntohl(tvb, offset)
);
found_turn_attributes = TRUE;
break;
case LIFETIME:
if (att_length < 4)
break;
proto_tree_add_item(att_tree, hf_stun_att_lifetime, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_item_append_text(att_tree, " %d", tvb_get_ntohl(tvb, offset));
col_append_fstr(
pinfo->cinfo, COL_INFO,
" lifetime: %d",
tvb_get_ntohl(tvb, offset)
);
found_turn_attributes = TRUE;
break;
case MS_VERSION:
proto_tree_add_item(att_tree, hf_stun_att_ms_version, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_item_append_text(att_tree, ": %s", val_to_str(tvb_get_ntohl(tvb, offset), ms_version_vals, "Unknown (0x%u)"));
break;
case MS_IMPLEMENTATION_VER:
proto_tree_add_item(att_tree, hf_stun_att_ms_version_ice, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_item_append_text(att_tree, ": %s", rval_to_str(tvb_get_ntohl(tvb, offset), ms_version_ice_rvals, "Unknown (0x%u)"));
break;
case MS_SEQUENCE_NUMBER:
proto_tree_add_item(att_tree, hf_stun_att_ms_connection_id, tvb, offset, 20, ENC_NA);
proto_tree_add_item(att_tree, hf_stun_att_ms_sequence_number, tvb, offset+20, 4, ENC_BIG_ENDIAN);
break;
case MS_SERVICE_QUALITY:
proto_tree_add_item(att_tree, hf_stun_att_ms_stream_type, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(att_tree, hf_stun_att_ms_service_quality, tvb, offset+2, 2, ENC_BIG_ENDIAN);
break;
case BANDWIDTH_ACM:
proto_tree_add_item(att_tree, hf_stun_att_reserved, tvb, offset, 2, ENC_NA);
proto_tree_add_item(att_tree, hf_stun_att_bandwidth_acm_type, tvb, offset+2, 2, ENC_BIG_ENDIAN);
break;
case BANDWIDTH_RSV_ID:
proto_tree_add_item(att_tree, hf_stun_att_bandwidth_rsv_id, tvb, offset, 16, ENC_NA);
break;
case BANDWIDTH_RSV_AMOUNT:
proto_tree_add_item(att_tree, hf_stun_att_bandwidth_rsv_amount_masb, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(att_tree, hf_stun_att_bandwidth_rsv_amount_misb, tvb, offset+4, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(att_tree, hf_stun_att_bandwidth_rsv_amount_marb, tvb, offset+8, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(att_tree, hf_stun_att_bandwidth_rsv_amount_mirb, tvb, offset+12, 4, ENC_BIG_ENDIAN);
break;
case REMOTE_SITE_ADDR_RP:
case LOCAL_SITE_ADDR_RP:
proto_tree_add_item(att_tree, hf_stun_att_address_rp_a, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(att_tree, hf_stun_att_address_rp_b, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(att_tree, hf_stun_att_address_rp_rsv1, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(att_tree, hf_stun_att_address_rp_masb, tvb, offset+4, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(att_tree, hf_stun_att_address_rp_marb, tvb, offset+8, 4, ENC_BIG_ENDIAN);
break;
case REMOTE_RELAY_SITE_RP:
case LOCAL_RELAY_SITE_RP:
proto_tree_add_item(att_tree, hf_stun_att_address_rp_a, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(att_tree, hf_stun_att_address_rp_rsv2, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(att_tree, hf_stun_att_address_rp_masb, tvb, offset+4, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(att_tree, hf_stun_att_address_rp_marb, tvb, offset+8, 4, ENC_BIG_ENDIAN);
break;
case SIP_DIALOG_ID:
proto_tree_add_item(att_tree, hf_stun_att_sip_dialog_id, tvb, offset, att_length, ENC_NA);
break;
case SIP_CALL_ID:
proto_tree_add_item(att_tree, hf_stun_att_sip_call_id, tvb, offset, att_length, ENC_NA);
break;
case LOCATION_PROFILE:
proto_tree_add_item(att_tree, hf_stun_att_lp_peer_location, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(att_tree, hf_stun_att_lp_self_location, tvb, offset+1, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(att_tree, hf_stun_att_lp_federation, tvb, offset+2, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(att_tree, hf_stun_att_reserved, tvb, offset+3, 1, ENC_NA);
break;
case MS_CANDIDATE_IDENTIFIER:
proto_tree_add_item(att_tree, hf_stun_att_ms_foundation, tvb, offset, 4, ENC_ASCII);
break;
case MS_MULTIPLEXED_TURN_SESSION_ID:
proto_tree_add_item(att_tree, hf_stun_att_ms_multiplexed_turn_session_id, tvb, offset, 8, ENC_NA);
/* Trick to force decoding of MS-TURN Multiplexed TURN channels */
found_turn_attributes = TRUE;
break;
case GOOG_NETWORK_INFO:
proto_tree_add_item(att_tree, hf_stun_att_google_network_id, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(att_tree, hf_stun_att_google_network_cost, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
break;
default:
if (att_length > 0)
proto_tree_add_item(att_tree, hf_stun_att_value, tvb, offset, att_length, ENC_NA);
break;
}
if ((network_version >= NET_VER_5389) && (att_length < att_length_pad))
proto_tree_add_uint(att_tree, hf_stun_att_padding, tvb, offset+att_length, att_length_pad-att_length, att_length_pad-att_length);
offset += att_length_pad;
}
}
if (found_turn_attributes) {
/* At least one STUN/TURN implementation (Facetime) uses unknown/custom
* TURN methods to setup a Channel Data, so the previous check to set
* "is_turn" variable fails. Fortunately, standard TURN attributes are still
* used in the replies */
is_turn = TRUE;
}
if (heur_check && conversation) {
/*
* When in heuristic dissector mode, if this is a STUN message, set
* the 5-tuple conversation to always decode as non-heuristic. The
* odds of incorrectly identifying a random packet as a STUN message
* (other than TURN ChannelData) is small, especially with RFC 7983
* implemented. A ChannelData message won't be matched when in heuristic
* mode, so heur_check can't be true in that case and get to this part
* of the code.
*
* XXX: If we ever support STUN over [D]TLS (or MS-TURN's Pseudo-TLS)
* as a heuristic dissector (instead of through ALPN), make sure to
* set the TLS app_handle instead of changing the conversation
* dissector from TLS. As it is, heur_check is FALSE over [D]TLS so
* we won't get here.
*/
if (pinfo->ptype == PT_TCP) {
conversation_set_dissector(conversation, stun_tcp_handle);
} else if (pinfo->ptype == PT_UDP) {
conversation_set_dissector(conversation, stun_udp_handle);
}
}
if (!PINFO_FD_VISITED(pinfo) && is_turn && (pinfo->ptype == PT_TCP)
&& (msg_type_method == CONNECTION_BIND) && (msg_type_class == SUCCESS_RESPONSE)) {
/* RFC 6062: after the ConnectionBind exchange, the connection is no longer framed as TURN;
instead, it is an unframed pass-through.
Starting from next frame set conversation dissector to data */
conversation_set_dissector_from_frame_number(conversation, pinfo->num+1, data_handle);
}
return reported_length;
}
static int
dissect_stun_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
return dissect_stun_message(tvb, pinfo, tree, FALSE, TRUE);
}
static int
dissect_stun_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
return dissect_stun_message(tvb, pinfo, tree, FALSE, FALSE);
}
static int
dissect_stun_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, MIN_HDR_LEN,
get_stun_message_len, dissect_stun_tcp_pdu, data);
return tvb_reported_length(tvb);
}
static gboolean
dissect_stun_heur_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
conversation_t *conversation;
guint captured_length;
guint16 msg_type;
guint msg_length;
guint tcp_framing_offset;
guint reported_length;
/* There might be multiple STUN messages in a TCP payload: try finding a valid
message and then switch to non-heuristic TCP dissector which will handle
multiple messages and reassembler stuff correctly */
captured_length = tvb_captured_length(tvb);
if (captured_length < MIN_HDR_LEN)
return FALSE;
reported_length = tvb_reported_length(tvb);
tcp_framing_offset = 0;
if ((captured_length >= TCP_FRAME_COOKIE_LEN) &&
(tvb_get_ntohl(tvb, 6) == MESSAGE_COOKIE)) {
/*
* The magic cookie is off by two, so this appears to be
* RFC 4571 framing, as per RFC 6544; the STUN/TURN
* ChannelData header begins after the 2-octet
* RFC 4571 length field.
*/
tcp_framing_offset = 2;
}
msg_type = tvb_get_ntohs(tvb, tcp_framing_offset + 0);
msg_length = tvb_get_ntohs(tvb, tcp_framing_offset + 2);
/* TURN ChannelData message ? */
if (msg_type & 0xC000) {
/* We don't want to handle TURN ChannelData message in heuristic function
See comment in dissect_stun_message() */
return FALSE;
}
/* Normal STUN message */
if (captured_length < STUN_HDR_LEN)
return FALSE;
/* Check if it is really a STUN message */
if (tvb_get_ntohl(tvb, tcp_framing_offset + 4) != MESSAGE_COOKIE)
return FALSE;
/* We may have more than one STUN message in the TCP payload */
if (reported_length < (msg_length + STUN_HDR_LEN + tcp_framing_offset))
return FALSE;
conversation = find_or_create_conversation(pinfo);
conversation_set_dissector(conversation, stun_tcp_handle);
dissect_stun_tcp(tvb, pinfo, tree, data);
return TRUE;
}
static gboolean
dissect_stun_heur_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
if (dissect_stun_message(tvb, pinfo, tree, TRUE, TRUE) == 0)
return FALSE;
return TRUE;
}
void
proto_register_stun(void)
{
static hf_register_info hf[] = {
{ &hf_stun_channel,
{ "Channel Number", "stun.channel", FT_UINT16,
BASE_HEX, NULL, 0x0, NULL, HFILL }
},
/* ////////////////////////////////////// */
{ &hf_stun_tcp_frame_length,
{ "TCP Frame Length", "stun.tcp_frame_length", FT_UINT16,
BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_type,
{ "Message Type", "stun.type", FT_UINT16,
BASE_HEX, NULL,0, NULL, HFILL }
},
{ &hf_stun_type_class,
{ "Message Class", "stun.type.class", FT_UINT16,
BASE_HEX, NULL, 0x0110, NULL, HFILL }
},
{ &hf_stun_type_method,
{ "Message Method", "stun.type.method", FT_UINT16,
BASE_HEX, NULL, 0x3EEF, NULL, HFILL }
},
{ &hf_stun_type_method_assignment,
{ "Message Method Assignment", "stun.type.method-assignment", FT_UINT16,
BASE_HEX, VALS(assignments), 0x2000, NULL, HFILL }
},
{ &hf_stun_length,
{ "Message Length", "stun.length", FT_UINT16,
BASE_DEC, NULL, 0x0, "Payload (attributes) length", HFILL }
},
{ &hf_stun_cookie,
{ "Message Cookie", "stun.cookie", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_id,
{ "Message Transaction ID", "stun.id", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_attributes,
{ "Attributes", "stun.attributes", FT_NONE,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_attr,
{ "Attribute Type", "stun.attribute", FT_UINT16,
BASE_HEX, NULL, 0, NULL, HFILL }
},
{ &hf_stun_response_in,
{ "Response In", "stun.response-in", FT_FRAMENUM,
BASE_NONE, NULL, 0x0, "The response to this STUN query is in this frame", HFILL }
},
{ &hf_stun_response_to,
{ "Request In", "stun.response-to", FT_FRAMENUM,
BASE_NONE, NULL, 0x0, "This is a response to the STUN Request in this frame", HFILL }
},
{ &hf_stun_time,
{ "Time", "stun.time", FT_RELATIVE_TIME,
BASE_NONE, NULL, 0x0, "The time between the Request and the Response", HFILL }
},
{ &hf_stun_duplicate,
{ "Duplicated original message in", "stun.reqduplicate", FT_FRAMENUM,
BASE_NONE, NULL, 0x0, "This is a duplicate of STUN message in this frame", HFILL }
},
/* ////////////////////////////////////// */
{ &hf_stun_att_type,
{ "Attribute Type", "stun.att.type", FT_UINT16,
BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_type_comprehension,
{ "Attribute Type Comprehension", "stun.att.type.comprehension", FT_UINT16,
BASE_HEX, VALS(comprehensions), 0x8000, NULL, HFILL }
},
{ &hf_stun_att_type_assignment,
{ "Attribute Type Assignment", "stun.att.type.assignment", FT_UINT16,
BASE_HEX, VALS(assignments), 0x4000, NULL, HFILL }
},
{ &hf_stun_att_length,
{ "Attribute Length", "stun.att.length", FT_UINT16,
BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_family,
{ "Protocol Family", "stun.att.family", FT_UINT8,
BASE_HEX, VALS(attributes_family), 0x0, NULL, HFILL }
},
{ &hf_stun_att_ipv4,
{ "IP", "stun.att.ipv4", FT_IPv4,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_ipv6,
{ "IP", "stun.att.ipv6", FT_IPv6,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_port,
{ "Port", "stun.att.port", FT_UINT16,
BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_username,
{ "Username", "stun.att.username", FT_STRING,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_username_opaque,
{ "Username", "stun.att.username.opaque", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_password,
{ "Password", "stun.att.password", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_padding,
{ "Padding", "stun.att.padding", FT_UINT16,
BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_hmac,
{ "HMAC-SHA1", "stun.att.hmac", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_crc32,
{ "CRC-32", "stun.att.crc32", FT_UINT32,
BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_crc32_status,
{ "CRC-32 Status", "stun.att.crc32.status", FT_UINT8,
BASE_NONE, VALS(proto_checksum_vals), 0x0, NULL, HFILL }
},
{ &hf_stun_att_error_class,
{ "Error Class","stun.att.error.class", FT_UINT8,
BASE_DEC, NULL, 0x07, NULL, HFILL}
},
{ &hf_stun_att_error_number,
{ "Error Code","stun.att.error", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_error_reason,
{ "Error Reason Phrase","stun.att.error.reason", FT_STRING,
BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_realm,
{ "Realm", "stun.att.realm", FT_STRING,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_nonce,
{ "Nonce", "stun.att.nonce", FT_STRING,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_unknown,
{ "Unknown Attribute","stun.att.unknown", FT_UINT16,
BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_xor_ipv4,
{ "IP (XOR-d)", "stun.att.ipv4-xord", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_xor_ipv6,
{ "IP (XOR-d)", "stun.att.ipv6-xord", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_xor_port,
{ "Port (XOR-d)", "stun.att.port-xord", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_icmp_type,
{ "ICMP type", "stun.att.icmp.type", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_icmp_code,
{ "ICMP code", "stun.att.icmp.code", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_ms_turn_unknown_8006,
{ "Unknown8006", "stun.att.unknown8006", FT_BYTES,
BASE_NONE, NULL, 0x0, "MS-TURN Unknown Attribute 0x8006", HFILL }
},
{ &hf_stun_att_software,
{ "Software","stun.att.software", FT_STRING,
BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_priority,
{ "Priority", "stun.att.priority", FT_UINT32,
BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_tie_breaker,
{ "Tie breaker", "stun.att.tie-breaker", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_lifetime,
{ "Lifetime", "stun.att.lifetime", FT_UINT32,
BASE_DEC, NULL, 0x0, "Session idle time remaining (seconds)", HFILL}
},
{ &hf_stun_att_change_ip,
{ "Change IP","stun.att.change-ip", FT_BOOLEAN,
16, TFS(&tfs_set_notset), 0x0004, NULL, HFILL}
},
{ &hf_stun_att_change_port,
{ "Change Port","stun.att.change-port", FT_BOOLEAN,
16, TFS(&tfs_set_notset), 0x0002, NULL, HFILL}
},
{ &hf_stun_att_pw_alg,
{ "Password Algorithm", "stun.att.pw_alg", FT_UINT16,
BASE_DEC, VALS(password_algorithm_vals), 0x0, NULL, HFILL }
},
{ &hf_stun_att_pw_alg_param_len,
{ "Password Algorithm Length", "stun.att.pw_alg_len", FT_UINT16,
BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_pw_alg_param_data,
{ "Password Algorithm Data", "stun.att.pw_alg_data", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_reserve_next,
{ "Reserve next","stun.att.even-port.reserve-next", FT_UINT8,
BASE_DEC, VALS(attributes_reserve_next), 0x80, NULL, HFILL}
},
{ &hf_stun_att_cache_timeout,
{ "Cache timeout", "stun.att.cache-timeout", FT_UINT32,
BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_token,
{ "Token", "stun.att.token", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_value,
{ "Value", "stun.value", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_reserved,
{ "Reserved", "stun.att.reserved", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_transp,
{ "Transport", "stun.att.transp", FT_UINT8,
BASE_HEX, VALS(transportnames), 0x0, NULL, HFILL }
},
{ &hf_stun_att_channelnum,
{ "Channel-Number", "stun.att.channelnum", FT_UINT16,
BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_magic_cookie,
{ "Magic Cookie", "stun.att.magic_cookie", FT_UINT32,
BASE_HEX, NULL, 0x0, NULL, HFILL }
},
{ &hf_stun_att_bandwidth,
{ "Bandwidth", "stun.port.bandwidth", FT_UINT32,
BASE_DEC, NULL, 0x0, "Peak Bandwidth (kBit/s)", HFILL }
},
{ &hf_stun_att_ms_version,
{ "MS Version", "stun.att.ms.version", FT_UINT32,
BASE_DEC, VALS(ms_version_vals), 0x0, NULL, HFILL}
},
{ &hf_stun_att_ms_version_ice,
{ "MS ICE Version", "stun.att.ms.version.ice", FT_UINT32,
BASE_DEC|BASE_RANGE_STRING, RVALS(ms_version_ice_rvals),
0x0, NULL, HFILL}
},
{ &hf_stun_att_ms_connection_id,
{ "Connection ID", "stun.att.ms.connection_id", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_ms_sequence_number,
{ "Sequence Number", "stun.att.ms.sequence_number", FT_UINT32,
BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_ms_stream_type,
{ "Stream Type", "stun.att.ms.stream_type", FT_UINT16,
BASE_DEC, VALS(ms_stream_type_vals), 0x0, NULL, HFILL}
},
{ &hf_stun_att_ms_service_quality,
{ "Service Quality", "stun.att.ms.service_quality", FT_UINT16,
BASE_DEC, VALS(ms_service_quality_vals), 0x0, NULL, HFILL}
},
{ &hf_stun_att_ms_foundation,
{ "Foundation", "stun.att.ms.foundation", FT_STRING,
BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_ms_multiplexed_turn_session_id,
{ "MS Multiplexed TURN Session Id", "stun.att.ms.multiplexed_turn_session_id", FT_UINT64,
BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_ms_turn_session_id,
{ "MS TURN Session Id", "stun.att.ms.turn_session_id", FT_UINT64,
BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_bandwidth_acm_type,
{ "Message Type", "stun.att.bandwidth_acm.type", FT_UINT16,
BASE_DEC, VALS(bandwidth_acm_type_vals), 0x0, NULL, HFILL}
},
{ &hf_stun_att_bandwidth_rsv_id,
{ "Reservation ID", "stun.att.bandwidth_rsv_id", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_bandwidth_rsv_amount_misb,
{ "Minimum Send Bandwidth", "stun.att.bandwidth_rsv_amount.misb", FT_UINT32,
BASE_DEC, NULL, 0x0, "In kilobits per second", HFILL}
},
{ &hf_stun_att_bandwidth_rsv_amount_masb,
{ "Maximum Send Bandwidth", "stun.att.bandwidth_rsv_amount.masb", FT_UINT32,
BASE_DEC, NULL, 0x0, "In kilobits per second", HFILL}
},
{ &hf_stun_att_bandwidth_rsv_amount_mirb,
{ "Minimum Receive Bandwidth", "stun.att.bandwidth_rsv_amount.mirb", FT_UINT32,
BASE_DEC, NULL, 0x0, "In kilobits per second", HFILL}
},
{ &hf_stun_att_bandwidth_rsv_amount_marb,
{ "Maximum Receive Bandwidth", "stun.att.bandwidth_rsv_amount.marb", FT_UINT32,
BASE_DEC, NULL, 0x0, "In kilobits per second", HFILL}
},
{ &hf_stun_att_address_rp_a,
{ "Valid", "stun.att.address_rp.valid", FT_BOOLEAN,
32, TFS(&tfs_yes_no), 0x80000000, NULL, HFILL}
},
{ &hf_stun_att_address_rp_b,
{ "PSTN", "stun.att.address_rp.pstn", FT_BOOLEAN,
32, TFS(&tfs_yes_no), 0x40000000, NULL, HFILL}
},
{ &hf_stun_att_address_rp_rsv1,
{ "Reserved", "stun.att.address_rp.reserved", FT_UINT32,
BASE_HEX, NULL, 0x3FFFFFFF, NULL, HFILL}
},
{ &hf_stun_att_address_rp_rsv2,
{ "Reserved", "stun.att.address_rp.reserved", FT_UINT32,
BASE_HEX, NULL, 0x7FFFFFFF, NULL, HFILL}
},
{ &hf_stun_att_address_rp_masb,
{ "Maximum Send Bandwidth", "stun.att.address_rp.masb", FT_UINT32,
BASE_DEC, NULL, 0x0, "In kilobits per second", HFILL}
},
{ &hf_stun_att_address_rp_marb,
{ "Maximum Receive Bandwidth", "stun.att.address_rp.marb", FT_UINT32,
BASE_DEC, NULL, 0x0, "In kilobits per second", HFILL}
},
{ &hf_stun_att_sip_dialog_id,
{ "SIP Dialog ID", "stun.att.sip_dialog_id", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_sip_call_id,
{ "SIP Call ID", "stun.att.sip_call_id", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_lp_peer_location,
{ "Peer Location", "stun.att.lp.peer_location", FT_UINT8,
BASE_DEC, VALS(location_vals), 0x0, NULL, HFILL}
},
{ &hf_stun_att_lp_self_location,
{ "Self Location", "stun.att.lp.seft_location", FT_UINT8,
BASE_DEC, VALS(location_vals), 0x0, NULL, HFILL}
},
{ &hf_stun_att_lp_federation,
{ "Federation", "stun.att.lp.federation", FT_UINT8,
BASE_DEC, VALS(federation_vals), 0x0, NULL, HFILL}
},
{ &hf_stun_att_google_network_id,
{ "Google Network ID", "stun.att.google.network_id", FT_UINT16,
BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{ &hf_stun_att_google_network_cost,
{ "Google Network Cost", "stun.att.google.network_cost", FT_UINT16,
BASE_DEC, VALS(google_network_cost_vals), 0x0, NULL, HFILL}
},
{ &hf_stun_network_version,
{ "STUN Network Version", "stun.network_version", FT_UINT8,
BASE_DEC, VALS(network_versions_vals), 0x0, NULL, HFILL }
},
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_stun,
&ett_stun_type,
&ett_stun_att_all,
&ett_stun_att,
&ett_stun_att_type,
};
static ei_register_info ei[] = {
{ &ei_stun_short_packet,
{ "stun.short_packet", PI_MALFORMED, PI_ERROR, "Packet is too short", EXPFILL }},
{ &ei_stun_wrong_msglen,
{ "stun.wrong_msglen", PI_MALFORMED, PI_ERROR, "Packet length is not multiple of 4 bytes", EXPFILL }},
{ &ei_stun_long_attribute,
{ "stun.long_attribute", PI_MALFORMED, PI_WARN, "Attribute has trailing data", EXPFILL }},
{ &ei_stun_unknown_attribute,
{ "stun.unknown_attribute", PI_UNDECODED, PI_WARN, "Attribute unknown", EXPFILL }},
{ &ei_stun_fingerprint_bad,
{ "stun.att.crc32.bad", PI_CHECKSUM, PI_WARN, "Bad Fingerprint", EXPFILL }},
};
module_t *stun_module;
expert_module_t* expert_stun;
/* Register the protocol name and description */
proto_stun = proto_register_protocol("Session Traversal Utilities for NAT", "STUN", "stun");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_stun, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
/* heuristic subdissectors (used for the DATA field) */
heur_subdissector_list = register_heur_dissector_list("stun", proto_stun);
register_dissector("stun-tcp", dissect_stun_tcp, proto_stun);
register_dissector("stun-udp", dissect_stun_udp, proto_stun);
register_dissector("stun-heur", dissect_stun_heur_udp, proto_stun);
/* Register preferences */
stun_module = prefs_register_protocol(proto_stun, NULL);
prefs_register_enum_preference(stun_module,
"stunversion", "Stun Version", "Stun Version on the Network",
&stun_network_version,
stun_network_version_vals,
FALSE);
expert_stun = expert_register_protocol(proto_stun);
expert_register_field_array(expert_stun, ei, array_length(ei));
}
void
proto_reg_handoff_stun(void)
{
stun_tcp_handle = find_dissector("stun-tcp");
stun_udp_handle = find_dissector("stun-udp");
dissector_add_uint_with_preference("tcp.port", TCP_PORT_STUN, stun_tcp_handle);
dissector_add_uint_with_preference("udp.port", UDP_PORT_STUN, stun_udp_handle);
/*
* SSL/TLS and DTLS Application-Layer Protocol Negotiation (ALPN)
* protocol ID.
*/
dissector_add_string("tls.alpn", "stun.nat-discovery", stun_tcp_handle);
dissector_add_string("dtls.alpn", "stun.nat-discovery", stun_udp_handle);
heur_dissector_add("udp", dissect_stun_heur_udp, "STUN over UDP", "stun_udp", proto_stun, HEURISTIC_ENABLE);
heur_dissector_add("tcp", dissect_stun_heur_tcp, "STUN over TCP", "stun_tcp", proto_stun, HEURISTIC_ENABLE);
/* STUN messages may be encapsulated in Send Indication or Channel Data message as DATA payload
* (in TURN and CLASSICSTUN, both) */
heur_dissector_add("stun", dissect_stun_heur_udp, "STUN over TURN", "stun_turn", proto_stun, HEURISTIC_DISABLE);
heur_dissector_add("classicstun", dissect_stun_heur_udp, "STUN over CLASSICSTUN", "stun_classicstun", proto_stun, HEURISTIC_DISABLE);
data_handle = find_dissector("data");
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
|
C
|
wireshark/epan/dissectors/packet-sua.c
|
/* packet-sua.c
* Routines for SS7 SCCP-User Adaptation Layer (SUA) dissection
* It is hopefully (needs testing) compliant to
* https://tools.ietf.org/html/draft-ietf-sigtran-sua-08
* https://tools.ietf.org/html/rfc3868
*
* Copyright 2002, 2003, 2004 Michael Tuexen <tuexen [AT] fh-muenster.de>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* Copied from README.developer
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/address_types.h>
#include <epan/prefs.h>
#include <epan/sctpppids.h>
#include <epan/tap.h>
#include <epan/to_str.h>
#include <wsutil/str_util.h>
#include <wsutil/ws_roundup.h>
#include "packet-mtp3.h"
#include "packet-sccp.h"
void proto_register_sua(void);
void proto_reg_handoff_sua(void);
#define SCTP_PORT_SUA 14001
#define RESERVED_1_LENGTH 1
#define RESERVED_2_LENGTH 2
#define RESERVED_3_LENGTH 3
#define VERSION_LENGTH 1
#define RESERVED_LENGTH 1
#define MESSAGE_CLASS_LENGTH 1
#define MESSAGE_TYPE_LENGTH 1
#define MESSAGE_LENGTH_LENGTH 4
#define COMMON_HEADER_LENGTH (VERSION_LENGTH + RESERVED_LENGTH + MESSAGE_CLASS_LENGTH + \
MESSAGE_TYPE_LENGTH + MESSAGE_LENGTH_LENGTH)
#define COMMON_HEADER_OFFSET 0
#define VERSION_OFFSET COMMON_HEADER_OFFSET
#define RESERVED_OFFSET (VERSION_OFFSET + VERSION_LENGTH)
#define MESSAGE_CLASS_OFFSET (RESERVED_OFFSET + RESERVED_LENGTH)
#define MESSAGE_TYPE_OFFSET (MESSAGE_CLASS_OFFSET + MESSAGE_CLASS_LENGTH)
#define MESSAGE_LENGTH_OFFSET (MESSAGE_TYPE_OFFSET + MESSAGE_TYPE_LENGTH)
#define PARAMETER_TAG_LENGTH 2
#define PARAMETER_LENGTH_LENGTH 2
#define PARAMETER_HEADER_LENGTH (PARAMETER_TAG_LENGTH + PARAMETER_LENGTH_LENGTH)
#define PARAMETER_TAG_OFFSET 0
#define PARAMETER_LENGTH_OFFSET (PARAMETER_TAG_OFFSET + PARAMETER_TAG_LENGTH)
#define PARAMETER_VALUE_OFFSET (PARAMETER_LENGTH_OFFSET + PARAMETER_LENGTH_LENGTH)
#define PARAMETER_HEADER_OFFSET PARAMETER_TAG_OFFSET
#define PROTOCOL_VERSION_RELEASE_1 1
static const value_string protocol_version_values[] = {
{ PROTOCOL_VERSION_RELEASE_1, "Release 1" },
{ 0, NULL } };
#define MESSAGE_CLASS_MGMT_MESSAGE 0
#define MESSAGE_CLASS_TFER_MESSAGE 1
#define MESSAGE_CLASS_SSNM_MESSAGE 2
#define MESSAGE_CLASS_ASPSM_MESSAGE 3
#define MESSAGE_CLASS_ASPTM_MESSAGE 4
#define MESSAGE_CLASS_CL_MESSAGE 7
#define MESSAGE_CLASS_CO_MESSAGE 8
#define MESSAGE_CLASS_RKM_MESSAGE 9
static const value_string message_class_values[] = {
{ MESSAGE_CLASS_MGMT_MESSAGE, "Management messages" },
{ MESSAGE_CLASS_SSNM_MESSAGE, "SS7 signalling network management messages" },
{ MESSAGE_CLASS_ASPSM_MESSAGE, "ASP state maintenance messages" },
{ MESSAGE_CLASS_ASPTM_MESSAGE, "ASP traffic maintenance messages" },
{ MESSAGE_CLASS_CL_MESSAGE, "Connectionless messages" },
{ MESSAGE_CLASS_CO_MESSAGE, "Connection-Oriented messages" },
{ MESSAGE_CLASS_RKM_MESSAGE, "Routing key management Messages" },
{ 0, NULL } };
#define MESSAGE_TYPE_ERR 0
#define MESSAGE_TYPE_NTFY 1
#define MESSAGE_TYPE_DUNA 1
#define MESSAGE_TYPE_DAVA 2
#define MESSAGE_TYPE_DAUD 3
#define MESSAGE_TYPE_SCON 4
#define MESSAGE_TYPE_DUPU 5
#define MESSAGE_TYPE_DRST 6
#define MESSAGE_TYPE_UP 1
#define MESSAGE_TYPE_DOWN 2
#define MESSAGE_TYPE_BEAT 3
#define MESSAGE_TYPE_UP_ACK 4
#define MESSAGE_TYPE_DOWN_ACK 5
#define MESSAGE_TYPE_BEAT_ACK 6
#define MESSAGE_TYPE_ACTIVE 1
#define MESSAGE_TYPE_INACTIVE 2
#define MESSAGE_TYPE_ACTIVE_ACK 3
#define MESSAGE_TYPE_INACTIVE_ACK 4
#define MESSAGE_TYPE_CLDT 1
#define MESSAGE_TYPE_CLDR 2
#define MESSAGE_TYPE_CORE 1
#define MESSAGE_TYPE_COAK 2
#define MESSAGE_TYPE_COREF 3
#define MESSAGE_TYPE_RELRE 4
#define MESSAGE_TYPE_RELCO 5
#define MESSAGE_TYPE_RESCO 6
#define MESSAGE_TYPE_RESRE 7
#define MESSAGE_TYPE_CODT 8
#define MESSAGE_TYPE_CODA 9
#define MESSAGE_TYPE_COERR 10
#define MESSAGE_TYPE_COIT 11
#define MESSAGE_TYPE_REG_REQ 1
#define MESSAGE_TYPE_REG_RSP 2
#define MESSAGE_TYPE_DEREG_REQ 3
#define MESSAGE_TYPE_DEREG_RSP 4
static const value_string message_class_type_values[] = {
{ MESSAGE_CLASS_MGMT_MESSAGE * 256 + MESSAGE_TYPE_ERR, "Error (ERR)" },
{ MESSAGE_CLASS_MGMT_MESSAGE * 256 + MESSAGE_TYPE_NTFY, "Notify (NTFY)" },
{ MESSAGE_CLASS_SSNM_MESSAGE * 256 + MESSAGE_TYPE_DUNA, "Destination unavailable (DUNA)" },
{ MESSAGE_CLASS_SSNM_MESSAGE * 256 + MESSAGE_TYPE_DAVA, "Destination available (DAVA)" },
{ MESSAGE_CLASS_SSNM_MESSAGE * 256 + MESSAGE_TYPE_DAUD, "Destination state audit (DAUD)" },
{ MESSAGE_CLASS_SSNM_MESSAGE * 256 + MESSAGE_TYPE_SCON, "SS7 Network congestion state (SCON)" },
{ MESSAGE_CLASS_SSNM_MESSAGE * 256 + MESSAGE_TYPE_DUPU, "Destination userpart unavailable (DUPU)" },
{ MESSAGE_CLASS_SSNM_MESSAGE * 256 + MESSAGE_TYPE_DRST, "Destination Restricted (DRST)" },
{ MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_UP, "ASP up (UP)" },
{ MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_DOWN, "ASP down (DOWN)" },
{ MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_BEAT, "Heartbeat (BEAT)" },
{ MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_UP_ACK, "ASP up ack (UP ACK)" },
{ MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_DOWN_ACK, "ASP down ack (DOWN ACK)" },
{ MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_BEAT_ACK, "Heartbeat ack (BEAT ACK)" },
{ MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_ACTIVE , "ASP active (ACTIVE)" },
{ MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_INACTIVE , "ASP inactive (INACTIVE)" },
{ MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_ACTIVE_ACK , "ASP active ack (ACTIVE ACK)" },
{ MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_INACTIVE_ACK , "ASP inactive ack (INACTIVE ACK)" },
{ MESSAGE_CLASS_CL_MESSAGE * 256 + MESSAGE_TYPE_CLDR , "Connectionless Data Response (CLDR)" },
{ MESSAGE_CLASS_CL_MESSAGE * 256 + MESSAGE_TYPE_CLDT , "Connectionless Data Transfer (CLDT)" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_CORE , "Connection Request (CORE)" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_COAK , "Connection Acknowledge (COAK)" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_COREF , "Connection Refused (COREF)" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_RELRE , "Release Request (RELRE)" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_RELCO , "Release Complete (RELCO)" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_RESCO , "Reset Confirm (RESCO)" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_RESRE , "Reset Request (RESRE)" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_CODT , "Connection Oriented Data Transfer (CODT)" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_CODA , "Connection Oriented Data Acknowledge (CODA)" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_COERR , "Connection Oriented Error (COERR)" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_COIT , "Inactivity Test (COIT)" },
{ MESSAGE_CLASS_RKM_MESSAGE * 256 + MESSAGE_TYPE_REG_REQ , "Registration Request (REG_REQ)" },
{ MESSAGE_CLASS_RKM_MESSAGE * 256 + MESSAGE_TYPE_REG_RSP , "Registration Response (REG_RSP)" },
{ MESSAGE_CLASS_RKM_MESSAGE * 256 + MESSAGE_TYPE_DEREG_REQ , "Deregistration Request (DEREG_REQ)" },
{ MESSAGE_CLASS_RKM_MESSAGE * 256 + MESSAGE_TYPE_DEREG_RSP , "Deregistration Response (DEREG_RSP)" },
{ 0, NULL } };
static const value_string message_class_type_acro_values[] = {
{ MESSAGE_CLASS_MGMT_MESSAGE * 256 + MESSAGE_TYPE_ERR, "ERR" },
{ MESSAGE_CLASS_MGMT_MESSAGE * 256 + MESSAGE_TYPE_NTFY, "NTFY" },
{ MESSAGE_CLASS_SSNM_MESSAGE * 256 + MESSAGE_TYPE_DUNA, "DUNA" },
{ MESSAGE_CLASS_SSNM_MESSAGE * 256 + MESSAGE_TYPE_DAVA, "DAVA" },
{ MESSAGE_CLASS_SSNM_MESSAGE * 256 + MESSAGE_TYPE_DAUD, "DAUD" },
{ MESSAGE_CLASS_SSNM_MESSAGE * 256 + MESSAGE_TYPE_SCON, "SCON" },
{ MESSAGE_CLASS_SSNM_MESSAGE * 256 + MESSAGE_TYPE_DUPU, "DUPU" },
{ MESSAGE_CLASS_SSNM_MESSAGE * 256 + MESSAGE_TYPE_DRST, "DRST" },
{ MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_UP, "ASP_UP" },
{ MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_DOWN, "ASP_DOWN" },
{ MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_BEAT, "BEAT" },
{ MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_UP_ACK, "ASP_UP_ACK" },
{ MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_DOWN_ACK, "ASP_DOWN_ACK" },
{ MESSAGE_CLASS_ASPSM_MESSAGE * 256 + MESSAGE_TYPE_BEAT_ACK, "BEAT_ACK" },
{ MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_ACTIVE , "ASP_ACTIVE" },
{ MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_INACTIVE , "ASP_INACTIVE" },
{ MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_ACTIVE_ACK , "ASP_ACTIVE_ACK" },
{ MESSAGE_CLASS_ASPTM_MESSAGE * 256 + MESSAGE_TYPE_INACTIVE_ACK , "ASP_INACTIVE_ACK" },
{ MESSAGE_CLASS_CL_MESSAGE * 256 + MESSAGE_TYPE_CLDR , "CLDR" },
{ MESSAGE_CLASS_CL_MESSAGE * 256 + MESSAGE_TYPE_CLDT , "CLDT" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_CORE , "CORE" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_COAK , "COAK" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_COREF , "COREF" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_RELRE , "RELRE" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_RELCO , "RELCO" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_RESCO , "RESCO" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_RESRE , "RESRE" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_CODT , "CODT" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_CODA , "CODA" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_COERR , "COERR" },
{ MESSAGE_CLASS_CO_MESSAGE * 256 + MESSAGE_TYPE_COIT , "COIT" },
{ MESSAGE_CLASS_RKM_MESSAGE * 256 + MESSAGE_TYPE_REG_REQ , "REG_REQ" },
{ MESSAGE_CLASS_RKM_MESSAGE * 256 + MESSAGE_TYPE_REG_RSP , "REG_RSP" },
{ MESSAGE_CLASS_RKM_MESSAGE * 256 + MESSAGE_TYPE_DEREG_REQ , "DEREG_REQ" },
{ MESSAGE_CLASS_RKM_MESSAGE * 256 + MESSAGE_TYPE_DEREG_RSP , "DEREG_RSP" },
{ 0, NULL } };
const value_string sua_co_class_type_acro_values[] = {
{ MESSAGE_TYPE_CORE , "CORE" },
{ MESSAGE_TYPE_COAK , "COAK" },
{ MESSAGE_TYPE_COREF , "COREF" },
{ MESSAGE_TYPE_RELRE , "RELRE" },
{ MESSAGE_TYPE_RELCO , "RELCO" },
{ MESSAGE_TYPE_RESCO , "RESCO" },
{ MESSAGE_TYPE_RESRE , "RESRE" },
{ MESSAGE_TYPE_CODT , "CODT" },
{ MESSAGE_TYPE_CODA , "CODA" },
{ MESSAGE_TYPE_COERR , "COERR" },
{ MESSAGE_TYPE_COIT , "COIT" },
{ 0, NULL }
};
/* Initialize the protocol and registered fields */
static int proto_sua = -1;
static int hf_sua_version = -1;
static int hf_sua_reserved = -1;
static int hf_sua_message_class = -1;
static int hf_sua_message_type = -1;
static int hf_sua_message_length = -1;
static int hf_sua_parameter_tag = -1;
static int hf_sua_v8_parameter_tag = -1;
static int hf_sua_parameter_length = -1;
static int hf_sua_parameter_value = -1;
static int hf_sua_parameter_padding = -1;
static int hf_sua_info_string = -1;
static int hf_sua_routing_context = -1;
static int hf_sua_diagnostic_information_info = -1;
static int hf_sua_heartbeat_data = -1;
static int hf_sua_traffic_mode_type = -1;
static int hf_sua_error_code = -1;
static int hf_sua_v8_error_code = -1;
static int hf_sua_status_type = -1;
static int hf_sua_status_info = -1;
static int hf_sua_congestion_level = -1;
static int hf_sua_asp_identifier = -1;
static int hf_sua_mask = -1;
static int hf_sua_dpc = -1;
static int hf_sua_registration_status = -1;
static int hf_sua_deregistration_status = -1;
static int hf_sua_local_routing_key_identifier = -1;
static int hf_sua_source_address_routing_indicator = -1;
static int hf_sua_source_address_reserved_bits = -1;
static int hf_sua_source_address_gt_bit = -1;
static int hf_sua_source_address_pc_bit = -1;
static int hf_sua_source_address_ssn_bit = -1;
static int hf_sua_source_gt_reserved = -1;
static int hf_sua_source_gti = -1;
static int hf_sua_source_number_of_digits = -1;
static int hf_sua_source_translation_type = -1;
static int hf_sua_source_numbering_plan = -1;
static int hf_sua_source_nature_of_address = -1;
static int hf_sua_source_global_title_digits = -1;
static int hf_sua_source_point_code = -1;
static int hf_sua_source_ssn_reserved = -1;
static int hf_sua_source_ssn_number = -1;
static int hf_sua_source_ipv4 = -1;
static int hf_sua_source_hostname = -1;
static int hf_sua_source_ipv6 = -1;
static int hf_sua_destination_address_routing_indicator = -1;
static int hf_sua_destination_address_reserved_bits = -1;
static int hf_sua_destination_address_gt_bit = -1;
static int hf_sua_destination_address_pc_bit = -1;
static int hf_sua_destination_address_ssn_bit = -1;
static int hf_sua_dest_gt_reserved = -1;
static int hf_sua_dest_gti = -1;
static int hf_sua_dest_number_of_digits = -1;
static int hf_sua_dest_translation_type = -1;
static int hf_sua_dest_numbering_plan = -1;
static int hf_sua_dest_nature_of_address = -1;
static int hf_sua_dest_global_title_digits = -1;
static int hf_sua_dest_point_code = -1;
static int hf_sua_dest_ssn_reserved = -1;
static int hf_sua_dest_ssn_number = -1;
static int hf_sua_dest_ipv4 = -1;
static int hf_sua_dest_hostname = -1;
static int hf_sua_dest_ipv6 = -1;
static int hf_sua_ss7_hop_counter_counter = -1;
static int hf_sua_ss7_hop_counter_reserved = -1;
static int hf_sua_destination_reference_number = -1;
static int hf_sua_source_reference_number = -1;
static int hf_sua_cause_reserved = -1;
static int hf_sua_cause_type = -1;
static int hf_sua_cause_value = -1;
static int hf_sua_sequence_number_reserved = -1;
static int hf_sua_sequence_number_rec_number = -1;
static int hf_sua_sequence_number_spare_bit = -1;
static int hf_sua_sequence_number_sent_number = -1;
static int hf_sua_sequence_number_more_data_bit = -1;
static int hf_sua_receive_sequence_number_reserved = -1;
static int hf_sua_receive_sequence_number_number = -1;
static int hf_sua_receive_sequence_number_spare_bit = -1;
static int hf_sua_protocol_classes = -1;
static int hf_sua_protocol_class_flags = -1;
static int hf_sua_asp_capabilities_reserved = -1;
static int hf_sua_asp_capabilities_reserved_bits = -1;
static int hf_sua_asp_capabilities_a_bit =-1;
static int hf_sua_asp_capabilities_b_bit =-1;
static int hf_sua_asp_capabilities_c_bit =-1;
static int hf_sua_asp_capabilities_d_bit =-1;
static int hf_sua_asp_capabilities_interworking = -1;
static int hf_sua_credit = -1;
static int hf_sua_data = -1;
static int hf_sua_cause = -1;
static int hf_sua_user = -1;
static int hf_sua_network_appearance = -1;
static int hf_sua_correlation_id = -1;
static int hf_sua_importance_reserved = -1;
static int hf_sua_importance = -1;
static int hf_sua_message_priority_reserved = -1;
static int hf_sua_message_priority = -1;
static int hf_sua_protocol_class_reserved = -1;
static int hf_sua_return_on_error_bit = -1;
static int hf_sua_protocol_class = -1;
static int hf_sua_sequence_control = -1;
static int hf_sua_first_remaining = -1;
static int hf_sua_first_bit = -1;
static int hf_sua_number_of_remaining_segments = -1;
static int hf_sua_segmentation_reference = -1;
static int hf_sua_smi = -1;
static int hf_sua_smi_reserved = -1;
static int hf_sua_tid_label_start = -1;
static int hf_sua_tid_label_end = -1;
static int hf_sua_tid_label_value = -1;
static int hf_sua_drn_label_start = -1;
static int hf_sua_drn_label_end = -1;
static int hf_sua_drn_label_value = -1;
static int hf_sua_assoc_id = -1;
/* Initialize the subtree pointers */
static gint ett_sua = -1;
static gint ett_sua_parameter = -1;
static gint ett_sua_source_address_indicator = -1;
static gint ett_sua_destination_address_indicator = -1;
static gint ett_sua_affected_destination = -1;
static gint ett_sua_first_remaining = -1;
static gint ett_sua_sequence_number_rec_number = -1;
static gint ett_sua_sequence_number_sent_number = -1;
static gint ett_sua_receive_sequence_number_number = -1;
static gint ett_sua_return_on_error_bit_and_protocol_class = -1;
static gint ett_sua_protocol_classes = -1;
static gint ett_sua_assoc = -1;
static int sua_tap = -1;
static mtp3_addr_pc_t *sua_dpc;
static mtp3_addr_pc_t *sua_opc;
static guint16 sua_ri;
static gchar *sua_source_gt;
static gchar *sua_destination_gt;
static dissector_handle_t sua_handle;
static dissector_handle_t sua_info_str_handle;
static dissector_table_t sua_parameter_table;
static dissector_table_t sccp_ssn_dissector_table;
static heur_dissector_list_t heur_subdissector_list;
static guint32 message_class, message_type, drn, srn;
static int ss7pc_address_type = -1;
#define INVALID_SSN 0xff
static guint next_assoc_id = 1;
/* Based om association tracking in the SCCP dissector */
typedef struct _sua_assoc_info_t {
guint assoc_id;
guint32 calling_routing_ind;
guint32 called_routing_ind;
guint32 calling_dpc;
guint32 called_dpc;
guint8 calling_ssn;
guint8 called_ssn;
gboolean has_bw_key;
gboolean has_fw_key;
} sua_assoc_info_t;
static wmem_tree_t* assocs = NULL;
static sua_assoc_info_t* assoc;
static sua_assoc_info_t no_sua_assoc = {
0, /* assoc_id */
0, /* calling_routing_ind */
0, /* called_routing_ind */
0, /* calling_dpc */
0, /* called_dpc */
INVALID_SSN, /* calling_ssn */
INVALID_SSN, /* called_ssn */
FALSE, /* has_bw_key */
FALSE /* has_fw_key */
};
static sua_assoc_info_t *
new_assoc(guint32 calling, guint32 called)
{
sua_assoc_info_t *a = wmem_new0(wmem_file_scope(), sua_assoc_info_t);
a->assoc_id = next_assoc_id++;
a->calling_routing_ind = 0;
a->called_routing_ind = 0;
a->calling_dpc = calling;
a->called_dpc = called;
a->calling_ssn = INVALID_SSN;
a->called_ssn = INVALID_SSN;
return a;
}
static sua_assoc_info_t*
sua_assoc(packet_info* pinfo, address* opc, address* dpc, guint src_rn, guint dst_rn)
{
guint32 opck, dpck;
if (!src_rn && !dst_rn) {
return &no_sua_assoc;
}
opck = opc->type == ss7pc_address_type ? mtp3_pc_hash((const mtp3_addr_pc_t *)opc->data) : g_str_hash(address_to_str(wmem_packet_scope(), opc));
dpck = dpc->type == ss7pc_address_type ? mtp3_pc_hash((const mtp3_addr_pc_t *)dpc->data) : g_str_hash(address_to_str(wmem_packet_scope(), dpc));
switch (message_type) {
case MESSAGE_TYPE_CORE:
{
/* Calling and called is seen from initiator of CORE */
wmem_tree_key_t bw_key[4];
bw_key[0].length = 1;
bw_key[0].key = &dpck;
bw_key[1].length = 1;
bw_key[1].key = &opck;
bw_key[2].length = 1;
bw_key[2].key = &src_rn;
bw_key[3].length = 0;
bw_key[3].key = NULL;
if ( !(assoc = (sua_assoc_info_t *)wmem_tree_lookup32_array(assocs,bw_key)) && ! pinfo->fd->visited) {
assoc = new_assoc(opck, dpck);
wmem_tree_insert32_array(assocs,bw_key,assoc);
assoc->has_bw_key = TRUE;
/*ws_warning("CORE dpck %u,opck %u,src_rn %u",dpck,opck,src_rn);*/
}
break;
}
case MESSAGE_TYPE_COAK:
{
wmem_tree_key_t fw_key[4];
wmem_tree_key_t bw_key[4];
fw_key[0].length = 1;
fw_key[0].key = &dpck;
fw_key[1].length = 1;
fw_key[1].key = &opck;
fw_key[2].length = 1;
fw_key[2].key = &src_rn;
fw_key[3].length = 0;
fw_key[3].key = NULL;
bw_key[0].length = 1;
bw_key[0].key = &opck;
bw_key[1].length = 1;
bw_key[1].key = &dpck;
bw_key[2].length = 1;
bw_key[2].key = &dst_rn;
bw_key[3].length = 0;
bw_key[3].key = NULL;
/*ws_warning("MESSAGE_TYPE_COAK dst_rn %u,src_rn %u ",dst_rn,src_rn);*/
if ( ( assoc = (sua_assoc_info_t *)wmem_tree_lookup32_array(assocs, bw_key) ) ) {
goto got_assoc;
}
if ( (assoc = (sua_assoc_info_t *)wmem_tree_lookup32_array(assocs, fw_key) ) ) {
goto got_assoc;
}
assoc = new_assoc(dpck,opck);
got_assoc:
pinfo->p2p_dir = P2P_DIR_RECV;
if ( ! pinfo->fd->visited && ! assoc->has_bw_key ) {
wmem_tree_insert32_array(assocs, bw_key, assoc);
assoc->has_bw_key = TRUE;
}
if ( ! pinfo->fd->visited && ! assoc->has_fw_key ) {
wmem_tree_insert32_array(assocs, fw_key, assoc);
assoc->has_fw_key = TRUE;
}
break;
}
default:
{
wmem_tree_key_t key[4];
key[0].length = 1;
key[0].key = &opck;
key[1].length = 1;
key[1].key = &dpck;
key[2].length = 1;
key[2].key = &dst_rn;
key[3].length = 0;
key[3].key = NULL;
assoc = (sua_assoc_info_t *)wmem_tree_lookup32_array(assocs,key);
/* Should a check be made on pinfo->p2p_dir ??? */
break;
}
}
return assoc ? assoc : &no_sua_assoc;
}
/* stuff for supporting multiple versions */
typedef enum {
SUA_V08,
SUA_RFC
} Version_Type;
static gint version = SUA_RFC;
static gboolean set_addresses = FALSE;
static void
dissect_parameters(tvbuff_t *tlv_tvb, packet_info *pinfo, proto_tree *tree, tvbuff_t **data_tvb, guint8 *source_ssn, guint8 *dest_ssn);
static void
dissect_common_header(tvbuff_t *common_header_tvb, packet_info *pinfo, proto_tree *sua_tree)
{
message_class = tvb_get_guint8(common_header_tvb, MESSAGE_CLASS_OFFSET);
message_type = tvb_get_guint8(common_header_tvb, MESSAGE_TYPE_OFFSET);
col_add_fstr(pinfo->cinfo, COL_INFO, "%s ", val_to_str_const(message_class * 256 + message_type, message_class_type_acro_values, "reserved"));
if (sua_tree) {
/* add the components of the common header to the protocol tree */
proto_tree_add_item(sua_tree, hf_sua_version, common_header_tvb, VERSION_OFFSET, VERSION_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(sua_tree, hf_sua_reserved, common_header_tvb, RESERVED_OFFSET, RESERVED_LENGTH, ENC_NA);
proto_tree_add_item(sua_tree, hf_sua_message_class, common_header_tvb, MESSAGE_CLASS_OFFSET, MESSAGE_CLASS_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_uint_format_value(sua_tree, hf_sua_message_type, common_header_tvb, MESSAGE_TYPE_OFFSET, MESSAGE_TYPE_LENGTH, message_type, "%s (%u)",
val_to_str_const(message_class * 256 + message_type, message_class_type_values, "reserved"), message_type);
proto_tree_add_item(sua_tree, hf_sua_message_length, common_header_tvb, MESSAGE_LENGTH_OFFSET, MESSAGE_LENGTH_LENGTH, ENC_BIG_ENDIAN);
};
}
#define INFO_STRING_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_info_string_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *parameter_tree, proto_item *parameter_item)
{
guint16 info_string_length;
tvbuff_t *next_tvb;
info_string_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
/* If we have a SUA Info String sub dissector call it */
if(sua_info_str_handle) {
next_tvb = tvb_new_subset_length(parameter_tvb, INFO_STRING_OFFSET, info_string_length);
call_dissector(sua_info_str_handle, next_tvb, pinfo, parameter_tree);
return;
}
proto_tree_add_item(parameter_tree, hf_sua_info_string, parameter_tvb, INFO_STRING_OFFSET, info_string_length, ENC_UTF_8);
proto_item_append_text(parameter_item, " (%s)",
tvb_format_text(pinfo->pool, parameter_tvb, INFO_STRING_OFFSET, info_string_length));
}
#define ROUTING_CONTEXT_LENGTH 4
static void
dissect_routing_context_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
guint16 number_of_contexts, context_number;
gint context_offset;
number_of_contexts = (tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH) / 4;
context_offset = PARAMETER_VALUE_OFFSET;
for(context_number=0; context_number < number_of_contexts; context_number++) {
proto_tree_add_item(parameter_tree, hf_sua_routing_context, parameter_tvb, context_offset, ROUTING_CONTEXT_LENGTH, ENC_BIG_ENDIAN);
context_offset += ROUTING_CONTEXT_LENGTH;
};
proto_item_append_text(parameter_item, " (%u context%s)", number_of_contexts, plurality(number_of_contexts, "", "s"));
}
#define DIAGNOSTIC_INFO_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_diagnostic_information_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
guint16 diag_info_length;
diag_info_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
proto_tree_add_item(parameter_tree, hf_sua_diagnostic_information_info, parameter_tvb, DIAGNOSTIC_INFO_OFFSET, diag_info_length, ENC_NA);
proto_item_append_text(parameter_item, " (%u byte%s)", diag_info_length, plurality(diag_info_length, "", "s"));
}
#define HEARTBEAT_DATA_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_heartbeat_data_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
guint16 heartbeat_data_length;
heartbeat_data_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
proto_tree_add_item(parameter_tree, hf_sua_heartbeat_data, parameter_tvb, HEARTBEAT_DATA_OFFSET, heartbeat_data_length, ENC_NA);
proto_item_append_text(parameter_item, " (%u byte%s)", heartbeat_data_length, plurality(heartbeat_data_length, "", "s"));
}
#define TRAFFIC_MODE_TYPE_OFFSET PARAMETER_VALUE_OFFSET
#define TRAFFIC_MODE_TYPE_LENGTH 4
static const value_string traffic_mode_type_values[] = {
{ 1, "Over-ride" },
{ 2, "Load-share" },
{ 3, "Broadcast" },
{ 0, NULL } };
static void
dissect_traffic_mode_type_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
proto_tree_add_item(parameter_tree, hf_sua_traffic_mode_type, parameter_tvb, TRAFFIC_MODE_TYPE_OFFSET, TRAFFIC_MODE_TYPE_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%s)", val_to_str_const(tvb_get_ntohl(parameter_tvb, TRAFFIC_MODE_TYPE_OFFSET), traffic_mode_type_values, "unknown"));
}
#define ERROR_CODE_OFFSET PARAMETER_VALUE_OFFSET
#define ERROR_CODE_LENGTH 4
static const value_string v8_error_code_values[] = {
{ 0x01, "Invalid version" },
{ 0x02, "Invalid interface identifier" },
{ 0x03, "Unsupported message class" },
{ 0x04, "Unsupported message type" },
{ 0x05, "Unsupported traffic handling mode" },
{ 0x06, "Unexpected message" },
{ 0x07, "Protocol error" },
{ 0x09, "Invalid stream identifier" },
{ 0x0d, "Refused - management blocking" },
{ 0x0e, "ASP identifier required" },
{ 0x0f, "Invalid ASP identifier" },
{ 0x11, "Invalid parameter value" },
{ 0x12, "Parameter field error" },
{ 0x13, "Unexpected parameter" },
{ 0x14, "Destination status unknown" },
{ 0x15, "Invalid network appearance" },
{ 0x16, "Missing parameter" },
{ 0x17, "Routing key change refused" },
{ 0x18, "Invalid loadsharing label" },
{ 0, NULL } };
static void
dissect_v8_error_code_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
proto_tree_add_item(parameter_tree, hf_sua_v8_error_code, parameter_tvb, ERROR_CODE_OFFSET, ERROR_CODE_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%s)", val_to_str_const(tvb_get_ntohl(parameter_tvb, ERROR_CODE_OFFSET), v8_error_code_values, "unknown"));
}
static const value_string error_code_values[] = {
{ 0x01, "Invalid version" },
{ 0x03, "Unsupported message class" },
{ 0x04, "Unsupported message type" },
{ 0x05, "Unsupported traffic handling mode" },
{ 0x06, "Unexpected message" },
{ 0x07, "Protocol error" },
{ 0x09, "Invalid stream identifier" },
{ 0x0d, "Refused - management blocking" },
{ 0x0e, "ASP identifier required" },
{ 0x0f, "Invalid ASP identifier" },
{ 0x11, "Invalid parameter value" },
{ 0x12, "Parameter field error" },
{ 0x13, "Unexpected parameter" },
{ 0x14, "Destination status unknown" },
{ 0x15, "Invalid network appearance" },
{ 0x16, "Missing parameter" },
{ 0x19, "Invalid routing context" },
{ 0x1a, "No configured AS for ASP" },
{ 0x1b, "Subsystem status unknown" },
{ 0x1c, "Invalid loadsharing label" },
{ 0, NULL } };
static void
dissect_error_code_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
proto_tree_add_item(parameter_tree, hf_sua_error_code, parameter_tvb, ERROR_CODE_OFFSET, ERROR_CODE_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%s)", val_to_str_const(tvb_get_ntohl(parameter_tvb, ERROR_CODE_OFFSET), error_code_values, "unknown"));
}
#define STATUS_TYPE_LENGTH 2
#define STATUS_INFO_LENGTH 2
#define STATUS_TYPE_OFFSET PARAMETER_VALUE_OFFSET
#define STATUS_INFO_OFFSET (STATUS_TYPE_OFFSET + STATUS_TYPE_LENGTH)
#define AS_STATE_CHANGE_TYPE 1
#define OTHER_TYPE 2
static const value_string status_type_values[] = {
{ AS_STATE_CHANGE_TYPE, "Application server state change" },
{ OTHER_TYPE, "Other" },
{ 0, NULL } };
#define RESERVED_INFO 1
#define AS_INACTIVE_INFO 2
#define AS_ACTIVE_INFO 3
#define AS_PENDING_INFO 4
#define INSUFFICIENT_ASP_RES_INFO 1
#define ALTERNATE_ASP_ACTIVE_INFO 2
#define ASP_FAILURE 3
static const value_string status_type_info_values[] = {
{ AS_STATE_CHANGE_TYPE * 256 * 256 + RESERVED_INFO, "Reserved" },
{ AS_STATE_CHANGE_TYPE * 256 * 256 + AS_INACTIVE_INFO, "Application server inactive" },
{ AS_STATE_CHANGE_TYPE * 256 * 256 + AS_ACTIVE_INFO, "Application server active" },
{ AS_STATE_CHANGE_TYPE * 256 * 256 + AS_PENDING_INFO, "Application server pending" },
{ OTHER_TYPE * 256 * 256 + INSUFFICIENT_ASP_RES_INFO, "Insufficient ASP resources active in AS" },
{ OTHER_TYPE * 256 * 256 + ALTERNATE_ASP_ACTIVE_INFO, "Alternate ASP active" },
{ OTHER_TYPE * 256 * 256 + ASP_FAILURE, "ASP Failure" },
{0, NULL } };
static void
dissect_status_type_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
guint16 status_type, status_info;
status_type = tvb_get_ntohs(parameter_tvb, STATUS_TYPE_OFFSET);
status_info = tvb_get_ntohs(parameter_tvb, STATUS_INFO_OFFSET);
proto_tree_add_item(parameter_tree, hf_sua_status_type, parameter_tvb, STATUS_TYPE_OFFSET, STATUS_TYPE_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_uint_format_value(parameter_tree, hf_sua_status_info, parameter_tvb, STATUS_INFO_OFFSET, STATUS_INFO_LENGTH,
status_info, "%s (%u)", val_to_str_const(status_type * 256 * 256 + status_info, status_type_info_values, "unknown"), status_info);
proto_item_append_text(parameter_item, " (%s)", val_to_str_const(status_type * 256 * 256 + status_info, status_type_info_values, "unknown"));
}
#define ASP_IDENTIFIER_LENGTH 4
#define ASP_IDENTIFIER_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_asp_identifier_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
proto_tree_add_item(parameter_tree, hf_sua_asp_identifier, parameter_tvb, ASP_IDENTIFIER_OFFSET, ASP_IDENTIFIER_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%u)", tvb_get_ntohl(parameter_tvb, ASP_IDENTIFIER_OFFSET));
}
#define AFFECTED_MASK_LENGTH 1
#define AFFECTED_DPC_LENGTH 3
#define AFFECTED_DESTINATION_LENGTH (AFFECTED_MASK_LENGTH + AFFECTED_DPC_LENGTH)
#define AFFECTED_MASK_OFFSET 0
#define AFFECTED_DPC_OFFSET 1
static void
dissect_affected_destinations_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
guint16 number_of_destinations, destination_number;
gint destination_offset;
proto_item *dpc_item;
number_of_destinations= (tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH) / 4;
destination_offset = PARAMETER_VALUE_OFFSET;
for(destination_number=0; destination_number < number_of_destinations; destination_number++) {
proto_tree_add_item(parameter_tree, hf_sua_mask, parameter_tvb, destination_offset + AFFECTED_MASK_OFFSET, AFFECTED_MASK_LENGTH, ENC_BIG_ENDIAN);
dpc_item = proto_tree_add_item(parameter_tree, hf_sua_dpc, parameter_tvb, destination_offset + AFFECTED_DPC_OFFSET, AFFECTED_DPC_LENGTH, ENC_BIG_ENDIAN);
if (mtp3_pc_structured())
proto_item_append_text(dpc_item, " (%s)", mtp3_pc_to_str(tvb_get_ntoh24(parameter_tvb, destination_offset + AFFECTED_DPC_OFFSET)));
destination_offset += AFFECTED_DESTINATION_LENGTH;
}
proto_item_append_text(parameter_item, " (%u destination%s)", number_of_destinations, plurality(number_of_destinations, "", "s"));
}
#define CORRELATION_ID_LENGTH 4
#define CORRELATION_ID_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_correlation_id_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
proto_tree_add_item(parameter_tree, hf_sua_correlation_id, parameter_tvb, CORRELATION_ID_OFFSET, CORRELATION_ID_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%u)", tvb_get_ntohl(parameter_tvb, CORRELATION_ID_OFFSET));
}
static void
dissect_registration_result_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *parameter_tree)
{
tvbuff_t *parameters_tvb;
parameters_tvb = tvb_new_subset_remaining(parameter_tvb, PARAMETER_VALUE_OFFSET);
dissect_parameters(parameters_tvb, pinfo, parameter_tree, NULL, NULL, NULL);
}
static void
dissect_deregistration_result_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *parameter_tree)
{
tvbuff_t *parameters_tvb;
parameters_tvb = tvb_new_subset_remaining(parameter_tvb, PARAMETER_VALUE_OFFSET);
dissect_parameters(parameters_tvb, pinfo, parameter_tree, NULL, NULL, NULL);
}
#define REGISTRATION_STATUS_LENGTH 4
#define REGISTRATION_STATUS_OFFSET PARAMETER_VALUE_OFFSET
static const value_string registration_status_values[] = {
{ 0, "Successfully registered" },
{ 1, "Error - unknown" },
{ 2, "Error - invalid destination address" },
{ 3, "Error - invalid network appearance" },
{ 4, "Error - invalid routing key" },
{ 5, "Error - permission denied" },
{ 6, "Error - cannot support unique routing" },
{ 7, "Error - routing key not currently provisioned" },
{ 8, "Error - insufficient resources" },
{ 9, "Error - unsupported RK parameter field" },
{ 10, "Error - unsupported/invalid traffic mode type" },
{ 11, "Error - routing key change refused" },
{ 0, NULL } };
static void
dissect_registration_status_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
proto_tree_add_item(parameter_tree, hf_sua_registration_status, parameter_tvb, REGISTRATION_STATUS_OFFSET, REGISTRATION_STATUS_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%s)", val_to_str_const(tvb_get_ntohl(parameter_tvb, REGISTRATION_STATUS_OFFSET), registration_status_values, "unknown"));
}
#define DEREGISTRATION_STATUS_LENGTH 4
#define DEREGISTRATION_STATUS_OFFSET PARAMETER_VALUE_OFFSET
static const value_string deregistration_status_values[] = {
{ 0, "Successfully deregistered" },
{ 1, "Error - unknown" },
{ 2, "Error - invalid routing context" },
{ 3, "Error - permission denied" },
{ 4, "Error - not registered" },
{ 5, "Error - ASP currently active for routing context" },
{ 0, NULL } };
static void
dissect_deregistration_status_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
proto_tree_add_item(parameter_tree, hf_sua_deregistration_status, parameter_tvb, DEREGISTRATION_STATUS_OFFSET, DEREGISTRATION_STATUS_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%s)", val_to_str_const(tvb_get_ntohl(parameter_tvb, DEREGISTRATION_STATUS_OFFSET), deregistration_status_values, "unknown"));
}
#define LOCAL_ROUTING_KEY_IDENTIFIER_LENGTH 4
#define LOCAL_ROUTING_KEY_IDENTIFIER_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_local_routing_key_identifier_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
proto_tree_add_item(parameter_tree, hf_sua_local_routing_key_identifier, parameter_tvb, LOCAL_ROUTING_KEY_IDENTIFIER_OFFSET, LOCAL_ROUTING_KEY_IDENTIFIER_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%d)", tvb_get_ntohl(parameter_tvb, LOCAL_ROUTING_KEY_IDENTIFIER_OFFSET));
}
#define SS7_HOP_COUNTER_LENGTH 1
#define SS7_HOP_COUNTER_OFFSET (PARAMETER_VALUE_OFFSET + RESERVED_3_LENGTH)
static void
dissect_ss7_hop_counter_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
proto_tree_add_item(parameter_tree, hf_sua_ss7_hop_counter_reserved, parameter_tvb, PARAMETER_VALUE_OFFSET, RESERVED_3_LENGTH, ENC_NA);
proto_tree_add_item(parameter_tree, hf_sua_ss7_hop_counter_counter, parameter_tvb, SS7_HOP_COUNTER_OFFSET, SS7_HOP_COUNTER_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%u)", tvb_get_guint8(parameter_tvb, SS7_HOP_COUNTER_OFFSET));
}
#define ROUTING_INDICATOR_LENGTH 2
#define ADDRESS_INDICATOR_LENGTH 2
#define ROUTING_INDICATOR_OFFSET PARAMETER_VALUE_OFFSET
#define ADDRESS_INDICATOR_OFFSET (ROUTING_INDICATOR_OFFSET + ROUTING_INDICATOR_LENGTH)
#define ADDRESS_PARAMETERS_OFFSET (ADDRESS_INDICATOR_OFFSET + ADDRESS_INDICATOR_LENGTH)
#define RESERVED_ROUTING_INDICATOR 0
#define ROUTE_ON_GT_ROUTING_INDICATOR 1
#define ROUTE_ON_SSN_PC_ROUTING_INDICATOR 2
#define ROUTE_ON_HOSTNAMEROUTING_INDICATOR 3
#define ROUTE_ON_SSN_IP_ROUTING_INDICATOR 4
static const value_string routing_indicator_values[] = {
{ RESERVED_ROUTING_INDICATOR, "Reserved" },
{ ROUTE_ON_GT_ROUTING_INDICATOR, "Route on Global Title" },
{ ROUTE_ON_SSN_PC_ROUTING_INDICATOR, "Route on SSN + PC" },
{ ROUTE_ON_HOSTNAMEROUTING_INDICATOR, "Route on Hostname" },
{ ROUTE_ON_SSN_IP_ROUTING_INDICATOR, "Route on SSN + IP Address" },
{ 0, NULL } };
#define ADDRESS_RESERVED_BITMASK 0xfff8
#define ADDRESS_GT_BITMASK 0x0004
#define ADDRESS_PC_BITMASK 0x0002
#define ADDRESS_SSN_BITMASK 0x0001
static void
dissect_source_address_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *parameter_tree, guint8 *ssn)
{
proto_tree *address_indicator_tree;
tvbuff_t *parameters_tvb;
sua_ri = tvb_get_ntohs(parameter_tvb, ROUTING_INDICATOR_OFFSET);
if(parameter_tree) {
proto_tree_add_item(parameter_tree, hf_sua_source_address_routing_indicator, parameter_tvb, ROUTING_INDICATOR_OFFSET, ROUTING_INDICATOR_LENGTH, ENC_BIG_ENDIAN);
address_indicator_tree = proto_tree_add_subtree(parameter_tree, parameter_tvb, ADDRESS_INDICATOR_OFFSET, ADDRESS_INDICATOR_LENGTH, ett_sua_source_address_indicator, NULL, "Address Indicator");
proto_tree_add_item(address_indicator_tree, hf_sua_source_address_reserved_bits, parameter_tvb, ADDRESS_INDICATOR_OFFSET, ADDRESS_INDICATOR_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(address_indicator_tree, hf_sua_source_address_gt_bit, parameter_tvb, ADDRESS_INDICATOR_OFFSET, ADDRESS_INDICATOR_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(address_indicator_tree, hf_sua_source_address_pc_bit, parameter_tvb, ADDRESS_INDICATOR_OFFSET, ADDRESS_INDICATOR_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(address_indicator_tree, hf_sua_source_address_ssn_bit, parameter_tvb, ADDRESS_INDICATOR_OFFSET, ADDRESS_INDICATOR_LENGTH, ENC_BIG_ENDIAN);
}
parameters_tvb = tvb_new_subset_remaining(parameter_tvb, ADDRESS_PARAMETERS_OFFSET);
dissect_parameters(parameters_tvb, pinfo, parameter_tree, NULL, ssn, NULL);
}
static void
dissect_destination_address_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *parameter_tree, guint8 *ssn)
{
proto_tree *address_indicator_tree;
tvbuff_t *parameters_tvb;
sua_ri = tvb_get_ntohs(parameter_tvb, ROUTING_INDICATOR_OFFSET);
if(parameter_tree) {
proto_tree_add_item(parameter_tree, hf_sua_destination_address_routing_indicator, parameter_tvb, ROUTING_INDICATOR_OFFSET, ROUTING_INDICATOR_LENGTH, ENC_BIG_ENDIAN);
address_indicator_tree = proto_tree_add_subtree(parameter_tree, parameter_tvb, ADDRESS_INDICATOR_OFFSET, ADDRESS_INDICATOR_LENGTH, ett_sua_destination_address_indicator, NULL, "Address Indicator");
proto_tree_add_item(address_indicator_tree, hf_sua_destination_address_reserved_bits, parameter_tvb, ADDRESS_INDICATOR_OFFSET, ADDRESS_INDICATOR_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(address_indicator_tree, hf_sua_destination_address_gt_bit, parameter_tvb, ADDRESS_INDICATOR_OFFSET, ADDRESS_INDICATOR_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(address_indicator_tree, hf_sua_destination_address_pc_bit, parameter_tvb, ADDRESS_INDICATOR_OFFSET, ADDRESS_INDICATOR_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(address_indicator_tree, hf_sua_destination_address_ssn_bit, parameter_tvb, ADDRESS_INDICATOR_OFFSET, ADDRESS_INDICATOR_LENGTH, ENC_BIG_ENDIAN);
}
parameters_tvb = tvb_new_subset_remaining(parameter_tvb, ADDRESS_PARAMETERS_OFFSET);
dissect_parameters(parameters_tvb, pinfo, parameter_tree, NULL, NULL, ssn);
}
#define SOURCE_REFERENCE_NUMBER_LENGTH 4
#define SOURCE_REFERENCE_NUMBER_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_source_reference_number_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
srn = tvb_get_ntohl(parameter_tvb, SOURCE_REFERENCE_NUMBER_OFFSET);
proto_tree_add_item(parameter_tree, hf_sua_source_reference_number, parameter_tvb, SOURCE_REFERENCE_NUMBER_OFFSET, SOURCE_REFERENCE_NUMBER_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%u)", tvb_get_ntohl(parameter_tvb, SOURCE_REFERENCE_NUMBER_OFFSET));
}
#define DESTINATION_REFERENCE_NUMBER_LENGTH 4
#define DESTINATION_REFERENCE_NUMBER_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_destination_reference_number_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
drn = tvb_get_ntohl(parameter_tvb, DESTINATION_REFERENCE_NUMBER_OFFSET);
proto_tree_add_item(parameter_tree, hf_sua_destination_reference_number, parameter_tvb, DESTINATION_REFERENCE_NUMBER_OFFSET, DESTINATION_REFERENCE_NUMBER_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%u)", tvb_get_ntohl(parameter_tvb, DESTINATION_REFERENCE_NUMBER_OFFSET));
}
#define CAUSE_TYPE_LENGTH 1
#define CAUSE_VALUE_LENGTH 1
#define CAUSE_TYPE_OFFSET (PARAMETER_VALUE_OFFSET + RESERVED_2_LENGTH)
#define CAUSE_VALUE_OFFSET (CAUSE_TYPE_OFFSET + CAUSE_TYPE_LENGTH)
#define CAUSE_TYPE_RETURN 0x1
#define CAUSE_TYPE_REFUSAL 0x2
#define CAUSE_TYPE_RELEASE 0x3
#define CAUSE_TYPE_RESET 0x4
#define CAUSE_TYPE_ERROR 0x5
static const value_string cause_type_values[] = {
{ CAUSE_TYPE_RETURN, "Return Cause" },
{ CAUSE_TYPE_REFUSAL, "Refusal Cause" },
{ CAUSE_TYPE_RELEASE, "Release Cause" },
{ CAUSE_TYPE_RESET, "Reset Cause" },
{ CAUSE_TYPE_ERROR, "Error cause" },
{ 0, NULL } };
static void
dissect_sccp_cause_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
guint8 cause_type, cause;
proto_item *pi;
const gchar *cause_string;
proto_tree_add_item(parameter_tree, hf_sua_cause_reserved, parameter_tvb, PARAMETER_VALUE_OFFSET, RESERVED_2_LENGTH, ENC_NA);
proto_tree_add_item(parameter_tree, hf_sua_cause_type, parameter_tvb, CAUSE_TYPE_OFFSET, CAUSE_TYPE_LENGTH, ENC_BIG_ENDIAN);
cause_type = tvb_get_guint8(parameter_tvb, CAUSE_TYPE_OFFSET);
pi = proto_tree_add_item(parameter_tree, hf_sua_cause_value, parameter_tvb, CAUSE_VALUE_OFFSET, CAUSE_VALUE_LENGTH, ENC_BIG_ENDIAN);
cause = tvb_get_guint8(parameter_tvb, CAUSE_VALUE_OFFSET);
switch (cause_type) {
case CAUSE_TYPE_RETURN:
cause_string = val_to_str_const(cause, sccp_return_cause_values, "unknown");
break;
case CAUSE_TYPE_REFUSAL:
cause_string = val_to_str_const(cause, sccp_refusal_cause_values, "unknown");
break;
case CAUSE_TYPE_RELEASE:
cause_string = val_to_str_const(cause, sccp_release_cause_values, "unknown");
break;
case CAUSE_TYPE_RESET:
cause_string = val_to_str_const(cause, sccp_reset_cause_values, "unknown");
break;
case CAUSE_TYPE_ERROR:
cause_string = val_to_str_const(cause, sccp_error_cause_values, "unknown");
break;
default:
cause_string = "unknown";
}
proto_item_append_text(pi, " (%s)", cause_string);
proto_item_append_text(parameter_item, " (%s: %s)", val_to_str_const(cause_type, cause_type_values, "unknown"), cause_string);
}
#define SEQUENCE_NUMBER_REC_SEQ_LENGTH 1
#define SEQUENCE_NUMBER_SENT_SEQ_LENGTH 1
#define SEQUENCE_NUMBER_REC_SEQ_OFFSET (PARAMETER_VALUE_OFFSET + RESERVED_2_LENGTH)
#define SEQUENCE_NUMBER_SENT_SEQ_OFFSET (SEQUENCE_NUMBER_REC_SEQ_OFFSET + SEQUENCE_NUMBER_REC_SEQ_LENGTH)
#define SEQ_NUM_MASK 0xFE
#define SPARE_BIT_MASK 0x01
#define MORE_DATA_BIT_MASK 0x01
static const true_false_string more_data_bit_value = {
"More Data",
"Not More Data"
};
static void
dissect_sequence_number_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree)
{
proto_tree *sent_sequence_number_tree;
proto_tree *receive_sequence_number_tree;
proto_tree_add_item(parameter_tree, hf_sua_sequence_number_reserved, parameter_tvb, PARAMETER_VALUE_OFFSET, RESERVED_2_LENGTH, ENC_NA);
receive_sequence_number_tree = proto_tree_add_subtree(parameter_tree, parameter_tvb, SEQUENCE_NUMBER_REC_SEQ_OFFSET, SEQUENCE_NUMBER_REC_SEQ_LENGTH,
ett_sua_sequence_number_rec_number, NULL, "Receive Sequence Number");
proto_tree_add_item(receive_sequence_number_tree, hf_sua_sequence_number_rec_number, parameter_tvb, SEQUENCE_NUMBER_REC_SEQ_OFFSET, SEQUENCE_NUMBER_REC_SEQ_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(receive_sequence_number_tree, hf_sua_sequence_number_more_data_bit, parameter_tvb, SEQUENCE_NUMBER_REC_SEQ_OFFSET, SEQUENCE_NUMBER_REC_SEQ_LENGTH, ENC_BIG_ENDIAN);
sent_sequence_number_tree = proto_tree_add_subtree(parameter_tree, parameter_tvb, SEQUENCE_NUMBER_SENT_SEQ_OFFSET, SEQUENCE_NUMBER_SENT_SEQ_LENGTH,
ett_sua_sequence_number_sent_number, NULL, "Sent Sequence Number");
proto_tree_add_item(sent_sequence_number_tree, hf_sua_sequence_number_sent_number, parameter_tvb, SEQUENCE_NUMBER_SENT_SEQ_OFFSET, SEQUENCE_NUMBER_SENT_SEQ_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(sent_sequence_number_tree, hf_sua_sequence_number_spare_bit, parameter_tvb, SEQUENCE_NUMBER_SENT_SEQ_OFFSET, SEQUENCE_NUMBER_SENT_SEQ_LENGTH, ENC_BIG_ENDIAN);
}
#define RECEIVE_SEQUENCE_NUMBER_REC_SEQ_LENGTH 1
#define RECEIVE_SEQUENCE_NUMBER_REC_SEQ_OFFSET (PARAMETER_VALUE_OFFSET + RESERVED_3_LENGTH)
static void
dissect_receive_sequence_number_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree)
{
proto_tree *receive_sequence_number_tree;
proto_tree_add_item(parameter_tree, hf_sua_receive_sequence_number_reserved, parameter_tvb, PARAMETER_VALUE_OFFSET, RESERVED_3_LENGTH, ENC_NA);
receive_sequence_number_tree = proto_tree_add_subtree(parameter_tree, parameter_tvb, RECEIVE_SEQUENCE_NUMBER_REC_SEQ_OFFSET, RECEIVE_SEQUENCE_NUMBER_REC_SEQ_LENGTH,
ett_sua_receive_sequence_number_number, NULL, "Receive Sequence Number");
proto_tree_add_item(receive_sequence_number_tree, hf_sua_receive_sequence_number_number, parameter_tvb, RECEIVE_SEQUENCE_NUMBER_REC_SEQ_OFFSET, RECEIVE_SEQUENCE_NUMBER_REC_SEQ_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(receive_sequence_number_tree, hf_sua_receive_sequence_number_spare_bit, parameter_tvb, RECEIVE_SEQUENCE_NUMBER_REC_SEQ_OFFSET, RECEIVE_SEQUENCE_NUMBER_REC_SEQ_LENGTH, ENC_BIG_ENDIAN);
}
#define PROTOCOL_CLASSES_LENGTH 1
#define INTERWORKING_LENGTH 1
#define PROTOCOL_CLASSES_OFFSET (PARAMETER_VALUE_OFFSET + RESERVED_2_LENGTH)
#define INTERWORKING_OFFSET (PROTOCOL_CLASSES_OFFSET + PROTOCOL_CLASSES_LENGTH)
#define A_BIT_MASK 0x08
#define B_BIT_MASK 0x04
#define C_BIT_MASK 0x02
#define D_BIT_MASK 0x01
#define RESERVED_BITS_MASK 0xF0
static const value_string interworking_values[] = {
{ 0x0, "No Interworking with SS7 Networks" },
{ 0x1, "IP-Signalling Endpoint interworking with SS7 networks" },
{ 0x2, "Signalling Gateway" },
{ 0x3, "Relay Node Support" },
{ 0, NULL } };
static void
dissect_asp_capabilities_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree)
{
static int * const capabilities[] = {
&hf_sua_asp_capabilities_reserved_bits,
&hf_sua_asp_capabilities_a_bit,
&hf_sua_asp_capabilities_b_bit,
&hf_sua_asp_capabilities_c_bit,
&hf_sua_asp_capabilities_d_bit,
NULL
};
proto_tree_add_item(parameter_tree, hf_sua_asp_capabilities_reserved, parameter_tvb, PARAMETER_VALUE_OFFSET, RESERVED_2_LENGTH, ENC_NA);
proto_tree_add_bitmask(parameter_tree, parameter_tvb, PROTOCOL_CLASSES_OFFSET, hf_sua_protocol_classes, ett_sua_protocol_classes, capabilities, ENC_BIG_ENDIAN);
proto_tree_add_item(parameter_tree, hf_sua_asp_capabilities_interworking, parameter_tvb, INTERWORKING_OFFSET, INTERWORKING_LENGTH, ENC_BIG_ENDIAN);
}
#define CREDIT_LENGTH 4
#define CREDIT_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_credit_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
proto_tree_add_item(parameter_tree, hf_sua_credit, parameter_tvb, CREDIT_OFFSET, CREDIT_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%u)", tvb_get_ntohl(parameter_tvb, CREDIT_OFFSET));
}
#define DATA_PARAMETER_DATA_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_data_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item, tvbuff_t **data_tvb)
{
guint16 data_length;
data_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
if(parameter_tree) {
proto_tree_add_item(parameter_tree, hf_sua_data, parameter_tvb, DATA_PARAMETER_DATA_OFFSET, data_length, ENC_NA);
proto_item_append_text(parameter_item, " (SS7 message of %u byte%s)", data_length, plurality(data_length, "", "s"));
}
if(data_tvb)
{
*data_tvb = tvb_new_subset_length(parameter_tvb, PARAMETER_VALUE_OFFSET, data_length);
}
}
#define CAUSE_LENGTH 2
#define USER_LENGTH 2
#define CAUSE_OFFSET PARAMETER_VALUE_OFFSET
#define USER_OFFSET (CAUSE_OFFSET + CAUSE_LENGTH)
static const value_string cause_values[] = {
{ 0x0, "Remote SCCP unavailable, Reason unknown" },
{ 0x2, "Remote SCCP unequipped" },
{ 0x3, "Remote SCCP inaccessible" },
{ 0, NULL } };
static void
dissect_user_cause_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree)
{
proto_tree_add_item(parameter_tree, hf_sua_cause, parameter_tvb, CAUSE_OFFSET, CAUSE_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(parameter_tree, hf_sua_user, parameter_tvb, USER_OFFSET, USER_LENGTH, ENC_BIG_ENDIAN);
}
#define NETWORK_APPEARANCE_LENGTH 4
#define NETWORK_APPEARANCE_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_network_appearance_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
proto_tree_add_item(parameter_tree, hf_sua_network_appearance, parameter_tvb, NETWORK_APPEARANCE_OFFSET, NETWORK_APPEARANCE_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%u)", tvb_get_ntohl(parameter_tvb, NETWORK_APPEARANCE_OFFSET));
}
static void
dissect_routing_key_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *parameter_tree)
{
tvbuff_t *parameters_tvb;
parameters_tvb = tvb_new_subset_remaining(parameter_tvb, PARAMETER_VALUE_OFFSET);
dissect_parameters(parameters_tvb, pinfo, parameter_tree, NULL, NULL, NULL);
}
#define DRN_START_LENGTH 1
#define DRN_END_LENGTH 1
#define DRN_VALUE_LENGTH 2
#define DRN_START_OFFSET PARAMETER_VALUE_OFFSET
#define DRN_END_OFFSET (DRN_START_OFFSET + DRN_START_LENGTH)
#define DRN_VALUE_OFFSET (DRN_END_OFFSET + DRN_END_LENGTH)
static void
dissect_drn_label_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree)
{
proto_tree_add_item(parameter_tree, hf_sua_drn_label_start, parameter_tvb, DRN_START_OFFSET, DRN_START_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(parameter_tree, hf_sua_drn_label_end, parameter_tvb, DRN_END_OFFSET, DRN_END_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(parameter_tree, hf_sua_drn_label_value, parameter_tvb, DRN_VALUE_OFFSET, DRN_VALUE_LENGTH, ENC_BIG_ENDIAN);
}
#define TID_START_LENGTH 1
#define TID_END_LENGTH 1
#define TID_VALUE_LENGTH 2
#define TID_START_OFFSET PARAMETER_VALUE_OFFSET
#define TID_END_OFFSET (TID_START_OFFSET + TID_START_LENGTH)
#define TID_VALUE_OFFSET (TID_END_OFFSET + TID_END_LENGTH)
static void
dissect_tid_label_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree)
{
proto_tree_add_item(parameter_tree, hf_sua_tid_label_start, parameter_tvb, TID_START_OFFSET, TID_START_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(parameter_tree, hf_sua_tid_label_end, parameter_tvb, TID_END_OFFSET, TID_END_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(parameter_tree, hf_sua_tid_label_value, parameter_tvb, TID_VALUE_OFFSET, TID_VALUE_LENGTH, ENC_BIG_ENDIAN);
}
#define ADDRESS_RANGE_ADDRESS_PARAMETERS_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_address_range_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *parameter_tree)
{
tvbuff_t *parameters_tvb;
parameters_tvb = tvb_new_subset_remaining(parameter_tvb, PARAMETER_VALUE_OFFSET);
dissect_parameters(parameters_tvb, pinfo, parameter_tree, NULL, NULL, NULL);
}
#define SMI_LENGTH 1
#define SMI_OFFSET (PARAMETER_VALUE_OFFSET + RESERVED_3_LENGTH)
static void
dissect_smi_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
proto_tree_add_item(parameter_tree, hf_sua_smi_reserved, parameter_tvb, PARAMETER_VALUE_OFFSET, RESERVED_3_LENGTH, ENC_NA);
proto_tree_add_item(parameter_tree, hf_sua_smi, parameter_tvb, SMI_OFFSET, SMI_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%u)", tvb_get_guint8(parameter_tvb, SMI_OFFSET));
}
#define IMPORTANCE_LENGTH 1
#define IMPORTANCE_OFFSET (PARAMETER_VALUE_OFFSET + RESERVED_3_LENGTH)
static void
dissect_importance_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
proto_tree_add_item(parameter_tree, hf_sua_importance_reserved, parameter_tvb, PARAMETER_VALUE_OFFSET, RESERVED_3_LENGTH, ENC_NA);
proto_tree_add_item(parameter_tree, hf_sua_importance, parameter_tvb, IMPORTANCE_OFFSET, IMPORTANCE_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%u)", tvb_get_guint8(parameter_tvb, IMPORTANCE_OFFSET));
}
#define MESSAGE_PRIORITY_LENGTH 1
#define MESSAGE_PRIORITY_OFFSET (PARAMETER_VALUE_OFFSET + RESERVED_3_LENGTH)
static void
dissect_message_priority_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
proto_tree_add_item(parameter_tree, hf_sua_message_priority_reserved, parameter_tvb, PARAMETER_VALUE_OFFSET, RESERVED_3_LENGTH, ENC_NA);
proto_tree_add_item(parameter_tree, hf_sua_message_priority, parameter_tvb, MESSAGE_PRIORITY_OFFSET, MESSAGE_PRIORITY_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%u)", tvb_get_guint8(parameter_tvb, MESSAGE_PRIORITY_OFFSET));
}
#define PROTOCOL_CLASS_LENGTH 1
#define PROTOCOL_CLASS_OFFSET (PARAMETER_VALUE_OFFSET + RESERVED_3_LENGTH)
#define RETURN_ON_ERROR_BIT_MASK 0x80
#define PROTOCOL_CLASS_MASK 0x7f
static const true_false_string return_on_error_bit_value = {
"Return Message On Error",
"No Special Options"
};
static void
dissect_protocol_class_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
static int * const capabilities[] = {
&hf_sua_return_on_error_bit,
&hf_sua_protocol_class,
NULL
};
proto_tree_add_item(parameter_tree, hf_sua_protocol_class_reserved, parameter_tvb, PARAMETER_VALUE_OFFSET, RESERVED_3_LENGTH, ENC_NA);
proto_tree_add_bitmask(parameter_tree, parameter_tvb, PROTOCOL_CLASS_OFFSET, hf_sua_protocol_class_flags, ett_sua_return_on_error_bit_and_protocol_class, capabilities, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%d)", tvb_get_guint8(parameter_tvb, PROTOCOL_CLASS_OFFSET) & PROTOCOL_CLASS_MASK);
}
#define SEQUENCE_CONTROL_LENGTH 4
#define SEQUENCE_CONTROL_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_sequence_control_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
proto_tree_add_item(parameter_tree, hf_sua_sequence_control, parameter_tvb, SEQUENCE_CONTROL_OFFSET, SEQUENCE_CONTROL_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%u)", tvb_get_ntohl(parameter_tvb, SEQUENCE_CONTROL_OFFSET));
}
#define FIRST_REMAINING_LENGTH 1
#define SEGMENTATION_REFERENCE_LENGTH 3
#define FIRST_REMAINING_OFFSET PARAMETER_VALUE_OFFSET
#define SEGMENTATION_REFERENCE_OFFSET (FIRST_REMAINING_OFFSET + FIRST_REMAINING_LENGTH)
#define FIRST_BIT_MASK 0x80
#define NUMBER_OF_SEGMENTS_MASK 0x7f
static const true_false_string first_bit_value = {
"First segment",
"Subsequent segment"
};
static void
dissect_segmentation_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree)
{
static int * const first_remaining[] = {
&hf_sua_first_bit,
&hf_sua_number_of_remaining_segments,
NULL
};
proto_tree_add_bitmask(parameter_tree, parameter_tvb, FIRST_REMAINING_OFFSET, hf_sua_first_remaining, ett_sua_first_remaining, first_remaining, ENC_BIG_ENDIAN);
proto_tree_add_item(parameter_tree, hf_sua_segmentation_reference, parameter_tvb, SEGMENTATION_REFERENCE_OFFSET, SEGMENTATION_REFERENCE_LENGTH, ENC_BIG_ENDIAN);
}
#define CONGESTION_LEVEL_LENGTH 4
#define CONGESTION_LEVEL_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_congestion_level_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
proto_tree_add_item(parameter_tree, hf_sua_congestion_level, parameter_tvb, CONGESTION_LEVEL_OFFSET, CONGESTION_LEVEL_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%u)", tvb_get_ntohl(parameter_tvb, CONGESTION_LEVEL_OFFSET));
}
#define GTI_LENGTH 1
#define NO_OF_DIGITS_LENGTH 1
#define TRANSLATION_TYPE_LENGTH 1
#define NUMBERING_PLAN_LENGTH 1
#define NATURE_OF_ADDRESS_LENGTH 1
#define GTI_OFFSET (PARAMETER_VALUE_OFFSET + RESERVED_3_LENGTH)
#define NO_OF_DIGITS_OFFSET (GTI_OFFSET + GTI_LENGTH)
#define TRANSLATION_TYPE_OFFSET (NO_OF_DIGITS_OFFSET + NO_OF_DIGITS_LENGTH)
#define NUMBERING_PLAN_OFFSET (TRANSLATION_TYPE_OFFSET + TRANSLATION_TYPE_LENGTH)
#define NATURE_OF_ADDRESS_OFFSET (NUMBERING_PLAN_OFFSET + NUMBERING_PLAN_LENGTH)
#define GLOBAL_TITLE_OFFSET (NATURE_OF_ADDRESS_OFFSET + NATURE_OF_ADDRESS_LENGTH)
#define ISDN_TELEPHONY_NUMBERING_PLAN 1
#define GENERIC_NUMBERING_PLAN 2
#define DATA_NUMBERING_PLAN 3
#define TELEX_NUMBERING_PLAN 4
#define MARITIME_MOBILE_NUMBERING_PLAN 5
#define LAND_MOBILE_NUMBERING_PLAN 6
#define ISDN_MOBILE_NUMBERING_PLAN 7
#define PRIVATE_NETWORK_NUMBERING_PLAN 14
static const value_string numbering_plan_values[] = {
{ ISDN_TELEPHONY_NUMBERING_PLAN, "ISDN/Telephony Numbering Plan (Rec. E.161 and E.164)" },
{ GENERIC_NUMBERING_PLAN, "Generic Numbering Plan" },
{ DATA_NUMBERING_PLAN, "Data Numbering Plan (Rec. X.121)" },
{ TELEX_NUMBERING_PLAN, "Telex Numbering Plan (Rec. F.69)" },
{ MARITIME_MOBILE_NUMBERING_PLAN, "Maritime Mobile Numbering Plan (Rec. E.210 and E.211)" },
{ LAND_MOBILE_NUMBERING_PLAN, "Land Mobile Numbering Plan (Rec. E.212)" },
{ ISDN_MOBILE_NUMBERING_PLAN, "ISDN/Mobile Numbering Plan (Rec. E.214)" },
{ PRIVATE_NETWORK_NUMBERING_PLAN, "Private Network Or Network-Specific Numbering Plan" },
{ 0, NULL } };
#define UNKNOWN_NATURE_OF_ADDRESS 0
#define SUBSCRIBER_NUMBER_NATURE_OF_ADDRESS 1
#define RESERVED_FOR_NATIONAL_USE_NATURE_OF_ADDRESS 2
#define NATIONAL_SIGNIFICANT_NUMBER_NATURE_OF_ADDRESS 3
#define INTERNATION_NUMBER_NATURE_OF_ADDRESS 4
static const value_string nature_of_address_values[] = {
{ UNKNOWN_NATURE_OF_ADDRESS, "Unknown" },
{ SUBSCRIBER_NUMBER_NATURE_OF_ADDRESS, "Subscriber Number" },
{ RESERVED_FOR_NATIONAL_USE_NATURE_OF_ADDRESS, "Reserved For National Use" },
{ NATIONAL_SIGNIFICANT_NUMBER_NATURE_OF_ADDRESS, "National Significant Number" },
{ INTERNATION_NUMBER_NATURE_OF_ADDRESS, "International Number" },
{ 0, NULL } };
static void
dissect_global_title_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, gboolean source)
{
guint16 global_title_length;
guint16 offset;
gboolean even_length;
guint8 odd_signal, even_signal;
guint8 number_of_digits;
char *gt_digits;
gt_digits = (char *)wmem_alloc0(wmem_packet_scope(), GT_MAX_SIGNALS+1);
global_title_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) -
(PARAMETER_HEADER_LENGTH + RESERVED_3_LENGTH + GTI_LENGTH + NO_OF_DIGITS_LENGTH + TRANSLATION_TYPE_LENGTH + NUMBERING_PLAN_LENGTH + NATURE_OF_ADDRESS_LENGTH);
proto_tree_add_item(parameter_tree, source ? hf_sua_source_gt_reserved : hf_sua_dest_gt_reserved, parameter_tvb, PARAMETER_VALUE_OFFSET, RESERVED_3_LENGTH, ENC_NA);
proto_tree_add_item(parameter_tree, source ? hf_sua_source_gti : hf_sua_dest_gti, parameter_tvb, GTI_OFFSET, GTI_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(parameter_tree, source ? hf_sua_source_number_of_digits : hf_sua_dest_number_of_digits, parameter_tvb, NO_OF_DIGITS_OFFSET, NO_OF_DIGITS_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(parameter_tree, source ? hf_sua_source_translation_type : hf_sua_dest_translation_type, parameter_tvb, TRANSLATION_TYPE_OFFSET, TRANSLATION_TYPE_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(parameter_tree, source ? hf_sua_source_numbering_plan : hf_sua_dest_numbering_plan, parameter_tvb, NUMBERING_PLAN_OFFSET, NUMBERING_PLAN_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(parameter_tree, source ? hf_sua_source_nature_of_address : hf_sua_dest_nature_of_address, parameter_tvb, NATURE_OF_ADDRESS_OFFSET, NATURE_OF_ADDRESS_LENGTH, ENC_BIG_ENDIAN);
number_of_digits = tvb_get_guint8(parameter_tvb, NO_OF_DIGITS_OFFSET);
even_length = !(number_of_digits % 2);
offset = GLOBAL_TITLE_OFFSET;
while(offset < GLOBAL_TITLE_OFFSET + global_title_length) {
odd_signal = tvb_get_guint8(parameter_tvb, offset) & GT_ODD_SIGNAL_MASK;
even_signal = tvb_get_guint8(parameter_tvb, offset) & GT_EVEN_SIGNAL_MASK;
even_signal >>= GT_EVEN_SIGNAL_SHIFT;
(void) g_strlcat(gt_digits, val_to_str_const(odd_signal, sccp_address_signal_values,
"Unknown"), GT_MAX_SIGNALS+1);
/* If the last signal is NOT filler */
if (offset != (GLOBAL_TITLE_OFFSET + global_title_length - 1) || even_length == TRUE)
(void) g_strlcat(gt_digits, val_to_str_const(even_signal, sccp_address_signal_values,
"Unknown"), GT_MAX_SIGNALS+1);
offset += GT_SIGNAL_LENGTH;
}
proto_tree_add_string_format(parameter_tree, source ? hf_sua_source_global_title_digits : hf_sua_dest_global_title_digits,
parameter_tvb, GLOBAL_TITLE_OFFSET,
global_title_length, gt_digits,
"Address information (digits): %s", gt_digits);
if (sua_ri == ROUTE_ON_GT_ROUTING_INDICATOR) {
if (source) {
sua_source_gt = gt_digits;
} else {
sua_destination_gt = gt_digits;
}
}
}
#define POINT_CODE_LENGTH 4
#define POINT_CODE_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_point_code_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item, gboolean source)
{
guint32 pc;
pc = tvb_get_ntohl(parameter_tvb, POINT_CODE_OFFSET);
if (sua_ri == ROUTE_ON_SSN_PC_ROUTING_INDICATOR) {
if (source) {
sua_opc->type = (Standard_Type)mtp3_standard;
sua_opc->pc = pc;
} else {
sua_dpc->type = (Standard_Type)mtp3_standard;
sua_dpc->pc = pc;
}
}
proto_tree_add_item(parameter_tree, source ? hf_sua_source_point_code : hf_sua_dest_point_code, parameter_tvb, POINT_CODE_OFFSET, POINT_CODE_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%s)", mtp3_pc_to_str(pc));
}
#define SSN_LENGTH 1
#define SSN_OFFSET (PARAMETER_VALUE_OFFSET + RESERVED_3_LENGTH)
#define INVALID_SSN 0xff
static void
dissect_ssn_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item, guint8 *ssn, gboolean source)
{
*ssn = tvb_get_guint8(parameter_tvb, SSN_OFFSET);
if(parameter_tree) {
proto_tree_add_item(parameter_tree, source ? hf_sua_source_ssn_reserved : hf_sua_dest_ssn_reserved, parameter_tvb, PARAMETER_VALUE_OFFSET, RESERVED_3_LENGTH, ENC_NA);
proto_tree_add_item(parameter_tree, source ? hf_sua_source_ssn_number : hf_sua_dest_ssn_number, parameter_tvb, SSN_OFFSET, SSN_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%u)", *ssn);
}
}
#define IPV4_ADDRESS_LENGTH 4
#define IPV4_ADDRESS_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_ipv4_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item, gboolean source)
{
proto_tree_add_item(parameter_tree, source ? hf_sua_source_ipv4 : hf_sua_dest_ipv4, parameter_tvb, IPV4_ADDRESS_OFFSET, IPV4_ADDRESS_LENGTH, ENC_BIG_ENDIAN);
proto_item_append_text(parameter_item, " (%s)", tvb_ip_to_str(wmem_packet_scope(), parameter_tvb, IPV4_ADDRESS_OFFSET));
}
#define HOSTNAME_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_hostname_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item, gboolean source)
{
guint16 hostname_length;
hostname_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
proto_tree_add_item(parameter_tree, source ? hf_sua_source_hostname : hf_sua_dest_hostname, parameter_tvb, HOSTNAME_OFFSET, hostname_length, ENC_ASCII);
proto_item_append_text(parameter_item, " (%s)",
tvb_format_text(wmem_packet_scope(), parameter_tvb, HOSTNAME_OFFSET, hostname_length));
}
#define IPV6_ADDRESS_LENGTH 16
#define IPV6_ADDRESS_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_ipv6_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item, gboolean source)
{
proto_tree_add_item(parameter_tree, source ? hf_sua_source_ipv6 : hf_sua_dest_ipv6, parameter_tvb, IPV6_ADDRESS_OFFSET, IPV6_ADDRESS_LENGTH, ENC_NA);
proto_item_append_text(parameter_item, " (%s)", tvb_ip6_to_str(wmem_packet_scope(), parameter_tvb, IPV6_ADDRESS_OFFSET));
}
static void
dissect_unknown_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
guint16 parameter_value_length;
parameter_value_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
proto_tree_add_item(parameter_tree, hf_sua_parameter_value, parameter_tvb, PARAMETER_VALUE_OFFSET, parameter_value_length, ENC_NA);
proto_item_append_text(parameter_item, "(tag %u and %u byte%s value)", tvb_get_ntohs(parameter_tvb, PARAMETER_TAG_OFFSET), parameter_value_length, plurality(parameter_value_length, "", "s"));
}
#define V8_DATA_PARAMETER_TAG 0x0003
#define V8_INFO_STRING_PARAMETER_TAG 0x0004
#define V8_ROUTING_CONTEXT_PARAMETER_TAG 0x0006
#define V8_DIAGNOSTIC_INFO_PARAMETER_TAG 0x0007
#define V8_HEARTBEAT_DATA_PARAMETER_TAG 0x0009
#define V8_TRAFFIC_MODE_TYPE_PARAMETER_TAG 0x000b
#define V8_ERROR_CODE_PARAMETER_TAG 0x000c
#define V8_STATUS_PARAMETER_TAG 0x000d
#define V8_CONGESTION_LEVEL_PARAMETER_TAG 0x000f
#define V8_ASP_IDENTIFIER_PARAMETER_TAG 0x0011
#define V8_AFFECTED_POINT_CODE_PARAMETER_TAG 0x0012
#define V8_SS7_HOP_COUNTER_PARAMETER_TAG 0x0101
#define V8_SOURCE_ADDRESS_PARAMETER_TAG 0x0102
#define V8_DESTINATION_ADDRESS_PARAMETER_TAG 0x0103
#define V8_SOURCE_REFERENCE_NUMBER_PARAMETER_TAG 0x0104
#define V8_DESTINATION_REFERENCE_NUMBER_PARAMETER_TAG 0x0105
#define V8_SCCP_CAUSE_PARAMETER_TAG 0x0106
#define V8_SEQUENCE_NUMBER_PARAMETER_TAG 0x0107
#define V8_RECEIVE_SEQUENCE_NUMBER_PARAMETER_TAG 0x0108
#define V8_ASP_CAPABILITIES_PARAMETER_TAG 0x0109
#define V8_CREDIT_PARAMETER_TAG 0x010a
#define V8_USER_CAUSE_PARAMETER_TAG 0x010c
#define V8_NETWORK_APPEARANCE_PARAMETER_TAG 0x010d
#define V8_ROUTING_KEY_PARAMETER_TAG 0x010e
#define V8_REGISTRATION_RESULT_PARAMETER_TAG 0x010f
#define V8_DEREGISTRATION_RESULT_PARAMETER_TAG 0x0110
#define V8_ADDRESS_RANGE_PARAMETER_TAG 0x0111
#define V8_CORRELATION_ID_PARAMETER_TAG 0x0112
#define V8_IMPORTANCE_PARAMETER_TAG 0x0113
#define V8_MESSAGE_PRIORITY_PARAMETER_TAG 0x0114
#define V8_PROTOCOL_CLASS_PARAMETER_TAG 0x0115
#define V8_SEQUENCE_CONTROL_PARAMETER_TAG 0x0116
#define V8_SEGMENTATION_PARAMETER_TAG 0x0117
#define V8_SMI_PARAMETER_TAG 0x0118
#define V8_TID_LABEL_PARAMETER_TAG 0x0119
#define V8_DRN_LABEL_PARAMETER_TAG 0x011a
#define V8_GLOBAL_TITLE_PARAMETER_TAG 0x8001
#define V8_POINT_CODE_PARAMETER_TAG 0x8002
#define V8_SUBSYSTEM_NUMBER_PARAMETER_TAG 0x8003
#define V8_IPV4_ADDRESS_PARAMETER_TAG 0x8004
#define V8_HOSTNAME_PARAMETER_TAG 0x8005
#define V8_IPV6_ADDRESS_PARAMETER_TAG 0x8006
static const value_string v8_parameter_tag_values[] = {
{ V8_DATA_PARAMETER_TAG, "Data" },
{ V8_INFO_STRING_PARAMETER_TAG, "Info String" },
{ V8_ROUTING_CONTEXT_PARAMETER_TAG, "Routing context" },
{ V8_DIAGNOSTIC_INFO_PARAMETER_TAG, "Diagnostic info" },
{ V8_HEARTBEAT_DATA_PARAMETER_TAG, "Heartbeat data" },
{ V8_TRAFFIC_MODE_TYPE_PARAMETER_TAG, "Traffic mode type" },
{ V8_ERROR_CODE_PARAMETER_TAG, "Error code" },
{ V8_STATUS_PARAMETER_TAG, "Status" },
{ V8_CONGESTION_LEVEL_PARAMETER_TAG, "Congestion level" },
{ V8_ASP_IDENTIFIER_PARAMETER_TAG, "ASP identifier" },
{ V8_AFFECTED_POINT_CODE_PARAMETER_TAG, "Affected point code" },
{ V8_SS7_HOP_COUNTER_PARAMETER_TAG, "SS7 hop counter" },
{ V8_SOURCE_ADDRESS_PARAMETER_TAG, "Source address" },
{ V8_DESTINATION_ADDRESS_PARAMETER_TAG, "Destination address" },
{ V8_SOURCE_REFERENCE_NUMBER_PARAMETER_TAG, "Source reference number" },
{ V8_DESTINATION_REFERENCE_NUMBER_PARAMETER_TAG, "Destination reference number" },
{ V8_SCCP_CAUSE_PARAMETER_TAG, "SCCP cause" },
{ V8_SEQUENCE_NUMBER_PARAMETER_TAG, "Sequence number" },
{ V8_RECEIVE_SEQUENCE_NUMBER_PARAMETER_TAG, "Receive sequence number" },
{ V8_ASP_CAPABILITIES_PARAMETER_TAG, "ASP capabilities" },
{ V8_CREDIT_PARAMETER_TAG, "Credit" },
{ V8_USER_CAUSE_PARAMETER_TAG, "User/Cause" },
{ V8_NETWORK_APPEARANCE_PARAMETER_TAG, "Network appearance" },
{ V8_ROUTING_KEY_PARAMETER_TAG, "Routing key" },
{ V8_REGISTRATION_RESULT_PARAMETER_TAG, "Registration result" },
{ V8_DEREGISTRATION_RESULT_PARAMETER_TAG, "Deregistration result" },
{ V8_ADDRESS_RANGE_PARAMETER_TAG, "Address range" },
{ V8_CORRELATION_ID_PARAMETER_TAG, "Correlation ID" },
{ V8_IMPORTANCE_PARAMETER_TAG, "Importance" },
{ V8_MESSAGE_PRIORITY_PARAMETER_TAG, "Message priority" },
{ V8_PROTOCOL_CLASS_PARAMETER_TAG, "Protocol class" },
{ V8_SEQUENCE_CONTROL_PARAMETER_TAG, "Sequence control" },
{ V8_SEGMENTATION_PARAMETER_TAG, "Segmentation" },
{ V8_SMI_PARAMETER_TAG, "SMI" },
{ V8_TID_LABEL_PARAMETER_TAG, "TID label" },
{ V8_DRN_LABEL_PARAMETER_TAG, "DRN label" },
{ V8_GLOBAL_TITLE_PARAMETER_TAG, "Global title" },
{ V8_POINT_CODE_PARAMETER_TAG, "Point code" },
{ V8_SUBSYSTEM_NUMBER_PARAMETER_TAG, "Subsystem number" },
{ V8_IPV4_ADDRESS_PARAMETER_TAG, "IPv4 address" },
{ V8_HOSTNAME_PARAMETER_TAG, "Hostname" },
{ V8_IPV6_ADDRESS_PARAMETER_TAG, "IPv6 address" },
{ 0, NULL } };
static void
dissect_v8_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, tvbuff_t **data_tvb, guint8 *source_ssn, guint8 *dest_ssn)
{
guint16 tag, length, padding_length;
proto_item *parameter_item;
proto_tree *parameter_tree;
guint8 ssn = INVALID_SSN;
/* extract tag and length from the parameter */
tag = tvb_get_ntohs(parameter_tvb, PARAMETER_TAG_OFFSET);
length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
padding_length = tvb_reported_length(parameter_tvb) - length;
/* create proto_tree stuff */
parameter_tree = proto_tree_add_subtree(tree, parameter_tvb, PARAMETER_HEADER_OFFSET, -1, ett_sua_parameter, ¶meter_item, val_to_str_const(tag, v8_parameter_tag_values, "Unknown parameter"));
/* add tag and length to the sua tree */
proto_tree_add_item(parameter_tree, hf_sua_v8_parameter_tag, parameter_tvb, PARAMETER_TAG_OFFSET, PARAMETER_TAG_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(parameter_tree, hf_sua_parameter_length, parameter_tvb, PARAMETER_LENGTH_OFFSET, PARAMETER_LENGTH_LENGTH, ENC_BIG_ENDIAN);
/*
** If no tree, only the data and ssn parameters in the source and destination
** address need to be dissected. This in order to make dissection of the data
** possible when there is no tree.
*/
if (!tree && tag != V8_DATA_PARAMETER_TAG
&& tag != V8_SOURCE_ADDRESS_PARAMETER_TAG
&& tag != V8_DESTINATION_ADDRESS_PARAMETER_TAG
&& tag != V8_DESTINATION_REFERENCE_NUMBER_PARAMETER_TAG
&& tag != V8_SOURCE_REFERENCE_NUMBER_PARAMETER_TAG
&& tag != V8_SUBSYSTEM_NUMBER_PARAMETER_TAG)
return;
switch(tag) {
case V8_DATA_PARAMETER_TAG:
dissect_data_parameter(parameter_tvb, parameter_tree, parameter_item, data_tvb);
break;
case V8_INFO_STRING_PARAMETER_TAG:
dissect_info_string_parameter(parameter_tvb, pinfo, parameter_tree, parameter_item);
break;
case V8_ROUTING_CONTEXT_PARAMETER_TAG:
dissect_routing_context_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_DIAGNOSTIC_INFO_PARAMETER_TAG:
dissect_diagnostic_information_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_HEARTBEAT_DATA_PARAMETER_TAG:
dissect_heartbeat_data_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_TRAFFIC_MODE_TYPE_PARAMETER_TAG:
dissect_traffic_mode_type_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_ERROR_CODE_PARAMETER_TAG:
dissect_v8_error_code_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_STATUS_PARAMETER_TAG:
dissect_status_type_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_CONGESTION_LEVEL_PARAMETER_TAG:
dissect_congestion_level_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_ASP_IDENTIFIER_PARAMETER_TAG:
dissect_asp_identifier_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_AFFECTED_POINT_CODE_PARAMETER_TAG:
dissect_affected_destinations_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_SS7_HOP_COUNTER_PARAMETER_TAG:
dissect_ss7_hop_counter_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_SOURCE_ADDRESS_PARAMETER_TAG:
dissect_source_address_parameter(parameter_tvb, pinfo, parameter_tree, source_ssn);
break;
case V8_DESTINATION_ADDRESS_PARAMETER_TAG:
dissect_destination_address_parameter(parameter_tvb, pinfo, parameter_tree, dest_ssn);
break;
case V8_SOURCE_REFERENCE_NUMBER_PARAMETER_TAG:
dissect_source_reference_number_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_DESTINATION_REFERENCE_NUMBER_PARAMETER_TAG:
dissect_destination_reference_number_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_SCCP_CAUSE_PARAMETER_TAG:
dissect_sccp_cause_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_SEQUENCE_NUMBER_PARAMETER_TAG:
dissect_sequence_number_parameter(parameter_tvb, parameter_tree);
break;
case V8_RECEIVE_SEQUENCE_NUMBER_PARAMETER_TAG:
dissect_receive_sequence_number_parameter(parameter_tvb, parameter_tree);
break;
case V8_ASP_CAPABILITIES_PARAMETER_TAG:
dissect_asp_capabilities_parameter(parameter_tvb, parameter_tree);
break;
case V8_CREDIT_PARAMETER_TAG:
dissect_credit_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_USER_CAUSE_PARAMETER_TAG:
dissect_user_cause_parameter(parameter_tvb, parameter_tree);
break;
case V8_NETWORK_APPEARANCE_PARAMETER_TAG:
dissect_network_appearance_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_ROUTING_KEY_PARAMETER_TAG:
dissect_routing_key_parameter(parameter_tvb, pinfo, parameter_tree);
break;
case V8_REGISTRATION_RESULT_PARAMETER_TAG:
dissect_registration_result_parameter(parameter_tvb, pinfo, parameter_tree);
break;
case V8_DEREGISTRATION_RESULT_PARAMETER_TAG:
dissect_deregistration_result_parameter(parameter_tvb, pinfo, parameter_tree);
break;
case V8_ADDRESS_RANGE_PARAMETER_TAG:
dissect_address_range_parameter(parameter_tvb, pinfo, parameter_tree);
break;
case V8_CORRELATION_ID_PARAMETER_TAG:
dissect_correlation_id_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_IMPORTANCE_PARAMETER_TAG:
dissect_importance_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_MESSAGE_PRIORITY_PARAMETER_TAG:
dissect_message_priority_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_PROTOCOL_CLASS_PARAMETER_TAG:
dissect_protocol_class_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_SEQUENCE_CONTROL_PARAMETER_TAG:
dissect_sequence_control_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_SEGMENTATION_PARAMETER_TAG:
dissect_segmentation_parameter(parameter_tvb, parameter_tree);
break;
case V8_SMI_PARAMETER_TAG:
dissect_smi_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case V8_TID_LABEL_PARAMETER_TAG:
dissect_tid_label_parameter(parameter_tvb, parameter_tree);
break;
case V8_DRN_LABEL_PARAMETER_TAG:
dissect_drn_label_parameter(parameter_tvb, parameter_tree);
break;
case V8_GLOBAL_TITLE_PARAMETER_TAG:
/* Reuse whether we have source_ssn or not to determine which address we're looking at */
dissect_global_title_parameter(parameter_tvb, parameter_tree, (source_ssn != NULL));
break;
case V8_POINT_CODE_PARAMETER_TAG:
/* Reuse whether we have source_ssn or not to determine which address we're looking at */
dissect_point_code_parameter(parameter_tvb, parameter_tree, parameter_item, (source_ssn != NULL));
break;
case V8_SUBSYSTEM_NUMBER_PARAMETER_TAG:
/* Reuse whether we have source_ssn or not to determine which address we're looking at */
dissect_ssn_parameter(parameter_tvb, parameter_tree, parameter_item, &ssn, (source_ssn != NULL));
if(source_ssn)
{
*source_ssn = ssn;
}
if(dest_ssn)
{
*dest_ssn = ssn;
}
break;
case V8_IPV4_ADDRESS_PARAMETER_TAG:
/* Reuse whether we have source_ssn or not to determine which address we're looking at */
dissect_ipv4_parameter(parameter_tvb, parameter_tree, parameter_item, (source_ssn != NULL));
break;
case V8_HOSTNAME_PARAMETER_TAG:
/* Reuse whether we have source_ssn or not to determine which address we're looking at */
dissect_hostname_parameter(parameter_tvb, parameter_tree, parameter_item, (source_ssn != NULL));
break;
case V8_IPV6_ADDRESS_PARAMETER_TAG:
/* Reuse whether we have source_ssn or not to determine which address we're looking at */
dissect_ipv6_parameter(parameter_tvb, parameter_tree, parameter_item, (source_ssn != NULL));
break;
default:
dissect_unknown_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
};
if (parameter_tree && (padding_length > 0))
proto_tree_add_item(parameter_tree, hf_sua_parameter_padding, parameter_tvb, PARAMETER_HEADER_OFFSET + length, padding_length, ENC_NA);
}
#define INFO_STRING_PARAMETER_TAG 0x0004
#define ROUTING_CONTEXT_PARAMETER_TAG 0x0006
#define DIAGNOSTIC_INFO_PARAMETER_TAG 0x0007
#define HEARTBEAT_DATA_PARAMETER_TAG 0x0009
#define TRAFFIC_MODE_TYPE_PARAMETER_TAG 0x000b
#define ERROR_CODE_PARAMETER_TAG 0x000c
#define STATUS_PARAMETER_TAG 0x000d
#define ASP_IDENTIFIER_PARAMETER_TAG 0x0011
#define AFFECTED_POINT_CODE_PARAMETER_TAG 0x0012
#define CORRELATION_ID_PARAMETER_TAG 0x0013
#define REGISTRATION_RESULT_PARAMETER_TAG 0x0014
#define DEREGISTRATION_RESULT_PARAMETER_TAG 0x0015
#define REGISTRATION_STATUS_PARAMETER_TAG 0x0016
#define DEREGISTRATION_STATUS_PARAMETER_TAG 0x0017
#define LOCAL_ROUTING_KEY_IDENTIFIER_PARAMETER_TAG 0x0018
#define SS7_HOP_COUNTER_PARAMETER_TAG 0x0101
#define SOURCE_ADDRESS_PARAMETER_TAG 0x0102
#define DESTINATION_ADDRESS_PARAMETER_TAG 0x0103
#define SOURCE_REFERENCE_NUMBER_PARAMETER_TAG 0x0104
#define DESTINATION_REFERENCE_NUMBER_PARAMETER_TAG 0x0105
#define SCCP_CAUSE_PARAMETER_TAG 0x0106
#define SEQUENCE_NUMBER_PARAMETER_TAG 0x0107
#define RECEIVE_SEQUENCE_NUMBER_PARAMETER_TAG 0x0108
#define ASP_CAPABILITIES_PARAMETER_TAG 0x0109
#define CREDIT_PARAMETER_TAG 0x010a
#define DATA_PARAMETER_TAG 0x010b
#define USER_CAUSE_PARAMETER_TAG 0x010c
#define NETWORK_APPEARANCE_PARAMETER_TAG 0x010d
#define ROUTING_KEY_PARAMETER_TAG 0x010e
#define DRN_LABEL_PARAMETER_TAG 0x010f
#define TID_LABEL_PARAMETER_TAG 0x0110
#define ADDRESS_RANGE_PARAMETER_TAG 0x0111
#define SMI_PARAMETER_TAG 0x0112
#define IMPORTANCE_PARAMETER_TAG 0x0113
#define MESSAGE_PRIORITY_PARAMETER_TAG 0x0114
#define PROTOCOL_CLASS_PARAMETER_TAG 0x0115
#define SEQUENCE_CONTROL_PARAMETER_TAG 0x0116
#define SEGMENTATION_PARAMETER_TAG 0x0117
#define CONGESTION_LEVEL_PARAMETER_TAG 0x0118
#define GLOBAL_TITLE_PARAMETER_TAG 0x8001
#define POINT_CODE_PARAMETER_TAG 0x8002
#define SUBSYSTEM_NUMBER_PARAMETER_TAG 0x8003
#define IPV4_ADDRESS_PARAMETER_TAG 0x8004
#define HOSTNAME_PARAMETER_TAG 0x8005
#define IPV6_ADDRESS_PARAMETER_TAG 0x8006
static const value_string parameter_tag_values[] = {
{ INFO_STRING_PARAMETER_TAG, "Info String" },
{ ROUTING_CONTEXT_PARAMETER_TAG, "Routing context" },
{ DIAGNOSTIC_INFO_PARAMETER_TAG, "Diagnostic info" },
{ HEARTBEAT_DATA_PARAMETER_TAG, "Heartbeat data" },
{ TRAFFIC_MODE_TYPE_PARAMETER_TAG, "Traffic mode type" },
{ ERROR_CODE_PARAMETER_TAG, "Error code" },
{ STATUS_PARAMETER_TAG, "Status" },
{ ASP_IDENTIFIER_PARAMETER_TAG, "ASP identifier" },
{ AFFECTED_POINT_CODE_PARAMETER_TAG, "Affected point code" },
{ CORRELATION_ID_PARAMETER_TAG, "Correlation ID" },
{ REGISTRATION_RESULT_PARAMETER_TAG, "Registration result" },
{ DEREGISTRATION_RESULT_PARAMETER_TAG, "Deregistration result" },
{ REGISTRATION_STATUS_PARAMETER_TAG, "Registration status" },
{ DEREGISTRATION_STATUS_PARAMETER_TAG, "Deregistration status" },
{ LOCAL_ROUTING_KEY_IDENTIFIER_PARAMETER_TAG, "Local routing key identifier" },
{ SS7_HOP_COUNTER_PARAMETER_TAG, "SS7 hop counter" },
{ SOURCE_ADDRESS_PARAMETER_TAG, "Source address" },
{ DESTINATION_ADDRESS_PARAMETER_TAG, "Destination address" },
{ SOURCE_REFERENCE_NUMBER_PARAMETER_TAG, "Source reference number" },
{ DESTINATION_REFERENCE_NUMBER_PARAMETER_TAG, "Destination reference number" },
{ SCCP_CAUSE_PARAMETER_TAG, "SCCP cause" },
{ SEQUENCE_NUMBER_PARAMETER_TAG, "Sequence number" },
{ RECEIVE_SEQUENCE_NUMBER_PARAMETER_TAG, "Receive sequence number" },
{ ASP_CAPABILITIES_PARAMETER_TAG, "ASP capabilities" },
{ CREDIT_PARAMETER_TAG, "Credit" },
{ DATA_PARAMETER_TAG, "Data" },
{ USER_CAUSE_PARAMETER_TAG, "User/Cause" },
{ NETWORK_APPEARANCE_PARAMETER_TAG, "Network appearance" },
{ ROUTING_KEY_PARAMETER_TAG, "Routing key" },
{ DRN_LABEL_PARAMETER_TAG, "DRN label" },
{ TID_LABEL_PARAMETER_TAG, "TID label" },
{ ADDRESS_RANGE_PARAMETER_TAG, "Address range" },
{ SMI_PARAMETER_TAG, "SMI" },
{ IMPORTANCE_PARAMETER_TAG, "Importance" },
{ MESSAGE_PRIORITY_PARAMETER_TAG, "Message priority" },
{ PROTOCOL_CLASS_PARAMETER_TAG, "Protocol class" },
{ SEQUENCE_CONTROL_PARAMETER_TAG, "Sequence control" },
{ SEGMENTATION_PARAMETER_TAG, "Segmentation" },
{ CONGESTION_LEVEL_PARAMETER_TAG, "Congestion level" },
{ GLOBAL_TITLE_PARAMETER_TAG, "Global title" },
{ POINT_CODE_PARAMETER_TAG, "Point code" },
{ SUBSYSTEM_NUMBER_PARAMETER_TAG, "Subsystem number" },
{ IPV4_ADDRESS_PARAMETER_TAG, "IPv4 address" },
{ HOSTNAME_PARAMETER_TAG, "Hostname" },
{ IPV6_ADDRESS_PARAMETER_TAG, "IPv6 address" },
{ 0, NULL } };
static void
dissect_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *tree, tvbuff_t **data_tvb, guint8 *source_ssn, guint8 *dest_ssn)
{
guint16 tag, length, padding_length;
proto_item *parameter_item;
proto_tree *parameter_tree;
guint8 ssn = INVALID_SSN;
const gchar *param_tag_str = NULL;
/* Extract tag and length from the parameter */
tag = tvb_get_ntohs(parameter_tvb, PARAMETER_TAG_OFFSET);
length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
padding_length = tvb_reported_length(parameter_tvb) - length;
/* Create proto_tree stuff */
/* If it's a known parameter it's present in the value_string.
* If param_tag_str = NULL then this is an unknown parameter
*/
param_tag_str = try_val_to_str(tag, parameter_tag_values);
if(param_tag_str) {
/* The parameter exists */
parameter_tree = proto_tree_add_subtree(tree, parameter_tvb, PARAMETER_HEADER_OFFSET, -1, ett_sua_parameter, ¶meter_item, param_tag_str);
} else {
if(dissector_try_uint(sua_parameter_table, tag, parameter_tvb, pinfo,tree)) {
return;
}
parameter_tree = proto_tree_add_subtree(tree, parameter_tvb, PARAMETER_HEADER_OFFSET, -1, ett_sua_parameter, ¶meter_item, "Unknown parameter");
}
/* Add tag and length to the sua tree */
proto_tree_add_item(parameter_tree, hf_sua_parameter_tag, parameter_tvb, PARAMETER_TAG_OFFSET, PARAMETER_TAG_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(parameter_tree, hf_sua_parameter_length, parameter_tvb, PARAMETER_LENGTH_OFFSET, PARAMETER_LENGTH_LENGTH, ENC_BIG_ENDIAN);
/*
** If no tree, only the data, ssn, PC, and GT parameters in the source and destination
** addresses need to be dissected. This in order to make dissection of the data
** possible and to allow us to set the source and destination addresses when there is
** no tree.
*/
if (!tree && tag != DATA_PARAMETER_TAG
&& tag != SOURCE_ADDRESS_PARAMETER_TAG
&& tag != DESTINATION_ADDRESS_PARAMETER_TAG
&& tag != POINT_CODE_PARAMETER_TAG
&& tag != GLOBAL_TITLE_PARAMETER_TAG
&& tag != DESTINATION_REFERENCE_NUMBER_PARAMETER_TAG
&& tag != SOURCE_REFERENCE_NUMBER_PARAMETER_TAG
&& tag != SUBSYSTEM_NUMBER_PARAMETER_TAG)
return; /* Nothing to do here */
switch(tag) {
case DATA_PARAMETER_TAG:
dissect_data_parameter(parameter_tvb, parameter_tree, parameter_item, data_tvb);
break;
case INFO_STRING_PARAMETER_TAG:
dissect_info_string_parameter(parameter_tvb, pinfo, parameter_tree, parameter_item);
break;
case ROUTING_CONTEXT_PARAMETER_TAG:
dissect_routing_context_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case DIAGNOSTIC_INFO_PARAMETER_TAG:
dissect_diagnostic_information_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case HEARTBEAT_DATA_PARAMETER_TAG:
dissect_heartbeat_data_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case TRAFFIC_MODE_TYPE_PARAMETER_TAG:
dissect_traffic_mode_type_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case ERROR_CODE_PARAMETER_TAG:
dissect_error_code_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case STATUS_PARAMETER_TAG:
dissect_status_type_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case CONGESTION_LEVEL_PARAMETER_TAG:
dissect_congestion_level_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case ASP_IDENTIFIER_PARAMETER_TAG:
dissect_asp_identifier_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case AFFECTED_POINT_CODE_PARAMETER_TAG:
dissect_affected_destinations_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case REGISTRATION_STATUS_PARAMETER_TAG:
dissect_registration_status_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case DEREGISTRATION_STATUS_PARAMETER_TAG:
dissect_deregistration_status_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case LOCAL_ROUTING_KEY_IDENTIFIER_PARAMETER_TAG:
dissect_local_routing_key_identifier_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case SS7_HOP_COUNTER_PARAMETER_TAG:
dissect_ss7_hop_counter_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case SOURCE_ADDRESS_PARAMETER_TAG:
dissect_source_address_parameter(parameter_tvb, pinfo, parameter_tree, source_ssn);
break;
case DESTINATION_ADDRESS_PARAMETER_TAG:
dissect_destination_address_parameter(parameter_tvb, pinfo, parameter_tree, dest_ssn);
break;
case SOURCE_REFERENCE_NUMBER_PARAMETER_TAG:
dissect_source_reference_number_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case DESTINATION_REFERENCE_NUMBER_PARAMETER_TAG:
dissect_destination_reference_number_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case SCCP_CAUSE_PARAMETER_TAG:
dissect_sccp_cause_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case SEQUENCE_NUMBER_PARAMETER_TAG:
dissect_sequence_number_parameter(parameter_tvb, parameter_tree);
break;
case RECEIVE_SEQUENCE_NUMBER_PARAMETER_TAG:
dissect_receive_sequence_number_parameter(parameter_tvb, parameter_tree);
break;
case ASP_CAPABILITIES_PARAMETER_TAG:
dissect_asp_capabilities_parameter(parameter_tvb, parameter_tree);
break;
case CREDIT_PARAMETER_TAG:
dissect_credit_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case USER_CAUSE_PARAMETER_TAG:
dissect_user_cause_parameter(parameter_tvb, parameter_tree);
break;
case NETWORK_APPEARANCE_PARAMETER_TAG:
dissect_network_appearance_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case ROUTING_KEY_PARAMETER_TAG:
dissect_routing_key_parameter(parameter_tvb, pinfo, parameter_tree);
break;
case REGISTRATION_RESULT_PARAMETER_TAG:
dissect_registration_result_parameter(parameter_tvb, pinfo, parameter_tree);
break;
case DEREGISTRATION_RESULT_PARAMETER_TAG:
dissect_deregistration_result_parameter(parameter_tvb, pinfo, parameter_tree);
break;
case ADDRESS_RANGE_PARAMETER_TAG:
dissect_address_range_parameter(parameter_tvb, pinfo, parameter_tree);
break;
case CORRELATION_ID_PARAMETER_TAG:
dissect_correlation_id_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case IMPORTANCE_PARAMETER_TAG:
dissect_importance_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case MESSAGE_PRIORITY_PARAMETER_TAG:
dissect_message_priority_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case PROTOCOL_CLASS_PARAMETER_TAG:
dissect_protocol_class_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case SEQUENCE_CONTROL_PARAMETER_TAG:
dissect_sequence_control_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case SEGMENTATION_PARAMETER_TAG:
dissect_segmentation_parameter(parameter_tvb, parameter_tree);
break;
case SMI_PARAMETER_TAG:
dissect_smi_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
case TID_LABEL_PARAMETER_TAG:
dissect_tid_label_parameter(parameter_tvb, parameter_tree);
break;
case DRN_LABEL_PARAMETER_TAG:
dissect_drn_label_parameter(parameter_tvb, parameter_tree);
break;
case GLOBAL_TITLE_PARAMETER_TAG:
/* Reuse whether we have source_ssn or not to determine which address we're looking at */
dissect_global_title_parameter(parameter_tvb, parameter_tree, (source_ssn != NULL));
break;
case POINT_CODE_PARAMETER_TAG:
/* Reuse whether we have source_ssn or not to determine which address we're looking at */
dissect_point_code_parameter(parameter_tvb, parameter_tree, parameter_item, (source_ssn != NULL));
break;
case SUBSYSTEM_NUMBER_PARAMETER_TAG:
/* Reuse whether we have source_ssn or not to determine which address we're looking at */
dissect_ssn_parameter(parameter_tvb, parameter_tree, parameter_item, &ssn, (source_ssn != NULL));
if(source_ssn)
{
*source_ssn = ssn;
}
if(dest_ssn)
{
*dest_ssn = ssn;
}
break;
case IPV4_ADDRESS_PARAMETER_TAG:
/* Reuse whether we have source_ssn or not to determine which address we're looking at */
dissect_ipv4_parameter(parameter_tvb, parameter_tree, parameter_item, (source_ssn != NULL));
break;
case HOSTNAME_PARAMETER_TAG:
/* Reuse whether we have source_ssn or not to determine which address we're looking at */
dissect_hostname_parameter(parameter_tvb, parameter_tree, parameter_item, (source_ssn != NULL));
break;
case IPV6_ADDRESS_PARAMETER_TAG:
/* Reuse whether we have source_ssn or not to determine which address we're looking at */
dissect_ipv6_parameter(parameter_tvb, parameter_tree, parameter_item, (source_ssn != NULL));
break;
default:
dissect_unknown_parameter(parameter_tvb, parameter_tree, parameter_item);
break;
};
if (parameter_tree && (padding_length > 0))
proto_tree_add_item(parameter_tree, hf_sua_parameter_padding, parameter_tvb, PARAMETER_HEADER_OFFSET + length, padding_length, ENC_NA);
}
static void
dissect_parameters(tvbuff_t *parameters_tvb, packet_info *pinfo, proto_tree *tree, tvbuff_t **data_tvb, guint8 *source_ssn, guint8 *dest_ssn)
{
gint offset, length, total_length, remaining_length;
tvbuff_t *parameter_tvb;
offset = 0;
while((remaining_length = tvb_reported_length_remaining(parameters_tvb, offset))) {
length = tvb_get_ntohs(parameters_tvb, offset + PARAMETER_LENGTH_OFFSET);
total_length = WS_ROUNDUP_4(length);
if (remaining_length >= length)
total_length = MIN(total_length, remaining_length);
/* create a tvb for the parameter including the padding bytes */
parameter_tvb = tvb_new_subset_length(parameters_tvb, offset, total_length);
switch(version) {
case SUA_V08:
dissect_v8_parameter(parameter_tvb, pinfo, tree, data_tvb, source_ssn, dest_ssn);
break;
case SUA_RFC:
dissect_parameter(parameter_tvb, pinfo, tree, data_tvb, source_ssn, dest_ssn);
break;
}
/* get rid of the handled parameter */
offset += total_length;
}
}
static void
dissect_sua_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *sua_tree, proto_tree *tree)
{
tvbuff_t *common_header_tvb;
tvbuff_t *parameters_tvb;
tvbuff_t *data_tvb = NULL;
heur_dtbl_entry_t *hdtbl_entry;
#if 0
proto_tree *assoc_tree;
#endif
guint8 source_ssn = INVALID_SSN;
guint8 dest_ssn = INVALID_SSN;
proto_item *assoc_item;
struct _sccp_msg_info_t* sccp_info = NULL;
message_class = 0;
message_type = 0;
drn = 0;
srn = 0;
assoc = NULL;
no_sua_assoc.calling_dpc = 0;
no_sua_assoc.called_dpc = 0;
no_sua_assoc.calling_ssn = INVALID_SSN;
no_sua_assoc.called_ssn = INVALID_SSN;
no_sua_assoc.has_bw_key = FALSE;
no_sua_assoc.has_fw_key = FALSE;
sua_opc = wmem_new0(pinfo->pool, mtp3_addr_pc_t);
sua_dpc = wmem_new0(pinfo->pool, mtp3_addr_pc_t);
sua_source_gt = NULL;
sua_destination_gt = NULL;
common_header_tvb = tvb_new_subset_length(message_tvb, COMMON_HEADER_OFFSET, COMMON_HEADER_LENGTH);
dissect_common_header(common_header_tvb, pinfo, sua_tree);
parameters_tvb = tvb_new_subset_remaining(message_tvb, COMMON_HEADER_LENGTH);
dissect_parameters(parameters_tvb, pinfo, sua_tree, &data_tvb, &source_ssn, &dest_ssn);
if (message_class == MESSAGE_CLASS_CO_MESSAGE) {
/* XXX: this might fail with multihomed SCTP (on a path failure during a call)
* or with "load sharing"?
*/
sccp_assoc_info_t* sccp_assoc;
sccp_decode_context_t sccp_decode;
/* sua assoc */
switch (message_type) {
case MESSAGE_TYPE_CORE:
assoc = sua_assoc(pinfo,&(pinfo->src),&(pinfo->dst), srn , drn);
if(assoc) {
assoc->calling_routing_ind = sua_ri;
assoc->calling_ssn = source_ssn;
assoc->called_ssn = dest_ssn;
}
break;
case MESSAGE_TYPE_COAK:
assoc = sua_assoc(pinfo,&(pinfo->src),&(pinfo->dst), srn , drn);
if(assoc) {
assoc->called_routing_ind = sua_ri;
if( (assoc->called_ssn != INVALID_SSN)&& (dest_ssn != INVALID_SSN)) {
assoc->called_ssn = dest_ssn;
}
}
break;
default :
assoc = sua_assoc(pinfo,&(pinfo->src),&(pinfo->dst), srn , drn);
}
switch (message_type) {
case MESSAGE_TYPE_CORE:
case MESSAGE_TYPE_COAK:
break;
default:
if((assoc && assoc->called_ssn != INVALID_SSN)&& (dest_ssn != INVALID_SSN)) {
dest_ssn = assoc->called_ssn;
}
if((assoc && assoc->calling_ssn != INVALID_SSN)&& (source_ssn != INVALID_SSN)) {
source_ssn = assoc->calling_ssn;
}
}
if (assoc && assoc->assoc_id !=0) {
assoc_item = proto_tree_add_uint(tree, hf_sua_assoc_id, message_tvb, 0, 0, assoc->assoc_id);
proto_item_set_generated(assoc_item);
#if 0
assoc_tree = proto_item_add_subtree(assoc_item, ett_sua_assoc);
proto_tree_add_debug_text(assoc_tree, message_tvb, 0, 0, "routing_ind %u", assoc->calling_routing_ind);
proto_tree_add_debug_text(assoc_tree, message_tvb, 0, 0, "routing_ind %u", assoc->called_routing_ind);
proto_tree_add_debug_text(assoc_tree, message_tvb, 0, 0, "calling_ssn %u", assoc->calling_ssn);
proto_tree_add_debug_text(assoc_tree, message_tvb, 0, 0, "called_ssn %u", assoc->called_ssn);
#endif /* 0 */
}
sccp_decode.message_type = message_type;
sccp_decode.dlr = drn;
sccp_decode.slr = srn;
sccp_decode.assoc = NULL;
sccp_decode.sccp_msg = NULL; /* Unused, but initialized */
sccp_assoc = get_sccp_assoc(pinfo, tvb_offset_from_real_beginning(message_tvb), &sccp_decode);
if (sccp_assoc && sccp_assoc->curr_msg) {
sccp_info = sccp_assoc->curr_msg;
tap_queue_packet(sua_tap,pinfo,sccp_assoc->curr_msg);
}
}
if (set_addresses) {
if (sua_opc->type)
set_address(&pinfo->src, ss7pc_address_type, sizeof(mtp3_addr_pc_t), (guint8 *) sua_opc);
if (sua_dpc->type)
set_address(&pinfo->dst, ss7pc_address_type, sizeof(mtp3_addr_pc_t), (guint8 *) sua_dpc);
if (sua_source_gt)
set_address(&pinfo->src, AT_STRINGZ, 1+(int)strlen(sua_source_gt), wmem_strdup(pinfo->pool, sua_source_gt));
if (sua_destination_gt)
set_address(&pinfo->dst, AT_STRINGZ, 1+(int)strlen(sua_destination_gt), wmem_strdup(pinfo->pool, sua_destination_gt));
}
/* If there was SUA data it could be dissected */
if(data_tvb)
{
/* Try subdissectors (if we found a valid SSN on the current message) */
if ((dest_ssn == INVALID_SSN ||
!dissector_try_uint_new(sccp_ssn_dissector_table, dest_ssn, data_tvb, pinfo, tree, TRUE, sccp_info))
&& (source_ssn == INVALID_SSN ||
!dissector_try_uint_new(sccp_ssn_dissector_table, source_ssn, data_tvb, pinfo, tree, TRUE, sccp_info)))
{
/* try heuristic subdissector list to see if there are any takers */
if (dissector_try_heuristic(heur_subdissector_list, data_tvb, pinfo, tree, &hdtbl_entry, sccp_info)) {
return;
}
/* No sub-dissection occurred, treat it as raw data */
call_data_dissector(data_tvb, pinfo, tree);
}
}
}
static int
dissect_sua(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
proto_item *sua_item;
proto_tree *sua_tree;
/* make entry in the Protocol column on summary display */
switch (version) {
case SUA_V08:
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SUA (ID 08)");
break;
case SUA_RFC:
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SUA (RFC 3868)");
break;
}
/* Clear entries in Info column on summary display */
col_clear(pinfo->cinfo, COL_INFO);
/* create the sua protocol tree */
sua_item = proto_tree_add_item(tree, proto_sua, message_tvb, 0, -1, ENC_NA);
sua_tree = proto_item_add_subtree(sua_item, ett_sua);
/* dissect the message */
dissect_sua_message(message_tvb, pinfo, sua_tree, tree);
return tvb_captured_length(message_tvb);
}
/* Register the protocol with Wireshark */
void
proto_register_sua(void)
{
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_sua_version, { "Version", "sua.version", FT_UINT8, BASE_DEC, VALS(protocol_version_values), 0x0, NULL, HFILL } },
{ &hf_sua_reserved, { "Reserved", "sua.reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_message_class, { "Message Class", "sua.message_class", FT_UINT8, BASE_DEC, VALS(message_class_values), 0x0, NULL, HFILL } },
{ &hf_sua_message_type, { "Message Type", "sua.message_type", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_message_length, { "Message Length", "sua.message_length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_parameter_tag, { "Parameter Tag", "sua.parameter_tag", FT_UINT16, BASE_HEX, VALS(parameter_tag_values), 0x0, NULL, HFILL } },
{ &hf_sua_v8_parameter_tag, { "Parameter Tag", "sua.parameter_tag", FT_UINT16, BASE_HEX, VALS(v8_parameter_tag_values), 0x0, NULL, HFILL } },
{ &hf_sua_parameter_length, { "Parameter Length", "sua.parameter_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_parameter_value, { "Parameter Value", "sua.parameter_value", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_parameter_padding, { "Padding", "sua.parameter_padding", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_info_string, { "Info string", "sua.info_string", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_routing_context, { "Routing context", "sua.routing_context", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_diagnostic_information_info, { "Diagnostic Information", "sua.diagnostic_information", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_heartbeat_data, { "Heartbeat Data", "sua.heartbeat_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_traffic_mode_type, { "Traffic mode Type", "sua.traffic_mode_type", FT_UINT32, BASE_DEC, VALS(traffic_mode_type_values), 0x0, NULL, HFILL } },
{ &hf_sua_error_code, { "Error code", "sua.error_code", FT_UINT32, BASE_DEC, VALS(error_code_values), 0x0, NULL, HFILL } },
{ &hf_sua_v8_error_code, { "Error code", "sua.error_code", FT_UINT32, BASE_DEC, VALS(v8_error_code_values), 0x0, NULL, HFILL } },
{ &hf_sua_status_type, { "Status type", "sua.status_type", FT_UINT16, BASE_DEC, VALS(status_type_values), 0x0, NULL, HFILL } },
{ &hf_sua_status_info, { "Status info", "sua.status_info", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_congestion_level, { "Congestion Level", "sua.congestion_level", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_asp_identifier, { "ASP Identifier", "sua.asp_identifier", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_mask, { "Mask", "sua.affected_point_code_mask", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_dpc, { "Affected DPC", "sua.affected_pointcode_dpc", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_registration_status, { "Registration status", "sua.registration_status", FT_UINT32, BASE_DEC, VALS(registration_status_values), 0x0, NULL, HFILL } },
{ &hf_sua_deregistration_status, { "Deregistration status", "sua.deregistration_status", FT_UINT32, BASE_DEC, VALS(deregistration_status_values), 0x0, NULL, HFILL } },
{ &hf_sua_local_routing_key_identifier, { "Local routing key identifier", "sua.local_routing_key_identifier", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_source_address_routing_indicator, { "Source Routing Indicator", "sua.source.routing_indicator", FT_UINT16, BASE_DEC, VALS(routing_indicator_values), 0x0, NULL, HFILL } },
{ &hf_sua_source_address_reserved_bits, { "Source Reserved Bits", "sua.source.reserved_bits", FT_UINT16, BASE_DEC, NULL, ADDRESS_RESERVED_BITMASK, NULL, HFILL } },
{ &hf_sua_source_address_gt_bit, { "Source Include GT", "sua.source.gt_bit", FT_BOOLEAN, 16, NULL, ADDRESS_GT_BITMASK, NULL, HFILL } },
{ &hf_sua_source_address_pc_bit, { "Source Include PC", "sua.source.pc_bit", FT_BOOLEAN, 16, NULL, ADDRESS_PC_BITMASK, NULL, HFILL } },
{ &hf_sua_source_address_ssn_bit, { "Source Include SSN", "sua.source.ssn_bit", FT_BOOLEAN, 16, NULL, ADDRESS_SSN_BITMASK, NULL, HFILL } },
{ &hf_sua_source_gt_reserved, { "Source Reserved", "sua.source.gt_reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_source_gti, { "Source GTI", "sua.source.gti", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_source_number_of_digits, { "Source Number of Digits", "sua.source.global_title_number_of_digits", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_source_translation_type, { "Source Translation Type", "sua.source.global_title_translation_type", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_source_numbering_plan, { "Source Numbering Plan", "sua.source.global_title_numbering_plan", FT_UINT8, BASE_HEX, VALS(numbering_plan_values), 0x0, NULL, HFILL } },
{ &hf_sua_source_nature_of_address, { "Source Nature of Address", "sua.source.global_title_nature_of_address", FT_UINT8, BASE_HEX, VALS(nature_of_address_values), 0x0, NULL, HFILL } },
{ &hf_sua_source_global_title_digits, { "Source Global Title Digits", "sua.source.global_title_digits", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_source_point_code, { "Source Point Code", "sua.source.point_code", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_source_ssn_reserved, { "Source Reserved", "sua.source.ssn_reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_source_ssn_number, { "Source Subsystem Number", "sua.source.ssn", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_source_ipv4, { "Source IP Version 4 address", "sua.source.ipv4_address", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_source_hostname, { "Source Hostname", "sua.source.hostname.name", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_source_ipv6, { "Source IP Version 6 address", "sua.source.ipv6_address", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_destination_address_routing_indicator, { "Destination Routing Indicator","sua.destination.routing_indicator", FT_UINT16, BASE_DEC, VALS(routing_indicator_values), 0x0, NULL, HFILL } },
{ &hf_sua_destination_address_reserved_bits, { "Destination Reserved Bits", "sua.destination.reserved_bits", FT_UINT16, BASE_DEC, NULL, ADDRESS_RESERVED_BITMASK, NULL, HFILL } },
{ &hf_sua_destination_address_gt_bit, { "Destination Include GT", "sua.destination.gt_bit", FT_BOOLEAN, 16, NULL, ADDRESS_GT_BITMASK, NULL, HFILL } },
{ &hf_sua_destination_address_pc_bit, { "Destination Include PC", "sua.destination.pc_bit", FT_BOOLEAN, 16, NULL, ADDRESS_PC_BITMASK, NULL, HFILL } },
{ &hf_sua_destination_address_ssn_bit, { "Destination Include SSN", "sua.destination.ssn_bit", FT_BOOLEAN, 16, NULL, ADDRESS_SSN_BITMASK, NULL, HFILL } },
{ &hf_sua_dest_gt_reserved, { "Destination Reserved", "sua.destination.gt_reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_dest_gti, { "Destination GTI", "sua.destination.gti", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_dest_number_of_digits, { "Destination Number of Digits", "sua.destination.global_title_number_of_digits", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_dest_translation_type, { "Destination Translation Type", "sua.destination.global_title_translation_type", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_dest_numbering_plan, { "Destination Numbering Plan", "sua.destination.global_title_numbering_plan", FT_UINT8, BASE_HEX, VALS(numbering_plan_values), 0x0, NULL, HFILL } },
{ &hf_sua_dest_nature_of_address, { "Destination Nature of Address","sua.destination.global_title_nature_of_address",FT_UINT8, BASE_HEX, VALS(nature_of_address_values), 0x0, NULL, HFILL } },
{ &hf_sua_dest_global_title_digits, { "Destination Global Title Digits","sua.destination.global_title_digits", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_dest_point_code, { "Destination Point Code", "sua.destination.point_code", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_dest_ssn_reserved, { "Destination Reserved", "sua.destination.ssn_reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_dest_ssn_number, { "Destination Subsystem Number", "sua.destination.ssn", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_dest_ipv4, { "Destination IPv4 address", "sua.destination.ipv4_address", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_dest_hostname, { "Destination Hostname", "sua.destination.hostname.name", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_dest_ipv6, { "Destination IPv6 address", "sua.destination.ipv6_address", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_ss7_hop_counter_counter, { "SS7 Hop Counter", "sua.ss7_hop_counter_counter", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_ss7_hop_counter_reserved, { "Reserved", "sua.ss7_hop_counter_reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_destination_reference_number, { "Destination Reference Number", "sua.destination_reference_number", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_source_reference_number, { "Source Reference Number", "sua.source_reference_number", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_cause_reserved, { "Reserved", "sua.sccp_cause_reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_cause_type, { "Cause Type", "sua.sccp_cause_type", FT_UINT8, BASE_HEX, VALS(cause_type_values), 0x0, NULL, HFILL } },
{ &hf_sua_cause_value, { "Cause Value", "sua.sccp_cause_value", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_sequence_number_reserved, { "Reserved", "sua.sequence_number_reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_sequence_number_rec_number, { "Receive Sequence Number P(R)", "sua.sequence_number_receive_sequence_number", FT_UINT8, BASE_DEC, NULL, SEQ_NUM_MASK, NULL, HFILL } },
{ &hf_sua_sequence_number_more_data_bit, { "More Data Bit", "sua.sequence_number_more_data_bit", FT_BOOLEAN, 8, TFS(&more_data_bit_value), MORE_DATA_BIT_MASK, NULL, HFILL } },
{ &hf_sua_sequence_number_sent_number, { "Sent Sequence Number P(S)", "sua.sequence_number_sent_sequence_number", FT_UINT8, BASE_DEC, NULL, SEQ_NUM_MASK, NULL, HFILL } },
{ &hf_sua_sequence_number_spare_bit, { "Spare Bit", "sua.sequence_number_spare_bit", FT_UINT8, BASE_DEC, NULL, SPARE_BIT_MASK, NULL, HFILL } },
{ &hf_sua_receive_sequence_number_reserved, { "Reserved", "sua.receive_sequence_number_reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_receive_sequence_number_number, { "Receive Sequence Number P(R)", "sua.receive_sequence_number_number", FT_UINT8, BASE_DEC, NULL, SEQ_NUM_MASK, NULL, HFILL } },
{ &hf_sua_receive_sequence_number_spare_bit, { "Spare Bit", "sua.receive_sequence_number_spare_bit", FT_UINT8, BASE_DEC, NULL, SPARE_BIT_MASK, NULL, HFILL } },
{ &hf_sua_asp_capabilities_reserved, { "Reserved", "sua.asp_capabilities_reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_protocol_classes, { "Protocol classes", "sua.protocol_classes", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_protocol_class_flags, { "Protocol class", "sua.protocol_class_flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_asp_capabilities_reserved_bits, { "Reserved Bits", "sua.asp_capabilities_reserved_bits", FT_UINT8, BASE_HEX, NULL, RESERVED_BITS_MASK, NULL, HFILL } },
{ &hf_sua_asp_capabilities_a_bit, { "Protocol Class 3", "sua.asp_capabilities_a_bit", FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), A_BIT_MASK, NULL, HFILL } },
{ &hf_sua_asp_capabilities_b_bit, { "Protocol Class 2", "sua.asp_capabilities_b_bit", FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), B_BIT_MASK, NULL, HFILL } },
{ &hf_sua_asp_capabilities_c_bit, { "Protocol Class 1", "sua.asp_capabilities_c_bit", FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), C_BIT_MASK, NULL, HFILL } },
{ &hf_sua_asp_capabilities_d_bit, { "Protocol Class 0", "sua.asp_capabilities_d_bit", FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), D_BIT_MASK, NULL, HFILL } },
{ &hf_sua_asp_capabilities_interworking, { "Interworking", "sua.asp_capabilities_interworking", FT_UINT8, BASE_HEX, VALS(interworking_values), 0x0, NULL, HFILL } },
{ &hf_sua_credit, { "Credit", "sua.credit", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_cause, { "Cause", "sua.cause_user_cause", FT_UINT16, BASE_DEC, VALS(cause_values), 0x0, NULL, HFILL } },
{ &hf_sua_user, { "User", "sua.cause_user_user", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_data, { "Data", "sua.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_network_appearance, { "Network Appearance", "sua.network_appearance", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_correlation_id, { "Correlation ID", "sua.correlation_id", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_importance_reserved, { "Reserved", "sua.importance_reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_importance, { "Importance", "sua.importance_importance", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_message_priority_reserved, { "Reserved", "sua.message_priority_reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_message_priority, { "Message Priority", "sua.message_priority_priority", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_protocol_class_reserved, { "Reserved", "sua.protocol_class_reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_return_on_error_bit, { "Return On Error Bit", "sua.protocol_class_return_on_error_bit", FT_BOOLEAN, 8, TFS(&return_on_error_bit_value), RETURN_ON_ERROR_BIT_MASK, NULL, HFILL } },
{ &hf_sua_protocol_class, { "Protocol Class", "sua.protocol_class_class", FT_UINT8, BASE_DEC, NULL, PROTOCOL_CLASS_MASK, NULL, HFILL } },
{ &hf_sua_sequence_control, { "Sequence Control", "sua.sequence_control_sequence_control", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_first_remaining, { "First / Remaining", "sua.first_remaining", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_first_bit, { "First Segment Bit", "sua.segmentation_first_bit", FT_BOOLEAN, 8, TFS(&first_bit_value), FIRST_BIT_MASK, NULL, HFILL } },
{ &hf_sua_number_of_remaining_segments, { "Number of Remaining Segments", "sua.segmentation_number_of_remaining_segments", FT_UINT8, BASE_DEC, NULL, NUMBER_OF_SEGMENTS_MASK, NULL, HFILL } },
{ &hf_sua_segmentation_reference, { "Segmentation Reference", "sua.segmentation_reference", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_smi_reserved, { "Reserved", "sua.smi_reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_smi, { "SMI", "sua.smi_smi", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_tid_label_start, { "Start", "sua.tid_label_start", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_tid_label_end, { "End", "sua.tid_label_end", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_tid_label_value, { "Label Value", "sua.tid_label_value", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_drn_label_start, { "Start", "sua.drn_label_start", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_drn_label_end, { "End", "sua.drn_label_end", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_drn_label_value, { "Label Value", "sua.drn_label_value", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_sua_assoc_id, { "Association ID", "sua.assoc.id", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}},
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_sua,
&ett_sua_parameter,
&ett_sua_source_address_indicator,
&ett_sua_destination_address_indicator,
&ett_sua_affected_destination,
&ett_sua_sequence_number_rec_number,
&ett_sua_sequence_number_sent_number,
&ett_sua_receive_sequence_number_number,
&ett_sua_protocol_classes,
&ett_sua_first_remaining,
&ett_sua_return_on_error_bit_and_protocol_class,
&ett_sua_assoc
};
module_t *sua_module;
static const enum_val_t options[] = {
{ "draft-08", "Internet Draft version 08", SUA_V08 },
{ "rfc3868", "RFC 3868", SUA_RFC },
{ NULL, NULL, 0 }
};
/* Register the protocol name and description */
proto_sua = proto_register_protocol("SS7 SCCP-User Adaptation Layer", "SUA", "sua");
sua_handle = register_dissector("sua", dissect_sua, proto_sua);
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_sua, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
sua_module = prefs_register_protocol(proto_sua, NULL);
prefs_register_obsolete_preference(sua_module, "sua_version");
prefs_register_enum_preference(sua_module, "version", "SUA Version", "Version used by Wireshark", &version, options, FALSE);
prefs_register_bool_preference(sua_module, "set_addresses", "Set source and destination addresses",
"Set the source and destination addresses to the PC or GT digits, depending on the routing indicator."
" This may affect TCAP's ability to recognize which messages belong to which TCAP session.", &set_addresses);
heur_subdissector_list = register_heur_dissector_list("sua", proto_sua);
sua_parameter_table = register_dissector_table("sua.prop.tags", "SUA Proprietary Tags", proto_sua, FT_UINT16, BASE_DEC);
sua_tap = register_tap("sua");
assocs = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
}
void
proto_reg_handoff_sua(void)
{
/* Do we have an info string dissector ? */
sua_info_str_handle = find_dissector("sua.infostring");
dissector_add_uint("sctp.ppi", SUA_PAYLOAD_PROTOCOL_ID, sua_handle);
dissector_add_uint("sctp.port", SCTP_PORT_SUA, sua_handle);
sccp_ssn_dissector_table = find_dissector_table("sccp.ssn");
ss7pc_address_type = address_type_get_by_name("AT_SS7PC");
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|
C
|
wireshark/epan/dissectors/packet-sv.c
|
/* Do not modify this file. Changes will be overwritten. */
/* Generated automatically by the ASN.1 to Wireshark dissector compiler */
/* packet-sv.c */
/* asn2wrs.py -b -L -p sv -c ./sv.cnf -s ./packet-sv-template -D . -O ../.. sv.asn */
/* packet-sv.c
* Routines for IEC 61850 Sampled Values packet dissection
* Michael Bernhard 2008
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/asn1.h>
#include <epan/etypes.h>
#include <epan/expert.h>
#include <epan/prefs.h>
#include <epan/addr_resolv.h>
#include "packet-ber.h"
#include "packet-acse.h"
#include "tap.h"
#include "packet-sv.h"
#define PNAME "IEC61850 Sampled Values"
#define PSNAME "SV"
#define PFNAME "sv"
/* see IEC61850-8-1 8.2 */
#define Q_VALIDITY_GOOD (0x0U << 0)
#define Q_VALIDITY_INVALID (0x1U << 0)
#define Q_VALIDITY_QUESTIONABLE (0x3U << 0)
#define Q_VALIDITY_MASK (0x3U << 0)
#define Q_OVERFLOW (1U << 2)
#define Q_OUTOFRANGE (1U << 3)
#define Q_BADREFERENCE (1U << 4)
#define Q_OSCILLATORY (1U << 5)
#define Q_FAILURE (1U << 6)
#define Q_OLDDATA (1U << 7)
#define Q_INCONSISTENT (1U << 8)
#define Q_INACCURATE (1U << 9)
#define Q_SOURCE_PROCESS (0U << 10)
#define Q_SOURCE_SUBSTITUTED (1U << 10)
#define Q_SOURCE_MASK (1U << 10)
#define Q_TEST (1U << 11)
#define Q_OPERATORBLOCKED (1U << 12)
/* see UCA Implementation Guideline for IEC 61850-9-2 */
#define Q_DERIVED (1U << 13)
/* Bit fields in the Reserved attributes */
#define F_RESERVE1_S_BIT 0x8000
void proto_register_sv(void);
void proto_reg_handoff_sv(void);
/* Data for SV tap */
static int sv_tap = -1;
static sv_frame_data sv_data;
/* Initialize the protocol and registered fields */
static int proto_sv = -1;
static int hf_sv_appid = -1;
static int hf_sv_length = -1;
static int hf_sv_reserve1 = -1;
static int hf_sv_reserve1_s_bit = -1;
static int hf_sv_reserve2 = -1;
static int hf_sv_phmeas_instmag_i = -1;
static int hf_sv_phsmeas_q = -1;
static int hf_sv_phsmeas_q_validity = -1;
static int hf_sv_phsmeas_q_overflow = -1;
static int hf_sv_phsmeas_q_outofrange = -1;
static int hf_sv_phsmeas_q_badreference = -1;
static int hf_sv_phsmeas_q_oscillatory = -1;
static int hf_sv_phsmeas_q_failure = -1;
static int hf_sv_phsmeas_q_olddata = -1;
static int hf_sv_phsmeas_q_inconsistent = -1;
static int hf_sv_phsmeas_q_inaccurate = -1;
static int hf_sv_phsmeas_q_source = -1;
static int hf_sv_phsmeas_q_test = -1;
static int hf_sv_phsmeas_q_operatorblocked = -1;
static int hf_sv_phsmeas_q_derived = -1;
static int hf_sv_gmidentity = -1;
static int hf_sv_gmidentity_manuf = -1;
static int hf_sv_savPdu = -1; /* SavPdu */
static int hf_sv_noASDU = -1; /* INTEGER_0_65535 */
static int hf_sv_seqASDU = -1; /* SEQUENCE_OF_ASDU */
static int hf_sv_seqASDU_item = -1; /* ASDU */
static int hf_sv_svID = -1; /* VisibleString */
static int hf_sv_datSet = -1; /* VisibleString */
static int hf_sv_smpCnt = -1; /* T_smpCnt */
static int hf_sv_confRev = -1; /* INTEGER_0_4294967295 */
static int hf_sv_refrTm = -1; /* UtcTime */
static int hf_sv_smpSynch = -1; /* T_smpSynch */
static int hf_sv_smpRate = -1; /* INTEGER_0_65535 */
static int hf_sv_seqData = -1; /* Data */
static int hf_sv_smpMod = -1; /* T_smpMod */
static int hf_sv_gmidData = -1; /* GmidData */
/* Initialize the subtree pointers */
static int ett_sv = -1;
static int ett_phsmeas = -1;
static int ett_phsmeas_q = -1;
static int ett_gmidentity = -1;
static int ett_reserve1 = -1;
static gint ett_sv_SampledValues = -1;
static gint ett_sv_SavPdu = -1;
static gint ett_sv_SEQUENCE_OF_ASDU = -1;
static gint ett_sv_ASDU = -1;
static expert_field ei_sv_mal_utctime = EI_INIT;
static expert_field ei_sv_zero_pdu = EI_INIT;
static expert_field ei_sv_mal_gmidentity = EI_INIT;
static gboolean sv_decode_data_as_phsmeas = FALSE;
static dissector_handle_t sv_handle;
static const value_string sv_q_validity_vals[] = {
{ 0, "good" },
{ 1, "invalid" },
{ 3, "questionable" },
{ 0, NULL }
};
static const value_string sv_q_source_vals[] = {
{ 0, "process" },
{ 1, "substituted" },
{ 0, NULL }
};
static int
dissect_PhsMeas1(bool implicit_tag, packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id _U_)
{
gint8 ber_class;
bool pc;
gint32 tag;
guint32 len;
proto_tree *subtree;
gint32 value;
guint32 qual;
guint32 i;
static int * const q_flags[] = {
&hf_sv_phsmeas_q_validity,
&hf_sv_phsmeas_q_overflow,
&hf_sv_phsmeas_q_outofrange,
&hf_sv_phsmeas_q_badreference,
&hf_sv_phsmeas_q_oscillatory,
&hf_sv_phsmeas_q_failure,
&hf_sv_phsmeas_q_olddata,
&hf_sv_phsmeas_q_inconsistent,
&hf_sv_phsmeas_q_inaccurate,
&hf_sv_phsmeas_q_source,
&hf_sv_phsmeas_q_test,
&hf_sv_phsmeas_q_operatorblocked,
&hf_sv_phsmeas_q_derived,
NULL
};
if (!implicit_tag) {
offset=dissect_ber_identifier(pinfo, tree, tvb, offset, &ber_class, &pc, &tag);
offset=dissect_ber_length(pinfo, tree, tvb, offset, &len, NULL);
} else {
len=tvb_reported_length_remaining(tvb, offset);
}
subtree = proto_tree_add_subtree(tree, tvb, offset, len, ett_phsmeas, NULL, "PhsMeas1");
sv_data.num_phsMeas = 0;
for (i = 0; i < len/8; i++) {
if (tree && subtree) {
value = tvb_get_ntohl(tvb, offset);
qual = tvb_get_ntohl(tvb, offset + 4);
proto_tree_add_item(subtree, hf_sv_phmeas_instmag_i, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_tree_add_bitmask(subtree, tvb, offset + 4, hf_sv_phsmeas_q, ett_phsmeas_q, q_flags, ENC_BIG_ENDIAN);
if (i < IEC61850_SV_MAX_PHSMEAS_ENTRIES) {
sv_data.phsMeas[i].value = value;
sv_data.phsMeas[i].qual = qual;
sv_data.num_phsMeas++;
}
}
offset += 8;
}
return offset;
}
static int
dissect_sv_INTEGER_0_65535(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static int
dissect_sv_VisibleString(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_VisibleString,
actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static int
dissect_sv_T_smpCnt(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
guint32 value;
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
&value);
sv_data.smpCnt = value;
return offset;
}
static int
dissect_sv_INTEGER_0_4294967295(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
NULL);
return offset;
}
static int
dissect_sv_UtcTime(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
guint32 len;
guint32 seconds;
guint32 fraction;
guint32 nanoseconds;
nstime_t ts;
gchar * ptime;
len = tvb_reported_length_remaining(tvb, offset);
if(len != 8)
{
proto_tree_add_expert_format(tree, actx->pinfo, &ei_sv_mal_utctime, tvb, offset, len,
"BER Error: malformed UTCTime encoding, length must be 8 bytes");
if(hf_index >= 0)
{
proto_tree_add_string(tree, hf_index, tvb, offset, len, "????");
}
return offset;
}
seconds = tvb_get_ntohl(tvb, offset);
fraction = tvb_get_ntoh24(tvb, offset+4) * 0x100; /* Only 3 bytes are recommended */
nanoseconds = (guint32)( ((guint64)fraction * G_GUINT64_CONSTANT(1000000000)) / G_GUINT64_CONSTANT(0x100000000) ) ;
ts.secs = seconds;
ts.nsecs = nanoseconds;
ptime = abs_time_to_str(actx->pinfo->pool, &ts, ABSOLUTE_TIME_UTC, TRUE);
if(hf_index >= 0)
{
proto_tree_add_string(tree, hf_index, tvb, offset, len, ptime);
}
offset += 8;
return offset;
}
static const value_string sv_T_smpSynch_vals[] = {
{ 0, "none" },
{ 1, "local" },
{ 2, "global" },
{ 0, NULL }
};
static int
dissect_sv_T_smpSynch(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
guint32 value;
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
&value);
sv_data.smpSynch = value;
return offset;
}
static int
dissect_sv_Data(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
if (sv_decode_data_as_phsmeas) {
offset = dissect_PhsMeas1(implicit_tag, actx->pinfo, tree, tvb, offset, hf_index);
} else {
offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
}
return offset;
}
static const value_string sv_T_smpMod_vals[] = {
{ 0, "samplesPerNormalPeriod" },
{ 1, "samplesPerSecond" },
{ 2, "secondsPerSample" },
{ 0, NULL }
};
static int
dissect_sv_T_smpMod(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
guint32 value;
offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
&value);
sv_data.smpMod = value;
return offset;
}
static int
dissect_sv_GmidData(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
guint32 len;
proto_item *gmidentity_ti;
proto_tree *gmidentity_tree;
const gchar *manuf_name;
len = tvb_reported_length_remaining(tvb, offset);
if(len != 8)
{
proto_tree_add_expert_format(tree, actx->pinfo, &ei_sv_mal_gmidentity, tvb, offset, len,
"BER Error: malformed gmIdentity encoding, length must be 8 bytes");
if(hf_index >= 0)
{
proto_tree_add_string(tree, hf_index, tvb, offset, len, "????");
}
return offset;
}
gmidentity_ti = proto_tree_add_item(tree, hf_sv_gmidentity, tvb, offset, 8, ENC_BIG_ENDIAN);
/* EUI-64: vendor ID | 0xFF - 0xFE | card ID */
if (tvb_get_ntohs(tvb, offset + 3) == 0xFFFE) {
gmidentity_tree = proto_item_add_subtree(gmidentity_ti, ett_gmidentity);
manuf_name = tvb_get_manuf_name(tvb, offset);
proto_tree_add_bytes_format_value(gmidentity_tree, hf_sv_gmidentity_manuf, tvb, offset, 3, NULL, "%s", manuf_name);
}
offset += 8;
return offset;
}
static const ber_sequence_t ASDU_sequence[] = {
{ &hf_sv_svID , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_sv_VisibleString },
{ &hf_sv_datSet , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_sv_VisibleString },
{ &hf_sv_smpCnt , BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_sv_T_smpCnt },
{ &hf_sv_confRev , BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_sv_INTEGER_0_4294967295 },
{ &hf_sv_refrTm , BER_CLASS_CON, 4, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_sv_UtcTime },
{ &hf_sv_smpSynch , BER_CLASS_CON, 5, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_sv_T_smpSynch },
{ &hf_sv_smpRate , BER_CLASS_CON, 6, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_sv_INTEGER_0_65535 },
{ &hf_sv_seqData , BER_CLASS_CON, 7, BER_FLAGS_IMPLTAG, dissect_sv_Data },
{ &hf_sv_smpMod , BER_CLASS_CON, 8, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_sv_T_smpMod },
{ &hf_sv_gmidData , BER_CLASS_CON, 9, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_sv_GmidData },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_sv_ASDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
ASDU_sequence, hf_index, ett_sv_ASDU);
return offset;
}
static const ber_sequence_t SEQUENCE_OF_ASDU_sequence_of[1] = {
{ &hf_sv_seqASDU_item , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_sv_ASDU },
};
static int
dissect_sv_SEQUENCE_OF_ASDU(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
SEQUENCE_OF_ASDU_sequence_of, hf_index, ett_sv_SEQUENCE_OF_ASDU);
return offset;
}
static const ber_sequence_t SavPdu_sequence[] = {
{ &hf_sv_noASDU , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_sv_INTEGER_0_65535 },
{ &hf_sv_seqASDU , BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_sv_SEQUENCE_OF_ASDU },
{ NULL, 0, 0, 0, NULL }
};
static int
dissect_sv_SavPdu(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
SavPdu_sequence, hf_index, ett_sv_SavPdu);
return offset;
}
static const ber_choice_t SampledValues_choice[] = {
{ 0, &hf_sv_savPdu , BER_CLASS_APP, 0, BER_FLAGS_IMPLTAG, dissect_sv_SavPdu },
{ 0, NULL, 0, 0, 0, NULL }
};
static int
dissect_sv_SampledValues(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_ber_choice(actx, tree, tvb, offset,
SampledValues_choice, hf_index, ett_sv_SampledValues,
NULL);
return offset;
}
/*
* Dissect SV PDUs inside a PPDU.
*/
static int
dissect_sv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_)
{
int offset = 0;
int old_offset;
guint sv_length = 0;
proto_item *item;
proto_tree *tree;
static int * const reserve1_flags[] = {
&hf_sv_reserve1_s_bit,
NULL
};
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
item = proto_tree_add_item(parent_tree, proto_sv, tvb, 0, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_sv);
col_set_str(pinfo->cinfo, COL_PROTOCOL, PNAME);
col_clear(pinfo->cinfo, COL_INFO);
/* APPID */
proto_tree_add_item(tree, hf_sv_appid, tvb, offset, 2, ENC_BIG_ENDIAN);
/* Length */
proto_tree_add_item_ret_uint(tree, hf_sv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN, &sv_length);
/* Reserved 1 */
proto_tree_add_bitmask(tree, tvb, offset + 4, hf_sv_reserve1, ett_reserve1,
reserve1_flags, ENC_BIG_ENDIAN);
/* Reserved 2 */
proto_tree_add_item(tree, hf_sv_reserve2, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
offset = 8;
set_actual_length(tvb, sv_length);
while (tvb_reported_length_remaining(tvb, offset) > 0) {
old_offset = offset;
offset = dissect_sv_SampledValues(FALSE, tvb, offset, &asn1_ctx , tree, -1);
if (offset == old_offset) {
proto_tree_add_expert(tree, pinfo, &ei_sv_zero_pdu, tvb, offset, -1);
break;
}
}
tap_queue_packet(sv_tap, pinfo, &sv_data);
return tvb_captured_length(tvb);
}
/*--- proto_register_sv -------------------------------------------*/
void proto_register_sv(void) {
/* List of fields */
static hf_register_info hf[] = {
{ &hf_sv_appid,
{ "APPID", "sv.appid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sv_length,
{ "Length", "sv.length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sv_reserve1,
{ "Reserved 1", "sv.reserve1", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sv_reserve1_s_bit,
{ "Simulated", "sv.reserve1.s_bit",
FT_BOOLEAN, 16, NULL, F_RESERVE1_S_BIT, NULL, HFILL } },
{ &hf_sv_reserve2,
{ "Reserved 2", "sv.reserve2", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_sv_phmeas_instmag_i,
{ "value", "sv.meas_value", FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}},
{ &hf_sv_phsmeas_q,
{ "quality", "sv.meas_quality", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_sv_phsmeas_q_validity,
{ "validity", "sv.meas_quality.validity", FT_UINT32, BASE_HEX, VALS(sv_q_validity_vals), Q_VALIDITY_MASK, NULL, HFILL}},
{ &hf_sv_phsmeas_q_overflow,
{ "overflow", "sv.meas_quality.overflow", FT_BOOLEAN, 32, NULL, Q_OVERFLOW, NULL, HFILL}},
{ &hf_sv_phsmeas_q_outofrange,
{ "out of range", "sv.meas_quality.outofrange", FT_BOOLEAN, 32, NULL, Q_OUTOFRANGE, NULL, HFILL}},
{ &hf_sv_phsmeas_q_badreference,
{ "bad reference", "sv.meas_quality.badreference", FT_BOOLEAN, 32, NULL, Q_BADREFERENCE, NULL, HFILL}},
{ &hf_sv_phsmeas_q_oscillatory,
{ "oscillatory", "sv.meas_quality.oscillatory", FT_BOOLEAN, 32, NULL, Q_OSCILLATORY, NULL, HFILL}},
{ &hf_sv_phsmeas_q_failure,
{ "failure", "sv.meas_quality.failure", FT_BOOLEAN, 32, NULL, Q_FAILURE, NULL, HFILL}},
{ &hf_sv_phsmeas_q_olddata,
{ "old data", "sv.meas_quality.olddata", FT_BOOLEAN, 32, NULL, Q_OLDDATA, NULL, HFILL}},
{ &hf_sv_phsmeas_q_inconsistent,
{ "inconsistent", "sv.meas_quality.inconsistent", FT_BOOLEAN, 32, NULL, Q_INCONSISTENT, NULL, HFILL}},
{ &hf_sv_phsmeas_q_inaccurate,
{ "inaccurate", "sv.meas_quality.inaccurate", FT_BOOLEAN, 32, NULL, Q_INACCURATE, NULL, HFILL}},
{ &hf_sv_phsmeas_q_source,
{ "source", "sv.meas_quality.source", FT_UINT32, BASE_HEX, VALS(sv_q_source_vals), Q_SOURCE_MASK, NULL, HFILL}},
{ &hf_sv_phsmeas_q_test,
{ "test", "sv.meas_quality.test", FT_BOOLEAN, 32, NULL, Q_TEST, NULL, HFILL}},
{ &hf_sv_phsmeas_q_operatorblocked,
{ "operator blocked", "sv.meas_quality.operatorblocked", FT_BOOLEAN, 32, NULL, Q_OPERATORBLOCKED, NULL, HFILL}},
{ &hf_sv_phsmeas_q_derived,
{ "derived", "sv.meas_quality.derived", FT_BOOLEAN, 32, NULL, Q_DERIVED, NULL, HFILL}},
{ &hf_sv_gmidentity,
{ "gmIdentity", "sv.gmidentity", FT_UINT64, BASE_HEX, NULL, 0x00, NULL, HFILL}},
{ &hf_sv_gmidentity_manuf,
{ "MAC Vendor", "sv.gmidentity_manuf", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL}},
{ &hf_sv_savPdu,
{ "savPdu", "sv.savPdu_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_sv_noASDU,
{ "noASDU", "sv.noASDU",
FT_UINT32, BASE_DEC, NULL, 0,
"INTEGER_0_65535", HFILL }},
{ &hf_sv_seqASDU,
{ "seqASDU", "sv.seqASDU",
FT_UINT32, BASE_DEC, NULL, 0,
"SEQUENCE_OF_ASDU", HFILL }},
{ &hf_sv_seqASDU_item,
{ "ASDU", "sv.ASDU_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_sv_svID,
{ "svID", "sv.svID",
FT_STRING, BASE_NONE, NULL, 0,
"VisibleString", HFILL }},
{ &hf_sv_datSet,
{ "datSet", "sv.datSet",
FT_STRING, BASE_NONE, NULL, 0,
"VisibleString", HFILL }},
{ &hf_sv_smpCnt,
{ "smpCnt", "sv.smpCnt",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_sv_confRev,
{ "confRev", "sv.confRev",
FT_UINT32, BASE_DEC, NULL, 0,
"INTEGER_0_4294967295", HFILL }},
{ &hf_sv_refrTm,
{ "refrTm", "sv.refrTm",
FT_STRING, BASE_NONE, NULL, 0,
"UtcTime", HFILL }},
{ &hf_sv_smpSynch,
{ "smpSynch", "sv.smpSynch",
FT_INT32, BASE_DEC, VALS(sv_T_smpSynch_vals), 0,
NULL, HFILL }},
{ &hf_sv_smpRate,
{ "smpRate", "sv.smpRate",
FT_UINT32, BASE_DEC, NULL, 0,
"INTEGER_0_65535", HFILL }},
{ &hf_sv_seqData,
{ "seqData", "sv.seqData",
FT_BYTES, BASE_NONE, NULL, 0,
"Data", HFILL }},
{ &hf_sv_smpMod,
{ "smpMod", "sv.smpMod",
FT_INT32, BASE_DEC, VALS(sv_T_smpMod_vals), 0,
NULL, HFILL }},
{ &hf_sv_gmidData,
{ "gmidData", "sv.gmidData",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
};
/* List of subtrees */
static gint *ett[] = {
&ett_sv,
&ett_phsmeas,
&ett_phsmeas_q,
&ett_gmidentity,
&ett_reserve1,
&ett_sv_SampledValues,
&ett_sv_SavPdu,
&ett_sv_SEQUENCE_OF_ASDU,
&ett_sv_ASDU,
};
static ei_register_info ei[] = {
{ &ei_sv_mal_utctime, { "sv.malformed.utctime", PI_MALFORMED, PI_WARN, "BER Error: malformed UTCTime encoding", EXPFILL }},
{ &ei_sv_zero_pdu, { "sv.zero_pdu", PI_PROTOCOL, PI_ERROR, "Internal error, zero-byte SV PDU", EXPFILL }},
{ &ei_sv_mal_gmidentity, { "sv.malformed.gmidentity", PI_MALFORMED, PI_WARN, "BER Error: malformed gmIdentity encoding", EXPFILL }},
};
expert_module_t* expert_sv;
module_t *sv_module;
/* Register protocol */
proto_sv = proto_register_protocol(PNAME, PSNAME, PFNAME);
sv_handle = register_dissector("sv", dissect_sv, proto_sv);
/* Register fields and subtrees */
proto_register_field_array(proto_sv, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_sv = expert_register_protocol(proto_sv);
expert_register_field_array(expert_sv, ei, array_length(ei));
sv_module = prefs_register_protocol(proto_sv, NULL);
prefs_register_bool_preference(sv_module, "decode_data_as_phsmeas",
"Force decoding of seqData as PhsMeas",
NULL, &sv_decode_data_as_phsmeas);
/* Register tap */
sv_tap = register_tap("sv");
}
/*--- proto_reg_handoff_sv --- */
void proto_reg_handoff_sv(void) {
dissector_add_uint("ethertype", ETHERTYPE_IEC61850_SV, sv_handle);
}
|
C/C++
|
wireshark/epan/dissectors/packet-sv.h
|
/* Do not modify this file. Changes will be overwritten. */
/* Generated automatically by the ASN.1 to Wireshark dissector compiler */
/* packet-sv.h */
/* asn2wrs.py -b -L -p sv -c ./sv.cnf -s ./packet-sv-template -D . -O ../.. sv.asn */
/* packet-sv.h
* Routines for IEC 61850 Sampled Vales packet dissection
* Michael Bernhard 2008
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PACKET_SV_H__
#define __PACKET_SV_H__
#define IEC61850_SV_MAX_PHSMEAS_ENTRIES 20
typedef struct _sv_phs_meas {
gint32 value;
guint32 qual;
} sv_phs_meas;
typedef struct _sv_frame_data {
guint16 smpCnt;
guint8 smpSynch;
guint8 num_phsMeas;
sv_phs_meas phsMeas[IEC61850_SV_MAX_PHSMEAS_ENTRIES];
guint16 smpMod;
} sv_frame_data;
#endif /*__PACKET_SV_H__*/
|
C
|
wireshark/epan/dissectors/packet-swipe.c
|
/* packet-swipe.c
* swIPe IP Security Protocol
*
* http://www.crypto.com/papers/swipe.id.txt
*
* Copyright 2014 by Michael Mann
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/ipproto.h>
void proto_register_swipe(void);
void proto_reg_handoff_swipe(void);
/* Routing Header Types */
static const value_string swipe_packet_type_vals[] = {
{ 0, "Plain encapsulation" },
{ 1, "Packet is authenticated but not encrypted" },
{ 2, "Packet is encrypted" },
{ 3, "Packet is both authenticated and encrypted" },
{ 0, NULL }
};
/* Initialize the protocol and registered fields */
static int proto_swipe = -1;
static int hf_swipe_packet_type = -1;
static int hf_swipe_len = -1;
static int hf_swipe_policy_id = -1;
static int hf_swipe_packet_seq = -1;
static int hf_swipe_authenticator = -1;
/* Initialize the subtree pointers */
static gint ett_swipe = -1;
static dissector_handle_t ipv6_handle;
static int
dissect_swipe(tvbuff_t *tvb, packet_info * pinfo, proto_tree *tree, void* data _U_)
{
int header_len, offset = 0;
proto_tree *swipe_tree;
proto_item *ti;
tvbuff_t *next_tvb;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "swIPe");
col_clear(pinfo->cinfo, COL_INFO);
header_len = tvb_get_guint8(tvb, offset + 1);
if (tree)
{
ti = proto_tree_add_item(tree, proto_swipe, tvb, offset, header_len, ENC_NA);
swipe_tree = proto_item_add_subtree(ti, ett_swipe);
/* Packet Type */
proto_tree_add_item(swipe_tree, hf_swipe_packet_type, tvb, offset, 1, ENC_BIG_ENDIAN);
/* Header Length */
proto_tree_add_item(swipe_tree, hf_swipe_len, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
/* Policy ID */
proto_tree_add_item(swipe_tree, hf_swipe_policy_id, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
/* Packet Sequence Number */
proto_tree_add_item(swipe_tree, hf_swipe_packet_seq, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
if (header_len > 8)
proto_tree_add_item(swipe_tree, hf_swipe_authenticator, tvb, offset + 8, header_len - 8, ENC_NA);
}
next_tvb = tvb_new_subset_remaining(tvb, header_len);
call_dissector(ipv6_handle, next_tvb, pinfo, tree);
return tvb_captured_length(tvb);
}
/* Register the protocol with Wireshark */
void
proto_register_swipe(void)
{
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_swipe_packet_type, { "Packet type", "swipe.packet_type", FT_UINT8, BASE_DEC, VALS(swipe_packet_type_vals), 0x0, NULL, HFILL } },
{ &hf_swipe_len, { "Header Length", "swipe.len", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_swipe_policy_id, { "Policy identifier", "swipe.policy_id", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_swipe_packet_seq, { "Packet sequence number", "swipe.packet_seq", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_swipe_authenticator, { "Authenticator", "swipe.authenticator", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_swipe
};
/* Register the protocol name and description */
proto_swipe = proto_register_protocol("swIPe IP Security Protocol", "swIPe", "swipe");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_swipe, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_swipe(void)
{
dissector_handle_t swipe_handle;
swipe_handle = create_dissector_handle(dissect_swipe, proto_swipe );
dissector_add_uint("ip.proto", IP_PROTO_SWIPE, swipe_handle);
ipv6_handle = find_dissector_add_dependency("ipv6", proto_swipe );
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
|
C
|
wireshark/epan/dissectors/packet-symantec.c
|
/* packet-symantec.c
* Routines for dissection of packets from the Axent Raptor firewall/
* Symantec Enterprise Firewall/Symantec Gateway Security appliance
* v2/Symantec Gateway Security appliance v3.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <wiretap/wtap.h>
#include <epan/etypes.h>
void proto_register_symantec(void);
void proto_reg_handoff_symantec(void);
static dissector_handle_t symantec_handle;
static dissector_table_t ethertype_dissector_table;
/* protocols and header fields */
static int proto_symantec = -1;
static int hf_symantec_if = -1;
static int hf_symantec_etype = -1;
static gint ett_symantec = -1;
static int
dissect_symantec(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
proto_item *ti;
proto_tree *symantec_tree;
guint16 etypev2, etypev3;
tvbuff_t *next_tvb;
/*
* Symantec records come in two variants:
*
* The older variant, dating from Axent days and continuing until
* the SGS v2.0.1 code level, is 44 bytes long.
* The first 4 bytes are the IPv4 address of the interface that
* captured the data, followed by 2 bytes of 0, then an Ethernet
* type, followed by 36 bytes of 0.
*
* The newer variant, introduced either in SGS v3.0 or v3.0.1
* (possibly in concert with VLAN support), is 56 bytes long.
* The first 4 bytes are the IPv4 address of the interface that
* captured the data, followed by 6 bytes of 0, then an Ethernet
* type, followed by 44 bytes of 0.
*
* Unfortunately, there is no flag to distiguish between the two
* flavours. The only indication of which flavour you have is the
* offset of the ETHERTYPE field. Fortunately, Symantec didn't
* use ETHERTYPE_UNK as a valid value.
*/
etypev2 = tvb_get_ntohs(tvb, 6);
etypev3 = tvb_get_ntohs(tvb, 10);
/* a valid packet can't be both v2 and v3 or neither v2 nor v3, */
if ((etypev2 == 0) == (etypev3 == 0))
return 12;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Symantec");
if (etypev3 == 0) { /* SEF and SGS v2 processing */
col_set_str(pinfo->cinfo, COL_INFO, "Symantec Enterprise Firewall");
ti = proto_tree_add_protocol_format(tree, proto_symantec, tvb,
0, 44, "Symantec firewall");
symantec_tree = proto_item_add_subtree(ti, ett_symantec);
proto_tree_add_item(symantec_tree, hf_symantec_if, tvb,
0, 4, ENC_BIG_ENDIAN);
proto_tree_add_uint(symantec_tree, hf_symantec_etype, tvb,
6, 2, etypev2);
next_tvb = tvb_new_subset_remaining(tvb, 44);
dissector_try_uint(ethertype_dissector_table, etypev2, next_tvb, pinfo,
tree);
}
if (etypev2 == 0) { /* SGS v3 processing */
col_set_str(pinfo->cinfo, COL_INFO, "Symantec SGS v3");
ti = proto_tree_add_protocol_format(tree, proto_symantec, tvb,
0, 56, "Symantec SGSv3");
symantec_tree = proto_item_add_subtree(ti, ett_symantec);
proto_tree_add_item(symantec_tree, hf_symantec_if, tvb,
0, 4, ENC_BIG_ENDIAN);
proto_tree_add_uint(symantec_tree, hf_symantec_etype, tvb,
10, 2, etypev3);
/*
* Dissection of VLAN information will have to wait until
* availability of a capture file from an SGSv3 box using VLAN
* tagging.
*/
next_tvb = tvb_new_subset_remaining(tvb, 56);
dissector_try_uint(ethertype_dissector_table, etypev3, next_tvb, pinfo,
tree);
}
return tvb_captured_length(tvb);
}
void
proto_register_symantec(void)
{
static hf_register_info hf[] = {
{ &hf_symantec_if,
{ "Interface", "symantec.if", FT_IPv4, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_symantec_etype,
{ "Type", "symantec.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0,
NULL, HFILL }},
};
static gint *ett[] = {
&ett_symantec,
};
proto_symantec = proto_register_protocol("Symantec Enterprise Firewall",
"Symantec", "symantec");
symantec_handle = register_dissector("symantec", dissect_symantec,
proto_symantec);
proto_register_field_array(proto_symantec, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_symantec(void)
{
ethertype_dissector_table = find_dissector_table("ethertype");
dissector_add_uint("wtap_encap", WTAP_ENCAP_SYMANTEC, symantec_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-sync.c
|
/* packet-sync.c
* Routines for MBMS synchronisation protocol dissection
* Copyright 2012, David Wei <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Ref 3GPP TS 25.446
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/expert.h>
#include <epan/crc6-tvb.h>
#define TYPE_0_LEN 17
#define TYPE_1_LEN 11
#define TYPE_2_LEN 12
#define TYPE_3_LEN 19
void proto_register_sync(void);
void proto_reg_handoff_sync(void);
/* Initialize the protocol and registered fields */
static int proto_sync = -1;
static int hf_sync_type = -1;
static int hf_sync_spare4 = -1;
static int hf_sync_timestamp = -1;
static int hf_sync_packet_nr = -1;
static int hf_sync_elapsed_octet_ctr = -1;
static int hf_sync_total_nr_of_packet = -1;
static int hf_sync_total_nr_of_octet = -1;
static int hf_sync_header_crc = -1;
static int hf_sync_payload_crc = -1;
static int hf_sync_length_of_packet = -1;
/* Initialize the subtree pointers */
static gint ett_sync = -1;
static expert_field ei_sync_pdu_type2 = EI_INIT;
static expert_field ei_sync_type = EI_INIT;
static dissector_handle_t sync_handle;
static dissector_handle_t ip_handle;
static const value_string sync_type_vals[] = {
{ 0, "Synchronisation frame without payload" },
{ 1, "User data with synchronisation frame for uncompressed headers" },
{ 2, "User data with synchronisation frame for compressed headers" },
{ 3, "Synchronisation frame with Length of Packets" },
/* 4-15 reserved for future PDU type extensions */
{ 0, NULL}
};
static int
dissect_sync(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
proto_item *ti, *item, *type_item;
proto_tree *sync_tree;
guint8 type, spare;
guint16 packet_nr, packet_len1, packet_len2;
guint32 timestamp, total_nr_of_packet;
int offset = 0;
tvbuff_t *next_tvb;
type = tvb_get_guint8(tvb, offset) >> 4;
spare = tvb_get_guint8(tvb, offset) & 0x0F;
/* Heuristics to check if packet is really MBMS sync */
#if 0
if ( type > 3 )
return 0;
if ( type == 0 && tvb_captured_length(tvb) < 18) {
return 0;
} else if ( type == 1 && tvb_captured_length(tvb) < 11 ) {
return 0;
} else if ( type == 3 && tvb_captured_length(tvb) < 19 ) {
return 0;
}
if ( (type != 2) && (spare != 0) )
return 0;
#endif
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SYNC");
col_set_str(pinfo->cinfo, COL_INFO, "MBMS synchronisation protocol");
/* Ugly, but necessary to get the correct length for type 3 */
packet_nr = tvb_get_ntohs(tvb, offset+3) + 1;
/* The length varies depending on PDU type */
switch (type) {
case 0:
ti = proto_tree_add_item(tree, proto_sync, tvb, 0, TYPE_0_LEN, ENC_NA);
break;
case 1:
ti = proto_tree_add_item(tree, proto_sync, tvb, 0, TYPE_1_LEN, ENC_NA);
break;
case 2:
ti = proto_tree_add_item(tree, proto_sync, tvb, 0, TYPE_2_LEN + (spare & 0x01 ? 40 : 20), ENC_NA);
break;
case 3:
ti = proto_tree_add_item(tree, proto_sync, tvb, 0,
TYPE_3_LEN + (gint16)(packet_nr % 2 == 0 ?
1.5*packet_nr : 1.5*(packet_nr-1)+2),
ENC_NA);
break;
default:
ti = proto_tree_add_item(tree, proto_sync, tvb, 0, -1, ENC_NA);
break;
}
sync_tree = proto_item_add_subtree(ti, ett_sync);
/* Octet 1 - PDU Type */
type_item = proto_tree_add_item(sync_tree, hf_sync_type, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sync_tree, hf_sync_spare4, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
/* Octet 2 - Time Stamp */
timestamp = tvb_get_ntohs(tvb, offset) * 10;
proto_tree_add_uint(sync_tree, hf_sync_timestamp, tvb, offset, 2, timestamp);
offset += 2;
/* Octet 4 - Packet Number */
proto_tree_add_uint(sync_tree, hf_sync_packet_nr, tvb, offset, 2, packet_nr);
offset += 2;
/* Octet 6 - Elapsed Octet Counter */
proto_tree_add_item(sync_tree, hf_sync_elapsed_octet_ctr, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
switch (type) {
case 0:
/* SYNC PDU Type 0 */
proto_tree_add_item(sync_tree, hf_sync_total_nr_of_packet, tvb, offset, 3, ENC_BIG_ENDIAN);
offset += 3;
proto_tree_add_item(sync_tree, hf_sync_total_nr_of_octet, tvb, offset, 5, ENC_BIG_ENDIAN);
offset += 5;
proto_tree_add_item(sync_tree, hf_sync_header_crc, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
break;
case 1:
/* SYNC PDU Type 1 */
/* XXX - Calculate the CRC and check against this value? */
item = proto_tree_add_item(sync_tree, hf_sync_header_crc, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sync_tree, hf_sync_payload_crc, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_item_append_text(item, " [Calculated CRC 0x%x]",
crc6_compute_tvb(tvb, offset));
offset += 2;
/* XXX - The payload may not always be present? */
next_tvb = tvb_new_subset_remaining(tvb, offset);
/* XXX - The payload may not always be IP? */
call_dissector(ip_handle, next_tvb, pinfo, tree);
break;
case 2:
/* SYNC PDU Type 2 */
expert_add_info(pinfo, ti, &ei_sync_pdu_type2);
break;
case 3:
/* SYNC PDU Type 3 */
total_nr_of_packet = tvb_get_ntoh24(tvb, offset);
proto_tree_add_item(sync_tree, hf_sync_total_nr_of_packet, tvb, offset, 3, ENC_BIG_ENDIAN);
offset += 3;
proto_tree_add_item(sync_tree, hf_sync_total_nr_of_octet, tvb, offset, 5, ENC_BIG_ENDIAN);
offset += 5;
proto_tree_add_item(sync_tree, hf_sync_header_crc, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sync_tree, hf_sync_payload_crc, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
if (offset < (gint)tvb_reported_length(tvb)) {
int i;
if (total_nr_of_packet != 0 && packet_nr % 2 == 0) {
/* Even number of packets */
for (i = 1; i < packet_nr; i+=2, offset+=3) {
packet_len1 = tvb_get_bits16(tvb, offset*8, 12, ENC_BIG_ENDIAN);
packet_len2 = tvb_get_bits16(tvb, offset*8+12, 12, ENC_BIG_ENDIAN);
proto_tree_add_uint_format(sync_tree, hf_sync_length_of_packet, tvb, offset, 2, packet_len1, "Length of Packet %u : %hu", i, packet_len1);
proto_tree_add_uint_format(sync_tree, hf_sync_length_of_packet, tvb, offset+1, 2, packet_len2, "Length of Packet %u : %hu", i+1, packet_len2);
}
} else {
/* Odd number of packets */
for (i = 1; i < packet_nr; i+=2, offset+=3) {
packet_len1 = tvb_get_bits16(tvb, offset*8, 12, ENC_BIG_ENDIAN);
packet_len2 = tvb_get_bits16(tvb, offset*8+12, 12, ENC_BIG_ENDIAN);
proto_tree_add_uint_format(sync_tree, hf_sync_length_of_packet, tvb, offset, 2, packet_len1, "Length of Packet %u : %hu", i, packet_len1);
proto_tree_add_uint_format(sync_tree, hf_sync_length_of_packet, tvb, offset+1, 2, packet_len2, "Length of Packet %u : %hu", i+1, packet_len2);
}
packet_len1 = tvb_get_bits16(tvb, offset*8, 12, ENC_BIG_ENDIAN);
proto_tree_add_uint_format(sync_tree, hf_sync_length_of_packet, tvb, offset, 2, packet_len1, "Length of Packet %u : %hu", packet_nr, packet_len1);
offset++;
proto_tree_add_item(sync_tree, hf_sync_spare4, tvb, offset, 1, ENC_BIG_ENDIAN);
}
}
break;
default:
expert_add_info(pinfo, type_item, &ei_sync_type);
break;
}
return tvb_captured_length(tvb);
}
void
proto_register_sync(void)
{
static hf_register_info hf_sync[] = {
{ &hf_sync_type,
{ "PDU Type", "sync.type",
FT_UINT8, BASE_DEC, VALS(sync_type_vals), 0xF0,
NULL, HFILL }
},
{ &hf_sync_spare4,
{ "Spare", "sync.spare",
FT_UINT8, BASE_DEC, NULL, 0x0F,
NULL, HFILL }
},
{ &hf_sync_timestamp,
{ "Timestamp", "sync.timestamp",
FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_milliseconds, 0x0,
"Relative time value for the starting time of a synchronisation sequence within the synchronisation period.", HFILL }
},
{ &hf_sync_packet_nr,
{ "Packet Number", "sync.packet_nr",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Number of elapsed SYNC PDUs cumulatively within the synchronisation sequence.", HFILL }
},
{ &hf_sync_elapsed_octet_ctr,
{ "Elapsed Octet Counter", "sync.elapsed_octet_ctr",
FT_UINT32, BASE_DEC, NULL, 0x0,
"Number of elapsed cumulative octets cumulatively within one synchronisation sequence.", HFILL }
},
{ &hf_sync_total_nr_of_packet,
{ "Total Number of Packet", "sync.total_nr_of_packet",
FT_UINT24, BASE_DEC, NULL, 0x0,
"Cumulatively the number of the packets for the MBMS service within one synchronisation period.", HFILL }
},
{ &hf_sync_total_nr_of_octet,
{ "Total Number of Octet", "sync.total_nr_of_octet",
FT_UINT64, BASE_DEC, NULL, 0x0,
"Cumulatively the number of the octets for the MBMS service within one synchronisation period.", HFILL }
},
{ &hf_sync_header_crc,
{ "Header CRC", "sync.header_crc",
FT_UINT8, BASE_HEX, NULL, 0xFC,
NULL, HFILL }
},
{ &hf_sync_payload_crc,
{ "Payload CRC", "sync.payload_crc",
FT_UINT16, BASE_HEX, NULL, 0x03FF,
NULL, HFILL }
},
{ &hf_sync_length_of_packet,
{ "Length of Packet", "sync.length_of_packet",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
};
static gint *ett_sync_array[] = {
&ett_sync
};
static ei_register_info ei[] = {
{ &ei_sync_pdu_type2, { "sync.pdu_type2", PI_UNDECODED, PI_WARN, "SYNC PDU type 2 unsupported", EXPFILL }},
{ &ei_sync_type, { "sync.type.unknown", PI_PROTOCOL, PI_WARN, "Unknown SYNC PDU type", EXPFILL }},
};
expert_module_t* expert_sync;
proto_sync = proto_register_protocol("MBMS synchronisation protocol", "SYNC", "sync");
proto_register_field_array(proto_sync, hf_sync, array_length(hf_sync));
proto_register_subtree_array(ett_sync_array, array_length(ett_sync_array));
expert_sync = expert_register_protocol(proto_sync);
expert_register_field_array(expert_sync, ei, array_length(ei));
sync_handle = register_dissector("sync", dissect_sync, proto_sync);
}
void
proto_reg_handoff_sync(void)
{
ip_handle = find_dissector_add_dependency("ip", proto_sync);
dissector_add_for_decode_as_with_preference("udp.port", sync_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-synergy.c
|
/* packet-synergy.c
* Routines for synergy dissection
* Copyright 2005, Vasanth Manickam <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include "packet-tcp.h"
void proto_register_synergy(void);
void proto_reg_handoff_synergy(void);
#define SYNERGY_PORT 24800 /* Not IANA registered */
static int proto_synergy = -1;
static int hf_synergy_packet_len = -1;
static int hf_synergy_packet_type = -1;
static int hf_synergy_unknown = -1;
static int hf_synergy_handshake = -1;
static int hf_synergy_handshake_majorversion = -1;
static int hf_synergy_handshake_minorversion = -1;
static int hf_synergy_handshake_clientname = -1;
static int hf_synergy_cbye = -1;
static int hf_synergy_cinn = -1;
static int hf_synergy_cinn_x = -1;
static int hf_synergy_cinn_y = -1;
static int hf_synergy_cinn_sequence = -1;
static int hf_synergy_cinn_modifiermask = -1;
static int hf_synergy_cout = -1;
static int hf_synergy_cclp = -1;
static int hf_synergy_cclp_clipboardidentifier = -1;
static int hf_synergy_cclp_sequencenumber = -1;
static int hf_synergy_csec = -1;
static int hf_synergy_crop = -1;
static int hf_synergy_ciak = -1;
static int hf_synergy_dkdn = -1;
static int hf_synergy_dkdn_keyid = -1;
static int hf_synergy_dkdn_keymodifiermask = -1;
static int hf_synergy_dkdn_keybutton = -1;
static int hf_synergy_dkrp = -1;
static int hf_synergy_dkrp_keyid = -1;
static int hf_synergy_dkrp_keymodifiermask = -1;
static int hf_synergy_dkrp_numberofrepeats = -1;
static int hf_synergy_dkrp_keybutton = -1;
static int hf_synergy_dkup = -1;
static int hf_synergy_dkup_keyid = -1;
static int hf_synergy_dkup_keymodifiermask = -1;
static int hf_synergy_dkup_keybutton = -1;
static int hf_synergy_dmdn = -1;
static int hf_synergy_dmup = -1;
static int hf_synergy_dmmv = -1;
static int hf_synergy_dmmv_x = -1;
static int hf_synergy_dmmv_y = -1;
static int hf_synergy_dmrm = -1;
static int hf_synergy_dmrm_x = -1;
static int hf_synergy_dmrm_y = -1;
static int hf_synergy_dmwm = -1;
static int hf_synergy_dclp = -1;
static int hf_synergy_dclp_clipboardidentifier = -1;
static int hf_synergy_dclp_sequencenumber = -1;
static int hf_synergy_dclp_clipboarddata = -1;
static int hf_synergy_dinf = -1;
static int hf_synergy_dinf_clp = -1;
static int hf_synergy_dinf_ctp= -1;
static int hf_synergy_dinf_wsp = -1;
static int hf_synergy_dinf_hsp = -1;
static int hf_synergy_dinf_swz = -1;
static int hf_synergy_dinf_x = -1;
static int hf_synergy_dinf_y = -1;
static int hf_synergy_dsop = -1;
static int hf_synergy_qinf = -1;
static int hf_synergy_eicv = -1;
static int hf_synergy_eicv_majorversion = -1;
static int hf_synergy_eicv_minorversion = -1;
static int hf_synergy_ebsy = -1;
static int hf_synergy_eunk = -1;
static int hf_synergy_ebad = -1;
/* Initialize the subtree pointers */
static gint ett_synergy = -1;
static dissector_handle_t synergy_handle;
static const string_string packet_type_vals[] = {
{ "CNOP", "No Operation" },
{ "CALV", "Keep Alive" },
{ "CBYE", "Close Connection" },
{ "CINN", "Enter Screen" },
{ "COUT", "Leave Screen" },
{ "CCLP", "Grab Clipboard" },
{ "CSEC", "Screen Saver Change" },
{ "CROP", "Reset Options" },
{ "CIAK", "Resolution Change Acknowledgment" },
{ "DKDN", "Key Pressed" },
{ "DKRP", "Key Auto-Repeat" },
{ "DKUP", "Key Released" },
{ "DMDN", "Mouse Button Pressed" },
{ "DMUP", "Mouse Button Released" },
{ "DMMV", "Mouse Moved" },
{ "DMRM", "Relative Mouse Move" },
{ "DMWM", "Mouse Button Pressed" },
{ "DCLP", "Clipboard Data" },
{ "DINF", "Client Data" },
{ "DSOP", "Set Options" },
{ "QINF", "Query Screen Info" },
{ "EICV", "Incompatible Versions" },
{ "EBSY", "Connection Already in Use" },
{ "EUNK", "Unknown Client" },
{ "EBAD", "Protocol Violation" },
{ NULL , NULL }
};
static void dissect_synergy_handshake(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,gint offset);
static void dissect_synergy_cinn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,gint offset);
static void dissect_synergy_cclp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,gint offset);
static void dissect_synergy_dkdn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,gint offset);
static void dissect_synergy_dkrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,gint offset);
static void dissect_synergy_dkup(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,gint offset);
static void dissect_synergy_dmmv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,gint offset);
static void dissect_synergy_dmrm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,gint offset);
static void dissect_synergy_dclp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,gint offset);
static void dissect_synergy_dinf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,gint offset);
static void dissect_synergy_eicv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,gint offset);
/* Code to dissect a single Synergy packet */
static int
dissect_synergy_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
col_set_str(pinfo->cinfo, COL_PROTOCOL, "synergy");
col_clear(pinfo->cinfo, COL_INFO);
if (tree) {
gint offset=0;
const guint8* packet_type;
proto_item *ti = NULL;
proto_tree *synergy_tree = NULL;
ti = proto_tree_add_protocol_format(tree, proto_synergy, tvb, 0, -1,"Synergy Protocol");
synergy_tree = proto_item_add_subtree(ti, ett_synergy);
proto_tree_add_item(synergy_tree,hf_synergy_packet_len,tvb,offset,4,ENC_BIG_ENDIAN);
/* Are the first 7 bytes of the payload "Synergy"?
* (Note this never throws an exception)
*/
if (tvb_strneql(tvb, offset+4, "Synergy", 7) == 0) {
/* Yes - dissect as a handshake. */
dissect_synergy_handshake(tvb,pinfo,synergy_tree,offset+11);
return tvb_captured_length(tvb);
}
/* No, so the first 4 bytes of the payload should be a packet type */
packet_type = tvb_get_string_enc(pinfo->pool, tvb, offset+4, 4, ENC_ASCII);
proto_tree_add_string_format_value(synergy_tree,hf_synergy_packet_type,tvb,offset+4,4, packet_type, "%s (%s)", str_to_str(packet_type, packet_type_vals, "Unknown"), packet_type);
if(strncmp(packet_type,"CNOP",4)==0) {
} else if(strncmp(packet_type,"CALV",4)==0) {
} else if(strncmp(packet_type,"CBYE",4)==0) {
proto_tree_add_item(synergy_tree,hf_synergy_cbye,tvb,offset+8,-1,ENC_NA);
} else if(strncmp(packet_type,"CINN",4)==0) {
dissect_synergy_cinn(tvb,pinfo,synergy_tree,offset+8);
} else if(strncmp(packet_type,"COUT",4)==0) {
proto_tree_add_item(synergy_tree,hf_synergy_cout,tvb,offset+8,-1,ENC_NA);
} else if(strncmp(packet_type,"CCLP",4)==0) {
dissect_synergy_cclp(tvb,pinfo,synergy_tree,offset+8);
} else if(strncmp(packet_type,"CSEC",4)==0) {
proto_tree_add_item(synergy_tree,hf_synergy_csec,tvb,offset+8,1,ENC_BIG_ENDIAN);
} else if(strncmp(packet_type,"CROP",4)==0) {
proto_tree_add_item(synergy_tree,hf_synergy_crop,tvb,offset+8,-1,ENC_NA);
} else if(strncmp(packet_type,"CIAK",4)==0) {
proto_tree_add_item(synergy_tree,hf_synergy_ciak,tvb,offset+8,-1,ENC_NA);
} else if(strncmp(packet_type,"DKDN",4)==0) {
dissect_synergy_dkdn(tvb,pinfo,synergy_tree,offset+8);
} else if(strncmp(packet_type,"DKRP",4)==0) {
dissect_synergy_dkrp(tvb,pinfo,synergy_tree,offset+8);
} else if(strncmp(packet_type,"DKUP",4)==0) {
dissect_synergy_dkup(tvb,pinfo,synergy_tree,offset+8);
} else if(strncmp(packet_type,"DMDN",4)==0) {
proto_tree_add_item(synergy_tree,hf_synergy_dmdn,tvb,offset+8,1,ENC_BIG_ENDIAN);
} else if(strncmp(packet_type,"DMUP",4)==0) {
proto_tree_add_item(synergy_tree,hf_synergy_dmup,tvb,offset+8,1,ENC_BIG_ENDIAN);
} else if(strncmp(packet_type,"DMMV",4)==0) {
dissect_synergy_dmmv(tvb,pinfo,synergy_tree,offset+8);
} else if(strncmp(packet_type,"DMRM",4)==0) {
dissect_synergy_dmrm(tvb,pinfo,synergy_tree,offset+8);
} else if(strncmp(packet_type,"DMWM",4)==0) {
proto_tree_add_item(synergy_tree,hf_synergy_dmwm,tvb,offset+8,2,ENC_BIG_ENDIAN);
} else if(strncmp(packet_type,"DCLP",4)==0) {
dissect_synergy_dclp(tvb,pinfo,synergy_tree,offset+8);
} else if(strncmp(packet_type,"DINF",4)==0) {
dissect_synergy_dinf(tvb,pinfo,synergy_tree,offset+8);
} else if(strncmp(packet_type,"DSOP",4)==0) {
proto_tree_add_item(synergy_tree,hf_synergy_dsop,tvb,offset+8,4,ENC_BIG_ENDIAN);
} else if(strncmp(packet_type,"QINF",4)==0) {
proto_tree_add_item(synergy_tree,hf_synergy_qinf,tvb,offset+8,-1,ENC_NA);
} else if(strncmp(packet_type,"EICV",4)==0) {
dissect_synergy_eicv(tvb,pinfo,synergy_tree,offset+8);
} else if(strncmp(packet_type,"EBSY",4)==0) {
proto_tree_add_item(synergy_tree,hf_synergy_ebsy,tvb,offset+8,-1,ENC_NA);
} else if(strncmp(packet_type,"EUNK",4)==0) {
proto_tree_add_item(synergy_tree,hf_synergy_eunk,tvb,offset+8,-1,ENC_NA);
} else if(strncmp(packet_type,"EBAD",4)==0) {
proto_tree_add_item(synergy_tree,hf_synergy_ebad,tvb,offset+8,-1,ENC_NA);
} else {
proto_tree_add_item(synergy_tree,hf_synergy_unknown,tvb,offset+8,-1,ENC_NA);
}
}
return tvb_captured_length(tvb);
}
static void dissect_synergy_handshake( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, gint offset )
{
proto_item *ti = NULL;
proto_tree *sub_tree = NULL;
ti = proto_tree_add_item(tree, hf_synergy_handshake, tvb, offset, -1, ENC_NA);
sub_tree = proto_item_add_subtree(ti, ett_synergy);
proto_tree_add_item(sub_tree, hf_synergy_handshake_majorversion, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_handshake_minorversion, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
if (tvb_reported_length_remaining(tvb, offset + 4) != 0)
{
proto_tree_add_item(sub_tree, hf_synergy_unknown, tvb, offset + 4, 4, ENC_NA);
proto_tree_add_item(sub_tree, hf_synergy_handshake_clientname, tvb, offset + 8, -1, ENC_ASCII);
}
}
static void dissect_synergy_cinn( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, gint offset )
{
proto_item *ti = NULL;
proto_tree *sub_tree = NULL;
ti = proto_tree_add_item(tree, hf_synergy_cinn, tvb, offset, -1, ENC_NA);
sub_tree = proto_item_add_subtree(ti, ett_synergy);
proto_tree_add_item(sub_tree, hf_synergy_cinn_x, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_cinn_y, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_cinn_sequence, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_cinn_modifiermask, tvb, offset + 8, 2, ENC_BIG_ENDIAN);
}
static void dissect_synergy_cclp( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, gint offset )
{
proto_item *ti = NULL;
proto_tree *sub_tree = NULL;
ti = proto_tree_add_item(tree, hf_synergy_cclp, tvb, offset, -1, ENC_NA);
sub_tree = proto_item_add_subtree(ti, ett_synergy);
proto_tree_add_item(sub_tree, hf_synergy_cclp_clipboardidentifier, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_cclp_sequencenumber, tvb, offset + 1, 4, ENC_BIG_ENDIAN);
}
static void dissect_synergy_dkdn( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, gint offset )
{
proto_item *ti = NULL;
proto_tree *sub_tree = NULL;
ti = proto_tree_add_item(tree, hf_synergy_dkdn, tvb, offset, -1, ENC_NA);
sub_tree = proto_item_add_subtree(ti, ett_synergy);
proto_tree_add_item(sub_tree, hf_synergy_dkdn_keyid, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_dkdn_keymodifiermask, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
if (tvb_reported_length_remaining(tvb, offset + 4) != 0)
proto_tree_add_item(sub_tree, hf_synergy_dkdn_keybutton, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
}
static void dissect_synergy_dkrp( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, gint offset )
{
proto_item *ti = NULL;
proto_tree *sub_tree = NULL;
ti = proto_tree_add_item(tree, hf_synergy_dkrp, tvb, offset, -1, ENC_NA);
sub_tree = proto_item_add_subtree(ti, ett_synergy);
proto_tree_add_item(sub_tree, hf_synergy_dkrp_keyid, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_dkrp_keymodifiermask, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_dkrp_numberofrepeats, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
if (tvb_reported_length_remaining(tvb, offset + 6) != 0)
proto_tree_add_item(sub_tree, hf_synergy_dkrp_keybutton, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
}
static void dissect_synergy_dkup( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, gint offset )
{
proto_item *ti = NULL;
proto_tree *sub_tree = NULL;
ti = proto_tree_add_item(tree, hf_synergy_dkup, tvb, offset, -1, ENC_NA);
sub_tree = proto_item_add_subtree(ti, ett_synergy);
proto_tree_add_item(sub_tree, hf_synergy_dkup_keyid, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_dkup_keymodifiermask, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
if (tvb_reported_length_remaining(tvb, offset + 4) != 0)
proto_tree_add_item(sub_tree, hf_synergy_dkup_keybutton, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
}
static void dissect_synergy_dmmv( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, gint offset )
{
proto_item *ti = NULL;
proto_tree *sub_tree = NULL;
ti = proto_tree_add_item(tree, hf_synergy_dmmv, tvb, offset, -1, ENC_NA);
sub_tree = proto_item_add_subtree(ti, ett_synergy);
proto_tree_add_item(sub_tree, hf_synergy_dmmv_x, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_dmmv_y, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
}
static void dissect_synergy_dmrm( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, gint offset )
{
proto_item *ti = NULL;
proto_tree *sub_tree = NULL;
ti = proto_tree_add_item(tree, hf_synergy_dmrm, tvb, offset, -1, ENC_NA);
sub_tree = proto_item_add_subtree(ti, ett_synergy);
proto_tree_add_item(sub_tree, hf_synergy_dmrm_x, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_dmrm_y, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
}
static void dissect_synergy_dclp( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, gint offset )
{
proto_item *ti = NULL;
proto_tree *sub_tree = NULL;
ti = proto_tree_add_item(tree, hf_synergy_dclp, tvb, offset, -1, ENC_NA);
sub_tree = proto_item_add_subtree(ti, ett_synergy);
proto_tree_add_item(sub_tree, hf_synergy_dclp_clipboardidentifier, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_dclp_sequencenumber, tvb, offset + 1, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_dclp_clipboarddata, tvb, offset + 5, -1, ENC_ASCII);
}
static void dissect_synergy_dinf( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, gint offset )
{
proto_item *ti = NULL;
proto_tree *sub_tree = NULL;
ti = proto_tree_add_item(tree, hf_synergy_dinf, tvb, offset, -1, ENC_NA);
sub_tree = proto_item_add_subtree(ti, ett_synergy);
proto_tree_add_item(sub_tree, hf_synergy_dinf_clp, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_dinf_ctp, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_dinf_wsp, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_dinf_hsp, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_dinf_swz, tvb, offset + 8, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_dinf_x, tvb, offset + 10, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_dinf_y, tvb, offset + 12, 2, ENC_BIG_ENDIAN);
}
static void dissect_synergy_eicv( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, gint offset )
{
proto_item *ti = NULL;
proto_tree *sub_tree = NULL;
ti = proto_tree_add_item(tree, hf_synergy_eicv, tvb, offset, -1, ENC_NA);
sub_tree = proto_item_add_subtree(ti, ett_synergy);
proto_tree_add_item(sub_tree, hf_synergy_eicv_majorversion, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(sub_tree, hf_synergy_eicv_minorversion, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
}
static guint
synergy_get_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
{
return tvb_get_ntohl(tvb, offset) + 4;
}
static int
dissect_synergy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 4, synergy_get_pdu_len,
dissect_synergy_pdu, NULL);
return tvb_captured_length(tvb);
}
void
proto_register_synergy(void)
{
static hf_register_info hf[] = {
{ &hf_synergy_packet_len,
{ "Packet Length","synergy.packet_len",FT_UINT32, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_packet_type,
{ "Packet Type","synergy.packet_type",FT_STRING, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_unknown,
{ "unknown","synergy.unknown",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_handshake,
{ "Handshake","synergy.handshake",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_handshake_majorversion,
{ "Major Version","synergy.handshake.majorversion",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_handshake_minorversion,
{ "Minor Version","synergy.handshake.minorversion",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_handshake_clientname,
{ "Client Name","synergy.handshake.client",FT_STRING, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_cbye,
{ "Close Connection","synergy.cbye",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_cinn,
{ "Enter Screen","synergy.cinn",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_cinn_x,
{ "Screen X","synergy.cinn.x",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_cinn_y,
{ "Screen Y","synergy.cinn.y",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_cinn_sequence,
{ "Sequence Number","synergy.cinn.sequence",FT_UINT32, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_cinn_modifiermask,
{ "Modifier Key Mask","synergy.cinn.mask",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_cout,
{ "Leave Screen","synergy.cout",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_cclp,
{ "Grab Clipboard","synergy.clipboard",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_cclp_clipboardidentifier,
{ "Identifier","synergy.clipboard.identifier",FT_UINT8, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_cclp_sequencenumber,
{ "Sequence Number","synergy.clipboard.sequence",FT_UINT32, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_csec,
{ "Screen Saver Change","synergy.screensaver",FT_BOOLEAN, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_crop,
{ "Reset Options","synergy.resetoptions",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_ciak,
{ "Resolution Change Acknowledgment","synergy.ack",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dkdn,
{ "Key Pressed","synergy.keypressed",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dkdn_keyid,
{ "Key Id","synergy.keypressed.keyid",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dkdn_keymodifiermask,
{ "Key Modifier Mask","synergy.keypressed.mask",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dkdn_keybutton,
{ "Key Button","synergy.keypressed.key",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dkrp,
{ "Key Auto-Repeat","synergy.keyautorepeat",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dkrp_keyid,
{ "Key ID","synergy.keyautorepeat.keyid",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dkrp_keymodifiermask,
{ "Key modifier Mask","synergy.keyautorepeat.mask",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dkrp_numberofrepeats,
{ "Number of Repeats","synergy.keyautorepeat.repeat",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dkrp_keybutton,
{ "Key Button","synergy.keyautorepeat.key",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dkup,
{ "Key Released","synergy.keyreleased",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dkup_keyid,
{ "Key Id","synergy.keyreleased.keyid",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dkup_keymodifiermask,
{ "Key Modifier Mask","synergy.keyreleased.mask",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dkup_keybutton,
{ "Key Button","synergy.keyreleased.key",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dmdn,
{ "Mouse Button Pressed","synergy.mousebuttonpressed",FT_UINT8, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dmup,
{ "Mouse Button Released","synergy.mousebuttonreleased",FT_UINT8, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dmmv,
{ "Mouse Moved","synergy.mousemoved",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dmmv_x,
{ "X Axis","synergy.mousemoved.x",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dmmv_y,
{ "Y Axis","synergy.mousemoved.y",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dmrm,
{ "Relative Mouse Move","synergy.relativemousemove",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dmrm_x,
{ "X Axis","synergy.relativemousemove.x",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dmrm_y,
{ "Y Axis","synergy.relativemousemove.y",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dmwm,
{ "Mouse Button Pressed","synergy.mousebuttonpressed",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dclp,
{ "Clipboard Data","synergy.clipboarddata",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dclp_clipboardidentifier,
{ "Clipboard Identifier","synergy.clipboarddata.identifier",FT_UINT8, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dclp_sequencenumber,
{ "Sequence Number","synergy.clipboarddata.sequence",FT_UINT32, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dclp_clipboarddata,
{ "Clipboard Data","synergy.clipboarddata.data",FT_STRING, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dinf,
{ "Client Data","synergy.clientdata",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dinf_clp,
{ "coordinate of leftmost pixel on secondary screen","synergy.clps",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dinf_ctp,
{ "coordinate of topmost pixel on secondary screen","synergy.clps.ctp",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dinf_wsp,
{ "width of secondary screen in pixels","synergy.clps.wsp",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dinf_hsp,
{ "height of secondary screen in pixels","synergy.clps.hsp",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dinf_swz,
{ "size of warp zone","synergy.clps.swz",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dinf_x,
{ "x position of the mouse on the secondary screen","synergy.clps.x",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dinf_y,
{ "y position of the mouse on the secondary screen","synergy.clps.y",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_dsop,
{ "Set Options","synergy.setoptions",FT_UINT32, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_qinf,
{ "Query Screen Info","synergy.qinf",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_eicv,
{ "Incompatible Versions","synergy.eicv",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_eicv_majorversion,
{ "Major Version Number","synergy.eicv.major",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_eicv_minorversion,
{ "Minor Version Number","synergy.eicv.minor",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_ebsy,
{ "Connection Already in Use","synergy.ebsy",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_eunk,
{ "Unknown Client","synergy.unknown",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
{ &hf_synergy_ebad,
{ "Protocol Violation","synergy.violation",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
},
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_synergy,
};
/* Register the protocol name and description */
proto_synergy = proto_register_protocol("Synergy", "Synergy", "synergy");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_synergy, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
synergy_handle = register_dissector("synergy", dissect_synergy, proto_synergy);
}
void
proto_reg_handoff_synergy(void)
{
dissector_add_uint_with_preference("tcp.port", SYNERGY_PORT, synergy_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-synphasor.c
|
/* packet-synphasor.c
* Dissector for IEEE C37.118 synchrophasor frames.
*
* Copyright 2008, Jens Steinhauser <[email protected]>
* Copyright 2019, Dwayne Rich <[email protected]>
* Copyright 2020, Dmitriy Eliseev <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <math.h>
#include <epan/packet.h>
#include <epan/crc16-tvb.h>
#include <epan/expert.h>
#include <epan/proto_data.h>
#include "packet-tcp.h"
#include <wsutil/utf8_entities.h>
#define PROTOCOL_NAME "IEEE C37.118 Synchrophasor Protocol"
#define PROTOCOL_SHORT_NAME "SYNCHROPHASOR"
#define PROTOCOL_ABBREV "synphasor"
/* forward references */
void proto_register_synphasor(void);
void proto_reg_handoff_synphasor(void);
/* global variables */
static int proto_synphasor = -1;
/* user preferences */
#define SYNPHASOR_TCP_PORT 4712 /* Not IANA registered */
#define SYNPHASOR_UDP_PORT 4713 /* Not IANA registered */
/* Config 1 & 2 frames have channel names that are all 16 bytes long */
/* Config 3 frame channel names have a variable length with a max of 255 characters */
#define CHNAM_LEN 16
#define MAX_NAME_LEN 255
#define G_PMU_ID_LEN 16
/* the ett... variables hold the state (open/close) of the treeview in the GUI */
static gint ett_synphasor = -1; /* root element for this protocol */
/* used in the common header */
static gint ett_frtype = -1;
static gint ett_timequal = -1;
/* used for config frames */
static gint ett_conf = -1;
static gint ett_conf_station = -1;
static gint ett_conf_format = -1;
static gint ett_conf_phnam = -1;
static gint ett_conf_annam = -1;
static gint ett_conf_dgnam = -1;
static gint ett_conf_phconv = -1;
static gint ett_conf_phlist = -1;
static gint ett_conf_phflags = -1;
static gint ett_conf_phmod_flags = -1;
static gint ett_conf_ph_user_flags = -1;
static gint ett_conf_anconv = -1;
static gint ett_conf_anlist = -1;
static gint ett_conf_dgmask = -1;
static gint ett_conf_chnam = -1;
static gint ett_conf_wgs84 = -1;
/* used for data frames */
static gint ett_data = -1;
static gint ett_data_block = -1;
static gint ett_data_stat = -1;
static gint ett_data_phasors = -1;
static gint ett_data_analog = -1;
static gint ett_data_digital = -1;
/* used for command frames */
static gint ett_command = -1;
static gint ett_status_word_mask = -1;
/* handles to the header fields hf[] in proto_register_synphasor() */
static int hf_sync = -1;
static int hf_sync_frtype = -1;
static int hf_sync_version = -1;
static int hf_station_name_len = -1;
static int hf_station_name = -1;
static int hf_idcode_stream_source = -1;
static int hf_idcode_data_source = -1;
static int hf_g_pmu_id = -1;
static int hf_frsize = -1;
static int hf_soc = -1;
static int hf_timeqal_lsdir = -1;
static int hf_timeqal_lsocc = -1;
static int hf_timeqal_lspend = -1;
static int hf_timeqal_timequalindic = -1;
static int hf_fracsec_raw = -1;
static int hf_fracsec_ms = -1;
static int hf_cont_idx = -1;
static int hf_conf_timebase = -1;
static int hf_conf_numpmu = -1;
static int hf_conf_formatb3 = -1;
static int hf_conf_formatb2 = -1;
static int hf_conf_formatb1 = -1;
static int hf_conf_formatb0 = -1;
static int hf_conf_chnam_len = -1;
static int hf_conf_chnam = -1;
static int hf_conf_phasor_mod_b15 = -1;
static int hf_conf_phasor_mod_b10 = -1;
static int hf_conf_phasor_mod_b09 = -1;
static int hf_conf_phasor_mod_b08 = -1;
static int hf_conf_phasor_mod_b07 = -1;
static int hf_conf_phasor_mod_b06 = -1;
static int hf_conf_phasor_mod_b05 = -1;
static int hf_conf_phasor_mod_b04 = -1;
static int hf_conf_phasor_mod_b03 = -1;
static int hf_conf_phasor_mod_b02 = -1;
static int hf_conf_phasor_mod_b01 = -1;
static int hf_conf_phasor_type_b03 = -1;
static int hf_conf_phasor_type_b02to00 = -1;
static int hf_conf_phasor_user_data = -1;
static int hf_conf_phasor_scale_factor = -1;
static int hf_conf_phasor_angle_offset = -1;
static int hf_conf_analog_scale_factor = -1;
static int hf_conf_analog_offset = -1;
static int hf_conf_pmu_lat = -1;
static int hf_conf_pmu_lon = -1;
static int hf_conf_pmu_elev = -1;
static int hf_conf_pmu_lat_unknown = -1;
static int hf_conf_pmu_lon_unknown = -1;
static int hf_conf_pmu_elev_unknown = -1;
static int hf_conf_svc_class = -1;
static int hf_conf_window = -1;
static int hf_conf_grp_dly = -1;
static int hf_conf_fnom = -1;
static int hf_conf_cfgcnt = -1;
static int hf_data_statb15to14 = -1;
static int hf_data_statb13 = -1;
static int hf_data_statb12 = -1;
static int hf_data_statb11 = -1;
static int hf_data_statb10 = -1;
static int hf_data_statb09 = -1;
static int hf_data_statb08to06 = -1;
static int hf_data_statb05to04 = -1;
static int hf_data_statb03to00 = -1;
static int hf_command = -1;
static int hf_cfg_frame_num = -1;
/* Generated from convert_proto_tree_add_text.pl */
static int hf_synphasor_data = -1;
static int hf_synphasor_checksum = -1;
static int hf_synphasor_checksum_status = -1;
static int hf_synphasor_num_phasors = -1;
static int hf_synphasor_num_analog_values = -1;
static int hf_synphasor_num_digital_status_words = -1;
static int hf_synphasor_rate_of_transmission = -1;
static int hf_synphasor_phasor = -1;
static int hf_synphasor_actual_frequency_value = -1;
static int hf_synphasor_rate_change_frequency = -1;
static int hf_synphasor_frequency_deviation_from_nominal = -1;
static int hf_synphasor_analog_value = -1;
static int hf_synphasor_digital_status_word = -1;
static int hf_synphasor_conversion_factor = -1;
static int hf_synphasor_factor_for_analog_value = -1;
static int hf_synphasor_channel_name = -1;
static int hf_synphasor_extended_frame_data = -1;
static int hf_synphasor_unknown_data = -1;
static int hf_synphasor_status_word_mask_normal_state = -1;
static int hf_synphasor_status_word_mask_valid_bits = -1;
static expert_field ei_synphasor_extended_frame_data = EI_INIT;
static expert_field ei_synphasor_checksum = EI_INIT;
static expert_field ei_synphasor_data_error = EI_INIT;
static expert_field ei_synphasor_pmu_not_sync = EI_INIT;
static dissector_handle_t synphasor_udp_handle;
/* the different frame types for this protocol */
enum FrameType {
DATA = 0,
HEADER,
CFG1,
CFG2,
CMD,
CFG3
};
/* Structures to save CFG frame content. */
/* type to indicate the format for (D)FREQ/PHASORS/ANALOG in data frame */
typedef enum { integer, /* 16 bit signed integer */
floating_point /* single precision floating point */
} data_format;
typedef enum { rect, polar } phasor_notation_e;
typedef enum { V, A } unit_e;
/* holds the information required to dissect a single phasor */
typedef struct {
char name[MAX_NAME_LEN + 1];
unit_e unit;
guint32 conv; /* cfg-2 conversion factor in 10^-5 scale */
float conv_cfg3; /* cfg-3 conversion scale factor */
float angle_offset_cfg3; /* cfg-3 angle offset */
} phasor_info;
/* holds the information for an analog value */
typedef struct {
char name[MAX_NAME_LEN + 1];
guint32 conv; /* cfg-2 conversion scale factor, user defined scaling (so it's pretty useless) */
float conv_cfg3; /* cfg-3 conversion scale factor */
float offset_cfg3; /* cfg-3 conversion offset */
} analog_info;
/* holds information required to dissect a single PMU block in a data frame */
typedef struct {
guint16 id; /* (Data Source ID) identifies source of block */
char name[MAX_NAME_LEN + 1]; /* holds STN */
guint8 cfg_frame_type; /* Config Frame Type (1,2,3,...) */
data_format format_fr; /* data format of FREQ and DFREQ */
data_format format_ph; /* data format of PHASORS */
data_format format_an; /* data format of ANALOG */
phasor_notation_e phasor_notation; /* format of the phasors */
guint fnom; /* nominal line frequency */
guint num_dg; /* number of digital status words */
wmem_array_t *phasors; /* array of phasor_infos */
wmem_array_t *analogs; /* array of analog_infos */
} config_block;
/* holds the id the configuration comes from an and
* an array of config_block members */
typedef struct {
guint32 fnum; /* frame number */
guint16 id; /* (Stream Source ID) identifies source of stream */
guint32 time_base; /* Time base - resolution of FRACSEC time stamp. */
wmem_array_t *config_blocks; /* Contains a config_block struct for
* every PMU included in the config frame */
} config_frame;
/* strings for type bits in SYNC */
static const value_string typenames[] = {
{ 0, "Data Frame" },
{ 1, "Header Frame" },
{ 2, "Configuration Frame 1" },
{ 3, "Configuration Frame 2" },
{ 4, "Command Frame" },
{ 5, "Configuration Frame 3" },
{ 0, NULL }
};
/* strings for version bits in SYNC */
static const value_string versionnames[] = {
{ 1, "Defined in IEEE Std C37.118-2005" },
{ 2, "Added in IEEE Std C37.118.2-2011" },
{ 0, NULL }
};
/* strings for the time quality flags in FRACSEC */
static const true_false_string leapseconddir = {
"Add",
"Delete"
};
static const value_string timequalcodes[] = {
{ 0xF, "Clock failure, time not reliable" },
{ 0xB, "Clock unlocked, time within 10 s" },
{ 0xA, "Clock unlocked, time within 1 s" },
{ 0x9, "Clock unlocked, time within 10^-1 s" },
{ 0x8, "Clock unlocked, time within 10^-2 s" },
{ 0x7, "Clock unlocked, time within 10^-3 s" },
{ 0x6, "Clock unlocked, time within 10^-4 s" },
{ 0x5, "Clock unlocked, time within 10^-5 s" },
{ 0x4, "Clock unlocked, time within 10^-6 s" },
{ 0x3, "Clock unlocked, time within 10^-7 s" },
{ 0x2, "Clock unlocked, time within 10^-8 s" },
{ 0x1, "Clock unlocked, time within 10^-9 s" },
{ 0x0, "Normal operation, clock locked" },
{ 0 , NULL }
};
/* strings for flags in the FORMAT word of a configuration frame */
static const true_false_string conf_formatb123names = {
"32-bit IEEE floating point",
"16-bit integer"
};
static const true_false_string conf_formatb0names = {
"polar",
"rectangular"
};
/* strings to decode ANUNIT in configuration frame */
static const range_string conf_anconvnames[] = {
{ 0, 0, "single point-on-wave" },
{ 1, 1, "rms of analog input" },
{ 2, 2, "peak of input" },
{ 3, 4, "undefined" },
{ 5, 64, "reserved" },
{ 65, 255, "user defined" },
{ 0, 0, NULL }
};
/* strings for the FNOM field */
static const true_false_string conf_fnomnames = {
"50Hz",
"60Hz"
};
static const true_false_string conf_phasor_mod_b15 = {
"Modification applied, type not here defined",
"None"
};
static const true_false_string conf_phasor_mod_b10 = {
"Pseudo-phasor value (combined from other phasors)",
"None"
};
static const true_false_string conf_phasor_mod_b09 = {
"Phasor phase adjusted for rotation",
"None"
};
static const true_false_string conf_phasor_mod_b08 = {
"Phasor phase adjusted for calibration",
"None"
};
static const true_false_string conf_phasor_mod_b07 = {
"Phasor magnitude adjusted for calibration",
"None"
};
static const true_false_string conf_phasor_mod_b06 = {
"Filtered without changing sampling",
"None"
};
static const true_false_string conf_phasor_mod_b05 = {
"Down sampled with non-FIR filter",
"None"
};
static const true_false_string conf_phasor_mod_b04 = {
"Down sampled with FIR filter",
"None"
};
static const true_false_string conf_phasor_mod_b03 = {
"Down sampled by reselection",
"None"
};
static const true_false_string conf_phasor_mod_b02 = {
"Up sampled with extrapolation",
"None"
};
static const true_false_string conf_phasor_mod_b01 = {
"Up sampled with interpolation",
"None"
};
static const value_string conf_phasor_type[] = {
{ 0, "Voltage, Zero sequence" },
{ 1, "Voltage, Positive sequence" },
{ 2, "Voltage, Negative sequence" },
{ 3, "Voltage, Reserved" },
{ 4, "Voltage, Phase A" },
{ 5, "Voltage, Phase B" },
{ 6, "Voltage, Phase C" },
{ 7, "Voltage, Reserved" },
{ 8, "Current, Zero sequence" },
{ 9, "Current, Positive sequence" },
{ 10, "Current, Negative sequence" },
{ 11, "Current, Reserved" },
{ 12, "Current, Phase A" },
{ 13, "Current, Phase B" },
{ 14, "Current, Phase C" },
{ 15, "Current, Reserved" },
{ 0, NULL }
};
static const true_false_string conf_phasor_type_b03 = {
"Current",
"Voltage"
};
static const value_string conf_phasor_type_b02to00[] = {
{ 0, "Zero sequence" },
{ 1, "Positive sequence"},
{ 2, "Negative sequence"},
{ 3, "Reserved" },
{ 4, "Phase A" },
{ 5, "Phase B" },
{ 6, "Phase C" },
{ 7, "Reserved" },
{ 0, NULL }
};
static const true_false_string conf_phasor_user_defined = {
"Flags set",
"No flags set"
};
/* strings for flags in the STAT word of a data frame */
static const value_string data_statb15to14names[] = {
{ 0, "Good measurement data, no errors" },
{ 1, "PMU error, no information about data" },
{ 2, "PMU in test mode or absent data tags have been inserted (do not use values)" },
{ 3, "PMU error (do not use values)" },
{ 0, NULL }
};
static const true_false_string data_statb13names = {
"Synchronization lost",
"Clock is synchronized"
};
static const true_false_string data_statb12names = {
"By arrival",
"By timestamp"
};
static const true_false_string data_statb11names = {
"Trigger detected",
"No trigger"
};
static const true_false_string data_statb10names = {
"Within 1 minute",
"No"
};
static const true_false_string data_statb09names = {
"Data modified by a post-processing device",
"Data not modified"
};
static const value_string data_statb08to06names[] = {
{ 0, "Not used (indicates code from previous version of profile)" },
{ 1, "Estimated maximum time error < 100 ns" },
{ 2, "Estimated maximum time error < 1 " UTF8_MICRO_SIGN "s" },
{ 3, "Estimated maximum time error < 10 " UTF8_MICRO_SIGN "s" },
{ 4, "Estimated maximum time error < 100 " UTF8_MICRO_SIGN "s" },
{ 5, "Estimated maximum time error < 1 ms" },
{ 6, "Estimated maximum time error < 10 ms" },
{ 7, "Estimated maximum time error > 10 ms or time error unknown" },
{ 0, NULL }
};
static const value_string data_statb05to04names[] = {
{ 0, "Locked or unlocked less than 10 s"},
{ 1, "Unlocked for 10-100 s" },
{ 2, "Unlocked for 100-1000 s" },
{ 3, "Unlocked for over 1000 s" },
{ 0, NULL }
};
static const value_string data_statb03to00names[] = {
{ 0x0, "Manual" },
{ 0x1, "Magnitude low" },
{ 0x2, "Magnitude high" },
{ 0x3, "Phase-angel diff" },
{ 0x4, "Frequency high or low" },
{ 0x5, "df/dt high" },
{ 0x6, "Reserved" },
{ 0x7, "Digital" },
{ 0x8, "User defined" },
{ 0x9, "User defined" },
{ 0xA, "User defined" },
{ 0xB, "User defined" },
{ 0xC, "User defined" },
{ 0xD, "User defined" },
{ 0xE, "User defined" },
{ 0xF, "User defined" },
{ 0, NULL }
};
/* strings to decode the commands (CMD Field) acording Table 15, p.26
* 0000 0000 0000 0001 - Turn off transmission of data frames
* 0000 0000 0000 0010 - Turn on transmission of data frames
* 0000 0000 0000 0011 - Send HDR frame
* 0000 0000 0000 0100 - Send CFG-1 frame.
* 0000 0000 0000 0101 - Send CFG-2 frame.
* 0000 0000 0000 0110 - Send CFG-3 frame (optional command).
* 0000 0000 0000 1000 - Extended frame.
* 0000 0000 xxxx xxxx - All undesignated codes reserved.
* 0000 yyyy xxxx xxxx - All codes where yyyy ≠ 0 available for user designation.
* zzzz xxxx xxxx xxxx - All codes where zzzz ≠ 0 reserved.
*/
static const range_string command_names[] = {
{ 0x0000, 0x0000, "reserved codes" },
{ 0x0001, 0x0001, "data transmission off" },
{ 0x0002, 0x0002, "data transmission on" },
{ 0x0003, 0x0003, "send HDR frame" },
{ 0x0004, 0x0004, "send CFG-1 frame" },
{ 0x0005, 0x0005, "send CFG-2 frame" },
{ 0x0006, 0x0006, "send CFG-3 frame" },
{ 0x0007, 0x0007, "reserved codes" },
{ 0x0008, 0x0008, "extended frame" },
{ 0x0009, 0x00FF, "reserved codes" },
{ 0x0100, 0x0FFF, "user designation" },
{ 0x1000, 0xFFFF, "reserved codes" },
{ 0x0000, 0x0000, NULL }
};
/******************************************************************************
* functions
******************************************************************************/
/* read in the size length for names found in config 3 frames
0 - no name
1-255 - length of name
*/
static guint8 get_name_length(tvbuff_t *tvb, gint offset)
{
guint8 name_length;
/* read the size of the name */
name_length = tvb_get_guint8(tvb, offset);
return name_length;
}
/* Checks the CRC of a synchrophasor frame, 'tvb' has to include the whole
* frame, including CRC, the calculated CRC is returned in '*computedcrc'.
*/
static gboolean check_crc(tvbuff_t *tvb, guint16 *computedcrc)
{
guint16 crc;
guint len = tvb_get_ntohs(tvb, 2);
crc = tvb_get_ntohs(tvb, len - 2);
*computedcrc = crc16_x25_ccitt_tvb(tvb, len - 2);
if (crc == *computedcrc)
return TRUE;
return FALSE;
}
/* Dissects a configuration frame (only the most important stuff, tries
* to be fast, does no GUI stuff) and returns a pointer to a config_frame
* struct that contains all the information from the frame needed to
* dissect a DATA frame.
*
* use 'config_frame_free()' to free the config_frame again
*/
static config_frame *config_frame_fast(tvbuff_t *tvb)
{
guint16 num_pmu;
gint offset;
config_frame *frame;
/* get a new frame and initialize it */
frame = wmem_new(wmem_file_scope(), config_frame);
frame->config_blocks = wmem_array_new(wmem_file_scope(), sizeof(config_block));
// Start with Stream Source ID - identifies source of stream
offset = 4;
frame->id = tvb_get_ntohs(tvb, offset);
/* Skip to time base for FRACSEC */
offset += 11; // high 8 bits reserved for flags, so +1 byte
frame->time_base = tvb_get_guint24(tvb, offset,ENC_BIG_ENDIAN);
/* Next number of PMU blocks */
offset += 3;
num_pmu = tvb_get_ntohs(tvb, offset);
// Start of repeating blocks
offset += 2;
while (num_pmu) {
guint16 format_flags;
gint num_ph,
num_an,
num_dg;
gint i,
phunit,
anunit,
fnom;
config_block block;
/* initialize the block */
block.phasors = wmem_array_new(wmem_file_scope(), sizeof(phasor_info));
block.analogs = wmem_array_new(wmem_file_scope(), sizeof(analog_info));
/* copy the station name from the tvb to block, and add NULL byte */
tvb_memcpy(tvb, block.name, offset, CHNAM_LEN); offset += CHNAM_LEN;
block.name[CHNAM_LEN] = '\0';
block.cfg_frame_type = 2;
block.id = tvb_get_ntohs(tvb, offset); offset += 2;
format_flags = tvb_get_ntohs(tvb, offset); offset += 2;
block.format_fr = (format_flags & 0x0008) ? floating_point : integer;
block.format_an = (format_flags & 0x0004) ? floating_point : integer;
block.format_ph = (format_flags & 0x0002) ? floating_point : integer;
block.phasor_notation = (format_flags & 0x0001) ? polar : rect;
num_ph = tvb_get_ntohs(tvb, offset); offset += 2;
num_an = tvb_get_ntohs(tvb, offset); offset += 2;
num_dg = tvb_get_ntohs(tvb, offset); offset += 2;
block.num_dg = num_dg;
/* the offset of the PHUNIT, ANUNIT, and FNOM blocks */
phunit = offset + (num_ph + num_an + num_dg * CHNAM_LEN) * CHNAM_LEN;
anunit = phunit + num_ph * 4;
fnom = anunit + num_an * 4 + num_dg * 4;
/* read num_ph phasor names and conversion factors */
for (i = 0; i != num_ph; i++) {
phasor_info pi;
guint32 conv;
/* copy the phasor name from the tvb, and add NULL byte */
tvb_memcpy(tvb, pi.name, offset, CHNAM_LEN); offset += CHNAM_LEN;
pi.name[CHNAM_LEN] = '\0';
conv = tvb_get_ntohl(tvb, phunit + 4 * i);
pi.unit = conv & 0xFF000000 ? A : V;
pi.conv = conv & 0x00FFFFFF;
pi.conv_cfg3 = 1;
pi.angle_offset_cfg3 = 0;
wmem_array_append_one(block.phasors, pi);
}
/* read num_an analog value names and conversion factors */
for (i = 0; i != num_an; i++) {
analog_info ai;
guint32 conv;
/* copy the phasor name from the tvb, and add NULL byte */
tvb_memcpy(tvb, ai.name, offset, CHNAM_LEN); offset += CHNAM_LEN;
ai.name[CHNAM_LEN] = '\0';
conv = tvb_get_ntohl(tvb, anunit + 4 * i);
ai.conv = conv;
ai.conv_cfg3 = 1;
ai.offset_cfg3 = 0;
wmem_array_append_one(block.analogs, ai);
}
/* the names for the bits in the digital status words aren't saved,
there is no space to display them in the GUI anyway */
/* save FNOM */
block.fnom = tvb_get_ntohs(tvb, fnom) & 0x0001 ? 50 : 60;
offset = fnom + 2;
/* skip CFGCNT */
offset += 2;
wmem_array_append_one(frame->config_blocks, block);
num_pmu--;
}
return frame;
} /* config_frame_fast() */
/* Dissects a configuration 3 frame (only the most important stuff, tries
* to be fast, does no GUI stuff) and returns a pointer to a config_frame
* struct that contains all the information from the frame needed to
* dissect a DATA frame.
*
* use 'config_frame_free()' to free the config_frame again
*/
static config_frame * config_3_frame_fast(tvbuff_t *tvb)
{
guint16 num_pmu;
gint offset;
config_frame *frame;
phasor_info *pi = NULL;
analog_info *ai = NULL;
gboolean frame_not_fragmented;
/* get a new frame and initialize it */
frame = wmem_new(wmem_file_scope(), config_frame);
frame->config_blocks = wmem_array_new(wmem_file_scope(), sizeof(config_block));
// Start with Stream Source ID - identifies source of stream
offset = 4;
frame->id = tvb_get_ntohs(tvb, offset);
/* Skip to CONT_IDX -- Fragmented Frames not supported at this time */
offset += 10;
frame_not_fragmented = tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN) == 0;
/* Skip to time base for FRACSEC */
offset += 3; // high 8 bits reserved for flags, so +1 byte
frame->time_base = tvb_get_guint24(tvb, offset,ENC_BIG_ENDIAN);
/* Skip to number of PMU blocks */
offset += 3;
num_pmu = tvb_get_ntohs(tvb, offset);
/* start of repeating blocks */
offset += 2;
while ((num_pmu) && (frame_not_fragmented)) {
guint16 format_flags;
gint num_ph,
num_an,
num_dg;
gint i;
guint8 name_length;
config_block block;
/* initialize the block */
block.phasors = wmem_array_new(wmem_file_scope(), sizeof(phasor_info));
block.analogs = wmem_array_new(wmem_file_scope(), sizeof(analog_info));
/* copy the station name from the tvb to block, and add NULL byte */
/* first byte is name size */
name_length = get_name_length(tvb, offset);
offset += 1;
tvb_memcpy(tvb, block.name, offset, name_length);
offset += name_length;
block.name[name_length] = '\0';
block.cfg_frame_type = 3;
/* Block ID and Global PMU ID */
block.id = tvb_get_ntohs(tvb, offset);
offset += 2;
/* skip over Global PMU ID */
offset += G_PMU_ID_LEN;
format_flags = tvb_get_ntohs(tvb, offset);
offset += 2;
block.format_fr = (format_flags & 0x0008) ? floating_point : integer;
block.format_an = (format_flags & 0x0004) ? floating_point : integer;
block.format_ph = (format_flags & 0x0002) ? floating_point : integer;
block.phasor_notation = (format_flags & 0x0001) ? polar : rect;
num_ph = tvb_get_ntohs(tvb, offset);
offset += 2;
num_an = tvb_get_ntohs(tvb, offset);
offset += 2;
num_dg = tvb_get_ntohs(tvb, offset);
offset += 2;
block.num_dg = num_dg;
/* grab phasor names */
if (num_ph > 0)
{
pi = (phasor_info *)wmem_alloc(wmem_file_scope(), sizeof(phasor_info)*num_ph);
for (i = 0; i != num_ph; i++) {
/* copy the phasor name from the tvb, and add NULL byte */
name_length = get_name_length(tvb, offset);
offset += 1;
tvb_memcpy(tvb, pi[i].name, offset, name_length);
offset += name_length;
pi[i].name[name_length] = '\0';
}
}
/* grab analog names */
if (num_an > 0)
{
ai = (analog_info *)wmem_alloc(wmem_file_scope(), sizeof(analog_info)*num_an);
for (i = 0; i != num_an; i++) {
/* copy the phasor name from the tvb, and add NULL byte */
name_length = get_name_length(tvb, offset);
offset += 1;
tvb_memcpy(tvb, ai[i].name, offset, name_length);
offset += name_length;
ai[i].name[name_length] = '\0';
}
}
/* skip digital names */
if (num_dg > 0)
{
for (i = 0; i != num_dg * 16; i++) {
name_length = get_name_length(tvb, offset);
offset += name_length + 1;
}
}
/* get phasor conversion factors */
if (num_ph > 0)
{
for (i = 0; i != num_ph; i++) {
guint32 phasor_unit;
/* get unit */
phasor_unit = tvb_get_ntohl(tvb, offset);
pi[i].unit = phasor_unit & 0x00000800 ? A : V;
pi[i].conv = 1;
pi[i].conv_cfg3 = tvb_get_ntohieee_float(tvb, offset + 4);
pi[i].angle_offset_cfg3 = tvb_get_ntohieee_float(tvb, offset + 8);
wmem_array_append_one(block.phasors, pi[i]);
offset += 12;
}
}
/* get analog conversion factors */
if (num_an > 0)
{
for (i = 0; i != num_an; i++) {
ai[i].conv = 1;
ai[i].conv_cfg3 = tvb_get_ntohieee_float(tvb, offset);
ai[i].offset_cfg3 = tvb_get_ntohieee_float(tvb, offset + 4);
wmem_array_append_one(block.analogs, ai[i]);
offset += 8;
}
}
/* skip digital masks */
if (num_dg > 0)
{
for (i = 0; i != num_dg; i++) {
offset += 4;
}
}
/* Skip to FNOM */
offset += 21;
/* save FNOM */
block.fnom = tvb_get_ntohs(tvb, offset) & 0x0001 ? 50 : 60;
offset += 2;
/* skip CFGCNT - offset ready for next PMU */
offset += 2;
wmem_array_append_one(frame->config_blocks, block);
num_pmu--;
}
return frame;
} /* config_3_frame_fast() */
/* Dissects the common header of frames.
*
* Returns the framesize, in contrast to most
* other helper functions that return the offset.
*/
static gint dissect_header(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo)
{
proto_tree *temp_tree;
proto_item *temp_item;
config_frame *conf;
gint offset = 0;
guint16 framesize;
conf = (config_frame *)p_get_proto_data(wmem_file_scope(), pinfo, proto_synphasor, 0);
/* SYNC and flags */
temp_item = proto_tree_add_item(tree, hf_sync, tvb, offset, 2, ENC_BIG_ENDIAN);
temp_tree = proto_item_add_subtree(temp_item, ett_frtype);
proto_tree_add_item(temp_tree, hf_sync_frtype, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(temp_tree, hf_sync_version, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* FRAMESIZE */
proto_tree_add_item(tree, hf_frsize, tvb, offset, 2, ENC_BIG_ENDIAN);
framesize = tvb_get_ntohs(tvb, offset); offset += 2;
/* IDCODE */
proto_tree_add_item(tree, hf_idcode_stream_source, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* SOC */
proto_tree_add_item(tree, hf_soc, tvb, offset, 4, ENC_TIME_SECS | ENC_BIG_ENDIAN);
offset += 4;
/* FRACSEC */
/* time quality flags */
temp_tree = proto_tree_add_subtree(tree, tvb, offset, 1, ett_timequal, NULL, "Time quality flags");
proto_tree_add_item(temp_tree, hf_timeqal_lsdir, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(temp_tree, hf_timeqal_lsocc, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(temp_tree, hf_timeqal_lspend, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(temp_tree, hf_timeqal_timequalindic, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
// Add RAW FRACSEC
proto_tree_add_item(tree, hf_fracsec_raw, tvb, offset, 3, ENC_BIG_ENDIAN);
// If exist configuration frame, add fracsec in milliseconds
if (conf){
guint32 fracsec_raw = tvb_get_guint24(tvb, offset, ENC_BIG_ENDIAN);
float fracsec_ms = 1000.0f*fracsec_raw/conf->time_base;
proto_tree_add_float(tree, hf_fracsec_ms, tvb, offset, 3, fracsec_ms);
} else
{
}
/*offset += 3;*/
return framesize;
}
/* Dissects a single phasor for 'dissect_PHASORS()' */
static int dissect_single_phasor(tvbuff_t *tvb, int offset,
gdouble *mag, gdouble *phase, /* returns the resulting values in polar format here */
gdouble* real, gdouble* imag, /* returns the resulting values in rectangular format here*/
gdouble* mag_real_unscaled, gdouble* phase_imag_unscaled, /* returns unscaled values*/
config_block *block, /* information needed to... */
phasor_info* pi) /* ...dissect the phasor */
{
if (floating_point == block->format_ph) {
if (polar == block->phasor_notation) {
/* float, polar */
*mag = tvb_get_ntohieee_float(tvb, offset );
*phase = tvb_get_ntohieee_float(tvb, offset + 4);
*real = (*mag) * cos(*phase);
*imag = (*mag) * sin(*phase);
}
else {
/* float, rect */
*real = tvb_get_ntohieee_float(tvb, offset );
*imag = tvb_get_ntohieee_float(tvb, offset + 4);
*mag = sqrt(pow(*real, 2) + pow(*imag, 2));
*phase = atan2(*imag, *real);
}
}
else {
if (polar == block->phasor_notation) {
/* int, polar */
*mag_real_unscaled = tvb_get_ntohs(tvb, offset );
*phase_imag_unscaled = tvb_get_ntohis(tvb, offset + 2);
/* For fixed-point data in polar format all values are permissible for the magnitude
field. However, the angle field is restricted to ±31416. A value of 0x8000 (–32768) used in the angle field
will be used to signify absent data.
bullet 6.3.1 page 16 IEEE Std C37.118.2-2011
*/
if (*phase_imag_unscaled == -32768) {
*phase_imag_unscaled = NAN;
*mag_real_unscaled = NAN;
}
*phase = *phase_imag_unscaled/10000.0; /* angle is in radians*10^4 */
/* for values in integer format, consider conversation factor */
if (block->cfg_frame_type == 3){
*mag = (*mag_real_unscaled * pi->conv_cfg3);
*phase = *phase - pi->angle_offset_cfg3;
}
else{
*mag = (*mag_real_unscaled * pi->conv) * 0.00001;
}
*real = (*mag) * cos(*phase);
*imag = (*mag) * sin(*phase);
}
else {
/* int, rect */
*mag_real_unscaled = tvb_get_ntohis(tvb, offset );
*phase_imag_unscaled = tvb_get_ntohis(tvb, offset + 2);
/* For fixed-point data in rectangular format the PDC will use
0x8000 (–32768) as the substitute for the absent data.
bullet 6.3.1 page 16 IEEE Std C37.118.2-2011
*/
if (*mag_real_unscaled == -32768) {
*mag_real_unscaled = NAN;
}
if (*phase_imag_unscaled == -32768) {
*phase_imag_unscaled = NAN;
}
*mag = sqrt(pow(*mag_real_unscaled, 2) + pow(*phase_imag_unscaled, 2));
*phase = atan2(*phase_imag_unscaled, *mag_real_unscaled);
/* for values in integer format, consider conversation factor */
if (block->cfg_frame_type == 3) {
*mag = (*mag * pi->conv_cfg3);
*phase = *phase - pi->angle_offset_cfg3;
}
else {
*mag = (*mag * pi->conv) * 0.00001;
}
*real = (*mag) * cos(*phase);
*imag = (*mag) * sin(*phase);
}
}
return floating_point == block->format_ph ? 8 : 4;
}
/* used by 'dissect_data_frame()' to dissect the PHASORS field */
static gint dissect_PHASORS(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset)
{
proto_tree *phasor_tree;
guint length;
gint j;
gint cnt = wmem_array_get_count(block->phasors); /* number of phasors to dissect */
if (0 == cnt)
return offset;
length = wmem_array_get_count(block->phasors) * (floating_point == block->format_ph ? 8 : 4);
phasor_tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_data_phasors, NULL,
"Phasors (%u), notation: %s, format: %s", cnt,
block->phasor_notation ? "polar" : "rectangular",
block->format_ph ? "floating point" : "integer");
/* dissect a phasor for every phasor_info saved in the config_block */
for (j = 0; j < cnt; j++) {
proto_item *temp_item;
gdouble mag, phase,real, imag;
gdouble mag_real_unscaled = NAN, phase_imag_unscaled = NAN;
phasor_info *pi;
pi = (phasor_info *)wmem_array_index(block->phasors, j);
temp_item = proto_tree_add_string_format(phasor_tree, hf_synphasor_phasor, tvb, offset,
floating_point == block->format_ph ? 8 : 4, pi->name,
"Phasor #%u: \"%s\"", j + 1, pi->name);
offset += dissect_single_phasor(tvb, offset,
&mag, &phase, &real, &imag,
&mag_real_unscaled, &phase_imag_unscaled,
block,pi);
#define SYNP_ANGLE "\xe2\x88\xa0" /* 8736 / 0x2220 */
char phasor_unit = V == pi->unit ? 'V' : 'A';
proto_item_append_text(temp_item, ", %10.3F%c " SYNP_ANGLE "%7.3F" UTF8_DEGREE_SIGN " alt %7.3F+j%7.3F%c",
mag, phasor_unit, phase * 180.0 / G_PI,
real, imag, phasor_unit);
if (integer == block->format_ph) {
proto_item_append_text(temp_item, "; unscaled: %5.0F, %5.0F",
mag_real_unscaled, phase_imag_unscaled);
}
#undef SYNP_ANGLE
}
return offset;
}
/* used by 'dissect_data_frame()' to dissect the FREQ and DFREQ fields */
static gint dissect_DFREQ(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset)
{
if (floating_point == block->format_fr) {
proto_tree_add_item(tree, hf_synphasor_actual_frequency_value, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
/* In new version of the standard IEEE Std C37.118.2-2011: "Can be 16-bit integer or IEEE floating point, same as FREQ above."
* --> no scaling factor is applied to DFREQ
*/
proto_tree_add_item(tree, hf_synphasor_rate_change_frequency, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
else {
gint16 tmp;
tmp = tvb_get_ntohs(tvb, offset);
proto_tree_add_int_format_value(tree, hf_synphasor_frequency_deviation_from_nominal, tvb, offset, 2, tmp,
"%dmHz (actual frequency: %.3fHz)", tmp, block->fnom + (tmp / 1000.0));
offset += 2;
tmp = tvb_get_ntohs(tvb, offset);
proto_tree_add_float_format_value(tree, hf_synphasor_rate_change_frequency, tvb, offset, 2, (gfloat)(tmp / 100.0), "%.3fHz/s", tmp / 100.0); offset += 2;
}
return offset;
}
/* used by 'dissect_data_frame()' to dissect the ANALOG field */
static gint dissect_ANALOG(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset)
{
proto_tree *analog_tree;
guint length;
gint j;
gint cnt = wmem_array_get_count(block->analogs); /* number of analog values to dissect */
if (0 == cnt)
return offset;
length = wmem_array_get_count(block->analogs) * (floating_point == block->format_an ? 4 : 2);
analog_tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_data_analog, NULL,
"Analog values (%u)", cnt);
for (j = 0; j < cnt; j++) {
proto_item *temp_item;
analog_info *ai = (analog_info *)wmem_array_index(block->analogs, j);
temp_item = proto_tree_add_string_format(analog_tree, hf_synphasor_analog_value, tvb, offset,
floating_point == block->format_an ? 4 : 2, ai->name,
"Analog value #%u: \"%s\"", j + 1, ai->name);
if (block->cfg_frame_type == 3)
{
if (floating_point == block->format_an) {
gfloat tmp;
tmp = tvb_get_ntohieee_float(tvb, offset);
offset += 4;
proto_item_append_text(temp_item, ", %.3f", tmp);
}
else {
/* the "standard" doesn't say if this is signed or unsigned,
* so I just use gint16 */
gint16 tmp_i;
gfloat tmp_f;
tmp_i = tvb_get_ntohs(tvb, offset);
offset += 2;
tmp_f = (tmp_i * ai->conv_cfg3) + ai->offset_cfg3;
proto_item_append_text(temp_item, ", %.3f", tmp_f);
}
}
else
{
if (floating_point == block->format_an) {
gfloat tmp = tvb_get_ntohieee_float(tvb, offset); offset += 4;
proto_item_append_text(temp_item, ", %.3f", tmp);
}
else {
/* the "standard" doesn't say if this is signed or unsigned,
* so I just use gint16; the scaling of the conversion factor
* is also "user defined", so I just write it after the analog value */
gint16 tmp = tvb_get_ntohs(tvb, offset); offset += 2;
proto_item_append_text(temp_item, ", %" PRId16 " (conversion factor: %#06x)",
tmp, ai->conv);
}
}
}
return offset;
}
/* used by 'dissect_data_frame()' to dissect the DIGITAL field */
static gint dissect_DIGITAL(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset)
{
gint j;
gint cnt = block->num_dg; /* number of digital status words to dissect */
if (0 == cnt)
return offset;
tree = proto_tree_add_subtree_format(tree, tvb, offset, cnt * 2, ett_data_digital, NULL,
"Digital status words (%u)", cnt);
for (j = 0; j < cnt; j++) {
guint16 tmp = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint_format(tree, hf_synphasor_digital_status_word, tvb, offset, 2, tmp, "Digital status word #%u: 0x%04x", j + 1, tmp);
offset += 2;
}
return offset;
}
/* used by 'dissect_config_frame()' to dissect the PHUNIT field */
static gint dissect_PHUNIT(tvbuff_t *tvb, proto_tree *tree, gint offset, gint cnt)
{
proto_tree *temp_tree;
gint i;
if (0 == cnt)
return offset;
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_phconv, NULL,
"Phasor conversion factors (%u)", cnt);
/* Conversion factor for phasor channels. Four bytes for each phasor.
* MSB: 0 = voltage, 1 = current
* Lower 3 Bytes: unsigned 24-bit word in 10^-5 V or A per bit to scale the phasor value
*/
for (i = 0; i < cnt; i++) {
guint32 tmp = tvb_get_ntohl(tvb, offset);
proto_tree_add_uint_format(temp_tree, hf_synphasor_conversion_factor, tvb, offset, 4,
tmp, "#%u factor: %u * 10^-5, unit: %s",
i + 1,
tmp & 0x00FFFFFF,
tmp & 0xFF000000 ? "Ampere" : "Volt");
offset += 4;
}
return offset;
}
/* used by 'dissect_config_3_frame()' to dissect the PHSCALE field */
static gint dissect_PHSCALE(tvbuff_t *tvb, proto_tree *tree, gint offset, gint cnt)
{
proto_tree *temp_tree;
gint i;
if (0 == cnt) {
return offset;
}
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 12 * cnt, ett_conf_phconv, NULL,
"Phasor scaling and data flags (%u)", cnt);
for (i = 0; i < cnt; i++) {
proto_tree *single_phasor_scaling_and_flags_tree;
proto_tree *phasor_flag1_tree;
proto_tree *phasor_flag2_tree;
proto_tree *data_flag_tree;
single_phasor_scaling_and_flags_tree = proto_tree_add_subtree_format(temp_tree, tvb, offset, 12,
ett_conf_phlist, NULL,
"Phasor #%u", i + 1);
data_flag_tree = proto_tree_add_subtree_format(single_phasor_scaling_and_flags_tree, tvb, offset, 4,
ett_conf_phflags, NULL, "Phasor Data flags: %s",
val_to_str_const(tvb_get_guint8(tvb, offset + 2), conf_phasor_type, "Unknown"));
/* first and second bytes - phasor modification flags*/
phasor_flag1_tree = proto_tree_add_subtree_format(data_flag_tree, tvb, offset, 2, ett_conf_phmod_flags,
NULL, "Modification Flags: 0x%04x",
tvb_get_ntohs(tvb, offset));
proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b15, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b10, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b09, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b08, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b07, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b06, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b05, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b04, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b03, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b02, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b01, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* third byte - phasor type*/
proto_tree_add_item(data_flag_tree, hf_conf_phasor_type_b03, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(data_flag_tree, hf_conf_phasor_type_b02to00, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
/* fourth byte - user designation*/
phasor_flag2_tree = proto_tree_add_subtree_format(data_flag_tree, tvb, offset, 1, ett_conf_ph_user_flags,
NULL, "User designated flags: 0x%02x",
tvb_get_guint8(tvb, offset));
proto_tree_add_item(phasor_flag2_tree, hf_conf_phasor_user_data, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
/* phasor scalefactor */
proto_tree_add_item(single_phasor_scaling_and_flags_tree, hf_conf_phasor_scale_factor,
tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
/* angle adjustment */
proto_tree_add_item(single_phasor_scaling_and_flags_tree, hf_conf_phasor_angle_offset,
tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
return offset;
}
/* used by 'dissect_config_frame()' to dissect the ANUNIT field */
static gint dissect_ANUNIT(tvbuff_t *tvb, proto_tree *tree, gint offset, gint cnt)
{
proto_item *temp_item;
proto_tree *temp_tree;
gint i;
if (0 == cnt)
return offset;
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_anconv, NULL,
"Analog values conversion factors (%u)", cnt);
/* Conversion factor for analog channels. Four bytes for each analog value.
* MSB: see 'synphasor_conf_anconvnames' in 'synphasor_strings.c'
* Lower 3 Bytes: signed 24-bit word, user-defined scaling
*/
for (i = 0; i < cnt; i++) {
gint32 tmp = tvb_get_ntohl(tvb, offset);
temp_item = proto_tree_add_uint_format(temp_tree, hf_synphasor_factor_for_analog_value, tvb, offset, 4,
tmp, "Factor for analog value #%i: %s",
i + 1,
try_rval_to_str((tmp >> 24) & 0x000000FF, conf_anconvnames));
tmp &= 0x00FFFFFF;
if ( tmp & 0x00800000) /* sign bit set */
tmp |= 0xFF000000;
proto_item_append_text(temp_item, ", value: %" PRId32, tmp);
offset += 4;
}
return offset;
}
/* used by 'dissect_config_3_frame()' to dissect the ANSCALE field */
static gint dissect_ANSCALE(tvbuff_t *tvb, proto_tree *tree, gint offset, gint cnt)
{
proto_tree *temp_tree;
gint i;
if (0 == cnt) {
return offset;
}
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 8 * cnt, ett_conf_anconv, NULL,
"Analog values conversion factors (%u)", cnt);
/* Conversion factor for analog channels. Four bytes for each analog value.
* MSB: see 'synphasor_conf_anconvnames' in 'synphasor_strings.c'
* Lower 3 Bytes: signed 24-bit word, user-defined scaling
*/
for (i = 0; i < cnt; i++) {
proto_tree *single_analog_scalefactor_tree;
single_analog_scalefactor_tree = proto_tree_add_subtree_format(temp_tree, tvb, offset, 8,
ett_conf_phlist, NULL,
"Analog #%u", i + 1);
/* analog scalefactor */
proto_tree_add_item(single_analog_scalefactor_tree, hf_conf_analog_scale_factor,
tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
/* angle adjustment */
proto_tree_add_item(single_analog_scalefactor_tree, hf_conf_analog_offset,
tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
return offset;
}
/* used by 'dissect_config_frame()' to dissect the DIGUNIT field */
static gint dissect_DIGUNIT(tvbuff_t *tvb, proto_tree *tree, gint offset, gint cnt)
{
proto_tree *temp_tree, *mask_tree;
gint i;
if (0 == cnt)
return offset;
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_dgmask, NULL,
"Masks for digital status words (%u)", cnt);
/* Mask words for digital status words. Two 16-bit words for each digital word. The first
* indicates the normal status of the inputs, the second indicated the valid bits in
* the status word
*/
for (i = 0; i < cnt; i++) {
mask_tree = proto_tree_add_subtree_format(temp_tree, tvb, offset, 4, ett_status_word_mask, NULL, "Mask for status word #%u: ", i + 1);
proto_tree_add_item(mask_tree, hf_synphasor_status_word_mask_normal_state, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
proto_tree_add_item(mask_tree, hf_synphasor_status_word_mask_valid_bits, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
}
return offset;
}
/* used by 'dissect_config_frame()' to dissect the "channel name"-fields */
static gint dissect_CHNAM(tvbuff_t *tvb, proto_tree *tree, gint offset, gint cnt, const char *prefix)
{
proto_tree *temp_tree;
gint i;
if (0 == cnt)
return offset;
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, CHNAM_LEN * cnt, ett_conf_phnam, NULL,
"%ss (%u)", prefix, cnt);
/* dissect the 'cnt' channel names */
for (i = 0; i < cnt; i++) {
char *str;
str = (char *)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, CHNAM_LEN, ENC_ASCII);
proto_tree_add_string_format(temp_tree, hf_synphasor_channel_name, tvb, offset, CHNAM_LEN,
str, "%s #%i: \"%s\"", prefix, i+1, str);
offset += CHNAM_LEN;
}
return offset;
}
/* used by 'dissect_config_3_frame()' to dissect the "channel name"-fields */
static gint dissect_config_3_CHNAM(tvbuff_t *tvb, proto_tree *tree, gint offset, gint cnt, const char *prefix)
{
proto_tree *temp_tree, *chnam_tree;
gint i;
guint8 name_length;
gint temp_offset;
gint subsection_length = 0;
if (0 == cnt) {
return offset;
}
/* get the subsection length */
temp_offset = offset;
for (i = 0; i < cnt; i++) {
name_length = get_name_length(tvb, temp_offset);
/* count the length byte and the actual name */
subsection_length += name_length + 1;
temp_offset += name_length + 1;
}
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, subsection_length, ett_conf_phnam,
NULL, "%ss (%u)", prefix, cnt);
/* dissect the 'cnt' channel names */
for (i = 0; i < cnt; i++) {
char *str;
name_length = get_name_length(tvb, offset);
str = (char *)tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, name_length, ENC_ASCII);
chnam_tree = proto_tree_add_subtree_format(temp_tree, tvb, offset, name_length + 1, ett_conf,
NULL, "%s #%i: \"%s\"", prefix, i + 1, str);
proto_tree_add_item(chnam_tree, hf_conf_chnam_len, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_string(chnam_tree, hf_conf_chnam, tvb, offset, 1, str);
offset += name_length;
}
return offset;
}
/* dissects a configuration frame (type 1 and 2) and adds fields to 'config_item' */
static int dissect_config_frame(tvbuff_t *tvb, proto_item *config_item)
{
proto_tree *config_tree;
gint offset = 0;
guint16 num_pmu, j;
proto_item_set_text (config_item, "Configuration data");
config_tree = proto_item_add_subtree(config_item, ett_conf);
/* TIME_BASE and NUM_PMU */
offset += 1; /* skip the reserved byte */
proto_tree_add_item(config_tree, hf_conf_timebase, tvb, offset, 3, ENC_BIG_ENDIAN); offset += 3;
proto_tree_add_item(config_tree, hf_conf_numpmu, tvb, offset, 2, ENC_BIG_ENDIAN);
/* add number of included PMUs to the text in the list view */
num_pmu = tvb_get_ntohs(tvb, offset); offset += 2;
proto_item_append_text(config_item, ", %"PRIu16" PMU(s) included", num_pmu);
/* dissect the repeating PMU blocks */
for (j = 0; j < num_pmu; j++) {
guint16 num_ph, num_an, num_dg;
proto_item *station_item;
proto_tree *station_tree;
proto_tree *temp_tree;
char *str;
gint oldoffset = offset; /* to calculate the length of the whole PMU block later */
/* STN with new tree to add the rest of the PMU block */
str = (char *)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, CHNAM_LEN, ENC_ASCII);
station_tree = proto_tree_add_subtree_format(config_tree, tvb, offset, CHNAM_LEN,
ett_conf_station, &station_item,
"Station #%i: \"%s\"", j + 1, str);
offset += CHNAM_LEN;
/* IDCODE */
proto_tree_add_item(station_tree, hf_idcode_data_source, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
/* FORMAT */
temp_tree = proto_tree_add_subtree(station_tree, tvb, offset, 2, ett_conf_format, NULL,
"Data format in data frame");
proto_tree_add_item(temp_tree, hf_conf_formatb3, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(temp_tree, hf_conf_formatb2, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(temp_tree, hf_conf_formatb1, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(temp_tree, hf_conf_formatb0, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* PHNMR, ANNMR, DGNMR */
num_ph = tvb_get_ntohs(tvb, offset );
num_an = tvb_get_ntohs(tvb, offset + 2);
num_dg = tvb_get_ntohs(tvb, offset + 4);
proto_tree_add_uint(station_tree, hf_synphasor_num_phasors, tvb, offset, 2, num_ph);
proto_tree_add_uint(station_tree, hf_synphasor_num_analog_values, tvb, offset + 2, 2, num_an);
proto_tree_add_uint(station_tree, hf_synphasor_num_digital_status_words, tvb, offset + 4, 2, num_dg);
offset += 6;
/* CHNAM, the channel names */
offset = dissect_CHNAM(tvb, station_tree, offset, num_ph , "Phasor name" );
offset = dissect_CHNAM(tvb, station_tree, offset, num_an , "Analog value" );
offset = dissect_CHNAM(tvb, station_tree, offset, num_dg * 16, "Digital status label");
/* PHUNIT, ANUINT and DIGUNIT */
offset = dissect_PHUNIT (tvb, station_tree, offset, num_ph);
offset = dissect_ANUNIT (tvb, station_tree, offset, num_an);
offset = dissect_DIGUNIT(tvb, station_tree, offset, num_dg);
/* FNOM and CFGCNT */
proto_tree_add_item(station_tree, hf_conf_fnom, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
proto_tree_add_item(station_tree, hf_conf_cfgcnt, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
/* set the correct length for the "Station :" item */
proto_item_set_len(station_item, offset - oldoffset);
} /* for() PMU blocks */
/* DATA_RATE */
{
gint16 tmp = tvb_get_ntohis(tvb, offset);
if (tmp > 0)
proto_tree_add_int_format_value(config_tree, hf_synphasor_rate_of_transmission, tvb, offset, 2, tmp,
"%d frame(s) per second", tmp);
else
proto_tree_add_int_format_value(config_tree, hf_synphasor_rate_of_transmission, tvb, offset, 2, tmp,
"1 frame per %d second(s)", (gint16)-tmp);
offset += 2;
}
return offset;
} /* dissect_config_frame() */
/* dissects a configuration frame type 3 and adds fields to 'config_item' */
static int dissect_config_3_frame(tvbuff_t *tvb, proto_item *config_item)
{
proto_tree *config_tree, *wgs84_tree;
gint offset = 0;
guint16 num_pmu, j;
proto_item_set_text(config_item, "Configuration data");
config_tree = proto_item_add_subtree(config_item, ett_conf);
/* CONT_IDX */
proto_tree_add_item(config_tree, hf_cont_idx, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* TIME_BASE and NUM_PMU */
offset += 1; /* skip the reserved byte */
proto_tree_add_item(config_tree, hf_conf_timebase, tvb, offset, 3, ENC_BIG_ENDIAN);
offset += 3;
proto_tree_add_item(config_tree, hf_conf_numpmu, tvb, offset, 2, ENC_BIG_ENDIAN);
/* add number of included PMUs to the text in the list view */
num_pmu = tvb_get_ntohs(tvb, offset);
offset += 2;
proto_item_append_text(config_item, ", %"PRIu16" PMU(s) included", num_pmu);
/* dissect the repeating PMU blocks */
for (j = 0; j < num_pmu; j++) {
guint16 num_ph, num_an, num_dg, i;
guint8 name_length;
gint oldoffset;
gfloat pmu_lat, pmu_long, pmu_elev;
proto_item *station_item;
proto_tree *station_tree;
proto_tree *temp_tree;
char *str, *service_class;
char *unspecified_location = "Unspecified Location";
guint8 g_pmu_id_array[G_PMU_ID_LEN];
oldoffset = offset; /* to calculate the length of the whole PMU block later */
/* STN with new tree to add the rest of the PMU block */
name_length = get_name_length(tvb, offset);
str = (char *)tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, name_length, ENC_ASCII);
station_tree = proto_tree_add_subtree_format(config_tree, tvb, offset, name_length + 1,
ett_conf_station, &station_item,
"Station #%i: \"%s\"", j + 1, str);
/* Station Name Length */
proto_tree_add_item(station_tree, hf_station_name_len, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
/* Station Name */
proto_tree_add_string(station_tree, hf_station_name, tvb, offset, 1, str);
offset += name_length;
/* IDCODE */
proto_tree_add_item(station_tree, hf_idcode_data_source, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* G_PMU_ID */
/* A 128 bit display as raw bytes */
for (i = 0; i < G_PMU_ID_LEN; i++) {
g_pmu_id_array[i] = tvb_get_guint8(tvb, offset + i);
}
proto_tree_add_bytes_format(station_tree, hf_g_pmu_id, tvb, offset, G_PMU_ID_LEN, 0,
"Global PMU ID (raw bytes): %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
g_pmu_id_array[0], g_pmu_id_array[1], g_pmu_id_array[2], g_pmu_id_array[3],
g_pmu_id_array[4], g_pmu_id_array[5], g_pmu_id_array[6], g_pmu_id_array[7],
g_pmu_id_array[8], g_pmu_id_array[9], g_pmu_id_array[10], g_pmu_id_array[11],
g_pmu_id_array[12], g_pmu_id_array[13], g_pmu_id_array[14], g_pmu_id_array[15]);
offset += G_PMU_ID_LEN;
/* FORMAT */
temp_tree = proto_tree_add_subtree(station_tree, tvb, offset, 2, ett_conf_format, NULL,
"Data format in data frame");
proto_tree_add_item(temp_tree, hf_conf_formatb3, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(temp_tree, hf_conf_formatb2, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(temp_tree, hf_conf_formatb1, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(temp_tree, hf_conf_formatb0, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* PHNMR, ANNMR, DGNMR */
num_ph = tvb_get_ntohs(tvb, offset );
num_an = tvb_get_ntohs(tvb, offset + 2);
num_dg = tvb_get_ntohs(tvb, offset + 4);
proto_tree_add_uint(station_tree, hf_synphasor_num_phasors, tvb, offset, 2, num_ph);
proto_tree_add_uint(station_tree, hf_synphasor_num_analog_values, tvb, offset + 2, 2, num_an);
proto_tree_add_uint(station_tree, hf_synphasor_num_digital_status_words, tvb, offset + 4, 2, num_dg);
offset += 6;
/* CHNAM, the channel names */
offset = dissect_config_3_CHNAM(tvb, station_tree, offset, num_ph, "Phasor name");
offset = dissect_config_3_CHNAM(tvb, station_tree, offset, num_an, "Analog value");
offset = dissect_config_3_CHNAM(tvb, station_tree, offset, num_dg * 16, "Digital label");
/* PHUNIT, ANUINT and DIGUNIT */
offset = dissect_PHSCALE(tvb, station_tree, offset, num_ph);
offset = dissect_ANSCALE(tvb, station_tree, offset, num_an);
offset = dissect_DIGUNIT(tvb, station_tree, offset, num_dg);
/* subtree for coordinate info*/
wgs84_tree = proto_tree_add_subtree_format(station_tree, tvb, offset, 12, ett_conf_wgs84, NULL,
"World Geodetic System 84 data");
/* preview latitude, longitude, and elevation values */
/* INFINITY is an unspecified location, otherwise use the actual float value */
pmu_lat = tvb_get_ntohieee_float(tvb, offset);
pmu_long = tvb_get_ntohieee_float(tvb, offset + 4);
pmu_elev = tvb_get_ntohieee_float(tvb, offset + 8);
/* PMU_LAT */
if (isinf(pmu_lat)) {
proto_tree_add_float_format_value(wgs84_tree, hf_conf_pmu_lat_unknown, tvb, offset,
4, INFINITY, "%s", unspecified_location);
}
else {
proto_tree_add_item(wgs84_tree, hf_conf_pmu_lat, tvb, offset, 4, ENC_BIG_ENDIAN);
}
offset += 4;
/* PMU_LON */
if (isinf(pmu_long)) {
proto_tree_add_float_format_value(wgs84_tree, hf_conf_pmu_lon_unknown, tvb, offset,
4, INFINITY, "%s", unspecified_location);
}
else {
proto_tree_add_item(wgs84_tree, hf_conf_pmu_lon, tvb, offset, 4, ENC_BIG_ENDIAN);
}
offset += 4;
/* PMU_ELEV */
if (isinf(pmu_elev)) {
proto_tree_add_float_format_value(wgs84_tree, hf_conf_pmu_elev_unknown, tvb, offset,
4, INFINITY, "%s", unspecified_location);
}
else {
proto_tree_add_item(wgs84_tree, hf_conf_pmu_elev, tvb, offset, 4, ENC_BIG_ENDIAN);
}
offset += 4;
/* SVC_CLASS */
service_class = (char *)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 1, ENC_ASCII);
if ((strcmp(service_class, "P") == 0) || (strcmp(service_class, "p") == 0)) {
proto_tree_add_string(station_tree, hf_conf_svc_class, tvb, offset, 1, "Protection");
}
else if ((strcmp(service_class, "M") == 0) || (strcmp(service_class, "m") == 0)) {
proto_tree_add_string(station_tree, hf_conf_svc_class, tvb, offset, 1, "Monitoring");
}
else {
proto_tree_add_string(station_tree, hf_conf_svc_class, tvb, offset, 1, "Unknown");
}
offset += 1;
/* WINDOW */
proto_tree_add_item(station_tree, hf_conf_window, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
/*GRP_DLY */
proto_tree_add_item(station_tree, hf_conf_grp_dly, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
/* FNOM and CFGCNT */
proto_tree_add_item(station_tree, hf_conf_fnom, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(station_tree, hf_conf_cfgcnt, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* set the correct length for the "Station :" item */
proto_item_set_len(station_item, offset - oldoffset);
} /* for() PMU blocks */
/* DATA_RATE */
{
gint16 tmp = tvb_get_ntohis(tvb, offset);
if (tmp > 0) {
proto_tree_add_int_format_value(config_tree, hf_synphasor_rate_of_transmission, tvb, offset, 2, tmp,
"%d frame(s) per second", tmp);
}
else {
proto_tree_add_int_format_value(config_tree, hf_synphasor_rate_of_transmission, tvb, offset, 2, tmp,
"1 frame per %d second(s)", (gint16)-tmp);
}
offset += 2;
}
return offset;
} /* dissect_config_3_frame() */
/* calculates the size (in bytes) of a data frame that the config_block describes */
#define SYNP_BLOCKSIZE(x) (2 /* STAT */ \
+ wmem_array_get_count((x).phasors) * (integer == (x).format_ph ? 4 : 8) /* PHASORS */ \
+ (integer == (x).format_fr ? 4 : 8) /* (D)FREQ */ \
+ wmem_array_get_count((x).analogs) * (integer == (x).format_an ? 2 : 4) /* ANALOG */ \
+ (x).num_dg * 2) /* DIGITAL */
/* Dissects a data frame */
static int dissect_data_frame(tvbuff_t *tvb,
proto_item *data_item, /* all items are placed beneath this item */
packet_info *pinfo) /* used to find the data from a CFG-2 or CFG-3 frame */
{
proto_tree *data_tree;
gint offset = 0;
guint i;
config_frame *conf;
proto_item_set_text(data_item, "Measurement data");
data_tree = proto_item_add_subtree(data_item, ett_data);
/* search for configuration information to dissect the frame */
{
gboolean config_found = FALSE;
conf = (config_frame *)p_get_proto_data(wmem_file_scope(), pinfo, proto_synphasor, 0);
if (conf) {
/* check if the size of the current frame is the
size of the frame the config_frame describes */
size_t reported_size = 0;
for (i = 0; i < wmem_array_get_count(conf->config_blocks); i++) {
config_block *block = (config_block*)wmem_array_index(conf->config_blocks, i);
reported_size += SYNP_BLOCKSIZE(*block);
}
if (tvb_reported_length(tvb) == reported_size) {
// Add link to CFG Frame
proto_item* item = proto_tree_add_uint(data_tree, hf_cfg_frame_num, tvb, 0,0, conf->fnum);
proto_item_set_generated(item);
config_found = TRUE;
}
}
if (!config_found) {
proto_item_append_text(data_item, ", no configuration frame found");
return 0;
}
}
/* dissect a PMU block for every config_block in the frame */
for (i = 0; i < wmem_array_get_count(conf->config_blocks); i++) {
config_block *block = (config_block*)wmem_array_index(conf->config_blocks, i);
proto_tree *block_tree = proto_tree_add_subtree_format(data_tree, tvb, offset, SYNP_BLOCKSIZE(*block),
ett_data_block, NULL,
"Station: \"%s\"", block->name);
/* STAT */
proto_tree *temp_tree = proto_tree_add_subtree(block_tree, tvb, offset, 2, ett_data_stat, NULL, "Flags");
proto_item *temp_item = proto_tree_add_item(temp_tree, hf_data_statb15to14, tvb, offset, 2, ENC_BIG_ENDIAN);
guint16 flag_bits = tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN) >> 14; // Get bits 15-14
if (flag_bits != 0) {
expert_add_info(pinfo, temp_item, &ei_synphasor_data_error);
}
temp_item = proto_tree_add_item(temp_tree, hf_data_statb13, tvb, offset, 2, ENC_BIG_ENDIAN);
flag_bits = tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN); // Get flag bits
if ((flag_bits >> 13)&1) { // Check 13 bit
expert_add_info(pinfo, temp_item, &ei_synphasor_pmu_not_sync);
}
proto_tree_add_item(temp_tree, hf_data_statb12, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(temp_tree, hf_data_statb11, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(temp_tree, hf_data_statb10, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(temp_tree, hf_data_statb09, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(temp_tree, hf_data_statb08to06, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(temp_tree, hf_data_statb05to04, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(temp_tree, hf_data_statb03to00, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* PHASORS, (D)FREQ, ANALOG, and DIGITAL */
offset = dissect_PHASORS(tvb, block_tree, block, offset);
offset = dissect_DFREQ (tvb, block_tree, block, offset);
offset = dissect_ANALOG (tvb, block_tree, block, offset);
offset = dissect_DIGITAL(tvb, block_tree, block, offset);
}
return offset;
} /* dissect_data_frame() */
/* Dissects a command frame and adds fields to config_item.
*
* 'pinfo' is used to add the type of command
* to the INFO column in the packet list.
*/
static int dissect_command_frame(tvbuff_t *tvb,
proto_item *command_item,
packet_info *pinfo)
{
proto_tree *command_tree;
guint tvbsize = tvb_reported_length(tvb);
const char *s;
proto_item_set_text(command_item, "Command data");
command_tree = proto_item_add_subtree(command_item, ett_command);
/* CMD */
proto_tree_add_item(command_tree, hf_command, tvb, 0, 2, ENC_BIG_ENDIAN);
s = rval_to_str_const(tvb_get_ntohs(tvb, 0), command_names, "invalid command");
col_append_str(pinfo->cinfo, COL_INFO, ", ");
col_append_str(pinfo->cinfo, COL_INFO, s);
if (tvbsize > 2) {
if (tvb_get_ntohs(tvb, 0) == 0x0008) {
/* Command: Extended Frame, the extra data is ok */
proto_item *ti = proto_tree_add_item(command_tree, hf_synphasor_extended_frame_data, tvb, 2, tvbsize - 2, ENC_NA);
if (tvbsize % 2)
expert_add_info(pinfo, ti, &ei_synphasor_extended_frame_data);
}
else
proto_tree_add_item(command_tree, hf_synphasor_unknown_data, tvb, 2, tvbsize - 2, ENC_NA);
}
return tvbsize;
} /* dissect_command_frame() */
/* Dissects the header (common to all types of frames) and then calls
* one of the subdissectors (declared above) for the rest of the frame.
*/
static int dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
guint8 frame_type;
guint16 crc;
guint tvbsize = tvb_reported_length(tvb);
/* some heuristics */
if (tvbsize < 17 /* 17 bytes = header frame with only a
NULL character, useless but valid */
|| tvb_get_guint8(tvb, 0) != 0xAA) /* every synchrophasor frame starts with 0xAA */
return 0;
/* write the protocol name to the info column */
col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTOCOL_SHORT_NAME);
frame_type = tvb_get_guint8(tvb, 1) >> 4;
col_add_str(pinfo->cinfo, COL_INFO, val_to_str_const(frame_type, typenames, "invalid packet type"));
/* CFG-2, CFG3, and DATA frames need special treatment during the first run:
* For CFG-2 & CFG-3 frames, a 'config_frame' struct is created to hold the
* information necessary to decode DATA frames. A pointer to this
* struct is saved in the conversation and is copied to the
* per-packet information if a DATA frame is dissected.
*/
if (!pinfo->fd->visited) {
if (CFG2 == frame_type &&
check_crc(tvb, &crc)) {
conversation_t *conversation;
/* fill the config_frame */
config_frame *frame = config_frame_fast(tvb);
frame->fnum = pinfo->num;
/* find a conversation, create a new one if none exists */
conversation = find_or_create_conversation(pinfo);
/* remove data from a previous CFG-2 frame, only
* the most recent configuration frame is relevant */
if (conversation_get_proto_data(conversation, proto_synphasor))
conversation_delete_proto_data(conversation, proto_synphasor);
conversation_add_proto_data(conversation, proto_synphasor, frame);
}
else if ((CFG3 == frame_type) && check_crc(tvb, &crc)) {
conversation_t *conversation;
config_frame *frame;
/* fill the config_frame */
frame = config_3_frame_fast(tvb);
frame->fnum = pinfo->num;
/* find a conversation, create a new one if none exists */
conversation = find_or_create_conversation(pinfo);
/* remove data from a previous CFG-3 frame, only
* the most recent configuration frame is relevant */
if (conversation_get_proto_data(conversation, proto_synphasor)) {
conversation_delete_proto_data(conversation, proto_synphasor);
}
conversation_add_proto_data(conversation, proto_synphasor, frame);
}
// Add conf to any frame for dissection fracsec
conversation_t *conversation = find_conversation_pinfo(pinfo, 0);
if (conversation) {
config_frame *conf = (config_frame *)conversation_get_proto_data(conversation, proto_synphasor);
/* no problem if 'conf' is NULL, the frame dissector checks this again */
p_add_proto_data(wmem_file_scope(), pinfo, proto_synphasor, 0, conf);
}
} /* if (!visited) */
{
proto_tree *synphasor_tree;
proto_item *temp_item;
proto_item *sub_item;
gint offset;
guint16 framesize;
tvbuff_t *sub_tvb;
gboolean crc_good;
temp_item = proto_tree_add_item(tree, proto_synphasor, tvb, 0, -1, ENC_NA);
proto_item_append_text(temp_item, ", %s", val_to_str_const(frame_type, typenames,
", invalid packet type"));
/* synphasor_tree is where from now on all new elements for this protocol get added */
synphasor_tree = proto_item_add_subtree(temp_item, ett_synphasor);
// Add pinfo for dissection fracsec
framesize = dissect_header(tvb, synphasor_tree, pinfo);
offset = 14; /* header is 14 bytes long */
/* check CRC, call appropriate subdissector for the rest of the frame if CRC is correct*/
sub_item = proto_tree_add_item(synphasor_tree, hf_synphasor_data, tvb, offset, tvbsize - 16, ENC_NA);
crc_good = check_crc(tvb, &crc);
proto_tree_add_checksum(synphasor_tree, tvb, tvbsize - 2, hf_synphasor_checksum, hf_synphasor_checksum_status, &ei_synphasor_checksum,
pinfo, crc16_x25_ccitt_tvb(tvb, tvb_get_ntohs(tvb, 2) - 2), ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
if (!crc_good) {
proto_item_append_text(sub_item, ", not dissected because of wrong checksum");
}
else {
/* create a new tvb to pass to the subdissector
'-16': length of header + 2 CRC bytes */
sub_tvb = tvb_new_subset_length_caplen(tvb, offset, tvbsize - 16, framesize - 16);
/* call subdissector */
switch (frame_type) {
case DATA:
dissect_data_frame(sub_tvb, sub_item, pinfo);
break;
case HEADER: /* no further dissection is done/needed */
proto_item_append_text(sub_item, "Header Frame");
break;
case CFG1:
case CFG2:
dissect_config_frame(sub_tvb, sub_item);
break;
case CMD:
dissect_command_frame(sub_tvb, sub_item, pinfo);
break;
case CFG3:
/* Note: The C37.118-2.2001 stanadard is vague on how to handle fragmented frames.
Until further clarification is given, fragmented frames with the CONT_IDX
are not supported. */
if (tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN) != 0) {
proto_item_append_text(sub_item, ", CFG-3 Fragmented Frame (Not Supported)");
}
else {
dissect_config_3_frame(sub_tvb, sub_item);
}
break;
default:
proto_item_append_text(sub_item, " of unknown type");
}
proto_item_append_text(temp_item, " [correct]");
}
/* remaining 2 bytes are the CRC */
}
return tvb_reported_length(tvb);
} /* dissect_common() */
/* called for synchrophasors over UDP */
static int dissect_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
return dissect_common(tvb, pinfo, tree, data);
}
/* callback for 'tcp_dissect_pdus()' to give it the length of the frame */
static guint get_pdu_length(packet_info *pinfo _U_, tvbuff_t *tvb,
int offset, void *data _U_)
{
return tvb_get_ntohs(tvb, offset + 2);
}
static int dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 4, get_pdu_length, dissect_common, data);
return tvb_reported_length(tvb);
}
/*******************************************************************/
/* after this line: Wireshark Register Routines */
/*******************************************************************/
/* Register Synchrophasor Protocol with Wireshark*/
void proto_register_synphasor(void)
{
static hf_register_info hf[] = {
/* Sync word */
{ &hf_sync,
{ "Synchronization word", "synphasor.sync", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
/* Flags in the Sync word */
{ &hf_sync_frtype,
{ "Frame Type", "synphasor.frtype", FT_UINT16, BASE_HEX,
VALS(typenames), 0x0070, NULL, HFILL }},
{ &hf_sync_version,
{ "Version", "synphasor.version", FT_UINT16, BASE_DEC,
VALS(versionnames), 0x000F, NULL, HFILL }},
{ &hf_frsize,
{ "Framesize", "synphasor.frsize", FT_UINT16, BASE_DEC | BASE_UNIT_STRING,
&units_byte_bytes, 0x0, NULL, HFILL }},
{ &hf_station_name_len,
{ "Station name length", "synphasor.station_name_len", FT_UINT8,
BASE_DEC | BASE_UNIT_STRING, &units_byte_bytes, 0x0, NULL, HFILL }},
{ &hf_station_name,
{ "Station name", "synphasor.station_name", FT_STRING, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_idcode_stream_source,
{ "PMU/DC ID number (Stream source ID)", "synphasor.idcode_stream_source", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_idcode_data_source,
{ "PMU/DC ID number (Data source ID)", "synphasor.idcode_data_source", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_g_pmu_id,
{ "Global PMU ID (raw hex bytes)", "synphasor.gpmuid", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_soc,
{ "SOC time stamp", "synphasor.soc", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC,
NULL, 0x0, NULL, HFILL }},
/* Time quality flags in fracsec */
{ &hf_timeqal_lsdir,
{ "Leap second direction", "synphasor.timeqal.lsdir", FT_BOOLEAN, 8,
TFS(&leapseconddir), 0x40, NULL, HFILL }},
{ &hf_timeqal_lsocc,
{ "Leap second occurred", "synphasor.timeqal.lsocc", FT_BOOLEAN, 8,
NULL, 0x20, NULL, HFILL }},
{ &hf_timeqal_lspend,
{ "Leap second pending", "synphasor.timeqal.lspend", FT_BOOLEAN, 8,
NULL, 0x10, NULL, HFILL }},
{ &hf_timeqal_timequalindic,
{ "Message Time Quality indicator code", "synphasor.timeqal.timequalindic", FT_UINT8, BASE_HEX,
VALS(timequalcodes), 0x0F, NULL, HFILL }},
/* Fraction of second */
{ &hf_fracsec_raw,
{ "Fraction of second (raw)", "synphasor.fracsec_raw", FT_UINT24, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_fracsec_ms,
{ "Fraction of second", "synphasor.fracsec_ms", FT_FLOAT, BASE_NONE | BASE_UNIT_STRING,
&units_millisecond_milliseconds, 0x0, NULL, HFILL }},
/* Data types for configuration frames */
{ &hf_cont_idx,
{ "Continuation index", "synphasor.conf.contindx", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_conf_timebase,
{ "Resolution of fractional second time stamp", "synphasor.conf.timebase", FT_UINT24, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_conf_numpmu,
{ "Number of PMU blocks included in the frame", "synphasor.conf.numpmu", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
/* Bits in the FORMAT word */
{ &hf_conf_formatb3,
{ "FREQ/DFREQ format", "synphasor.conf.dfreq_format", FT_BOOLEAN, 16,
TFS(&conf_formatb123names), 0x8, NULL, HFILL }},
{ &hf_conf_formatb2,
{ "Analog values format", "synphasor.conf.analog_format", FT_BOOLEAN, 16,
TFS(&conf_formatb123names), 0x4, NULL, HFILL }},
{ &hf_conf_formatb1,
{ "Phasor format", "synphasor.conf.phasor_format", FT_BOOLEAN, 16,
TFS(&conf_formatb123names), 0x2, NULL, HFILL }},
{ &hf_conf_formatb0,
{ "Phasor notation", "synphasor.conf.phasor_notation", FT_BOOLEAN, 16,
TFS(&conf_formatb0names), 0x1, NULL, HFILL }},
{ &hf_conf_chnam_len,
{ "Channel name length", "synphasor.conf.chnam_len", FT_UINT8,
BASE_DEC | BASE_UNIT_STRING, &units_byte_bytes, 0x0, NULL, HFILL }},
{ &hf_conf_chnam,
{ "Channel name", "synphasor.conf.chnam", FT_STRING, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_conf_phasor_mod_b15,
{ "Modification", "synphasor.conf.phasor_mod.type_not_def", FT_BOOLEAN, 16,
TFS(&conf_phasor_mod_b15), 0x8000, NULL, HFILL }},
{ &hf_conf_phasor_mod_b10,
{ "Modification", "synphasor.conf.phasor_mod.pseudo_phasor", FT_BOOLEAN, 16,
TFS(&conf_phasor_mod_b10), 0x0400, NULL, HFILL }},
{ &hf_conf_phasor_mod_b09,
{ "Modification", "synphasor.conf.phasor_mod.phase_rotation", FT_BOOLEAN, 16,
TFS(&conf_phasor_mod_b09), 0x0200, NULL, HFILL }},
{ &hf_conf_phasor_mod_b08,
{ "Modification", "synphasor.conf.phasor_mod.phase_calibration", FT_BOOLEAN, 16,
TFS(&conf_phasor_mod_b08), 0x0100, NULL, HFILL }},
{ &hf_conf_phasor_mod_b07,
{ "Modification", "synphasor.conf.phasor_mod.mag_calibration", FT_BOOLEAN, 16,
TFS(&conf_phasor_mod_b07), 0x0080, NULL, HFILL }},
{ &hf_conf_phasor_mod_b06,
{ "Modification", "synphasor.conf.phasor_mod.filtered", FT_BOOLEAN, 16,
TFS(&conf_phasor_mod_b06), 0x0040, NULL, HFILL }},
{ &hf_conf_phasor_mod_b05,
{ "Modification", "synphasor.conf.phasor_mod.downsampled", FT_BOOLEAN, 16,
TFS(&conf_phasor_mod_b05), 0x0020, NULL, HFILL }},
{ &hf_conf_phasor_mod_b04,
{ "Modification", "synphasor.conf.phasor_mod.downsampled_fir", FT_BOOLEAN, 16,
TFS(&conf_phasor_mod_b04), 0x0010, NULL, HFILL }},
{ &hf_conf_phasor_mod_b03,
{ "Modification", "synphasor.conf.phasor_mod.downsampled_reselect", FT_BOOLEAN, 16,
TFS(&conf_phasor_mod_b03), 0x0008, NULL, HFILL }},
{ &hf_conf_phasor_mod_b02,
{ "Modification", "synphasor.conf.phasor_mod.upsampled_extrapolation", FT_BOOLEAN, 16,
TFS(&conf_phasor_mod_b02), 0x0004, NULL, HFILL }},
{ &hf_conf_phasor_mod_b01,
{ "Modification", "synphasor.conf.phasor_mod.upsampled_interpolation", FT_BOOLEAN, 16,
TFS(&conf_phasor_mod_b01), 0x0002, NULL, HFILL }},
{ &hf_conf_phasor_type_b03,
{ "Phasor Type", "synphasor.conf.phasor_type", FT_BOOLEAN, 8,
TFS(&conf_phasor_type_b03), 0x8, NULL, HFILL }},
{ &hf_conf_phasor_type_b02to00,
{ "Phasor Type", "synphasor.conf.phasor_component", FT_UINT8, BASE_HEX,
VALS(conf_phasor_type_b02to00), 0x7, NULL, HFILL }},
{ &hf_conf_phasor_user_data,
{ "Binary format", "synphasor.conf.phasor_user_flags", FT_BOOLEAN, 8,
TFS(&conf_phasor_user_defined), 0xff, NULL, HFILL }},
{ &hf_conf_phasor_scale_factor,
{ "Phasor scale factor", "synphasor.conf.phasor_scale_factor", FT_FLOAT,
BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_conf_phasor_angle_offset,
{ "Phasor angle offset", "synphasor.conf.phasor_angle_offset", FT_FLOAT,
BASE_NONE | BASE_UNIT_STRING, &units_degree_degrees, 0x0, NULL, HFILL }},
{ &hf_conf_analog_scale_factor,
{ "Analog scale factor", "synphasor.conf.analog_scale_factor", FT_FLOAT,
BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_conf_analog_offset,
{ "Analog offset", "synphasor.conf.analog_offset", FT_FLOAT,
BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_conf_pmu_lat,
{ "PMU Latitude", "synphasor.conf.pmu_latitude", FT_FLOAT,
BASE_NONE | BASE_UNIT_STRING, &units_degree_degrees, 0x0, NULL, HFILL }},
{ &hf_conf_pmu_lon,
{ "PMU Longitude", "synphasor.conf.pmu_longitude", FT_FLOAT,
BASE_NONE | BASE_UNIT_STRING, &units_degree_degrees, 0x0, NULL, HFILL }},
{ &hf_conf_pmu_elev,
{ "PMU Elevation", "synphasor.conf.pmu_elevation", FT_FLOAT,
BASE_NONE | BASE_UNIT_STRING, &units_meter_meters, 0x0, NULL, HFILL }},
{ &hf_conf_pmu_lat_unknown,
{ "PMU Latitude", "synphasor.conf.pmu_latitude", FT_FLOAT, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_conf_pmu_lon_unknown,
{ "PMU Longitude", "synphasor.conf.pmu_longitude", FT_FLOAT, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_conf_pmu_elev_unknown,
{ "PMU Elevation", "synphasor.conf.pmu_elevation", FT_FLOAT, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_conf_svc_class,
{ "Service class", "synphasor.conf.svc_class", FT_STRING, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_conf_window,
{ "PM window length", "synphasor.conf.window", FT_UINT32,
BASE_DEC | BASE_UNIT_STRING, &units_microsecond_microseconds, 0x0, NULL, HFILL }},
{ &hf_conf_grp_dly,
{ "PM group delay", "synphasor.conf.grp_dly", FT_UINT32,
BASE_DEC | BASE_UNIT_STRING, &units_microsecond_microseconds, 0x0, NULL, HFILL }},
{ &hf_conf_fnom,
{ "Nominal line frequency", "synphasor.conf.fnom", FT_BOOLEAN, 16,
TFS(&conf_fnomnames), 0x0001, NULL, HFILL }},
{ &hf_conf_cfgcnt,
{ "Configuration change count", "synphasor.conf.cfgcnt", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
/* Data types for data frames */
/* Link to CFG Frame */
{ &hf_cfg_frame_num,
{ "Dissected using configuration from frame", "synphasor.data.conf_frame", FT_FRAMENUM, BASE_NONE, NULL, 0x0,"", HFILL }},
/* Flags in the STAT word */
{ &hf_data_statb15to14,
{ "Data error", "synphasor.data.status", FT_UINT16, BASE_HEX,
VALS(data_statb15to14names), 0xC000, NULL, HFILL }},
{ &hf_data_statb13,
{ "Time synchronized", "synphasor.data.sync", FT_BOOLEAN, 16,
TFS(&data_statb13names), 0x2000, NULL, HFILL }},
{ &hf_data_statb12,
{ "Data sorting", "synphasor.data.sorting", FT_BOOLEAN, 16,
TFS(&data_statb12names), 0x1000, NULL, HFILL }},
{ &hf_data_statb11,
{ "Trigger detected", "synphasor.data.trigger", FT_BOOLEAN, 16,
TFS(&data_statb11names), 0x0800, NULL, HFILL }},
{ &hf_data_statb10,
{ "Configuration changed", "synphasor.data.CFGchange", FT_BOOLEAN, 16,
TFS(&data_statb10names), 0x0400, NULL, HFILL }},
{ &hf_data_statb09,
{ "Data modified indicator", "synphasor.data.data_modified", FT_BOOLEAN, 16,
TFS(&data_statb09names), 0x0200, NULL, HFILL }},
{ &hf_data_statb08to06,
{ "PMU Time Quality", "synphasor.data.pmu_tq", FT_UINT16, BASE_HEX,
VALS(data_statb08to06names), 0x01C0, NULL, HFILL }},
{ &hf_data_statb05to04,
{ "Unlocked time", "synphasor.data.t_unlock", FT_UINT16, BASE_HEX,
VALS(data_statb05to04names), 0x0030, NULL, HFILL }},
{ &hf_data_statb03to00,
{ "Trigger reason", "synphasor.data.trigger_reason", FT_UINT16, BASE_HEX,
VALS(data_statb03to00names), 0x000F, NULL, HFILL }},
/* Data type for command frame */
{ &hf_command,
{ "Command", "synphasor.command", FT_UINT16, BASE_HEX|BASE_RANGE_STRING,
RVALS(command_names), 0x0, NULL, HFILL }},
/* Generated from convert_proto_tree_add_text.pl */
{ &hf_synphasor_data, { "Data", "synphasor.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_synphasor_checksum, { "Checksum", "synphasor.checksum", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_synphasor_checksum_status, { "Checksum Status", "synphasor.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0, NULL, HFILL }},
{ &hf_synphasor_num_phasors, { "Number of phasors", "synphasor.num_phasors", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_synphasor_num_analog_values, { "Number of analog values", "synphasor.num_analog_values", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_synphasor_num_digital_status_words, { "Number of digital status words", "synphasor.num_digital_status_words", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_synphasor_rate_of_transmission, { "Rate of transmission", "synphasor.rate_of_transmission", FT_INT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_synphasor_phasor, { "Phasor", "synphasor.phasor", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_synphasor_actual_frequency_value, { "Actual frequency value", "synphasor.actual_frequency_value", FT_FLOAT, BASE_NONE|BASE_UNIT_STRING, &units_hz, 0x0, NULL, HFILL }},
{ &hf_synphasor_rate_change_frequency, { "Rate of change of frequency", "synphasor.rate_change_frequency", FT_FLOAT, BASE_NONE|BASE_UNIT_STRING, &units_hz_s, 0x0, NULL, HFILL }},
{ &hf_synphasor_frequency_deviation_from_nominal, { "Frequency deviation from nominal", "synphasor.frequency_deviation_from_nominal", FT_INT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_synphasor_analog_value, { "Analog value", "synphasor.analog_value", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_synphasor_digital_status_word, { "Digital status word", "synphasor.digital_status_word", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_synphasor_conversion_factor, { "conversion factor", "synphasor.conversion_factor", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_synphasor_factor_for_analog_value, { "Factor for analog value", "synphasor.factor_for_analog_value", FT_UINT32, BASE_DEC, NULL, 0x000000FF, NULL, HFILL }},
{ &hf_synphasor_channel_name, { "Channel name", "synphasor.channel_name", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_synphasor_extended_frame_data, { "Extended frame data", "synphasor.extended_frame_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_synphasor_unknown_data, { "Unknown data", "synphasor.data.unknown", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_synphasor_status_word_mask_normal_state, { "Normal state", "synphasor.status_word_mask.normal_state", FT_UINT16, BASE_HEX, NULL, 0xFFFF, NULL, HFILL }},
{ &hf_synphasor_status_word_mask_valid_bits, { "Valid bits", "synphasor.status_word_mask.valid_bits", FT_UINT16, BASE_HEX, NULL, 0xFFFF, NULL, HFILL }},
};
/* protocol subtree array */
static gint *ett[] = {
&ett_synphasor,
&ett_frtype,
&ett_timequal,
&ett_conf,
&ett_conf_station,
&ett_conf_format,
&ett_conf_phnam,
&ett_conf_annam,
&ett_conf_dgnam,
&ett_conf_phconv,
&ett_conf_phlist,
&ett_conf_phflags,
&ett_conf_phmod_flags,
&ett_conf_ph_user_flags,
&ett_conf_anconv,
&ett_conf_anlist,
&ett_conf_dgmask,
&ett_conf_chnam,
&ett_conf_wgs84,
&ett_data,
&ett_data_block,
&ett_data_stat,
&ett_data_phasors,
&ett_data_analog,
&ett_data_digital,
&ett_command,
&ett_status_word_mask
};
static ei_register_info ei[] = {
{ &ei_synphasor_extended_frame_data, { "synphasor.extended_frame_data.unaligned", PI_PROTOCOL, PI_WARN, "Size not multiple of 16-bit word", EXPFILL }},
{ &ei_synphasor_checksum, { "synphasor.bad_checksum", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
{ &ei_synphasor_data_error, { "synphasor.data_error", PI_RESPONSE_CODE, PI_NOTE, "Data Error flag set", EXPFILL }},
{ &ei_synphasor_pmu_not_sync, { "synphasor.pmu_not_sync", PI_RESPONSE_CODE, PI_NOTE, "PMU not sync flag set", EXPFILL }},
};
expert_module_t* expert_synphasor;
/* register protocol */
proto_synphasor = proto_register_protocol(PROTOCOL_NAME,
PROTOCOL_SHORT_NAME,
PROTOCOL_ABBREV);
/* Registering protocol to be called by another dissector */
synphasor_udp_handle = register_dissector("synphasor", dissect_udp, proto_synphasor);
proto_register_field_array(proto_synphasor, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_synphasor = expert_register_protocol(proto_synphasor);
expert_register_field_array(expert_synphasor, ei, array_length(ei));
} /* proto_register_synphasor() */
/* called at startup and when the preferences change */
void proto_reg_handoff_synphasor(void)
{
dissector_handle_t synphasor_tcp_handle;
synphasor_tcp_handle = create_dissector_handle(dissect_tcp, proto_synphasor);
dissector_add_for_decode_as("rtacser.data", synphasor_udp_handle);
dissector_add_uint_with_preference("udp.port", SYNPHASOR_UDP_PORT, synphasor_udp_handle);
dissector_add_uint_with_preference("tcp.port", SYNPHASOR_TCP_PORT, synphasor_tcp_handle);
} /* proto_reg_handoff_synphasor() */
/*
* Editor modelines - https://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:
*/
|
C
|
wireshark/epan/dissectors/packet-sysdig-event.c
|
/* EDIT WITH CARE.
* Many sections of this file were automatically generated.
*/
/* packet-sysdig-event.c
* Routines for Sysdig event dissection
* http://www.sysdig.org/
* Copyright 2015, Gerald Combs <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
* Sysdig is a tool that captures and analyzes system state.
* This dissects pcapng Sysdig Event Blocks (0x00000204), which contains
* a system call entry or exit along with its associated parameters.
*/
/*
* To do:
* - Event with flags (0x00000208).
* - Enter/exit delay.
* - Most of this could be automatically generated from the Sysdig sources.
* - Alternatively we could modify Sysdig to dump its internal tables and
* generate a dissector from that output.
* - Generate the column info table.
* - Pull metainformation (processes, users, etc) into hash tables.
*/
#include <config.h>
#include <epan/packet.h>
#include <epan/strutil.h>
#include <wiretap/wtap.h>
/* #include <epan/expert.h> */
/* #include <epan/prefs.h> */
#define BLOCK_TYPE_SYSDIG_EVENT 0x00000204
#define BLOCK_TYPE_SYSDIG_EVENT_V2 0x00000216
#define BLOCK_TYPE_SYSDIG_EVENT_V2_LARGE 0x00000221
#define SYSDIG_PARAM_SIZE 2
#define SYSDIG_PARAM_SIZE_V2 2
#define SYSDIG_PARAM_SIZE_V2_LARGE 4
/* Prototypes */
void proto_reg_handoff_sysdig_event(void);
void proto_register_sysdig_event(void);
/* Initialize the protocol and registered fields */
static int proto_sysdig_event = -1;
/* Add byte order? */
static int hf_se_cpu_id = -1;
static int hf_se_thread_id = -1;
static int hf_se_event_length = -1;
static int hf_se_nparams = -1;
static int hf_se_event_type = -1;
static int hf_se_event_name = -1;
static int hf_se_param_lens = -1;
static int hf_se_param_len = -1;
/* Name+type */
/* Header fields. Automatically generated by tools/generate-sysdig-event.py */
static int hf_param_ID_uint16 = -1;
static int hf_param_action_uint32 = -1;
static int hf_param_addr_bytes = -1;
static int hf_param_addr_uint64 = -1;
static int hf_param_arg2_int_int64 = -1;
static int hf_param_arg2_str_string = -1;
static int hf_param_arg_uint64 = -1;
static int hf_param_args_string = -1;
static int hf_param_argument_uint64 = -1;
static int hf_param_aux_int32 = -1;
static int hf_param_backlog_int32 = -1;
static int hf_param_cap_effective_uint64 = -1;
static int hf_param_cap_inheritable_uint64 = -1;
static int hf_param_cap_permitted_uint64 = -1;
static int hf_param_cgroups_bytes = -1;
static int hf_param_clockid_uint8 = -1;
static int hf_param_cmd_bytes = -1;
static int hf_param_cmd_int16 = -1;
static int hf_param_cmd_int64 = -1;
static int hf_param_comm_string = -1;
static int hf_param_container_id_string = -1;
static int hf_param_core_uint8 = -1;
static int hf_param_cpu_sys_uint64 = -1;
static int hf_param_cpu_uint32 = -1;
static int hf_param_cpu_usr_uint64 = -1;
static int hf_param_cq_entries_uint32 = -1;
static int hf_param_cur_int64 = -1;
static int hf_param_cwd_string = -1;
static int hf_param_data_bytes = -1;
static int hf_param_desc_string = -1;
static int hf_param_description_string = -1;
static int hf_param_dev_string = -1;
static int hf_param_dev_uint32 = -1;
static int hf_param_dir_string = -1;
static int hf_param_dirfd_int64 = -1;
static int hf_param_domain_bytes = -1;
static int hf_param_dpid_int64 = -1;
static int hf_param_dqb_bhardlimit_uint64 = -1;
static int hf_param_dqb_bsoftlimit_uint64 = -1;
static int hf_param_dqb_btime_bytes = -1;
static int hf_param_dqb_curspace_uint64 = -1;
static int hf_param_dqb_ihardlimit_uint64 = -1;
static int hf_param_dqb_isoftlimit_uint64 = -1;
static int hf_param_dqb_itime_bytes = -1;
static int hf_param_dqi_bgrace_bytes = -1;
static int hf_param_dqi_flags_int8 = -1;
static int hf_param_dqi_igrace_bytes = -1;
static int hf_param_egid_int32 = -1;
static int hf_param_entries_uint32 = -1;
static int hf_param_env_string = -1;
static int hf_param_error_int32 = -1;
static int hf_param_euid_int32 = -1;
static int hf_param_event_data_bytes = -1;
static int hf_param_event_data_uint64 = -1;
static int hf_param_event_type_uint32 = -1;
static int hf_param_exe_ino_ctime_bytes = -1;
static int hf_param_exe_ino_mtime_bytes = -1;
static int hf_param_exe_ino_uint64 = -1;
static int hf_param_exe_string = -1;
static int hf_param_fd1_int64 = -1;
static int hf_param_fd2_int64 = -1;
static int hf_param_fd_in_int64 = -1;
static int hf_param_fd_int64 = -1;
static int hf_param_fd_out_int64 = -1;
static int hf_param_fdin_int64 = -1;
static int hf_param_fdlimit_int64 = -1;
static int hf_param_fdlimit_uint64 = -1;
static int hf_param_fdout_int64 = -1;
static int hf_param_fds_bytes = -1;
static int hf_param_features_int32 = -1;
static int hf_param_filename_string = -1;
static int hf_param_flags_int16 = -1;
static int hf_param_flags_int32 = -1;
static int hf_param_flags_int8 = -1;
static int hf_param_flags_uint32 = -1;
static int hf_param_gid_int32 = -1;
static int hf_param_gid_uint32 = -1;
static int hf_param_home_string = -1;
static int hf_param_how_bytes = -1;
static int hf_param_id_int64 = -1;
static int hf_param_id_string = -1;
static int hf_param_id_uint32 = -1;
static int hf_param_image_string = -1;
static int hf_param_img_bytes = -1;
static int hf_param_in_fd_int64 = -1;
static int hf_param_initval_uint64 = -1;
static int hf_param_ino_uint64 = -1;
static int hf_param_interval_bytes = -1;
static int hf_param_ip_uint64 = -1;
static int hf_param_json_string = -1;
static int hf_param_key_int32 = -1;
static int hf_param_key_string = -1;
static int hf_param_len_uint64 = -1;
static int hf_param_length_uint64 = -1;
static int hf_param_level_bytes = -1;
static int hf_param_linkdirfd_int64 = -1;
static int hf_param_linkpath_string = -1;
static int hf_param_loginuid_int32 = -1;
static int hf_param_mask_uint32 = -1;
static int hf_param_max_int64 = -1;
static int hf_param_maxevents_int64 = -1;
static int hf_param_min_complete_uint32 = -1;
static int hf_param_mode_int32 = -1;
static int hf_param_mode_uint32 = -1;
static int hf_param_mountfd_int64 = -1;
static int hf_param_name_string = -1;
static int hf_param_nativeID_uint16 = -1;
static int hf_param_newcur_int64 = -1;
static int hf_param_newdir_int64 = -1;
static int hf_param_newdirfd_int64 = -1;
static int hf_param_newfd_int64 = -1;
static int hf_param_newmax_int64 = -1;
static int hf_param_newpath_string = -1;
static int hf_param_next_int64 = -1;
static int hf_param_nr_args_uint32 = -1;
static int hf_param_nsems_int32 = -1;
static int hf_param_nsops_uint32 = -1;
static int hf_param_nstype_int32 = -1;
static int hf_param_offin_uint64 = -1;
static int hf_param_offout_uint64 = -1;
static int hf_param_offset_uint64 = -1;
static int hf_param_oldcur_int64 = -1;
static int hf_param_olddir_int64 = -1;
static int hf_param_olddirfd_int64 = -1;
static int hf_param_oldfd_int64 = -1;
static int hf_param_oldmax_int64 = -1;
static int hf_param_oldpath_string = -1;
static int hf_param_op_bytes = -1;
static int hf_param_op_uint64 = -1;
static int hf_param_opcode_bytes = -1;
static int hf_param_operation_int32 = -1;
static int hf_param_option_bytes = -1;
static int hf_param_optlen_uint32 = -1;
static int hf_param_optname_bytes = -1;
static int hf_param_out_fd_int64 = -1;
static int hf_param_path_string = -1;
static int hf_param_pathname_string = -1;
static int hf_param_peer_uint64 = -1;
static int hf_param_pgft_maj_uint64 = -1;
static int hf_param_pgft_min_uint64 = -1;
static int hf_param_pgid_int64 = -1;
static int hf_param_pgoffset_uint64 = -1;
static int hf_param_pid_fd_int64 = -1;
static int hf_param_pid_int64 = -1;
static int hf_param_pidns_init_start_ts_uint64 = -1;
static int hf_param_plugin_id_uint32 = -1;
static int hf_param_pos_uint64 = -1;
static int hf_param_prot_int32 = -1;
static int hf_param_proto_uint32 = -1;
static int hf_param_ptid_int64 = -1;
static int hf_param_queuelen_uint32 = -1;
static int hf_param_queuemax_uint32 = -1;
static int hf_param_queuepct_uint8 = -1;
static int hf_param_quota_fmt_int8 = -1;
static int hf_param_quota_fmt_out_int8 = -1;
static int hf_param_quotafilepath_string = -1;
static int hf_param_ratio_uint32 = -1;
static int hf_param_reaper_tid_int64 = -1;
static int hf_param_request_bytes = -1;
static int hf_param_request_uint64 = -1;
static int hf_param_res_int64 = -1;
static int hf_param_res_or_fd_bytes = -1;
static int hf_param_res_uint64 = -1;
static int hf_param_resolve_int32 = -1;
static int hf_param_resource_bytes = -1;
static int hf_param_ret_int64 = -1;
static int hf_param_rgid_int32 = -1;
static int hf_param_ruid_int32 = -1;
static int hf_param_scope_string = -1;
static int hf_param_sem_flg_0_int16 = -1;
static int hf_param_sem_flg_1_int16 = -1;
static int hf_param_sem_num_0_uint16 = -1;
static int hf_param_sem_num_1_uint16 = -1;
static int hf_param_sem_op_0_int16 = -1;
static int hf_param_sem_op_1_int16 = -1;
static int hf_param_semflg_int32 = -1;
static int hf_param_semid_int32 = -1;
static int hf_param_semnum_int32 = -1;
static int hf_param_sgid_int32 = -1;
static int hf_param_shell_string = -1;
static int hf_param_sig_bytes = -1;
static int hf_param_sigmask_bytes = -1;
static int hf_param_size_int32 = -1;
static int hf_param_size_uint32 = -1;
static int hf_param_size_uint64 = -1;
static int hf_param_source_string = -1;
static int hf_param_source_uint64 = -1;
static int hf_param_special_string = -1;
static int hf_param_spid_int64 = -1;
static int hf_param_sq_entries_uint32 = -1;
static int hf_param_sq_thread_cpu_uint32 = -1;
static int hf_param_sq_thread_idle_uint32 = -1;
static int hf_param_status_int64 = -1;
static int hf_param_suid_int32 = -1;
static int hf_param_tags_bytes = -1;
static int hf_param_target_fd_int64 = -1;
static int hf_param_target_string = -1;
static int hf_param_tid_int64 = -1;
static int hf_param_timeout_bytes = -1;
static int hf_param_timeout_int64 = -1;
static int hf_param_to_submit_uint32 = -1;
static int hf_param_tty_int32 = -1;
static int hf_param_tty_uint32 = -1;
static int hf_param_tuple_bytes = -1;
static int hf_param_type_int8 = -1;
static int hf_param_type_string = -1;
static int hf_param_type_uint32 = -1;
static int hf_param_uargs_string = -1;
static int hf_param_uid_int32 = -1;
static int hf_param_uid_uint32 = -1;
static int hf_param_val_bytes = -1;
static int hf_param_val_int32 = -1;
static int hf_param_val_uint64 = -1;
static int hf_param_value_bytebuf_bytes = -1;
static int hf_param_value_charbuf_string = -1;
static int hf_param_vm_rss_uint32 = -1;
static int hf_param_vm_size_uint32 = -1;
static int hf_param_vm_swap_uint32 = -1;
static int hf_param_vpid_int64 = -1;
static int hf_param_vtid_int64 = -1;
static int hf_param_whence_bytes = -1;
/* Initialize the subtree pointers */
static gint ett_sysdig_event = -1;
static gint ett_sysdig_parm_lens = -1;
static gint ett_sysdig_syscall = -1;
/* Initialize the pointer to the child plugin dissector */
static dissector_handle_t plugin_dissector_handle = NULL;
#define SYSDIG_EVENT_MIN_LENGTH 8 /* XXX Fix */
/* Event names. Automatically generated by tools/generate-sysdig-event.py */
#define EVT_STR_NA "NA"
#define EVT_STR_ACCEPT "accept"
#define EVT_STR_ACCEPT4 "accept4"
#define EVT_STR_ACCESS "access"
#define EVT_STR_ASYNCEVENT "asyncevent"
#define EVT_STR_BIND "bind"
#define EVT_STR_BPF "bpf"
#define EVT_STR_BRK "brk"
#define EVT_STR_CAPSET "capset"
#define EVT_STR_CHDIR "chdir"
#define EVT_STR_CHMOD "chmod"
#define EVT_STR_CHOWN "chown"
#define EVT_STR_CHROOT "chroot"
#define EVT_STR_CLONE "clone"
#define EVT_STR_CLONE3 "clone3"
#define EVT_STR_CLOSE "close"
#define EVT_STR_CONNECT "connect"
#define EVT_STR_CONTAINER "container"
#define EVT_STR_COPY_FILE_RANGE "copy_file_range"
#define EVT_STR_CPU_HOTPLUG "cpu_hotplug"
#define EVT_STR_CREAT "creat"
#define EVT_STR_DROP "drop"
#define EVT_STR_DUP "dup"
#define EVT_STR_DUP2 "dup2"
#define EVT_STR_DUP3 "dup3"
#define EVT_STR_EPOLL_CREATE "epoll_create"
#define EVT_STR_EPOLL_CREATE1 "epoll_create1"
#define EVT_STR_EPOLL_WAIT "epoll_wait"
#define EVT_STR_EVENTFD "eventfd"
#define EVT_STR_EVENTFD2 "eventfd2"
#define EVT_STR_EXECVE "execve"
#define EVT_STR_EXECVEAT "execveat"
#define EVT_STR_FCHDIR "fchdir"
#define EVT_STR_FCHMOD "fchmod"
#define EVT_STR_FCHMODAT "fchmodat"
#define EVT_STR_FCHOWN "fchown"
#define EVT_STR_FCHOWNAT "fchownat"
#define EVT_STR_FCNTL "fcntl"
#define EVT_STR_FINIT_MODULE "finit_module"
#define EVT_STR_FLOCK "flock"
#define EVT_STR_FORK "fork"
#define EVT_STR_FSCONFIG "fsconfig"
#define EVT_STR_FSTAT "fstat"
#define EVT_STR_FSTAT64 "fstat64"
#define EVT_STR_FUTEX "futex"
#define EVT_STR_GETCWD "getcwd"
#define EVT_STR_GETDENTS "getdents"
#define EVT_STR_GETDENTS64 "getdents64"
#define EVT_STR_GETEGID "getegid"
#define EVT_STR_GETEUID "geteuid"
#define EVT_STR_GETGID "getgid"
#define EVT_STR_GETPEERNAME "getpeername"
#define EVT_STR_GETRESGID "getresgid"
#define EVT_STR_GETRESUID "getresuid"
#define EVT_STR_GETRLIMIT "getrlimit"
#define EVT_STR_GETSOCKNAME "getsockname"
#define EVT_STR_GETSOCKOPT "getsockopt"
#define EVT_STR_GETUID "getuid"
#define EVT_STR_GROUPADDED "groupadded"
#define EVT_STR_GROUPDELETED "groupdeleted"
#define EVT_STR_INFRA "infra"
#define EVT_STR_INIT_MODULE "init_module"
#define EVT_STR_INOTIFY_INIT "inotify_init"
#define EVT_STR_INOTIFY_INIT1 "inotify_init1"
#define EVT_STR_IO_URING_ENTER "io_uring_enter"
#define EVT_STR_IO_URING_REGISTER "io_uring_register"
#define EVT_STR_IO_URING_SETUP "io_uring_setup"
#define EVT_STR_IOCTL "ioctl"
#define EVT_STR_K8S "k8s"
#define EVT_STR_KILL "kill"
#define EVT_STR_LCHOWN "lchown"
#define EVT_STR_LINK "link"
#define EVT_STR_LINKAT "linkat"
#define EVT_STR_LISTEN "listen"
#define EVT_STR_LLSEEK "llseek"
#define EVT_STR_LSEEK "lseek"
#define EVT_STR_LSTAT "lstat"
#define EVT_STR_LSTAT64 "lstat64"
#define EVT_STR_MEMFD_CREATE "memfd_create"
#define EVT_STR_MESOS "mesos"
#define EVT_STR_MKDIR "mkdir"
#define EVT_STR_MKDIRAT "mkdirat"
#define EVT_STR_MKNOD "mknod"
#define EVT_STR_MKNODAT "mknodat"
#define EVT_STR_MLOCK "mlock"
#define EVT_STR_MLOCK2 "mlock2"
#define EVT_STR_MLOCKALL "mlockall"
#define EVT_STR_MMAP "mmap"
#define EVT_STR_MMAP2 "mmap2"
#define EVT_STR_MOUNT "mount"
#define EVT_STR_MPROTECT "mprotect"
#define EVT_STR_MUNLOCK "munlock"
#define EVT_STR_MUNLOCKALL "munlockall"
#define EVT_STR_MUNMAP "munmap"
#define EVT_STR_NANOSLEEP "nanosleep"
#define EVT_STR_NOTIFICATION "notification"
#define EVT_STR_OPEN "open"
#define EVT_STR_OPEN_BY_HANDLE_AT "open_by_handle_at"
#define EVT_STR_OPENAT "openat"
#define EVT_STR_OPENAT2 "openat2"
#define EVT_STR_PAGE_FAULT "page_fault"
#define EVT_STR_PIDFD_GETFD "pidfd_getfd"
#define EVT_STR_PIDFD_OPEN "pidfd_open"
#define EVT_STR_PIPE "pipe"
#define EVT_STR_PIPE2 "pipe2"
#define EVT_STR_PLUGINEVENT "pluginevent"
#define EVT_STR_POLL "poll"
#define EVT_STR_PPOLL "ppoll"
#define EVT_STR_PRCTL "prctl"
#define EVT_STR_PREAD "pread"
#define EVT_STR_PREADV "preadv"
#define EVT_STR_PRLIMIT "prlimit"
#define EVT_STR_PROCEXIT "procexit"
#define EVT_STR_PROCINFO "procinfo"
#define EVT_STR_PTRACE "ptrace"
#define EVT_STR_PWRITE "pwrite"
#define EVT_STR_PWRITEV "pwritev"
#define EVT_STR_QUOTACTL "quotactl"
#define EVT_STR_READ "read"
#define EVT_STR_READV "readv"
#define EVT_STR_RECV "recv"
#define EVT_STR_RECVFROM "recvfrom"
#define EVT_STR_RECVMMSG "recvmmsg"
#define EVT_STR_RECVMSG "recvmsg"
#define EVT_STR_RENAME "rename"
#define EVT_STR_RENAMEAT "renameat"
#define EVT_STR_RENAMEAT2 "renameat2"
#define EVT_STR_RMDIR "rmdir"
#define EVT_STR_SCAPEVENT "scapevent"
#define EVT_STR_SECCOMP "seccomp"
#define EVT_STR_SELECT "select"
#define EVT_STR_SEMCTL "semctl"
#define EVT_STR_SEMGET "semget"
#define EVT_STR_SEMOP "semop"
#define EVT_STR_SEND "send"
#define EVT_STR_SENDFILE "sendfile"
#define EVT_STR_SENDMMSG "sendmmsg"
#define EVT_STR_SENDMSG "sendmsg"
#define EVT_STR_SENDTO "sendto"
#define EVT_STR_SETGID "setgid"
#define EVT_STR_SETNS "setns"
#define EVT_STR_SETPGID "setpgid"
#define EVT_STR_SETRESGID "setresgid"
#define EVT_STR_SETRESUID "setresuid"
#define EVT_STR_SETRLIMIT "setrlimit"
#define EVT_STR_SETSID "setsid"
#define EVT_STR_SETSOCKOPT "setsockopt"
#define EVT_STR_SETUID "setuid"
#define EVT_STR_SHUTDOWN "shutdown"
#define EVT_STR_SIGNALDELIVER "signaldeliver"
#define EVT_STR_SIGNALFD "signalfd"
#define EVT_STR_SIGNALFD4 "signalfd4"
#define EVT_STR_SOCKET "socket"
#define EVT_STR_SOCKETPAIR "socketpair"
#define EVT_STR_SPLICE "splice"
#define EVT_STR_STAT "stat"
#define EVT_STR_STAT64 "stat64"
#define EVT_STR_SWITCH "switch"
#define EVT_STR_SYMLINK "symlink"
#define EVT_STR_SYMLINKAT "symlinkat"
#define EVT_STR_SYSCALL "syscall"
#define EVT_STR_TGKILL "tgkill"
#define EVT_STR_TIMERFD_CREATE "timerfd_create"
#define EVT_STR_TKILL "tkill"
#define EVT_STR_TRACER "tracer"
#define EVT_STR_UMOUNT "umount"
#define EVT_STR_UMOUNT2 "umount2"
#define EVT_STR_UNLINK "unlink"
#define EVT_STR_UNLINKAT "unlinkat"
#define EVT_STR_UNSHARE "unshare"
#define EVT_STR_USERADDED "useradded"
#define EVT_STR_USERDELETED "userdeleted"
#define EVT_STR_USERFAULTFD "userfaultfd"
#define EVT_STR_VFORK "vfork"
#define EVT_STR_WRITE "write"
#define EVT_STR_WRITEV "writev"
/* EVT_... = PPME_... */
/* Event definitions. Automatically generated by tools/generate-sysdig-event.py */
#define EVT_GENERIC_E 0
#define EVT_GENERIC_X 1
#define EVT_SYSCALL_OPEN_E 2
#define EVT_SYSCALL_OPEN_X 3
#define EVT_SYSCALL_CLOSE_E 4
#define EVT_SYSCALL_CLOSE_X 5
#define EVT_SYSCALL_READ_E 6
#define EVT_SYSCALL_READ_X 7
#define EVT_SYSCALL_WRITE_E 8
#define EVT_SYSCALL_WRITE_X 9
#define EVT_SYSCALL_BRK_1_E 10
#define EVT_SYSCALL_BRK_1_X 11
#define EVT_SYSCALL_EXECVE_8_E 12
#define EVT_SYSCALL_EXECVE_8_X 13
#define EVT_SYSCALL_CLONE_11_E 14
#define EVT_SYSCALL_CLONE_11_X 15
#define EVT_PROCEXIT_E 16
#define EVT_PROCEXIT_X 17
#define EVT_SOCKET_SOCKET_E 18
#define EVT_SOCKET_SOCKET_X 19
#define EVT_SOCKET_BIND_E 20
#define EVT_SOCKET_BIND_X 21
#define EVT_SOCKET_CONNECT_E 22
#define EVT_SOCKET_CONNECT_X 23
#define EVT_SOCKET_LISTEN_E 24
#define EVT_SOCKET_LISTEN_X 25
#define EVT_SOCKET_ACCEPT_E 26
#define EVT_SOCKET_ACCEPT_X 27
#define EVT_SOCKET_SEND_E 28
#define EVT_SOCKET_SEND_X 29
#define EVT_SOCKET_SENDTO_E 30
#define EVT_SOCKET_SENDTO_X 31
#define EVT_SOCKET_RECV_E 32
#define EVT_SOCKET_RECV_X 33
#define EVT_SOCKET_RECVFROM_E 34
#define EVT_SOCKET_RECVFROM_X 35
#define EVT_SOCKET_SHUTDOWN_E 36
#define EVT_SOCKET_SHUTDOWN_X 37
#define EVT_SOCKET_GETSOCKNAME_E 38
#define EVT_SOCKET_GETSOCKNAME_X 39
#define EVT_SOCKET_GETPEERNAME_E 40
#define EVT_SOCKET_GETPEERNAME_X 41
#define EVT_SOCKET_SOCKETPAIR_E 42
#define EVT_SOCKET_SOCKETPAIR_X 43
#define EVT_SOCKET_SETSOCKOPT_E 44
#define EVT_SOCKET_SETSOCKOPT_X 45
#define EVT_SOCKET_GETSOCKOPT_E 46
#define EVT_SOCKET_GETSOCKOPT_X 47
#define EVT_SOCKET_SENDMSG_E 48
#define EVT_SOCKET_SENDMSG_X 49
#define EVT_SOCKET_SENDMMSG_E 50
#define EVT_SOCKET_SENDMMSG_X 51
#define EVT_SOCKET_RECVMSG_E 52
#define EVT_SOCKET_RECVMSG_X 53
#define EVT_SOCKET_RECVMMSG_E 54
#define EVT_SOCKET_RECVMMSG_X 55
#define EVT_SOCKET_ACCEPT4_E 56
#define EVT_SOCKET_ACCEPT4_X 57
#define EVT_SYSCALL_CREAT_E 58
#define EVT_SYSCALL_CREAT_X 59
#define EVT_SYSCALL_PIPE_E 60
#define EVT_SYSCALL_PIPE_X 61
#define EVT_SYSCALL_EVENTFD_E 62
#define EVT_SYSCALL_EVENTFD_X 63
#define EVT_SYSCALL_FUTEX_E 64
#define EVT_SYSCALL_FUTEX_X 65
#define EVT_SYSCALL_STAT_E 66
#define EVT_SYSCALL_STAT_X 67
#define EVT_SYSCALL_LSTAT_E 68
#define EVT_SYSCALL_LSTAT_X 69
#define EVT_SYSCALL_FSTAT_E 70
#define EVT_SYSCALL_FSTAT_X 71
#define EVT_SYSCALL_STAT64_E 72
#define EVT_SYSCALL_STAT64_X 73
#define EVT_SYSCALL_LSTAT64_E 74
#define EVT_SYSCALL_LSTAT64_X 75
#define EVT_SYSCALL_FSTAT64_E 76
#define EVT_SYSCALL_FSTAT64_X 77
#define EVT_SYSCALL_EPOLLWAIT_E 78
#define EVT_SYSCALL_EPOLLWAIT_X 79
#define EVT_SYSCALL_POLL_E 80
#define EVT_SYSCALL_POLL_X 81
#define EVT_SYSCALL_SELECT_E 82
#define EVT_SYSCALL_SELECT_X 83
#define EVT_SYSCALL_NEWSELECT_E 84
#define EVT_SYSCALL_NEWSELECT_X 85
#define EVT_SYSCALL_LSEEK_E 86
#define EVT_SYSCALL_LSEEK_X 87
#define EVT_SYSCALL_LLSEEK_E 88
#define EVT_SYSCALL_LLSEEK_X 89
#define EVT_SYSCALL_IOCTL_2_E 90
#define EVT_SYSCALL_IOCTL_2_X 91
#define EVT_SYSCALL_GETCWD_E 92
#define EVT_SYSCALL_GETCWD_X 93
#define EVT_SYSCALL_CHDIR_E 94
#define EVT_SYSCALL_CHDIR_X 95
#define EVT_SYSCALL_FCHDIR_E 96
#define EVT_SYSCALL_FCHDIR_X 97
#define EVT_SYSCALL_MKDIR_E 98
#define EVT_SYSCALL_MKDIR_X 99
#define EVT_SYSCALL_RMDIR_E 100
#define EVT_SYSCALL_RMDIR_X 101
#define EVT_SYSCALL_OPENAT_E 102
#define EVT_SYSCALL_OPENAT_X 103
#define EVT_SYSCALL_LINK_E 104
#define EVT_SYSCALL_LINK_X 105
#define EVT_SYSCALL_LINKAT_E 106
#define EVT_SYSCALL_LINKAT_X 107
#define EVT_SYSCALL_UNLINK_E 108
#define EVT_SYSCALL_UNLINK_X 109
#define EVT_SYSCALL_UNLINKAT_E 110
#define EVT_SYSCALL_UNLINKAT_X 111
#define EVT_SYSCALL_PREAD_E 112
#define EVT_SYSCALL_PREAD_X 113
#define EVT_SYSCALL_PWRITE_E 114
#define EVT_SYSCALL_PWRITE_X 115
#define EVT_SYSCALL_READV_E 116
#define EVT_SYSCALL_READV_X 117
#define EVT_SYSCALL_WRITEV_E 118
#define EVT_SYSCALL_WRITEV_X 119
#define EVT_SYSCALL_PREADV_E 120
#define EVT_SYSCALL_PREADV_X 121
#define EVT_SYSCALL_PWRITEV_E 122
#define EVT_SYSCALL_PWRITEV_X 123
#define EVT_SYSCALL_DUP_E 124
#define EVT_SYSCALL_DUP_X 125
#define EVT_SYSCALL_SIGNALFD_E 126
#define EVT_SYSCALL_SIGNALFD_X 127
#define EVT_SYSCALL_KILL_E 128
#define EVT_SYSCALL_KILL_X 129
#define EVT_SYSCALL_TKILL_E 130
#define EVT_SYSCALL_TKILL_X 131
#define EVT_SYSCALL_TGKILL_E 132
#define EVT_SYSCALL_TGKILL_X 133
#define EVT_SYSCALL_NANOSLEEP_E 134
#define EVT_SYSCALL_NANOSLEEP_X 135
#define EVT_SYSCALL_TIMERFD_CREATE_E 136
#define EVT_SYSCALL_TIMERFD_CREATE_X 137
#define EVT_SYSCALL_INOTIFY_INIT_E 138
#define EVT_SYSCALL_INOTIFY_INIT_X 139
#define EVT_SYSCALL_GETRLIMIT_E 140
#define EVT_SYSCALL_GETRLIMIT_X 141
#define EVT_SYSCALL_SETRLIMIT_E 142
#define EVT_SYSCALL_SETRLIMIT_X 143
#define EVT_SYSCALL_PRLIMIT_E 144
#define EVT_SYSCALL_PRLIMIT_X 145
#define EVT_SCHEDSWITCH_1_E 146
#define EVT_SCHEDSWITCH_1_X 147
#define EVT_DROP_E 148
#define EVT_DROP_X 149
#define EVT_SYSCALL_FCNTL_E 150
#define EVT_SYSCALL_FCNTL_X 151
#define EVT_SCHEDSWITCH_6_E 152
#define EVT_SCHEDSWITCH_6_X 153
#define EVT_SYSCALL_EXECVE_13_E 154
#define EVT_SYSCALL_EXECVE_13_X 155
#define EVT_SYSCALL_CLONE_16_E 156
#define EVT_SYSCALL_CLONE_16_X 157
#define EVT_SYSCALL_BRK_4_E 158
#define EVT_SYSCALL_BRK_4_X 159
#define EVT_SYSCALL_MMAP_E 160
#define EVT_SYSCALL_MMAP_X 161
#define EVT_SYSCALL_MMAP2_E 162
#define EVT_SYSCALL_MMAP2_X 163
#define EVT_SYSCALL_MUNMAP_E 164
#define EVT_SYSCALL_MUNMAP_X 165
#define EVT_SYSCALL_SPLICE_E 166
#define EVT_SYSCALL_SPLICE_X 167
#define EVT_SYSCALL_PTRACE_E 168
#define EVT_SYSCALL_PTRACE_X 169
#define EVT_SYSCALL_IOCTL_3_E 170
#define EVT_SYSCALL_IOCTL_3_X 171
#define EVT_SYSCALL_EXECVE_14_E 172
#define EVT_SYSCALL_EXECVE_14_X 173
#define EVT_SYSCALL_RENAME_E 174
#define EVT_SYSCALL_RENAME_X 175
#define EVT_SYSCALL_RENAMEAT_E 176
#define EVT_SYSCALL_RENAMEAT_X 177
#define EVT_SYSCALL_SYMLINK_E 178
#define EVT_SYSCALL_SYMLINK_X 179
#define EVT_SYSCALL_SYMLINKAT_E 180
#define EVT_SYSCALL_SYMLINKAT_X 181
#define EVT_SYSCALL_FORK_E 182
#define EVT_SYSCALL_FORK_X 183
#define EVT_SYSCALL_VFORK_E 184
#define EVT_SYSCALL_VFORK_X 185
#define EVT_PROCEXIT_1_E 186
#define EVT_PROCEXIT_1_X 187
#define EVT_SYSCALL_SENDFILE_E 188
#define EVT_SYSCALL_SENDFILE_X 189
#define EVT_SYSCALL_QUOTACTL_E 190
#define EVT_SYSCALL_QUOTACTL_X 191
#define EVT_SYSCALL_SETRESUID_E 192
#define EVT_SYSCALL_SETRESUID_X 193
#define EVT_SYSCALL_SETRESGID_E 194
#define EVT_SYSCALL_SETRESGID_X 195
#define EVT_SCAPEVENT_E 196
#define EVT_SCAPEVENT_X 197
#define EVT_SYSCALL_SETUID_E 198
#define EVT_SYSCALL_SETUID_X 199
#define EVT_SYSCALL_SETGID_E 200
#define EVT_SYSCALL_SETGID_X 201
#define EVT_SYSCALL_GETUID_E 202
#define EVT_SYSCALL_GETUID_X 203
#define EVT_SYSCALL_GETEUID_E 204
#define EVT_SYSCALL_GETEUID_X 205
#define EVT_SYSCALL_GETGID_E 206
#define EVT_SYSCALL_GETGID_X 207
#define EVT_SYSCALL_GETEGID_E 208
#define EVT_SYSCALL_GETEGID_X 209
#define EVT_SYSCALL_GETRESUID_E 210
#define EVT_SYSCALL_GETRESUID_X 211
#define EVT_SYSCALL_GETRESGID_E 212
#define EVT_SYSCALL_GETRESGID_X 213
#define EVT_SYSCALL_EXECVE_15_E 214
#define EVT_SYSCALL_EXECVE_15_X 215
#define EVT_SYSCALL_CLONE_17_E 216
#define EVT_SYSCALL_CLONE_17_X 217
#define EVT_SYSCALL_FORK_17_E 218
#define EVT_SYSCALL_FORK_17_X 219
#define EVT_SYSCALL_VFORK_17_E 220
#define EVT_SYSCALL_VFORK_17_X 221
#define EVT_SYSCALL_CLONE_20_E 222
#define EVT_SYSCALL_CLONE_20_X 223
#define EVT_SYSCALL_FORK_20_E 224
#define EVT_SYSCALL_FORK_20_X 225
#define EVT_SYSCALL_VFORK_20_E 226
#define EVT_SYSCALL_VFORK_20_X 227
#define EVT_CONTAINER_E 228
#define EVT_CONTAINER_X 229
#define EVT_SYSCALL_EXECVE_16_E 230
#define EVT_SYSCALL_EXECVE_16_X 231
#define EVT_SIGNALDELIVER_E 232
#define EVT_SIGNALDELIVER_X 233
#define EVT_PROCINFO_E 234
#define EVT_PROCINFO_X 235
#define EVT_SYSCALL_GETDENTS_E 236
#define EVT_SYSCALL_GETDENTS_X 237
#define EVT_SYSCALL_GETDENTS64_E 238
#define EVT_SYSCALL_GETDENTS64_X 239
#define EVT_SYSCALL_SETNS_E 240
#define EVT_SYSCALL_SETNS_X 241
#define EVT_SYSCALL_FLOCK_E 242
#define EVT_SYSCALL_FLOCK_X 243
#define EVT_CPU_HOTPLUG_E 244
#define EVT_CPU_HOTPLUG_X 245
#define EVT_SOCKET_ACCEPT_5_E 246
#define EVT_SOCKET_ACCEPT_5_X 247
#define EVT_SOCKET_ACCEPT4_5_E 248
#define EVT_SOCKET_ACCEPT4_5_X 249
#define EVT_SYSCALL_SEMOP_E 250
#define EVT_SYSCALL_SEMOP_X 251
#define EVT_SYSCALL_SEMCTL_E 252
#define EVT_SYSCALL_SEMCTL_X 253
#define EVT_SYSCALL_PPOLL_E 254
#define EVT_SYSCALL_PPOLL_X 255
#define EVT_SYSCALL_MOUNT_E 256
#define EVT_SYSCALL_MOUNT_X 257
#define EVT_SYSCALL_UMOUNT_E 258
#define EVT_SYSCALL_UMOUNT_X 259
#define EVT_K8S_E 260
#define EVT_K8S_X 261
#define EVT_SYSCALL_SEMGET_E 262
#define EVT_SYSCALL_SEMGET_X 263
#define EVT_SYSCALL_ACCESS_E 264
#define EVT_SYSCALL_ACCESS_X 265
#define EVT_SYSCALL_CHROOT_E 266
#define EVT_SYSCALL_CHROOT_X 267
#define EVT_TRACER_E 268
#define EVT_TRACER_X 269
#define EVT_MESOS_E 270
#define EVT_MESOS_X 271
#define EVT_CONTAINER_JSON_E 272
#define EVT_CONTAINER_JSON_X 273
#define EVT_SYSCALL_SETSID_E 274
#define EVT_SYSCALL_SETSID_X 275
#define EVT_SYSCALL_MKDIR_2_E 276
#define EVT_SYSCALL_MKDIR_2_X 277
#define EVT_SYSCALL_RMDIR_2_E 278
#define EVT_SYSCALL_RMDIR_2_X 279
#define EVT_NOTIFICATION_E 280
#define EVT_NOTIFICATION_X 281
#define EVT_SYSCALL_EXECVE_17_E 282
#define EVT_SYSCALL_EXECVE_17_X 283
#define EVT_SYSCALL_UNSHARE_E 284
#define EVT_SYSCALL_UNSHARE_X 285
#define EVT_INFRASTRUCTURE_EVENT_E 286
#define EVT_INFRASTRUCTURE_EVENT_X 287
#define EVT_SYSCALL_EXECVE_18_E 288
#define EVT_SYSCALL_EXECVE_18_X 289
#define EVT_PAGE_FAULT_E 290
#define EVT_PAGE_FAULT_X 291
#define EVT_SYSCALL_EXECVE_19_E 292
#define EVT_SYSCALL_EXECVE_19_X 293
#define EVT_SYSCALL_SETPGID_E 294
#define EVT_SYSCALL_SETPGID_X 295
#define EVT_SYSCALL_BPF_E 296
#define EVT_SYSCALL_BPF_X 297
#define EVT_SYSCALL_SECCOMP_E 298
#define EVT_SYSCALL_SECCOMP_X 299
#define EVT_SYSCALL_UNLINK_2_E 300
#define EVT_SYSCALL_UNLINK_2_X 301
#define EVT_SYSCALL_UNLINKAT_2_E 302
#define EVT_SYSCALL_UNLINKAT_2_X 303
#define EVT_SYSCALL_MKDIRAT_E 304
#define EVT_SYSCALL_MKDIRAT_X 305
#define EVT_SYSCALL_OPENAT_2_E 306
#define EVT_SYSCALL_OPENAT_2_X 307
#define EVT_SYSCALL_LINK_2_E 308
#define EVT_SYSCALL_LINK_2_X 309
#define EVT_SYSCALL_LINKAT_2_E 310
#define EVT_SYSCALL_LINKAT_2_X 311
#define EVT_SYSCALL_FCHMODAT_E 312
#define EVT_SYSCALL_FCHMODAT_X 313
#define EVT_SYSCALL_CHMOD_E 314
#define EVT_SYSCALL_CHMOD_X 315
#define EVT_SYSCALL_FCHMOD_E 316
#define EVT_SYSCALL_FCHMOD_X 317
#define EVT_SYSCALL_RENAMEAT2_E 318
#define EVT_SYSCALL_RENAMEAT2_X 319
#define EVT_SYSCALL_USERFAULTFD_E 320
#define EVT_SYSCALL_USERFAULTFD_X 321
#define EVT_PLUGINEVENT_E 322
#define EVT_PLUGINEVENT_X 323
#define EVT_CONTAINER_JSON_2_E 324
#define EVT_CONTAINER_JSON_2_X 325
#define EVT_SYSCALL_OPENAT2_E 326
#define EVT_SYSCALL_OPENAT2_X 327
#define EVT_SYSCALL_MPROTECT_E 328
#define EVT_SYSCALL_MPROTECT_X 329
#define EVT_SYSCALL_EXECVEAT_E 330
#define EVT_SYSCALL_EXECVEAT_X 331
#define EVT_SYSCALL_COPY_FILE_RANGE_E 332
#define EVT_SYSCALL_COPY_FILE_RANGE_X 333
#define EVT_SYSCALL_CLONE3_E 334
#define EVT_SYSCALL_CLONE3_X 335
#define EVT_SYSCALL_OPEN_BY_HANDLE_AT_E 336
#define EVT_SYSCALL_OPEN_BY_HANDLE_AT_X 337
#define EVT_SYSCALL_IO_URING_SETUP_E 338
#define EVT_SYSCALL_IO_URING_SETUP_X 339
#define EVT_SYSCALL_IO_URING_ENTER_E 340
#define EVT_SYSCALL_IO_URING_ENTER_X 341
#define EVT_SYSCALL_IO_URING_REGISTER_E 342
#define EVT_SYSCALL_IO_URING_REGISTER_X 343
#define EVT_SYSCALL_MLOCK_E 344
#define EVT_SYSCALL_MLOCK_X 345
#define EVT_SYSCALL_MUNLOCK_E 346
#define EVT_SYSCALL_MUNLOCK_X 347
#define EVT_SYSCALL_MLOCKALL_E 348
#define EVT_SYSCALL_MLOCKALL_X 349
#define EVT_SYSCALL_MUNLOCKALL_E 350
#define EVT_SYSCALL_MUNLOCKALL_X 351
#define EVT_SYSCALL_CAPSET_E 352
#define EVT_SYSCALL_CAPSET_X 353
#define EVT_USER_ADDED_E 354
#define EVT_USER_ADDED_X 355
#define EVT_USER_DELETED_E 356
#define EVT_USER_DELETED_X 357
#define EVT_GROUP_ADDED_E 358
#define EVT_GROUP_ADDED_X 359
#define EVT_GROUP_DELETED_E 360
#define EVT_GROUP_DELETED_X 361
#define EVT_SYSCALL_DUP2_E 362
#define EVT_SYSCALL_DUP2_X 363
#define EVT_SYSCALL_DUP3_E 364
#define EVT_SYSCALL_DUP3_X 365
#define EVT_SYSCALL_DUP_1_E 366
#define EVT_SYSCALL_DUP_1_X 367
#define EVT_SYSCALL_BPF_2_E 368
#define EVT_SYSCALL_BPF_2_X 369
#define EVT_SYSCALL_MLOCK2_E 370
#define EVT_SYSCALL_MLOCK2_X 371
#define EVT_SYSCALL_FSCONFIG_E 372
#define EVT_SYSCALL_FSCONFIG_X 373
#define EVT_SYSCALL_EPOLL_CREATE_E 374
#define EVT_SYSCALL_EPOLL_CREATE_X 375
#define EVT_SYSCALL_EPOLL_CREATE1_E 376
#define EVT_SYSCALL_EPOLL_CREATE1_X 377
#define EVT_SYSCALL_CHOWN_E 378
#define EVT_SYSCALL_CHOWN_X 379
#define EVT_SYSCALL_LCHOWN_E 380
#define EVT_SYSCALL_LCHOWN_X 381
#define EVT_SYSCALL_FCHOWN_E 382
#define EVT_SYSCALL_FCHOWN_X 383
#define EVT_SYSCALL_FCHOWNAT_E 384
#define EVT_SYSCALL_FCHOWNAT_X 385
#define EVT_SYSCALL_UMOUNT_1_E 386
#define EVT_SYSCALL_UMOUNT_1_X 387
#define EVT_SOCKET_ACCEPT4_6_E 388
#define EVT_SOCKET_ACCEPT4_6_X 389
#define EVT_SYSCALL_UMOUNT2_E 390
#define EVT_SYSCALL_UMOUNT2_X 391
#define EVT_SYSCALL_PIPE2_E 392
#define EVT_SYSCALL_PIPE2_X 393
#define EVT_SYSCALL_INOTIFY_INIT1_E 394
#define EVT_SYSCALL_INOTIFY_INIT1_X 395
#define EVT_SYSCALL_EVENTFD2_E 396
#define EVT_SYSCALL_EVENTFD2_X 397
#define EVT_SYSCALL_SIGNALFD4_E 398
#define EVT_SYSCALL_SIGNALFD4_X 399
#define EVT_SYSCALL_PRCTL_E 400
#define EVT_SYSCALL_PRCTL_X 401
#define EVT_ASYNCEVENT_E 402
#define EVT_ASYNCEVENT_X 403
#define EVT_SYSCALL_MEMFD_CREATE_E 404
#define EVT_SYSCALL_MEMFD_CREATE_X 405
#define EVT_SYSCALL_PIDFD_GETFD_E 406
#define EVT_SYSCALL_PIDFD_GETFD_X 407
#define EVT_SYSCALL_PIDFD_OPEN_E 408
#define EVT_SYSCALL_PIDFD_OPEN_X 409
#define EVT_SYSCALL_INIT_MODULE_E 410
#define EVT_SYSCALL_INIT_MODULE_X 411
#define EVT_SYSCALL_FINIT_MODULE_E 412
#define EVT_SYSCALL_FINIT_MODULE_X 413
#define EVT_SYSCALL_MKNOD_E 414
#define EVT_SYSCALL_MKNOD_X 415
#define EVT_SYSCALL_MKNODAT_E 416
#define EVT_SYSCALL_MKNODAT_X 417
static const value_string event_type_vals[] = {
/* Value strings. Automatically generated by tools/generate-sysdig-event.py */
{ EVT_GENERIC_E, EVT_STR_SYSCALL },
{ EVT_GENERIC_X, EVT_STR_SYSCALL },
{ EVT_SYSCALL_OPEN_E, EVT_STR_OPEN },
{ EVT_SYSCALL_OPEN_X, EVT_STR_OPEN },
{ EVT_SYSCALL_CLOSE_E, EVT_STR_CLOSE },
{ EVT_SYSCALL_CLOSE_X, EVT_STR_CLOSE },
{ EVT_SYSCALL_READ_E, EVT_STR_READ },
{ EVT_SYSCALL_READ_X, EVT_STR_READ },
{ EVT_SYSCALL_WRITE_E, EVT_STR_WRITE },
{ EVT_SYSCALL_WRITE_X, EVT_STR_WRITE },
{ EVT_SYSCALL_BRK_1_E, EVT_STR_BRK },
{ EVT_SYSCALL_BRK_1_X, EVT_STR_BRK },
{ EVT_SYSCALL_EXECVE_8_E, EVT_STR_EXECVE },
{ EVT_SYSCALL_EXECVE_8_X, EVT_STR_EXECVE },
{ EVT_SYSCALL_CLONE_11_E, EVT_STR_CLONE },
{ EVT_SYSCALL_CLONE_11_X, EVT_STR_CLONE },
{ EVT_PROCEXIT_E, EVT_STR_PROCEXIT },
{ EVT_PROCEXIT_X, EVT_STR_NA },
{ EVT_SOCKET_SOCKET_E, EVT_STR_SOCKET },
{ EVT_SOCKET_SOCKET_X, EVT_STR_SOCKET },
{ EVT_SOCKET_BIND_E, EVT_STR_BIND },
{ EVT_SOCKET_BIND_X, EVT_STR_BIND },
{ EVT_SOCKET_CONNECT_E, EVT_STR_CONNECT },
{ EVT_SOCKET_CONNECT_X, EVT_STR_CONNECT },
{ EVT_SOCKET_LISTEN_E, EVT_STR_LISTEN },
{ EVT_SOCKET_LISTEN_X, EVT_STR_LISTEN },
{ EVT_SOCKET_ACCEPT_E, EVT_STR_ACCEPT },
{ EVT_SOCKET_ACCEPT_X, EVT_STR_ACCEPT },
{ EVT_SOCKET_SEND_E, EVT_STR_SEND },
{ EVT_SOCKET_SEND_X, EVT_STR_SEND },
{ EVT_SOCKET_SENDTO_E, EVT_STR_SENDTO },
{ EVT_SOCKET_SENDTO_X, EVT_STR_SENDTO },
{ EVT_SOCKET_RECV_E, EVT_STR_RECV },
{ EVT_SOCKET_RECV_X, EVT_STR_RECV },
{ EVT_SOCKET_RECVFROM_E, EVT_STR_RECVFROM },
{ EVT_SOCKET_RECVFROM_X, EVT_STR_RECVFROM },
{ EVT_SOCKET_SHUTDOWN_E, EVT_STR_SHUTDOWN },
{ EVT_SOCKET_SHUTDOWN_X, EVT_STR_SHUTDOWN },
{ EVT_SOCKET_GETSOCKNAME_E, EVT_STR_GETSOCKNAME },
{ EVT_SOCKET_GETSOCKNAME_X, EVT_STR_GETSOCKNAME },
{ EVT_SOCKET_GETPEERNAME_E, EVT_STR_GETPEERNAME },
{ EVT_SOCKET_GETPEERNAME_X, EVT_STR_GETPEERNAME },
{ EVT_SOCKET_SOCKETPAIR_E, EVT_STR_SOCKETPAIR },
{ EVT_SOCKET_SOCKETPAIR_X, EVT_STR_SOCKETPAIR },
{ EVT_SOCKET_SETSOCKOPT_E, EVT_STR_SETSOCKOPT },
{ EVT_SOCKET_SETSOCKOPT_X, EVT_STR_SETSOCKOPT },
{ EVT_SOCKET_GETSOCKOPT_E, EVT_STR_GETSOCKOPT },
{ EVT_SOCKET_GETSOCKOPT_X, EVT_STR_GETSOCKOPT },
{ EVT_SOCKET_SENDMSG_E, EVT_STR_SENDMSG },
{ EVT_SOCKET_SENDMSG_X, EVT_STR_SENDMSG },
{ EVT_SOCKET_SENDMMSG_E, EVT_STR_SENDMMSG },
{ EVT_SOCKET_SENDMMSG_X, EVT_STR_SENDMMSG },
{ EVT_SOCKET_RECVMSG_E, EVT_STR_RECVMSG },
{ EVT_SOCKET_RECVMSG_X, EVT_STR_RECVMSG },
{ EVT_SOCKET_RECVMMSG_E, EVT_STR_RECVMMSG },
{ EVT_SOCKET_RECVMMSG_X, EVT_STR_RECVMMSG },
{ EVT_SOCKET_ACCEPT4_E, EVT_STR_ACCEPT },
{ EVT_SOCKET_ACCEPT4_X, EVT_STR_ACCEPT },
{ EVT_SYSCALL_CREAT_E, EVT_STR_CREAT },
{ EVT_SYSCALL_CREAT_X, EVT_STR_CREAT },
{ EVT_SYSCALL_PIPE_E, EVT_STR_PIPE },
{ EVT_SYSCALL_PIPE_X, EVT_STR_PIPE },
{ EVT_SYSCALL_EVENTFD_E, EVT_STR_EVENTFD },
{ EVT_SYSCALL_EVENTFD_X, EVT_STR_EVENTFD },
{ EVT_SYSCALL_FUTEX_E, EVT_STR_FUTEX },
{ EVT_SYSCALL_FUTEX_X, EVT_STR_FUTEX },
{ EVT_SYSCALL_STAT_E, EVT_STR_STAT },
{ EVT_SYSCALL_STAT_X, EVT_STR_STAT },
{ EVT_SYSCALL_LSTAT_E, EVT_STR_LSTAT },
{ EVT_SYSCALL_LSTAT_X, EVT_STR_LSTAT },
{ EVT_SYSCALL_FSTAT_E, EVT_STR_FSTAT },
{ EVT_SYSCALL_FSTAT_X, EVT_STR_FSTAT },
{ EVT_SYSCALL_STAT64_E, EVT_STR_STAT64 },
{ EVT_SYSCALL_STAT64_X, EVT_STR_STAT64 },
{ EVT_SYSCALL_LSTAT64_E, EVT_STR_LSTAT64 },
{ EVT_SYSCALL_LSTAT64_X, EVT_STR_LSTAT64 },
{ EVT_SYSCALL_FSTAT64_E, EVT_STR_FSTAT64 },
{ EVT_SYSCALL_FSTAT64_X, EVT_STR_FSTAT64 },
{ EVT_SYSCALL_EPOLLWAIT_E, EVT_STR_EPOLL_WAIT },
{ EVT_SYSCALL_EPOLLWAIT_X, EVT_STR_EPOLL_WAIT },
{ EVT_SYSCALL_POLL_E, EVT_STR_POLL },
{ EVT_SYSCALL_POLL_X, EVT_STR_POLL },
{ EVT_SYSCALL_SELECT_E, EVT_STR_SELECT },
{ EVT_SYSCALL_SELECT_X, EVT_STR_SELECT },
{ EVT_SYSCALL_NEWSELECT_E, EVT_STR_SELECT },
{ EVT_SYSCALL_NEWSELECT_X, EVT_STR_SELECT },
{ EVT_SYSCALL_LSEEK_E, EVT_STR_LSEEK },
{ EVT_SYSCALL_LSEEK_X, EVT_STR_LSEEK },
{ EVT_SYSCALL_LLSEEK_E, EVT_STR_LLSEEK },
{ EVT_SYSCALL_LLSEEK_X, EVT_STR_LLSEEK },
{ EVT_SYSCALL_IOCTL_2_E, EVT_STR_IOCTL },
{ EVT_SYSCALL_IOCTL_2_X, EVT_STR_IOCTL },
{ EVT_SYSCALL_GETCWD_E, EVT_STR_GETCWD },
{ EVT_SYSCALL_GETCWD_X, EVT_STR_GETCWD },
{ EVT_SYSCALL_CHDIR_E, EVT_STR_CHDIR },
{ EVT_SYSCALL_CHDIR_X, EVT_STR_CHDIR },
{ EVT_SYSCALL_FCHDIR_E, EVT_STR_FCHDIR },
{ EVT_SYSCALL_FCHDIR_X, EVT_STR_FCHDIR },
{ EVT_SYSCALL_MKDIR_E, EVT_STR_MKDIR },
{ EVT_SYSCALL_MKDIR_X, EVT_STR_MKDIR },
{ EVT_SYSCALL_RMDIR_E, EVT_STR_RMDIR },
{ EVT_SYSCALL_RMDIR_X, EVT_STR_RMDIR },
{ EVT_SYSCALL_OPENAT_E, EVT_STR_OPENAT },
{ EVT_SYSCALL_OPENAT_X, EVT_STR_OPENAT },
{ EVT_SYSCALL_LINK_E, EVT_STR_LINK },
{ EVT_SYSCALL_LINK_X, EVT_STR_LINK },
{ EVT_SYSCALL_LINKAT_E, EVT_STR_LINKAT },
{ EVT_SYSCALL_LINKAT_X, EVT_STR_LINKAT },
{ EVT_SYSCALL_UNLINK_E, EVT_STR_UNLINK },
{ EVT_SYSCALL_UNLINK_X, EVT_STR_UNLINK },
{ EVT_SYSCALL_UNLINKAT_E, EVT_STR_UNLINKAT },
{ EVT_SYSCALL_UNLINKAT_X, EVT_STR_UNLINKAT },
{ EVT_SYSCALL_PREAD_E, EVT_STR_PREAD },
{ EVT_SYSCALL_PREAD_X, EVT_STR_PREAD },
{ EVT_SYSCALL_PWRITE_E, EVT_STR_PWRITE },
{ EVT_SYSCALL_PWRITE_X, EVT_STR_PWRITE },
{ EVT_SYSCALL_READV_E, EVT_STR_READV },
{ EVT_SYSCALL_READV_X, EVT_STR_READV },
{ EVT_SYSCALL_WRITEV_E, EVT_STR_WRITEV },
{ EVT_SYSCALL_WRITEV_X, EVT_STR_WRITEV },
{ EVT_SYSCALL_PREADV_E, EVT_STR_PREADV },
{ EVT_SYSCALL_PREADV_X, EVT_STR_PREADV },
{ EVT_SYSCALL_PWRITEV_E, EVT_STR_PWRITEV },
{ EVT_SYSCALL_PWRITEV_X, EVT_STR_PWRITEV },
{ EVT_SYSCALL_DUP_E, EVT_STR_DUP },
{ EVT_SYSCALL_DUP_X, EVT_STR_DUP },
{ EVT_SYSCALL_SIGNALFD_E, EVT_STR_SIGNALFD },
{ EVT_SYSCALL_SIGNALFD_X, EVT_STR_SIGNALFD },
{ EVT_SYSCALL_KILL_E, EVT_STR_KILL },
{ EVT_SYSCALL_KILL_X, EVT_STR_KILL },
{ EVT_SYSCALL_TKILL_E, EVT_STR_TKILL },
{ EVT_SYSCALL_TKILL_X, EVT_STR_TKILL },
{ EVT_SYSCALL_TGKILL_E, EVT_STR_TGKILL },
{ EVT_SYSCALL_TGKILL_X, EVT_STR_TGKILL },
{ EVT_SYSCALL_NANOSLEEP_E, EVT_STR_NANOSLEEP },
{ EVT_SYSCALL_NANOSLEEP_X, EVT_STR_NANOSLEEP },
{ EVT_SYSCALL_TIMERFD_CREATE_E, EVT_STR_TIMERFD_CREATE },
{ EVT_SYSCALL_TIMERFD_CREATE_X, EVT_STR_TIMERFD_CREATE },
{ EVT_SYSCALL_INOTIFY_INIT_E, EVT_STR_INOTIFY_INIT },
{ EVT_SYSCALL_INOTIFY_INIT_X, EVT_STR_INOTIFY_INIT },
{ EVT_SYSCALL_GETRLIMIT_E, EVT_STR_GETRLIMIT },
{ EVT_SYSCALL_GETRLIMIT_X, EVT_STR_GETRLIMIT },
{ EVT_SYSCALL_SETRLIMIT_E, EVT_STR_SETRLIMIT },
{ EVT_SYSCALL_SETRLIMIT_X, EVT_STR_SETRLIMIT },
{ EVT_SYSCALL_PRLIMIT_E, EVT_STR_PRLIMIT },
{ EVT_SYSCALL_PRLIMIT_X, EVT_STR_PRLIMIT },
{ EVT_SCHEDSWITCH_1_E, EVT_STR_SWITCH },
{ EVT_SCHEDSWITCH_1_X, EVT_STR_NA },
{ EVT_DROP_E, EVT_STR_DROP },
{ EVT_DROP_X, EVT_STR_DROP },
{ EVT_SYSCALL_FCNTL_E, EVT_STR_FCNTL },
{ EVT_SYSCALL_FCNTL_X, EVT_STR_FCNTL },
{ EVT_SCHEDSWITCH_6_E, EVT_STR_SWITCH },
{ EVT_SCHEDSWITCH_6_X, EVT_STR_NA },
{ EVT_SYSCALL_EXECVE_13_E, EVT_STR_EXECVE },
{ EVT_SYSCALL_EXECVE_13_X, EVT_STR_EXECVE },
{ EVT_SYSCALL_CLONE_16_E, EVT_STR_CLONE },
{ EVT_SYSCALL_CLONE_16_X, EVT_STR_CLONE },
{ EVT_SYSCALL_BRK_4_E, EVT_STR_BRK },
{ EVT_SYSCALL_BRK_4_X, EVT_STR_BRK },
{ EVT_SYSCALL_MMAP_E, EVT_STR_MMAP },
{ EVT_SYSCALL_MMAP_X, EVT_STR_MMAP },
{ EVT_SYSCALL_MMAP2_E, EVT_STR_MMAP2 },
{ EVT_SYSCALL_MMAP2_X, EVT_STR_MMAP2 },
{ EVT_SYSCALL_MUNMAP_E, EVT_STR_MUNMAP },
{ EVT_SYSCALL_MUNMAP_X, EVT_STR_MUNMAP },
{ EVT_SYSCALL_SPLICE_E, EVT_STR_SPLICE },
{ EVT_SYSCALL_SPLICE_X, EVT_STR_SPLICE },
{ EVT_SYSCALL_PTRACE_E, EVT_STR_PTRACE },
{ EVT_SYSCALL_PTRACE_X, EVT_STR_PTRACE },
{ EVT_SYSCALL_IOCTL_3_E, EVT_STR_IOCTL },
{ EVT_SYSCALL_IOCTL_3_X, EVT_STR_IOCTL },
{ EVT_SYSCALL_EXECVE_14_E, EVT_STR_EXECVE },
{ EVT_SYSCALL_EXECVE_14_X, EVT_STR_EXECVE },
{ EVT_SYSCALL_RENAME_E, EVT_STR_RENAME },
{ EVT_SYSCALL_RENAME_X, EVT_STR_RENAME },
{ EVT_SYSCALL_RENAMEAT_E, EVT_STR_RENAMEAT },
{ EVT_SYSCALL_RENAMEAT_X, EVT_STR_RENAMEAT },
{ EVT_SYSCALL_SYMLINK_E, EVT_STR_SYMLINK },
{ EVT_SYSCALL_SYMLINK_X, EVT_STR_SYMLINK },
{ EVT_SYSCALL_SYMLINKAT_E, EVT_STR_SYMLINKAT },
{ EVT_SYSCALL_SYMLINKAT_X, EVT_STR_SYMLINKAT },
{ EVT_SYSCALL_FORK_E, EVT_STR_FORK },
{ EVT_SYSCALL_FORK_X, EVT_STR_FORK },
{ EVT_SYSCALL_VFORK_E, EVT_STR_VFORK },
{ EVT_SYSCALL_VFORK_X, EVT_STR_VFORK },
{ EVT_PROCEXIT_1_E, EVT_STR_PROCEXIT },
{ EVT_PROCEXIT_1_X, EVT_STR_NA },
{ EVT_SYSCALL_SENDFILE_E, EVT_STR_SENDFILE },
{ EVT_SYSCALL_SENDFILE_X, EVT_STR_SENDFILE },
{ EVT_SYSCALL_QUOTACTL_E, EVT_STR_QUOTACTL },
{ EVT_SYSCALL_QUOTACTL_X, EVT_STR_QUOTACTL },
{ EVT_SYSCALL_SETRESUID_E, EVT_STR_SETRESUID },
{ EVT_SYSCALL_SETRESUID_X, EVT_STR_SETRESUID },
{ EVT_SYSCALL_SETRESGID_E, EVT_STR_SETRESGID },
{ EVT_SYSCALL_SETRESGID_X, EVT_STR_SETRESGID },
{ EVT_SCAPEVENT_E, EVT_STR_SCAPEVENT },
{ EVT_SCAPEVENT_X, EVT_STR_SCAPEVENT },
{ EVT_SYSCALL_SETUID_E, EVT_STR_SETUID },
{ EVT_SYSCALL_SETUID_X, EVT_STR_SETUID },
{ EVT_SYSCALL_SETGID_E, EVT_STR_SETGID },
{ EVT_SYSCALL_SETGID_X, EVT_STR_SETGID },
{ EVT_SYSCALL_GETUID_E, EVT_STR_GETUID },
{ EVT_SYSCALL_GETUID_X, EVT_STR_GETUID },
{ EVT_SYSCALL_GETEUID_E, EVT_STR_GETEUID },
{ EVT_SYSCALL_GETEUID_X, EVT_STR_GETEUID },
{ EVT_SYSCALL_GETGID_E, EVT_STR_GETGID },
{ EVT_SYSCALL_GETGID_X, EVT_STR_GETGID },
{ EVT_SYSCALL_GETEGID_E, EVT_STR_GETEGID },
{ EVT_SYSCALL_GETEGID_X, EVT_STR_GETEGID },
{ EVT_SYSCALL_GETRESUID_E, EVT_STR_GETRESUID },
{ EVT_SYSCALL_GETRESUID_X, EVT_STR_GETRESUID },
{ EVT_SYSCALL_GETRESGID_E, EVT_STR_GETRESGID },
{ EVT_SYSCALL_GETRESGID_X, EVT_STR_GETRESGID },
{ EVT_SYSCALL_EXECVE_15_E, EVT_STR_EXECVE },
{ EVT_SYSCALL_EXECVE_15_X, EVT_STR_EXECVE },
{ EVT_SYSCALL_CLONE_17_E, EVT_STR_CLONE },
{ EVT_SYSCALL_CLONE_17_X, EVT_STR_CLONE },
{ EVT_SYSCALL_FORK_17_E, EVT_STR_FORK },
{ EVT_SYSCALL_FORK_17_X, EVT_STR_FORK },
{ EVT_SYSCALL_VFORK_17_E, EVT_STR_VFORK },
{ EVT_SYSCALL_VFORK_17_X, EVT_STR_VFORK },
{ EVT_SYSCALL_CLONE_20_E, EVT_STR_CLONE },
{ EVT_SYSCALL_CLONE_20_X, EVT_STR_CLONE },
{ EVT_SYSCALL_FORK_20_E, EVT_STR_FORK },
{ EVT_SYSCALL_FORK_20_X, EVT_STR_FORK },
{ EVT_SYSCALL_VFORK_20_E, EVT_STR_VFORK },
{ EVT_SYSCALL_VFORK_20_X, EVT_STR_VFORK },
{ EVT_CONTAINER_E, EVT_STR_CONTAINER },
{ EVT_CONTAINER_X, EVT_STR_NA },
{ EVT_SYSCALL_EXECVE_16_E, EVT_STR_EXECVE },
{ EVT_SYSCALL_EXECVE_16_X, EVT_STR_EXECVE },
{ EVT_SIGNALDELIVER_E, EVT_STR_SIGNALDELIVER },
{ EVT_SIGNALDELIVER_X, EVT_STR_NA },
{ EVT_PROCINFO_E, EVT_STR_PROCINFO },
{ EVT_PROCINFO_X, EVT_STR_NA },
{ EVT_SYSCALL_GETDENTS_E, EVT_STR_GETDENTS },
{ EVT_SYSCALL_GETDENTS_X, EVT_STR_GETDENTS },
{ EVT_SYSCALL_GETDENTS64_E, EVT_STR_GETDENTS64 },
{ EVT_SYSCALL_GETDENTS64_X, EVT_STR_GETDENTS64 },
{ EVT_SYSCALL_SETNS_E, EVT_STR_SETNS },
{ EVT_SYSCALL_SETNS_X, EVT_STR_SETNS },
{ EVT_SYSCALL_FLOCK_E, EVT_STR_FLOCK },
{ EVT_SYSCALL_FLOCK_X, EVT_STR_FLOCK },
{ EVT_CPU_HOTPLUG_E, EVT_STR_CPU_HOTPLUG },
{ EVT_CPU_HOTPLUG_X, EVT_STR_NA },
{ EVT_SOCKET_ACCEPT_5_E, EVT_STR_ACCEPT },
{ EVT_SOCKET_ACCEPT_5_X, EVT_STR_ACCEPT },
{ EVT_SOCKET_ACCEPT4_5_E, EVT_STR_ACCEPT },
{ EVT_SOCKET_ACCEPT4_5_X, EVT_STR_ACCEPT },
{ EVT_SYSCALL_SEMOP_E, EVT_STR_SEMOP },
{ EVT_SYSCALL_SEMOP_X, EVT_STR_SEMOP },
{ EVT_SYSCALL_SEMCTL_E, EVT_STR_SEMCTL },
{ EVT_SYSCALL_SEMCTL_X, EVT_STR_SEMCTL },
{ EVT_SYSCALL_PPOLL_E, EVT_STR_PPOLL },
{ EVT_SYSCALL_PPOLL_X, EVT_STR_PPOLL },
{ EVT_SYSCALL_MOUNT_E, EVT_STR_MOUNT },
{ EVT_SYSCALL_MOUNT_X, EVT_STR_MOUNT },
{ EVT_SYSCALL_UMOUNT_E, EVT_STR_UMOUNT },
{ EVT_SYSCALL_UMOUNT_X, EVT_STR_UMOUNT },
{ EVT_K8S_E, EVT_STR_K8S },
{ EVT_K8S_X, EVT_STR_NA },
{ EVT_SYSCALL_SEMGET_E, EVT_STR_SEMGET },
{ EVT_SYSCALL_SEMGET_X, EVT_STR_SEMGET },
{ EVT_SYSCALL_ACCESS_E, EVT_STR_ACCESS },
{ EVT_SYSCALL_ACCESS_X, EVT_STR_ACCESS },
{ EVT_SYSCALL_CHROOT_E, EVT_STR_CHROOT },
{ EVT_SYSCALL_CHROOT_X, EVT_STR_CHROOT },
{ EVT_TRACER_E, EVT_STR_TRACER },
{ EVT_TRACER_X, EVT_STR_TRACER },
{ EVT_MESOS_E, EVT_STR_MESOS },
{ EVT_MESOS_X, EVT_STR_NA },
{ EVT_CONTAINER_JSON_E, EVT_STR_CONTAINER },
{ EVT_CONTAINER_JSON_X, EVT_STR_NA },
{ EVT_SYSCALL_SETSID_E, EVT_STR_SETSID },
{ EVT_SYSCALL_SETSID_X, EVT_STR_SETSID },
{ EVT_SYSCALL_MKDIR_2_E, EVT_STR_MKDIR },
{ EVT_SYSCALL_MKDIR_2_X, EVT_STR_MKDIR },
{ EVT_SYSCALL_RMDIR_2_E, EVT_STR_RMDIR },
{ EVT_SYSCALL_RMDIR_2_X, EVT_STR_RMDIR },
{ EVT_NOTIFICATION_E, EVT_STR_NOTIFICATION },
{ EVT_NOTIFICATION_X, EVT_STR_NA },
{ EVT_SYSCALL_EXECVE_17_E, EVT_STR_EXECVE },
{ EVT_SYSCALL_EXECVE_17_X, EVT_STR_EXECVE },
{ EVT_SYSCALL_UNSHARE_E, EVT_STR_UNSHARE },
{ EVT_SYSCALL_UNSHARE_X, EVT_STR_UNSHARE },
{ EVT_INFRASTRUCTURE_EVENT_E, EVT_STR_INFRA },
{ EVT_INFRASTRUCTURE_EVENT_X, EVT_STR_NA },
{ EVT_SYSCALL_EXECVE_18_E, EVT_STR_EXECVE },
{ EVT_SYSCALL_EXECVE_18_X, EVT_STR_EXECVE },
{ EVT_PAGE_FAULT_E, EVT_STR_PAGE_FAULT },
{ EVT_PAGE_FAULT_X, EVT_STR_NA },
{ EVT_SYSCALL_EXECVE_19_E, EVT_STR_EXECVE },
{ EVT_SYSCALL_EXECVE_19_X, EVT_STR_EXECVE },
{ EVT_SYSCALL_SETPGID_E, EVT_STR_SETPGID },
{ EVT_SYSCALL_SETPGID_X, EVT_STR_SETPGID },
{ EVT_SYSCALL_BPF_E, EVT_STR_BPF },
{ EVT_SYSCALL_BPF_X, EVT_STR_BPF },
{ EVT_SYSCALL_SECCOMP_E, EVT_STR_SECCOMP },
{ EVT_SYSCALL_SECCOMP_X, EVT_STR_SECCOMP },
{ EVT_SYSCALL_UNLINK_2_E, EVT_STR_UNLINK },
{ EVT_SYSCALL_UNLINK_2_X, EVT_STR_UNLINK },
{ EVT_SYSCALL_UNLINKAT_2_E, EVT_STR_UNLINKAT },
{ EVT_SYSCALL_UNLINKAT_2_X, EVT_STR_UNLINKAT },
{ EVT_SYSCALL_MKDIRAT_E, EVT_STR_MKDIRAT },
{ EVT_SYSCALL_MKDIRAT_X, EVT_STR_MKDIRAT },
{ EVT_SYSCALL_OPENAT_2_E, EVT_STR_OPENAT },
{ EVT_SYSCALL_OPENAT_2_X, EVT_STR_OPENAT },
{ EVT_SYSCALL_LINK_2_E, EVT_STR_LINK },
{ EVT_SYSCALL_LINK_2_X, EVT_STR_LINK },
{ EVT_SYSCALL_LINKAT_2_E, EVT_STR_LINKAT },
{ EVT_SYSCALL_LINKAT_2_X, EVT_STR_LINKAT },
{ EVT_SYSCALL_FCHMODAT_E, EVT_STR_FCHMODAT },
{ EVT_SYSCALL_FCHMODAT_X, EVT_STR_FCHMODAT },
{ EVT_SYSCALL_CHMOD_E, EVT_STR_CHMOD },
{ EVT_SYSCALL_CHMOD_X, EVT_STR_CHMOD },
{ EVT_SYSCALL_FCHMOD_E, EVT_STR_FCHMOD },
{ EVT_SYSCALL_FCHMOD_X, EVT_STR_FCHMOD },
{ EVT_SYSCALL_RENAMEAT2_E, EVT_STR_RENAMEAT2 },
{ EVT_SYSCALL_RENAMEAT2_X, EVT_STR_RENAMEAT2 },
{ EVT_SYSCALL_USERFAULTFD_E, EVT_STR_USERFAULTFD },
{ EVT_SYSCALL_USERFAULTFD_X, EVT_STR_USERFAULTFD },
{ EVT_PLUGINEVENT_E, EVT_STR_PLUGINEVENT },
{ EVT_PLUGINEVENT_X, EVT_STR_NA },
{ EVT_CONTAINER_JSON_2_E, EVT_STR_CONTAINER },
{ EVT_CONTAINER_JSON_2_X, EVT_STR_NA },
{ EVT_SYSCALL_OPENAT2_E, EVT_STR_OPENAT2 },
{ EVT_SYSCALL_OPENAT2_X, EVT_STR_OPENAT2 },
{ EVT_SYSCALL_MPROTECT_E, EVT_STR_MPROTECT },
{ EVT_SYSCALL_MPROTECT_X, EVT_STR_MPROTECT },
{ EVT_SYSCALL_EXECVEAT_E, EVT_STR_EXECVEAT },
{ EVT_SYSCALL_EXECVEAT_X, EVT_STR_EXECVEAT },
{ EVT_SYSCALL_COPY_FILE_RANGE_E, EVT_STR_COPY_FILE_RANGE },
{ EVT_SYSCALL_COPY_FILE_RANGE_X, EVT_STR_COPY_FILE_RANGE },
{ EVT_SYSCALL_CLONE3_E, EVT_STR_CLONE3 },
{ EVT_SYSCALL_CLONE3_X, EVT_STR_CLONE3 },
{ EVT_SYSCALL_OPEN_BY_HANDLE_AT_E, EVT_STR_OPEN_BY_HANDLE_AT },
{ EVT_SYSCALL_OPEN_BY_HANDLE_AT_X, EVT_STR_OPEN_BY_HANDLE_AT },
{ EVT_SYSCALL_IO_URING_SETUP_E, EVT_STR_IO_URING_SETUP },
{ EVT_SYSCALL_IO_URING_SETUP_X, EVT_STR_IO_URING_SETUP },
{ EVT_SYSCALL_IO_URING_ENTER_E, EVT_STR_IO_URING_ENTER },
{ EVT_SYSCALL_IO_URING_ENTER_X, EVT_STR_IO_URING_ENTER },
{ EVT_SYSCALL_IO_URING_REGISTER_E, EVT_STR_IO_URING_REGISTER },
{ EVT_SYSCALL_IO_URING_REGISTER_X, EVT_STR_IO_URING_REGISTER },
{ EVT_SYSCALL_MLOCK_E, EVT_STR_MLOCK },
{ EVT_SYSCALL_MLOCK_X, EVT_STR_MLOCK },
{ EVT_SYSCALL_MUNLOCK_E, EVT_STR_MUNLOCK },
{ EVT_SYSCALL_MUNLOCK_X, EVT_STR_MUNLOCK },
{ EVT_SYSCALL_MLOCKALL_E, EVT_STR_MLOCKALL },
{ EVT_SYSCALL_MLOCKALL_X, EVT_STR_MLOCKALL },
{ EVT_SYSCALL_MUNLOCKALL_E, EVT_STR_MUNLOCKALL },
{ EVT_SYSCALL_MUNLOCKALL_X, EVT_STR_MUNLOCKALL },
{ EVT_SYSCALL_CAPSET_E, EVT_STR_CAPSET },
{ EVT_SYSCALL_CAPSET_X, EVT_STR_CAPSET },
{ EVT_USER_ADDED_E, EVT_STR_USERADDED },
{ EVT_USER_ADDED_X, EVT_STR_NA },
{ EVT_USER_DELETED_E, EVT_STR_USERDELETED },
{ EVT_USER_DELETED_X, EVT_STR_NA },
{ EVT_GROUP_ADDED_E, EVT_STR_GROUPADDED },
{ EVT_GROUP_ADDED_X, EVT_STR_NA },
{ EVT_GROUP_DELETED_E, EVT_STR_GROUPDELETED },
{ EVT_GROUP_DELETED_X, EVT_STR_NA },
{ EVT_SYSCALL_DUP2_E, EVT_STR_DUP2 },
{ EVT_SYSCALL_DUP2_X, EVT_STR_DUP2 },
{ EVT_SYSCALL_DUP3_E, EVT_STR_DUP3 },
{ EVT_SYSCALL_DUP3_X, EVT_STR_DUP3 },
{ EVT_SYSCALL_DUP_1_E, EVT_STR_DUP },
{ EVT_SYSCALL_DUP_1_X, EVT_STR_DUP },
{ EVT_SYSCALL_BPF_2_E, EVT_STR_BPF },
{ EVT_SYSCALL_BPF_2_X, EVT_STR_BPF },
{ EVT_SYSCALL_MLOCK2_E, EVT_STR_MLOCK2 },
{ EVT_SYSCALL_MLOCK2_X, EVT_STR_MLOCK2 },
{ EVT_SYSCALL_FSCONFIG_E, EVT_STR_FSCONFIG },
{ EVT_SYSCALL_FSCONFIG_X, EVT_STR_FSCONFIG },
{ EVT_SYSCALL_EPOLL_CREATE_E, EVT_STR_EPOLL_CREATE },
{ EVT_SYSCALL_EPOLL_CREATE_X, EVT_STR_EPOLL_CREATE },
{ EVT_SYSCALL_EPOLL_CREATE1_E, EVT_STR_EPOLL_CREATE1 },
{ EVT_SYSCALL_EPOLL_CREATE1_X, EVT_STR_EPOLL_CREATE1 },
{ EVT_SYSCALL_CHOWN_E, EVT_STR_CHOWN },
{ EVT_SYSCALL_CHOWN_X, EVT_STR_CHOWN },
{ EVT_SYSCALL_LCHOWN_E, EVT_STR_LCHOWN },
{ EVT_SYSCALL_LCHOWN_X, EVT_STR_LCHOWN },
{ EVT_SYSCALL_FCHOWN_E, EVT_STR_FCHOWN },
{ EVT_SYSCALL_FCHOWN_X, EVT_STR_FCHOWN },
{ EVT_SYSCALL_FCHOWNAT_E, EVT_STR_FCHOWNAT },
{ EVT_SYSCALL_FCHOWNAT_X, EVT_STR_FCHOWNAT },
{ EVT_SYSCALL_UMOUNT_1_E, EVT_STR_UMOUNT },
{ EVT_SYSCALL_UMOUNT_1_X, EVT_STR_UMOUNT },
{ EVT_SOCKET_ACCEPT4_6_E, EVT_STR_ACCEPT4 },
{ EVT_SOCKET_ACCEPT4_6_X, EVT_STR_ACCEPT4 },
{ EVT_SYSCALL_UMOUNT2_E, EVT_STR_UMOUNT2 },
{ EVT_SYSCALL_UMOUNT2_X, EVT_STR_UMOUNT2 },
{ EVT_SYSCALL_PIPE2_E, EVT_STR_PIPE2 },
{ EVT_SYSCALL_PIPE2_X, EVT_STR_PIPE2 },
{ EVT_SYSCALL_INOTIFY_INIT1_E, EVT_STR_INOTIFY_INIT1 },
{ EVT_SYSCALL_INOTIFY_INIT1_X, EVT_STR_INOTIFY_INIT1 },
{ EVT_SYSCALL_EVENTFD2_E, EVT_STR_EVENTFD2 },
{ EVT_SYSCALL_EVENTFD2_X, EVT_STR_EVENTFD2 },
{ EVT_SYSCALL_SIGNALFD4_E, EVT_STR_SIGNALFD4 },
{ EVT_SYSCALL_SIGNALFD4_X, EVT_STR_SIGNALFD4 },
{ EVT_SYSCALL_PRCTL_E, EVT_STR_PRCTL },
{ EVT_SYSCALL_PRCTL_X, EVT_STR_PRCTL },
{ EVT_ASYNCEVENT_E, EVT_STR_ASYNCEVENT },
{ EVT_ASYNCEVENT_X, EVT_STR_NA },
{ EVT_SYSCALL_MEMFD_CREATE_E, EVT_STR_MEMFD_CREATE },
{ EVT_SYSCALL_MEMFD_CREATE_X, EVT_STR_MEMFD_CREATE },
{ EVT_SYSCALL_PIDFD_GETFD_E, EVT_STR_PIDFD_GETFD },
{ EVT_SYSCALL_PIDFD_GETFD_X, EVT_STR_PIDFD_GETFD },
{ EVT_SYSCALL_PIDFD_OPEN_E, EVT_STR_PIDFD_OPEN },
{ EVT_SYSCALL_PIDFD_OPEN_X, EVT_STR_PIDFD_OPEN },
{ EVT_SYSCALL_INIT_MODULE_E, EVT_STR_INIT_MODULE },
{ EVT_SYSCALL_INIT_MODULE_X, EVT_STR_INIT_MODULE },
{ EVT_SYSCALL_FINIT_MODULE_E, EVT_STR_FINIT_MODULE },
{ EVT_SYSCALL_FINIT_MODULE_X, EVT_STR_FINIT_MODULE },
{ EVT_SYSCALL_MKNOD_E, EVT_STR_MKNOD },
{ EVT_SYSCALL_MKNOD_X, EVT_STR_MKNOD },
{ EVT_SYSCALL_MKNODAT_E, EVT_STR_MKNODAT },
{ EVT_SYSCALL_MKNODAT_X, EVT_STR_MKNODAT },
{0, NULL }
};
/*
* "Interesting" parameters, which are appended to COL_INFO.
* Manually generated for now.
*/
struct _event_col_info_param {
const int param_num;
const char *param_name;
enum ftenum param_ftype;
};
static const struct _event_col_info_param open_x_params[] = {
{ 0, "fd", FT_UINT64 },
{ 1, "name", FT_STRING },
{ 0, NULL, FT_NONE }
};
static const struct _event_col_info_param close_e_params[] = {
{ 0, "fd", FT_UINT64 },
{ 0, NULL, FT_NONE }
};
static const struct _event_col_info_param read_e_params[] = {
{ 0, "fd", FT_UINT64 },
{ 0, NULL, FT_NONE }
};
static const struct _event_col_info_param write_e_params[] = {
{ 0, "fd", FT_UINT64 },
{ 0, NULL, FT_NONE }
};
static const struct _event_col_info_param execve_15_x_params[] = {
{ 1, "exe", FT_STRING },
{ 2, "args", FT_STRING },
{ 0, NULL, FT_NONE }
};
struct _event_col_info {
const guint event_type;
const int num_len_fields;
const struct _event_col_info_param *params;
};
/* Info column parameters */
static const struct _event_col_info event_col_info[] = {
{ EVT_SYSCALL_OPEN_X, 4, open_x_params },
{ EVT_SYSCALL_CLOSE_E, 1, close_e_params },
{ EVT_SYSCALL_READ_E, 2, read_e_params },
{ EVT_SYSCALL_WRITE_E, 2, write_e_params },
{ EVT_SYSCALL_EXECVE_15_X, 15, execve_15_x_params },
{ 0, 0, NULL }
};
struct _event_tree_info {
const guint event_type;
/* int num_params; */
int * const *hf_indexes;
};
static int * const no_indexes[] = { NULL };
/* Parameter indexes. Automatically generated by tools/generate-sysdig-event.py */
static int * const generic_e_indexes[] = { &hf_param_ID_uint16, &hf_param_nativeID_uint16, NULL };
static int * const generic_x_indexes[] = { &hf_param_ID_uint16, NULL };
static int * const syscall_open_e_indexes[] = { &hf_param_name_string, &hf_param_flags_int32, &hf_param_mode_uint32, NULL };
static int * const syscall_open_x_indexes[] = { &hf_param_fd_int64, &hf_param_name_string, &hf_param_flags_int32, &hf_param_mode_uint32, &hf_param_dev_uint32, &hf_param_ino_uint64, NULL };
static int * const syscall_close_e_indexes[] = { &hf_param_fd_int64, NULL };
static int * const syscall_close_x_indexes[] = { &hf_param_res_int64, NULL };
static int * const syscall_read_e_indexes[] = { &hf_param_fd_int64, &hf_param_size_uint32, NULL };
static int * const syscall_read_x_indexes[] = { &hf_param_res_int64, &hf_param_data_bytes, NULL };
#define syscall_write_e_indexes syscall_read_e_indexes
#define syscall_write_x_indexes syscall_read_x_indexes
static int * const syscall_brk_1_e_indexes[] = { &hf_param_size_uint32, NULL };
static int * const syscall_brk_1_x_indexes[] = { &hf_param_res_uint64, NULL };
#define syscall_execve_8_e_indexes no_indexes
static int * const syscall_execve_8_x_indexes[] = { &hf_param_res_int64, &hf_param_exe_string, &hf_param_args_string, &hf_param_tid_int64, &hf_param_pid_int64, &hf_param_ptid_int64, &hf_param_cwd_string, &hf_param_fdlimit_uint64, NULL };
#define syscall_clone_11_e_indexes no_indexes
static int * const syscall_clone_11_x_indexes[] = { &hf_param_res_int64, &hf_param_exe_string, &hf_param_args_string, &hf_param_tid_int64, &hf_param_pid_int64, &hf_param_ptid_int64, &hf_param_cwd_string, &hf_param_fdlimit_int64, &hf_param_flags_int32, &hf_param_uid_uint32, &hf_param_gid_uint32, NULL };
#define procexit_e_indexes no_indexes
#define procexit_x_indexes no_indexes
static int * const socket_socket_e_indexes[] = { &hf_param_domain_bytes, &hf_param_type_uint32, &hf_param_proto_uint32, NULL };
#define socket_socket_x_indexes syscall_close_e_indexes
#define socket_bind_e_indexes syscall_close_e_indexes
static int * const socket_bind_x_indexes[] = { &hf_param_res_int64, &hf_param_addr_bytes, NULL };
static int * const socket_connect_e_indexes[] = { &hf_param_fd_int64, &hf_param_addr_bytes, NULL };
static int * const socket_connect_x_indexes[] = { &hf_param_res_int64, &hf_param_tuple_bytes, &hf_param_fd_int64, NULL };
static int * const socket_listen_e_indexes[] = { &hf_param_fd_int64, &hf_param_backlog_int32, NULL };
#define socket_listen_x_indexes syscall_close_x_indexes
#define socket_accept_e_indexes no_indexes
static int * const socket_accept_x_indexes[] = { &hf_param_fd_int64, &hf_param_tuple_bytes, &hf_param_queuepct_uint8, NULL };
#define socket_send_e_indexes syscall_read_e_indexes
#define socket_send_x_indexes syscall_read_x_indexes
static int * const socket_sendto_e_indexes[] = { &hf_param_fd_int64, &hf_param_size_uint32, &hf_param_tuple_bytes, NULL };
#define socket_sendto_x_indexes syscall_read_x_indexes
#define socket_recv_e_indexes syscall_read_e_indexes
#define socket_recv_x_indexes syscall_read_x_indexes
#define socket_recvfrom_e_indexes syscall_read_e_indexes
static int * const socket_recvfrom_x_indexes[] = { &hf_param_res_int64, &hf_param_data_bytes, &hf_param_tuple_bytes, NULL };
static int * const socket_shutdown_e_indexes[] = { &hf_param_fd_int64, &hf_param_how_bytes, NULL };
#define socket_shutdown_x_indexes syscall_close_x_indexes
#define socket_getsockname_e_indexes no_indexes
#define socket_getsockname_x_indexes no_indexes
#define socket_getpeername_e_indexes no_indexes
#define socket_getpeername_x_indexes no_indexes
#define socket_socketpair_e_indexes socket_socket_e_indexes
static int * const socket_socketpair_x_indexes[] = { &hf_param_res_int64, &hf_param_fd1_int64, &hf_param_fd2_int64, &hf_param_source_uint64, &hf_param_peer_uint64, NULL };
#define socket_setsockopt_e_indexes no_indexes
static int * const socket_setsockopt_x_indexes[] = { &hf_param_res_int64, &hf_param_fd_int64, &hf_param_level_bytes, &hf_param_optname_bytes, &hf_param_val_bytes, &hf_param_optlen_uint32, NULL };
#define socket_getsockopt_e_indexes no_indexes
#define socket_getsockopt_x_indexes socket_setsockopt_x_indexes
#define socket_sendmsg_e_indexes socket_sendto_e_indexes
#define socket_sendmsg_x_indexes syscall_read_x_indexes
#define socket_sendmmsg_e_indexes no_indexes
#define socket_sendmmsg_x_indexes no_indexes
#define socket_recvmsg_e_indexes syscall_close_e_indexes
static int * const socket_recvmsg_x_indexes[] = { &hf_param_res_int64, &hf_param_size_uint32, &hf_param_data_bytes, &hf_param_tuple_bytes, NULL };
#define socket_recvmmsg_e_indexes no_indexes
#define socket_recvmmsg_x_indexes no_indexes
static int * const socket_accept4_e_indexes[] = { &hf_param_flags_uint32, NULL };
#define socket_accept4_x_indexes socket_accept_x_indexes
static int * const syscall_creat_e_indexes[] = { &hf_param_name_string, &hf_param_mode_uint32, NULL };
static int * const syscall_creat_x_indexes[] = { &hf_param_fd_int64, &hf_param_name_string, &hf_param_mode_uint32, &hf_param_dev_uint32, &hf_param_ino_uint64, NULL };
#define syscall_pipe_e_indexes no_indexes
static int * const syscall_pipe_x_indexes[] = { &hf_param_res_int64, &hf_param_fd1_int64, &hf_param_fd2_int64, &hf_param_ino_uint64, NULL };
static int * const syscall_eventfd_e_indexes[] = { &hf_param_initval_uint64, &hf_param_flags_int32, NULL };
#define syscall_eventfd_x_indexes syscall_close_x_indexes
static int * const syscall_futex_e_indexes[] = { &hf_param_addr_uint64, &hf_param_op_bytes, &hf_param_val_uint64, NULL };
#define syscall_futex_x_indexes syscall_close_x_indexes
#define syscall_stat_e_indexes no_indexes
static int * const syscall_stat_x_indexes[] = { &hf_param_res_int64, &hf_param_path_string, NULL };
#define syscall_lstat_e_indexes no_indexes
#define syscall_lstat_x_indexes syscall_stat_x_indexes
#define syscall_fstat_e_indexes syscall_close_e_indexes
#define syscall_fstat_x_indexes syscall_close_x_indexes
#define syscall_stat64_e_indexes no_indexes
#define syscall_stat64_x_indexes syscall_stat_x_indexes
#define syscall_lstat64_e_indexes no_indexes
#define syscall_lstat64_x_indexes syscall_stat_x_indexes
#define syscall_fstat64_e_indexes syscall_close_e_indexes
#define syscall_fstat64_x_indexes syscall_close_x_indexes
static int * const syscall_epollwait_e_indexes[] = { &hf_param_maxevents_int64, NULL };
#define syscall_epollwait_x_indexes syscall_close_x_indexes
static int * const syscall_poll_e_indexes[] = { &hf_param_fds_bytes, &hf_param_timeout_int64, NULL };
static int * const syscall_poll_x_indexes[] = { &hf_param_res_int64, &hf_param_fds_bytes, NULL };
#define syscall_select_e_indexes no_indexes
#define syscall_select_x_indexes syscall_close_x_indexes
#define syscall_newselect_e_indexes no_indexes
#define syscall_newselect_x_indexes syscall_close_x_indexes
static int * const syscall_lseek_e_indexes[] = { &hf_param_fd_int64, &hf_param_offset_uint64, &hf_param_whence_bytes, NULL };
#define syscall_lseek_x_indexes syscall_close_x_indexes
#define syscall_llseek_e_indexes syscall_lseek_e_indexes
#define syscall_llseek_x_indexes syscall_close_x_indexes
static int * const syscall_ioctl_2_e_indexes[] = { &hf_param_fd_int64, &hf_param_request_uint64, NULL };
#define syscall_ioctl_2_x_indexes syscall_close_x_indexes
#define syscall_getcwd_e_indexes no_indexes
#define syscall_getcwd_x_indexes syscall_stat_x_indexes
#define syscall_chdir_e_indexes no_indexes
#define syscall_chdir_x_indexes syscall_stat_x_indexes
#define syscall_fchdir_e_indexes syscall_close_e_indexes
#define syscall_fchdir_x_indexes syscall_close_x_indexes
static int * const syscall_mkdir_e_indexes[] = { &hf_param_path_string, &hf_param_mode_uint32, NULL };
#define syscall_mkdir_x_indexes syscall_close_x_indexes
static int * const syscall_rmdir_e_indexes[] = { &hf_param_path_string, NULL };
#define syscall_rmdir_x_indexes syscall_close_x_indexes
static int * const syscall_openat_e_indexes[] = { &hf_param_dirfd_int64, &hf_param_name_string, &hf_param_flags_int32, &hf_param_mode_uint32, NULL };
#define syscall_openat_x_indexes syscall_close_e_indexes
static int * const syscall_link_e_indexes[] = { &hf_param_oldpath_string, &hf_param_newpath_string, NULL };
#define syscall_link_x_indexes syscall_close_x_indexes
static int * const syscall_linkat_e_indexes[] = { &hf_param_olddir_int64, &hf_param_oldpath_string, &hf_param_newdir_int64, &hf_param_newpath_string, NULL };
#define syscall_linkat_x_indexes syscall_close_x_indexes
#define syscall_unlink_e_indexes syscall_rmdir_e_indexes
#define syscall_unlink_x_indexes syscall_close_x_indexes
static int * const syscall_unlinkat_e_indexes[] = { &hf_param_dirfd_int64, &hf_param_name_string, NULL };
#define syscall_unlinkat_x_indexes syscall_close_x_indexes
static int * const syscall_pread_e_indexes[] = { &hf_param_fd_int64, &hf_param_size_uint32, &hf_param_pos_uint64, NULL };
#define syscall_pread_x_indexes syscall_read_x_indexes
#define syscall_pwrite_e_indexes syscall_pread_e_indexes
#define syscall_pwrite_x_indexes syscall_read_x_indexes
#define syscall_readv_e_indexes syscall_close_e_indexes
static int * const syscall_readv_x_indexes[] = { &hf_param_res_int64, &hf_param_size_uint32, &hf_param_data_bytes, NULL };
#define syscall_writev_e_indexes syscall_read_e_indexes
#define syscall_writev_x_indexes syscall_read_x_indexes
static int * const syscall_preadv_e_indexes[] = { &hf_param_fd_int64, &hf_param_pos_uint64, NULL };
#define syscall_preadv_x_indexes syscall_readv_x_indexes
#define syscall_pwritev_e_indexes syscall_pread_e_indexes
#define syscall_pwritev_x_indexes syscall_read_x_indexes
#define syscall_dup_e_indexes syscall_close_e_indexes
#define syscall_dup_x_indexes syscall_close_x_indexes
static int * const syscall_signalfd_e_indexes[] = { &hf_param_fd_int64, &hf_param_mask_uint32, &hf_param_flags_int8, NULL };
#define syscall_signalfd_x_indexes syscall_close_x_indexes
static int * const syscall_kill_e_indexes[] = { &hf_param_pid_int64, &hf_param_sig_bytes, NULL };
#define syscall_kill_x_indexes syscall_close_x_indexes
static int * const syscall_tkill_e_indexes[] = { &hf_param_tid_int64, &hf_param_sig_bytes, NULL };
#define syscall_tkill_x_indexes syscall_close_x_indexes
static int * const syscall_tgkill_e_indexes[] = { &hf_param_pid_int64, &hf_param_tid_int64, &hf_param_sig_bytes, NULL };
#define syscall_tgkill_x_indexes syscall_close_x_indexes
static int * const syscall_nanosleep_e_indexes[] = { &hf_param_interval_bytes, NULL };
#define syscall_nanosleep_x_indexes syscall_close_x_indexes
static int * const syscall_timerfd_create_e_indexes[] = { &hf_param_clockid_uint8, &hf_param_flags_int8, NULL };
#define syscall_timerfd_create_x_indexes syscall_close_x_indexes
static int * const syscall_inotify_init_e_indexes[] = { &hf_param_flags_int8, NULL };
#define syscall_inotify_init_x_indexes syscall_close_x_indexes
static int * const syscall_getrlimit_e_indexes[] = { &hf_param_resource_bytes, NULL };
static int * const syscall_getrlimit_x_indexes[] = { &hf_param_res_int64, &hf_param_cur_int64, &hf_param_max_int64, NULL };
#define syscall_setrlimit_e_indexes syscall_getrlimit_e_indexes
#define syscall_setrlimit_x_indexes syscall_getrlimit_x_indexes
static int * const syscall_prlimit_e_indexes[] = { &hf_param_pid_int64, &hf_param_resource_bytes, NULL };
static int * const syscall_prlimit_x_indexes[] = { &hf_param_res_int64, &hf_param_newcur_int64, &hf_param_newmax_int64, &hf_param_oldcur_int64, &hf_param_oldmax_int64, NULL };
static int * const schedswitch_1_e_indexes[] = { &hf_param_next_int64, NULL };
#define schedswitch_1_x_indexes no_indexes
static int * const drop_e_indexes[] = { &hf_param_ratio_uint32, NULL };
#define drop_x_indexes drop_e_indexes
static int * const syscall_fcntl_e_indexes[] = { &hf_param_fd_int64, &hf_param_cmd_bytes, NULL };
#define syscall_fcntl_x_indexes syscall_close_x_indexes
static int * const schedswitch_6_e_indexes[] = { &hf_param_next_int64, &hf_param_pgft_maj_uint64, &hf_param_pgft_min_uint64, &hf_param_vm_size_uint32, &hf_param_vm_rss_uint32, &hf_param_vm_swap_uint32, NULL };
#define schedswitch_6_x_indexes no_indexes
#define syscall_execve_13_e_indexes no_indexes
static int * const syscall_execve_13_x_indexes[] = { &hf_param_res_int64, &hf_param_exe_string, &hf_param_args_string, &hf_param_tid_int64, &hf_param_pid_int64, &hf_param_ptid_int64, &hf_param_cwd_string, &hf_param_fdlimit_uint64, &hf_param_pgft_maj_uint64, &hf_param_pgft_min_uint64, &hf_param_vm_size_uint32, &hf_param_vm_rss_uint32, &hf_param_vm_swap_uint32, NULL };
#define syscall_clone_16_e_indexes no_indexes
static int * const syscall_clone_16_x_indexes[] = { &hf_param_res_int64, &hf_param_exe_string, &hf_param_args_string, &hf_param_tid_int64, &hf_param_pid_int64, &hf_param_ptid_int64, &hf_param_cwd_string, &hf_param_fdlimit_int64, &hf_param_pgft_maj_uint64, &hf_param_pgft_min_uint64, &hf_param_vm_size_uint32, &hf_param_vm_rss_uint32, &hf_param_vm_swap_uint32, &hf_param_flags_int32, &hf_param_uid_uint32, &hf_param_gid_uint32, NULL };
static int * const syscall_brk_4_e_indexes[] = { &hf_param_addr_uint64, NULL };
static int * const syscall_brk_4_x_indexes[] = { &hf_param_res_uint64, &hf_param_vm_size_uint32, &hf_param_vm_rss_uint32, &hf_param_vm_swap_uint32, NULL };
static int * const syscall_mmap_e_indexes[] = { &hf_param_addr_uint64, &hf_param_length_uint64, &hf_param_prot_int32, &hf_param_flags_int32, &hf_param_fd_int64, &hf_param_offset_uint64, NULL };
static int * const syscall_mmap_x_indexes[] = { &hf_param_res_int64, &hf_param_vm_size_uint32, &hf_param_vm_rss_uint32, &hf_param_vm_swap_uint32, NULL };
static int * const syscall_mmap2_e_indexes[] = { &hf_param_addr_uint64, &hf_param_length_uint64, &hf_param_prot_int32, &hf_param_flags_int32, &hf_param_fd_int64, &hf_param_pgoffset_uint64, NULL };
#define syscall_mmap2_x_indexes syscall_mmap_x_indexes
static int * const syscall_munmap_e_indexes[] = { &hf_param_addr_uint64, &hf_param_length_uint64, NULL };
#define syscall_munmap_x_indexes syscall_mmap_x_indexes
static int * const syscall_splice_e_indexes[] = { &hf_param_fd_in_int64, &hf_param_fd_out_int64, &hf_param_size_uint64, &hf_param_flags_int32, NULL };
#define syscall_splice_x_indexes syscall_close_x_indexes
static int * const syscall_ptrace_e_indexes[] = { &hf_param_request_bytes, &hf_param_pid_int64, NULL };
static int * const syscall_ptrace_x_indexes[] = { &hf_param_res_int64, &hf_param_addr_bytes, &hf_param_data_bytes, NULL };
static int * const syscall_ioctl_3_e_indexes[] = { &hf_param_fd_int64, &hf_param_request_uint64, &hf_param_argument_uint64, NULL };
#define syscall_ioctl_3_x_indexes syscall_close_x_indexes
#define syscall_execve_14_e_indexes no_indexes
static int * const syscall_execve_14_x_indexes[] = { &hf_param_res_int64, &hf_param_exe_string, &hf_param_args_string, &hf_param_tid_int64, &hf_param_pid_int64, &hf_param_ptid_int64, &hf_param_cwd_string, &hf_param_fdlimit_uint64, &hf_param_pgft_maj_uint64, &hf_param_pgft_min_uint64, &hf_param_vm_size_uint32, &hf_param_vm_rss_uint32, &hf_param_vm_swap_uint32, &hf_param_env_string, NULL };
#define syscall_rename_e_indexes no_indexes
static int * const syscall_rename_x_indexes[] = { &hf_param_res_int64, &hf_param_oldpath_string, &hf_param_newpath_string, NULL };
#define syscall_renameat_e_indexes no_indexes
static int * const syscall_renameat_x_indexes[] = { &hf_param_res_int64, &hf_param_olddirfd_int64, &hf_param_oldpath_string, &hf_param_newdirfd_int64, &hf_param_newpath_string, NULL };
#define syscall_symlink_e_indexes no_indexes
static int * const syscall_symlink_x_indexes[] = { &hf_param_res_int64, &hf_param_target_string, &hf_param_linkpath_string, NULL };
#define syscall_symlinkat_e_indexes no_indexes
static int * const syscall_symlinkat_x_indexes[] = { &hf_param_res_int64, &hf_param_target_string, &hf_param_linkdirfd_int64, &hf_param_linkpath_string, NULL };
#define syscall_fork_e_indexes no_indexes
#define syscall_fork_x_indexes syscall_clone_16_x_indexes
#define syscall_vfork_e_indexes no_indexes
#define syscall_vfork_x_indexes syscall_clone_16_x_indexes
static int * const procexit_1_e_indexes[] = { &hf_param_status_int64, &hf_param_ret_int64, &hf_param_sig_bytes, &hf_param_core_uint8, &hf_param_reaper_tid_int64, NULL };
#define procexit_1_x_indexes no_indexes
static int * const syscall_sendfile_e_indexes[] = { &hf_param_out_fd_int64, &hf_param_in_fd_int64, &hf_param_offset_uint64, &hf_param_size_uint64, NULL };
static int * const syscall_sendfile_x_indexes[] = { &hf_param_res_int64, &hf_param_offset_uint64, NULL };
static int * const syscall_quotactl_e_indexes[] = { &hf_param_cmd_int16, &hf_param_type_int8, &hf_param_id_uint32, &hf_param_quota_fmt_int8, NULL };
static int * const syscall_quotactl_x_indexes[] = { &hf_param_res_int64, &hf_param_special_string, &hf_param_quotafilepath_string, &hf_param_dqb_bhardlimit_uint64, &hf_param_dqb_bsoftlimit_uint64, &hf_param_dqb_curspace_uint64, &hf_param_dqb_ihardlimit_uint64, &hf_param_dqb_isoftlimit_uint64, &hf_param_dqb_btime_bytes, &hf_param_dqb_itime_bytes, &hf_param_dqi_bgrace_bytes, &hf_param_dqi_igrace_bytes, &hf_param_dqi_flags_int8, &hf_param_quota_fmt_out_int8, NULL };
static int * const syscall_setresuid_e_indexes[] = { &hf_param_ruid_int32, &hf_param_euid_int32, &hf_param_suid_int32, NULL };
#define syscall_setresuid_x_indexes syscall_close_x_indexes
static int * const syscall_setresgid_e_indexes[] = { &hf_param_rgid_int32, &hf_param_egid_int32, &hf_param_sgid_int32, NULL };
#define syscall_setresgid_x_indexes syscall_close_x_indexes
static int * const scapevent_e_indexes[] = { &hf_param_event_type_uint32, &hf_param_event_data_uint64, NULL };
#define scapevent_x_indexes no_indexes
static int * const syscall_setuid_e_indexes[] = { &hf_param_uid_int32, NULL };
#define syscall_setuid_x_indexes syscall_close_x_indexes
static int * const syscall_setgid_e_indexes[] = { &hf_param_gid_int32, NULL };
#define syscall_setgid_x_indexes syscall_close_x_indexes
#define syscall_getuid_e_indexes no_indexes
#define syscall_getuid_x_indexes syscall_setuid_e_indexes
#define syscall_geteuid_e_indexes no_indexes
static int * const syscall_geteuid_x_indexes[] = { &hf_param_euid_int32, NULL };
#define syscall_getgid_e_indexes no_indexes
#define syscall_getgid_x_indexes syscall_setgid_e_indexes
#define syscall_getegid_e_indexes no_indexes
static int * const syscall_getegid_x_indexes[] = { &hf_param_egid_int32, NULL };
#define syscall_getresuid_e_indexes no_indexes
static int * const syscall_getresuid_x_indexes[] = { &hf_param_res_int64, &hf_param_ruid_int32, &hf_param_euid_int32, &hf_param_suid_int32, NULL };
#define syscall_getresgid_e_indexes no_indexes
static int * const syscall_getresgid_x_indexes[] = { &hf_param_res_int64, &hf_param_rgid_int32, &hf_param_egid_int32, &hf_param_sgid_int32, NULL };
#define syscall_execve_15_e_indexes no_indexes
static int * const syscall_execve_15_x_indexes[] = { &hf_param_res_int64, &hf_param_exe_string, &hf_param_args_string, &hf_param_tid_int64, &hf_param_pid_int64, &hf_param_ptid_int64, &hf_param_cwd_string, &hf_param_fdlimit_uint64, &hf_param_pgft_maj_uint64, &hf_param_pgft_min_uint64, &hf_param_vm_size_uint32, &hf_param_vm_rss_uint32, &hf_param_vm_swap_uint32, &hf_param_comm_string, &hf_param_env_string, NULL };
#define syscall_clone_17_e_indexes no_indexes
static int * const syscall_clone_17_x_indexes[] = { &hf_param_res_int64, &hf_param_exe_string, &hf_param_args_string, &hf_param_tid_int64, &hf_param_pid_int64, &hf_param_ptid_int64, &hf_param_cwd_string, &hf_param_fdlimit_int64, &hf_param_pgft_maj_uint64, &hf_param_pgft_min_uint64, &hf_param_vm_size_uint32, &hf_param_vm_rss_uint32, &hf_param_vm_swap_uint32, &hf_param_comm_string, &hf_param_flags_int32, &hf_param_uid_uint32, &hf_param_gid_uint32, NULL };
#define syscall_fork_17_e_indexes no_indexes
#define syscall_fork_17_x_indexes syscall_clone_17_x_indexes
#define syscall_vfork_17_e_indexes no_indexes
#define syscall_vfork_17_x_indexes syscall_clone_17_x_indexes
#define syscall_clone_20_e_indexes no_indexes
static int * const syscall_clone_20_x_indexes[] = { &hf_param_res_int64, &hf_param_exe_string, &hf_param_args_string, &hf_param_tid_int64, &hf_param_pid_int64, &hf_param_ptid_int64, &hf_param_cwd_string, &hf_param_fdlimit_int64, &hf_param_pgft_maj_uint64, &hf_param_pgft_min_uint64, &hf_param_vm_size_uint32, &hf_param_vm_rss_uint32, &hf_param_vm_swap_uint32, &hf_param_comm_string, &hf_param_cgroups_bytes, &hf_param_flags_int32, &hf_param_uid_uint32, &hf_param_gid_uint32, &hf_param_vtid_int64, &hf_param_vpid_int64, &hf_param_pidns_init_start_ts_uint64, NULL };
#define syscall_fork_20_e_indexes no_indexes
#define syscall_fork_20_x_indexes syscall_clone_20_x_indexes
#define syscall_vfork_20_e_indexes no_indexes
#define syscall_vfork_20_x_indexes syscall_clone_20_x_indexes
static int * const container_e_indexes[] = { &hf_param_id_string, &hf_param_type_uint32, &hf_param_name_string, &hf_param_image_string, NULL };
#define container_x_indexes no_indexes
#define syscall_execve_16_e_indexes no_indexes
static int * const syscall_execve_16_x_indexes[] = { &hf_param_res_int64, &hf_param_exe_string, &hf_param_args_string, &hf_param_tid_int64, &hf_param_pid_int64, &hf_param_ptid_int64, &hf_param_cwd_string, &hf_param_fdlimit_uint64, &hf_param_pgft_maj_uint64, &hf_param_pgft_min_uint64, &hf_param_vm_size_uint32, &hf_param_vm_rss_uint32, &hf_param_vm_swap_uint32, &hf_param_comm_string, &hf_param_cgroups_bytes, &hf_param_env_string, NULL };
static int * const signaldeliver_e_indexes[] = { &hf_param_spid_int64, &hf_param_dpid_int64, &hf_param_sig_bytes, NULL };
#define signaldeliver_x_indexes no_indexes
static int * const procinfo_e_indexes[] = { &hf_param_cpu_usr_uint64, &hf_param_cpu_sys_uint64, NULL };
#define procinfo_x_indexes no_indexes
#define syscall_getdents_e_indexes syscall_close_e_indexes
#define syscall_getdents_x_indexes syscall_close_x_indexes
#define syscall_getdents64_e_indexes syscall_close_e_indexes
#define syscall_getdents64_x_indexes syscall_close_x_indexes
static int * const syscall_setns_e_indexes[] = { &hf_param_fd_int64, &hf_param_nstype_int32, NULL };
#define syscall_setns_x_indexes syscall_close_x_indexes
static int * const syscall_flock_e_indexes[] = { &hf_param_fd_int64, &hf_param_operation_int32, NULL };
#define syscall_flock_x_indexes syscall_close_x_indexes
static int * const cpu_hotplug_e_indexes[] = { &hf_param_cpu_uint32, &hf_param_action_uint32, NULL };
#define cpu_hotplug_x_indexes no_indexes
#define socket_accept_5_e_indexes no_indexes
static int * const socket_accept_5_x_indexes[] = { &hf_param_fd_int64, &hf_param_tuple_bytes, &hf_param_queuepct_uint8, &hf_param_queuelen_uint32, &hf_param_queuemax_uint32, NULL };
#define socket_accept4_5_e_indexes socket_accept4_e_indexes
#define socket_accept4_5_x_indexes socket_accept_5_x_indexes
static int * const syscall_semop_e_indexes[] = { &hf_param_semid_int32, NULL };
static int * const syscall_semop_x_indexes[] = { &hf_param_res_int64, &hf_param_nsops_uint32, &hf_param_sem_num_0_uint16, &hf_param_sem_op_0_int16, &hf_param_sem_flg_0_int16, &hf_param_sem_num_1_uint16, &hf_param_sem_op_1_int16, &hf_param_sem_flg_1_int16, NULL };
static int * const syscall_semctl_e_indexes[] = { &hf_param_semid_int32, &hf_param_semnum_int32, &hf_param_cmd_int16, &hf_param_val_int32, NULL };
#define syscall_semctl_x_indexes syscall_close_x_indexes
static int * const syscall_ppoll_e_indexes[] = { &hf_param_fds_bytes, &hf_param_timeout_bytes, &hf_param_sigmask_bytes, NULL };
#define syscall_ppoll_x_indexes syscall_poll_x_indexes
static int * const syscall_mount_e_indexes[] = { &hf_param_flags_int32, NULL };
static int * const syscall_mount_x_indexes[] = { &hf_param_res_int64, &hf_param_dev_string, &hf_param_dir_string, &hf_param_type_string, NULL };
#define syscall_umount_e_indexes syscall_mount_e_indexes
static int * const syscall_umount_x_indexes[] = { &hf_param_res_int64, &hf_param_name_string, NULL };
static int * const k8s_e_indexes[] = { &hf_param_json_string, NULL };
#define k8s_x_indexes no_indexes
static int * const syscall_semget_e_indexes[] = { &hf_param_key_int32, &hf_param_nsems_int32, &hf_param_semflg_int32, NULL };
#define syscall_semget_x_indexes syscall_close_x_indexes
static int * const syscall_access_e_indexes[] = { &hf_param_mode_int32, NULL };
#define syscall_access_x_indexes syscall_umount_x_indexes
#define syscall_chroot_e_indexes no_indexes
#define syscall_chroot_x_indexes syscall_stat_x_indexes
static int * const tracer_e_indexes[] = { &hf_param_id_int64, &hf_param_tags_bytes, &hf_param_args_string, NULL };
#define tracer_x_indexes tracer_e_indexes
#define mesos_e_indexes k8s_e_indexes
#define mesos_x_indexes no_indexes
#define container_json_e_indexes k8s_e_indexes
#define container_json_x_indexes no_indexes
#define syscall_setsid_e_indexes no_indexes
#define syscall_setsid_x_indexes syscall_close_x_indexes
static int * const syscall_mkdir_2_e_indexes[] = { &hf_param_mode_uint32, NULL };
#define syscall_mkdir_2_x_indexes syscall_stat_x_indexes
#define syscall_rmdir_2_e_indexes no_indexes
#define syscall_rmdir_2_x_indexes syscall_stat_x_indexes
static int * const notification_e_indexes[] = { &hf_param_id_string, &hf_param_desc_string, NULL };
#define notification_x_indexes no_indexes
#define syscall_execve_17_e_indexes no_indexes
static int * const syscall_execve_17_x_indexes[] = { &hf_param_res_int64, &hf_param_exe_string, &hf_param_args_string, &hf_param_tid_int64, &hf_param_pid_int64, &hf_param_ptid_int64, &hf_param_cwd_string, &hf_param_fdlimit_uint64, &hf_param_pgft_maj_uint64, &hf_param_pgft_min_uint64, &hf_param_vm_size_uint32, &hf_param_vm_rss_uint32, &hf_param_vm_swap_uint32, &hf_param_comm_string, &hf_param_cgroups_bytes, &hf_param_env_string, &hf_param_tty_int32, NULL };
#define syscall_unshare_e_indexes syscall_mount_e_indexes
#define syscall_unshare_x_indexes syscall_close_x_indexes
static int * const infrastructure_event_e_indexes[] = { &hf_param_source_string, &hf_param_name_string, &hf_param_description_string, &hf_param_scope_string, NULL };
#define infrastructure_event_x_indexes no_indexes
static int * const syscall_execve_18_e_indexes[] = { &hf_param_filename_string, NULL };
#define syscall_execve_18_x_indexes syscall_execve_17_x_indexes
static int * const page_fault_e_indexes[] = { &hf_param_addr_uint64, &hf_param_ip_uint64, &hf_param_error_int32, NULL };
#define page_fault_x_indexes no_indexes
#define syscall_execve_19_e_indexes syscall_execve_18_e_indexes
static int * const syscall_execve_19_x_indexes[] = { &hf_param_res_int64, &hf_param_exe_string, &hf_param_args_string, &hf_param_tid_int64, &hf_param_pid_int64, &hf_param_ptid_int64, &hf_param_cwd_string, &hf_param_fdlimit_uint64, &hf_param_pgft_maj_uint64, &hf_param_pgft_min_uint64, &hf_param_vm_size_uint32, &hf_param_vm_rss_uint32, &hf_param_vm_swap_uint32, &hf_param_comm_string, &hf_param_cgroups_bytes, &hf_param_env_string, &hf_param_tty_uint32, &hf_param_pgid_int64, &hf_param_loginuid_int32, &hf_param_flags_int32, &hf_param_cap_inheritable_uint64, &hf_param_cap_permitted_uint64, &hf_param_cap_effective_uint64, &hf_param_exe_ino_uint64, &hf_param_exe_ino_ctime_bytes, &hf_param_exe_ino_mtime_bytes, &hf_param_uid_int32, NULL };
static int * const syscall_setpgid_e_indexes[] = { &hf_param_pid_int64, &hf_param_pgid_int64, NULL };
#define syscall_setpgid_x_indexes syscall_close_x_indexes
static int * const syscall_bpf_e_indexes[] = { &hf_param_cmd_int64, NULL };
static int * const syscall_bpf_x_indexes[] = { &hf_param_res_or_fd_bytes, NULL };
static int * const syscall_seccomp_e_indexes[] = { &hf_param_op_uint64, NULL };
#define syscall_seccomp_x_indexes syscall_close_x_indexes
#define syscall_unlink_2_e_indexes no_indexes
#define syscall_unlink_2_x_indexes syscall_stat_x_indexes
#define syscall_unlinkat_2_e_indexes no_indexes
static int * const syscall_unlinkat_2_x_indexes[] = { &hf_param_res_int64, &hf_param_dirfd_int64, &hf_param_name_string, &hf_param_flags_int32, NULL };
#define syscall_mkdirat_e_indexes no_indexes
static int * const syscall_mkdirat_x_indexes[] = { &hf_param_res_int64, &hf_param_dirfd_int64, &hf_param_path_string, &hf_param_mode_uint32, NULL };
#define syscall_openat_2_e_indexes syscall_openat_e_indexes
static int * const syscall_openat_2_x_indexes[] = { &hf_param_fd_int64, &hf_param_dirfd_int64, &hf_param_name_string, &hf_param_flags_int32, &hf_param_mode_uint32, &hf_param_dev_uint32, &hf_param_ino_uint64, NULL };
#define syscall_link_2_e_indexes no_indexes
#define syscall_link_2_x_indexes syscall_rename_x_indexes
#define syscall_linkat_2_e_indexes no_indexes
static int * const syscall_linkat_2_x_indexes[] = { &hf_param_res_int64, &hf_param_olddir_int64, &hf_param_oldpath_string, &hf_param_newdir_int64, &hf_param_newpath_string, &hf_param_flags_int32, NULL };
#define syscall_fchmodat_e_indexes no_indexes
static int * const syscall_fchmodat_x_indexes[] = { &hf_param_res_int64, &hf_param_dirfd_int64, &hf_param_filename_string, &hf_param_mode_int32, NULL };
#define syscall_chmod_e_indexes no_indexes
static int * const syscall_chmod_x_indexes[] = { &hf_param_res_int64, &hf_param_filename_string, &hf_param_mode_int32, NULL };
#define syscall_fchmod_e_indexes no_indexes
static int * const syscall_fchmod_x_indexes[] = { &hf_param_res_int64, &hf_param_fd_int64, &hf_param_mode_int32, NULL };
#define syscall_renameat2_e_indexes no_indexes
static int * const syscall_renameat2_x_indexes[] = { &hf_param_res_int64, &hf_param_olddirfd_int64, &hf_param_oldpath_string, &hf_param_newdirfd_int64, &hf_param_newpath_string, &hf_param_flags_int32, NULL };
#define syscall_userfaultfd_e_indexes no_indexes
static int * const syscall_userfaultfd_x_indexes[] = { &hf_param_res_int64, &hf_param_flags_int32, NULL };
static int * const pluginevent_e_indexes[] = { &hf_param_plugin_id_uint32, &hf_param_event_data_bytes, NULL };
#define pluginevent_x_indexes no_indexes
#define container_json_2_e_indexes k8s_e_indexes
#define container_json_2_x_indexes no_indexes
static int * const syscall_openat2_e_indexes[] = { &hf_param_dirfd_int64, &hf_param_name_string, &hf_param_flags_int32, &hf_param_mode_uint32, &hf_param_resolve_int32, NULL };
static int * const syscall_openat2_x_indexes[] = { &hf_param_fd_int64, &hf_param_dirfd_int64, &hf_param_name_string, &hf_param_flags_int32, &hf_param_mode_uint32, &hf_param_resolve_int32, NULL };
static int * const syscall_mprotect_e_indexes[] = { &hf_param_addr_uint64, &hf_param_length_uint64, &hf_param_prot_int32, NULL };
#define syscall_mprotect_x_indexes syscall_close_x_indexes
static int * const syscall_execveat_e_indexes[] = { &hf_param_dirfd_int64, &hf_param_pathname_string, &hf_param_flags_int32, NULL };
#define syscall_execveat_x_indexes syscall_execve_19_x_indexes
static int * const syscall_copy_file_range_e_indexes[] = { &hf_param_fdin_int64, &hf_param_offin_uint64, &hf_param_len_uint64, NULL };
static int * const syscall_copy_file_range_x_indexes[] = { &hf_param_res_int64, &hf_param_fdout_int64, &hf_param_offout_uint64, NULL };
#define syscall_clone3_e_indexes no_indexes
#define syscall_clone3_x_indexes syscall_clone_20_x_indexes
#define syscall_open_by_handle_at_e_indexes no_indexes
static int * const syscall_open_by_handle_at_x_indexes[] = { &hf_param_fd_int64, &hf_param_mountfd_int64, &hf_param_flags_int32, &hf_param_path_string, NULL };
#define syscall_io_uring_setup_e_indexes no_indexes
static int * const syscall_io_uring_setup_x_indexes[] = { &hf_param_res_int64, &hf_param_entries_uint32, &hf_param_sq_entries_uint32, &hf_param_cq_entries_uint32, &hf_param_flags_int32, &hf_param_sq_thread_cpu_uint32, &hf_param_sq_thread_idle_uint32, &hf_param_features_int32, NULL };
#define syscall_io_uring_enter_e_indexes no_indexes
static int * const syscall_io_uring_enter_x_indexes[] = { &hf_param_res_int64, &hf_param_fd_int64, &hf_param_to_submit_uint32, &hf_param_min_complete_uint32, &hf_param_flags_int32, &hf_param_sig_bytes, NULL };
#define syscall_io_uring_register_e_indexes no_indexes
static int * const syscall_io_uring_register_x_indexes[] = { &hf_param_res_int64, &hf_param_fd_int64, &hf_param_opcode_bytes, &hf_param_arg_uint64, &hf_param_nr_args_uint32, NULL };
#define syscall_mlock_e_indexes no_indexes
static int * const syscall_mlock_x_indexes[] = { &hf_param_res_int64, &hf_param_addr_uint64, &hf_param_len_uint64, NULL };
#define syscall_munlock_e_indexes no_indexes
#define syscall_munlock_x_indexes syscall_mlock_x_indexes
#define syscall_mlockall_e_indexes no_indexes
#define syscall_mlockall_x_indexes syscall_userfaultfd_x_indexes
#define syscall_munlockall_e_indexes no_indexes
#define syscall_munlockall_x_indexes syscall_close_x_indexes
#define syscall_capset_e_indexes no_indexes
static int * const syscall_capset_x_indexes[] = { &hf_param_res_int64, &hf_param_cap_inheritable_uint64, &hf_param_cap_permitted_uint64, &hf_param_cap_effective_uint64, NULL };
static int * const user_added_e_indexes[] = { &hf_param_uid_uint32, &hf_param_gid_uint32, &hf_param_name_string, &hf_param_home_string, &hf_param_shell_string, &hf_param_container_id_string, NULL };
#define user_added_x_indexes no_indexes
#define user_deleted_e_indexes user_added_e_indexes
#define user_deleted_x_indexes no_indexes
static int * const group_added_e_indexes[] = { &hf_param_gid_uint32, &hf_param_name_string, &hf_param_container_id_string, NULL };
#define group_added_x_indexes no_indexes
#define group_deleted_e_indexes group_added_e_indexes
#define group_deleted_x_indexes no_indexes
#define syscall_dup2_e_indexes syscall_close_e_indexes
static int * const syscall_dup2_x_indexes[] = { &hf_param_res_int64, &hf_param_oldfd_int64, &hf_param_newfd_int64, NULL };
#define syscall_dup3_e_indexes syscall_close_e_indexes
static int * const syscall_dup3_x_indexes[] = { &hf_param_res_int64, &hf_param_oldfd_int64, &hf_param_newfd_int64, &hf_param_flags_int32, NULL };
#define syscall_dup_1_e_indexes syscall_close_e_indexes
static int * const syscall_dup_1_x_indexes[] = { &hf_param_res_int64, &hf_param_oldfd_int64, NULL };
#define syscall_bpf_2_e_indexes syscall_bpf_e_indexes
#define syscall_bpf_2_x_indexes syscall_close_e_indexes
#define syscall_mlock2_e_indexes no_indexes
static int * const syscall_mlock2_x_indexes[] = { &hf_param_res_int64, &hf_param_addr_uint64, &hf_param_len_uint64, &hf_param_flags_uint32, NULL };
#define syscall_fsconfig_e_indexes no_indexes
static int * const syscall_fsconfig_x_indexes[] = { &hf_param_res_int64, &hf_param_fd_int64, &hf_param_cmd_bytes, &hf_param_key_string, &hf_param_value_bytebuf_bytes, &hf_param_value_charbuf_string, &hf_param_aux_int32, NULL };
static int * const syscall_epoll_create_e_indexes[] = { &hf_param_size_int32, NULL };
#define syscall_epoll_create_x_indexes syscall_close_x_indexes
#define syscall_epoll_create1_e_indexes syscall_mount_e_indexes
#define syscall_epoll_create1_x_indexes syscall_close_x_indexes
#define syscall_chown_e_indexes no_indexes
static int * const syscall_chown_x_indexes[] = { &hf_param_res_int64, &hf_param_path_string, &hf_param_uid_uint32, &hf_param_gid_uint32, NULL };
#define syscall_lchown_e_indexes no_indexes
#define syscall_lchown_x_indexes syscall_chown_x_indexes
#define syscall_fchown_e_indexes no_indexes
static int * const syscall_fchown_x_indexes[] = { &hf_param_res_int64, &hf_param_fd_int64, &hf_param_uid_uint32, &hf_param_gid_uint32, NULL };
#define syscall_fchownat_e_indexes no_indexes
static int * const syscall_fchownat_x_indexes[] = { &hf_param_res_int64, &hf_param_dirfd_int64, &hf_param_pathname_string, &hf_param_uid_uint32, &hf_param_gid_uint32, &hf_param_flags_int32, NULL };
#define syscall_umount_1_e_indexes no_indexes
#define syscall_umount_1_x_indexes syscall_umount_x_indexes
#define socket_accept4_6_e_indexes socket_accept4_e_indexes
#define socket_accept4_6_x_indexes socket_accept_5_x_indexes
#define syscall_umount2_e_indexes syscall_mount_e_indexes
#define syscall_umount2_x_indexes syscall_umount_x_indexes
#define syscall_pipe2_e_indexes no_indexes
static int * const syscall_pipe2_x_indexes[] = { &hf_param_res_int64, &hf_param_fd1_int64, &hf_param_fd2_int64, &hf_param_ino_uint64, &hf_param_flags_int32, NULL };
#define syscall_inotify_init1_e_indexes no_indexes
static int * const syscall_inotify_init1_x_indexes[] = { &hf_param_res_int64, &hf_param_flags_int16, NULL };
static int * const syscall_eventfd2_e_indexes[] = { &hf_param_initval_uint64, NULL };
#define syscall_eventfd2_x_indexes syscall_inotify_init1_x_indexes
static int * const syscall_signalfd4_e_indexes[] = { &hf_param_fd_int64, &hf_param_mask_uint32, NULL };
#define syscall_signalfd4_x_indexes syscall_inotify_init1_x_indexes
#define syscall_prctl_e_indexes no_indexes
static int * const syscall_prctl_x_indexes[] = { &hf_param_res_int64, &hf_param_option_bytes, &hf_param_arg2_str_string, &hf_param_arg2_int_int64, NULL };
static int * const asyncevent_e_indexes[] = { &hf_param_plugin_id_uint32, &hf_param_name_string, &hf_param_data_bytes, NULL };
#define asyncevent_x_indexes no_indexes
#define syscall_memfd_create_e_indexes no_indexes
static int * const syscall_memfd_create_x_indexes[] = { &hf_param_fd_int64, &hf_param_name_string, &hf_param_flags_int32, NULL };
#define syscall_pidfd_getfd_e_indexes no_indexes
static int * const syscall_pidfd_getfd_x_indexes[] = { &hf_param_fd_int64, &hf_param_pid_fd_int64, &hf_param_target_fd_int64, &hf_param_flags_int32, NULL };
#define syscall_pidfd_open_e_indexes no_indexes
static int * const syscall_pidfd_open_x_indexes[] = { &hf_param_fd_int64, &hf_param_pid_int64, &hf_param_flags_int32, NULL };
#define syscall_init_module_e_indexes no_indexes
static int * const syscall_init_module_x_indexes[] = { &hf_param_res_int64, &hf_param_img_bytes, &hf_param_length_uint64, &hf_param_uargs_string, NULL };
#define syscall_finit_module_e_indexes no_indexes
static int * const syscall_finit_module_x_indexes[] = { &hf_param_res_int64, &hf_param_fd_int64, &hf_param_uargs_string, &hf_param_flags_int32, NULL };
#define syscall_mknod_e_indexes no_indexes
static int * const syscall_mknod_x_indexes[] = { &hf_param_res_int64, &hf_param_path_string, &hf_param_mode_int32, &hf_param_dev_uint32, NULL };
#define syscall_mknodat_e_indexes no_indexes
static int * const syscall_mknodat_x_indexes[] = { &hf_param_res_int64, &hf_param_dirfd_int64, &hf_param_path_string, &hf_param_mode_int32, &hf_param_dev_uint32, NULL };
static const struct _event_tree_info event_tree_info[] = {
/* Event tree. Automatically generated by tools/generate-sysdig-event.py */
{ EVT_GENERIC_E, generic_e_indexes },
{ EVT_GENERIC_X, generic_x_indexes },
{ EVT_SYSCALL_OPEN_E, syscall_open_e_indexes },
{ EVT_SYSCALL_OPEN_X, syscall_open_x_indexes },
{ EVT_SYSCALL_CLOSE_E, syscall_close_e_indexes },
{ EVT_SYSCALL_CLOSE_X, syscall_close_x_indexes },
{ EVT_SYSCALL_READ_E, syscall_read_e_indexes },
{ EVT_SYSCALL_READ_X, syscall_read_x_indexes },
{ EVT_SYSCALL_WRITE_E, syscall_write_e_indexes },
{ EVT_SYSCALL_WRITE_X, syscall_write_x_indexes },
{ EVT_SYSCALL_BRK_1_E, syscall_brk_1_e_indexes },
{ EVT_SYSCALL_BRK_1_X, syscall_brk_1_x_indexes },
{ EVT_SYSCALL_EXECVE_8_E, syscall_execve_8_e_indexes },
{ EVT_SYSCALL_EXECVE_8_X, syscall_execve_8_x_indexes },
{ EVT_SYSCALL_CLONE_11_E, syscall_clone_11_e_indexes },
{ EVT_SYSCALL_CLONE_11_X, syscall_clone_11_x_indexes },
{ EVT_PROCEXIT_E, procexit_e_indexes },
{ EVT_PROCEXIT_X, procexit_x_indexes },
{ EVT_SOCKET_SOCKET_E, socket_socket_e_indexes },
{ EVT_SOCKET_SOCKET_X, socket_socket_x_indexes },
{ EVT_SOCKET_BIND_E, socket_bind_e_indexes },
{ EVT_SOCKET_BIND_X, socket_bind_x_indexes },
{ EVT_SOCKET_CONNECT_E, socket_connect_e_indexes },
{ EVT_SOCKET_CONNECT_X, socket_connect_x_indexes },
{ EVT_SOCKET_LISTEN_E, socket_listen_e_indexes },
{ EVT_SOCKET_LISTEN_X, socket_listen_x_indexes },
{ EVT_SOCKET_ACCEPT_E, socket_accept_e_indexes },
{ EVT_SOCKET_ACCEPT_X, socket_accept_x_indexes },
{ EVT_SOCKET_SEND_E, socket_send_e_indexes },
{ EVT_SOCKET_SEND_X, socket_send_x_indexes },
{ EVT_SOCKET_SENDTO_E, socket_sendto_e_indexes },
{ EVT_SOCKET_SENDTO_X, socket_sendto_x_indexes },
{ EVT_SOCKET_RECV_E, socket_recv_e_indexes },
{ EVT_SOCKET_RECV_X, socket_recv_x_indexes },
{ EVT_SOCKET_RECVFROM_E, socket_recvfrom_e_indexes },
{ EVT_SOCKET_RECVFROM_X, socket_recvfrom_x_indexes },
{ EVT_SOCKET_SHUTDOWN_E, socket_shutdown_e_indexes },
{ EVT_SOCKET_SHUTDOWN_X, socket_shutdown_x_indexes },
{ EVT_SOCKET_GETSOCKNAME_E, socket_getsockname_e_indexes },
{ EVT_SOCKET_GETSOCKNAME_X, socket_getsockname_x_indexes },
{ EVT_SOCKET_GETPEERNAME_E, socket_getpeername_e_indexes },
{ EVT_SOCKET_GETPEERNAME_X, socket_getpeername_x_indexes },
{ EVT_SOCKET_SOCKETPAIR_E, socket_socketpair_e_indexes },
{ EVT_SOCKET_SOCKETPAIR_X, socket_socketpair_x_indexes },
{ EVT_SOCKET_SETSOCKOPT_E, socket_setsockopt_e_indexes },
{ EVT_SOCKET_SETSOCKOPT_X, socket_setsockopt_x_indexes },
{ EVT_SOCKET_GETSOCKOPT_E, socket_getsockopt_e_indexes },
{ EVT_SOCKET_GETSOCKOPT_X, socket_getsockopt_x_indexes },
{ EVT_SOCKET_SENDMSG_E, socket_sendmsg_e_indexes },
{ EVT_SOCKET_SENDMSG_X, socket_sendmsg_x_indexes },
{ EVT_SOCKET_SENDMMSG_E, socket_sendmmsg_e_indexes },
{ EVT_SOCKET_SENDMMSG_X, socket_sendmmsg_x_indexes },
{ EVT_SOCKET_RECVMSG_E, socket_recvmsg_e_indexes },
{ EVT_SOCKET_RECVMSG_X, socket_recvmsg_x_indexes },
{ EVT_SOCKET_RECVMMSG_E, socket_recvmmsg_e_indexes },
{ EVT_SOCKET_RECVMMSG_X, socket_recvmmsg_x_indexes },
{ EVT_SOCKET_ACCEPT4_E, socket_accept4_e_indexes },
{ EVT_SOCKET_ACCEPT4_X, socket_accept4_x_indexes },
{ EVT_SYSCALL_CREAT_E, syscall_creat_e_indexes },
{ EVT_SYSCALL_CREAT_X, syscall_creat_x_indexes },
{ EVT_SYSCALL_PIPE_E, syscall_pipe_e_indexes },
{ EVT_SYSCALL_PIPE_X, syscall_pipe_x_indexes },
{ EVT_SYSCALL_EVENTFD_E, syscall_eventfd_e_indexes },
{ EVT_SYSCALL_EVENTFD_X, syscall_eventfd_x_indexes },
{ EVT_SYSCALL_FUTEX_E, syscall_futex_e_indexes },
{ EVT_SYSCALL_FUTEX_X, syscall_futex_x_indexes },
{ EVT_SYSCALL_STAT_E, syscall_stat_e_indexes },
{ EVT_SYSCALL_STAT_X, syscall_stat_x_indexes },
{ EVT_SYSCALL_LSTAT_E, syscall_lstat_e_indexes },
{ EVT_SYSCALL_LSTAT_X, syscall_lstat_x_indexes },
{ EVT_SYSCALL_FSTAT_E, syscall_fstat_e_indexes },
{ EVT_SYSCALL_FSTAT_X, syscall_fstat_x_indexes },
{ EVT_SYSCALL_STAT64_E, syscall_stat64_e_indexes },
{ EVT_SYSCALL_STAT64_X, syscall_stat64_x_indexes },
{ EVT_SYSCALL_LSTAT64_E, syscall_lstat64_e_indexes },
{ EVT_SYSCALL_LSTAT64_X, syscall_lstat64_x_indexes },
{ EVT_SYSCALL_FSTAT64_E, syscall_fstat64_e_indexes },
{ EVT_SYSCALL_FSTAT64_X, syscall_fstat64_x_indexes },
{ EVT_SYSCALL_EPOLLWAIT_E, syscall_epollwait_e_indexes },
{ EVT_SYSCALL_EPOLLWAIT_X, syscall_epollwait_x_indexes },
{ EVT_SYSCALL_POLL_E, syscall_poll_e_indexes },
{ EVT_SYSCALL_POLL_X, syscall_poll_x_indexes },
{ EVT_SYSCALL_SELECT_E, syscall_select_e_indexes },
{ EVT_SYSCALL_SELECT_X, syscall_select_x_indexes },
{ EVT_SYSCALL_NEWSELECT_E, syscall_newselect_e_indexes },
{ EVT_SYSCALL_NEWSELECT_X, syscall_newselect_x_indexes },
{ EVT_SYSCALL_LSEEK_E, syscall_lseek_e_indexes },
{ EVT_SYSCALL_LSEEK_X, syscall_lseek_x_indexes },
{ EVT_SYSCALL_LLSEEK_E, syscall_llseek_e_indexes },
{ EVT_SYSCALL_LLSEEK_X, syscall_llseek_x_indexes },
{ EVT_SYSCALL_IOCTL_2_E, syscall_ioctl_2_e_indexes },
{ EVT_SYSCALL_IOCTL_2_X, syscall_ioctl_2_x_indexes },
{ EVT_SYSCALL_GETCWD_E, syscall_getcwd_e_indexes },
{ EVT_SYSCALL_GETCWD_X, syscall_getcwd_x_indexes },
{ EVT_SYSCALL_CHDIR_E, syscall_chdir_e_indexes },
{ EVT_SYSCALL_CHDIR_X, syscall_chdir_x_indexes },
{ EVT_SYSCALL_FCHDIR_E, syscall_fchdir_e_indexes },
{ EVT_SYSCALL_FCHDIR_X, syscall_fchdir_x_indexes },
{ EVT_SYSCALL_MKDIR_E, syscall_mkdir_e_indexes },
{ EVT_SYSCALL_MKDIR_X, syscall_mkdir_x_indexes },
{ EVT_SYSCALL_RMDIR_E, syscall_rmdir_e_indexes },
{ EVT_SYSCALL_RMDIR_X, syscall_rmdir_x_indexes },
{ EVT_SYSCALL_OPENAT_E, syscall_openat_e_indexes },
{ EVT_SYSCALL_OPENAT_X, syscall_openat_x_indexes },
{ EVT_SYSCALL_LINK_E, syscall_link_e_indexes },
{ EVT_SYSCALL_LINK_X, syscall_link_x_indexes },
{ EVT_SYSCALL_LINKAT_E, syscall_linkat_e_indexes },
{ EVT_SYSCALL_LINKAT_X, syscall_linkat_x_indexes },
{ EVT_SYSCALL_UNLINK_E, syscall_unlink_e_indexes },
{ EVT_SYSCALL_UNLINK_X, syscall_unlink_x_indexes },
{ EVT_SYSCALL_UNLINKAT_E, syscall_unlinkat_e_indexes },
{ EVT_SYSCALL_UNLINKAT_X, syscall_unlinkat_x_indexes },
{ EVT_SYSCALL_PREAD_E, syscall_pread_e_indexes },
{ EVT_SYSCALL_PREAD_X, syscall_pread_x_indexes },
{ EVT_SYSCALL_PWRITE_E, syscall_pwrite_e_indexes },
{ EVT_SYSCALL_PWRITE_X, syscall_pwrite_x_indexes },
{ EVT_SYSCALL_READV_E, syscall_readv_e_indexes },
{ EVT_SYSCALL_READV_X, syscall_readv_x_indexes },
{ EVT_SYSCALL_WRITEV_E, syscall_writev_e_indexes },
{ EVT_SYSCALL_WRITEV_X, syscall_writev_x_indexes },
{ EVT_SYSCALL_PREADV_E, syscall_preadv_e_indexes },
{ EVT_SYSCALL_PREADV_X, syscall_preadv_x_indexes },
{ EVT_SYSCALL_PWRITEV_E, syscall_pwritev_e_indexes },
{ EVT_SYSCALL_PWRITEV_X, syscall_pwritev_x_indexes },
{ EVT_SYSCALL_DUP_E, syscall_dup_e_indexes },
{ EVT_SYSCALL_DUP_X, syscall_dup_x_indexes },
{ EVT_SYSCALL_SIGNALFD_E, syscall_signalfd_e_indexes },
{ EVT_SYSCALL_SIGNALFD_X, syscall_signalfd_x_indexes },
{ EVT_SYSCALL_KILL_E, syscall_kill_e_indexes },
{ EVT_SYSCALL_KILL_X, syscall_kill_x_indexes },
{ EVT_SYSCALL_TKILL_E, syscall_tkill_e_indexes },
{ EVT_SYSCALL_TKILL_X, syscall_tkill_x_indexes },
{ EVT_SYSCALL_TGKILL_E, syscall_tgkill_e_indexes },
{ EVT_SYSCALL_TGKILL_X, syscall_tgkill_x_indexes },
{ EVT_SYSCALL_NANOSLEEP_E, syscall_nanosleep_e_indexes },
{ EVT_SYSCALL_NANOSLEEP_X, syscall_nanosleep_x_indexes },
{ EVT_SYSCALL_TIMERFD_CREATE_E, syscall_timerfd_create_e_indexes },
{ EVT_SYSCALL_TIMERFD_CREATE_X, syscall_timerfd_create_x_indexes },
{ EVT_SYSCALL_INOTIFY_INIT_E, syscall_inotify_init_e_indexes },
{ EVT_SYSCALL_INOTIFY_INIT_X, syscall_inotify_init_x_indexes },
{ EVT_SYSCALL_GETRLIMIT_E, syscall_getrlimit_e_indexes },
{ EVT_SYSCALL_GETRLIMIT_X, syscall_getrlimit_x_indexes },
{ EVT_SYSCALL_SETRLIMIT_E, syscall_setrlimit_e_indexes },
{ EVT_SYSCALL_SETRLIMIT_X, syscall_setrlimit_x_indexes },
{ EVT_SYSCALL_PRLIMIT_E, syscall_prlimit_e_indexes },
{ EVT_SYSCALL_PRLIMIT_X, syscall_prlimit_x_indexes },
{ EVT_SCHEDSWITCH_1_E, schedswitch_1_e_indexes },
{ EVT_SCHEDSWITCH_1_X, schedswitch_1_x_indexes },
{ EVT_DROP_E, drop_e_indexes },
{ EVT_DROP_X, drop_x_indexes },
{ EVT_SYSCALL_FCNTL_E, syscall_fcntl_e_indexes },
{ EVT_SYSCALL_FCNTL_X, syscall_fcntl_x_indexes },
{ EVT_SCHEDSWITCH_6_E, schedswitch_6_e_indexes },
{ EVT_SCHEDSWITCH_6_X, schedswitch_6_x_indexes },
{ EVT_SYSCALL_EXECVE_13_E, syscall_execve_13_e_indexes },
{ EVT_SYSCALL_EXECVE_13_X, syscall_execve_13_x_indexes },
{ EVT_SYSCALL_CLONE_16_E, syscall_clone_16_e_indexes },
{ EVT_SYSCALL_CLONE_16_X, syscall_clone_16_x_indexes },
{ EVT_SYSCALL_BRK_4_E, syscall_brk_4_e_indexes },
{ EVT_SYSCALL_BRK_4_X, syscall_brk_4_x_indexes },
{ EVT_SYSCALL_MMAP_E, syscall_mmap_e_indexes },
{ EVT_SYSCALL_MMAP_X, syscall_mmap_x_indexes },
{ EVT_SYSCALL_MMAP2_E, syscall_mmap2_e_indexes },
{ EVT_SYSCALL_MMAP2_X, syscall_mmap2_x_indexes },
{ EVT_SYSCALL_MUNMAP_E, syscall_munmap_e_indexes },
{ EVT_SYSCALL_MUNMAP_X, syscall_munmap_x_indexes },
{ EVT_SYSCALL_SPLICE_E, syscall_splice_e_indexes },
{ EVT_SYSCALL_SPLICE_X, syscall_splice_x_indexes },
{ EVT_SYSCALL_PTRACE_E, syscall_ptrace_e_indexes },
{ EVT_SYSCALL_PTRACE_X, syscall_ptrace_x_indexes },
{ EVT_SYSCALL_IOCTL_3_E, syscall_ioctl_3_e_indexes },
{ EVT_SYSCALL_IOCTL_3_X, syscall_ioctl_3_x_indexes },
{ EVT_SYSCALL_EXECVE_14_E, syscall_execve_14_e_indexes },
{ EVT_SYSCALL_EXECVE_14_X, syscall_execve_14_x_indexes },
{ EVT_SYSCALL_RENAME_E, syscall_rename_e_indexes },
{ EVT_SYSCALL_RENAME_X, syscall_rename_x_indexes },
{ EVT_SYSCALL_RENAMEAT_E, syscall_renameat_e_indexes },
{ EVT_SYSCALL_RENAMEAT_X, syscall_renameat_x_indexes },
{ EVT_SYSCALL_SYMLINK_E, syscall_symlink_e_indexes },
{ EVT_SYSCALL_SYMLINK_X, syscall_symlink_x_indexes },
{ EVT_SYSCALL_SYMLINKAT_E, syscall_symlinkat_e_indexes },
{ EVT_SYSCALL_SYMLINKAT_X, syscall_symlinkat_x_indexes },
{ EVT_SYSCALL_FORK_E, syscall_fork_e_indexes },
{ EVT_SYSCALL_FORK_X, syscall_fork_x_indexes },
{ EVT_SYSCALL_VFORK_E, syscall_vfork_e_indexes },
{ EVT_SYSCALL_VFORK_X, syscall_vfork_x_indexes },
{ EVT_PROCEXIT_1_E, procexit_1_e_indexes },
{ EVT_PROCEXIT_1_X, procexit_1_x_indexes },
{ EVT_SYSCALL_SENDFILE_E, syscall_sendfile_e_indexes },
{ EVT_SYSCALL_SENDFILE_X, syscall_sendfile_x_indexes },
{ EVT_SYSCALL_QUOTACTL_E, syscall_quotactl_e_indexes },
{ EVT_SYSCALL_QUOTACTL_X, syscall_quotactl_x_indexes },
{ EVT_SYSCALL_SETRESUID_E, syscall_setresuid_e_indexes },
{ EVT_SYSCALL_SETRESUID_X, syscall_setresuid_x_indexes },
{ EVT_SYSCALL_SETRESGID_E, syscall_setresgid_e_indexes },
{ EVT_SYSCALL_SETRESGID_X, syscall_setresgid_x_indexes },
{ EVT_SCAPEVENT_E, scapevent_e_indexes },
{ EVT_SCAPEVENT_X, scapevent_x_indexes },
{ EVT_SYSCALL_SETUID_E, syscall_setuid_e_indexes },
{ EVT_SYSCALL_SETUID_X, syscall_setuid_x_indexes },
{ EVT_SYSCALL_SETGID_E, syscall_setgid_e_indexes },
{ EVT_SYSCALL_SETGID_X, syscall_setgid_x_indexes },
{ EVT_SYSCALL_GETUID_E, syscall_getuid_e_indexes },
{ EVT_SYSCALL_GETUID_X, syscall_getuid_x_indexes },
{ EVT_SYSCALL_GETEUID_E, syscall_geteuid_e_indexes },
{ EVT_SYSCALL_GETEUID_X, syscall_geteuid_x_indexes },
{ EVT_SYSCALL_GETGID_E, syscall_getgid_e_indexes },
{ EVT_SYSCALL_GETGID_X, syscall_getgid_x_indexes },
{ EVT_SYSCALL_GETEGID_E, syscall_getegid_e_indexes },
{ EVT_SYSCALL_GETEGID_X, syscall_getegid_x_indexes },
{ EVT_SYSCALL_GETRESUID_E, syscall_getresuid_e_indexes },
{ EVT_SYSCALL_GETRESUID_X, syscall_getresuid_x_indexes },
{ EVT_SYSCALL_GETRESGID_E, syscall_getresgid_e_indexes },
{ EVT_SYSCALL_GETRESGID_X, syscall_getresgid_x_indexes },
{ EVT_SYSCALL_EXECVE_15_E, syscall_execve_15_e_indexes },
{ EVT_SYSCALL_EXECVE_15_X, syscall_execve_15_x_indexes },
{ EVT_SYSCALL_CLONE_17_E, syscall_clone_17_e_indexes },
{ EVT_SYSCALL_CLONE_17_X, syscall_clone_17_x_indexes },
{ EVT_SYSCALL_FORK_17_E, syscall_fork_17_e_indexes },
{ EVT_SYSCALL_FORK_17_X, syscall_fork_17_x_indexes },
{ EVT_SYSCALL_VFORK_17_E, syscall_vfork_17_e_indexes },
{ EVT_SYSCALL_VFORK_17_X, syscall_vfork_17_x_indexes },
{ EVT_SYSCALL_CLONE_20_E, syscall_clone_20_e_indexes },
{ EVT_SYSCALL_CLONE_20_X, syscall_clone_20_x_indexes },
{ EVT_SYSCALL_FORK_20_E, syscall_fork_20_e_indexes },
{ EVT_SYSCALL_FORK_20_X, syscall_fork_20_x_indexes },
{ EVT_SYSCALL_VFORK_20_E, syscall_vfork_20_e_indexes },
{ EVT_SYSCALL_VFORK_20_X, syscall_vfork_20_x_indexes },
{ EVT_CONTAINER_E, container_e_indexes },
{ EVT_CONTAINER_X, container_x_indexes },
{ EVT_SYSCALL_EXECVE_16_E, syscall_execve_16_e_indexes },
{ EVT_SYSCALL_EXECVE_16_X, syscall_execve_16_x_indexes },
{ EVT_SIGNALDELIVER_E, signaldeliver_e_indexes },
{ EVT_SIGNALDELIVER_X, signaldeliver_x_indexes },
{ EVT_PROCINFO_E, procinfo_e_indexes },
{ EVT_PROCINFO_X, procinfo_x_indexes },
{ EVT_SYSCALL_GETDENTS_E, syscall_getdents_e_indexes },
{ EVT_SYSCALL_GETDENTS_X, syscall_getdents_x_indexes },
{ EVT_SYSCALL_GETDENTS64_E, syscall_getdents64_e_indexes },
{ EVT_SYSCALL_GETDENTS64_X, syscall_getdents64_x_indexes },
{ EVT_SYSCALL_SETNS_E, syscall_setns_e_indexes },
{ EVT_SYSCALL_SETNS_X, syscall_setns_x_indexes },
{ EVT_SYSCALL_FLOCK_E, syscall_flock_e_indexes },
{ EVT_SYSCALL_FLOCK_X, syscall_flock_x_indexes },
{ EVT_CPU_HOTPLUG_E, cpu_hotplug_e_indexes },
{ EVT_CPU_HOTPLUG_X, cpu_hotplug_x_indexes },
{ EVT_SOCKET_ACCEPT_5_E, socket_accept_5_e_indexes },
{ EVT_SOCKET_ACCEPT_5_X, socket_accept_5_x_indexes },
{ EVT_SOCKET_ACCEPT4_5_E, socket_accept4_5_e_indexes },
{ EVT_SOCKET_ACCEPT4_5_X, socket_accept4_5_x_indexes },
{ EVT_SYSCALL_SEMOP_E, syscall_semop_e_indexes },
{ EVT_SYSCALL_SEMOP_X, syscall_semop_x_indexes },
{ EVT_SYSCALL_SEMCTL_E, syscall_semctl_e_indexes },
{ EVT_SYSCALL_SEMCTL_X, syscall_semctl_x_indexes },
{ EVT_SYSCALL_PPOLL_E, syscall_ppoll_e_indexes },
{ EVT_SYSCALL_PPOLL_X, syscall_ppoll_x_indexes },
{ EVT_SYSCALL_MOUNT_E, syscall_mount_e_indexes },
{ EVT_SYSCALL_MOUNT_X, syscall_mount_x_indexes },
{ EVT_SYSCALL_UMOUNT_E, syscall_umount_e_indexes },
{ EVT_SYSCALL_UMOUNT_X, syscall_umount_x_indexes },
{ EVT_K8S_E, k8s_e_indexes },
{ EVT_K8S_X, k8s_x_indexes },
{ EVT_SYSCALL_SEMGET_E, syscall_semget_e_indexes },
{ EVT_SYSCALL_SEMGET_X, syscall_semget_x_indexes },
{ EVT_SYSCALL_ACCESS_E, syscall_access_e_indexes },
{ EVT_SYSCALL_ACCESS_X, syscall_access_x_indexes },
{ EVT_SYSCALL_CHROOT_E, syscall_chroot_e_indexes },
{ EVT_SYSCALL_CHROOT_X, syscall_chroot_x_indexes },
{ EVT_TRACER_E, tracer_e_indexes },
{ EVT_TRACER_X, tracer_x_indexes },
{ EVT_MESOS_E, mesos_e_indexes },
{ EVT_MESOS_X, mesos_x_indexes },
{ EVT_CONTAINER_JSON_E, container_json_e_indexes },
{ EVT_CONTAINER_JSON_X, container_json_x_indexes },
{ EVT_SYSCALL_SETSID_E, syscall_setsid_e_indexes },
{ EVT_SYSCALL_SETSID_X, syscall_setsid_x_indexes },
{ EVT_SYSCALL_MKDIR_2_E, syscall_mkdir_2_e_indexes },
{ EVT_SYSCALL_MKDIR_2_X, syscall_mkdir_2_x_indexes },
{ EVT_SYSCALL_RMDIR_2_E, syscall_rmdir_2_e_indexes },
{ EVT_SYSCALL_RMDIR_2_X, syscall_rmdir_2_x_indexes },
{ EVT_NOTIFICATION_E, notification_e_indexes },
{ EVT_NOTIFICATION_X, notification_x_indexes },
{ EVT_SYSCALL_EXECVE_17_E, syscall_execve_17_e_indexes },
{ EVT_SYSCALL_EXECVE_17_X, syscall_execve_17_x_indexes },
{ EVT_SYSCALL_UNSHARE_E, syscall_unshare_e_indexes },
{ EVT_SYSCALL_UNSHARE_X, syscall_unshare_x_indexes },
{ EVT_INFRASTRUCTURE_EVENT_E, infrastructure_event_e_indexes },
{ EVT_INFRASTRUCTURE_EVENT_X, infrastructure_event_x_indexes },
{ EVT_SYSCALL_EXECVE_18_E, syscall_execve_18_e_indexes },
{ EVT_SYSCALL_EXECVE_18_X, syscall_execve_18_x_indexes },
{ EVT_PAGE_FAULT_E, page_fault_e_indexes },
{ EVT_PAGE_FAULT_X, page_fault_x_indexes },
{ EVT_SYSCALL_EXECVE_19_E, syscall_execve_19_e_indexes },
{ EVT_SYSCALL_EXECVE_19_X, syscall_execve_19_x_indexes },
{ EVT_SYSCALL_SETPGID_E, syscall_setpgid_e_indexes },
{ EVT_SYSCALL_SETPGID_X, syscall_setpgid_x_indexes },
{ EVT_SYSCALL_BPF_E, syscall_bpf_e_indexes },
{ EVT_SYSCALL_BPF_X, syscall_bpf_x_indexes },
{ EVT_SYSCALL_SECCOMP_E, syscall_seccomp_e_indexes },
{ EVT_SYSCALL_SECCOMP_X, syscall_seccomp_x_indexes },
{ EVT_SYSCALL_UNLINK_2_E, syscall_unlink_2_e_indexes },
{ EVT_SYSCALL_UNLINK_2_X, syscall_unlink_2_x_indexes },
{ EVT_SYSCALL_UNLINKAT_2_E, syscall_unlinkat_2_e_indexes },
{ EVT_SYSCALL_UNLINKAT_2_X, syscall_unlinkat_2_x_indexes },
{ EVT_SYSCALL_MKDIRAT_E, syscall_mkdirat_e_indexes },
{ EVT_SYSCALL_MKDIRAT_X, syscall_mkdirat_x_indexes },
{ EVT_SYSCALL_OPENAT_2_E, syscall_openat_2_e_indexes },
{ EVT_SYSCALL_OPENAT_2_X, syscall_openat_2_x_indexes },
{ EVT_SYSCALL_LINK_2_E, syscall_link_2_e_indexes },
{ EVT_SYSCALL_LINK_2_X, syscall_link_2_x_indexes },
{ EVT_SYSCALL_LINKAT_2_E, syscall_linkat_2_e_indexes },
{ EVT_SYSCALL_LINKAT_2_X, syscall_linkat_2_x_indexes },
{ EVT_SYSCALL_FCHMODAT_E, syscall_fchmodat_e_indexes },
{ EVT_SYSCALL_FCHMODAT_X, syscall_fchmodat_x_indexes },
{ EVT_SYSCALL_CHMOD_E, syscall_chmod_e_indexes },
{ EVT_SYSCALL_CHMOD_X, syscall_chmod_x_indexes },
{ EVT_SYSCALL_FCHMOD_E, syscall_fchmod_e_indexes },
{ EVT_SYSCALL_FCHMOD_X, syscall_fchmod_x_indexes },
{ EVT_SYSCALL_RENAMEAT2_E, syscall_renameat2_e_indexes },
{ EVT_SYSCALL_RENAMEAT2_X, syscall_renameat2_x_indexes },
{ EVT_SYSCALL_USERFAULTFD_E, syscall_userfaultfd_e_indexes },
{ EVT_SYSCALL_USERFAULTFD_X, syscall_userfaultfd_x_indexes },
{ EVT_PLUGINEVENT_E, pluginevent_e_indexes },
{ EVT_PLUGINEVENT_X, pluginevent_x_indexes },
{ EVT_CONTAINER_JSON_2_E, container_json_2_e_indexes },
{ EVT_CONTAINER_JSON_2_X, container_json_2_x_indexes },
{ EVT_SYSCALL_OPENAT2_E, syscall_openat2_e_indexes },
{ EVT_SYSCALL_OPENAT2_X, syscall_openat2_x_indexes },
{ EVT_SYSCALL_MPROTECT_E, syscall_mprotect_e_indexes },
{ EVT_SYSCALL_MPROTECT_X, syscall_mprotect_x_indexes },
{ EVT_SYSCALL_EXECVEAT_E, syscall_execveat_e_indexes },
{ EVT_SYSCALL_EXECVEAT_X, syscall_execveat_x_indexes },
{ EVT_SYSCALL_COPY_FILE_RANGE_E, syscall_copy_file_range_e_indexes },
{ EVT_SYSCALL_COPY_FILE_RANGE_X, syscall_copy_file_range_x_indexes },
{ EVT_SYSCALL_CLONE3_E, syscall_clone3_e_indexes },
{ EVT_SYSCALL_CLONE3_X, syscall_clone3_x_indexes },
{ EVT_SYSCALL_OPEN_BY_HANDLE_AT_E, syscall_open_by_handle_at_e_indexes },
{ EVT_SYSCALL_OPEN_BY_HANDLE_AT_X, syscall_open_by_handle_at_x_indexes },
{ EVT_SYSCALL_IO_URING_SETUP_E, syscall_io_uring_setup_e_indexes },
{ EVT_SYSCALL_IO_URING_SETUP_X, syscall_io_uring_setup_x_indexes },
{ EVT_SYSCALL_IO_URING_ENTER_E, syscall_io_uring_enter_e_indexes },
{ EVT_SYSCALL_IO_URING_ENTER_X, syscall_io_uring_enter_x_indexes },
{ EVT_SYSCALL_IO_URING_REGISTER_E, syscall_io_uring_register_e_indexes },
{ EVT_SYSCALL_IO_URING_REGISTER_X, syscall_io_uring_register_x_indexes },
{ EVT_SYSCALL_MLOCK_E, syscall_mlock_e_indexes },
{ EVT_SYSCALL_MLOCK_X, syscall_mlock_x_indexes },
{ EVT_SYSCALL_MUNLOCK_E, syscall_munlock_e_indexes },
{ EVT_SYSCALL_MUNLOCK_X, syscall_munlock_x_indexes },
{ EVT_SYSCALL_MLOCKALL_E, syscall_mlockall_e_indexes },
{ EVT_SYSCALL_MLOCKALL_X, syscall_mlockall_x_indexes },
{ EVT_SYSCALL_MUNLOCKALL_E, syscall_munlockall_e_indexes },
{ EVT_SYSCALL_MUNLOCKALL_X, syscall_munlockall_x_indexes },
{ EVT_SYSCALL_CAPSET_E, syscall_capset_e_indexes },
{ EVT_SYSCALL_CAPSET_X, syscall_capset_x_indexes },
{ EVT_USER_ADDED_E, user_added_e_indexes },
{ EVT_USER_ADDED_X, user_added_x_indexes },
{ EVT_USER_DELETED_E, user_deleted_e_indexes },
{ EVT_USER_DELETED_X, user_deleted_x_indexes },
{ EVT_GROUP_ADDED_E, group_added_e_indexes },
{ EVT_GROUP_ADDED_X, group_added_x_indexes },
{ EVT_GROUP_DELETED_E, group_deleted_e_indexes },
{ EVT_GROUP_DELETED_X, group_deleted_x_indexes },
{ EVT_SYSCALL_DUP2_E, syscall_dup2_e_indexes },
{ EVT_SYSCALL_DUP2_X, syscall_dup2_x_indexes },
{ EVT_SYSCALL_DUP3_E, syscall_dup3_e_indexes },
{ EVT_SYSCALL_DUP3_X, syscall_dup3_x_indexes },
{ EVT_SYSCALL_DUP_1_E, syscall_dup_1_e_indexes },
{ EVT_SYSCALL_DUP_1_X, syscall_dup_1_x_indexes },
{ EVT_SYSCALL_BPF_2_E, syscall_bpf_2_e_indexes },
{ EVT_SYSCALL_BPF_2_X, syscall_bpf_2_x_indexes },
{ EVT_SYSCALL_MLOCK2_E, syscall_mlock2_e_indexes },
{ EVT_SYSCALL_MLOCK2_X, syscall_mlock2_x_indexes },
{ EVT_SYSCALL_FSCONFIG_E, syscall_fsconfig_e_indexes },
{ EVT_SYSCALL_FSCONFIG_X, syscall_fsconfig_x_indexes },
{ EVT_SYSCALL_EPOLL_CREATE_E, syscall_epoll_create_e_indexes },
{ EVT_SYSCALL_EPOLL_CREATE_X, syscall_epoll_create_x_indexes },
{ EVT_SYSCALL_EPOLL_CREATE1_E, syscall_epoll_create1_e_indexes },
{ EVT_SYSCALL_EPOLL_CREATE1_X, syscall_epoll_create1_x_indexes },
{ EVT_SYSCALL_CHOWN_E, syscall_chown_e_indexes },
{ EVT_SYSCALL_CHOWN_X, syscall_chown_x_indexes },
{ EVT_SYSCALL_LCHOWN_E, syscall_lchown_e_indexes },
{ EVT_SYSCALL_LCHOWN_X, syscall_lchown_x_indexes },
{ EVT_SYSCALL_FCHOWN_E, syscall_fchown_e_indexes },
{ EVT_SYSCALL_FCHOWN_X, syscall_fchown_x_indexes },
{ EVT_SYSCALL_FCHOWNAT_E, syscall_fchownat_e_indexes },
{ EVT_SYSCALL_FCHOWNAT_X, syscall_fchownat_x_indexes },
{ EVT_SYSCALL_UMOUNT_1_E, syscall_umount_1_e_indexes },
{ EVT_SYSCALL_UMOUNT_1_X, syscall_umount_1_x_indexes },
{ EVT_SOCKET_ACCEPT4_6_E, socket_accept4_6_e_indexes },
{ EVT_SOCKET_ACCEPT4_6_X, socket_accept4_6_x_indexes },
{ EVT_SYSCALL_UMOUNT2_E, syscall_umount2_e_indexes },
{ EVT_SYSCALL_UMOUNT2_X, syscall_umount2_x_indexes },
{ EVT_SYSCALL_PIPE2_E, syscall_pipe2_e_indexes },
{ EVT_SYSCALL_PIPE2_X, syscall_pipe2_x_indexes },
{ EVT_SYSCALL_INOTIFY_INIT1_E, syscall_inotify_init1_e_indexes },
{ EVT_SYSCALL_INOTIFY_INIT1_X, syscall_inotify_init1_x_indexes },
{ EVT_SYSCALL_EVENTFD2_E, syscall_eventfd2_e_indexes },
{ EVT_SYSCALL_EVENTFD2_X, syscall_eventfd2_x_indexes },
{ EVT_SYSCALL_SIGNALFD4_E, syscall_signalfd4_e_indexes },
{ EVT_SYSCALL_SIGNALFD4_X, syscall_signalfd4_x_indexes },
{ EVT_SYSCALL_PRCTL_E, syscall_prctl_e_indexes },
{ EVT_SYSCALL_PRCTL_X, syscall_prctl_x_indexes },
{ EVT_ASYNCEVENT_E, asyncevent_e_indexes },
{ EVT_ASYNCEVENT_X, asyncevent_x_indexes },
{ EVT_SYSCALL_MEMFD_CREATE_E, syscall_memfd_create_e_indexes },
{ EVT_SYSCALL_MEMFD_CREATE_X, syscall_memfd_create_x_indexes },
{ EVT_SYSCALL_PIDFD_GETFD_E, syscall_pidfd_getfd_e_indexes },
{ EVT_SYSCALL_PIDFD_GETFD_X, syscall_pidfd_getfd_x_indexes },
{ EVT_SYSCALL_PIDFD_OPEN_E, syscall_pidfd_open_e_indexes },
{ EVT_SYSCALL_PIDFD_OPEN_X, syscall_pidfd_open_x_indexes },
{ EVT_SYSCALL_INIT_MODULE_E, syscall_init_module_e_indexes },
{ EVT_SYSCALL_INIT_MODULE_X, syscall_init_module_x_indexes },
{ EVT_SYSCALL_FINIT_MODULE_E, syscall_finit_module_e_indexes },
{ EVT_SYSCALL_FINIT_MODULE_X, syscall_finit_module_x_indexes },
{ EVT_SYSCALL_MKNOD_E, syscall_mknod_e_indexes },
{ EVT_SYSCALL_MKNOD_X, syscall_mknod_x_indexes },
{ EVT_SYSCALL_MKNODAT_E, syscall_mknodat_e_indexes },
{ EVT_SYSCALL_MKNODAT_X, syscall_mknodat_x_indexes },
{ 0, NULL }
};
/*
* Value strings.
* If the X_Y_vals has a matching hf_param_X_Y it will be added as a
* VALS field conversion below.
*/
static const value_string ID_uint16_vals[] = {
/* Syscall codes. Automatically generated by tools/generate-sysdig-event.py */
{ 0, "unknown" }, // PPM_SC_UNKNOWN
{ 1, "restart_syscall" }, // PPM_SC_RESTART_SYSCALL
{ 2, "exit" }, // PPM_SC_EXIT
{ 3, "read" }, // PPM_SC_READ
{ 4, "write" }, // PPM_SC_WRITE
{ 5, "open" }, // PPM_SC_OPEN
{ 6, "close" }, // PPM_SC_CLOSE
{ 7, "creat" }, // PPM_SC_CREAT
{ 8, "link" }, // PPM_SC_LINK
{ 9, "unlink" }, // PPM_SC_UNLINK
{ 10, "chdir" }, // PPM_SC_CHDIR
{ 11, "time" }, // PPM_SC_TIME
{ 12, "mknod" }, // PPM_SC_MKNOD
{ 13, "chmod" }, // PPM_SC_CHMOD
{ 14, "stat" }, // PPM_SC_STAT
{ 15, "lseek" }, // PPM_SC_LSEEK
{ 16, "getpid" }, // PPM_SC_GETPID
{ 17, "mount" }, // PPM_SC_MOUNT
{ 18, "ptrace" }, // PPM_SC_PTRACE
{ 19, "alarm" }, // PPM_SC_ALARM
{ 20, "fstat" }, // PPM_SC_FSTAT
{ 21, "pause" }, // PPM_SC_PAUSE
{ 22, "utime" }, // PPM_SC_UTIME
{ 23, "access" }, // PPM_SC_ACCESS
{ 24, "sync" }, // PPM_SC_SYNC
{ 25, "kill" }, // PPM_SC_KILL
{ 26, "rename" }, // PPM_SC_RENAME
{ 27, "mkdir" }, // PPM_SC_MKDIR
{ 28, "rmdir" }, // PPM_SC_RMDIR
{ 29, "dup" }, // PPM_SC_DUP
{ 30, "pipe" }, // PPM_SC_PIPE
{ 31, "times" }, // PPM_SC_TIMES
{ 32, "brk" }, // PPM_SC_BRK
{ 33, "acct" }, // PPM_SC_ACCT
{ 34, "ioctl" }, // PPM_SC_IOCTL
{ 35, "fcntl" }, // PPM_SC_FCNTL
{ 36, "setpgid" }, // PPM_SC_SETPGID
{ 37, "umask" }, // PPM_SC_UMASK
{ 38, "chroot" }, // PPM_SC_CHROOT
{ 39, "ustat" }, // PPM_SC_USTAT
{ 40, "dup2" }, // PPM_SC_DUP2
{ 41, "getppid" }, // PPM_SC_GETPPID
{ 42, "getpgrp" }, // PPM_SC_GETPGRP
{ 43, "setsid" }, // PPM_SC_SETSID
{ 44, "sethostname" }, // PPM_SC_SETHOSTNAME
{ 45, "setrlimit" }, // PPM_SC_SETRLIMIT
{ 46, "getrusage" }, // PPM_SC_GETRUSAGE
{ 47, "gettimeofday" }, // PPM_SC_GETTIMEOFDAY
{ 48, "settimeofday" }, // PPM_SC_SETTIMEOFDAY
{ 49, "symlink" }, // PPM_SC_SYMLINK
{ 50, "lstat" }, // PPM_SC_LSTAT
{ 51, "readlink" }, // PPM_SC_READLINK
{ 52, "uselib" }, // PPM_SC_USELIB
{ 53, "swapon" }, // PPM_SC_SWAPON
{ 54, "reboot" }, // PPM_SC_REBOOT
{ 55, "mmap" }, // PPM_SC_MMAP
{ 56, "munmap" }, // PPM_SC_MUNMAP
{ 57, "truncate" }, // PPM_SC_TRUNCATE
{ 58, "ftruncate" }, // PPM_SC_FTRUNCATE
{ 59, "fchmod" }, // PPM_SC_FCHMOD
{ 60, "getpriority" }, // PPM_SC_GETPRIORITY
{ 61, "setpriority" }, // PPM_SC_SETPRIORITY
{ 62, "statfs" }, // PPM_SC_STATFS
{ 63, "fstatfs" }, // PPM_SC_FSTATFS
{ 64, "syslog" }, // PPM_SC_SYSLOG
{ 65, "setitimer" }, // PPM_SC_SETITIMER
{ 66, "getitimer" }, // PPM_SC_GETITIMER
{ 67, "uname" }, // PPM_SC_UNAME
{ 68, "vhangup" }, // PPM_SC_VHANGUP
{ 69, "wait4" }, // PPM_SC_WAIT4
{ 70, "swapoff" }, // PPM_SC_SWAPOFF
{ 71, "sysinfo" }, // PPM_SC_SYSINFO
{ 72, "fsync" }, // PPM_SC_FSYNC
{ 73, "setdomainname" }, // PPM_SC_SETDOMAINNAME
{ 74, "adjtimex" }, // PPM_SC_ADJTIMEX
{ 75, "mprotect" }, // PPM_SC_MPROTECT
{ 76, "init_module" }, // PPM_SC_INIT_MODULE
{ 77, "delete_module" }, // PPM_SC_DELETE_MODULE
{ 78, "quotactl" }, // PPM_SC_QUOTACTL
{ 79, "getpgid" }, // PPM_SC_GETPGID
{ 80, "fchdir" }, // PPM_SC_FCHDIR
{ 81, "sysfs" }, // PPM_SC_SYSFS
{ 82, "personality" }, // PPM_SC_PERSONALITY
{ 83, "getdents" }, // PPM_SC_GETDENTS
{ 84, "select" }, // PPM_SC_SELECT
{ 85, "flock" }, // PPM_SC_FLOCK
{ 86, "msync" }, // PPM_SC_MSYNC
{ 87, "readv" }, // PPM_SC_READV
{ 88, "writev" }, // PPM_SC_WRITEV
{ 89, "getsid" }, // PPM_SC_GETSID
{ 90, "fdatasync" }, // PPM_SC_FDATASYNC
{ 91, "mlock" }, // PPM_SC_MLOCK
{ 92, "munlock" }, // PPM_SC_MUNLOCK
{ 93, "mlockall" }, // PPM_SC_MLOCKALL
{ 94, "munlockall" }, // PPM_SC_MUNLOCKALL
{ 95, "sched_setparam" }, // PPM_SC_SCHED_SETPARAM
{ 96, "sched_getparam" }, // PPM_SC_SCHED_GETPARAM
{ 97, "sched_setscheduler" }, // PPM_SC_SCHED_SETSCHEDULER
{ 98, "sched_getscheduler" }, // PPM_SC_SCHED_GETSCHEDULER
{ 99, "sched_yield" }, // PPM_SC_SCHED_YIELD
{ 100, "sched_get_priority_max" }, // PPM_SC_SCHED_GET_PRIORITY_MAX
{ 101, "sched_get_priority_min" }, // PPM_SC_SCHED_GET_PRIORITY_MIN
{ 102, "sched_rr_get_interval" }, // PPM_SC_SCHED_RR_GET_INTERVAL
{ 103, "nanosleep" }, // PPM_SC_NANOSLEEP
{ 104, "mremap" }, // PPM_SC_MREMAP
{ 105, "poll" }, // PPM_SC_POLL
{ 106, "prctl" }, // PPM_SC_PRCTL
{ 107, "rt_sigaction" }, // PPM_SC_RT_SIGACTION
{ 108, "rt_sigprocmask" }, // PPM_SC_RT_SIGPROCMASK
{ 109, "rt_sigpending" }, // PPM_SC_RT_SIGPENDING
{ 110, "rt_sigtimedwait" }, // PPM_SC_RT_SIGTIMEDWAIT
{ 111, "rt_sigqueueinfo" }, // PPM_SC_RT_SIGQUEUEINFO
{ 112, "rt_sigsuspend" }, // PPM_SC_RT_SIGSUSPEND
{ 113, "getcwd" }, // PPM_SC_GETCWD
{ 114, "capget" }, // PPM_SC_CAPGET
{ 115, "capset" }, // PPM_SC_CAPSET
{ 116, "sendfile" }, // PPM_SC_SENDFILE
{ 117, "getrlimit" }, // PPM_SC_GETRLIMIT
{ 118, "lchown" }, // PPM_SC_LCHOWN
{ 119, "getuid" }, // PPM_SC_GETUID
{ 120, "getgid" }, // PPM_SC_GETGID
{ 121, "geteuid" }, // PPM_SC_GETEUID
{ 122, "getegid" }, // PPM_SC_GETEGID
{ 123, "setreuid" }, // PPM_SC_SETREUID
{ 124, "setregid" }, // PPM_SC_SETREGID
{ 125, "getgroups" }, // PPM_SC_GETGROUPS
{ 126, "setgroups" }, // PPM_SC_SETGROUPS
{ 127, "fchown" }, // PPM_SC_FCHOWN
{ 128, "setresuid" }, // PPM_SC_SETRESUID
{ 129, "getresuid" }, // PPM_SC_GETRESUID
{ 130, "setresgid" }, // PPM_SC_SETRESGID
{ 131, "getresgid" }, // PPM_SC_GETRESGID
{ 132, "chown" }, // PPM_SC_CHOWN
{ 133, "setuid" }, // PPM_SC_SETUID
{ 134, "setgid" }, // PPM_SC_SETGID
{ 135, "setfsuid" }, // PPM_SC_SETFSUID
{ 136, "setfsgid" }, // PPM_SC_SETFSGID
{ 137, "pivot_root" }, // PPM_SC_PIVOT_ROOT
{ 138, "mincore" }, // PPM_SC_MINCORE
{ 139, "madvise" }, // PPM_SC_MADVISE
{ 140, "gettid" }, // PPM_SC_GETTID
{ 141, "setxattr" }, // PPM_SC_SETXATTR
{ 142, "lsetxattr" }, // PPM_SC_LSETXATTR
{ 143, "fsetxattr" }, // PPM_SC_FSETXATTR
{ 144, "getxattr" }, // PPM_SC_GETXATTR
{ 145, "lgetxattr" }, // PPM_SC_LGETXATTR
{ 146, "fgetxattr" }, // PPM_SC_FGETXATTR
{ 147, "listxattr" }, // PPM_SC_LISTXATTR
{ 148, "llistxattr" }, // PPM_SC_LLISTXATTR
{ 149, "flistxattr" }, // PPM_SC_FLISTXATTR
{ 150, "removexattr" }, // PPM_SC_REMOVEXATTR
{ 151, "lremovexattr" }, // PPM_SC_LREMOVEXATTR
{ 152, "fremovexattr" }, // PPM_SC_FREMOVEXATTR
{ 153, "tkill" }, // PPM_SC_TKILL
{ 154, "futex" }, // PPM_SC_FUTEX
{ 155, "sched_setaffinity" }, // PPM_SC_SCHED_SETAFFINITY
{ 156, "sched_getaffinity" }, // PPM_SC_SCHED_GETAFFINITY
{ 157, "set_thread_area" }, // PPM_SC_SET_THREAD_AREA
{ 158, "get_thread_area" }, // PPM_SC_GET_THREAD_AREA
{ 159, "io_setup" }, // PPM_SC_IO_SETUP
{ 160, "io_destroy" }, // PPM_SC_IO_DESTROY
{ 161, "io_getevents" }, // PPM_SC_IO_GETEVENTS
{ 162, "io_submit" }, // PPM_SC_IO_SUBMIT
{ 163, "io_cancel" }, // PPM_SC_IO_CANCEL
{ 164, "exit_group" }, // PPM_SC_EXIT_GROUP
{ 165, "epoll_create" }, // PPM_SC_EPOLL_CREATE
{ 166, "epoll_ctl" }, // PPM_SC_EPOLL_CTL
{ 167, "epoll_wait" }, // PPM_SC_EPOLL_WAIT
{ 168, "remap_file_pages" }, // PPM_SC_REMAP_FILE_PAGES
{ 169, "set_tid_address" }, // PPM_SC_SET_TID_ADDRESS
{ 170, "timer_create" }, // PPM_SC_TIMER_CREATE
{ 171, "timer_settime" }, // PPM_SC_TIMER_SETTIME
{ 172, "timer_gettime" }, // PPM_SC_TIMER_GETTIME
{ 173, "timer_getoverrun" }, // PPM_SC_TIMER_GETOVERRUN
{ 174, "timer_delete" }, // PPM_SC_TIMER_DELETE
{ 175, "clock_settime" }, // PPM_SC_CLOCK_SETTIME
{ 176, "clock_gettime" }, // PPM_SC_CLOCK_GETTIME
{ 177, "clock_getres" }, // PPM_SC_CLOCK_GETRES
{ 178, "clock_nanosleep" }, // PPM_SC_CLOCK_NANOSLEEP
{ 179, "tgkill" }, // PPM_SC_TGKILL
{ 180, "utimes" }, // PPM_SC_UTIMES
{ 181, "mq_open" }, // PPM_SC_MQ_OPEN
{ 182, "mq_unlink" }, // PPM_SC_MQ_UNLINK
{ 183, "mq_timedsend" }, // PPM_SC_MQ_TIMEDSEND
{ 184, "mq_timedreceive" }, // PPM_SC_MQ_TIMEDRECEIVE
{ 185, "mq_notify" }, // PPM_SC_MQ_NOTIFY
{ 186, "mq_getsetattr" }, // PPM_SC_MQ_GETSETATTR
{ 187, "kexec_load" }, // PPM_SC_KEXEC_LOAD
{ 188, "waitid" }, // PPM_SC_WAITID
{ 189, "add_key" }, // PPM_SC_ADD_KEY
{ 190, "request_key" }, // PPM_SC_REQUEST_KEY
{ 191, "keyctl" }, // PPM_SC_KEYCTL
{ 192, "ioprio_set" }, // PPM_SC_IOPRIO_SET
{ 193, "ioprio_get" }, // PPM_SC_IOPRIO_GET
{ 194, "inotify_init" }, // PPM_SC_INOTIFY_INIT
{ 195, "inotify_add_watch" }, // PPM_SC_INOTIFY_ADD_WATCH
{ 196, "inotify_rm_watch" }, // PPM_SC_INOTIFY_RM_WATCH
{ 197, "openat" }, // PPM_SC_OPENAT
{ 198, "mkdirat" }, // PPM_SC_MKDIRAT
{ 199, "mknodat" }, // PPM_SC_MKNODAT
{ 200, "fchownat" }, // PPM_SC_FCHOWNAT
{ 201, "futimesat" }, // PPM_SC_FUTIMESAT
{ 202, "unlinkat" }, // PPM_SC_UNLINKAT
{ 203, "renameat" }, // PPM_SC_RENAMEAT
{ 204, "linkat" }, // PPM_SC_LINKAT
{ 205, "symlinkat" }, // PPM_SC_SYMLINKAT
{ 206, "readlinkat" }, // PPM_SC_READLINKAT
{ 207, "fchmodat" }, // PPM_SC_FCHMODAT
{ 208, "faccessat" }, // PPM_SC_FACCESSAT
{ 209, "pselect6" }, // PPM_SC_PSELECT6
{ 210, "ppoll" }, // PPM_SC_PPOLL
{ 211, "unshare" }, // PPM_SC_UNSHARE
{ 212, "set_robust_list" }, // PPM_SC_SET_ROBUST_LIST
{ 213, "get_robust_list" }, // PPM_SC_GET_ROBUST_LIST
{ 214, "splice" }, // PPM_SC_SPLICE
{ 215, "tee" }, // PPM_SC_TEE
{ 216, "vmsplice" }, // PPM_SC_VMSPLICE
{ 217, "getcpu" }, // PPM_SC_GETCPU
{ 218, "epoll_pwait" }, // PPM_SC_EPOLL_PWAIT
{ 219, "utimensat" }, // PPM_SC_UTIMENSAT
{ 220, "signalfd" }, // PPM_SC_SIGNALFD
{ 221, "timerfd_create" }, // PPM_SC_TIMERFD_CREATE
{ 222, "eventfd" }, // PPM_SC_EVENTFD
{ 223, "timerfd_settime" }, // PPM_SC_TIMERFD_SETTIME
{ 224, "timerfd_gettime" }, // PPM_SC_TIMERFD_GETTIME
{ 225, "signalfd4" }, // PPM_SC_SIGNALFD4
{ 226, "eventfd2" }, // PPM_SC_EVENTFD2
{ 227, "epoll_create1" }, // PPM_SC_EPOLL_CREATE1
{ 228, "dup3" }, // PPM_SC_DUP3
{ 229, "pipe2" }, // PPM_SC_PIPE2
{ 230, "inotify_init1" }, // PPM_SC_INOTIFY_INIT1
{ 231, "preadv" }, // PPM_SC_PREADV
{ 232, "pwritev" }, // PPM_SC_PWRITEV
{ 233, "rt_tgsigqueueinfo" }, // PPM_SC_RT_TGSIGQUEUEINFO
{ 234, "perf_event_open" }, // PPM_SC_PERF_EVENT_OPEN
{ 235, "fanotify_init" }, // PPM_SC_FANOTIFY_INIT
{ 236, "prlimit64" }, // PPM_SC_PRLIMIT64
{ 237, "clock_adjtime" }, // PPM_SC_CLOCK_ADJTIME
{ 238, "syncfs" }, // PPM_SC_SYNCFS
{ 239, "setns" }, // PPM_SC_SETNS
{ 240, "getdents64" }, // PPM_SC_GETDENTS64
{ 241, "socket" }, // PPM_SC_SOCKET
{ 242, "bind" }, // PPM_SC_BIND
{ 243, "connect" }, // PPM_SC_CONNECT
{ 244, "listen" }, // PPM_SC_LISTEN
{ 245, "accept" }, // PPM_SC_ACCEPT
{ 246, "getsockname" }, // PPM_SC_GETSOCKNAME
{ 247, "getpeername" }, // PPM_SC_GETPEERNAME
{ 248, "socketpair" }, // PPM_SC_SOCKETPAIR
{ 249, "sendto" }, // PPM_SC_SENDTO
{ 250, "recvfrom" }, // PPM_SC_RECVFROM
{ 251, "shutdown" }, // PPM_SC_SHUTDOWN
{ 252, "setsockopt" }, // PPM_SC_SETSOCKOPT
{ 253, "getsockopt" }, // PPM_SC_GETSOCKOPT
{ 254, "sendmsg" }, // PPM_SC_SENDMSG
{ 255, "sendmmsg" }, // PPM_SC_SENDMMSG
{ 256, "recvmsg" }, // PPM_SC_RECVMSG
{ 257, "recvmmsg" }, // PPM_SC_RECVMMSG
{ 258, "accept4" }, // PPM_SC_ACCEPT4
{ 259, "semop" }, // PPM_SC_SEMOP
{ 260, "semget" }, // PPM_SC_SEMGET
{ 261, "semctl" }, // PPM_SC_SEMCTL
{ 262, "msgsnd" }, // PPM_SC_MSGSND
{ 263, "msgrcv" }, // PPM_SC_MSGRCV
{ 264, "msgget" }, // PPM_SC_MSGGET
{ 265, "msgctl" }, // PPM_SC_MSGCTL
{ 266, "shmdt" }, // PPM_SC_SHMDT
{ 267, "shmget" }, // PPM_SC_SHMGET
{ 268, "shmctl" }, // PPM_SC_SHMCTL
{ 269, "statfs64" }, // PPM_SC_STATFS64
{ 270, "fstatfs64" }, // PPM_SC_FSTATFS64
{ 271, "fstatat64" }, // PPM_SC_FSTATAT64
{ 272, "sendfile64" }, // PPM_SC_SENDFILE64
{ 273, "ugetrlimit" }, // PPM_SC_UGETRLIMIT
{ 274, "bdflush" }, // PPM_SC_BDFLUSH
{ 275, "sigprocmask" }, // PPM_SC_SIGPROCMASK
{ 276, "ipc" }, // PPM_SC_IPC
{ 277, "socketcall" }, // PPM_SC_SOCKETCALL
{ 278, "stat64" }, // PPM_SC_STAT64
{ 279, "lstat64" }, // PPM_SC_LSTAT64
{ 280, "fstat64" }, // PPM_SC_FSTAT64
{ 281, "fcntl64" }, // PPM_SC_FCNTL64
{ 282, "mmap2" }, // PPM_SC_MMAP2
{ 283, "_newselect" }, // PPM_SC__NEWSELECT
{ 284, "sgetmask" }, // PPM_SC_SGETMASK
{ 285, "ssetmask" }, // PPM_SC_SSETMASK
{ 286, "sigpending" }, // PPM_SC_SIGPENDING
{ 287, "olduname" }, // PPM_SC_OLDUNAME
{ 288, "umount" }, // PPM_SC_UMOUNT
{ 289, "signal" }, // PPM_SC_SIGNAL
{ 290, "nice" }, // PPM_SC_NICE
{ 291, "stime" }, // PPM_SC_STIME
{ 292, "_llseek" }, // PPM_SC__LLSEEK
{ 293, "waitpid" }, // PPM_SC_WAITPID
{ 294, "pread64" }, // PPM_SC_PREAD64
{ 295, "pwrite64" }, // PPM_SC_PWRITE64
{ 296, "arch_prctl" }, // PPM_SC_ARCH_PRCTL
{ 297, "shmat" }, // PPM_SC_SHMAT
{ 298, "rt_sigreturn" }, // PPM_SC_RT_SIGRETURN
{ 299, "fallocate" }, // PPM_SC_FALLOCATE
{ 300, "newfstatat" }, // PPM_SC_NEWFSTATAT
{ 301, "process_vm_readv" }, // PPM_SC_PROCESS_VM_READV
{ 302, "process_vm_writev" }, // PPM_SC_PROCESS_VM_WRITEV
{ 303, "fork" }, // PPM_SC_FORK
{ 304, "vfork" }, // PPM_SC_VFORK
{ 305, "setuid32" }, // PPM_SC_SETUID32
{ 306, "getuid32" }, // PPM_SC_GETUID32
{ 307, "setgid32" }, // PPM_SC_SETGID32
{ 308, "geteuid32" }, // PPM_SC_GETEUID32
{ 309, "getgid32" }, // PPM_SC_GETGID32
{ 310, "setresuid32" }, // PPM_SC_SETRESUID32
{ 311, "setresgid32" }, // PPM_SC_SETRESGID32
{ 312, "getresuid32" }, // PPM_SC_GETRESUID32
{ 313, "getresgid32" }, // PPM_SC_GETRESGID32
{ 314, "finit_module" }, // PPM_SC_FINIT_MODULE
{ 315, "bpf" }, // PPM_SC_BPF
{ 316, "seccomp" }, // PPM_SC_SECCOMP
{ 317, "sigaltstack" }, // PPM_SC_SIGALTSTACK
{ 318, "getrandom" }, // PPM_SC_GETRANDOM
{ 319, "fadvise64" }, // PPM_SC_FADVISE64
{ 320, "renameat2" }, // PPM_SC_RENAMEAT2
{ 321, "userfaultfd" }, // PPM_SC_USERFAULTFD
{ 322, "openat2" }, // PPM_SC_OPENAT2
{ 323, "umount2" }, // PPM_SC_UMOUNT2
{ 324, "execve" }, // PPM_SC_EXECVE
{ 325, "execveat" }, // PPM_SC_EXECVEAT
{ 326, "copy_file_range" }, // PPM_SC_COPY_FILE_RANGE
{ 327, "clone" }, // PPM_SC_CLONE
{ 328, "clone3" }, // PPM_SC_CLONE3
{ 329, "open_by_handle_at" }, // PPM_SC_OPEN_BY_HANDLE_AT
{ 330, "io_uring_setup" }, // PPM_SC_IO_URING_SETUP
{ 331, "io_uring_enter" }, // PPM_SC_IO_URING_ENTER
{ 332, "io_uring_register" }, // PPM_SC_IO_URING_REGISTER
{ 333, "mlock2" }, // PPM_SC_MLOCK2
{ 334, "getegid32" }, // PPM_SC_GETEGID32
{ 335, "fsconfig" }, // PPM_SC_FSCONFIG
{ 336, "fspick" }, // PPM_SC_FSPICK
{ 337, "fsmount" }, // PPM_SC_FSMOUNT
{ 338, "fsopen" }, // PPM_SC_FSOPEN
{ 339, "open_tree" }, // PPM_SC_OPEN_TREE
{ 340, "move_mount" }, // PPM_SC_MOVE_MOUNT
{ 341, "mount_setattr" }, // PPM_SC_MOUNT_SETATTR
{ 342, "memfd_create" }, // PPM_SC_MEMFD_CREATE
{ 343, "memfd_secret" }, // PPM_SC_MEMFD_SECRET
{ 344, "ioperm" }, // PPM_SC_IOPERM
{ 345, "kexec_file_load" }, // PPM_SC_KEXEC_FILE_LOAD
{ 346, "pidfd_getfd" }, // PPM_SC_PIDFD_GETFD
{ 347, "pidfd_open" }, // PPM_SC_PIDFD_OPEN
{ 348, "pidfd_send_signal" }, // PPM_SC_PIDFD_SEND_SIGNAL
{ 349, "pkey_alloc" }, // PPM_SC_PKEY_ALLOC
{ 350, "pkey_mprotect" }, // PPM_SC_PKEY_MPROTECT
{ 351, "pkey_free" }, // PPM_SC_PKEY_FREE
{ 352, "landlock_create_ruleset" }, // PPM_SC_LANDLOCK_CREATE_RULESET
{ 353, "quotactl_fd" }, // PPM_SC_QUOTACTL_FD
{ 354, "landlock_restrict_self" }, // PPM_SC_LANDLOCK_RESTRICT_SELF
{ 355, "landlock_add_rule" }, // PPM_SC_LANDLOCK_ADD_RULE
{ 356, "epoll_pwait2" }, // PPM_SC_EPOLL_PWAIT2
{ 357, "migrate_pages" }, // PPM_SC_MIGRATE_PAGES
{ 358, "move_pages" }, // PPM_SC_MOVE_PAGES
{ 359, "preadv2" }, // PPM_SC_PREADV2
{ 360, "pwritev2" }, // PPM_SC_PWRITEV2
{ 361, "kcmp" }, // PPM_SC_KCMP
{ 362, "sched_setattr" }, // PPM_SC_SCHED_SETATTR
{ 363, "mbind" }, // PPM_SC_MBIND
{ 364, "epoll_ctl_old" }, // PPM_SC_EPOLL_CTL_OLD
{ 365, "lookup_dcookie" }, // PPM_SC_LOOKUP_DCOOKIE
{ 366, "modify_ldt" }, // PPM_SC_MODIFY_LDT
{ 367, "statx" }, // PPM_SC_STATX
{ 368, "set_mempolicy" }, // PPM_SC_SET_MEMPOLICY
{ 369, "io_pgetevents" }, // PPM_SC_IO_PGETEVENTS
{ 370, "set_mempolicy_home_node" }, // PPM_SC_SET_MEMPOLICY_HOME_NODE
{ 371, "semtimedop" }, // PPM_SC_SEMTIMEDOP
{ 372, "get_kernel_syms" }, // PPM_SC_GET_KERNEL_SYMS
{ 373, "readahead" }, // PPM_SC_READAHEAD
{ 374, "futex_waitv" }, // PPM_SC_FUTEX_WAITV
{ 375, "getpmsg" }, // PPM_SC_GETPMSG
{ 376, "name_to_handle_at" }, // PPM_SC_NAME_TO_HANDLE_AT
{ 377, "process_mrelease" }, // PPM_SC_PROCESS_MRELEASE
{ 378, "nfsservctl" }, // PPM_SC_NFSSERVCTL
{ 379, "epoll_wait_old" }, // PPM_SC_EPOLL_WAIT_OLD
{ 380, "rseq" }, // PPM_SC_RSEQ
{ 381, "create_module" }, // PPM_SC_CREATE_MODULE
{ 383, "sched_getattr" }, // PPM_SC_SCHED_GETATTR
{ 384, "faccessat2" }, // PPM_SC_FACCESSAT2
{ 385, "_sysctl" }, // PPM_SC__SYSCTL
{ 386, "query_module" }, // PPM_SC_QUERY_MODULE
{ 387, "get_mempolicy" }, // PPM_SC_GET_MEMPOLICY
{ 388, "sync_file_range" }, // PPM_SC_SYNC_FILE_RANGE
{ 389, "process_madvise" }, // PPM_SC_PROCESS_MADVISE
{ 390, "membarrier" }, // PPM_SC_MEMBARRIER
{ 391, "iopl" }, // PPM_SC_IOPL
{ 392, "close_range" }, // PPM_SC_CLOSE_RANGE
{ 393, "fanotify_mark" }, // PPM_SC_FANOTIFY_MARK
{ 394, "recv" }, // PPM_SC_RECV
{ 395, "send" }, // PPM_SC_SEND
{ 396, "sched_process_exit" }, // PPM_SC_SCHED_PROCESS_EXIT
{ 397, "sched_switch" }, // PPM_SC_SCHED_SWITCH
{ 398, "page_fault_user" }, // PPM_SC_PAGE_FAULT_USER
{ 399, "page_fault_kernel" }, // PPM_SC_PAGE_FAULT_KERNEL
{ 400, "signal_deliver" }, // PPM_SC_SIGNAL_DELIVER
{ 401, "timerfd" }, // PPM_SC_TIMERFD
{ 402, "s390_pci_mmio_read" }, // PPM_SC_S390_PCI_MMIO_READ
{ 403, "sigaction" }, // PPM_SC_SIGACTION
{ 404, "s390_pci_mmio_write" }, // PPM_SC_S390_PCI_MMIO_WRITE
{ 405, "readdir" }, // PPM_SC_READDIR
{ 406, "s390_sthyi" }, // PPM_SC_S390_STHYI
{ 407, "sigsuspend" }, // PPM_SC_SIGSUSPEND
{ 408, "idle" }, // PPM_SC_IDLE
{ 409, "s390_runtime_instr" }, // PPM_SC_S390_RUNTIME_INSTR
{ 410, "sigreturn" }, // PPM_SC_SIGRETURN
{ 411, "s390_guarded_storage" }, // PPM_SC_S390_GUARDED_STORAGE
{ 412, "cachestat" }, // PPM_SC_CACHESTAT
{ 0, NULL }
};
/*
static const value_string param_category_vals[] = {
{ 1, "Other"},
{ 2, "File"},
{ 3, "Network operation"},
{ 4, "IPC operation"},
{ 5, "Memory operation"},
{ 6, "Process operation"},
{ 7, "Plain sleep"},
{ 8, "System operation"},
{ 9, "Signal operation"},
{ 10, "User operation"},
{ 11, "Time"},
{ 12, "User-level processing"},
{ 32, "I/O read"},
{ 33, "I/O write"},
{ 34, "I/O other"},
{ 64, "General wait"},
{128, "Scheduler event"},
{256, "Internal event"},
{0, NULL}
};
*/
/*
static const value_string param_flag_vals[] = {
{ 0, "None"},
{1 << 0, "Creates FD"},
{1 << 1, "Destroys FD"},
{1 << 2, "Uses FD"},
{1 << 3, "Reads from FD"},
{1 << 4, "Writes to FD"},
{1 << 5, "Modifies state"},
{1 << 6, "Unused"},
{1 << 7, "Waits"},
{1 << 8, "Skip parse reset"},
{1 << 9, "Old version"},
{0, NULL}
};
*/
/*
static const value_string param_subcategory_vals[] = {
{ 0, "Unknown"},
{ 1, "None"},
{ 2, "Other"},
{ 3, "File"},
{ 4, "Net"},
{ 5, "IPC"},
{0, NULL}
};
*/
static inline const gchar *format_param_str(tvbuff_t *tvb, int offset, int len) {
char *param_str;
param_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_UTF_8|ENC_NA);
if (len < 2) {
return param_str;
}
return format_text_chr(wmem_packet_scope(), param_str, len - 1, ' '); /* Leave terminating NULLs alone. */
}
/* Code to actually dissect the packets */
static int
dissect_header_lens_v1(tvbuff_t *tvb, int offset, proto_tree *tree, int encoding, int * const *hf_indexes)
{
int param_count;
proto_item *ti;
proto_tree *len_tree;
for (param_count = 0; hf_indexes[param_count]; param_count++);
ti = proto_tree_add_item(tree, hf_se_param_lens, tvb, offset, param_count * SYSDIG_PARAM_SIZE, ENC_NA);
len_tree = proto_item_add_subtree(ti, ett_sysdig_parm_lens);
for (param_count = 0; hf_indexes[param_count]; param_count++) {
proto_tree_add_item(len_tree, hf_se_param_len, tvb, offset + (param_count * SYSDIG_PARAM_SIZE), SYSDIG_PARAM_SIZE, encoding);
}
proto_item_set_len(ti, param_count * SYSDIG_PARAM_SIZE);
return param_count * SYSDIG_PARAM_SIZE;
}
static int
dissect_header_lens_v2(tvbuff_t *tvb, wtap_syscall_header* syscall_header, int offset, proto_tree *tree, int encoding)
{
guint32 param_count;
proto_item *ti;
proto_tree *len_tree;
ti = proto_tree_add_item(tree, hf_se_param_lens, tvb, offset, syscall_header->nparams * SYSDIG_PARAM_SIZE_V2, ENC_NA);
len_tree = proto_item_add_subtree(ti, ett_sysdig_parm_lens);
for (param_count = 0; param_count < syscall_header->nparams; param_count++) {
proto_tree_add_item(len_tree, hf_se_param_len, tvb, offset + (param_count * SYSDIG_PARAM_SIZE_V2), SYSDIG_PARAM_SIZE_V2, encoding);
}
proto_item_set_len(ti, syscall_header->nparams * SYSDIG_PARAM_SIZE_V2);
return syscall_header->nparams * SYSDIG_PARAM_SIZE_V2;
}
static int
dissect_header_lens_v2_large(tvbuff_t *tvb, wtap_syscall_header* syscall_header, int offset, proto_tree *tree, int encoding)
{
guint32 param_count;
proto_item *ti;
proto_tree *len_tree;
ti = proto_tree_add_item(tree, hf_se_param_lens, tvb, offset, syscall_header->nparams * SYSDIG_PARAM_SIZE_V2_LARGE, ENC_NA);
len_tree = proto_item_add_subtree(ti, ett_sysdig_parm_lens);
for (param_count = 0; param_count < syscall_header->nparams; param_count++) {
proto_tree_add_item(len_tree, hf_se_param_len, tvb, offset + (param_count * SYSDIG_PARAM_SIZE_V2_LARGE), SYSDIG_PARAM_SIZE_V2_LARGE, encoding);
}
proto_item_set_len(ti, syscall_header->nparams * SYSDIG_PARAM_SIZE_V2_LARGE);
return syscall_header->nparams * SYSDIG_PARAM_SIZE_V2_LARGE;
}
/* Dissect events */
static int
dissect_event_params(tvbuff_t *tvb, packet_info *pinfo, const char **event_name, wtap_syscall_header* syscall_header, int offset, proto_tree *tree, int encoding, int * const *hf_indexes)
{
int len_offset = offset;
int param_offset;
int len_size;
guint32 cur_param;
switch (syscall_header->record_type) {
case BLOCK_TYPE_SYSDIG_EVENT_V2_LARGE:
param_offset = offset + dissect_header_lens_v2_large(tvb, syscall_header, offset, tree, encoding);
len_size = SYSDIG_PARAM_SIZE_V2_LARGE;
break;
case BLOCK_TYPE_SYSDIG_EVENT_V2:
param_offset = offset + dissect_header_lens_v2(tvb, syscall_header, offset, tree, encoding);
len_size = SYSDIG_PARAM_SIZE_V2;
break;
default:
param_offset = offset + dissect_header_lens_v1(tvb, offset, tree, encoding, hf_indexes);
len_size = SYSDIG_PARAM_SIZE;
break;
}
for (cur_param = 0; cur_param < syscall_header->nparams; cur_param++) {
if (!hf_indexes[cur_param]) {
// This happens when new params are added to existent events in sysdig,
// if the event is already mapped in wireshark with a lower number of params.
// hf_indexes array size would be < than event being dissected, leading to SIGSEGV.
break;
}
guint32 param_len;
if (syscall_header->record_type == BLOCK_TYPE_SYSDIG_EVENT_V2_LARGE) {
param_len = tvb_get_guint32(tvb, len_offset, encoding);
} else {
param_len = tvb_get_guint16(tvb, len_offset, encoding);
}
const int hf_index = *hf_indexes[cur_param];
if (proto_registrar_get_ftype(hf_index) == FT_STRING) {
proto_tree_add_string(tree, hf_index, tvb, param_offset, param_len,
format_param_str(tvb, param_offset, param_len));
} else {
proto_tree_add_item(tree, hf_index, tvb, param_offset, param_len, encoding);
}
if (hf_index == hf_param_ID_uint16) {
uint16_t id = tvb_get_guint16(tvb, param_offset, encoding);
*event_name = val_to_str(id, ID_uint16_vals, "Unknown ID %u");
col_add_str(pinfo->cinfo, COL_INFO, *event_name);
}
param_offset += param_len;
len_offset += len_size;
}
return param_offset - offset;
}
static int
dissect_plugin_event(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
if (!plugin_dissector_handle) {
return 0;
}
return call_dissector_with_data(plugin_dissector_handle, tvb, pinfo, tree, data);
}
static int
dissect_sysdig_event(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data)
{
proto_item *ti;
proto_tree *se_tree, *syscall_tree;
unsigned event_type = pinfo->rec->rec_header.syscall_header.event_type;
int encoding = pinfo->rec->rec_header.syscall_header.byte_order == G_BIG_ENDIAN ? ENC_BIG_ENDIAN : ENC_LITTLE_ENDIAN;
const struct _event_col_info *cur_col_info;
const struct _event_tree_info *cur_tree_info;
/*** HEURISTICS ***/
/* Check that the packet is long enough for it to belong to us. */
if (tvb_reported_length(tvb) < SYSDIG_EVENT_MIN_LENGTH)
return 0;
/*** COLUMN DATA ***/
/*
* If this is a plugin event, handle it appropriately and return
*/
if (event_type == EVT_PLUGINEVENT_E) {
return dissect_plugin_event(tvb, pinfo, tree, data);
}
const char *event_name = val_to_str(event_type, event_type_vals, "Unknown syscall %u");
/*
* Sysdig uses the term "event" internally. So far every event has been
* a syscall.
*/
col_clear(pinfo->cinfo, COL_INFO);
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Sysdig Event");
col_add_str(pinfo->cinfo, COL_INFO, event_name);
/*
* XXX We can ditch this in favor of a simple index when event_col_info
* is contiguous and in the correct order.
*/
for (cur_col_info = event_col_info; cur_col_info->params; cur_col_info++) {
if (cur_col_info->event_type == event_type) {
const struct _event_col_info_param *cur_param = cur_col_info->params;
int param_offset = cur_col_info->num_len_fields * 2;
/* Find the data offset */
int cur_len_field;
for (cur_len_field = 0;
cur_len_field < cur_col_info->num_len_fields && cur_param->param_name;
cur_len_field++) {
unsigned param_len = tvb_get_guint16(tvb, cur_len_field * 2, encoding);
if (cur_param->param_num == cur_len_field) {
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s=", cur_param->param_name);
switch (cur_param->param_ftype) {
case FT_STRING:
col_append_str(pinfo->cinfo, COL_INFO, format_param_str(tvb, param_offset, param_len));
break;
case FT_UINT64:
col_append_fstr(pinfo->cinfo, COL_INFO, "%" PRIu64, tvb_get_guint64(tvb, param_offset, encoding));
default:
break;
}
cur_param++;
}
param_offset += param_len;
}
}
}
/*** PROTOCOL TREE ***/
/* create display subtree for the protocol */
ti = proto_tree_add_item(tree, proto_sysdig_event, tvb, 0, -1, ENC_NA);
se_tree = proto_item_add_subtree(ti, ett_sysdig_event);
proto_tree_add_uint(se_tree, hf_se_cpu_id, tvb, 0, 0, pinfo->rec->rec_header.syscall_header.cpu_id);
proto_tree_add_uint64(se_tree, hf_se_thread_id, tvb, 0, 0, pinfo->rec->rec_header.syscall_header.thread_id);
proto_tree_add_uint(se_tree, hf_se_event_length, tvb, 0, 0, pinfo->rec->rec_header.syscall_header.event_len);
if (pinfo->rec->rec_header.syscall_header.nparams != 0) {
proto_tree_add_uint(se_tree, hf_se_nparams, tvb, 0, 0, pinfo->rec->rec_header.syscall_header.nparams);
}
ti = proto_tree_add_uint(se_tree, hf_se_event_type, tvb, 0, 0, event_type);
syscall_tree = proto_item_add_subtree(ti, ett_sysdig_syscall);
for (cur_tree_info = event_tree_info; cur_tree_info->hf_indexes; cur_tree_info++) {
if (cur_tree_info->event_type == event_type) {
dissect_event_params(tvb, pinfo, &event_name, &pinfo->rec->rec_header.syscall_header, 0, syscall_tree, encoding, cur_tree_info->hf_indexes);
break;
}
}
proto_tree_add_string(se_tree, hf_se_event_name, tvb, 0, 0, event_name);
/* XXX */
/* return offset; */
return pinfo->rec->rec_header.syscall_header.event_len;
}
/* Register the protocol with Wireshark.
*
* This format is required because a script is used to build the C function that
* calls all the protocol registration.
*/
void
proto_register_sysdig_event(void)
{
/* XXX Match up with Sysdig's names. */
static hf_register_info hf[] = {
{ &hf_se_cpu_id,
{ "CPU ID", "sysdig.cpu_id",
FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }
},
{ &hf_se_thread_id,
{ "Thread ID", "sysdig.thread_id",
FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL }
},
{ &hf_se_event_length,
{ "Event length", "sysdig.event_len",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }
},
{ &hf_se_nparams,
{ "Number of parameters", "sysdig.nparams",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }
},
{ &hf_se_event_type,
{ "Event type", "sysdig.event_type",
FT_UINT16, BASE_DEC, VALS(event_type_vals), 0, NULL, HFILL }
},
{ &hf_se_event_name,
{ "Event name", "sysdig.event_name",
FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }
},
{ &hf_se_param_lens,
{ "Parameter lengths", "sysdig.param.lens",
FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }
},
{ &hf_se_param_len,
{ "Parameter length", "sysdig.param.len",
FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }
},
/* Header field registration. Automatically generated by tools/generate-sysdig-event.py */
{ &hf_param_ID_uint16, { "ID", "sysdig.param.syscall.ID", FT_UINT16, BASE_DEC, VALS(ID_uint16_vals), 0, NULL, HFILL } },
{ &hf_param_action_uint32, { "action", "sysdig.param.cpu_hotplug.action", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_addr_bytes, { "addr", "sysdig.param.ptrace.addr", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_addr_uint64, { "addr", "sysdig.param.mlock2.addr", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },
{ &hf_param_arg2_int_int64, { "arg2_int", "sysdig.param.prctl.arg2_int", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_arg2_str_string, { "arg2_str", "sysdig.param.prctl.arg2_str", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_arg_uint64, { "arg", "sysdig.param.io_uring_register.arg", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },
{ &hf_param_args_string, { "args", "sysdig.param.clone3.args", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_argument_uint64, { "I/O control: argument", "sysdig.param.ioctl.argument", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },
{ &hf_param_aux_int32, { "aux", "sysdig.param.fsconfig.aux", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_backlog_int32, { "backlog", "sysdig.param.listen.backlog", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_cap_effective_uint64, { "cap_effective", "sysdig.param.capset.cap_effective", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },
{ &hf_param_cap_inheritable_uint64, { "cap_inheritable", "sysdig.param.capset.cap_inheritable", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },
{ &hf_param_cap_permitted_uint64, { "cap_permitted", "sysdig.param.capset.cap_permitted", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },
{ &hf_param_cgroups_bytes, { "cgroups", "sysdig.param.clone3.cgroups", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_clockid_uint8, { "clockid", "sysdig.param.timerfd_create.clockid", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_cmd_bytes, { "cmd", "sysdig.param.fsconfig.cmd", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_cmd_int16, { "cmd", "sysdig.param.semctl.cmd", FT_INT16, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_cmd_int64, { "cmd", "sysdig.param.bpf.cmd", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_comm_string, { "comm", "sysdig.param.clone3.comm", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_container_id_string, { "container_id", "sysdig.param.groupdeleted.container_id", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_core_uint8, { "core", "sysdig.param.procexit.core", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_cpu_sys_uint64, { "cpu_sys", "sysdig.param.procinfo.cpu_sys", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_cpu_uint32, { "cpu", "sysdig.param.cpu_hotplug.cpu", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_cpu_usr_uint64, { "cpu_usr", "sysdig.param.procinfo.cpu_usr", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_cq_entries_uint32, { "cq_entries", "sysdig.param.io_uring_setup.cq_entries", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_cur_int64, { "cur", "sysdig.param.setrlimit.cur", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_cwd_string, { "cwd", "sysdig.param.clone3.cwd", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_data_bytes, { "data", "sysdig.param.asyncevent.data", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_desc_string, { "desc", "sysdig.param.notification.desc", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_description_string, { "description", "sysdig.param.infra.description", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_dev_string, { "dev", "sysdig.param.mount.dev", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_dev_uint32, { "dev", "sysdig.param.mknodat.dev", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_dir_string, { "dir", "sysdig.param.mount.dir", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_dirfd_int64, { "dirfd", "sysdig.param.mknodat.dirfd", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_domain_bytes, { "domain", "sysdig.param.socketpair.domain", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_dpid_int64, { "dpid", "sysdig.param.signaldeliver.dpid", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_dqb_bhardlimit_uint64, { "dqb_bhardlimit", "sysdig.param.quotactl.dqb_bhardlimit", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_dqb_bsoftlimit_uint64, { "dqb_bsoftlimit", "sysdig.param.quotactl.dqb_bsoftlimit", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_dqb_btime_bytes, { "dqb_btime", "sysdig.param.quotactl.dqb_btime", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_dqb_curspace_uint64, { "dqb_curspace", "sysdig.param.quotactl.dqb_curspace", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_dqb_ihardlimit_uint64, { "dqb_ihardlimit", "sysdig.param.quotactl.dqb_ihardlimit", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_dqb_isoftlimit_uint64, { "dqb_isoftlimit", "sysdig.param.quotactl.dqb_isoftlimit", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_dqb_itime_bytes, { "dqb_itime", "sysdig.param.quotactl.dqb_itime", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_dqi_bgrace_bytes, { "dqi_bgrace", "sysdig.param.quotactl.dqi_bgrace", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_dqi_flags_int8, { "dqi_flags", "sysdig.param.quotactl.dqi_flags", FT_INT8, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_dqi_igrace_bytes, { "dqi_igrace", "sysdig.param.quotactl.dqi_igrace", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_egid_int32, { "egid", "sysdig.param.getresgid.egid", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_entries_uint32, { "entries", "sysdig.param.io_uring_setup.entries", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_env_string, { "env", "sysdig.param.execveat.env", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_error_int32, { "error", "sysdig.param.page_fault.error", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_euid_int32, { "euid", "sysdig.param.getresuid.euid", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_event_data_bytes, { "event_data", "sysdig.param.pluginevent.event_data", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_event_data_uint64, { "event_data", "sysdig.param.scapevent.event_data", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_event_type_uint32, { "event_type", "sysdig.param.scapevent.event_type", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_exe_ino_ctime_bytes, { "exe_ino_ctime", "sysdig.param.execveat.exe_ino_ctime", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_exe_ino_mtime_bytes, { "exe_ino_mtime", "sysdig.param.execveat.exe_ino_mtime", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_exe_ino_uint64, { "exe_ino", "sysdig.param.execveat.exe_ino", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_exe_string, { "exe", "sysdig.param.clone3.exe", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_fd1_int64, { "fd1", "sysdig.param.pipe2.fd1", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_fd2_int64, { "fd2", "sysdig.param.pipe2.fd2", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_fd_in_int64, { "fd_in", "sysdig.param.splice.fd_in", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_fd_int64, { "fd", "sysdig.param.finit_module.fd", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_fd_out_int64, { "fd_out", "sysdig.param.splice.fd_out", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_fdin_int64, { "fdin", "sysdig.param.copy_file_range.fdin", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_fdlimit_int64, { "fdlimit", "sysdig.param.clone3.fdlimit", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_fdlimit_uint64, { "fdlimit", "sysdig.param.execveat.fdlimit", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_fdout_int64, { "fdout", "sysdig.param.copy_file_range.fdout", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_fds_bytes, { "fds", "sysdig.param.ppoll.fds", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_features_int32, { "features", "sysdig.param.io_uring_setup.features", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_filename_string, { "filename", "sysdig.param.chmod.filename", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_flags_int16, { "flags", "sysdig.param.signalfd4.flags", FT_INT16, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_flags_int32, { "flags", "sysdig.param.finit_module.flags", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_flags_int8, { "flags", "sysdig.param.inotify_init.flags", FT_INT8, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_flags_uint32, { "flags", "sysdig.param.accept4.flags", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL } },
{ &hf_param_gid_int32, { "gid", "sysdig.param.getgid.gid", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_gid_uint32, { "gid", "sysdig.param.fchownat.gid", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_home_string, { "home", "sysdig.param.userdeleted.home", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_how_bytes, { "how", "sysdig.param.shutdown.how", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_id_int64, { "id", "sysdig.param.tracer.id", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_id_string, { "id", "sysdig.param.notification.id", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_id_uint32, { "id", "sysdig.param.quotactl.id", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_image_string, { "image", "sysdig.param.container.image", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_img_bytes, { "img", "sysdig.param.init_module.img", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_in_fd_int64, { "in_fd", "sysdig.param.sendfile.in_fd", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_initval_uint64, { "initval", "sysdig.param.eventfd2.initval", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_ino_uint64, { "ino", "sysdig.param.pipe2.ino", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_interval_bytes, { "interval", "sysdig.param.nanosleep.interval", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_ip_uint64, { "ip", "sysdig.param.page_fault.ip", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },
{ &hf_param_json_string, { "json", "sysdig.param.container.json", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_key_int32, { "key", "sysdig.param.semget.key", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_key_string, { "key", "sysdig.param.fsconfig.key", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_len_uint64, { "len", "sysdig.param.mlock2.len", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_length_uint64, { "length", "sysdig.param.init_module.length", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_level_bytes, { "level", "sysdig.param.getsockopt.level", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_linkdirfd_int64, { "linkdirfd", "sysdig.param.symlinkat.linkdirfd", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_linkpath_string, { "linkpath", "sysdig.param.symlinkat.linkpath", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_loginuid_int32, { "loginuid", "sysdig.param.execveat.loginuid", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_mask_uint32, { "mask", "sysdig.param.signalfd4.mask", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL } },
{ &hf_param_max_int64, { "max", "sysdig.param.setrlimit.max", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_maxevents_int64, { "maxevents", "sysdig.param.epoll_wait.maxevents", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_min_complete_uint32, { "min_complete", "sysdig.param.io_uring_enter.min_complete", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_mode_int32, { "mode", "sysdig.param.mknodat.mode", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_mode_uint32, { "mode", "sysdig.param.openat2.mode", FT_UINT32, BASE_OCT, NULL, 0, NULL, HFILL } },
{ &hf_param_mountfd_int64, { "mountfd", "sysdig.param.open_by_handle_at.mountfd", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_name_string, { "name", "sysdig.param.memfd_create.name", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_nativeID_uint16, { "nativeID", "sysdig.param.syscall.nativeID", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_newcur_int64, { "newcur", "sysdig.param.prlimit.newcur", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_newdir_int64, { "newdir", "sysdig.param.linkat.newdir", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_newdirfd_int64, { "newdirfd", "sysdig.param.renameat2.newdirfd", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_newfd_int64, { "newfd", "sysdig.param.dup3.newfd", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_newmax_int64, { "newmax", "sysdig.param.prlimit.newmax", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_newpath_string, { "newpath", "sysdig.param.renameat2.newpath", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_next_int64, { "next", "sysdig.param.switch.next", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_nr_args_uint32, { "nr_args", "sysdig.param.io_uring_register.nr_args", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_nsems_int32, { "nsems", "sysdig.param.semget.nsems", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_nsops_uint32, { "nsops", "sysdig.param.semop.nsops", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_nstype_int32, { "nstype", "sysdig.param.setns.nstype", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_offin_uint64, { "offin", "sysdig.param.copy_file_range.offin", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_offout_uint64, { "offout", "sysdig.param.copy_file_range.offout", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_offset_uint64, { "offset", "sysdig.param.sendfile.offset", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_oldcur_int64, { "oldcur", "sysdig.param.prlimit.oldcur", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_olddir_int64, { "olddir", "sysdig.param.linkat.olddir", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_olddirfd_int64, { "olddirfd", "sysdig.param.renameat2.olddirfd", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_oldfd_int64, { "oldfd", "sysdig.param.dup.oldfd", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_oldmax_int64, { "oldmax", "sysdig.param.prlimit.oldmax", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_oldpath_string, { "oldpath", "sysdig.param.renameat2.oldpath", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_op_bytes, { "op", "sysdig.param.futex.op", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_op_uint64, { "op", "sysdig.param.seccomp.op", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_opcode_bytes, { "opcode", "sysdig.param.io_uring_register.opcode", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_operation_int32, { "operation", "sysdig.param.flock.operation", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_option_bytes, { "option", "sysdig.param.prctl.option", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_optlen_uint32, { "optlen", "sysdig.param.getsockopt.optlen", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_optname_bytes, { "optname", "sysdig.param.getsockopt.optname", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_out_fd_int64, { "out_fd", "sysdig.param.sendfile.out_fd", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_path_string, { "path", "sysdig.param.mknodat.path", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_pathname_string, { "pathname", "sysdig.param.fchownat.pathname", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_peer_uint64, { "peer", "sysdig.param.socketpair.peer", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },
{ &hf_param_pgft_maj_uint64, { "pgft_maj", "sysdig.param.clone3.pgft_maj", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_pgft_min_uint64, { "pgft_min", "sysdig.param.clone3.pgft_min", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_pgid_int64, { "pgid", "sysdig.param.execveat.pgid", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_pgoffset_uint64, { "pgoffset", "sysdig.param.mmap2.pgoffset", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_pid_fd_int64, { "pid_fd", "sysdig.param.pidfd_getfd.pid_fd", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_pid_int64, { "pid", "sysdig.param.pidfd_open.pid", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_pidns_init_start_ts_uint64, { "pidns_init_start_ts", "sysdig.param.clone3.pidns_init_start_ts", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_plugin_id_uint32, { "plugin_id", "sysdig.param.asyncevent.plugin_id", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_pos_uint64, { "pos", "sysdig.param.pwritev.pos", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_prot_int32, { "prot", "sysdig.param.mprotect.prot", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_proto_uint32, { "proto", "sysdig.param.socketpair.proto", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_ptid_int64, { "ptid", "sysdig.param.clone3.ptid", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_queuelen_uint32, { "queuelen", "sysdig.param.accept4.queuelen", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_queuemax_uint32, { "queuemax", "sysdig.param.accept4.queuemax", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_queuepct_uint8, { "queuepct", "sysdig.param.accept4.queuepct", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_quota_fmt_int8, { "quota_fmt", "sysdig.param.quotactl.quota_fmt", FT_INT8, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_quota_fmt_out_int8, { "quota_fmt_out", "sysdig.param.quotactl.quota_fmt_out", FT_INT8, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_quotafilepath_string, { "quotafilepath", "sysdig.param.quotactl.quotafilepath", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_ratio_uint32, { "ratio", "sysdig.param.drop.ratio", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_reaper_tid_int64, { "reaper_tid", "sysdig.param.procexit.reaper_tid", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_request_bytes, { "request", "sysdig.param.ptrace.request", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_request_uint64, { "I/O control: request", "sysdig.param.ioctl.request", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },
{ &hf_param_res_int64, { "res", "sysdig.param.mknodat.res", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_res_or_fd_bytes, { "res_or_fd", "sysdig.param.bpf.res_or_fd", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_res_uint64, { "res", "sysdig.param.brk.res", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },
{ &hf_param_resolve_int32, { "resolve", "sysdig.param.openat2.resolve", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_resource_bytes, { "resource", "sysdig.param.prlimit.resource", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_ret_int64, { "ret", "sysdig.param.procexit.ret", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_rgid_int32, { "rgid", "sysdig.param.getresgid.rgid", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_ruid_int32, { "ruid", "sysdig.param.getresuid.ruid", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_scope_string, { "scope", "sysdig.param.infra.scope", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_sem_flg_0_int16, { "sem_flg_0", "sysdig.param.semop.sem_flg_0", FT_INT16, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_sem_flg_1_int16, { "sem_flg_1", "sysdig.param.semop.sem_flg_1", FT_INT16, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_sem_num_0_uint16, { "sem_num_0", "sysdig.param.semop.sem_num_0", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_sem_num_1_uint16, { "sem_num_1", "sysdig.param.semop.sem_num_1", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_sem_op_0_int16, { "sem_op_0", "sysdig.param.semop.sem_op_0", FT_INT16, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_sem_op_1_int16, { "sem_op_1", "sysdig.param.semop.sem_op_1", FT_INT16, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_semflg_int32, { "semflg", "sysdig.param.semget.semflg", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_semid_int32, { "semid", "sysdig.param.semctl.semid", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_semnum_int32, { "semnum", "sysdig.param.semctl.semnum", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_sgid_int32, { "sgid", "sysdig.param.getresgid.sgid", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_shell_string, { "shell", "sysdig.param.userdeleted.shell", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_sig_bytes, { "sig", "sysdig.param.io_uring_enter.sig", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_sigmask_bytes, { "sigmask", "sysdig.param.ppoll.sigmask", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_size_int32, { "size", "sysdig.param.epoll_create.size", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_size_uint32, { "size", "sysdig.param.pwritev.size", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_size_uint64, { "size", "sysdig.param.sendfile.size", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_source_string, { "source", "sysdig.param.infra.source", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_source_uint64, { "source", "sysdig.param.socketpair.source", FT_UINT64, BASE_HEX, NULL, 0, NULL, HFILL } },
{ &hf_param_special_string, { "special", "sysdig.param.quotactl.special", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_spid_int64, { "spid", "sysdig.param.signaldeliver.spid", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_sq_entries_uint32, { "sq_entries", "sysdig.param.io_uring_setup.sq_entries", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_sq_thread_cpu_uint32, { "sq_thread_cpu", "sysdig.param.io_uring_setup.sq_thread_cpu", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_sq_thread_idle_uint32, { "sq_thread_idle", "sysdig.param.io_uring_setup.sq_thread_idle", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_status_int64, { "status", "sysdig.param.procexit.status", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_suid_int32, { "suid", "sysdig.param.getresuid.suid", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_tags_bytes, { "tags", "sysdig.param.tracer.tags", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_target_fd_int64, { "target_fd", "sysdig.param.pidfd_getfd.target_fd", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_target_string, { "target", "sysdig.param.symlinkat.target", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_tid_int64, { "tid", "sysdig.param.clone3.tid", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_timeout_bytes, { "timeout", "sysdig.param.ppoll.timeout", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_timeout_int64, { "timeout", "sysdig.param.poll.timeout", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_to_submit_uint32, { "to_submit", "sysdig.param.io_uring_enter.to_submit", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_tty_int32, { "tty", "sysdig.param.execve.tty", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_tty_uint32, { "tty", "sysdig.param.execveat.tty", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_tuple_bytes, { "tuple", "sysdig.param.accept4.tuple", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_type_int8, { "type", "sysdig.param.quotactl.type", FT_INT8, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_type_string, { "type", "sysdig.param.mount.type", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_type_uint32, { "type", "sysdig.param.container.type", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_uargs_string, { "uargs", "sysdig.param.finit_module.uargs", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_uid_int32, { "uid", "sysdig.param.execveat.uid", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_uid_uint32, { "uid", "sysdig.param.fchownat.uid", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_val_bytes, { "val", "sysdig.param.getsockopt.val", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_val_int32, { "val", "sysdig.param.semctl.val", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_val_uint64, { "val", "sysdig.param.futex.val", FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_value_bytebuf_bytes, { "value_bytebuf", "sysdig.param.fsconfig.value_bytebuf", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_value_charbuf_string, { "value_charbuf", "sysdig.param.fsconfig.value_charbuf", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL } },
{ &hf_param_vm_rss_uint32, { "vm_rss", "sysdig.param.clone3.vm_rss", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_vm_size_uint32, { "vm_size", "sysdig.param.clone3.vm_size", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_vm_swap_uint32, { "vm_swap", "sysdig.param.clone3.vm_swap", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_vpid_int64, { "vpid", "sysdig.param.clone3.vpid", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_vtid_int64, { "vtid", "sysdig.param.clone3.vtid", FT_INT64, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_param_whence_bytes, { "whence", "sysdig.param.llseek.whence", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL } },
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_sysdig_event,
&ett_sysdig_parm_lens,
&ett_sysdig_syscall
};
/* Register the protocol name and description */
proto_sysdig_event = proto_register_protocol("Sysdig Event",
"Sysdig Event", "sysdig");
/* Required function calls to register the header fields and subtrees */
proto_register_field_array(proto_sysdig_event, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_dissector("sysdig", dissect_sysdig_event, proto_sysdig_event);
}
void
proto_reg_handoff_sysdig_event(void)
{
dissector_handle_t sysdig_event_handle;
/* Use create_dissector_handle() to indicate that dissect_sysdig_event()
* returns the number of bytes it dissected (or 0 if it thinks the packet
* does not belong to PROTONAME).
*/
sysdig_event_handle = create_dissector_handle(dissect_sysdig_event,
proto_sysdig_event);
dissector_add_uint("pcapng.block_type", BLOCK_TYPE_SYSDIG_EVENT, sysdig_event_handle);
dissector_add_uint("pcapng.block_type", BLOCK_TYPE_SYSDIG_EVENT_V2, sysdig_event_handle);
dissector_add_uint("pcapng.block_type", BLOCK_TYPE_SYSDIG_EVENT_V2_LARGE, sysdig_event_handle);
plugin_dissector_handle = find_dissector("falcobridge");
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-sysex.c
|
/* packet-sysex.c
*
* MIDI SysEx dissector
* Tomasz Mon 2012
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/conversation.h>
#include <epan/expert.h>
void proto_register_sysex(void);
void proto_reg_handoff_sysex(void);
/* protocols and header fields */
static int proto_sysex = -1;
static int hf_sysex_message_start = -1;
static int hf_sysex_manufacturer_id = -1;
static int hf_sysex_three_byte_manufacturer_id = -1;
static int hf_sysex_message_eox = -1;
static gint ett_sysex = -1;
static dissector_handle_t sysex_digitech_handle;
static expert_field ei_sysex_message_start_byte = EI_INIT;
static expert_field ei_sysex_message_end_byte = EI_INIT;
static expert_field ei_sysex_undecoded = EI_INIT;
#define SYSEX_MANUFACTURER_DOD 0x000010
/* Manufacturer and Extended Manufacturer IDs as of April 2019
* https://www.midi.org/specifications-old/item/manufacturer-id-numbers
*/
static const value_string sysex_manufacturer_id_vals[] = {
{0x01, "Sequential"},
{0x02, "IDP"},
{0x03, "Voyetra Turtle Beach, Inc."},
{0x04, "Moog Music"},
{0x05, "Passport Designs"},
{0x06, "Lexicon Inc."},
{0x07, "Kurzweil / Young Chang"},
{0x08, "Fender"},
{0x09, "MIDI9"},
{0x0A, "AKG Acoustics"},
{0x0B, "Voyce Music"},
{0x0C, "WaveFrame (Timeline)"},
{0x0D, "ADA Signal Processors, Inc."},
{0x0E, "Garfield Electronics"},
{0x0F, "Ensoniq"},
{0x10, "Oberheim / Gibson Labs"},
{0x11, "Apple, Inc."},
{0x12, "Grey Matter Response"},
{0x13, "Digidesign Inc."},
{0x14, "Palmtree Instruments"},
{0x15, "JLCooper Electronics"},
{0x16, "Lowrey Organ Company"},
{0x17, "Adams-Smith"},
{0x18, "E-mu"},
{0x19, "Harmony Systems"},
{0x1A, "ART"},
{0x1B, "Baldwin"},
{0x1C, "Eventide"},
{0x1D, "Inventronics"},
{0x1E, "Key Concepts"},
{0x1F, "Clarity"},
{0x20, "Passac"},
{0x21, "Proel Labs (SIEL)"},
{0x22, "Synthaxe (UK)"},
{0x23, "Stepp"},
{0x24, "Hohner"},
{0x25, "Twister"},
{0x26, "Ketron s.r.l."},
{0x27, "Jellinghaus MS"},
{0x28, "Southworth Music Systems"},
{0x29, "PPG (Germany)"},
{0x2A, "JEN"},
{0x2B, "Solid State Logic Organ Systems"},
{0x2C, "Audio Veritrieb-P. Struven"},
{0x2D, "Neve"},
{0x2E, "Soundtracs Ltd."},
{0x2F, "Elka"},
{0x30, "Dynacord"},
{0x31, "Viscount International Spa (Intercontinental Electronics)"},
{0x32, "Drawmer"},
{0x33, "Clavia Digital Instruments"},
{0x34, "Audio Architecture"},
{0x35, "Generalmusic Corp SpA"},
{0x36, "Cheetah Marketing"},
{0x37, "C.T.M."},
{0x38, "Simmons UK"},
{0x39, "Soundcraft Electronics"},
{0x3A, "Steinberg Media Technologies AG"},
{0x3B, "Wersi Gmbh"},
{0x3C, "AVAB Niethammer AB"},
{0x3D, "Digigram"},
{0x3E, "Waldorf Electronics GmbH"},
{0x3F, "Quasimidi"},
{0x40, "Kawai Musical Instruments MFG. CO. Ltd"},
{0x41, "Roland Corporation"},
{0x42, "Korg Inc."},
{0x43, "Yamaha Corporation"},
{0x44, "Casio Computer Co. Ltd"},
{0x46, "Kamiya Studio Co. Ltd"},
{0x47, "Akai Electric Co. Ltd."},
{0x48, "Victor Company of Japan, Ltd."},
{0x4B, "Fujitsu Limited"},
{0x4C, "Sony Corporation"},
{0x4E, "Teac Corporation"},
{0x50, "Matsushita Electric Industrial Co. , Ltd"},
{0x51, "Fostex Corporation"},
{0x52, "Zoom Corporation"},
{0x54, "Matsushita Communication Industrial Co., Ltd."},
{0x55, "Suzuki Musical Instruments MFG. Co., Ltd."},
{0x56, "Fuji Sound Corporation Ltd."},
{0x57, "Acoustic Technical Laboratory, Inc."},
{0x59, "Faith, Inc."},
{0x5A, "Internet Corporation"},
{0x5C, "Seekers Co. Ltd."},
{0x5F, "SD Card Association"},
/* Three special IDs specified in MIDI 1.0 Detailed Specification */
{0x7D, "Educational/Non-Commercial Use"},
{0x7E, "Non-Real Time Universal System Exclusive"},
{0x7F, "Real Time Universal System Exclusive"},
{0,NULL}
};
static value_string_ext sysex_manufacturer_id_vals_ext =
VALUE_STRING_EXT_INIT(sysex_manufacturer_id_vals);
static const value_string sysex_extended_manufacturer_id_vals[] = {
{0x000001, "Time/Warner Interactive"},
{0x000002, "Advanced Gravis Comp. Tech Ltd."},
{0x000003, "Media Vision"},
{0x000004, "Dornes Research Group"},
{0x000005, "K-Muse"},
{0x000006, "Stypher"},
{0x000007, "Digital Music Corp."},
{0x000008, "IOTA Systems"},
{0x000009, "New England Digital"},
{0x00000A, "Artisyn"},
{0x00000B, "IVL Technologies Ltd."},
{0x00000C, "Southern Music Systems"},
{0x00000D, "Lake Butler Sound Company"},
{0x00000E, "Alesis Studio Electronics"},
{0x00000F, "Sound Creation"},
{0x000010, "DOD Electronics Corp."},
{0x000011, "Studer-Editech"},
{0x000012, "Sonus"},
{0x000013, "Temporal Acuity Products"},
{0x000014, "Perfect Fretworks"},
{0x000015, "KAT Inc."},
{0x000016, "Opcode Systems"},
{0x000017, "Rane Corporation"},
{0x000018, "Anadi Electronique"},
{0x000019, "KMX"},
{0x00001A, "Allen & Heath Brenell"},
{0x00001B, "Peavey Electronics"},
{0x00001C, "360 Systems"},
{0x00001D, "Spectrum Design and Development"},
{0x00001E, "Marquis Music"},
{0x00001F, "Zeta Systems"},
{0x000020, "Axxes (Brian Parsonett)"},
{0x000021, "Orban"},
{0x000022, "Indian Valley Mfg."},
{0x000023, "Triton"},
{0x000024, "KTI"},
{0x000025, "Breakaway Technologies"},
{0x000026, "Leprecon / CAE Inc."},
{0x000027, "Harrison Systems Inc."},
{0x000028, "Future Lab/Mark Kuo"},
{0x000029, "Rocktron Corporation"},
{0x00002A, "PianoDisc"},
{0x00002B, "Cannon Research Group"},
{0x00002C, "Reserved"},
{0x00002D, "Rodgers Instrument LLC"},
{0x00002E, "Blue Sky Logic"},
{0x00002F, "Encore Electronics"},
{0x000030, "Uptown"},
{0x000031, "Voce"},
{0x000032, "CTI Audio, Inc. (Musically Intel. Devs.)"},
{0x000033, "S3 Incorporated"},
{0x000034, "Broderbund / Red Orb"},
{0x000035, "Allen Organ Co."},
{0x000036, "Reserved"},
{0x000037, "Music Quest"},
{0x000038, "Aphex"},
{0x000039, "Gallien Krueger"},
{0x00003A, "IBM"},
{0x00003B, "Mark Of The Unicorn"},
{0x00003C, "Hotz Corporation"},
{0x00003D, "ETA Lighting"},
{0x00003E, "NSI Corporation"},
{0x00003F, "Ad Lib, Inc."},
{0x000040, "Richmond Sound Design"},
{0x000041, "Microsoft"},
{0x000042, "Mindscape (Software Toolworks)"},
{0x000043, "Russ Jones Marketing / Niche"},
{0x000044, "Intone"},
{0x000045, "Advanced Remote Technologies"},
{0x000046, "White Instruments"},
{0x000047, "GT Electronics/Groove Tubes"},
{0x000048, "Pacific Research & Engineering"},
{0x000049, "Timeline Vista, Inc."},
{0x00004A, "Mesa Boogie Ltd."},
{0x00004B, "FSLI"},
{0x00004C, "Sequoia Development Group"},
{0x00004D, "Studio Electronics"},
{0x00004E, "Euphonix, Inc"},
{0x00004F, "InterMIDI, Inc."},
{0x000050, "MIDI Solutions Inc."},
{0x000051, "3DO Company"},
{0x000052, "Lightwave Research / High End Systems"},
{0x000053, "Micro-W Corporation"},
{0x000054, "Spectral Synthesis, Inc."},
{0x000055, "Lone Wolf"},
{0x000056, "Studio Technologies Inc."},
{0x000057, "Peterson Electro-Musical Product, Inc."},
{0x000058, "Atari Corporation"},
{0x000059, "Marion Systems Corporation"},
{0x00005A, "Design Event"},
{0x00005B, "Winjammer Software Ltd."},
{0x00005C, "AT&T Bell Laboratories"},
{0x00005D, "Reserved"},
{0x00005E, "Symetrix"},
{0x00005F, "MIDI the World"},
{0x000060, "Spatializer"},
{0x000061, "Micros 'N MIDI"},
{0x000062, "Accordians International"},
{0x000063, "EuPhonics (now 3Com)"},
{0x000064, "Musonix"},
{0x000065, "Turtle Beach Systems (Voyetra)"},
{0x000066, "Loud Technologies / Mackie"},
{0x000067, "Compuserve"},
{0x000068, "BEC Technologies"},
{0x000069, "QRS Music Inc"},
{0x00006A, "P.G. Music"},
{0x00006B, "Sierra Semiconductor"},
{0x00006C, "EpiGraf"},
{0x00006D, "Electronics Diversified Inc"},
{0x00006E, "Tune 1000"},
{0x00006F, "Advanced Micro Devices"},
{0x000070, "Mediamation"},
{0x000071, "Sabine Musical Mfg. Co. Inc."},
{0x000072, "Woog Labs"},
{0x000073, "Micropolis Corp"},
{0x000074, "Ta Horng Musical Instrument"},
{0x000075, "e-Tek Labs (Forte Tech)"},
{0x000076, "Electro-Voice"},
{0x000077, "Midisoft Corporation"},
{0x000078, "QSound Labs"},
{0x000079, "Westrex"},
{0x00007A, "Nvidia"},
{0x00007B, "ESS Technology"},
{0x00007C, "Media Trix Peripherals"},
{0x00007D, "Brooktree Corp"},
{0x00007E, "Otari Corp"},
{0x00007F, "Key Electronics, Inc."},
{0x000100, "Shure Incorporated"},
{0x000101, "AuraSound"},
{0x000102, "Crystal Semiconductor"},
{0x000103, "Conexant (Rockwell)"},
{0x000104, "Silicon Graphics"},
{0x000105, "M-Audio (Midiman)"},
{0x000106, "PreSonus"},
{0x000108, "Topaz Enterprises"},
{0x000109, "Cast Lighting"},
{0x00010A, "Microsoft"},
{0x00010B, "Sonic Foundry"},
{0x00010C, "Line 6 (Fast Forward) (Yamaha)"},
{0x00010D, "Beatnik Inc"},
{0x00010E, "Van Koevering Company"},
{0x00010F, "Altech Systems"},
{0x000110, "S & S Research"},
{0x000111, "VLSI Technology"},
{0x000112, "Chromatic Research"},
{0x000113, "Sapphire"},
{0x000114, "IDRC"},
{0x000115, "Justonic Tuning"},
{0x000116, "TorComp Research Inc."},
{0x000117, "Newtek Inc."},
{0x000118, "Sound Sculpture"},
{0x000119, "Walker Technical"},
{0x00011A, "Digital Harmony (PAVO)"},
{0x00011B, "InVision Interactive"},
{0x00011C, "T-Square Design"},
{0x00011D, "Nemesys Music Technology"},
{0x00011E, "DBX Professional (Harman Intl)"},
{0x00011F, "Syndyne Corporation"},
{0x000120, "Bitheadz"},
{0x000121, "Cakewalk Music Software"},
{0x000122, "Analog Devices"},
{0x000123, "National Semiconductor"},
{0x000124, "Boom Theory / Adinolfi Alternative Percussion"},
{0x000125, "Virtual DSP Corporation"},
{0x000126, "Antares Systems"},
{0x000127, "Angel Software"},
{0x000128, "St Louis Music"},
{0x000129, "Passport Music Software LLC (Gvox)"},
{0x00012A, "Ashley Audio Inc."},
{0x00012B, "Vari-Lite Inc."},
{0x00012C, "Summit Audio Inc."},
{0x00012D, "Aureal Semiconductor Inc."},
{0x00012E, "SeaSound LLC"},
{0x00012F, "U.S. Robotics"},
{0x000130, "Aurisis Research"},
{0x000131, "Nearfield Research"},
{0x000132, "FM7 Inc"},
{0x000133, "Swivel Systems"},
{0x000134, "Hyperactive Audio Systems"},
{0x000135, "MidiLite (Castle Studios Productions)"},
{0x000136, "Radikal Technologies"},
{0x000137, "Roger Linn Design"},
{0x000138, "TC-Helicon Vocal Technologies"},
{0x000139, "Event Electronics"},
{0x00013A, "Sonic Network Inc"},
{0x00013B, "Realtime Music Solutions"},
{0x00013C, "Apogee Digital"},
{0x00013D, "Classical Organs, Inc."},
{0x00013E, "Microtools Inc."},
{0x00013F, "Numark Industries"},
{0x000140, "Frontier Design Group, LLC"},
{0x000141, "Recordare LLC"},
{0x000142, "Starr Labs"},
{0x000143, "Voyager Sound Inc."},
{0x000144, "Manifold Labs"},
{0x000145, "Aviom Inc."},
{0x000146, "Mixmeister Technology"},
{0x000147, "Notation Software"},
{0x000148, "Mercurial Communications"},
{0x000149, "Wave Arts"},
{0x00014A, "Logic Sequencing Devices"},
{0x00014B, "Axess Electronics"},
{0x00014C, "Muse Research"},
{0x00014D, "Open Labs"},
{0x00014E, "Guillemot Corp"},
{0x00014F, "Samson Technologies"},
{0x000150, "Electronic Theatre Controls"},
{0x000151, "Blackberry (RIM)"},
{0x000152, "Mobileer"},
{0x000153, "Synthogy"},
{0x000154, "Lynx Studio Technology Inc."},
{0x000155, "Damage Control Engineering LLC"},
{0x000156, "Yost Engineering, Inc."},
{0x000157, "Brooks & Forsman Designs LLC / DrumLite"},
{0x000158, "Infinite Response"},
{0x000159, "Garritan Corp"},
{0x00015A, "Plogue Art et Technologie, Inc"},
{0x00015B, "RJM Music Technology"},
{0x00015C, "Custom Solutions Software"},
{0x00015D, "Sonarcana LLC / Highly Liquid"},
{0x00015E, "Centrance"},
{0x00015F, "Kesumo LLC"},
{0x000160, "Stanton (Gibson Brands)"},
{0x000161, "Livid Instruments"},
{0x000162, "First Act / 745 Media"},
{0x000163, "Pygraphics, Inc."},
{0x000164, "Panadigm Innovations Ltd"},
{0x000165, "Avedis Zildjian Co"},
{0x000166, "Auvital Music Corp"},
{0x000167, "You Rock Guitar (was: Inspired Instruments)"},
{0x000168, "Chris Grigg Designs"},
{0x000169, "Slate Digital LLC"},
{0x00016A, "Mixware"},
{0x00016B, "Social Entropy"},
{0x00016C, "Source Audio LLC"},
{0x00016D, "Ernie Ball / Music Man"},
{0x00016E, "Fishman"},
{0x00016F, "Custom Audio Electronics"},
{0x000170, "American Audio/DJ"},
{0x000171, "Mega Control Systems"},
{0x000172, "Kilpatrick Audio"},
{0x000173, "iConnectivity"},
{0x000174, "Fractal Audio"},
{0x000175, "NetLogic Microsystems"},
{0x000176, "Music Computing"},
{0x000177, "Nektar Technology Inc"},
{0x000178, "Zenph Sound Innovations"},
{0x000179, "DJTechTools.com"},
{0x00017A, "Rezonance Labs"},
{0x00017B, "Decibel Eleven"},
{0x00017C, "CNMAT"},
{0x00017D, "Media Overkill"},
{0x00017E, "Confusion Studios"},
{0x00017F, "moForte Inc"},
{0x000200, "Miselu Inc"},
{0x000201, "Amelia's Compass LLC"},
{0x000202, "Zivix LLC"},
{0x000203, "Artiphon"},
{0x000204, "Synclavier Digital"},
{0x000205, "Light & Sound Control Devices LLC"},
{0x000206, "Retronyms Inc"},
{0x000207, "JS Technologies"},
{0x000208, "Quicco Sound"},
{0x000209, "A-Designs Audio"},
{0x00020A, "McCarthy Music Corp"},
{0x00020B, "Denon DJ"},
{0x00020C, "Keith Robert Murray"},
{0x00020D, "Google"},
{0x00020E, "ISP Technologies"},
{0x00020F, "Abstrakt Instruments LLC"},
{0x000210, "Meris LLC"},
{0x000211, "Sensorpoint LLC"},
{0x000212, "Hi-Z Labs"},
{0x000213, "Imitone"},
{0x000214, "Intellijel Designs Inc."},
{0x000215, "Dasz Instruments Inc."},
{0x000216, "Remidi"},
{0x000217, "Disaster Area Designs LLC"},
{0x000218, "Universal Audio"},
{0x000219, "Carter Duncan Corp"},
{0x00021A, "Essential Technology"},
{0x00021B, "Cantux Research LLC"},
{0x00021C, "Hummel Technologies"},
{0x00021D, "Sensel Inc"},
{0x00021E, "DBML Group"},
{0x00021F, "Madrona Labs"},
{0x000220, "Mesa Boogie"},
{0x000221, "Effigy Labs"},
{0x000222, "MK2 Image Ltd"},
{0x000223, "Red Panda LLC"},
{0x000224, "OnSong LLC"},
{0x000225, "Jamboxx Inc."},
{0x000226, "Electro-Harmonix "},
{0x000227, "RnD64 Inc"},
{0x000228, "Neunaber Technology LLC "},
{0x000229, "Kaom Inc."},
{0x00022A, "Hallowell EMC"},
{0x00022B, "Sound Devices, LLC"},
{0x00022C, "Spectrasonics, Inc"},
{0x00022D, "Second Sound, LLC"},
{0x002000, "Dream SAS"},
{0x002001, "Strand Lighting"},
{0x002002, "Amek Div of Harman Industries"},
{0x002003, "Casa Di Risparmio Di Loreto"},
{0x002004, "Böhm electronic GmbH"},
{0x002005, "Syntec Digital Audio"},
{0x002006, "Trident Audio Developments"},
{0x002007, "Real World Studio"},
{0x002008, "Evolution Synthesis, Ltd"},
{0x002009, "Yes Technology"},
{0x00200A, "Audiomatica"},
{0x00200B, "Bontempi SpA (Sigma)"},
{0x00200C, "F.B.T. Elettronica SpA"},
{0x00200D, "MidiTemp GmbH"},
{0x00200E, "LA Audio (Larking Audio)"},
{0x00200F, "Zero 88 Lighting Limited"},
{0x002010, "Micon Audio Electronics GmbH"},
{0x002011, "Forefront Technology"},
{0x002012, "Studio Audio and Video Ltd."},
{0x002013, "Kenton Electronics"},
{0x002014, "Celco/ Electrosonic"},
{0x002015, "ADB"},
{0x002016, "Marshall Products Limited"},
{0x002017, "DDA"},
{0x002018, "BSS Audio Ltd."},
{0x002019, "MA Lighting Technology"},
{0x00201A, "Fatar SRL c/o Music Industries"},
{0x00201B, "QSC Audio Products Inc."},
{0x00201C, "Artisan Clasic Organ Inc."},
{0x00201D, "Orla Spa"},
{0x00201E, "Pinnacle Audio (Klark Teknik PLC)"},
{0x00201F, "TC Electronics"},
{0x002020, "Doepfer Musikelektronik GmbH"},
{0x002021, "Creative ATC / E-mu"},
{0x002022, "Seyddo/Minami"},
{0x002023, "LG Electronics (Goldstar)"},
{0x002024, "Midisoft sas di M.Cima & C"},
{0x002025, "Samick Musical Inst. Co. Ltd."},
{0x002026, "Penny and Giles (Bowthorpe PLC)"},
{0x002027, "Acorn Computer"},
{0x002028, "LSC Electronics Pty. Ltd."},
{0x002029, "Focusrite/Novation"},
{0x00202A, "Samkyung Mechatronics"},
{0x00202B, "Medeli Electronics Co."},
{0x00202C, "Charlie Lab SRL"},
{0x00202D, "Blue Chip Music Technology"},
{0x00202E, "BEE OH Corp"},
{0x00202F, "LG Semicon America"},
{0x002030, "TESI"},
{0x002031, "EMAGIC"},
{0x002032, "Behringer GmbH"},
{0x002033, "Access Music Electronics"},
{0x002034, "Synoptic"},
{0x002035, "Hanmesoft"},
{0x002036, "Terratec Electronic GmbH"},
{0x002037, "Proel SpA"},
{0x002038, "IBK MIDI"},
{0x002039, "IRCAM"},
{0x00203A, "Propellerhead Software"},
{0x00203B, "Red Sound Systems Ltd"},
{0x00203C, "Elektron ESI AB"},
{0x00203D, "Sintefex Audio"},
{0x00203E, "MAM (Music and More)"},
{0x00203F, "Amsaro GmbH"},
{0x002040, "CDS Advanced Technology BV (Lanbox)"},
{0x002041, "Mode Machines (Touched By Sound GmbH)"},
{0x002042, "DSP Arts"},
{0x002043, "Phil Rees Music Tech"},
{0x002044, "Stamer Musikanlagen GmbH"},
{0x002045, "Musical Muntaner S.A. dba Soundart"},
{0x002046, "C-Mexx Software"},
{0x002047, "Klavis Technologies"},
{0x002048, "Noteheads AB"},
{0x002049, "Algorithmix"},
{0x00204A, "Skrydstrup R&D"},
{0x00204B, "Professional Audio Company"},
{0x00204C, "NewWave Labs (MadWaves)"},
{0x00204D, "Vermona"},
{0x00204E, "Nokia"},
{0x00204F, "Wave Idea"},
{0x002050, "Hartmann GmbH"},
{0x002051, "Lion's Tracs"},
{0x002052, "Analogue Systems"},
{0x002053, "Focal-JMlab"},
{0x002054, "Ringway Electronics (Chang-Zhou) Co Ltd"},
{0x002055, "Faith Technologies (Digiplug)"},
{0x002056, "Showworks"},
{0x002057, "Manikin Electronic"},
{0x002058, "1 Come Tech"},
{0x002059, "Phonic Corp"},
{0x00205A, "Dolby Australia (Lake)"},
{0x00205B, "Silansys Technologies"},
{0x00205C, "Winbond Electronics"},
{0x00205D, "Cinetix Medien und Interface GmbH"},
{0x00205E, "A&G Soluzioni Digitali"},
{0x00205F, "Sequentix GmbH"},
{0x002060, "Oram Pro Audio"},
{0x002061, "Be4 Ltd"},
{0x002062, "Infection Music"},
{0x002063, "Central Music Co. (CME)"},
{0x002064, "genoQs Machines GmbH"},
{0x002065, "Medialon"},
{0x002066, "Waves Audio Ltd"},
{0x002067, "Jerash Labs"},
{0x002068, "Da Fact"},
{0x002069, "Elby Designs"},
{0x00206A, "Spectral Audio"},
{0x00206B, "Arturia"},
{0x00206C, "Vixid"},
{0x00206D, "C-Thru Music"},
{0x00206E, "Ya Horng Electronic Co LTD"},
{0x00206F, "SM Pro Audio"},
{0x002070, "OTO Machines"},
{0x002071, "ELZAB S.A. (G LAB)"},
{0x002072, "Blackstar Amplification Ltd"},
{0x002073, "M3i Technologies GmbH"},
{0x002074, "Gemalto (from Xiring)"},
{0x002075, "Prostage SL"},
{0x002076, "Teenage Engineering"},
{0x002077, "Tobias Erichsen Consulting"},
{0x002078, "Nixer Ltd"},
{0x002079, "Hanpin Electron Co Ltd"},
{0x00207A, "\"MIDI-hardware\" R.Sowa"},
{0x00207B, "Beyond Music Industrial Ltd"},
{0x00207C, "Kiss Box B.V."},
{0x00207D, "Misa Digital Technologies Ltd"},
{0x00207E, "AI Musics Technology Inc"},
{0x00207F, "Serato Inc LP"},
{0x002100, "Limex"},
{0x002101, "Kyodday (Tokai)"},
{0x002102, "Mutable Instruments"},
{0x002103, "PreSonus Software Ltd"},
{0x002104, "Ingenico (was Xiring)"},
{0x002105, "Fairlight Instruments Pty Ltd"},
{0x002106, "Musicom Lab"},
{0x002107, "Modal Electronics (Modulus/VacoLoco)"},
{0x002108, "RWA (Hong Kong) Limited"},
{0x002109, "Native Instruments"},
{0x00210A, "Naonext"},
{0x00210B, "MFB"},
{0x00210C, "Teknel Research"},
{0x00210D, "Ploytec GmbH"},
{0x00210E, "Surfin Kangaroo Studio"},
{0x00210F, "Philips Electronics HK Ltd"},
{0x002110, "ROLI Ltd"},
{0x002111, "Panda-Audio Ltd"},
{0x002112, "BauM Software"},
{0x002113, "Machinewerks Ltd."},
{0x002114, "Xiamen Elane Electronics"},
{0x002115, "Marshall Amplification PLC"},
{0x002116, "Kiwitechnics Ltd"},
{0x002117, "Rob Papen"},
{0x002118, "Spicetone OU"},
{0x002119, "V3Sound"},
{0x00211A, "IK Multimedia"},
{0x00211B, "Novalia Ltd"},
{0x00211C, "Modor Music"},
{0x00211D, "Ableton"},
{0x00211E, "Dtronics"},
{0x00211F, "ZAQ Audio"},
{0x002120, "Muabaobao Education Technology Co Ltd"},
{0x002121, "Flux Effects"},
{0x002122, "Audiothingies (MCDA)"},
{0x002123, "Retrokits"},
{0x002124, "Morningstar FX Pte Ltd"},
{0x002125, "Changsha Hotone Audio Co Ltd"},
{0x002126, "Expressive E"},
{0x002127, "Expert Sleepers Ltd"},
{0x002128, "Timecode-Vision Technology"},
{0x002129, "Hornberg Research GbR"},
{0x00212A, "Sonic Potions"},
{0x00212B, "Audiofront"},
{0x00212C, "Fred's Lab"},
{0x00212D, "Audio Modeling"},
{0x00212E, "C. Bechstein Digital GmbH"},
{0x00212F, "Motas Electronics Ltd"},
{0x002130, "MIND Music Labs"},
{0x002131, "Sonic Academy Ltd"},
{0x002132, "Bome Software"},
{0x002133, "AODYO SAS"},
{0x002134, "Pianoforce S.R.O"},
{0x002135, "Dreadbox P.C."},
{0x002136, "TouchKeys Instruments Ltd"},
{0x002137, "The Gigrig Ltd"},
{0x002138, "ALM Co"},
{0x002139, "CH Sound Design"},
{0x00213A, "Beat Bars"},
{0x00213B, "Blokas"},
{0x00213C, "GEWA Music GmbH"},
{0x00213D, "dadamachines"},
{0x00213E, "Augmented Instruments Ltd (Bela)"},
{0x00213F, "Supercritical Ltd"},
{0x004000, "Crimson Technology Inc."},
{0x004001, "Softbank Mobile Corp"},
{0x004003, "D&M Holdings Inc."},
{0,NULL}
};
static value_string_ext sysex_extended_manufacturer_id_vals_ext =
VALUE_STRING_EXT_INIT(sysex_extended_manufacturer_id_vals);
/* dissector for System Exclusive MIDI data */
static int
dissect_sysex_command(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_)
{
guint8 sysex_helper;
gint data_len;
proto_item *item;
proto_item *ti = NULL;
proto_tree *tree = NULL;
gint offset = 0;
gint manufacturer_payload_len;
guint8 manufacturer_id;
guint32 three_byte_manufacturer_id = 0xFFFFFF;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SYSEX");
col_set_str(pinfo->cinfo, COL_INFO, "MIDI System Exclusive Command");
data_len = tvb_reported_length(tvb);
ti = proto_tree_add_protocol_format(parent_tree, proto_sysex, tvb, 0, -1, "MIDI System Exclusive Command");
tree = proto_item_add_subtree(ti, ett_sysex);
/* Check start byte (System Exclusive - 0xF0) */
sysex_helper = tvb_get_guint8(tvb, 0);
item = proto_tree_add_item(tree, hf_sysex_message_start, tvb, offset, 1, ENC_BIG_ENDIAN);
if (sysex_helper != 0xF0)
{
expert_add_info(pinfo, item, &ei_sysex_message_start_byte);
}
offset++;
manufacturer_id = tvb_get_guint8(tvb, offset);
/* Three-byte manufacturer ID starts with 00 */
if (manufacturer_id == 0)
{
three_byte_manufacturer_id = tvb_get_ntoh24(tvb, offset);
proto_tree_add_item(tree, hf_sysex_three_byte_manufacturer_id, tvb, offset, 3, ENC_BIG_ENDIAN);
offset += 3;
}
/* One-byte manufacturer ID */
else
{
proto_tree_add_item(tree, hf_sysex_manufacturer_id, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
}
/* Following data is menufacturer-specific */
manufacturer_payload_len = data_len - offset - 1;
if (manufacturer_payload_len > 0)
{
tvbuff_t *payload_tvb = tvb_new_subset_length(tvb, offset, manufacturer_payload_len);
switch (three_byte_manufacturer_id)
{
case SYSEX_MANUFACTURER_DOD:
{
offset += call_dissector(sysex_digitech_handle, payload_tvb, pinfo, parent_tree);
break;
}
default:
break;
}
}
if (offset < data_len - 1)
{
proto_tree_add_expert(tree, pinfo, &ei_sysex_undecoded, tvb, offset, data_len - offset - 1);
}
/* Check end byte (EOX - 0xF7) */
sysex_helper = tvb_get_guint8(tvb, data_len - 1);
item = proto_tree_add_item(tree, hf_sysex_message_eox, tvb, data_len - 1, 1, ENC_BIG_ENDIAN);
if (sysex_helper != 0xF7)
{
expert_add_info(pinfo, item, &ei_sysex_message_end_byte);
}
return tvb_captured_length(tvb);
}
void
proto_register_sysex(void)
{
static hf_register_info hf[] = {
{ &hf_sysex_message_start,
{ "SysEx message start", "sysex.start", FT_UINT8, BASE_HEX,
NULL, 0, "System Exclusive Message start (0xF0)", HFILL }},
{ &hf_sysex_manufacturer_id,
{ "Manufacturer ID", "sysex.manufacturer_id", FT_UINT8, BASE_HEX|BASE_EXT_STRING,
&sysex_manufacturer_id_vals_ext, 0, NULL, HFILL }},
{ &hf_sysex_three_byte_manufacturer_id,
{ "Manufacturer ID", "sysex.manufacturer_id", FT_UINT24, BASE_HEX|BASE_EXT_STRING,
&sysex_extended_manufacturer_id_vals_ext, 0, NULL, HFILL }},
{ &hf_sysex_message_eox,
{ "EOX", "sysex.eox", FT_UINT8, BASE_HEX,
NULL, 0, "System Exclusive Message end (0xF7)", HFILL}},
};
static gint *sysex_subtrees[] = {
&ett_sysex
};
static ei_register_info ei[] = {
{ &ei_sysex_message_start_byte, { "sysex.message_start_byte", PI_PROTOCOL, PI_WARN, "SYSEX Error: Wrong start byte", EXPFILL }},
{ &ei_sysex_message_end_byte, { "sysex.message_end_byte", PI_PROTOCOL, PI_WARN, "SYSEX Error: Wrong end byte", EXPFILL }},
{ &ei_sysex_undecoded, { "sysex.undecoded", PI_UNDECODED, PI_WARN, "Not dissected yet (report to wireshark.org)", EXPFILL }},
};
expert_module_t* expert_sysex;
proto_sysex = proto_register_protocol("MIDI System Exclusive", "SYSEX", "sysex");
proto_register_field_array(proto_sysex, hf, array_length(hf));
proto_register_subtree_array(sysex_subtrees, array_length(sysex_subtrees));
expert_sysex = expert_register_protocol(proto_sysex);
expert_register_field_array(expert_sysex, ei, array_length(ei));
register_dissector("sysex", dissect_sysex_command, proto_sysex);
}
void
proto_reg_handoff_sysex(void)
{
sysex_digitech_handle = find_dissector_add_dependency("sysex_digitech", proto_sysex);
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
|
C
|
wireshark/epan/dissectors/packet-sysex_digitech.c
|
/* packet-sysex-digitech.c
*
* MIDI SysEx dissector for Digitech devices (DOD Electronics Corp.)
* Tomasz Mon 2012
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/conversation.h>
#include <epan/expert.h>
void proto_register_sysex_digitech(void);
/* protocols and header fields */
static int proto_sysex_digitech = -1;
static int hf_digitech_device_id = -1;
static int hf_digitech_family_id = -1;
static int hf_digitech_rp_product_id = -1;
static int hf_digitech_unknown_product_id = -1;
static int hf_digitech_procedure_id = -1;
static int hf_digitech_desired_device_id = -1;
static int hf_digitech_desired_family_id = -1;
static int hf_digitech_desired_product_id = -1;
static int hf_digitech_received_device_id = -1;
static int hf_digitech_os_mode = -1;
static int hf_digitech_preset_bank = -1;
static int hf_digitech_preset_index = -1;
static int hf_digitech_preset_count = -1;
static int hf_digitech_preset_name = -1;
static int hf_digitech_preset_modified = -1;
static int hf_digitech_message_count = -1;
static int hf_digitech_parameter_count = -1;
static int hf_digitech_parameter_id = -1;
static int hf_digitech_parameter_id_global = -1;
static int hf_digitech_parameter_id_pickup = -1;
static int hf_digitech_parameter_id_wah = -1;
static int hf_digitech_parameter_id_compressor = -1;
static int hf_digitech_parameter_id_gnx3k_whammy = -1;
static int hf_digitech_parameter_id_distortion = -1;
static int hf_digitech_parameter_id_amp_channel = -1;
static int hf_digitech_parameter_id_amp = -1;
static int hf_digitech_parameter_id_amp_cabinet = -1;
static int hf_digitech_parameter_id_amp_b = -1;
static int hf_digitech_parameter_id_amp_cabinet_b = -1;
static int hf_digitech_parameter_id_noisegate = -1;
static int hf_digitech_parameter_id_volume_pre_fx = -1;
static int hf_digitech_parameter_id_chorusfx = -1;
static int hf_digitech_parameter_id_delay = -1;
static int hf_digitech_parameter_id_reverb = -1;
static int hf_digitech_parameter_id_volume_post_fx = -1;
static int hf_digitech_parameter_id_preset = -1;
static int hf_digitech_parameter_id_wah_min_max = -1;
static int hf_digitech_parameter_id_equalizer = -1;
static int hf_digitech_parameter_id_equalizer_b = -1;
static int hf_digitech_parameter_id_amp_loop = -1;
static int hf_digitech_parameter_position = -1;
static int hf_digitech_parameter_data = -1;
static int hf_digitech_parameter_data_count = -1;
static int hf_digitech_parameter_data_two_byte_count = -1;
static int hf_digitech_parameter_multibyte_data = -1;
static int hf_digitech_ack_request_proc_id = -1;
static int hf_digitech_nack_request_proc_id = -1;
static int hf_digitech_checksum = -1;
static int hf_digitech_checksum_status = -1;
static gint ett_sysex_digitech = -1;
static expert_field ei_digitech_checksum_bad = EI_INIT;
static expert_field ei_digitech_undecoded = EI_INIT;
typedef struct _digitech_conv_data_t {
gint protocol_version;
} digitech_conv_data_t;
#define DIGITECH_FAMILY_X_FLOOR 0x5C
#define DIGITECH_FAMILY_JAMMAN 0x5D
#define DIGITECH_FAMILY_RP 0x5E
#define DIGITECH_FAMILY_RACK 0x5F
#define DIGITECH_FAMILY_VOCALIST 0x60
static const value_string digitech_family_id[] = {
{DIGITECH_FAMILY_X_FLOOR, "\"X\" Floor Guitar Processor"},
{DIGITECH_FAMILY_JAMMAN, "JamMan"},
{DIGITECH_FAMILY_RP, "RP series"},
{DIGITECH_FAMILY_RACK, "Rack"},
{DIGITECH_FAMILY_VOCALIST, "Vocalist"},
{0x7F, "All"},
{0, NULL}
};
static const value_string digitech_rp_product_id[] = {
{0x01, "RP150"},
{0x02, "RP250"},
{0x03, "RP350"},
{0x04, "RP370"},
{0x05, "RP500"},
{0x06, "RP1000"},
{0x07, "RP155"},
{0x08, "RP255"},
{0x09, "RP355"},
{0, NULL}
};
typedef enum _digitech_procedure_id {
DIGITECH_PROCEDURE_REQUEST_WHO_AM_I = 0x01,
DIGITECH_PROCEDURE_RECEIVE_WHO_AM_I = 0x02,
DIGITECH_PROCEDURE_REQUEST_DEVICE_CONFIGURATION = 0x08,
DIGITECH_PROCEDURE_RECEIVE_DEVICE_CONFIGURATION = 0x09,
DIGITECH_PROCEDURE_REQUEST_GLOBAL_PARAMETERS = 0x10,
DIGITECH_PROCEDURE_RECEIVE_GLOBAL_PARAMETERS = 0x11,
DIGITECH_PROCEDURE_REQUEST_BULK_DUMP = 0x18,
DIGITECH_PROCEDURE_RECEIVE_BULK_DUMP_START = 0x19,
DIGITECH_PROCEDURE_RECEIVE_BULK_DUMP_END = 0x1B,
DIGITECH_PROCEDURE_RECEIVE_USER_PRESET_INDEX_TABLE = 0x20,
DIGITECH_PROCEDURE_REQUEST_PRESET_NAMES = 0x21,
DIGITECH_PROCEDURE_RECEIVE_PRESET_NAMES = 0x22,
DIGITECH_PROCEDURE_REQUEST_PRESET_NAME = 0x28,
DIGITECH_PROCEDURE_RECEIVE_PRESET_NAME = 0x29,
DIGITECH_PROCEDURE_REQUEST_PRESET = 0x2A,
DIGITECH_PROCEDURE_RECEIVE_PRESET_START = 0x2B,
DIGITECH_PROCEDURE_RECEIVE_PRESET_END = 0x2C,
DIGITECH_PROCEDURE_RECEIVE_PRESET_PARAMETERS = 0x2D,
DIGITECH_PROCEDURE_LOAD_EDIT_BUFFER_PRESET = 0x38, /* version 0 only
use move preset in later versions */
DIGITECH_PROCEDURE_MOVE_PRESET = 0x39,
DIGITECH_PROCEDURE_REQUEST_MODIFIER_LINKABLE_LIST = 0x3A,
DIGITECH_PROCEDURE_RECEIVE_MODIFIER_LINKABLE_LIST = 0x3B,
DIGITECH_PROCEDURE_REQUEST_PARAMETER_VALUE = 0x40,
DIGITECH_PROCEDURE_RECEIVE_PARAMETER_VALUE = 0x41,
/* version 1 and later */
DIGITECH_PROCEDURE_REQUEST_OBJECT_NAMES = 0x50,
DIGITECH_PROCEDURE_RECEIVE_OBJECT_NAMES = 0x51,
DIGITECH_PROCEDURE_REQUEST_OBJECT_NAME = 0x52,
DIGITECH_PROCEDURE_RECEIVE_OBJECT_NAME = 0x53,
DIGITECH_PROCEDURE_REQUEST_OBJECT = 0x54,
DIGITECH_PROCEDURE_RECEIVE_OBJECT = 0x55,
DIGITECH_PROCEDURE_MOVE_OBJECT = 0x56,
DIGITECH_PROCEDURE_DELETE_OBJECT = 0x57,
DIGITECH_PROCEDURE_REQUEST_TABLE = 0x5A,
DIGITECH_PROCEDURE_RECEIVE_TABLE = 0x5B,
DIGITECH_PROCEDURE_RECEIVE_DEVICE_NOTIFICATION = 0x70,
DIGITECH_PROCEDURE_START_OS_DOWNLOAD = 0x71,
DIGITECH_PROCEDURE_RESTART_DEVICE = 0x72,
DIGITECH_PROCEDURE_REQUEST_DEBUG_DATA = 0x73,
DIGITECH_PROCEDURE_RECEIVE_DEBUG_DATA = 0x74,
DIGITECH_PROCEDURE_ACK = 0x7E,
DIGITECH_PROCEDURE_NACK = 0x7F
} digitech_procedure_id;
static const value_string digitech_procedures[] = {
{DIGITECH_PROCEDURE_REQUEST_WHO_AM_I, "Request WhoAmI"},
{DIGITECH_PROCEDURE_RECEIVE_WHO_AM_I, "Receive WhoAmI"},
{DIGITECH_PROCEDURE_REQUEST_DEVICE_CONFIGURATION, "Request Device Configuration"},
{DIGITECH_PROCEDURE_RECEIVE_DEVICE_CONFIGURATION, "Receive Device Configuration"},
{DIGITECH_PROCEDURE_REQUEST_GLOBAL_PARAMETERS, "Request Global Parameters"},
{DIGITECH_PROCEDURE_RECEIVE_GLOBAL_PARAMETERS, "Receive Global Parameters"},
{DIGITECH_PROCEDURE_REQUEST_BULK_DUMP, "Request Bulk Dump"},
{DIGITECH_PROCEDURE_RECEIVE_BULK_DUMP_START, "Receive Bulk Dump Start"},
{DIGITECH_PROCEDURE_RECEIVE_BULK_DUMP_END, "Receive Bulk Dump End"},
{DIGITECH_PROCEDURE_RECEIVE_USER_PRESET_INDEX_TABLE, "Receive User Preset Index Table"},
{DIGITECH_PROCEDURE_REQUEST_PRESET_NAMES, "Request Preset Names"},
{DIGITECH_PROCEDURE_RECEIVE_PRESET_NAMES, "Receive Preset Names"},
{DIGITECH_PROCEDURE_REQUEST_PRESET_NAME, "Request Preset Name"},
{DIGITECH_PROCEDURE_RECEIVE_PRESET_NAME, "Receive Preset Name"},
{DIGITECH_PROCEDURE_REQUEST_PRESET, "Request Preset"},
{DIGITECH_PROCEDURE_RECEIVE_PRESET_START, "Receive Preset Start"},
{DIGITECH_PROCEDURE_RECEIVE_PRESET_END, "Receive Preset End"},
{DIGITECH_PROCEDURE_RECEIVE_PRESET_PARAMETERS, "Receive Preset Parameters"},
{DIGITECH_PROCEDURE_LOAD_EDIT_BUFFER_PRESET, "Load Edit Buffer Preset"},
{DIGITECH_PROCEDURE_MOVE_PRESET, "Move Preset"},
{DIGITECH_PROCEDURE_REQUEST_MODIFIER_LINKABLE_LIST, "Request Modifier-Linkable List"},
{DIGITECH_PROCEDURE_RECEIVE_MODIFIER_LINKABLE_LIST, "Receive Modifier-Linkable List"},
{DIGITECH_PROCEDURE_REQUEST_PARAMETER_VALUE, "Request Parameter Value"},
{DIGITECH_PROCEDURE_RECEIVE_PARAMETER_VALUE, "Receive Parameter Value"},
{DIGITECH_PROCEDURE_REQUEST_OBJECT_NAMES, "Request Object Names"},
{DIGITECH_PROCEDURE_RECEIVE_OBJECT_NAMES, "Receive Object Names"},
{DIGITECH_PROCEDURE_REQUEST_OBJECT_NAME, "Request Object Name"},
{DIGITECH_PROCEDURE_RECEIVE_OBJECT_NAME, "Receive Object Name"},
{DIGITECH_PROCEDURE_REQUEST_OBJECT, "Request Object"},
{DIGITECH_PROCEDURE_RECEIVE_OBJECT, "Receive Object"},
{DIGITECH_PROCEDURE_MOVE_OBJECT, "Move Object"},
{DIGITECH_PROCEDURE_DELETE_OBJECT, "Delete Object"},
{DIGITECH_PROCEDURE_REQUEST_TABLE, "Request Table"},
{DIGITECH_PROCEDURE_RECEIVE_TABLE, "Receive Table"},
{DIGITECH_PROCEDURE_RECEIVE_DEVICE_NOTIFICATION, "Receive Device Notification"},
{DIGITECH_PROCEDURE_START_OS_DOWNLOAD, "Start OS Download"},
{DIGITECH_PROCEDURE_RESTART_DEVICE, "Restart Device"},
{DIGITECH_PROCEDURE_REQUEST_DEBUG_DATA, "Request Debug Data"},
{DIGITECH_PROCEDURE_RECEIVE_DEBUG_DATA, "Receive Debug Data"},
{DIGITECH_PROCEDURE_ACK, "ACK"},
{DIGITECH_PROCEDURE_NACK, "NACK"},
{0, NULL}
};
static value_string_ext digitech_procedures_ext =
VALUE_STRING_EXT_INIT(digitech_procedures);
static const value_string digitech_os_modes[] = {
{0, "Normal"},
{1, "Flash update"},
{0, NULL}
};
static const value_string digitech_preset_banks[] = {
{0, "Factory (fixed) bank"},
{1, "User bank"},
{2, "Artist bank"},
{3, "Media card (CF or other)"},
{4, "Current preset edit buffer"},
{5, "Second factory bank"},
{6, "External preset"},
{0, NULL}
};
static const value_string digitech_parameter_ids_global[] = {
{12361, "Amp/Cab Bypass On/Off"},
{12298, "GUI Mode On/Off"},
{0, NULL}
};
static const value_string digitech_parameter_ids_pickup[] = {
{65, "Pickup On/Off"},
{0, NULL}
};
static const value_string digitech_parameter_ids_wah[] = {
{129, "Wah On/Off"},
{133, "Wah Level"},
{0, NULL}
};
static const value_string digitech_parameter_ids_compressor[] = {
{193, "Compressor On/Off"},
{194, "Compressor Attack"},
{195, "Compressor Ratio"},
{200, "Compressor Threshold"},
{201, "Compressor Gain"},
{208, "Compressor Sustain"},
{209, "Compressor Tone"},
{210, "Compressor Level"},
{211, "Compressor Attack"},
{212, "Compressor Output"},
{213, "Compressor Sensitivity"},
{0, NULL}
};
static const value_string digitech_parameter_ids_gnx3k_whammy[] = {
{769, "Whammy/IPS On/Off"},
{1667, "Whammy/IPS Detune Level"},
{1670, "Whammy/IPS Detune Shift Amount"},
{1731, "Whammy/IPS Pitch Shift Level"},
{1732, "Whammy/IPS Pitch Shift Shift Amount"},
{1795, "Whammy/IPS Whammy Pedal"},
{1796, "Whammy/IPS Whammy Mix"},
{1797, "Whammy/IPS Whammy Shift Amount"},
{2754, "Whammy/IPS IPS Shift Amount"},
{2755, "Whammy/IPS IPS Scale"},
{2756, "Whammy/IPS IPS Key"},
{2757, "Whammy/IPS IPS Level"},
{2818, "Whammy/IPS Talker Mic Level"},
{0, NULL}
};
static value_string_ext digitech_parameter_ids_gnx3k_whammy_ext =
VALUE_STRING_EXT_INIT(digitech_parameter_ids_gnx3k_whammy);
static const value_string digitech_parameter_ids_distortion[] = {
{2433, "Distortion On/Off"},
{2434, "Distortion Screamer Drive"},
{2435, "Distortion Screamer Tone"},
{2436, "Distortion Screamer Level"},
{2437, "Distortion Rodent Dist"},
{2438, "Distortion Rodent Filter"},
{2439, "Distortion Rodent Level"},
{2440, "Distortion DS Gain"},
{2441, "Distortion DS Tone"},
{2442, "Distortion DS Level"},
{2443, "Distortion DOD250 Gain"},
{2444, "Distortion DOD250 Level"},
{2445, "Distortion Big MP Sustain"},
{2446, "Distortion Big MP Tone"},
{2447, "Distortion Big MP Volume"},
{2448, "Distortion GuyOD Drive"},
{2449, "Distortion GuyOD Level"},
{2450, "Distortion Sparkdrive Gain"},
{2451, "Distortion Sparkdrive Tone"},
{2452, "Distortion Sparkdrive Clean"},
{2453, "Distortion Sparkdrive Volume"},
{2454, "Distortion Grunge Grunge"},
{2455, "Distortion Grunge Butt"},
{2456, "Distortion Grunge Face"},
{2457, "Distortion Grunge Loud"},
{2458, "Distortion Fuzzy Fuzz"},
{2459, "Distortion Fuzzy Volume"},
{2460, "Distortion Zone Gain"},
{2461, "Distortion Zone Mid freq"},
{2462, "Distortion Zone Mid level"},
{2463, "Distortion Zone Low"},
{2464, "Distortion Zone High"},
{2465, "Distortion Zone Level"},
{2466, "Distortion 8tavia Drive"},
{2467, "Distortion 8tavia Volume"},
{2468, "Distortion MX Dist"},
{2469, "Distortion MX Output"},
{2470, "Distortion Gonk Suck"},
{2471, "Distortion Gonk Smear"},
{2472, "Distortion Gonk Heave"},
{2473, "Distortion 808 Overdrive"},
{2474, "Distortion 808 Tone"},
{2475, "Distortion 808 Level"},
{2476, "Distortion Death Mid"},
{2477, "Distortion Death Low"},
{2478, "Distortion Death Level"},
{2479, "Distortion Death High"},
{2480, "Distortion Gonk Gonk"},
{2481, "Distortion Fuzzlator Fuzz"},
{2482, "Distortion Fuzzlator Tone"},
{2483, "Distortion Fuzzlator LooseTight"},
{2484, "Distortion Fuzzlator Volume"},
{2485, "Distortion Classic Fuzz Fuzz"},
{2486, "Distortion Classic Fuzz Tone"},
{2487, "Distortion Classic Fuzz Volume"},
{2488, "Distortion Redline Gain"},
{2489, "Distortion Redline Low"},
{2490, "Distortion Redline High"},
{2491, "Distortion Redline Level"},
{2492, "Distortion OC Drive Drive"},
{2493, "Distortion OC Drive HP/LP"},
{2494, "Distortion OC Drive Tone"},
{2495, "Distortion OC Drive Level"},
{2562, "Distortion TS Mod Drive"},
{2563, "Distortion TS Mod Level"},
{2564, "Distortion TS Mod Tone"},
{2565, "Distortion SD Overdrive Drive"},
{2566, "Distortion SD Overdrive Tone"},
{2567, "Distortion SD Overdrive Level"},
{2568, "Distortion OD Overdrive Overdrive"},
{2569, "Distortion OD Overdrive Level"},
{2570, "Distortion Amp Driver Gain"},
{2571, "Distortion Amp Driver Mid Boost"},
{2572, "Distortion Amp Driver Level"},
{0, NULL}
};
static value_string_ext digitech_parameter_ids_distortion_ext =
VALUE_STRING_EXT_INIT(digitech_parameter_ids_distortion);
static const value_string digitech_parameter_ids_amp_channel[] = {
{260, "Amp Channel Amp Channel"},
{261, "Amp Channel Warp"},
{262, "Amp Channel Amp Warp"},
{263, "Amp Channel Cabinet Warp"},
{0, NULL}
};
static const value_string digitech_parameter_ids_amp[] = {
{265, "Amplifier On/Off"},
{2497, "Amplifier Gain"},
{2498, "Amplifier Level"},
{2499, "Channel 1 Bass Freq"},
{2500, "Channel 1 Bass Level"},
{2501, "Channel 1 Mid Freq"},
{2502, "Channel 1 Mid Level"},
{2503, "Channel 1 Treb Freq"},
{2504, "Channel 1 Treb Level"},
{2505, "EQ Enable On/Off"},
{2506, "Channel 1 Presence"},
{2507, "Amplifier Bass"},
{2508, "Amplifier Mid"},
{2509, "Amplifier Treble"},
{0, NULL}
};
static value_string_ext digitech_parameter_ids_amp_ext =
VALUE_STRING_EXT_INIT(digitech_parameter_ids_amp);
static const value_string digitech_parameter_ids_amp_cabinet[] = {
{2561, "Channel 1 Tuning"},
{0, NULL}
};
static const value_string digitech_parameter_ids_amp_b[] = {
{265, "Amplifier B On/Off"},
{2497, "Amplifier B Gain"},
{2498, "Amplifier B Level"},
{2499, "Channel 2 Bass Freq"},
{2500, "Channel 2 Bass Level"},
{2501, "Channel 2 Mid Freq"},
{2502, "Channel 2 Mid Level"},
{2503, "Channel 2 Treb Freq"},
{2504, "Channel 2 Treb Level"},
{2505, "EQ Enable On/Off"},
{2506, "Channel 2 Presence"},
{0, NULL}
};
static const value_string digitech_parameter_ids_amp_cabinet_b[] = {
{2561, "Channel 2 Tuning"},
{0, NULL}
};
static const value_string digitech_parameter_ids_noisegate[] = {
{705, "Noisegate On/Off"},
{706, "Noisegate Attack"},
{710, "Noisegate Threshold"},
{711, "Noisegate Sens"},
{712, "Noisegate Attack"},
{713, "Noisegate Release"},
{714, "Noisegate Attn"},
{0, NULL}
};
static const value_string digitech_parameter_ids_volume_pre_fx[] = {
{2626, "Pickup Volume Pre FX"},
{0, NULL}
};
static const value_string digitech_parameter_ids_chorusfx[] = {
{769, "Chorus/FX On/Off"},
{836, "Chorus/FX Chorus Level"},
{837, "Chorus/FX Chorus Speed"},
{838, "Chorus/FX CE/Dual/Multi Chorus Depth"},
{839, "Chorus/FX Chorus Predelay"},
{840, "Chorus/FX Dual/Multi Chorus Wave"},
{841, "Chorus/FX Chorus Balance"},
{848, "Chorus/FX Chorus Width"},
{849, "Chorus/FX Chorus Intensity"},
{850, "Chorus/FX Small Clone Rate"},
{901, "Chorus/FX Flanger Level/Mix"},
{902, "Chorus/FX Flanger Speed"},
{903, "Chorus/FX Flanger Depth"},
{904, "Chorus/FX Flanger Regen"},
{905, "Chorus/FX Flanger Waveform"},
{906, "Chorus/FX Flanger Balance"},
{914, "Chorus/FX Flanger Width"},
{916, "Chorus/FX Flanger Color"},
{917, "Chorus/FX Flanger Manual"},
{918, "Chorus/FX Flanger Rate"},
{919, "Chorus/FX Flanger Range"},
{920, "Chorus/FX Flanger Enhance"},
{921, "Chorus/FX Flanger Harmonics"},
{922, "Chorus/FX Filter Flanger Frequency"},
{962, "Chorus/FX Phaser Speed"},
{963, "Chorus/FX Phaser Depth"},
{965, "Chorus/FX Phaser Level"},
{966, "Chorus/FX Phaser Regen"},
{967, "Chorus/FX Phaser Waveform"},
{968, "Chorus/FX Phaser Balance"},
{976, "Chorus/FX MX Phaser Intensity"},
{977, "Chorus/FX EH Phaser Color"},
{979, "Chorus/FX EH Phaser Rate"},
{1028, "Chorus/FX Triggered Flanger Lfo Start"},
{1029, "Chorus/FX Triggered Flanger/Phaser Mix"},
{1030, "Chorus/FX Triggered Flanger Speed"},
{1031, "Chorus/FX Triggered Flanger Sens"},
{1032, "Chorus/FX Triggered Flanger Level"},
{1092, "Chorus/FX Triggered Phaser Lfo Start"},
{1094, "Chorus/FX Triggered Phaser Speed"},
{1095, "Chorus/FX Triggered Phaser Sens"},
{1096, "Chorus/FX Triggered Phaser Level"},
{1155, "Chorus/FX Tremolo Depth"},
{1156, "Chorus/FX Tremolo Speed"},
{1157, "Chorus/FX Tremolo Wave"},
{1219, "Chorus/FX Panner Depth"},
{1220, "Chorus/FX Panner Speed"},
{1221, "Chorus/FX Panner Wave"},
{1284, "Chorus/FX Vibrato Speed"},
{1285, "Chorus/FX Vibrato Depth"},
{1286, "Chorus/FX Vibrato Waveform"},
{1314, "Chorus/FX Vibropan Speed"},
{1315, "Chorus/FX Vibropan Depth"},
{1316, "Chorus/FX Vibropan Vibra"},
{1317, "Chorus/FX Vibropan Wave"},
{1346, "Chorus/FX Rotary Speed"},
{1348, "Chorus/FX Rotary Intensity"},
{1349, "Chorus/FX Rotary Mix"},
{1350, "Chorus/FX Rotary Doppler"},
{1351, "Chorus/FX Rotary Crossover"},
{1352, "Chorus/FX Rotary Balance"},
{1410, "Chorus/FX YaYa Pedal"},
{1412, "Chorus/FX YaYa Range"},
{1413, "Chorus/FX YaYa Mix"},
{1414, "Chorus/FX YaYa Depth"},
{1416, "Chorus/FX YaYa Balance"},
{1417, "Chorus/FX YaYa Intensity"},
{1418, "Chorus/FX YaYa Range"},
{1476, "Chorus/FX AutoYa Range"},
{1477, "Chorus/FX AutoYa Mix"},
{1478, "Chorus/FX AutoYa Speed"},
{1479, "Chorus/FX AutoYa Depth"},
{1481, "Chorus/FX AutoYa Balance"},
{1482, "Chorus/FX AutoYa Intensity"},
{1483, "Chorus/FX AutoYa Range"},
{1540, "Chorus/FX Synthtalk Vox"},
{1542, "Chorus/FX Synthtalk Attack"},
{1543, "Chorus/FX Synthtalk Release"},
{1544, "Chorus/FX Synthtalk Sens"},
{1545, "Chorus/FX Synthtalk Balance"},
{1604, "Chorus/FX Envelope Mix"},
{1605, "Chorus/FX Envelope/FX25 Range"},
{1606, "Chorus/FX Envelope/FX25 Sensitivity"},
{1607, "Chorus/FX Envelope Balance"},
{1608, "Chorus/FX FX25 Blend"},
{1667, "Chorus/FX Detune Level"},
{1668, "Chorus/FX Detune Amount"},
{1669, "Chorus/FX Detune Balance"},
{1730, "Chorus/FX Pitch Shift Amount"},
{1731, "Chorus/FX Pitch Level"},
{1733, "Chorus/FX Pitch Balance"},
{1745, "Chorus/FX Pitch Shift Mix"},
{1746, "Chorus/FX Octaver Octave 1"},
{1747, "Chorus/FX Octaver Octave 2"},
{1748, "Chorus/FX Octaver Dry Level"},
{1795, "Chorus/FX Whammy Pedal"},
{1796, "Chorus/FX Whammy Mix"},
{1797, "Chorus/FX Whammy Amount"},
{2754, "Chorus/FX IPS/Harmony Pitch Shift"},
{2755, "Chorus/FX IPS/Harmony Pitch Scale"},
{2756, "Chorus/FX IPS/Harmony Pitch Key"},
{2757, "Chorus/FX IPS/Harmony Pitch Level"},
{2882, "Chorus/FX Unovibe Chorus/Vibrato"},
{2883, "Chorus/FX Unovibe Intensity"},
{2884, "Chorus/FX Unovibe Pedal Speed"},
{2885, "Chorus/FX Unovibe Volume"},
{3010, "Chorus/FX Step Filter Speed"},
{3011, "Chorus/FX Step Filter Intensity"},
{3012, "Chorus/FX Sample/Hold Speed"},
{3013, "Chorus/FX Sample/Hold Intensity"},
{0, NULL}
};
static value_string_ext digitech_parameter_ids_chorusfx_ext =
VALUE_STRING_EXT_INIT(digitech_parameter_ids_chorusfx);
static const value_string digitech_parameter_ids_delay[] = {
{1857, "Delay On/Off"},
{1860, "Delay Level"},
{1862, "Delay Time"},
{1863, "Delay Repeats"},
{1864, "Delay Thresh"},
{1865, "Delay Atten"},
{1866, "Delay Balance"},
{1867, "Delay Spread"},
{1868, "Delay Tap Time"},
{1873, "Delay Depth"},
{1874, "Delay Repeats"},
{1888, "Delay Time"},
{1889, "Delay Ducker thresh"},
{1890, "Delay Ducker level"},
{1891, "Delay Tape Wow"},
{1892, "Delay Tape Flutter"},
{1893, "Delay Echo Plex Volume"},
{1894, "Delay DM Repeat Rate"},
{1895, "Delay DM Echo"},
{1896, "Delay DM Intensity"},
{1897, "Delay Echo Plex Time"},
{1898, "Delay DM Delay Repeat Rate"},
{1899, "Delay Echo Plex Time"},
{1900, "Delay Tap Time"},
{1901, "Delay Reverse Time"},
{1902, "Delay Reverse Mix"},
{1905, "Delay 2-tap Ratio"},
{0, NULL}
};
static value_string_ext digitech_parameter_ids_delay_ext =
VALUE_STRING_EXT_INIT(digitech_parameter_ids_delay);
static const value_string digitech_parameter_ids_reverb[] = {
{1921, "Reverb On/Off"},
{1922, "Reverb Predelay"},
{1924, "Reverb Damping"},
{1925, "Reverb Level"},
{1927, "Reverb Decay"},
{1928, "Reverb Balance"},
{1933, "Reverb Liveliness"},
{0, NULL}
};
static const value_string digitech_parameter_ids_volume_post_fx[] = {
{2626, "Pickup Volume Post FX"},
{0, NULL}
};
static const value_string digitech_parameter_ids_preset[] = {
{2626, "Pickup Preset Level"},
{0, NULL}
};
static const value_string digitech_parameter_ids_wah_min_max[] = {
{8195, "Wah Min"},
{8196, "Wah Max"},
{0, NULL}
};
static const value_string digitech_parameter_ids_equalizer[] = {
{3203, "Equalizer Bass"},
{3204, "Equalizer Mid"},
{3205, "Equalizer Treble"},
{3206, "Equalizer Mid Hz"},
{3207, "Equalizer Presence"},
{3211, "Equalizer Treb Hz"},
{3212, "Equalizer On/Off"},
{3213, "Equalizer Low Freq"},
{3215, "Equalizer High Freq"},
{3216, "Equalizer Low Bandwidth"},
{3217, "Equalizer Mid Bandwidth"},
{3218, "Equalizer High Bandwidth"},
{0, NULL}
};
static const value_string digitech_parameter_ids_equalizer_b[] = {
{3203, "Equalizer B Bass"},
{3204, "Equalizer B Mid"},
{3205, "Equalizer B Treble"},
{3206, "Equalizer B Mid Hz"},
{3207, "Equalizer B Presence"},
{3211, "Equalizer B Treb Hz"},
{3212, "Equalizer B On/Off"},
{0, NULL}
};
static const value_string digitech_parameter_ids_amp_loop[] = {
{3649, "Amp Loop On/Off"},
{0, NULL}
};
#define DIGITECH_POSITION_GLOBAL 0
#define DIGITECH_POSITION_PICKUP 2
#define DIGITECH_POSITION_WAH 3
#define DIGITECH_POSITION_COMPRESSOR 4
#define DIGITECH_POSITION_GNX3K_WHAMMY 5
#define DIGITECH_POSITION_DISTORTION 6
#define DIGITECH_POSITION_AMP_CHANNEL 7
#define DIGITECH_POSITION_AMP 8
#define DIGITECH_POSITION_AMP_CABINET 9
#define DIGITECH_POSITION_AMP_B 10
#define DIGITECH_POSITION_AMP_CABINET_B 11
#define DIGITECH_POSITION_NOISEGATE 12
#define DIGITECH_POSITION_VOLUME_PRE_FX 13
#define DIGITECH_POSITION_CHORUS_FX 14
#define DIGITECH_POSITION_DELAY 15
#define DIGITECH_POSITION_REVERB 16
#define DIGITECH_POSITION_VOLUME_POST_FX 17
#define DIGITECH_POSITION_PRESET 18
#define DIGITECH_POSITION_EXPRESSION 19
#define DIGITECH_POSITION_WAH_MIN_MAX 20
#define DIGITECH_POSITION_V_SWITCH_ASSIGN 21
#define DIGITECH_POSITION_LFO_1 22
#define DIGITECH_POSITION_LFO_2 23
#define DIGITECH_POSITION_EQUALIZER 24
#define DIGITECH_POSITION_EQUALIZER_B 25
#define DIGITECH_POSITION_LIBRARY 26
#define DIGITECH_POSITION_AMP_LOOP 33
#define DIGITECH_POSITION_WAH_PEDAL 132
static const value_string digitech_parameter_positions[] = {
{DIGITECH_POSITION_GLOBAL, "Global"},
{DIGITECH_POSITION_PICKUP, "Pickup"},
{DIGITECH_POSITION_WAH, "Wah"},
{DIGITECH_POSITION_COMPRESSOR, "Compressor"},
{DIGITECH_POSITION_GNX3K_WHAMMY, "GNX3K Whammy"},
{DIGITECH_POSITION_DISTORTION, "Distortion"},
{DIGITECH_POSITION_AMP_CHANNEL, "Amp Channel"},
{DIGITECH_POSITION_AMP, "Amp"},
{DIGITECH_POSITION_AMP_CABINET, "Amp Cabinet"},
{DIGITECH_POSITION_AMP_B, "Amp B"},
{DIGITECH_POSITION_AMP_CABINET_B, "Amp Cabinet B"},
{DIGITECH_POSITION_NOISEGATE, "Noisegate"},
{DIGITECH_POSITION_VOLUME_PRE_FX, "Volume Pre Fx"},
{DIGITECH_POSITION_CHORUS_FX, "Chorus/FX"},
{DIGITECH_POSITION_DELAY, "Delay"},
{DIGITECH_POSITION_REVERB, "Reverb"},
{DIGITECH_POSITION_VOLUME_POST_FX, "Volume Post Fx"},
{DIGITECH_POSITION_PRESET, "Preset"},
{DIGITECH_POSITION_EXPRESSION, "Expression"},
{DIGITECH_POSITION_WAH_MIN_MAX, "Wah Min-Max"},
{DIGITECH_POSITION_V_SWITCH_ASSIGN, "V-Switch Assign"},
{DIGITECH_POSITION_LFO_1, "LFO 1"},
{DIGITECH_POSITION_LFO_2, "LFO 2"},
{DIGITECH_POSITION_EQUALIZER, "Equalizer"},
{DIGITECH_POSITION_EQUALIZER_B, "Equalizer B"},
{DIGITECH_POSITION_LIBRARY, "Library"},
{DIGITECH_POSITION_AMP_LOOP, "Amp Loop"},
{DIGITECH_POSITION_WAH_PEDAL, "Wah Pedal"},
{0, NULL}
};
static value_string_ext digitech_parameter_positions_ext =
VALUE_STRING_EXT_INIT(digitech_parameter_positions);
static tvbuff_t *
unpack_digitech_message(packet_info *pinfo, tvbuff_t *tvb, gint offset)
{
tvbuff_t *next_tvb;
gint length = tvb_reported_length(tvb);
gint data_len = length - offset - 1;
const guint8* data_ptr;
gint remaining = data_len;
guchar* unpacked;
guchar* unpacked_ptr;
gint unpacked_size;
guint8 msb;
gint i;
unpacked_size = data_len - (data_len / 8);
if (data_len % 8)
{
unpacked_size--;
}
data_ptr = tvb_get_ptr(tvb, offset, data_len);
unpacked = (guchar*)wmem_alloc(pinfo->pool, unpacked_size);
unpacked_ptr = unpacked;
while (remaining > 0)
{
msb = *data_ptr++;
remaining--;
for (i = 0; (i < 7) && (remaining > 0); ++i, --remaining)
{
*unpacked_ptr = *data_ptr | ((msb << (i + 1)) & 0x80);
unpacked_ptr++;
data_ptr++;
}
}
/* Create new tvb with unpacked data */
next_tvb = tvb_new_child_real_data(tvb, unpacked, unpacked_size, unpacked_size);
return next_tvb;
}
static int
get_digitech_hf_parameter_id_by_position(guint8 position)
{
int hf_parameter = hf_digitech_parameter_id;
switch (position)
{
case DIGITECH_POSITION_GLOBAL:
hf_parameter = hf_digitech_parameter_id_global;
break;
case DIGITECH_POSITION_PICKUP:
hf_parameter = hf_digitech_parameter_id_pickup;
break;
case DIGITECH_POSITION_WAH:
hf_parameter = hf_digitech_parameter_id_wah;
break;
case DIGITECH_POSITION_COMPRESSOR:
hf_parameter = hf_digitech_parameter_id_compressor;
break;
case DIGITECH_POSITION_GNX3K_WHAMMY:
hf_parameter = hf_digitech_parameter_id_gnx3k_whammy;
break;
case DIGITECH_POSITION_DISTORTION:
hf_parameter = hf_digitech_parameter_id_distortion;
break;
case DIGITECH_POSITION_AMP_CHANNEL:
hf_parameter = hf_digitech_parameter_id_amp_channel;
break;
case DIGITECH_POSITION_AMP:
hf_parameter = hf_digitech_parameter_id_amp;
break;
case DIGITECH_POSITION_AMP_CABINET:
hf_parameter = hf_digitech_parameter_id_amp_cabinet;
break;
case DIGITECH_POSITION_AMP_B:
hf_parameter = hf_digitech_parameter_id_amp_b;
break;
case DIGITECH_POSITION_AMP_CABINET_B:
hf_parameter = hf_digitech_parameter_id_amp_cabinet_b;
break;
case DIGITECH_POSITION_NOISEGATE:
hf_parameter = hf_digitech_parameter_id_noisegate;
break;
case DIGITECH_POSITION_VOLUME_PRE_FX:
hf_parameter = hf_digitech_parameter_id_volume_pre_fx;
break;
case DIGITECH_POSITION_CHORUS_FX:
hf_parameter = hf_digitech_parameter_id_chorusfx;
break;
case DIGITECH_POSITION_DELAY:
hf_parameter = hf_digitech_parameter_id_delay;
break;
case DIGITECH_POSITION_REVERB:
hf_parameter = hf_digitech_parameter_id_reverb;
break;
case DIGITECH_POSITION_VOLUME_POST_FX:
hf_parameter = hf_digitech_parameter_id_volume_post_fx;
break;
case DIGITECH_POSITION_PRESET:
hf_parameter = hf_digitech_parameter_id_preset;
break;
case DIGITECH_POSITION_WAH_MIN_MAX:
hf_parameter = hf_digitech_parameter_id_wah_min_max;
break;
case DIGITECH_POSITION_EQUALIZER:
hf_parameter = hf_digitech_parameter_id_equalizer;
break;
case DIGITECH_POSITION_EQUALIZER_B:
hf_parameter = hf_digitech_parameter_id_equalizer_b;
break;
case DIGITECH_POSITION_AMP_LOOP:
hf_parameter = hf_digitech_parameter_id_amp_loop;
break;
case DIGITECH_POSITION_EXPRESSION:
case DIGITECH_POSITION_V_SWITCH_ASSIGN:
case DIGITECH_POSITION_LFO_1:
case DIGITECH_POSITION_LFO_2:
case DIGITECH_POSITION_LIBRARY:
case DIGITECH_POSITION_WAH_PEDAL:
/* TODO */
default:
break;
}
return hf_parameter;
}
/* Dissects DigiTech parameter starting at data_offset.
* Returns new data_offset.
*/
static gint
dissect_digitech_parameter(tvbuff_t *data_tvb, proto_tree *tree,
digitech_conv_data_t *conv_data, gint data_offset)
{
guint8 digitech_helper;
int hf_parameter = hf_digitech_parameter_id;
/* Version 1 and later specify parameter position */
if (conv_data->protocol_version >= 1)
{
digitech_helper = tvb_get_guint8(data_tvb, data_offset+2);
hf_parameter = get_digitech_hf_parameter_id_by_position(digitech_helper);
}
proto_tree_add_item(tree, hf_parameter, data_tvb, data_offset, 2, ENC_BIG_ENDIAN);
data_offset += 2;
/* Add (optional) position to tree */
if (conv_data->protocol_version >= 1)
{
proto_tree_add_item(tree, hf_digitech_parameter_position, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
}
digitech_helper = tvb_get_guint8(data_tvb, data_offset);
/* Values 0-127 fit in one byte */
if (digitech_helper < 0x80)
{
proto_tree_add_item(tree, hf_digitech_parameter_data, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
}
else /* digitech_helper >= 0x80 */
{
guint16 data_count;
/* Single byte data count */
if (digitech_helper > 0x80)
{
data_count = (guint16)(digitech_helper & ~0x80);
proto_tree_add_uint(tree, hf_digitech_parameter_data_count, data_tvb,
data_offset, 1, (guint32)data_count);
data_offset++;
}
/* Two-byte data count */
else /* digitech_helper == 0x80 */
{
data_count = (guint16)tvb_get_ntohs(data_tvb, data_offset+1);
proto_tree_add_uint(tree, hf_digitech_parameter_data_two_byte_count, data_tvb,
data_offset, 3, (guint32)data_count);
data_offset += 3;
}
proto_tree_add_item(tree, hf_digitech_parameter_multibyte_data, data_tvb,
data_offset, (gint)data_count, ENC_NA);
data_offset += data_count;
}
return data_offset;
}
static int
get_digitech_hf_product_by_family(guint8 family)
{
int hf_product = hf_digitech_unknown_product_id;
switch (family)
{
case DIGITECH_FAMILY_RP:
hf_product = hf_digitech_rp_product_id;
break;
default:
break;
}
return hf_product;
}
static void
dissect_digitech_procedure(guint8 procedure, const gint offset,
tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
tvbuff_t *data_tvb;
gint data_offset;
gint data_len;
guint8 *tmp_string;
guint str_size;
guint16 count;
guint8 digitech_helper;
conversation_t *conversation;
digitech_conv_data_t *conv_data;
conversation = find_or_create_conversation(pinfo);
conv_data = (digitech_conv_data_t *)conversation_get_proto_data(conversation, proto_sysex_digitech);
if (conv_data == NULL)
{
conv_data = wmem_new(wmem_file_scope(), digitech_conv_data_t);
conv_data->protocol_version = 1; /* Default to version 1 */
}
/* Procedure data starts at offset and ends one byte before end
* of System Exclusive manufacturer payload (last byte is checksum)
*/
if (tvb_reported_length(tvb) - offset < 1)
{
/* There is no DigiTech procedure data, do not attempt further
* dissection */
return;
}
data_tvb = unpack_digitech_message(pinfo, tvb, offset);
add_new_data_source(pinfo, data_tvb, "Unpacked Procedure Data");
data_offset = 0;
data_len = tvb_reported_length(data_tvb);
switch (procedure)
{
case DIGITECH_PROCEDURE_REQUEST_WHO_AM_I:
proto_tree_add_item(tree, hf_digitech_desired_device_id, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
proto_tree_add_item(tree, hf_digitech_desired_family_id, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
proto_tree_add_item(tree, hf_digitech_desired_product_id, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
break;
case DIGITECH_PROCEDURE_RECEIVE_WHO_AM_I:
proto_tree_add_item(tree, hf_digitech_received_device_id, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
digitech_helper = tvb_get_guint8(data_tvb, data_offset);
proto_tree_add_item(tree, hf_digitech_family_id, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
proto_tree_add_item(tree, get_digitech_hf_product_by_family(digitech_helper),
data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
if (data_len == 3)
{
/* Version 0, everything already decoded */
conv_data->protocol_version = 0;
}
else if (data_len == 4)
{
/* Version 1 and later */
conv_data->protocol_version = 1;
proto_tree_add_item(tree, hf_digitech_os_mode, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
}
break;
case DIGITECH_PROCEDURE_REQUEST_PRESET_NAMES:
proto_tree_add_item(tree, hf_digitech_preset_bank, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
break;
case DIGITECH_PROCEDURE_RECEIVE_PRESET_NAMES:
proto_tree_add_item(tree, hf_digitech_preset_bank, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
count = (guint16)tvb_get_guint8(data_tvb, data_offset);
proto_tree_add_item(tree, hf_digitech_preset_count, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
while ((count > 0) && (str_size = tvb_strsize(data_tvb, data_offset)))
{
tmp_string = tvb_get_string_enc(pinfo->pool, data_tvb, data_offset, str_size - 1, ENC_ASCII);
proto_tree_add_string(tree, hf_digitech_preset_name, data_tvb, data_offset, str_size, tmp_string);
data_offset += (gint)str_size;
count--;
}
break;
case DIGITECH_PROCEDURE_REQUEST_PRESET:
proto_tree_add_item(tree, hf_digitech_preset_bank, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
proto_tree_add_item(tree, hf_digitech_preset_index, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
break;
case DIGITECH_PROCEDURE_RECEIVE_PRESET_START:
/* Preset bank */
proto_tree_add_item(tree, hf_digitech_preset_bank, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
/* Preset index */
proto_tree_add_item(tree, hf_digitech_preset_index, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
/* Preset name (NULL-terminated) */
str_size = tvb_strsize(data_tvb, data_offset);
tmp_string = tvb_get_string_enc(pinfo->pool, data_tvb, data_offset, str_size - 1, ENC_ASCII);
proto_tree_add_string(tree, hf_digitech_preset_name, data_tvb, data_offset, str_size, tmp_string);
data_offset += (gint)str_size;
/* Preset modified (0 = unmodified, !0 = modified) */
proto_tree_add_item(tree, hf_digitech_preset_modified, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
/* Message Count */
proto_tree_add_item(tree, hf_digitech_message_count, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
break;
case DIGITECH_PROCEDURE_RECEIVE_PRESET_PARAMETERS:
count = tvb_get_ntohs(data_tvb, data_offset);
proto_tree_add_item(tree, hf_digitech_parameter_count, data_tvb, data_offset, 2, ENC_BIG_ENDIAN);
data_offset += 2;
while (count > 0)
{
data_offset = dissect_digitech_parameter(data_tvb, tree, conv_data, data_offset);
count--;
}
break;
case DIGITECH_PROCEDURE_RECEIVE_PARAMETER_VALUE:
data_offset = dissect_digitech_parameter(data_tvb, tree, conv_data, data_offset);
break;
case DIGITECH_PROCEDURE_ACK:
proto_tree_add_item(tree, hf_digitech_ack_request_proc_id, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
break;
case DIGITECH_PROCEDURE_NACK:
proto_tree_add_item(tree, hf_digitech_nack_request_proc_id, data_tvb, data_offset, 1, ENC_BIG_ENDIAN);
data_offset++;
break;
default:
break;
}
if (data_offset < data_len)
{
proto_tree_add_expert(tree, pinfo, &ei_digitech_undecoded,
data_tvb, data_offset, data_len - data_offset);
}
}
static int
dissect_sysex_digitech_command(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_)
{
gint offset = 0;
guint8 procedure_id;
guint8 digitech_helper;
proto_item *ti = NULL;
proto_tree *tree = NULL;
const guint8 *data_ptr;
int len;
int i;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "X MIDI");
col_set_str(pinfo->cinfo, COL_INFO, "DigiTech X MIDI SysEx");
ti = proto_tree_add_protocol_format(parent_tree, proto_sysex_digitech, tvb, 0, -1, "DigiTech X MIDI SysEx");
tree = proto_item_add_subtree(ti, ett_sysex_digitech);
proto_tree_add_item(tree, hf_digitech_device_id, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
digitech_helper = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_digitech_family_id, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(tree, get_digitech_hf_product_by_family(digitech_helper),
tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
procedure_id = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_digitech_procedure_id, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
dissect_digitech_procedure(procedure_id, offset, tvb, pinfo, tree);
len = tvb_reported_length(tvb) - 1;
offset = len; /* Last byte is checksum */
data_ptr = tvb_get_ptr(tvb, 0, len);
/* Calculate checksum. Start with 0x10 as that's the XOR of DOD Electronics Corp.
* The Extended Manufacturer ID is part of checksum but is not part of payload tvb.
*/
for (i = 0, digitech_helper = 0x10; i < len; ++i)
{
digitech_helper ^= *data_ptr++;
}
proto_tree_add_checksum(tree, tvb, offset, hf_digitech_checksum, hf_digitech_checksum_status, &ei_digitech_checksum_bad, pinfo, digitech_helper,
ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
offset++;
return offset;
}
void
proto_register_sysex_digitech(void)
{
static hf_register_info hf[] = {
/* DigiTech manufacturer-specific fields */
{ &hf_digitech_device_id,
{ "Device ID", "sysex_digitech.device_id", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_digitech_family_id,
{ "Family ID", "sysex_digitech.family_id", FT_UINT8, BASE_HEX,
VALS(digitech_family_id), 0, NULL, HFILL }},
{ &hf_digitech_unknown_product_id,
{ "Product ID", "sysex_digitech.product_id", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_digitech_rp_product_id,
{ "Product ID", "sysex_digitech.product_id", FT_UINT8, BASE_HEX,
VALS(digitech_rp_product_id), 0, NULL, HFILL }},
{ &hf_digitech_procedure_id,
{ "Procedure ID", "sysex_digitech.procedure_id", FT_UINT8, BASE_HEX | BASE_EXT_STRING,
&digitech_procedures_ext, 0, NULL, HFILL }},
{ &hf_digitech_desired_device_id,
{ "Desired Device ID", "sysex_digitech.desired_device_id", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_digitech_desired_family_id,
{ "Desired Family ID", "sysex_digitech.desired_family_id", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_digitech_desired_product_id,
{ "Desired Product ID", "sysex_digitech.desired_product_id", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_digitech_received_device_id,
{ "Device ID", "sysex_digitech.received_device_id", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_digitech_os_mode,
{ "OS Mode", "sysex_digitech.os_mode", FT_UINT8, BASE_HEX,
VALS(digitech_os_modes), 0, "DigiTech OS Mode", HFILL }},
{ &hf_digitech_preset_bank,
{ "Preset Bank", "sysex_digitech.preset_bank", FT_UINT8, BASE_HEX,
VALS(digitech_preset_banks), 0, NULL, HFILL }},
{ &hf_digitech_preset_index,
{ "Preset Index", "sysex_digitech.preset_index", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_digitech_preset_count,
{ "Preset Count", "sysex_digitech.preset_count", FT_UINT8, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_digitech_preset_name,
{ "Preset Name", "sysex_digitech.preset_name", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_digitech_preset_modified,
{ "Preset Modified", "sysex_digitech.preset_modified", FT_BOOLEAN, BASE_NONE,
TFS(&tfs_yes_no), 0, "Modified flag (0 = unmodified)", HFILL }},
{ &hf_digitech_message_count,
{ "Messages to follow", "sysex_digitech.message_count", FT_UINT8, BASE_DEC,
NULL, 0, "Number of messages to follow", HFILL }},
{ &hf_digitech_parameter_count,
{ "Parameter Count", "sysex_digitech.parameter_count", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_digitech_parameter_id,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_global,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_global), 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_pickup,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_pickup), 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_wah,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_wah), 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_compressor,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_compressor), 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_gnx3k_whammy,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC | BASE_EXT_STRING,
&digitech_parameter_ids_gnx3k_whammy_ext, 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_distortion,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC | BASE_EXT_STRING,
&digitech_parameter_ids_distortion_ext, 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_amp_channel,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_amp_channel), 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_amp,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC | BASE_EXT_STRING,
&digitech_parameter_ids_amp_ext, 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_amp_cabinet,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_amp_cabinet), 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_amp_b,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_amp_b), 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_amp_cabinet_b,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_amp_cabinet_b), 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_noisegate,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_noisegate), 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_volume_pre_fx,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_volume_pre_fx), 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_chorusfx,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC | BASE_EXT_STRING,
&digitech_parameter_ids_chorusfx_ext, 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_delay,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC | BASE_EXT_STRING,
&digitech_parameter_ids_delay_ext, 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_reverb,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_reverb), 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_volume_post_fx,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_volume_post_fx), 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_preset,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_preset), 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_wah_min_max,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_wah_min_max), 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_equalizer,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_equalizer), 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_equalizer_b,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_equalizer_b), 0, NULL, HFILL }},
{ &hf_digitech_parameter_id_amp_loop,
{ "Parameter ID", "sysex_digitech.parameter_id", FT_UINT16, BASE_DEC,
VALS(digitech_parameter_ids_amp_loop), 0, NULL, HFILL }},
{ &hf_digitech_parameter_position,
{ "Parameter position", "sysex_digitech.parameter_position", FT_UINT8, BASE_DEC | BASE_EXT_STRING,
&digitech_parameter_positions_ext, 0, NULL, HFILL }},
{ &hf_digitech_parameter_data,
{ "Parameter data", "sysex_digitech.parameter_data", FT_UINT8, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_digitech_parameter_data_count,
{ "Parameter value count", "sysex_digitech.parameter_value_count", FT_UINT8, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_digitech_parameter_data_two_byte_count,
{ "Parameter data count", "sysex_digitech.parameter_data_count", FT_UINT24, BASE_DEC,
NULL, 0, NULL, HFILL }},
{ &hf_digitech_parameter_multibyte_data,
{ "Parameter data", "sysex_digitech.parameter_multibyte_data", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
{ &hf_digitech_ack_request_proc_id,
{ "Requesting Procedure ID", "sysex_digitech.ack.procedure_id", FT_UINT8, BASE_HEX | BASE_EXT_STRING,
&digitech_procedures_ext, 0, "Procedure ID of the request being ACKed", HFILL }},
{ &hf_digitech_nack_request_proc_id,
{ "Requesting Procedure ID", "sysex_digitech.ack.procedure_id", FT_UINT8, BASE_HEX | BASE_EXT_STRING,
&digitech_procedures_ext, 0, "Procedure ID of the request being NACKed", HFILL }},
{ &hf_digitech_checksum,
{ "Checksum", "sysex_digitech.checksum", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL }},
{ &hf_digitech_checksum_status,
{ "Checksum Status", "sysex_digitech.checksum.status", FT_UINT8, BASE_NONE,
VALS(proto_checksum_vals), 0, NULL, HFILL }},
};
static gint *sysex_digitech_subtrees[] = {
&ett_sysex_digitech
};
static ei_register_info ei[] = {
{ &ei_digitech_checksum_bad, { "sysex_digitech.checksum_bad", PI_CHECKSUM, PI_WARN, "Bad checksum", EXPFILL }},
{ &ei_digitech_undecoded, { "sysex_digitech.undecoded", PI_UNDECODED, PI_WARN, "Not dissected yet (report to wireshark.org)", EXPFILL }},
};
expert_module_t* expert_sysex_digitech;
proto_sysex_digitech = proto_register_protocol("MIDI System Exclusive DigiTech", "SYSEX DigiTech", "sysex_digitech");
proto_register_field_array(proto_sysex_digitech, hf, array_length(hf));
proto_register_subtree_array(sysex_digitech_subtrees, array_length(sysex_digitech_subtrees));
expert_sysex_digitech = expert_register_protocol(proto_sysex_digitech);
expert_register_field_array(expert_sysex_digitech, ei, array_length(ei));
register_dissector("sysex_digitech", dissect_sysex_digitech_command, proto_sysex_digitech);
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
|
C
|
wireshark/epan/dissectors/packet-syslog.c
|
/* packet-syslog.c
* Routines for syslog message dissection
*
* Copyright 2000, Gerald Combs <gerald[AT]wireshark.org>
*
* Support for passing SS7 MSUs (from the Cisco ITP Packet Logging
* facility) to the MTP3 dissector by Abhik Sarkar <sarkar.abhik[AT]gmail.com>
* with some rework by Jeff Morriss <jeff.morriss.ws [AT] gmail.com>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald[AT]wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/strutil.h>
#include "packet-syslog.h"
#include "packet-acdr.h"
#define UDP_PORT_SYSLOG 514
#define PRIORITY_MASK 0x0007 /* 0000 0111 */
#define FACILITY_MASK 0x03f8 /* 1111 1000 */
void proto_reg_handoff_syslog(void);
void proto_register_syslog(void);
/* The maximum number if priority digits to read in. */
#define MAX_DIGITS 3
static const value_string short_level_vals[] = {
{ LEVEL_EMERG, "EMERG" },
{ LEVEL_ALERT, "ALERT" },
{ LEVEL_CRIT, "CRIT" },
{ LEVEL_ERR, "ERR" },
{ LEVEL_WARNING, "WARNING" },
{ LEVEL_NOTICE, "NOTICE" },
{ LEVEL_INFO, "INFO" },
{ LEVEL_DEBUG, "DEBUG" },
{ 0, NULL }
};
static const value_string short_facility_vals[] = {
{ FAC_KERN, "KERN" },
{ FAC_USER, "USER" },
{ FAC_MAIL, "MAIL" },
{ FAC_DAEMON, "DAEMON" },
{ FAC_AUTH, "AUTH" },
{ FAC_SYSLOG, "SYSLOG" },
{ FAC_LPR, "LPR" },
{ FAC_NEWS, "NEWS" },
{ FAC_UUCP, "UUCP" },
{ FAC_CRON, "CRON" }, /* The BSDs, Linux, and others */
{ FAC_AUTHPRIV, "AUTHPRIV" },
{ FAC_FTP, "FTP" },
{ FAC_NTP, "NTP" },
{ FAC_LOGAUDIT, "LOGAUDIT" },
{ FAC_LOGALERT, "LOGALERT" },
{ FAC_CRON_SOL, "CRON" }, /* Solaris */
{ FAC_LOCAL0, "LOCAL0" },
{ FAC_LOCAL1, "LOCAL1" },
{ FAC_LOCAL2, "LOCAL2" },
{ FAC_LOCAL3, "LOCAL3" },
{ FAC_LOCAL4, "LOCAL4" },
{ FAC_LOCAL5, "LOCAL5" },
{ FAC_LOCAL6, "LOCAL6" },
{ FAC_LOCAL7, "LOCAL7" },
{ 0, NULL }
};
static gint proto_syslog = -1;
static gint hf_syslog_level = -1;
static gint hf_syslog_facility = -1;
static gint hf_syslog_msg = -1;
static gint hf_syslog_msu_present = -1;
static gint hf_syslog_version = -1;
static gint hf_syslog_timestamp = -1;
static gint hf_syslog_timestamp_old = -1;
static gint hf_syslog_hostname = -1;
static gint hf_syslog_appname = -1;
static gint hf_syslog_procid = -1;
static gint hf_syslog_msgid = -1;
static gint hf_syslog_msgid_utf8 = -1;
static gint hf_syslog_msgid_bom = -1;
static gint ett_syslog = -1;
static gint ett_syslog_msg = -1;
static dissector_handle_t syslog_handle;
static dissector_handle_t mtp_handle;
/* The Cisco ITP's packet logging facility allows selected (SS7) MSUs to be
* to be encapsulated in syslog UDP datagrams and sent to a monitoring tool.
* However, no actual tool to monitor/decode the MSUs is provided. The aim
* of this routine is to extract the hex dump of the MSU from the syslog
* packet so that it can be passed on to the mtp3 dissector for decoding.
*/
static tvbuff_t *
mtp3_msu_present(tvbuff_t *tvb, packet_info *pinfo, gint fac, gint level, const char *msg_str, gint chars_truncated)
{
size_t nbytes;
size_t len;
gchar **split_string, *msu_hex_dump;
tvbuff_t *mtp3_tvb = NULL;
guint8 *byte_array;
/* In the sample capture I have, all MSUs are LOCAL0.DEBUG.
* Try to optimize this routine for most syslog users by short-cutting
* out here.
*/
if (!(fac == FAC_LOCAL0 && level == LEVEL_DEBUG))
return NULL;
if (strstr(msg_str, "msu=") == NULL)
return NULL;
split_string = g_strsplit(msg_str, "msu=", 2);
msu_hex_dump = split_string[1];
if (msu_hex_dump && (len = strlen(msu_hex_dump))) {
/* convert_string_to_hex() will return NULL if it gets an incomplete
* byte. If we have an odd string length then chop off the remaining
* nibble so we can get at least a partial MSU (chances are the
* subdissector will except out, of course).
*/
if (len % 2)
msu_hex_dump[len - 1] = '\0';
byte_array = convert_string_to_hex(msu_hex_dump, &nbytes);
if (byte_array) {
mtp3_tvb = tvb_new_child_real_data(tvb, byte_array, (guint)nbytes,
(guint)nbytes + chars_truncated / 2);
tvb_set_free_cb(mtp3_tvb, g_free);
/* ...and add the encapsulated MSU as a new data source so that it gets
* its own tab in the packet bytes pane.
*/
add_new_data_source(pinfo, mtp3_tvb, "Encapsulated MSU");
}
}
g_strfreev(split_string);
return(mtp3_tvb);
}
static gboolean dissect_syslog_info(proto_tree* tree, tvbuff_t* tvb, guint* offset, gint hfindex)
{
gint end_offset = tvb_find_guint8(tvb, *offset, -1, ' ');
if (end_offset == -1)
return FALSE;
proto_tree_add_item(tree, hfindex, tvb, *offset, end_offset - *offset, ENC_NA);
*offset = end_offset + 1;
return TRUE;
}
/* Dissect message as defined in RFC5424 */
static void
dissect_syslog_message(proto_tree* tree, tvbuff_t* tvb, guint offset)
{
gint end_offset;
if (!dissect_syslog_info(tree, tvb, &offset, hf_syslog_version))
return;
end_offset = tvb_find_guint8(tvb, offset, -1, ' ');
if (end_offset == -1)
return;
if ((guint)end_offset != offset) {
/* do not call proto_tree_add_time_item with a length of 0 */
proto_tree_add_time_item(tree, hf_syslog_timestamp, tvb, offset, end_offset - offset, ENC_ISO_8601_DATE_TIME,
NULL, NULL, NULL);
}
offset = end_offset + 1;
if (!dissect_syslog_info(tree, tvb, &offset, hf_syslog_hostname))
return;
if (!dissect_syslog_info(tree, tvb, &offset, hf_syslog_appname))
return;
if (!dissect_syslog_info(tree, tvb, &offset, hf_syslog_procid))
return;
if (tvb_get_guint24(tvb, offset, ENC_BIG_ENDIAN) == 0xefbbbf) {
proto_tree_add_item(tree, hf_syslog_msgid_bom, tvb, offset, 3, ENC_BIG_ENDIAN);
offset += 3;
proto_tree_add_item(tree, hf_syslog_msgid_utf8, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_UTF_8);
} else {
proto_tree_add_item(tree, hf_syslog_msgid, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_ASCII);
}
}
/* Dissect message as defined in RFC3164 */
static void
dissect_rfc3164_syslog_message(proto_tree* tree, tvbuff_t* tvb, guint offset)
{
guint tvb_offset = 0;
/* Simple check if the first 16 bytes look like TIMESTAMP "Mmm dd hh:mm:ss"
* by checking for spaces and colons. Otherwise return without processing
* the message. */
if (tvb_get_guint8(tvb, offset + 3) == ' ' && tvb_get_guint8(tvb, offset + 6) == ' ' &&
tvb_get_guint8(tvb, offset + 9) == ':' && tvb_get_guint8(tvb, offset + 12) == ':' &&
tvb_get_guint8(tvb, offset + 15) == ' ') {
proto_tree_add_item(tree, hf_syslog_timestamp_old, tvb, offset, 15, ENC_ASCII);
offset += 16;
} else {
return;
}
if (!dissect_syslog_info(tree, tvb, &offset, hf_syslog_hostname))
return;
for (tvb_offset=offset; tvb_offset < offset+32; tvb_offset++){
guint8 octet;
octet = tvb_get_guint8(tvb, tvb_offset);
if (!g_ascii_isalnum(octet)){
proto_tree_add_item(tree, hf_syslog_procid, tvb, offset, tvb_offset - offset, ENC_ASCII);
offset = tvb_offset;
break;
}
}
proto_tree_add_item(tree, hf_syslog_msgid, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_ASCII);
}
/* The message format is defined in RFC 3164 */
static int
dissect_syslog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
gint pri = -1, lev = -1, fac = -1;
gint msg_off = 0, msg_len, reported_msg_len;
proto_item *ti;
proto_tree *syslog_tree;
proto_tree *syslog_message_tree;
const char *msg_str;
tvbuff_t *mtp3_tvb;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Syslog");
col_clear(pinfo->cinfo, COL_INFO);
if (tvb_get_guint8(tvb, msg_off) == '<') {
/* A facility and level follow. */
msg_off++;
pri = 0;
while (tvb_bytes_exist(tvb, msg_off, 1) &&
g_ascii_isdigit(tvb_get_guint8(tvb, msg_off)) && msg_off <= MAX_DIGITS) {
pri = pri * 10 + (tvb_get_guint8(tvb, msg_off) - '0');
msg_off++;
}
if (tvb_get_guint8(tvb, msg_off) == '>')
msg_off++;
fac = (pri & FACILITY_MASK) >> 3;
lev = pri & PRIORITY_MASK;
}
msg_len = tvb_ensure_captured_length_remaining(tvb, msg_off);
msg_str = tvb_format_text(pinfo->pool, tvb, msg_off, msg_len);
reported_msg_len = tvb_reported_length_remaining(tvb, msg_off);
mtp3_tvb = mtp3_msu_present(tvb, pinfo, fac, lev, msg_str,
(reported_msg_len - msg_len));
if (mtp3_tvb == NULL) {
if (pri >= 0) {
col_add_fstr(pinfo->cinfo, COL_INFO, "%s.%s: %s",
val_to_str_const(fac, short_facility_vals, "UNKNOWN"),
val_to_str_const(lev, short_level_vals, "UNKNOWN"), msg_str);
} else {
col_add_str(pinfo->cinfo, COL_INFO, msg_str);
}
}
if (tree) {
if (pri >= 0) {
ti = proto_tree_add_protocol_format(tree, proto_syslog, tvb, 0, -1,
"Syslog message: %s.%s: %s",
val_to_str_const(fac, short_facility_vals, "UNKNOWN"),
val_to_str_const(lev, short_level_vals, "UNKNOWN"), msg_str);
} else {
ti = proto_tree_add_protocol_format(tree, proto_syslog, tvb, 0, -1,
"Syslog message: (unknown): %s", msg_str);
}
syslog_tree = proto_item_add_subtree(ti, ett_syslog);
if (pri >= 0) {
proto_tree_add_uint(syslog_tree, hf_syslog_facility, tvb, 0,
msg_off, pri);
proto_tree_add_uint(syslog_tree, hf_syslog_level, tvb, 0,
msg_off, pri);
}
ti = proto_tree_add_item(syslog_tree, hf_syslog_msg, tvb, msg_off,
msg_len, ENC_UTF_8);
syslog_message_tree = proto_item_add_subtree(ti, ett_syslog_msg);
/* RFC5424 defines a version field which is currently defined as '1'
* followed by a space (0x3120). Otherwise the message is probable
* a RFC3164 message.
*/
if (msg_len > 2 && tvb_get_ntohs(tvb, msg_off) == 0x3120) {
dissect_syslog_message(syslog_message_tree, tvb, msg_off);
} else if ( msg_len > 15) {
dissect_rfc3164_syslog_message(syslog_message_tree, tvb, msg_off);
}
if (mtp3_tvb) {
proto_item *mtp3_item;
mtp3_item = proto_tree_add_boolean(syslog_tree, hf_syslog_msu_present,
tvb, msg_off, msg_len, TRUE);
proto_item_set_generated(mtp3_item);
}
}
/* Call MTP dissector if encapsulated MSU was found... */
if (mtp3_tvb) {
call_dissector(mtp_handle, mtp3_tvb, pinfo, tree);
}
return tvb_captured_length(tvb);
}
/* Register the protocol with Wireshark */
void proto_register_syslog(void)
{
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_syslog_facility,
{ "Facility", "syslog.facility",
FT_UINT8, BASE_DEC, VALS(syslog_facility_vals), FACILITY_MASK,
"Message facility", HFILL }
},
{ &hf_syslog_level,
{ "Level", "syslog.level",
FT_UINT8, BASE_DEC, VALS(syslog_level_vals), PRIORITY_MASK,
"Message level", HFILL }
},
{ &hf_syslog_msg,
{ "Message", "syslog.msg",
FT_STRING, BASE_NONE, NULL, 0x0,
"Message Text", HFILL }
},
{ &hf_syslog_msu_present,
{ "SS7 MSU present", "syslog.msu_present",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"True if an SS7 MSU was detected in the syslog message",
HFILL }
},
{ &hf_syslog_version,
{ "Syslog version", "syslog.version",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL,
HFILL }
},
{ &hf_syslog_timestamp,
{ "Syslog timestamp", "syslog.timestamp",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0,
NULL,
HFILL }
},
{ &hf_syslog_timestamp_old,
{ "Syslog timestamp (RFC3164)", "syslog.timestamp_rfc3164",
FT_STRING, ENC_ASCII, NULL, 0x0,
NULL,
HFILL }
},
{ &hf_syslog_hostname,
{ "Syslog hostname", "syslog.hostname",
FT_STRING, ENC_ASCII, NULL, 0x0,
NULL,
HFILL }
},
{ &hf_syslog_appname,
{ "Syslog app name", "syslog.appname",
FT_STRING, ENC_ASCII, NULL, 0x0,
"The name of the app that generated this message",
HFILL }
},
{ &hf_syslog_procid,
{ "Syslog process id", "syslog.procid",
FT_STRING, ENC_ASCII, NULL, 0x0,
NULL,
HFILL }
},
{ &hf_syslog_msgid,
{ "Syslog message id", "syslog.msgid",
FT_STRING, ENC_ASCII, NULL, 0x0,
NULL,
HFILL }
},
{ &hf_syslog_msgid_utf8,
{ "Syslog message id", "syslog.msgid",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL,
HFILL }
},
{ &hf_syslog_msgid_bom,
{ "Syslog BOM", "syslog.msgid.bom",
FT_UINT24, BASE_HEX, NULL, 0x0,
NULL,
HFILL }
}
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_syslog,
&ett_syslog_msg
};
/* Register the protocol name and description */
proto_syslog = proto_register_protocol("Syslog message", "Syslog", "syslog");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_syslog, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
syslog_handle = register_dissector("syslog", dissect_syslog, proto_syslog);
}
void
proto_reg_handoff_syslog(void)
{
dissector_add_uint_with_preference("udp.port", UDP_PORT_SYSLOG, syslog_handle);
dissector_add_for_decode_as_with_preference("tcp.port", syslog_handle);
dissector_add_uint("acdr.media_type", ACDR_Info, syslog_handle);
/* Find the mtp3 dissector */
mtp_handle = find_dissector_add_dependency("mtp3", proto_syslog);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|
C/C++
|
wireshark/epan/dissectors/packet-syslog.h
|
/* packet-syslog.h
* Routines for syslog message dissection
*
* Copyright 2000, Gerald Combs <gerald[AT]wireshark.org>
*
* Support for passing SS7 MSUs (from the Cisco ITP Packet Logging
* facility) to the MTP3 dissector by Abhik Sarkar <sarkar.abhik[AT]gmail.com>
* with some rework by Jeff Morriss <jeff.morriss.ws [AT] gmail.com>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald[AT]wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PACKET_SYSLOG_H__
#define __PACKET_SYSLOG_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Level / Priority */
#define LEVEL_EMERG 0
#define LEVEL_ALERT 1
#define LEVEL_CRIT 2
#define LEVEL_ERR 3
#define LEVEL_WARNING 4
#define LEVEL_NOTICE 5
#define LEVEL_INFO 6
#define LEVEL_DEBUG 7
static const value_string syslog_level_vals[] = {
{ LEVEL_EMERG, "EMERG - system is unusable" },
{ LEVEL_ALERT, "ALERT - action must be taken immediately" },
{ LEVEL_CRIT, "CRIT - critical conditions" },
{ LEVEL_ERR, "ERR - error conditions" },
{ LEVEL_WARNING, "WARNING - warning conditions" },
{ LEVEL_NOTICE, "NOTICE - normal but significant condition" },
{ LEVEL_INFO, "INFO - informational" },
{ LEVEL_DEBUG, "DEBUG - debug-level messages" },
{ 0, NULL }
};
/* Facility */
#define FAC_KERN 0
#define FAC_USER 1
#define FAC_MAIL 2
#define FAC_DAEMON 3
#define FAC_AUTH 4
#define FAC_SYSLOG 5
#define FAC_LPR 6
#define FAC_NEWS 7
#define FAC_UUCP 8
#define FAC_CRON 9
#define FAC_AUTHPRIV 10
#define FAC_FTP 11
#define FAC_NTP 12
#define FAC_LOGAUDIT 13
#define FAC_LOGALERT 14
#define FAC_CRON_SOL 15
#define FAC_LOCAL0 16
#define FAC_LOCAL1 17
#define FAC_LOCAL2 18
#define FAC_LOCAL3 19
#define FAC_LOCAL4 20
#define FAC_LOCAL5 21
#define FAC_LOCAL6 22
#define FAC_LOCAL7 23
static const value_string syslog_facility_vals[] = {
{ FAC_KERN, "KERN - kernel messages" },
{ FAC_USER, "USER - random user-level messages" },
{ FAC_MAIL, "MAIL - mail system" },
{ FAC_DAEMON, "DAEMON - system daemons" },
{ FAC_AUTH, "AUTH - security/authorization messages" },
{ FAC_SYSLOG, "SYSLOG - messages generated internally by syslogd" },
{ FAC_LPR, "LPR - line printer subsystem" },
{ FAC_NEWS, "NEWS - network news subsystem" },
{ FAC_UUCP, "UUCP - UUCP subsystem" },
{ FAC_CRON, "CRON - clock daemon (BSD, Linux)" },
{ FAC_AUTHPRIV, "AUTHPRIV - security/authorization messages (private)" },
{ FAC_FTP, "FTP - ftp daemon" },
{ FAC_NTP, "NTP - ntp subsystem" },
{ FAC_LOGAUDIT, "LOGAUDIT - log audit" },
{ FAC_LOGALERT, "LOGALERT - log alert" },
{ FAC_CRON_SOL, "CRON - clock daemon (Solaris)" },
{ FAC_LOCAL0, "LOCAL0 - reserved for local use" },
{ FAC_LOCAL1, "LOCAL1 - reserved for local use" },
{ FAC_LOCAL2, "LOCAL2 - reserved for local use" },
{ FAC_LOCAL3, "LOCAL3 - reserved for local use" },
{ FAC_LOCAL4, "LOCAL4 - reserved for local use" },
{ FAC_LOCAL5, "LOCAL5 - reserved for local use" },
{ FAC_LOCAL6, "LOCAL6 - reserved for local use" },
{ FAC_LOCAL7, "LOCAL7 - reserved for local use" },
{ 0, NULL }
};
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // __PACKET_SYSLOG_H__
|
C
|
wireshark/epan/dissectors/packet-systemd-journal.c
|
/* packet-systemd-journal.c
* Routines for systemd journal export (application/vnd.fdo.journal) dissection
* Copyright 2018, Gerald Combs <[email protected]>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
* Dissector for systemd's mostly-text-based Journal Export Format described
* at https://www.freedesktop.org/wiki/Software/systemd/export/.
*
* Registered MIME type: application/vnd.fdo.journal
*
* To do:
* - Rename systemd_journal to sdjournal? It's easier to type.
* - Add an extcap module.
* - Add errno strings.
* - Pretty-print _CAP_EFFECTIVE
* - Handle Journal JSON Format? https://www.freedesktop.org/wiki/Software/systemd/json/
* - Handle raw journal files? https://www.freedesktop.org/wiki/Software/systemd/journal-files/
*/
#include <config.h>
#include <epan/exceptions.h>
#include <epan/packet.h>
#include <epan/expert.h>
#include <wiretap/wtap.h>
#include <wsutil/strtoi.h>
#include "packet-syslog.h"
#define PNAME "systemd Journal Entry"
#define PSNAME "systemd Journal"
#define PFNAME "systemd_journal"
void proto_reg_handoff_systemd_journal(void);
void proto_register_systemd_journal(void);
/* Initialize the protocol and registered fields */
static int proto_systemd_journal = -1;
// Official entries, listed in
// https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html
// as of 2018-08.
static int hf_sj_message = -1;
static int hf_sj_message_id = -1;
static int hf_sj_priority = -1;
static int hf_sj_code_file = -1;
static int hf_sj_code_line = -1;
static int hf_sj_code_func = -1;
static int hf_sj_errno = -1;
static int hf_sj_syslog_facility = -1;
static int hf_sj_syslog_identifier = -1;
static int hf_sj_syslog_pid = -1;
static int hf_sj_pid = -1;
static int hf_sj_uid = -1;
static int hf_sj_gid = -1;
static int hf_sj_comm = -1;
static int hf_sj_exe = -1;
static int hf_sj_cmdline = -1;
static int hf_sj_cap_effective = -1;
static int hf_sj_audit_session = -1;
static int hf_sj_audit_loginuid = -1;
static int hf_sj_systemd_cgroup = -1;
static int hf_sj_systemd_slice = -1;
static int hf_sj_systemd_unit = -1;
static int hf_sj_systemd_user_unit = -1;
static int hf_sj_systemd_session = -1;
static int hf_sj_systemd_owner_uid = -1;
static int hf_sj_selinux_context = -1;
static int hf_sj_source_realtime_timestamp = -1;
static int hf_sj_boot_id = -1;
static int hf_sj_machine_id = -1;
static int hf_sj_systemd_invocation_id = -1;
static int hf_sj_hostname = -1;
static int hf_sj_transport = -1;
static int hf_sj_stream_id = -1;
static int hf_sj_line_break = -1;
static int hf_sj_kernel_device = -1;
static int hf_sj_kernel_subsystem = -1;
static int hf_sj_udev_sysname = -1;
static int hf_sj_udev_devnode = -1;
static int hf_sj_udev_devlink = -1;
static int hf_sj_coredump_unit = -1;
static int hf_sj_coredump_user_unit = -1;
static int hf_sj_object_pid = -1;
static int hf_sj_object_uid = -1;
static int hf_sj_object_gid = -1;
static int hf_sj_object_comm = -1;
static int hf_sj_object_exe = -1;
static int hf_sj_object_cmdline = -1;
static int hf_sj_object_audit_session = -1;
static int hf_sj_object_audit_loginuid = -1;
static int hf_sj_object_cap_effective = -1;
static int hf_sj_object_selinux_context = -1;
static int hf_sj_object_systemd_cgroup = -1;
static int hf_sj_object_systemd_session = -1;
static int hf_sj_object_systemd_owner_uid = -1;
static int hf_sj_object_systemd_unit = -1;
static int hf_sj_object_systemd_user_unit = -1;
static int hf_sj_object_systemd_slice = -1;
static int hf_sj_object_systemd_user_slice = -1;
static int hf_sj_object_systemd_invocation_id = -1;
static int hf_sj_cursor = -1;
static int hf_sj_realtime_timestamp = -1;
static int hf_sj_monotonic_timestamp = -1;
// Unofficial(?) fields. Not listed in the documentation but present in logs.
static int hf_sj_result = -1;
static int hf_sj_source_monotonic_timestamp = -1;
static int hf_sj_journal_name = -1;
static int hf_sj_journal_path = -1;
static int hf_sj_current_use = -1;
static int hf_sj_current_use_pretty = -1;
static int hf_sj_max_use = -1;
static int hf_sj_max_use_pretty = -1;
static int hf_sj_disk_keep_free = -1;
static int hf_sj_disk_keep_free_pretty = -1;
static int hf_sj_disk_available = -1;
static int hf_sj_disk_available_pretty = -1;
static int hf_sj_limit = -1;
static int hf_sj_limit_pretty = -1;
static int hf_sj_available = -1;
static int hf_sj_available_pretty = -1;
static int hf_sj_audit_type = -1;
static int hf_sj_audit_id = -1;
static int hf_sj_audit_field_apparmor = -1;
static int hf_sj_audit_field_operation = -1;
static int hf_sj_audit_field_profile = -1;
static int hf_sj_audit_field_name = -1;
static int hf_sj_seat_id = -1;
static int hf_sj_kernel_usec = -1;
static int hf_sj_userspace_usec = -1;
static int hf_sj_session_id = -1;
static int hf_sj_user_id = -1;
static int hf_sj_leader = -1;
static int hf_sj_job_type = -1;
static int hf_sj_job_result = -1;
static int hf_sj_user_invocation_id = -1;
static int hf_sj_systemd_user_slice = -1;
// Metadata.
static int hf_sj_binary_data_len = -1;
static int hf_sj_unknown_field = -1;
static int hf_sj_unknown_field_name = -1;
static int hf_sj_unknown_field_value = -1;
static int hf_sj_unknown_field_data = -1;
static int hf_sj_unhandled_field_type = -1;
static expert_field ei_unhandled_field_type = EI_INIT;
static expert_field ei_nonbinary_field = EI_INIT;
static expert_field ei_undecoded_field = EI_INIT;
static dissector_handle_t sje_handle = NULL;
#define MAX_DATA_SIZE 262144 // WTAP_MAX_PACKET_SIZE_STANDARD. Increase if needed.
/* Initialize the subtree pointers */
static gint ett_systemd_journal_entry = -1;
static gint ett_systemd_binary_data = -1;
static gint ett_systemd_unknown_field = -1;
// XXX Use a value_string instead?
typedef struct _journal_field_hf_map {
int hfid;
const char *name;
} journal_field_hf_map;
static journal_field_hf_map *jf_to_hf;
static void init_jf_to_hf_map(void) {
journal_field_hf_map jhmap[] = {
// Official.
{ hf_sj_message, "MESSAGE=" },
{ hf_sj_message_id, "MESSAGE_ID=" },
{ hf_sj_priority, "PRIORITY=" },
{ hf_sj_code_file, "CODE_FILE=" },
{ hf_sj_code_line, "CODE_LINE=" },
{ hf_sj_code_func, "CODE_FUNC=" },
{ hf_sj_result, "RESULT=" },
{ hf_sj_errno, "ERRNO=" },
{ hf_sj_syslog_facility, "SYSLOG_FACILITY=" },
{ hf_sj_syslog_identifier, "SYSLOG_IDENTIFIER=" },
{ hf_sj_syslog_pid, "SYSLOG_PID=" },
{ hf_sj_pid, "_PID=" },
{ hf_sj_uid, "_UID=" },
{ hf_sj_gid, "_GID=" },
{ hf_sj_comm, "_COMM=" },
{ hf_sj_exe, "_EXE=" },
{ hf_sj_cmdline, "_CMDLINE=" },
{ hf_sj_cap_effective, "_CAP_EFFECTIVE=" },
{ hf_sj_audit_session, "_AUDIT_SESSION=" },
{ hf_sj_audit_loginuid, "_AUDIT_LOGINUID=" },
{ hf_sj_systemd_cgroup, "_SYSTEMD_CGROUP=" },
{ hf_sj_systemd_slice, "_SYSTEMD_SLICE=" },
{ hf_sj_systemd_unit, "_SYSTEMD_UNIT=" },
{ hf_sj_systemd_user_unit, "_SYSTEMD_USER_UNIT=" },
{ hf_sj_systemd_session, "_SYSTEMD_SESSION=" },
{ hf_sj_systemd_owner_uid, "_SYSTEMD_OWNER_UID=" },
{ hf_sj_selinux_context, "_SELINUX_CONTEXT=" },
{ hf_sj_source_realtime_timestamp, "_SOURCE_REALTIME_TIMESTAMP=" },
{ hf_sj_source_monotonic_timestamp, "_SOURCE_MONOTONIC_TIMESTAMP=" },
{ hf_sj_boot_id, "_BOOT_ID=" },
{ hf_sj_machine_id, "_MACHINE_ID=" },
{ hf_sj_systemd_invocation_id, "_SYSTEMD_INVOCATION_ID=" },
{ hf_sj_hostname, "_HOSTNAME=" },
{ hf_sj_transport, "_TRANSPORT=" },
{ hf_sj_stream_id, "_STREAM_ID=" },
{ hf_sj_line_break, "_LINE_BREAK=" },
{ hf_sj_kernel_device, "_KERNEL_DEVICE=" },
{ hf_sj_kernel_subsystem, "_KERNEL_SUBSYSTEM=" },
{ hf_sj_udev_sysname, "_UDEV_SYSNAME=" },
{ hf_sj_udev_devnode, "_UDEV_DEVNODE=" },
{ hf_sj_udev_devlink, "_UDEV_DEVLINK=" },
{ hf_sj_coredump_unit, "COREDUMP_UNIT=" },
{ hf_sj_coredump_user_unit, "COREDUMP_USER_UNIT=" },
{ hf_sj_object_pid, "OBJECT_PID=" },
{ hf_sj_object_uid, "OBJECT_UID=" },
{ hf_sj_object_gid, "OBJECT_GID=" },
{ hf_sj_object_comm, "OBJECT_COMM=" },
{ hf_sj_object_exe, "OBJECT_EXE=" },
{ hf_sj_object_cmdline, "OBJECT_CMDLINE=" },
{ hf_sj_object_audit_session, "OBJECT_AUDIT_SESSION=" },
{ hf_sj_object_audit_loginuid, "OBJECT_AUDIT_LOGINUID=" },
{ hf_sj_object_cap_effective, "OBJECT_CAP_EFFECTIVE=" },
{ hf_sj_object_selinux_context, "OBJECT_SELINUX_CONTEXT=" },
{ hf_sj_object_systemd_cgroup, "OBJECT_SYSTEMD_CGROUP=" },
{ hf_sj_object_systemd_session, "OBJECT_SYSTEMD_SESSION=" },
{ hf_sj_object_systemd_owner_uid, "OBJECT_SYSTEMD_OWNER_UID=" },
{ hf_sj_object_systemd_unit, "OBJECT_SYSTEMD_UNIT=" },
{ hf_sj_object_systemd_user_unit, "OBJECT_SYSTEMD_USER_UNIT=" },
{ hf_sj_object_systemd_slice, "OBJECT_SYSTEMD_SLICE=" },
{ hf_sj_object_systemd_user_slice, "OBJECT_SYSTEMD_USER_SLICE=" },
{ hf_sj_object_systemd_invocation_id, "OBJECT_SYSTEMD_INVOCATION_ID=" },
{ hf_sj_cursor, "__CURSOR=" },
{ hf_sj_realtime_timestamp, "__REALTIME_TIMESTAMP=" },
{ hf_sj_monotonic_timestamp, "__MONOTONIC_TIMESTAMP=" },
// Unofficial?
{ hf_sj_journal_name, "JOURNAL_NAME=" }, // systemd-journald: Runtime journal (/run/log/journal/) is ...
{ hf_sj_journal_path, "JOURNAL_PATH=" }, // ""
{ hf_sj_current_use, "CURRENT_USE=" }, // ""
{ hf_sj_current_use_pretty, "CURRENT_USE_PRETTY=" }, // ""
{ hf_sj_max_use, "MAX_USE=" }, // ""
{ hf_sj_max_use_pretty, "MAX_USE_PRETTY=" }, // ""
{ hf_sj_disk_keep_free, "DISK_KEEP_FREE=" }, // ""
{ hf_sj_disk_keep_free_pretty, "DISK_KEEP_FREE_PRETTY=" }, // ""
{ hf_sj_disk_available, "DISK_AVAILABLE=" }, // ""
{ hf_sj_disk_available_pretty, "DISK_AVAILABLE_PRETTY=" }, // ""
{ hf_sj_limit, "LIMIT=" }, // ""
{ hf_sj_limit_pretty, "LIMIT_PRETTY=" }, // ""
{ hf_sj_available, "AVAILABLE=" }, // ""
{ hf_sj_available_pretty, "AVAILABLE_PRETTY=" }, // ""
{ hf_sj_code_func, "CODE_FUNCTION=" }, // Dup / alias of CODE_FUNC?
{ hf_sj_systemd_user_unit, "UNIT=" }, // Dup / alias of _SYSTEMD_UNIT?
{ hf_sj_systemd_user_unit, "USER_UNIT=" }, // Dup / alias of _SYSTEMD_USER_UNIT?
{ hf_sj_audit_type, "_AUDIT_TYPE=" },
{ hf_sj_audit_id, "_AUDIT_ID=" },
{ hf_sj_audit_field_apparmor, "_AUDIT_FIELD_APPARMOR=" },
{ hf_sj_audit_field_operation, "_AUDIT_FIELD_OPERATION=" },
{ hf_sj_audit_field_profile, "_AUDIT_FIELD_PROFILE=" },
{ hf_sj_audit_field_name, "_AUDIT_FIELD_NAME=" },
{ hf_sj_seat_id, "SEAT_ID=" },
{ hf_sj_kernel_usec, "KERNEL_USEC=" },
{ hf_sj_userspace_usec, "USERSPACE_USEC" },
{ hf_sj_session_id, "SESSION_ID" },
{ hf_sj_user_id, "USER_ID" },
{ hf_sj_leader, "LEADER" },
{ hf_sj_job_type, "JOB_TYPE" },
{ hf_sj_job_result, "JOB_RESULT" },
{ hf_sj_user_invocation_id, "USER_INVOCATION_ID" },
{ hf_sj_systemd_user_slice, "_SYSTEMD_USER_SLICE=" },
{ 0, NULL }
};
jf_to_hf = (journal_field_hf_map*) g_memdup2(jhmap, sizeof(jhmap));
}
static void
dissect_sjle_time_usecs(proto_tree *tree, int hf_idx, tvbuff_t *tvb, int offset, int len) {
guint64 rt_ts = 0;
char *time_str = tvb_format_text(wmem_packet_scope(), tvb, offset, len);
gboolean ok = ws_strtou64(time_str, NULL, &rt_ts);
if (ok) {
nstime_t ts;
ts.secs = (time_t) (rt_ts / 1000000);
ts.nsecs = (rt_ts % 1000000) * 1000;
proto_tree_add_time(tree, hf_idx, tvb, offset, len, &ts);
} else {
proto_tree_add_expert_format(tree, NULL, &ei_undecoded_field, tvb, offset, len, "Invalid time value %s", time_str);
}
}
static void
dissect_sjle_uint(proto_tree *tree, int hf_idx, tvbuff_t *tvb, int offset, int len) {
guint32 uint_val = (guint32) strtoul(tvb_format_text(wmem_packet_scope(), tvb, offset, len), NULL, 10);
proto_tree_add_uint(tree, hf_idx, tvb, offset, len, uint_val);
}
static void
dissect_sjle_int(proto_tree *tree, int hf_idx, tvbuff_t *tvb, int offset, int len) {
gint32 int_val = (gint32) strtol(tvb_format_text(wmem_packet_scope(), tvb, offset, len), NULL, 10);
proto_tree_add_int(tree, hf_idx, tvb, offset, len, int_val);
}
/* Dissect a line-based journal export entry */
static int
dissect_systemd_journal_line_entry(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
void *data _U_)
{
proto_item *ti;
proto_tree *sje_tree;
int offset = 0, next_offset = 0;
col_set_str(pinfo->cinfo, COL_PROTOCOL, PSNAME);
col_clear(pinfo->cinfo, COL_INFO);
col_set_str(pinfo->cinfo, COL_INFO, "Journal Entry");
ti = proto_tree_add_item(tree, proto_systemd_journal, tvb, 0, -1, ENC_NA);
sje_tree = proto_item_add_subtree(ti, ett_systemd_journal_entry);
while (tvb_offset_exists(tvb, offset)) {
int line_len = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
if (line_len < 3) {
// Invalid or zero length.
// XXX Add an expert item for non-empty lines.
offset = next_offset;
continue;
}
gboolean found = FALSE;
int eq_off = tvb_find_guint8(tvb, offset, line_len, '=') + 1;
int val_len = offset + line_len - eq_off;
for (int i = 0; jf_to_hf[i].name; i++) {
if (tvb_memeql(tvb, offset, (const guint8*) jf_to_hf[i].name, strlen(jf_to_hf[i].name)) == 0) {
int hf_idx = jf_to_hf[i].hfid;
switch (proto_registrar_get_ftype(hf_idx)) {
case FT_ABSOLUTE_TIME:
case FT_RELATIVE_TIME:
dissect_sjle_time_usecs(sje_tree, hf_idx, tvb, eq_off, val_len);
break;
case FT_UINT32:
case FT_UINT16:
case FT_UINT8:
dissect_sjle_uint(sje_tree, hf_idx, tvb, eq_off, val_len);
break;
case FT_INT32:
case FT_INT16:
case FT_INT8:
dissect_sjle_int(sje_tree, hf_idx, tvb, eq_off, val_len);
break;
case FT_STRING:
proto_tree_add_item(sje_tree, jf_to_hf[i].hfid, tvb, eq_off, val_len, ENC_UTF_8|ENC_NA);
break;
default:
{
proto_item *expert_ti = proto_tree_add_item(sje_tree, hf_sj_unhandled_field_type, tvb, offset, line_len,
ENC_UTF_8);
expert_add_info(pinfo, expert_ti, &ei_unhandled_field_type);
break;
}
}
if (hf_idx == hf_sj_message) {
col_clear(pinfo->cinfo, COL_INFO);
col_add_str(pinfo->cinfo, COL_INFO, (char *) tvb_get_string_enc(pinfo->pool, tvb, eq_off, val_len, ENC_UTF_8));
}
found = TRUE;
}
}
if (!found && eq_off > offset + 1) {
proto_item *unk_ti = proto_tree_add_none_format(sje_tree, hf_sj_unknown_field, tvb, offset, line_len,
"Unknown text field: %s", tvb_get_string_enc(pinfo->pool, tvb, offset, eq_off - offset - 1, ENC_UTF_8));
proto_tree *unk_tree = proto_item_add_subtree(unk_ti, ett_systemd_unknown_field);
proto_tree_add_item(unk_tree, hf_sj_unknown_field_name, tvb, offset, eq_off - offset - 1, ENC_UTF_8);
proto_tree_add_item(unk_tree, hf_sj_unknown_field_value, tvb, eq_off, val_len, ENC_UTF_8);
offset = next_offset;
continue;
}
// Try again, looking for binary fields.
if (!found) {
for (int i = 0; jf_to_hf[i].name; i++) {
int noeql_len = (int) strlen(jf_to_hf[i].name) - 1;
if (tvb_memeql(tvb, offset, (const guint8 *) jf_to_hf[i].name, (size_t) noeql_len) == 0 && tvb_memeql(tvb, offset+noeql_len, (const guint8 *) "\n", 1) == 0) {
int hf_idx = jf_to_hf[i].hfid;
guint64 data_len = tvb_get_letoh64(tvb, offset + noeql_len + 1);
int data_off = offset + noeql_len + 1 + 8; // \n + data len
next_offset = data_off + (int) data_len + 1;
if (proto_registrar_get_ftype(hf_idx) == FT_STRING) {
proto_item *bin_ti = proto_tree_add_item(sje_tree, hf_idx, tvb, data_off, (int) data_len, ENC_NA);
proto_tree *bin_tree = proto_item_add_subtree(bin_ti, ett_systemd_binary_data);
proto_tree_add_item(bin_tree, hf_sj_binary_data_len, tvb, offset + noeql_len + 1, 8, ENC_LITTLE_ENDIAN);
if (hf_idx == hf_sj_message) {
col_clear(pinfo->cinfo, COL_INFO);
col_add_str(pinfo->cinfo, COL_INFO, tvb_format_text(pinfo->pool, tvb, data_off, (int) data_len));
}
} else {
proto_item *unk_ti = proto_tree_add_none_format(sje_tree, hf_sj_unknown_field, tvb, offset, line_len,
"Unknown data field: %s", tvb_format_text(pinfo->pool, tvb, offset, eq_off - offset - 1));
proto_tree *unk_tree = proto_item_add_subtree(unk_ti, ett_systemd_unknown_field);
proto_item *expert_ti = proto_tree_add_item(unk_tree, hf_sj_unknown_field_name, tvb, offset, offset + noeql_len, ENC_UTF_8);
proto_tree_add_item(unk_tree, hf_sj_unknown_field_data, tvb, data_off, (int) data_len, ENC_UTF_8);
expert_add_info(pinfo, expert_ti, &ei_nonbinary_field);
}
}
}
}
offset = next_offset;
}
return offset;
}
/*
* Register the protocol with Wireshark.
*/
void
proto_register_systemd_journal(void)
{
expert_module_t *expert_systemd_journal;
static hf_register_info hf[] = {
{ &hf_sj_message,
{ "Message", "systemd_journal.message",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_message_id,
{ "Message ID", "systemd_journal.message_id",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_priority,
{ "Priority", "systemd_journal.priority",
FT_UINT8, BASE_DEC, VALS(syslog_level_vals), 0x0, NULL, HFILL }
},
{ &hf_sj_code_file,
{ "Code file", "systemd_journal.code_file",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_code_line,
{ "Code line", "systemd_journal.code_line",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_code_func,
{ "Code func", "systemd_journal.code_func",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_errno,
{ "Errno", "systemd_journal.errno",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_syslog_facility,
{ "Syslog facility", "systemd_journal.syslog_facility",
FT_UINT8, BASE_NONE, VALS(syslog_facility_vals), 0x0, NULL, HFILL }
},
{ &hf_sj_syslog_identifier,
{ "Syslog identifier", "systemd_journal.syslog_id",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_syslog_pid,
{ "Syslog PID", "systemd_journal.syslog_pid",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_pid,
{ "PID", "systemd_journal.pid",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_uid,
{ "UID", "systemd_journal.uid",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_gid,
{ "GID", "systemd_journal.gid",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_comm,
{ "Command name", "systemd_journal.comm",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_exe,
{ "Executable path", "systemd_journal.exe",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_cmdline,
{ "Command line", "systemd_journal.cmdline",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_cap_effective,
{ "Effective capability", "systemd_journal.cap_effective",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_audit_session,
{ "Audit session", "systemd_journal.audit_session",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_audit_loginuid,
{ "Audit login UID", "systemd_journal.audit_loginuid",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_systemd_cgroup,
{ "Systemd cgroup", "systemd_journal.systemd_cgroup",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_systemd_slice,
{ "Systemd slice", "systemd_journal.systemd_slice",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_systemd_unit,
{ "Systemd unit", "systemd_journal.systemd_unit",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_systemd_user_unit,
{ "Systemd user unit", "systemd_journal.systemd_user_unit",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_systemd_session,
{ "Systemd session", "systemd_journal.systemd_session",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_systemd_owner_uid,
{ "Systemd owner UID", "systemd_journal.systemd_owner_uid",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_selinux_context,
{ "SELinux context", "systemd_journal.selinux_context",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_source_realtime_timestamp,
{ "Source realtime timestamp", "systemd_journal.source_realtime_timestamp",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_boot_id,
{ "Boot ID", "systemd_journal.boot_id",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_machine_id,
{ "Machine ID", "systemd_journal.machine_id",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_systemd_invocation_id,
{ "Systemd invocation ID", "systemd_journal.systemd_invocation_id",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_hostname,
{ "Hostname", "systemd_journal.hostname",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_transport,
{ "Transport", "systemd_journal.transport",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_stream_id,
{ "Stream ID", "systemd_journal.stream_id",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_line_break,
{ "Line break", "systemd_journal.line_break",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_kernel_device,
{ "Kernel device", "systemd_journal.kernel_device",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_kernel_subsystem,
{ "Kernel subsystem", "systemd_journal.kernel_subsystem",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_udev_sysname,
{ "Device tree name", "systemd_journal.udev_sysname",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_udev_devnode,
{ "Device tree node", "systemd_journal.udev_devnode",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_udev_devlink,
{ "Device tree symlink", "systemd_journal.udev_devlink",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_coredump_unit,
{ "Coredump unit", "systemd_journal.coredump_unit",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_coredump_user_unit,
{ "Coredump user unit", "systemd_journal.coredump_user_unit",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_pid,
{ "Object PID", "systemd_journal.object_pid",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_uid,
{ "Object UID", "systemd_journal.object_uid",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_gid,
{ "Object GID", "systemd_journal.object_gid",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_comm,
{ "Object command name", "systemd_journal.object_comm",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_exe,
{ "Object executable path", "systemd_journal.object_exe",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_cmdline,
{ "Object command line", "systemd_journal.object_cmdline",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_audit_session,
{ "Object audit session", "systemd_journal.object_audit_session",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_audit_loginuid,
{ "Object audit login UID", "systemd_journal.object_audit_loginuid",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_cap_effective,
{ "Object effective capability", "systemd_journal.object_cap_effective",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_selinux_context,
{ "Object SELinux context", "systemd_journal.object_selinux_context",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_systemd_cgroup,
{ "Object systemd cgroup", "systemd_journal.object_systemd_cgroup",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_systemd_session,
{ "Object systemd session", "systemd_journal.object_systemd_session",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_systemd_owner_uid,
{ "Object systemd owner UID", "systemd_journal.object_systemd_owner_uid",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_systemd_unit,
{ "Object systemd unit", "systemd_journal.object_systemd_unit",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_systemd_user_unit,
{ "Object systemd user unit", "systemd_journal.object_systemd_user_unit",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_systemd_slice,
{ "Object systemd slice", "systemd_journal.object_systemd_slice",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_systemd_user_slice,
{ "Object systemd user slice", "systemd_journal.object_systemd_user_slice",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_object_systemd_invocation_id,
{ "Object systemd invocation ID", "systemd_journal.object_systemd_invocation_id",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_cursor,
{ "Cursor", "systemd_journal.cursor",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_realtime_timestamp,
{ "Realtime Timestamp", "systemd_journal.realtime_timestamp",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_monotonic_timestamp,
{ "Monotonic Timestamp", "systemd_journal.monotonic_timestamp",
FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_journal_name,
{ "Journal name", "systemd_journal.journal_name",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_journal_path,
{ "Journal path", "systemd_journal.journal_path",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_current_use,
{ "Current use", "systemd_journal.current_use",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_current_use_pretty,
{ "Human readable current use", "systemd_journal.current_use_pretty",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_max_use,
{ "Max use", "systemd_journal.max_use",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_max_use_pretty,
{ "Human readable max use", "systemd_journal.max_use_pretty",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_disk_keep_free,
{ "Disk keep free", "systemd_journal.disk_keep_free",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_disk_keep_free_pretty,
{ "Human readable disk keep free", "systemd_journal.disk_keep_free_pretty",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_disk_available,
{ "Disk available", "systemd_journal.disk_available",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_disk_available_pretty,
{ "Human readable disk available", "systemd_journal.disk_available_pretty",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_limit,
{ "Limit", "systemd_journal.limit",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_limit_pretty,
{ "Human readable limit", "systemd_journal.limit_pretty",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_available,
{ "Available", "systemd_journal.available",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_available_pretty,
{ "Human readable available", "systemd_journal.available_pretty",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_result,
{ "Result", "systemd_journal.result",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_source_monotonic_timestamp,
{ "Source monotonic timestamp", "systemd_journal.source_monotonic_timestamp",
FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_audit_type,
{ "Audit type", "systemd_journal.audit_type",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_audit_id,
{ "Audit ID", "systemd_journal.audit_id",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_audit_field_apparmor,
{ "Audit field AppArmor", "systemd_journal.audit_field_apparmor",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_audit_field_operation,
{ "Audit field operation", "systemd_journal.audit_field_operation",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_audit_field_profile,
{ "Audit field profile", "systemd_journal.audit_field_profile",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_audit_field_name,
{ "Audit field name", "systemd_journal.audit_field_name",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_seat_id,
{ "Seat ID", "systemd_journal.seat_id",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_kernel_usec,
{ "Kernel microseconds", "systemd_journal.kernel_usec",
FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_userspace_usec,
{ "Userspace microseconds", "systemd_journal.userspace_usec",
FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_session_id,
{ "Session ID", "systemd_journal.session_id",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_user_id,
{ "User ID", "systemd_journal.user_id",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_leader,
{ "Leader", "systemd_journal.leader",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_job_type,
{ "Job type", "systemd_journal.job_type",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_job_result,
{ "Job result", "systemd_journal.job_result",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_user_invocation_id,
{ "User invocation ID", "systemd_journal.user_invocation_id",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_systemd_user_slice,
{ "Systemd user slice", "systemd_journal.systemd_user_slice",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_binary_data_len,
{ "Binary data length", "systemd_journal.binary_data_len",
FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_unknown_field,
{ "Unknown field", "systemd_journal.field",
FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_unknown_field_name,
{ "Field name", "systemd_journal.field.name",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_unknown_field_value,
{ "Field value", "systemd_journal.field.value",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_unknown_field_data,
{ "Field data", "systemd_journal.field.data",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
{ &hf_sj_unhandled_field_type,
{ "Field data", "systemd_journal.unhandled_field_type",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
}
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_systemd_journal_entry,
&ett_systemd_binary_data,
&ett_systemd_unknown_field
};
/* Setup protocol expert items */
static ei_register_info ei[] = {
{ &ei_unhandled_field_type,
{ "systemd_journal.unhandled_field_type.undecoded", PI_UNDECODED, PI_ERROR,
"Unhandled field type", EXPFILL }
},
{ &ei_nonbinary_field,
{ "systemd_journal.nonbinary_field", PI_UNDECODED, PI_WARN,
"Field shouldn't be binary", EXPFILL }
},
{ &ei_undecoded_field,
{ "systemd_journal.undecoded_field", PI_UNDECODED, PI_WARN,
"Unable to decode field", EXPFILL }
}
};
/* Register the protocol name and description */
proto_systemd_journal = proto_register_protocol(PNAME, PSNAME, PFNAME);
/* Required function calls to register the header fields and subtrees */
proto_register_field_array(proto_systemd_journal, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
/* Required function calls to register expert items */
expert_systemd_journal = expert_register_protocol(proto_systemd_journal);
expert_register_field_array(expert_systemd_journal, ei, array_length(ei));
sje_handle = register_dissector("systemd_journal", dissect_systemd_journal_line_entry,
proto_systemd_journal);
init_jf_to_hf_map();
}
#define BLOCK_TYPE_SYSTEMD_JOURNAL_EXPORT 0x0000009
void
proto_reg_handoff_systemd_journal(void)
{
int file_type_subtype_systemd_journal;
file_type_subtype_systemd_journal = wtap_name_to_file_type_subtype("systemd_journal");
if (file_type_subtype_systemd_journal != -1)
dissector_add_uint("wtap_fts_rec", file_type_subtype_systemd_journal, sje_handle);
dissector_add_uint("pcapng.block_type", BLOCK_TYPE_SYSTEMD_JOURNAL_EXPORT, sje_handle);
// It's possible to ship journal entries over HTTP/HTTPS using
// systemd-journal-remote. Dissecting them on the wire isn't very
// useful since it's easy to end up with a packet containing a
// single, huge reassembled journal with many entries.
dissector_add_string("media_type", "application/vnd.fdo.journal", sje_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* 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:
*/
|
C
|
wireshark/epan/dissectors/packet-t124.c
|
/* Do not modify this file. Changes will be overwritten. */
/* Generated automatically by the ASN.1 to Wireshark dissector compiler */
/* packet-t124.c */
/* asn2wrs.py -L -p t124 -c ./t124.cnf -s ./packet-t124-template -D . -O ../.. GCC-PROTOCOL.asn ../t125/MCS-PROTOCOL.asn */
/* packet-t124.c
* Routines for t124 packet dissection
* Copyright 2010, Graeme Lunt
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <[email protected]>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/conversation.h>
#include <epan/asn1.h>
#include "packet-per.h"
#include "packet-ber.h"
#include "packet-t124.h"
#ifdef _MSC_VER
/* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */
#pragma warning(disable:4146)
#endif
#define PNAME "GENERIC-CONFERENCE-CONTROL T.124"
#define PSNAME "T.124"
#define PFNAME "t124"
void proto_register_t124(void);
void proto_reg_handoff_t124(void);
/* Initialize the protocol and registered fields */
static int proto_t124 = -1;
static proto_tree *top_tree = NULL;
static int hf_t124_object = -1; /* T_object */
static int hf_t124_h221NonStandard = -1; /* H221NonStandardIdentifier */
static int hf_t124_key = -1; /* Key */
static int hf_t124_data = -1; /* OCTET_STRING */
static int hf_t124_UserData_item = -1; /* UserData_item */
static int hf_t124_value = -1; /* T_value */
static int hf_t124_numeric = -1; /* SimpleNumericString */
static int hf_t124_text = -1; /* SimpleTextString */
static int hf_t124_unicodeText = -1; /* TextString */
static int hf_t124_passwordString = -1; /* PasswordSelector */
static int hf_t124_responseData = -1; /* UserData */
static int hf_t124_passwordInTheClear = -1; /* NULL */
static int hf_t124_nonStandardAlgorithm = -1; /* NonStandardParameter */
static int hf_t124_responseAlgorithm = -1; /* ChallengeResponseAlgorithm */
static int hf_t124_challengeData = -1; /* UserData */
static int hf_t124_challengeTag = -1; /* INTEGER */
static int hf_t124_challengeSet = -1; /* SET_OF_ChallengeItem */
static int hf_t124_challengeSet_item = -1; /* ChallengeItem */
static int hf_t124_responseItem = -1; /* ChallengeResponseItem */
static int hf_t124_passwordInTheClear_01 = -1; /* PasswordSelector */
static int hf_t124_challengeRequestResponse = -1; /* T_challengeRequestResponse */
static int hf_t124_challengeRequest = -1; /* ChallengeRequest */
static int hf_t124_challengeResponse = -1; /* ChallengeResponse */
static int hf_t124_nonStandardScheme = -1; /* NonStandardParameter */
static int hf_t124_priority = -1; /* INTEGER_0_65535 */
static int hf_t124_scheme = -1; /* ConferencePriorityScheme */
static int hf_t124_conventional = -1; /* NULL */
static int hf_t124_counted = -1; /* NULL */
static int hf_t124_anonymous = -1; /* NULL */
static int hf_t124_nonStandardCategory = -1; /* NonStandardParameter */
static int hf_t124_conventional_only = -1; /* NULL */
static int hf_t124_counted_only = -1; /* NULL */
static int hf_t124_anonymous_only = -1; /* NULL */
static int hf_t124_conventional_control = -1; /* NULL */
static int hf_t124_unrestricted_mode = -1; /* NULL */
static int hf_t124_non_standard_mode = -1; /* NonStandardParameter */
static int hf_t124_NetworkAddress_item = -1; /* NetworkAddress_item */
static int hf_t124_aggregatedChannel = -1; /* T_aggregatedChannel */
static int hf_t124_transferModes = -1; /* T_transferModes */
static int hf_t124_speech = -1; /* BOOLEAN */
static int hf_t124_voice_band = -1; /* BOOLEAN */
static int hf_t124_digital_56k = -1; /* BOOLEAN */
static int hf_t124_digital_64k = -1; /* BOOLEAN */
static int hf_t124_digital_128k = -1; /* BOOLEAN */
static int hf_t124_digital_192k = -1; /* BOOLEAN */
static int hf_t124_digital_256k = -1; /* BOOLEAN */
static int hf_t124_digital_320k = -1; /* BOOLEAN */
static int hf_t124_digital_384k = -1; /* BOOLEAN */
static int hf_t124_digital_512k = -1; /* BOOLEAN */
static int hf_t124_digital_768k = -1; /* BOOLEAN */
static int hf_t124_digital_1152k = -1; /* BOOLEAN */
static int hf_t124_digital_1472k = -1; /* BOOLEAN */
static int hf_t124_digital_1536k = -1; /* BOOLEAN */
static int hf_t124_digital_1920k = -1; /* BOOLEAN */
static int hf_t124_packet_mode = -1; /* BOOLEAN */
static int hf_t124_frame_mode = -1; /* BOOLEAN */
static int hf_t124_atm = -1; /* BOOLEAN */
static int hf_t124_internationalNumber = -1; /* DiallingString */
static int hf_t124_subAddress = -1; /* SubAddressString */
static int hf_t124_extraDialling = -1; /* ExtraDiallingString */
static int hf_t124_highLayerCompatibility = -1; /* T_highLayerCompatibility */
static int hf_t124_telephony3kHz = -1; /* BOOLEAN */
static int hf_t124_telephony7kHz = -1; /* BOOLEAN */
static int hf_t124_videotelephony = -1; /* BOOLEAN */
static int hf_t124_videoconference = -1; /* BOOLEAN */
static int hf_t124_audiographic = -1; /* BOOLEAN */
static int hf_t124_audiovisual = -1; /* BOOLEAN */
static int hf_t124_multimedia = -1; /* BOOLEAN */
static int hf_t124_transportConnection = -1; /* T_transportConnection */
static int hf_t124_nsapAddress = -1; /* OCTET_STRING_SIZE_1_20 */
static int hf_t124_transportSelector = -1; /* OCTET_STRING */
static int hf_t124_nonStandard = -1; /* NonStandardParameter */
static int hf_t124_callingNode = -1; /* NULL */
static int hf_t124_calledNode = -1; /* NULL */
static int hf_t124_unknown = -1; /* INTEGER_0_4294967295 */
static int hf_t124_conferenceName = -1; /* ConferenceName */
static int hf_t124_conferenceNameModifier = -1; /* ConferenceNameModifier */
static int hf_t124_conferenceDescription = -1; /* TextString */
static int hf_t124_lockedConference = -1; /* BOOLEAN */
static int hf_t124_passwordInTheClearRequired = -1; /* BOOLEAN */
static int hf_t124_networkAddress = -1; /* NetworkAddress */
static int hf_t124_defaultConferenceFlag = -1; /* BOOLEAN */
static int hf_t124_conferenceMode = -1; /* ConferenceMode */
static int hf_t124_convenerPassword = -1; /* Password */
static int hf_t124_password = -1; /* Password */
static int hf_t124_listedConference = -1; /* BOOLEAN */
static int hf_t124_conductibleConference = -1; /* BOOLEAN */
static int hf_t124_terminationMethod = -1; /* TerminationMethod */
static int hf_t124_conductorPrivileges = -1; /* SET_OF_Privilege */
static int hf_t124_conductorPrivileges_item = -1; /* Privilege */
static int hf_t124_conductedPrivileges = -1; /* SET_OF_Privilege */
static int hf_t124_conductedPrivileges_item = -1; /* Privilege */
static int hf_t124_nonConductedPrivileges = -1; /* SET_OF_Privilege */
static int hf_t124_nonConductedPrivileges_item = -1; /* Privilege */
static int hf_t124_callerIdentifier = -1; /* TextString */
static int hf_t124_userData = -1; /* UserData */
static int hf_t124_conferencePriority = -1; /* ConferencePriority */
static int hf_t124_nodeID = -1; /* UserID */
static int hf_t124_tag = -1; /* INTEGER */
static int hf_t124_result = -1; /* T_result */
static int hf_t124_nodeType = -1; /* NodeType */
static int hf_t124_asymmetryIndicator = -1; /* AsymmetryIndicator */
static int hf_t124_conferenceList = -1; /* SET_OF_ConferenceDescriptor */
static int hf_t124_conferenceList_item = -1; /* ConferenceDescriptor */
static int hf_t124_queryResponseResult = -1; /* QueryResponseResult */
static int hf_t124_waitForInvitationFlag = -1; /* BOOLEAN */
static int hf_t124_noUnlistedConferenceFlag = -1; /* BOOLEAN */
static int hf_t124_conferenceName_01 = -1; /* ConferenceNameSelector */
static int hf_t124_password_01 = -1; /* PasswordChallengeRequestResponse */
static int hf_t124_convenerPassword_01 = -1; /* PasswordSelector */
static int hf_t124_nodeCategory = -1; /* NodeCategory */
static int hf_t124_topNodeID = -1; /* UserID */
static int hf_t124_conferenceNameAlias = -1; /* ConferenceNameSelector */
static int hf_t124_joinResponseResult = -1; /* JoinResponseResult */
static int hf_t124_inviteResponseResult = -1; /* InviteResponseResult */
static int hf_t124_t124Identifier = -1; /* Key */
static int hf_t124_connectPDU = -1; /* T_connectPDU */
static int hf_t124_conferenceCreateRequest = -1; /* ConferenceCreateRequest */
static int hf_t124_conferenceCreateResponse = -1; /* ConferenceCreateResponse */
static int hf_t124_conferenceQueryRequest = -1; /* ConferenceQueryRequest */
static int hf_t124_conferenceQueryResponse = -1; /* ConferenceQueryResponse */
static int hf_t124_conferenceJoinRequest = -1; /* ConferenceJoinRequest */
static int hf_t124_conferenceJoinResponse = -1; /* ConferenceJoinResponse */
static int hf_t124_conferenceInviteRequest = -1; /* ConferenceInviteRequest */
static int hf_t124_conferenceInviteResponse = -1; /* ConferenceInviteResponse */
static int hf_t124_heightLimit = -1; /* INTEGER_0_MAX */
static int hf_t124_subHeight = -1; /* INTEGER_0_MAX */
static int hf_t124_subInterval = -1; /* INTEGER_0_MAX */
static int hf_t124_static = -1; /* T_static */
static int hf_t124_channelId = -1; /* StaticChannelId */
static int hf_t124_userId = -1; /* T_userId */
static int hf_t124_joined = -1; /* BOOLEAN */
static int hf_t124_userId_01 = -1; /* UserId */
static int hf_t124_private = -1; /* T_private */
static int hf_t124_channelId_01 = -1; /* PrivateChannelId */
static int hf_t124_manager = -1; /* UserId */
static int hf_t124_admitted = -1; /* SET_OF_UserId */
static int hf_t124_admitted_item = -1; /* UserId */
static int hf_t124_assigned = -1; /* T_assigned */
static int hf_t124_channelId_02 = -1; /* AssignedChannelId */
static int hf_t124_mergeChannels = -1; /* SET_OF_ChannelAttributes */
static int hf_t124_mergeChannels_item = -1; /* ChannelAttributes */
static int hf_t124_purgeChannelIds = -1; /* SET_OF_ChannelId */
static int hf_t124_purgeChannelIds_item = -1; /* ChannelId */
static int hf_t124_detachUserIds = -1; /* SET_OF_UserId */
static int hf_t124_detachUserIds_item = -1; /* UserId */
static int hf_t124_grabbed = -1; /* T_grabbed */
static int hf_t124_tokenId = -1; /* TokenId */
static int hf_t124_grabber = -1; /* UserId */
static int hf_t124_inhibited = -1; /* T_inhibited */
static int hf_t124_inhibitors = -1; /* SET_OF_UserId */
static int hf_t124_inhibitors_item = -1; /* UserId */
static int hf_t124_giving = -1; /* T_giving */
static int hf_t124_recipient = -1; /* UserId */
static int hf_t124_ungivable = -1; /* T_ungivable */
static int hf_t124_given = -1; /* T_given */
static int hf_t124_mergeTokens = -1; /* SET_OF_TokenAttributes */
static int hf_t124_mergeTokens_item = -1; /* TokenAttributes */
static int hf_t124_purgeTokenIds = -1; /* SET_OF_TokenId */
static int hf_t124_purgeTokenIds_item = -1; /* TokenId */
static int hf_t124_reason = -1; /* Reason */
static int hf_t124_diagnostic = -1; /* Diagnostic */
static int hf_t124_initialOctets = -1; /* OCTET_STRING */
static int hf_t124_result_01 = -1; /* Result */
static int hf_t124_initiator = -1; /* UserId */
static int hf_t124_userIds = -1; /* SET_OF_UserId */
static int hf_t124_userIds_item = -1; /* UserId */
static int hf_t124_channelId_03 = -1; /* ChannelId */
static int hf_t124_requested = -1; /* ChannelId */
static int hf_t124_channelIds = -1; /* SET_OF_ChannelId */
static int hf_t124_channelIds_item = -1; /* ChannelId */
static int hf_t124_dataPriority = -1; /* DataPriority */
static int hf_t124_segmentation = -1; /* Segmentation */
static int hf_t124_userData_01 = -1; /* T_userData */
static int hf_t124_userData_02 = -1; /* T_userData_01 */
static int hf_t124_userData_03 = -1; /* OCTET_STRING */
static int hf_t124_tokenStatus = -1; /* TokenStatus */
static int hf_t124_plumbDomainIndication = -1; /* PlumbDomainIndication */
static int hf_t124_erectDomainRequest = -1; /* ErectDomainRequest */
static int hf_t124_mergeChannelsRequest = -1; /* MergeChannelsRequest */
static int hf_t124_mergeChannelsConfirm = -1; /* MergeChannelsConfirm */
static int hf_t124_purgeChannelsIndication = -1; /* PurgeChannelsIndication */
static int hf_t124_mergeTokensRequest = -1; /* MergeTokensRequest */
static int hf_t124_mergeTokensConfirm = -1; /* MergeTokensConfirm */
static int hf_t124_purgeTokensIndication = -1; /* PurgeTokensIndication */
static int hf_t124_disconnectProviderUltimatum = -1; /* DisconnectProviderUltimatum */
static int hf_t124_rejectMCSPDUUltimatum = -1; /* RejectMCSPDUUltimatum */
static int hf_t124_attachUserRequest = -1; /* AttachUserRequest */
static int hf_t124_attachUserConfirm = -1; /* AttachUserConfirm */
static int hf_t124_detachUserRequest = -1; /* DetachUserRequest */
static int hf_t124_detachUserIndication = -1; /* DetachUserIndication */
static int hf_t124_channelJoinRequest = -1; /* ChannelJoinRequest */
static int hf_t124_channelJoinConfirm = -1; /* ChannelJoinConfirm */
static int hf_t124_channelLeaveRequest = -1; /* ChannelLeaveRequest */
static int hf_t124_channelConveneRequest = -1; /* ChannelConveneRequest */
static int hf_t124_channelConveneConfirm = -1; /* ChannelConveneConfirm */
static int hf_t124_channelDisbandRequest = -1; /* ChannelDisbandRequest */
static int hf_t124_channelDisbandIndication = -1; /* ChannelDisbandIndication */
static int hf_t124_channelAdmitRequest = -1; /* ChannelAdmitRequest */
static int hf_t124_channelAdmitIndication = -1; /* ChannelAdmitIndication */
static int hf_t124_channelExpelRequest = -1; /* ChannelExpelRequest */
static int hf_t124_channelExpelIndication = -1; /* ChannelExpelIndication */
static int hf_t124_sendDataRequest = -1; /* SendDataRequest */
static int hf_t124_sendDataIndication = -1; /* SendDataIndication */
static int hf_t124_uniformSendDataRequest = -1; /* UniformSendDataRequest */
static int hf_t124_uniformSendDataIndication = -1; /* UniformSendDataIndication */
static int hf_t124_tokenGrabRequest = -1; /* TokenGrabRequest */
static int hf_t124_tokenGrabConfirm = -1; /* TokenGrabConfirm */
static int hf_t124_tokenInhibitRequest = -1; /* TokenInhibitRequest */
static int hf_t124_tokenInhibitConfirm = -1; /* TokenInhibitConfirm */
static int hf_t124_tokenGiveRequest = -1; /* TokenGiveRequest */
static int hf_t124_tokenGiveIndication = -1; /* TokenGiveIndication */
static int hf_t124_tokenGiveResponse = -1; /* TokenGiveResponse */
static int hf_t124_tokenGiveConfirm = -1; /* TokenGiveConfirm */
static int hf_t124_tokenPleaseRequest = -1; /* TokenPleaseRequest */
static int hf_t124_tokenPleaseIndication = -1; /* TokenPleaseIndication */
static int hf_t124_tokenReleaseRequest = -1; /* TokenReleaseRequest */
static int hf_t124_tokenReleaseConfirm = -1; /* TokenReleaseConfirm */
static int hf_t124_tokenTestRequest = -1; /* TokenTestRequest */
static int hf_t124_tokenTestConfirm = -1; /* TokenTestConfirm */
/* named bits */
static int hf_t124_Segmentation_begin = -1;
static int hf_t124_Segmentation_end = -1;
/* Initialize the subtree pointers */
static int ett_t124 = -1;
static int ett_t124_connectGCCPDU = -1;
static int hf_t124_ConnectData = -1;
static int hf_t124_connectGCCPDU = -1;
static int hf_t124_DomainMCSPDU_PDU = -1;
static guint32 channelId = -1;
static dissector_table_t t124_ns_dissector_table=NULL;
static dissector_table_t t124_sd_dissector_table=NULL;
static gint ett_t124_Key = -1;
static gint ett_t124_NonStandardParameter = -1;
static gint ett_t124_UserData = -1;
static gint ett_t124_UserData_item = -1;
static gint ett_t124_Password = -1;
static gint ett_t124_PasswordSelector = -1;
static gint ett_t124_ChallengeResponseItem = -1;
static gint ett_t124_ChallengeResponseAlgorithm = -1;
static gint ett_t124_ChallengeItem = -1;
static gint ett_t124_ChallengeRequest = -1;
static gint ett_t124_SET_OF_ChallengeItem = -1;
static gint ett_t124_ChallengeResponse = -1;
static gint ett_t124_PasswordChallengeRequestResponse = -1;
static gint ett_t124_T_challengeRequestResponse = -1;
static gint ett_t124_ConferenceName = -1;
static gint ett_t124_ConferenceNameSelector = -1;
static gint ett_t124_ConferencePriorityScheme = -1;
static gint ett_t124_ConferencePriority = -1;
static gint ett_t124_NodeCategory = -1;
static gint ett_t124_ConferenceMode = -1;
static gint ett_t124_NetworkAddress = -1;
static gint ett_t124_NetworkAddress_item = -1;
static gint ett_t124_T_aggregatedChannel = -1;
static gint ett_t124_T_transferModes = -1;
static gint ett_t124_T_highLayerCompatibility = -1;
static gint ett_t124_T_transportConnection = -1;
static gint ett_t124_AsymmetryIndicator = -1;
static gint ett_t124_ConferenceDescriptor = -1;
static gint ett_t124_ConferenceCreateRequest = -1;
static gint ett_t124_SET_OF_Privilege = -1;
static gint ett_t124_ConferenceCreateResponse = -1;
static gint ett_t124_ConferenceQueryRequest = -1;
static gint ett_t124_ConferenceQueryResponse = -1;
static gint ett_t124_SET_OF_ConferenceDescriptor = -1;
static gint ett_t124_ConferenceJoinRequest = -1;
static gint ett_t124_ConferenceJoinResponse = -1;
static gint ett_t124_ConferenceInviteRequest = -1;
static gint ett_t124_ConferenceInviteResponse = -1;
static gint ett_t124_ConnectData = -1;
static gint ett_t124_ConnectGCCPDU = -1;
static gint ett_t124_Segmentation = -1;
static gint ett_t124_PlumbDomainIndication = -1;
static gint ett_t124_ErectDomainRequest = -1;
static gint ett_t124_ChannelAttributes = -1;
static gint ett_t124_T_static = -1;
static gint ett_t124_T_userId = -1;
static gint ett_t124_T_private = -1;
static gint ett_t124_SET_OF_UserId = -1;
static gint ett_t124_T_assigned = -1;
static gint ett_t124_MergeChannelsRequest = -1;
static gint ett_t124_SET_OF_ChannelAttributes = -1;
static gint ett_t124_SET_OF_ChannelId = -1;
static gint ett_t124_MergeChannelsConfirm = -1;
static gint ett_t124_PurgeChannelsIndication = -1;
static gint ett_t124_TokenAttributes = -1;
static gint ett_t124_T_grabbed = -1;
static gint ett_t124_T_inhibited = -1;
static gint ett_t124_T_giving = -1;
static gint ett_t124_T_ungivable = -1;
static gint ett_t124_T_given = -1;
static gint ett_t124_MergeTokensRequest = -1;
static gint ett_t124_SET_OF_TokenAttributes = -1;
static gint ett_t124_SET_OF_TokenId = -1;
static gint ett_t124_MergeTokensConfirm = -1;
static gint ett_t124_PurgeTokensIndication = -1;
static gint ett_t124_DisconnectProviderUltimatum = -1;
static gint ett_t124_RejectMCSPDUUltimatum = -1;
static gint ett_t124_AttachUserRequest = -1;
static gint ett_t124_AttachUserConfirm = -1;
static gint ett_t124_DetachUserRequest = -1;
static gint ett_t124_DetachUserIndication = -1;
static gint ett_t124_ChannelJoinRequest = -1;
static gint ett_t124_ChannelJoinConfirm = -1;
static gint ett_t124_ChannelLeaveRequest = -1;
static gint ett_t124_ChannelConveneRequest = -1;
static gint ett_t124_ChannelConveneConfirm = -1;
static gint ett_t124_ChannelDisbandRequest = -1;
static gint ett_t124_ChannelDisbandIndication = -1;
static gint ett_t124_ChannelAdmitRequest = -1;
static gint ett_t124_ChannelAdmitIndication = -1;
static gint ett_t124_ChannelExpelRequest = -1;
static gint ett_t124_ChannelExpelIndication = -1;
static gint ett_t124_SendDataRequest = -1;
static gint ett_t124_SendDataIndication = -1;
static gint ett_t124_UniformSendDataRequest = -1;
static gint ett_t124_UniformSendDataIndication = -1;
static gint ett_t124_TokenGrabRequest = -1;
static gint ett_t124_TokenGrabConfirm = -1;
static gint ett_t124_TokenInhibitRequest = -1;
static gint ett_t124_TokenInhibitConfirm = -1;
static gint ett_t124_TokenGiveRequest = -1;
static gint ett_t124_TokenGiveIndication = -1;
static gint ett_t124_TokenGiveResponse = -1;
static gint ett_t124_TokenGiveConfirm = -1;
static gint ett_t124_TokenPleaseRequest = -1;
static gint ett_t124_TokenPleaseIndication = -1;
static gint ett_t124_TokenReleaseRequest = -1;
static gint ett_t124_TokenReleaseConfirm = -1;
static gint ett_t124_TokenTestRequest = -1;
static gint ett_t124_TokenTestConfirm = -1;
static gint ett_t124_DomainMCSPDU = -1;
static int
dissect_t124_DynamicChannelID(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
1001U, 65535U, NULL, FALSE);
return offset;
}
static int
dissect_t124_UserID(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_t124_DynamicChannelID(tvb, offset, actx, tree, hf_index);
return offset;
}
static int
dissect_t124_H221NonStandardIdentifier(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_octet_string(tvb, offset, actx, tree, hf_index,
4, 255, FALSE, (tvbuff_t**)&actx->private_data);
return offset;
}
static int
dissect_t124_T_object(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_object_identifier_str(tvb, offset, actx, tree, hf_index, &actx->external.direct_reference);
return offset;
}
static const value_string t124_Key_vals[] = {
{ 0, "object" },
{ 1, "h221NonStandard" },
{ 0, NULL }
};
static const per_choice_t Key_choice[] = {
{ 0, &hf_t124_object , ASN1_NO_EXTENSIONS , dissect_t124_T_object },
{ 1, &hf_t124_h221NonStandard, ASN1_NO_EXTENSIONS , dissect_t124_H221NonStandardIdentifier },
{ 0, NULL, 0, NULL }
};
static int
dissect_t124_Key(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_t124_Key, Key_choice,
NULL);
return offset;
}
static int
dissect_t124_OCTET_STRING(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_octet_string(tvb, offset, actx, tree, hf_index,
NO_BOUND, NO_BOUND, FALSE, NULL);
return offset;
}
static const per_sequence_t NonStandardParameter_sequence[] = {
{ &hf_t124_key , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Key },
{ &hf_t124_data , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_OCTET_STRING },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_NonStandardParameter(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_NonStandardParameter, NonStandardParameter_sequence);
return offset;
}
static int
dissect_t124_TextString(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_BMPString(tvb, offset, actx, tree, hf_index,
0, 255, FALSE);
return offset;
}
static int
dissect_t124_SimpleTextString(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_BMPString(tvb, offset, actx, tree, hf_index,
0, 255, FALSE);
return offset;
}
static int
dissect_t124_SimpleNumericString(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_restricted_character_string(tvb, offset, actx, tree, hf_index,
1, 255, FALSE, "0123456789", 10,
NULL);
return offset;
}
static int
dissect_t124_DiallingString(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_restricted_character_string(tvb, offset, actx, tree, hf_index,
1, 16, FALSE, "0123456789", 10,
NULL);
return offset;
}
static int
dissect_t124_SubAddressString(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_restricted_character_string(tvb, offset, actx, tree, hf_index,
1, 40, FALSE, "0123456789", 10,
NULL);
return offset;
}
static int
dissect_t124_ExtraDiallingString(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_size_constrained_type(tvb, offset, actx, tree, hf_index, dissect_t124_TextString,
"TextString", 1, 255, FALSE);
return offset;
}
static int
dissect_t124_T_value(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
tvbuff_t *next_tvb = NULL;
tvbuff_t *t124NSIdentifier = (tvbuff_t*)actx->private_data;
guint8 *ns = NULL;
offset = dissect_per_octet_string(tvb, offset, actx, tree, hf_index,
NO_BOUND, NO_BOUND, FALSE, &next_tvb);
if(next_tvb && t124NSIdentifier) {
ns = tvb_get_string_enc(actx->pinfo->pool, t124NSIdentifier, 0, tvb_reported_length(t124NSIdentifier), ENC_ASCII|ENC_NA);
if(ns != NULL) {
dissector_try_string_new(t124_ns_dissector_table, ns, next_tvb, actx->pinfo, top_tree, FALSE, NULL);
}
}
return offset;
}
static const per_sequence_t UserData_item_sequence[] = {
{ &hf_t124_key , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Key },
{ &hf_t124_value , ASN1_NO_EXTENSIONS , ASN1_OPTIONAL , dissect_t124_T_value },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_UserData_item(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_UserData_item, UserData_item_sequence);
return offset;
}
static const per_sequence_t UserData_set_of[1] = {
{ &hf_t124_UserData_item , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserData_item },
};
static int
dissect_t124_UserData(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_set_of(tvb, offset, actx, tree, hf_index,
ett_t124_UserData, UserData_set_of);
return offset;
}
static const per_sequence_t Password_sequence[] = {
{ &hf_t124_numeric , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_SimpleNumericString },
{ &hf_t124_text , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_SimpleTextString },
{ &hf_t124_unicodeText , ASN1_NOT_EXTENSION_ROOT, ASN1_OPTIONAL , dissect_t124_TextString },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_Password(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_Password, Password_sequence);
return offset;
}
static const value_string t124_PasswordSelector_vals[] = {
{ 0, "numeric" },
{ 1, "text" },
{ 2, "unicodeText" },
{ 0, NULL }
};
static const per_choice_t PasswordSelector_choice[] = {
{ 0, &hf_t124_numeric , ASN1_EXTENSION_ROOT , dissect_t124_SimpleNumericString },
{ 1, &hf_t124_text , ASN1_EXTENSION_ROOT , dissect_t124_SimpleTextString },
{ 2, &hf_t124_unicodeText , ASN1_NOT_EXTENSION_ROOT, dissect_t124_TextString },
{ 0, NULL, 0, NULL }
};
static int
dissect_t124_PasswordSelector(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_t124_PasswordSelector, PasswordSelector_choice,
NULL);
return offset;
}
static const value_string t124_ChallengeResponseItem_vals[] = {
{ 0, "passwordString" },
{ 1, "responseData" },
{ 0, NULL }
};
static const per_choice_t ChallengeResponseItem_choice[] = {
{ 0, &hf_t124_passwordString , ASN1_EXTENSION_ROOT , dissect_t124_PasswordSelector },
{ 1, &hf_t124_responseData , ASN1_EXTENSION_ROOT , dissect_t124_UserData },
{ 0, NULL, 0, NULL }
};
static int
dissect_t124_ChallengeResponseItem(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_t124_ChallengeResponseItem, ChallengeResponseItem_choice,
NULL);
return offset;
}
static int
dissect_t124_NULL(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_null(tvb, offset, actx, tree, hf_index);
return offset;
}
static const value_string t124_ChallengeResponseAlgorithm_vals[] = {
{ 0, "passwordInTheClear" },
{ 1, "nonStandardAlgorithm" },
{ 0, NULL }
};
static const per_choice_t ChallengeResponseAlgorithm_choice[] = {
{ 0, &hf_t124_passwordInTheClear, ASN1_EXTENSION_ROOT , dissect_t124_NULL },
{ 1, &hf_t124_nonStandardAlgorithm, ASN1_EXTENSION_ROOT , dissect_t124_NonStandardParameter },
{ 0, NULL, 0, NULL }
};
static int
dissect_t124_ChallengeResponseAlgorithm(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_t124_ChallengeResponseAlgorithm, ChallengeResponseAlgorithm_choice,
NULL);
return offset;
}
static const per_sequence_t ChallengeItem_sequence[] = {
{ &hf_t124_responseAlgorithm, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_ChallengeResponseAlgorithm },
{ &hf_t124_challengeData , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_UserData },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ChallengeItem(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ChallengeItem, ChallengeItem_sequence);
return offset;
}
static int
dissect_t124_INTEGER(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_integer(tvb, offset, actx, tree, hf_index, NULL);
return offset;
}
static const per_sequence_t SET_OF_ChallengeItem_set_of[1] = {
{ &hf_t124_challengeSet_item, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_ChallengeItem },
};
static int
dissect_t124_SET_OF_ChallengeItem(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_set_of(tvb, offset, actx, tree, hf_index,
ett_t124_SET_OF_ChallengeItem, SET_OF_ChallengeItem_set_of);
return offset;
}
static const per_sequence_t ChallengeRequest_sequence[] = {
{ &hf_t124_challengeTag , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_INTEGER },
{ &hf_t124_challengeSet , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_ChallengeItem },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ChallengeRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ChallengeRequest, ChallengeRequest_sequence);
return offset;
}
static const per_sequence_t ChallengeResponse_sequence[] = {
{ &hf_t124_challengeTag , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_INTEGER },
{ &hf_t124_responseAlgorithm, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_ChallengeResponseAlgorithm },
{ &hf_t124_responseItem , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_ChallengeResponseItem },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ChallengeResponse(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ChallengeResponse, ChallengeResponse_sequence);
return offset;
}
static const per_sequence_t T_challengeRequestResponse_sequence[] = {
{ &hf_t124_challengeRequest, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_ChallengeRequest },
{ &hf_t124_challengeResponse, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_ChallengeResponse },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_T_challengeRequestResponse(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_T_challengeRequestResponse, T_challengeRequestResponse_sequence);
return offset;
}
static const value_string t124_PasswordChallengeRequestResponse_vals[] = {
{ 0, "passwordInTheClear" },
{ 1, "challengeRequestResponse" },
{ 0, NULL }
};
static const per_choice_t PasswordChallengeRequestResponse_choice[] = {
{ 0, &hf_t124_passwordInTheClear_01, ASN1_EXTENSION_ROOT , dissect_t124_PasswordSelector },
{ 1, &hf_t124_challengeRequestResponse, ASN1_EXTENSION_ROOT , dissect_t124_T_challengeRequestResponse },
{ 0, NULL, 0, NULL }
};
static int
dissect_t124_PasswordChallengeRequestResponse(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_t124_PasswordChallengeRequestResponse, PasswordChallengeRequestResponse_choice,
NULL);
return offset;
}
static const per_sequence_t ConferenceName_sequence[] = {
{ &hf_t124_numeric , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_SimpleNumericString },
{ &hf_t124_text , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_SimpleTextString },
{ &hf_t124_unicodeText , ASN1_NOT_EXTENSION_ROOT, ASN1_OPTIONAL , dissect_t124_TextString },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ConferenceName(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ConferenceName, ConferenceName_sequence);
return offset;
}
static const value_string t124_ConferenceNameSelector_vals[] = {
{ 0, "numeric" },
{ 1, "text" },
{ 2, "unicodeText" },
{ 0, NULL }
};
static const per_choice_t ConferenceNameSelector_choice[] = {
{ 0, &hf_t124_numeric , ASN1_EXTENSION_ROOT , dissect_t124_SimpleNumericString },
{ 1, &hf_t124_text , ASN1_EXTENSION_ROOT , dissect_t124_SimpleTextString },
{ 2, &hf_t124_unicodeText , ASN1_NOT_EXTENSION_ROOT, dissect_t124_TextString },
{ 0, NULL, 0, NULL }
};
static int
dissect_t124_ConferenceNameSelector(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_t124_ConferenceNameSelector, ConferenceNameSelector_choice,
NULL);
return offset;
}
static int
dissect_t124_ConferenceNameModifier(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_t124_SimpleNumericString(tvb, offset, actx, tree, hf_index);
return offset;
}
static const value_string t124_Privilege_vals[] = {
{ 0, "terminate" },
{ 1, "ejectUser" },
{ 2, "add" },
{ 3, "lockUnlock" },
{ 4, "transfer" },
{ 0, NULL }
};
static int
dissect_t124_Privilege(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
5, NULL, TRUE, 0, NULL);
return offset;
}
static const value_string t124_TerminationMethod_vals[] = {
{ 0, "automatic" },
{ 1, "manual" },
{ 0, NULL }
};
static int
dissect_t124_TerminationMethod(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
2, NULL, TRUE, 0, NULL);
return offset;
}
static const value_string t124_ConferencePriorityScheme_vals[] = {
{ 0, "nonStandardScheme" },
{ 0, NULL }
};
static const per_choice_t ConferencePriorityScheme_choice[] = {
{ 0, &hf_t124_nonStandardScheme, ASN1_EXTENSION_ROOT , dissect_t124_NonStandardParameter },
{ 0, NULL, 0, NULL }
};
static int
dissect_t124_ConferencePriorityScheme(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_t124_ConferencePriorityScheme, ConferencePriorityScheme_choice,
NULL);
return offset;
}
static int
dissect_t124_INTEGER_0_65535(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
0U, 65535U, NULL, FALSE);
return offset;
}
static const per_sequence_t ConferencePriority_sequence[] = {
{ &hf_t124_priority , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_INTEGER_0_65535 },
{ &hf_t124_scheme , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_ConferencePriorityScheme },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ConferencePriority(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ConferencePriority, ConferencePriority_sequence);
return offset;
}
static const value_string t124_NodeCategory_vals[] = {
{ 0, "conventional" },
{ 1, "counted" },
{ 2, "anonymous" },
{ 3, "nonStandardCategory" },
{ 0, NULL }
};
static const per_choice_t NodeCategory_choice[] = {
{ 0, &hf_t124_conventional , ASN1_EXTENSION_ROOT , dissect_t124_NULL },
{ 1, &hf_t124_counted , ASN1_EXTENSION_ROOT , dissect_t124_NULL },
{ 2, &hf_t124_anonymous , ASN1_EXTENSION_ROOT , dissect_t124_NULL },
{ 3, &hf_t124_nonStandardCategory, ASN1_EXTENSION_ROOT , dissect_t124_NonStandardParameter },
{ 0, NULL, 0, NULL }
};
static int
dissect_t124_NodeCategory(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_t124_NodeCategory, NodeCategory_choice,
NULL);
return offset;
}
static const value_string t124_ConferenceMode_vals[] = {
{ 0, "conventional-only" },
{ 1, "counted-only" },
{ 2, "anonymous-only" },
{ 3, "conventional-control" },
{ 4, "unrestricted-mode" },
{ 5, "non-standard-mode" },
{ 0, NULL }
};
static const per_choice_t ConferenceMode_choice[] = {
{ 0, &hf_t124_conventional_only, ASN1_EXTENSION_ROOT , dissect_t124_NULL },
{ 1, &hf_t124_counted_only , ASN1_EXTENSION_ROOT , dissect_t124_NULL },
{ 2, &hf_t124_anonymous_only , ASN1_EXTENSION_ROOT , dissect_t124_NULL },
{ 3, &hf_t124_conventional_control, ASN1_EXTENSION_ROOT , dissect_t124_NULL },
{ 4, &hf_t124_unrestricted_mode, ASN1_EXTENSION_ROOT , dissect_t124_NULL },
{ 5, &hf_t124_non_standard_mode, ASN1_EXTENSION_ROOT , dissect_t124_NonStandardParameter },
{ 0, NULL, 0, NULL }
};
static int
dissect_t124_ConferenceMode(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_t124_ConferenceMode, ConferenceMode_choice,
NULL);
return offset;
}
static int
dissect_t124_BOOLEAN(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_boolean(tvb, offset, actx, tree, hf_index, NULL);
return offset;
}
static const per_sequence_t T_transferModes_sequence[] = {
{ &hf_t124_speech , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_voice_band , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_digital_56k , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_digital_64k , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_digital_128k , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_digital_192k , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_digital_256k , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_digital_320k , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_digital_384k , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_digital_512k , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_digital_768k , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_digital_1152k , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_digital_1472k , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_digital_1536k , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_digital_1920k , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_packet_mode , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_frame_mode , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_atm , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_T_transferModes(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_T_transferModes, T_transferModes_sequence);
return offset;
}
static const per_sequence_t T_highLayerCompatibility_sequence[] = {
{ &hf_t124_telephony3kHz , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_telephony7kHz , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_videotelephony , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_videoconference, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_audiographic , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_audiovisual , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_multimedia , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_T_highLayerCompatibility(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_T_highLayerCompatibility, T_highLayerCompatibility_sequence);
return offset;
}
static const per_sequence_t T_aggregatedChannel_sequence[] = {
{ &hf_t124_transferModes , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_T_transferModes },
{ &hf_t124_internationalNumber, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_DiallingString },
{ &hf_t124_subAddress , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_SubAddressString },
{ &hf_t124_extraDialling , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_ExtraDiallingString },
{ &hf_t124_highLayerCompatibility, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_T_highLayerCompatibility },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_T_aggregatedChannel(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_T_aggregatedChannel, T_aggregatedChannel_sequence);
return offset;
}
static int
dissect_t124_OCTET_STRING_SIZE_1_20(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_octet_string(tvb, offset, actx, tree, hf_index,
1, 20, FALSE, NULL);
return offset;
}
static const per_sequence_t T_transportConnection_sequence[] = {
{ &hf_t124_nsapAddress , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_OCTET_STRING_SIZE_1_20 },
{ &hf_t124_transportSelector, ASN1_NO_EXTENSIONS , ASN1_OPTIONAL , dissect_t124_OCTET_STRING },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_T_transportConnection(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_T_transportConnection, T_transportConnection_sequence);
return offset;
}
static const value_string t124_NetworkAddress_item_vals[] = {
{ 0, "aggregatedChannel" },
{ 1, "transportConnection" },
{ 2, "nonStandard" },
{ 0, NULL }
};
static const per_choice_t NetworkAddress_item_choice[] = {
{ 0, &hf_t124_aggregatedChannel, ASN1_EXTENSION_ROOT , dissect_t124_T_aggregatedChannel },
{ 1, &hf_t124_transportConnection, ASN1_EXTENSION_ROOT , dissect_t124_T_transportConnection },
{ 2, &hf_t124_nonStandard , ASN1_EXTENSION_ROOT , dissect_t124_NonStandardParameter },
{ 0, NULL, 0, NULL }
};
static int
dissect_t124_NetworkAddress_item(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_t124_NetworkAddress_item, NetworkAddress_item_choice,
NULL);
return offset;
}
static const per_sequence_t NetworkAddress_sequence_of[1] = {
{ &hf_t124_NetworkAddress_item, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_NetworkAddress_item },
};
static int
dissect_t124_NetworkAddress(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_constrained_sequence_of(tvb, offset, actx, tree, hf_index,
ett_t124_NetworkAddress, NetworkAddress_sequence_of,
1, 64, FALSE);
return offset;
}
static const value_string t124_NodeType_vals[] = {
{ 0, "terminal" },
{ 1, "multiportTerminal" },
{ 2, "mcu" },
{ 0, NULL }
};
static int
dissect_t124_NodeType(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
3, NULL, TRUE, 0, NULL);
return offset;
}
static int
dissect_t124_INTEGER_0_4294967295(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
0U, 4294967295U, NULL, FALSE);
return offset;
}
static const value_string t124_AsymmetryIndicator_vals[] = {
{ 0, "callingNode" },
{ 1, "calledNode" },
{ 2, "unknown" },
{ 0, NULL }
};
static const per_choice_t AsymmetryIndicator_choice[] = {
{ 0, &hf_t124_callingNode , ASN1_NO_EXTENSIONS , dissect_t124_NULL },
{ 1, &hf_t124_calledNode , ASN1_NO_EXTENSIONS , dissect_t124_NULL },
{ 2, &hf_t124_unknown , ASN1_NO_EXTENSIONS , dissect_t124_INTEGER_0_4294967295 },
{ 0, NULL, 0, NULL }
};
static int
dissect_t124_AsymmetryIndicator(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_t124_AsymmetryIndicator, AsymmetryIndicator_choice,
NULL);
return offset;
}
static const per_sequence_t ConferenceDescriptor_sequence[] = {
{ &hf_t124_conferenceName , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_ConferenceName },
{ &hf_t124_conferenceNameModifier, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_ConferenceNameModifier },
{ &hf_t124_conferenceDescription, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_TextString },
{ &hf_t124_lockedConference, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_passwordInTheClearRequired, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_networkAddress , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_NetworkAddress },
{ &hf_t124_defaultConferenceFlag, ASN1_NOT_EXTENSION_ROOT, ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_conferenceMode , ASN1_NOT_EXTENSION_ROOT, ASN1_NOT_OPTIONAL, dissect_t124_ConferenceMode },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ConferenceDescriptor(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ConferenceDescriptor, ConferenceDescriptor_sequence);
return offset;
}
static const per_sequence_t SET_OF_Privilege_set_of[1] = {
{ &hf_t124_conductorPrivileges_item, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Privilege },
};
static int
dissect_t124_SET_OF_Privilege(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_set_of(tvb, offset, actx, tree, hf_index,
ett_t124_SET_OF_Privilege, SET_OF_Privilege_set_of);
return offset;
}
static const per_sequence_t ConferenceCreateRequest_sequence[] = {
{ &hf_t124_conferenceName , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_ConferenceName },
{ &hf_t124_convenerPassword, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_Password },
{ &hf_t124_password , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_Password },
{ &hf_t124_lockedConference, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_listedConference, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_conductibleConference, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_terminationMethod, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_TerminationMethod },
{ &hf_t124_conductorPrivileges, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_SET_OF_Privilege },
{ &hf_t124_conductedPrivileges, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_SET_OF_Privilege },
{ &hf_t124_nonConductedPrivileges, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_SET_OF_Privilege },
{ &hf_t124_conferenceDescription, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_TextString },
{ &hf_t124_callerIdentifier, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_TextString },
{ &hf_t124_userData , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_UserData },
{ &hf_t124_conferencePriority, ASN1_NOT_EXTENSION_ROOT, ASN1_OPTIONAL , dissect_t124_ConferencePriority },
{ &hf_t124_conferenceMode , ASN1_NOT_EXTENSION_ROOT, ASN1_OPTIONAL , dissect_t124_ConferenceMode },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ConferenceCreateRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ConferenceCreateRequest, ConferenceCreateRequest_sequence);
return offset;
}
static const value_string t124_T_result_vals[] = {
{ 0, "success" },
{ 1, "userRejected" },
{ 2, "resourcesNotAvailable" },
{ 3, "rejectedForSymmetryBreaking" },
{ 4, "lockedConferenceNotSupported" },
{ 0, NULL }
};
static int
dissect_t124_T_result(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
5, NULL, TRUE, 0, NULL);
return offset;
}
static const per_sequence_t ConferenceCreateResponse_sequence[] = {
{ &hf_t124_nodeID , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_UserID },
{ &hf_t124_tag , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_INTEGER },
{ &hf_t124_result , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_T_result },
{ &hf_t124_userData , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_UserData },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ConferenceCreateResponse(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ConferenceCreateResponse, ConferenceCreateResponse_sequence);
return offset;
}
static const per_sequence_t ConferenceQueryRequest_sequence[] = {
{ &hf_t124_nodeType , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_NodeType },
{ &hf_t124_asymmetryIndicator, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_AsymmetryIndicator },
{ &hf_t124_userData , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_UserData },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ConferenceQueryRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ConferenceQueryRequest, ConferenceQueryRequest_sequence);
return offset;
}
static const per_sequence_t SET_OF_ConferenceDescriptor_set_of[1] = {
{ &hf_t124_conferenceList_item, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_ConferenceDescriptor },
};
static int
dissect_t124_SET_OF_ConferenceDescriptor(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_set_of(tvb, offset, actx, tree, hf_index,
ett_t124_SET_OF_ConferenceDescriptor, SET_OF_ConferenceDescriptor_set_of);
return offset;
}
static const value_string t124_QueryResponseResult_vals[] = {
{ 0, "success" },
{ 1, "userRejected" },
{ 0, NULL }
};
static int
dissect_t124_QueryResponseResult(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
2, NULL, TRUE, 0, NULL);
return offset;
}
static const per_sequence_t ConferenceQueryResponse_sequence[] = {
{ &hf_t124_nodeType , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_NodeType },
{ &hf_t124_asymmetryIndicator, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_AsymmetryIndicator },
{ &hf_t124_conferenceList , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_ConferenceDescriptor },
{ &hf_t124_queryResponseResult, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_QueryResponseResult },
{ &hf_t124_userData , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_UserData },
{ &hf_t124_waitForInvitationFlag, ASN1_NOT_EXTENSION_ROOT, ASN1_OPTIONAL , dissect_t124_BOOLEAN },
{ &hf_t124_noUnlistedConferenceFlag, ASN1_NOT_EXTENSION_ROOT, ASN1_OPTIONAL , dissect_t124_BOOLEAN },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ConferenceQueryResponse(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ConferenceQueryResponse, ConferenceQueryResponse_sequence);
return offset;
}
static const per_sequence_t ConferenceJoinRequest_sequence[] = {
{ &hf_t124_conferenceName_01, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_ConferenceNameSelector },
{ &hf_t124_conferenceNameModifier, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_ConferenceNameModifier },
{ &hf_t124_tag , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_INTEGER },
{ &hf_t124_password_01 , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_PasswordChallengeRequestResponse },
{ &hf_t124_convenerPassword_01, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_PasswordSelector },
{ &hf_t124_callerIdentifier, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_TextString },
{ &hf_t124_userData , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_UserData },
{ &hf_t124_nodeCategory , ASN1_NOT_EXTENSION_ROOT, ASN1_OPTIONAL , dissect_t124_NodeCategory },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ConferenceJoinRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ConferenceJoinRequest, ConferenceJoinRequest_sequence);
return offset;
}
static const value_string t124_JoinResponseResult_vals[] = {
{ 0, "success" },
{ 1, "userRejected" },
{ 2, "invalidConference" },
{ 3, "invalidPassword" },
{ 4, "invalidConvenerPassword" },
{ 5, "challengeResponseRequired" },
{ 6, "invalidChallengeResponse" },
{ 0, NULL }
};
static int
dissect_t124_JoinResponseResult(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
7, NULL, TRUE, 0, NULL);
return offset;
}
static const per_sequence_t ConferenceJoinResponse_sequence[] = {
{ &hf_t124_nodeID , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_UserID },
{ &hf_t124_topNodeID , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_UserID },
{ &hf_t124_tag , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_INTEGER },
{ &hf_t124_conferenceNameAlias, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_ConferenceNameSelector },
{ &hf_t124_passwordInTheClearRequired, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_lockedConference, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_listedConference, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_conductibleConference, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_terminationMethod, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_TerminationMethod },
{ &hf_t124_conductorPrivileges, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_SET_OF_Privilege },
{ &hf_t124_conductedPrivileges, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_SET_OF_Privilege },
{ &hf_t124_nonConductedPrivileges, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_SET_OF_Privilege },
{ &hf_t124_conferenceDescription, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_TextString },
{ &hf_t124_password_01 , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_PasswordChallengeRequestResponse },
{ &hf_t124_joinResponseResult, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_JoinResponseResult },
{ &hf_t124_userData , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_UserData },
{ &hf_t124_nodeCategory , ASN1_NOT_EXTENSION_ROOT, ASN1_OPTIONAL , dissect_t124_NodeCategory },
{ &hf_t124_conferenceMode , ASN1_NOT_EXTENSION_ROOT, ASN1_OPTIONAL , dissect_t124_ConferenceMode },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ConferenceJoinResponse(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ConferenceJoinResponse, ConferenceJoinResponse_sequence);
return offset;
}
static const per_sequence_t ConferenceInviteRequest_sequence[] = {
{ &hf_t124_conferenceName , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_ConferenceName },
{ &hf_t124_nodeID , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_UserID },
{ &hf_t124_topNodeID , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_UserID },
{ &hf_t124_tag , ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_INTEGER },
{ &hf_t124_passwordInTheClearRequired, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_lockedConference, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_listedConference, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_conductibleConference, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_terminationMethod, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_TerminationMethod },
{ &hf_t124_conductorPrivileges, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_SET_OF_Privilege },
{ &hf_t124_conductedPrivileges, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_SET_OF_Privilege },
{ &hf_t124_nonConductedPrivileges, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_SET_OF_Privilege },
{ &hf_t124_conferenceDescription, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_TextString },
{ &hf_t124_callerIdentifier, ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_TextString },
{ &hf_t124_userData , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_UserData },
{ &hf_t124_conferencePriority, ASN1_NOT_EXTENSION_ROOT, ASN1_OPTIONAL , dissect_t124_ConferencePriority },
{ &hf_t124_nodeCategory , ASN1_NOT_EXTENSION_ROOT, ASN1_OPTIONAL , dissect_t124_NodeCategory },
{ &hf_t124_conferenceMode , ASN1_NOT_EXTENSION_ROOT, ASN1_OPTIONAL , dissect_t124_ConferenceMode },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ConferenceInviteRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ConferenceInviteRequest, ConferenceInviteRequest_sequence);
return offset;
}
static const value_string t124_InviteResponseResult_vals[] = {
{ 0, "success" },
{ 1, "userRejected" },
{ 0, NULL }
};
static int
dissect_t124_InviteResponseResult(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
2, NULL, TRUE, 0, NULL);
return offset;
}
static const per_sequence_t ConferenceInviteResponse_sequence[] = {
{ &hf_t124_inviteResponseResult, ASN1_EXTENSION_ROOT , ASN1_NOT_OPTIONAL, dissect_t124_InviteResponseResult },
{ &hf_t124_userData , ASN1_EXTENSION_ROOT , ASN1_OPTIONAL , dissect_t124_UserData },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ConferenceInviteResponse(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ConferenceInviteResponse, ConferenceInviteResponse_sequence);
return offset;
}
static int
dissect_t124_T_connectPDU(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
tvbuff_t *next_tvb = NULL;
proto_tree *next_tree = NULL;
int old_offset = 0;
old_offset = offset;
offset = dissect_per_octet_string(tvb, offset, actx, tree, hf_index,
NO_BOUND, NO_BOUND, FALSE, &next_tvb);
if(next_tvb) {
/* "2a -> ConnectData::connectPDU length = 42 bytes */
/* This length MUST be ignored by the client." */
/* Not sure why - but lets ignore the length. */
/* We assume the OCTET STRING is all of the remaining bytes */
if(tvb_reported_length(next_tvb) == 42) {
/* this is perhaps a naive ... */
next_tvb = tvb_new_subset_remaining(tvb, (old_offset>>3)+1);
}
next_tree = proto_item_add_subtree(actx->created_item, ett_t124_connectGCCPDU);
dissect_t124_ConnectGCCPDU(next_tvb, 0, actx, next_tree, hf_t124_connectGCCPDU);
}
return offset;
}
static const per_sequence_t ConnectData_sequence[] = {
{ &hf_t124_t124Identifier , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Key },
{ &hf_t124_connectPDU , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_T_connectPDU },
{ NULL, 0, 0, NULL }
};
int
dissect_t124_ConnectData(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ConnectData, ConnectData_sequence);
return offset;
}
const value_string t124_ConnectGCCPDU_vals[] = {
{ 0, "conferenceCreateRequest" },
{ 1, "conferenceCreateResponse" },
{ 2, "conferenceQueryRequest" },
{ 3, "conferenceQueryResponse" },
{ 4, "conferenceJoinRequest" },
{ 5, "conferenceJoinResponse" },
{ 6, "conferenceInviteRequest" },
{ 7, "conferenceInviteResponse" },
{ 0, NULL }
};
static const per_choice_t ConnectGCCPDU_choice[] = {
{ 0, &hf_t124_conferenceCreateRequest, ASN1_EXTENSION_ROOT , dissect_t124_ConferenceCreateRequest },
{ 1, &hf_t124_conferenceCreateResponse, ASN1_EXTENSION_ROOT , dissect_t124_ConferenceCreateResponse },
{ 2, &hf_t124_conferenceQueryRequest, ASN1_EXTENSION_ROOT , dissect_t124_ConferenceQueryRequest },
{ 3, &hf_t124_conferenceQueryResponse, ASN1_EXTENSION_ROOT , dissect_t124_ConferenceQueryResponse },
{ 4, &hf_t124_conferenceJoinRequest, ASN1_EXTENSION_ROOT , dissect_t124_ConferenceJoinRequest },
{ 5, &hf_t124_conferenceJoinResponse, ASN1_EXTENSION_ROOT , dissect_t124_ConferenceJoinResponse },
{ 6, &hf_t124_conferenceInviteRequest, ASN1_EXTENSION_ROOT , dissect_t124_ConferenceInviteRequest },
{ 7, &hf_t124_conferenceInviteResponse, ASN1_EXTENSION_ROOT , dissect_t124_ConferenceInviteResponse },
{ 0, NULL, 0, NULL }
};
int
dissect_t124_ConnectGCCPDU(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_t124_ConnectGCCPDU, ConnectGCCPDU_choice,
NULL);
return offset;
}
static int
dissect_t124_ChannelId(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
0U, 65535U, &channelId, FALSE);
if(hf_index == hf_t124_channelId_03)
col_append_fstr(actx->pinfo->cinfo, COL_INFO, "%d", channelId);
return offset;
}
static int
dissect_t124_StaticChannelId(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_t124_ChannelId(tvb, offset, actx, tree, hf_index);
return offset;
}
static int
dissect_t124_DynamicChannelId(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_t124_ChannelId(tvb, offset, actx, tree, hf_index);
return offset;
}
static int
dissect_t124_UserId(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_t124_DynamicChannelId(tvb, offset, actx, tree, hf_index);
return offset;
}
static int
dissect_t124_PrivateChannelId(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_t124_DynamicChannelId(tvb, offset, actx, tree, hf_index);
return offset;
}
static int
dissect_t124_AssignedChannelId(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_t124_DynamicChannelId(tvb, offset, actx, tree, hf_index);
return offset;
}
static int
dissect_t124_TokenId(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
1U, 65535U, NULL, FALSE);
return offset;
}
static const value_string t124_TokenStatus_vals[] = {
{ 0, "notInUse" },
{ 1, "selfGrabbed" },
{ 2, "otherGrabbed" },
{ 3, "selfInhibited" },
{ 4, "otherInhibited" },
{ 5, "selfRecipient" },
{ 6, "selfGiving" },
{ 7, "otherGiving" },
{ 0, NULL }
};
static int
dissect_t124_TokenStatus(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
8, NULL, FALSE, 0, NULL);
return offset;
}
static const value_string t124_DataPriority_vals[] = {
{ 0, "top" },
{ 1, "high" },
{ 2, "medium" },
{ 3, "low" },
{ 0, NULL }
};
static int
dissect_t124_DataPriority(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
4, NULL, FALSE, 0, NULL);
return offset;
}
static int * const Segmentation_bits[] = {
&hf_t124_Segmentation_begin,
&hf_t124_Segmentation_end,
NULL
};
static int
dissect_t124_Segmentation(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_bit_string(tvb, offset, actx, tree, hf_index,
2, 2, FALSE, Segmentation_bits, 2, NULL, NULL);
return offset;
}
static int
dissect_t124_INTEGER_0_MAX(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_constrained_integer_64b(tvb, offset, actx, tree, hf_index,
0U, NO_BOUND, NULL, FALSE);
return offset;
}
static const per_sequence_t PlumbDomainIndication_sequence[] = {
{ &hf_t124_heightLimit , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_INTEGER_0_MAX },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_PlumbDomainIndication(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_PlumbDomainIndication, PlumbDomainIndication_sequence);
return offset;
}
static const per_sequence_t ErectDomainRequest_sequence[] = {
{ &hf_t124_subHeight , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_INTEGER_0_MAX },
{ &hf_t124_subInterval , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_INTEGER_0_MAX },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ErectDomainRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ErectDomainRequest, ErectDomainRequest_sequence);
return offset;
}
static const per_sequence_t T_static_sequence[] = {
{ &hf_t124_channelId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_StaticChannelId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_T_static(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_T_static, T_static_sequence);
return offset;
}
static const per_sequence_t T_userId_sequence[] = {
{ &hf_t124_joined , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_userId_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_T_userId(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_T_userId, T_userId_sequence);
return offset;
}
static const per_sequence_t SET_OF_UserId_set_of[1] = {
{ &hf_t124_admitted_item , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
};
static int
dissect_t124_SET_OF_UserId(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_set_of(tvb, offset, actx, tree, hf_index,
ett_t124_SET_OF_UserId, SET_OF_UserId_set_of);
return offset;
}
static const per_sequence_t T_private_sequence[] = {
{ &hf_t124_joined , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_BOOLEAN },
{ &hf_t124_channelId_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_PrivateChannelId },
{ &hf_t124_manager , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_admitted , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_T_private(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_T_private, T_private_sequence);
return offset;
}
static const per_sequence_t T_assigned_sequence[] = {
{ &hf_t124_channelId_02 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_AssignedChannelId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_T_assigned(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_T_assigned, T_assigned_sequence);
return offset;
}
static const value_string t124_ChannelAttributes_vals[] = {
{ 0, "static" },
{ 1, "userId" },
{ 2, "private" },
{ 3, "assigned" },
{ 0, NULL }
};
static const per_choice_t ChannelAttributes_choice[] = {
{ 0, &hf_t124_static , ASN1_NO_EXTENSIONS , dissect_t124_T_static },
{ 1, &hf_t124_userId , ASN1_NO_EXTENSIONS , dissect_t124_T_userId },
{ 2, &hf_t124_private , ASN1_NO_EXTENSIONS , dissect_t124_T_private },
{ 3, &hf_t124_assigned , ASN1_NO_EXTENSIONS , dissect_t124_T_assigned },
{ 0, NULL, 0, NULL }
};
static int
dissect_t124_ChannelAttributes(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_t124_ChannelAttributes, ChannelAttributes_choice,
NULL);
return offset;
}
static const per_sequence_t SET_OF_ChannelAttributes_set_of[1] = {
{ &hf_t124_mergeChannels_item, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_ChannelAttributes },
};
static int
dissect_t124_SET_OF_ChannelAttributes(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_set_of(tvb, offset, actx, tree, hf_index,
ett_t124_SET_OF_ChannelAttributes, SET_OF_ChannelAttributes_set_of);
return offset;
}
static const per_sequence_t SET_OF_ChannelId_set_of[1] = {
{ &hf_t124_purgeChannelIds_item, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_ChannelId },
};
static int
dissect_t124_SET_OF_ChannelId(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_set_of(tvb, offset, actx, tree, hf_index,
ett_t124_SET_OF_ChannelId, SET_OF_ChannelId_set_of);
return offset;
}
static const per_sequence_t MergeChannelsRequest_sequence[] = {
{ &hf_t124_mergeChannels , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_ChannelAttributes },
{ &hf_t124_purgeChannelIds, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_ChannelId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_MergeChannelsRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_MergeChannelsRequest, MergeChannelsRequest_sequence);
return offset;
}
static const per_sequence_t MergeChannelsConfirm_sequence[] = {
{ &hf_t124_mergeChannels , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_ChannelAttributes },
{ &hf_t124_purgeChannelIds, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_ChannelId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_MergeChannelsConfirm(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_MergeChannelsConfirm, MergeChannelsConfirm_sequence);
return offset;
}
static const per_sequence_t PurgeChannelsIndication_sequence[] = {
{ &hf_t124_detachUserIds , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_UserId },
{ &hf_t124_purgeChannelIds, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_ChannelId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_PurgeChannelsIndication(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_PurgeChannelsIndication, PurgeChannelsIndication_sequence);
return offset;
}
static const per_sequence_t T_grabbed_sequence[] = {
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ &hf_t124_grabber , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_T_grabbed(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_T_grabbed, T_grabbed_sequence);
return offset;
}
static const per_sequence_t T_inhibited_sequence[] = {
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ &hf_t124_inhibitors , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_T_inhibited(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_T_inhibited, T_inhibited_sequence);
return offset;
}
static const per_sequence_t T_giving_sequence[] = {
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ &hf_t124_grabber , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_recipient , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_T_giving(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_T_giving, T_giving_sequence);
return offset;
}
static const per_sequence_t T_ungivable_sequence[] = {
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ &hf_t124_grabber , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_T_ungivable(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_T_ungivable, T_ungivable_sequence);
return offset;
}
static const per_sequence_t T_given_sequence[] = {
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ &hf_t124_recipient , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_T_given(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_T_given, T_given_sequence);
return offset;
}
static const value_string t124_TokenAttributes_vals[] = {
{ 0, "grabbed" },
{ 1, "inhibited" },
{ 2, "giving" },
{ 3, "ungivable" },
{ 4, "given" },
{ 0, NULL }
};
static const per_choice_t TokenAttributes_choice[] = {
{ 0, &hf_t124_grabbed , ASN1_NO_EXTENSIONS , dissect_t124_T_grabbed },
{ 1, &hf_t124_inhibited , ASN1_NO_EXTENSIONS , dissect_t124_T_inhibited },
{ 2, &hf_t124_giving , ASN1_NO_EXTENSIONS , dissect_t124_T_giving },
{ 3, &hf_t124_ungivable , ASN1_NO_EXTENSIONS , dissect_t124_T_ungivable },
{ 4, &hf_t124_given , ASN1_NO_EXTENSIONS , dissect_t124_T_given },
{ 0, NULL, 0, NULL }
};
static int
dissect_t124_TokenAttributes(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_t124_TokenAttributes, TokenAttributes_choice,
NULL);
return offset;
}
static const per_sequence_t SET_OF_TokenAttributes_set_of[1] = {
{ &hf_t124_mergeTokens_item, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenAttributes },
};
static int
dissect_t124_SET_OF_TokenAttributes(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_set_of(tvb, offset, actx, tree, hf_index,
ett_t124_SET_OF_TokenAttributes, SET_OF_TokenAttributes_set_of);
return offset;
}
static const per_sequence_t SET_OF_TokenId_set_of[1] = {
{ &hf_t124_purgeTokenIds_item, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
};
static int
dissect_t124_SET_OF_TokenId(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_set_of(tvb, offset, actx, tree, hf_index,
ett_t124_SET_OF_TokenId, SET_OF_TokenId_set_of);
return offset;
}
static const per_sequence_t MergeTokensRequest_sequence[] = {
{ &hf_t124_mergeTokens , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_TokenAttributes },
{ &hf_t124_purgeTokenIds , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_TokenId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_MergeTokensRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_MergeTokensRequest, MergeTokensRequest_sequence);
return offset;
}
static const per_sequence_t MergeTokensConfirm_sequence[] = {
{ &hf_t124_mergeTokens , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_TokenAttributes },
{ &hf_t124_purgeTokenIds , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_TokenId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_MergeTokensConfirm(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_MergeTokensConfirm, MergeTokensConfirm_sequence);
return offset;
}
static const per_sequence_t PurgeTokensIndication_sequence[] = {
{ &hf_t124_purgeTokenIds , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_TokenId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_PurgeTokensIndication(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_PurgeTokensIndication, PurgeTokensIndication_sequence);
return offset;
}
static const value_string t124_Reason_vals[] = {
{ 0, "rn-domain-disconnected" },
{ 1, "rn-provider-initiated" },
{ 2, "rn-token-purged" },
{ 3, "rn-user-requested" },
{ 4, "rn-channel-purged" },
{ 0, NULL }
};
static int
dissect_t124_Reason(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
5, NULL, FALSE, 0, NULL);
return offset;
}
static const per_sequence_t DisconnectProviderUltimatum_sequence[] = {
{ &hf_t124_reason , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Reason },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_DisconnectProviderUltimatum(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_DisconnectProviderUltimatum, DisconnectProviderUltimatum_sequence);
return offset;
}
static const value_string t124_Diagnostic_vals[] = {
{ 0, "dc-inconsistent-merge" },
{ 1, "dc-forbidden-PDU-downward" },
{ 2, "dc-forbidden-PDU-upward" },
{ 3, "dc-invalid-BER-encoding" },
{ 4, "dc-invalid-PER-encoding" },
{ 5, "dc-misrouted-user" },
{ 6, "dc-unrequested-confirm" },
{ 7, "dc-wrong-transport-priority" },
{ 8, "dc-channel-id-conflict" },
{ 9, "dc-token-id-conflict" },
{ 10, "dc-not-user-id-channel" },
{ 11, "dc-too-many-channels" },
{ 12, "dc-too-many-tokens" },
{ 13, "dc-too-many-users" },
{ 0, NULL }
};
static int
dissect_t124_Diagnostic(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
14, NULL, FALSE, 0, NULL);
return offset;
}
static const per_sequence_t RejectMCSPDUUltimatum_sequence[] = {
{ &hf_t124_diagnostic , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Diagnostic },
{ &hf_t124_initialOctets , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_OCTET_STRING },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_RejectMCSPDUUltimatum(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_RejectMCSPDUUltimatum, RejectMCSPDUUltimatum_sequence);
return offset;
}
static const per_sequence_t AttachUserRequest_sequence[] = {
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_AttachUserRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_AttachUserRequest, AttachUserRequest_sequence);
return offset;
}
static const value_string t124_Result_vals[] = {
{ 0, "rt-successful" },
{ 1, "rt-domain-merging" },
{ 2, "rt-domain-not-hierarchical" },
{ 3, "rt-no-such-channel" },
{ 4, "rt-no-such-domain" },
{ 5, "rt-no-such-user" },
{ 6, "rt-not-admitted" },
{ 7, "rt-other-user-id" },
{ 8, "rt-parameters-unacceptable" },
{ 9, "rt-token-not-available" },
{ 10, "rt-token-not-possessed" },
{ 11, "rt-too-many-channels" },
{ 12, "rt-too-many-tokens" },
{ 13, "rt-too-many-users" },
{ 14, "rt-unspecified-failure" },
{ 15, "rt-user-rejected" },
{ 0, NULL }
};
static int
dissect_t124_Result(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
16, NULL, FALSE, 0, NULL);
return offset;
}
static const per_sequence_t AttachUserConfirm_sequence[] = {
{ &hf_t124_result_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Result },
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_OPTIONAL , dissect_t124_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_AttachUserConfirm(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_AttachUserConfirm, AttachUserConfirm_sequence);
return offset;
}
static const per_sequence_t DetachUserRequest_sequence[] = {
{ &hf_t124_reason , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Reason },
{ &hf_t124_userIds , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_DetachUserRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_DetachUserRequest, DetachUserRequest_sequence);
return offset;
}
static const per_sequence_t DetachUserIndication_sequence[] = {
{ &hf_t124_reason , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Reason },
{ &hf_t124_userIds , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_DetachUserIndication(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_DetachUserIndication, DetachUserIndication_sequence);
return offset;
}
static const per_sequence_t ChannelJoinRequest_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_channelId_03 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_ChannelId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ChannelJoinRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ChannelJoinRequest, ChannelJoinRequest_sequence);
return offset;
}
static const per_sequence_t ChannelJoinConfirm_sequence[] = {
{ &hf_t124_result_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Result },
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_requested , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_ChannelId },
{ &hf_t124_channelId_03 , ASN1_NO_EXTENSIONS , ASN1_OPTIONAL , dissect_t124_ChannelId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ChannelJoinConfirm(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ChannelJoinConfirm, ChannelJoinConfirm_sequence);
return offset;
}
static const per_sequence_t ChannelLeaveRequest_sequence[] = {
{ &hf_t124_channelIds , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_ChannelId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ChannelLeaveRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ChannelLeaveRequest, ChannelLeaveRequest_sequence);
return offset;
}
static const per_sequence_t ChannelConveneRequest_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ChannelConveneRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ChannelConveneRequest, ChannelConveneRequest_sequence);
return offset;
}
static const per_sequence_t ChannelConveneConfirm_sequence[] = {
{ &hf_t124_result_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Result },
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_channelId_01 , ASN1_NO_EXTENSIONS , ASN1_OPTIONAL , dissect_t124_PrivateChannelId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ChannelConveneConfirm(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ChannelConveneConfirm, ChannelConveneConfirm_sequence);
return offset;
}
static const per_sequence_t ChannelDisbandRequest_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_channelId_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_PrivateChannelId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ChannelDisbandRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ChannelDisbandRequest, ChannelDisbandRequest_sequence);
return offset;
}
static const per_sequence_t ChannelDisbandIndication_sequence[] = {
{ &hf_t124_channelId_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_PrivateChannelId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ChannelDisbandIndication(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ChannelDisbandIndication, ChannelDisbandIndication_sequence);
return offset;
}
static const per_sequence_t ChannelAdmitRequest_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_channelId_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_PrivateChannelId },
{ &hf_t124_userIds , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ChannelAdmitRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ChannelAdmitRequest, ChannelAdmitRequest_sequence);
return offset;
}
static const per_sequence_t ChannelAdmitIndication_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_channelId_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_PrivateChannelId },
{ &hf_t124_userIds , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ChannelAdmitIndication(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ChannelAdmitIndication, ChannelAdmitIndication_sequence);
return offset;
}
static const per_sequence_t ChannelExpelRequest_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_channelId_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_PrivateChannelId },
{ &hf_t124_userIds , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ChannelExpelRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ChannelExpelRequest, ChannelExpelRequest_sequence);
return offset;
}
static const per_sequence_t ChannelExpelIndication_sequence[] = {
{ &hf_t124_channelId_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_PrivateChannelId },
{ &hf_t124_userIds , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_SET_OF_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_ChannelExpelIndication(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_ChannelExpelIndication, ChannelExpelIndication_sequence);
return offset;
}
static int
dissect_t124_T_userData(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
tvbuff_t *next_tvb = NULL;
offset = dissect_per_octet_string(tvb, offset, actx, tree, hf_index,
NO_BOUND, NO_BOUND, FALSE, &next_tvb);
if(next_tvb) {
dissector_try_uint_new(t124_sd_dissector_table, channelId, next_tvb, actx->pinfo, top_tree, FALSE, NULL);
}
return offset;
}
static const per_sequence_t SendDataRequest_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_channelId_03 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_ChannelId },
{ &hf_t124_dataPriority , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_DataPriority },
{ &hf_t124_segmentation , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Segmentation },
{ &hf_t124_userData_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_T_userData },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_SendDataRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_SendDataRequest, SendDataRequest_sequence);
return offset;
}
static int
dissect_t124_T_userData_01(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
tvbuff_t *next_tvb = NULL;
offset = dissect_per_octet_string(tvb, offset, actx, tree, hf_index,
NO_BOUND, NO_BOUND, FALSE, &next_tvb);
if(next_tvb) {
dissector_try_uint(t124_sd_dissector_table, channelId, next_tvb, actx->pinfo, top_tree);
}
return offset;
}
static const per_sequence_t SendDataIndication_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_channelId_03 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_ChannelId },
{ &hf_t124_dataPriority , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_DataPriority },
{ &hf_t124_segmentation , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Segmentation },
{ &hf_t124_userData_02 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_T_userData_01 },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_SendDataIndication(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_SendDataIndication, SendDataIndication_sequence);
return offset;
}
static const per_sequence_t UniformSendDataRequest_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_channelId_03 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_ChannelId },
{ &hf_t124_dataPriority , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_DataPriority },
{ &hf_t124_segmentation , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Segmentation },
{ &hf_t124_userData_03 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_OCTET_STRING },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_UniformSendDataRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_UniformSendDataRequest, UniformSendDataRequest_sequence);
return offset;
}
static const per_sequence_t UniformSendDataIndication_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_channelId_03 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_ChannelId },
{ &hf_t124_dataPriority , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_DataPriority },
{ &hf_t124_segmentation , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Segmentation },
{ &hf_t124_userData_03 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_OCTET_STRING },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_UniformSendDataIndication(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_UniformSendDataIndication, UniformSendDataIndication_sequence);
return offset;
}
static const per_sequence_t TokenGrabRequest_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_TokenGrabRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_TokenGrabRequest, TokenGrabRequest_sequence);
return offset;
}
static const per_sequence_t TokenGrabConfirm_sequence[] = {
{ &hf_t124_result_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Result },
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ &hf_t124_tokenStatus , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenStatus },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_TokenGrabConfirm(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_TokenGrabConfirm, TokenGrabConfirm_sequence);
return offset;
}
static const per_sequence_t TokenInhibitRequest_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_TokenInhibitRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_TokenInhibitRequest, TokenInhibitRequest_sequence);
return offset;
}
static const per_sequence_t TokenInhibitConfirm_sequence[] = {
{ &hf_t124_result_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Result },
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ &hf_t124_tokenStatus , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenStatus },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_TokenInhibitConfirm(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_TokenInhibitConfirm, TokenInhibitConfirm_sequence);
return offset;
}
static const per_sequence_t TokenGiveRequest_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ &hf_t124_recipient , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_TokenGiveRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_TokenGiveRequest, TokenGiveRequest_sequence);
return offset;
}
static const per_sequence_t TokenGiveIndication_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ &hf_t124_recipient , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_TokenGiveIndication(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_TokenGiveIndication, TokenGiveIndication_sequence);
return offset;
}
static const per_sequence_t TokenGiveResponse_sequence[] = {
{ &hf_t124_result_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Result },
{ &hf_t124_recipient , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_TokenGiveResponse(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_TokenGiveResponse, TokenGiveResponse_sequence);
return offset;
}
static const per_sequence_t TokenGiveConfirm_sequence[] = {
{ &hf_t124_result_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Result },
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ &hf_t124_tokenStatus , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenStatus },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_TokenGiveConfirm(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_TokenGiveConfirm, TokenGiveConfirm_sequence);
return offset;
}
static const per_sequence_t TokenPleaseRequest_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_TokenPleaseRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_TokenPleaseRequest, TokenPleaseRequest_sequence);
return offset;
}
static const per_sequence_t TokenPleaseIndication_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_TokenPleaseIndication(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_TokenPleaseIndication, TokenPleaseIndication_sequence);
return offset;
}
static const per_sequence_t TokenReleaseRequest_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_TokenReleaseRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_TokenReleaseRequest, TokenReleaseRequest_sequence);
return offset;
}
static const per_sequence_t TokenReleaseConfirm_sequence[] = {
{ &hf_t124_result_01 , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Result },
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ &hf_t124_tokenStatus , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenStatus },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_TokenReleaseConfirm(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_TokenReleaseConfirm, TokenReleaseConfirm_sequence);
return offset;
}
static const per_sequence_t TokenTestRequest_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_TokenTestRequest(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_TokenTestRequest, TokenTestRequest_sequence);
return offset;
}
static const per_sequence_t TokenTestConfirm_sequence[] = {
{ &hf_t124_initiator , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_UserId },
{ &hf_t124_tokenId , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenId },
{ &hf_t124_tokenStatus , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_TokenStatus },
{ NULL, 0, 0, NULL }
};
static int
dissect_t124_TokenTestConfirm(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_t124_TokenTestConfirm, TokenTestConfirm_sequence);
return offset;
}
static const value_string t124_DomainMCSPDU_vals[] = {
{ 0, "plumbDomainIndication" },
{ 1, "erectDomainRequest" },
{ 2, "mergeChannelsRequest" },
{ 3, "mergeChannelsConfirm" },
{ 4, "purgeChannelsIndication" },
{ 5, "mergeTokensRequest" },
{ 6, "mergeTokensConfirm" },
{ 7, "purgeTokensIndication" },
{ 8, "disconnectProviderUltimatum" },
{ 9, "rejectMCSPDUUltimatum" },
{ 10, "attachUserRequest" },
{ 11, "attachUserConfirm" },
{ 12, "detachUserRequest" },
{ 13, "detachUserIndication" },
{ 14, "channelJoinRequest" },
{ 15, "channelJoinConfirm" },
{ 16, "channelLeaveRequest" },
{ 17, "channelConveneRequest" },
{ 18, "channelConveneConfirm" },
{ 19, "channelDisbandRequest" },
{ 20, "channelDisbandIndication" },
{ 21, "channelAdmitRequest" },
{ 22, "channelAdmitIndication" },
{ 23, "channelExpelRequest" },
{ 24, "channelExpelIndication" },
{ 25, "sendDataRequest" },
{ 26, "sendDataIndication" },
{ 27, "uniformSendDataRequest" },
{ 28, "uniformSendDataIndication" },
{ 29, "tokenGrabRequest" },
{ 30, "tokenGrabConfirm" },
{ 31, "tokenInhibitRequest" },
{ 32, "tokenInhibitConfirm" },
{ 33, "tokenGiveRequest" },
{ 34, "tokenGiveIndication" },
{ 35, "tokenGiveResponse" },
{ 36, "tokenGiveConfirm" },
{ 37, "tokenPleaseRequest" },
{ 38, "tokenPleaseIndication" },
{ 39, "tokenReleaseRequest" },
{ 40, "tokenReleaseConfirm" },
{ 41, "tokenTestRequest" },
{ 42, "tokenTestConfirm" },
{ 0, NULL }
};
static const per_choice_t DomainMCSPDU_choice[] = {
{ 0, &hf_t124_plumbDomainIndication, ASN1_NO_EXTENSIONS , dissect_t124_PlumbDomainIndication },
{ 1, &hf_t124_erectDomainRequest, ASN1_NO_EXTENSIONS , dissect_t124_ErectDomainRequest },
{ 2, &hf_t124_mergeChannelsRequest, ASN1_NO_EXTENSIONS , dissect_t124_MergeChannelsRequest },
{ 3, &hf_t124_mergeChannelsConfirm, ASN1_NO_EXTENSIONS , dissect_t124_MergeChannelsConfirm },
{ 4, &hf_t124_purgeChannelsIndication, ASN1_NO_EXTENSIONS , dissect_t124_PurgeChannelsIndication },
{ 5, &hf_t124_mergeTokensRequest, ASN1_NO_EXTENSIONS , dissect_t124_MergeTokensRequest },
{ 6, &hf_t124_mergeTokensConfirm, ASN1_NO_EXTENSIONS , dissect_t124_MergeTokensConfirm },
{ 7, &hf_t124_purgeTokensIndication, ASN1_NO_EXTENSIONS , dissect_t124_PurgeTokensIndication },
{ 8, &hf_t124_disconnectProviderUltimatum, ASN1_NO_EXTENSIONS , dissect_t124_DisconnectProviderUltimatum },
{ 9, &hf_t124_rejectMCSPDUUltimatum, ASN1_NO_EXTENSIONS , dissect_t124_RejectMCSPDUUltimatum },
{ 10, &hf_t124_attachUserRequest, ASN1_NO_EXTENSIONS , dissect_t124_AttachUserRequest },
{ 11, &hf_t124_attachUserConfirm, ASN1_NO_EXTENSIONS , dissect_t124_AttachUserConfirm },
{ 12, &hf_t124_detachUserRequest, ASN1_NO_EXTENSIONS , dissect_t124_DetachUserRequest },
{ 13, &hf_t124_detachUserIndication, ASN1_NO_EXTENSIONS , dissect_t124_DetachUserIndication },
{ 14, &hf_t124_channelJoinRequest, ASN1_NO_EXTENSIONS , dissect_t124_ChannelJoinRequest },
{ 15, &hf_t124_channelJoinConfirm, ASN1_NO_EXTENSIONS , dissect_t124_ChannelJoinConfirm },
{ 16, &hf_t124_channelLeaveRequest, ASN1_NO_EXTENSIONS , dissect_t124_ChannelLeaveRequest },
{ 17, &hf_t124_channelConveneRequest, ASN1_NO_EXTENSIONS , dissect_t124_ChannelConveneRequest },
{ 18, &hf_t124_channelConveneConfirm, ASN1_NO_EXTENSIONS , dissect_t124_ChannelConveneConfirm },
{ 19, &hf_t124_channelDisbandRequest, ASN1_NO_EXTENSIONS , dissect_t124_ChannelDisbandRequest },
{ 20, &hf_t124_channelDisbandIndication, ASN1_NO_EXTENSIONS , dissect_t124_ChannelDisbandIndication },
{ 21, &hf_t124_channelAdmitRequest, ASN1_NO_EXTENSIONS , dissect_t124_ChannelAdmitRequest },
{ 22, &hf_t124_channelAdmitIndication, ASN1_NO_EXTENSIONS , dissect_t124_ChannelAdmitIndication },
{ 23, &hf_t124_channelExpelRequest, ASN1_NO_EXTENSIONS , dissect_t124_ChannelExpelRequest },
{ 24, &hf_t124_channelExpelIndication, ASN1_NO_EXTENSIONS , dissect_t124_ChannelExpelIndication },
{ 25, &hf_t124_sendDataRequest, ASN1_NO_EXTENSIONS , dissect_t124_SendDataRequest },
{ 26, &hf_t124_sendDataIndication, ASN1_NO_EXTENSIONS , dissect_t124_SendDataIndication },
{ 27, &hf_t124_uniformSendDataRequest, ASN1_NO_EXTENSIONS , dissect_t124_UniformSendDataRequest },
{ 28, &hf_t124_uniformSendDataIndication, ASN1_NO_EXTENSIONS , dissect_t124_UniformSendDataIndication },
{ 29, &hf_t124_tokenGrabRequest, ASN1_NO_EXTENSIONS , dissect_t124_TokenGrabRequest },
{ 30, &hf_t124_tokenGrabConfirm, ASN1_NO_EXTENSIONS , dissect_t124_TokenGrabConfirm },
{ 31, &hf_t124_tokenInhibitRequest, ASN1_NO_EXTENSIONS , dissect_t124_TokenInhibitRequest },
{ 32, &hf_t124_tokenInhibitConfirm, ASN1_NO_EXTENSIONS , dissect_t124_TokenInhibitConfirm },
{ 33, &hf_t124_tokenGiveRequest, ASN1_NO_EXTENSIONS , dissect_t124_TokenGiveRequest },
{ 34, &hf_t124_tokenGiveIndication, ASN1_NO_EXTENSIONS , dissect_t124_TokenGiveIndication },
{ 35, &hf_t124_tokenGiveResponse, ASN1_NO_EXTENSIONS , dissect_t124_TokenGiveResponse },
{ 36, &hf_t124_tokenGiveConfirm, ASN1_NO_EXTENSIONS , dissect_t124_TokenGiveConfirm },
{ 37, &hf_t124_tokenPleaseRequest, ASN1_NO_EXTENSIONS , dissect_t124_TokenPleaseRequest },
{ 38, &hf_t124_tokenPleaseIndication, ASN1_NO_EXTENSIONS , dissect_t124_TokenPleaseIndication },
{ 39, &hf_t124_tokenReleaseRequest, ASN1_NO_EXTENSIONS , dissect_t124_TokenReleaseRequest },
{ 40, &hf_t124_tokenReleaseConfirm, ASN1_NO_EXTENSIONS , dissect_t124_TokenReleaseConfirm },
{ 41, &hf_t124_tokenTestRequest, ASN1_NO_EXTENSIONS , dissect_t124_TokenTestRequest },
{ 42, &hf_t124_tokenTestConfirm, ASN1_NO_EXTENSIONS , dissect_t124_TokenTestConfirm },
{ 0, NULL, 0, NULL }
};
static int
dissect_t124_DomainMCSPDU(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
gint domainmcs_value;
offset = dissect_per_choice(tvb, offset, actx, tree, hf_index,
ett_t124_DomainMCSPDU, DomainMCSPDU_choice,
&domainmcs_value);
switch(domainmcs_value) {
case 25: /* sendDataRequest */
case 26: /* sendDataIndication */
case 27: /* uniformSendDataRequest */
case 28: /* uniformSendDataIndication */
/* Do nothing */
break;
default:
col_prepend_fstr(actx->pinfo->cinfo, COL_INFO, "%s ", val_to_str(domainmcs_value, t124_DomainMCSPDU_vals, "Unknown"));
break;
}
return offset;
}
static const per_sequence_t t124Heur_sequence[] = {
{ &hf_t124_t124Identifier , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_t124_Key },
{ NULL, 0, 0, NULL }
};
void
register_t124_ns_dissector(const char *nsKey, dissector_t dissector, int proto)
{
dissector_handle_t dissector_handle;
dissector_handle=create_dissector_handle(dissector, proto);
dissector_add_string("t124.ns", nsKey, dissector_handle);
}
void register_t124_sd_dissector(packet_info *pinfo _U_, guint32 channelId_param, dissector_t dissector, int proto)
{
/* XXX: we should keep the sub-dissectors list per conversation
as the same channels may be used.
While we are just using RDP over T.124, then we can get away with it.
*/
dissector_handle_t dissector_handle;
dissector_handle=create_dissector_handle(dissector, proto);
dissector_add_uint("t124.sd", channelId_param, dissector_handle);
}
guint32 t124_get_last_channelId(void)
{
return channelId;
}
void t124_set_top_tree(proto_tree *tree)
{
top_tree = tree;
}
int dissect_DomainMCSPDU_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
int offset = 0;
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, TRUE, pinfo);
offset = dissect_t124_DomainMCSPDU(tvb, offset, &asn1_ctx, tree, hf_t124_DomainMCSPDU_PDU);
offset += 7; offset >>= 3;
return offset;
}
static int
dissect_t124(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
asn1_ctx_t asn1_ctx;
top_tree = parent_tree;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "T.124");
col_clear(pinfo->cinfo, COL_INFO);
item = proto_tree_add_item(parent_tree, proto_t124, tvb, 0, tvb_captured_length(tvb), ENC_NA);
tree = proto_item_add_subtree(item, ett_t124);
asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, TRUE, pinfo);
dissect_t124_ConnectData(tvb, 0, &asn1_ctx, tree, hf_t124_ConnectData);
return tvb_captured_length(tvb);
}
static gboolean
dissect_t124_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
{
asn1_ctx_t asn1_ctx;
volatile gboolean failed = FALSE;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, TRUE, pinfo);
/*
* We must catch all the "ran past the end of the packet" exceptions
* here and, if we catch one, just return FALSE. It's too painful
* to have a version of dissect_per_sequence() that checks all
* references to the tvbuff before making them and returning "no"
* if they would fail.
*
* We (ab)use hf_t124_connectGCCPDU here just to give a valid entry...
*/
TRY {
(void) dissect_per_sequence(tvb, 0, &asn1_ctx, NULL, hf_t124_connectGCCPDU, -1, t124Heur_sequence);
} CATCH_BOUNDS_ERRORS {
failed = TRUE;
} ENDTRY;
if (!failed && ((asn1_ctx.external.direct_reference != NULL) &&
(strcmp(asn1_ctx.external.direct_reference, "0.0.20.124.0.1") == 0))) {
dissect_t124(tvb, pinfo, parent_tree, data);
return TRUE;
}
return FALSE;
}
/*--- proto_register_t124 -------------------------------------------*/
void proto_register_t124(void) {
/* List of fields */
static hf_register_info hf[] = {
{ &hf_t124_ConnectData,
{ "ConnectData", "t124.ConnectData",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_connectGCCPDU,
{ "connectGCCPDU", "t124.connectGCCPDU",
FT_UINT32, BASE_DEC, VALS(t124_ConnectGCCPDU_vals), 0,
NULL, HFILL }},
{ &hf_t124_DomainMCSPDU_PDU,
{ "DomainMCSPDU", "t124.DomainMCSPDU",
FT_UINT32, BASE_DEC, VALS(t124_DomainMCSPDU_vals), 0,
NULL, HFILL }},
{ &hf_t124_object,
{ "object", "t124.object",
FT_OID, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_h221NonStandard,
{ "h221NonStandard", "t124.h221NonStandard",
FT_BYTES, BASE_NONE, NULL, 0,
"H221NonStandardIdentifier", HFILL }},
{ &hf_t124_key,
{ "key", "t124.key",
FT_UINT32, BASE_DEC, VALS(t124_Key_vals), 0,
NULL, HFILL }},
{ &hf_t124_data,
{ "data", "t124.data",
FT_BYTES, BASE_NONE, NULL, 0,
"OCTET_STRING", HFILL }},
{ &hf_t124_UserData_item,
{ "UserData item", "t124.UserData_item_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_value,
{ "value", "t124.value",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_numeric,
{ "numeric", "t124.numeric",
FT_STRING, BASE_NONE, NULL, 0,
"SimpleNumericString", HFILL }},
{ &hf_t124_text,
{ "text", "t124.text",
FT_STRING, BASE_NONE, NULL, 0,
"SimpleTextString", HFILL }},
{ &hf_t124_unicodeText,
{ "unicodeText", "t124.unicodeText",
FT_STRING, BASE_NONE, NULL, 0,
"TextString", HFILL }},
{ &hf_t124_passwordString,
{ "passwordString", "t124.passwordString",
FT_UINT32, BASE_DEC, VALS(t124_PasswordSelector_vals), 0,
"PasswordSelector", HFILL }},
{ &hf_t124_responseData,
{ "responseData", "t124.responseData",
FT_UINT32, BASE_DEC, NULL, 0,
"UserData", HFILL }},
{ &hf_t124_passwordInTheClear,
{ "passwordInTheClear", "t124.passwordInTheClear_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_nonStandardAlgorithm,
{ "nonStandardAlgorithm", "t124.nonStandardAlgorithm_element",
FT_NONE, BASE_NONE, NULL, 0,
"NonStandardParameter", HFILL }},
{ &hf_t124_responseAlgorithm,
{ "responseAlgorithm", "t124.responseAlgorithm",
FT_UINT32, BASE_DEC, VALS(t124_ChallengeResponseAlgorithm_vals), 0,
"ChallengeResponseAlgorithm", HFILL }},
{ &hf_t124_challengeData,
{ "challengeData", "t124.challengeData",
FT_UINT32, BASE_DEC, NULL, 0,
"UserData", HFILL }},
{ &hf_t124_challengeTag,
{ "challengeTag", "t124.challengeTag",
FT_INT32, BASE_DEC, NULL, 0,
"INTEGER", HFILL }},
{ &hf_t124_challengeSet,
{ "challengeSet", "t124.challengeSet",
FT_UINT32, BASE_DEC, NULL, 0,
"SET_OF_ChallengeItem", HFILL }},
{ &hf_t124_challengeSet_item,
{ "ChallengeItem", "t124.ChallengeItem_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_responseItem,
{ "responseItem", "t124.responseItem",
FT_UINT32, BASE_DEC, VALS(t124_ChallengeResponseItem_vals), 0,
"ChallengeResponseItem", HFILL }},
{ &hf_t124_passwordInTheClear_01,
{ "passwordInTheClear", "t124.passwordInTheClear",
FT_UINT32, BASE_DEC, VALS(t124_PasswordSelector_vals), 0,
"PasswordSelector", HFILL }},
{ &hf_t124_challengeRequestResponse,
{ "challengeRequestResponse", "t124.challengeRequestResponse_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_challengeRequest,
{ "challengeRequest", "t124.challengeRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_challengeResponse,
{ "challengeResponse", "t124.challengeResponse_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_nonStandardScheme,
{ "nonStandardScheme", "t124.nonStandardScheme_element",
FT_NONE, BASE_NONE, NULL, 0,
"NonStandardParameter", HFILL }},
{ &hf_t124_priority,
{ "priority", "t124.priority",
FT_UINT32, BASE_DEC, NULL, 0,
"INTEGER_0_65535", HFILL }},
{ &hf_t124_scheme,
{ "scheme", "t124.scheme",
FT_UINT32, BASE_DEC, VALS(t124_ConferencePriorityScheme_vals), 0,
"ConferencePriorityScheme", HFILL }},
{ &hf_t124_conventional,
{ "conventional", "t124.conventional_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_counted,
{ "counted", "t124.counted_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_anonymous,
{ "anonymous", "t124.anonymous_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_nonStandardCategory,
{ "nonStandardCategory", "t124.nonStandardCategory_element",
FT_NONE, BASE_NONE, NULL, 0,
"NonStandardParameter", HFILL }},
{ &hf_t124_conventional_only,
{ "conventional-only", "t124.conventional_only_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_counted_only,
{ "counted-only", "t124.counted_only_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_anonymous_only,
{ "anonymous-only", "t124.anonymous_only_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_conventional_control,
{ "conventional-control", "t124.conventional_control_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_unrestricted_mode,
{ "unrestricted-mode", "t124.unrestricted_mode_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_non_standard_mode,
{ "non-standard-mode", "t124.non_standard_mode_element",
FT_NONE, BASE_NONE, NULL, 0,
"NonStandardParameter", HFILL }},
{ &hf_t124_NetworkAddress_item,
{ "NetworkAddress item", "t124.NetworkAddress_item",
FT_UINT32, BASE_DEC, VALS(t124_NetworkAddress_item_vals), 0,
NULL, HFILL }},
{ &hf_t124_aggregatedChannel,
{ "aggregatedChannel", "t124.aggregatedChannel_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_transferModes,
{ "transferModes", "t124.transferModes_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_speech,
{ "speech", "t124.speech",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_voice_band,
{ "voice-band", "t124.voice_band",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_digital_56k,
{ "digital-56k", "t124.digital_56k",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_digital_64k,
{ "digital-64k", "t124.digital_64k",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_digital_128k,
{ "digital-128k", "t124.digital_128k",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_digital_192k,
{ "digital-192k", "t124.digital_192k",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_digital_256k,
{ "digital-256k", "t124.digital_256k",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_digital_320k,
{ "digital-320k", "t124.digital_320k",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_digital_384k,
{ "digital-384k", "t124.digital_384k",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_digital_512k,
{ "digital-512k", "t124.digital_512k",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_digital_768k,
{ "digital-768k", "t124.digital_768k",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_digital_1152k,
{ "digital-1152k", "t124.digital_1152k",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_digital_1472k,
{ "digital-1472k", "t124.digital_1472k",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_digital_1536k,
{ "digital-1536k", "t124.digital_1536k",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_digital_1920k,
{ "digital-1920k", "t124.digital_1920k",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_packet_mode,
{ "packet-mode", "t124.packet_mode",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_frame_mode,
{ "frame-mode", "t124.frame_mode",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_atm,
{ "atm", "t124.atm",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_internationalNumber,
{ "internationalNumber", "t124.internationalNumber",
FT_STRING, BASE_NONE, NULL, 0,
"DiallingString", HFILL }},
{ &hf_t124_subAddress,
{ "subAddress", "t124.subAddress",
FT_STRING, BASE_NONE, NULL, 0,
"SubAddressString", HFILL }},
{ &hf_t124_extraDialling,
{ "extraDialling", "t124.extraDialling",
FT_STRING, BASE_NONE, NULL, 0,
"ExtraDiallingString", HFILL }},
{ &hf_t124_highLayerCompatibility,
{ "highLayerCompatibility", "t124.highLayerCompatibility_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_telephony3kHz,
{ "telephony3kHz", "t124.telephony3kHz",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_telephony7kHz,
{ "telephony7kHz", "t124.telephony7kHz",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_videotelephony,
{ "videotelephony", "t124.videotelephony",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_videoconference,
{ "videoconference", "t124.videoconference",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_audiographic,
{ "audiographic", "t124.audiographic",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_audiovisual,
{ "audiovisual", "t124.audiovisual",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_multimedia,
{ "multimedia", "t124.multimedia",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_transportConnection,
{ "transportConnection", "t124.transportConnection_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_nsapAddress,
{ "nsapAddress", "t124.nsapAddress",
FT_BYTES, BASE_NONE, NULL, 0,
"OCTET_STRING_SIZE_1_20", HFILL }},
{ &hf_t124_transportSelector,
{ "transportSelector", "t124.transportSelector",
FT_BYTES, BASE_NONE, NULL, 0,
"OCTET_STRING", HFILL }},
{ &hf_t124_nonStandard,
{ "nonStandard", "t124.nonStandard_element",
FT_NONE, BASE_NONE, NULL, 0,
"NonStandardParameter", HFILL }},
{ &hf_t124_callingNode,
{ "callingNode", "t124.callingNode_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_calledNode,
{ "calledNode", "t124.calledNode_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_unknown,
{ "unknown", "t124.unknown",
FT_UINT32, BASE_DEC, NULL, 0,
"INTEGER_0_4294967295", HFILL }},
{ &hf_t124_conferenceName,
{ "conferenceName", "t124.conferenceName_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_conferenceNameModifier,
{ "conferenceNameModifier", "t124.conferenceNameModifier",
FT_STRING, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_conferenceDescription,
{ "conferenceDescription", "t124.conferenceDescription",
FT_STRING, BASE_NONE, NULL, 0,
"TextString", HFILL }},
{ &hf_t124_lockedConference,
{ "lockedConference", "t124.lockedConference",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_passwordInTheClearRequired,
{ "passwordInTheClearRequired", "t124.passwordInTheClearRequired",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_networkAddress,
{ "networkAddress", "t124.networkAddress",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_t124_defaultConferenceFlag,
{ "defaultConferenceFlag", "t124.defaultConferenceFlag",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_conferenceMode,
{ "conferenceMode", "t124.conferenceMode",
FT_UINT32, BASE_DEC, VALS(t124_ConferenceMode_vals), 0,
NULL, HFILL }},
{ &hf_t124_convenerPassword,
{ "convenerPassword", "t124.convenerPassword_element",
FT_NONE, BASE_NONE, NULL, 0,
"Password", HFILL }},
{ &hf_t124_password,
{ "password", "t124.password_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_listedConference,
{ "listedConference", "t124.listedConference",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_conductibleConference,
{ "conductibleConference", "t124.conductibleConference",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_terminationMethod,
{ "terminationMethod", "t124.terminationMethod",
FT_UINT32, BASE_DEC, VALS(t124_TerminationMethod_vals), 0,
NULL, HFILL }},
{ &hf_t124_conductorPrivileges,
{ "conductorPrivileges", "t124.conductorPrivileges",
FT_UINT32, BASE_DEC, NULL, 0,
"SET_OF_Privilege", HFILL }},
{ &hf_t124_conductorPrivileges_item,
{ "Privilege", "t124.Privilege",
FT_UINT32, BASE_DEC, VALS(t124_Privilege_vals), 0,
NULL, HFILL }},
{ &hf_t124_conductedPrivileges,
{ "conductedPrivileges", "t124.conductedPrivileges",
FT_UINT32, BASE_DEC, NULL, 0,
"SET_OF_Privilege", HFILL }},
{ &hf_t124_conductedPrivileges_item,
{ "Privilege", "t124.Privilege",
FT_UINT32, BASE_DEC, VALS(t124_Privilege_vals), 0,
NULL, HFILL }},
{ &hf_t124_nonConductedPrivileges,
{ "nonConductedPrivileges", "t124.nonConductedPrivileges",
FT_UINT32, BASE_DEC, NULL, 0,
"SET_OF_Privilege", HFILL }},
{ &hf_t124_nonConductedPrivileges_item,
{ "Privilege", "t124.Privilege",
FT_UINT32, BASE_DEC, VALS(t124_Privilege_vals), 0,
NULL, HFILL }},
{ &hf_t124_callerIdentifier,
{ "callerIdentifier", "t124.callerIdentifier",
FT_STRING, BASE_NONE, NULL, 0,
"TextString", HFILL }},
{ &hf_t124_userData,
{ "userData", "t124.userData",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_t124_conferencePriority,
{ "conferencePriority", "t124.conferencePriority_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_nodeID,
{ "nodeID", "t124.nodeID",
FT_UINT32, BASE_DEC, NULL, 0,
"UserID", HFILL }},
{ &hf_t124_tag,
{ "tag", "t124.tag",
FT_INT32, BASE_DEC, NULL, 0,
"INTEGER", HFILL }},
{ &hf_t124_result,
{ "result", "t124.result",
FT_UINT32, BASE_DEC, VALS(t124_T_result_vals), 0,
NULL, HFILL }},
{ &hf_t124_nodeType,
{ "nodeType", "t124.nodeType",
FT_UINT32, BASE_DEC, VALS(t124_NodeType_vals), 0,
NULL, HFILL }},
{ &hf_t124_asymmetryIndicator,
{ "asymmetryIndicator", "t124.asymmetryIndicator",
FT_UINT32, BASE_DEC, VALS(t124_AsymmetryIndicator_vals), 0,
NULL, HFILL }},
{ &hf_t124_conferenceList,
{ "conferenceList", "t124.conferenceList",
FT_UINT32, BASE_DEC, NULL, 0,
"SET_OF_ConferenceDescriptor", HFILL }},
{ &hf_t124_conferenceList_item,
{ "ConferenceDescriptor", "t124.ConferenceDescriptor_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_queryResponseResult,
{ "result", "t124.result",
FT_UINT32, BASE_DEC, VALS(t124_QueryResponseResult_vals), 0,
"QueryResponseResult", HFILL }},
{ &hf_t124_waitForInvitationFlag,
{ "waitForInvitationFlag", "t124.waitForInvitationFlag",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_noUnlistedConferenceFlag,
{ "noUnlistedConferenceFlag", "t124.noUnlistedConferenceFlag",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_conferenceName_01,
{ "conferenceName", "t124.conferenceName",
FT_UINT32, BASE_DEC, VALS(t124_ConferenceNameSelector_vals), 0,
"ConferenceNameSelector", HFILL }},
{ &hf_t124_password_01,
{ "password", "t124.password",
FT_UINT32, BASE_DEC, VALS(t124_PasswordChallengeRequestResponse_vals), 0,
"PasswordChallengeRequestResponse", HFILL }},
{ &hf_t124_convenerPassword_01,
{ "convenerPassword", "t124.convenerPassword",
FT_UINT32, BASE_DEC, VALS(t124_PasswordSelector_vals), 0,
"PasswordSelector", HFILL }},
{ &hf_t124_nodeCategory,
{ "nodeCategory", "t124.nodeCategory",
FT_UINT32, BASE_DEC, VALS(t124_NodeCategory_vals), 0,
NULL, HFILL }},
{ &hf_t124_topNodeID,
{ "topNodeID", "t124.topNodeID",
FT_UINT32, BASE_DEC, NULL, 0,
"UserID", HFILL }},
{ &hf_t124_conferenceNameAlias,
{ "conferenceNameAlias", "t124.conferenceNameAlias",
FT_UINT32, BASE_DEC, VALS(t124_ConferenceNameSelector_vals), 0,
"ConferenceNameSelector", HFILL }},
{ &hf_t124_joinResponseResult,
{ "result", "t124.result",
FT_UINT32, BASE_DEC, VALS(t124_JoinResponseResult_vals), 0,
"JoinResponseResult", HFILL }},
{ &hf_t124_inviteResponseResult,
{ "result", "t124.result",
FT_UINT32, BASE_DEC, VALS(t124_InviteResponseResult_vals), 0,
"InviteResponseResult", HFILL }},
{ &hf_t124_t124Identifier,
{ "t124Identifier", "t124.t124Identifier",
FT_UINT32, BASE_DEC, VALS(t124_Key_vals), 0,
"Key", HFILL }},
{ &hf_t124_connectPDU,
{ "connectPDU", "t124.connectPDU",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_conferenceCreateRequest,
{ "conferenceCreateRequest", "t124.conferenceCreateRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_conferenceCreateResponse,
{ "conferenceCreateResponse", "t124.conferenceCreateResponse_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_conferenceQueryRequest,
{ "conferenceQueryRequest", "t124.conferenceQueryRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_conferenceQueryResponse,
{ "conferenceQueryResponse", "t124.conferenceQueryResponse_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_conferenceJoinRequest,
{ "conferenceJoinRequest", "t124.conferenceJoinRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_conferenceJoinResponse,
{ "conferenceJoinResponse", "t124.conferenceJoinResponse_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_conferenceInviteRequest,
{ "conferenceInviteRequest", "t124.conferenceInviteRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_conferenceInviteResponse,
{ "conferenceInviteResponse", "t124.conferenceInviteResponse_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_heightLimit,
{ "heightLimit", "t124.heightLimit",
FT_UINT64, BASE_DEC, NULL, 0,
"INTEGER_0_MAX", HFILL }},
{ &hf_t124_subHeight,
{ "subHeight", "t124.subHeight",
FT_UINT64, BASE_DEC, NULL, 0,
"INTEGER_0_MAX", HFILL }},
{ &hf_t124_subInterval,
{ "subInterval", "t124.subInterval",
FT_UINT64, BASE_DEC, NULL, 0,
"INTEGER_0_MAX", HFILL }},
{ &hf_t124_static,
{ "static", "t124.static_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_channelId,
{ "channelId", "t124.channelId",
FT_UINT32, BASE_DEC, NULL, 0,
"StaticChannelId", HFILL }},
{ &hf_t124_userId,
{ "userId", "t124.userId_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_joined,
{ "joined", "t124.joined",
FT_BOOLEAN, BASE_NONE, NULL, 0,
"BOOLEAN", HFILL }},
{ &hf_t124_userId_01,
{ "userId", "t124.userId",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_t124_private,
{ "private", "t124.private_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_channelId_01,
{ "channelId", "t124.channelId",
FT_UINT32, BASE_DEC, NULL, 0,
"PrivateChannelId", HFILL }},
{ &hf_t124_manager,
{ "manager", "t124.manager",
FT_UINT32, BASE_DEC, NULL, 0,
"UserId", HFILL }},
{ &hf_t124_admitted,
{ "admitted", "t124.admitted",
FT_UINT32, BASE_DEC, NULL, 0,
"SET_OF_UserId", HFILL }},
{ &hf_t124_admitted_item,
{ "UserId", "t124.UserId",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_t124_assigned,
{ "assigned", "t124.assigned_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_channelId_02,
{ "channelId", "t124.channelId",
FT_UINT32, BASE_DEC, NULL, 0,
"AssignedChannelId", HFILL }},
{ &hf_t124_mergeChannels,
{ "mergeChannels", "t124.mergeChannels",
FT_UINT32, BASE_DEC, NULL, 0,
"SET_OF_ChannelAttributes", HFILL }},
{ &hf_t124_mergeChannels_item,
{ "ChannelAttributes", "t124.ChannelAttributes",
FT_UINT32, BASE_DEC, VALS(t124_ChannelAttributes_vals), 0,
NULL, HFILL }},
{ &hf_t124_purgeChannelIds,
{ "purgeChannelIds", "t124.purgeChannelIds",
FT_UINT32, BASE_DEC, NULL, 0,
"SET_OF_ChannelId", HFILL }},
{ &hf_t124_purgeChannelIds_item,
{ "ChannelId", "t124.ChannelId",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_t124_detachUserIds,
{ "detachUserIds", "t124.detachUserIds",
FT_UINT32, BASE_DEC, NULL, 0,
"SET_OF_UserId", HFILL }},
{ &hf_t124_detachUserIds_item,
{ "UserId", "t124.UserId",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_t124_grabbed,
{ "grabbed", "t124.grabbed_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_tokenId,
{ "tokenId", "t124.tokenId",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_t124_grabber,
{ "grabber", "t124.grabber",
FT_UINT32, BASE_DEC, NULL, 0,
"UserId", HFILL }},
{ &hf_t124_inhibited,
{ "inhibited", "t124.inhibited_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_inhibitors,
{ "inhibitors", "t124.inhibitors",
FT_UINT32, BASE_DEC, NULL, 0,
"SET_OF_UserId", HFILL }},
{ &hf_t124_inhibitors_item,
{ "UserId", "t124.UserId",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_t124_giving,
{ "giving", "t124.giving_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_recipient,
{ "recipient", "t124.recipient",
FT_UINT32, BASE_DEC, NULL, 0,
"UserId", HFILL }},
{ &hf_t124_ungivable,
{ "ungivable", "t124.ungivable_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_given,
{ "given", "t124.given_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_mergeTokens,
{ "mergeTokens", "t124.mergeTokens",
FT_UINT32, BASE_DEC, NULL, 0,
"SET_OF_TokenAttributes", HFILL }},
{ &hf_t124_mergeTokens_item,
{ "TokenAttributes", "t124.TokenAttributes",
FT_UINT32, BASE_DEC, VALS(t124_TokenAttributes_vals), 0,
NULL, HFILL }},
{ &hf_t124_purgeTokenIds,
{ "purgeTokenIds", "t124.purgeTokenIds",
FT_UINT32, BASE_DEC, NULL, 0,
"SET_OF_TokenId", HFILL }},
{ &hf_t124_purgeTokenIds_item,
{ "TokenId", "t124.TokenId",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_t124_reason,
{ "reason", "t124.reason",
FT_UINT32, BASE_DEC, VALS(t124_Reason_vals), 0,
NULL, HFILL }},
{ &hf_t124_diagnostic,
{ "diagnostic", "t124.diagnostic",
FT_UINT32, BASE_DEC, VALS(t124_Diagnostic_vals), 0,
NULL, HFILL }},
{ &hf_t124_initialOctets,
{ "initialOctets", "t124.initialOctets",
FT_BYTES, BASE_NONE, NULL, 0,
"OCTET_STRING", HFILL }},
{ &hf_t124_result_01,
{ "result", "t124.result",
FT_UINT32, BASE_DEC, VALS(t124_Result_vals), 0,
NULL, HFILL }},
{ &hf_t124_initiator,
{ "initiator", "t124.initiator",
FT_UINT32, BASE_DEC, NULL, 0,
"UserId", HFILL }},
{ &hf_t124_userIds,
{ "userIds", "t124.userIds",
FT_UINT32, BASE_DEC, NULL, 0,
"SET_OF_UserId", HFILL }},
{ &hf_t124_userIds_item,
{ "UserId", "t124.UserId",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_t124_channelId_03,
{ "channelId", "t124.channelId",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_t124_requested,
{ "requested", "t124.requested",
FT_UINT32, BASE_DEC, NULL, 0,
"ChannelId", HFILL }},
{ &hf_t124_channelIds,
{ "channelIds", "t124.channelIds",
FT_UINT32, BASE_DEC, NULL, 0,
"SET_OF_ChannelId", HFILL }},
{ &hf_t124_channelIds_item,
{ "ChannelId", "t124.ChannelId",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_t124_dataPriority,
{ "dataPriority", "t124.dataPriority",
FT_UINT32, BASE_DEC, VALS(t124_DataPriority_vals), 0,
NULL, HFILL }},
{ &hf_t124_segmentation,
{ "segmentation", "t124.segmentation",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_userData_01,
{ "userData", "t124.userData",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_userData_02,
{ "userData", "t124.userData",
FT_BYTES, BASE_NONE, NULL, 0,
"T_userData_01", HFILL }},
{ &hf_t124_userData_03,
{ "userData", "t124.userData",
FT_BYTES, BASE_NONE, NULL, 0,
"OCTET_STRING", HFILL }},
{ &hf_t124_tokenStatus,
{ "tokenStatus", "t124.tokenStatus",
FT_UINT32, BASE_DEC, VALS(t124_TokenStatus_vals), 0,
NULL, HFILL }},
{ &hf_t124_plumbDomainIndication,
{ "plumbDomainIndication", "t124.plumbDomainIndication_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_erectDomainRequest,
{ "erectDomainRequest", "t124.erectDomainRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_mergeChannelsRequest,
{ "mergeChannelsRequest", "t124.mergeChannelsRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_mergeChannelsConfirm,
{ "mergeChannelsConfirm", "t124.mergeChannelsConfirm_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_purgeChannelsIndication,
{ "purgeChannelsIndication", "t124.purgeChannelsIndication_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_mergeTokensRequest,
{ "mergeTokensRequest", "t124.mergeTokensRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_mergeTokensConfirm,
{ "mergeTokensConfirm", "t124.mergeTokensConfirm_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_purgeTokensIndication,
{ "purgeTokensIndication", "t124.purgeTokensIndication_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_disconnectProviderUltimatum,
{ "disconnectProviderUltimatum", "t124.disconnectProviderUltimatum_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_rejectMCSPDUUltimatum,
{ "rejectMCSPDUUltimatum", "t124.rejectMCSPDUUltimatum_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_attachUserRequest,
{ "attachUserRequest", "t124.attachUserRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_attachUserConfirm,
{ "attachUserConfirm", "t124.attachUserConfirm_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_detachUserRequest,
{ "detachUserRequest", "t124.detachUserRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_detachUserIndication,
{ "detachUserIndication", "t124.detachUserIndication_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_channelJoinRequest,
{ "channelJoinRequest", "t124.channelJoinRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_channelJoinConfirm,
{ "channelJoinConfirm", "t124.channelJoinConfirm_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_channelLeaveRequest,
{ "channelLeaveRequest", "t124.channelLeaveRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_channelConveneRequest,
{ "channelConveneRequest", "t124.channelConveneRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_channelConveneConfirm,
{ "channelConveneConfirm", "t124.channelConveneConfirm_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_channelDisbandRequest,
{ "channelDisbandRequest", "t124.channelDisbandRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_channelDisbandIndication,
{ "channelDisbandIndication", "t124.channelDisbandIndication_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_channelAdmitRequest,
{ "channelAdmitRequest", "t124.channelAdmitRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_channelAdmitIndication,
{ "channelAdmitIndication", "t124.channelAdmitIndication_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_channelExpelRequest,
{ "channelExpelRequest", "t124.channelExpelRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_channelExpelIndication,
{ "channelExpelIndication", "t124.channelExpelIndication_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_sendDataRequest,
{ "sendDataRequest", "t124.sendDataRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_sendDataIndication,
{ "sendDataIndication", "t124.sendDataIndication_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_uniformSendDataRequest,
{ "uniformSendDataRequest", "t124.uniformSendDataRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_uniformSendDataIndication,
{ "uniformSendDataIndication", "t124.uniformSendDataIndication_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_tokenGrabRequest,
{ "tokenGrabRequest", "t124.tokenGrabRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_tokenGrabConfirm,
{ "tokenGrabConfirm", "t124.tokenGrabConfirm_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_tokenInhibitRequest,
{ "tokenInhibitRequest", "t124.tokenInhibitRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_tokenInhibitConfirm,
{ "tokenInhibitConfirm", "t124.tokenInhibitConfirm_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_tokenGiveRequest,
{ "tokenGiveRequest", "t124.tokenGiveRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_tokenGiveIndication,
{ "tokenGiveIndication", "t124.tokenGiveIndication_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_tokenGiveResponse,
{ "tokenGiveResponse", "t124.tokenGiveResponse_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_tokenGiveConfirm,
{ "tokenGiveConfirm", "t124.tokenGiveConfirm_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_tokenPleaseRequest,
{ "tokenPleaseRequest", "t124.tokenPleaseRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_tokenPleaseIndication,
{ "tokenPleaseIndication", "t124.tokenPleaseIndication_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_tokenReleaseRequest,
{ "tokenReleaseRequest", "t124.tokenReleaseRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_tokenReleaseConfirm,
{ "tokenReleaseConfirm", "t124.tokenReleaseConfirm_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_tokenTestRequest,
{ "tokenTestRequest", "t124.tokenTestRequest_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_tokenTestConfirm,
{ "tokenTestConfirm", "t124.tokenTestConfirm_element",
FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_t124_Segmentation_begin,
{ "begin", "t124.Segmentation.begin",
FT_BOOLEAN, 8, NULL, 0x80,
NULL, HFILL }},
{ &hf_t124_Segmentation_end,
{ "end", "t124.Segmentation.end",
FT_BOOLEAN, 8, NULL, 0x40,
NULL, HFILL }},
};
/* List of subtrees */
static gint *ett[] = {
&ett_t124,
&ett_t124_connectGCCPDU,
&ett_t124_Key,
&ett_t124_NonStandardParameter,
&ett_t124_UserData,
&ett_t124_UserData_item,
&ett_t124_Password,
&ett_t124_PasswordSelector,
&ett_t124_ChallengeResponseItem,
&ett_t124_ChallengeResponseAlgorithm,
&ett_t124_ChallengeItem,
&ett_t124_ChallengeRequest,
&ett_t124_SET_OF_ChallengeItem,
&ett_t124_ChallengeResponse,
&ett_t124_PasswordChallengeRequestResponse,
&ett_t124_T_challengeRequestResponse,
&ett_t124_ConferenceName,
&ett_t124_ConferenceNameSelector,
&ett_t124_ConferencePriorityScheme,
&ett_t124_ConferencePriority,
&ett_t124_NodeCategory,
&ett_t124_ConferenceMode,
&ett_t124_NetworkAddress,
&ett_t124_NetworkAddress_item,
&ett_t124_T_aggregatedChannel,
&ett_t124_T_transferModes,
&ett_t124_T_highLayerCompatibility,
&ett_t124_T_transportConnection,
&ett_t124_AsymmetryIndicator,
&ett_t124_ConferenceDescriptor,
&ett_t124_ConferenceCreateRequest,
&ett_t124_SET_OF_Privilege,
&ett_t124_ConferenceCreateResponse,
&ett_t124_ConferenceQueryRequest,
&ett_t124_ConferenceQueryResponse,
&ett_t124_SET_OF_ConferenceDescriptor,
&ett_t124_ConferenceJoinRequest,
&ett_t124_ConferenceJoinResponse,
&ett_t124_ConferenceInviteRequest,
&ett_t124_ConferenceInviteResponse,
&ett_t124_ConnectData,
&ett_t124_ConnectGCCPDU,
&ett_t124_Segmentation,
&ett_t124_PlumbDomainIndication,
&ett_t124_ErectDomainRequest,
&ett_t124_ChannelAttributes,
&ett_t124_T_static,
&ett_t124_T_userId,
&ett_t124_T_private,
&ett_t124_SET_OF_UserId,
&ett_t124_T_assigned,
&ett_t124_MergeChannelsRequest,
&ett_t124_SET_OF_ChannelAttributes,
&ett_t124_SET_OF_ChannelId,
&ett_t124_MergeChannelsConfirm,
&ett_t124_PurgeChannelsIndication,
&ett_t124_TokenAttributes,
&ett_t124_T_grabbed,
&ett_t124_T_inhibited,
&ett_t124_T_giving,
&ett_t124_T_ungivable,
&ett_t124_T_given,
&ett_t124_MergeTokensRequest,
&ett_t124_SET_OF_TokenAttributes,
&ett_t124_SET_OF_TokenId,
&ett_t124_MergeTokensConfirm,
&ett_t124_PurgeTokensIndication,
&ett_t124_DisconnectProviderUltimatum,
&ett_t124_RejectMCSPDUUltimatum,
&ett_t124_AttachUserRequest,
&ett_t124_AttachUserConfirm,
&ett_t124_DetachUserRequest,
&ett_t124_DetachUserIndication,
&ett_t124_ChannelJoinRequest,
&ett_t124_ChannelJoinConfirm,
&ett_t124_ChannelLeaveRequest,
&ett_t124_ChannelConveneRequest,
&ett_t124_ChannelConveneConfirm,
&ett_t124_ChannelDisbandRequest,
&ett_t124_ChannelDisbandIndication,
&ett_t124_ChannelAdmitRequest,
&ett_t124_ChannelAdmitIndication,
&ett_t124_ChannelExpelRequest,
&ett_t124_ChannelExpelIndication,
&ett_t124_SendDataRequest,
&ett_t124_SendDataIndication,
&ett_t124_UniformSendDataRequest,
&ett_t124_UniformSendDataIndication,
&ett_t124_TokenGrabRequest,
&ett_t124_TokenGrabConfirm,
&ett_t124_TokenInhibitRequest,
&ett_t124_TokenInhibitConfirm,
&ett_t124_TokenGiveRequest,
&ett_t124_TokenGiveIndication,
&ett_t124_TokenGiveResponse,
&ett_t124_TokenGiveConfirm,
&ett_t124_TokenPleaseRequest,
&ett_t124_TokenPleaseIndication,
&ett_t124_TokenReleaseRequest,
&ett_t124_TokenReleaseConfirm,
&ett_t124_TokenTestRequest,
&ett_t124_TokenTestConfirm,
&ett_t124_DomainMCSPDU,
};
/* Register protocol */
proto_t124 = proto_register_protocol(PNAME, PSNAME, PFNAME);
/* Register fields and subtrees */
proto_register_field_array(proto_t124, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
t124_ns_dissector_table = register_dissector_table("t124.ns", "T.124 H.221 Non Standard Dissectors", proto_t124, FT_STRING, STRING_CASE_SENSITIVE);
t124_sd_dissector_table = register_dissector_table("t124.sd", "T.124 H.221 Send Data Dissectors", proto_t124, FT_UINT32, BASE_HEX);
register_dissector("t124", dissect_t124, proto_t124);
}
void
proto_reg_handoff_t124(void) {
register_ber_oid_dissector("0.0.20.124.0.1", dissect_t124, proto_t124, "Generic Conference Control");
heur_dissector_add("t125", dissect_t124_heur, "T.124 over T.125", "t124_t125", proto_t124, HEURISTIC_ENABLE);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.