Skip to content

Commit 90d1c84

Browse files
authored
Merge pull request #54 from CESNET/devel
Bugfixes and improvements
2 parents 185c52b + 754addb commit 90d1c84

File tree

24 files changed

+739
-125
lines changed

24 files changed

+739
-125
lines changed

Makefile.am

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ SUBDIRS+=input/nfbCInterface
55
endif
66

77
SUBDIRS+=. tests init
8-
bin_PROGRAMS=ipfixprobe
8+
bin_PROGRAMS=ipfixprobe ipfixprobe_stats
99

1010
DISTCHECK_CONFIGURE_FLAGS="--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)"
1111

12-
ipfixprobe_LDFLAGS=-lpthread -ldl
12+
ipfixprobe_LDFLAGS=-lpthread -ldl -latomic
1313
ipfixprobe_CFLAGS=-I$(srcdir)/include/
1414
ipfixprobe_CXXFLAGS=-std=gnu++11 -Wno-write-strings -I$(srcdir)/include/
1515

@@ -181,6 +181,8 @@ ipfixprobe_src=\
181181
ring.c \
182182
workers.cpp \
183183
workers.hpp \
184+
stats.cpp \
185+
stats.hpp \
184186
ipfixprobe.hpp \
185187
ipfixprobe.cpp
186188

@@ -192,6 +194,15 @@ endif
192194

193195
ipfixprobe_SOURCES=$(ipfixprobe_src) main.cpp
194196

197+
ipfixprobe_stats_CXXFLAGS=-std=gnu++11 -Wno-write-strings -I$(srcdir)/include/
198+
ipfixprobe_stats_SOURCES=ipfixprobe_stats.cpp \
199+
include/ipfixprobe/options.hpp \
200+
include/ipfixprobe/utils.hpp \
201+
stats.cpp \
202+
stats.hpp \
203+
options.cpp \
204+
utils.cpp
205+
195206
pkgdocdir=${docdir}/ipfixprobe
196207
pkgdoc_DATA=README.md
197208
EXTRA_DIST=README.md \

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This application creates biflows from packet input and exports them to output interface.
55

