cisco / mercury

Mercury: network metadata capture and analysis
Other
445 stars 76 forks source link

Big Sur Mac Support Documentation #11

Closed IrPgFKS0 closed 3 years ago

IrPgFKS0 commented 3 years ago

Any guidance compiling this for Big Sur, I get compiling errors, but I was able to compile and install Cisco Joy just fine, what are the dependencies I am missing for Mercury?

davidmcgrew commented 3 years ago

Thanks for reporting this! Basically, there are a few places in mercury where size_t should be replaced with uint64_t. MacOS builds are failing with the error "cannot initialize a parameter of type 'size_t ' (aka 'unsigned long ') with an rvalue of type 'uint64_t ' (aka 'unsigned long long ')". Bitten by the integer size non-portability gremlin. I'll fix this sometime this week.

Please note that mercury won't run in capture mode on MacOS, even after the above code changes are made, because it uses AF_PACKET, which is a Linux kernel specific interface. It would be nice to have a BSD/MacOS native capture capability, there, but we don't have plans to add that code soon. At least I don't.

IrPgFKS0 commented 3 years ago

Thank you for the quick response, Mac support might easily be added by just piping Wireshark's dumpcap -w - or tcpdump -w - binary output as a file to mercury, I can test that once I get it installed to see if that may be a clean workaround for capturing on Mac's.

davidmcgrew commented 3 years ago

The last commit https://github.com/cisco/mercury/commit/b1201adf2c14ed07d64030c94925dd37f30aea4f should have fixed the mercury build. Can you please verify? Mercury can read a PCAP file from the standard input, so your dumpcap suggestion sounds perfect as a workaround.

Some of the other utilities (like libmerc_test) won't build (at least with clang).

Thanks!

IrPgFKS0 commented 3 years ago

Looks like it got a lot further, however I am still getting this error...

In file included from ./json_object.h:11:
./datum.h:252:119: warning: format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
            mercury_debug("%s: num_bytes: %u, value (hex) %08x (decimal): %zu\n", __func__, num_bytes, (unsigned)tmp, tmp);
                                                                          ~~~                                         ^~~
                                                                          %llu
./datum.h:27:46: note: expanded from macro 'mercury_debug'
#define mercury_debug(...)  (fprintf(stdout, __VA_ARGS__))
                                             ^~~~~~~~~~~

cd lctrie && /Applications/Xcode.app/Contents/Developer/usr/bin/make liblctrie.a
g++ -MT lctrie.o -MMD -MP -MF .d/lctrie.Td -g -ggdb -std=c++11 -Wall -O3 -fPIC  -I/usr/local/opt/openssl@1.1/include  -c -o lctrie.o lctrie.c
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
mv -f .d/lctrie.Td .d/lctrie.d
g++ -MT lctrie_bgp.o -MMD -MP -MF .d/lctrie_bgp.Td -g -ggdb -std=c++11 -Wall -O3 -fPIC  -I/usr/local/opt/openssl@1.1/include  -c -o lctrie_bgp.o lctrie_bgp.c
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
mv -f .d/lctrie_bgp.Td .d/lctrie_bgp.d
g++ -MT lctrie_ip.o -MMD -MP -MF .d/lctrie_ip.Td -g -ggdb -std=c++11 -Wall -O3 -fPIC  -I/usr/local/opt/openssl@1.1/include  -c -o lctrie_ip.o lctrie_ip.c
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
mv -f .d/lctrie_ip.Td .d/lctrie_ip.d
ar rcs liblctrie.a lctrie.o lctrie_bgp.o lctrie_ip.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: liblctrie.a(lctrie.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: liblctrie.a(lctrie_ip.o) has no symbols
ar -x lctrie/liblctrie.a
g++ -shared -fPIC -Wl,-soname,libmerc.so.0 -o libmerc.so analysis.o addr.o dns.o datum.o extractor.o http.o libmerc.o match.o packet.o pkt_proc.o ssh.o tls.o udp.o utils.o wireguard.o lctrie.o lctrie_ip.o lctrie_bgp.o
ld: unknown option: -soname
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libmerc.so] Error 1
make[1]: *** [libmerc] Error 2
make: *** [install-mercury] Error 2
IrPgFKS0 commented 3 years ago

Commit b1201ad resolved the issue, thank you!