problem with fragment_add_seq_next
A pcap file have 5 packet with the following parameters. these packets must be reassembled and formed two 2 different messages.
message 1 = packet 1 + packet 2 + packet 3(first_part_of_packet 3);
message 2 = packet 3(second_part_of_packet 3) + packet 4 + packet 5;
packet 1: id =1; start_flag =1; end_flag = 0; cont_flag = 0;
packet 2: id =1; start_flag =0; end_flag = 0; cont_flag = 1;
packet 3: first part of packet 3 : id =1; start_flag =0; end_flag = 1; cont_flag = 0;
packet 3: second part of packet 3 : id =1; start_flag =1; end_flag = 0; cont_flag = 0;
packet 4: id =1; start_flag =0; end_flag = 0; cont_flag = 1;
packet 5: id =1; start_flag =0; end_flag = 1; cont_flag = 0;
result:
message 1 = packet 1 + packet 2 + packet 3(first_part_of_packet 3);
message 2 = packet 4 + packet 5;
how can I fix this problem.
static int
desegment_fnc( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_ ,guint8 start_flag ,guint8 end_flag ,guint8 cont_flag, guint8 reassembly_id)
{
...
...
fragment_head *head = NULL;
head = fragment_add_seq_next(&myproto_reassembly_table, tvb, offset ,pinfo, reassembly_id, tvb_captured_length(tvb), moregrag);
...
...
return tvb_captured_length(tvb);
}
static int
dissect_myproto( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_ )
{
if (cond1)
{
...
...
tvbuff_t *next_tvb = tvb_new_subset_remaining(tvb, offset);
...
...
start_flag =1;end_flag = 0; cont_flag = 0;
desegment_fnc(next_tvb, pinfo ,tree, id, start_flag ,end_flag , cont_flag, id);
}
else if (cond2)
{
...
...
tvbuff_t *next_tvb = tvb_new_subset_remaining(tvb, offset);
...
...
start_flag =0; end_flag = 0; cont_flag = 1;
desegment_fnc(next_tvb, pinfo ,tree, id, start_flag ,end_flag , cont_flag, id);
}
else if (cond3) // packet 3
{
...
...
if(cond3_subcond) // first part of packet 3
{
// first part of packet 3
tvbuff_t *next_tvb = tvb_new_subset_remaining(tvb, offset); // tvb fot first part of packet 3
// process and extract info from next_tvb
...
...
start_flag =0; end_flag = 1; cont_flag = 0;
desegment_fnc(next_tvb, pinfo ,tree, id, start_flag ,end_flag , cont_flag, id);
}
else
{
// second part of packet 3
...
...
tvbuff_t *next_tvb = tvb_new_subset_remaining(tvb, offset); // tvb fot second part of packet 3
// process and extract info from next_tvb
...
...
start_flag =1; end_flag = 0; cont_flag = 0;
desegment_fnc(next_tvb, pinfo ,tree, id, start_flag ,end_flag , cont_flag, id);
}
}
return tvb_captured_length(tvb);
}