Skip to content

Commit

Permalink
Merge pull request #2 from negbie/master
Browse files Browse the repository at this point in the history
Makefile
  • Loading branch information
negbie authored Aug 4, 2018
2 parents e52a805 + 149ec80 commit 3bd7855
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 35 deletions.
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

NAME?=go-peafowl

all:
@ if [ ! -d "peafowl_lib" ]; then git clone https://github.com/DanieleDeSensi/Peafowl.git peafowl_lib; fi;
@ if [ ! -f peafowl_lib/lib/libdpi.a ]; then make -C peafowl_lib; fi;

go build -ldflags "-s -w" -o $(NAME) *.go

debug:
go build -o $(NAME) *.go

.PHONY: clean
clean:
rm -fr $(NAME)
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# go-peafowl

```
chmod +x compile.sh
./compile.sh
go build
make
./go-peafowl -rf pcap/http.pcap
```


Expand Down
17 changes: 0 additions & 17 deletions compile.sh

This file was deleted.

29 changes: 14 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ package main
#include "peafowl_lib/src/api.h"
#ifdef WIN32
#define gopacket_time_secs_t long
#define gopacket_time_usecs_t long
#define dpi_time_secs_t long
#define dpi_time_usecs_t long
#elif __APPLE__
#define gopacket_time_secs_t __darwin_time_t
#define gopacket_time_usecs_t __darwin_suseconds_t
#define dpi_time_secs_t __darwin_time_t
#define dpi_time_usecs_t __darwin_suseconds_t
#elif __ANDROID__
#define gopacket_time_secs_t __kernel_time_t
#define gopacket_time_usecs_t __kernel_suseconds_t
#define dpi_time_secs_t __kernel_time_t
#define dpi_time_usecs_t __kernel_suseconds_t
#elif __GLIBC__
#define gopacket_time_secs_t __time_t
#define gopacket_time_usecs_t __suseconds_t
#define dpi_time_secs_t __time_t
#define dpi_time_usecs_t __suseconds_t
#else // Some form of linux/bsd/etc...
#include <sys/param.h>
#ifdef __OpenBSD__
#define gopacket_time_secs_t u_int32_t
#define gopacket_time_usecs_t u_int32_t
#define dpi_time_secs_t u_int32_t
#define dpi_time_usecs_t u_int32_t
#else
#define gopacket_time_secs_t time_t
#define gopacket_time_usecs_t suseconds_t
#define dpi_time_secs_t time_t
#define dpi_time_usecs_t suseconds_t
#endif
#endif
Expand Down Expand Up @@ -59,7 +59,6 @@ u_int32_t rtp_matches=0;
u_int32_t sip_matches=0;
// init state
int init()
{
Expand Down Expand Up @@ -261,8 +260,8 @@ func main() {
}

var hdr C.struct_pcap_pkthdr
hdr.ts.tv_sec = C.gopacket_time_secs_t(ci.Timestamp.Unix())
hdr.ts.tv_usec = C.gopacket_time_usecs_t(ci.Timestamp.Nanosecond() / 1000)
hdr.ts.tv_sec = C.dpi_time_secs_t(ci.Timestamp.Unix())
hdr.ts.tv_usec = C.dpi_time_usecs_t(ci.Timestamp.Nanosecond() / 1000)
hdr.caplen = C.bpf_u_int32(len(data)) // Trust actual length over ci.Length.
hdr.len = C.bpf_u_int32(ci.Length)

Expand Down

0 comments on commit 3bd7855

Please sign in to comment.