yzslab / CCDGUTNetCrackerR

CCDGUT Network Cracker - Router version
GNU General Public License v3.0
16 stars 6 forks source link

Lede-17.01编译失败 #3

Closed CzzzzzHyq closed 6 years ago

CzzzzzHyq commented 6 years ago

main.c: In function 'tcp_checksum': main.c:326:12: error: 'struct tcphdr' has no member named 'check' tcphdrp->check = 0; ^ main.c:341:12: error: 'struct tcphdr' has no member named 'check' tcphdrp->check = (unsigned short) sum; ^ main.c: In function 'package_processor': main.c:505:51: error: 'struct tcphdr' has no member named 'doff' tcp_header_length = tcp_header->doff << 2u;

大佬,这是什么情况?求解

yzslab commented 6 years ago

查找你的toolchain使用的头文件"netinet/tcp.h"的路径,编辑打开,查找struct tcphdr的check、doff需要定义什么宏才能启用,使用gcc的-D参数定义所需的宏进行编译。

CzzzzzHyq commented 6 years ago

struct tcphdr { be16 source; be16 dest; be32 seq; be32 ack_seq;

if defined(__LITTLE_ENDIAN_BITFIELD)

__u16   res1:4,
    doff:4,
    fin:1,
    syn:1,
    rst:1,
    psh:1,
    ack:1,
    urg:1,
    ece:1,
    cwr:1;

elif defined(__BIG_ENDIAN_BITFIELD)

__u16   doff:4,
    res1:4,
    cwr:1,
    ece:1,
    urg:1,
    ack:1,
    psh:1,
    rst:1,
    syn:1,
    fin:1;

else

error "Adjust your <asm/byteorder.h> defines"

endif

__be16  window;
__sum16 check;
__be16  urg_ptr;

} tcp.h下有这个tcphdr结构体的定义,那应该怎么开启? 直接-D __u16 这样吗?

yzslab commented 6 years ago

请把tcp.h的内容完整上传

CzzzzzHyq commented 6 years ago

/*

ifndef _UAPI_LINUX_TCP_H

define _UAPI_LINUX_TCP_H

include <linux/types.h>

include <asm/byteorder.h>

include <linux/socket.h>

struct tcphdr { be16 source; be16 dest; be32 seq; be32 ack_seq;

if defined(__LITTLE_ENDIAN_BITFIELD)

__u16   res1:4,
    doff:4,
    fin:1,
    syn:1,
    rst:1,
    psh:1,
    ack:1,
    urg:1,
    ece:1,
    cwr:1;

elif defined(__BIG_ENDIAN_BITFIELD)

__u16   doff:4,
    res1:4,
    cwr:1,
    ece:1,
    urg:1,
    ack:1,
    psh:1,
    rst:1,
    syn:1,
    fin:1;

else

error "Adjust your <asm/byteorder.h> defines"

endif

__be16  window;
__sum16 check;
__be16  urg_ptr;

} attribute((packed, aligned(2)));

/*

define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3])

enum { TCP_FLAG_CWR = constant_cpu_to_be32(0x00800000), TCP_FLAG_ECE = __constant_cpu_to_be32(0x00400000), TCP_FLAG_URG = constant_cpu_to_be32(0x00200000), TCP_FLAG_ACK = constant_cpu_to_be32(0x00100000), TCP_FLAG_PSH = __constant_cpu_to_be32(0x00080000), TCP_FLAG_RST = constant_cpu_to_be32(0x00040000), TCP_FLAG_SYN = constant_cpu_to_be32(0x00020000), TCP_FLAG_FIN = __constant_cpu_to_be32(0x00010000), TCP_RESERVED_BITS = constant_cpu_to_be32(0x0F000000), TCP_DATA_OFFSET = __constant_cpu_to_be32(0xF0000000) };

/*

/ TCP socket options /

define TCP_NODELAY 1 / Turn off Nagle's algorithm. /

define TCP_MAXSEG 2 / Limit MSS /

define TCP_CORK 3 / Never send partially complete segments /

define TCP_KEEPIDLE 4 / Start keeplives after this period /

define TCP_KEEPINTVL 5 / Interval between keepalives /

define TCP_KEEPCNT 6 / Number of keepalives before death /

define TCP_SYNCNT 7 / Number of SYN retransmits /

define TCP_LINGER2 8 / Life time of orphaned FIN-WAIT-2 state /

define TCP_DEFER_ACCEPT 9 / Wake up listener only when data arrive /

define TCP_WINDOW_CLAMP 10 / Bound advertised window /

define TCP_INFO 11 / Information about this connection. /

define TCP_QUICKACK 12 / Block/reenable quick acks /

define TCP_CONGESTION 13 / Congestion control algorithm /

define TCP_MD5SIG 14 / TCP MD5 Signature (RFC2385) /

define TCP_THIN_LINEAR_TIMEOUTS 16 / Use linear timeouts for thin streams/

define TCP_THIN_DUPACK 17 / Fast retrans. after 1 dupack /

define TCP_USER_TIMEOUT 18 / How long for loss retry before timeout /

define TCP_REPAIR 19 / TCP sock is under repair right now /

define TCP_REPAIR_QUEUE 20

define TCP_QUEUE_SEQ 21

define TCP_REPAIR_OPTIONS 22

define TCP_FASTOPEN 23 / Enable FastOpen on listeners /

define TCP_TIMESTAMP 24

define TCP_NOTSENT_LOWAT 25 / limit number of unsent bytes in write queue /

define TCP_CC_INFO 26 / Get Congestion Control (optional) info /

define TCP_SAVE_SYN 27 / Record SYN headers for new connections /

define TCP_SAVED_SYN 28 / Get SYN headers recorded for connection /

struct tcp_repair_opt { __u32 opt_code; __u32 opt_val; };

enum { TCP_NO_QUEUE, TCP_RECV_QUEUE, TCP_SEND_QUEUE, TCP_QUEUES_NR, };

/ for TCP_INFO socket option /

define TCPI_OPT_TIMESTAMPS 1

define TCPI_OPT_SACK 2

define TCPI_OPT_WSCALE 4

define TCPI_OPT_ECN 8 / ECN was negociated at TCP session init /

define TCPI_OPT_ECN_SEEN 16 / we received at least one packet with ECT /

define TCPI_OPT_SYN_DATA 32 / SYN-ACK acked data in SYN sent or rcvd /

enum tcp_ca_state { TCP_CA_Open = 0,

define TCPF_CA_Open (1<<TCP_CA_Open)

TCP_CA_Disorder = 1,

define TCPF_CA_Disorder (1<<TCP_CA_Disorder)

TCP_CA_CWR = 2,

define TCPF_CA_CWR (1<<TCP_CA_CWR)

TCP_CA_Recovery = 3,

define TCPF_CA_Recovery (1<<TCP_CA_Recovery)

TCP_CA_Loss = 4

define TCPF_CA_Loss (1<<TCP_CA_Loss)

};

struct tcp_info { u8 tcpi_state; u8 tcpi_ca_state; u8 tcpi_retransmits; u8 tcpi_probes; u8 tcpi_backoff; __u8 tcpi_options; u8 tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;

__u32   tcpi_rto;
__u32   tcpi_ato;
__u32   tcpi_snd_mss;
__u32   tcpi_rcv_mss;

__u32   tcpi_unacked;
__u32   tcpi_sacked;
__u32   tcpi_lost;
__u32   tcpi_retrans;
__u32   tcpi_fackets;

/* Times. */
__u32   tcpi_last_data_sent;
__u32   tcpi_last_ack_sent;     /* Not remembered, sorry. */
__u32   tcpi_last_data_recv;
__u32   tcpi_last_ack_recv;

