Custom Query (89 matches)

Filters
 
Or
 
  
 
Columns

Show under each result:


Results (67 - 69 of 89)

Ticket Resolution Summary Owner Reporter
#322 fixed Shift overflow salcock kaiux
Description

Build a simple code with clang gives the following warning:

/usr/local/include/libtrace.h:376:22: warning: signed shift result (0x100000000) requires 34 bits to represent, but 'int' only has 32 bits

[-Wshift-overflow]

TRACE_RT_LAST = (2<<31)

~

#335 fixed Fix RT export of native format packets salcock salcock
Description

Need to think a bit more about the availability of the various format prepare_packet functions, especially for formats that we compile conditionally.

For example, imagine a setup where a monitor is capturing using int: on a Linux machine and exporting over RT to a BSD client. The BSD client will not be able to decode the packets correctly because format_linux.c will not have been built - so it can't create a dummy int: trace or call trace_prepare_packet using it.

Instead, we need to consider re-aligning the conditional compilation to at least build a barebones version of the format that includes all the packet parsing and preparation functions but not init, read, write etc.

Not a huge priority, because we're not likely to need this anytime soon but is a bit of a major oversight...

#395 fixed Support for pcap-ng / pcap nanosecond resolution rjs51 mbligh@…
Description

Ugh. This thing doesn't seem to support attachement. There's no email address I can see.

diff --git a/trace/libtrace-3.0.18/lib/format_pcapfile.c b/trace/libtrace-3.0.18/lib/format_pcapfile.c index 2ef6417..71d6aff 100644 --- a/trace/libtrace-3.0.18/lib/format_pcapfile.c +++ b/trace/libtrace-3.0.18/lib/format_pcapfile.c @@ -71,6 +71,23 @@ typedef struct pcapfile_header_t {

uint32_t network; /* data link type */

} pcapfile_header_t;

+#define MAGIC1 0xa1b2c3d4 Original +#define MAGIC2 0xa1b23c4d Newer nanosecond format + +static inline int header_is_backwards_magic(pcapfile_header_t *header) {

+ return (header->magic_number == byteswap32(MAGIC1)
header->magic_number == byteswap32(MAGIC2));

+} + +static inline int header_is_magic(pcapfile_header_t *header) {

+ return (header->magic_number == MAGIC1
header->magic_number == MAGIC2

+ header_is_backwards_magic(header)); +} + +static inline int trace_in_nanoseconds(pcapfile_header_t *header) { + Sadly, nothing seems to use sigfigs. Sigh.

+ return (header->magic_number == MAGIC2
header->magic_number == byteswap32(MAGIC2));

+} +

struct pcapfile_format_data_t {

struct {

/* Indicates whether the event API should replicate the pauses

@@ -98,18 +115,20 @@ static int pcapfile_probe_magic(io_t *io)

pcapfile_header_t header; int len; len = wandio_peek(io, &header, sizeof(header));

+

/* Is this long enough? */ if (len < (int)sizeof(header)) {

return 0;

} /* Pcap magic? */

if (header.magic_number == 0xa1b2c3d4
header.magic_number == 0xd4c3b2a1) {

+ if (header_is_magic(&header)) {

return 1;

} /* Nope, not pcap */ return 0;

}

+

static int pcapfile_init_input(libtrace_t *libtrace) {

libtrace->format_data = malloc(sizeof(struct pcapfile_format_data_t));

@@ -145,7 +164,7 @@ static inline uint16_t swaps(libtrace_t *libtrace, uint16_t num)

return num;

/* We can use the PCAP magic number to determine the byte order */

  • if (DATA(libtrace)->header.magic_number == 0xd4c3b2a1)

+ if (header_is_backwards_magic(&(DATA(libtrace)->header)))

return byteswap16(num);

return num;

@@ -160,7 +179,7 @@ static inline uint32_t swapl(libtrace_t *libtrace, uint32_t num)

return num;

/* We can use the PCAP magic number to determine the byte order */

  • if (DATA(libtrace)->header.magic_number == 0xd4c3b2a1)

+ if (header_is_backwards_magic(&(DATA(libtrace)->header)))

return byteswap32(num);

return num;

@@ -196,10 +215,10 @@ static int pcapfile_start_input(libtrace_t *libtrace)

return -1;

}

  • if (swapl(libtrace,DATA(libtrace)->header.magic_number) !=
  • 0xa1b2c3d4) {

+ if (!header_is_magic(&(DATA(libtrace)->header))) {

trace_set_err(libtrace,TRACE_ERR_INIT_FAILED,

"Not a pcap tracefile (magic=%08x)\n",swapl(libtrace,DATA(libtrace)->header.magic_number));

+ fprintf(stderr, "Not a pcap tracefile (magic=%08x)\n",swapl(libtrace,DATA(libtrace)->header.magic_number));

return -1; /* Not a pcap file */

}

@@ -593,7 +612,28 @@ static struct timeval pcapfile_get_timeval(

hdr = (libtrace_pcapfile_pkt_hdr_t*)packet->header; ts.tv_sec = swapl(packet->trace,hdr->ts_sec);

  • ts.tv_usec = swapl(packet->trace,hdr->ts_usec);

+ if (trace_in_nanoseconds(packet->header)) + ts.tv_usec = swapl(packet->trace, hdr->ts_usec) / 1000; + else + ts.tv_usec = swapl(packet->trace,hdr->ts_usec); + return ts; +} + +static struct timespec pcapfile_get_timespec( + const libtrace_packet_t *packet) +{ + libtrace_pcapfile_pkt_hdr_t *hdr; + pcapfile_header_t *header = &(DATA(packet->trace)->header); + struct timespec ts; + + assert(packet->header); + + hdr = (libtrace_pcapfile_pkt_hdr_t*)packet->header; + ts.tv_sec = swapl(packet->trace,hdr->ts_sec); + if (trace_in_nanoseconds(header)) + ts.tv_nsec = swapl(packet->trace, hdr->ts_usec); + else + ts.tv_nsec = swapl(packet->trace, hdr->ts_usec) * 1000;

return ts;

}

@@ -715,7 +755,7 @@ static struct libtrace_format_t pcapfile = {

NULL, /* set_direction */ NULL, /* get_erf_timestamp */ pcapfile_get_timeval, /* get_timeval */

  • NULL, /* get_timespec */

+ pcapfile_get_timespec, /* get_timespec */

NULL, /* get_seconds */ NULL, /* seek_erf */ NULL, /* seek_timeval */

Note: See TracQuery for help on using queries.