Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreadman committed Feb 4, 2025
2 parents fda4107 + a7a71b0 commit 0439c72
Show file tree
Hide file tree
Showing 35 changed files with 1,697 additions and 80 deletions.
4 changes: 3 additions & 1 deletion cmake/modules/UseAsn2Wrs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ function(ASN2WRS)
# Creates a dissector in the source directory and store the timestamp.
add_custom_command(
OUTPUT packet-${PROTOCOL_NAME}-stamp
COMMAND "${Python3_EXECUTABLE}"
COMMAND
"${CMAKE_COMMAND}" -E env PYTHONUTF8=1
"${Python3_EXECUTABLE}"
${CMAKE_SOURCE_DIR}/tools/asn2wrs.py
${A2W_FLAGS}
${PROTO_OPT}
Expand Down
1 change: 1 addition & 0 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ set(WSLUA_MODULES
${CMAKE_SOURCE_DIR}/epan/wslua/wslua_pinfo.c
${CMAKE_SOURCE_DIR}/epan/wslua/wslua_address.c
${CMAKE_SOURCE_DIR}/epan/wslua/wslua_column.c
${CMAKE_SOURCE_DIR}/epan/wslua/wslua_conversation.c
${CMAKE_SOURCE_DIR}/epan/wslua/wslua_nstime.c
${CMAKE_SOURCE_DIR}/epan/wslua/wslua_proto.c
${CMAKE_SOURCE_DIR}/epan/wslua/wslua_dissector.c
Expand Down
1 change: 1 addition & 0 deletions epan/dissectors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,7 @@ set(DISSECTOR_SRC
${CMAKE_CURRENT_SOURCE_DIR}/packet-shim6.c
${CMAKE_CURRENT_SOURCE_DIR}/packet-sigcomp.c
${CMAKE_CURRENT_SOURCE_DIR}/packet-signal-pdu.c
${CMAKE_CURRENT_SOURCE_DIR}/packet-silabs-dch.c
${CMAKE_CURRENT_SOURCE_DIR}/packet-simple.c
${CMAKE_CURRENT_SOURCE_DIR}/packet-simulcrypt.c
${CMAKE_CURRENT_SOURCE_DIR}/packet-sinecap.c
Expand Down
4 changes: 2 additions & 2 deletions epan/dissectors/packet-cipsafety.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* This dissector includes items from:
* CIP Volume 1: Common Industrial Protocol, Edition 3.24
* CIP Volume 5: CIP Safety, Edition 2.22
* CIP Volume 5: CIP Safety, Edition 2.26
*
* Copyright 2011
* Michael Mann <[email protected]>
Expand Down Expand Up @@ -2036,7 +2036,7 @@ dissect_cip_safety_data( proto_tree *tree, proto_item *item, tvbuff_t *tvb, int

if (multicast)
{
dissect_base_format_time_correction_message(tree, tvb, (io_data_size * 2) + 5);
dissect_base_format_time_correction_message(tree, tvb, item_length - 6);
}
}
break;
Expand Down
19 changes: 18 additions & 1 deletion epan/dissectors/packet-enip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,14 @@ enip_conv_info_t* get_conversation_info_one_direction(packet_info* pinfo, addres
/* default some information if not included */
if ((connid_info->port == 0) || (connid_info->type == CONN_TYPE_MULTICAST))
{
connid_info->port = ENIP_IO_PORT;
if (pinfo->srcport == ENIP_SECURE_PORT || pinfo->destport == ENIP_SECURE_PORT)
{
connid_info->port = ENIP_SECURE_PORT;
}
else
{
connid_info->port = ENIP_IO_PORT;
}
}

ws_in6_addr ipv6_zero = {0};
Expand Down Expand Up @@ -1420,6 +1427,16 @@ enip_get_io_connid(packet_info *pinfo, uint32_t connid, enum enip_connid_type* p
conversation_pt_to_conversation_type(pinfo->ptype),
pinfo->destport, 0, NO_PORT_B);

// If we couldn't find anything, search based on the source port. Some types of IO traffic use the
// same src/dest port. Other types have a unique source port.
if (conversation == NULL)
{
conversation = find_conversation(pinfo->num,
&pinfo->src, &pinfo->dst,
conversation_pt_to_conversation_type(pinfo->ptype),
pinfo->srcport, 0, NO_PORT_B);
}

if (conversation == NULL)
return NULL;

Expand Down
88 changes: 72 additions & 16 deletions epan/dissectors/packet-quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,69 @@ quic_connection_destroy(void *data, void *user_data _U_)
/* QUIC Streams tracking and reassembly. {{{ */
static reassembly_table quic_reassembly_table;

typedef struct _quic_stream_key {
uint64_t stream_id;
uint32_t id;
uint32_t conn_number;
bool from_server;
} quic_stream_key;

static unsigned
quic_stream_hash(const void *k)
{
const quic_stream_key *key = (const quic_stream_key*)k;
unsigned hash_val;

hash_val = key->id;

return hash_val;
}

static int
quic_stream_equal(const void *k1, const void *k2)
{
const quic_stream_key* key1 = (const quic_stream_key*)k1;
const quic_stream_key* key2 = (const quic_stream_key*)k2;

return (key1->id == key2->id) &&
(key1->stream_id == key2->stream_id) &&
(key1->conn_number == key2->conn_number) &&
(key1->from_server == key2->from_server);
}

static void *
quic_stream_persistent_key(const packet_info *pinfo _U_, const uint32_t id,
const void *data)
{
const quic_stream_info* stream_info = (const quic_stream_info*)data;
DISSECTOR_ASSERT(stream_info != NULL);
quic_stream_key *key = g_slice_new(quic_stream_key);

key->id = id;
key->stream_id = stream_info->stream_id;
key->conn_number = stream_info->quic_info->number;
key->from_server = stream_info->from_server;

return (void *)key;
}

static void
quic_stream_free_persistent_key(void *ptr)
{
quic_stream_key *key = (quic_stream_key *)ptr;
g_slice_free(quic_stream_key, key);
}

const reassembly_table_functions
quic_reassembly_table_functions = {
quic_stream_hash,
quic_stream_equal,
quic_stream_persistent_key,
quic_stream_persistent_key,
quic_stream_free_persistent_key,
quic_stream_free_persistent_key
};

/** Perform sequence analysis for STREAM frames. */
static quic_stream_state *
quic_get_stream_state(packet_info *pinfo, quic_info_data_t *quic_info, bool from_server, uint64_t stream_id)
Expand Down Expand Up @@ -1611,15 +1674,7 @@ desegment_quic_stream(tvbuff_t *tvb, int offset, int length, packet_info *pinfo,
// result in a reassembly ID collision here. If that collision becomes
// an issue, we would have to replace "msp->first_frame" with a new
// field in "msp" that is initialized with "stream_info->stream_offset".
#if 0
uint64_t reassembly_id_data[2];
reassembly_id_data[0] = stream_info->stream_id;
reassembly_id_data[1] = msp ? msp->first_frame : pinfo->num;
reassembly_id = wmem_strong_hash((const uint8_t *)&reassembly_id_data, sizeof(reassembly_id_data));
#else
// XXX for debug (visibility) purposes, do not use a hash but concatenate
reassembly_id = ((msp ? msp->first_frame : pinfo->num) << 16) | (uint32_t)stream_info->stream_id;
#endif
reassembly_id = msp ? msp->first_frame : pinfo->num;
}

if (msp && msp->seq <= seq && msp->nxtpdu > seq) {
Expand All @@ -1642,7 +1697,7 @@ desegment_quic_stream(tvbuff_t *tvb, int offset, int length, packet_info *pinfo,
last_fragment_len = len;

fh = fragment_add(&quic_reassembly_table, tvb, offset,
pinfo, reassembly_id, NULL,
pinfo, reassembly_id, stream_info,
seq - msp->seq, len,
nxtseq < msp->nxtpdu);
if (fh) {
Expand Down Expand Up @@ -1740,7 +1795,7 @@ desegment_quic_stream(tvbuff_t *tvb, int offset, int length, packet_info *pinfo,
* needs desegmentation).
*/
fragment_set_partial_reassembly(&quic_reassembly_table,
pinfo, reassembly_id, NULL);
pinfo, reassembly_id, stream_info);

/* Update msp->nxtpdu to point to the new next
* pdu boundary.
Expand Down Expand Up @@ -1829,7 +1884,7 @@ desegment_quic_stream(tvbuff_t *tvb, int offset, int length, packet_info *pinfo,

/* add this segment as the first one for this new pdu */
fragment_add(&quic_reassembly_table, tvb, deseg_offset,
pinfo, reassembly_id, NULL,
pinfo, reassembly_id, stream_info,
0, nxtseq - deseg_seq,
nxtseq < msp->nxtpdu);
}
Expand All @@ -1839,7 +1894,7 @@ desegment_quic_stream(tvbuff_t *tvb, int offset, int length, packet_info *pinfo,
* know what later frame the PDU is reassembled in.
*/
if (((struct tcp_multisegment_pdu *)wmem_tree_lookup32(stream->multisegment_pdus, deseg_seq))) {
fh = fragment_get(&quic_reassembly_table, pinfo, reassembly_id, NULL);
fh = fragment_get(&quic_reassembly_table, pinfo, reassembly_id, stream_info);
}
}
}
Expand Down Expand Up @@ -5749,11 +5804,12 @@ proto_register_quic(void)
udp_port_to_display, follow_quic_tap_listener, get_quic_connections_count,
quic_get_sub_stream_id);

// TODO implement custom reassembly functions that uses the QUIC Connection
// ID instead of address and port numbers.
reassembly_table_register(&quic_reassembly_table,
&addresses_ports_reassembly_table_functions);
&quic_reassembly_table_functions);

// TODO do we need custom reassembly functions that use the QUIC Connection
// ID instead of address and port numbers here? It seems less likely that
// something will change the address or port than with STREAM frames.
reassembly_table_register(&quic_crypto_reassembly_table,
&tcp_reassembly_table_functions);

Expand Down
Loading

0 comments on commit 0439c72

Please sign in to comment.