66
## Requirements
7+
- libatomic
78
- kernel version at least 3.19 when using raw sockets input plugin enabled by default (disable with `--without-raw` parameter for `./configure`)
89
- [libpcap](http://www.tcpdump.org/) when compiling with pcap plugin (`--with-pcap` parameter)
910
- netcope-common [COMBO cards](https://www.liberouter.org/technologies/cards/) when compiling with ndp plugin (`--with-ndp` parameter)
@@ -231,10 +232,12 @@ List of unirec fields exported together with basic flow fields on interface by R
231232
### TLS
232233
List of unirec fields exported together with basic flow fields on interface by TLS plugin.
233234

234-
| UniRec field | Type | Description |
235-
|:-------------------:|:------:|:----------------------------:|
236-
| TLS_SNI | string | TLS server name indication |
237-
| TLS_JA3 | string | TLS client JA3 fingerprint |
235+
| UniRec field | Type | Description |
236+
|:-------------------:|:------:|:-------------------------------------------------------------:|
237+
| TLS_SNI | string | TLS server name indication field from client |
238+
| TLS_ALPN | string | TLS application protocol layer negotiation field from server |
239+
| TLS_VERSION | uint16 | TLS client protocol version |
240+
| TLS_JA3 | string | TLS client JA3 fingerprint |
238241

239242
### DNS
240243
List of unirec fields exported together with basic flow fields on interface by DNS plugin.
@@ -411,7 +414,7 @@ Note: the following fields are UniRec arrays.
411414

412415
##### Example:
413416
```
414-
ipfixprobe -p pstats:includezeros -r sample.pcap -i "f:output.trapcap"
417+
ipfixprobe 'pcap;file=pcaps/http.pcap' -p pstats:includezeros -o 'unirec;i=u:stats:timeout=WAIT;p=stats'"
415418
```
416419

417420
### OSQUERY
@@ -522,7 +525,7 @@ The exported unirec fields and IPFIX basiclists is shown in following table:
522525

523526
##### Example:
524527
```
525-
ipfixprobe -p phists:includezeros -r sample.pcap -i "f:output.trapcap"
528+
ipfixprobe 'pcap;file=pcaps/http.pcap' -p phists:includezeros -o 'unirec;i=u:hists:timeout=WAIT;p=phists'"
526529
```
527530
### BSTATS
528531

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ AC_TYPE_UINT8_T
7373
AX_C_BIGENDIAN_CROSS
7474

7575

76+
AC_ARG_WITH([defaultsocketdir],
77+
[AS_HELP_STRING([--with-defaultsocketdir=DIR], [Directory for UNIX&service IFCs [/tmp], for production set it to e.g. /var/run/ipfixprobe.])],
78+
[],
79+
[with_defaultsocketdir=/tmp])
80+
81+
AC_SUBST([defaultsocketdir], [$with_defaultsocketdir])
82+
AC_DEFINE_DIR([DEFAULTSOCKETDIR], [defaultsocketdir], [Default path to socket directory])
83+
84+
AC_CHECK_LIB(atomic, __atomic_store, [libatomic=yes], AC_MSG_ERROR([libatomic not found]))
85+
7686
### gtest
7787
AC_ARG_WITH([gtest],
7888
AC_HELP_STRING([--with-gtest],[Compile ipfixprobe with gtest framework]),

include/ipfixprobe/input.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ class InputPlugin : public Plugin
6666
ERROR
6767
};
6868

69-
uint64_t m_processed;
69+
uint64_t m_seen;
7070
uint64_t m_parsed;
71+
uint64_t m_dropped;
7172

72-
InputPlugin() : m_processed(0), m_parsed(0) {}
73+
InputPlugin() : m_seen(0), m_parsed(0), m_dropped(0) {}
7374
virtual ~InputPlugin() {}
7475

7576
virtual Result get(PacketBlock &packets) = 0;

include/ipfixprobe/ipfix-elements.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ namespace ipxp {
194194

195195
#define TLS_SNI(F) F(8057, 808, -1, nullptr)
196196
#define TLS_ALPN(F) F(8057, 809, -1, nullptr)
197+
#define TLS_VERSION(F) F(8057, 810, 2, nullptr)
197198
#define TLS_JA3(F) F(8057, 830, -1, nullptr)
198199

199200
#define SMTP_COMMANDS(F) F(8057, 810, 4, nullptr)
@@ -348,6 +349,7 @@ namespace ipxp {
348349
#define IPFIX_TLS_TEMPLATE(F) \
349350
F(TLS_SNI) \
350351
F(TLS_ALPN) \
352+
F(TLS_VERSION) \
351353
F(TLS_JA3)
352354

353355
#define IPFIX_NTP_TEMPLATE(F) \

input/benchmark.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ InputPlugin::Result Benchmark::get(PacketBlock &packets)
131131
break;
132132
}
133133
}
134-
m_processed += packets.cnt;
134+
m_seen += packets.cnt;
135135
m_parsed += packets.cnt;
136136
return res;
137137
}

input/parser.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
#include <iostream>
4848
#include <sys/types.h>
4949

50-
#ifndef WITH_NDP
50+
#ifdef WITH_PCAP
5151
#include <pcap/sll.h>
52-
#endif /* WITH_NDP */
52+
#endif /* WITH_PCAP */
5353

5454
#include "parser.hpp"
5555
#include "headers.hpp"
@@ -141,7 +141,7 @@ inline uint16_t parse_eth_hdr(const u_char *data_ptr, uint16_t data_len, Packet
141141
return hdr_len;
142142
}
143143

144-
#ifndef WITH_NDP
144+
#ifdef WITH_PCAP
145145
/**
146146
* \brief Parse specific fields from SLL frame header.
147147
* \param [in] data_ptr Pointer to begin of header.
@@ -178,7 +178,7 @@ inline uint16_t parse_sll(const u_char *data_ptr, uint16_t data_len, Packet *pkt
178178
pkt->ethertype = ntohs(sll->sll_protocol);
179179
return sizeof(struct sll_header);
180180
}
181-
#endif /* WITH_NDP */
181+
#endif /* WITH_PCAP */
182182

183183

184184
/**
@@ -614,15 +614,15 @@ void parse_packet(parser_opt_t *opt, struct timeval ts, const uint8_t *data, uin
614614
uint32_t l3_hdr_offset = 0;
615615
uint32_t l4_hdr_offset = 0;
616616
try {
617-
#ifndef WITH_NDP
617+
#ifdef WITH_PCAP
618618
if (opt->datalink == DLT_EN10MB) {
619619
data_offset = parse_eth_hdr(data, caplen, pkt);
620620
} else {
621621
data_offset = parse_sll(data, caplen, pkt);
622622
}
623623
#else
624624
data_offset = parse_eth_hdr(data, caplen, pkt);
625-
#endif /* WITH_NDP */
625+
#endif /* WITH_PCAP */
626626

627627
if (pkt->ethertype == ETH_P_TRILL) {
628628
data_offset += parse_trill(data + data_offset, caplen - data_offset, pkt);

input/pcap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,13 @@ InputPlugin::Result PcapReader::get(PacketBlock &packets)
263263
return Result::TIMEOUT;
264264
}
265265
if (ret > 0) {
266-
m_processed += ret;
266+
m_seen += ret;
267267
m_parsed += opt.pblock->cnt;
268268
return opt.packet_valid ? Result::PARSED : Result::NOT_PARSED;
269269
}
270270
} else {
271271
if (opt.pblock->cnt) {
272-
m_processed += ret ? ret : opt.pblock->cnt;
272+
m_seen += ret ? ret : opt.pblock->cnt;
273273
m_parsed += opt.pblock->cnt;
274274
return Result::PARSED;
275275
} else if (ret == 0) {

input/pcap.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class PcapOptParser : public OptionsParser
8282
register_option("f", "file", "PATH", "Path to a pcap file", [this](const char *arg){m_file = arg; return true;}, OptionFlags::RequiredArgument);
8383
register_option("i", "ifc", "IFC", "Network interface name", [this](const char *arg){m_ifc = arg; return true;}, OptionFlags::RequiredArgument);
8484
register_option("F", "filter", "STR", "Filter string", [this](const char *arg){m_filter = arg; return true;}, OptionFlags::RequiredArgument);
85-
register_option("s", "snaplen", "SIZE", "Snapshot length in bytes",
85+
register_option("s", "snaplen", "SIZE", "Snapshot length in bytes (live capture only)",
8686
[this](const char *arg){try {m_snaplen = str2num<decltype(m_snaplen)>(arg);} catch(std::invalid_argument &e) {return false;} return true;},
8787
OptionFlags::RequiredArgument);
8888
register_option("l", "list", "", "Print list of available interfaces", [this](const char *arg){m_list = true; return true;}, OptionFlags::NoArgument);

input/raw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ InputPlugin::Result RawReader::get(PacketBlock &packets)
369369
throw PluginError("error during reading from socket");
370370
}
371371

372-
m_processed += ret;
372+
m_seen += ret;
373373
m_parsed += packets.cnt;
374374
return packets.cnt ? Result::PARSED : Result::NOT_PARSED;
375375
}

0 commit comments

Comments
 (0)