forked from osmocom/wireshark
Heuristically dissect TIPC IP payloads.
svn path=/trunk/; revision=44900
This commit is contained in:
parent
6aca10831f
commit
ffbacb51d2
|
@ -2408,6 +2408,46 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
|
|||
pinfo->fragmented = save_fragmented;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
dissect_ip_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
||||
{
|
||||
int length, tot_length;
|
||||
guint8 oct, version, ihl;
|
||||
|
||||
/*
|
||||
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| IHL |Type of Service| Total Length |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
*/
|
||||
length = tvb_length(tvb);
|
||||
if(length<4){
|
||||
/* Need at least 4 bytes to make some sort of decision */
|
||||
return FALSE;
|
||||
}
|
||||
oct = tvb_get_guint8(tvb,0);
|
||||
ihl = oct & 0x0f;
|
||||
version = oct >> 4;
|
||||
if(version == 6){
|
||||
/* TODO: Add IPv6 checks here */
|
||||
return FALSE;
|
||||
}
|
||||
/* version == IPv4 , the minimum value for a correct header is 5 */
|
||||
if((version != 4)|| (ihl < 5)){
|
||||
return FALSE;
|
||||
}
|
||||
tot_length = tvb_get_ntohs(tvb,2);
|
||||
|
||||
if(tot_length != tvb_reported_length(tvb)){
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
dissect_ip(tvb, pinfo, tree);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
proto_register_ip(void)
|
||||
{
|
||||
|
@ -2938,6 +2978,8 @@ proto_reg_handoff_ip(void)
|
|||
dissector_add_uint("arcnet.protocol_id", ARCNET_PROTO_IP_1201, ip_handle);
|
||||
dissector_add_uint("ax25.pid", AX25_P_IP, ip_handle);
|
||||
dissector_add_handle("udp.port", ip_handle);
|
||||
|
||||
heur_dissector_add("tipc", dissect_ip_heur, proto_ip);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue