--- /dev/null
+libpcap-dev
+libpcre3-dev
#include <unistd.h>
#define IFTTY_STDOUT(x) (istty_stdout ? (x) : "")
-uint8_t istty_stdout;
+extern uint8_t istty_stdout;
#define IFTTY_STDERR(x) (istty_stderr ? (x) : "")
-uint8_t istty_stderr;
+extern uint8_t istty_stderr;
#define C_RED_LIGHT "1;31"
#define C_GREEN_LIGHT "1;32"
#define C_CYAN_LIGHT "1;36"
/* Must be called at least once to determine where stdout, stderr refer to. */
+#define CPRINT_SETUP uint8_t istty_stdout, istty_stderr;
#define CPRINT_INIT {\
istty_stdout = isatty(STDOUT_FILENO); \
istty_stderr = isatty(STDERR_FILENO); \
#define IPVERSION 4
+#ifndef IPPROTO_TCP
#define IPPROTO_TCP 6
+#endif
+
+#ifndef IPPROTO_UDP
#define IPPROTO_UDP 17
+#endif
/* TCP */
#define BPF bpf_s
#define BPF_OPTIMIZE 1
+CPRINT_SETUP
+
int main (int argc, char *argv[])
{
/* Name of the network interface to capture from. */
/* Read context. */
ctx.in = payload;
ctx.read_bytes_available = payload_length;
+#pragma GCC diagnostic push
+ /* Here we read the address of a local variable into a pointer.
+ * The pointer becomes dangling if used outside the frame of
+ * the current function. This doesn't happen. The pointer is
+ * used by nested function calls so we suppress the warning. */
+#pragma GCC diagnostic ignored "-Wdangling-pointer"
tls_in = &ctx;
+#pragma GCC diagnostic pop
while (ctx.read_bytes_available > 0) {
/* read SSL/TLS record header */