/* Metrics. */
__u32   tcpi_pmtu;
__u32   tcpi_rcv_ssthresh;
__u32   tcpi_rtt;
__u32   tcpi_rttvar;
__u32   tcpi_snd_ssthresh;
__u32   tcpi_snd_cwnd;
__u32   tcpi_advmss;
__u32   tcpi_reordering;

__u32   tcpi_rcv_rtt;
__u32   tcpi_rcv_space;

__u32   tcpi_total_retrans;

__u64   tcpi_pacing_rate;
__u64   tcpi_max_pacing_rate;
__u64   tcpi_bytes_acked;    /* RFC4898 tcpEStatsAppHCThruOctetsAcked */
__u64   tcpi_bytes_received; /* RFC4898 tcpEStatsAppHCThruOctetsReceived */
__u32   tcpi_segs_out;       /* RFC4898 tcpEStatsPerfSegsOut */
__u32   tcpi_segs_in;        /* RFC4898 tcpEStatsPerfSegsIn */

};

/ for TCP_MD5SIG socket option /

define TCP_MD5SIG_MAXKEYLEN 80

struct tcp_md5sig { struct kernel_sockaddr_storage tcpm_addr; / address associated / u16 tcpm_pad1; / zero / u16 tcpm_keylen; / key length / u32 tcpm_pad2; / zero / __u8 tcpm_key[TCP_MD5SIG_MAXKEYLEN]; / key (binary) / };

endif / _UAPI_LINUX_TCP_H /

麻烦大佬了

yzslab commented 6 years ago

你的toolchain是哪里下载的,提供一下下载地址吧,我看看。

CzzzzzHyq commented 6 years ago

https://downloads.openwrt.org/releases/17.01.2/targets/ar71xx/nand/lede-sdk-17.01.2-ar71xx-nand_gcc-5.4.0_musl-1.1.16.Linux-x86_64.tar.xz 刚刚在吃饭 不好意思呀

yzslab commented 6 years ago

staging_dir/toolchain-mips_24kc_gcc-5.4.0_musl-1.1.16/include/netinet/tcp.h的77行:

#ifdef _GNU_SOURCE

用以下命令编译程序(记得替换TOOLCHAIN_GCC为你toolchain的gcc):

TOOLCHAIN_GCC -D_GNU_SOURCE main.c -o CCDGUTNetCrackerR
CzzzzzHyq commented 6 years ago

已成功!谢谢大佬!

Subdue0 commented 5 years ago

按大佬说的,加了参数,-D_GNU_SOURCE,编译的确是通过了,但是编译出来的东西不正常,运行/usr/sbin/CCDGUTNetCrackerR br-lan daemon,没办法以守护进程运行。 出现提示: Random string: FpouCwDtHD Delete firewall rule. Add firewall rule. 然后本来正常的网络,直接没网了。这咋办