Problem with the payload given to callback function by pcap_loop

Bug #504324 reported by Johan.Mazel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mlpcap (Ubuntu)
New
Undecided
Unassigned

Bug Description

My configuration is the following one:
*lsb_release -rd gives:
Description: Ubuntu 9.10
Release: 9.10
*apt-cache policy libmlpcap-ocaml gives:
libmlpcap-ocaml:
  Installé : 0.9-14build1
  Candidat : 0.9-14build1
 Table de version :
 *** 0.9-14build1 0
        500 http://fr.archive.ubuntu.com karmic/universe Packages
        100 /var/lib/dpkg/status

Context:
If you use pcap_loop, to launch a callback function, there is a problem.
The call function is supposed to look like something similar to this: "let callback_process _ pkt_hdr pcap_payload = ...".
The type of pkt_hdr is PCAP.struct2.
The type of pcap_payload is string.

What is supposed to happen:
The field caplen of pkt_hdr is supposed to contain the number of bytes inside the captured packet. This works perfectly.
The packet itself is supposed to be contained inside pcap_payload. The size of pcap_payload is supposed to be equal to caplen and the size of the packet captured

What happens instead:
The size of pcap_payload is always -1. This means that we can never access to the data inside the packet.

I added an archive to this post with a simple example which show the problem.
To use this code once compiled with whatever tool you want to use, simply give a trace name as the first parameter.

Revision history for this message
Johan.Mazel (johan-mazel) wrote :
Revision history for this message
Johan.Mazel (johan-mazel) wrote :

Precision:
To compile the code you need to type these three lines:
ocamlfind ocamlopt -package pcap, -c packet_analyser.ml
ocamlfind ocamlopt -package pcap, -c main.ml
ocamlfind ocamlopt -package pcap, -linkpkg -cclib -lutil -o main packet_analyser.cmx main.cmx

I'm not sure these are the perfect commands for teh compilation because my knowledge of ocaml's compilation is very small.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.