Qihoo360 / mysql-sniffer

mysql-sniffer is a network traffic analyzer tool for mysql, it is developed by Qihoo DBA and infrastructure team
MIT License
852 stars 295 forks source link

mac上编译失败 #28

Closed keladi closed 6 years ago

keladi commented 6 years ago

[ 14%] Building C object bin/CMakeFiles/mysql-sniffer.dir/main.c.o /tmp/mysql-sniffer/src/main.c:67:64: warning: declaration of 'struct iphdr' will not be visible outside of this function [-Wvisibility] void tcp_resume_is_client(struct tcphdr packet_tcphdr, struct iphdr packet_iphdr, int* is_client){ ^ /tmp/mysql-sniffer/src/main.c:80:37: error: no member named 'dest' in 'struct tcphdr' int port = ntohs(packet_tcphdr->dest);


/usr/include/sys/_endian.h:132:39: note: expanded from macro 'ntohs'
#define ntohs(x)        __DARWIN_OSSwapInt16(x)
                                             ^
/usr/include/libkern/_OSByteOrder.h:72:40: note: expanded from macro '__DARWIN_OSSwapInt16'
    ((__uint16_t)(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x)))
                                       ^
/tmp/mysql-sniffer/src/main.c:80:37: error: no member named 'dest' in 'struct tcphdr'
    int port = ntohs(packet_tcphdr->dest);
                     ~~~~~~~~~~~~~  ^
/usr/include/sys/_endian.h:132:39: note: expanded from macro 'ntohs'
#define ntohs(x)        __DARWIN_OSSwapInt16(x)
                                             ^
/usr/include/libkern/_OSByteOrder.h:72:71: note: expanded from macro '__DARWIN_OSSwapInt16'
    ((__uint16_t)(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x)))
                                                                      ^
/usr/include/libkern/_OSByteOrder.h:44:34: note: expanded from macro '__DARWIN_OSSwapConstInt16'
    ((__uint16_t)((((__uint16_t)(x) & 0xff00) >> 8) | \
                                 ^
/tmp/mysql-sniffer/src/main.c:80:37: error: no member named 'dest' in 'struct tcphdr'
    int port = ntohs(packet_tcphdr->dest);
                     ~~~~~~~~~~~~~  ^
/usr/include/sys/_endian.h:132:39: note: expanded from macro 'ntohs'
#define ntohs(x)        __DARWIN_OSSwapInt16(x)
                                             ^
/usr/include/libkern/_OSByteOrder.h:72:71: note: expanded from macro '__DARWIN_OSSwapInt16'
    ((__uint16_t)(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x)))
                                                                      ^
/usr/include/libkern/_OSByteOrder.h:45:32: note: expanded from macro '__DARWIN_OSSwapConstInt16'
                (((__uint16_t)(x) & 0x00ff) << 8)))
                               ^
/tmp/mysql-sniffer/src/main.c:80:37: error: no member named 'dest' in 'struct tcphdr'
    int port = ntohs(packet_tcphdr->dest);
                     ~~~~~~~~~~~~~  ^
/usr/include/sys/_endian.h:132:39: note: expanded from macro 'ntohs'
#define ntohs(x)        __DARWIN_OSSwapInt16(x)
                                             ^
/usr/include/libkern/_OSByteOrder.h:72:89: note: expanded from macro '__DARWIN_OSSwapInt16'
    ((__uint16_t)(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt16(x) : _OSSwapInt16(x)))
                                                                                        ^
/tmp/mysql-sniffer/src/main.c:87:28: error: incomplete definition of type 'struct iphdr'
            if(packet_iphdr->daddr == this_ipaddr.s_addr && config_is_server_port(port)){
               ~~~~~~~~~~~~^
/tmp/mysql-sniffer/src/main.c:67:64: note: forward declaration of 'struct iphdr'
void tcp_resume_is_client(struct tcphdr* packet_tcphdr, struct iphdr* packet_iphdr, int* is_client){
                                                               ^
/tmp/mysql-sniffer/src/main.c:147:9: warning: 'daemon' is deprecated: first deprecated in macOS 10.5 - Use posix_spawn APIs
      instead. [-Wdeprecated-declarations]
        daemon(1, 0);
        ^
/usr/include/stdlib.h:285:6: note: 'daemon' has been explicitly marked deprecated here
int      daemon(int, int) __DARWIN_1050(daemon) __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_0, __MAC_10_5, __IPHONE_2_0, ...
         ^
2 warnings and 5 errors generated.
make[2]: *** [bin/CMakeFiles/mysql-sniffer.dir/main.c.o] Error 1
make[1]: *** [bin/CMakeFiles/mysql-sniffer.dir/all] Error 2
make: *** [all] Error 2
yihaoDeng commented 6 years ago

暂时不支持mac