diff --git a/mdig/mdig.c b/mdig/mdig.c index f91cb9b..b50d95a 100644 --- a/mdig/mdig.c +++ b/mdig/mdig.c @@ -354,7 +354,6 @@ int main(int argc, char **argv) case 2: /* verbose */ glob.verbose = '\1'; break; - glob.threads = optarg ? atoi(optarg) : 0; case 3: /* stats */ glob.stats_every = optarg ? atoi(optarg) : 0; break; diff --git a/nfq/checksum.c b/nfq/checksum.c index e29b521..09be36b 100644 --- a/nfq/checksum.c +++ b/nfq/checksum.c @@ -18,7 +18,7 @@ static uint16_t do_csum(const uint8_t * buff, size_t len) uint64_t result,w,carry=0; uint16_t u16; - if (len <= 0) return 0; + if (!len) return 0; odd = (uint8_t)(1 & (size_t)buff); if (odd) { diff --git a/nfq/conntrack.c b/nfq/conntrack.c index 9cf3935..a1b396d 100644 --- a/nfq/conntrack.c +++ b/nfq/conntrack.c @@ -276,7 +276,7 @@ void ConntrackPoolPurge(t_conntrack *p) HASH_ITER(hh, p, t, tmp) { \ *sa1=0; inet_ntop(AF_INET##f, &t->conn.e1.adr, sa1, sizeof(sa1)); \ *sa2=0; inet_ntop(AF_INET##f, &t->conn.e2.adr, sa2, sizeof(sa2)); \ - printf("[%s]:%u => [%s]:%u : %s : t0=%lld last=t0+%lld now=last+%lld packets_orig=%llu packets_reply=%llu seq0=%u rseq=%u ack0=%u rack=%u wsize_orig=%u:%d wsize_reply=%u:%d cutoff=%u wss_cutoff=%u d_cutoff=%u\n", \ + printf("[%s]:%u => [%s]:%u : %s : t0=%llu last=t0+%llu now=last+%llu packets_orig=%llu packets_reply=%llu seq0=%u rseq=%u ack0=%u rack=%u wsize_orig=%u:%d wsize_reply=%u:%d cutoff=%u wss_cutoff=%u d_cutoff=%u\n", \ sa1, t->conn.e1.port, sa2, t->conn.e2.port, \ connstate_s[t->track.state], \ (unsigned long long)t->track.t_start, (unsigned long long)(t->track.t_last - t->track.t_start), (unsigned long long)(tnow - t->track.t_last), \ diff --git a/nfq/darkmagic.c b/nfq/darkmagic.c index d193297..05df8ff 100644 --- a/nfq/darkmagic.c +++ b/nfq/darkmagic.c @@ -103,7 +103,7 @@ static void fill_tcphdr(struct tcphdr *tcp, uint8_t fooling, uint8_t tcp_flags, while (t&3) tcpopt[t++]=1; // noop tcp->th_off += t>>2; } -static uint16_t tcpopt_len(uint8_t fooling, uint32_t *timestamps, uint8_t scale_factor) +static uint16_t tcpopt_len(uint8_t fooling, const uint32_t *timestamps, uint8_t scale_factor) { uint16_t t=0; if (fooling & TCP_FOOL_MD5SIG) t=18; @@ -586,7 +586,7 @@ void print_tcphdr(const struct tcphdr *tcphdr) -bool proto_check_ipv4(uint8_t *data, size_t len) +bool proto_check_ipv4(const uint8_t *data, size_t len) { return len >= 20 && (data[0] & 0xF0) == 0x40 && len >= ((data[0] & 0x0F) << 2); @@ -600,7 +600,7 @@ void proto_skip_ipv4(uint8_t **data, size_t *len) *data += l; *len -= l; } -bool proto_check_tcp(uint8_t *data, size_t len) +bool proto_check_tcp(const uint8_t *data, size_t len) { return len >= 20 && len >= ((data[12] & 0xF0) >> 2); } @@ -612,7 +612,7 @@ void proto_skip_tcp(uint8_t **data, size_t *len) *len -= l; } -bool proto_check_ipv6(uint8_t *data, size_t len) +bool proto_check_ipv6(const uint8_t *data, size_t len) { return len >= 40 && (data[0] & 0xF0) == 0x60 && (len - 40) >= htons(*(uint16_t*)(data + 4)); // payload length @@ -702,7 +702,6 @@ void tcp_rewrite_wscale(struct tcphdr *tcp, uint8_t scale_factor) void tcp_rewrite_winsize(struct tcphdr *tcp, uint16_t winsize, uint8_t scale_factor) { uint16_t winsize_old; - uint8_t *scale,scale_factor_old; winsize_old = htons(tcp->th_win); // << scale_factor; tcp->th_win = htons(winsize); diff --git a/nfq/darkmagic.h b/nfq/darkmagic.h index a5c3999..6430e8f 100644 --- a/nfq/darkmagic.h +++ b/nfq/darkmagic.h @@ -73,11 +73,11 @@ void print_ip6hdr(const struct ip6_hdr *ip6hdr, uint8_t proto); void print_tcphdr(const struct tcphdr *tcphdr); -bool proto_check_ipv4(uint8_t *data, size_t len); +bool proto_check_ipv4(const uint8_t *data, size_t len); void proto_skip_ipv4(uint8_t **data, size_t *len); -bool proto_check_tcp(uint8_t *data, size_t len); +bool proto_check_tcp(const uint8_t *data, size_t len); void proto_skip_tcp(uint8_t **data, size_t *len); -bool proto_check_ipv6(uint8_t *data, size_t len); +bool proto_check_ipv6(const uint8_t *data, size_t len); void proto_skip_ipv6(uint8_t **data, size_t *len, uint8_t *proto_type); bool tcp_synack_segment(const struct tcphdr *tcphdr); diff --git a/nfq/hostlist.c b/nfq/hostlist.c index b4136d2..797e363 100644 --- a/nfq/hostlist.c +++ b/nfq/hostlist.c @@ -3,7 +3,7 @@ #include "gzip.h" -static bool addpool(strpool **hostlist, char **s, char *end) +static bool addpool(strpool **hostlist, char **s, const char *end) { char *p; diff --git a/nfq/nfqws.c b/nfq/nfqws.c index 2a37ee3..276513f 100644 --- a/nfq/nfqws.c +++ b/nfq/nfqws.c @@ -166,7 +166,7 @@ static int nfq_cb(struct nfq_q_handle *qh, struct nfgenmsg *nfmsg, struct nfq_data *nfa, void *cookie) { int id; - size_t len; + int len; struct nfqnl_msg_packet_hdr *ph; uint8_t *data; diff --git a/tpws/hostlist.c b/tpws/hostlist.c index 87116e2..9768379 100644 --- a/tpws/hostlist.c +++ b/tpws/hostlist.c @@ -3,7 +3,7 @@ #include "gzip.h" #include "params.h" -static bool addpool(strpool **hostlist, char **s, char *end) +static bool addpool(strpool **hostlist, char **s, const char *end) { char *p; diff --git a/tpws/tamper.c b/tpws/tamper.c index f9f2748..45f7ef1 100644 --- a/tpws/tamper.c +++ b/tpws/tamper.c @@ -16,7 +16,7 @@ bool find_host(char **pHost,char *buf,size_t bs) if (*pHost) { (*pHost)++; - VPRINT("Found Host: at pos %zu",*pHost - buf) + VPRINT("Found Host: at pos %td",*pHost - buf) } } return !!*pHost; @@ -73,7 +73,7 @@ void modify_tcp_segment(char *segment,size_t segment_buffer_size,size_t *size,si if (pp == (p - 1)) { // probably end of http headers - VPRINT("Found double EOL at pos %zu. Stop replacing.", pp - segment) + VPRINT("Found double EOL at pos %td. Stop replacing.", pp - segment) break; } pp = p; @@ -141,7 +141,7 @@ void modify_tcp_segment(char *segment,size_t segment_buffer_size,size_t *size,si } if (params.hostcase && find_host(&pHost,segment,*size)) { - VPRINT("Changing 'Host:' => '%c%c%c%c:' at pos %zu", params.hostspell[0], params.hostspell[1], params.hostspell[2], params.hostspell[3], pHost - segment) + VPRINT("Changing 'Host:' => '%c%c%c%c:' at pos %td", params.hostspell[0], params.hostspell[1], params.hostspell[2], params.hostspell[3], pHost - segment) memcpy(pHost, params.hostspell, 4); } if (params.hostpad && find_host(&pHost,segment,*size)) diff --git a/tpws/tpws.c b/tpws/tpws.c index fe4298a..afef457 100644 --- a/tpws/tpws.c +++ b/tpws/tpws.c @@ -629,7 +629,7 @@ static bool set_ulimit() DBGPRINT("set_ulimit : current system file-max=%ju",(uintmax_t)cur_lim) if (cur_limfd,conn_has_unsent(conn),conn_partner_alive(conn) ? conn_has_unsent(conn->partner) : false) @@ -610,7 +610,6 @@ static bool handle_unsent(tproxy_conn_t *conn) if (errno==EAGAIN) wr=0; else return false; } - twr += wr; conn->twr += wr; conn->wr_unsent -= wr; } @@ -620,7 +619,6 @@ static bool handle_unsent(tproxy_conn_t *conn) wr=conn_buffers_send(conn); DBGPRINT("conn_buffers_send wr=%zd",wr) if (wr<0) return false; - twr += wr; } return epoll_set_flow_pair(conn); } @@ -1006,7 +1004,7 @@ static bool remove_closed_connections(int efd, struct tailhead *close_list) shutdown(conn->fd,SHUT_RDWR); epoll_del(conn); - VPRINT("Socket fd=%d (partner_fd=%d, remote=%d) closed, connection removed. total_read=%zu total_write=%zu event_count=%d", + VPRINT("Socket fd=%d (partner_fd=%d, remote=%d) closed, connection removed. total_read=%zu total_write=%zu event_count=%u", conn->fd, conn->partner ? conn->partner->fd : 0, conn->remote, conn->trd, conn->twr, conn->event_count) if (conn->remote) legs_remote--; else legs_local--; free_conn(conn); @@ -1102,7 +1100,7 @@ static void conn_close_with_partner_check(struct tailhead *conn_list, struct tai } } -int event_loop(int *listen_fd, size_t listen_fd_ct) +int event_loop(const int *listen_fd, size_t listen_fd_ct) { int retval = 0, num_events = 0; int tmp_fd = 0; //Used to temporarily hold the accepted file descriptor diff --git a/tpws/tpws_conn.h b/tpws/tpws_conn.h index 193695c..5b574d2 100644 --- a/tpws/tpws_conn.h +++ b/tpws/tpws_conn.h @@ -11,7 +11,7 @@ #define DEFAULT_MAX_CONN 512 #define DEFAULT_MAX_ORPHAN_TIME 5 -int event_loop(int *listen_fd, size_t listen_fd_ct); +int event_loop(const int *listen_fd, size_t listen_fd_ct); //Three different states of a connection enum{