UDP: Fix indentation and convert to 4-space
This commit is contained in:
parent
3d369c01cc
commit
95b7c4fd28
|
@ -2074,9 +2074,6 @@ indent_size = tab
|
|||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[packet-udp.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[packet-udt.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
|
|
@ -187,8 +187,7 @@ static gboolean udp_calculate_ts = TRUE;
|
|||
static gboolean udplite_calculate_ts = TRUE;
|
||||
|
||||
/* Per-packet-info for UDP */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
heur_dtbl_entry_t *heur_dtbl_entry;
|
||||
nstime_t ts_delta;
|
||||
gboolean ts_delta_valid;
|
||||
|
@ -288,7 +287,8 @@ get_udp_conversation_data(conversation_t *conv, packet_info *pinfo)
|
|||
if (direction >= 0) {
|
||||
udpd->fwd=&(udpd->flow1);
|
||||
udpd->rev=&(udpd->flow2);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
udpd->fwd=&(udpd->flow2);
|
||||
udpd->rev=&(udpd->flow1);
|
||||
}
|
||||
|
@ -343,7 +343,10 @@ udpip_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_
|
|||
conv_hash_t *hash = (conv_hash_t*) pct;
|
||||
const e_udphdr *udphdr=(const e_udphdr *)vip;
|
||||
|
||||
add_conversation_table_data_with_conv_id(hash, &udphdr->ip_src, &udphdr->ip_dst, udphdr->uh_sport, udphdr->uh_dport, (conv_id_t) udphdr->uh_stream, 1, pinfo->fd->pkt_len, &pinfo->rel_ts, &pinfo->abs_ts, &udp_ct_dissector_info, ENDPOINT_UDP);
|
||||
add_conversation_table_data_with_conv_id(hash,
|
||||
&udphdr->ip_src, &udphdr->ip_dst, udphdr->uh_sport, udphdr->uh_dport,
|
||||
(conv_id_t) udphdr->uh_stream, 1, pinfo->fd->pkt_len, &pinfo->rel_ts, &pinfo->abs_ts,
|
||||
&udp_ct_dissector_info, ENDPOINT_UDP);
|
||||
|
||||
return TAP_PACKET_REDRAW;
|
||||
}
|
||||
|
@ -441,8 +444,7 @@ static gchar *udp_follow_conv_filter(epan_dissect_t *edt _U_, packet_info *pinfo
|
|||
|
||||
if( ((pinfo->net_src.type == AT_IPv4 && pinfo->net_dst.type == AT_IPv4) ||
|
||||
(pinfo->net_src.type == AT_IPv6 && pinfo->net_dst.type == AT_IPv6))
|
||||
&& (conv=find_conversation_pinfo(pinfo, 0)) != NULL )
|
||||
{
|
||||
&& (conv=find_conversation_pinfo(pinfo, 0)) != NULL ) {
|
||||
/* UDP over IPv4/6 */
|
||||
udpd=get_udp_conversation_data(conv, pinfo);
|
||||
if (udpd == NULL)
|
||||
|
@ -484,7 +486,10 @@ static gchar *udp_follow_address_filter(address *src_addr, address *dst_addr, in
|
|||
/* Attach process info to a flow */
|
||||
/* XXX - We depend on the UDP dissector finding the conversation first */
|
||||
void
|
||||
add_udp_process_info(guint32 frame_num, address *local_addr, address *remote_addr, guint16 local_port, guint16 remote_port, guint32 uid, guint32 pid, gchar *username, gchar *command) {
|
||||
add_udp_process_info(guint32 frame_num, address *local_addr, address *remote_addr,
|
||||
guint16 local_port, guint16 remote_port, guint32 uid, guint32 pid,
|
||||
gchar *username, gchar *command)
|
||||
{
|
||||
conversation_t *conv;
|
||||
struct udp_analysis *udpd;
|
||||
udp_flow_t *flow = NULL;
|
||||
|
@ -505,7 +510,8 @@ add_udp_process_info(guint32 frame_num, address *local_addr, address *remote_add
|
|||
|
||||
if ((cmp_address(local_addr, conversation_key_addr1(conv->key_ptr)) == 0) && (local_port == conversation_key_port1(conv->key_ptr))) {
|
||||
flow = &udpd->flow1;
|
||||
} else if ((cmp_address(remote_addr, conversation_key_addr1(conv->key_ptr)) == 0) && (remote_port == conversation_key_port1(conv->key_ptr))) {
|
||||
}
|
||||
else if ((cmp_address(remote_addr, conversation_key_addr1(conv->key_ptr)) == 0) && (remote_port == conversation_key_port1(conv->key_ptr))) {
|
||||
flow = &udpd->flow2;
|
||||
}
|
||||
if (!flow || flow->command) {
|
||||
|
@ -564,7 +570,8 @@ handle_export_pdu_heuristic(packet_info *pinfo, tvbuff_t *tvb, heur_dtbl_entry_t
|
|||
if ((!hdtbl_entry->enabled) ||
|
||||
(hdtbl_entry->protocol != NULL && !proto_is_protocol_enabled(hdtbl_entry->protocol))) {
|
||||
exp_pdu_data = export_pdu_create_common_tags(pinfo, "data", EXP_PDU_TAG_PROTO_NAME);
|
||||
} else if (hdtbl_entry->protocol != NULL) {
|
||||
}
|
||||
else if (hdtbl_entry->protocol != NULL) {
|
||||
exp_pdu_data = export_pdu_create_common_tags(pinfo, hdtbl_entry->short_name, EXP_PDU_TAG_HEUR_PROTO_NAME);
|
||||
}
|
||||
|
||||
|
@ -583,11 +590,9 @@ handle_export_pdu_conversation(packet_info *pinfo, tvbuff_t *tvb, int uh_dport,
|
|||
{
|
||||
if (have_tap_listener(exported_pdu_tap)) {
|
||||
conversation_t *conversation = find_conversation(pinfo->num, &pinfo->dst, &pinfo->src, ENDPOINT_UDP, uh_dport, uh_sport, 0);
|
||||
if (conversation != NULL)
|
||||
{
|
||||
if (conversation != NULL) {
|
||||
dissector_handle_t handle = (dissector_handle_t)wmem_tree_lookup32_le(conversation->dissector_tree, pinfo->num);
|
||||
if (handle != NULL)
|
||||
{
|
||||
if (handle != NULL) {
|
||||
exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, dissector_handle_get_dissector_name(handle), EXP_PDU_TAG_PROTO_NAME);
|
||||
exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb);
|
||||
exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
|
||||
|
@ -666,7 +671,8 @@ decode_udp_ports(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
if (uh_sport > uh_dport) {
|
||||
low_port = uh_dport;
|
||||
high_port = uh_sport;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
low_port = uh_sport;
|
||||
high_port = uh_dport;
|
||||
}
|
||||
|
@ -678,7 +684,8 @@ decode_udp_ports(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
handle_export_pdu_dissection_table(pinfo, next_tvb, low_port);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* The default; try it later */
|
||||
try_low_port = TRUE;
|
||||
}
|
||||
|
@ -691,7 +698,8 @@ decode_udp_ports(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
handle_export_pdu_dissection_table(pinfo, next_tvb, high_port);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* The default; try it later */
|
||||
try_high_port = TRUE;
|
||||
}
|
||||
|
@ -726,13 +734,11 @@ decode_udp_ports(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
will always pick the right port number.
|
||||
*/
|
||||
|
||||
if ((try_low_port) &&
|
||||
dissector_try_uint(udp_dissector_table, low_port, next_tvb, pinfo, tree)) {
|
||||
if ((try_low_port) && dissector_try_uint(udp_dissector_table, low_port, next_tvb, pinfo, tree)) {
|
||||
handle_export_pdu_dissection_table(pinfo, next_tvb, low_port);
|
||||
return;
|
||||
}
|
||||
if ((try_high_port) &&
|
||||
dissector_try_uint(udp_dissector_table, high_port, next_tvb, pinfo, tree)) {
|
||||
if ((try_high_port) && dissector_try_uint(udp_dissector_table, high_port, next_tvb, pinfo, tree)) {
|
||||
handle_export_pdu_dissection_table(pinfo, next_tvb, high_port);
|
||||
return;
|
||||
}
|
||||
|
@ -920,17 +926,16 @@ capture_udp(const guchar *pd _U_, int offset _U_, int len _U_, capture_packet_in
|
|||
if (src_port > dst_port) {
|
||||
low_port = dst_port;
|
||||
high_port = src_port;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
low_port = src_port;
|
||||
high_port = dst_port;
|
||||
}
|
||||
|
||||
if (low_port != 0 &&
|
||||
try_capture_dissector("udp.port", low_port, pd, offset+20, len, cpinfo, pseudo_header))
|
||||
if (low_port != 0 && try_capture_dissector("udp.port", low_port, pd, offset+20, len, cpinfo, pseudo_header))
|
||||
return TRUE;
|
||||
|
||||
if (high_port != 0 &&
|
||||
try_capture_dissector("udp.port", high_port, pd, offset+20, len, cpinfo, pseudo_header))
|
||||
if (high_port != 0 && try_capture_dissector("udp.port", high_port, pd, offset+20, len, cpinfo, pseudo_header))
|
||||
return TRUE;
|
||||
|
||||
/* We've at least identified one type of packet, so this shouldn't be "other" */
|
||||
|
@ -1092,7 +1097,8 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
|
|||
if (udp_jumbogram && (udph->uh_ulen < 65536)) {
|
||||
expert_add_info(pinfo, len_cov_item, &ei_udp_length_bad_zero);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
len_cov_item = proto_tree_add_item(udp_tree, &hfi_udplite_checksum_coverage, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
|
||||
udph->uh_ulen = reported_len;
|
||||
if (udph->uh_sum_cov == 0) {
|
||||
|
@ -1129,7 +1135,8 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
|
|||
if (ignore_zero_checksum || pinfo->flags.in_error_pkt) {
|
||||
proto_item_append_text(item, " [zero-value ignored]");
|
||||
checksum_status = PROTO_CHECKSUM_E_NOT_PRESENT;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
proto_item_append_text(item, " [zero-value illegal]");
|
||||
checksum_status = PROTO_CHECKSUM_E_ILLEGAL;
|
||||
expert_add_info(pinfo, item, &ei_udp_checksum_zero);
|
||||
|
@ -1138,7 +1145,8 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
|
|||
checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
|
||||
item = proto_tree_add_uint(checksum_tree, &hfi_udp_checksum_status, tvb, offset + 6, 2, checksum_status);
|
||||
proto_item_set_generated(item);
|
||||
} else if (!pinfo->fragmented && (len >= reported_len) &&
|
||||
}
|
||||
else if (!pinfo->fragmented && (len >= reported_len) &&
|
||||
(len >= udph->uh_sum_cov) && (reported_len >= udph->uh_sum_cov) &&
|
||||
(udph->uh_sum_cov >= 8)) {
|
||||
/* The packet isn't part of a fragmented datagram and isn't
|
||||
|
@ -1214,16 +1222,19 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
|
|||
col_append_str(pinfo->cinfo, COL_INFO, " [UDP CHECKSUM INCORRECT]");
|
||||
calc_item = proto_tree_add_uint(checksum_tree, &hfi_udp_checksum_calculated,
|
||||
tvb, offset + 6, 2, in_cksum_shouldbe(udph->uh_sum, computed_cksum));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
calc_item = proto_tree_add_uint(checksum_tree, &hfi_udp_checksum_calculated,
|
||||
tvb, offset + 6, 2, udph->uh_sum);
|
||||
}
|
||||
proto_item_set_generated(calc_item);
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
proto_tree_add_checksum(udp_tree, tvb, offset + 6, &hfi_udp_checksum, hfi_udp_checksum_status.id, &ei_udp_checksum_bad, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
proto_tree_add_checksum(udp_tree, tvb, offset + 6, &hfi_udp_checksum, hfi_udp_checksum_status.id, &ei_udp_checksum_bad, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
|
||||
}
|
||||
|
||||
|
@ -1378,15 +1389,13 @@ proto_register_udp(void)
|
|||
|
||||
int proto_udp, proto_udplite;
|
||||
|
||||
proto_udp = proto_register_protocol("User Datagram Protocol",
|
||||
"UDP", "udp");
|
||||
proto_udp = proto_register_protocol("User Datagram Protocol", "UDP", "udp");
|
||||
hfi_udp = proto_registrar_get_nth(proto_udp);
|
||||
udp_handle = register_dissector("udp", dissect_udp, proto_udp);
|
||||
expert_udp = expert_register_protocol(proto_udp);
|
||||
proto_register_fields(proto_udp, hfi, array_length(hfi));
|
||||
|
||||
proto_udplite = proto_register_protocol("Lightweight User Datagram Protocol",
|
||||
"UDP-Lite", "udplite");
|
||||
proto_udplite = proto_register_protocol("Lightweight User Datagram Protocol", "UDP-Lite", "udplite");
|
||||
udplite_handle = create_dissector_handle(dissect_udplite, proto_udplite);
|
||||
hfi_udplite = proto_registrar_get_nth(proto_udplite);
|
||||
proto_register_fields(proto_udplite, hfi_lite, array_length(hfi_lite));
|
||||
|
@ -1395,8 +1404,7 @@ proto_register_udp(void)
|
|||
expert_register_field_array(expert_udp, ei, array_length(ei));
|
||||
|
||||
/* subdissector code */
|
||||
udp_dissector_table = register_dissector_table("udp.port",
|
||||
"UDP port", proto_udp, FT_UINT16, BASE_DEC);
|
||||
udp_dissector_table = register_dissector_table("udp.port", "UDP port", proto_udp, FT_UINT16, BASE_DEC);
|
||||
heur_subdissector_list = register_heur_dissector_list("udp", proto_udp);
|
||||
|
||||
register_capture_dissector_table("udp.port", "UDP");
|
||||
|
@ -1450,7 +1458,6 @@ proto_register_udp(void)
|
|||
udp_port_to_display, follow_tvb_tap_listener);
|
||||
|
||||
register_init_routine(udp_init);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1475,11 +1482,11 @@ proto_reg_handoff_udp(void)
|
|||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 2
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=2 tabstop=8 expandtab:
|
||||
* :indentSize=2:tabSize=8:noTabs=true:
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
||||
|
|
|
@ -95,18 +95,25 @@ struct udp_analysis {
|
|||
* @param username Ephemeral string containing the full or partial process name
|
||||
* @param command Ephemeral string containing the full or partial process name
|
||||
*/
|
||||
extern void add_udp_process_info(guint32 frame_num, address *local_addr, address *remote_addr, guint16 local_port, guint16 remote_port, guint32 uid, guint32 pid, gchar *username, gchar *command);
|
||||
extern void
|
||||
add_udp_process_info(guint32 frame_num, address *local_addr, address *remote_addr,
|
||||
guint16 local_port, guint16 remote_port,
|
||||
guint32 uid, guint32 pid,
|
||||
gchar *username, gchar *command);
|
||||
|
||||
/** Get the current number of UDP streams
|
||||
*
|
||||
* @return The number of UDP streams
|
||||
*/
|
||||
WS_DLL_PUBLIC guint32 get_udp_stream_count(void);
|
||||
WS_DLL_PUBLIC guint32
|
||||
get_udp_stream_count(void);
|
||||
|
||||
WS_DLL_PUBLIC void decode_udp_ports(tvbuff_t *, int, packet_info *,
|
||||
WS_DLL_PUBLIC void
|
||||
decode_udp_ports(tvbuff_t *, int, packet_info *,
|
||||
proto_tree *, int, int, int);
|
||||
|
||||
WS_DLL_PUBLIC struct udp_analysis *get_udp_conversation_data(conversation_t *,
|
||||
WS_DLL_PUBLIC struct udp_analysis *
|
||||
get_udp_conversation_data(conversation_t *,
|
||||
packet_info *);
|
||||
|
||||
/*
|
||||
|
@ -129,7 +136,8 @@ WS_DLL_PUBLIC struct udp_analysis *get_udp_conversation_data(conversation_t *,
|
|||
*/
|
||||
WS_DLL_PUBLIC int
|
||||
udp_dissect_pdus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
||||
guint fixed_len, gboolean (*heuristic_check)(packet_info *, tvbuff_t *, int, void*),
|
||||
guint fixed_len,
|
||||
gboolean (*heuristic_check)(packet_info *, tvbuff_t *, int, void*),
|
||||
guint (*get_pdu_len)(packet_info *, tvbuff_t *, int, void*),
|
||||
dissector_t dissect_pdu, void* dissector_data);
|
||||
|
||||
|
|
Loading…
Reference in New Issue