Skip to content

Commit

Permalink
Merge branch 'rc-4.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
salcock committed Nov 15, 2017
2 parents 6463f32 + 21c7681 commit 14b7489
Show file tree
Hide file tree
Showing 51 changed files with 3,712 additions and 286 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ test/test-live-snaplen
test/test-pcap-bpf
test/test-plen
test/test-ports
test/test-setcaplen
test/test-time
test/test-tracetime-parallel
test/test-vxlan
test/test-wireless
test/test-write
test/*.dSYM/
test/DPDK_source/
test/DPDK_builds/
tools/traceanon/traceanon
Expand Down
14 changes: 8 additions & 6 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ The primary authors of libtrace were:
* Daniel Lawson
* Richard Sanger

Libtrace is currently maintained by Shane Alcock <salcock@waikato.ac.nz>.
Libtrace is currently maintained by the LibtraceTeam on Github:
https://github.com/LibtraceTeam.

However, we would also like to acknowledge a number of people who have
However, we would also like to acknowledge a number of people who have
generously contributed bug-fixes, extensions and other improvements over the
years. It is contributions like these that help keep libtrace relevant and
useful to a broad community, so thanks very much.

In no particular order, we would like to recognise:

* Matt Brown for getting us into Debian and keeping us up to date.
* Brad Cowie for packaging libtrace4 for Debian and Ubuntu
* Alistair King for reporting and suggesting fixes for numerous bugs,
* Brad Cowie for packaging libtrace4 for Debian and Ubuntu.
* Alistair King for reporting and suggesting fixes for numerous bugs,
particularly in libwandio
* Simon Wadsworth for writing the original version of most of the OSPF code
* Nevil Brownlee for reporting a huge number of bugs
Expand All @@ -35,5 +36,6 @@ In no particular order, we would like to recognise:
* Brendon Jones for creating the original Windows DLLs and writing bits of
code here and there

Apologies to anyone that we've missed out or forgotten. If you're really
offended, fire us an email and we'll add you to the list.
Apologies to anyone that we've missed out or forgotten. If you're really
offended, fire one of us an email and we'll make sure you are added to the
list.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
libtrace 4.0.1
libtrace 4.0.2

---------------------------------------------------------------------------
Copyright (c) 2007-2017 The University of Waikato, Hamilton, New Zealand.
Expand Down
7 changes: 3 additions & 4 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# Now you only need to update the version number in two places - below,
# and in the README

AC_INIT([libtrace],[4.0.1],[contact@wand.net.nz],[libtrace])
AC_INIT([libtrace],[4.0.2],[contact@wand.net.nz],[libtrace])

LIBTRACE_MAJOR=4
LIBTRACE_MID=0
LIBTRACE_MINOR=1
LIBTRACE_MINOR=2

# OpenSolaris hides libraries like libncurses in /usr/gnu/lib, which is not
# searched by default - add it to LDFLAGS so we at least have a chance of
Expand Down Expand Up @@ -125,7 +125,7 @@ AC_PROG_LIBTOOL
AC_PROG_GCC_TRADITIONAL

# Fail if any of these functions are missing
AC_CHECK_FUNCS(socket strdup strlcpy strcasecmp strncasecmp snprintf vsnprintf)
AC_CHECK_FUNCS(socket strdup strlcpy strcasecmp strncasecmp snprintf vsnprintf recvmmsg)

AC_CHECK_SIZEOF([long int])

Expand Down Expand Up @@ -249,7 +249,6 @@ else
TOOL_LIBS="$TOOL_LIBS -lpcap"
LIBTRACE_LIBS="$LIBTRACE_LIBS -lpcap"
AC_DEFINE([HAVE_LIBPCAP],1,[compile with libpcap support])
AC_DEFINE([HAVE_BPF_FILTER],1,[compile with bpf filter support])

LIBS="-lpcap"
AC_CHECK_FUNCS(pcap_inject pcap_sendpacket pcap_setnonblock)
Expand Down
4 changes: 2 additions & 2 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ libtrace_la_SOURCES = trace.c trace_parallel.c common.h \
format_erf.c format_pcap.c format_legacy.c \
format_rt.c format_helper.c format_helper.h format_pcapfile.c \
format_duck.c format_tsh.c $(NATIVEFORMATS) $(BPFFORMATS) \
format_atmhdr.c \
format_atmhdr.c format_pcapng.c \
libtrace_int.h lt_inttypes.h lt_bswap.h \
linktypes.c link_wireless.c byteswap.c \
checksum.c checksum.h \
protocols_pktmeta.c protocols_l2.c protocols_l3.c \
protocols_transport.c protocols.h protocols_ospf.c \
protocols_application.c \
$(DAGSOURCE) format_erf.h \
$(DAGSOURCE) format_erf.h format_ndag.c format_ndag.h \
$(BPFJITSOURCE) \
libtrace_arphrd.h \
data-struct/ring_buffer.c data-struct/vector.c \
Expand Down
4 changes: 3 additions & 1 deletion lib/format_erf.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ typedef struct erf_index_t {
*/
static int erf_get_padding(const libtrace_packet_t *packet)
{
if (packet->trace->format->type==TRACE_FORMAT_ERF) {
if (packet->trace->format->type==TRACE_FORMAT_ERF ||
packet->trace->format->type == TRACE_FORMAT_NDAG ||
packet->trace->format->type == TRACE_FORMAT_RAWERF) {
dag_record_t *erfptr = (dag_record_t *)packet->header;
switch((erfptr->type & 0x7f)) {
case TYPE_ETH:
Expand Down
81 changes: 81 additions & 0 deletions lib/format_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,84 @@ void trace_set_err_out(libtrace_out_t *trace,int errcode,const char *msg,...)
}
va_end(va);
}

/** Attempts to determine the direction for a pcap (or pcapng) packet.
*
* @param packet The packet in question.
* @return A valid libtrace_direction_t describing the direction that the
* packet was travelling, if direction can be determined. Otherwise
* returns TRACE_DIR_UNKNOWN.
* @internal
*
* Note that we can determine the direction for only certain types of packets
* if they are captured using pcap/pcapng, specifically SLL and PFLOG captures.
*/
libtrace_direction_t pcap_get_direction(const libtrace_packet_t *packet) {
libtrace_direction_t direction = -1;
switch(pcap_linktype_to_libtrace(rt_to_pcap_linktype(packet->type))) {
/* We can only get the direction for PCAP packets that have
* been encapsulated in Linux SLL or PFLOG */
case TRACE_TYPE_LINUX_SLL:
{
libtrace_sll_header_t *sll;
libtrace_linktype_t linktype;

sll = (libtrace_sll_header_t*)trace_get_packet_buffer(
packet,
&linktype,
NULL);
if (!sll) {
trace_set_err(packet->trace,
TRACE_ERR_BAD_PACKET,
"Bad or missing packet");
return -1;
}
/* 0 == LINUX_SLL_HOST */
/* the Waikato Capture point defines "packets
* originating locally" (ie, outbound), with a
* direction of 0, and "packets destined locally"
* (ie, inbound), with a direction of 1.
* This is kind-of-opposite to LINUX_SLL.
* We return consistent values here, however
*
* Note that in recent versions of pcap, you can
* use "inbound" and "outbound" on ppp in linux
*/
if (ntohs(sll->pkttype == 0)) {
direction = TRACE_DIR_INCOMING;
} else {
direction = TRACE_DIR_OUTGOING;
}
break;

}
case TRACE_TYPE_PFLOG:
{
libtrace_pflog_header_t *pflog;
libtrace_linktype_t linktype;

pflog=(libtrace_pflog_header_t*)trace_get_packet_buffer(
packet,&linktype,NULL);
if (!pflog) {
trace_set_err(packet->trace,
TRACE_ERR_BAD_PACKET,
"Bad or missing packet");
return -1;
}
/* enum { PF_IN=0, PF_OUT=1 }; */
if (ntohs(pflog->dir==0)) {

direction = TRACE_DIR_INCOMING;
}
else {
direction = TRACE_DIR_OUTGOING;
}
break;
}
default:
break;
}
return direction;
}


16 changes: 16 additions & 0 deletions lib/format_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,20 @@ iow_t *trace_open_file_out(libtrace_out_t *libtrace,
int compress_type,
int level,
int filemode);


/** Attempts to determine the direction for a pcap (or pcapng) packet.
*
* @param packet The packet in question.
* @return A valid libtrace_direction_t describing the direction that the
* packet was travelling, if direction can be determined. Otherwise
* returns TRACE_DIR_UNKNOWN.
*
* Note that we can determine the direction for only certain types of packets
* if they are captured using pcap/pcapng, specifically SLL and PFLOG captures.
*/
libtrace_direction_t pcap_get_direction(const libtrace_packet_t *packet);



#endif /* FORMAT_HELPER_H */
6 changes: 4 additions & 2 deletions lib/format_linux_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int linuxcommon_probe_filename(const char *filename)
/* Compiles a libtrace BPF filter for use with a linux native socket */
static int linuxnative_configure_bpf(libtrace_t *libtrace,
libtrace_filter_t *filter) {
#ifdef HAVE_LIBPCAP
#if defined(HAVE_LIBPCAP) && defined(HAVE_BPF)
struct ifreq ifr;
unsigned int arphrd;
libtrace_dlt_t dlt;
Expand Down Expand Up @@ -124,7 +124,7 @@ static int linuxnative_configure_bpf(libtrace_t *libtrace,

return 0;
#else
return -1
return -1;
#endif
}

Expand Down Expand Up @@ -403,6 +403,7 @@ int linuxcommon_start_input_stream(libtrace_t *libtrace,
* that the filterstring has been compiled, or the filter was supplied
* pre-compiled.
*/
#ifdef HAVE_BPF
if (filter != NULL) {
/* Check if the filter was successfully compiled. If not,
* it is probably a bad filter and we should return an error
Expand All @@ -423,6 +424,7 @@ int linuxcommon_start_input_stream(libtrace_t *libtrace,
perror("setsockopt(SO_ATTACH_FILTER)");
}
}
#endif

/* Consume any buffered packets that were received before the socket
* was properly setup, including those which missed the filter and
Expand Down
Loading

0 comments on commit 14b7489

Please sign in to comment.